void addProtoStatusMenuItem(char *protoName) { PROTOACCOUNT *pdescr = Proto_GetAccount(protoName); if (pdescr == nullptr || pdescr->ppro == nullptr) return; HGENMENU hRoot = Menu_GetProtocolRoot(pdescr->ppro); if (hRoot == nullptr) return; char buf[200]; mir_snprintf(buf, "CSList/ShowList/%s", protoName); if (!ServiceExists(buf)) CreateServiceFunctionParam(buf, showList, (LPARAM)protoName); CMenuItem mi(g_plugin); mi.flags = CMIF_UNICODE; mi.hIcolibItem = forms[0].hIcoLibItem; mi.name.w = MODULENAME; mi.position = 2000040000; mi.pszService = buf; mi.root = hRoot; Menu_AddStatusMenuItem(&mi); RegisterHotkeys(buf, pdescr->tszAccountName, pdescr->iOrder); }
int InitMenus(WPARAM wParam, LPARAM lParam) { GoogleTalkAcc *pga = isGoogle(lParam); if (pga != NULL) { LPCSTR szModuleName = pga->m_japi->GetModuleName(); char szServiceName[100]; mir_snprintf(szServiceName, "%s/%s", szModuleName, MS_GTALKEXT_OPENMAILBOX); CreateServiceFunctionParam(szServiceName, OpenMailboxMenuHandler, (LPARAM)szModuleName); CMenuItem mi; mi.root = HGENMENU(wParam); mi.hIcolibItem = g_hPopupIcon; mi.position = 200101; mi.name.a = LPGEN("Open mailbox"); mi.pszService = szServiceName; Menu_AddProtoMenuItem(&mi); } return 0; }
void Meta_InitServices() { previousMode = mcStatus = ID_STATUS_OFFLINE; CreateServiceFunction("MetaContacts/Convert", Meta_Convert); CreateServiceFunction("MetaContacts/AddTo", Meta_AddTo); CreateServiceFunction("MetaContacts/Edit", Meta_Edit); CreateServiceFunction("MetaContacts/Delete", Meta_Delete); CreateServiceFunction("MetaContacts/Default", Meta_Default); // hidden contact menu items...ho hum for (int i = 0; i < MAX_CONTACTS; i++) { char szServiceName[100]; mir_snprintf(szServiceName, SIZEOF(szServiceName), "MetaContacts/MenuFunc%d", i); CreateServiceFunctionParam(szServiceName, MenuFunc, i); } CreateProtoServiceFunction(META_PROTO, PS_GETCAPS, Meta_GetCaps); CreateProtoServiceFunction(META_PROTO, PS_GETNAME, Meta_GetName); CreateProtoServiceFunction(META_PROTO, PS_LOADICON, Meta_LoadIcon); CreateProtoServiceFunction(META_PROTO, PS_SETSTATUS, Meta_SetStatus); CreateProtoServiceFunction(META_PROTO, PS_GETSTATUS, Meta_GetStatus); CreateProtoServiceFunction(META_PROTO, PSS_MESSAGE, Meta_SendMessage); CreateProtoServiceFunction(META_PROTO, PSS_USERISTYPING, Meta_UserIsTyping); // file recv is done by subcontacts CreateProtoServiceFunction(META_PROTO, PSS_FILE, Meta_FileSend); CreateProtoServiceFunction(META_PROTO, PSS_GETAWAYMSG, Meta_GetAwayMsg); CreateProtoServiceFunction(META_PROTO, PS_GETAVATARINFOT, Meta_GetAvatarInfo); CreateProtoServiceFunction(META_PROTO, PSS_GETINFO, Meta_GetInfo); // receive filter CreateProtoServiceFunction(META_FILTER, PSR_MESSAGE, MetaFilter_RecvMessage); // API services and events CreateApiServices(); CreateServiceFunction("MetaContacts/OnOff", Meta_OnOff); CreateServiceFunction(MS_MC_GETSRMMSUB, Meta_SrmmCurrentSub); CreateProtoServiceFunction(META_PROTO, PS_SEND_NUDGE, Meta_SendNudge); // create our hookable events hSubcontactsChanged = CreateHookableEvent(ME_MC_SUBCONTACTSCHANGED); // hook other module events we need HookEvent(ME_PROTO_ACK, Meta_HandleACK); HookEvent(ME_DB_CONTACT_DELETED, Meta_ContactDeleted); HookEvent(ME_DB_CONTACT_SETTINGCHANGED, Meta_SettingChanged); HookEvent(ME_OPT_INITIALISE, Meta_OptInit); HookEvent(ME_SYSTEM_MODULESLOADED, Meta_ModulesLoaded); HookEvent(ME_SYSTEM_PRESHUTDOWN, Meta_PreShutdown); // hook our own events, used to call Meta_GetMostOnline which sets nick for metacontact HookEvent(ME_MC_DEFAULTTCHANGED, Meta_CallMostOnline); // redirect nudge events hEventNudge = CreateHookableEvent(META_PROTO "/Nudge"); }
static INT_PTR PreBuildContactMenu(WPARAM wParam, LPARAM lParam) { HideMenuItem(hCMCall); HideMenuItem(hCMAnswer); HideMenuItem(hCMHold); HideMenuItem(hCMDrop); for(unsigned int i = 0; i < hCMCalls.size(); ++i) HideMenuItem(hCMCalls[i]); HANDLE hContact = (HANDLE) wParam; if (hContact == NULL) return -1; hContact = ConvertMetacontact(hContact); // There is a current call already? VoiceCall *call = FindVoiceCall(hContact); if (call == NULL) { OBJLIST<CallingMethod> methods(10, sttCompareCallingMethods); BuildCallingMethodsList(&methods, hContact); if (methods.getCount() == 1) { CallingMethod *method = &methods[0]; TCHAR name[128]; if (!IsEmpty(method->number)) mir_sntprintf(name, MAX_REGS(name), TranslateT("Call %s with %s"), method->number, method->provider->description); else mir_sntprintf(name, MAX_REGS(name), TranslateT("Call with %s"), method->provider->description); CLISTMENUITEM mi = {0}; mi.cbSize = sizeof(mi); mi.flags = CMIM_FLAGS | CMIF_TCHAR | CMIM_NAME; mi.ptszName = name; CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hCMCall, (LPARAM) &mi); } else if (methods.getCount() > 1) { CLISTMENUITEM mi = {0}; mi.cbSize = sizeof(mi); mi.flags = CMIM_FLAGS | CMIF_TCHAR | CMIM_NAME; mi.ptszName = _T("Call"); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hCMCall, (LPARAM) &mi); for(int i = 0; i < methods.getCount(); ++i) { CallingMethod *method = &methods[i]; HICON hIcon = method->provider->GetIcon(); TCHAR name[128]; if (!IsEmpty(method->number)) mir_sntprintf(name, MAX_REGS(name), TranslateT("%s with %s"), method->number, method->provider->description); else mir_sntprintf(name, MAX_REGS(name), TranslateT("with %s"), method->provider->description); char service[128]; mir_snprintf(service, MAX_REGS(service), "VoiceService/ContactMenu/Call_%d", i); CLISTMENUITEM mi = {0}; mi.cbSize = sizeof(mi); mi.position = i; mi.flags = CMIF_TCHAR | CMIF_ROOTHANDLE; mi.ptszName = name; mi.hIcon = hIcon; mi.pszService = service; mi.hParentMenu = (HGENMENU) hCMCall; if (i == hCMCalls.size()) { CreateServiceFunctionParam(service, Service_CallItem, i); HANDLE hMenu = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); hCMCalls.push_back(hMenu); } else { HANDLE hMenu = hCMCalls[i]; mi.flags = mi.flags | CMIM_ALL; CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hMenu, (LPARAM) &mi); } method->provider->ReleaseIcon(hIcon); } } } else { switch (call->state) { case VOICE_STATE_CALLING: { ShowMenuItem(hCMDrop); break; } case VOICE_STATE_TALKING: { if (call->module->CanHold()) ShowMenuItem(hCMHold); ShowMenuItem(hCMDrop); break; } case VOICE_STATE_RINGING: case VOICE_STATE_ON_HOLD: { ShowMenuItem(hCMAnswer); ShowMenuItem(hCMDrop); break; } } } return 0; }
void g_MenuInit(void) { hStatusMenuInit = CreateHookableEvent(ME_JABBER_MENUINIT); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, JabberPrebuildContactMenu); CreateServiceFunction("Jabber/MenuChoose", JabberMenuChooseService); hChooserMenu = Menu_AddObject("JabberAccountChooser", LPGEN("Jabber account chooser"), 0, "Jabber/MenuChoose"); { CMenuItem mi; mi.name.a = "Cancel"; mi.position = 9999999; mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE); Menu_AddItem(hChooserMenu, &mi, NULL); } ////////////////////////////////////////////////////////////////////////////////////// // Contact menu initialization CMenuItem mi; mi.flags = CMIF_UNMOVABLE; // "Request authorization" SET_UID(mi, 0x36375a1f, 0xc142, 0x4d6e, 0xa6, 0x57, 0xe4, 0x76, 0x5d, 0xbc, 0x59, 0x8e); mi.name.a = LPGEN("Request authorization"); mi.position = -2000001000; mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REQUEST); mi.pszService = "Jabber/ReqAuth"; g_hMenuRequestAuth = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuHandleRequestAuth); // "Grant authorization" SET_UID(mi, 0x4c90452a, 0x869a, 0x4a81, 0xaf, 0xa8, 0x28, 0x34, 0xaf, 0x2b, 0x6b, 0x30); mi.pszService = "Jabber/GrantAuth"; mi.name.a = LPGEN("Grant authorization"); mi.position = -2000001001; mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_GRANT); g_hMenuGrantAuth = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuHandleGrantAuth); // Revoke auth SET_UID(mi, 0x619efdcb, 0x99c0, 0x44a8, 0xbf, 0x28, 0xc3, 0xe0, 0x2f, 0xb3, 0x7e, 0x77); mi.pszService = "Jabber/RevokeAuth"; mi.name.a = LPGEN("Revoke authorization"); mi.position = -2000001002; mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REVOKE); g_hMenuRevokeAuth = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuRevokeAuth); // "Convert Chat/Contact" SET_UID(mi, 0xa98894ec, 0xbaa6, 0x4e1e, 0x8d, 0x75, 0x72, 0xc, 0xae, 0x25, 0xd8, 0x87); mi.pszService = "Jabber/ConvertChatContact"; mi.name.a = LPGEN("Convert"); mi.position = -1999901004; mi.hIcolibItem = g_GetIconHandle(IDI_USER2ROOM); g_hMenuConvert = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuConvertChatContact); // "Add to roster" SET_UID(mi, 0x3928ba10, 0x69bc, 0x4ec9, 0x96, 0x48, 0xa4, 0x1b, 0xbe, 0x58, 0x4a, 0x7e); mi.pszService = "Jabber/AddToRoster"; mi.name.a = LPGEN("Add to roster"); mi.position = -1999901005; mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_ADD); g_hMenuRosterAdd = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuRosterAdd); // "Add to Bookmarks" SET_UID(mi, 0x7d06d00b, 0x3a3e, 0x4d65, 0xac, 0xc5, 0x63, 0xe2, 0x60, 0xbe, 0xc6, 0x6); mi.pszService = "Jabber/AddToBookmarks"; mi.name.a = LPGEN("Add to Bookmarks"); mi.position = -1999901006; mi.hIcolibItem = g_GetIconHandle(IDI_BOOKMARKS); g_hMenuAddBookmark = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuBookmarkAdd); // Login/logout SET_UID(mi, 0x7674d540, 0x2638, 0x4958, 0x99, 0xda, 0x8, 0x3f, 0xad, 0x66, 0x8f, 0xed); mi.pszService = "Jabber/TransportLogin"; mi.name.a = LPGEN("Login/logout"); mi.position = -1999901007; mi.hIcolibItem = g_GetIconHandle(IDI_LOGIN); g_hMenuLogin = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuTransportLogin); // Retrieve nicks SET_UID(mi, 0x6adf70d9, 0x6e92, 0x4a4f, 0x90, 0x71, 0x67, 0xa7, 0xaa, 0x1a, 0x19, 0x7a); mi.pszService = "Jabber/TransportGetNicks"; mi.name.a = LPGEN("Resolve nicks"); mi.position = -1999901008; mi.hIcolibItem = g_GetIconHandle(IDI_REFRESH); g_hMenuRefresh = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuTransportResolve); // Run Commands SET_UID(mi, 0x25546e26, 0xc82, 0x4715, 0xb8, 0xca, 0xe5, 0xf7, 0x2a, 0x58, 0x9, 0x2); mi.pszService = "Jabber/RunCommands"; mi.name.a = LPGEN("Commands"); mi.position = -1999901009; mi.hIcolibItem = g_GetIconHandle(IDI_COMMAND); g_hMenuCommands = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberContactMenuRunCommands); // Send Note SET_UID(mi, 0xf4b0cc51, 0xab9, 0x4cf0, 0x96, 0xaa, 0x22, 0xa0, 0x33, 0x9b, 0x56, 0xc5); mi.pszService = "Jabber/SendNote"; mi.name.a = LPGEN("Send Note"); mi.position = -1999901010; mi.hIcolibItem = g_GetIconHandle(IDI_SEND_NOTE); g_hMenuSendNote = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuSendNote); // Direct Presence SET_UID(mi, 0x89803943, 0xa87e, 0x4ae9, 0xbf, 0x79, 0xe3, 0xf3, 0xd6, 0x86, 0xf8, 0x3d); mi.pszService = "Jabber/DirectPresenceDummySvc"; mi.name.a = LPGEN("Send Presence"); mi.position = -1999901011; mi.hIcolibItem = g_GetIconHandle(IDI_NOTES); g_hMenuDirectPresence[0] = Menu_AddContactMenuItem(&mi); UNSET_UID(mi); mi.flags |= CMIF_TCHAR; mi.root = g_hMenuDirectPresence[0]; for (int i = 0; i < _countof(PresenceModeArray); i++) { char buf[] = "Jabber/DirectPresenceX"; buf[_countof(buf) - 2] = '0' + i; mi.pszService = buf; mi.name.t = pcli->pfnGetStatusModeDescription(PresenceModeArray[i].mode, 0); mi.position = -1999901000; mi.hIcolibItem = Skin_LoadIcon(PresenceModeArray[i].icon); g_hMenuDirectPresence[i + 1] = Menu_AddContactMenuItem(&mi); CreateServiceFunctionParam(mi.pszService, JabberMenuHandleDirectPresence, PresenceModeArray[i].mode); } mi.flags &= ~(CMIF_TCHAR); mi.root = NULL; // Resource selector SET_UID(mi, 0x32a7bb9d, 0x4d9, 0x49b3, 0xac, 0x8f, 0x83, 0xb5, 0x6b, 0xff, 0x4f, 0x5); mi.pszService = "Jabber/ResourceSelectorDummySvc"; mi.name.a = LPGEN("Jabber Resource"); mi.position = -1999901011; mi.hIcolibItem = g_GetIconHandle(IDI_JABBER); g_hMenuResourcesRoot = Menu_AddContactMenuItem(&mi); SET_UID(mi, 0xb8059d69, 0xa927, 0x4d68, 0xb4, 0x88, 0xf7, 0x32, 0x85, 0x50, 0xde, 0x6f); mi.pszService = "Jabber/UseResource_last"; mi.name.a = LPGEN("Last Active"); mi.position = -1999901000; mi.root = g_hMenuResourcesRoot; mi.hIcolibItem = g_GetIconHandle(IDI_JABBER); g_hMenuResourcesActive = Menu_AddContactMenuItem(&mi); CreateServiceFunctionParam(mi.pszService, JabberMenuHandleResource, MENUITEM_LASTSEEN); SET_UID(mi,0xf44812ea, 0x4f37, 0x4a57, 0x86, 0xa8, 0x40, 0x51, 0x22, 0x9f, 0xd5, 0xa8); mi.pszService = "Jabber/UseResource_server"; mi.name.a = LPGEN("Server's Choice"); mi.position = -1999901000; mi.hIcolibItem = g_GetIconHandle(IDI_NODE_SERVER); g_hMenuResourcesServer = Menu_AddContactMenuItem(&mi); CreateServiceFunctionParam(mi.pszService, JabberMenuHandleResource, MENUITEM_SERVER); }
int WhatsAppProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam) { HANDLE hContact = reinterpret_cast<HANDLE>(wParam); if (hContact) debugLogA(this->GetContactDisplayName(hContact).c_str()); else debugLogA("No contact found"); if (g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP] != NULL) CallService("CList/RemoveContactMenuItem", (WPARAM) g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP], (LPARAM) 0); if (g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP] != NULL) CallService("CList/RemoveContactMenuItem", (WPARAM) g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP], (LPARAM) 0); int chatType = getByte(hContact, "SimpleChatRoom", 0); CLISTMENUITEM mi = {sizeof(mi)}; if (chatType == 0) { mi.flags = CMIF_CHILDPOPUP; mi.position= -2000006102; mi.icolibItem = GetIconHandle("addContactToGroup"); mi.pszName = GetIconDescription("addContactToGroup"); mi.pszService = NULL; g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP] = Menu_AddContactMenuItem(&mi); if (!isOnline()) { Menu_ShowItem(g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP], false); return 0; } mi.hParentMenu = (HGENMENU) g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP]; mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR; int iGrpCount = 0; string fullSvcName; string svcName = m_szModuleName; svcName += "/AddContactToGroup_"; DBVARIANT dbv; for (map<HANDLE, map<HANDLE, bool>>::iterator it = this->isMemberByGroupContact.begin(); it != this->isMemberByGroupContact.end(); ++it) { map<HANDLE, bool>::iterator memberIt = it->second.find(hContact); // Only, if current contact is not already member of this group if ((memberIt == it->second.end() || memberIt->second == false) && !getString(it->first, "ID", &dbv)) { fullSvcName = svcName + dbv.pszVal; mi.pszService = (char*) fullSvcName.c_str(); mi.ptszName = mir_a2t_cp(this->GetContactDisplayName(it->first).c_str(), CP_UTF8); CreateServiceFunctionParam(mi.pszService, GlobalServiceParam<&WhatsAppProto::OnAddContactToGroup>, (LPARAM) it->first); Menu_AddContactMenuItem(&mi); db_free(&dbv); mir_free(mi.ptszName); iGrpCount++; } } if (!iGrpCount) Menu_ShowItem(g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP], false); } else if (chatType == 1) { mi.flags = CMIM_FLAGS; if (!isOnline() || getByte(hContact, "IsGroupMember", 0) == 0) mi.flags |= CMIF_GRAYED; CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_LEAVE_GROUP], (LPARAM) &mi); } else if (chatType == 2) { // owning chat/group mi.flags = CMIF_CHILDPOPUP; mi.position= -2000006102; mi.icolibItem = GetIconHandle("removeContactFromGroup"); mi.pszName = GetIconDescription("removeContactFromGroup"); mi.pszService = NULL; g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP] = Menu_AddContactMenuItem(&mi); bool bShow = false; if (isOnline() && getByte(hContact, "IsGroupMember", 0) == 1) { map<HANDLE, map<HANDLE, bool>>::iterator groupsIt = this->isMemberByGroupContact.find(hContact); if (groupsIt == this->isMemberByGroupContact.end()) { debugLogA("Group exists only on contact list"); } else { mi.hParentMenu = (HGENMENU) g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP]; mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR; string fullSvcName; string svcName = m_szModuleName; svcName += "/RemoveContactFromGroup_"; DBVARIANT dbv; for (map<HANDLE, bool>::iterator it = groupsIt->second.begin(); it != groupsIt->second.end(); ++it) { if (!getString(it->first, "ID", &dbv)) { fullSvcName = svcName + dbv.pszVal; mi.pszService = (char*) fullSvcName.c_str(); mi.ptszName = mir_a2t_cp(this->GetContactDisplayName(it->first).c_str(), CP_UTF8); CreateServiceFunctionParam(mi.pszService, GlobalServiceParam<&WhatsAppProto::OnRemoveContactFromGroup>, (LPARAM) it->first); Menu_AddContactMenuItem(&mi); db_free(&dbv); mir_free(mi.ptszName); bShow = true; } } } } else Menu_ShowItem(g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP], false); Menu_ShowItem(g_hContactMenuItems[CMI_REMOVE_GROUP], bShow); Menu_ShowItem(g_hContactMenuItems[CMI_CHANGE_GROUP_SUBJECT], bShow); } return 0; }