summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/clistmenus.cpp55
-rw-r--r--src/mir_app/src/genmenu.cpp220
-rw-r--r--src/mir_app/src/genmenu.h6
-rw-r--r--src/mir_app/src/mir_app.def7
-rw-r--r--src/mir_app/src/mir_app64.def7
-rw-r--r--src/mir_app/src/movetogroup.cpp2
6 files changed, 143 insertions, 154 deletions
diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp
index 8d7725c402..32193ed18d 100644
--- a/src/mir_app/src/clistmenus.cpp
+++ b/src/mir_app/src/clistmenus.cpp
@@ -178,12 +178,9 @@ int fnGetAverageMode(int *pNetProtoCount)
static INT_PTR BuildMainMenu(WPARAM, LPARAM)
{
- ListParam param = { 0 };
- param.MenuObjectHandle = hMainMenuObject;
-
NotifyEventHooks(hPreBuildMainMenuEvent, 0, 0);
- CallService(MO_BUILDMENU, (WPARAM)hMainMenu, (LPARAM)&param);
+ Menu_Build(hMainMenu, hMainMenuObject);
DrawMenuBar((HWND)CallService("CLUI/GetHwnd", 0, 0));
return (INT_PTR)hMainMenu;
}
@@ -205,7 +202,7 @@ static INT_PTR AddMainMenuItem(WPARAM, LPARAM lParam)
mmep->szMenuName = tmi.name.t;
tmi.ownerdata = mmep;
- TMO_IntMenuItem *pimi = MO_AddNewMenuItem(hMainMenuObject, &tmi);
+ TMO_IntMenuItem *pimi = Menu_AddItem(hMainMenuObject, &tmi);
char* name;
bool needFree = false;
@@ -280,7 +277,7 @@ static INT_PTR AddContactMenuItem(WPARAM, LPARAM lParam)
tmi.ownerdata = cmep;
//may be need to change how UniqueName is formed?
- TMO_IntMenuItem *menuHandle = MO_AddNewMenuItem(hContactMenuObject, &tmi);
+ TMO_IntMenuItem *menuHandle = Menu_AddItem(hContactMenuObject, &tmi);
char buf[256];
if (mi->pszService)
mir_snprintf(buf, "%s/%s", (mi->pszContactOwner) ? mi->pszContactOwner : "", (mi->pszService) ? mi->pszService : "");
@@ -306,13 +303,8 @@ static INT_PTR BuildContactMenu(WPARAM hContact, LPARAM)
bcp.isOnList = (db_get_b(hContact, "CList", "NotOnList", 0) == 0);
bcp.isOnline = (szProto != NULL && ID_STATUS_OFFLINE != db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE));
- ListParam param = { 0 };
- param.MenuObjectHandle = hContactMenuObject;
- param.wParam = (WPARAM)&bcp;
-
HMENU hMenu = CreatePopupMenu();
- CallService(MO_BUILDMENU, (WPARAM)hMenu, (LPARAM)&param);
-
+ Menu_Build(hMenu, hContactMenuObject, (WPARAM)&bcp);
return (INT_PTR)hMenu;
}
@@ -332,7 +324,7 @@ INT_PTR ContactMenuExecService(WPARAM wParam, LPARAM lParam)
//true - ok, false ignore
INT_PTR ContactMenuCheckService(WPARAM wParam, LPARAM)
{
- PCheckProcParam pcpp = (PCheckProcParam)wParam;
+ TCheckProcParam *pcpp = (TCheckProcParam*)wParam;
if (pcpp == NULL)
return FALSE;
@@ -408,7 +400,7 @@ BOOL FindMenuHandleByGlobalID(HMENU hMenu, TMO_IntMenuItem *id, MenuItemData* it
INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM)
{
- PCheckProcParam pcpp = (PCheckProcParam)wParam;
+ TCheckProcParam *pcpp = (TCheckProcParam*)wParam;
if (!pcpp)
return TRUE;
@@ -636,7 +628,7 @@ INT_PTR MenuProcessCommand(WPARAM wParam, LPARAM lParam)
if (hst >= ID_STATUS_OFFLINE && hst <= ID_STATUS_OUTTOLUNCH) {
int pos = statustopos(hst);
if (pos != -1 && hStatusMainMenuHandles != NULL)
- return MO_ProcessCommand(hStatusMainMenuHandles[pos], lParam);
+ return Menu_ProcessCommand(hStatusMainMenuHandles[pos], lParam);
}
}
@@ -648,7 +640,7 @@ INT_PTR MenuProcessCommand(WPARAM wParam, LPARAM lParam)
return MO_ProcessCommandBySubMenuIdent((int)hContactMenuObject, LOWORD(wParam), lParam);
//unknown old menu
- return MO_ProcessCommandByMenuIdent(LOWORD(wParam), lParam);
+ return Menu_ProcessCommandById(LOWORD(wParam), lParam);
}
BOOL FindMenuHanleByGlobalID(HMENU hMenu, TMO_IntMenuItem *id, MenuItemData* itdat)
@@ -729,17 +721,16 @@ int RecursiveDeleteMenu(HMENU hMenu)
static INT_PTR MenuGetMain(WPARAM, LPARAM)
{
RecursiveDeleteMenu(hMainMenu);
+
BuildMainMenu(0, 0);
return (INT_PTR)hMainMenu;
}
static INT_PTR BuildStatusMenu(WPARAM, LPARAM)
{
- ListParam param = { 0 };
- param.MenuObjectHandle = hStatusMenuObject;
-
RecursiveDeleteMenu(hStatusMenu);
- CallService(MO_BUILDMENU, (WPARAM)hStatusMenu, (LPARAM)&param);
+
+ Menu_Build(hStatusMenu, hStatusMenuObject);
return (INT_PTR)hStatusMenu;
}
@@ -805,12 +796,12 @@ void RebuildMenuOrder(void)
//status menu
if (hStatusMenuObject != 0) {
- CallService(MO_REMOVEMENUOBJECT, (WPARAM)hStatusMenuObject, 0);
+ Menu_RemoveObject(hStatusMenuObject);
mir_free(hStatusMainMenuHandles);
mir_free(hStatusMenuHandles);
}
- hStatusMenuObject = MO_CreateMenuObject("StatusMenu", LPGEN("Status menu"), "StatusMenuCheckService", "StatusMenuExecService");
+ hStatusMenuObject = Menu_AddObject("StatusMenu", LPGEN("Status menu"), "StatusMenuCheckService", "StatusMenuExecService");
Menu_ConfigureObject(hStatusMenuObject, MCO_OPT_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataStatusMenu");
hStatusMainMenuHandles = (TMO_IntMenuItem**)mir_calloc(_countof(statusModeList) * sizeof(TMO_IntMenuItem*));
@@ -852,7 +843,7 @@ void RebuildMenuOrder(void)
smep->proto = mir_strdup(pa->szModuleName);
tmi.ownerdata = smep;
- TMO_IntMenuItem *rootmenu = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
+ TMO_IntMenuItem *rootmenu = Menu_AddItem(hStatusMenuObject, &tmi);
memset(&tmi, 0, sizeof(tmi));
tmi.flags = CMIF_TCHAR | CMIF_ROOTHANDLE | CMIF_KEEPUNTRANSLATED;
@@ -874,7 +865,7 @@ void RebuildMenuOrder(void)
}
else tmi.name.t = pa->tszAccountName;
- TMO_IntMenuItem *menuHandle = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
+ TMO_IntMenuItem *menuHandle = Menu_AddItem(hStatusMenuObject, &tmi);
((StatusMenuExecParam*)tmi.ownerdata)->protoindex = (int)menuHandle;
Menu_ModifyItem(menuHandle, tmi.name.t, tmi.hIcon, tmi.flags);
@@ -916,7 +907,7 @@ void RebuildMenuOrder(void)
hStatusMenuHandles[i].protoindex = i;
hStatusMenuHandles[i].protostatus[j] = statusModeList[j];
- hStatusMenuHandles[i].menuhandle[j] = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
+ hStatusMenuHandles[i].menuhandle[j] = Menu_AddItem(hStatusMenuObject, &tmi);
char buf[256];
mir_snprintf(buf, "ProtocolIcon_%s_%s", pa->szModuleName, tmi.name.a);
@@ -958,7 +949,7 @@ void RebuildMenuOrder(void)
HotkeyToName(hotkeyName, _countof(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey));
mir_sntprintf(buf, _T("%s\t%s"), cli.pfnGetStatusModeDescription(statusModeList[j], 0), hotkeyName);
tmi.name.t = buf;
- hStatusMainMenuHandles[j] = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
+ hStatusMainMenuHandles[j] = Menu_AddItem(hStatusMenuObject, &tmi);
hStatusMainMenuHandles[j]->hotKey = hotKey;
}
@@ -1131,7 +1122,7 @@ static INT_PTR AddStatusMenuItem(WPARAM wParam, LPARAM lParam)
tmi.root = mp->pMenu;
tmi.hIcon = NULL;
tmi.name.a = mi->pszPopupName;
- pRoot = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
+ pRoot = Menu_AddItem(hStatusMenuObject, &tmi);
}
tmi.flags |= CMIF_ROOTHANDLE;
@@ -1161,7 +1152,7 @@ static INT_PTR AddStatusMenuItem(WPARAM wParam, LPARAM lParam)
tmi.ownerdata = smep;
}
- TMO_IntMenuItem *menuHandle = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
+ TMO_IntMenuItem *menuHandle = Menu_AddItem(hStatusMenuObject, &tmi);
if (smep)
smep->hMenuItem = menuHandle;
@@ -1248,12 +1239,12 @@ void InitCustomMenus(void)
InitGenMenu();
// main menu
- hMainMenuObject = MO_CreateMenuObject("MainMenu", LPGEN("Main menu"), 0, "MainMenuExecService");
+ hMainMenuObject = Menu_AddObject("MainMenu", LPGEN("Main menu"), 0, "MainMenuExecService");
Menu_ConfigureObject(hMainMenuObject, MCO_OPT_USERDEFINEDITEMS, TRUE);
Menu_ConfigureObject(hMainMenuObject, MCO_OPT_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataMainMenu");
// contact menu
- hContactMenuObject = MO_CreateMenuObject("ContactMenu", LPGEN("Contact menu"), "ContactMenuCheckService", "ContactMenuExecService");
+ hContactMenuObject = Menu_AddObject("ContactMenu", LPGEN("Contact menu"), "ContactMenuCheckService", "ContactMenuExecService");
Menu_ConfigureObject(hContactMenuObject, MCO_OPT_USERDEFINEDITEMS, TRUE);
Menu_ConfigureObject(hContactMenuObject, MCO_OPT_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataContactMenu");
@@ -1299,8 +1290,8 @@ void UninitCustomMenus(void)
mir_free(hStatusMenuHandles);
hStatusMenuHandles = NULL;
- if (hMainMenuObject) CallService(MO_REMOVEMENUOBJECT, (WPARAM)hMainMenuObject, 0);
- if (hStatusMenuObject) CallService(MO_REMOVEMENUOBJECT, (WPARAM)hMainMenuObject, 0);
+ Menu_RemoveObject(hMainMenuObject);
+ Menu_RemoveObject(hMainMenuObject);
UnloadMoveToGroup();
FreeMenuProtos();
diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp
index 4a7036d37a..9396daad50 100644
--- a/src/mir_app/src/genmenu.cpp
+++ b/src/mir_app/src/genmenu.cpp
@@ -194,24 +194,6 @@ int MO_RemoveAllObjects()
/////////////////////////////////////////////////////////////////////////////////////////
// wparam = MenuObjectHandle
-
-INT_PTR MO_RemoveMenuObject(WPARAM wParam, LPARAM)
-{
- if (!bIsGenMenuInited)
- return -1;
-
- mir_cslock lck(csMenuHook);
- int objidx = GetMenuObjbyId((int)wParam);
- if (objidx == -1)
- return -1;
-
- delete g_menus[objidx];
- g_menus.remove(objidx);
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// wparam = MenuObjectHandle
// lparam = vKey
INT_PTR MO_ProcessHotKeys(HANDLE menuHandle, INT_PTR vKey)
@@ -231,7 +213,7 @@ INT_PTR MO_ProcessHotKeys(HANDLE menuHandle, INT_PTR vKey)
if (!(LOWORD(pimi->hotKey) & MOD_CONTROL) != !(GetKeyState(VK_CONTROL) & 0x8000)) continue;
if (!(LOWORD(pimi->hotKey) & MOD_SHIFT) != !(GetKeyState(VK_SHIFT) & 0x8000)) continue;
- MO_ProcessCommand(pimi, 0);
+ Menu_ProcessCommand(pimi, 0);
return TRUE;
}
@@ -380,7 +362,6 @@ TMO_IntMenuItem *MO_GetIntMenuItem(HGENMENU wParam)
}
/////////////////////////////////////////////////////////////////////////////////////////
-// LOWORD(wparam) menuident
static int FindMenuByCommand(TMO_IntMenuItem *pimi, void* pCommand)
{
@@ -402,43 +383,46 @@ int MO_ProcessCommandBySubMenuIdent(int menuID, int command, LPARAM lParam)
pimi = MO_RecursiveWalkMenu(g_menus[objidx]->m_items.first, FindMenuByCommand, (void*)command);
}
- return (pimi) ? MO_ProcessCommand(pimi, lParam) : -1;
+ return (pimi) ? Menu_ProcessCommand(pimi, lParam) : -1;
}
-INT_PTR MO_ProcessCommandByMenuIdent(WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(BOOL) Menu_ProcessCommandById(int command, LPARAM lParam)
{
if (!bIsGenMenuInited)
return -1;
- TMO_IntMenuItem *pimi = NULL;
- {
- mir_cslock lck(csMenuHook);
- for (int i = 0; i < g_menus.getCount(); i++)
- if ((pimi = MO_RecursiveWalkMenu(g_menus[i]->m_items.first, FindMenuByCommand, (void*)wParam)) != NULL)
- break;
- }
+ mir_cslock lck(csMenuHook);
+ for (int i = 0; i < g_menus.getCount(); i++)
+ if (TMO_IntMenuItem *pimi = MO_RecursiveWalkMenu(g_menus[i]->m_items.first, FindMenuByCommand, (void*)command))
+ return Menu_ProcessCommand(pimi, lParam);
- return (pimi) ? MO_ProcessCommand(pimi, lParam) : FALSE;
+ return false;
}
-int MO_ProcessCommand(TMO_IntMenuItem *aHandle, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(BOOL) Menu_ProcessCommand(HGENMENU hMenuItem, LPARAM lParam)
{
if (!bIsGenMenuInited)
- return -1;
+ return false;
TMO_IntMenuItem *pimi;
{
mir_cslock lck(csMenuHook);
- if ((pimi = MO_GetIntMenuItem(aHandle)) == NULL)
- return -1;
+ if ((pimi = MO_GetIntMenuItem(hMenuItem)) == NULL)
+ return false;
}
LPCSTR srvname = pimi->parent->ExecService;
void *ownerdata = pimi->mi.ownerdata;
CallService(srvname, (WPARAM)ownerdata, lParam);
- return 1;
+ return true;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(int) Menu_ConfigureItem(HGENMENU hItem, int iOption, INT_PTR value)
{
if (!bIsGenMenuInited)
@@ -462,6 +446,8 @@ MIR_APP_DLL(int) Menu_ConfigureItem(HGENMENU hItem, int iOption, INT_PTR value)
return 1;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(int) Menu_ConfigureObject(HANDLE handle, int setting, INT_PTR value)
{
if (!bIsGenMenuInited)
@@ -500,27 +486,40 @@ MIR_APP_DLL(int) Menu_ConfigureObject(HANDLE handle, int setting, INT_PTR value)
}
/////////////////////////////////////////////////////////////////////////////////////////
-// wparam = LPCSTR szDisplayName;
-// lparam = PMenuParam;
-// result = MenuObjectHandle
-INT_PTR MO_CreateNewMenuObject(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(HANDLE) Menu_AddObject(LPCSTR szName, LPCSTR szDisplayName, LPCSTR szCheckService, LPCSTR szExecService)
{
- TMenuParam *pmp = (TMenuParam *)lParam;
- if (!bIsGenMenuInited || pmp == NULL)
- return -1;
+ if (!bIsGenMenuInited || szName == NULL)
+ return NULL;
mir_cslock lck(csMenuHook);
- TIntMenuObject* p = new TIntMenuObject();
+ TIntMenuObject *p = new TIntMenuObject();
p->id = NextObjectId++;
- p->pszName = mir_strdup(pmp->name);
- p->ptszDisplayName = mir_a2t(LPCSTR(wParam));
- p->CheckService = mir_strdup(pmp->CheckService);
- p->ExecService = mir_strdup(pmp->ExecService);
+ p->pszName = mir_strdup(szName);
+ p->ptszDisplayName = mir_a2t(szDisplayName);
+ p->CheckService = mir_strdup(szCheckService);
+ p->ExecService = mir_strdup(szExecService);
p->m_hMenuIcons = ImageList_Create(g_iIconSX, g_iIconSY, ILC_COLOR32 | ILC_MASK, 15, 100);
g_menus.insert(p);
- return p->id;
+ return (HANDLE)p->id;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(int) Menu_RemoveObject(HANDLE hMenuObject)
+{
+ if (!bIsGenMenuInited || hMenuObject == NULL)
+ return -1;
+
+ mir_cslock lck(csMenuHook);
+ int objidx = GetMenuObjbyId((int)hMenuObject);
+ if (objidx == -1)
+ return -1;
+
+ delete g_menus[objidx];
+ g_menus.remove(objidx);
+ return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -538,10 +537,10 @@ static int FindParent(TMO_IntMenuItem* pimi, void* p)
return pimi->next == p;
}
-INT_PTR MO_RemoveMenuItem(WPARAM wParam, LPARAM)
+MIR_APP_DLL(int) Menu_RemoveItem(HGENMENU hMenuItem)
{
mir_cslock lck(csMenuHook);
- TMO_IntMenuItem *pimi = MO_GetIntMenuItem((HGENMENU)wParam);
+ TMO_IntMenuItem *pimi = MO_GetIntMenuItem(hMenuItem);
if (pimi == NULL)
return -1;
@@ -595,7 +594,7 @@ MIR_APP_DLL(void) KillModuleMenus(int hLangpack)
MO_RecursiveWalkMenu(g_menus[i]->m_items.first, (pfnWalkFunc)KillMenuItems, &param);
for (int k = 0; k < param.arItems.getCount(); k++)
- MO_RemoveMenuItem((WPARAM)param.arItems[k], 0);
+ Menu_RemoveItem(param.arItems[k]);
}
///////////////////////////////////////////////////////////////////////////////
@@ -624,17 +623,17 @@ static int GetNextObjectMenuItemId()
// lparam = PMO_MenuItem
// return MenuItemHandle
-TMO_IntMenuItem *MO_AddNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi)
+MIR_APP_DLL(HGENMENU) Menu_AddItem(HANDLE hMenuObject, TMO_MenuItem *pmi)
{
if (!bIsGenMenuInited || pmi == NULL)
return NULL;
// old mode
if (!(pmi->flags & CMIF_ROOTHANDLE))
- return MO_AddOldNewMenuItem(menuobjecthandle, pmi);
+ return MO_AddOldNewMenuItem(hMenuObject, pmi);
mir_cslock lck(csMenuHook);
- int objidx = GetMenuObjbyId((int)menuobjecthandle);
+ int objidx = GetMenuObjbyId((int)hMenuObject);
if (objidx == -1)
return NULL;
@@ -696,7 +695,7 @@ int FindRoot(TMO_IntMenuItem *pimi, void* param)
return FALSE;
}
-TMO_IntMenuItem *MO_AddOldNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi)
+TMO_IntMenuItem* MO_AddOldNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi)
{
if (!bIsGenMenuInited || pmi == NULL)
return NULL;
@@ -731,7 +730,7 @@ TMO_IntMenuItem *MO_AddOldNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi
tmi.root = NULL;
// copy pszPopupName
tmi.name.t = (TCHAR*)pmi->root;
- if ((oldroot = MO_AddNewMenuItem(menuobjecthandle, &tmi)) != NULL)
+ if ((oldroot = Menu_AddItem(menuobjecthandle, &tmi)) != NULL)
Menu_ConfigureItem(oldroot, MCI_OPT_UNIQUENAME, (const char*)pmi->root);
}
pmi->root = oldroot;
@@ -740,7 +739,7 @@ TMO_IntMenuItem *MO_AddOldNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi
}
pmi->flags |= CMIF_ROOTHANDLE;
// add popup(root allready exists)
- return MO_AddNewMenuItem(menuobjecthandle, pmi);
+ return Menu_AddItem(menuobjecthandle, pmi);
}
static int WhereToPlace(HMENU hMenu, TMO_MenuItem *mi)
@@ -836,28 +835,6 @@ static void InsertMenuItemWithSeparators(HMENU hMenu, int uItem, MENUITEMINFO *l
}
/////////////////////////////////////////////////////////////////////////////////////////
-// wparam started hMenu
-// lparam ListParam*
-// result hMenu
-
-INT_PTR MO_BuildMenu(WPARAM wParam, LPARAM lParam)
-{
- if (!bIsGenMenuInited)
- return -1;
-
- mir_cslock lck(csMenuHook);
-
- ListParam *lp = (ListParam*)lParam;
- int pimoidx = GetMenuObjbyId((int)lp->MenuObjectHandle);
- if (pimoidx == -1)
- return 0;
-
- #if defined(_DEBUG)
- // DumpMenuItem(g_menus[pimoidx]->m_items.first);
- #endif
-
- return (INT_PTR)BuildRecursiveMenu((HMENU)wParam, g_menus[pimoidx]->m_items.first, (ListParam*)lParam);
-}
#ifdef _DEBUG
#define PUTPOSITIONSONMENU
@@ -873,19 +850,16 @@ void GetMenuItemName(TMO_IntMenuItem *pMenuItem, char* pszDest, size_t cbDestSiz
mir_snprintf(pszDest, cbDestSize, "{%s}", pMenuItem->mi.name.t);
}
-HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem *pRootMenu, ListParam *param)
+static HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem *pRootMenu, INT_PTR iRootLevel, WPARAM wParam, LPARAM lParam)
{
- if (param == NULL || pRootMenu == NULL)
+ if (pRootMenu == NULL)
return NULL;
TIntMenuObject* pmo = pRootMenu->parent;
- int rootlevel = (param->rootlevel == -1) ? 0 : param->rootlevel;
-
- ListParam localparam = *param;
-
- while (rootlevel == 0 && GetMenuItemCount(hMenu) > 0)
- DeleteMenu(hMenu, 0, MF_BYPOSITION);
+ if (iRootLevel == 0)
+ while (GetMenuItemCount(hMenu) > 0)
+ DeleteMenu(hMenu, 0, MF_BYPOSITION);
for (TMO_IntMenuItem *pmi = pRootMenu; pmi != NULL; pmi = pmi->next) {
TMO_MenuItem *mi = &pmi->mi;
@@ -894,8 +868,8 @@ HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem *pRootMenu, ListParam *par
if (pmo->CheckService != NULL) {
TCheckProcParam CheckParam;
- CheckParam.lParam = param->lParam;
- CheckParam.wParam = param->wParam;
+ CheckParam.wParam = wParam;
+ CheckParam.lParam = lParam;
CheckParam.MenuItemOwnerData = mi->ownerdata;
CheckParam.MenuItemHandle = pmi;
if (CallService(pmo->CheckService, (WPARAM)&CheckParam, 0) == FALSE)
@@ -903,7 +877,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem *pRootMenu, ListParam *par
}
/**************************************/
- if (rootlevel == 0 && mi->root == NULL && pmo->m_bUseUserDefinedItems) {
+ if (iRootLevel == 0 && mi->root == NULL && pmo->m_bUseUserDefinedItems) {
char DBString[256];
DBVARIANT dbv = { 0 };
int pos;
@@ -943,7 +917,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem *pRootMenu, ListParam *par
/**************************************/
- if (rootlevel != (int)pmi->mi.root)
+ if (iRootLevel != (INT_PTR)pmi->mi.root)
continue;
int i = WhereToPlace(hMenu, mi);
@@ -975,28 +949,27 @@ HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem *pRootMenu, ListParam *par
mii.fMask |= MIIM_SUBMENU;
mii.hSubMenu = CreatePopupMenu();
- #ifdef PUTPOSITIONSONMENU
- if (GetKeyState(VK_CONTROL) & 0x8000) {
- TCHAR str[256];
- mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->name.a, mi->position, mii.dwItemData);
- mii.dwTypeData = str;
- }
- #endif
+#ifdef PUTPOSITIONSONMENU
+ if (GetKeyState(VK_CONTROL) & 0x8000) {
+ TCHAR str[256];
+ mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->name.a, mi->position, mii.dwItemData);
+ mii.dwTypeData = str;
+ }
+#endif
InsertMenuItemWithSeparators(hMenu, i, &mii);
- localparam.rootlevel = LPARAM(pmi);
- BuildRecursiveMenu(mii.hSubMenu, pmi->submenu.first, &localparam);
+ BuildRecursiveMenu(mii.hSubMenu, pmi->submenu.first, LPARAM(pmi), wParam, lParam);
}
else {
mii.wID = pmi->iCommand;
- #ifdef PUTPOSITIONSONMENU
- if (GetKeyState(VK_CONTROL) & 0x8000) {
- TCHAR str[256];
- mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->name.a, mi->position, mii.dwItemData);
- mii.dwTypeData = str;
- }
- #endif
+#ifdef PUTPOSITIONSONMENU
+ if (GetKeyState(VK_CONTROL) & 0x8000) {
+ TCHAR str[256];
+ mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->name.a, mi->position, mii.dwItemData);
+ mii.dwTypeData = str;
+ }
+#endif
if (pmo->onAddService != NULL)
if (CallService(pmo->onAddService, (WPARAM)&mii, (LPARAM)pmi) == FALSE)
@@ -1010,6 +983,29 @@ HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem *pRootMenu, ListParam *par
}
/////////////////////////////////////////////////////////////////////////////////////////
+// wparam started hMenu
+// lparam ListParam*
+// result hMenu
+
+EXTERN_C MIR_APP_DLL(HMENU) Menu_Build(HMENU parent, HANDLE hMenuObject, WPARAM wParam, LPARAM lParam)
+{
+ if (!bIsGenMenuInited)
+ return NULL;
+
+ mir_cslock lck(csMenuHook);
+
+ int pimoidx = GetMenuObjbyId(int(hMenuObject));
+ if (pimoidx == -1)
+ return 0;
+
+ #if defined(_DEBUG)
+ // DumpMenuItem(g_menus[pimoidx]->m_items.first);
+ #endif
+
+ return BuildRecursiveMenu(parent, g_menus[pimoidx]->m_items.first, 0, wParam, lParam);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// iconlib in menu
static int MO_ReloadIcon(TMO_IntMenuItem *pmi, void*)
@@ -1111,7 +1107,7 @@ int TryProcessDoubleClick(MCONTACT hContact)
TMO_IntMenuItem *pimi = (TMO_IntMenuItem*)MO_GetDefaultMenuItem((WPARAM)g_menus[iMenuID]->m_items.first, 0);
if (pimi != NULL) {
- MO_ProcessCommand(pimi, hContact);
+ Menu_ProcessCommand(pimi, hContact);
return 0;
}
}
@@ -1139,18 +1135,10 @@ static int OnModulesLoaded(WPARAM, LPARAM)
int InitGenMenu()
{
- CreateServiceFunction(MO_BUILDMENU, MO_BuildMenu);
-
- CreateServiceFunction(MO_PROCESSCOMMAND, (MIRANDASERVICE)MO_ProcessCommand);
- CreateServiceFunction("MO/CreateNewMenuObject", MO_CreateNewMenuObject);
- CreateServiceFunction(MO_REMOVEMENUITEM, MO_RemoveMenuItem);
- CreateServiceFunction(MO_ADDNEWMENUITEM, (MIRANDASERVICE)MO_AddNewMenuItem);
CreateServiceFunction(MO_MENUITEMGETOWNERDATA, MO_MenuItemGetOwnerData);
CreateServiceFunction(MO_GETMENUITEM, MO_GetMenuItem);
CreateServiceFunction(MO_GETDEFAULTMENUITEM, MO_GetDefaultMenuItem);
- CreateServiceFunction(MO_PROCESSCOMMANDBYMENUIDENT, MO_ProcessCommandByMenuIdent);
CreateServiceFunction(MO_PROCESSHOTKEYS, (MIRANDASERVICE)MO_ProcessHotKeys);
- CreateServiceFunction(MO_REMOVEMENUOBJECT, MO_RemoveMenuObject);
bIconsDisabled = db_get_b(NULL, "CList", "DisableMenuIcons", 0) != 0;
diff --git a/src/mir_app/src/genmenu.h b/src/mir_app/src/genmenu.h
index 0c5f3cd0d2..7ae31f8b25 100644
--- a/src/mir_app/src/genmenu.h
+++ b/src/mir_app/src/genmenu.h
@@ -101,21 +101,17 @@ extern LIST<TIntMenuObject> g_menus;
#define SEPARATORPOSITIONINTERVAL 100000
-//internal usage
-HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem*, ListParam *param);
+// internal usage
void GetMenuItemName(TMO_IntMenuItem *pMenuItem, char* pszDest, size_t cbDestSize);
TMO_IntMenuItem* MO_GetIntMenuItem(HGENMENU);
-TMO_IntMenuItem* MO_AddNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi);
TMO_IntMenuItem* MO_AddOldNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi);
int MO_DrawMenuItem(LPDRAWITEMSTRUCT dis);
int MO_MeasureMenuItem(LPMEASUREITEMSTRUCT mis);
-int MO_ProcessCommand(TMO_IntMenuItem *pimi, LPARAM lParam);
INT_PTR MO_ProcessHotKeys(HANDLE menuHandle, INT_PTR vKey);
-INT_PTR MO_ProcessCommandByMenuIdent(WPARAM wParam, LPARAM lParam);
int MO_ProcessCommandBySubMenuIdent(int menuID, int command, LPARAM lParam);
// function returns TRUE if the walk should be immediately stopped
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index e8e029f9e7..f54b171e6c 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -205,3 +205,10 @@ Menu_ModifyItem @202
Menu_ConfigureItem @203
Menu_GetProtocolRoot @204
Menu_ConfigureObject @205
+Menu_Build @206
+Menu_ProcessCommand @207
+Menu_ProcessCommandById @208
+Menu_AddItem @209
+Menu_RemoveItem @210
+Menu_AddObject @211
+Menu_RemoveObject @212
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index e1114580b8..c97bd514b1 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -205,3 +205,10 @@ Menu_ModifyItem @202
Menu_ConfigureItem @203
Menu_GetProtocolRoot @204
Menu_ConfigureObject @205
+Menu_Build @206
+Menu_ProcessCommand @207
+Menu_ProcessCommandById @208
+Menu_AddItem @209
+Menu_RemoveItem @210
+Menu_AddObject @211
+Menu_RemoveObject @212
diff --git a/src/mir_app/src/movetogroup.cpp b/src/mir_app/src/movetogroup.cpp
index 75b9a66dff..ba995132c8 100644
--- a/src/mir_app/src/movetogroup.cpp
+++ b/src/mir_app/src/movetogroup.cpp
@@ -98,7 +98,7 @@ static int OnContactMenuBuild(WPARAM wParam, LPARAM)
}
for (i=0; i < lphGroupsItems.getCount(); i++)
- CallService(MO_REMOVEMENUITEM, (WPARAM)lphGroupsItems[i], 0);
+ Menu_RemoveItem((HGENMENU)lphGroupsItems[i]);
lphGroupsItems.destroy();
ptrT szContactGroup(db_get_tsa(wParam, "CList", "Group"));