int LoadFavoriteContactMenu() { Icon_Register(g_hInst, LPGEN("Contact list"), iconList, _countof(iconList)); CreateServiceFunction(CLUI_FAVSETRATE, FAV_SetRate); CreateServiceFunction(CLUI_FAVTOGGLESHOWOFFLINE, FAV_ToggleShowOffline); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, FAV_OnContactMenuBuild); CMenuItem mi; SET_UID(mi, 0xf99a2320, 0xc024, 0x48bd, 0x81, 0xf7, 0x9f, 0xa2, 0x5, 0xb0, 0x7f, 0xdc); mi.name.t = FAVMENUROOTNAME; mi.flags = CMIF_TCHAR; hFavoriteContactMenu = Menu_AddContactMenuItem(&mi); Menu_ConfigureItem(hFavoriteContactMenu, MCI_OPT_UNIQUENAME, "ModernClistMenu_ContactRate"); UNSET_UID(mi); mi.root = hFavoriteContactMenu; mi.flags = CMIF_TCHAR | CMIF_SYSTEM; // not included into new menu settings mi.pszService = CLUI_FAVSETRATE; for (int i = 0; i < _countof(rates); i++) { mi.hIcolibItem = iconList[i].hIcolib; mi.name.t = rates[i]; hFavoriteContactMenuItems[i] = Menu_AddContactMenuItem(&mi); Menu_ConfigureItem(hFavoriteContactMenuItems[i], MCI_OPT_EXECPARAM, i); } mi.hIcolibItem = NULL; mi.pszService = CLUI_FAVTOGGLESHOWOFFLINE; mi.position = -100000000; mi.name.t = LPGENT("Show even if offline"); hShowIfOflineItem = Menu_AddContactMenuItem(&mi); Menu_ConfigureItem(hShowIfOflineItem, MCI_OPT_EXECPARAM, _countof(rates) + 100000000); return 0; }
HGENMENU CMraProto::CListCreateMenu(LONG lPosition, LONG lPopupPosition, BOOL bIsMain, const IconItem *pgdiItems, size_t dwCount, HGENMENU *hResult) { if (!pgdiItems || !dwCount || !hResult) return NULL; char szServiceFunction[MAX_PATH]; CMenuItem mi; HGENMENU hRootMenu, (__stdcall *fnAddFunc)(TMO_MenuItem*, const char*); if (bIsMain) { fnAddFunc = Menu_AddProtoMenuItem; hRootMenu = Menu_GetProtocolRoot(this); if (hRootMenu == NULL) { mi.name.t = m_tszUserName; mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; mi.hIcolibItem = g_hMainIcon; hRootMenu = Menu_AddProtoMenuItem(&mi); } mi.position = 20003; mi.root = hRootMenu; } else { fnAddFunc = Menu_AddContactMenuItem; mi.position = lPosition; } SET_UID(mi, 0x83C8B6A7, 0xEC0D, 0x41D6, 0x8A, 0x0E, 0xAC, 0x90, 0x8C, 0xEE, 0xAF, 0xFE); mi.flags = 0; mi.name.a = LPGEN("Services..."); mi.hIcolibItem = g_hMainIcon; hRootMenu = fnAddFunc(&mi, m_szModuleName); UNSET_UID(mi); mi.flags = CMIF_SYSTEM; mi.root = hRootMenu; mi.pszService = szServiceFunction; for (size_t i = 0; i < dwCount; i++) { mi.pszService = pgdiItems[i].szName; mi.position = int(lPosition + i); mi.hIcolibItem = pgdiItems[i].hIcolib; mi.name.a = pgdiItems[i].szDescr; hResult[i] = fnAddFunc(&mi, m_szModuleName); Menu_ConfigureItem(hResult[i], MCI_OPT_EXECPARAM, lPopupPosition); } return hRootMenu; }
void MakeMenuItem(lua_State *L, CMenuItem &mi) { mi.hLangpack = hScriptsLangpack; lua_pushliteral(L, "Flags"); lua_gettable(L, -2); mi.flags = lua_tointeger(L, -1); lua_pop(L, 1); if (!(mi.flags & CMIF_TCHAR)) mi.flags |= CMIF_TCHAR; lua_pushliteral(L, "Uid"); lua_gettable(L, -2); const char* uuid = (char*)lua_tostring(L, -1); if (CLSIDFromString((LPCOLESTR)ptrT(mir_utf8decodeT(uuid)), (LPCLSID)&mi.uid) != NOERROR) UNSET_UID(mi); lua_pop(L, 1); lua_pushliteral(L, "Name"); lua_gettable(L, -2); mi.name.t = mir_utf8decodeT((char*)luaL_checkstring(L, -1)); lua_pop(L, 1); lua_pushliteral(L, "Position"); lua_gettable(L, -2); mi.position = lua_tointeger(L, -1); lua_pop(L, 1); lua_pushliteral(L, "Icon"); lua_gettable(L, -2); mi.hIcolibItem = (HANDLE)lua_touserdata(L, -1); lua_pop(L, 1); lua_pushliteral(L, "Service"); lua_gettable(L, -2); mi.pszService = (char*)lua_tostring(L, -1); lua_pop(L, 1); lua_pushliteral(L, "Parent"); lua_gettable(L, -2); mi.root = (HGENMENU)lua_touserdata(L, -1); lua_pop(L, 1); }
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 MirandaLoaded(WPARAM, LPARAM) { LoadMsgTreeModule(); LoadCListModule(); InitUpdateMsgs(); g_IconList.ReloadIcons(); int numAccs = 0; PROTOACCOUNT **accs; Proto_EnumAccounts(&numAccs, &accs); for (int i = 0, CurProtoIndex = 0; i < numAccs && CurProtoIndex < MAXICQACCOUNTS; i++) { HANDLE hHook = HookEvent(CString(accs[i]->szModuleName) + ME_ICQ_STATUSMSGREQ, StatusMsgReqHooks[CurProtoIndex]); if (hHook) { ICQProtoList[CurProtoIndex] = accs[i]->szModuleName; CurProtoIndex++; } } CreateServiceFunction(MS_AWAYSYS_SETCONTACTSTATMSG, SetContactStatMsg); CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_TOGGLE, ToggleSendOnEvent); CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_ON, srvAutoreplyOn); CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_OFF, srvAutoreplyOff); CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_USEDEFAULT, srvAutoreplyUseDefault); CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSGW, GetStatusMsgW); CreateServiceFunction(MS_NAS_GETSTATEA, GetStateA); CreateServiceFunction(MS_NAS_SETSTATEA, SetStateA); CreateServiceFunction(MS_NAS_GETSTATEW, GetStateW); CreateServiceFunction(MS_NAS_SETSTATEW, SetStateW); CreateServiceFunction(MS_NAS_INVOKESTATUSWINDOW, InvokeStatusWindow); // and old AwaySysMod service, for compatibility reasons CreateServiceFunction(MS_AWAYSYS_SETSTATUSMODE, SetStatusMode); HookEvent(ME_TTB_MODULELOADED, Create_TopToolbar); HookEvent(ME_OPT_INITIALISE, OptsDlgInit); HookEvent(ME_CLIST_STATUSMODECHANGE, StatusChanged); HookEvent(ME_CS_STATUSCHANGEEX, CSStatusChange); // for compatibility with StartupStatus and AdvancedAutoAway HookEvent(ME_DB_CONTACT_SETTINGCHANGED, DBSettingChanged); HookEvent(ME_DB_EVENT_FILTER_ADD, MsgEventAdded); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu); HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged); HookEvent(ME_IDLE_CHANGED, IdleChangeEvent); g_hReadWndList = WindowList_Create(); int SendOnEvent = CContactSettings(g_ProtoStates[(char*)NULL].m_status).Autoreply; CMenuItem mi; SET_UID(mi, 0xa379c361, 0x9e3f, 0x468d, 0xb2, 0xac, 0xc4, 0x89, 0xbb, 0xfc, 0x81, 0x15); mi.position = 1000020000; mi.flags = CMIF_TCHAR | CMIF_NOTOFFLINE; mi.hIcolibItem = iconList[SendOnEvent ? 1 : 0].hIcolib; mi.name.t = SendOnEvent ? DISABLE_SOE_COMMAND : ENABLE_SOE_COMMAND; mi.pszService = MS_AWAYSYS_AUTOREPLY_TOGGLE; g_hToggleSOEMenuItem = Menu_AddMainMenuItem(&mi); memset(&mi, 0, sizeof(mi)); SET_UID(mi, 0xd3282acc, 0x9ff1, 0x4ede, 0x8a, 0x1e, 0x36, 0x72, 0x3f, 0x44, 0x4f, 0x84); mi.position = -2000005000; mi.flags = CMIF_TCHAR | CMIF_NOTOFFLINE | CMIF_HIDDEN; mi.name.t = LPGENT("Read status message"); // never seen... mi.pszService = MS_AWAYMSG_SHOWAWAYMSG; g_hReadStatMenuItem = Menu_AddContactMenuItem(&mi); if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_USEMENUITEM)) { memset(&mi, 0, sizeof(mi)); SET_UID(mi, 0xc42a4fdb, 0x51b8, 0x4bbe, 0x83, 0xee, 0x2d, 0x32, 0x29, 0x5c, 0x2, 0xb3); mi.flags = CMIF_TCHAR | CMIF_HIDDEN; mi.name.t = LPGENT("Set status message"); // will never be shown mi.position = 1000020000; mi.hIcolibItem = iconList[8].hIcolib; mi.pszService = MS_AWAYSYS_SETCONTACTSTATMSG; g_hContactMenuItem = Menu_AddContactMenuItem(&mi); memset(&mi, 0, sizeof(mi)); SET_UID(mi, 0x47a3c631, 0x8ca9, 0x4b7e, 0x84, 0x6e, 0x29, 0xbf, 0x53, 0x30, 0x6f, 0x83); mi.flags = CMIF_TCHAR; mi.hIcolibItem = NULL; mi.position = 1000020000; mi.name.t = LPGENT("Autoreply"); g_hToggleSOEContactMenuItem = Menu_AddContactMenuItem(&mi); UNSET_UID(mi); mi.flags = CMIF_TCHAR | CMIF_SYSTEM; mi.root = g_hToggleSOEContactMenuItem; mi.position = 1000020000; mi.hIcolibItem = iconList[1].hIcolib; mi.name.t = LPGENT("On"); mi.pszService = MS_AWAYSYS_AUTOREPLY_ON; g_hAutoreplyOnContactMenuItem = Menu_AddContactMenuItem(&mi); mi.hIcolibItem = iconList[0].hIcolib; mi.name.t = LPGENT("Off"); mi.pszService = MS_AWAYSYS_AUTOREPLY_OFF; g_hAutoreplyOffContactMenuItem = Menu_AddContactMenuItem(&mi); mi.hIcolibItem = iconList[5].hIcolib; mi.name.t = LPGENT("Use the default setting"); mi.pszService = MS_AWAYSYS_AUTOREPLY_USEDEFAULT; g_hAutoreplyUseDefaultContactMenuItem = Menu_AddContactMenuItem(&mi); } // add that funky thingy (just tweaked a bit, was spotted in Miranda's src code) // we have to read the status message from contacts too... err CreateServiceFunction(MS_AWAYMSG_SHOWAWAYMSG, GetContactStatMsg); SkinAddNewSoundEx(AWAYSYS_STATUSMSGREQUEST_SOUND, NULL, LPGEN("NewAwaySys: Incoming status message request")); if (ServiceExists(MS_VARS_REGISTERTOKEN)) { CreateServiceFunction(MS_AWAYSYS_FREEVARMEM, srvFreeVarMem); CreateServiceFunction(MS_AWAYSYS_VARIABLESHANDLER, srvVariablesHandler); TOKENREGISTER tr = { sizeof(tr) }; tr.szService = MS_AWAYSYS_VARIABLESHANDLER; tr.szCleanupService = MS_AWAYSYS_FREEVARMEM; tr.memType = TR_MEM_OWNER; for (int i = 0; i < _countof(Variables); i++) { tr.flags = Variables[i].Flags | TRF_CALLSVC | TRF_TCHAR; tr.tszTokenString = Variables[i].Name; tr.szHelpText = Variables[i].Descr; CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr); } } HookEvent(ME_MODERNOPT_INITIALIZE, ModernOptInitialise); return 0; }