2012-05-29 13:31:11 +00:00
|
|
|
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
|
|
|
// Copyright (C) 2010 Winch Gate Property Limited
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "log_analyser.h"
|
|
|
|
#include "PlugInSelector.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
#define new DEBUG_NEW
|
|
|
|
#undef THIS_FILE
|
|
|
|
static char THIS_FILE[] = __FILE__;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CPlugInSelector dialog
|
|
|
|
|
|
|
|
|
|
|
|
CPlugInSelector::CPlugInSelector(CWnd* pParent /*=NULL*/)
|
|
|
|
: CDialog(CPlugInSelector::IDD, pParent)
|
|
|
|
{
|
|
|
|
//{{AFX_DATA_INIT(CPlugInSelector)
|
|
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
|
|
//}}AFX_DATA_INIT
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CPlugInSelector::DoDataExchange(CDataExchange* pDX)
|
|
|
|
{
|
|
|
|
CDialog::DoDataExchange(pDX);
|
|
|
|
//{{AFX_DATA_MAP(CPlugInSelector)
|
|
|
|
DDX_Control(pDX, IDC_LIST1, m_PlugInListBox);
|
|
|
|
//}}AFX_DATA_MAP
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CPlugInSelector, CDialog)
|
|
|
|
//{{AFX_MSG_MAP(CPlugInSelector)
|
|
|
|
ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
|
|
|
|
//}}AFX_MSG_MAP
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CPlugInSelector message handlers
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL CPlugInSelector::OnInitDialog()
|
|
|
|
{
|
|
|
|
CDialog::OnInitDialog();
|
|
|
|
|
|
|
|
if ( m_PlugInListBox.GetCount() == 0 )
|
|
|
|
{
|
|
|
|
for (unsigned int i=0; i!=Dlls->size(); ++i )
|
|
|
|
{
|
|
|
|
m_PlugInListBox.InsertString( i, (*Dlls)[i] ); // not sorted
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AnalyseFunc = NULL;
|
|
|
|
LibInst = NULL;
|
|
|
|
|
|
|
|
GetDlgItem( IDC_GROUP_INFO )->EnableWindow( ! Dlls->empty() );
|
|
|
|
GetDlgItem( IDOK )->EnableWindow( ! Dlls->empty() );
|
|
|
|
if ( ! Dlls->empty() )
|
|
|
|
{
|
|
|
|
m_PlugInListBox.SetCurSel( 0 );
|
|
|
|
OnSelchangeList1();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-22 11:22:17 +00:00
|
|
|
std::string::size_type getLastSeparator (const string &filename)
|
2012-05-29 13:31:11 +00:00
|
|
|
{
|
|
|
|
string::size_type pos = filename.find_last_of ('/');
|
|
|
|
if (pos == string::npos)
|
|
|
|
{
|
|
|
|
pos = filename.find_last_of ('\\');
|
|
|
|
if (pos == string::npos)
|
|
|
|
{
|
|
|
|
pos = filename.find_last_of ('@');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string getFilename (const string &filename)
|
|
|
|
{
|
|
|
|
string::size_type pos = getLastSeparator(filename);
|
|
|
|
if (pos != string::npos)
|
|
|
|
return filename.substr (pos + 1);
|
|
|
|
else
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void CPlugInSelector::OnSelchangeList1()
|
|
|
|
{
|
|
|
|
CString dllName;
|
|
|
|
m_PlugInListBox.GetText( m_PlugInListBox.GetCurSel(), dllName );
|
|
|
|
|
|
|
|
// Release previous DLL if any
|
|
|
|
if ( LibInst != NULL )
|
|
|
|
{
|
|
|
|
FreeLibrary( LibInst );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load DLL
|
|
|
|
LibInst = LoadLibrary( dllName );
|
|
|
|
if ( ! LibInst )
|
|
|
|
{
|
|
|
|
CString s;
|
2016-11-29 19:24:58 +00:00
|
|
|
TCHAR msg [300];
|
2012-05-29 13:31:11 +00:00
|
|
|
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
|
|
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), msg, 299, NULL );
|
2016-11-29 19:24:58 +00:00
|
|
|
s.Format(_T("Can't load %s: %s"), dllName, msg );
|
2012-05-29 13:31:11 +00:00
|
|
|
AfxMessageBox( s );
|
|
|
|
AnalyseFunc = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display info
|
|
|
|
TInfoFunc infoFunc = (TInfoFunc)GetProcAddress( LibInst, "getInfoString" );
|
|
|
|
if ( ! infoFunc )
|
|
|
|
{
|
2016-11-29 19:24:58 +00:00
|
|
|
AfxMessageBox( _T("Can't find function getInfoString in dll") );
|
2012-05-29 13:31:11 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-04-30 22:46:01 +00:00
|
|
|
GetDlgItem(IDC_GROUP_INFO)->SetWindowText(nlUtf8ToTStr(getFilename(NLMISC::tStrToUtf8(dllName))));
|
|
|
|
GetDlgItem(IDC_PLUGIN_INFO)->SetWindowText(nlUtf8ToTStr(infoFunc()));
|
2012-05-29 13:31:11 +00:00
|
|
|
|
|
|
|
// Prepare analyse func
|
|
|
|
AnalyseFunc = (TAnalyseFunc)GetProcAddress( LibInst, "doAnalyse" );
|
|
|
|
if ( ! AnalyseFunc )
|
|
|
|
{
|
2016-11-29 19:24:58 +00:00
|
|
|
AfxMessageBox( _T("Can't find function doAnalyse in dll") );
|
2012-05-29 13:31:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetDlgItem( IDOK )->EnableWindow( m_PlugInListBox.GetCurSel() != LB_ERR );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void CPlugInSelector::OnCancel()
|
|
|
|
{
|
|
|
|
AnalyseFunc = NULL;
|
|
|
|
|
|
|
|
// Release previous DLL if any
|
|
|
|
if ( LibInst != NULL )
|
|
|
|
{
|
|
|
|
FreeLibrary( LibInst );
|
|
|
|
LibInst = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
CDialog::OnCancel();
|
|
|
|
}
|