void CJabberProto::UpdatePriorityMenu(short priority) { if (!m_hMenuPriorityRoot || m_priorityMenuValSet && (priority == m_priorityMenuVal)) return; TCHAR szName[128]; mir_sntprintf(szName, TranslateT("Resource priority [%d]"), (int)priority); Menu_ModifyItem(m_hMenuPriorityRoot, szName); m_priorityMenuVal = priority; m_priorityMenuValSet = true; }
static INT_PTR OnMainMenu_HideAll(WPARAM, LPARAM) { fcOpt.bHideAll = !fcOpt.bHideAll; db_set_b(NULL, MODULE, "HideAll", (BYTE)fcOpt.bHideAll); OnStatusChanged(); Menu_ModifyItem(hMainMenuItemHideAll, fcOpt.bHideAll ? LPGENT("Show all thumbs") : LPGENT("Hide all thumbs"), LoadIcon(hInst, MAKEINTRESOURCE(fcOpt.bHideAll ? IDI_SHOW : IDI_HIDE))); return 0; }
static int OnBuildSubGroupMenu(WPARAM wParam, LPARAM) { ClcGroup *group = (ClcGroup *)wParam; if (group == 0) return 0; //contact->group CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS | (group->hideOffline ? CMIF_CHECKED : 0); Menu_ModifyItem(hHideOfflineUsersHereMenuItem, &mi); return 0; }
static INT_PTR OnMainMenu_HideAll(WPARAM wParam, LPARAM lParam) { fcOpt.bHideAll = !fcOpt.bHideAll; db_set_b(NULL, MODULE, "HideAll", (BYTE)fcOpt.bHideAll); OnStatusChanged(); CLISTMENUITEM clmi = { sizeof(clmi) }; clmi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR; clmi.hIcon = LoadIcon( hInst, MAKEINTRESOURCE(fcOpt.bHideAll ? IDI_SHOW : IDI_HIDE)); clmi.ptszName = fcOpt.bHideAll ? LPGENT("Show all thumbs") : LPGENT("Hide all thumbs"); Menu_ModifyItem(hMainMenuItemHideAll, &clmi); return 0; }
static int IconsChanged(WPARAM, LPARAM) { LoadActions(); CLISTMENUITEM mi = { sizeof(mi) }; if (PopupOptions.ModuleIsEnabled == TRUE) { //The module is enabled. //The action to do is "disable popups" (show disabled) and we must write "enable popup" in the new item. mi.hIcon = IcoLib_GetIcon(ICO_POPUP_ON, 0); } else { //The module is disabled. //The action to do is enable popups (show enabled), then write "disable popup" in the new item. mi.hIcon = IcoLib_GetIcon(ICO_POPUP_OFF, 0); } mi.flags = CMIM_ICON; Menu_ModifyItem(hMenuItem, &mi); Menu_ModifyItem(hMenuRoot, &mi); mi.hIcon = IcoLib_GetIcon(ICO_HISTORY, 0); mi.flags = CMIM_ICON; Menu_ModifyItem(hMenuItemHistory, &mi); return 0; }
static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM lParam) { TCHAR str[128]; char *szProto = GetContactProto(hContact); int iHidden = szProto ? db_get_b(hContact, szProto, "ChatRoom", 0) : 0; int iStatus; if (!iHidden) { iHidden = 1; iStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGRECV) { if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iStatus == ID_STATUS_OFFLINE ? ID_STATUS_INVISIBLE : iStatus)) { iHidden = 0; HICON hIcon = Skin_LoadProtoIcon(szProto, iStatus); mir_sntprintf(str, _countof(str), TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(iStatus, 0)); Menu_ModifyItem(hAwayMsgMenuItem, str, hIcon, 0); IcoLib_ReleaseIcon(hIcon); } } } else Menu_ShowItem(hAwayMsgMenuItem, false); ptrA szMsg(db_get_sa(hContact, "CList", "StatusMsg")); if (!iHidden && szMsg != NULL) { mir_sntprintf(str, _countof(str), TranslateT("Copy %s message"), pcli->pfnGetStatusModeDescription(iStatus, 0)); Menu_ModifyItem(hCopyMsgMenuItem, str); } else Menu_ShowItem(hCopyMsgMenuItem, false); if (!iHidden && szMsg != NULL && StrFindURL(szMsg) != NULL) { mir_sntprintf(str, _countof(str), TranslateT("&Go to URL in %s message"), pcli->pfnGetStatusModeDescription(iStatus, 0)); Menu_ModifyItem(hGoToURLMenuItem, str); } else Menu_ShowItem(hGoToURLMenuItem, false); return 0; }
static int GenMenuInit(WPARAM, LPARAM) // Modify menu item text before to show the main menu { if (g_hMenuItem) { TCHAR buf[128] = {0}; mir_sntprintf(buf, SIZEOF(buf), _T("%s [%s]"), TranslateT("Hide"), GetBossKeyText()); CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS | CMIF_TCHAR | CMIM_NAME; mi.ptszName = buf; Menu_ModifyItem(g_hMenuItem, &mi); } return 0; }
int PreBuildContactMenu(WPARAM hContact, LPARAM) { char *szProto = GetContactProto(hContact); int iMode = szProto ? CallProtoService(szProto, PS_GETSTATUS, 0, 0) : 0; int Flag1 = szProto ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) : 0; int iContactMode = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); TCHAR szSetStr[256], szReadStr[256]; szSetStr[0] = szReadStr[0] = 0; HICON hReadMsgIcon = NULL; if (szProto) { int i; for (i = _countof(StatusModeList) - 1; i >= 0; i--) if (iMode == StatusModeList[i].Status) break; // the protocol supports status message sending for current status, or autoreplying if ((Flag1 & PF1_MODEMSGSEND && CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iMode)) || ((Flag1 & PF1_IM) == PF1_IM && (i < 0 || !g_AutoreplyOptPage.GetDBValueCopy(StatusModeList[i].DisableReplyCtlID)))) mir_sntprintf(szSetStr, TranslateT("Set %s message for the contact"), pcli->pfnGetStatusModeDescription(iMode, 0), pcli->pfnGetContactDisplayName(hContact, 0)); // the protocol supports status message reading for contact's status if (Flag1 & PF1_MODEMSGRECV && CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iContactMode)) { mir_sntprintf(szReadStr, TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(iContactMode, 0)); hReadMsgIcon = Skin_LoadProtoIcon(szProto, iContactMode); } } if (g_hContactMenuItem) { if (szSetStr[0] == 0) Menu_ShowItem(g_hContactMenuItem, false); else Menu_ModifyItem(g_hContactMenuItem, szSetStr, iconList[8].hIcolib, 0); // if this contact supports sending/receiving messages if ((Flag1 & PF1_IM) == PF1_IM) { int iAutoreply = CContactSettings(g_ProtoStates[szProto].m_status, hContact).Autoreply; HANDLE hIcon; switch (iAutoreply) { case VAL_USEDEFAULT: hIcon = Skin_LoadIcon(IDI_DOT); break; case 0: hIcon = iconList[0].hIcolib; break; default: iAutoreply = 1; hIcon = iconList[1].hIcolib; break; } Menu_ModifyItem(g_hToggleSOEContactMenuItem, NULL, hIcon, 0); Menu_ModifyItem(g_hAutoreplyOnContactMenuItem, NULL, iconList[1].hIcolib, (iAutoreply == 1) ? CMIF_CHECKED : 0); Menu_ModifyItem(g_hAutoreplyOffContactMenuItem, NULL, iconList[0].hIcolib, (iAutoreply == 0) ? CMIF_CHECKED : 0); Menu_ModifyItem(g_hAutoreplyUseDefaultContactMenuItem, NULL, iconList[5].hIcolib, (iAutoreply == VAL_USEDEFAULT) ? CMIF_CHECKED : 0); } else // hide the Autoreply menu item Menu_ShowItem(g_hToggleSOEContactMenuItem, false); } if (szReadStr[0] == 0) Menu_ShowItem(g_hReadStatMenuItem, false); else Menu_ModifyItem(g_hReadStatMenuItem, szReadStr, hReadMsgIcon, 0); return 0; }
INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/) { CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_NAME | CMIM_ICON; if (!hDirectBoundPort) { NETLIBUSERSETTINGS nus = { 0 }; nus.cbSize = sizeof(nus); if (!CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM) hNetlibUser, (LPARAM) &nus)) Netlib_Logf(hNetlibUser, "Failed to get NETLIBUSERSETTINGS using MS_NETLIB_GETUSERSETTINGS"); NETLIBBIND nlb = { 0 }; nlb.cbSize = sizeof(NETLIBBIND); nlb.pfnNewConnection = ConnectionOpen; if (nus.specifyIncomingPorts && nus.szIncomingPorts && nus.szIncomingPorts[0]) nlb.wPort = 0; else nlb.wPort = 80; hDirectBoundPort = (HANDLE) CallService(MS_NETLIB_BINDPORT, (WPARAM) hNetlibUser, (LPARAM) & nlb); if (!hDirectBoundPort) { TCHAR szTemp[200]; mir_snprintf(szTemp, SIZEOF(szTemp), TranslateT("Failed to bind to port %s\r\nThis is most likely because another program or service is using this port") , nlb.wPort == 80 ? "80" : nus.szIncomingPorts); MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_OK); return 1001; } dwLocalPortUsed = nlb.wPort; dwLocalIpAddress = nlb.dwInternalIP; mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DISABLE_SERVER)); mi.ptszName = LPGENT("Disable HTTP server"); } else if (hDirectBoundPort && wparam == 0) { Netlib_CloseHandle(hDirectBoundPort); hDirectBoundPort = 0; mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE)); mi.ptszName = LPGENT("Enable HTTP server"); } else return 0; // no changes; if (hAcceptConnectionsMenuItem) Menu_ModifyItem(hAcceptConnectionsMenuItem, &mi); if (! bShutdownInProgress) db_set_b(NULL, MODULE, "AcceptConnections", hDirectBoundPort != 0); return 0; }
CJabberProto* JabberChooseInstance(bool bIsLink) { if (g_Instances.getCount() == 0) return NULL; if (g_Instances.getCount() == 1) { if (g_Instances[0]->m_iStatus != ID_STATUS_OFFLINE && g_Instances[0]->m_iStatus != ID_STATUS_CONNECTING) return g_Instances[0]; return NULL; } if (bIsLink) for (int i = 0; i < g_Instances.getCount(); i++) if (g_Instances[i]->m_options.ProcessXMPPLinks) return g_Instances[i]; int nItems = 0, lastItemId = 0; for (int i = 0; i < g_Instances.getCount(); i++) { CJabberProto *ppro = g_Instances[i]; if (ppro->m_iStatus != ID_STATUS_OFFLINE && ppro->m_iStatus != ID_STATUS_CONNECTING) { ++nItems; lastItemId = i + 1; Menu_ModifyItem(ppro->m_hChooseMenuItem, NULL, Skin_LoadProtoIcon(ppro->m_szModuleName, ppro->m_iStatus)); } else Menu_ShowItem(ppro->m_hChooseMenuItem, false); } if (nItems > 1) { POINT pt; GetCursorPos(&pt); HMENU hMenu = CreatePopupMenu(); Menu_Build(hMenu, hChooserMenu); int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, pcli->hwndContactList, NULL); DestroyMenu(hMenu); if (res) { CJabberProto* pro = NULL; Menu_ProcessCommandById(res, (LPARAM)&pro); return pro; } return NULL; } return lastItemId ? g_Instances[lastItemId - 1] : NULL; }
void UpdateMenu(BOOL State) { CLISTMENUITEM mi = { sizeof(mi) }; if (!State) { // to enable auto-update mi.ptszName = LPGENT("Auto Update Enabled"); mi.icolibItem = GetIconHandle("enabled"); } else { // to disable auto-update mi.ptszName = LPGENT("Auto Update Disabled"); mi.icolibItem = GetIconHandle("disabled"); } mi.flags = CMIM_ICON | CMIM_NAME | CMIF_TCHAR; Menu_ModifyItem(hService2[0], &mi); CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTBButton, State ? TTBST_PUSHED : TTBST_RELEASED); db_set_b(NULL, MODULE, "AutoUpdate", !State); }
static int FAV_OnContactMenuBuild(WPARAM hContact, LPARAM) { BYTE bContactRate = db_get_b(hContact, "CList", "Rate", 0); if (bContactRate > _countof(rates) - 1) bContactRate = _countof(rates) - 1; CMString tszName; if (!bContactRate) tszName = FAVMENUROOTNAME; else tszName.Format(_T("%s (%s)"), TranslateTS(FAVMENUROOTNAME), TranslateTS(rates[bContactRate])); Menu_ModifyItem(hFavoriteContactMenu, tszName); for (int i = 0; i < _countof(rates); i++) Menu_SetChecked(hFavoriteContactMenuItems[i], bContactRate == i); Menu_SetChecked(hShowIfOflineItem, db_get_b(hContact, "CList", "noOffline", 0) != 0); return 0; }
static int PrebuildMainMenu(WPARAM wParam, LPARAM lParam) { // we have to use ME_CLIST_PREBUILDMAINMENU instead of updating menu items only on settings change, because "popup_enabled" and "popup_disabled" icons are not always available yet in ModulesLoaded if (bPopupExists) { CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIF_TCHAR | CMIM_NAME | CMIM_ICON; if (g_PopupOptPage.GetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY)) { mi.ptszName = LPGENT("Disable c&lient change notification"); mi.hIcon = Skin_GetIcon("popup_enabled"); } else { mi.ptszName = LPGENT("Enable c&lient change notification"); mi.hIcon = Skin_GetIcon("popup_disabled"); } mi.ptszPopupName = LPGENT("Popups"); Menu_ModifyItem(g_hTogglePopupsMenuItem, &mi); } return 0; }
int __cdecl CMsnProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam) { switch(eventType) { case EV_PROTO_ONLOAD: return OnModulesLoaded(0, 0); case EV_PROTO_ONEXIT: return OnPreShutdown(0, 0); case EV_PROTO_ONOPTIONS: return OnOptionsInit(wParam, lParam); case EV_PROTO_ONMENU: MsnInitMainMenu(); break; case EV_PROTO_ONERASE: { char szDbsettings[64]; mir_snprintf(szDbsettings, sizeof(szDbsettings), "%s_HTTPS", m_szModuleName); CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szDbsettings); break; } case EV_PROTO_ONRENAME: if (mainMenuRoot) { CLISTMENUITEM clmi = { sizeof(clmi) }; clmi.flags = CMIM_NAME | CMIF_TCHAR; clmi.ptszName = m_tszUserName; Menu_ModifyItem(mainMenuRoot, &clmi); } break; case EV_PROTO_ONCONTACTDELETED: return OnContactDeleted(wParam, lParam); case EV_PROTO_DBSETTINGSCHANGED: return OnDbSettingChanged(wParam, lParam); } return 1; }
void UpdatePopupMenu(BOOL State) { // update option setting opt.UsePopup = State; db_set_b(NULL, WEATHERPROTONAME, "UsePopup", (BYTE)opt.UsePopup); CLISTMENUITEM mi = { sizeof(mi) }; if (State) { // to enable popup mi.pszName = LPGEN("Disable &weather notification"); mi.icolibItem = GetIconHandle("popup"); } else { // to disable popup mi.pszName = LPGEN("Enable &weather notification"); mi.icolibItem = GetIconHandle("nopopup"); } mi.flags = CMIM_ICON | CMIM_NAME; Menu_ModifyItem(hEnableDisablePopupMenu, &mi); }
static INT_PTR EnableDisableMenuCommand(WPARAM wParam,LPARAM lParam) { Disabled = !Disabled; if (PluginConfig.g_PopupAvail) { CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_ICON | CMIM_NAME; if (!Disabled) { mi.pszName = LPGEN("Disable &typing notification"); mi.hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ENABLED)); } else { mi.pszName = LPGEN("Enable &typing notification"); mi.hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_DISABLED)); } Menu_ModifyItem(hDisableMenu, &mi); } return 0; }
int CIcqProto::OnPreBuildContactMenu(WPARAM wParam, LPARAM) { HANDLE hContact = (HANDLE)wParam; if (hContact == NULL) return 0; if (icqOnline()) { BOOL bCtrlPressed = (GetKeyState(VK_CONTROL)&0x8000 ) != 0; DWORD dwUin = getContactUin(hContact); Menu_ShowItem(g_hContactMenuItems[ICMI_AUTH_REQUEST], dwUin && (bCtrlPressed || (getByte((HANDLE)wParam, "Auth", 0) && getWord((HANDLE)wParam, DBSETTING_SERVLIST_ID, 0)))); Menu_ShowItem(g_hContactMenuItems[ICMI_AUTH_GRANT], dwUin && (bCtrlPressed || getByte((HANDLE)wParam, "Grant", 0))); Menu_ShowItem(g_hContactMenuItems[ICMI_AUTH_REVOKE], dwUin && (bCtrlPressed || (getByte("PrivacyItems", 0) && !getByte((HANDLE)wParam, "Grant", 0)))); Menu_ShowItem(g_hContactMenuItems[ICMI_ADD_TO_SERVLIST], m_bSsiEnabled && !getWord((HANDLE)wParam, DBSETTING_SERVLIST_ID, 0) && !getWord((HANDLE)wParam, DBSETTING_SERVLIST_IGNORE, 0) && !db_get_b(hContact, "CList", "NotOnList", 0)); } Menu_ShowItem(g_hContactMenuItems[ICMI_OPEN_PROFILE],getContactUin(hContact) != 0); BYTE bXStatus = getContactXStatus((HANDLE)wParam); Menu_ShowItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS], m_bHideXStatusUI ? 0 : bXStatus != 0); if (bXStatus && !m_bHideXStatusUI) { CLISTMENUITEM clmi = { sizeof(clmi) }; clmi.flags = CMIM_ICON; if (bXStatus > 0 && bXStatus <= XSTATUS_COUNT) clmi.hIcon = getXStatusIcon(bXStatus, LR_SHARED); else clmi.hIcon = LoadSkinnedIcon(SKINICON_OTHER_SMALLDOT); Menu_ModifyItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS], &clmi); } return 0; }
void UpdateMenu(BOOL State) { // update option setting opt.CAutoUpdate = State; db_set_b(NULL, WEATHERPROTONAME, "AutoUpdate", (BYTE)State); CLISTMENUITEM mi = { sizeof(mi) }; if (State) { // to enable auto-update mi.pszName = LPGEN("Auto Update Enabled"); mi.icolibItem = GetIconHandle("main"); opt.AutoUpdate = 1; } else { // to disable auto-update mi.pszName = LPGEN("Auto Update Disabled"); mi.icolibItem = GetIconHandle("disabled"); opt.AutoUpdate = 0; } mi.flags = CMIM_ICON | CMIM_NAME; Menu_ModifyItem(hEnableDisableMenu, &mi); CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTBButton, !State ? TTBST_PUSHED : TTBST_RELEASED); }
static int OnBuildGroupMenu(WPARAM wParam, LPARAM lParam) { CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS | (cfg::getByte("CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT) ? CMIF_CHECKED : 0); Menu_ModifyItem(hHideOfflineUsersMenuItem, &mi); mi.flags = CMIM_FLAGS | (SendMessage(pcli->hwndContactTree, CLM_GETHIDEOFFLINEROOT, 0, 0) ? CMIF_CHECKED : 0); Menu_ModifyItem(hHideOfflineUsersOutHereMenuItem, &mi); mi.flags = CMIM_FLAGS | (GetWindowLongPtr(pcli->hwndContactTree, GWL_STYLE) & CLS_HIDEEMPTYGROUPS ? CMIF_CHECKED : 0); Menu_ModifyItem(hHideEmptyGroupsMenuItem, &mi); mi.flags = CMIM_FLAGS | (GetWindowLongPtr(pcli->hwndContactTree, GWL_STYLE) & CLS_USEGROUPS ? 0 : CMIF_CHECKED); Menu_ModifyItem(hDisableGroupsMenuItem, &mi); mi.flags = CMIM_FLAGS; Menu_ModifyItem(hGroupMainMenuItemProxy, &mi); mi.flags = CMIM_FLAGS; Menu_ModifyItem(hAppearanceMenuItemProxy, &mi); return 0; }
void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) { XmlNode *queryNode; char *type; char *str; // RECVED: roster information // ACTION: populate LIST_ROSTER and create contact for any new rosters if ((type=TlenXmlGetAttrValue(iqNode, "type")) == NULL) return; if ((queryNode=TlenXmlGetChild(iqNode, "query")) == NULL) return; if (!strcmp(type, "result")) { str = TlenXmlGetAttrValue(queryNode, "xmlns"); if (str != NULL && !strcmp(str, "jabber:iq:roster")) { DBVARIANT dbv; XmlNode *itemNode, *groupNode; TLEN_SUBSCRIPTION sub; TLEN_LIST_ITEM *item; char *jid, *name, *nick; int i, oldStatus; for (i=0; i<queryNode->numChild; i++) { itemNode = queryNode->child[i]; if (!strcmp(itemNode->name, "item")) { str = TlenXmlGetAttrValue(itemNode, "subscription"); if (str == NULL) sub = SUB_NONE; else if (!strcmp(str, "both")) sub = SUB_BOTH; else if (!strcmp(str, "to")) sub = SUB_TO; else if (!strcmp(str, "from")) sub = SUB_FROM; else sub = SUB_NONE; //if (str != NULL && (!strcmp(str, "to") || !strcmp(str, "both"))) { if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) { if ((name=TlenXmlGetAttrValue(itemNode, "name")) != NULL) nick = TlenTextDecode(name); else nick = TlenLocalNickFromJID(jid); if (nick != NULL) { MCONTACT hContact; item = TlenListAdd(proto, LIST_ROSTER, jid); if (item->nick) mir_free(item->nick); item->nick = nick; item->subscription = sub; if ((hContact=TlenHContactFromJID(proto, jid)) == NULL) { // Received roster has a new JID. // Add the jid (with empty resource) to Miranda contact list. hContact = TlenDBCreateContact(proto, jid, nick, FALSE); } db_set_s(hContact, "CList", "MyHandle", nick); if (item->group) mir_free(item->group); if ((groupNode=TlenXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) { item->group = TlenGroupDecode(groupNode->text); Clist_CreateGroup(0, _A2T(item->group)); // Don't set group again if already correct, or Miranda may show wrong group count in some case if (!db_get(hContact, "CList", "Group", &dbv)) { if (strcmp(dbv.pszVal, item->group)) db_set_s(hContact, "CList", "Group", item->group); db_free(&dbv); } else db_set_s(hContact, "CList", "Group", item->group); } else { item->group = NULL; db_unset(hContact, "CList", "Group"); } if (!db_get(hContact, proto->m_szModuleName, "AvatarHash", &dbv)) { if (item->avatarHash) mir_free(item->avatarHash); item->avatarHash = mir_strdup(dbv.pszVal); proto->debugLogA("Setting hash [%s] = %s", nick, item->avatarHash); db_free(&dbv); } item->avatarFormat = db_get_dw(hContact, proto->m_szModuleName, "AvatarFormat", PA_FORMAT_UNKNOWN); } } } } // Delete orphaned contacts (if roster sync is enabled) if (db_get_b(NULL, proto->m_szModuleName, "RosterSync", FALSE) == TRUE) { for (MCONTACT hContact = db_find_first(proto->m_szModuleName); hContact; ) { MCONTACT hNext = hContact = db_find_next(hContact, proto->m_szModuleName); ptrA jid( db_get_sa(hContact, proto->m_szModuleName, "jid")); if (jid != NULL) { if (!TlenListExist(proto, LIST_ROSTER, jid)) { proto->debugLogA("Syncing roster: deleting 0x%x", hContact); CallService(MS_DB_CONTACT_DELETE, hContact, 0); } } hContact = hNext; } } CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS; Menu_ModifyItem(proto->hMenuMUC, &mi); if (proto->hMenuChats != NULL) Menu_ModifyItem(proto->hMenuChats, &mi); proto->isOnline = TRUE; proto->debugLogA("Status changed via THREADSTART"); oldStatus = proto->m_iStatus; TlenSendPresence(proto, proto->m_iDesiredStatus); ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, proto->m_iStatus); } } }
static int PluginInit(WPARAM wparam,LPARAM lparam) { int startup=0; HookEvent(ME_MSG_WINDOWEVENT, GetContactHandle); HookEvent(ME_OPT_INITIALISE, OptionsInit); HookEvent(ME_TTB_MODULELOADED, CreateButtons); startup=db_get_b(NULL, MODNAME, "StartupMode", 3); if (startup == 1||(startup == 3&&isLastTRUE == TRUE)) { StartUp=TRUE; g_hDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc); } else if (startup == 2&&isLastTRUE == TRUE) { g_hghostw=TRUE; g_hDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc); } // Hotkeys HOTKEYDESC hkd = { sizeof(hkd) }; hkd.dwFlags = HKD_TCHAR; hkd.ptszSection = LPGENT("Sessions"); hkd.pszName = "OpenSessionsManager"; hkd.ptszDescription = LPGENT("Open Sessions Manager"); hkd.pszService = MS_SESSIONS_OPENMANAGER; Hotkey_Register(&hkd); hkd.pszName = "RestoreLastSession"; hkd.ptszDescription = LPGENT("Restore last Session"); hkd.pszService = MS_SESSIONS_RESTORELASTSESSION; Hotkey_Register(&hkd); hkd.pszName = "SaveSession"; hkd.ptszDescription = LPGENT("Save Session"); hkd.pszService = MS_SESSIONS_SAVEUSERSESSION; Hotkey_Register(&hkd); hkd.pszName = "CloseSession"; hkd.ptszDescription = LPGENT("Close Session"); hkd.pszService = MS_SESSIONS_CLOSESESSION; Hotkey_Register(&hkd); // Icons Icon_Register(hinstance, MODNAME, iconList, SIZEOF(iconList)); // Main menu CLISTMENUITEM cl = { sizeof(cl) }; cl.position = 1000000000; cl.flags = CMIM_ALL | CMIF_TCHAR; cl.ptszName = LPGENT("Save session..."); cl.ptszPopupName = LPGENT("Sessions Manager"); cl.icolibItem = iconList[0].hIcolib; cl.pszService = MS_SESSIONS_SAVEUSERSESSION; hmSaveCurrentSession = Menu_AddMainMenuItem(&cl); cl.ptszName = LPGENT("Load session..."); cl.pszService = MS_SESSIONS_OPENMANAGER; cl.icolibItem = iconList[3].hIcolib; hmLoadLastSession = Menu_AddMainMenuItem(&cl); cl.ptszName = LPGENT("Close session"); cl.pszService = MS_SESSIONS_CLOSESESSION; cl.icolibItem = 0; hmLoadSession = Menu_AddMainMenuItem(&cl); cl.ptszName = LPGENT("Load last session"); cl.pszService = MS_SESSIONS_RESTORELASTSESSION; cl.icolibItem = iconList[5].hIcolib; cl.position = 10100000; hmLoadSession = Menu_AddMainMenuItem(&cl); ZeroMemory(&cl, sizeof(cl)); cl.cbSize = sizeof(cl); cl.flags = CMIM_ICON; cl.icolibItem = iconList[4].hIcolib; Menu_ModifyItem(hmSaveCurrentSession, &cl); return 0; }
int __cdecl PrebuildContactMenu(WPARAM wParam, LPARAM) { MCONTACT hContact = (MCONTACT) wParam; char *szProto = GetContactProto(hContact); if (!szProto) return 0; // Clear hold-Item in case it exists CLISTMENUITEM mi = HoldCallItem(); mi.flags |= CMIM_ALL; Menu_ModifyItem(hMenuHoldCallItem, &mi); DBVARIANT dbv; BOOL callAvailable = FALSE; BOOL hangupAvailable = FALSE; if (!strcmp(szProto, SKYPE_PROTONAME)) { if (!db_get(hContact, SKYPE_PROTONAME, "CallId", &dbv)) { if (db_get_b(hContact, SKYPE_PROTONAME, "OnHold", 0)) mi = ResumeCallItem(); else mi = HoldCallItem(); mi.flags = CMIM_ALL; Menu_ModifyItem(hMenuHoldCallItem, &mi); callAvailable = FALSE; hangupAvailable = TRUE; db_free(&dbv); } else { callAvailable = TRUE; hangupAvailable = FALSE; } if (db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) != 0) { callAvailable = FALSE; hangupAvailable = FALSE; } mi = CallItem(); mi.flags |= CMIM_ALL | (!callAvailable ? CMIF_HIDDEN : 0); Menu_ModifyItem(hMenuCallItem, &mi); mi = HupItem(); mi.flags |= CMIM_ALL | (!hangupAvailable ? CMIF_HIDDEN : 0); Menu_ModifyItem(hMenuCallHangup, &mi); // Clear SkypeOut menu in case it exists mi = SkypeOutCallItem(); mi.flags |= CMIM_ALL; Menu_ModifyItem(hMenuSkypeOutCallItem, &mi); // File sending and groupchat-creation works starting with protocol version 5 if (protocol >= 5) { mi = FileTransferItem(); if (db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 0) mi.flags ^= CMIF_HIDDEN; mi.flags |= CMIM_FLAGS; Menu_ModifyItem(hMenuFileTransferItem, &mi); } if (protocol >= 5 || bIsImoproxy) { mi = ChatInitItem(); if (db_get_b(NULL, SKYPE_PROTONAME, "UseGroupchat", 0) && db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 0) mi.flags ^= CMIF_HIDDEN; mi.flags |= CMIM_FLAGS; Menu_ModifyItem(hMenuChatInitItem, &mi); mi = BlockContactItem(); mi.flags ^= CMIF_HIDDEN; mi.flags |= CMIM_FLAGS | CMIM_NAME; if (db_get_b(hContact, SKYPE_PROTONAME, "IsBlocked", 0) == 1) mi.ptszName = LPGENT("Unblock contact"); Menu_ModifyItem(hMenuBlockContactItem, &mi); } } else if (bSkypeOut) { if (!db_get(hContact, SKYPE_PROTONAME, "CallId", &dbv)) { mi = SkypeOutHupItem(); db_free(&dbv); } else { mi = SkypeOutCallItem(); if (!db_get(hContact, "UserInfo", "MyPhone0", &dbv)) { db_free(&dbv); mi.flags = 0; } } mi.flags |= CMIM_ALL; Menu_ModifyItem(hMenuSkypeOutCallItem, &mi); } return 0; }
INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) { PCheckProcParam pcpp = (PCheckProcParam)wParam; if (!pcpp) return TRUE; PMO_IntMenuItem timi = MO_GetIntMenuItem(pcpp->MenuItemHandle); if (!timi) return TRUE; StatusMenuExecParam *smep = (StatusMenuExecParam*)pcpp->MenuItemOwnerData; if (smep && !smep->status && smep->custom) { if (wildcmp(smep->svc, "*XStatus*")) { int XStatus; CUSTOM_STATUS cs = { sizeof(cs) }; cs.flags = CSSF_MASK_STATUS; cs.status = &XStatus; if (CallProtoServiceInt(NULL, smep->proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) != 0) XStatus = 0; char buf[255]; mir_snprintf(buf, SIZEOF(buf), "*XStatus%d", XStatus); bool check = wildcmp(smep->svc, buf) != 0; bool reset = wildcmp(smep->svc, "*XStatus0") != 0; if (check) timi->mi.flags |= CMIF_CHECKED; else timi->mi.flags &= ~CMIF_CHECKED; if (reset || check) { PMO_IntMenuItem timiParent = MO_GetIntMenuItem(timi->mi.root); if (timiParent) { CLISTMENUITEM mi2 = { sizeof(mi2) }; mi2.flags = CMIM_NAME | CMIF_TCHAR; mi2.ptszName = TranslateTH(timi->mi.hLangpack, timi->mi.hIcon ? timi->mi.ptszName : LPGENT("Custom status")); timiParent = MO_GetIntMenuItem(timi->mi.root); MenuItemData it = { 0 }; if (FindMenuHandleByGlobalID(hStatusMenu, timiParent, &it)) { MENUITEMINFO mi = { 0 }; TCHAR d[100]; GetMenuString(it.OwnerMenu, it.position, d, SIZEOF(d), MF_BYPOSITION); mi.cbSize = sizeof(mi); mi.fMask = MIIM_STRING | MIIM_STATE; if (timi->iconId != -1) { mi.fMask |= MIIM_BITMAP; if (IsWinVerVistaPlus() && IsThemeActive()) { if (timi->hBmp == NULL) timi->hBmp = ConvertIconToBitmap(NULL, timi->parent->m_hMenuIcons, timi->iconId); mi.hbmpItem = timi->hBmp; } else mi.hbmpItem = HBMMENU_CALLBACK; } mi.fState |= (check && !reset ? MFS_CHECKED : MFS_UNCHECKED); mi.dwTypeData = mi2.ptszName; SetMenuItemInfo(it.OwnerMenu, it.position, TRUE, &mi); } Menu_ModifyItem(timi->mi.root, &mi2); timiParent->iconId = timi->iconId; if (timiParent->hBmp) DeleteObject(timiParent->hBmp); timiParent->hBmp = NULL; } } } } else if (smep && smep->status && !smep->custom) { int curProtoStatus = (smep->proto) ? CallProtoServiceInt(NULL, smep->proto, PS_GETSTATUS, 0, 0) : cli.pfnGetAverageMode(NULL); if (smep->status == curProtoStatus) timi->mi.flags |= CMIF_CHECKED; else timi->mi.flags &= ~CMIF_CHECKED; } else if ((!smep || smep->proto) && timi->mi.pszName) { int curProtoStatus = 0; BOOL IconNeedDestroy = FALSE; char* prot; if (smep) prot = smep->proto; else { char *prn = mir_u2a(timi->mi.ptszName); prot = NEWSTR_ALLOCA(prn); if (prn) mir_free(prn); } if (Proto_GetAccount(prot) == NULL) return TRUE; if ((curProtoStatus = CallProtoServiceInt(NULL, prot, PS_GETSTATUS, 0, 0)) == CALLSERVICE_NOTFOUND) curProtoStatus = 0; if (curProtoStatus >= ID_STATUS_OFFLINE && curProtoStatus < ID_STATUS_IDLE) timi->mi.hIcon = LoadSkinProtoIcon(prot, curProtoStatus); else { timi->mi.hIcon = (HICON)CallProtoServiceInt(NULL, prot, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); if (timi->mi.hIcon == (HICON)CALLSERVICE_NOTFOUND) timi->mi.hIcon = NULL; else IconNeedDestroy = TRUE; } if (timi->mi.hIcon) { timi->mi.flags |= CMIM_ICON; MO_ModifyMenuItem(timi, &timi->mi); if (IconNeedDestroy) { DestroyIcon(timi->mi.hIcon); timi->mi.hIcon = NULL; } else IcoLib_ReleaseIcon(timi->mi.hIcon, 0); } } return TRUE; }
void TlenProtocol::initMenuItems() { char text[_MAX_PATH]; strncpy_s(text, sizeof(text), m_szModuleName, _TRUNCATE); char *pSvcName = text + strlen(text); CLISTMENUITEM mi = { sizeof(mi) }, clmi = { sizeof(clmi) }; clmi.flags = CMIM_FLAGS | CMIF_GRAYED; mi.pszContactOwner = m_szModuleName; mi.popupPosition = 500090000; strcpy(text, m_szModuleName); mi.pszService = text; mi.ptszName = m_tszUserName; mi.position = -1999901009; mi.hParentMenu = HGENMENU_ROOT; mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR; mi.icolibItem = GetIconHandle(IDI_TLEN); hMenuRoot = Menu_AddMainMenuItem(&mi); mi.flags = CMIF_CHILDPOPUP; //mi.pszPopupName = (char *)hMenuRoot; mi.hParentMenu = (HGENMENU)hMenuRoot; hMenuChats = NULL; // "Multi-User Conference" strcpy(pSvcName, "/MainMenuMUC"); CreateProtoService(pSvcName, &TlenProtocol::MUCMenuHandleMUC); mi.pszName = LPGEN("Multi-User Conference"); mi.position = 2000050002; mi.icolibItem = GetIconHandle(IDI_MUC); mi.pszService = text; hMenuMUC = Menu_AddMainMenuItem(&mi); Menu_ModifyItem(hMenuMUC, &clmi); strcpy(pSvcName, "/MainMenuInbox"); CreateProtoService(pSvcName, &TlenProtocol::MenuHandleInbox); mi.pszName = LPGEN("Tlen Mail"); mi.position = 2000050003; mi.icolibItem = GetIconHandle(IDI_MAIL); mi.pszService = text; hMenuInbox = Menu_AddMainMenuItem(&mi); mi.hParentMenu = NULL; // "Send picture" strcpy(pSvcName, "/SendPicture"); CreateProtoService(pSvcName, &TlenProtocol::ContactMenuHandleSendPicture); mi.pszName = LPGEN("Send picture"); mi.position = -2000019030; mi.icolibItem = GetIconHandle(IDI_IMAGE); hMenuPicture = Menu_AddContactMenuItem(&mi); // "Invite to MUC" strcpy(pSvcName, "/ContactMenuMUC"); CreateProtoService(pSvcName, &TlenProtocol::MUCContactMenuHandleMUC); mi.pszName = LPGEN("Multi-User Conference"); mi.position = -2000019020; mi.icolibItem = GetIconHandle(IDI_MUC); hMenuContactMUC = Menu_AddContactMenuItem(&mi); // "Invite to voice chat" strcpy(pSvcName, "/ContactMenuVoice"); CreateProtoService(pSvcName, &TlenProtocol::VoiceContactMenuHandleVoice); mi.pszName = LPGEN("Voice Chat"); mi.position = -2000019010; mi.icolibItem = GetIconHandle(IDI_VOICE); hMenuContactVoice = Menu_AddContactMenuItem(&mi); // "Request authorization" strcpy(pSvcName, "/RequestAuth"); CreateProtoService(pSvcName, &TlenProtocol::ContactMenuHandleRequestAuth); mi.pszName = LPGEN("Request authorization"); mi.position = -2000001001; mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_REQUEST); hMenuContactRequestAuth = Menu_AddContactMenuItem(&mi); // "Grant authorization" strcpy(pSvcName, "/GrantAuth"); CreateProtoService(pSvcName, &TlenProtocol::ContactMenuHandleGrantAuth); mi.pszName = LPGEN("Grant authorization"); mi.position = -2000001000; mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_GRANT); hMenuContactGrantAuth = Menu_AddContactMenuItem(&mi); }
void CDb3Mmap::UpdateMenuItem() { Menu_ModifyItem(hSetPwdMenu, GetMenuTitle(), iconList[1].hIcolib); }
void InitMenus() { CMenuItem mi; // main menu item mi.hIcolibItem = GetIconHandle(I_MENUOFF); mi.name.a = LPGEN("Toggle metacontacts off"); mi.pszService = "MetaContacts/OnOff"; mi.position = 500010000; hMenuOnOff = Menu_AddMainMenuItem(&mi); // contact menu items mi.hIcolibItem = GetIconHandle(I_CONVERT); mi.position = -200010; mi.name.a = LPGEN("Convert to metacontact"); mi.pszService = "MetaContacts/Convert"; hMenuConvert = Menu_AddContactMenuItem(&mi); mi.hIcolibItem = GetIconHandle(I_ADD); mi.position = -200009; mi.name.a = LPGEN("Add to existing metacontact..."); mi.pszService = "MetaContacts/AddTo"; hMenuAdd = Menu_AddContactMenuItem(&mi); mi.hIcolibItem = GetIconHandle(I_EDIT); mi.position = -200010; mi.name.a = LPGEN("Edit metacontact..."); mi.pszService = "MetaContacts/Edit"; hMenuEdit = Menu_AddContactMenuItem(&mi); mi.hIcolibItem = GetIconHandle(I_SETDEFAULT); mi.position = -200009; mi.name.a = LPGEN("Set as metacontact default"); mi.pszService = "MetaContacts/Default"; hMenuDefault = Menu_AddContactMenuItem(&mi); mi.hIcolibItem = GetIconHandle(I_REMOVE); mi.position = -200008; mi.name.a = LPGEN("Delete metacontact"); mi.pszService = "MetaContacts/Delete"; hMenuDelete = Menu_AddContactMenuItem(&mi); mi.position = -99000; mi.flags = CMIF_HIDDEN; mi.hIcolibItem = 0; mi.name.a = LPGEN("Subcontacts"); hMenuRoot = Menu_AddContactMenuItem(&mi); mi.flags |= CMIF_SYSTEM; mi.root = hMenuRoot; for (int i = 0; i < MAX_CONTACTS; i++) { mi.position--; mi.name.a = ""; char buffer[512]; mir_snprintf(buffer, "MetaContacts/MenuFunc%d", i); mi.pszService = buffer; mi.position++; hMenuContact[i] = Menu_AddContactMenuItem(&mi); } Meta_HideLinkedContacts(); if (!db_mc_isEnabled()) { // modify main menu item Menu_ModifyItem(hMenuOnOff, LPGENT("Toggle metacontacts on"), GetIconHandle(I_MENU)); Meta_HideMetaContacts(true); } else { Meta_SuppressStatus(options.bSuppressStatus); Meta_HideMetaContacts(false); } }
static int FAV_OnContactMenuBuild(WPARAM hContact, LPARAM) { BYTE bContactRate = db_get_b(hContact, "CList", "Rate", 0); if (bContactRate > SIZEOF(rates) - 1) bContactRate = SIZEOF(rates) - 1; BOOL bModifyMenu = FALSE; CLISTMENUITEM mi = { sizeof(mi) }; mi.icolibItem = iconList[bContactRate].hIcolib; mi.pszPopupName = (char *)-1; mi.position = 0; mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR; if (!bContactRate) mi.ptszName = FAVMENUROOTNAME; else { TCHAR *str1 = TranslateTS(FAVMENUROOTNAME), *str2 = TranslateTS(rates[bContactRate]); size_t bufsize = (mir_tstrlen(str1) + mir_tstrlen(str2) + 15) * sizeof(TCHAR); TCHAR *name = (TCHAR *)_alloca(bufsize); mir_sntprintf(name, (bufsize / sizeof(TCHAR)), _T("%s (%s)"), str1, str2); mi.ptszName = name; mi.flags |= CMIF_KEEPUNTRANSLATED; } if (!hFavoriteContactMenu) hFavoriteContactMenu = Menu_AddContactMenuItem(&mi); else { mi.flags |= CMIM_FLAGS | CMIM_NAME; Menu_ModifyItem(hFavoriteContactMenu, &mi); bModifyMenu = TRUE; } OptParam op; op.Handle = hFavoriteContactMenu; op.Setting = OPT_MENUITEMSETUNIQNAME; op.Value = (INT_PTR)"ModernClistMenu_ContactRate"; CallService(MO_SETOPTIONSMENUITEM, 0, (LPARAM)&op); mi.hParentMenu = hFavoriteContactMenu; if (!hFavoriteContactMenuItems) { hFavoriteContactMenuItems = (HGENMENU *)malloc(sizeof(HANDLE) * SIZEOF(rates)); memset(hFavoriteContactMenuItems, 0, sizeof(HANDLE) * SIZEOF(rates)); } int i; for (i = 0; i < SIZEOF(rates); i++) { mi.icolibItem = iconList[i].hIcolib; mi.ptszName = rates[i]; mi.flags = CMIF_CHILDPOPUP | CMIF_TCHAR | ((bContactRate == i) ? CMIF_CHECKED : 0); mi.pszService = CLUI_FAVSETRATE; mi.popupPosition = i; if (bModifyMenu && hFavoriteContactMenuItems[i]) { mi.flags |= CMIM_FLAGS | CMIM_ICON; Menu_ModifyItem(hFavoriteContactMenuItems[i], &mi); } else hFavoriteContactMenuItems[i] = Menu_AddContactMenuItem(&mi); } mi.hIcon = NULL; mi.ptszName = LPGENT("Show even if offline"); mi.flags = CMIF_CHILDPOPUP | CMIF_TCHAR | (db_get_b(hContact, "CList", "noOffline", 0) ? CMIF_CHECKED : 0); mi.pszService = CLUI_FAVTOGGLESHOWOFFLINE; mi.popupPosition = i + 100000000; mi.position = -100000000; if (bModifyMenu && hShowIfOflineItem) { mi.flags |= CMIM_FLAGS | CMIM_ICON; Menu_ModifyItem(hShowIfOflineItem, &mi); } else hShowIfOflineItem = Menu_AddContactMenuItem(&mi); return 0; }
int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) { if (hContact == NULL) return 0; bool bIsChatRoom = isChatRoom(hContact); bool bIsTransport = getBool(hContact, "IsTransport", false); if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0) { if (ptrT(getTStringA(hContact, bIsChatRoom ? (char*)"ChatRoomID" : (char*)"jid")) != NULL) { Menu_ShowItem(g_hMenuConvert, TRUE); Menu_ModifyItem(g_hMenuConvert, bIsChatRoom ? LPGENT("&Convert to Contact") : LPGENT("&Convert to Chat Room")); } } if (!m_bJabberOnline) return 0; Menu_ShowItem(g_hMenuDirectPresence[0], TRUE); for (int i = 0; i < _countof(PresenceModeArray); i++) Menu_ModifyItem(g_hMenuDirectPresence[i + 1], NULL, Skin_LoadProtoIcon(m_szModuleName, PresenceModeArray[i].mode)); if (bIsChatRoom) { ptrT roomid(getTStringA(hContact, "ChatRoomID")); if (roomid != NULL) { Menu_ShowItem(g_hMenuRosterAdd, FALSE); if (ListGetItemPtr(LIST_BOOKMARK, roomid) == NULL) if (m_ThreadInfo && m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE) Menu_ShowItem(g_hMenuAddBookmark, TRUE); } } if (bIsChatRoom == GCW_CHATROOM) return 0; if (bIsTransport) { Menu_ShowItem(g_hMenuLogin, TRUE); Menu_ShowItem(g_hMenuRefresh, TRUE); } ptrT jid(getTStringA(hContact, "jid")); if (jid == NULL) return 0; JabberCapsBits jcb = GetTotalJidCapabilites(jid); JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid); if (item == NULL) return 0; bool bCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0; Menu_ShowItem(g_hMenuRequestAuth, item->subscription == SUB_FROM || item->subscription == SUB_NONE || bCtrlPressed); Menu_ShowItem(g_hMenuGrantAuth, bCtrlPressed); Menu_ShowItem(g_hMenuRevokeAuth, item->subscription == SUB_FROM || item->subscription == SUB_BOTH || bCtrlPressed); Menu_ShowItem(g_hMenuCommands, ((jcb & JABBER_CAPS_COMMANDS) != 0) || bCtrlPressed); Menu_ShowItem(g_hMenuSendNote, TRUE); if (item->arResources.getCount() == 0) return 0; Menu_ShowItem(g_hMenuResourcesRoot, TRUE); Menu_ModifyItem(g_hMenuResourcesRoot, NULL, m_hProtoIcon); Menu_ModifyItem(g_hMenuResourcesActive, NULL, m_hProtoIcon, (item->resourceMode == RSMODE_LASTSEEN) ? CMIF_CHECKED : 0); Menu_ModifyItem(g_hMenuResourcesServer, NULL, m_hProtoIcon, (item->resourceMode == RSMODE_SERVER) ? CMIF_CHECKED : 0); int nMenuResourceItemsNew = m_nMenuResourceItems; if (m_nMenuResourceItems < item->arResources.getCount()) { m_phMenuResourceItems = (HGENMENU*)mir_realloc(m_phMenuResourceItems, item->arResources.getCount() * sizeof(HGENMENU)); nMenuResourceItemsNew = item->arResources.getCount(); } char text[256]; CMenuItem mi; mi.pszService = text; CMString szTmp; for (int i = 0; i < nMenuResourceItemsNew; i++) { mir_snprintf(text, "/UseResource_%d", i); if (i >= m_nMenuResourceItems) { CreateProtoServiceParam(text, &CJabberProto::OnMenuHandleResource, MENUITEM_RESOURCES + i); mi.name.a = ""; mi.position = i; mi.root = g_hMenuResourcesRoot; m_phMenuResourceItems[i] = Menu_AddContactMenuItem(&mi, m_szModuleName); } if (i < item->arResources.getCount()) { pResourceStatus r(item->arResources[i]); HICON hIcon = (HICON)INVALID_HANDLE_VALUE; Menu_SetChecked(m_phMenuResourceItems[i], item->resourceMode == RSMODE_MANUAL && item->m_pManualResource == r); if (ServiceExists(MS_FP_GETCLIENTICONT)) { FormatMirVer(r, szTmp); hIcon = Finger_GetClientIcon(szTmp, 0); } szTmp.Format(_T("%s [%s, %d]"), r->m_tszResourceName, pcli->pfnGetStatusModeDescription(r->m_iStatus, 0), r->m_iPriority); Menu_ModifyItem(m_phMenuResourceItems[i], szTmp, hIcon); DestroyIcon(hIcon); } else Menu_ShowItem(m_phMenuResourceItems[i], FALSE); } m_nMenuResourceItems = nMenuResourceItemsNew; return 0; }
int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; BOOL bMC = isProtoMetaContacts(hContact); if (bMC ) hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение pUinKey ptr = getUinKey(hContact); int i; CLISTMENUITEM mi = { sizeof(mi) }; ShowStatusIconNotify(hContact); // check offline/online if (!ptr) { // hide menu bars for (i=0; i < SIZEOF(g_hMenu); i++) Menu_ShowItem(g_hMenu[i], false); return 0; } bool isSecureProto = isSecureProtocol(hContact); bool isPGP = isContactPGP(hContact); bool isGPG = isContactGPG(hContact); bool isSecured = (isContactSecured(hContact)&SECURED) != 0; bool isChat = isChatRoom(hContact); bool isMiranda = isClientMiranda(hContact); // hide all menu bars for (i=0; i < SIZEOF(g_hMenu); i++) Menu_ShowItem(g_hMenu[i], false); if (isSecureProto && !isChat && isMiranda && (ptr->mode == MODE_NATIVE || ptr->mode == MODE_RSAAES)) { // Native/RSAAES mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIM_ICON; if (!isSecured) { // create secureim connection mi.hIcon = mode2icon(ptr->mode|SECURED,2); Menu_ModifyItem(g_hMenu[0], &mi); } else { // disable secureim connection mi.hIcon = mode2icon(ptr->mode,2); Menu_ModifyItem(g_hMenu[1], &mi); } // set status menu if (bSCM && !bMC && (!isSecured || ptr->mode == MODE_PGP || ptr->mode == MODE_GPG)) { mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON; mi.hIcon = g_hICO[ICO_ST_DIS+ptr->status]; mi.pszName = (LPSTR)sim312[ptr->status]; Menu_ModifyItem(g_hMenu[2], &mi); mi.flags = CMIM_FLAGS | CMIM_ICON; for (i=0;i<=(ptr->mode == MODE_RSAAES?1:2);i++) { mi.hIcon = (i == ptr->status) ? g_hICO[ICO_ST_DIS+ptr->status] : NULL; Menu_ModifyItem(g_hMenu[3+i], &mi); } } } else if (isSecureProto && !isChat && (ptr->mode == MODE_PGP || ptr->mode == MODE_GPG)) { // PGP, GPG if (ptr->mode == MODE_PGP && bPGPloaded) if ((bPGPkeyrings || bPGPprivkey) && !isGPG) Menu_ShowItem(g_hMenu[isPGP+6], true); if (ptr->mode == MODE_GPG && bGPGloaded) if (bGPGkeyrings && !isPGP) Menu_ShowItem(g_hMenu[isGPG+8], true); } if (isSecureProto && !isChat && isMiranda) { // set mode menu if (bMCM && !bMC && (!isSecured || ptr->mode == MODE_PGP || ptr->mode == MODE_GPG)) { mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON; mi.hIcon = g_hICO[ICO_OV_NAT+ptr->mode]; mi.pszName = (LPSTR)sim311[ptr->mode]; Menu_ModifyItem(g_hMenu[10], &mi); mi.flags = CMIM_FLAGS | CMIM_ICON; for (i=0;i<MODE_CNT;i++) { if (i == MODE_PGP && ptr->mode != MODE_PGP && !bPGP ) continue; if (i == MODE_GPG && ptr->mode != MODE_GPG && !bGPG ) continue; mi.hIcon = (i == ptr->mode) ? g_hICO[ICO_ST_ENA] : NULL; Menu_ModifyItem(g_hMenu[11+i], &mi); } } } return 0; }
static INT_PTR gg_parselink(WPARAM wParam, LPARAM lParam) { char *arg = (char*)lParam; uin_t uin; int items = 0; if (g_Instances.getCount() == 0) return 0; if (arg == NULL) return 1; arg = strchr(arg, ':'); if (arg == NULL) return 1; for (++arg; *arg == '/'; ++arg); uin = atoi(arg); if (!uin) return 1; GGPROTO *gg = NULL; for (int i=0; i < g_Instances.getCount(); i++) { gg = g_Instances[i]; CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS; if (gg->m_iStatus > ID_STATUS_OFFLINE) { ++items; mi.flags |= CMIM_ICON; mi.hIcon = LoadSkinnedProtoIcon(gg->m_szModuleName, gg->m_iStatus); } else mi.flags |= CMIF_HIDDEN; Menu_ModifyItem(gg->hInstanceMenuItem, &mi); if (mi.hIcon) Skin_ReleaseIcon(mi.hIcon); } if (items > 1) { ListParam param = {0}; HMENU hMenu = CreatePopupMenu(); POINT pt; int cmd = 0; param.MenuObjectHandle = hInstanceMenu; CallService(MO_BUILDMENU, (WPARAM)hMenu, (LPARAM)¶m); GetCursorPos(&pt); cmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, pcli->hwndContactList, NULL); DestroyMenu(hMenu); if (cmd) CallService(MO_PROCESSCOMMANDBYMENUIDENT, cmd, (LPARAM)&gg); } if (gg == NULL) return 0; if (ServiceExists(MS_MSG_SENDMESSAGE)) { HANDLE hContact = gg->getcontact(uin, 1, 0, NULL); if (hContact != NULL) CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0); } return 0; }