From 27035a4a46167dc714b770c77561f14e8d0b945d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 25 Sep 2012 16:44:33 +0000 Subject: draft version of the dynamic accounts' removal git-svn-id: http://svn.miranda-ng.org/main/trunk@1655 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/clist/clistmenus.cpp | 3 +-- src/modules/plugins/newplugins.cpp | 6 ++++- src/modules/plugins/pluginopts.cpp | 2 +- src/modules/protocols/protoaccs.cpp | 48 +++++++++++++++++++++---------------- 4 files changed, 35 insertions(+), 24 deletions(-) (limited to 'src/modules') diff --git a/src/modules/clist/clistmenus.cpp b/src/modules/clist/clistmenus.cpp index 53f7728d9c..00d5ad157a 100644 --- a/src/modules/clist/clistmenus.cpp +++ b/src/modules/clist/clistmenus.cpp @@ -812,8 +812,7 @@ int fnGetProtoIndexByPos(PROTOCOLDESCRIPTOR ** proto, int protoCnt, int Pos) int fnGetAccountIndexByPos(int Pos) { - int i; - for (i=0; i < accounts.getCount(); i++) + for (int i=0; i < accounts.getCount(); i++) if (accounts[i]->iOrder == Pos) return i; diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 5e3d5baa9f..667aabccfc 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -198,6 +198,7 @@ MUUID miid_chat = MIID_CHAT; MUUID miid_srmm = MIID_SRMM; MUUID miid_clist = MIID_CLIST; MUUID miid_database = MIID_DATABASE; +MUUID miid_protocol = MIID_PROTOCOL; MUUID miid_servicemode = MIID_SERVICEMODE; static bool validInterfaceList(MUUID *piface) @@ -337,7 +338,10 @@ void Plugin_Uninit(pluginEntry* p) int Plugin_UnloadDyn(pluginEntry* p) { if (p->bpi.hInst) { - if (CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0) != 0) + if ( hasMuuid(p->bpi.Interfaces, miid_protocol)) + KillProtoAccounts(p->bpi.pluginInfo->shortName); + + if ( CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0) != 0) return FALSE; NotifyEventHooks(hevUnloadModule, (WPARAM)p->bpi.InfoEx, (LPARAM)p->bpi.hInst); diff --git a/src/modules/plugins/pluginopts.cpp b/src/modules/plugins/pluginopts.cpp index 61063de605..7f1483a5b1 100644 --- a/src/modules/plugins/pluginopts.cpp +++ b/src/modules/plugins/pluginopts.cpp @@ -221,7 +221,7 @@ static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LP } } else if (lvi.iImage == 2) { - if (UnloadPluginDynamically(dat)) { + if ( UnloadPluginDynamically(dat)) { lvi.iImage = 3; ListView_SetItem(hwnd, &lvi); } } } } } diff --git a/src/modules/protocols/protoaccs.cpp b/src/modules/protocols/protoaccs.cpp index 3fd5aeee6b..65ad1e3de7 100644 --- a/src/modules/protocols/protoaccs.cpp +++ b/src/modules/protocols/protoaccs.cpp @@ -452,28 +452,27 @@ BOOL ActivateAccount(PROTOACCOUNT* pa) CreateProtoServiceEx(pa->szModuleName, PS_GETNAME, (MIRANDASERVICEOBJ)stub41, pa->ppro); CreateProtoServiceEx(pa->szModuleName, PS_GETSTATUS, (MIRANDASERVICEOBJ)stub42, pa->ppro); + char szServiceName[ 200 ]; + mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_GETAVATARINFO); + if ( !ServiceExists(szServiceName)) { + mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_GETAVATARINFOW); + if (ServiceExists(szServiceName)) + CreateProtoServiceEx(pa->szModuleName, PS_GETAVATARINFO, (MIRANDASERVICEOBJ)stub43, pa->ppro); + } - char szServiceName[ 200 ]; - mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_GETAVATARINFO); - if ( !ServiceExists(szServiceName)) { - mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_GETAVATARINFOW); - if (ServiceExists(szServiceName)) - CreateProtoServiceEx(pa->szModuleName, PS_GETAVATARINFO, (MIRANDASERVICEOBJ)stub43, pa->ppro); - } - - mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_GETMYAVATAR); - if ( !ServiceExists(szServiceName)) { - mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_GETMYAVATARW); - if (ServiceExists(szServiceName)) - CreateProtoServiceEx(pa->szModuleName, PS_GETMYAVATAR, (MIRANDASERVICEOBJ)stub44, pa->ppro); - } + mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_GETMYAVATAR); + if ( !ServiceExists(szServiceName)) { + mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_GETMYAVATARW); + if (ServiceExists(szServiceName)) + CreateProtoServiceEx(pa->szModuleName, PS_GETMYAVATAR, (MIRANDASERVICEOBJ)stub44, pa->ppro); + } - mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_SETMYAVATAR); - if ( !ServiceExists(szServiceName)) { - mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_SETMYAVATARW); - if (ServiceExists(szServiceName)) - CreateProtoServiceEx(pa->szModuleName, PS_SETMYAVATAR, (MIRANDASERVICEOBJ)stub45, pa->ppro); - } + mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_SETMYAVATAR); + if ( !ServiceExists(szServiceName)) { + mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s%s", pa->szModuleName, PS_SETMYAVATARW); + if (ServiceExists(szServiceName)) + CreateProtoServiceEx(pa->szModuleName, PS_SETMYAVATAR, (MIRANDASERVICEOBJ)stub45, pa->ppro); + } return TRUE; } @@ -615,6 +614,15 @@ void UnloadAccountsModule() ///////////////////////////////////////////////////////////////////////////////////////// +void KillProtoAccounts(const char *szProtoName) +{ + for (int i=0; i < accounts.getCount(); i++) + if ( !strcmp(szProtoName, accounts[i]->szProtoName)) + DeactivateAccount(accounts[i], true, false); +} + +///////////////////////////////////////////////////////////////////////////////////////// + void BuildProtoMenus() { for (int i=0; i < accounts.getCount(); i++) { -- cgit v1.2.3