summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-03-24 15:38:17 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-03-24 15:38:17 +0300
commite84bafdd3f3d2eb67e10a9bd3fbe600748962b6f (patch)
tree1b563061e473ef8bbe62b86821da21c319cca2c5 /protocols
parentaa55162ab85df5aa0ac6b87711bfee222b3222dd (diff)
revolution in chat menus
- common code moved to the core (Chat_CreateGCMenu, Chat_DestroyGCMenu); - ability added to any plugin to add its own items into any GC menu, not only to the protocol plugins to do that a plugin calls Chat_AddMenuItems and returns 0 to allow any other plugin to process menu hook
Diffstat (limited to 'protocols')
-rw-r--r--protocols/AimOscar/src/chat.cpp13
-rw-r--r--protocols/Discord/src/groupchat.cpp6
-rw-r--r--protocols/FacebookRM/src/chat.cpp8
-rw-r--r--protocols/IRCG/src/resource.h1
-rw-r--r--protocols/IRCG/src/services.cpp27
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp95
-rw-r--r--protocols/MSN/src/msn_chat.cpp9
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp31
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp13
-rw-r--r--protocols/WhatsApp/src/chat.cpp12
10 files changed, 88 insertions, 127 deletions
diff --git a/protocols/AimOscar/src/chat.cpp b/protocols/AimOscar/src/chat.cpp
index bd7a371619..24df22d77b 100644
--- a/protocols/AimOscar/src/chat.cpp
+++ b/protocols/AimOscar/src/chat.cpp
@@ -162,16 +162,15 @@ int CAimProto::OnGCEvent(WPARAM, LPARAM lParam)
int CAimProto::OnGCMenuHook(WPARAM, LPARAM lParam)
{
GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;
-
- if (gcmi == NULL || _stricmp(gcmi->pszModule, m_szModuleName)) return 0;
+ if (mir_strcmp(gcmi->pszModule, m_szModuleName))
+ return 0;
if (gcmi->Type == MENU_ON_LOG) {
static const struct gc_item Items[] = {
{ TranslateT("&Invite user..."), 10, MENU_ITEM, FALSE },
{ TranslateT("&Leave chat session"), 20, MENU_ITEM, FALSE }
};
- gcmi->nItems = _countof(Items);
- gcmi->Item = (gc_item*)Items;
+ Chat_AddMenuItems(gcmi->hMenu, _countof(Items), Items);
}
else if (gcmi->Type == MENU_ON_NICKLIST) {
char* sn = mir_u2a(gcmi->pszUID);
@@ -182,16 +181,14 @@ int CAimProto::OnGCMenuHook(WPARAM, LPARAM lParam)
{ L"", 100, MENU_SEPARATOR, FALSE },
{ TranslateT("&Leave chat session"), 110, MENU_ITEM, FALSE }
};
- gcmi->nItems = _countof(Items);
- gcmi->Item = (gc_item*)Items;
+ Chat_AddMenuItems(gcmi->hMenu, _countof(Items), Items);
}
else {
static const struct gc_item Items[] = {
{ TranslateT("User &details"), 10, MENU_ITEM, FALSE },
{ TranslateT("User &history"), 20, MENU_ITEM, FALSE }
};
- gcmi->nItems = _countof(Items);
- gcmi->Item = (gc_item*)Items;
+ Chat_AddMenuItems(gcmi->hMenu, _countof(Items), Items);
}
mir_free(sn);
}
diff --git a/protocols/Discord/src/groupchat.cpp b/protocols/Discord/src/groupchat.cpp
index e0f1603ac8..729afc84f0 100644
--- a/protocols/Discord/src/groupchat.cpp
+++ b/protocols/Discord/src/groupchat.cpp
@@ -60,10 +60,8 @@ int CDiscordProto::GroupchatMenuHook(WPARAM, LPARAM lParam)
if (pChat == nullptr)
return 0;
- if (gcmi->Type == MENU_ON_LOG) {
- gcmi->nItems = _countof(sttLogListItems);
- gcmi->Item = sttLogListItems;
- }
+ if (gcmi->Type == MENU_ON_LOG)
+ Chat_AddMenuItems(gcmi->hMenu, _countof(sttLogListItems), sttLogListItems);
return 0;
}
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp
index 126976137f..880077eb7d 100644
--- a/protocols/FacebookRM/src/chat.cpp
+++ b/protocols/FacebookRM/src/chat.cpp
@@ -348,8 +348,7 @@ int FacebookProto::OnGCMenuHook(WPARAM, LPARAM lParam)
{ LPGENW("&Invite user..."), 10, MENU_ITEM, FALSE },
{ LPGENW("&Leave chat session"), 20, MENU_ITEM, FALSE }
};
- gcmi->nItems = _countof(Items);
- gcmi->Item = (gc_item*)Items;
+ Chat_AddMenuItems(gcmi->hMenu, _countof(Items), Items);
}
else if (gcmi->Type == MENU_ON_NICKLIST)
{
@@ -364,8 +363,6 @@ int FacebookProto::OnGCMenuHook(WPARAM, LPARAM lParam)
};
gcmi->nItems = _countof(Items);
gcmi->Item = (gc_item*)Items;*/
- gcmi->nItems = 0;
- gcmi->Item = NULL;
}
else
{
@@ -374,8 +371,7 @@ int FacebookProto::OnGCMenuHook(WPARAM, LPARAM lParam)
{ LPGENW("User &details"), 10, MENU_ITEM, FALSE },
{ LPGENW("User &history"), 20, MENU_ITEM, FALSE }
};
- gcmi->nItems = _countof(Items);
- gcmi->Item = (gc_item*)Items;
+ Chat_AddMenuItems(gcmi->hMenu, _countof(Items), Items);
}
}
diff --git a/protocols/IRCG/src/resource.h b/protocols/IRCG/src/resource.h
index 8727232122..b2462f00ca 100644
--- a/protocols/IRCG/src/resource.h
+++ b/protocols/IRCG/src/resource.h
@@ -11,7 +11,6 @@
#define IDD_PREFS_OTHER 113
#define IDD_ADDSERVER 120
#define IDD_LIST 123
-#define IDR_MENU 129
#define IDD_QUICKCONN 133
#define IDI_MAIN 136
#define IDD_USERINFO 154
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp
index 6dae62da22..8e56330c58 100644
--- a/protocols/IRCG/src/services.cpp
+++ b/protocols/IRCG/src/services.cpp
@@ -819,28 +819,23 @@ int __cdecl CIrcProto::GCMenuHook(WPARAM, LPARAM lParam)
if (gcmi) {
if (!mir_strcmpi(gcmi->pszModule, m_szModuleName)) {
if (gcmi->Type == MENU_ON_LOG) {
- if (mir_wstrcmpi(gcmi->pszID, SERVERWINDOW)) {
- gcmi->nItems = _countof(logItems);
- gcmi->Item = logItems;
- }
- else gcmi->nItems = 0;
+ if (mir_wstrcmpi(gcmi->pszID, SERVERWINDOW))
+ Chat_AddMenuItems(gcmi->hMenu, _countof(logItems), logItems);
}
if (gcmi->Type == MENU_ON_NICKLIST) {
CONTACT user = { (wchar_t*)gcmi->pszUID, NULL, NULL, false, false, false };
MCONTACT hContact = CList_FindContact(&user);
- gcmi->nItems = _countof(nickItems);
- gcmi->Item = nickItems;
BOOL bIsInList = (hContact && db_get_b(hContact, "CList", "NotOnList", 0) == 0);
- gcmi->Item[gcmi->nItems - 1].bDisabled = bIsInList;
+ nickItems[_countof(nickItems)-1].bDisabled = bIsInList;
unsigned long ulAdr = 0;
if (m_manualHost)
ulAdr = ConvertIPToInteger(m_mySpecifiedHostIP);
else
ulAdr = ConvertIPToInteger(m_IPFromServer ? m_myHost : m_myLocalHost);
- gcmi->Item[23].bDisabled = ulAdr == 0 ? TRUE : FALSE; // DCC submenu
+ nickItems[23].bDisabled = ulAdr == 0 ? TRUE : FALSE; // DCC submenu
CHANNELINFO *wi = (CHANNELINFO *)Chat_GetUserInfo(m_szModuleName, gcmi->pszID);
BOOL bServOwner = strchr(sUserModes.c_str(), 'q') == NULL ? FALSE : TRUE;
@@ -852,13 +847,13 @@ int __cdecl CIrcProto::GCMenuHook(WPARAM, LPARAM lParam)
BOOL bForceEnable = GetAsyncKeyState(VK_CONTROL);
- gcmi->Item[6].bDisabled /* "Control" submenu */ = !(bForceEnable || bHalfop || bOp || bAdmin || bOwner);
- gcmi->Item[7].uType = gcmi->Item[8].uType = /* +/- Owner */ bServOwner ? MENU_POPUPITEM : 0;
- gcmi->Item[9].uType = gcmi->Item[10].uType = /* +/- Admin */ bServAdmin ? MENU_POPUPITEM : 0;
- gcmi->Item[7].bDisabled = gcmi->Item[8].bDisabled = gcmi->Item[9].bDisabled = gcmi->Item[10].bDisabled = /* +/- Owner/Admin */
- !(bForceEnable || bOwner);
- gcmi->Item[11].bDisabled = gcmi->Item[12].bDisabled = gcmi->Item[13].bDisabled = gcmi->Item[14].bDisabled = /* +/- Op/hop */
- !(bForceEnable || bOp || bAdmin || bOwner);
+ nickItems[6].bDisabled = !(bForceEnable || bHalfop || bOp || bAdmin || bOwner);
+ nickItems[7].uType = nickItems[8].uType = bServOwner ? MENU_POPUPITEM : 0;
+ nickItems[9].uType = nickItems[10].uType = bServAdmin ? MENU_POPUPITEM : 0;
+ nickItems[7].bDisabled = nickItems[8].bDisabled = nickItems[9].bDisabled = nickItems[10].bDisabled = !(bForceEnable || bOwner);
+ nickItems[11].bDisabled = nickItems[12].bDisabled = nickItems[13].bDisabled = nickItems[14].bDisabled = !(bForceEnable || bOp || bAdmin || bOwner);
+
+ Chat_AddMenuItems(gcmi->hMenu, _countof(nickItems), nickItems);
}
}
}
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index e5b5a5c0b2..7223db5d5f 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -350,38 +350,39 @@ void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, HXML reason)
/////////////////////////////////////////////////////////////////////////////////////////
// Context menu hooks
-static gc_item *sttFindGcMenuItem(GCMENUITEMS *items, DWORD id)
+static gc_item *sttFindGcMenuItem(int nItems, gc_item *items, DWORD id)
{
- for (int i = 0; i < items->nItems; i++)
- if (items->Item[i].dwID == id)
- return items->Item + i;
- return NULL;
+ for (int i = 0; i < nItems; i++)
+ if (items[i].dwID == id)
+ return items + i;
+
+ return nullptr;
}
-static void sttSetupGcMenuItem(GCMENUITEMS *items, DWORD id, bool disabled)
+static void sttSetupGcMenuItem(int nItems, gc_item *items, DWORD id, bool disabled)
{
- for (int i = 0; i < items->nItems; i++)
- if (!id || (items->Item[i].dwID == id))
- items->Item[i].bDisabled = disabled;
+ for (int i = 0; i < nItems; i++)
+ if (!id || (items[i].dwID == id))
+ items[i].bDisabled = disabled;
}
-static void sttShowGcMenuItem(GCMENUITEMS *items, DWORD id, int type)
+static void sttShowGcMenuItem(int nItems, gc_item *items, DWORD id, int type)
{
- for (int i = 0; i < items->nItems; i++)
- if (!id || (items->Item[i].dwID == id))
- items->Item[i].uType = type;
+ for (int i = 0; i < nItems; i++)
+ if (!id || (items[i].dwID == id))
+ items[i].uType = type;
}
-static void sttSetupGcMenuItems(GCMENUITEMS *items, DWORD *ids, bool disabled)
+static void sttSetupGcMenuItems(int nItems, gc_item *items, DWORD *ids, bool disabled)
{
for (; *ids; ++ids)
- sttSetupGcMenuItem(items, *ids, disabled);
+ sttSetupGcMenuItem(nItems, items, *ids, disabled);
}
-static void sttShowGcMenuItems(GCMENUITEMS *items, DWORD *ids, int type)
+static void sttShowGcMenuItems(int nItems, gc_item *items, DWORD *ids, int type)
{
for (; *ids; ++ids)
- sttShowGcMenuItem(items, *ids, type);
+ sttShowGcMenuItem(nItems, items, *ids, type);
}
static gc_item sttLogListItems[] =
@@ -506,14 +507,11 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
if (gcmi->Type == MENU_ON_LOG) {
static wchar_t url_buf[1024] = { 0 };
- gcmi->nItems = _countof(sttLogListItems);
- gcmi->Item = sttLogListItems;
-
static DWORD sttModeratorItems[] = { IDM_LST_PARTICIPANT, 0 };
static DWORD sttAdminItems[] = { IDM_LST_MODERATOR, IDM_LST_MEMBER, IDM_LST_ADMIN, IDM_LST_OWNER, IDM_LST_BAN, 0 };
static DWORD sttOwnerItems[] = { IDM_CONFIG, IDM_DESTROY, 0 };
- sttSetupGcMenuItem(gcmi, 0, FALSE);
+ sttSetupGcMenuItem(_countof(sttLogListItems), sttLogListItems, 0, FALSE);
int idx = IDM_LINK0;
wchar_t *ptszStatusMsg = item->getTemp()->m_tszStatusMessage;
@@ -522,7 +520,7 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
for (wchar_t *p = wcsstr(ptszStatusMsg, L"http"); p && *p; p = wcsstr(p + 1, L"http")) {
if (!wcsncmp(p, L"http://", 7) || !wcsncmp(p, L"https://", 8)) {
mir_wstrncpy(bufPtr, p, _countof(url_buf) - (bufPtr - url_buf));
- gc_item *pItem = sttFindGcMenuItem(gcmi, idx);
+ gc_item *pItem = sttFindGcMenuItem(_countof(sttLogListItems), sttLogListItems, idx);
pItem->pszDesc = bufPtr;
pItem->uType = MENU_POPUPITEM;
for (; *bufPtr && !iswspace(*bufPtr); ++bufPtr);
@@ -534,28 +532,26 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
}
}
for (; idx <= IDM_LINK9; ++idx)
- sttFindGcMenuItem(gcmi, idx)->uType = 0;
+ sttFindGcMenuItem(_countof(sttLogListItems), sttLogListItems, idx)->uType = 0;
if (!GetAsyncKeyState(VK_CONTROL)) {
if (me) {
- sttSetupGcMenuItems(gcmi, sttModeratorItems, (me->m_role < ROLE_MODERATOR));
- sttSetupGcMenuItems(gcmi, sttAdminItems, (me->m_affiliation < AFFILIATION_ADMIN));
- sttSetupGcMenuItems(gcmi, sttOwnerItems, (me->m_affiliation < AFFILIATION_OWNER));
+ sttSetupGcMenuItems(_countof(sttLogListItems), sttLogListItems, sttModeratorItems, (me->m_role < ROLE_MODERATOR));
+ sttSetupGcMenuItems(_countof(sttLogListItems), sttLogListItems, sttAdminItems, (me->m_affiliation < AFFILIATION_ADMIN));
+ sttSetupGcMenuItems(_countof(sttLogListItems), sttLogListItems, sttOwnerItems, (me->m_affiliation < AFFILIATION_OWNER));
}
if (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE)
- sttSetupGcMenuItem(gcmi, IDM_BOOKMARKS, FALSE);
+ sttSetupGcMenuItem(_countof(sttLogListItems), sttLogListItems, IDM_BOOKMARKS, FALSE);
}
+ Chat_AddMenuItems(gcmi->hMenu, _countof(sttLogListItems), sttLogListItems);
}
else if (gcmi->Type == MENU_ON_NICKLIST) {
- gcmi->nItems = _countof(sttListItems);
- gcmi->Item = sttListItems;
-
static DWORD sttRJidItems[] = { IDM_RJID_VCARD, IDM_RJID_ADD, IDM_RJID_COPY, 0 };
if (me && him) {
int i, idx;
BOOL force = GetAsyncKeyState(VK_CONTROL);
- sttSetupGcMenuItem(gcmi, 0, FALSE);
+ sttSetupGcMenuItem(_countof(sttListItems), sttListItems, 0, FALSE);
idx = IDM_LINK0;
LISTFOREACH_NODEF(i, this, LIST_CHATROOM)
@@ -563,7 +559,7 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
if (!item->bChatActive)
continue;
- gc_item *pItem = sttFindGcMenuItem(gcmi, idx);
+ gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, idx);
pItem->pszDesc = item->jid;
pItem->uType = MENU_POPUPITEM;
if (++idx > IDM_LINK9)
@@ -571,16 +567,16 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
}
for (; idx <= IDM_LINK9; ++idx)
- sttFindGcMenuItem(gcmi, idx)->uType = 0;
+ sttFindGcMenuItem(_countof(sttListItems), sttListItems, idx)->uType = 0;
for (i = 0; i < _countof(sttAffiliationItems); i++) {
- gc_item *pItem = sttFindGcMenuItem(gcmi, sttAffiliationItems[i].id);
+ gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, sttAffiliationItems[i].id);
pItem->uType = (him->m_affiliation == sttAffiliationItems[i].value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
pItem->bDisabled = !(force || sttAffiliationItems[i].check(me, him));
}
for (i = 0; i < _countof(sttRoleItems); i++) {
- gc_item *pItem = sttFindGcMenuItem(gcmi, sttRoleItems[i].id);
+ gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, sttRoleItems[i].id);
pItem->uType = (him->m_role == sttRoleItems[i].value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
pItem->bDisabled = !(force || sttRoleItems[i].check(me, him));
}
@@ -590,38 +586,39 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
if (wchar_t *tmp = wcschr(sttRJidBuf, '/')) *tmp = 0;
if (MCONTACT hContact = HContactFromJID(him->m_tszRealJid)) {
- gcmi->Item[3].uType = MENU_HMENU;
- gcmi->Item[3].dwID = (INT_PTR)Menu_BuildContactMenu(hContact);
- sttShowGcMenuItems(gcmi, sttRJidItems, 0);
+ sttListItems[3].uType = MENU_HMENU;
+ sttListItems[3].dwID = (INT_PTR)Menu_BuildContactMenu(hContact);
+ sttShowGcMenuItems(_countof(sttListItems), sttListItems, sttRJidItems, 0);
}
else {
- gcmi->Item[3].uType = MENU_NEWPOPUP;
- sttShowGcMenuItems(gcmi, sttRJidItems, MENU_POPUPITEM);
+ sttListItems[3].uType = MENU_NEWPOPUP;
+ sttShowGcMenuItems(_countof(sttListItems), sttListItems, sttRJidItems, MENU_POPUPITEM);
}
- sttSetupGcMenuItem(gcmi, IDM_CPY_RJID, FALSE);
+ sttSetupGcMenuItem(_countof(sttListItems), sttListItems, IDM_CPY_RJID, FALSE);
}
else {
- gcmi->Item[3].uType = 0;
- sttShowGcMenuItems(gcmi, sttRJidItems, 0);
+ sttListItems[3].uType = 0;
+ sttShowGcMenuItems(_countof(sttListItems), sttListItems, sttRJidItems, 0);
- sttSetupGcMenuItem(gcmi, IDM_CPY_RJID, TRUE);
+ sttSetupGcMenuItem(_countof(sttListItems), sttListItems, IDM_CPY_RJID, TRUE);
}
if (!force) {
if (me->m_role < ROLE_MODERATOR || (me->m_affiliation <= him->m_affiliation))
- sttSetupGcMenuItem(gcmi, IDM_KICK, TRUE);
+ sttSetupGcMenuItem(_countof(sttListItems), sttListItems, IDM_KICK, TRUE);
if ((me->m_affiliation < AFFILIATION_ADMIN) ||
(me->m_affiliation == AFFILIATION_ADMIN) && (me->m_affiliation <= him->m_affiliation))
- sttSetupGcMenuItem(gcmi, IDM_SET_BAN, TRUE);
+ sttSetupGcMenuItem(_countof(sttListItems), sttListItems, IDM_SET_BAN, TRUE);
}
}
else {
- sttSetupGcMenuItem(gcmi, 0, TRUE);
- gcmi->Item[2].uType = 0;
- sttShowGcMenuItems(gcmi, sttRJidItems, 0);
+ sttSetupGcMenuItem(_countof(sttListItems), sttListItems, 0, TRUE);
+ sttListItems[2].uType = 0;
+ sttShowGcMenuItems(_countof(sttListItems), sttListItems, sttRJidItems, 0);
}
+ Chat_AddMenuItems(gcmi->hMenu, _countof(sttListItems), sttListItems);
}
return 0;
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp
index f46ca005ca..e276f165a5 100644
--- a/protocols/MSN/src/msn_chat.cpp
+++ b/protocols/MSN/src/msn_chat.cpp
@@ -574,8 +574,7 @@ int CMsnProto::MSN_GCMenuHook(WPARAM, LPARAM lParam)
{ LPGENW("&Invite user..."), 10, MENU_ITEM, FALSE },
{ LPGENW("&Leave chat session"), 20, MENU_ITEM, FALSE }
};
- gcmi->nItems = _countof(Items);
- gcmi->Item = (gc_item*)Items;
+ Chat_AddMenuItems(gcmi->hMenu, _countof(Items), Items);
}
else if (gcmi->Type == MENU_ON_NICKLIST) {
char *email = mir_u2a(gcmi->pszUID);
@@ -587,8 +586,7 @@ int CMsnProto::MSN_GCMenuHook(WPARAM, LPARAM lParam)
{ L"", 100, MENU_SEPARATOR, FALSE },
{ LPGENW("&Leave chat session"), 110, MENU_ITEM, FALSE }
};
- gcmi->nItems = _countof(Items);
- gcmi->Item = (gc_item*)Items;
+ Chat_AddMenuItems(gcmi->hMenu, _countof(Items), Items);
}
else {
static struct gc_item Items[] =
@@ -608,8 +606,7 @@ int CMsnProto::MSN_GCMenuHook(WPARAM, LPARAM lParam)
if (pszRole && !mir_wstrcmpi(pszRole, L"admin"))
Items[3].pszDesc = LPGENW("&Deop user");
}
- gcmi->nItems = _countof(Items);
- gcmi->Item = (gc_item*)Items;
+ Chat_AddMenuItems(gcmi->hMenu, _countof(Items), Items);
}
mir_free(email);
}
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 30f566e0fc..0d0f304798 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -635,33 +635,22 @@ int CSkypeProto::OnGroupChatMenuHook(WPARAM, LPARAM lParam)
{ LPGENW("&Leave chat session"), 20, MENU_ITEM, FALSE },
{ LPGENW("&Change topic..."), 30, MENU_ITEM, FALSE }
};
- gcmi->nItems = _countof(Items);
- gcmi->Item = (gc_item*)Items;
+ Chat_AddMenuItems(gcmi->hMenu, _countof(Items), Items);
}
else if (gcmi->Type == MENU_ON_NICKLIST)
{
-/* if (IsMe(_T2A(gcmi->pszUID)))
+ static const struct gc_item Items[] =
{
- gcmi->nItems = 0;
- gcmi->Item = NULL;
- }
- else
- {*/
- static const struct gc_item Items[] =
- {
- { LPGENW("Kick &user"), 10, MENU_ITEM },
- { NULL, 0, MENU_SEPARATOR },
- { LPGENW("Set &role"), 20, MENU_NEWPOPUP },
- { LPGENW("&Admin"), 30, MENU_POPUPITEM },
- { LPGENW("&User"), 40, MENU_POPUPITEM },
- { LPGENW("Change nick..."), 50, MENU_ITEM },
- };
- gcmi->nItems = _countof(Items);
- gcmi->Item = (gc_item*)Items;
-// }
+ { LPGENW("Kick &user"), 10, MENU_ITEM },
+ { NULL, 0, MENU_SEPARATOR },
+ { LPGENW("Set &role"), 20, MENU_NEWPOPUP },
+ { LPGENW("&Admin"), 30, MENU_POPUPITEM },
+ { LPGENW("&User"), 40, MENU_POPUPITEM },
+ { LPGENW("Change nick..."), 50, MENU_ITEM },
+ };
+ Chat_AddMenuItems(gcmi->hMenu, _countof(Items), Items);
}
-
return 0;
}
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 5806f618ce..484602e265 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -797,14 +797,11 @@ int CVkProto::OnGcMenuHook(WPARAM, LPARAM lParam)
if (mir_strcmpi(gcmi->pszModule, m_szModuleName))
return 0;
- if (gcmi->Type == MENU_ON_LOG) {
- gcmi->nItems = _countof(sttLogListItems);
- gcmi->Item = sttLogListItems;
- }
- else if (gcmi->Type == MENU_ON_NICKLIST) {
- gcmi->nItems = _countof(sttListItems);
- gcmi->Item = sttListItems;
- }
+ if (gcmi->Type == MENU_ON_LOG)
+ Chat_AddMenuItems(gcmi->hMenu, _countof(sttLogListItems), sttLogListItems);
+ else if (gcmi->Type == MENU_ON_NICKLIST)
+ Chat_AddMenuItems(gcmi->hMenu, _countof(sttListItems), sttListItems);
+
return 0;
}
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp
index a87be6a24f..38f4878f7d 100644
--- a/protocols/WhatsApp/src/chat.cpp
+++ b/protocols/WhatsApp/src/chat.cpp
@@ -273,14 +273,10 @@ int WhatsAppProto::OnChatMenu(WPARAM, LPARAM lParam)
if (mir_strcmpi(gcmi->pszModule, m_szModuleName))
return 0;
- if (gcmi->Type == MENU_ON_LOG) {
- gcmi->nItems = _countof(sttLogListItems);
- gcmi->Item = sttLogListItems;
- }
- else if (gcmi->Type == MENU_ON_NICKLIST) {
- gcmi->nItems = _countof(sttNickListItems);
- gcmi->Item = sttNickListItems;
- }
+ if (gcmi->Type == MENU_ON_LOG)
+ Chat_AddMenuItems(gcmi->hMenu, _countof(sttLogListItems), sttLogListItems);
+ else if (gcmi->Type == MENU_ON_NICKLIST)
+ Chat_AddMenuItems(gcmi->hMenu, _countof(sttNickListItems), sttNickListItems);
return 0;
}