summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-09-25 16:44:33 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-09-25 16:44:33 +0000
commit27035a4a46167dc714b770c77561f14e8d0b945d (patch)
treeb67bbf56d590118aeae36bd187966666983f8631 /src
parenta30011d4b7881cc9e55077ddd6b9686ce54c3343 (diff)
draft version of the dynamic accounts' removal
git-svn-id: http://svn.miranda-ng.org/main/trunk@1655 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/core/miranda.h3
-rw-r--r--src/modules/clist/clistmenus.cpp3
-rw-r--r--src/modules/plugins/newplugins.cpp6
-rw-r--r--src/modules/plugins/pluginopts.cpp2
-rw-r--r--src/modules/protocols/protoaccs.cpp48
5 files changed, 37 insertions, 25 deletions
diff --git a/src/core/miranda.h b/src/core/miranda.h
index b74a85b5f9..74266aced9 100644
--- a/src/core/miranda.h
+++ b/src/core/miranda.h
@@ -201,10 +201,11 @@ PROTO_INTERFACE* AddDefaultAccount(const char* szProtoName);
int FreeDefaultAccount(PROTO_INTERFACE* ppi);
BOOL ActivateAccount(PROTOACCOUNT* pa);
-void EraseAccount(const char* pszProtoName);
+void EraseAccount(const char *pszProtoName);
void DeactivateAccount(PROTOACCOUNT* pa, bool bIsDynamic, bool bErase);
void UnloadAccount(PROTOACCOUNT* pa, bool bIsDynamic, bool bErase);
void OpenAccountOptions(PROTOACCOUNT* pa);
+void KillProtoAccounts(const char *pszProtoName);
void LoadDbAccounts(void);
void WriteDbAccounts(void);
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++) {