diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-22 12:13:16 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-22 12:13:16 +0000 |
commit | 4625aafb053a002f0223bfbe76abfbec629feacf (patch) | |
tree | 512f5e5fc5fd6b4d7a79d9b535158d065017f94f | |
parent | 28a3f4e95a93f30155c68aa87198595ca9e100b5 (diff) |
minor correction in the internal genmenu structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@14324 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/delphi/m_genmenu.inc | 3 | ||||
-rw-r--r-- | include/m_genmenu.h | 13 | ||||
-rw-r--r-- | plugins/MirOTR/src/mirotrmenu.cpp | 153 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/links.cpp | 23 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_menu.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/clistmenus.cpp | 41 | ||||
-rw-r--r-- | src/mir_app/src/genmenu.cpp | 58 | ||||
-rw-r--r-- | src/mir_app/src/genmenu.h | 6 |
8 files changed, 139 insertions, 162 deletions
diff --git a/include/delphi/m_genmenu.inc b/include/delphi/m_genmenu.inc index f64f48dbf2..a8d54d8edb 100644 --- a/include/delphi/m_genmenu.inc +++ b/include/delphi/m_genmenu.inc @@ -195,10 +195,9 @@ const type
PMO_MenuItem = ^TMO_MenuItem;
TMO_MenuItem = record
- cbSize :int;
- szName :TCHAR;
position :int;
root :HGENMENU;
+ szName :TCHAR;
flags :integer;
hIcon :HICON; // or hIcolibItem:THANDLE;
hotKey :dword;
diff --git a/include/m_genmenu.h b/include/m_genmenu.h index 1bcfd1581d..55ba8115ee 100644 --- a/include/m_genmenu.h +++ b/include/m_genmenu.h @@ -179,21 +179,15 @@ __forceinline HGENMENU Menu_AddTrayMenuItem(CLISTMENUITEM *mi) //wParam=lParam=0
#define ME_CLIST_PREBUILDMAINMENU "CList/PreBuildMainMenu"
-
/*GENMENU_MODULE*/
#define SETTING_NOOFFLINEBOTTOM_DEFAULT 0
-typedef struct
+struct TMO_MenuItem
{
- int cbSize;
- union
- {
- char *pszName;
- TCHAR *ptszName;
- };
int position;
HGENMENU root;
+ MAllStrings name;
int flags;
union {
HICON hIcon;
@@ -202,8 +196,7 @@ typedef struct DWORD hotKey;
void *ownerdata;
int hLangpack;
-}
- TMO_MenuItem,*PMO_MenuItem;
+};
/*
This structure passed to CheckService.
diff --git a/plugins/MirOTR/src/mirotrmenu.cpp b/plugins/MirOTR/src/mirotrmenu.cpp index 4cab62e690..33f69c3915 100644 --- a/plugins/MirOTR/src/mirotrmenu.cpp +++ b/plugins/MirOTR/src/mirotrmenu.cpp @@ -28,13 +28,12 @@ static INT_PTR AddMirOTRMenuItem(WPARAM, LPARAM lParam) return 0; TMO_MenuItem tmi = { 0 }; - tmi.cbSize = sizeof(tmi); tmi.flags = mi->flags; tmi.hIcon = mi->hIcon; tmi.hIcolibItem = mi->icolibItem; tmi.hotKey = mi->hotKey; tmi.position = mi->position; - tmi.ptszName = mi->ptszName; + tmi.name.t = mi->ptszName; tmi.root = mi->root; //owner data @@ -71,92 +70,91 @@ INT_PTR MirOTRMenuExecService(WPARAM wParam,LPARAM lParam) return 0; } -//true - ok,false ignore -INT_PTR MirOTRMenuCheckService(WPARAM wParam,LPARAM) +// true - ok,false ignore +INT_PTR MirOTRMenuCheckService(WPARAM wParam, LPARAM) { - PCheckProcParam pcpp = ( PCheckProcParam )wParam; + PCheckProcParam pcpp = (PCheckProcParam)wParam; TMO_MenuItem mi; - if ( pcpp == NULL ) + if (pcpp == NULL) return FALSE; - lpMirOTRMenuExecParam cmep = ( lpMirOTRMenuExecParam )pcpp->MenuItemOwnerData; - if ( cmep == NULL ) //this is rootsection...build it + lpMirOTRMenuExecParam cmep = (lpMirOTRMenuExecParam)pcpp->MenuItemOwnerData; + if (cmep == NULL) //this is rootsection...build it return TRUE; MCONTACT hContact = (MCONTACT)pcpp->wParam, hSub; - if((hSub = db_mc_getMostOnline(hContact)) != 0) + if ((hSub = db_mc_getMostOnline(hContact)) != 0) hContact = hSub; - + ConnContext *context = otrl_context_find_miranda(otr_user_state, hContact); TrustLevel level = (TrustLevel)otr_context_get_trust(context); - - mi.cbSize = sizeof(mi); - if ( CallService(MO_GETMENUITEM, (WPARAM)pcpp->MenuItemHandle, (LPARAM)&mi) == 0) { - - if ( mi.flags & CMIF_HIDDEN ) return FALSE; - if ( mi.flags & CMIF_NOTPRIVATE && level==TRUST_PRIVATE ) return FALSE; - if ( mi.flags & CMIF_NOTFINISHED && level==TRUST_FINISHED ) return FALSE; - if ( mi.flags & CMIF_NOTUNVERIFIED && level==TRUST_UNVERIFIED ) return FALSE; - if ( mi.flags & CMIF_NOTNOTPRIVATE && level==TRUST_NOT_PRIVATE ) return FALSE; - + + if (CallService(MO_GETMENUITEM, (WPARAM)pcpp->MenuItemHandle, (LPARAM)&mi) == 0) { + if (mi.flags & CMIF_HIDDEN) return FALSE; + if (mi.flags & CMIF_NOTPRIVATE && level == TRUST_PRIVATE) return FALSE; + if (mi.flags & CMIF_NOTFINISHED && level == TRUST_FINISHED) return FALSE; + if (mi.flags & CMIF_NOTUNVERIFIED && level == TRUST_UNVERIFIED) return FALSE; + if (mi.flags & CMIF_NOTNOTPRIVATE && level == TRUST_NOT_PRIVATE) return FALSE; + if (pcpp->MenuItemHandle == hStatusInfoItem) { + size_t len; TCHAR text[128]; - mi.ptszName = text; + mi.name.t = text; mi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR; switch (level) { - case TRUST_PRIVATE:{ - mi.hIcolibItem = IcoLib_GetIconHandle(ICON_PRIVATE); - mir_tstrncpy(text,TranslateT(LANG_STATUS_PRIVATE),_countof(text)); - size_t len = mir_tstrlen(text); - if(len < _countof(text)) - mir_sntprintf(text+len, _countof(text)-len, _T(" [v%i]"), context->protocol_version); - break;} - case TRUST_UNVERIFIED:{ - mi.hIcolibItem = IcoLib_GetIconHandle(ICON_UNVERIFIED); - mir_tstrncpy(text,TranslateT(LANG_STATUS_UNVERIFIED),_countof(text)); - size_t len = mir_tstrlen(text); - if(len < _countof(text)) - mir_sntprintf(text+len, _countof(text)-len, _T(" [v%i]"), context->protocol_version); - break;} - case TRUST_FINISHED: - mi.hIcolibItem = IcoLib_GetIconHandle(ICON_FINISHED); - mi.ptszName = TranslateT(LANG_STATUS_FINISHED); - break; - default: - mi.hIcolibItem = IcoLib_GetIconHandle(ICON_NOT_PRIVATE); - mi.ptszName = TranslateT(LANG_STATUS_DISABLED); + case TRUST_PRIVATE: + mi.hIcolibItem = IcoLib_GetIconHandle(ICON_PRIVATE); + mir_tstrncpy(text, TranslateT(LANG_STATUS_PRIVATE), _countof(text)); + len = mir_tstrlen(text); + if (len < _countof(text)) + mir_sntprintf(text + len, _countof(text) - len, _T(" [v%i]"), context->protocol_version); + break; + case TRUST_UNVERIFIED: + mi.hIcolibItem = IcoLib_GetIconHandle(ICON_UNVERIFIED); + mir_tstrncpy(text, TranslateT(LANG_STATUS_UNVERIFIED), _countof(text)); + len = mir_tstrlen(text); + if (len < _countof(text)) + mir_sntprintf(text + len, _countof(text) - len, _T(" [v%i]"), context->protocol_version); + break; + case TRUST_FINISHED: + mi.hIcolibItem = IcoLib_GetIconHandle(ICON_FINISHED); + mi.name.t = TranslateT(LANG_STATUS_FINISHED); + break; + default: + mi.hIcolibItem = IcoLib_GetIconHandle(ICON_NOT_PRIVATE); + mi.name.t = TranslateT(LANG_STATUS_DISABLED); } CallService(MO_MODIFYMENUITEM, (WPARAM)hStatusInfoItem, (LPARAM)&mi); - } else if (pcpp->MenuItemHandle == hHTMLConvMenuItem) { - if (db_get_b(hContact, MODULENAME, "HTMLConv", 0) ) - mi.flags |= CMIM_FLAGS|CMIF_CHECKED; + } + else if (pcpp->MenuItemHandle == hHTMLConvMenuItem) { + if (db_get_b(hContact, MODULENAME, "HTMLConv", 0)) + mi.flags |= CMIM_FLAGS | CMIF_CHECKED; else - mi.flags = CMIM_FLAGS|(mi.flags &~CMIF_CHECKED); + mi.flags = CMIM_FLAGS | (mi.flags &~CMIF_CHECKED); CallService(MO_MODIFYMENUITEM, (WPARAM)hHTMLConvMenuItem, (LPARAM)&mi); } } return TRUE; } -INT_PTR FreeOwnerDataMirOTRMenu (WPARAM, LPARAM lParam) +INT_PTR FreeOwnerDataMirOTRMenu(WPARAM, LPARAM lParam) { - lpMirOTRMenuExecParam cmep = ( lpMirOTRMenuExecParam )lParam; - if ( cmep != NULL ) { + lpMirOTRMenuExecParam cmep = (lpMirOTRMenuExecParam)lParam; + if (cmep != NULL) { if (cmep->szServiceName) mir_free(cmep->szServiceName); mir_free(cmep); } return 0; } -INT_PTR OnAddMenuItemMirOTRMenu (WPARAM wParam, LPARAM lParam) +INT_PTR OnAddMenuItemMirOTRMenu(WPARAM wParam, LPARAM lParam) { MENUITEMINFO *mii = (MENUITEMINFO*)wParam; if (!mii || mii->cbSize != sizeof(MENUITEMINFO)) return 0; - - TMO_MenuItem mi; - mi.cbSize = sizeof(mi); - if ( CallService(MO_GETMENUITEM, (WPARAM)lParam, (LPARAM)&mi) == 0) { + + TMO_MenuItem mi; + if (CallService(MO_GETMENUITEM, (WPARAM)lParam, (LPARAM)&mi) == 0) { if (mi.flags & CMIF_DISABLED) { mii->fMask |= MIIM_STATE; mii->fState |= MF_DISABLED; @@ -165,11 +163,9 @@ INT_PTR OnAddMenuItemMirOTRMenu (WPARAM wParam, LPARAM lParam) return 1; } - LRESULT CALLBACK PopupMenuWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (message) - { + switch (message) { case WM_MEASUREITEM: if (CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam)) return TRUE; break; @@ -179,12 +175,13 @@ LRESULT CALLBACK PopupMenuWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM case WM_COMMAND: if (CallService(MO_PROCESSCOMMANDBYMENUIDENT, wParam, GetWindowLongPtr(hwnd, GWLP_USERDATA))) return TRUE; break; - } - return DefWindowProc(hwnd, message, wParam, lParam); + } + return DefWindowProc(hwnd, message, wParam, lParam); } -void ShowOTRMenu(MCONTACT hContact, POINT pt){ - HMENU menu = (HMENU) CallService(MS_MIROTR_MENUBUILDMIROTR, hContact, 0); +void ShowOTRMenu(MCONTACT hContact, POINT pt) +{ + HMENU menu = (HMENU)CallService(MS_MIROTR_MENUBUILDMIROTR, hContact, 0); SetWindowLongPtr(hDummyPaintWin, GWLP_USERDATA, (LONG_PTR)hContact); TrackPopupMenu(menu, 0, pt.x, pt.y, 0, hDummyPaintWin, 0); DestroyMenu(menu); @@ -192,23 +189,23 @@ void ShowOTRMenu(MCONTACT hContact, POINT pt){ void InitMirOTRMenu(void) { - WNDCLASS wc = {0}; + WNDCLASS wc = { 0 }; wc.hInstance = hInst; wc.lpfnWndProc = PopupMenuWndProc; wc.lpszClassName = _T("MirOTRPopupMenuProcessor"); RegisterClass(&wc); hDummyPaintWin = CreateWindowEx(0, _T("MirOTRPopupMenuProcessor"), NULL, 0, 0, 0, 1, 1, 0, 0, hInst, 0); - CreateServiceFunction("MirOTRMenuExecService",MirOTRMenuExecService); - CreateServiceFunction("MirOTRMenuCheckService",MirOTRMenuCheckService); + CreateServiceFunction("MirOTRMenuExecService", MirOTRMenuExecService); + CreateServiceFunction("MirOTRMenuCheckService", MirOTRMenuCheckService); // menu object - CreateServiceFunction("MIROTRMENUS/FreeOwnerDataMirOTRMenu",FreeOwnerDataMirOTRMenu); - CreateServiceFunction("MIROTRMENUS/OnAddMenuItemMirOTRMenu",OnAddMenuItemMirOTRMenu); + CreateServiceFunction("MIROTRMENUS/FreeOwnerDataMirOTRMenu", FreeOwnerDataMirOTRMenu); + CreateServiceFunction("MIROTRMENUS/OnAddMenuItemMirOTRMenu", OnAddMenuItemMirOTRMenu); - CreateServiceFunction(MS_MIROTR_ADDMIROTRMENUITEM,AddMirOTRMenuItem); - CreateServiceFunction(MS_MIROTR_MENUBUILDMIROTR,BuildMirOTRMenu); - CreateServiceFunction(MS_MIROTR_REMOVEMIROTRMENUITEM,RemoveMirOTRMenuItem); + CreateServiceFunction(MS_MIROTR_ADDMIROTRMENUITEM, AddMirOTRMenuItem); + CreateServiceFunction(MS_MIROTR_MENUBUILDMIROTR, BuildMirOTRMenu); + CreateServiceFunction(MS_MIROTR_REMOVEMIROTRMENUITEM, RemoveMirOTRMenuItem); hMirOTRMenuObject = MO_CreateMenuObject("MirOTRMenu", LPGEN("MirOTR menu"), "MirOTRMenuCheckService", "MirOTRMenuExecService"); MO_SetMenuObjectParam(hMirOTRMenuObject, OPT_USERDEFINEDITEMS, FALSE); @@ -216,47 +213,47 @@ void InitMirOTRMenu(void) MO_SetMenuObjectParam(hMirOTRMenuObject, OPT_MENUOBJECT_SET_ONADD_SERVICE, "MIROTRMENUS/OnAddMenuItemMirOTRMenu"); // menu items - MIROTRMENUITEM mi = {0}; + MIROTRMENUITEM mi = { 0 }; mi.cbSize = sizeof(mi); mi.flags = CMIF_DISABLED | CMIF_TCHAR; mi.ptszName = LPGENT("OTR Status"); mi.position = 0; - hStatusInfoItem = (HGENMENU) AddMirOTRMenuItem(0, (LPARAM) &mi); + hStatusInfoItem = (HGENMENU)AddMirOTRMenuItem(0, (LPARAM)&mi); mi.flags = CMIF_TCHAR | CMIF_NOTPRIVATE | CMIF_NOTUNVERIFIED; mi.ptszName = LANG_MENU_START; mi.position = 100001; mi.pszService = MS_OTR_MENUSTART; mi.icolibItem = IcoLib_GetIconHandle(ICON_UNVERIFIED); - AddMirOTRMenuItem(0, (LPARAM) &mi); + AddMirOTRMenuItem(0, (LPARAM)&mi); mi.flags = CMIF_TCHAR | CMIF_NOTNOTPRIVATE | CMIF_NOTFINISHED; mi.ptszName = LANG_MENU_REFRESH; mi.position = 100002; mi.pszService = MS_OTR_MENUREFRESH; mi.icolibItem = IcoLib_GetIconHandle(ICON_FINISHED); - AddMirOTRMenuItem(0, (LPARAM) &mi); + AddMirOTRMenuItem(0, (LPARAM)&mi); mi.flags = CMIF_TCHAR | CMIF_NOTNOTPRIVATE; mi.ptszName = LANG_MENU_STOP; mi.position = 100003; mi.pszService = MS_OTR_MENUSTOP; mi.icolibItem = IcoLib_GetIconHandle(ICON_NOT_PRIVATE); - AddMirOTRMenuItem(0, (LPARAM) &mi); + AddMirOTRMenuItem(0, (LPARAM)&mi); mi.flags = CMIF_TCHAR | CMIF_NOTNOTPRIVATE | CMIF_NOTFINISHED; mi.ptszName = LANG_MENU_VERIFY; mi.position = 200001; mi.pszService = MS_OTR_MENUVERIFY; mi.icolibItem = IcoLib_GetIconHandle(ICON_PRIVATE); - AddMirOTRMenuItem(0, (LPARAM) &mi); + AddMirOTRMenuItem(0, (LPARAM)&mi); - mi.flags = CMIF_TCHAR|CMIF_CHECKED; + mi.flags = CMIF_TCHAR | CMIF_CHECKED; mi.ptszName = LANG_MENU_TOGGLEHTML; mi.position = 300001; mi.pszService = MS_OTR_MENUTOGGLEHTML; - hHTMLConvMenuItem = (HGENMENU) AddMirOTRMenuItem(0, (LPARAM) &mi); + hHTMLConvMenuItem = (HGENMENU)AddMirOTRMenuItem(0, (LPARAM)&mi); } void UninitMirOTRMenu(void) @@ -264,6 +261,6 @@ void UninitMirOTRMenu(void) DestroyWindow(hDummyPaintWin); hDummyPaintWin = 0; UnregisterClass(_T("MirOTRPopupMenuProcessor"), hInst); - if ( hMirOTRMenuObject ) CallService(MO_REMOVEMENUOBJECT, (WPARAM)hMirOTRMenuObject, 0 ); + if (hMirOTRMenuObject) CallService(MO_REMOVEMENUOBJECT, (WPARAM)hMirOTRMenuObject, 0); hMirOTRMenuObject = 0; } diff --git a/protocols/Gadu-Gadu/src/links.cpp b/protocols/Gadu-Gadu/src/links.cpp index 4cb99e7a47..deff5e16c0 100644 --- a/protocols/Gadu-Gadu/src/links.cpp +++ b/protocols/Gadu-Gadu/src/links.cpp @@ -112,12 +112,11 @@ void gg_links_instancemenu_init() CreateServiceFunction(GGS_MENUCHOOSE, gg_menuchoose);
hInstanceMenu = MO_CreateMenuObject("GGAccountChooser", LPGEN("Gadu-Gadu account chooser"), 0, GGS_MENUCHOOSE);
- TMO_MenuItem tmi = {0};
- tmi.cbSize = sizeof(tmi);
- tmi.pszName = "Cancel";
- tmi.position = 9999999;
- tmi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE);
- CallService(MO_ADDNEWMENUITEM, (WPARAM)hInstanceMenu, (LPARAM)&tmi);
+ TMO_MenuItem mi = {0};
+ mi.name.a = "Cancel";
+ mi.position = 9999999;
+ mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE);
+ CallService(MO_ADDNEWMENUITEM, (WPARAM)hInstanceMenu, (LPARAM)&mi);
}
void gg_links_init()
@@ -131,11 +130,11 @@ void gg_links_init() void GGPROTO::links_instance_init()
{
if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
- TMO_MenuItem tmi = { sizeof(tmi) };
- tmi.flags = CMIF_TCHAR;
- tmi.ownerdata = this;
- tmi.position = g_Instances.getCount();
- tmi.ptszName = m_tszUserName;
- hInstanceMenuItem = (HGENMENU)CallService(MO_ADDNEWMENUITEM, (WPARAM)hInstanceMenu, (LPARAM)&tmi);
+ TMO_MenuItem mi = { 0 };
+ mi.flags = CMIF_TCHAR;
+ mi.ownerdata = this;
+ mi.position = g_Instances.getCount();
+ mi.name.t = m_tszUserName;
+ hInstanceMenuItem = (HGENMENU)CallService(MO_ADDNEWMENUITEM, (WPARAM)hInstanceMenu, (LPARAM)&mi);
}
}
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index bc8841eeee..3ba484b46c 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -188,7 +188,7 @@ void g_MenuInit(void) hChooserMenu = MO_CreateMenuObject("JabberAccountChooser", LPGEN("Jabber account chooser"), 0, "Jabber/MenuChoose");
TMO_MenuItem tmi = { sizeof(tmi) };
- tmi.pszName = "Cancel";
+ tmi.name.a = "Cancel";
tmi.position = 9999999;
tmi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE);
CallService(MO_ADDNEWMENUITEM, (WPARAM)hChooserMenu, (LPARAM)&tmi);
@@ -818,7 +818,7 @@ void CJabberProto::GlobalMenuInit() tmi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
tmi.ownerdata = this;
tmi.position = iChooserMenuPos++;
- tmi.ptszName = m_tszUserName;
+ tmi.name.t = m_tszUserName;
m_hChooseMenuItem = (HGENMENU)CallService(MO_ADDNEWMENUITEM, (WPARAM)hChooserMenu, (LPARAM)&tmi);
//////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp index 4cf60f4414..069f55920c 100644 --- a/src/mir_app/src/clistmenus.cpp +++ b/src/mir_app/src/clistmenus.cpp @@ -202,7 +202,7 @@ static INT_PTR AddMainMenuItem(WPARAM, LPARAM lParam) //we need just one parametr.
mmep->szServiceName = mir_strdup(mi->pszService);
mmep->Param1 = mi->popupPosition;
- mmep->szMenuName = tmi.ptszName;
+ mmep->szMenuName = tmi.name.t;
tmi.ownerdata = mmep;
PMO_IntMenuItem pimi = MO_AddNewMenuItem(hMainMenuObject, &tmi);
@@ -441,7 +441,7 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) if (timiParent) {
CLISTMENUITEM mi2 = { sizeof(mi2) };
mi2.flags = CMIM_NAME | CMIF_TCHAR;
- mi2.ptszName = TranslateTH(timi->mi.hLangpack, timi->mi.hIcon ? timi->mi.ptszName : LPGENT("Custom status"));
+ mi2.ptszName = TranslateTH(timi->mi.hLangpack, timi->mi.hIcon ? timi->mi.name.t : LPGENT("Custom status"));
timiParent = MO_GetIntMenuItem(timi->mi.root);
@@ -484,14 +484,14 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) else
timi->mi.flags &= ~CMIF_CHECKED;
}
- else if ((!smep || smep->proto) && timi->mi.pszName) {
+ else if ((!smep || smep->proto) && timi->mi.name.a) {
int curProtoStatus = 0;
BOOL IconNeedDestroy = FALSE;
char* prot;
if (smep)
prot = smep->proto;
else {
- char *prn = mir_u2a(timi->mi.ptszName);
+ char *prn = mir_u2a(timi->mi.name.t);
prot = NEWSTR_ALLOCA(prn);
if (prn) mir_free(prn);
}
@@ -564,8 +564,8 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) ptszName = acc->tszAccountName;
pimi->mi.flags &= ~CMIF_CHECKED;
}
- replaceStrT(pimi->mi.ptszName, ptszName);
- replaceStrT(root->mi.ptszName, ptszName);
+ replaceStrT(pimi->mi.name.t, ptszName);
+ replaceStrT(root->mi.name.t, ptszName);
if (cli.hwndStatus)
InvalidateRect(cli.hwndStatus, NULL, TRUE);
@@ -851,16 +851,15 @@ void RebuildMenuOrder(void) //adding root
TMO_MenuItem tmi = { 0 };
- tmi.cbSize = sizeof(tmi);
tmi.flags = CMIF_TCHAR | CMIF_ROOTHANDLE | CMIF_KEEPUNTRANSLATED;
tmi.position = pos++;
tmi.hIcon = ic = (HICON)CallProtoServiceInt(NULL, pa->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
if (Proto_IsAccountLocked(pa) && cli.bDisplayLocked) {
mir_sntprintf(tbuf, _countof(tbuf), TranslateT("%s (locked)"), pa->tszAccountName);
- tmi.ptszName = tbuf;
+ tmi.name.t = tbuf;
}
- else tmi.ptszName = pa->tszAccountName;
+ else tmi.name.t = pa->tszAccountName;
//owner data
StatusMenuExecParam *smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
@@ -870,7 +869,6 @@ void RebuildMenuOrder(void) PMO_IntMenuItem rootmenu = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
memset(&tmi, 0, sizeof(tmi));
- tmi.cbSize = sizeof(tmi);
tmi.flags = CMIF_TCHAR | CMIF_ROOTHANDLE | CMIF_KEEPUNTRANSLATED;
tmi.root = rootmenu;
tmi.position = pos++;
@@ -886,9 +884,9 @@ void RebuildMenuOrder(void) if ((tmi.flags & CMIF_CHECKED) && cli.bDisplayLocked) {
mir_sntprintf(tbuf, _countof(tbuf), TranslateT("%s (locked)"), pa->tszAccountName);
- tmi.ptszName = tbuf;
+ tmi.name.t = tbuf;
}
- else tmi.ptszName = pa->tszAccountName;
+ else tmi.name.t = pa->tszAccountName;
PMO_IntMenuItem menuHandle = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
((StatusMenuExecParam*)tmi.ownerdata)->protoindex = (int)menuHandle;
@@ -914,13 +912,12 @@ void RebuildMenuOrder(void) // adding
memset(&tmi, 0, sizeof(tmi));
- tmi.cbSize = sizeof(tmi);
tmi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
if (statusModeList[j] == ID_STATUS_OFFLINE)
tmi.flags |= CMIF_CHECKED;
tmi.root = rootmenu;
tmi.position = pos++;
- tmi.ptszName = cli.pfnGetStatusModeDescription(statusModeList[j], GSMDF_UNTRANSLATED);
+ tmi.name.t = cli.pfnGetStatusModeDescription(statusModeList[j], GSMDF_UNTRANSLATED);
tmi.hIcon = Skin_LoadProtoIcon(pa->szModuleName, statusModeList[j]);
// owner data
@@ -936,7 +933,7 @@ void RebuildMenuOrder(void) hStatusMenuHandles[i].menuhandle[j] = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
char buf[256];
- mir_snprintf(buf, "ProtocolIcon_%s_%s", pa->szModuleName, tmi.pszName);
+ mir_snprintf(buf, "ProtocolIcon_%s_%s", pa->szModuleName, tmi.name.a);
MO_SetOptionsMenuItem(hStatusMenuHandles[i].menuhandle[j], OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);
IcoLib_ReleaseIcon(tmi.hIcon);
@@ -976,13 +973,13 @@ 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.ptszName = buf;
+ tmi.name.t = buf;
tmi.hotKey = MAKELONG(HIBYTE(hotKey), LOBYTE(hotKey));
hStatusMainMenuHandles[j] = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
}
char buf[256];
- mir_snprintf(buf, "Root2ProtocolIcon_%s_%s", pa->szModuleName, tmi.pszName);
+ mir_snprintf(buf, "Root2ProtocolIcon_%s_%s", pa->szModuleName, tmi.name.a);
MO_SetOptionsMenuItem(hStatusMainMenuHandles[j], OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);
IcoLib_ReleaseIcon(tmi.hIcon);
@@ -1005,7 +1002,7 @@ static int sttRebuildHotkeys(WPARAM, LPARAM) 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);
- tmi.ptszName = buf;
+ tmi.name.t = buf;
tmi.hotKey = MAKELONG(HIBYTE(hotKey), LOBYTE(hotKey));
MO_ModifyMenuItem(hStatusMainMenuHandles[j], &tmi);
}
@@ -1106,12 +1103,11 @@ int fnConvertMenu(CLISTMENUITEM *mi, TMO_MenuItem *pmi) return FALSE;
memset(pmi, 0, sizeof(TMO_MenuItem));
- pmi->cbSize = sizeof(TMO_MenuItem);
pmi->root = mi->hParentMenu;
pmi->flags = mi->flags;
pmi->hIcon = mi->hIcon;
pmi->hotKey = mi->hotKey;
- pmi->pszName = mi->pszName;
+ pmi->name.a = mi->pszName;
pmi->position = mi->position;
pmi->hLangpack = mi->hLangpack;
return TRUE;
@@ -1164,12 +1160,11 @@ static INT_PTR AddStatusMenuItem(WPARAM wParam, LPARAM lParam) }
if (pRoot == NULL) {
TMO_MenuItem tmi = { 0 };
- tmi.cbSize = sizeof(tmi);
tmi.flags = (mi->flags & CMIF_UNICODE) | CMIF_ROOTHANDLE;
tmi.position = 1001;
tmi.root = mp->pMenu;
tmi.hIcon = NULL;
- tmi.pszName = mi->pszPopupName;
+ tmi.name.a = mi->pszPopupName;
pRoot = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
}
@@ -1205,7 +1200,7 @@ static INT_PTR AddStatusMenuItem(WPARAM wParam, LPARAM lParam) smep->hMenuItem = menuHandle;
char buf[MAX_PATH + 64];
- char *p = (pRoot) ? mir_t2a(pRoot->mi.ptszName) : NULL;
+ char *p = (pRoot) ? mir_t2a(pRoot->mi.name.t) : NULL;
mir_snprintf(buf, "%s/%s", (p) ? p : "", mi->pszService ? mi->pszService : "");
mir_free(p);
diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp index 4920542b06..ac481b7407 100644 --- a/src/mir_app/src/genmenu.cpp +++ b/src/mir_app/src/genmenu.cpp @@ -39,7 +39,7 @@ static void DumpMenuItem(TMO_IntMenuItem* pParent, int level = 0) temp[ level ] = 0;
for (PMO_IntMenuItem pimi = pParent; pimi != NULL; pimi = pimi->next) {
- Netlib_Logf(NULL, "%sMenu item %08p [%08p]: %S", temp, pimi, pimi->mi.root, pimi->mi.ptszName);
+ Netlib_Logf(NULL, "%sMenu item %08p [%08p]: %S", temp, pimi, pimi->mi.root, pimi->mi.name.t);
PMO_IntMenuItem submenu = pimi->submenu.first;
if (submenu)
@@ -79,9 +79,9 @@ int GetMenuObjbyId(const int id) LPTSTR GetMenuItemText(PMO_IntMenuItem pimi)
{
if (pimi->mi.flags & CMIF_KEEPUNTRANSLATED)
- return pimi->mi.ptszName;
+ return pimi->mi.name.t;
- return TranslateTH(pimi->mi.hLangpack, pimi->mi.ptszName);
+ return TranslateTH(pimi->mi.hLangpack, pimi->mi.name.t);
}
///////////////////////////////////////////////////////////////////////////////
@@ -266,7 +266,7 @@ INT_PTR MO_GetProtoRootMenu(WPARAM wParam, LPARAM) // lparam = PMO_MenuItem
INT_PTR MO_GetMenuItem(WPARAM wParam, LPARAM lParam)
{
- PMO_MenuItem mi = (PMO_MenuItem)lParam;
+ TMO_MenuItem *mi = (TMO_MenuItem*)lParam;
if (!bIsGenMenuInited || mi == NULL)
return -1;
@@ -301,11 +301,11 @@ INT_PTR MO_GetDefaultMenuItem(WPARAM wParam, LPARAM) // wparam MenuItemHandle
// lparam PMO_MenuItem
-int MO_ModifyMenuItem(PMO_IntMenuItem menuHandle, PMO_MenuItem pmi)
+int MO_ModifyMenuItem(PMO_IntMenuItem menuHandle, TMO_MenuItem *pmi)
{
int oldflags;
- if (!bIsGenMenuInited || pmi == NULL || pmi->cbSize != sizeof(TMO_MenuItem))
+ if (!bIsGenMenuInited || pmi == NULL)
return -1;
mir_cslock lck(csMenuHook);
@@ -315,12 +315,12 @@ int MO_ModifyMenuItem(PMO_IntMenuItem menuHandle, PMO_MenuItem pmi) return -1;
if (pmi->flags & CMIM_NAME) {
- FreeAndNil((void**)&pimi->mi.pszName);
+ FreeAndNil((void**)&pimi->mi.name.t);
if (pmi->flags & CMIF_UNICODE)
- pimi->mi.ptszName = mir_tstrdup(pmi->ptszName);
+ pimi->mi.name.t = mir_tstrdup(pmi->name.t);
else
- pimi->mi.ptszName = mir_a2t(pmi->pszName);
+ pimi->mi.name.t = mir_a2t(pmi->name.a);
}
if (pmi->flags & CMIM_FLAGS) {
@@ -631,9 +631,9 @@ static int GetNextObjectMenuItemId() // lparam = PMO_MenuItem
// return MenuItemHandle
-PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi)
+PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi)
{
- if (!bIsGenMenuInited || pmi == NULL || pmi->cbSize != sizeof(TMO_MenuItem))
+ if (!bIsGenMenuInited || pmi == NULL)
return NULL;
// old mode
@@ -658,9 +658,9 @@ PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi) p->hLangpack = pmi->hLangpack;
if (pmi->flags & CMIF_UNICODE)
- p->mi.ptszName = mir_tstrdup(pmi->ptszName);
+ p->mi.name.t = mir_tstrdup(pmi->name.t);
else
- p->mi.ptszName = mir_a2u(pmi->pszName);
+ p->mi.name.t = mir_a2u(pmi->name.a);
if (pmi->hIcon != NULL && !bIconsDisabled) {
HANDLE hIcolibItem = IcoLib_IsManaged(pmi->hIcon);
@@ -696,14 +696,14 @@ PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi) int FindRoot(PMO_IntMenuItem pimi, void* param)
{
- if (pimi->mi.pszName != NULL)
- if (pimi->submenu.first && !mir_tstrcmp(pimi->mi.ptszName, (TCHAR*)param))
+ if (pimi->mi.name.t != NULL)
+ if (pimi->submenu.first && !mir_tstrcmp(pimi->mi.name.t, (TCHAR*)param))
return TRUE;
return FALSE;
}
-PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi)
+PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi)
{
if (!bIsGenMenuInited || pmi == NULL)
return NULL;
@@ -712,9 +712,6 @@ PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi) if (objidx == -1)
return NULL;
- if (pmi->cbSize != sizeof(TMO_MenuItem))
- return NULL;
-
if (pmi->flags & CMIF_ROOTHANDLE)
return NULL;
@@ -740,7 +737,7 @@ PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi) tmi.ownerdata = 0;
tmi.root = NULL;
// copy pszPopupName
- tmi.ptszName = (TCHAR*)pmi->root;
+ tmi.name.t = (TCHAR*)pmi->root;
if ((oldroot = MO_AddNewMenuItem(menuobjecthandle, &tmi)) != NULL)
MO_SetOptionsMenuItem(oldroot, OPT_MENUITEMSETUNIQNAME, (INT_PTR)pmi->root);
}
@@ -753,7 +750,7 @@ PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi) return MO_AddNewMenuItem(menuobjecthandle, pmi);
}
-static int WhereToPlace(HMENU hMenu, PMO_MenuItem mi)
+static int WhereToPlace(HMENU hMenu, TMO_MenuItem *mi)
{
MENUITEMINFO mii = { sizeof(mii) };
mii.fMask = MIIM_SUBMENU | MIIM_DATA;
@@ -874,9 +871,9 @@ void GetMenuItemName(PMO_IntMenuItem pMenuItem, char* pszDest, size_t cbDestSize if (pMenuItem->UniqName)
mir_snprintf(pszDest, cbDestSize, "{%s}", pMenuItem->UniqName);
else if (pMenuItem->mi.flags & CMIF_UNICODE)
- mir_snprintf(pszDest, cbDestSize, "{%s}", (char*)_T2A(pMenuItem->mi.ptszName));
+ mir_snprintf(pszDest, cbDestSize, "{%s}", (char*)_T2A(pMenuItem->mi.name.t));
else
- mir_snprintf(pszDest, cbDestSize, "{%s}", pMenuItem->mi.pszName);
+ mir_snprintf(pszDest, cbDestSize, "{%s}", pMenuItem->mi.name.t);
}
HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *param)
@@ -894,10 +891,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para DeleteMenu(hMenu, 0, MF_BYPOSITION);
for (PMO_IntMenuItem pmi = pRootMenu; pmi != NULL; pmi = pmi->next) {
- PMO_MenuItem mi = &pmi->mi;
- if (mi->cbSize != sizeof(TMO_MenuItem))
- continue;
-
+ TMO_MenuItem *mi = &pmi->mi;
if (mi->flags & CMIF_HIDDEN)
continue;
@@ -933,7 +927,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para continue; // find out what value to return if not getting added
}
- // mi.pszName
+ // mi.name.t
mir_snprintf(DBString, _countof(DBString), "%s_name", menuItemName);
if (!db_get_ts(NULL, MenuNameItems, DBString, &dbv)) {
if (mir_tstrlen(dbv.ptszVal) > 0)
@@ -976,7 +970,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para if (pmi->mi.flags & CMIF_DEFAULT)
mii.fState |= MFS_DEFAULT;
- mii.dwTypeData = (pmi->CustomName) ? pmi->CustomName : mi->ptszName;
+ mii.dwTypeData = (pmi->CustomName) ? pmi->CustomName : mi->name.t;
// it's a submenu
if (pmi->submenu.first) {
@@ -986,7 +980,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para #ifdef PUTPOSITIONSONMENU
if (GetKeyState(VK_CONTROL) & 0x8000) {
TCHAR str[256];
- mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData);
+ mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->name.a, mi->position, mii.dwItemData);
mii.dwTypeData = str;
}
#endif
@@ -1001,7 +995,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para #ifdef PUTPOSITIONSONMENU
if (GetKeyState(VK_CONTROL) & 0x8000) {
TCHAR str[256];
- mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData);
+ mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->name.a, mi->position, mii.dwItemData);
mii.dwTypeData = str;
}
#endif
@@ -1228,7 +1222,7 @@ void TIntMenuObject::freeItem(TMO_IntMenuItem *p) CallService(FreeService, (WPARAM)p, (LPARAM)p->mi.ownerdata);
p->signature = 0;
- FreeAndNil((void**)&p->mi.pszName);
+ FreeAndNil((void**)&p->mi.name.t);
FreeAndNil((void**)&p->UniqName);
FreeAndNil((void**)&p->CustomName);
if (p->hBmp) DeleteObject(p->hBmp);
diff --git a/src/mir_app/src/genmenu.h b/src/mir_app/src/genmenu.h index 198d5417bc..1c129f2197 100644 --- a/src/mir_app/src/genmenu.h +++ b/src/mir_app/src/genmenu.h @@ -104,12 +104,12 @@ void GetMenuItemName(PMO_IntMenuItem pMenuItem, char* pszDest, size_t cbDestSize PMO_IntMenuItem MO_GetIntMenuItem(HGENMENU);
-PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi);
-PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi);
+PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi);
+PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi);
int MO_DrawMenuItem(LPDRAWITEMSTRUCT dis);
int MO_MeasureMenuItem(LPMEASUREITEMSTRUCT mis);
-int MO_ModifyMenuItem(PMO_IntMenuItem menuHandle, PMO_MenuItem pmiparam);
+int MO_ModifyMenuItem(PMO_IntMenuItem menuHandle, TMO_MenuItem *pmiparam);
int MO_ProcessCommand(PMO_IntMenuItem pimi, LPARAM lParam);
INT_PTR MO_ProcessHotKeys(HANDLE menuHandle, INT_PTR vKey);
int MO_SetOptionsMenuItem(PMO_IntMenuItem menuobjecthandle, int setting, INT_PTR value);
|