int CompareContacts2(const ClcContact *contact1, const ClcContact *contact2, int by) { TCHAR *namea, *nameb; int statusa, statusb; char *szProto1, *szProto2; if ((INT_PTR)contact1 < 100 || (INT_PTR)contact2 < 100) return 0; MCONTACT a = contact1->hContact; MCONTACT b = contact2->hContact; namea = (TCHAR *)contact1->szText; statusa = GetContactCachedStatus(contact1->hContact); szProto1 = contact1->proto; nameb = (TCHAR *)contact2->szText; statusb = GetContactCachedStatus(contact2->hContact); szProto2 = contact2->proto; if (by == SORTBY_STATUS) { //status int ordera, orderb; ordera = GetStatusModeOrdering(statusa); orderb = GetStatusModeOrdering(statusb); return (ordera != orderb) ? ordera - orderb : 0; } //one is offline: offline goes below online if (g_CluiData.fSortNoOfflineBottom == 0 && (statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) return 2 * (statusa == ID_STATUS_OFFLINE) - 1; if (by == SORTBY_NAME) //name return mir_tstrcmpi(namea, nameb); if (by == SORTBY_NAME_LOCALE) { //name static int LocaleId = -1; if (LocaleId == -1) LocaleId = Langpack_GetDefaultLocale(); return (CompareString(LocaleId, NORM_IGNORECASE, SAFETSTRING(namea), -1, SAFETSTRING(nameb), -1)) - 2; } if (by == SORTBY_LASTMSG) { //last message DWORD ta = CompareContacts2_getLMTime(a); DWORD tb = CompareContacts2_getLMTime(b); return tb - ta; } if (by == SORTBY_PROTO) { int rc = GetProtoIndex(szProto1) - GetProtoIndex(szProto2); if (rc != 0 && (szProto1 != NULL && szProto2 != NULL)) return rc; } else if (by == SORTBY_RATE) return contact2->bContactRate - contact1->bContactRate; // else :o) return 0; }
// -1 for XStatus, 1 for Status int GetStatusMessage(TCHAR *text, int text_size, struct ClcContact *contact, BOOL xstatus_has_priority) { DBVARIANT dbv; BOOL noAwayMsg=FALSE; text[0] = '\0'; if (contact->status==0) { contact->status=GetContactCachedStatus(contact->hContact); } // Hide status text if Offline /// no offline if (contact->status==ID_STATUS_OFFLINE || contact->status==0) noAwayMsg=TRUE; // Get XStatusMsg if (!noAwayMsg &&xstatus_has_priority && contact->hContact && contact->proto) { // Try to get XStatusMsg if (!DBGetContactSettingTString(contact->hContact, contact->proto, "XStatusMsg", &dbv)) { //lstrcpyn(text, dbv.pszVal, text_size); CopySkipUnPrintableChars(text, dbv.ptszVal, text_size-1); DBFreeVariant(&dbv); if (text[0] != '\0') return -1; } } // Get StatusMsg if (contact->hContact && text[0] == '\0') { if (!DBGetContactSettingTString(contact->hContact, "CList", "StatusMsg", &dbv)) { //lstrcpyn(text, dbv.pszVal, text_size); CopySkipUnPrintableChars(text, dbv.ptszVal, text_size-1); DBFreeVariant(&dbv); if (text[0] != '\0') return 1; } } // Get XStatusMsg if (!noAwayMsg && !xstatus_has_priority && contact->hContact && contact->proto && text[0] == '\0') { // Try to get XStatusMsg if (!DBGetContactSettingTString(contact->hContact, contact->proto, "XStatusMsg", &dbv)) { //lstrcpyn(text, dbv.pszVal, text_size); CopySkipUnPrintableChars(text, dbv.ptszVal, text_size-1); DBFreeVariant(&dbv); if (text[0] != '\0') return -1; } } return 1; }
// -1 for XStatus, 1 for Status int GetStatusName(TCHAR *text, int text_size, struct ClcContact *contact, BOOL xstatus_has_priority) { //DBVARIANT dbv; BOOL noAwayMsg=FALSE; BOOL noXstatus=FALSE; // Hide status text if Offline /// no offline if (contact->status==0) { contact->status=GetContactCachedStatus(contact->hContact); } if ((contact->status==ID_STATUS_OFFLINE || contact->status==0) && DBGetContactSettingByte(NULL,"ModernData","RemoveAwayMessageForOffline",0)) noAwayMsg=TRUE; if (contact->status==ID_STATUS_OFFLINE || contact->status==0) noXstatus=TRUE; text[0] = '\0'; // Get XStatusName if (!noAwayMsg&& !noXstatus&& xstatus_has_priority && contact->hContact && contact->proto) { DBVARIANT dbv; if (!DBGetContactSettingTString(contact->hContact, contact->proto, "XStatusName", &dbv)) { //lstrcpyn(text, dbv.pszVal, text_size); CopySkipUnPrintableChars(text, dbv.ptszVal, text_size-1); DBFreeVariant(&dbv); if (text[0] != '\0') return -1; } } // Get Status name { TCHAR *tmp = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)contact->status, CNF_UNICODET); lstrcpyn(text, tmp, text_size); //CopySkipUnPrintableChars(text, dbv.pszVal, text_size-1); if (text[0] != '\0') return 1; } // Get XStatusName if (!noAwayMsg && !noXstatus && !xstatus_has_priority && contact->hContact && contact->proto) { DBVARIANT dbv; if (!DBGetContactSettingTString(contact->hContact, contact->proto, "XStatusName", &dbv)) { //lstrcpyn(text, dbv.pszVal, text_size); CopySkipUnPrintableChars(text, dbv.ptszVal, text_size-1); DBFreeVariant(&dbv); if (text[0] != '\0') return -1; } } return 1; }
static int GetContactStatus(HANDLE hContact) { /* char *szProto; szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); if(szProto==NULL) return ID_STATUS_OFFLINE; return DBGetContactSettingWord(hContact,szProto,"Status",ID_STATUS_OFFLINE); */ return (GetContactCachedStatus(hContact)); }
static int GetContactStatus(MCONTACT hContact) { /* char *szProto; szProto = GetContactProto(hContact,0); if (szProto == NULL) return ID_STATUS_OFFLINE; return db_get_w(hContact,szProto,"Status",ID_STATUS_OFFLINE); */ return (GetContactCachedStatus(hContact)); }
static int GetContactStatus(MCONTACT hContact) { return (GetContactCachedStatus(hContact)); }
static int GetContactStatus(HANDLE hContact) { return (GetContactCachedStatus(hContact)); }