void CVkProto::RetrieveStatusMusic(const CMString &StatusMsg) { debugLogA("CVkProto::RetrieveStatusMusic"); if (!IsOnline() || m_iStatus == ID_STATUS_INVISIBLE || m_vkOptions.iMusicSendMetod == MusicSendMetod::sendNone) return; CMString code; CMString tszOldStatusMsg(db_get_tsa(0, m_szModuleName, "OldStatusMsg")); if (StatusMsg.IsEmpty()) { if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendBroadcastOnly) code = "API.audio.setBroadcast();return null;"; else { CMString codeformat("API.status.set({text:\"%s\"});return null;"); code.AppendFormat(codeformat, tszOldStatusMsg); } m_bSetBroadcast = false; } else { if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendBroadcastOnly) { CMString codeformat("var StatusMsg=\"%s\";var CntLmt=100;var OldMsg=API.status.get();" "var Tracks=API.audio.search({\"q\":StatusMsg,\"count\":CntLmt,\"search_own\":1});" "var Cnt=Tracks.count;if(Cnt>CntLmt){Cnt=CntLmt;}" "if(Cnt==0){API.audio.setBroadcast();}" "else{var i=0;var j=0;var Track=\" \";" "while(i<Cnt){Track=Tracks.items[i].artist+\" - \"+Tracks.items[i].title;if(Track==StatusMsg){j=i;}i=i+1;}" "Track=Tracks.items[j].owner_id+\"_\"+Tracks.items[j].id;API.audio.setBroadcast({\"audio\":Track});" "};return OldMsg;"); code.AppendFormat(codeformat, StatusMsg); } else if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendStatusOnly) { CMString codeformat("var StatusMsg=\"♫ %s\";var OldMsg=API.status.get();" "API.status.set({\"text\":StatusMsg});" "return OldMsg;"); code.AppendFormat(codeformat, StatusMsg); } else if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendBroadcastAndStatus) { CMString codeformat("var StatusMsg=\"%s\";var CntLmt=100;var Track=\" \";var OldMsg=API.status.get();" "var Tracks=API.audio.search({\"q\":StatusMsg,\"count\":CntLmt,\"search_own\":1});" "var Cnt=Tracks.count;if(Cnt>CntLmt){Cnt=CntLmt;}" "if(Cnt==0){Track=\"♫ \"+StatusMsg;API.status.set({\"text\":Track});}" "else{var i=0;var j=-1;" "while(i<Cnt){Track=Tracks.items[i].artist+\" - \"+Tracks.items[i].title;if(Track==StatusMsg){j=i;}i=i+1;}" "if(j==-1){Track=\"♫ \"+StatusMsg;API.status.set({\"text\":Track});}else{" "Track=Tracks.items[j].owner_id+\"_\"+Tracks.items[j].id;};API.audio.setBroadcast({\"audio\":Track});" "};return OldMsg;"); code.AppendFormat(codeformat, StatusMsg); } m_bSetBroadcast = true; } Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveStatus) << TCHAR_PARAM("code", code)); }
MIR_CORE_DLL(void) Bitmap_GetFilter(TCHAR *dest, size_t destLen) { if (dest == NULL) return; CMString filter; filter.AppendFormat(_T("%s (*.bmp;*.jpg;*.gif;*.png)%c*.BMP;*.RLE;*.JPG;*.JPEG;*.GIF;*.PNG%c"), TranslateT("All Files"), 0, 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); filter.AppendChar(0); _tcsncpy_s(dest, destLen, filter, filter.GetLength()); }
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); }
CMString CVkProto::GetVkFeedback(const JSONNode &jnFeedback, VKObjType vkFeedbackType, OBJLIST<CVkUserInfo> &vkUsers, CVkUserInfo *vkUser) { debugLogA("CVkProto::GetVkFeedback"); CMString tszRes; if (!jnFeedback || !vkFeedbackType) return tszRes; CMString tszFormat; LONG iUserId = 0; if (vkFeedbackType == vkComment) { iUserId = jnFeedback["from_id"].as_int(); tszFormat = _T("%s %%s %%s\n%s"); } else if (vkFeedbackType == vkPost) { iUserId = jnFeedback["owner_id "].as_int(); tszFormat = _T("%s %%s %%s\n%s"); } else if (vkFeedbackType == VKObjType::vkUsers || vkFeedbackType == vkCopy) { const JSONNode &jnUsers = jnFeedback["items"]; CMString tszUsers; for (auto it = jnUsers.begin(); it != jnUsers.end(); ++it) { const JSONNode &jnUserItem = (*it); if (!jnUserItem["from_id"]) continue; iUserId = jnUserItem["from_id"].as_int(); vkUser = GetVkUserInfo(iUserId, vkUsers); if (!tszUsers.IsEmpty()) tszUsers += _T(", "); tszUsers += SetBBCString(vkUser->m_tszUserNick, m_iBBCForNews, vkbbcUrl, vkUser->m_tszLink); } tszRes.AppendFormat(_T("%s %%s %%s"), tszUsers); vkUser = NULL; iUserId = 0; } if (iUserId) { vkUser = GetVkUserInfo(iUserId, vkUsers); CMString tszText(jnFeedback["text"].as_mstring()); tszText.Replace(_T("%"), _T("%%")); tszRes.AppendFormat(tszFormat, SetBBCString(vkUser->m_tszUserNick, m_iBBCForNews, vkbbcUrl, vkUser->m_tszLink), ClearFormatNick(tszText)); } return tszRes; }
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 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); }
// we assume that it could be called only for the metacontacts static int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam) { StatusIconClickData *sicd = (StatusIconClickData*)lParam; if (lstrcmpA(sicd->szModule, META_PROTO)) return 0; DBCachedContact *cc = CheckMeta(hMeta); if (cc == NULL) return 0; HMENU hMenu = CreatePopupMenu(); int iDefault = Meta_GetContactNumber(cc, db_mc_getSrmmSub(cc->contactID)); MENUITEMINFO mii = { sizeof(mii) }; mii.fMask = MIIM_ID | MIIM_STATE | MIIM_STRING; for (int i = 0; i < cc->nSubs; i++) { char *szProto = GetContactProto(cc->pSubs[i]); if (szProto == NULL) continue; PROTOACCOUNT *pa = ProtoGetAccount(szProto); if (pa == NULL) continue; CMString tszNick; if (options.menu_contact_label == DNT_DID) tszNick = cli.pfnGetContactDisplayName(cc->pSubs[i], 0); else Meta_GetSubNick(hMeta, i, tszNick); tszNick.AppendFormat(_T(" [%s]"), pa->tszAccountName); mii.wID = i + 1; mii.fState = (i == iDefault) ? MFS_CHECKED : MFS_ENABLED; mii.dwTypeData = tszNick.GetBuffer(); mii.cch = tszNick.GetLength(); InsertMenuItem(hMenu, i, TRUE, &mii); } UINT res = TrackPopupMenu(hMenu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_BOTTOMALIGN | TPM_LEFTALIGN, sicd->clickLocation.x, sicd->clickLocation.y, 0, cli.hwndContactTree, NULL); if (res > 0) { MCONTACT hChosen = Meta_GetContactHandle(cc, res - 1); MetaSrmmData tmp = { cc->contactID }; if (MetaSrmmData *p = arMetaWindows.find(&tmp)) p->m_hSub = hChosen; db_mc_setDefault(cc->contactID, hChosen, true); } return 0; }
CVKNewsItem* CVkProto::GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers) { debugLogA("CVkProto::GetVkNotificationsItem"); if (!jnItem) return NULL; CMString tszType(jnItem["type"].as_mstring()); VKObjType vkFeedbackType = vkNull, vkParentType = vkNull; CMString tszNotificationTranslate = SpanVKNotificationType(tszType, vkFeedbackType, vkParentType); const JSONNode &jnFeedback = jnItem["feedback"]; const JSONNode &jnParent = jnItem["parent"]; if (!jnFeedback || !jnParent) return NULL; CVkUserInfo *vkUser = NULL; CMString tszFeedback = GetVkFeedback(jnFeedback, vkFeedbackType, vkUsers, vkUser); CVKNewsItem* vkNotification = GetVkParent(jnParent, vkParentType); if (!vkNotification) return NULL; if (vkNotification && !tszFeedback.IsEmpty()) { CMString tszNotificaton; tszNotificaton.AppendFormat(tszFeedback, tszNotificationTranslate, vkNotification->tszText); vkNotification->tszText = tszNotificaton; tszFeedback = RemoveBBC(tszFeedback); int idx = tszFeedback.Find(_T(" %s %s")); vkNotification->tszPopupTitle.AppendFormat(_T("%s %s"), tszFeedback.Mid(0, idx), tszNotificationTranslate); if (tszFeedback.GetLength() > idx + 7) { if (!vkNotification->tszPopupText.IsEmpty()) vkNotification->tszPopupText += _T("\n>> "); vkNotification->tszPopupText += tszFeedback.Mid(idx + 7, tszFeedback.GetLength() - idx - 7); } vkNotification->tszType = tszType; vkNotification->tDate = jnItem["date"].as_int(); vkNotification->vkFeedbackType = vkFeedbackType; vkNotification->vkParentType = vkParentType; vkNotification->vkUser = vkUser; return vkNotification; } delete vkNotification; return NULL; }
static void GetProtocolStrings(CMString& buffer) { PROTOACCOUNT **accList; int accCount; int i, j; Proto_EnumAccounts(&accCount, &accList); int protoCount; PROTOCOLDESCRIPTOR **protoList; Proto_EnumProtocols(&protoCount, &protoList); int protoCountMy = 0; char** protoListMy = (char**)alloca((protoCount + accCount) * sizeof(char*)); for (i = 0; i < protoCount; i++) { if (protoList[i]->type != PROTOTYPE_PROTOCOL) continue; protoListMy[protoCountMy++] = protoList[i]->szName; } for (j = 0; j < accCount; j++) { for (i = 0; i < protoCountMy; i++) if (!mir_strcmp(protoListMy[i], accList[j]->szProtoName)) break; if (i == protoCountMy) protoListMy[protoCountMy++] = accList[j]->szProtoName; } ProtoCount *protos = (ProtoCount*)alloca(sizeof(ProtoCount) * protoCountMy); memset(protos, 0, sizeof(ProtoCount) * protoCountMy); for (j = 0; j < accCount; j++) for (i = 0; i < protoCountMy; i++) if (!mir_strcmp(protoListMy[i], accList[j]->szProtoName)) { protos[i].nloaded = accList[j]->bDynDisabled != 0; if (Proto_IsAccountEnabled(accList[j])) ++protos[i].countse; else ++protos[i].countsd; break; } for (i = 0; i < protoCountMy; i++) buffer.AppendFormat(TEXT("%-24s %d - Enabled %d - Disabled %sLoaded\r\n"), (TCHAR*)_A2T(protoListMy[i]), protos[i].countse, protos[i].countsd, protos[i].nloaded ? _T("Not ") : _T("")); }
void UnreadThreadNotification(LPCSTR acc, LPCTSTR jid, LPCTSTR url, LPCTSTR unreadCount, const MAIL_THREAD_NOTIFICATION *mtn) { POPUPDATAT data = { 0 }; FormatPseudocontactDisplayName(&data.lptzContactName[0], jid, unreadCount); CMString tszSenders; for (int i = 0; i < SENDER_COUNT; i++) { const SENDER &p = mtn->senders[i]; if (p.addr == NULL) break; if (p.name) tszSenders.AppendFormat(_T(" %s <%s>\n"), p.name, p.addr); else tszSenders.AppendFormat(_T(" %s\n"), p.addr); } if (ReadCheckbox(0, IDC_ADDSNIP, (DWORD)TlsGetValue(itlsSettings))) mir_sntprintf(data.lptzText, TranslateTS(FULL_NOTIFICATION_FORMAT), mtn->subj, tszSenders.c_str(), mtn->snip); else mir_sntprintf(data.lptzText, TranslateTS(SHORT_NOTIFICATION_FORMAT), mtn->subj, tszSenders.c_str()); ShowNotification(acc, &data, jid, url, unreadCount); }
static INT_PTR CALLBACK WallPostFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WALLPOST_FORM_PARAMS *param = (WALLPOST_FORM_PARAMS *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: param = (WALLPOST_FORM_PARAMS *)lParam; TranslateDialogDefault(hwndDlg); { SetDlgItemText(hwndDlg, IDC_ST_WARNING, _T("")); CMString tszTitle; tszTitle.AppendFormat(_T("%s %s"), TranslateT("Wall message for"), param->ptszNick); SetWindowText(hwndDlg, tszTitle); } SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)param); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, 0); return TRUE; case IDOK: TCHAR tszMsg[4096], tszUrl[4096]; GetDlgItemText(hwndDlg, IDC_ED_MSG, tszMsg, _countof(tszMsg)); GetDlgItemText(hwndDlg, IDC_ED_URL, tszUrl, _countof(tszUrl)); if (IsEmpty(tszMsg) && IsEmpty(tszUrl)) { SetDlgItemText(hwndDlg, IDC_ST_WARNING, TranslateT("Attention! Message body or url should not be empty!")); return FALSE; } if (!IsEmpty(tszMsg)) param->ptszMsg = mir_tstrdup(tszMsg); if (!IsEmpty(tszUrl)) param->ptszUrl = mir_tstrdup(tszUrl); param->bFriendsOnly = IsDlgButtonChecked(hwndDlg, IDC_ONLY_FRIENDS) == BST_CHECKED; EndDialog(hwndDlg, (INT_PTR)param); return TRUE; } } return FALSE; }
CVKNewsItem* CVkProto::GetVkGroupInvates(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers) { debugLogA("CVkProto::GetVkGroupInvates"); if (!jnItem) return NULL; CMString tszType(jnItem["type"].as_mstring()); VKObjType vkFeedbackType = vkNull, vkParentType = vkNull; CMString tszNotificationTranslate = SpanVKNotificationType(tszType, vkFeedbackType, vkParentType); if (!jnItem["id"]) return NULL; LONG iGroupId = jnItem["id"].as_int(); CMString tszId; tszId.AppendFormat(_T("%d,"), iGroupId); CMString tszIds = ptrT(db_get_tsa(NULL, m_szModuleName, "InviteGroupIds")); if (tszIds.Find(tszId, 0) != -1) return NULL; LONG iUserId = !jnItem["invited_by"] ? 0 : jnItem["invited_by"].as_int(); CVKNewsItem *vkNotification = new CVKNewsItem(); vkNotification->tDate = time(NULL); vkNotification->vkUser = GetVkUserInfo(iUserId, vkUsers); vkNotification->tszType = tszType; vkNotification->tszId = tszId; vkNotification->vkFeedbackType = vkFeedbackType; vkNotification->vkParentType = vkParentType; CMString tszGroupName, tszGLink; CMString tszGName = jnItem["name"].as_mstring(); tszGLink.AppendFormat(_T("https://vk.com/%s"), jnItem["screen_name"].as_mstring()); tszGroupName = SetBBCString(tszGName, m_iBBCForNews, vkbbcUrl, tszGLink); CMString tszUsers = SetBBCString(iUserId ? vkNotification->vkUser->m_tszUserNick : TranslateT("Unknown"), m_iBBCForNews, vkbbcUrl, iUserId ? vkNotification->vkUser->m_tszLink : _T("https://vk.com/")); vkNotification->tszText.AppendFormat(_T("%s %s %s"), tszUsers, tszNotificationTranslate, tszGroupName); tszIds += tszId; setTString("InviteGroupIds", tszIds); return vkNotification; }
bool GetSmileyFile(CMString& url, const CMString& packstr) { _TPattern *urlsplit = _TPattern::compile(_T(".*/(.*)")); _TMatcher *m0 = urlsplit->createTMatcher(url); m0->findFirstMatch(); CMString filename; filename.AppendFormat(_T("%s\\%s\\"), cachepath, packstr.c_str()); int pathpos = filename.GetLength(); filename += m0->getGroup(1); delete m0; delete urlsplit; bool needext = filename.Find('.') == -1; if (needext) filename += _T(".*"); _tfinddata_t c_file; INT_PTR hFile = _tfindfirst((TCHAR*)filename.c_str(), &c_file); if (hFile > -1) { _findclose(hFile); filename.Truncate(pathpos); filename += c_file.name; url = filename; return false; } if (needext) filename.Truncate(filename.GetLength() - 1); WaitForSingleObject(g_hDlMutex, 3000); dlQueue.insert(new QueueElem(url, filename, needext)); ReleaseMutex(g_hDlMutex); if (!threadRunning) { threadRunning = true; mir_forkthread(SmileyDownloadThread, NULL); } url = filename; return false; }
INT_PTR __cdecl CVkProto::SvcDeleteFriend(WPARAM hContact, LPARAM flag) { debugLogA("CVkProto::SvcDeleteFriend"); LONG userID = getDword(hContact, "ID", -1); if (!IsOnline() || userID == -1 || userID == VK_FEED_USER) return 1; ptrT ptszNick(db_get_tsa(hContact, m_szModuleName, "Nick")); CMString ptszMsg; if (flag == 0) { ptszMsg.AppendFormat(TranslateT("Are you sure to delete %s from your friend list?"), IsEmpty(ptszNick) ? TranslateT("(Unknown contact)") : ptszNick); if (IDNO == MessageBox(NULL, ptszMsg, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO)) return 1; } Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/friends.delete.json", true, &CVkProto::OnReceiveDeleteFriend) << INT_PARAM("user_id", userID) << VER_API)->pUserInfo = new CVkSendMsgParam(hContact); return 0; }
void CVkProto::RetrieveUnreadNotifications(time_t tLastNotificationsTime) { debugLogA("CVkProto::RetrieveUnreadNotifications"); if (!IsOnline()) return; time_t tLastNotificationsReqTime = getDword("LastNotificationsReqTime", time(NULL) - 24 * 60 * 60); if (time(NULL) - tLastNotificationsReqTime < 3 * 60) return; CMString code; code.AppendFormat(_T("return{\"notifications\":API.notifications.get({\"count\": 100, \"start_time\":%d})%s"), (LONG)(tLastNotificationsTime + 1), m_bNotificationFilterInvites ? _T(",\"groupinvates\":API.groups.getInvites({\"extended\":1})};") : _T("};")); Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveUnreadNotifications)) << TCHAR_PARAM("code", code) << VER_API; setDword("LastNotificationsReqTime", (DWORD)time(NULL)); }
CVkUserInfo* CVkProto::GetVkUserInfo(LONG iUserId, OBJLIST<CVkUserInfo> &vkUsers) { debugLogA("CVkProto::GetVkUserInfo %d", iUserId); if (iUserId == 0) return NULL; bool bIsGroup = (iUserId < 0); CVkUserInfo * vkUser = vkUsers.find((CVkUserInfo *)&iUserId); if (vkUser == NULL) { CMString tszNick = TranslateT("Unknown"); CMString tszLink = _T("https://vk.com/"); if (iUserId) { tszLink += bIsGroup ? "club" : "id"; tszLink.AppendFormat(_T("%d"), bIsGroup ? -iUserId : iUserId); } vkUser = new CVkUserInfo(iUserId, bIsGroup, tszNick, tszLink, bIsGroup ? NULL : FindUser(iUserId)); vkUsers.insert(vkUser); } return vkUser; }
void CSkypeProto::UpdateProfileDisplayName(const JSONNode &root, MCONTACT hContact) { ptrT firstname(getTStringA(hContact, "FirstName")); ptrT lastname(getTStringA(hContact, "LastName")); if (firstname) { CMString nick = firstname; if (lastname) nick.AppendFormat(_T(" %s"), lastname); setTString(hContact, "Nick", nick); } else if (lastname) setTString(hContact, "Nick", lastname); else { const JSONNode &node = root["displayname"]; CMString displayname((!node) ? root["username"].as_mstring() : node.as_mstring()); if (!displayname.IsEmpty() && displayname != "null") setTString(hContact, "Nick", displayname); else delSetting(hContact, "Nick"); } }
CVKNewsItem* CVkProto::GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers) { debugLogA("CVkProto::GetVkNotificationsItem"); if (!jnItem) return NULL; CMString tszType(jnItem["type"].as_mstring()); VKObjType vkFeedbackType = vkNull, vkParentType = vkNull; CMString tszNotificationTranslate = SpanVKNotificationType(tszType, vkFeedbackType, vkParentType); const JSONNode &jnFeedback = jnItem["feedback"]; const JSONNode &jnParent = jnItem["parent"]; if (!jnFeedback || !jnParent) return NULL; CVkUserInfo *vkUser = NULL; CMString tszFeedback = GetVkFeedback(jnFeedback, vkFeedbackType, vkUsers, vkUser); CVKNewsItem* vkNotification = GetVkParent(jnParent, vkParentType); if (!vkNotification) return NULL; if (vkNotification && !tszFeedback.IsEmpty()) { CMString tszNotificaton; tszNotificaton.AppendFormat(tszFeedback, tszNotificationTranslate, vkNotification->tszText); vkNotification->tszText = tszNotificaton; vkNotification->tszType = tszType; vkNotification->tDate = jnItem["date"].as_int(); vkNotification->vkFeedbackType = vkFeedbackType; vkNotification->vkParentType = vkParentType; vkNotification->vkUser = vkUser; return vkNotification; } delete vkNotification; return NULL; }
static void GetIconStrings(CMString& buffer) { 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("\\Icons\\*.*")); WIN32_FIND_DATA FindFileData; HANDLE hFind = FindFirstFile(path, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) return; do { if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; TCHAR timebuf[30] = TEXT(""); GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); buffer.AppendFormat(TEXT(" %s [%s]\r\n"), FindFileData.cFileName, timebuf); } while (FindNextFile(hFind, &FindFileData)); FindClose(hFind); }
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); }
static void GetWeatherStrings(CMString& buffer, unsigned flags) { 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\\weather\\*.ini")); WIN32_FIND_DATA FindFileData; HANDLE hFind = FindFirstFile(path, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) return; do { if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; mir_sntprintf(fname, MAX_PATH - (fname - path), TEXT("\\plugins\\weather\\%s"), FindFileData.cFileName); HANDLE hDumpFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hDumpFile != INVALID_HANDLE_VALUE) { char buf[8192]; DWORD bytes = 0; ReadFile(hDumpFile, buf, 8190, &bytes, NULL); buf[bytes] = 0; char* ver = strstr(buf, "Version="); if (ver != NULL) { char *endid = strchr(ver, '\r'); if (endid != NULL) *endid = 0; else { endid = strchr(ver, '\n'); if (endid != NULL) *endid = 0; } ver += 8; } char *id = strstr(buf, "Name="); if (id != NULL) { char *endid = strchr(id, '\r'); if (endid != NULL) *endid = 0; else { endid = strchr(id, '\n'); if (endid != NULL) *endid = 0; } id += 5; } TCHAR timebuf[30] = TEXT(""); GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); static const TCHAR format[] = TEXT(" %s v.%s%S%s [%s] - %S\r\n"); buffer.AppendFormat(format, FindFileData.cFileName, (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), ver, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""), timebuf, id); CloseHandle(hDumpFile); } } while (FindNextFile(hFind, &FindFileData)); FindClose(hFind); }
void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { CVkFileUploadParam *fup = (CVkFileUploadParam *)pReq->pUserInfo; if (!IsOnline()) { SendFileFiled(fup, VKERR_OFFLINE); return; } debugLogA("CVkProto::OnReciveUploadFile %d", reply->resultCode); if (reply->resultCode != 200) { SendFileFiled(fup, VKERR_FILE_NOT_UPLOADED); return; } JSONNode jnRoot; const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot); if (!jnResponse || pReq->m_iErrorCode) { SendFileFiled(fup, pReq->m_iErrorCode); return; } int id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["id"].as_int() : (*jnResponse.begin())["id"].as_int(); int owner_id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["owner_id"].as_int() : (*jnResponse.begin())["owner_id"].as_int(); if ((id == 0) || (owner_id == 0)) { SendFileFiled(fup, VKERR_INVALID_PARAMETERS); return; } CMString Attachment; switch (fup->GetType()) { case CVkFileUploadParam::typeImg: Attachment.AppendFormat(_T("photo%d_%d"), owner_id, id); break; case CVkFileUploadParam::typeAudio: Attachment.AppendFormat(_T("audio%d_%d"), owner_id, id); break; case CVkFileUploadParam::typeDoc: Attachment.AppendFormat(_T("doc%d_%d"), owner_id, id); break; default: SendFileFiled(fup, VKERR_FTYPE_NOT_SUPPORTED); return; } AsyncHttpRequest *pMsgReq; if (isChatRoom(fup->hContact)) { ptrT tszChatID(getTStringA(fup->hContact, "ChatRoomID")); if (!tszChatID) { SendFileFiled(fup, VKERR_INVALID_USER); return; } CVkChatInfo *cc = GetChatById(tszChatID); if (cc == NULL) { SendFileFiled(fup, VKERR_INVALID_USER); return; } pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendChatMsg, AsyncHttpRequest::rpHigh) << INT_PARAM("chat_id", cc->m_chatid); pMsgReq->pUserInfo = pReq->pUserInfo; } else { LONG userID = getDword(fup->hContact, "ID", -1); if (userID == -1 || userID == VK_FEED_USER) { SendFileFiled(fup, VKERR_INVALID_USER); return; } pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh) << INT_PARAM("user_id", userID); pMsgReq->pUserInfo = new CVkSendMsgParam(fup->hContact, fup); } pMsgReq << TCHAR_PARAM("message", fup->Desc) << TCHAR_PARAM("attachment", Attachment) << VER_API; pMsgReq->AddHeader("Content-Type", "application/x-www-form-urlencoded"); Push(pMsgReq); }
CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments) { CMString res; res.AppendChar('\n'); res += TranslateT("Attachments:"); res.AppendChar('\n'); JSONNODE *pAttach; for (int k = 0; (pAttach = json_at(pAttachments, k)) != NULL; k++) { res.AppendChar('\t'); ptrT ptszType(json_as_string(json_get(pAttach, "type"))); if (!lstrcmp(ptszType, _T("photo"))) { JSONNODE *pPhoto = json_get(pAttach, "photo"); if (pPhoto == NULL) continue; ptrT ptszLink; for (int i = 0; i < SIZEOF(szImageTypes); i++) { JSONNODE *n = json_get(pPhoto, szImageTypes[i]); if (n != NULL) { ptszLink = json_as_string(n); break; } } int iWidth = json_as_int(json_get(pPhoto, "width")); int iHeight = json_as_int(json_get(pPhoto, "height")); res.AppendFormat(_T("%s: %s (%dx%d)"), TranslateT("Photo"), ptszLink, iWidth, iHeight); } else if (!lstrcmp(ptszType, _T("audio"))) { JSONNODE *pAudio = json_get(pAttach, "audio"); if (pAudio == NULL) continue; int aid = json_as_int(json_get(pAudio, "aid")); int ownerID = json_as_int(json_get(pAudio, "owner_id")); ptrT ptszArtist(json_as_string(json_get(pAudio, "artist"))); ptrT ptszTitle(json_as_string(json_get(pAudio, "title"))); res.AppendFormat(_T("%s: (%s - %s) - http://vk.com/audio%d_%d"), TranslateT("Audio"), ptszArtist, ptszTitle, ownerID, aid); } else if (!lstrcmp(ptszType, _T("video"))) { JSONNODE *pVideo = json_get(pAttach, "video"); if (pVideo == NULL) continue; ptrT ptszTitle(json_as_string(json_get(pVideo, "title"))); int vid = json_as_int(json_get(pVideo, "vid")); int ownerID = json_as_int(json_get(pVideo, "owner_id")); res.AppendFormat(_T("%s: %s - http://vk.com/video%d_%d"), TranslateT("Video"), ptszTitle, ownerID, vid); } else if (!lstrcmp(ptszType, _T("doc"))) { JSONNODE *pDoc = json_get(pAttach, "doc"); if (pDoc == NULL) continue; ptrT ptszTitle(json_as_string(json_get(pDoc, "title"))); ptrT ptszUrl(json_as_string(json_get(pDoc, "url"))); res.AppendFormat(_T("%s: (%s) - %s"), TranslateT("Document"), ptszTitle, ptszUrl); } else if (!lstrcmp(ptszType, _T("wall"))) { JSONNODE *pWall = json_get(pAttach, "wall"); if (pWall == NULL) continue; ptrT ptszText(json_as_string(json_get(pWall, "text"))); int id = json_as_int(json_get(pWall, "id")); int fromID = json_as_int(json_get(pWall, "from_id")); res.AppendFormat(_T("%s: %s - http://vk.com/wall%d_%d"), TranslateT("Wall post"), ptszText, fromID, id); } else res.AppendFormat(TranslateT("Unsupported or unknown attachment type: %s"), ptszType); res.AppendChar('\n'); } return res; }
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); } }
static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { SHAutoComplete(GetDlgItem(hwndDlg, IDC_FILEDIR), SHACF_FILESYS_DIRS); TCHAR str[MAX_PATH]; GetContactReceivedFilesDir(NULL, str, _countof(str), FALSE); SetDlgItemText(hwndDlg, IDC_FILEDIR, str); CheckDlgButton(hwndDlg, IDC_AUTOACCEPT, db_get_b(NULL, "SRFile", "AutoAccept", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOMIN, db_get_b(NULL, "SRFile", "AutoMin", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOCLOSE, db_get_b(NULL, "SRFile", "AutoClose", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOCLEAR, db_get_b(NULL, "SRFile", "AutoClear", 1) ? BST_CHECKED : BST_UNCHECKED); switch (db_get_b(NULL, "SRFile", "UseScanner", VIRUSSCAN_DISABLE)) { case VIRUSSCAN_AFTERDL: CheckDlgButton(hwndDlg, IDC_SCANAFTERDL, BST_CHECKED); break; case VIRUSSCAN_DURINGDL: CheckDlgButton(hwndDlg, IDC_SCANDURINGDL, BST_CHECKED); break; default: CheckDlgButton(hwndDlg, IDC_NOSCANNER, BST_CHECKED); break; } CheckDlgButton(hwndDlg, IDC_WARNBEFOREOPENING, db_get_b(NULL, "SRFile", "WarnBeforeOpening", 1) ? BST_CHECKED : BST_UNCHECKED); for (int i = 0; i < _countof(virusScanners); i++) { TCHAR szScanExe[MAX_PATH]; if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, _countof(szScanExe))) { int iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)virusScanners[i].szProductName); SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, i); } } if (SendDlgItemMessageA(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0) == 0) { int iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)_T("")); SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, (LPARAM)-1); } DBVARIANT dbv; if (db_get_ts(NULL, "SRFile", "ScanCmdLine", &dbv) == 0) { SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, dbv.ptszVal); db_free(&dbv); } else if (SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0)) { SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETCURSEL, 0, 0); PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0); } switch (db_get_b(NULL, "SRFile", "IfExists", FILERESUME_ASK)) { case FILERESUME_RESUMEALL: CheckDlgButton(hwndDlg, IDC_RESUME, BST_CHECKED); break; case FILERESUME_OVERWRITEALL: CheckDlgButton(hwndDlg, IDC_OVERWRITE, BST_CHECKED); break; case FILERESUME_RENAMEALL: CheckDlgButton(hwndDlg, IDC_RENAME, BST_CHECKED); break; default: CheckDlgButton(hwndDlg, IDC_ASK, BST_CHECKED); break; } SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0); } return TRUE; case M_UPDATEENABLING: { int on = BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_NOSCANNER); EnableWindow(GetDlgItem(hwndDlg, IDC_ST_CMDLINE), on); EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINE), on); EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINEBROWSE), on); EnableWindow(GetDlgItem(hwndDlg, IDC_ST_CMDLINEHELP), on); EnableWindow(GetDlgItem(hwndDlg, IDC_AUTOMIN), IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT)); } break; case M_SCANCMDLINESELCHANGE: { TCHAR str[512]; TCHAR szScanExe[MAX_PATH]; int iScanner = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCURSEL, 0, 0), 0); if (iScanner >= _countof(virusScanners) || iScanner < 0) break; str[0] = '\0'; if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, _countof(szScanExe))) mir_sntprintf(str, virusScanners[iScanner].szCommandLine, szScanExe); SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_FILEDIR: if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; break; case IDC_FILEDIRBROWSE: { TCHAR str[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(str)); if (BrowseForFolder(hwndDlg, str)) SetDlgItemText(hwndDlg, IDC_FILEDIR, str); } break; case IDC_AUTOACCEPT: case IDC_NOSCANNER: case IDC_SCANAFTERDL: case IDC_SCANDURINGDL: SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0); break; case IDC_SCANCMDLINE: if (HIWORD(wParam) == CBN_SELCHANGE) PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0); else if (HIWORD(wParam) != CBN_EDITCHANGE) return 0; break; case IDC_SCANCMDLINEBROWSE: TCHAR str[MAX_PATH + 2]; GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str)); CMString tszFilter; tszFilter.AppendFormat(_T("%s (*.exe)%c*.exe%c"), TranslateT("Executable files"), 0, 0); tszFilter.AppendFormat(_T("%s (*)%c*%c"), TranslateT("All files"), 0, 0); OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT; ofn.lpstrFilter = tszFilter; ofn.lpstrFile = str; ofn.nMaxFile = _countof(str) - 2; if (str[0] == '"') { TCHAR *pszQuote = _tcschr(str + 1, '"'); if (pszQuote) *pszQuote = 0; memmove(str, str + 1, (mir_tstrlen(str) * sizeof(TCHAR))); } else { TCHAR *pszSpace = _tcschr(str, ' '); if (pszSpace) *pszSpace = 0; } ofn.nMaxFileTitle = MAX_PATH; if (!GetOpenFileName(&ofn)) break; if (_tcschr(str, ' ') != NULL) { memmove(str + 1, str, ((_countof(str) - 2) * sizeof(TCHAR))); str[0] = '"'; mir_tstrcat(str, _T("\"")); } SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str); break; } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: TCHAR str[512]; GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(str)); RemoveInvalidPathChars(str); db_set_ts(NULL, "SRFile", "RecvFilesDirAdv", str); db_set_b(NULL, "SRFile", "AutoAccept", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT)); db_set_b(NULL, "SRFile", "AutoMin", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOMIN)); db_set_b(NULL, "SRFile", "AutoClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLOSE)); db_set_b(NULL, "SRFile", "AutoClear", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLEAR)); db_set_b(NULL, "SRFile", "UseScanner", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCANAFTERDL) ? VIRUSSCAN_AFTERDL : (IsDlgButtonChecked(hwndDlg, IDC_SCANDURINGDL) ? VIRUSSCAN_DURINGDL : VIRUSSCAN_DISABLE))); GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str)); db_set_ts(NULL, "SRFile", "ScanCmdLine", str); db_set_b(NULL, "SRFile", "WarnBeforeOpening", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WARNBEFOREOPENING)); db_set_b(NULL, "SRFile", "IfExists", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ASK) ? FILERESUME_ASK : (IsDlgButtonChecked(hwndDlg, IDC_RESUME) ? FILERESUME_RESUMEALL : (IsDlgButtonChecked(hwndDlg, IDC_OVERWRITE) ? FILERESUME_OVERWRITEALL : FILERESUME_RENAMEALL)))); return TRUE; } break; } 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) {} }
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; }
CVKNewsItem* CVkProto::GetVkParent(const JSONNode &jnParent, VKObjType vkParentType, LPCTSTR ptszReplyText, LPCTSTR ptszReplyLink) { debugLogA("CVkProto::GetVkParent"); CMString tszRes; if (!jnParent || !vkParentType) return NULL; CVKNewsItem * vkNotificationItem = new CVKNewsItem(); if (vkParentType == vkPhoto) { CMString tszPhoto = GetVkPhotoItem(jnParent, m_iBBCForNews); LONG iOwnerId = jnParent["owner_id"].as_int(); LONG iId = jnParent["id"].as_int(); vkNotificationItem->tszId.AppendFormat(_T("%d_%d"), iOwnerId, iId); vkNotificationItem->tszLink.AppendFormat(_T("https://vk.com/photo%s"), vkNotificationItem->tszId); vkNotificationItem->tszText.AppendFormat(_T("\n%s"), tszPhoto); if (ptszReplyText) vkNotificationItem->tszText.AppendFormat(_T("\n>> %s"), SetBBCString(ptszReplyText, m_iBBCForNews, vkbbcI)); vkNotificationItem->tszText.AppendFormat(_T("\n%s"), SetBBCString(TranslateT("Link"), m_iBBCForNews, vkbbcUrl, vkNotificationItem->tszLink)); } else if (vkParentType == vkVideo) { LONG iOwnerId = jnParent["owner_id"].as_int(); LONG iId = jnParent["id"].as_int(); CMString tszTitle(jnParent["title"].as_mstring()); vkNotificationItem->tszId.AppendFormat(_T("%d_%d"), iOwnerId, iId); vkNotificationItem->tszLink.AppendFormat(_T("https://vk.com/video%s"), vkNotificationItem->tszId); CMString tszText(jnParent["text"].as_mstring()); ClearFormatNick(tszText); if (!tszText.IsEmpty()) vkNotificationItem->tszText.AppendFormat(_T("\n%s: %s"), SetBBCString(TranslateT("Video description:"), m_iBBCForNews, vkbbcB), SetBBCString(tszText, m_iBBCForNews, vkbbcI)); if (ptszReplyText) vkNotificationItem->tszText.AppendFormat(_T("\n>> %s"), SetBBCString(ptszReplyText, m_iBBCForNews, vkbbcI)); vkNotificationItem->tszText.AppendFormat(_T("\n%s"), SetBBCString(tszTitle, m_iBBCForNews, vkbbcUrl, vkNotificationItem->tszLink)); } else if (vkParentType == vkPost) { LONG iToId = jnParent["to_id"].as_int(); LONG iId = jnParent["id"].as_int(); vkNotificationItem->tszId.AppendFormat(_T("%d_%d"), iToId, iId); vkNotificationItem->tszLink.AppendFormat(_T("https://vk.com/wall%s%s"), vkNotificationItem->tszId, ptszReplyLink ? ptszReplyLink : _T("")); CMString tszText(jnParent["text"].as_mstring()); ClearFormatNick(tszText); if (!tszText.IsEmpty()) vkNotificationItem->tszText.AppendFormat(_T("\n%s: %s"), SetBBCString(TranslateT("Post text:"), m_iBBCForNews, vkbbcB), SetBBCString(tszText, m_iBBCForNews, vkbbcI)); if (ptszReplyText) vkNotificationItem->tszText.AppendFormat(_T("\n>> %s"), SetBBCString(ptszReplyText, m_iBBCForNews, vkbbcI)); vkNotificationItem->tszText.AppendFormat(_T("\n%s"), SetBBCString(TranslateT("Link"), m_iBBCForNews, vkbbcUrl, vkNotificationItem->tszLink)); } else if (vkParentType == vkTopic) { LONG iOwnerId = jnParent["owner_id"].as_int(); LONG iId = jnParent["id"].as_int(); CMString tszTitle(jnParent["title"].as_mstring()); vkNotificationItem->tszId.AppendFormat(_T("%d_%d"), iOwnerId, iId); vkNotificationItem->tszLink.AppendFormat(_T("https://vk.com/topic%s%s"), vkNotificationItem->tszId, ptszReplyLink ? ptszReplyLink : _T("")); CMString tszText(jnParent["text"].as_mstring()); ClearFormatNick(tszText); if (!tszText.IsEmpty()) vkNotificationItem->tszText.AppendFormat(_T("\n%s: %s"), SetBBCString(TranslateT("Topic text:"), m_iBBCForNews, vkbbcB), SetBBCString(tszText, m_iBBCForNews, vkbbcI)); if (ptszReplyText) vkNotificationItem->tszText.AppendFormat(_T("\n>> %s"), SetBBCString(ptszReplyText, m_iBBCForNews, vkbbcI)); vkNotificationItem->tszText.AppendFormat(_T("\n%s"), SetBBCString(tszTitle, m_iBBCForNews, vkbbcUrl, vkNotificationItem->tszLink)); } else if (vkParentType == vkComment) { CMString tszText(jnParent["text"].as_mstring()); ClearFormatNick(tszText); const JSONNode &jnPhoto = jnParent["photo"]; if (!jnPhoto.isnull()) { delete vkNotificationItem; return GetVkParent(jnPhoto, vkPhoto, tszText); } const JSONNode &jnVideo = jnParent["video"]; if (!jnVideo.isnull()) { delete vkNotificationItem; return GetVkParent(jnVideo, vkVideo, tszText); } LONG iId = jnParent["id"].as_int(); const JSONNode &jnPost = jnParent["post"]; if (!jnPost.isnull()) { CMString tszRepl; tszRepl.AppendFormat(_T("?reply=%d"), iId); delete vkNotificationItem; return GetVkParent(jnPost, vkPost, tszText, tszRepl); } const JSONNode &jnTopic = jnParent["topic"]; if (!jnTopic.isnull()) { CMString tszRepl; tszRepl.AppendFormat(_T("?reply=%d"), iId); delete vkNotificationItem; return GetVkParent(jnTopic, vkTopic, tszText, tszRepl); } } return vkNotificationItem; }