MCONTACT GetContactFromID(TCHAR *szID, char *szProto) { TCHAR *szHandle; TCHAR dispName[1024]; char cProtocol[256]; TCHAR *tmp; int found = 0; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { GetContactProtocol(hContact, cProtocol, sizeof(cProtocol)); szHandle = GetContactID(hContact, cProtocol); tmp = pcli->pfnGetContactDisplayName(hContact, 0); _tcsncpy(dispName, tmp, _countof(dispName)); if ((szHandle) && ((mir_tstrcmpi(szHandle, szID) == 0) || (mir_tstrcmpi(dispName, szID) == 0)) && ((szProto == NULL) || (_stricmp(szProto, cProtocol) == 0))) found = 1; if (szHandle) { free(szHandle); } if (found) return hContact; } return NULL; }
TCHAR *GetContactID(MCONTACT hContact) { char protocol[256]; GetContactProtocol(hContact, protocol, sizeof(protocol)); return GetContactID(hContact, protocol); }
TCHAR *GetContactName(MCONTACT hContact, char *szProto) { CONTACTINFO ctInfo; char proto[200]; memset(&ctInfo, 0, sizeof(ctInfo)); ctInfo.cbSize = sizeof(ctInfo); if (szProto) { ctInfo.szProto = szProto; } else{ GetContactProtocol(hContact, proto, sizeof(proto)); ctInfo.szProto = proto; } ctInfo.dwFlag = CNF_DISPLAY | CNF_TCHAR; ctInfo.hContact = hContact; //_debug_message("retrieving contact name for %d", hContact); INT_PTR ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo); //_debug_message(" contact name %s", ctInfo.pszVal); TCHAR *buffer; if (!ret) buffer = _tcsdup(ctInfo.pszVal); mir_free(ctInfo.pszVal); if (!ret) return buffer; return NULL; }
void ResetGroupCallback(MCONTACT hContact, char *protocol) { char p[128] = {0}; GetContactProtocol(hContact, p, sizeof(protocol)); if ((!protocol) || (_stricmp(protocol, p) == 0)) { db_unset(hContact, "CList", "Group"); } }
void YahooMoveCallback(MCONTACT hContact, char *unused) { char protocol[128] = {0}; GetContactProtocol(hContact, protocol, sizeof(protocol)); if (mir_strlen(protocol) > 0) { char ygroup[128] = {0}; if (!GetStringFromDatabase(hContact, protocol, "YGroup", NULL, ygroup, sizeof(ygroup))) { CreateGroup(ygroup); AddContactToGroup(hContact, ygroup); } } }