summaryrefslogtreecommitdiff
path: root/protocols/Slack/src/slack_menus.cpp
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2017-03-12 21:19:21 +0300
committeraunsane <aunsane@gmail.com>2017-03-12 21:19:38 +0300
commitb9c2a6953f0fa75a1c4de6079e9c97b3a60be7e5 (patch)
tree83940e0306fd9b0eca9dfe7ce679b437cde9331b /protocols/Slack/src/slack_menus.cpp
parent9826bda7bcd2a2024eac0fcecffc9633f5ac79f6 (diff)
Slack: initial commit
Diffstat (limited to 'protocols/Slack/src/slack_menus.cpp')
-rw-r--r--protocols/Slack/src/slack_menus.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/protocols/Slack/src/slack_menus.cpp b/protocols/Slack/src/slack_menus.cpp
new file mode 100644
index 0000000000..183971237f
--- /dev/null
+++ b/protocols/Slack/src/slack_menus.cpp
@@ -0,0 +1,57 @@
+#include "stdafx.h"
+
+HGENMENU CSlackProto::ContactMenuItems[CMI_MAX];
+
+int CSlackProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
+{
+ if (!hContact)
+ return 0;
+
+ if (!this->IsOnline())
+ return 0;
+
+ if (this->isChatRoom(hContact))
+ return 0;
+
+ bool isCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
+
+ bool isAuthNeed = getByte(hContact, "Auth", 0) > 0;
+ Menu_ShowItem(ContactMenuItems[CMI_AUTH_REQUEST], isCtrlPressed || isAuthNeed);
+
+ bool isGrantNeed = getByte(hContact, "Grant", 0) > 0;
+ Menu_ShowItem(ContactMenuItems[CMI_AUTH_GRANT], isCtrlPressed || isGrantNeed);
+
+ return 0;
+}
+
+int CSlackProto::PrebuildContactMenu(WPARAM hContact, LPARAM lParam)
+{
+ for (int i = 0; i < _countof(ContactMenuItems); i++)
+ Menu_ShowItem(ContactMenuItems[i], FALSE);
+ CSlackProto *proto = CSlackProto::GetContactAccount(hContact);
+ return proto ? proto->OnPrebuildContactMenu(hContact, lParam) : 0;
+}
+
+void CSlackProto::InitMenus()
+{
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CSlackProto::PrebuildContactMenu);
+
+ CMenuItem mi;
+ mi.flags = CMIF_UNICODE;
+ /*
+ // Request authorization
+ mi.pszService = MODULE"/RequestAuth";
+ mi.ptszName = LPGENT("Request authorization");
+ mi.position = CMI_POSITION + CMI_AUTH_REQUEST;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_REQUEST);
+ ContactMenuItems[CMI_AUTH_REQUEST] = Menu_AddContactMenuItem(&mi);
+ CreateServiceFunction(mi.pszService, GlobalService<&CSlackProto::OnRequestAuth>);
+
+ // Grant authorization
+ mi.pszService = MODULE"/GrantAuth";
+ mi.ptszName = LPGENT("Grant authorization");
+ mi.position = CMI_POSITION + CMI_AUTH_GRANT;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_GRANT);
+ ContactMenuItems[CMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
+ CreateServiceFunction(mi.pszService, GlobalService<&CSlackProto::OnGrantAuth>);*/
+}