1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "log_analyser.h"
22 #include "PlugInSelector.h"
29 static char THIS_FILE
[] = __FILE__
;
32 /////////////////////////////////////////////////////////////////////////////
33 // CPlugInSelector dialog
36 CPlugInSelector::CPlugInSelector(CWnd
* pParent
/*=NULL*/)
37 : CDialog(CPlugInSelector::IDD
, pParent
)
39 //{{AFX_DATA_INIT(CPlugInSelector)
40 // NOTE: the ClassWizard will add member initialization here
45 void CPlugInSelector::DoDataExchange(CDataExchange
* pDX
)
47 CDialog::DoDataExchange(pDX
);
48 //{{AFX_DATA_MAP(CPlugInSelector)
49 DDX_Control(pDX
, IDC_LIST1
, m_PlugInListBox
);
54 BEGIN_MESSAGE_MAP(CPlugInSelector
, CDialog
)
55 //{{AFX_MSG_MAP(CPlugInSelector)
56 ON_LBN_SELCHANGE(IDC_LIST1
, OnSelchangeList1
)
60 /////////////////////////////////////////////////////////////////////////////
61 // CPlugInSelector message handlers
66 BOOL
CPlugInSelector::OnInitDialog()
68 CDialog::OnInitDialog();
70 if ( m_PlugInListBox
.GetCount() == 0 )
72 for (unsigned int i
=0; i
!=Dlls
->size(); ++i
)
74 m_PlugInListBox
.InsertString( i
, (*Dlls
)[i
] ); // not sorted
81 GetDlgItem( IDC_GROUP_INFO
)->EnableWindow( ! Dlls
->empty() );
82 GetDlgItem( IDOK
)->EnableWindow( ! Dlls
->empty() );
83 if ( ! Dlls
->empty() )
85 m_PlugInListBox
.SetCurSel( 0 );
93 std::string::size_type
getLastSeparator (const string
&filename
)
95 string::size_type pos
= filename
.find_last_of ('/');
96 if (pos
== string::npos
)
98 pos
= filename
.find_last_of ('\\');
99 if (pos
== string::npos
)
101 pos
= filename
.find_last_of ('@');
108 string
getFilename (const string
&filename
)
110 string::size_type pos
= getLastSeparator(filename
);
111 if (pos
!= string::npos
)
112 return filename
.substr (pos
+ 1);
121 void CPlugInSelector::OnSelchangeList1()
124 m_PlugInListBox
.GetText( m_PlugInListBox
.GetCurSel(), dllName
);
126 // Release previous DLL if any
127 if ( LibInst
!= NULL
)
129 FreeLibrary( LibInst
);
133 LibInst
= LoadLibrary( dllName
);
138 FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS
,
139 NULL
, GetLastError(), MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
), msg
, 299, NULL
);
140 s
.Format(_T("Can't load %s: %s"), dllName
, msg
);
147 TInfoFunc infoFunc
= (TInfoFunc
)GetProcAddress( LibInst
, "getInfoString" );
150 AfxMessageBox( _T("Can't find function getInfoString in dll") );
153 GetDlgItem(IDC_GROUP_INFO
)->SetWindowText(nlUtf8ToTStr(getFilename(NLMISC::tStrToUtf8(dllName
))));
154 GetDlgItem(IDC_PLUGIN_INFO
)->SetWindowText(nlUtf8ToTStr(infoFunc()));
156 // Prepare analyse func
157 AnalyseFunc
= (TAnalyseFunc
)GetProcAddress( LibInst
, "doAnalyse" );
160 AfxMessageBox( _T("Can't find function doAnalyse in dll") );
164 GetDlgItem( IDOK
)->EnableWindow( m_PlugInListBox
.GetCurSel() != LB_ERR
);
171 void CPlugInSelector::OnCancel()
175 // Release previous DLL if any
176 if ( LibInst
!= NULL
)
178 FreeLibrary( LibInst
);