From d19a80ba02d6b4baab923fc80408e5c878f8c520 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 23 Jun 2013 18:03:02 +0000 Subject: fix for Skype contact's menu git-svn-id: http://svn.miranda-ng.org/main/trunk@5101 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype.h | 16 +++++--- protocols/Skype/src/skype_menus.cpp | 80 ++++++++++--------------------------- protocols/Skype/src/skype_proto.h | 6 +-- 3 files changed, 34 insertions(+), 68 deletions(-) diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h index f5eb253a88..098a5efeb8 100644 --- a/protocols/Skype/src/skype.h +++ b/protocols/Skype/src/skype.h @@ -67,12 +67,16 @@ #define SKYPE_DB_EVENT_TYPE_CONTACTS 10002 #define SKYPE_DB_EVENT_TYPE_CALL 10010 -#define CMI_AUTH_REQUEST 1 -#define CMI_AUTH_GRANT 2 -#define CMI_AUTH_REVOKE 3 -#define CMI_CHAT_BOOKMARK 4 -#define CMI_IGNORE 5 -#define CMI_BLOCK 6 +enum +{ + CMI_AUTH_REQUEST, + CMI_AUTH_GRANT, + CMI_AUTH_REVOKE, + CMI_CHAT_BOOKMARK, + CMI_IGNORE, + CMI_BLOCK, + CMI_MAX // this item shall be the last one +}; #define SMI_CHAT_INVITE 1 #define SMI_CHAT_BOOKMARKS 2 diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp index ee227134a1..5f9b5a4e73 100644 --- a/protocols/Skype/src/skype_menus.cpp +++ b/protocols/Skype/src/skype_menus.cpp @@ -1,7 +1,7 @@ #include "skype.h" -HANDLE CSkypeProto::hChooserMenu; -std::map CSkypeProto::contactMenuItems; +HGENMENU CSkypeProto::hChooserMenu; +HGENMENU CSkypeProto::contactMenuItems[CMI_MAX]; INT_PTR CSkypeProto::MenuChooseService(WPARAM wParam, LPARAM lParam) { @@ -11,37 +11,14 @@ INT_PTR CSkypeProto::MenuChooseService(WPARAM wParam, LPARAM lParam) return 0; } -void CSkypeProto::ShowMenuItem(HANDLE hMenuItem, BOOL show) -{ - CLISTMENUITEM clmi = {0}; - clmi.cbSize = sizeof(CLISTMENUITEM); - clmi.flags = CMIM_FLAGS; - if (!show) - clmi.flags |= CMIF_HIDDEN; - - ::CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuItem, (LPARAM)&clmi); -} - int CSkypeProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) { HANDLE hContact = (HANDLE)wParam; - if (hContact == NULL) return 0; - if ( !this->IsOnline()) - { - if (::db_get_b(hContact, this->m_szModuleName, "IsSkypeOut", 0) > 0) - { - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_REQUEST], false); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_GRANT], false); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_REVOKE], false); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_CHAT_BOOKMARK], false); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_IGNORE], false); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_BLOCK], false); - } + if ( !this->IsOnline() || lstrcmpA( GetContactProto(hContact), m_szModuleName)) return 0; - } if ( !this->IsChatRoom(hContact)) { @@ -51,42 +28,29 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) bool grantNeed = ::db_get_b(hContact, this->m_szModuleName, "Grant", 0) > 0; bool ignored = ::db_get_b(hContact, this->m_szModuleName, "Ignore", 0) > 0; - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_REQUEST], ctrlPressed || authNeed); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_GRANT], ctrlPressed || grantNeed); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || (!grantNeed && !authNeed)); - - { // ignore - CLISTMENUITEM clmi = {0}; - clmi.cbSize = sizeof(CLISTMENUITEM); - clmi.flags = CMIM_FLAGS; + Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_REQUEST], ctrlPressed || authNeed); + Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_GRANT], ctrlPressed || grantNeed); + Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || (!grantNeed && !authNeed)); + Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_BLOCK], ctrlPressed); - if (::db_get_b(hContact, this->m_szModuleName, "Ignore", 0) == 1) - clmi.flags |= CMIF_CHECKED; + CLISTMENUITEM clmi = { sizeof(clmi) }; + clmi.cbSize = sizeof(CLISTMENUITEM); + clmi.flags = CMIM_FLAGS; + if (::db_get_b(hContact, this->m_szModuleName, "Ignore", 0) == 1) + clmi.flags |= CMIF_CHECKED; - ::CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)CSkypeProto::contactMenuItems[CMI_IGNORE], (LPARAM)&clmi); - } - - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_BLOCK], ctrlPressed); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_CHAT_BOOKMARK], false); + ::CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)CSkypeProto::contactMenuItems[CMI_IGNORE], (LPARAM)&clmi); } else { - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_REQUEST], false); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_GRANT], false); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_REVOKE], false); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_IGNORE], false); - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[CMI_BLOCK], false); - - { // bookmark - CLISTMENUITEM clmi = {0}; - clmi.cbSize = sizeof(CLISTMENUITEM); - clmi.flags = CMIM_FLAGS; - - if (this->IsChatRoomBookmarked(hContact)) - clmi.flags |= CMIF_CHECKED; + // bookmark + CLISTMENUITEM clmi = { sizeof(clmi) }; + clmi.flags = CMIM_FLAGS; + + if (this->IsChatRoomBookmarked(hContact)) + clmi.flags |= CMIF_CHECKED; - ::CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)CSkypeProto::contactMenuItems[CMI_CHAT_BOOKMARK], (LPARAM)&clmi); - } + ::CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)CSkypeProto::contactMenuItems[CMI_CHAT_BOOKMARK], (LPARAM)&clmi); } return 0; @@ -206,7 +170,7 @@ INT_PTR CSkypeProto::ShowBookmarksCommand(WPARAM, LPARAM) int CSkypeProto::PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { for (size_t i = 0; i < SIZEOF(CSkypeProto::contactMenuItems); i++) - CSkypeProto::ShowMenuItem(CSkypeProto::contactMenuItems[i], false); + Menu_ShowItem(CSkypeProto::contactMenuItems[i], false); CSkypeProto* ppro = CSkypeProto::GetInstanceByHContact((HANDLE)wParam); return (ppro) ? ppro->OnPrebuildContactMenu(wParam, lParam) : 0; @@ -218,7 +182,7 @@ void CSkypeProto::InitMenus() mnu.cbSize = sizeof(mnu); mnu.name = "SkypeAccountChooser"; mnu.ExecService = "Skype/MenuChoose"; - hChooserMenu = (HANDLE)::CallService(MO_CREATENEWMENUOBJECT, 0, (LPARAM)&mnu); + hChooserMenu = (HGENMENU)::CallService(MO_CREATENEWMENUOBJECT, 0, (LPARAM)&mnu); ////////////////////////////////////////////////////////////////////////////////////// // Contact menu initialization diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 24df7c7e40..3abce98378 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -431,15 +431,13 @@ protected: // menus HGENMENU m_hMenuRoot; - static HANDLE hChooserMenu; - static std::map contactMenuItems; + static HGENMENU hChooserMenu; + static HGENMENU contactMenuItems[CMI_MAX]; virtual int __cdecl RequestAuth(WPARAM, LPARAM); virtual int __cdecl GrantAuth(WPARAM, LPARAM); virtual int __cdecl RevokeAuth(WPARAM, LPARAM); - static void ShowMenuItem(HANDLE hMenuItem, BOOL show); - static INT_PTR MenuChooseService(WPARAM wParam, LPARAM lParam); int __cdecl IgnoreCommand(WPARAM, LPARAM); -- cgit v1.2.3