summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-12-01 15:43:03 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-12-01 15:43:03 +0000
commitd31d23e418dbf778e7cb9d9563e1a5a1bdb15d48 (patch)
tree7479f5206120bc12fa04810719809c665fd6e719 /plugins
parented0e4c1d9be5e715a5cfbb8968761b3990f17fe5 (diff)
fix for duplicate menu entries in CSList
git-svn-id: http://svn.miranda-ng.org/main/trunk@2594 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CSList/src/cslist.cpp47
-rw-r--r--plugins/CSList/src/cslist.h3
2 files changed, 23 insertions, 27 deletions
diff --git a/plugins/CSList/src/cslist.cpp b/plugins/CSList/src/cslist.cpp
index 94b1235cb9..68d447eb4b 100644
--- a/plugins/CSList/src/cslist.cpp
+++ b/plugins/CSList/src/cslist.cpp
@@ -94,9 +94,19 @@ static int OnInitOptions(WPARAM wparam, LPARAM lparam)
return 0;
}
-static int OnCreateMenuItems(WPARAM wparam, LPARAM lparam)
+static int OnCreateMenuItems(WPARAM, LPARAM)
{
- forAllProtocols(addProtoStatusMenuItem, 0);
+ int protoCount;
+ PROTOACCOUNT** pdesc;
+ ProtoEnumAccounts(&protoCount, &pdesc);
+
+ for (int i = 0; i < protoCount; i++) {
+ char szService[100];
+ mir_snprintf(szService, SIZEOF(szService), "%s%s", pdesc[i]->szModuleName, PS_SETCUSTOMSTATUSEX);
+ if ( ServiceExists(szService))
+ addProtoStatusMenuItem(pdesc[i]->szModuleName);
+ }
+
return 0;
}
@@ -141,8 +151,10 @@ extern "C" __declspec(dllexport) int Load()
HookEvent(ME_OPT_INITIALISE, OnInitOptions);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnDbChanged);
HookEvent(ME_CLIST_PREBUILDSTATUSMENU, OnCreateMenuItems);
- HookEvent(ME_SYSTEM_MODULESLOADED, OnCreateMenuItems);
HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreshutdown);
+
+ // if we load a plugin dynamically, it will work, otherwise fail
+ OnCreateMenuItems(0, 0);
return 0;
}
@@ -219,43 +231,28 @@ INT_PTR showList(WPARAM wparam, LPARAM lparam, LPARAM param)
return 0;
}
-void forAllProtocols( pForAllProtosFunc pFunc, void *arg )
-{
- int protoCount;
- PROTOACCOUNT** pdesc;
- ProtoEnumAccounts(&protoCount, &pdesc);
-
- for (int i = 0; i < protoCount; i++) {
- char szService[100];
- mir_snprintf(szService, SIZEOF(szService), "%s%s", pdesc[i]->szModuleName, PS_SETCUSTOMSTATUSEX);
- if ( ServiceExists(szService))
- pFunc(pdesc[i]->szModuleName , arg);
- }
-}
-
-void addProtoStatusMenuItem(char *protoName, void *arg)
+void addProtoStatusMenuItem(char *protoName)
{
PROTOACCOUNT *pdescr = ProtoGetAccount(protoName);
if (pdescr == NULL)
return;
+ HGENMENU hRoot = MO_GetProtoRootMenu(pdescr->szModuleName);
+ if (hRoot == NULL)
+ return;
+
char buf[200];
mir_snprintf(buf, SIZEOF(buf), "CSList/ShowList/%s", protoName);
if ( !ServiceExists(buf))
CreateServiceFunctionParam(buf, showList, (LPARAM)protoName);
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIF_TCHAR | CMIF_ICONFROMICOLIB;
+ mi.flags = CMIF_CHILDPOPUP | CMIF_TCHAR | CMIF_ICONFROMICOLIB;
mi.icolibItem = forms[0].hIcoLibItem;
mi.ptszName = _T(MODULENAME);
mi.position = 2000040000;
mi.pszService = buf;
- if ( CallService(MS_PROTO_ISACCOUNTLOCKED, 0, (LPARAM)pdescr->szModuleName)) {
- TCHAR szBuffer[256];
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s (locked)"), pdescr->tszAccountName);
- mi.ptszPopupName = szBuffer;
- }
- else mi.ptszPopupName = pdescr->tszAccountName;
+ mi.hParentMenu = hRoot;
Menu_AddStatusMenuItem(&mi);
RegisterHotkeys(buf, pdescr->tszAccountName, pdescr->iOrder);
diff --git a/plugins/CSList/src/cslist.h b/plugins/CSList/src/cslist.h
index e2313d85af..f26a2c608c 100644
--- a/plugins/CSList/src/cslist.h
+++ b/plugins/CSList/src/cslist.h
@@ -416,8 +416,7 @@ struct CSAMWindow
INT_PTR __cdecl showList(WPARAM, LPARAM, LPARAM);
// protocols enumeration related functions
-void forAllProtocols(pForAllProtosFunc pFunc, void *arg);
-void addProtoStatusMenuItem( char *protoName, void *arg);
+void addProtoStatusMenuItem(char *protoName);
// other functions
void IitIcoLib();