diff options
author | George Hazan <george.hazan@gmail.com> | 2013-09-24 19:22:39 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-09-24 19:22:39 +0000 |
commit | 19ab68c3d146d0d0dc24e9c8153e90d218395209 (patch) | |
tree | 0e5a8d34a25dafa1d1fb71cddd9e5d7528c116e1 /protocols/GTalkExt/src/menu.cpp | |
parent | fb190494fe8550288e5c8741bebec9ab0f58284e (diff) |
GTalkExt: contact list contact restored
git-svn-id: http://svn.miranda-ng.org/main/trunk@6214 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/GTalkExt/src/menu.cpp')
-rw-r--r-- | protocols/GTalkExt/src/menu.cpp | 72 |
1 files changed, 56 insertions, 16 deletions
diff --git a/protocols/GTalkExt/src/menu.cpp b/protocols/GTalkExt/src/menu.cpp index 31aa364710..6cbe2f2209 100644 --- a/protocols/GTalkExt/src/menu.cpp +++ b/protocols/GTalkExt/src/menu.cpp @@ -26,32 +26,72 @@ #include "inbox.h"
static const LPSTR MS_GTALKEXT_OPENMAILBOX = SHORT_PLUGIN_NAME "/OpenMailbox";
+static const LPTSTR _T(OPEN_MAILBOX_ITEM_CAPTION) = LPGENT("Open mailbox");
extern HICON g_hPopupIcon;
-INT_PTR OpenMailboxMenuHandler(WPARAM wParam, LPARAM lParam, LPARAM param)
+HANDLE hOpenMailboxService = 0;
+HANDLE hOnPrebuildMenu = 0;
+
+HGENMENU hOpenMailboxMenuItem = 0;
+
+INT_PTR OpenMailboxMenuHandler(WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hContact = (HANDLE)wParam;
+ if (db_get_b(hContact, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0))
+ OpenContactInbox(hContact);
+ return 0;
+}
+
+int OnPrebuildMenu(WPARAM wParam, LPARAM lParam)
{
- OpenContactInbox((LPCSTR)param);
+ CLISTMENUITEM cmi = { sizeof(cmi) };
+ cmi.flags = CMIM_FLAGS;
+ if (!db_get_b((HANDLE)wParam, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0))
+ cmi.flags |= CMIF_HIDDEN;
+ Menu_ModifyItem(hOpenMailboxMenuItem, &cmi);
return 0;
}
-int InitMenus(WPARAM wParam, LPARAM lParam)
+BOOL InitMenus(BOOL init)
{
- IJabberInterface *ji = (IJabberInterface*)lParam;
- LPCSTR szModuleName = ji->Sys()->GetModuleName();
- if ( IsGoogleAccount(szModuleName)) {
- char szServiceName[100];
- mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s/%s", szModuleName, MS_GTALKEXT_OPENMAILBOX);
- CreateServiceFunctionParam(szServiceName, OpenMailboxMenuHandler, (LPARAM)szModuleName);
+ if (init) {
+ hOpenMailboxService = (HANDLE)CreateServiceFunction(MS_GTALKEXT_OPENMAILBOX, OpenMailboxMenuHandler);
+ if (!hOpenMailboxService) {
+ InitMenus(FALSE);
+ return FALSE;
+ }
+
+ extern HICON g_hPopupIcon;
CLISTMENUITEM cmi = { sizeof(cmi) };
- cmi.flags = CMIF_CHILDPOPUP;
- cmi.hParentMenu = HGENMENU(wParam);
+ cmi.flags = CMIF_TCHAR;
cmi.hIcon = g_hPopupIcon;
- cmi.position = 200101;
- cmi.pszName = LPGEN("Open mailbox");
- cmi.pszService = szServiceName;
- Menu_AddProtoMenuItem(&cmi);
+ cmi.ptszName = _T(OPEN_MAILBOX_ITEM_CAPTION);
+ cmi.pszService = MS_GTALKEXT_OPENMAILBOX;
+ hOpenMailboxMenuItem = Menu_AddContactMenuItem(&cmi);
+
+ if (!hOpenMailboxMenuItem) {
+ InitMenus(FALSE);
+ return FALSE;
+ }
+
+ hOnPrebuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPrebuildMenu);
+ if (!hOnPrebuildMenu) {
+ InitMenus(FALSE);
+ return FALSE;
+ }
}
- return 0;
+ else {
+ if (hOnPrebuildMenu) {
+ UnhookEvent(hOnPrebuildMenu);
+ hOnPrebuildMenu = 0;
+ }
+ if (hOpenMailboxService) {
+ DestroyServiceFunction(hOpenMailboxService);
+ hOpenMailboxService = 0;
+ }
+ }
+
+ return TRUE;
}
|