diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/modules.cpp | 50 | ||||
-rw-r--r-- | src/modules/options/options.cpp | 2 | ||||
-rw-r--r-- | src/modules/plugins/newplugins.cpp | 114 | ||||
-rw-r--r-- | src/modules/plugins/pluginopts.cpp | 24 | ||||
-rw-r--r-- | src/modules/plugins/plugins.h | 16 | ||||
-rw-r--r-- | src/modules/protocols/protocols.cpp | 2 |
6 files changed, 133 insertions, 75 deletions
diff --git a/src/core/modules.cpp b/src/core/modules.cpp index 977a50d4f8..68a718bc11 100644 --- a/src/core/modules.cpp +++ b/src/core/modules.cpp @@ -21,7 +21,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "commonheaders.h"
-#include <m_plugins.h>
+
+#include "../modules/plugins/plugins.h"
// other static variables
static BOOL bServiceMode = FALSE;
@@ -93,6 +94,7 @@ void UnloadErrorsModule(void); int LoadIcoTabsModule();
int LoadHeaderbarModule();
int LoadDescButtonModule();
+
int LoadDefaultModules(void)
{
//load order is very important for these
@@ -112,16 +114,12 @@ int LoadDefaultModules(void) // if ( LoadErrorsModule()) return 1;
bServiceMode = LoadServiceModePlugin();
- switch (bServiceMode)
- {
+ switch (bServiceMode) {
case 1: return 0; // stop loading here
case 0: break;
default: return 1;
}
- //this info will be available at LoadNewPluginsModule()
- INT_PTR *disableDefaultModule=(INT_PTR*)CallService(MS_PLUGINS_GETDISABLEDEFAULTARRAY, 0, 0);
-
if ( LoadSkinSounds()) return 1;
if ( LoadSkinHotkeys()) return 1;
if ( LoadFontserviceModule()) return 1;
@@ -129,8 +127,10 @@ int LoadDefaultModules(void) if ( LoadDescButtonModule()) return 1;
if ( LoadOptionsModule()) return 1;
if ( LoadNetlibModule()) return 1;
+ if ( LoadSslModule()) return 1;
+ NetlibInitSsl();
if ( LoadProtocolsModule()) return 1;
- LoadDbAccounts(); // retrieves the account array from a database
+ LoadDbAccounts(); // retrieves the account array from a database
if ( LoadContactsModule()) return 1;
if ( LoadContactListModule()) return 1;
if ( LoadAddContactModule()) return 1;
@@ -138,27 +138,25 @@ int LoadDefaultModules(void) LangPackDropUnusedItems();
- if ( !disableDefaultModule[DEFMOD_SSL]) if (LoadSslModule()) return 1;
- NetlibInitSsl();
-
- if (LoadAccountsModule()) return 1;
+ if ( LoadAccountsModule()) return 1;
//order becomes less important below here
- if ( !disableDefaultModule[DEFMOD_UIFINDADD]) if (LoadFindAddModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_UIUSERINFO]) if (LoadUserInfoModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_SRURL]) if (LoadSendRecvUrlModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_SREMAIL]) if (LoadSendRecvEMailModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_SRAUTH]) if (LoadSendRecvAuthModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_SRFILE]) if (LoadSendRecvFileModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_UIHELP]) if (LoadHelpModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_UIHISTORY]) if (LoadHistoryModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_RNDIDLE]) if (LoadIdleModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_RNDAUTOAWAY]) if (LoadAutoAwayModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_RNDUSERONLINE]) if (LoadUserOnlineModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_SRAWAY]) if (LoadAwayMsgModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_RNDIGNORE]) if (LoadIgnoreModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_UIVISIBILITY]) if (LoadVisibilityModule()) return 1;
- if ( !disableDefaultModule[DEFMOD_UPDATENOTIFY]) if (LoadUpdateNotifyModule()) return 1;
+ if ( LoadFindAddModule()) return 1;
+ if ( LoadAwayMsgModule()) return 1;
+ if ( LoadIgnoreModule()) return 1;
+ if ( LoadVisibilityModule()) return 1;
+
+ if ( !pluginDefault[ 0].pImpl) if ( LoadUserInfoModule()) return 1;
+ if ( !pluginDefault[ 1].pImpl) if ( LoadSendRecvUrlModule()) return 1;
+ if ( !pluginDefault[ 2].pImpl) if ( LoadSendRecvEMailModule()) return 1;
+ if ( !pluginDefault[ 3].pImpl) if ( LoadSendRecvAuthModule()) return 1;
+ if ( !pluginDefault[ 4].pImpl) if ( LoadSendRecvFileModule()) return 1;
+ if ( !pluginDefault[ 5].pImpl) if ( LoadHelpModule()) return 1;
+ if ( !pluginDefault[ 6].pImpl) if ( LoadHistoryModule()) return 1;
+ if ( !pluginDefault[ 7].pImpl) if ( LoadIdleModule()) return 1;
+ if ( !pluginDefault[ 8].pImpl) if ( LoadAutoAwayModule()) return 1;
+ if ( !pluginDefault[ 9].pImpl) if ( LoadUserOnlineModule()) return 1;
+ if ( !pluginDefault[10].pImpl) if ( LoadUpdateNotifyModule()) return 1;
return 0;
}
diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp index e949ff31c5..9310c6c5d9 100644 --- a/src/modules/options/options.cpp +++ b/src/modules/options/options.cpp @@ -621,7 +621,7 @@ static void LoadOptionsModule(HWND hdlg, OptionsDlgData *dat, HINSTANCE hInst) for (int i=0; i < opi.pageCount; i++) {
OptionsPageData* opd = (OptionsPageData*)mir_calloc(sizeof(OptionsPageData));
- if (LoadOptionsPage(&opi.odp[i], opd))
+ if ( LoadOptionsPage(&opi.odp[i], opd))
dat->arOpd.insert(opd);
else
mir_free(opd);
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; i<pluginBannedListCount; i++) {
- if (equalUUID(pluginBannedList[i].uuid, u1)) {
- if (dwVersion<pluginBannedList[i].maxVersion)
+ for (int i=0; i < SIZEOF(pluginBannedList); i++) {
+ if ( equalUUID(pluginBannedList[i].uuid, u1)) {
+ if (dwVersion < pluginBannedList[i].maxVersion)
return 1;
return 0;
}
@@ -165,11 +206,6 @@ static int checkPI(BASIC_PLUGIN_INFO* bpi, PLUGININFOEX* pi) pi->authorEmail == 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[];
diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp index 69f3c846cd..991ebdfe08 100644 --- a/src/modules/protocols/protocols.cpp +++ b/src/modules/protocols/protocols.cpp @@ -714,7 +714,7 @@ int LoadProtocolsModule(void) {
bModuleInitialized = TRUE;
- if (LoadProtoChains())
+ if ( LoadProtoChains())
return 1;
InsertServiceListItem( 1, PS_ADDTOLIST);
|