From e412759d7e551e3fc4dc4be6e1fae1cd4f308868 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 3 Jul 2012 21:47:03 +0000 Subject: no more PLUGININFOEX::replacesDefaultModule, that old & nasty clutch since now all Myranda plugins are binary incompatible with Miranda's git-svn-id: http://svn.miranda-ng.org/main/trunk@743 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/plugins/newplugins.cpp | 114 ++++++++++++++++++++++++------------- src/modules/plugins/pluginopts.cpp | 24 ++++++-- src/modules/plugins/plugins.h | 16 +++++- 3 files changed, 107 insertions(+), 47 deletions(-) (limited to 'src/modules/plugins') diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 040a870cca..6c142d852e 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -43,7 +43,26 @@ static const pluginBannedList[] = {{0xe00f1643, 0x263c, 0x4599, { 0xb8, 0x4b, 0x05, 0x3e, 0x5c, 0x51, 0x1d, 0x28 }}, MAX_MIR_VER}, // loadavatars (unicode) {{0xc9e01eb0, 0xa119, 0x42d2, { 0xb3, 0x40, 0xe8, 0x67, 0x8f, 0x5f, 0xea, 0xd9 }}, MAX_MIR_VER}, // loadavatars (ansi) }; -const int pluginBannedListCount = SIZEOF(pluginBannedList); + +MuuidReplacement pluginDefault[] = +{ + { MIID_UIUSERINFO, NULL }, // 0 + { MIID_SRURL, NULL }, // 1 + { MIID_SREMAIL, NULL }, // 2 + { MIID_SRAUTH, NULL }, // 3 + { MIID_SRFILE, NULL }, // 4 + { MIID_UIHELP, NULL }, // 5 + { MIID_UIHISTORY, NULL }, // 6 + { MIID_IDLE, NULL }, // 7 + { MIID_AUTOAWAY, NULL }, // 8 + { MIID_USERONLINE, NULL }, // 9 + { MIID_UPDATENOTIFY, NULL }, // 10 + + { MIID_CLIST, NULL }, // 11 + { MIID_CHAT, NULL }, // 12 + { MIID_SRMM, NULL }, // 13 + { MIID_DATABASE, NULL }, // 14 +}; static BOOL bModuleInitialized = FALSE; @@ -56,7 +75,6 @@ static pluginEntry * pluginListUI; static pluginEntry * pluginList_freeimg; static pluginEntry * pluginList_crshdmp; static HANDLE hPluginListHeap = NULL; -static pluginEntry * pluginDefModList[DEFMOD_HIGHEST+1]; // do not free this memory static int askAboutIgnoredPlugins; int InitIni(void); @@ -68,9 +86,10 @@ int LoadDatabaseModule(void); char* GetPluginNameByInstance(HINSTANCE hInstance) { - int i = 0; - if (pluginList.getCount() == 0) return NULL; - for (i = 0; i < pluginList.getCount(); i++) { + if (pluginList.getCount() == 0) + return NULL; + + for (int i = 0; i < pluginList.getCount(); i++) { pluginEntry* pe = pluginList[i]; if (pe->bpi.pluginInfo && pe->bpi.hInst == hInstance) return pe->bpi.pluginInfo->shortName; @@ -83,7 +102,31 @@ int equalUUID(const MUUID& u1, const MUUID& u2) return memcmp(&u1, &u2, sizeof(MUUID))?0:1; } +bool hasMuuid(const BASIC_PLUGIN_INFO& bpi, const MUUID& uuid) +{ + if (bpi.Interfaces) { + MUUID *piface = bpi.Interfaces(); + for (int i=0; !equalUUID(miid_last, piface[i]); i++) + if ( equalUUID(uuid, piface[i])) + return true; + } + return false; +} + +int getDefaultPluginIdx(const MUUID& muuid) +{ + for (int i=0; i < SIZEOF(pluginDefault); i++) + if (equalUUID(muuid, pluginDefault[i].uuid)) + return i; + + return -1; +} + MUUID miid_last = MIID_LAST; +MUUID miid_chat = MIID_CHAT; +MUUID miid_srmm = MIID_SRMM; +MUUID miid_clist = MIID_CLIST; +MUUID miid_database = MIID_DATABASE; MUUID miid_servicemode = MIID_SERVICEMODE; static bool validInterfaceList(Miranda_Plugin_Interfaces ifaceProc) @@ -104,11 +147,9 @@ static bool validInterfaceList(Miranda_Plugin_Interfaces ifaceProc) static int isPluginBanned(MUUID u1, DWORD dwVersion) { - int i; - - for (i=0; iauthorEmail == NULL || pi->copyright == NULL || pi->homepage == NULL) return FALSE; - if (pi->replacesDefaultModule > DEFMOD_HIGHEST || - pi->replacesDefaultModule == DEFMOD_REMOVED_UIPLUGINOPTS || - pi->replacesDefaultModule == DEFMOD_REMOVED_PROTOCOLNETLIB) - return FALSE; - return TRUE; } @@ -362,11 +398,6 @@ static INT_PTR PluginsEnum(WPARAM, LPARAM lParam) return pluginListDb != NULL ? 1 : -1; } -static INT_PTR PluginsGetDefaultArray(WPARAM, LPARAM) -{ - return (INT_PTR)&pluginDefModList; -} - pluginEntry* OpenPlugin(TCHAR* tszFileName, TCHAR* path) { int isdb = validguess_db_name(tszFileName); @@ -402,17 +433,11 @@ pluginEntry* OpenPlugin(TCHAR* tszFileName, TCHAR* path) if (checkAPI(buf, &bpi, mirandaVersion, CHECKAPI_NONE)) { p->pclass |= (PCLASS_OK | PCLASS_BASICAPI); p->bpi = bpi; - if (bpi.Interfaces) { - int i = 0; - MUUID *piface = bpi.Interfaces(); - while ( !equalUUID(miid_last, piface[i])) { - if ( !equalUUID(miid_servicemode, piface[i++])) - continue; - p->pclass |= (PCLASS_SERVICE); - if (pluginListSM != NULL) p->nextclass = pluginListSM; - pluginListSM = p; - break; - } + if ( hasMuuid(bpi, miid_servicemode)) { + p->pclass |= (PCLASS_SERVICE); + if (pluginListSM != NULL) + p->nextclass = pluginListSM; + pluginListSM = p; } } else @@ -482,13 +507,18 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic) if ( !checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_NONE)) p->pclass |= PCLASS_FAILED; else { - int rm = bpi.pluginInfo->replacesDefaultModule; p->bpi = bpi; p->pclass |= PCLASS_OK | PCLASS_BASICAPI; - if (pluginDefModList[rm] != NULL) { - SetPluginOnWhiteList(p->pluginname, 0); - return false; + if (p->bpi.Interfaces) { + MUUID *piface = bpi.Interfaces(); + for (int i=0; !equalUUID(miid_last, piface[i]); i++) { + int idx = getDefaultPluginIdx( piface[i] ); + if (idx != -1 && pluginDefault[idx].pImpl) { + SetPluginOnWhiteList(p->pluginname, 0); + return false; + } + } } RegisterModule(p->bpi.hInst); @@ -496,7 +526,14 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic) return false; p->pclass |= PCLASS_LOADED; - if (rm) pluginDefModList[rm]=p; + if (p->bpi.Interfaces) { + MUUID *piface = bpi.Interfaces(); + for (int i=0; !equalUUID(miid_last, piface[i]); i++) { + int idx = getDefaultPluginIdx( piface[i] ); + if (idx != -1) + pluginDefault[idx].pImpl = p; + } + } } } else if (p->bpi.hInst != NULL) { @@ -686,7 +723,7 @@ int LoadNewPluginsModule(void) i--; } else if (p->pclass & PCLASS_LOADED) - msgModule |= (p->bpi.pluginInfo->replacesDefaultModule == DEFMOD_SRMESSAGE); + msgModule |= hasMuuid(p->bpi, miid_srmm); } if ( !msgModule) @@ -710,14 +747,13 @@ int LoadNewPluginsModuleInfos(void) mirandaVersion = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0); CreateServiceFunction(MS_PLUGINS_ENUMDBPLUGINS, PluginsEnum); - CreateServiceFunction(MS_PLUGINS_GETDISABLEDEFAULTARRAY, PluginsGetDefaultArray); // remember where the mirandaboot.ini goes PathToAbsoluteT(_T("mirandaboot.ini"), mirandabootini, NULL); // look for all *.dll's enumPlugins(scanPluginsDir, 0, 0); // the database will select which db plugin to use, or fail if no profile is selected - if (LoadDatabaseModule()) return 1; + if ( LoadDatabaseModule()) return 1; InitIni(); // could validate the plugin entries here but internal modules arent loaded so can't call Load(void) in one pass return 0; diff --git a/src/modules/plugins/pluginopts.cpp b/src/modules/plugins/pluginopts.cpp index 83a3c2f4c5..58d5b23128 100644 --- a/src/modules/plugins/pluginopts.cpp +++ b/src/modules/plugins/pluginopts.cpp @@ -26,6 +26,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "plugins.h" +#define IS_DATABASE (1 << 14) + +extern MUUID miid_clist, miid_database; extern HANDLE hShutdownEvent, hPreShutdownEvent; static HANDLE hevLoadModule, hevUnloadModule; @@ -58,8 +61,8 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA* fd, TCHAR* path, WPARAM, LPARAM l if (checkAPI(buf, &pi, MIRANDA_VERSION_CORE, CHECKAPI_NONE) == 0) return TRUE; - int isdb = pi.pluginInfo->replacesDefaultModule == DEFMOD_DB; - int isclist = pi.pluginInfo->replacesDefaultModule == DEFMOD_CLISTALL; + int isdb = hasMuuid(pi, miid_database); + int isclist = hasMuuid(pi, miid_clist); PluginListItemData* dat = (PluginListItemData*)mir_alloc(sizeof(PluginListItemData)); dat->hInst = hInst; @@ -85,7 +88,16 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA* fd, TCHAR* path, WPARAM, LPARAM l ListView_SetItemText(hwndList, iRow, 2, fd->cFileName); - dat->flags = pi.pluginInfo->replacesDefaultModule; + dat->flags = 0; + if (pi.Interfaces) { + MUUID *piface = pi.Interfaces(); + for (int i=0; !equalUUID(miid_last, piface[i]); i++) { + int idx = getDefaultPluginIdx( piface[i] ); + if (idx != -1 ) { + dat->flags |= (1 << idx); + break; + } } } + dat->author = mir_strdup(pi.pluginInfo->author); dat->authorEmail = mir_strdup(pi.pluginInfo->authorEmail); dat->copyright = mir_strdup(pi.pluginInfo->copyright); @@ -211,7 +223,7 @@ static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LP PluginListItemData* dat = (PluginListItemData*)lvi.lParam; if (lvi.iImage == 3) { - if (LoadPluginDynamically(dat)) { + if ( LoadPluginDynamically(dat)) { lvi.iImage = 2; ListView_SetItem(hwnd, &lvi); } @@ -301,7 +313,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar break; PluginListItemData* dat = (PluginListItemData*)it.lParam; - if (dat->flags == DEFMOD_DB) { + if (dat->flags & IS_DATABASE) { ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK); return FALSE; } @@ -314,7 +326,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar dt.iItem = iRow; if (ListView_GetItem(hwndList, &dt)) { PluginListItemData* dat2 = (PluginListItemData*)dt.lParam; - if (dat2->flags == dat->flags) { + 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; diff --git a/src/modules/plugins/plugins.h b/src/modules/plugins/plugins.h index 686f0e0963..7a3a082f3e 100644 --- a/src/modules/plugins/plugins.h +++ b/src/modules/plugins/plugins.h @@ -20,7 +20,9 @@ typedef int (__cdecl * CList_Initialise) (void); // Interface support typedef MUUID * (__cdecl * Miranda_Plugin_Interfaces) (void); -typedef struct { // can all be NULL +// can all be NULL +struct BASIC_PLUGIN_INFO +{ HINSTANCE hInst; Miranda_Plugin_Load Load; Miranda_Plugin_Unload Unload; @@ -30,7 +32,7 @@ typedef struct { // can all be NULL 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. @@ -60,6 +62,8 @@ void UnloadPluginOptions(); int isPluginOnWhiteList(const TCHAR* pluginname); void SetPluginOnWhiteList(const TCHAR* pluginname, int allow); +int getDefaultPluginIdx(const MUUID& muuid); +bool hasMuuid(const BASIC_PLUGIN_INFO&, const MUUID&); 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); @@ -68,3 +72,11 @@ 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); + +struct MuuidReplacement +{ + MUUID uuid; // default interface plugin + pluginEntry* pImpl; // replacement plugin +}; + +extern MuuidReplacement pluginDefault[]; -- cgit v1.2.3