summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-22 12:13:16 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-22 12:13:16 +0000
commit4625aafb053a002f0223bfbe76abfbec629feacf (patch)
tree512f5e5fc5fd6b4d7a79d9b535158d065017f94f /plugins
parent28a3f4e95a93f30155c68aa87198595ca9e100b5 (diff)
minor correction in the internal genmenu structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@14324 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MirOTR/src/mirotrmenu.cpp153
1 files changed, 75 insertions, 78 deletions
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;
}