diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-26 20:58:32 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-26 20:58:32 +0000 |
commit | 2c6fdda841bfff2425a29c17a0a52a9aa189db42 (patch) | |
tree | 603155af17803cb0a826aaeeadfd9a2654c9008b /src | |
parent | ecdc78ceeab06693142db6b3c1b44169cc035e7a (diff) |
service plugins' load order
git-svn-id: http://svn.miranda-ng.org/main/trunk@1205 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/modules.cpp | 17 | ||||
-rw-r--r-- | src/modules/plugins/newplugins.cpp | 40 |
2 files changed, 35 insertions, 22 deletions
diff --git a/src/core/modules.cpp b/src/core/modules.cpp index 1023506247..6ada0cf650 100644 --- a/src/core/modules.cpp +++ b/src/core/modules.cpp @@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../modules/plugins/plugins.h"
// other static variables
-static BOOL bServiceMode = FALSE;
static DWORD mainThreadId;
static HANDLE hMainThread;
static HANDLE hMissingService;
@@ -67,6 +66,7 @@ void UnloadUtilsModule(void); void UnloadButtonModule(void);
void UnloadClcModule(void);
void UnloadContactListModule(void);
+void UnloadDatabase(void);
void UnloadEventsModule(void);
void UnloadSslModule(void);
void UnloadNetlibModule(void);
@@ -101,11 +101,16 @@ int LoadDefaultModules(void) // if ( LoadErrorsModule()) return 1;
- bServiceMode = LoadServiceModePlugin();
- switch (bServiceMode) {
- case 1: return 0; // stop loading here
- case 0: break;
- default: return 1;
+ switch ( LoadServiceModePlugin()) {
+ case SERVICE_CONTINUE: // continue loading Miranda normally
+ break;
+ case SERVICE_ONLYDB: // load database and go to the message cycle
+ return 0;
+ case SERVICE_MONOPOLY: // unload database and go to the message cycle
+ UnloadDatabase();
+ return 0;
+ default: // smth went wrong, terminating
+ return 1;
}
if ( LoadSkinSounds()) return 1;
diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index dec6102770..32214a1c52 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -592,18 +592,21 @@ void SetServiceModePlugin(pluginEntry *p) int LoadServiceModePlugin(void)
{
if (serviceModePlugin == NULL)
- return 0;
-
- if (serviceModePlugin->bpi.Load() == 0) {
- serviceModePlugin->pclass |= PCLASS_LOADED;
- if (CallService(MS_SERVICEMODE_LAUNCH, 0, 0) != CALLSERVICE_NOTFOUND)
- return 1;
+ return SERVICE_CONTINUE;
- MessageBox(NULL, TranslateT("Unable to load plugin in Service Mode!"), serviceModePlugin->pluginname, 0);
- return -1;
+ // plugin load failed - terminating Miranda
+ if (serviceModePlugin->bpi.Load() != ERROR_SUCCESS) {
+ Plugin_Uninit(serviceModePlugin);
+ return SERVICE_FAILED;
}
- Plugin_Uninit(serviceModePlugin);
- return -1;
+
+ serviceModePlugin->pclass |= PCLASS_LOADED;
+ INT_PTR res = CallService(MS_SERVICEMODE_LAUNCH, 0, 0);
+ if (res != CALLSERVICE_NOTFOUND)
+ return res;
+
+ MessageBox(NULL, TranslateT("Unable to load plugin in Service Mode!"), serviceModePlugin->pluginname, 0);
+ return SERVICE_FAILED;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -754,6 +757,16 @@ int LoadNewPluginsModuleInfos(void) // Plugins module unloading
// called at the end of module chain unloading, just modular engine left at this point
+void UnloadDatabase(void)
+{
+ if (currDb != NULL) {
+ db_setCurrent(NULL);
+ currDblink->Unload(currDb);
+ currDb = NULL;
+ currDblink = NULL;
+ }
+}
+
void UnloadNewPluginsModule(void)
{
if ( !bModuleInitialized)
@@ -771,12 +784,7 @@ void UnloadNewPluginsModule(void) if (pluginList_crshdmp)
Plugin_Uninit(pluginList_crshdmp);
- // unload the DB
- if (currDb != NULL) {
- db_setCurrent(NULL);
- currDblink->Unload(currDb);
- currDb = NULL;
- }
+ UnloadDatabase();
for (int k = pluginList.getCount()-1; k >= 0; k--) {
pluginEntry* p = pluginList[k];
|