diff options
author | George Hazan <george.hazan@gmail.com> | 2012-06-15 16:48:03 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-06-15 16:48:03 +0000 |
commit | 3744b5146df8530d3b43a972d58223cb3ffb533c (patch) | |
tree | a322ca4d0f8eda203cdb618071399c2d0a30e841 | |
parent | b92b010ae92db3f61a20ff2f579a5b717cfc8168 (diff) |
- fixes for the plugins options' dialog;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@430 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | src/miranda32_10.vcxproj | 4 | ||||
-rw-r--r-- | src/miranda32_10.vcxproj.filters | 6 | ||||
-rw-r--r-- | src/modules/clist/genmenu.cpp | 29 | ||||
-rw-r--r-- | src/modules/clist/genmenuopt.cpp | 2 | ||||
-rw-r--r-- | src/modules/clist/groups.cpp | 4 | ||||
-rw-r--r-- | src/modules/findadd/findadd.cpp | 2 | ||||
-rw-r--r-- | src/modules/fonts/FontOptions.cpp | 2 | ||||
-rw-r--r-- | src/modules/langpack/langpack.cpp | 2 | ||||
-rw-r--r-- | src/modules/netlib/netlibhttp.cpp | 4 | ||||
-rw-r--r-- | src/modules/netlib/netliblog.cpp | 4 | ||||
-rw-r--r-- | src/modules/netlib/netlibsock.cpp | 2 | ||||
-rw-r--r-- | src/modules/options/filter.h | 2 | ||||
-rw-r--r-- | src/modules/options/options.cpp | 2 | ||||
-rw-r--r-- | src/modules/plugins/newplugins.cpp | 452 | ||||
-rw-r--r-- | src/modules/plugins/pluginopts.cpp | 415 | ||||
-rw-r--r-- | src/modules/plugins/plugins.h | 70 | ||||
-rw-r--r-- | src/modules/protocols/protochains.cpp | 2 | ||||
-rw-r--r-- | src/modules/protocols/protoopts.cpp | 2 | ||||
-rw-r--r-- | src/modules/skin/skinicons.cpp | 2 | ||||
-rw-r--r-- | src/modules/utils/utils.cpp | 2 | ||||
-rw-r--r-- | src/modules/xml/xmlParser.cpp | 4 |
21 files changed, 546 insertions, 468 deletions
diff --git a/src/miranda32_10.vcxproj b/src/miranda32_10.vcxproj index c2d094c3b5..740d95dba1 100644 --- a/src/miranda32_10.vcxproj +++ b/src/miranda32_10.vcxproj @@ -247,6 +247,7 @@ <ClInclude Include="modules\netlib\netlib.h" />
<ClInclude Include="modules\options\filter.h" />
<ClInclude Include="..\include\m_protoint.h" />
+ <ClInclude Include="modules\plugins\plugins.h" />
<ClInclude Include="modules\srfile\file.h" />
<ClInclude Include="modules\srurl\url.h" />
<ClInclude Include="modules\clist\clc.h" />
@@ -375,6 +376,9 @@ <ClCompile Include="modules\plugins\newplugins.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
+ <ClCompile Include="modules\plugins\pluginopts.cpp">
+ <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
<ClCompile Include="modules\protocols\protoaccs.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/src/miranda32_10.vcxproj.filters b/src/miranda32_10.vcxproj.filters index e529686eb4..4852f59e61 100644 --- a/src/miranda32_10.vcxproj.filters +++ b/src/miranda32_10.vcxproj.filters @@ -273,6 +273,9 @@ <ClInclude Include="..\include\m_timezones.h">
<Filter>SDK</Filter>
</ClInclude>
+ <ClInclude Include="modules\plugins\plugins.h">
+ <Filter>Modules\plugins</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="core\commonheaders.cpp">
@@ -611,6 +614,9 @@ <ClCompile Include="modules\utils\timeutils.cpp">
<Filter>Modules\utils</Filter>
</ClCompile>
+ <ClCompile Include="modules\plugins\pluginopts.cpp">
+ <Filter>Modules\plugins</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="res\_blank.ico">
diff --git a/src/modules/clist/genmenu.cpp b/src/modules/clist/genmenu.cpp index c6413ee556..2399286f72 100644 --- a/src/modules/clist/genmenu.cpp +++ b/src/modules/clist/genmenu.cpp @@ -772,6 +772,17 @@ static int WhereToPlace( HMENU hMenu, PMO_MenuItem mi ) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static DWORD GetMenuItemType(HMENU hMenu, int uItem)
+{
+ MENUITEMINFO mii = { 0 };
+ mii.cbSize = MENUITEMINFO_V4_SIZE;
+ mii.fMask = MIIM_TYPE;
+ GetMenuItemInfo(hMenu, uItem, TRUE, &mii);
+ return mii.fType;
+}
+
static void InsertMenuItemWithSeparators(HMENU hMenu, int uItem, MENUITEMINFO *lpmii)
{
PMO_IntMenuItem pimi = MO_GetIntMenuItem(( HGENMENU )lpmii->dwItemData );
@@ -782,20 +793,14 @@ static void InsertMenuItemWithSeparators(HMENU hMenu, int uItem, MENUITEMINFO *l mii.cbSize = MENUITEMINFO_V4_SIZE;
//check for separator before
if ( uItem ) {
- mii.fMask = MIIM_SUBMENU | MIIM_DATA | MIIM_TYPE;
+ mii.fMask = MIIM_DATA;
GetMenuItemInfo( hMenu, uItem-1, TRUE, &mii );
PMO_IntMenuItem p = MO_GetIntMenuItem(( HGENMENU )mii.dwItemData );
if ( p != NULL && mii.fType != MFT_SEPARATOR) {
int needSeparator = (p->mi.position / SEPARATORPOSITIONINTERVAL) != (pimi->mi.position / SEPARATORPOSITIONINTERVAL);
if ( needSeparator) {
//but might be supposed to be after the next one instead
- memset(&mii, 0, sizeof(mii));
- mii.cbSize = MENUITEMINFO_V4_SIZE;
- if ( uItem < GetMenuItemCount( hMenu )) {
- mii.fMask = MIIM_TYPE;
- GetMenuItemInfo( hMenu, uItem, TRUE, &mii );
- }
- if ( mii.fType != MFT_SEPARATOR) {
+ if ( uItem < GetMenuItemCount(hMenu) && GetMenuItemType(hMenu, uItem) != MFT_SEPARATOR) {
mii.fMask = MIIM_TYPE;
mii.fType = MFT_SEPARATOR;
InsertMenuItem( hMenu, uItem, TRUE, &mii );
@@ -834,9 +839,11 @@ static void InsertMenuItemWithSeparators(HMENU hMenu, int uItem, MENUITEMINFO *l InsertMenuItem( hMenu, uItem, TRUE, &mii);
}
-//wparam started hMenu
-//lparam ListParam*
-//result hMenu
+/////////////////////////////////////////////////////////////////////////////////////////
+// wparam started hMenu
+// lparam ListParam*
+// result hMenu
+
INT_PTR MO_BuildMenu(WPARAM wParam, LPARAM lParam)
{
if ( !bIsGenMenuInited )
diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp index 421616b5e5..3937306464 100644 --- a/src/modules/clist/genmenuopt.cpp +++ b/src/modules/clist/genmenuopt.cpp @@ -731,7 +731,7 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA HWND tvw;
HTREEITEM * pSIT;
HTREEITEM FirstItem=NULL;
- UINT uITCnt, uSic ;
+ UINT uITCnt, uSic;
tvw=GetDlgItem(hwndDlg, IDC_MENUITEMS);
uITCnt=TreeView_GetCount(tvw);
uSic=0;
diff --git a/src/modules/clist/groups.cpp b/src/modules/clist/groups.cpp index 75e18e0a4e..c741c02008 100644 --- a/src/modules/clist/groups.cpp +++ b/src/modules/clist/groups.cpp @@ -184,7 +184,7 @@ static INT_PTR DeleteGroup(WPARAM wParam, LPARAM) CLISTGROUPCHANGE grpChg = { sizeof(CLISTGROUPCHANGE), NULL, NULL };
for (hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- hContact ;
+ hContact;
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0))
{
if (DBGetContactSettingTString(hContact, "CList", "Group", &dbv))
@@ -541,7 +541,7 @@ static INT_PTR BuildGroupMenu(WPARAM, LPARAM) int InitGroupServices(void)
{
- for (int i = 0; ; i++)
+ for (int i = 0;; i++)
{
char str[32];
_itoa(i, str, 10);
diff --git a/src/modules/findadd/findadd.cpp b/src/modules/findadd/findadd.cpp index d483844f9b..27ae355ae2 100644 --- a/src/modules/findadd/findadd.cpp +++ b/src/modules/findadd/findadd.cpp @@ -816,7 +816,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP for (iColumn=0; iColumn<csr->nFieldCount; iColumn++)
{
lvc.pszText=TranslateTS(csr->pszFields[iColumn]);
- ListView_InsertColumn (hwndList, iColumn+1, &lvc) ;
+ ListView_InsertColumn (hwndList, iColumn+1, &lvc);
}
// Column inserting Done
} else { // blob contain info about found contacts
diff --git a/src/modules/fonts/FontOptions.cpp b/src/modules/fonts/FontOptions.cpp index 34267a1ca6..2e8ac7823e 100644 --- a/src/modules/fonts/FontOptions.cpp +++ b/src/modules/fonts/FontOptions.cpp @@ -488,7 +488,7 @@ static INT_PTR CALLBACK ChooseEffectDlgProc( HWND hwndDlg, UINT uMsg, WPARAM wPa _T("Contour heavy"),
};
- for ( i=0; i<SIZEOF(ModernEffectNames) ; i++ )
+ for ( i=0; i < SIZEOF(ModernEffectNames); i++ )
{
int itemid = SendDlgItemMessage(hwndDlg, IDC_EFFECT_COMBO, CB_ADDSTRING, 0, (LPARAM)TranslateTS(ModernEffectNames[i]));
SendDlgItemMessage(hwndDlg, IDC_EFFECT_COMBO, CB_SETITEMDATA, itemid, i );
diff --git a/src/modules/langpack/langpack.cpp b/src/modules/langpack/langpack.cpp index aaa02ec52c..54e78b6dae 100644 --- a/src/modules/langpack/langpack.cpp +++ b/src/modules/langpack/langpack.cpp @@ -148,7 +148,7 @@ unsigned int __fastcall hashstrW(const char * key) if (key == NULL) return 0;
const unsigned int len = (unsigned int)wcslen((const wchar_t*)key);
char* buf = (char*)alloca(len + 1);
- for (unsigned i = 0; i <= len ; ++i)
+ for (unsigned i = 0; i <= len; ++i)
buf[i] = key[i << 1];
return hash(buf, len);
}
diff --git a/src/modules/netlib/netlibhttp.cpp b/src/modules/netlib/netlibhttp.cpp index 6c6c58a481..708ebf962f 100644 --- a/src/modules/netlib/netlibhttp.cpp +++ b/src/modules/netlib/netlibhttp.cpp @@ -905,7 +905,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam) }
buffer[bytesPeeked] = 0;
- for (pbuffer = buffer, headersCount = 0; ; pbuffer = peol + 1, ++headersCount)
+ for (pbuffer = buffer, headersCount = 0;; pbuffer = peol + 1, ++headersCount)
{
peol = strchr(pbuffer, '\n');
if (peol == NULL) break;
@@ -933,7 +933,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam) nlhr->headersCount = headersCount;
nlhr->headers = (NETLIBHTTPHEADER*)mir_calloc(sizeof(NETLIBHTTPHEADER) * headersCount);
- for (pbuffer = buffer, headersCount = 0; ; pbuffer = peol + 1, ++headersCount)
+ for (pbuffer = buffer, headersCount = 0;; pbuffer = peol + 1, ++headersCount)
{
peol = strchr(pbuffer, '\n');
if (peol == NULL || peol == pbuffer || (peol == (pbuffer + 1) && *pbuffer == '\r')) break;
diff --git a/src/modules/netlib/netliblog.cpp b/src/modules/netlib/netliblog.cpp index 8991f6ff24..6f633a6622 100644 --- a/src/modules/netlib/netliblog.cpp +++ b/src/modules/netlib/netliblog.cpp @@ -520,7 +520,7 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent, szBuf = (char*)(useStack ? alloca(sz) : mir_alloc(sz));
CopyMemory(szBuf, szTitleLine, titleLineLen);
pszBuf = szBuf + titleLineLen;
- for ( line = 0; ; line += 16 ) {
+ for ( line = 0;; line += 16 ) {
colsInLine = min(16, len - line);
if (colsInLine == 16) {
@@ -535,7 +535,7 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent, for (col = 0; col < colsInLine; col++)
pszBuf += wsprintfA(pszBuf, "%02X%c", buf[line + col], ((col&3) == 3 && col != 15)?'-':' ');
// Fill out last line with blanks
- for ( ; col<16; col++)
+ for (; col<16; col++)
{
lstrcpyA(pszBuf, " ");
pszBuf += 3;
diff --git a/src/modules/netlib/netlibsock.cpp b/src/modules/netlib/netlibsock.cpp index c2f5094aac..a4894a52ff 100644 --- a/src/modules/netlib/netlibsock.cpp +++ b/src/modules/netlib/netlibsock.cpp @@ -334,7 +334,7 @@ static NETLIBIPLIST* GetMyIpv4(void) PHOSTENT he = gethostbyname(hostname);
unsigned n;
- for (n = 0; he->h_addr_list[n]; ++n) ;
+ for (n = 0; he->h_addr_list[n]; ++n);
NETLIBIPLIST *addr = (NETLIBIPLIST*)mir_calloc(n * 64 + 4);
addr->cbNum = n;
diff --git a/src/modules/options/filter.h b/src/modules/options/filter.h index fc15074502..68d9c4100a 100644 --- a/src/modules/options/filter.h +++ b/src/modules/options/filter.h @@ -66,7 +66,7 @@ public: {
TCHAR * plwrWord = _tcslwr_locale( mir_tstrdup( ptKeyWord ) );
if ( _pageKeyWords.getIndex( plwrWord ) == -1 )
- _pageKeyWords.insert( plwrWord ) ;
+ _pageKeyWords.insert( plwrWord );
else
mir_free( plwrWord );
};
diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp index 9f0abd7837..b522ff0edb 100644 --- a/src/modules/options/options.cpp +++ b/src/modules/options/options.cpp @@ -251,7 +251,7 @@ static void FindFilterStrings(int enableKeywordFiltering, int current, HWND hWnd char * temp = GetPluginNameByInstance( page->hInst );
if ( temp ) PluginFullName = mir_a2t( temp );
GetDialogStrings(enableKeywordFiltering, key, GetPluginName(page->hInst, pluginName, SIZEOF(pluginName)), hWnd, page->pszGroup, page->pszTitle, page->pszTab, PluginFullName );
- if ( PluginFullName ) mir_free( PluginFullName ) ;
+ if ( PluginFullName ) mir_free( PluginFullName );
if (enableKeywordFiltering && !current)
DestroyWindow(hWnd); //destroy the page, we're done with it
diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 369e96fb19..cc4829cc44 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -21,52 +21,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "..\..\core\commonheaders.h"
-
-// block these plugins
-#define DEFMOD_REMOVED_UIPLUGINOPTS 21
-#define DEFMOD_REMOVED_PROTOCOLNETLIB 22
-
-// basic export prototypes
-typedef int (__cdecl * Miranda_Plugin_Load) ( PLUGINLINK * );
-typedef int (__cdecl * Miranda_Plugin_Unload) ( void );
-// version control
-typedef PLUGININFOEX * (__cdecl * Miranda_Plugin_InfoEx) ( DWORD mirandaVersion );
-// prototype for databases
-typedef DATABASELINK * (__cdecl * Database_Plugin_Info) ( void * reserved );
-// prototype for clists
-typedef int (__cdecl * CList_Initialise) ( PLUGINLINK * );
-// Interface support
-typedef MUUID * (__cdecl * Miranda_Plugin_Interfaces) ( void );
-
-typedef struct { // can all be NULL
- HINSTANCE hInst;
- Miranda_Plugin_Load Load;
- Miranda_Plugin_Unload Unload;
- Miranda_Plugin_InfoEx InfoEx;
- Miranda_Plugin_Interfaces Interfaces;
- Database_Plugin_Info DbInfo;
- CList_Initialise clistlink;
- PLUGININFOEX * pluginInfo; // must be freed if hInst == NULL then its a copy
- DATABASELINK * dblink; // only valid during module being in memory
-} BASIC_PLUGIN_INFO;
-
-#define PCLASS_FAILED 0x1 // not a valid plugin, or API is invalid, pluginname is valid
-#define PCLASS_BASICAPI 0x2 // has Load, Unload, MirandaPluginInfo() -> PLUGININFO seems valid, this dll is in memory.
-#define PCLASS_DB 0x4 // has DatabasePluginInfo() and is valid as can be, and PCLASS_BASICAPI has to be set too
-#define PCLASS_LAST 0x8 // this plugin should be unloaded after everything else
-#define PCLASS_OK 0x10 // plugin should be loaded, if DB means nothing
-#define PCLASS_LOADED 0x20 // Load() has been called, Unload() should be called.
-#define PCLASS_STOPPED 0x40 // wasn't loaded cos plugin name not on white list
-#define PCLASS_CLIST 0x80 // a CList implementation
-#define PCLASS_SERVICE 0x100 // has Service Mode implementation
-
-struct pluginEntry
-{
- TCHAR pluginname[64];
- unsigned int pclass; // PCLASS_*
- BASIC_PLUGIN_INFO bpi;
- pluginEntry* nextclass;
-};
+#include "plugins.h"
static int sttComparePlugins( const pluginEntry* p1, const pluginEntry* p2 )
{
@@ -112,7 +67,6 @@ static pluginEntry * pluginList_crshdmp; static HANDLE hPluginListHeap = NULL;
static pluginEntry * pluginDefModList[DEFMOD_HIGHEST+1]; // do not free this memory
static int askAboutIgnoredPlugins;
-static HANDLE hevLoadModule, hevUnloadModule;
int InitIni(void);
void UninitIni(void);
@@ -158,21 +112,13 @@ HINSTANCE GetInstByAddress( void* codePtr ) return result;
}
-static int uuidToString(const MUUID uuid, char *szStr, int cbLen)
-{
- if (cbLen<1||!szStr) return 0;
- mir_snprintf(szStr, cbLen, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
- uuid.a, uuid.b, uuid.c, uuid.d[0], uuid.d[1], uuid.d[2], uuid.d[3], uuid.d[4], uuid.d[5], uuid.d[6], uuid.d[7]);
- return 1;
-}
-
-static int equalUUID(const MUUID& u1, const MUUID& u2)
+int equalUUID(const MUUID& u1, const MUUID& u2)
{
return memcmp(&u1, &u2, sizeof(MUUID))?0:1;
}
-static MUUID miid_last = MIID_LAST;
-static MUUID miid_servicemode = MIID_SERVICEMODE;
+MUUID miid_last = MIID_LAST;
+MUUID miid_servicemode = MIID_SERVICEMODE;
static bool validInterfaceList(Miranda_Plugin_Interfaces ifaceProc)
{
@@ -261,7 +207,7 @@ static int checkPI( BASIC_PLUGIN_INFO* bpi, PLUGININFOEX* pi ) return TRUE;
}
-static int checkAPI(TCHAR* plugin, BASIC_PLUGIN_INFO* bpi, DWORD mirandaVersion, int checkTypeAPI)
+int checkAPI(TCHAR* plugin, BASIC_PLUGIN_INFO* bpi, DWORD mirandaVersion, int checkTypeAPI)
{
HINSTANCE h = NULL;
@@ -374,7 +320,7 @@ static int validguess_servicemode_name(TCHAR * name) }
// perform any API related tasks to freeing
-static void Plugin_Uninit(pluginEntry* p, bool bDynamic=false)
+void Plugin_Uninit(pluginEntry* p, bool bDynamic)
{
if (bDynamic && p->bpi.hInst)
CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0);
@@ -400,9 +346,7 @@ static void Plugin_Uninit(pluginEntry* p, bool bDynamic=false) pluginListAddr.remove( p );
}
-typedef BOOL (*SCAN_PLUGINS_CALLBACK) ( WIN32_FIND_DATA * fd, TCHAR * path, WPARAM wParam, LPARAM lParam );
-
-static void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam)
+void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam)
{
// get miranda's exe path
TCHAR exe[MAX_PATH];
@@ -458,7 +402,7 @@ static INT_PTR PluginsGetDefaultArray(WPARAM, LPARAM) return (INT_PTR)&pluginDefModList;
}
-static pluginEntry* OpenPlugin(TCHAR* tszFileName, TCHAR* path)
+pluginEntry* OpenPlugin(TCHAR* tszFileName, TCHAR* path)
{
int isdb = validguess_db_name(tszFileName);
BASIC_PLUGIN_INFO bpi;
@@ -533,13 +477,13 @@ static BOOL scanPluginsDir(WIN32_FIND_DATA *fd, TCHAR *path, WPARAM, LPARAM) return TRUE;
}
-static void SetPluginOnWhiteList(TCHAR * pluginname, int allow)
+void SetPluginOnWhiteList(const TCHAR* pluginname, int allow)
{
DBWriteContactSettingByte(NULL, PLUGINDISABLELIST, StrConvA(pluginname), allow == 0);
}
// returns 1 if the plugin should be enabled within this profile, filename is always lower case
-static int isPluginOnWhiteList(TCHAR * pluginname)
+int isPluginOnWhiteList(const TCHAR* pluginname)
{
char* pluginnameA = _strlwr(mir_t2a(pluginname));
int rc = DBGetContactSettingByte(NULL, PLUGINDISABLELIST, pluginnameA, 0);
@@ -556,7 +500,7 @@ static int isPluginOnWhiteList(TCHAR * pluginname) return rc == 0;
}
-static bool TryLoadPlugin(pluginEntry *p, bool bDynamic)
+bool TryLoadPlugin(pluginEntry *p, bool bDynamic)
{
TCHAR exe[MAX_PATH];
GetModuleFileName(NULL, exe, SIZEOF(exe));
@@ -707,372 +651,6 @@ void UnloadNewPlugins(void) } }
/////////////////////////////////////////////////////////////////////////////////////////
-// Plugins options page dialog
-
-typedef struct
-{
- HINSTANCE hInst;
- int flags;
- char* author;
- char* authorEmail;
- char* description;
- char* copyright;
- char* homepage;
- MUUID uuid;
- TCHAR fileName[MAX_PATH];
-}
- PluginListItemData;
-
-static BOOL dialogListPlugins(WIN32_FIND_DATA* fd, TCHAR* path, WPARAM, LPARAM lParam)
-{
- TCHAR buf[MAX_PATH];
- mir_sntprintf(buf, SIZEOF(buf), _T("%s\\Plugins\\%s"), path, fd->cFileName);
- HINSTANCE hInst = GetModuleHandle(buf);
-
- CharLower(fd->cFileName);
-
- BASIC_PLUGIN_INFO pi;
- if ( checkAPI(buf, &pi, mirandaVersion, CHECKAPI_NONE) == 0 )
- return TRUE;
-
- int isdb = pi.pluginInfo->replacesDefaultModule == DEFMOD_DB;
- PluginListItemData* dat = (PluginListItemData*)mir_alloc( sizeof( PluginListItemData ));
- dat->hInst = hInst;
- _tcsncpy(dat->fileName, fd->cFileName, SIZEOF(dat->fileName));
- HWND hwndList = (HWND)lParam;
-
- LVITEM it = { 0 };
- it.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
- it.iImage = ( pi.pluginInfo->flags & 1 ) ? 0 : 1;
- it.iItem = 100000; // add to the end
- it.lParam = (LPARAM)dat;
- int iRow = ListView_InsertItem( hwndList, &it );
- if ( isPluginOnWhiteList(fd->cFileName) )
- ListView_SetItemState(hwndList, iRow, !isdb ? 0x2000 : 0x3000, LVIS_STATEIMAGEMASK);
- if ( iRow != -1 ) {
- it.mask = LVIF_IMAGE;
- it.iItem = iRow;
- it.iSubItem = 1;
- it.iImage = ( hInst != NULL ) ? 2 : 3;
- ListView_SetItem( hwndList, &it );
-
- ListView_SetItemText(hwndList, iRow, 2, fd->cFileName);
-
- dat->flags = pi.pluginInfo->replacesDefaultModule;
- dat->author = mir_strdup( pi.pluginInfo->author );
- dat->authorEmail = mir_strdup( pi.pluginInfo->authorEmail );
- dat->copyright = mir_strdup( pi.pluginInfo->copyright );
- dat->description = mir_strdup( pi.pluginInfo->description );
- dat->homepage = mir_strdup( pi.pluginInfo->homepage );
- if ( pi.pluginInfo->cbSize == sizeof( PLUGININFOEX ))
- dat->uuid = pi.pluginInfo->uuid;
- else
- memset( &dat->uuid, 0, sizeof(dat->uuid));
-
- TCHAR *shortNameT = mir_a2t(pi.pluginInfo->shortName);
- ListView_SetItemText(hwndList, iRow, 3, shortNameT);
- mir_free(shortNameT);
-
- DWORD unused, verInfoSize = GetFileVersionInfoSize(buf, &unused);
- if ( verInfoSize != 0 ) {
- UINT blockSize;
- VS_FIXEDFILEINFO* fi;
- void* pVerInfo = mir_alloc(verInfoSize);
- GetFileVersionInfo(buf, 0, verInfoSize, pVerInfo);
- VerQueryValue(pVerInfo, _T("\\"), (LPVOID*)&fi, &blockSize);
- mir_sntprintf(buf, SIZEOF(buf), _T("%d.%d.%d.%d"), HIWORD(fi->dwProductVersionMS),
- LOWORD(fi->dwProductVersionMS), HIWORD(fi->dwProductVersionLS), LOWORD(fi->dwProductVersionLS));
- mir_free( pVerInfo );
- }
- else
- mir_sntprintf(buf, SIZEOF(buf), _T("%d.%d.%d.%d"), HIBYTE(HIWORD(pi.pluginInfo->version)),
- LOBYTE(HIWORD(pi.pluginInfo->version)), HIBYTE(LOWORD(pi.pluginInfo->version)),
- LOBYTE(LOWORD(pi.pluginInfo->version)));
-
- ListView_SetItemText(hwndList, iRow, 4, buf);
- }
- else mir_free( dat );
- FreeLibrary(pi.hInst);
- return TRUE;
-}
-
-static void RemoveAllItems( HWND hwnd )
-{
- LVITEM lvi;
- lvi.mask = LVIF_PARAM;
- lvi.iItem = 0;
- while ( ListView_GetItem( hwnd, &lvi )) {
- PluginListItemData* dat = ( PluginListItemData* )lvi.lParam;
- mir_free( dat->author );
- mir_free( dat->authorEmail );
- mir_free( dat->copyright );
- mir_free( dat->description );
- mir_free( dat->homepage );
- mir_free( dat );
- lvi.iItem ++;
-} }
-
-static int LoadPluginDynamically(PluginListItemData* dat)
-{
- TCHAR exe[MAX_PATH];
- GetModuleFileName(NULL, exe, SIZEOF(exe));
- TCHAR *p = _tcsrchr(exe, '\\'); if (p) *p = 0;
-
- pluginEntry* pPlug = OpenPlugin(dat->fileName, exe);
- if (pPlug->pclass & PCLASS_FAILED) {
-LBL_Error:
- Plugin_Uninit(pPlug, true);
- return FALSE;
- }
-
- if ( !TryLoadPlugin(pPlug, true))
- goto LBL_Error;
-
- if ( CallPluginEventHook(pPlug->bpi.hInst, hModulesLoadedEvent, 0, 0) != 0)
- goto LBL_Error;
-
- dat->hInst = pPlug->bpi.hInst;
- CallHookSubscribers(hevLoadModule, (WPARAM)pPlug->bpi.InfoEx, 0);
- return TRUE;
-}
-
-static int UnloadPluginDynamically(PluginListItemData* dat)
-{
- pluginEntry tmp;
- _tcsncpy(tmp.pluginname, dat->fileName, SIZEOF(tmp.pluginname)-1);
-
- int idx = pluginList.getIndex(&tmp);
- if (idx == -1)
- return FALSE;
-
- pluginEntry* pPlug = pluginList[idx];
- if ( CallPluginEventHook(pPlug->bpi.hInst, hOkToExitEvent, 0, 0) != 0)
- return FALSE;
-
- CallHookSubscribers(hevUnloadModule, (WPARAM)pPlug->bpi.InfoEx, 0);
-
- dat->hInst = NULL;
- Plugin_Uninit(pPlug, true);
- return TRUE;
-}
-
-static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (msg == WM_LBUTTONDOWN) {
- LVHITTESTINFO hi;
- hi.pt.x = LOWORD(lParam); hi.pt.y = HIWORD(lParam);
- ListView_SubItemHitTest(hwnd, &hi);
- if ( hi.iSubItem == 1 ) {
- LVITEM lvi;
- lvi.mask = LVIF_PARAM;
- lvi.iItem = hi.iItem;
- if ( ListView_GetItem( hwnd, &lvi )) {
- lvi.iSubItem = 1;
- lvi.mask = LVIF_IMAGE;
-
- PluginListItemData* dat = ( PluginListItemData* )lvi.lParam;
- if (dat->hInst == NULL) {
- if ( LoadPluginDynamically(dat)) {
- lvi.iImage = 2;
- ListView_SetItem(hwnd, &lvi);
- }
- }
- else {
- if ( UnloadPluginDynamically(dat)) {
- lvi.iImage = 3;
- ListView_SetItem(hwnd, &lvi);
- } } } } }
-
- WNDPROC wnProc = ( WNDPROC )GetWindowLongPtr(hwnd, GWLP_USERDATA);
- return CallWindowProc(wnProc, hwnd, msg, wParam, lParam);
-}
-
-INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- {
- HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
- SetWindowLongPtr(hwndList, GWLP_USERDATA, (LONG_PTR)GetWindowLongPtr(hwndList, GWLP_WNDPROC));
- SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)PluginListWndProc);
-
- HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus()? ILC_COLOR32 : ILC_COLOR16), 4, 0);
- ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_UNICODE );
- ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_ANSI );
- ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_LOADED );
- ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_NOTLOADED );
- ListView_SetImageList( hwndList, hIml, LVSIL_SMALL );
-
- LVCOLUMN col;
- col.mask = LVCF_TEXT | LVCF_WIDTH;
- col.pszText = _T("");
- col.cx = 40;
- ListView_InsertColumn(hwndList, 0, &col);
-
- col.pszText = _T("");
- col.cx = 20;
- ListView_InsertColumn(hwndList, 1, &col);
-
- col.pszText = TranslateT("Plugin");
- col.cx = 70;
- ListView_InsertColumn(hwndList, 2, &col);
-
- col.pszText = TranslateT("Name");
- col.cx = 70;//max = 220;
- ListView_InsertColumn(hwndList, 3, &col);
-
- col.pszText = TranslateT("Version");
- col.cx = 70;
- ListView_InsertColumn(hwndList, 4, &col);
-
- // XXX: Won't work on windows 95 without IE3+ or 4.70
- ListView_SetExtendedListViewStyleEx( hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT );
- // scan the plugin dir for plugins, cos
- enumPlugins( dialogListPlugins, ( WPARAM )hwndDlg, ( LPARAM )hwndList );
- // sort out the headers
-
- ListView_SetColumnWidth( hwndList, 2, LVSCW_AUTOSIZE ); // dll name
- int w = ListView_GetColumnWidth( hwndList, 2 );
- if (w > 110) {
- ListView_SetColumnWidth( hwndList, 2, 110 );
- w = 110;
- }
- int max = w < 110 ? 199+110-w:199;
- ListView_SetColumnWidth( hwndList, 3, LVSCW_AUTOSIZE ); // short name
- w = ListView_GetColumnWidth( hwndList, 3 );
- if (w > max)
- ListView_SetColumnWidth( hwndList, 3, max );
- }
- return TRUE;
-
- case WM_NOTIFY:
- if ( lParam ) {
- NMLISTVIEW * hdr = (NMLISTVIEW *) lParam;
- if ( hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom)) {
- if (hdr->uOldState != 0 && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000 )) {
- HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
-
- LVITEM it;
- it.mask = LVIF_PARAM | LVIF_STATE;
- it.iItem = hdr->iItem;
- if ( !ListView_GetItem( hwndList, &it ))
- break;
-
- PluginListItemData* dat = ( PluginListItemData* )it.lParam;
- if ( dat->flags == DEFMOD_DB ) {
- ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK);
- return FALSE;
- }
- // if enabling and replaces, find all other replaces and toggle off
- if ( hdr->uNewState & 0x2000 && dat->flags != 0 ) {
- for ( int iRow=0; iRow != -1; ) {
- if ( iRow != hdr->iItem ) {
- LVITEM dt;
- dt.mask = LVIF_PARAM;
- dt.iItem = iRow;
- if ( ListView_GetItem( hwndList, &dt )) {
- PluginListItemData* dat2 = ( PluginListItemData* )dt.lParam;
- if ( dat2->flags == dat->flags ) {
- // the lParam is unset, so when the check is unset the clist block doesnt trigger
- int lParam = dat2->flags;
- dat2->flags = 0;
- ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK );
- dat2->flags = lParam;
- } } }
-
- iRow = ListView_GetNextItem( hwndList, iRow, LVNI_ALL );
- } }
-
- ShowWindow( GetDlgItem(hwndDlg, IDC_RESTART ), TRUE );
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
- break;
- }
-
- if ( hdr->iItem != -1 ) {
- TCHAR buf[1024];
- int sel = hdr->uNewState & LVIS_SELECTED;
- HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_PARAM;
- lvi.iItem = hdr->iItem;
- if ( ListView_GetItem( hwndList, &lvi )) {
- PluginListItemData* dat = ( PluginListItemData* )lvi.lParam;
-
- ListView_GetItemText(hwndList, hdr->iItem, 1, buf, SIZEOF(buf));
- SetWindowText(GetDlgItem(hwndDlg, IDC_PLUGININFOFRAME), sel ? buf : _T(""));
-
- SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINAUTHOR), sel ? dat->author : "" );
- SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINEMAIL), sel ? dat->authorEmail : "" );
- {
- TCHAR* p = LangPackPcharToTchar( dat->description );
- SetWindowText(GetDlgItem(hwndDlg, IDC_PLUGINLONGINFO), sel ? p : _T(""));
- mir_free( p );
- }
- SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINCPYR), sel ? dat->copyright : "" );
- SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINURL), sel ? dat->homepage : "" );
- if (equalUUID(miid_last, dat->uuid))
- SetWindowText(GetDlgItem(hwndDlg, IDC_PLUGINPID), sel ? TranslateT("<none>") : _T(""));
- else {
- char szUID[128];
- uuidToString( dat->uuid, szUID, sizeof(szUID));
- SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINPID), sel ? szUID : "" );
- } } } }
-
- if ( hdr->hdr.code == PSN_APPLY ) {
- HWND hwndList=GetDlgItem(hwndDlg, IDC_PLUGLIST);
- int iRow;
- int iState;
- TCHAR buf[1024];
- for (iRow=0 ; iRow != (-1) ; ) {
- ListView_GetItemText(hwndList, iRow, 0, buf, SIZEOF(buf));
- iState=ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK);
- SetPluginOnWhiteList(buf, iState&0x2000 ? 1 : 0);
- iRow=ListView_GetNextItem(hwndList, iRow, LVNI_ALL);
- } } }
- break;
-
- case WM_COMMAND:
- if ( HIWORD(wParam) == STN_CLICKED ) {
- switch (LOWORD(wParam)) {
- case IDC_PLUGINEMAIL:
- case IDC_PLUGINURL:
- {
- char buf[512];
- char *p = &buf[7];
- lstrcpyA(buf, "mailto:");
- if ( GetWindowTextA(GetDlgItem(hwndDlg, LOWORD(wParam)), p, SIZEOF(buf) - 7))
- CallService(MS_UTILS_OPENURL, 0, (LPARAM) (LOWORD(wParam) == IDC_PLUGINEMAIL ? buf : p) );
- break;
- }
- case IDC_GETMOREPLUGINS:
- CallService(MS_UTILS_OPENURL, 0, (LPARAM) "http://addons.miranda-im.org/index.php?action=display&id=1" );
- break;
- } }
- break;
-
- case WM_DESTROY:
- RemoveAllItems( GetDlgItem( hwndDlg, IDC_PLUGLIST ));
- break;
- }
- return FALSE;
-}
-
-static int PluginOptionsInit(WPARAM wParam, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.cbSize = sizeof(odp);
- odp.hInstance = hMirandaInst;
- odp.pfnDlgProc = DlgPluginOpt;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_PLUGINS);
- odp.position = 1300000000;
- odp.pszTitle = LPGEN("Plugins");
- odp.flags = ODPF_BOLDGROUPS;
- CallService( MS_OPT_ADDPAGE, wParam, ( LPARAM )&odp );
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
//
// Loads all plugins
@@ -1161,15 +739,14 @@ int LoadNewPluginsModuleInfos(void) {
bModuleInitialized = TRUE;
+ LoadPluginOptions();
+
hPluginListHeap = HeapCreate(HEAP_NO_SERIALIZE, 0, 0);
mirandaVersion = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0);
CreateServiceFunction(MS_PLUGINS_ENUMDBPLUGINS, PluginsEnum);
CreateServiceFunction(MS_PLUGINS_GETDISABLEDEFAULTARRAY, PluginsGetDefaultArray);
- hevLoadModule = CreateHookableEvent(ME_SYSTEM_MODULELOAD);
- hevUnloadModule = CreateHookableEvent(ME_SYSTEM_MODULEUNLOAD);
-
// make sure plugins can get internal core APIs
pluginCoreLink.CallService = CallService;
pluginCoreLink.ServiceExists = ServiceExists;
@@ -1218,8 +795,7 @@ void UnloadNewPluginsModule(void) if ( !bModuleInitialized ) return;
- DestroyHookableEvent(hevLoadModule);
- DestroyHookableEvent(hevUnloadModule);
+ UnloadPluginOptions();
// unload everything but the DB
for ( i = pluginList.getCount()-1; i >= 0; i-- ) {
diff --git a/src/modules/plugins/pluginopts.cpp b/src/modules/plugins/pluginopts.cpp new file mode 100644 index 0000000000..dc1cfb9e24 --- /dev/null +++ b/src/modules/plugins/pluginopts.cpp @@ -0,0 +1,415 @@ +/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2010 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "..\..\core\commonheaders.h"
+
+#include <m_version.h>
+
+#include "plugins.h"
+
+static HANDLE hevLoadModule, hevUnloadModule;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Plugins options page dialog
+
+typedef struct
+{
+ HINSTANCE hInst;
+ int flags;
+ char* author;
+ char* authorEmail;
+ char* description;
+ char* copyright;
+ char* homepage;
+ MUUID uuid;
+ TCHAR fileName[MAX_PATH];
+}
+ PluginListItemData;
+
+static BOOL dialogListPlugins(WIN32_FIND_DATA* fd, TCHAR* path, WPARAM, LPARAM lParam)
+{
+ TCHAR buf[MAX_PATH];
+ mir_sntprintf(buf, SIZEOF(buf), _T("%s\\Plugins\\%s"), path, fd->cFileName);
+ HINSTANCE hInst = GetModuleHandle(buf);
+
+ CharLower(fd->cFileName);
+
+ BASIC_PLUGIN_INFO pi;
+ if ( checkAPI(buf, &pi, MIRANDA_VERSION_CORE, CHECKAPI_NONE) == 0 )
+ return TRUE;
+
+ int isdb = pi.pluginInfo->replacesDefaultModule == DEFMOD_DB;
+ PluginListItemData* dat = (PluginListItemData*)mir_alloc( sizeof( PluginListItemData ));
+ dat->hInst = hInst;
+ _tcsncpy(dat->fileName, fd->cFileName, SIZEOF(dat->fileName));
+ HWND hwndList = (HWND)lParam;
+
+ LVITEM it = { 0 };
+ it.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ it.iImage = ( pi.pluginInfo->flags & 1 ) ? 0 : 1;
+ it.iItem = 100000; // add to the end
+ it.lParam = (LPARAM)dat;
+ int iRow = ListView_InsertItem( hwndList, &it );
+ if ( isPluginOnWhiteList(fd->cFileName) )
+ ListView_SetItemState(hwndList, iRow, !isdb ? 0x2000 : 0x3000, LVIS_STATEIMAGEMASK);
+ if ( iRow != -1 ) {
+ it.mask = LVIF_IMAGE;
+ it.iItem = iRow;
+ it.iSubItem = 1;
+ it.iImage = ( hInst != NULL ) ? 2 : 3;
+ ListView_SetItem( hwndList, &it );
+
+ ListView_SetItemText(hwndList, iRow, 2, fd->cFileName);
+
+ dat->flags = pi.pluginInfo->replacesDefaultModule;
+ dat->author = mir_strdup( pi.pluginInfo->author );
+ dat->authorEmail = mir_strdup( pi.pluginInfo->authorEmail );
+ dat->copyright = mir_strdup( pi.pluginInfo->copyright );
+ dat->description = mir_strdup( pi.pluginInfo->description );
+ dat->homepage = mir_strdup( pi.pluginInfo->homepage );
+ if ( pi.pluginInfo->cbSize == sizeof( PLUGININFOEX ))
+ dat->uuid = pi.pluginInfo->uuid;
+ else
+ memset( &dat->uuid, 0, sizeof(dat->uuid));
+
+ TCHAR *shortNameT = mir_a2t(pi.pluginInfo->shortName);
+ ListView_SetItemText(hwndList, iRow, 3, shortNameT);
+ mir_free(shortNameT);
+
+ DWORD unused, verInfoSize = GetFileVersionInfoSize(buf, &unused);
+ if ( verInfoSize != 0 ) {
+ UINT blockSize;
+ VS_FIXEDFILEINFO* fi;
+ void* pVerInfo = mir_alloc(verInfoSize);
+ GetFileVersionInfo(buf, 0, verInfoSize, pVerInfo);
+ VerQueryValue(pVerInfo, _T("\\"), (LPVOID*)&fi, &blockSize);
+ mir_sntprintf(buf, SIZEOF(buf), _T("%d.%d.%d.%d"), HIWORD(fi->dwProductVersionMS),
+ LOWORD(fi->dwProductVersionMS), HIWORD(fi->dwProductVersionLS), LOWORD(fi->dwProductVersionLS));
+ mir_free( pVerInfo );
+ }
+ else
+ mir_sntprintf(buf, SIZEOF(buf), _T("%d.%d.%d.%d"), HIBYTE(HIWORD(pi.pluginInfo->version)),
+ LOBYTE(HIWORD(pi.pluginInfo->version)), HIBYTE(LOWORD(pi.pluginInfo->version)),
+ LOBYTE(LOWORD(pi.pluginInfo->version)));
+
+ ListView_SetItemText(hwndList, iRow, 4, buf);
+ }
+ else mir_free( dat );
+ FreeLibrary(pi.hInst);
+ return TRUE;
+}
+
+static int uuidToString(const MUUID uuid, char *szStr, int cbLen)
+{
+ if (cbLen<1||!szStr) return 0;
+ mir_snprintf(szStr, cbLen, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
+ uuid.a, uuid.b, uuid.c, uuid.d[0], uuid.d[1], uuid.d[2], uuid.d[3], uuid.d[4], uuid.d[5], uuid.d[6], uuid.d[7]);
+ return 1;
+}
+
+static void RemoveAllItems( HWND hwnd )
+{
+ LVITEM lvi;
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = 0;
+ while ( ListView_GetItem( hwnd, &lvi )) {
+ PluginListItemData* dat = ( PluginListItemData* )lvi.lParam;
+ mir_free( dat->author );
+ mir_free( dat->authorEmail );
+ mir_free( dat->copyright );
+ mir_free( dat->description );
+ mir_free( dat->homepage );
+ mir_free( dat );
+ lvi.iItem ++;
+} }
+
+static int LoadPluginDynamically(PluginListItemData* dat)
+{
+ TCHAR exe[MAX_PATH];
+ GetModuleFileName(NULL, exe, SIZEOF(exe));
+ TCHAR *p = _tcsrchr(exe, '\\'); if (p) *p = 0;
+
+ pluginEntry* pPlug = OpenPlugin(dat->fileName, exe);
+ if (pPlug->pclass & PCLASS_FAILED) {
+LBL_Error:
+ Plugin_Uninit(pPlug, true);
+ return FALSE;
+ }
+
+ if ( !TryLoadPlugin(pPlug, true))
+ goto LBL_Error;
+
+ if ( CallPluginEventHook(pPlug->bpi.hInst, hModulesLoadedEvent, 0, 0) != 0)
+ goto LBL_Error;
+
+ dat->hInst = pPlug->bpi.hInst;
+ CallHookSubscribers(hevLoadModule, (WPARAM)pPlug->bpi.InfoEx, 0);
+ return TRUE;
+}
+
+static int UnloadPluginDynamically(PluginListItemData* dat)
+{
+ pluginEntry tmp;
+ _tcsncpy(tmp.pluginname, dat->fileName, SIZEOF(tmp.pluginname)-1);
+
+ int idx = pluginList.getIndex(&tmp);
+ if (idx == -1)
+ return FALSE;
+
+ pluginEntry* pPlug = pluginList[idx];
+ if ( CallPluginEventHook(pPlug->bpi.hInst, hOkToExitEvent, 0, 0) != 0)
+ return FALSE;
+
+ CallHookSubscribers(hevUnloadModule, (WPARAM)pPlug->bpi.InfoEx, 0);
+
+ dat->hInst = NULL;
+ Plugin_Uninit(pPlug, true);
+ return TRUE;
+}
+
+static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ if (msg == WM_LBUTTONDOWN) {
+ LVHITTESTINFO hi;
+ hi.pt.x = LOWORD(lParam); hi.pt.y = HIWORD(lParam);
+ ListView_SubItemHitTest(hwnd, &hi);
+ if ( hi.iSubItem == 1 ) {
+ LVITEM lvi;
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = hi.iItem;
+ if ( ListView_GetItem( hwnd, &lvi )) {
+ lvi.iSubItem = 1;
+ lvi.mask = LVIF_IMAGE;
+
+ PluginListItemData* dat = ( PluginListItemData* )lvi.lParam;
+ if (dat->hInst == NULL) {
+ if ( LoadPluginDynamically(dat)) {
+ lvi.iImage = 2;
+ ListView_SetItem(hwnd, &lvi);
+ }
+ }
+ else {
+ if ( UnloadPluginDynamically(dat)) {
+ lvi.iImage = 3;
+ ListView_SetItem(hwnd, &lvi);
+ } } } } }
+
+ WNDPROC wnProc = ( WNDPROC )GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ return CallWindowProc(wnProc, hwnd, msg, wParam, lParam);
+}
+
+INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ {
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
+ SetWindowLongPtr(hwndList, GWLP_USERDATA, (LONG_PTR)GetWindowLongPtr(hwndList, GWLP_WNDPROC));
+ SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)PluginListWndProc);
+
+ HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus()? ILC_COLOR32 : ILC_COLOR16), 4, 0);
+ ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_UNICODE );
+ ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_ANSI );
+ ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_LOADED );
+ ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_NOTLOADED );
+ ListView_SetImageList( hwndList, hIml, LVSIL_SMALL );
+
+ LVCOLUMN col;
+ col.mask = LVCF_TEXT | LVCF_WIDTH;
+ col.pszText = _T("");
+ col.cx = 40;
+ ListView_InsertColumn(hwndList, 0, &col);
+
+ col.pszText = _T("");
+ col.cx = 20;
+ ListView_InsertColumn(hwndList, 1, &col);
+
+ col.pszText = TranslateT("Plugin");
+ col.cx = 70;
+ ListView_InsertColumn(hwndList, 2, &col);
+
+ col.pszText = TranslateT("Name");
+ col.cx = 70;//max = 220;
+ ListView_InsertColumn(hwndList, 3, &col);
+
+ col.pszText = TranslateT("Version");
+ col.cx = 70;
+ ListView_InsertColumn(hwndList, 4, &col);
+
+ // XXX: Won't work on windows 95 without IE3+ or 4.70
+ ListView_SetExtendedListViewStyleEx( hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT );
+ // scan the plugin dir for plugins, cos
+ enumPlugins( dialogListPlugins, ( WPARAM )hwndDlg, ( LPARAM )hwndList );
+ // sort out the headers
+
+ ListView_SetColumnWidth( hwndList, 2, LVSCW_AUTOSIZE ); // dll name
+ int w = ListView_GetColumnWidth( hwndList, 2 );
+ if (w > 110) {
+ ListView_SetColumnWidth( hwndList, 2, 110 );
+ w = 110;
+ }
+ int max = w < 110 ? 199+110-w:199;
+ ListView_SetColumnWidth( hwndList, 3, LVSCW_AUTOSIZE ); // short name
+ w = ListView_GetColumnWidth( hwndList, 3 );
+ if (w > max)
+ ListView_SetColumnWidth( hwndList, 3, max );
+ }
+ return TRUE;
+
+ case WM_NOTIFY:
+ if ( lParam ) {
+ NMLISTVIEW * hdr = (NMLISTVIEW *) lParam;
+ if ( hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom)) {
+ if (hdr->uOldState != 0 && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000 )) {
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
+
+ LVITEM it;
+ it.mask = LVIF_PARAM | LVIF_STATE;
+ it.iItem = hdr->iItem;
+ if ( !ListView_GetItem( hwndList, &it ))
+ break;
+
+ PluginListItemData* dat = ( PluginListItemData* )it.lParam;
+ if ( dat->flags == DEFMOD_DB ) {
+ ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK);
+ return FALSE;
+ }
+ // if enabling and replaces, find all other replaces and toggle off
+ if (( hdr->uNewState & 0x2000) && dat->flags != 0 ) {
+ for ( int iRow=0; iRow != -1; ) {
+ if ( iRow != hdr->iItem ) {
+ LVITEM dt;
+ dt.mask = LVIF_PARAM;
+ dt.iItem = iRow;
+ if ( ListView_GetItem( hwndList, &dt )) {
+ PluginListItemData* dat2 = ( PluginListItemData* )dt.lParam;
+ if ( dat2->flags == dat->flags ) {
+ // the lParam is unset, so when the check is unset the clist block doesnt trigger
+ int lParam = dat2->flags;
+ dat2->flags = 0;
+ ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK );
+ dat2->flags = lParam;
+ } } }
+
+ iRow = ListView_GetNextItem( hwndList, iRow, LVNI_ALL );
+ } }
+
+ ShowWindow( GetDlgItem(hwndDlg, IDC_RESTART ), TRUE );
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ break;
+ }
+
+ if ( hdr->iItem != -1 ) {
+ TCHAR buf[1024];
+ int sel = hdr->uNewState & LVIS_SELECTED;
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
+ LVITEM lvi = { 0 };
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = hdr->iItem;
+ if ( ListView_GetItem( hwndList, &lvi )) {
+ PluginListItemData* dat = ( PluginListItemData* )lvi.lParam;
+
+ ListView_GetItemText(hwndList, hdr->iItem, 1, buf, SIZEOF(buf));
+ SetWindowText(GetDlgItem(hwndDlg, IDC_PLUGININFOFRAME), sel ? buf : _T(""));
+
+ SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINAUTHOR), sel ? dat->author : "" );
+ SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINEMAIL), sel ? dat->authorEmail : "" );
+ {
+ TCHAR* p = LangPackPcharToTchar( dat->description );
+ SetWindowText(GetDlgItem(hwndDlg, IDC_PLUGINLONGINFO), sel ? p : _T(""));
+ mir_free( p );
+ }
+ SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINCPYR), sel ? dat->copyright : "" );
+ SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINURL), sel ? dat->homepage : "" );
+ if (equalUUID(miid_last, dat->uuid))
+ SetWindowText(GetDlgItem(hwndDlg, IDC_PLUGINPID), sel ? TranslateT("<none>") : _T(""));
+ else {
+ char szUID[128];
+ uuidToString( dat->uuid, szUID, sizeof(szUID));
+ SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINPID), sel ? szUID : "" );
+ } } } }
+
+ if ( hdr->hdr.code == PSN_APPLY ) {
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
+ TCHAR buf[1024];
+ for (int iRow=0; iRow != -1; ) {
+ ListView_GetItemText(hwndList, iRow, 2, buf, SIZEOF(buf));
+ int iState = ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK);
+ SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0);
+ iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL);
+ } } }
+ break;
+
+ case WM_COMMAND:
+ if ( HIWORD(wParam) == STN_CLICKED ) {
+ switch (LOWORD(wParam)) {
+ case IDC_PLUGINEMAIL:
+ case IDC_PLUGINURL:
+ {
+ char buf[512];
+ char *p = &buf[7];
+ lstrcpyA(buf, "mailto:");
+ if ( GetWindowTextA(GetDlgItem(hwndDlg, LOWORD(wParam)), p, SIZEOF(buf) - 7))
+ CallService(MS_UTILS_OPENURL, 0, (LPARAM) (LOWORD(wParam) == IDC_PLUGINEMAIL ? buf : p) );
+ break;
+ }
+ case IDC_GETMOREPLUGINS:
+ CallService(MS_UTILS_OPENURL, 0, (LPARAM) "http://addons.miranda-im.org/index.php?action=display&id=1" );
+ break;
+ } }
+ break;
+
+ case WM_DESTROY:
+ RemoveAllItems( GetDlgItem( hwndDlg, IDC_PLUGLIST ));
+ break;
+ }
+ return FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int PluginOptionsInit(WPARAM wParam, LPARAM)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+ odp.cbSize = sizeof(odp);
+ odp.hInstance = hMirandaInst;
+ odp.pfnDlgProc = DlgPluginOpt;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_PLUGINS);
+ odp.position = 1300000000;
+ odp.pszTitle = LPGEN("Plugins");
+ odp.flags = ODPF_BOLDGROUPS;
+ CallService( MS_OPT_ADDPAGE, wParam, ( LPARAM )&odp );
+ return 0;
+}
+
+void LoadPluginOptions()
+{
+ hevLoadModule = CreateHookableEvent(ME_SYSTEM_MODULELOAD);
+ hevUnloadModule = CreateHookableEvent(ME_SYSTEM_MODULEUNLOAD);
+}
+
+void UnloadPluginOptions()
+{
+ DestroyHookableEvent(hevLoadModule);
+ DestroyHookableEvent(hevUnloadModule);
+}
\ No newline at end of file diff --git a/src/modules/plugins/plugins.h b/src/modules/plugins/plugins.h new file mode 100644 index 0000000000..00033c8142 --- /dev/null +++ b/src/modules/plugins/plugins.h @@ -0,0 +1,70 @@ +
+// returns true if the API exports were good, otherwise, passed in data is returned
+#define CHECKAPI_NONE 0
+#define CHECKAPI_DB 1
+#define CHECKAPI_CLIST 2
+
+// block these plugins
+#define DEFMOD_REMOVED_UIPLUGINOPTS 21
+#define DEFMOD_REMOVED_PROTOCOLNETLIB 22
+
+// basic export prototypes
+typedef int (__cdecl * Miranda_Plugin_Load) ( PLUGINLINK * );
+typedef int (__cdecl * Miranda_Plugin_Unload) ( void );
+// version control
+typedef PLUGININFOEX * (__cdecl * Miranda_Plugin_InfoEx) ( DWORD mirandaVersion );
+// prototype for databases
+typedef DATABASELINK * (__cdecl * Database_Plugin_Info) ( void * reserved );
+// prototype for clists
+typedef int (__cdecl * CList_Initialise) ( PLUGINLINK * );
+// Interface support
+typedef MUUID * (__cdecl * Miranda_Plugin_Interfaces) ( void );
+
+typedef struct { // can all be NULL
+ HINSTANCE hInst;
+ Miranda_Plugin_Load Load;
+ Miranda_Plugin_Unload Unload;
+ Miranda_Plugin_InfoEx InfoEx;
+ Miranda_Plugin_Interfaces Interfaces;
+ Database_Plugin_Info DbInfo;
+ CList_Initialise clistlink;
+ PLUGININFOEX * pluginInfo; // must be freed if hInst == NULL then its a copy
+ DATABASELINK * dblink; // only valid during module being in memory
+} BASIC_PLUGIN_INFO;
+
+#define PCLASS_FAILED 0x1 // not a valid plugin, or API is invalid, pluginname is valid
+#define PCLASS_BASICAPI 0x2 // has Load, Unload, MirandaPluginInfo() -> PLUGININFO seems valid, this dll is in memory.
+#define PCLASS_DB 0x4 // has DatabasePluginInfo() and is valid as can be, and PCLASS_BASICAPI has to be set too
+#define PCLASS_LAST 0x8 // this plugin should be unloaded after everything else
+#define PCLASS_OK 0x10 // plugin should be loaded, if DB means nothing
+#define PCLASS_LOADED 0x20 // Load() has been called, Unload() should be called.
+#define PCLASS_STOPPED 0x40 // wasn't loaded cos plugin name not on white list
+#define PCLASS_CLIST 0x80 // a CList implementation
+#define PCLASS_SERVICE 0x100 // has Service Mode implementation
+
+struct pluginEntry
+{
+ TCHAR pluginname[64];
+ unsigned int pclass; // PCLASS_*
+ BASIC_PLUGIN_INFO bpi;
+ pluginEntry* nextclass;
+};
+
+extern LIST<pluginEntry> pluginList, pluginListAddr;
+extern MUUID miid_last;
+
+int PluginOptionsInit(WPARAM, LPARAM);
+void LoadPluginOptions();
+void UnloadPluginOptions();
+
+int isPluginOnWhiteList(const TCHAR* pluginname);
+void SetPluginOnWhiteList(const TCHAR* pluginname, int allow);
+
+int equalUUID(const MUUID& u1, const MUUID& u2);
+int checkAPI(TCHAR* plugin, BASIC_PLUGIN_INFO* bpi, DWORD mirandaVersion, int checkTypeAPI);
+pluginEntry* OpenPlugin(TCHAR* tszFileName, TCHAR* path);
+bool TryLoadPlugin(pluginEntry *p, bool bDynamic);
+void Plugin_Uninit(pluginEntry* p, bool bDynamic=false);
+
+typedef BOOL (*SCAN_PLUGINS_CALLBACK) ( WIN32_FIND_DATA * fd, TCHAR * path, WPARAM wParam, LPARAM lParam );
+void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam);
diff --git a/src/modules/protocols/protochains.cpp b/src/modules/protocols/protochains.cpp index 0960aa34f0..f75418cb5c 100644 --- a/src/modules/protocols/protochains.cpp +++ b/src/modules/protocols/protochains.cpp @@ -79,7 +79,7 @@ static INT_PTR CallRecvChain(WPARAM wParam, LPARAM lParam) if ( wParam == (WPARAM)(-1)) return 1; //shouldn't happen - sanity check
if ( wParam == 0 ) { //begin processing by finding end of chain
- for ( ;;wParam++ ) {
+ for (;;wParam++ ) {
_itoa( wParam, str, 10 );
if ( DBGetContactSettingString( ccs->hContact, "_Filter", str, &dbv ))
break;
diff --git a/src/modules/protocols/protoopts.cpp b/src/modules/protocols/protoopts.cpp index ccf68482ee..10beb627c7 100644 --- a/src/modules/protocols/protoopts.cpp +++ b/src/modules/protocols/protoopts.cpp @@ -173,7 +173,7 @@ static INT_PTR CALLBACK AccFormDlgProc(HWND hwndDlg, UINT message, WPARAM wParam rtrim( buf );
if ( buf[0] == 0 ) {
int count = 1;
- for ( ;; ) {
+ for (;; ) {
DBVARIANT dbv;
mir_snprintf( buf, SIZEOF(buf), "%s_%d", pa->szProtoName, count++ );
if ( DBGetContactSettingString( NULL, buf, "AM_BaseProto", &dbv ))
diff --git a/src/modules/skin/skinicons.cpp b/src/modules/skin/skinicons.cpp index 11b8ff3a4b..31100a41bd 100644 --- a/src/modules/skin/skinicons.cpp +++ b/src/modules/skin/skinicons.cpp @@ -428,7 +428,7 @@ int LoadSkinIcons(void) DBDeleteContactSetting( NULL, "Icons", moduleName );
}
- for ( ;; ) {
+ for (;; ) {
// get the next protocol name
moduleName[0] = 'p';
moduleName[1] = 0;
diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp index 50358ca6f9..6372bac5cb 100644 --- a/src/modules/utils/utils.cpp +++ b/src/modules/utils/utils.cpp @@ -450,7 +450,7 @@ static INT_PTR GenerateRandom(WPARAM wParam, LPARAM lParam) {
srand(GetTickCount());
unsigned short* buf = (unsigned short*)lParam;
- for ( ; (long)(wParam-=2) >= 0; )
+ for (; (long)(wParam-=2) >= 0; )
*(buf++) = (unsigned short)rand();
if (lParam < 0)
*(char*)buf = (char)(rand() & 0xFF);
diff --git a/src/modules/xml/xmlParser.cpp b/src/modules/xml/xmlParser.cpp index c718b9c46c..c596d99c3f 100644 --- a/src/modules/xml/xmlParser.cpp +++ b/src/modules/xml/xmlParser.cpp @@ -2261,7 +2261,7 @@ XMLNode& XMLNode::operator=( const XMLNode& A ) {
if (d) { d->ref_count--; emptyTheNode(0); }
d=A.d;
- if (d) (d->ref_count) ++ ;
+ if (d) (d->ref_count) ++;
}
return *this;
}
@@ -2270,7 +2270,7 @@ XMLNode::XMLNode(const XMLNode &A) {
// shallow copy
d=A.d;
- if (d) (d->ref_count)++ ;
+ if (d) (d->ref_count)++;
}
XMLNode XMLNode::deepCopy() const
|