void FormatTime(const SYSTEMTIME *st, const TCHAR *szFormat, TCHAR *szDest, size_t cbDest) { if (szDest == NULL || cbDest == 0) return; CMString tszTemp; for (const TCHAR* pFormat = szFormat; *pFormat; ++pFormat) { DWORD fmt = 0; bool date = false, iso = false; switch (*pFormat) { case 't': fmt = TIME_NOSECONDS; date = false; break; case 's': fmt = 0; date = false; break; case 'm': fmt = TIME_NOMINUTESORSECONDS; date = false; break; case 'd': fmt = DATE_SHORTDATE; date = true; break; case 'D': fmt = DATE_LONGDATE; date = true; break; case 'I': iso = true; break; default: tszTemp.AppendChar(*pFormat); continue; } TCHAR dateTimeStr[64]; if (iso) tszTemp.AppendFormat(_T("%d-%02d-%02dT%02d:%02d:%02dZ"), st->wYear, st->wMonth, st->wDay, st->wHour, st->wMinute, st->wSecond); else if (date) { GetDateFormat(LOCALE_USER_DEFAULT, fmt, st, NULL, dateTimeStr, _countof(dateTimeStr)); tszTemp.Append(dateTimeStr); } else { GetTimeFormat(LOCALE_USER_DEFAULT, fmt, st, NULL, dateTimeStr, _countof(dateTimeStr)); tszTemp.Append(dateTimeStr); } } _tcsncpy_s(szDest, cbDest, tszTemp, _TRUNCATE); }
void CJabberProto::FormatMirVer(pResourceStatus &resource, CMString &res) { res.Empty(); if (resource == NULL) return; // jabber:iq:version info requested and exists? if (resource->m_dwVersionRequestTime && resource->m_tszSoftware) { debugLog(_T("JabberUpdateMirVer: for iq:version rc %s: %s"), resource->m_tszResourceName, resource->m_tszSoftware); if (!resource->m_tszSoftwareVersion || _tcsstr(resource->m_tszSoftware, resource->m_tszSoftwareVersion)) res = resource->m_tszSoftware; else res.Format(_T("%s %s"), resource->m_tszSoftware, resource->m_tszSoftwareVersion); } // no version info and no caps info? set MirVer = resource name else if (!resource->m_tszCapsNode || !resource->m_tszCapsVer) { debugLog(_T("JabberUpdateMirVer: for rc %s: %s"), resource->m_tszResourceName, resource->m_tszResourceName); if (resource->m_tszResourceName) res = resource->m_tszResourceName; } // XEP-0115 caps mode else { debugLog(_T("JabberUpdateMirVer: for rc %s: %s#%s"), resource->m_tszResourceName, resource->m_tszCapsNode, resource->m_tszCapsVer); int i; // search through known software list for (i = 0; i < SIZEOF(sttCapsNodeToName_Map); i++) if (_tcsstr(resource->m_tszCapsNode, sttCapsNodeToName_Map[i].node)) { res.Format(_T("%s %s"), sttCapsNodeToName_Map[i].name, resource->m_tszCapsVer); break; } // unknown software if (i == SIZEOF(sttCapsNodeToName_Map)) res.Format(_T("%s %s"), resource->m_tszCapsNode, resource->m_tszCapsVer); } // attach additional info for fingerprint plguin if (resource->m_tszCapsExt && _tcsstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX86) && !_tcsstr(res, _T("x86"))) res.Append(_T(" x86")); if (resource->m_tszCapsExt && _tcsstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX64) && !_tcsstr(res, _T("x64"))) res.Append(_T(" x64")); if (resource->m_tszCapsExt && _tcsstr(resource->m_tszCapsExt, JABBER_EXT_SECUREIM) && !_tcsstr(res, _T("(SecureIM)"))) res.Append(_T(" (SecureIM)")); if (resource->m_tszCapsExt && _tcsstr(resource->m_tszCapsExt, JABBER_EXT_MIROTR) && !_tcsstr(res, _T("(MirOTR)"))) res.Append(_T(" (MirOTR)")); if (resource->m_tszCapsExt && _tcsstr(resource->m_tszCapsExt, JABBER_EXT_NEWGPG) && !_tcsstr(res, _T("(New_GPG)"))) res.Append(_T(" (New_GPG)")); if (resource->m_tszResourceName && !_tcsstr(res, resource->m_tszResourceName)) if (_tcsstr(res, _T("Miranda IM")) || _tcsstr(res, _T("Miranda NG")) || m_options.ShowForeignResourceInMirVer) res.AppendFormat(_T(" [%s]"), resource->m_tszResourceName); }
void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnReceiveUserInfo %d", reply->resultCode); if (reply->resultCode != 200) return; JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); if (pResponse == NULL) return; for (size_t i=0; ; i++) { JSONNODE *pRecord = json_at(pResponse, i); if (pRecord == NULL) break; LONG userid = json_as_int( json_get(pRecord, "uid")); if (userid == 0) return; MCONTACT hContact; if (userid == m_myUserId) hContact = NULL; else if ((hContact = FindUser(userid, false)) == NULL) return; CMString tszNick; ptrT szValue( json_as_string( json_get(pRecord, "first_name"))); if (szValue) { setTString(hContact, "FirstName", szValue); tszNick.Append(szValue); tszNick.AppendChar(' '); } if (szValue = json_as_string( json_get(pRecord, "last_name"))) { setTString(hContact, "LastName", szValue); tszNick.Append(szValue); } if (!tszNick.IsEmpty()) setTString(hContact, "Nick", tszNick); setByte(hContact, "Gender", json_as_int( json_get(pRecord, "sex")) == 2 ? 'M' : 'F'); if (szValue = json_as_string( json_get(pRecord, "bdate"))) { int d, m, y; if ( _stscanf(szValue, _T("%d.%d.%d"), &d, &m, &y) == 3) { setByte(hContact, "BirthDay", d); setByte(hContact, "BirthMonth", m); setWord(hContact, "BirthYear", y); } } szValue = json_as_string( json_get(pRecord, "photo_medium")); SetAvatarUrl(hContact, szValue); } }
void GetLinkedModulesInfo(TCHAR *moduleName, CMString &buffer) { HANDLE hDllFile = CreateFile(moduleName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hDllFile == INVALID_HANDLE_VALUE) return; HANDLE hDllMapping = CreateFileMapping(hDllFile, NULL, PAGE_READONLY, 0, 0, NULL); if (hDllMapping == INVALID_HANDLE_VALUE) { CloseHandle(hDllFile); return; } LPVOID dllAddr = MapViewOfFile(hDllMapping, FILE_MAP_READ, 0, 0, 0); static const TCHAR format[] = TEXT(" Plugin statically linked to missing module: %S\r\n"); __try { PIMAGE_NT_HEADERS nthdrs = ImageNtHeader(dllAddr); ULONG tableSize; PIMAGE_IMPORT_DESCRIPTOR importData = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToData(dllAddr, FALSE, IMAGE_DIRECTORY_ENTRY_IMPORT, &tableSize); if (importData) { while (importData->Name) { char* moduleName = (char*)ImageRvaToVa(nthdrs, dllAddr, importData->Name, NULL); if (!SearchPathA(NULL, moduleName, NULL, NULL, 0, NULL)) buffer.AppendFormat(format, moduleName); importData++; //go to next record } } bool found = false; PIMAGE_EXPORT_DIRECTORY exportData = (PIMAGE_EXPORT_DIRECTORY)ImageDirectoryEntryToData(dllAddr, FALSE, IMAGE_DIRECTORY_ENTRY_EXPORT, &tableSize); if (exportData) { ULONG* funcAddr = (ULONG*)ImageRvaToVa(nthdrs, dllAddr, exportData->AddressOfNames, NULL); for (unsigned i = 0; i < exportData->NumberOfNames && !found; ++i) { char* funcName = (char*)ImageRvaToVa(nthdrs, dllAddr, funcAddr[i], NULL); found = mir_strcmp(funcName, "MirandaPluginInfoEx") == 0 || mir_strcmp(funcName, "MirandaPluginInfo") == 0; if (mir_strcmp(funcName, "DatabasePluginInfo") == 0) { buffer.Append(TEXT(" This dll is a Miranda database plugin, another database is active right now\r\n")); found = true; } } } if (!found) buffer.Append(TEXT(" This dll is not a Miranda plugin and should be removed from plugins directory\r\n")); } __except (EXCEPTION_EXECUTE_HANDLER) {} UnmapViewOfFile(dllAddr); CloseHandle(hDllMapping); CloseHandle(hDllFile); }
void WriteBBFile(CMString& buffer, bool hdr) { static const TCHAR header[] = TEXT("[spoiler=VersionInfo][quote]"); static const TCHAR footer[] = TEXT("[/quote][/spoiler]"); buffer.Append(hdr ? header : footer); }
static void FilterGetStrings(CMString &filter, BOOL xml, BOOL swf) { filter.AppendFormat(_T("%s (*.bmp;*.jpg;*.gif;*.png"), TranslateT("All Files")); if (swf) filter.Append(_T(";*.swf")); if (xml) filter.Append(_T(";*.xml")); filter.AppendFormat(_T(")%c*.BMP;*.RLE;*.JPG;*.JPEG;*.GIF;*.PNG"), 0); if (swf) filter.Append(_T(";*.SWF")); if (xml) filter.Append(_T(";*.XML")); filter.AppendChar(0); filter.AppendFormat(_T("%s (*.bmp;*.rle)%c*.BMP;*.RLE%c"), TranslateT("Windows Bitmaps"), 0, 0); filter.AppendFormat(_T("%s (*.jpg;*.jpeg)%c*.JPG;*.JPEG%c"), TranslateT("JPEG Bitmaps"), 0, 0); filter.AppendFormat(_T("%s (*.gif)%c*.GIF%c"), TranslateT("GIF Bitmaps"), 0, 0); filter.AppendFormat(_T("%s (*.png)%c*.PNG%c"), TranslateT("PNG Bitmaps"), 0, 0); if (swf) filter.AppendFormat(_T("%s (*.swf)%c*.SWF%c"), TranslateT("Flash Animations"), 0, 0); if (xml) filter.AppendFormat(_T("%s (*.xml)%c*.XML%c"), TranslateT("XML Files"), 0, 0); filter.AppendChar(0); }
LPTSTR CJabberProto::GetResourceList(LPCTSTR jid) { if (jid == NULL) return NULL; mir_cslock lck(m_csLists); JABBER_LIST_ITEM *item = NULL; if ((item = ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL) item = ListGetItemPtr(LIST_ROSTER, jid); if (item == NULL) return NULL; if (!item->arResources.getCount()) return NULL; CMString res; for (int i=0; i < item->arResources.getCount(); i++) { res.Append(item->arResources[i]->m_tszResourceName); res.AppendChar(0); } res.AppendChar(0); return mir_tstrndup(res, res.GetLength()); }
INT_PTR CALLBACK DlgProcOptionsPage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { char key[64]; int count = 0; CMString replies; TranslateDialogDefault(hwndDlg); variables_skin_helpbutton(hwndDlg, IDC_VARIABLES); ShowWindow(GetDlgItem(hwndDlg, IDC_VARIABLES_HINT), ServiceExists(MS_VARS_FORMATSTRING)); mir_subclassWindow(GetDlgItem(hwndDlg, IDC_REPLIES), MessageEditSubclassProc); mir_snprintf(key, _countof(key), "ImmediatelySend_%x", iNumber); CheckDlgButton(hwndDlg, IDC_IMMEDIATELY, db_get_w(NULL, MODULE, key, 1) ? BST_CHECKED : BST_UNCHECKED); mir_snprintf(key, _countof(key), "RepliesCount_%x", iNumber); count = db_get_w(NULL, MODULE, key, 0); for (int i = 0; i < count; i++) { mir_snprintf(key, _countof(key), "Reply_%x_%x", iNumber, i); wchar_t *value = db_get_wsa(NULL, MODULE, key); if (value) { replies.Append(value); replies.Append(_T("\r\n")); } mir_free(value); } SetDlgItemText(hwndDlg, IDC_REPLIES, replies.GetBuffer()); } return TRUE; case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) { switch(LOWORD(wParam)) { case IDC_VARIABLES: variables_showhelp(hwndDlg, IDC_REPLIES, VHF_SIMPLEDLG, NULL, NULL); break; case IDC_IMMEDIATELY: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } } break; case WM_NOTIFY: { NMHDR *p = ((LPNMHDR)lParam); switch (p->code) { case PSN_APPLY: { char key[64]; int count = 0; wchar_t *tszReplies; mir_snprintf(key, _countof(key), "RepliesCount_%x", iNumber); count = db_get_b(NULL, MODULE, key, 0); for (int i = 0; i < count; i++) { mir_snprintf(key, _countof(key), "Reply_%x_%x", iNumber, i); db_unset(NULL, MODULE, key); } int length = SendDlgItemMessage(hwndDlg, IDC_REPLIES, WM_GETTEXTLENGTH, 0, 0); tszReplies = (wchar_t*)mir_alloc(sizeof(wchar_t)* (length + 1)); GetDlgItemText(hwndDlg, IDC_REPLIES, tszReplies, length + 1); tszReplies[length] = '\0'; { CMString replies = tszReplies; if (replies.Right(2) != _T("\r\n")) replies.Append(_T("\r\n")); count = 0; int pos = -1, prev = 0; while ((pos = replies.Find(_T("\r\n"), prev)) != -1) { mir_snprintf(key, _countof(key), "Reply_%x_%x", iNumber, count++); db_set_ws(NULL, MODULE, key, replies.Mid(prev, pos - prev).GetBuffer()); prev = pos + 2; } } mir_free(tszReplies); mir_snprintf(key, _countof(key), "RepliesCount_%x", iNumber); db_set_w(NULL, MODULE, key, count); mir_snprintf(key, _countof(key), "ImmediatelySend_%x", iNumber); db_set_b(NULL, MODULE, key, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IMMEDIATELY)); return TRUE; } break; } } break; } if (HIWORD(wParam) == EN_CHANGE && GetFocus() == (HWND)lParam) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); return FALSE; }
void PrintVersionInfo(CMString& buffer, unsigned flags) { GetProcessorString(buffer); buffer.Append(TEXT("\r\n")); GetFreeMemoryString(buffer); buffer.Append(TEXT("\r\n")); GetOSDisplayString(buffer); buffer.Append(TEXT("\r\n")); GetInternetExplorerVersion(buffer); buffer.Append(TEXT("\r\n")); GetAdminString(buffer); buffer.Append(TEXT("\r\n")); GetLanguageString(buffer); buffer.Append(TEXT("\r\n")); TCHAR *profpathfull = Utils_ReplaceVarsT(profpath); if (flags & VI_FLAG_PRNVAR) { GetFreeDiskString(profpathfull, buffer); buffer.Append(TEXT("\r\n")); } buffer.AppendFormat(TEXT("\r\nMiranda NG Version: %s"), vertxt); GetWow64String(buffer); buffer.Append(TEXT("\r\n")); TCHAR path[MAX_PATH], mirtime[30]; GetModuleFileName(NULL, path, MAX_PATH); GetLastWriteTime(path, mirtime, 30); buffer.AppendFormat(TEXT("Build time: %s\r\n"), mirtime); TCHAR profpn[MAX_PATH]; mir_sntprintf(profpn, _countof(profpn), TEXT("%s\\%s"), profpathfull, profname); buffer.AppendFormat(TEXT("Profile: %s\r\n"), profpn); if (flags & VI_FLAG_PRNVAR) { WIN32_FIND_DATA FindFileData; HANDLE hFind = FindFirstFile(profpn, &FindFileData); if (hFind != INVALID_HANDLE_VALUE) { FindClose(hFind); unsigned __int64 fsize = (unsigned __int64)FindFileData.nFileSizeHigh << 32 | FindFileData.nFileSizeLow; buffer.AppendFormat(TEXT("Profile size: %I64u Bytes\r\n"), fsize), GetLastWriteTime(&FindFileData.ftCreationTime, mirtime, 30); buffer.AppendFormat(TEXT("Profile creation date: %s\r\n"), mirtime); } } mir_free(profpathfull); GetLanguagePackString(buffer); buffer.Append(TEXT("\r\n")); // buffer.AppendFormat(TEXT("Nightly: %s\r\n"), _tcsstr(vertxt, TEXT("alpha")) ? TEXT("Yes") : TEXT("No")); // buffer.AppendFormat(TEXT("Unicode: %s\r\n"), _tcsstr(vertxt, TEXT("Unicode")) ? TEXT("Yes") : TEXT("No")); GetPluginsString(buffer, flags); if (flags & VI_FLAG_WEATHER) { buffer.AppendFormat(TEXT("\r\n%sWeather ini files:%s\r\n-------------------------------------------------------------------------------\r\n"), (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); GetWeatherStrings(buffer, flags); } if (flags & VI_FLAG_PRNVAR && !servicemode) { buffer.AppendFormat(TEXT("\r\n%sProtocols and Accounts:%s\r\n-------------------------------------------------------------------------------\r\n"), (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); GetProtocolStrings(buffer); } if (flags & VI_FLAG_PRNVAR) { buffer.AppendFormat(TEXT("\r\n%sIcon Packs:%s\r\n-------------------------------------------------------------------------------\r\n"), (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); GetIconStrings(buffer); } if (flags & VI_FLAG_PRNDLL) { __try { buffer.Append(TEXT("\r\nLoaded Modules:\r\n-------------------------------------------------------------------------------\r\n")); EnumerateLoadedModules64(GetCurrentProcess(), LoadedModules64, &buffer); } __except (EXCEPTION_EXECUTE_HANDLER) {} }
static void GetPluginsString(CMString& buffer, unsigned& flags) { buffer.AppendFormat(TEXT("Service Mode: %s\r\n"), servicemode ? TEXT("Yes") : TEXT("No")); TCHAR path[MAX_PATH]; GetModuleFileName(NULL, path, MAX_PATH); LPTSTR fname = _tcsrchr(path, TEXT('\\')); if (fname == NULL) fname = path; mir_sntprintf(fname, MAX_PATH - (fname - path), TEXT("\\plugins\\*.dll")); WIN32_FIND_DATA FindFileData; HANDLE hFind = FindFirstFile(path, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) return; size_t count = 0, ucount = 0; CMString ubuffer; ListItem* dlllist = NULL; static const TCHAR format[] = TEXT("%c %s v.%s%d.%d.%d.%d%s [%s] - %S %s\r\n"); do { bool loaded = false; mir_sntprintf(fname, MAX_PATH - (fname - path), TEXT("\\plugins\\%s"), FindFileData.cFileName); HMODULE hModule = GetModuleHandle(path); if (hModule == NULL && servicemode) { hModule = LoadLibrary(path); loaded = true; } if (hModule == NULL) { if ((flags & VI_FLAG_PRNVAR) && IsPluginEnabled(FindFileData.cFileName)) { TCHAR timebuf[30] = TEXT(""); GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); ubuffer.AppendFormat(format, TEXT(' '), FindFileData.cFileName, (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), 0, 0, 0, 0, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""), timebuf, "<unknown>", TEXT("")); GetLinkedModulesInfo(path, ubuffer); ubuffer.Append(TEXT("\r\n")); ++ucount; } continue; } PLUGININFOEX* pi = GetMirInfo(hModule); if (pi != NULL) { TCHAR timebuf[30] = TEXT(""); GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); bool ep = (size_t)pi->cbSize > sizeof(PLUGININFOEX); const TCHAR *unica = (ep && ((PLUGININFOEX*)pi)->flags & 1) ? TEXT("|Unicode aware|") : TEXT(""); ListItem* lst = new ListItem; int v1, v2, v3, v4; DWORD unused, verInfoSize = GetFileVersionInfoSize(path, &unused); if (verInfoSize != 0) { UINT blockSize; VS_FIXEDFILEINFO* fi; void* pVerInfo = mir_alloc(verInfoSize); GetFileVersionInfo(path, 0, verInfoSize, pVerInfo); VerQueryValue(pVerInfo, _T("\\"), (LPVOID*)&fi, &blockSize); v1 = HIWORD(fi->dwProductVersionMS), v2 = LOWORD(fi->dwProductVersionMS), v3 = HIWORD(fi->dwProductVersionLS), v4 = LOWORD(fi->dwProductVersionLS); mir_free(pVerInfo); } else { DWORD ver = pi->version; v1 = HIBYTE(HIWORD(ver)), v2 = LOBYTE(HIWORD(ver)), v3 = HIBYTE(LOWORD(ver)), v4 = LOBYTE(LOWORD(ver)); } lst->str.AppendFormat(format, ep ? TEXT('\xa4') : TEXT(' '), FindFileData.cFileName, (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), v1, v2, v3, v4, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""), timebuf, pi->shortName ? pi->shortName : "", unica); ListItem* lsttmp = dlllist; ListItem* lsttmppv = NULL; while (lsttmp != NULL) { if (lsttmp->str.CompareNoCase(lst->str) > 0) break; lsttmppv = lsttmp; lsttmp = lsttmp->next; } lst->next = lsttmp; if (lsttmppv == NULL) dlllist = lst; else lsttmppv->next = lst; if (mir_tstrcmpi(FindFileData.cFileName, TEXT("weather.dll")) == 0) flags |= VI_FLAG_WEATHER; ++count; } if (loaded) FreeLibrary(hModule); } while (FindNextFile(hFind, &FindFileData)); FindClose(hFind); buffer.AppendFormat(TEXT("\r\n%sActive Plugins (%u):%s\r\n"), (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), count, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); ListItem* lsttmp = dlllist; while (lsttmp != NULL) { buffer.Append(lsttmp->str); ListItem* lsttmp1 = lsttmp->next; delete lsttmp; lsttmp = lsttmp1; } if (ucount) { buffer.AppendFormat(TEXT("\r\n%sUnloadable Plugins (%u):%s\r\n"), (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), ucount, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); buffer.Append(ubuffer); } }
void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnReceiveFriends %d", reply->resultCode); if (reply->resultCode != 200) return; JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot), *pInfo; if (pResponse == NULL) return; bool bCleanContacts = getByte("AutoClean", 0) != 0; LIST<void> arContacts(10, PtrKeySortT); if (bCleanContacts) for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) if (!isChatRoom(hContact)) arContacts.insert((HANDLE)hContact); for (int i = 0; (pInfo = json_at(pResponse, i)) != NULL; i++) { ptrT szValue(json_as_string(json_get(pInfo, "uid"))); if (szValue == NULL) continue; CMString tszNick; MCONTACT hContact = FindUser(_ttoi(szValue), true); arContacts.remove((HANDLE)hContact); szValue = json_as_string(json_get(pInfo, "first_name")); if (szValue) { setTString(hContact, "FirstName", szValue); tszNick.Append(szValue); tszNick.AppendChar(' '); } if (szValue = json_as_string(json_get(pInfo, "last_name"))) { setTString(hContact, "LastName", szValue); tszNick.Append(szValue); } if (!tszNick.IsEmpty()) setTString(hContact, "Nick", tszNick); szValue = json_as_string(json_get(pInfo, "photo_medium")); SetAvatarUrl(hContact, szValue); setWord(hContact, "Status", (json_as_int(json_get(pInfo, "online")) == 0) ? ID_STATUS_OFFLINE : ID_STATUS_ONLINE); int iValue = json_as_int(json_get(pInfo, "sex")); if (iValue) setByte(hContact, "Gender", (iValue == 2) ? 'M' : 'F'); if ((iValue = json_as_int(json_get(pInfo, "timezone"))) != 0) setByte(hContact, "Timezone", iValue * -2); szValue = json_as_string(json_get(pInfo, "mobile_phone")); if (szValue && *szValue) setTString(hContact, "Cellular", szValue); szValue = json_as_string(json_get(pInfo, "home_phone")); if (szValue && *szValue) setTString(hContact, "Phone", szValue); } if (bCleanContacts) for (int i = 0; i < arContacts.getCount(); i++) CallService(MS_DB_CONTACT_DELETE, (WPARAM)arContacts[i], 0); }
TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto) { initcheck NULL; mir_cslock lck(trayLockCS); TCHAR *szSeparator = _T("\n"); if (szProto == NULL) { if (accounts.getCount() == 0) return NULL; if (accounts.getCount() == 1) return cli.pfnTrayIconMakeTooltip(szPrefix, accounts[0]->szModuleName); CMString tszTip; if (szPrefix && szPrefix[0]) { if (!db_get_b(NULL, "CList", "AlwaysStatus", SETTING_ALWAYSSTATUS_DEFAULT)) { _tcsncpy_s(cli.szTip, MAX_TIP_SIZE, szPrefix, _TRUNCATE); return cli.szTip; } tszTip.Append(szPrefix); } for (int t = 0; t < accounts.getCount(); t++) { int i = cli.pfnGetAccountIndexByPos(t); if (i == -1) continue; PROTOACCOUNT *pa = accounts[i]; if (!cli.pfnGetProtocolVisibility(pa->szModuleName)) continue; TCHAR *szStatus = cli.pfnGetStatusModeDescription(CallProtoServiceInt(NULL, pa->szModuleName, PS_GETSTATUS, 0, 0), 0); if (!szStatus) continue; if (!tszTip.IsEmpty()) tszTip.AppendChar('\n'); if (mToolTipTrayTips) { tszTip.AppendFormat(_T("<b>%-12.12s</b>\t%s"), pa->tszAccountName, szStatus); ptrT ProtoXStatus(sttGetXStatus(pa->szModuleName)); if (ProtoXStatus != NULL) { if (!tszTip.IsEmpty()) tszTip.AppendChar('\n'); tszTip.AppendFormat(_T("%-24.24s\n"), ProtoXStatus); } } else tszTip.AppendFormat(_T("%s %s"), pa->tszAccountName, szStatus); } _tcsncpy_s(cli.szTip, MAX_TIP_SIZE, tszTip, _TRUNCATE); } else { PROTOACCOUNT *pa = Proto_GetAccount(szProto); if (pa != NULL) { ptrT ProtoXStatus(sttGetXStatus(szProto)); TCHAR *szStatus = cli.pfnGetStatusModeDescription(CallProtoServiceInt(NULL, szProto, PS_GETSTATUS, 0, 0), 0); if (szPrefix && szPrefix[0]) { if (db_get_b(NULL, "CList", "AlwaysStatus", SETTING_ALWAYSSTATUS_DEFAULT)) { if (mToolTipTrayTips) { if (ProtoXStatus != NULL) mir_sntprintf(cli.szTip, MAX_TIP_SIZE, _T("%s%s<b>%-12.12s</b>\t%s%s%-24.24s"), szPrefix, szSeparator, pa->tszAccountName, szStatus, szSeparator, ProtoXStatus); else mir_sntprintf(cli.szTip, MAX_TIP_SIZE, _T("%s%s<b>%-12.12s</b>\t%s"), szPrefix, szSeparator, pa->tszAccountName, szStatus); } else mir_sntprintf(cli.szTip, MAX_TIP_SIZE, _T("%s%s%s %s"), szPrefix, szSeparator, pa->tszAccountName, szStatus); } else mir_tstrncpy(cli.szTip, szPrefix, MAX_TIP_SIZE); } else { if (mToolTipTrayTips) { if (ProtoXStatus != NULL) mir_sntprintf(cli.szTip, MAX_TIP_SIZE, _T("<b>%-12.12s</b>\t%s\n%-24.24s"), pa->tszAccountName, szStatus, ProtoXStatus); else mir_sntprintf(cli.szTip, MAX_TIP_SIZE, _T("<b>%-12.12s</b>\t%s"), pa->tszAccountName, szStatus); } else mir_sntprintf(cli.szTip, MAX_TIP_SIZE, _T("%s %s"), pa->tszAccountName, szStatus); } } } return cli.szTip; }