summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-10 19:11:06 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-10 19:11:06 +0000
commit302abe573a8256d8c813af8f55d436e7b1c1dfb6 (patch)
tree855753b1d37503ac60bbc74563a6c01f3a955f2a
parent24879d15a1e7f0d7bf02bb10b4145aff2f72f585 (diff)
GTalk: old menu restored (in protocol menu)
git-svn-id: http://svn.miranda-ng.org/main/trunk@6431 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/GTalkExt/src/GTalkExt.cpp2
-rw-r--r--protocols/GTalkExt/src/handlers.cpp1
-rw-r--r--protocols/GTalkExt/src/inbox.cpp10
-rw-r--r--protocols/GTalkExt/src/inbox.h4
-rw-r--r--protocols/GTalkExt/src/menu.cpp72
5 files changed, 22 insertions, 67 deletions
diff --git a/protocols/GTalkExt/src/GTalkExt.cpp b/protocols/GTalkExt/src/GTalkExt.cpp
index 120a89bb31..ab4a13bfa2 100644
--- a/protocols/GTalkExt/src/GTalkExt.cpp
+++ b/protocols/GTalkExt/src/GTalkExt.cpp
@@ -89,7 +89,6 @@ extern "C" int __declspec(dllexport) Load(void)
g_hPopupIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_POPUP));
InitAvaUnit(TRUE);
- InitMenus(TRUE);
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
HookEvent(ME_PROTO_ACCLISTCHANGED, AccListChanged);
@@ -104,6 +103,5 @@ extern "C" int __declspec(dllexport) Unload(void)
{
g_accs.destroy();
InitAvaUnit(FALSE);
- InitMenus(FALSE);
return 0;
}
diff --git a/protocols/GTalkExt/src/handlers.cpp b/protocols/GTalkExt/src/handlers.cpp
index fcc08177fc..4643a26275 100644
--- a/protocols/GTalkExt/src/handlers.cpp
+++ b/protocols/GTalkExt/src/handlers.cpp
@@ -474,6 +474,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam)
for (int i=0; i < count; i++)
sttCreateInstance(protos[i]->szModuleName);
+ HookEvent(ME_JABBER_MENUINIT, InitMenus);
HookEvent(ME_POPUP_FILTER, OnFilterPopup);
HookEvent(ME_JABBER_EXTLISTINIT, OnExtListInit);
HookEvent(ME_OPT_INITIALISE, OptionsInitialization);
diff --git a/protocols/GTalkExt/src/inbox.cpp b/protocols/GTalkExt/src/inbox.cpp
index 8e6a6c5625..435c73c9da 100644
--- a/protocols/GTalkExt/src/inbox.cpp
+++ b/protocols/GTalkExt/src/inbox.cpp
@@ -226,13 +226,9 @@ void OpenUrl(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url)
mir_forkthread(ShellExecuteThread, mir_tstrdup(url));
}
-void OpenContactInbox(HANDLE hContact)
+void OpenContactInbox(LPCSTR szModuleName)
{
- LPSTR acc = GetContactProto(hContact);
- if (acc == NULL)
- return;
-
- ptrT tszJid( db_get_tsa(0, acc, "jid"));
+ ptrT tszJid( db_get_tsa(0, szModuleName, "jid"));
if (tszJid == NULL)
return;
@@ -246,5 +242,5 @@ void OpenContactInbox(HANDLE hContact)
mir_sntprintf(buf, SIZEOF(buf), INBOX_URL_FORMAT, _T("a/"), host); // hosted
else
mir_sntprintf(buf, SIZEOF(buf), INBOX_URL_FORMAT, _T(""), _T("mail")); // common
- OpenUrl(acc, tszJid, buf);
+ OpenUrl(szModuleName, tszJid, buf);
}
diff --git a/protocols/GTalkExt/src/inbox.h b/protocols/GTalkExt/src/inbox.h
index 54c3686155..2ddf4709e6 100644
--- a/protocols/GTalkExt/src/inbox.h
+++ b/protocols/GTalkExt/src/inbox.h
@@ -22,6 +22,6 @@
#pragma once
void OpenUrl(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url);
-void OpenContactInbox(HANDLE hContact);
+void OpenContactInbox(LPCSTR);
-BOOL InitMenus(BOOL init); \ No newline at end of file
+int InitMenus(WPARAM, LPARAM); \ No newline at end of file
diff --git a/protocols/GTalkExt/src/menu.cpp b/protocols/GTalkExt/src/menu.cpp
index 28f84ddb8b..7d09ec15fa 100644
--- a/protocols/GTalkExt/src/menu.cpp
+++ b/protocols/GTalkExt/src/menu.cpp
@@ -26,72 +26,32 @@
#include "inbox.h"
#define MS_GTALKEXT_OPENMAILBOX SHORT_PLUGIN_NAME "/OpenMailbox"
-#define OPEN_MAILBOX_ITEM_CAPTION LPGENT("Open mailbox")
extern HICON g_hPopupIcon;
-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)
+INT_PTR OpenMailboxMenuHandler(WPARAM wParam, LPARAM lParam, LPARAM 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);
+ OpenContactInbox((LPCSTR)param);
return 0;
}
-BOOL InitMenus(BOOL init)
+int InitMenus(WPARAM wParam, LPARAM lParam)
{
- if (init) {
- hOpenMailboxService = (HANDLE)CreateServiceFunction(MS_GTALKEXT_OPENMAILBOX, OpenMailboxMenuHandler);
- if (!hOpenMailboxService) {
- InitMenus(FALSE);
- return FALSE;
- }
-
- extern HICON g_hPopupIcon;
+ GoogleTalkAcc* pga = isGoogle(lParam);
+ if (pga != NULL) {
+ LPCSTR szModuleName = pga->m_japi->GetModuleName();
+ char szServiceName[100];
+ mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s/%s", szModuleName, MS_GTALKEXT_OPENMAILBOX);
+ CreateServiceFunctionParam(szServiceName, OpenMailboxMenuHandler, (LPARAM)szModuleName);
CLISTMENUITEM cmi = { sizeof(cmi) };
- cmi.flags = CMIF_TCHAR;
+ cmi.flags = CMIF_CHILDPOPUP;
+ cmi.hParentMenu = HGENMENU(wParam);
cmi.hIcon = g_hPopupIcon;
- cmi.ptszName = 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;
- }
+ cmi.position = 200101;
+ cmi.pszName = LPGEN("Open mailbox");
+ cmi.pszService = szServiceName;
+ Menu_AddProtoMenuItem(&cmi);
}
- else {
- if (hOnPrebuildMenu) {
- UnhookEvent(hOnPrebuildMenu);
- hOnPrebuildMenu = 0;
- }
- if (hOpenMailboxService) {
- DestroyServiceFunction(hOpenMailboxService);
- hOpenMailboxService = 0;
- }
- }
-
- return TRUE;
+ return 0;
}