summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-30 20:27:23 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-30 20:27:23 +0000
commita8c93cfbf235c31cf604cb6bd40009e9bf88f36a (patch)
tree0eaf9592ee3cd752e8f2d0273132de0004aa1f6e
parent6b893bc94df93321a216ba62c3d56a6e08086e36 (diff)
- fix for the old perversion with manual protocol root calculation;
- protocol menu root is always created by the core; - other minor problems with protocol menus in main menu went away git-svn-id: http://svn.miranda-ng.org/main/trunk@14462 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/delphi/m_protoint.inc1
-rw-r--r--include/m_genmenu.h2
-rw-r--r--include/m_protoint.h2
-rw-r--r--plugins/CSList/src/cslist.cpp4
-rw-r--r--plugins/SecureIM/src/main.cpp2
-rw-r--r--protocols/AimOscar/src/proto.cpp5
-rw-r--r--protocols/AimOscar/src/proto.h1
-rw-r--r--protocols/AimOscar/src/theme.cpp18
-rw-r--r--protocols/FacebookRM/src/proto.h1
-rw-r--r--protocols/FacebookRM/src/theme.cpp20
-rw-r--r--protocols/Gadu-Gadu/src/gg.cpp43
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.cpp8
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.h1
-rw-r--r--protocols/Gadu-Gadu/src/sessions.cpp2
-rw-r--r--protocols/IRCG/src/ircproto.cpp8
-rw-r--r--protocols/IRCG/src/services.cpp19
-rw-r--r--protocols/IRCG/src/stdafx.h2
-rw-r--r--protocols/JabberG/src/jabber_menu.cpp26
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp2
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp5
-rw-r--r--protocols/JabberG/src/jabber_xstatus.cpp2
-rw-r--r--protocols/MRA/src/Mra_menus.cpp2
-rw-r--r--protocols/MSN/src/msn_menu.cpp23
-rw-r--r--protocols/MSN/src/msn_proto.cpp7
-rw-r--r--protocols/MSN/src/msn_proto.h2
-rw-r--r--protocols/SkypeWeb/src/skype_menus.cpp13
-rw-r--r--protocols/Steam/src/steam_menus.cpp15
-rw-r--r--protocols/Steam/src/steam_proto.cpp1
-rw-r--r--protocols/Steam/src/steam_proto.h1
-rw-r--r--protocols/Tox/src/tox_menus.cpp13
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp2
-rw-r--r--protocols/WhatsApp/src/proto.h2
-rw-r--r--protocols/WhatsApp/src/theme.cpp19
-rw-r--r--protocols/Yahoo/src/proto.cpp5
-rw-r--r--protocols/Yahoo/src/proto.h1
-rw-r--r--protocols/Yahoo/src/services.cpp21
-rw-r--r--src/mir_app/src/genmenu.cpp23
-rw-r--r--src/mir_app/src/proto_opts.cpp6
38 files changed, 63 insertions, 267 deletions
diff --git a/include/delphi/m_protoint.inc b/include/delphi/m_protoint.inc
index 716c52f85b..1416684b80 100644
--- a/include/delphi/m_protoint.inc
+++ b/include/delphi/m_protoint.inc
@@ -52,6 +52,7 @@ type
hProtoIcon :THANDLE;
hNetlibUser :THANDLE;
hWindowList :THANDLE;
+ hMainMenuItem :HGENMENU;
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
// Virtual functions
diff --git a/include/m_genmenu.h b/include/m_genmenu.h
index a159b34e22..3e9b93fbc7 100644
--- a/include/m_genmenu.h
+++ b/include/m_genmenu.h
@@ -245,7 +245,7 @@ __forceinline int Menu_ConfigureItem(HGENMENU hMenu, int iSetting, LPCSTR pszVal
/////////////////////////////////////////////////////////////////////////////////////////
// returns HGENMENU of the root item or NULL
-EXTERN_C MIR_APP_DLL(HGENMENU) Menu_GetProtocolRoot(const char *szProtoName);
+EXTERN_C MIR_APP_DLL(HGENMENU) Menu_GetProtocolRoot(PROTO_INTERFACE *pThis);
/////////////////////////////////////////////////////////////////////////////////////////
// kills all menu items & submenus that belong to the hLangpack given
diff --git a/include/m_protoint.h b/include/m_protoint.h
index 3c5cb5f39d..bff7adb764 100644
--- a/include/m_protoint.h
+++ b/include/m_protoint.h
@@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_system_cpp.h>
#include <m_protosvc.h>
#include <m_database.h>
+#include <m_genmenu.h>
#include <m_utils.h>
/////////////////////////////////////////////////////////////////////////////////////////
@@ -93,6 +94,7 @@ struct MIR_APP_EXPORT PROTO_INTERFACE : public MZeroedObject
HANDLE m_hProtoIcon; // icon to be displayed in the account manager
HANDLE m_hNetlibUser; // network agent
MWindowList m_hWindowList; // list of all windows which belong to this protocol's instance
+ HGENMENU m_hMainMenuItem; // if protocol menus are displayed in the main menu, this is the root
//////////////////////////////////////////////////////////////////////////////////////
// Helpers
diff --git a/plugins/CSList/src/cslist.cpp b/plugins/CSList/src/cslist.cpp
index 2c5adcd426..442d2ae86d 100644
--- a/plugins/CSList/src/cslist.cpp
+++ b/plugins/CSList/src/cslist.cpp
@@ -226,10 +226,10 @@ INT_PTR showList(WPARAM, LPARAM, LPARAM param)
void addProtoStatusMenuItem(char *protoName)
{
PROTOACCOUNT *pdescr = Proto_GetAccount(protoName);
- if (pdescr == NULL)
+ if (pdescr == NULL || pdescr->ppro == NULL)
return;
- HGENMENU hRoot = Menu_GetProtocolRoot(pdescr->szModuleName);
+ HGENMENU hRoot = Menu_GetProtocolRoot(pdescr->ppro);
if (hRoot == NULL)
return;
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp
index 97ce846321..b95da08213 100644
--- a/plugins/SecureIM/src/main.cpp
+++ b/plugins/SecureIM/src/main.cpp
@@ -51,7 +51,7 @@ static HGENMENU MyAddMenuItem(LPCWSTR name, int pos, HICON hicon, LPCSTR service
static HGENMENU MyAddSubItem(HGENMENU hRoot, LPCSTR name, int pos, int poppos, LPCSTR service, WPARAM wParam = 0)
{
CMenuItem mi;
- mi.flags = CMIF_HIDDEN;
+ mi.flags = CMIF_HIDDEN;
mi.position = pos;
mi.name.a = (char*)name;
mi.root = hRoot;
diff --git a/protocols/AimOscar/src/proto.cpp b/protocols/AimOscar/src/proto.cpp
index 6097af60cb..4dc782f75a 100644
--- a/protocols/AimOscar/src/proto.cpp
+++ b/protocols/AimOscar/src/proto.cpp
@@ -703,11 +703,6 @@ int __cdecl CAimProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM l
}
break;
- case EV_PROTO_ONRENAME:
- if (hMenuRoot)
- Menu_ModifyItem(hMenuRoot, m_tszUserName);
- break;
-
case EV_PROTO_ONCONTACTDELETED:
return OnContactDeleted(wParam, lParam);
diff --git a/protocols/AimOscar/src/proto.h b/protocols/AimOscar/src/proto.h
index 5ee46474c8..ea4688b1ef 100644
--- a/protocols/AimOscar/src/proto.h
+++ b/protocols/AimOscar/src/proto.h
@@ -133,7 +133,6 @@ struct CAimProto : public PROTO<CAimProto>
HANDLE hDirectBoundPort;//direct connection listening port
//Handles for the context menu items
- HGENMENU hMenuRoot;
HGENMENU hHTMLAwayContextMenuItem;
HGENMENU hAddToServerListContextMenuItem;
HGENMENU hBlockContextMenuItem;
diff --git a/protocols/AimOscar/src/theme.cpp b/protocols/AimOscar/src/theme.cpp
index de5f0a4220..c419b3d1ec 100644
--- a/protocols/AimOscar/src/theme.cpp
+++ b/protocols/AimOscar/src/theme.cpp
@@ -209,24 +209,8 @@ int CAimProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM)
void CAimProto::InitMainMenus(void)
{
- HGENMENU hRoot = Menu_GetProtocolRoot(m_szModuleName);
- if (hRoot == NULL) {
- CMenuItem mi;
- mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.hIcolibItem = GetIconHandle("aim");
- mi.name.t = m_tszUserName;
- mi.position = 500090000;
- hRoot = hMenuRoot = Menu_AddProtoMenuItem(&mi);
- }
- else {
- if (hMenuRoot) {
- Menu_RemoveItem(hMenuRoot);
- hMenuRoot = NULL;
- }
- }
-
CMenuItem mi;
- mi.root = hRoot;
+ mi.root = Menu_GetProtocolRoot(this);
mi.pszService = "/ManageAccount";
CreateProtoService(mi.pszService, &CAimProto::ManageAccount);
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index 33cdd19bfe..9e4dafbab5 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -234,7 +234,6 @@ public:
bool RunCaptchaForm(std::string imageUrl, std::string &result);
// Menu items
- HGENMENU m_hMenuRoot;
HGENMENU m_hMenuServicesRoot;
HGENMENU m_hStatusMind;
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp
index 1c0abafb6d..adc1214647 100644
--- a/protocols/FacebookRM/src/theme.cpp
+++ b/protocols/FacebookRM/src/theme.cpp
@@ -208,25 +208,9 @@ int FacebookProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
int FacebookProto::OnBuildStatusMenu(WPARAM, LPARAM)
{
- HGENMENU hRoot = Menu_GetProtocolRoot(m_szModuleName);
- if (hRoot == NULL) {
- CMenuItem miRoot;
- miRoot.position = 500085000;
- miRoot.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED | (this->isOnline() ? 0 : CMIF_GRAYED);
- miRoot.hIcolibItem = GetIconHandle("facebook");
- miRoot.name.t = m_tszUserName;
- hRoot = m_hMenuRoot = Menu_AddProtoMenuItem(&miRoot);
- }
- else {
- if (m_hMenuRoot) {
- Menu_RemoveItem(m_hMenuRoot);
- m_hMenuRoot = NULL;
- }
- }
-
CMenuItem mi;
mi.position = 201001;
- mi.root = hRoot;
+ mi.root = Menu_GetProtocolRoot(this);
mi.pszService = "/Mind";
CreateProtoService(mi.pszService, &FacebookProto::OnMind);
@@ -275,7 +259,7 @@ int FacebookProto::OnBuildStatusMenu(WPARAM, LPARAM)
void FacebookProto::ToggleStatusMenuItems(bool bEnable)
{
- Menu_EnableItem(m_hMenuRoot, bEnable);
+ Menu_EnableItem(m_hMainMenuItem, bEnable);
Menu_EnableItem(m_hStatusMind, bEnable);
Menu_EnableItem(m_hMenuServicesRoot, bEnable);
}
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp
index cdcca1a571..cf9f0aad10 100644
--- a/protocols/Gadu-Gadu/src/gg.cpp
+++ b/protocols/Gadu-Gadu/src/gg.cpp
@@ -257,34 +257,21 @@ void GGPROTO::block_uninit()
// Menus initialization
void GGPROTO::menus_init()
{
- CMenuItem mi;
-
- HGENMENU hGCRoot, hCLRoot, hRoot = Menu_GetProtocolRoot(m_szModuleName);
- if (hRoot == NULL) {
- mi.name.t = m_tszUserName;
- mi.position = 500090000;
- mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.hIcolibItem = iconList[0].hIcolib;
- hGCRoot = hCLRoot = hRoot = hMenuRoot = Menu_AddProtoMenuItem(&mi);
- }
- else {
- mi.root = hRoot;
- mi.flags = CMIF_TCHAR;
-
- mi.name.t = LPGENT("Conference");
- mi.position = 200001;
- mi.hIcolibItem = iconList[14].hIcolib;
- hGCRoot = Menu_AddProtoMenuItem(&mi, m_szModuleName);
-
- mi.name.t = LPGENT("Contact list");
- mi.position = 200002;
- mi.hIcolibItem = iconList[7].hIcolib;
- hCLRoot = Menu_AddProtoMenuItem(&mi, m_szModuleName);
-
- if (hMenuRoot)
- Menu_RemoveItem(hMenuRoot);
- hMenuRoot = NULL;
- }
+ HGENMENU hRoot = Menu_GetProtocolRoot(this);
+
+ CMenuItem mi;
+ mi.root = hRoot;
+ mi.flags = CMIF_TCHAR;
+
+ mi.name.t = LPGENT("Conference");
+ mi.position = 200001;
+ mi.hIcolibItem = iconList[14].hIcolib;
+ HGENMENU hGCRoot = Menu_AddProtoMenuItem(&mi, m_szModuleName);
+
+ mi.name.t = LPGENT("Contact list");
+ mi.position = 200002;
+ mi.hIcolibItem = iconList[7].hIcolib;
+ HGENMENU hCLRoot = Menu_AddProtoMenuItem(&mi, m_szModuleName);
gc_menus_init(hGCRoot);
import_init(hCLRoot);
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp
index a3c8ba8141..d77fb87d72 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.cpp
+++ b/protocols/Gadu-Gadu/src/gg_proto.cpp
@@ -94,9 +94,6 @@ GGPROTO::~GGPROTO()
Popup_UnregisterClass(hPopupError);
Popup_UnregisterClass(hPopupNotify);
- if (hMenuRoot)
- Menu_RemoveItem(hMenuRoot);
-
// Close handles
Netlib_CloseHandle(m_hNetlibUser);
@@ -763,11 +760,6 @@ int GGPROTO::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam)
menus_init();
break;
- case EV_PROTO_ONRENAME:
- if (hMenuRoot)
- Menu_ModifyItem(hMenuRoot, m_tszUserName);
- break;
-
case EV_PROTO_ONCONTACTDELETED:
return contactdeleted(wParam, lParam);
diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h
index 45a1ec9899..5b6f79292c 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.h
+++ b/protocols/Gadu-Gadu/src/gg_proto.h
@@ -243,7 +243,6 @@ struct GGPROTO : public PROTO<GGPROTO>
TCHAR *offline;
} modemsg;
- HGENMENU hMenuRoot;
HGENMENU hMainMenu[7];
HGENMENU hBlockMenuItem, hImageMenuItem, hInstanceMenuItem;
HANDLE hPrebuildMenuHook;
diff --git a/protocols/Gadu-Gadu/src/sessions.cpp b/protocols/Gadu-Gadu/src/sessions.cpp
index 640aec001d..001d2189b9 100644
--- a/protocols/Gadu-Gadu/src/sessions.cpp
+++ b/protocols/Gadu-Gadu/src/sessions.cpp
@@ -422,7 +422,7 @@ void GGPROTO::sessions_menus_init(HGENMENU hRoot)
mi.pszService = GGS_CONCUR_SESS;
CreateProtoService(mi.pszService, &GGPROTO::sessions_view);
- mi.position = (hMenuRoot) ? 2050000001 : 200003;
+ mi.position = 200003;
mi.hIcolibItem = iconList[16].hIcolib;
mi.name.t = LPGENT("Concurrent &sessions");
Menu_AddProtoMenuItem(&mi, m_szModuleName);
diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp
index 4b60263266..26601b2d0f 100644
--- a/protocols/IRCG/src/ircproto.cpp
+++ b/protocols/IRCG/src/ircproto.cpp
@@ -146,9 +146,6 @@ CIrcProto::~CIrcProto()
Netlib_CloseHandle(m_hNetlibUser); m_hNetlibUser = NULL;
Netlib_CloseHandle(hNetlibDCC); hNetlibDCC = NULL;
- if (hMenuRoot)
- Menu_RemoveItem(hMenuRoot);
-
mir_free(m_alias);
CloseHandle(m_evWndCreate);
@@ -839,11 +836,6 @@ int __cdecl CIrcProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM l
InitMainMenus();
break;
- case EV_PROTO_ONRENAME:
- if (hMenuRoot)
- Menu_ModifyItem(hMenuRoot, m_tszUserName);
- break;
-
case EV_PROTO_ONCONTACTDELETED:
return OnContactDeleted(wParam, lParam);
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp
index 83f25fec4b..579c409c47 100644
--- a/protocols/IRCG/src/services.cpp
+++ b/protocols/IRCG/src/services.cpp
@@ -23,25 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void CIrcProto::InitMainMenus(void)
{
- HGENMENU hRoot = Menu_GetProtocolRoot(m_szModuleName);
- if (hRoot == NULL) {
- // Root popupmenuitem
- CMenuItem mi;
- mi.name.t = m_tszUserName;
- mi.position = -1999901010;
- mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.hIcolibItem = GetIconHandle(IDI_MAIN);
- hRoot = hMenuRoot = Menu_AddProtoMenuItem(&mi);
- }
- else {
- if (hMenuRoot) {
- Menu_RemoveItem(hMenuRoot);
- hMenuRoot = NULL;
- }
- }
-
CMenuItem mi;
- mi.root = hRoot;
+ mi.root = Menu_GetProtocolRoot(this);
mi.name.a = LPGEN("&Quick connect");
mi.hIcolibItem = GetIconHandle(IDI_QUICK);
diff --git a/protocols/IRCG/src/stdafx.h b/protocols/IRCG/src/stdafx.h
index 8cdf9c96b7..850c2f44e1 100644
--- a/protocols/IRCG/src/stdafx.h
+++ b/protocols/IRCG/src/stdafx.h
@@ -337,7 +337,7 @@ struct CIrcProto : public PROTO<CIrcProto>
DWORD m_bConnectRequested;
DWORD m_bConnectThreadRunning;
- HGENMENU hMenuRoot, hMenuQuick, hMenuServer, hMenuJoin, hMenuNick, hMenuList;
+ HGENMENU hMenuQuick, hMenuServer, hMenuJoin, hMenuNick, hMenuList;
HANDLE hNetlibDCC;
bool bTempDisableCheck, bTempForceCheck, bEcho;
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp
index 88f3746d36..e241a5200c 100644
--- a/protocols/JabberG/src/jabber_menu.cpp
+++ b/protocols/JabberG/src/jabber_menu.cpp
@@ -579,24 +579,8 @@ INT_PTR __cdecl CJabberProto::OnMenuBookmarkAdd(WPARAM hContact, LPARAM)
void CJabberProto::MenuInit()
{
- HGENMENU hJabberRoot = Menu_GetProtocolRoot(m_szModuleName);
- if (hJabberRoot == NULL) {
- CMenuItem mi;
- mi.name.t = m_tszUserName;
- mi.position = -1999901006;
- mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.hIcolibItem = m_hProtoIcon;
- hJabberRoot = m_hMenuRoot = Menu_AddProtoMenuItem(&mi);
- }
- else {
- if (m_hMenuRoot) {
- Menu_RemoveItem(m_hMenuRoot);
- m_hMenuRoot = NULL;
- }
- }
-
CMenuItem mi;
- mi.root = hJabberRoot;
+ mi.root = m_hMenuRoot = Menu_GetProtocolRoot(this);
// "Bookmarks..."
mi.pszService = "/Bookmarks";
@@ -693,7 +677,7 @@ void CJabberProto::MenuInit()
mi.pszService = NULL;
mi.position = 200006;
- mi.root = hJabberRoot;
+ mi.root = m_hMenuRoot;
mi.name.a = LPGEN("Resource priority");
mi.flags = CMIF_HIDDEN;
m_hMenuPriorityRoot = Menu_AddProtoMenuItem(&mi);
@@ -743,7 +727,7 @@ void CJabberProto::MenuInit()
m_pepServices.RebuildMenu();
CheckMenuItems();
- NotifyFastHook(hStatusMenuInit, (WPARAM)hJabberRoot, (LPARAM)(IJabberInterface*)this);
+ NotifyFastHook(hStatusMenuInit, (WPARAM)m_hMenuRoot, (LPARAM)(IJabberInterface*)this);
}
//////////////////////////////////////////////////////////////////////////
@@ -876,10 +860,6 @@ void CJabberProto::GlobalMenuUninit()
m_phMenuResourceItems = NULL;
}
m_nMenuResourceItems = 0;
-
- if (m_hMenuRoot)
- Menu_RemoveItem(m_hMenuRoot);
- m_hMenuRoot = NULL;
}
void CJabberProto::EnableMenuItems(BOOL bEnable)
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index 35fdcde2f6..f70aa8741e 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -2095,7 +2095,7 @@ void CJabberProto::BuildPrivacyMenu()
mi.hIcolibItem = GetIconHandle(IDI_AGENTS);
mi.flags = CMIF_HIDDEN;
mi.name.a = LPGEN("Privacy Lists");
- mi.root = Menu_GetProtocolRoot(m_szModuleName);
+ mi.root = m_hMenuRoot;
m_hPrivacyMenuRoot = Menu_AddProtoMenuItem(&mi);
mi.pszService = "/PrivacyLists";
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index f589828244..0cfc3446f8 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -1318,11 +1318,6 @@ int __cdecl CJabberProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARA
MenuInit();
break;
- case EV_PROTO_ONRENAME:
- if (m_hMenuRoot)
- Menu_ModifyItem(m_hMenuRoot, m_tszUserName);
- break;
-
case EV_PROTO_ONCONTACTDELETED:
return OnContactDeleted(wParam, lParam);
diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp
index f28aa0abc4..ddde385b99 100644
--- a/protocols/JabberG/src/jabber_xstatus.cpp
+++ b/protocols/JabberG/src/jabber_xstatus.cpp
@@ -458,7 +458,7 @@ void CPepGuiService::InitGui()
void CPepGuiService::RebuildMenu()
{
- HGENMENU hJabberRoot = Menu_GetProtocolRoot(m_proto->m_szModuleName);
+ HGENMENU hJabberRoot = m_proto->m_hMenuRoot;
if (hJabberRoot == NULL)
return;
diff --git a/protocols/MRA/src/Mra_menus.cpp b/protocols/MRA/src/Mra_menus.cpp
index b6cc63c25e..b251560c18 100644
--- a/protocols/MRA/src/Mra_menus.cpp
+++ b/protocols/MRA/src/Mra_menus.cpp
@@ -338,7 +338,7 @@ HGENMENU CMraProto::CListCreateMenu(LONG lPosition, LONG lPopupPosition, BOOL bI
if (bIsMain) {
fnAddFunc = Menu_AddProtoMenuItem;
- hRootMenu = Menu_GetProtocolRoot(m_szModuleName);
+ hRootMenu = Menu_GetProtocolRoot(this);
if (hRootMenu == NULL) {
mi.name.t = m_tszUserName;
mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
diff --git a/protocols/MSN/src/msn_menu.cpp b/protocols/MSN/src/msn_menu.cpp
index 2458b7aeb1..43b52d153b 100644
--- a/protocols/MSN/src/msn_menu.cpp
+++ b/protocols/MSN/src/msn_menu.cpp
@@ -269,22 +269,7 @@ INT_PTR CMsnProto::SetNicknameUI(WPARAM, LPARAM)
void CMsnProto::MsnInitMainMenu(void)
{
CMenuItem mi;
-
- HGENMENU hRoot = Menu_GetProtocolRoot(m_szModuleName);
- if (hRoot == NULL) {
- mi.position = 500085000;
- mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.hIcolibItem = GetIconHandle(IDI_MSN);
- mi.name.t = m_tszUserName;
- hRoot = mainMenuRoot = Menu_AddProtoMenuItem(&mi);
- }
- else {
- MsnRemoveMainMenus();
- mainMenuRoot = NULL;
- }
-
- mi.flags = 0;
- mi.root = hRoot;
+ mi.root = Menu_GetProtocolRoot(this);
#ifdef OBSOLETE
mi.pszService = MS_SET_NICKNAME_UI;
@@ -326,12 +311,6 @@ void CMsnProto::MsnInitMainMenu(void)
MSN_EnableMenuItems(m_iStatus >= ID_STATUS_ONLINE);
}
-void CMsnProto::MsnRemoveMainMenus(void)
-{
- if (mainMenuRoot)
- Menu_RemoveItem(mainMenuRoot);
-}
-
void CMsnProto::MSN_EnableMenuItems(bool bEnable)
{
for (int i = 0; i < _countof(menuItemsMain); i++)
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index 8bf72194d9..5c9955d37b 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -151,8 +151,6 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :
CMsnProto::~CMsnProto()
{
- MsnRemoveMainMenus();
-
MSN_FreeGroups();
Threads_Uninit();
AvatarQueue_Uninit();
@@ -1230,11 +1228,6 @@ int __cdecl CMsnProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM l
CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szDbsettings);
break;
- case EV_PROTO_ONRENAME:
- if (mainMenuRoot)
- Menu_ModifyItem(mainMenuRoot, m_tszUserName);
- break;
-
case EV_PROTO_ONCONTACTDELETED:
return OnContactDeleted(wParam, lParam);
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h
index 5020d88ad2..952c32db05 100644
--- a/protocols/MSN/src/msn_proto.h
+++ b/protocols/MSN/src/msn_proto.h
@@ -254,11 +254,9 @@ struct CMsnProto : public PROTO<CMsnProto>
/////////////////////////////////////////////////////////////////////////////////////////
// MSN menus
- HGENMENU mainMenuRoot;
HGENMENU menuItemsMain[4];
void MsnInitMainMenu(void);
- void MsnRemoveMainMenus(void);
void MSN_EnableMenuItems(bool parEnable);
void MsnInvokeMyURL(bool ismail, const char* url);
diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp
index 47c9138cd4..4c5c1c3049 100644
--- a/protocols/SkypeWeb/src/skype_menus.cpp
+++ b/protocols/SkypeWeb/src/skype_menus.cpp
@@ -108,19 +108,8 @@ void CSkypeProto::UninitMenus()
int CSkypeProto::OnInitStatusMenu()
{
- HGENMENU hStatusMenuRoot = Menu_GetProtocolRoot(m_szModuleName);
- if (!hStatusMenuRoot)
- {
- CMenuItem mi;
- mi.name.t = m_tszUserName;
- mi.position = -1999901006;
- mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.hIcolibItem = Skin_GetIconHandle("main");
- hStatusMenuRoot = Menu_AddProtoMenuItem(&mi);
- }
-
CMenuItem mi;
- mi.root = hStatusMenuRoot;
+ mi.root = Menu_GetProtocolRoot(this);
mi.pszService = "/CreateNewChat";
CreateProtoService(mi.pszService, &CSkypeProto::SvcCreateChat);
diff --git a/protocols/Steam/src/steam_menus.cpp b/protocols/Steam/src/steam_menus.cpp
index d975b21872..be3282378a 100644
--- a/protocols/Steam/src/steam_menus.cpp
+++ b/protocols/Steam/src/steam_menus.cpp
@@ -96,22 +96,9 @@ int CSteamProto::PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
void CSteamProto::OnInitStatusMenu()
{
- HGENMENU hSteamRoot = Menu_GetProtocolRoot(m_szModuleName);
- if (!hSteamRoot) {
- CMenuItem mi;
- mi.name.t = m_tszUserName;
- mi.position = -1999901006;
- mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- hSteamRoot = m_hMenuRoot = Menu_AddProtoMenuItem(&mi);
- }
- else {
- Menu_RemoveItem(m_hMenuRoot);
- m_hMenuRoot = NULL;
- }
-
CMenuItem mi;
mi.flags = CMIF_TCHAR;
- mi.root = hSteamRoot;
+ mi.root = Menu_GetProtocolRoot(this);
// Show block list
mi.pszService = "/BlockList";
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index 2a626f5020..807d2a091d 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -12,7 +12,6 @@ CSteamProto::CSteamProto(const char* protoName, const TCHAR* userName) :
m_hQueueThread = NULL;
m_pollingConnection = NULL;
m_hPollingThread = NULL;
- m_hMenuRoot = NULL;
// icons
wchar_t filePath[MAX_PATH];
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index c254d43865..12e1cee5a2 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -160,7 +160,6 @@ protected:
void OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg);
// menus
- HGENMENU m_hMenuRoot;
static int hChooserMenu;
static HGENMENU contactMenuItems[CMI_MAX];
diff --git a/protocols/Tox/src/tox_menus.cpp b/protocols/Tox/src/tox_menus.cpp
index c7c77ba163..565a66e4c2 100644
--- a/protocols/Tox/src/tox_menus.cpp
+++ b/protocols/Tox/src/tox_menus.cpp
@@ -75,20 +75,9 @@ void CToxProto::UninitMenus()
int CToxProto::OnInitStatusMenu()
{
- HGENMENU hStatusMenuRoot = Menu_GetProtocolRoot(m_szModuleName);
- if (!hStatusMenuRoot)
- {
- CMenuItem mi;
- mi.name.t = m_tszUserName;
- mi.position = -1999901006;
- mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.hIcolibItem = Skin_GetIconHandle("main");
- hStatusMenuRoot = Menu_AddProtoMenuItem(&mi);
- }
-
CMenuItem mi;
mi.flags = CMIF_TCHAR;
- mi.root = hStatusMenuRoot;
+ mi.root = Menu_GetProtocolRoot(this);
// Create copy tox id command
mi.pszService = "/CopyToxID";
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index de2aeb5825..efa6adfc2d 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -192,7 +192,7 @@ void CVkProto::InitMenus()
CreateProtoService(PS_WALLPOST, &CVkProto::SvcWallPost);
CMenuItem mi;
- mi.root = Menu_GetProtocolRoot(m_szModuleName);
+ mi.root = Menu_GetProtocolRoot(this);
// Proto menu
mi.pszService = PS_CREATECHAT;
diff --git a/protocols/WhatsApp/src/proto.h b/protocols/WhatsApp/src/proto.h
index 5a3cf8cac9..7c153ef781 100644
--- a/protocols/WhatsApp/src/proto.h
+++ b/protocols/WhatsApp/src/proto.h
@@ -141,7 +141,7 @@ private:
// Private data //////////////////////////////////////////////////////////////////////
- HGENMENU m_hMenuRoot, m_hMenuCreateGroup;
+ HGENMENU m_hMenuCreateGroup;
HANDLE update_loop_lock_;
diff --git a/protocols/WhatsApp/src/theme.cpp b/protocols/WhatsApp/src/theme.cpp
index 1a11414f4b..d3a2cbd434 100644
--- a/protocols/WhatsApp/src/theme.cpp
+++ b/protocols/WhatsApp/src/theme.cpp
@@ -47,29 +47,13 @@ static WhatsAppProto* GetInstanceByHContact(MCONTACT hContact)
int WhatsAppProto::OnBuildStatusMenu(WPARAM wParam, LPARAM lParam)
{
- HGENMENU hRoot = Menu_GetProtocolRoot(m_szModuleName);
- if (hRoot == NULL) {
- CMenuItem mi;
- mi.position = 500085000;
- mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED | (isOnline() ? 0 : CMIF_GRAYED);
- mi.hIcolibItem = GetIconHandle("whatsApp");
- mi.name.t = m_tszUserName;
- hRoot = m_hMenuRoot = Menu_AddProtoMenuItem(&mi);
- }
- else {
- if (m_hMenuRoot) {
- Menu_RemoveItem(m_hMenuRoot);
- m_hMenuRoot = NULL;
- }
- }
-
CMenuItem mi;
mi.flags = (isOnline() ? 0 : CMIF_GRAYED);
mi.position = 201001;
mi.pszService = "/CreateGroup";
CreateProtoService(mi.pszService, &WhatsAppProto::OnCreateGroup);
- mi.root = hRoot;
+ mi.root = Menu_GetProtocolRoot(this);
mi.name.a = LPGEN("Create group");
mi.hIcolibItem = GetIconHandle("createGroup");
m_hMenuCreateGroup = Menu_AddProtoMenuItem(&mi, m_szModuleName);
@@ -78,6 +62,5 @@ int WhatsAppProto::OnBuildStatusMenu(WPARAM wParam, LPARAM lParam)
void WhatsAppProto::ToggleStatusMenuItems(bool bEnable)
{
- Menu_EnableItem(m_hMenuRoot, bEnable);
Menu_EnableItem(m_hMenuCreateGroup, bEnable);
}
diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp
index faab974481..ccb3c16257 100644
--- a/protocols/Yahoo/src/proto.cpp
+++ b/protocols/Yahoo/src/proto.cpp
@@ -638,11 +638,6 @@ int __cdecl CYahooProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM
MenuMainInit();
break;
- case EV_PROTO_ONRENAME:
- if (mainMenuRoot)
- Menu_ModifyItem(mainMenuRoot, m_tszUserName, INVALID_HANDLE_VALUE, CMIF_KEEPUNTRANSLATED);
- break;
-
case EV_PROTO_ONCONTACTDELETED:
return OnContactDeleted(wParam, lParam);
diff --git a/protocols/Yahoo/src/proto.h b/protocols/Yahoo/src/proto.h
index a220b3b788..992b9292c3 100644
--- a/protocols/Yahoo/src/proto.h
+++ b/protocols/Yahoo/src/proto.h
@@ -279,7 +279,6 @@ private:
HANDLE hYahooNudge;
- HGENMENU mainMenuRoot;
HGENMENU hShowProfileMenuItem;
HGENMENU menuItemsAll[ 8 ];
};
diff --git a/protocols/Yahoo/src/services.cpp b/protocols/Yahoo/src/services.cpp
index 49cdb8b93d..25e7a2a1e1 100644
--- a/protocols/Yahoo/src/services.cpp
+++ b/protocols/Yahoo/src/services.cpp
@@ -359,24 +359,8 @@ INT_PTR __cdecl CYahooProto::GetUnreadEmailCount(WPARAM, LPARAM)
void CYahooProto::MenuMainInit(void)
{
CMenuItem mi;
-
- HGENMENU hRoot = Menu_GetProtocolRoot(m_szModuleName);
- if (hRoot == NULL) {
- mi.position = 500015000;
- mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.hIcolibItem = GetIconHandle(IDI_YAHOO);
- mi.name.t = m_tszUserName;
- hRoot = mainMenuRoot = Menu_AddProtoMenuItem(&mi);
- }
- else {
- if (mainMenuRoot) {
- Menu_RemoveItem(mainMenuRoot);
- mainMenuRoot = NULL;
- }
- }
-
mi.flags = 0;
- mi.root = hRoot;
+ mi.root = Menu_GetProtocolRoot(this);
// Show custom status menu
mi.pszService = YAHOO_SET_CUST_STAT;
@@ -450,9 +434,6 @@ void CYahooProto::MenuContactInit(void)
void CYahooProto::MenuUninit(void)
{
- if (mainMenuRoot)
- Menu_RemoveItem(mainMenuRoot);
-
Menu_RemoveItem(hShowProfileMenuItem);
}
diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp
index 4821c15d84..758d3c8b5e 100644
--- a/src/mir_app/src/genmenu.cpp
+++ b/src/mir_app/src/genmenu.cpp
@@ -225,13 +225,18 @@ EXTERN_C MIR_APP_DLL(BOOL) Menu_ProcessHotKey(int hMenuObject, int key)
/////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(HGENMENU) Menu_GetProtocolRoot(const char *szProto)
+MIR_APP_DLL(HGENMENU) Menu_GetProtocolRoot(PROTO_INTERFACE *pThis)
{
- if (szProto == NULL)
+ if (pThis == NULL)
return 0;
- if (db_get_b(NULL, "CList", "MoveProtoMenus", TRUE))
- return cli.pfnGetProtocolMenu(szProto);
+ if (db_get_b(NULL, "CList", "MoveProtoMenus", TRUE)) {
+ if (pThis->m_hMainMenuItem != NULL) {
+ Menu_RemoveItem(pThis->m_hMainMenuItem);
+ pThis->m_hMainMenuItem = NULL;
+ }
+ return cli.pfnGetProtocolMenu(pThis->m_szModuleName);
+ }
TIntMenuObject *pmo = GetMenuObjbyId(hMainMenuObject);
if (pmo == NULL)
@@ -239,10 +244,16 @@ MIR_APP_DLL(HGENMENU) Menu_GetProtocolRoot(const char *szProto)
mir_cslock lck(csMenuHook);
for (TMO_IntMenuItem *p = pmo->m_items.first; p != NULL; p = p->next)
- if (!mir_strcmp(p->UniqName, szProto))
+ if (!mir_strcmp(p->UniqName, pThis->m_szModuleName))
return p;
- return NULL;
+ // create protocol root in the main menu
+ CMenuItem mi;
+ mi.name.t = pThis->m_tszUserName;
+ mi.position = 500090000;
+ mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
+ mi.hIcolibItem = pThis->m_hProtoIcon;
+ return pThis->m_hMainMenuItem = Menu_AddMainMenuItem(&mi);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp
index d4f29726c7..151a3c2ff8 100644
--- a/src/mir_app/src/proto_opts.cpp
+++ b/src/mir_app/src/proto_opts.cpp
@@ -1034,9 +1034,11 @@ static int OnAccListChanged(WPARAM eventCode, LPARAM lParam)
switch (eventCode) {
case PRAC_CHANGED:
if (pa->ppro) {
- mir_free(pa->ppro->m_tszUserName);
- pa->ppro->m_tszUserName = mir_tstrdup(pa->tszAccountName);
+ replaceStrT(pa->ppro->m_tszUserName, pa->tszAccountName);
pa->ppro->OnEvent(EV_PROTO_ONRENAME, 0, lParam);
+
+ if (pa->ppro->m_hMainMenuItem)
+ Menu_ModifyItem(pa->ppro->m_hMainMenuItem, pa->tszAccountName);
}
}