void CJabberProto::ListRemoveResource(JABBER_LIST list, const TCHAR *jid) { mir_cslockfull lck(m_csLists); JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid); if (LI == NULL) return; const TCHAR *p = _tcschr(jid, '@'); const TCHAR *q = _tcschr((p == NULL) ? jid : p, '/'); if (q == NULL) return; pResourceStatus r( LI->findResource(q+1)); if (r == NULL) return; // Found last seen resource ID to be removed if (LI->m_pLastSeenResource == r) LI->m_pLastSeenResource = NULL; // update manually selected resource ID if (LI->resourceMode == RSMODE_MANUAL && LI->m_pManualResource == r) { LI->resourceMode = RSMODE_LASTSEEN; LI->m_pManualResource = NULL; } // Update MirVer due to possible resource changes UpdateMirVer(LI); LI->arResources.remove(r); r->Release(); lck.unlock(); MenuUpdateSrmmIcon(LI); }
pResourceStatus CJabberProto::ListFindResource(JABBER_LIST list, const TCHAR *jid) { mir_cslock lck(m_csLists); JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid); if (LI == NULL) return NULL; const TCHAR *p = _tcschr(jid, '@'); const TCHAR *q = _tcschr((p == NULL) ? jid : p, '/'); return (q == NULL) ? NULL : LI->findResource(q+1); }
INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lParam) { if (!wParam || !lParam) return 0; //room global tooltip not supported yet JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, (TCHAR*)wParam); if (item == NULL) return 0; //no room found pResourceStatus info( item->findResource((TCHAR*)lParam)); if (info == NULL) return 0; //no info found // ok process info output will be: // JID: real@jid/resource or // Nick: Nickname // Status: StatusText // Role: Moderator // Affiliation: Affiliation TCHAR outBuf[2048]; outBuf[0]=0; bool bIsTipper = db_get_b(NULL, "Tab_SRMsg", "adv_TipperTooltip", 0) && ServiceExists("mToolTip/HideTip"); //JID: if (_tcschr(info->m_tszResourceName, _T('@')) != NULL) appendString(bIsTipper, LPGENT("JID:"), info->m_tszResourceName, outBuf, SIZEOF(outBuf)); else if (lParam) //or simple nick appendString(bIsTipper, LPGENT("Nick:"), (TCHAR*)lParam, outBuf, SIZEOF(outBuf)); // status if (info->m_iStatus >= ID_STATUS_OFFLINE && info->m_iStatus <= ID_STATUS_IDLE ) appendString(bIsTipper, LPGENT("Status:"), pcli->pfnGetStatusModeDescription(info->m_iStatus, 0), outBuf, SIZEOF(outBuf)); // status text if (info->m_tszStatusMessage) appendString(bIsTipper, LPGENT("Status text:"), info->m_tszStatusMessage, outBuf, SIZEOF(outBuf)); // Role appendString(bIsTipper, LPGENT("Role:"), TranslateTS(JabberEnum2RoleStr[info->m_role]), outBuf, SIZEOF(outBuf)); // Affiliation appendString(bIsTipper, LPGENT("Affiliation:"), TranslateTS(JabberEnum2AffilationStr[info->m_affiliation]), outBuf, SIZEOF(outBuf)); // real jid if (info->m_tszRealJid) appendString(bIsTipper, LPGENT("Real JID:"), info->m_tszRealJid, outBuf, SIZEOF(outBuf)); return (outBuf[0] == 0 ? NULL : (INT_PTR) mir_tstrdup(outBuf)); }
bool CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status, const TCHAR *statusMessage, char priority, const TCHAR *nick) { mir_cslockfull lck(m_csLists); JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid); if (LI == NULL) return false; bool bIsNewResource = false; const TCHAR *p = _tcschr(jid, '@'); const TCHAR *q = _tcschr((p == NULL) ? jid : p, '/'); if (q) { const TCHAR *resource = q+1; if (*resource == 0) return 0; JABBER_RESOURCE_STATUS *r = LI->findResource(resource); if (r != NULL) { // Already exists, update status and statusMessage r->m_iStatus = status; r->m_tszStatusMessage = mir_tstrdup(statusMessage); r->m_iPriority = priority; } else { // Does not exist, add new resource bIsNewResource = true; r = new JABBER_RESOURCE_STATUS(); r->m_iStatus = status; r->m_affiliation = AFFILIATION_NONE; r->m_role = ROLE_NONE; r->m_tszResourceName = mir_tstrdup(resource); r->m_tszNick = mir_tstrdup(nick); if (statusMessage) r->m_tszStatusMessage = mir_tstrdup(statusMessage); r->m_iPriority = priority; LI->arResources.insert(r); } } // No resource, update the main statusMessage else { JABBER_RESOURCE_STATUS *r = LI->getTemp(); r->m_iStatus = status; r->m_tszStatusMessage = mir_tstrdup(statusMessage); } lck.unlock(); MenuUpdateSrmmIcon(LI); return bIsNewResource; }