diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-27 11:09:19 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-27 11:09:19 +0000 |
commit | ab4abbb7a60f941acab8f0566c6b619f68f1b489 (patch) | |
tree | a67f4d3bde6bb59d3c49195a8c6e9085e01124eb /src | |
parent | 9d65ee38c92c7a0656ddc6c4c26017b7226fc44b (diff) |
- CLISTMENUITEM::pszContactOwner removed, because it's supported only by contact's menu;
- Menu_AddContactMenuItem now receives parameter szProto;
- Menu_Add* helpers are converted into real functions;
git-svn-id: http://svn.miranda-ng.org/main/trunk@14409 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdaway/src/awaymsg.cpp | 2 | ||||
-rw-r--r-- | src/core/stdemail/src/email.cpp | 2 | ||||
-rw-r--r-- | src/core/stdfile/src/file.cpp | 4 | ||||
-rw-r--r-- | src/core/stdhelp/src/help.cpp | 8 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 2 | ||||
-rw-r--r-- | src/core/stduihist/src/history.cpp | 2 | ||||
-rw-r--r-- | src/core/stdurl/url.cpp | 2 | ||||
-rw-r--r-- | src/core/stduserinfo/src/userinfo.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/clistmenus.cpp | 284 | ||||
-rw-r--r-- | src/mir_app/src/clui.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/findadd.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/framesmenu.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/genmenu.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/meta_menu.cpp | 16 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 4 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 4 | ||||
-rw-r--r-- | src/mir_app/src/movetogroup.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/options.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/proto_opts.cpp | 2 |
20 files changed, 183 insertions, 179 deletions
diff --git a/src/core/stdaway/src/awaymsg.cpp b/src/core/stdaway/src/awaymsg.cpp index 6be4cf1a7e..b3c9f95c44 100644 --- a/src/core/stdaway/src/awaymsg.cpp +++ b/src/core/stdaway/src/awaymsg.cpp @@ -170,7 +170,7 @@ int LoadAwayMsgModule(void) CLISTMENUITEM mi = { 0 };
mi.position = -2000005000;
mi.flags = CMIF_NOTOFFLINE;
- mi.pszName = LPGEN("Re&ad status message");
+ mi.name.a = LPGEN("Re&ad status message");
mi.pszService = MS_AWAYMSG_SHOWAWAYMSG;
hAwayMsgMenuItem = Menu_AddContactMenuItem(&mi);
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, AwayMsgPreBuildMenu);
diff --git a/src/core/stdemail/src/email.cpp b/src/core/stdemail/src/email.cpp index 52b6e64e5d..87c505b6ea 100644 --- a/src/core/stdemail/src/email.cpp +++ b/src/core/stdemail/src/email.cpp @@ -69,7 +69,7 @@ int LoadSendRecvEMailModule(void) CLISTMENUITEM mi = { 0 };
mi.position = -2000010000;
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_SENDEMAIL);
- mi.pszName = LPGEN("&E-mail");
+ mi.name.a = LPGEN("&E-mail");
mi.pszService = MS_EMAIL_SENDEMAIL;
hEMailMenuItem = Menu_AddContactMenuItem(&mi);
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp index 1a7ad53931..6c0c01c207 100644 --- a/src/core/stdfile/src/file.cpp +++ b/src/core/stdfile/src/file.cpp @@ -339,7 +339,7 @@ static int SRFileModulesLoaded(WPARAM, LPARAM) CLISTMENUITEM mi = { 0 };
mi.position = -2000020000;
mi.icolibItem = Skin_GetIconHandle(SKINICON_EVENT_FILE);
- mi.pszName = LPGEN("&File");
+ mi.name.a = LPGEN("&File");
mi.pszService = MS_FILE_SENDFILE;
hSRFileMenuItem = Menu_AddContactMenuItem(&mi);
@@ -437,7 +437,7 @@ int LoadSendRecvFileModule(void) CLISTMENUITEM mi = { 0 };
mi.icolibItem = Skin_GetIconHandle(SKINICON_EVENT_FILE);
mi.position = 1900000000;
- mi.pszName = LPGEN("File &transfers...");
+ mi.name.a = LPGEN("File &transfers...");
mi.pszService = "FtMgr/Show"; //MS_PROTO_SHOWFTMGR;
Menu_AddMainMenuItem(&mi);
diff --git a/src/core/stdhelp/src/help.cpp b/src/core/stdhelp/src/help.cpp index 95fbab090f..d134d9fc26 100644 --- a/src/core/stdhelp/src/help.cpp +++ b/src/core/stdhelp/src/help.cpp @@ -77,25 +77,25 @@ int LoadHelpModule(void) mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA);
mi.hParentMenu = Menu_CreateRoot(MO_MAIN, LPGENT("&Help"), 2000090000);
mi.position = 2000090000;
- mi.pszName = LPGEN("&About...");
+ mi.name.a = LPGEN("&About...");
mi.pszService = "Help/AboutCommand";
Menu_AddMainMenuItem(&mi);
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_HELP);
mi.position = -500050000;
- mi.pszName = LPGEN("&Support");
+ mi.name.a = LPGEN("&Support");
mi.pszService = "Help/IndexCommand";
Menu_AddMainMenuItem(&mi);
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDAWEB);
mi.position = 2000050000;
- mi.pszName = LPGEN("&Miranda NG homepage");
+ mi.name.a = LPGEN("&Miranda NG homepage");
mi.pszService = "Help/WebsiteCommand";
Menu_AddMainMenuItem(&mi);
mi.icolibItem = Skin_GetIconHandle(SKINICON_EVENT_URL);
mi.position = 2000040000;
- mi.pszName = LPGEN("&Report bug");
+ mi.name.a = LPGEN("&Report bug");
mi.pszService = "Help/BugCommand";
Menu_AddMainMenuItem(&mi);
return 0;
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 330913a4a5..ba2f82ab62 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -282,7 +282,7 @@ static int SplitmsgModulesLoaded(WPARAM, LPARAM) mi.position = -2000090000;
mi.flags = CMIF_DEFAULT;
mi.icolibItem = Skin_GetIconHandle(SKINICON_EVENT_MESSAGE);
- mi.pszName = LPGEN("&Message");
+ mi.name.a = LPGEN("&Message");
mi.pszService = MS_MSG_SENDMESSAGE;
hMsgMenuItem = Menu_AddContactMenuItem(&mi);
diff --git a/src/core/stduihist/src/history.cpp b/src/core/stduihist/src/history.cpp index 8ea9ae4aa2..94de89639c 100644 --- a/src/core/stduihist/src/history.cpp +++ b/src/core/stduihist/src/history.cpp @@ -404,7 +404,7 @@ int LoadHistoryModule(void) CLISTMENUITEM mi = { 0 };
mi.position = 1000090000;
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_HISTORY);
- mi.pszName = LPGEN("View &history");
+ mi.name.a = LPGEN("View &history");
mi.pszService = MS_HISTORY_SHOWCONTACTHISTORY;
hContactMenu = Menu_AddContactMenuItem(&mi);
diff --git a/src/core/stdurl/url.cpp b/src/core/stdurl/url.cpp index ad3476c23a..e6bbf11e77 100644 --- a/src/core/stdurl/url.cpp +++ b/src/core/stdurl/url.cpp @@ -122,7 +122,7 @@ static int SRUrlModulesLoaded(WPARAM, LPARAM) CLISTMENUITEM mi = { 0 };
mi.position = -2000040000;
mi.icolibItem = Skin_GetIconHandle(SKINICON_EVENT_URL);
- mi.pszName = LPGEN("Web page address (&URL)");
+ mi.name.a = LPGEN("Web page address (&URL)");
mi.pszService = MS_URL_SENDURL;
hSRUrlMenuItem = Menu_AddContactMenuItem(&mi);
diff --git a/src/core/stduserinfo/src/userinfo.cpp b/src/core/stduserinfo/src/userinfo.cpp index ed003d3954..93511c627f 100644 --- a/src/core/stduserinfo/src/userinfo.cpp +++ b/src/core/stduserinfo/src/userinfo.cpp @@ -631,12 +631,12 @@ int LoadUserInfoModule(void) CLISTMENUITEM mi = { 0 };
mi.position = 1000050000;
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_USERDETAILS);
- mi.pszName = LPGEN("User &details");
+ mi.name.a = LPGEN("User &details");
mi.pszService = MS_USERINFO_SHOWDIALOG;
Menu_AddContactMenuItem(&mi);
mi.position = 500050000;
- mi.pszName = LPGEN("View/change my &details...");
+ mi.name.a = LPGEN("View/change my &details...");
Menu_AddMainMenuItem(&mi);
hWindowList = WindowList_Create();
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index fb3b35ea17..b38bf3d194 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -564,14 +564,14 @@ static int ModulesLoaded(WPARAM, LPARAM) mi.position = -2000090001; mi.flags = CMIF_DEFAULT; mi.icolibItem = Skin_GetIconHandle(SKINICON_CHAT_JOIN); - mi.pszName = LPGEN("&Join chat"); + mi.name.a = LPGEN("&Join chat"); mi.pszService = "GChat/JoinChat"; hJoinMenuItem = Menu_AddContactMenuItem(&mi); mi.position = -2000090000; mi.icolibItem = Skin_GetIconHandle(SKINICON_CHAT_LEAVE); mi.flags = CMIF_NOTOFFLINE; - mi.pszName = LPGEN("&Leave chat"); + mi.name.a = LPGEN("&Leave chat"); mi.pszService = "GChat/LeaveChat"; hLeaveMenuItem = Menu_AddContactMenuItem(&mi); diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp index a3343b8506..6d1e4ec605 100644 --- a/src/mir_app/src/clistmenus.cpp +++ b/src/mir_app/src/clistmenus.cpp @@ -97,17 +97,6 @@ struct BuildContactParam int isOnline;
};
-struct StatusMenuExecParam
-{
- char *proto; //This is unique protoname
- int protoindex;
- int status;
-
- BOOL custom;
- char *svc;
- HANDLE hMenuItem;
-};
-
struct MenuItemData
{
HMENU OwnerMenu;
@@ -173,10 +162,9 @@ static INT_PTR BuildMainMenu(WPARAM, LPARAM) return (INT_PTR)hMainMenu;
}
-static INT_PTR AddMainMenuItem(WPARAM, LPARAM lParam)
+MIR_APP_DLL(HGENMENU) Menu_AddMainMenuItem(CLISTMENUITEM *mi, int _hLang)
{
TMO_MenuItem tmi;
- CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
if (!cli.pfnConvertMenu(mi, &tmi))
return 0;
@@ -190,6 +178,7 @@ static INT_PTR AddMainMenuItem(WPARAM, LPARAM lParam) tmi.ownerdata = mmep;
TMO_IntMenuItem *pimi = Menu_AddItem(hMainMenuObject, &tmi);
+ pimi->hLangpack = _hLang;
mmep->pimi = pimi;
char* name;
@@ -198,20 +187,15 @@ static INT_PTR AddMainMenuItem(WPARAM, LPARAM lParam) if (mi->pszService)
name = mi->pszService;
else if (mi->flags & CMIF_UNICODE) {
- name = mir_t2a(mi->ptszName);
+ name = mir_t2a(mi->name.t);
needFree = true;
}
- else name = mi->pszName;
+ else name = mi->name.a;
Menu_ConfigureItem(pimi, MCI_OPT_UNIQUENAME, name);
if (needFree) mir_free(name);
- return (INT_PTR)pimi;
-}
-
-int MainMenuCheckService(WPARAM, LPARAM)
-{
- return 0;
+ return pimi;
}
// called with:
@@ -242,40 +226,44 @@ INT_PTR FreeOwnerDataMainMenu(WPARAM, LPARAM lParam) struct ContactMenuExecParam
{
char *szServiceName;
- char *pszContactOwner;//for check proc
+ char *pszContactOwner;
TMO_IntMenuItem *pimi;
};
-static INT_PTR AddContactMenuItem(WPARAM, LPARAM lParam)
+MIR_APP_DLL(HGENMENU) Menu_AddContactMenuItem(CLISTMENUITEM *mi, const char *pszProto, int _hLang)
{
TMO_MenuItem tmi;
- CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
if (!cli.pfnConvertMenu(mi, &tmi))
return 0;
// owner data
ContactMenuExecParam *cmep = (ContactMenuExecParam*)mir_calloc(sizeof(ContactMenuExecParam));
cmep->szServiceName = mir_strdup(mi->pszService);
- if (mi->pszContactOwner != NULL)
- cmep->pszContactOwner = mir_strdup(mi->pszContactOwner);
+ if (pszProto != NULL)
+ cmep->pszContactOwner = mir_strdup(pszProto);
tmi.ownerdata = cmep;
// may be need to change how UniqueName is formed?
TMO_IntMenuItem *pimi = Menu_AddItem(hContactMenuObject, &tmi);
+ pimi->hLangpack = _hLang;
cmep->pimi = pimi;
+ if (pszProto == NULL)
+ pszProto = "";
+
char buf[256];
- if (mi->pszService)
- mir_snprintf(buf, "%s/%s", (mi->pszContactOwner) ? mi->pszContactOwner : "", (mi->pszService) ? mi->pszService : "");
- else if (mi->ptszName) {
+ if (mi->pszService) {
+ mir_snprintf(buf, "%s/%s", pszProto, (mi->pszService) ? mi->pszService : "");
+ Menu_ConfigureItem(pimi, MCI_OPT_UNIQUENAME, buf);
+ }
+ else if (mi->name.t) {
if (tmi.flags & CMIF_UNICODE)
- mir_snprintf(buf, "%s/NoService/%s", (mi->pszContactOwner) ? mi->pszContactOwner : "", _T2A(mi->ptszName));
+ mir_snprintf(buf, "%s/NoService/%S", pszProto, mi->name.t);
else
- mir_snprintf(buf, "%s/NoService/%s", (mi->pszContactOwner) ? mi->pszContactOwner : "", mi->ptszName);
+ mir_snprintf(buf, "%s/NoService/%s", pszProto, mi->name.a);
+ Menu_ConfigureItem(pimi, MCI_OPT_UNIQUENAME, buf);
}
- else buf[0] = '\0';
- if (buf[0]) Menu_ConfigureItem(pimi, MCI_OPT_UNIQUENAME, buf);
- return (INT_PTR)pimi;
+ return pimi;
}
static INT_PTR BuildContactMenu(WPARAM hContact, LPARAM)
@@ -294,20 +282,22 @@ static INT_PTR BuildContactMenu(WPARAM hContact, LPARAM) return (INT_PTR)hMenu;
}
-//called with:
-//wparam - ownerdata
-//lparam - lparam from winproc
+// called with:
+// wparam - ownerdata
+// lparam - lparam from winproc
INT_PTR ContactMenuExecService(WPARAM wParam, LPARAM lParam)
{
if (wParam != 0) {
ContactMenuExecParam *cmep = (ContactMenuExecParam*)wParam;
- //call with wParam = (MCONTACT)hContact, lparam = popupposition
- CallService(cmep->szServiceName, lParam, cmep->pimi->execParam);
+ if (cmep->pszContactOwner && cmep->szServiceName && cmep->szServiceName[0] == '/')
+ ProtoCallService(cmep->pszContactOwner, cmep->szServiceName, lParam, cmep->pimi->execParam);
+ else
+ CallService(cmep->szServiceName, lParam, cmep->pimi->execParam);
}
return 0;
}
-//true - ok, false ignore
+// true - ok, false ignore
INT_PTR ContactMenuCheckService(WPARAM wParam, LPARAM)
{
TCheckProcParam *pcpp = (TCheckProcParam*)wParam;
@@ -327,14 +317,12 @@ INT_PTR ContactMenuCheckService(WPARAM wParam, LPARAM) if (mir_strcmp(cmep->pszContactOwner, bcp->szProto)) return FALSE;
}
- TMO_MenuItem mi;
- if (Menu_GetItemInfo(pcpp->MenuItemHandle, mi) == 0) {
- if (mi.flags & CMIF_HIDDEN) return FALSE;
- if (mi.flags & CMIF_NOTONLIST && bcp->isOnList) return FALSE;
- if (mi.flags & CMIF_NOTOFFLIST && !bcp->isOnList) return FALSE;
- if (mi.flags & CMIF_NOTONLINE && bcp->isOnline) return FALSE;
- if (mi.flags & CMIF_NOTOFFLINE && !bcp->isOnline) return FALSE;
- }
+ TMO_MenuItem &mi = pcpp->MenuItemHandle->mi;
+ if (mi.flags & CMIF_HIDDEN) return FALSE;
+ if (mi.flags & CMIF_NOTONLIST && bcp->isOnList) return FALSE;
+ if (mi.flags & CMIF_NOTOFFLIST && !bcp->isOnList) return FALSE;
+ if (mi.flags & CMIF_NOTONLINE && bcp->isOnline) return FALSE;
+ if (mi.flags & CMIF_NOTOFFLINE && !bcp->isOnline) return FALSE;
return TRUE;
}
@@ -352,6 +340,53 @@ INT_PTR FreeOwnerDataContactMenu(WPARAM, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
// STATUS MENU
+struct StatusMenuExecParam
+{
+ char *szProto; // This is unique protoname
+ int protoindex;
+ int status;
+
+ BOOL custom;
+ char *svc;
+ HANDLE hMenuItem;
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(HGENMENU) Menu_AddStatusMenuItem(CLISTMENUITEM *mi, const char *pszProto, int _hLangpack)
+{
+ TMO_MenuItem tmi;
+ if (!cli.pfnConvertMenu(mi, &tmi))
+ return 0;
+
+ TMO_IntMenuItem *pRoot = MO_GetIntMenuItem(mi->hParentMenu);
+
+ // owner data
+ StatusMenuExecParam *smep = NULL;
+ if (mi->pszService) {
+ smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
+ smep->custom = TRUE;
+ smep->svc = mir_strdup(mi->pszService);
+ smep->szProto = mir_strdup(pszProto);
+ tmi.ownerdata = smep;
+ }
+
+ TMO_IntMenuItem *pimi = Menu_AddItem(hStatusMenuObject, &tmi);
+ pimi->hLangpack = _hLangpack;
+ if (smep)
+ smep->hMenuItem = pimi;
+
+ char buf[MAX_PATH + 64];
+ char *p = (pRoot) ? mir_t2a(pRoot->mi.name.t) : NULL;
+ mir_snprintf(buf, "%s/%s", (p) ? p : "", mi->pszService ? mi->pszService : "");
+ mir_free(p);
+
+ Menu_ConfigureItem(pimi, MCI_OPT_UNIQUENAME, buf);
+ return pimi;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
BOOL FindMenuHandleByGlobalID(HMENU hMenu, TMO_IntMenuItem *id, MenuItemData* itdat)
{
if (!itdat)
@@ -390,8 +425,8 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) if (!pcpp)
return TRUE;
- TMO_IntMenuItem *timi = MO_GetIntMenuItem(pcpp->MenuItemHandle);
- if (!timi)
+ TMO_IntMenuItem *pimi = MO_GetIntMenuItem(pcpp->MenuItemHandle);
+ if (!pimi)
return TRUE;
StatusMenuExecParam *smep = (StatusMenuExecParam*)pcpp->MenuItemOwnerData;
@@ -401,7 +436,7 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) CUSTOM_STATUS cs = { sizeof(cs) };
cs.flags = CSSF_MASK_STATUS;
cs.status = &XStatus;
- if (CallProtoServiceInt(NULL, smep->proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) != 0)
+ if (CallProtoServiceInt(NULL, smep->szProto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) != 0)
XStatus = 0;
char buf[255];
@@ -411,16 +446,16 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) bool reset = wildcmp(smep->svc, "*XStatus0") != 0;
if (check)
- timi->mi.flags |= CMIF_CHECKED;
+ pimi->mi.flags |= CMIF_CHECKED;
else
- timi->mi.flags &= ~CMIF_CHECKED;
+ pimi->mi.flags &= ~CMIF_CHECKED;
if (reset || check) {
- TMO_IntMenuItem *timiParent = MO_GetIntMenuItem(timi->mi.root);
+ TMO_IntMenuItem *timiParent = MO_GetIntMenuItem(pimi->mi.root);
if (timiParent) {
- LPTSTR ptszName = TranslateTH(timi->mi.hLangpack, timi->mi.hIcon ? timi->mi.name.t : LPGENT("Custom status"));
+ LPTSTR ptszName = TranslateTH(pimi->mi.hLangpack, pimi->mi.hIcolibItem ? pimi->mi.name.t : LPGENT("Custom status"));
- timiParent = MO_GetIntMenuItem(timi->mi.root);
+ timiParent = MO_GetIntMenuItem(pimi->mi.root);
MenuItemData it = { 0 };
if (FindMenuHandleByGlobalID(hStatusMenu, timiParent, &it)) {
@@ -430,12 +465,12 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING | MIIM_STATE;
- if (timi->iconId != -1) {
+ if (pimi->iconId != -1) {
mii.fMask |= MIIM_BITMAP;
if (IsWinVerVistaPlus() && IsThemeActive()) {
- if (timi->hBmp == NULL)
- timi->hBmp = ConvertIconToBitmap(NULL, timi->parent->m_hMenuIcons, timi->iconId);
- mii.hbmpItem = timi->hBmp;
+ if (pimi->hBmp == NULL)
+ pimi->hBmp = ConvertIconToBitmap(NULL, pimi->parent->m_hMenuIcons, pimi->iconId);
+ mii.hbmpItem = pimi->hBmp;
}
else mii.hbmpItem = HBMMENU_CALLBACK;
}
@@ -445,9 +480,9 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) SetMenuItemInfo(it.OwnerMenu, it.position, TRUE, &mii);
}
- Menu_ModifyItem(timi->mi.root, ptszName);
+ Menu_ModifyItem(pimi->mi.root, ptszName);
- timiParent->iconId = timi->iconId;
+ timiParent->iconId = pimi->iconId;
if (timiParent->hBmp) DeleteObject(timiParent->hBmp);
timiParent->hBmp = NULL;
}
@@ -455,20 +490,20 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) }
}
else if (smep && smep->status && !smep->custom) {
- int curProtoStatus = (smep->proto) ? CallProtoServiceInt(NULL, smep->proto, PS_GETSTATUS, 0, 0) : cli.pfnGetAverageMode(NULL);
+ int curProtoStatus = (smep->szProto) ? CallProtoServiceInt(NULL, smep->szProto, PS_GETSTATUS, 0, 0) : cli.pfnGetAverageMode(NULL);
if (smep->status == curProtoStatus)
- timi->mi.flags |= CMIF_CHECKED;
+ pimi->mi.flags |= CMIF_CHECKED;
else
- timi->mi.flags &= ~CMIF_CHECKED;
+ pimi->mi.flags &= ~CMIF_CHECKED;
}
- else if ((!smep || smep->proto) && timi->mi.name.a) {
+ else if ((!smep || smep->szProto) && pimi->mi.name.a) {
int curProtoStatus = 0;
BOOL IconNeedDestroy = FALSE;
char* prot;
if (smep)
- prot = smep->proto;
+ prot = smep->szProto;
else {
- char *prn = mir_u2a(timi->mi.name.t);
+ char *prn = mir_u2a(pimi->mi.name.t);
prot = NEWSTR_ALLOCA(prn);
if (prn) mir_free(prn);
}
@@ -479,22 +514,22 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) curProtoStatus = 0;
if (curProtoStatus >= ID_STATUS_OFFLINE && curProtoStatus < ID_STATUS_IDLE)
- timi->mi.hIcon = Skin_LoadProtoIcon(prot, curProtoStatus);
+ pimi->mi.hIcolibItem = Skin_LoadProtoIcon(prot, curProtoStatus);
else {
- timi->mi.hIcon = (HICON)CallProtoServiceInt(NULL, prot, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
- if (timi->mi.hIcon == (HICON)CALLSERVICE_NOTFOUND)
- timi->mi.hIcon = NULL;
+ pimi->mi.hIcolibItem = (HICON)CallProtoServiceInt(NULL, prot, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
+ if (pimi->mi.hIcolibItem == (HICON)CALLSERVICE_NOTFOUND)
+ pimi->mi.hIcolibItem = NULL;
else
IconNeedDestroy = TRUE;
}
- if (timi->mi.hIcon) {
- Menu_ModifyItem(timi, NULL, timi->mi.hIcon);
+ if (pimi->mi.hIcolibItem) {
+ Menu_ModifyItem(pimi, NULL, pimi->mi.hIcolibItem);
if (IconNeedDestroy) {
- DestroyIcon(timi->mi.hIcon);
- timi->mi.hIcon = NULL;
+ DestroyIcon((HICON)pimi->mi.hIcolibItem);
+ pimi->mi.hIcolibItem = NULL;
}
- else IcoLib_ReleaseIcon(timi->mi.hIcon);
+ else IcoLib_ReleaseIcon((HICON)pimi->mi.hIcolibItem);
}
}
@@ -513,14 +548,14 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) return 0;
}
- if (smep->status == 0 && smep->protoindex != 0 && smep->proto != NULL) {
- char *prot = smep->proto;
+ if (smep->status == 0 && smep->protoindex != 0 && smep->szProto != NULL) {
+ char *prot = smep->szProto;
char szHumanName[64] = { 0 };
- PROTOACCOUNT *acc = Proto_GetAccount(smep->proto);
+ PROTOACCOUNT *acc = Proto_GetAccount(smep->szProto);
bool bIsLocked = !Proto_IsAccountLocked(acc);
db_set_b(NULL, prot, "LockMainStatus", bIsLocked);
- CallProtoServiceInt(NULL, smep->proto, PS_GETNAME, (WPARAM)_countof(szHumanName), (LPARAM)szHumanName);
+ CallProtoServiceInt(NULL, smep->szProto, PS_GETNAME, _countof(szHumanName), (LPARAM)szHumanName);
TMO_IntMenuItem *pimi = MO_GetIntMenuItem((HGENMENU)smep->protoindex);
if (pimi == NULL)
@@ -548,9 +583,9 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) return 0;
}
- if (smep->proto != NULL) {
- Proto_SetStatus(smep->proto, smep->status);
- NotifyEventHooks(hStatusModeChangeEvent, smep->status, (LPARAM)smep->proto);
+ if (smep->szProto != NULL) {
+ Proto_SetStatus(smep->szProto, smep->status);
+ NotifyEventHooks(hStatusModeChangeEvent, smep->status, (LPARAM)smep->szProto);
return 0;
}
@@ -580,9 +615,9 @@ INT_PTR FreeOwnerDataStatusMenu(WPARAM, LPARAM lParam) {
StatusMenuExecParam *smep = (StatusMenuExecParam*)lParam;
if (smep != NULL) {
- FreeAndNil((void**)&smep->proto);
- FreeAndNil((void**)&smep->svc);
- FreeAndNil((void**)&smep);
+ mir_free(smep->szProto);
+ mir_free(smep->svc);
+ mir_free(&smep);
}
return (0);
@@ -802,7 +837,7 @@ void RebuildMenuOrder(void) //owner data
StatusMenuExecParam *smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
- smep->proto = mir_strdup(pa->szModuleName);
+ smep->szProto = mir_strdup(pa->szModuleName);
tmi.ownerdata = smep;
TMO_IntMenuItem *rootmenu = Menu_AddItem(hStatusMenuObject, &tmi);
@@ -815,7 +850,7 @@ void RebuildMenuOrder(void) //owner data
smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
- smep->proto = mir_strdup(pa->szModuleName);
+ smep->szProto = mir_strdup(pa->szModuleName);
tmi.ownerdata = smep;
if (Proto_IsAccountLocked(pa))
@@ -864,7 +899,7 @@ void RebuildMenuOrder(void) smep->custom = FALSE;
smep->status = statusModeList[j];
smep->protoindex = i;
- smep->proto = mir_strdup(pa->szModuleName);
+ smep->szProto = mir_strdup(pa->szModuleName);
tmi.ownerdata = smep;
hStatusMenuHandles[i].protoindex = i;
@@ -1025,8 +1060,8 @@ int fnConvertMenu(CLISTMENUITEM *mi, TMO_MenuItem *pmi) memset(pmi, 0, sizeof(TMO_MenuItem));
pmi->root = mi->hParentMenu;
pmi->flags = mi->flags;
- pmi->hIcon = mi->hIcon;
- pmi->name.a = mi->pszName;
+ pmi->hIcolibItem = mi->icolibItem;
+ pmi->name.a = mi->name.a;
pmi->position = mi->position;
pmi->hLangpack = mi->hLangpack;
return TRUE;
@@ -1055,47 +1090,6 @@ HGENMENU fnGetProtocolMenu(const char* proto) /////////////////////////////////////////////////////////////////////////////////////////
-static INT_PTR AddStatusMenuItem(WPARAM, LPARAM lParam)
-{
- TMO_MenuItem tmi;
- CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
- if (!cli.pfnConvertMenu(mi, &tmi))
- return 0;
-
- TMO_IntMenuItem *pRoot = MO_GetIntMenuItem(mi->hParentMenu);
-
- // owner data
- StatusMenuExecParam *smep = NULL;
- if (mi->pszService) {
- smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
- smep->custom = TRUE;
- smep->svc = mir_strdup(mi->pszService);
- {
- char *buf = mir_strdup(mi->pszService);
- int i = 0;
- while (buf[i] != '\0' && buf[i] != '/') i++;
- buf[i] = '\0';
- smep->proto = mir_strdup(buf);
- mir_free(buf);
- }
- tmi.ownerdata = smep;
- }
-
- TMO_IntMenuItem *pimi = Menu_AddItem(hStatusMenuObject, &tmi);
- if (smep)
- smep->hMenuItem = pimi;
-
- char buf[MAX_PATH + 64];
- char *p = (pRoot) ? mir_t2a(pRoot->mi.name.t) : NULL;
- mir_snprintf(buf, "%s/%s", (p) ? p : "", mi->pszService ? mi->pszService : "");
- mir_free(p);
-
- Menu_ConfigureItem(pimi, MCI_OPT_UNIQUENAME, buf);
- return (INT_PTR)pimi;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
static INT_PTR HotkeySetStatus(WPARAM, LPARAM lParam)
{
return SetStatusMode(lParam, 0);
@@ -1104,12 +1098,21 @@ static INT_PTR HotkeySetStatus(WPARAM, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
// PROTOCOL MENU
-static INT_PTR AddProtoMenuItem(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(HGENMENU) Menu_AddProtoMenuItem(CLISTMENUITEM *mi, const char *pszProto, int _hLangpack)
{
+ if (mi == NULL)
+ return NULL;
+
if (db_get_b(NULL, "CList", "MoveProtoMenus", TRUE))
- return AddStatusMenuItem(wParam, lParam);
+ return Menu_AddStatusMenuItem(mi, pszProto, _hLangpack);
- return AddMainMenuItem(wParam, lParam);
+ char szService[100];
+ if (pszProto && mi->pszService && *mi->pszService == '/') {
+ strncpy_s(szService, pszProto, _TRUNCATE);
+ strncat_s(szService, mi->pszService, _TRUNCATE);
+ mi->pszService = szService;
+ }
+ return Menu_AddMainMenuItem(mi, _hLangpack);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1131,20 +1134,15 @@ void InitCustomMenus(void) CreateServiceFunction(MS_CLIST_SETSTATUSMODE, SetStatusMode);
- CreateServiceFunction("CList/AddMainMenuItem", AddMainMenuItem);
- CreateServiceFunction("CList/AddStatusMenuItem", AddStatusMenuItem);
CreateServiceFunction(MS_CLIST_MENUGETMAIN, MenuGetMain);
CreateServiceFunction(MS_CLIST_MENUBUILDMAIN, BuildMainMenu);
- CreateServiceFunction("CList/AddContactMenuItem", AddContactMenuItem);
CreateServiceFunction(MS_CLIST_MENUBUILDCONTACT, BuildContactMenu);
CreateServiceFunction(MS_CLIST_MENUGETSTATUS, BuildStatusMenu);
CreateServiceFunction(MS_CLIST_MENUPROCESSCOMMAND, MenuProcessCommand);
CreateServiceFunction(MS_CLIST_MENUPROCESSHOTKEY, MenuProcessHotkey);
- CreateServiceFunction("CList/AddProtoMenuItem", AddProtoMenuItem);
-
hPreBuildContactMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDCONTACTMENU);
hPreBuildMainMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDMAINMENU);
cli.hPreBuildStatusMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDSTATUSMENU);
@@ -1198,9 +1196,9 @@ void InitCustomMenus(void) CLISTMENUITEM mi = { 0 };
mi.position = 0x7fffffff;
mi.pszService = "CloseAction";
- mi.pszName = LPGEN("E&xit");
+ mi.name.a = LPGEN("E&xit");
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_EXIT);
- AddMainMenuItem(0, (LPARAM)&mi);
+ Menu_AddMainMenuItem(&mi);
cli.currentStatusMenuItem = ID_STATUS_OFFLINE;
cli.currentDesiredStatusMode = ID_STATUS_OFFLINE;
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index c899b5f1f4..dc3413ee4c 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -331,14 +331,14 @@ int LoadCLUIModule(void) CreateServiceFunction("CList/DeleteContactCommand", MenuItem_DeleteContact);
mi.position = 2000070000;
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE);
- mi.pszName = LPGEN("De&lete");
+ mi.name.a = LPGEN("De&lete");
mi.pszService = "CList/DeleteContactCommand";
Menu_AddContactMenuItem(&mi);
CreateServiceFunction("CList/RenameContactCommand", MenuItem_RenameContact);
mi.position = 2000050000;
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_RENAME);
- mi.pszName = LPGEN("&Rename");
+ mi.name.a = LPGEN("&Rename");
mi.pszService = "CList/RenameContactCommand";
hRenameMenuItem = Menu_AddContactMenuItem(&mi);
@@ -346,7 +346,7 @@ int LoadCLUIModule(void) mi.position = -2050000000;
mi.flags |= CMIF_NOTONLIST;
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_ADDCONTACT);
- mi.pszName = LPGEN("&Add permanently to list");
+ mi.name.a = LPGEN("&Add permanently to list");
mi.pszService = "CList/AddToListContactCommand";
Menu_AddContactMenuItem(&mi);
diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp index ea9efe510c..35da0d8310 100644 --- a/src/mir_app/src/findadd.cpp +++ b/src/mir_app/src/findadd.cpp @@ -1031,7 +1031,7 @@ int LoadFindAddModule(void) CLISTMENUITEM mi = { 0 }; mi.position = 500020000; mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_FINDUSER); - mi.pszName = LPGEN("&Find/add contacts..."); + mi.name.a = LPGEN("&Find/add contacts..."); mi.pszService = MS_FINDADD_FINDADD; hMainMenuItem = Menu_AddMainMenuItem(&mi); return 0; diff --git a/src/mir_app/src/framesmenu.cpp b/src/mir_app/src/framesmenu.cpp index d13fdccb82..72f2aa24b4 100644 --- a/src/mir_app/src/framesmenu.cpp +++ b/src/mir_app/src/framesmenu.cpp @@ -35,7 +35,6 @@ static HANDLE hPreBuildFrameMenuEvent; struct FrameMenuExecParam
{
ptrA szServiceName;
- INT_PTR param1;
};
INT_PTR FreeOwnerDataFrameMenu(WPARAM, LPARAM lParam)
@@ -56,7 +55,6 @@ static INT_PTR AddContextFrameMenuItem(WPARAM, LPARAM lParam) FrameMenuExecParam *fmep = new FrameMenuExecParam();
fmep->szServiceName = mir_strdup(mi->pszService);
- fmep->param1 = (INT_PTR)mi->pszContactOwner;
tmi.ownerdata = fmep;
return (INT_PTR)Menu_AddItem(hFrameMenuObject, &tmi);
}
@@ -70,7 +68,7 @@ INT_PTR FrameMenuExecService(WPARAM wParam, LPARAM lParam) if (fmep == NULL)
return -1;
- CallService(fmep->szServiceName, lParam, fmep->param1);
+ CallService(fmep->szServiceName, lParam, 0);
return 0;
}
diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp index 71b1f7b5de..a420ced350 100644 --- a/src/mir_app/src/genmenu.cpp +++ b/src/mir_app/src/genmenu.cpp @@ -355,7 +355,7 @@ MIR_APP_DLL(int) Menu_ModifyItem(HGENMENU hMenuItem, const TCHAR *ptszName, HAND else pimi->iconId = -1, pimi->hIcolibItem = NULL;
}
else {
- pimi->mi.hIcon = (HICON)hIcon;
+ pimi->mi.hIcolibItem = (HICON)hIcon;
if (hIcon != NULL)
pimi->iconId = ImageList_ReplaceIcon(pimi->parent->m_hMenuIcons, pimi->iconId, (HICON)hIcon);
else
diff --git a/src/mir_app/src/meta_menu.cpp b/src/mir_app/src/meta_menu.cpp index 28f321a63b..df4fbe6bd5 100644 --- a/src/mir_app/src/meta_menu.cpp +++ b/src/mir_app/src/meta_menu.cpp @@ -360,7 +360,7 @@ void InitMenus() // main menu item
mi.icolibItem = GetIconHandle(I_MENUOFF);
- mi.pszName = LPGEN("Toggle metacontacts off");
+ mi.name.a = LPGEN("Toggle metacontacts off");
mi.pszService = "MetaContacts/OnOff";
mi.position = 500010000;
hMenuOnOff = Menu_AddMainMenuItem(&mi);
@@ -368,45 +368,45 @@ void InitMenus() // contact menu items
mi.icolibItem = GetIconHandle(I_CONVERT);
mi.position = -200010;
- mi.pszName = LPGEN("Convert to metacontact");
+ mi.name.a = LPGEN("Convert to metacontact");
mi.pszService = "MetaContacts/Convert";
hMenuConvert = Menu_AddContactMenuItem(&mi);
mi.icolibItem = GetIconHandle(I_ADD);
mi.position = -200009;
- mi.pszName = LPGEN("Add to existing metacontact...");
+ mi.name.a = LPGEN("Add to existing metacontact...");
mi.pszService = "MetaContacts/AddTo";
hMenuAdd = Menu_AddContactMenuItem(&mi);
mi.icolibItem = GetIconHandle(I_EDIT);
mi.position = -200010;
- mi.pszName = LPGEN("Edit metacontact...");
+ mi.name.a = LPGEN("Edit metacontact...");
mi.pszService = "MetaContacts/Edit";
hMenuEdit = Menu_AddContactMenuItem(&mi);
mi.icolibItem = GetIconHandle(I_SETDEFAULT);
mi.position = -200009;
- mi.pszName = LPGEN("Set as metacontact default");
+ mi.name.a = LPGEN("Set as metacontact default");
mi.pszService = "MetaContacts/Default";
hMenuDefault = Menu_AddContactMenuItem(&mi);
mi.icolibItem = GetIconHandle(I_REMOVE);
mi.position = -200008;
- mi.pszName = LPGEN("Delete metacontact");
+ mi.name.a = LPGEN("Delete metacontact");
mi.pszService = "MetaContacts/Delete";
hMenuDelete = Menu_AddContactMenuItem(&mi);
mi.position = -99000;
mi.flags = CMIF_HIDDEN;
mi.icolibItem = 0;
- mi.pszName = LPGEN("Subcontacts");
+ mi.name.a = LPGEN("Subcontacts");
hMenuRoot = Menu_AddContactMenuItem(&mi);
mi.flags = CMIF_HIDDEN;
mi.hParentMenu = hMenuRoot;
for (int i = 0; i < MAX_CONTACTS; i++) {
mi.position--;
- mi.pszName = "";
+ mi.name.a = "";
char buffer[512];
mir_snprintf(buffer, "MetaContacts/MenuFunc%d", i);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index dd9455a4bc..4daf0930f4 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -221,3 +221,7 @@ Menu_MeasureItem @218 Menu_EnableItem @219
Menu_SetChecked @220
Menu_CreateRoot @221
+Menu_AddContactMenuItem @222
+Menu_AddMainMenuItem @223
+Menu_AddProtoMenuItem @224
+Menu_AddStatusMenuItem @225
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 6f0ce211bd..e115db38c2 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -221,3 +221,7 @@ Menu_MeasureItem @218 Menu_EnableItem @219
Menu_SetChecked @220
Menu_CreateRoot @221
+Menu_AddContactMenuItem @222
+Menu_AddMainMenuItem @223
+Menu_AddProtoMenuItem @224
+Menu_AddStatusMenuItem @225
diff --git a/src/mir_app/src/movetogroup.cpp b/src/mir_app/src/movetogroup.cpp index 7deca5d376..55e90eac34 100644 --- a/src/mir_app/src/movetogroup.cpp +++ b/src/mir_app/src/movetogroup.cpp @@ -70,7 +70,7 @@ static void AddGroupItem(HGENMENU hRoot, TCHAR* name, int pos, WPARAM param, boo CLISTMENUITEM mi = { 0 };
mi.hParentMenu = hRoot;
mi.position = pos;
- mi.ptszName = PrepareGroupName(name);
+ mi.name.t = PrepareGroupName(name);
mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
if (checked)
mi.flags |= CMIF_CHECKED;
@@ -79,7 +79,7 @@ static void AddGroupItem(HGENMENU hRoot, TCHAR* name, int pos, WPARAM param, boo Menu_ConfigureItem(result, MCI_OPT_EXECPARAM, param);
lphGroupsItems.insert((HANDLE*)result);
- mir_free(mi.ptszName);
+ mir_free(mi.name.t);
}
static int OnContactMenuBuild(WPARAM wParam, LPARAM)
@@ -90,7 +90,7 @@ static int OnContactMenuBuild(WPARAM wParam, LPARAM) if (!hMoveToGroupItem) {
CLISTMENUITEM mi = { 0 };
mi.position = 100000;
- mi.pszName = LPGEN("&Move to group");
+ mi.name.a = LPGEN("&Move to group");
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_GROUP);
hMoveToGroupItem = Menu_AddContactMenuItem(&mi);
diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp index aee3be838e..1733efbc26 100644 --- a/src/mir_app/src/options.cpp +++ b/src/mir_app/src/options.cpp @@ -1296,7 +1296,7 @@ static int OptModulesLoaded(WPARAM, LPARAM) CLISTMENUITEM mi = { 0 };
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_OPTIONS);
mi.position = 1900000000;
- mi.pszName = LPGEN("&Options...");
+ mi.name.a = LPGEN("&Options...");
mi.pszService = "Options/OptionsCommand";
Menu_AddMainMenuItem(&mi);
return 0;
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index d2b45a520a..cd98784e71 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -1021,7 +1021,7 @@ int OptProtosLoaded(WPARAM, LPARAM) CLISTMENUITEM mi = { 0 };
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_ACCMGR);
mi.position = 1900000000;
- mi.pszName = LPGEN("&Accounts...");
+ mi.name.a = LPGEN("&Accounts...");
mi.pszService = MS_PROTO_SHOWACCMGR;
Menu_AddMainMenuItem(&mi);
return 0;
|