summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_menus.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-03-17 20:33:47 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-03-17 20:33:47 +0000
commitdd3d0e59dcd34beb222fcf612a51d3fee82c0e43 (patch)
tree0ae5a6e0a83399036d1452256ee3f89dc6da8872 /protocols/SkypeWeb/src/skype_menus.cpp
parent076fa9b3142f55fc736fbf58b20bfa45973acd68 (diff)
SkypeWeb: initial commit
git-svn-id: http://svn.miranda-ng.org/main/trunk@12424 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_menus.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_menus.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp
new file mode 100644
index 0000000000..cd38b5a4c5
--- /dev/null
+++ b/protocols/SkypeWeb/src/skype_menus.cpp
@@ -0,0 +1,97 @@
+#include "common.h"
+
+HGENMENU CSkypeProto::ContactMenuItems[CMI_MAX];
+
+int CSkypeProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
+{
+ if (!hContact)
+ return 0;
+
+ if (m_iStatus < ID_STATUS_ONLINE)
+ return 0;
+
+ if (this->isChatRoom(hContact))
+ return 0;
+
+ bool isCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ bool isAuthNeed = getByte(hContact, "Auth", 0) > 0;
+ bool isGrantNeed = getByte(hContact, "Grant", 0) > 0;
+
+ Menu_ShowItem(ContactMenuItems[CMI_AUTH_REQUEST], isCtrlPressed || isAuthNeed);
+ Menu_ShowItem(ContactMenuItems[CMI_AUTH_GRANT], isCtrlPressed || isGrantNeed);
+
+ return 0;
+}
+
+int CSkypeProto::PrebuildContactMenu(WPARAM hContact, LPARAM lParam)
+{
+ for (int i = 0; i < SIZEOF(ContactMenuItems); i++)
+ {
+ Menu_ShowItem(ContactMenuItems[i], false);
+ }
+ CSkypeProto *proto = CSkypeProto::GetContactAccount(hContact);
+ return proto ? proto->OnPrebuildContactMenu(hContact, lParam) : 0;
+}
+
+void CSkypeProto::InitMenus()
+{
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CSkypeProto::PrebuildContactMenu);
+
+ //hChooserMenu = MO_CreateMenuObject("SkypeAccountChooser", LPGEN("Skype menu chooser"), 0, "Skype/MenuChoose");
+
+ CLISTMENUITEM mi = { sizeof(CLISTMENUITEM) };
+ mi.flags = CMIF_TCHAR;
+
+ // 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<&CSkypeProto::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<&CSkypeProto::OnGrantAuth>);
+}
+
+void CSkypeProto::UninitMenus()
+{
+}
+
+
+int CSkypeProto::OnInitStatusMenu()
+{
+ char text[MAX_PATH];
+ mir_strcpy(text, m_szModuleName);
+ char *tDest = text + strlen(text);
+
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.pszService = text;
+
+ HGENMENU hStatusMunuRoot = MO_GetProtoRootMenu(m_szModuleName);
+ if (!hStatusMunuRoot)
+ {
+ mi.ptszName = m_tszUserName;
+ mi.position = -1999901006;
+ mi.hParentMenu = HGENMENU_ROOT;
+ mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
+ mi.icolibItem = GetSkinIconHandle("main");
+ hStatusMunuRoot = /*m_hMenuRoot = */Menu_AddProtoMenuItem(&mi);
+ }
+ /*else
+ {
+ if (m_hMenuRoot)
+ CallService(MO_REMOVEMENUITEM, (WPARAM)m_hMenuRoot, 0);
+ m_hMenuRoot = NULL;
+ }*/
+
+ mi.hParentMenu = hStatusMunuRoot;
+ mi.flags = CMIF_CHILDPOPUP | CMIF_TCHAR;
+
+ return 0;
+} \ No newline at end of file