summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-25 20:37:12 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-25 20:37:12 +0000
commit5a3fa95fbe1930c035cd1adffee0792b7d1d8846 (patch)
tree017dfe1d07b1dc16bddf1aa77e85eb19d385f551
parent3d411171eba820bffa2998f2442c197a553153f4 (diff)
GTalk menu item is inserted now into the Jabber protocol menu
git-svn-id: http://svn.miranda-ng.org/main/trunk@4190 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_jabber.h11
-rw-r--r--protocols/GTalkExt/src/handlers.cpp2
-rw-r--r--protocols/GTalkExt/src/inbox.cpp6
-rw-r--r--protocols/GTalkExt/src/inbox.h4
-rw-r--r--protocols/GTalkExt/src/menu.cpp32
-rw-r--r--protocols/JabberG/jabber_11.vcxproj1
-rw-r--r--protocols/JabberG/jabber_11.vcxproj.filters3
-rw-r--r--protocols/JabberG/src/jabber_menu.cpp8
8 files changed, 46 insertions, 21 deletions
diff --git a/include/m_jabber.h b/include/m_jabber.h
index d39bc143f7..0e1fe707eb 100644
--- a/include/m_jabber.h
+++ b/include/m_jabber.h
@@ -200,4 +200,15 @@ __forceinline IJabberInterface *getJabberApi(const char *szAccount)
#endif // __cplusplus
+/*
+A menu hook to be called during Jabber protocol menu initialization.
+
+wParam = 0;
+lParam = (LPARAM)(IJabberInterface**).
+
+Returns FALSE if all is Ok, and TRUE otherwise.
+*/
+
+#define ME_JABBER_MENUINIT "Jabber/ProtoMenuInit"
+
#endif // M_JABBER_H__
diff --git a/protocols/GTalkExt/src/handlers.cpp b/protocols/GTalkExt/src/handlers.cpp
index 3b48137b3c..83e4c036ad 100644
--- a/protocols/GTalkExt/src/handlers.cpp
+++ b/protocols/GTalkExt/src/handlers.cpp
@@ -22,6 +22,7 @@
#include "StdAfx.h"
#include "handlers.h"
#include "db.h"
+#include "inbox.h"
#include "notifications.h"
#include "options.h"
@@ -423,6 +424,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam)
japi->Net()->AddSendHandler(SendHandler);
}
+ HookEvent(ME_JABBER_MENUINIT, InitMenus);
HookOptionsInitialization();
return 0;
}
diff --git a/protocols/GTalkExt/src/inbox.cpp b/protocols/GTalkExt/src/inbox.cpp
index 4faf247172..bb699e365c 100644
--- a/protocols/GTalkExt/src/inbox.cpp
+++ b/protocols/GTalkExt/src/inbox.cpp
@@ -238,12 +238,8 @@ void OpenUrl(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url)
mir_forkthread(ShellExecuteThread, mir_tstrdup(url));
}
-void OpenContactInbox(HANDLE hContact)
+void OpenContactInbox(LPCSTR acc)
{
- LPSTR acc = GetContactProto(hContact);
- if (!acc)
- return;
-
DBVARIANT dbv;
if ( DBGetContactSettingTString(0, acc, "jid", &dbv))
return;
diff --git a/protocols/GTalkExt/src/inbox.h b/protocols/GTalkExt/src/inbox.h
index 0b00128ab9..2b26a074ca 100644
--- a/protocols/GTalkExt/src/inbox.h
+++ b/protocols/GTalkExt/src/inbox.h
@@ -22,4 +22,6 @@
#pragma once
void OpenUrl(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url);
-void OpenContactInbox(HANDLE hContact); \ No newline at end of file
+void OpenContactInbox(LPCSTR acc);
+
+int InitMenus(WPARAM wParam, LPARAM lParam);
diff --git a/protocols/GTalkExt/src/menu.cpp b/protocols/GTalkExt/src/menu.cpp
index 377b776091..ea241e6f55 100644
--- a/protocols/GTalkExt/src/menu.cpp
+++ b/protocols/GTalkExt/src/menu.cpp
@@ -25,26 +25,30 @@
#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;
-HANDLE hOnPrebuildMenu = 0;
-
-INT_PTR OpenMailboxMenuHandler(WPARAM wParam, LPARAM lParam)
+INT_PTR OpenMailboxMenuHandler(WPARAM wParam, LPARAM lParam, LPARAM param)
{
- OpenContactInbox((HANDLE)wParam);
+ OpenContactInbox((LPCSTR)param);
return 0;
}
-void InitMenus()
+int InitMenus(WPARAM wParam, LPARAM lParam)
{
- CreateServiceFunction(MS_GTALKEXT_OPENMAILBOX, OpenMailboxMenuHandler);
-/*!!!!!!!!!!!!!!!!!!!!!
- CLISTMENUITEM cmi = { sizeof(cmi) };
- cmi.flags = CMIF_TCHAR;
- cmi.hIcon = g_hPopupIcon;
- cmi.ptszName = _T(OPEN_MAILBOX_ITEM_CAPTION);
- cmi.pszService = MS_GTALKEXT_OPENMAILBOX;
- Menu_AddContactMenuItem(&cmi); */
+ IJabberInterface *ji = (IJabberInterface*)lParam;
+
+ char szServiceName[100];
+ mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s/%s", ji->Sys()->GetModuleName(), MS_GTALKEXT_OPENMAILBOX);
+ CreateServiceFunctionParam(szServiceName, OpenMailboxMenuHandler, (LPARAM)ji->Sys()->GetModuleName());
+
+ CLISTMENUITEM cmi = { sizeof(cmi) };
+ cmi.flags = CMIF_CHILDPOPUP;
+ cmi.hParentMenu = HGENMENU(wParam);
+ cmi.hIcon = g_hPopupIcon;
+ cmi.position = 200101;
+ cmi.pszName = LPGEN("Open mailbox");
+ cmi.pszService = szServiceName;
+ Menu_AddProtoMenuItem(&cmi);
+ return 0;
}
diff --git a/protocols/JabberG/jabber_11.vcxproj b/protocols/JabberG/jabber_11.vcxproj
index 8a17792102..42b365c162 100644
--- a/protocols/JabberG/jabber_11.vcxproj
+++ b/protocols/JabberG/jabber_11.vcxproj
@@ -264,6 +264,7 @@
<ClCompile Include="src\ui_utils.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\..\include\m_jabber.h" />
<ClInclude Include="src\jabber.h" />
<ClInclude Include="src\jabber_byte.h" />
<ClInclude Include="src\jabber_caps.h" />
diff --git a/protocols/JabberG/jabber_11.vcxproj.filters b/protocols/JabberG/jabber_11.vcxproj.filters
index 4f8501af1d..916485ff20 100644
--- a/protocols/JabberG/jabber_11.vcxproj.filters
+++ b/protocols/JabberG/jabber_11.vcxproj.filters
@@ -260,6 +260,9 @@
<ClInclude Include="src\jabber_xstatus.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\m_jabber.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\jabber.rc">
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp
index 70ea480613..d70d2c5241 100644
--- a/protocols/JabberG/src/jabber_menu.cpp
+++ b/protocols/JabberG/src/jabber_menu.cpp
@@ -39,7 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MENUITEM_SERVER 2
#define MENUITEM_RESOURCES 10
-static HANDLE hChooserMenu;
+static HANDLE hChooserMenu, hStatusMenuInit;
static int iChooserMenuPos = 30000;
static HGENMENU g_hMenuRequestAuth;
@@ -193,6 +193,8 @@ static int JabberPrebuildContactMenu(WPARAM wParam, LPARAM lParam)
void g_MenuInit(void)
{
+ hStatusMenuInit = CreateHookableEvent(ME_JABBER_MENUINIT);
+
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, JabberPrebuildContactMenu);
CreateServiceFunction("Jabber/MenuChoose", JabberMenuChooseService);
@@ -348,6 +350,8 @@ void g_MenuInit(void)
void g_MenuUninit(void)
{
+ DestroyHookableEvent(hStatusMenuInit);
+
CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuRequestAuth, 0);
CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuGrantAuth, 0);
CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuRevokeAuth, 0);
@@ -844,6 +848,8 @@ void CJabberProto::MenuInit()
m_pepServices.RebuildMenu();
CheckMenuItems();
+
+ NotifyFastHook(hStatusMenuInit, (WPARAM)hJabberRoot, (LPARAM)&m_JabberApi);
}
//////////////////////////////////////////////////////////////////////////