diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-29 20:10:40 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-29 20:10:40 +0000 |
commit | 916c8dea1e49bbfcf7503fc83db63ddc94648f9b (patch) | |
tree | 04b54b1ba8f482121d689cead7da679f444e4b1c | |
parent | 28b5f3536672bdfa6b3ed76a8483424453108b7a (diff) |
ownerData isolated inside TMO_IntMenuItem not to allow external structures to play with it
git-svn-id: http://svn.miranda-ng.org/main/trunk@14443 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/m_genmenu.h | 3 | ||||
-rw-r--r-- | plugins/Clist_modern/src/CLUIFrames/groupmenu.cpp | 6 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clisttray.cpp | 3 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp | 7 | ||||
-rw-r--r-- | plugins/MirOTR/src/mirotrmenu.cpp | 3 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/links.cpp | 5 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_menu.cpp | 5 | ||||
-rw-r--r-- | src/mir_app/src/clistmenus.cpp | 24 | ||||
-rw-r--r-- | src/mir_app/src/framesmenu.cpp | 3 | ||||
-rw-r--r-- | src/mir_app/src/genmenu.cpp | 13 | ||||
-rw-r--r-- | src/mir_app/src/genmenu.h | 1 |
11 files changed, 29 insertions, 44 deletions
diff --git a/include/m_genmenu.h b/include/m_genmenu.h index 2ea11b239b..a159b34e22 100644 --- a/include/m_genmenu.h +++ b/include/m_genmenu.h @@ -46,7 +46,6 @@ struct TMO_MenuItem HICON hIcon;
HANDLE hIcolibItem;
};
- void *ownerdata;
int hLangpack;
};
@@ -104,7 +103,7 @@ EXTERN_C MIR_APP_DLL(BOOL) Menu_ProcessCommandById(int command, LPARAM lParam); // Adds a menu item to genmenu
// Returns HGENMENU on success, or NULL on failure
-EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddItem(int hMenuObject, TMO_MenuItem *pItem);
+EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddItem(int hMenuObject, TMO_MenuItem *pItem, void *pUserData);
/////////////////////////////////////////////////////////////////////////////////////////
// Adds new submenu
diff --git a/plugins/Clist_modern/src/CLUIFrames/groupmenu.cpp b/plugins/Clist_modern/src/CLUIFrames/groupmenu.cpp index 3bc84b1bcc..5e6a01de74 100644 --- a/plugins/Clist_modern/src/CLUIFrames/groupmenu.cpp +++ b/plugins/Clist_modern/src/CLUIFrames/groupmenu.cpp @@ -75,9 +75,8 @@ static INT_PTR AddGroupMenuItem(WPARAM wParam, LPARAM lParam) mmep->Param1 = gmp->wParam;
mmep->Param2 = gmp->lParam;
}
- pmi->ownerdata = mmep;
- HGENMENU hNewItem = Menu_AddItem(hGroupMenuObject, pmi);
+ HGENMENU hNewItem = Menu_AddItem(hGroupMenuObject, pmi, mmep);
char buf[1024];
mir_snprintf(buf, "%s/%s", pmi->pszService, pmi->name.a);
@@ -370,9 +369,8 @@ static INT_PTR AddSubGroupMenuItem(WPARAM wParam, LPARAM lParam) mmep->Param1 = gmp->wParam;
mmep->Param2 = gmp->lParam;
}
- pmi->ownerdata = mmep;
- HGENMENU hNewItem = Menu_AddItem(hSubGroupMenuObject, pmi);
+ HGENMENU hNewItem = Menu_AddItem(hSubGroupMenuObject, pmi, mmep);
char buf[1024];
mir_snprintf(buf, "%s/%s", pmi->pszService, pmi->name.a);
diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index 7e2fcf48e5..583dec0ed8 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -171,9 +171,8 @@ static INT_PTR BuildTrayMenu(WPARAM, LPARAM) static INT_PTR AddTrayMenuItem(WPARAM, LPARAM lParam)
{
TMO_MenuItem *pmi = (TMO_MenuItem*)lParam;
- pmi->ownerdata = mir_strdup(pmi->pszService);
- HGENMENU hNewItem = Menu_AddItem(hTrayMenuObject, pmi);
+ HGENMENU hNewItem = Menu_AddItem(hTrayMenuObject, pmi, mir_strdup(pmi->pszService));
Menu_ConfigureItem(hNewItem, MCI_OPT_UNIQUENAME, pmi->pszService);
return (INT_PTR)hNewItem;
}
diff --git a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp b/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp index 54e104243c..93dba7710d 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp @@ -76,9 +76,8 @@ static INT_PTR AddGroupMenuItem(WPARAM wParam, LPARAM lParam) mmep->Param1 = gmp->wParam;
mmep->Param2 = gmp->lParam;
}
- pmi->ownerdata = mmep;
- HGENMENU hNewItem = Menu_AddItem(hGroupMenuObject, pmi);
+ HGENMENU hNewItem = Menu_AddItem(hGroupMenuObject, pmi, mmep);
char buf[1024];
mir_snprintf(buf, "%s/%s", pmi->pszService, pmi->name.a);
@@ -356,8 +355,8 @@ static INT_PTR AddSubGroupMenuItem(WPARAM wParam, LPARAM lParam) mmep->Param1 = gmp->wParam;
mmep->Param2 = gmp->lParam;
}
- pmi->ownerdata = mmep;
- HGENMENU hNewItem = Menu_AddItem(hSubGroupMenuObject, pmi);
+
+ HGENMENU hNewItem = Menu_AddItem(hSubGroupMenuObject, pmi, mmep);
char buf[1024];
mir_snprintf(buf, "%s/%s", pmi->pszService, pmi->name.a);
diff --git a/plugins/MirOTR/src/mirotrmenu.cpp b/plugins/MirOTR/src/mirotrmenu.cpp index e946b25199..60c8747b35 100644 --- a/plugins/MirOTR/src/mirotrmenu.cpp +++ b/plugins/MirOTR/src/mirotrmenu.cpp @@ -21,8 +21,7 @@ static HGENMENU AddMirOTRMenuItem(TMO_MenuItem *pmi, const char *pszService) // add owner data lpMirOTRMenuExecParam cmep = ( lpMirOTRMenuExecParam )mir_calloc(sizeof(MirOTRMenuExecParam)); cmep->szServiceName = mir_strdup(pszService); - pmi->ownerdata = cmep; - return Menu_AddItem(hMirOTRMenuObject, pmi); + return Menu_AddItem(hMirOTRMenuObject, pmi, cmep); } //called with: diff --git a/protocols/Gadu-Gadu/src/links.cpp b/protocols/Gadu-Gadu/src/links.cpp index 5a5b75df90..e64432a3b1 100644 --- a/protocols/Gadu-Gadu/src/links.cpp +++ b/protocols/Gadu-Gadu/src/links.cpp @@ -101,7 +101,7 @@ void gg_links_instancemenu_init() mi.name.a = "Cancel";
mi.position = 9999999;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE);
- Menu_AddItem(hInstanceMenu, &mi);
+ Menu_AddItem(hInstanceMenu, &mi, NULL);
}
void gg_links_init()
@@ -117,9 +117,8 @@ void GGPROTO::links_instance_init() if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
CMenuItem mi;
mi.flags = CMIF_TCHAR;
- mi.ownerdata = this;
mi.position = g_Instances.getCount();
mi.name.t = m_tszUserName;
- hInstanceMenuItem = Menu_AddItem(hInstanceMenu, &mi);
+ hInstanceMenuItem = Menu_AddItem(hInstanceMenu, &mi, this);
}
}
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index 11b651c68e..88f3746d36 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -193,7 +193,7 @@ void g_MenuInit(void) mi.name.a = "Cancel";
mi.position = 9999999;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE);
- Menu_AddItem(hChooserMenu, &mi);
+ Menu_AddItem(hChooserMenu, &mi, NULL);
}
//////////////////////////////////////////////////////////////////////////////////////
@@ -784,10 +784,9 @@ void CJabberProto::GlobalMenuInit() CMenuItem mi;
mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.ownerdata = this;
mi.position = iChooserMenuPos++;
mi.name.t = m_tszUserName;
- m_hChooseMenuItem = Menu_AddItem(hChooserMenu, &mi);
+ m_hChooseMenuItem = Menu_AddItem(hChooserMenu, &mi, this);
//////////////////////////////////////////////////////////////////////////////////////
// Hotkeys
diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp index f8f94e5175..fe6499c42f 100644 --- a/src/mir_app/src/clistmenus.cpp +++ b/src/mir_app/src/clistmenus.cpp @@ -187,9 +187,8 @@ MIR_APP_DLL(HGENMENU) Menu_AddMainMenuItem(TMO_MenuItem *pmi) //we need just one parametr.
mmep->szServiceName = mir_strdup(pmi->pszService);
mmep->szMenuName = pmi->name.t;
- pmi->ownerdata = mmep;
- TMO_IntMenuItem *pimi = Menu_AddItem(hMainMenuObject, pmi);
+ TMO_IntMenuItem *pimi = Menu_AddItem(hMainMenuObject, pmi, mmep);
if (pimi == NULL)
return NULL;
@@ -254,10 +253,9 @@ MIR_APP_DLL(HGENMENU) Menu_AddContactMenuItem(TMO_MenuItem *pmi, const char *psz cmep->szServiceName = mir_strdup(pmi->pszService);
if (pszProto != NULL)
cmep->pszContactOwner = mir_strdup(pszProto);
- pmi->ownerdata = cmep;
// may be need to change how UniqueName is formed?
- TMO_IntMenuItem *pimi = Menu_AddItem(hContactMenuObject, pmi);
+ TMO_IntMenuItem *pimi = Menu_AddItem(hContactMenuObject, pmi, cmep);
if (pimi == NULL)
return NULL;
@@ -384,9 +382,8 @@ MIR_APP_DLL(HGENMENU) Menu_AddStatusMenuItem(TMO_MenuItem *pmi, const char *pszP smep->svc = mir_strdup(pmi->pszService);
smep->szProto = mir_strdup(pszProto);
}
- pmi->ownerdata = smep;
- TMO_IntMenuItem *pimi = Menu_AddItem(hStatusMenuObject, pmi);
+ TMO_IntMenuItem *pimi = Menu_AddItem(hStatusMenuObject, pmi, smep);
if (pimi == NULL)
return NULL;
@@ -842,9 +839,7 @@ void RebuildMenuOrder(void) // owner data
StatusMenuExecParam *smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
smep->szProto = mir_strdup(pa->szModuleName);
- mi.ownerdata = smep;
-
- TMO_IntMenuItem *rootmenu = Menu_AddItem(hStatusMenuObject, &mi);
+ TMO_IntMenuItem *rootmenu = Menu_AddItem(hStatusMenuObject, &mi, smep);
memset(&mi, 0, sizeof(mi));
mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
@@ -855,7 +850,6 @@ void RebuildMenuOrder(void) // owner data
smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
smep->szProto = mir_strdup(pa->szModuleName);
- mi.ownerdata = smep;
if (Proto_IsAccountLocked(pa))
mi.flags |= CMIF_CHECKED;
@@ -866,8 +860,8 @@ void RebuildMenuOrder(void) }
else mi.name.t = pa->tszAccountName;
- TMO_IntMenuItem *pimi = Menu_AddItem(hStatusMenuObject, &mi);
- ((StatusMenuExecParam*)mi.ownerdata)->protoindex = (int)pimi;
+ TMO_IntMenuItem *pimi = Menu_AddItem(hStatusMenuObject, &mi, smep);
+ smep->protoindex = (int)pimi;
Menu_ModifyItem(pimi, mi.name.t, mi.hIcon, mi.flags);
cli.menuProtos = (MenuProto*)mir_realloc(cli.menuProtos, sizeof(MenuProto)*(cli.menuProtoCount + 1));
@@ -904,11 +898,10 @@ void RebuildMenuOrder(void) smep->status = statusModeList[j];
smep->protoindex = i;
smep->szProto = mir_strdup(pa->szModuleName);
- mi.ownerdata = smep;
hStatusMenuHandles[i].protoindex = i;
hStatusMenuHandles[i].protostatus[j] = statusModeList[j];
- hStatusMenuHandles[i].menuhandle[j] = Menu_AddItem(hStatusMenuObject, &mi);
+ hStatusMenuHandles[i].menuhandle[j] = Menu_AddItem(hStatusMenuObject, &mi, smep);
char buf[256];
mir_snprintf(buf, "ProtocolIcon_%s_%s", pa->szModuleName, mi.name.a);
@@ -943,14 +936,13 @@ void RebuildMenuOrder(void) // owner data
StatusMenuExecParam *smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
smep->status = statusModeList[j];
- mi.ownerdata = smep;
{
TCHAR buf[256], hotkeyName[100];
WORD hotKey = GetHotkeyValue(statusHotkeys[j]);
HotkeyToName(hotkeyName, _countof(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey));
mir_sntprintf(buf, _T("%s\t%s"), cli.pfnGetStatusModeDescription(statusModeList[j], 0), hotkeyName);
mi.name.t = buf;
- hStatusMainMenuHandles[j] = Menu_AddItem(hStatusMenuObject, &mi);
+ hStatusMainMenuHandles[j] = Menu_AddItem(hStatusMenuObject, &mi, smep);
hStatusMainMenuHandles[j]->hotKey = hotKey;
}
diff --git a/src/mir_app/src/framesmenu.cpp b/src/mir_app/src/framesmenu.cpp index d5b3c81c17..98f7da0cdd 100644 --- a/src/mir_app/src/framesmenu.cpp +++ b/src/mir_app/src/framesmenu.cpp @@ -49,8 +49,7 @@ static INT_PTR AddContextFrameMenuItem(WPARAM, LPARAM lParam) FrameMenuExecParam *fmep = new FrameMenuExecParam();
fmep->szServiceName = mir_strdup(pmi->pszService);
- pmi->ownerdata = fmep;
- return (INT_PTR)Menu_AddItem(hFrameMenuObject, pmi);
+ return (INT_PTR)Menu_AddItem(hFrameMenuObject, pmi, fmep);
}
// called with:
diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp index 1738d8b2bf..f4134d0218 100644 --- a/src/mir_app/src/genmenu.cpp +++ b/src/mir_app/src/genmenu.cpp @@ -379,7 +379,7 @@ MIR_APP_DLL(void*) Menu_GetItemData(HGENMENU hMenuItem) mir_cslock lck(csMenuHook);
TMO_IntMenuItem *pimi = MO_GetIntMenuItem(hMenuItem);
- return (pimi) ? pimi->mi.ownerdata : NULL;
+ return (pimi) ? pimi->pUserData : NULL;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -457,7 +457,7 @@ MIR_APP_DLL(BOOL) Menu_ProcessCommand(HGENMENU hMenuItem, LPARAM lParam) }
LPCSTR srvname = pimi->parent->ExecService;
- CallService(srvname, (WPARAM)pimi->mi.ownerdata, lParam);
+ CallService(srvname, (WPARAM)pimi->pUserData, lParam);
return true;
}
@@ -692,14 +692,14 @@ MIR_APP_DLL(HGENMENU) Menu_CreateRoot(int hMenuObject, LPCTSTR ptszName, int pos mi.hLangpack = hLang;
mi.name.t = (TCHAR*)ptszName;
mi.position = position;
- return Menu_AddItem(hMenuObject, &mi);
+ return Menu_AddItem(hMenuObject, &mi, NULL);
}
/////////////////////////////////////////////////////////////////////////////////////////
// Adds new menu item
// Returns a handle to the newly created item or NULL
-MIR_APP_DLL(HGENMENU) Menu_AddItem(int hMenuObject, TMO_MenuItem *pmi)
+MIR_APP_DLL(HGENMENU) Menu_AddItem(int hMenuObject, TMO_MenuItem *pmi, void *pUserData)
{
if (!bIsGenMenuInited || pmi == NULL)
return NULL;
@@ -719,6 +719,7 @@ MIR_APP_DLL(HGENMENU) Menu_AddItem(int hMenuObject, TMO_MenuItem *pmi) p->iconId = -1;
p->OverrideShow = TRUE;
p->originalPosition = pmi->position;
+ p->pUserData = pUserData;
if (pmi->flags & CMIF_UNICODE)
p->mi.name.t = mir_tstrdup(pmi->name.t);
@@ -885,7 +886,7 @@ static HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem *pRootMenu, INT_PTR TCheckProcParam CheckParam;
CheckParam.wParam = wParam;
CheckParam.lParam = lParam;
- CheckParam.MenuItemOwnerData = mi->ownerdata;
+ CheckParam.MenuItemOwnerData = pmi->pUserData;
CheckParam.MenuItemHandle = pmi;
if (CallService(pmo->CheckService, (WPARAM)&CheckParam, 0) == FALSE)
continue;
@@ -1191,7 +1192,7 @@ TIntMenuObject::~TIntMenuObject() void TIntMenuObject::freeItem(TMO_IntMenuItem *p)
{
if (FreeService)
- CallService(FreeService, (WPARAM)p, (LPARAM)p->mi.ownerdata);
+ CallService(FreeService, (WPARAM)p, (LPARAM)p->pUserData);
p->signature = 0;
FreeAndNil((void**)&p->mi.name.t);
diff --git a/src/mir_app/src/genmenu.h b/src/mir_app/src/genmenu.h index a100379541..5c7dfb1c1e 100644 --- a/src/mir_app/src/genmenu.h +++ b/src/mir_app/src/genmenu.h @@ -55,6 +55,7 @@ struct TMO_IntMenuItem int originalPosition;
DWORD hotKey;
WPARAM execParam;
+ void* pUserData;
TMO_IntMenuItem *next; // next item in list
TIntMenuObject *parent;
|