summaryrefslogtreecommitdiff
path: root/protocols/Tox
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-09 16:13:50 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-09 16:13:50 +0300
commitd15bd517fb0eb4bbdb1b118b44398b00bc8f6d6a (patch)
treeead9ec16a070ed6237975fe00a368fec2491e1ad /protocols/Tox
parentb407cbb7ad5cf00f0420fd91b82969ffcbaba5b5 (diff)
all duplicate "Request auth", "Grant auth" & "Revoke auth" menu items eliminated
Diffstat (limited to 'protocols/Tox')
-rw-r--r--protocols/Tox/src/main.cpp1
-rw-r--r--protocols/Tox/src/tox_menus.cpp43
-rw-r--r--protocols/Tox/src/tox_menus.h2
-rw-r--r--protocols/Tox/src/tox_proto.cpp6
-rw-r--r--protocols/Tox/src/tox_proto.h15
5 files changed, 14 insertions, 53 deletions
diff --git a/protocols/Tox/src/main.cpp b/protocols/Tox/src/main.cpp
index 99cd7607a1..6bff578137 100644
--- a/protocols/Tox/src/main.cpp
+++ b/protocols/Tox/src/main.cpp
@@ -37,7 +37,6 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC
int OnModulesLoaded(WPARAM, LPARAM)
{
CToxProto::InitIcons();
- CToxProto::InitContactMenu();
hProfileFolderPath = FoldersRegisterCustomPathT("Tox", "ProfilesFolder", MIRANDA_USERDATAT, TranslateT("Profiles folder"));
diff --git a/protocols/Tox/src/tox_menus.cpp b/protocols/Tox/src/tox_menus.cpp
index 5694689e1a..9dc0ee8b79 100644
--- a/protocols/Tox/src/tox_menus.cpp
+++ b/protocols/Tox/src/tox_menus.cpp
@@ -1,9 +1,12 @@
#include "stdafx.h"
-HGENMENU CToxProto::ContactMenuItems[CMI_MAX];
+// HGENMENU CToxProto::ContactMenuItems[CMI_MAX];
int CToxProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
{
+ // for (auto &it : ContactMenuItems)
+ // Menu_ShowItem(it, false);
+
if (!hContact)
return 0;
@@ -16,48 +19,14 @@ int CToxProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
bool isCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
bool isAuthNeed = getByte(hContact, "Auth", 0) > 0;
- Menu_ShowItem(ContactMenuItems[CMI_AUTH_REQUEST], isCtrlPressed || isAuthNeed);
+ Menu_ShowItem(m_hmiReqAuth, isCtrlPressed || isAuthNeed);
bool isGrantNeed = getByte(hContact, "Grant", 0) > 0;
- Menu_ShowItem(ContactMenuItems[CMI_AUTH_GRANT], isCtrlPressed || isGrantNeed);
+ Menu_ShowItem(m_hmiGrantAuth, isCtrlPressed || isGrantNeed);
return 0;
}
-int CToxProto::PrebuildContactMenu(WPARAM hContact, LPARAM lParam)
-{
- for (auto &it : ContactMenuItems)
- Menu_ShowItem(it, FALSE);
- CToxProto *proto = CToxProto::GetContactAccount(hContact);
- return proto ? proto->OnPrebuildContactMenu(hContact, lParam) : 0;
-}
-
-void CToxProto::InitContactMenu()
-{
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CToxProto::PrebuildContactMenu);
-
- CMenuItem mi;
- mi.flags = CMIF_UNICODE;
-
- // Request authorization
- SET_UID(mi, 0x36375a1f, 0xc142, 0x4d6e, 0xa6, 0x57, 0xe4, 0x76, 0x5d, 0xbc, 0x59, 0x8e);
- mi.pszService = MODULE"/RequestAuth";
- mi.name.w = LPGENW("Request authorization");
- mi.position = CMI_POSITION + CMI_AUTH_REQUEST;
- mi.hIcolibItem = ::Skin_GetIconHandle(SKINICON_AUTH_REQUEST);
- ContactMenuItems[CMI_AUTH_REQUEST] = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, GlobalService<&CToxProto::OnRequestAuth>);
-
- // Grant authorization
- SET_UID(mi, 0x4c90452a, 0x869a, 0x4a81, 0xaf, 0xa8, 0x28, 0x34, 0xaf, 0x2b, 0x6b, 0x30);
- mi.pszService = MODULE"/GrantAuth";
- mi.name.w = LPGENW("Grant authorization");
- mi.position = CMI_POSITION + CMI_AUTH_GRANT;
- mi.hIcolibItem = ::Skin_GetIconHandle(SKINICON_AUTH_GRANT);
- ContactMenuItems[CMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, GlobalService<&CToxProto::OnGrantAuth>);
-}
-
int CToxProto::UpdateStatusMenu(WPARAM, LPARAM)
{
bool isOnline = IsOnline();
diff --git a/protocols/Tox/src/tox_menus.h b/protocols/Tox/src/tox_menus.h
index 85b9f55055..e7c0d10340 100644
--- a/protocols/Tox/src/tox_menus.h
+++ b/protocols/Tox/src/tox_menus.h
@@ -5,8 +5,6 @@
enum CMI_MENU_ITEMS
{
- CMI_AUTH_REQUEST,
- CMI_AUTH_GRANT,
CMI_MAX // this item shall be the last one
};
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
index f5c435b89a..a6159e06f3 100644
--- a/protocols/Tox/src/tox_proto.cpp
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -24,12 +24,18 @@ CToxProto::CToxProto(const char* protoName, const wchar_t* userName)
CreateProtoService(PS_GETMYAVATAR, &CToxProto::GetMyAvatar);
CreateProtoService(PS_SETMYAVATAR, &CToxProto::SetMyAvatar);
+ // menus
+ CreateProtoService(PS_MENU_REQAUTH, &CToxProto::OnRequestAuth);
+ CreateProtoService(PS_MENU_GRANTAUTH, &CToxProto::OnGrantAuth);
+
// nick
CreateProtoService(PS_SETMYNICKNAME, &CToxProto::SetMyNickname);
// events
CreateServiceFunction(MODULE "/GetEventIcon", &CToxProto::EventGetIcon);
+ HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CToxProto::OnPrebuildContactMenu);
+
hTerminateEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
}
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h
index 97acbe5dac..cfbee1b4ec 100644
--- a/protocols/Tox/src/tox_proto.h
+++ b/protocols/Tox/src/tox_proto.h
@@ -11,7 +11,7 @@ struct CToxProto : public PROTO<CToxProto>
public:
//////////////////////////////////////////////////////////////////////////////////////
- //Ctors
+ // Ctors
CToxProto(const char *protoName, const wchar_t *userName);
~CToxProto();
@@ -55,9 +55,6 @@ public:
// icons
static void InitIcons();
- // menus
- static void InitContactMenu();
-
// utils
static void ShowNotification(const wchar_t *message, int flags = 0, MCONTACT hContact = NULL);
@@ -139,8 +136,7 @@ private:
// menus
static HGENMENU ContactMenuItems[CMI_MAX];
- int OnPrebuildContactMenu(WPARAM hContact, LPARAM);
- static int PrebuildContactMenu(WPARAM hContact, LPARAM lParam);
+ int __cdecl OnPrebuildContactMenu(WPARAM hContact, LPARAM);
HGENMENU StatusMenuItems[SMI_MAX];
int OnInitStatusMenu();
@@ -257,13 +253,6 @@ private:
static bool IsFileExists(const wchar_t* path);
MEVENT AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, PBYTE pBlob, size_t cbBlob);
-
- template<INT_PTR(__cdecl CToxProto::*Service)(WPARAM, LPARAM)>
- static INT_PTR __cdecl GlobalService(WPARAM wParam, LPARAM lParam)
- {
- CToxProto *proto = CToxProto::GetContactAccount((MCONTACT)wParam);
- return proto ? (proto->*Service)(wParam, lParam) : 0;
- }
};
#endif //_TOX_PROTO_H_ \ No newline at end of file