TCHAR* Protocol::GetNick() { // See if can get one if (!CanGetNick()) return NULL; // Get it CONTACTINFO ci = { 0 }; ci.cbSize = sizeof(ci); ci.hContact = NULL; ci.szProto = name; ci.dwFlag = CNF_DISPLAY; #ifdef UNICODE ci.dwFlag |= CNF_UNICODE; #endif if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) { // CNF_DISPLAY always returns a string type lcopystr(nickname, ci.pszVal, SIZEOF(nickname)); mir_free(ci.pszVal); } else lcopystr(nickname, _T(""), SIZEOF(nickname)); return nickname; }
void Protocol::GetStatusMsg(int aStatus, TCHAR *msg, size_t msg_size) { if (!CanGetStatusMsg()) lcopystr(msg, _T(""), msg_size); else if (aStatus == status && ProtoServiceExists(name, PS_GETMYAWAYMSG)) { ptrT tmp((TCHAR *)CallProtoService(name, PS_GETMYAWAYMSG, 0, SGMA_TCHAR)); lcopystr(msg, tmp == NULL ? _T("") : tmp, msg_size); } else if (ServiceExists(MS_AWAYMSG_GETSTATUSMSGT)) { ptrT tmp((TCHAR *)CallService(MS_AWAYMSG_GETSTATUSMSGT, (WPARAM)aStatus, (LPARAM)name)); lcopystr(msg, tmp == NULL ? _T("") : tmp, msg_size); } }
TCHAR *Protocol::GetListeningTo() { if (!CanGetListeningTo()) { lcopystr(listening_to, _T(""), _countof(listening_to)); return listening_to; } DBVARIANT dbv = { 0 }; if (db_get_ts(NULL, name, "ListeningTo", &dbv)) { lcopystr(listening_to, _T(""), _countof(listening_to)); return listening_to; } lcopystr(listening_to, dbv.ptszVal, _countof(listening_to)); db_free(&dbv); return listening_to; }
int Protocol::GetStatus() { INT_PTR iStatus = CallProtoService(name, PS_GETSTATUS, 0, 0); if (iStatus == CALLSERVICE_NOTFOUND) return status = ID_STATUS_OFFLINE; if (iStatus != status) data_changed = true; status = (int)iStatus; // check if protocol supports custom status CUSTOM_STATUS css = { sizeof(css) }; TCHAR tszXStatusName[256], tszXStatusMessage[1024]; if (ProtoServiceExists(name, PS_GETCUSTOMSTATUSEX)) { // check if custom status is set css.flags = CSSF_TCHAR | CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE | CSSF_DEFAULT_NAME; css.status = &custom_status; css.ptszName = tszXStatusName; css.ptszMessage = tszXStatusMessage; if (CallProtoService(name, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&css) != 0) tszXStatusMessage[0] = tszXStatusName[0] = 0, custom_status = 0; } else custom_status = 0; // if protocol supports custom status, but it is not set (custom_status will be -1), show normal status if (custom_status < 0) custom_status = 0; if (custom_status == 0) { TCHAR *tmp = pcli->pfnGetStatusModeDescription(status, 0); lcopystr(status_name, tmp, _countof(status_name)); } else { TCHAR *p = (tszXStatusName[0] != 0) ? TranslateTS(tszXStatusName) : TranslateT("<no status name>"); if (tszXStatusMessage[0]) mir_sntprintf(status_name, _T("%s: %s"), p, tszXStatusMessage); else lcopystr(status_name, p, _countof(status_name)); } return status; }
TCHAR* Protocol::GetNick() { ptrT nick(Contact_GetInfo(CNF_DISPLAY, NULL, name)); lcopystr(nickname, (nick != NULL) ? nick : _T(""), _countof(nickname)); return nickname; }