From 4000b35d600ecd71733cb929c407e814309f3f49 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 6 Nov 2023 19:39:18 +0300 Subject: =?UTF-8?q?fixes=20#3854=20(PasteIt:=20=D1=81=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20"None"=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D0=BC=D1=8B=D0=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/PasteIt/src/Options.cpp | 6 ++--- plugins/PasteIt/src/PasteIt.cpp | 4 ++-- plugins/PasteIt/src/PasteToWeb.cpp | 46 ++++++++++++++++++------------------- plugins/PasteIt/src/PasteToWeb1.cpp | 2 +- plugins/PasteIt/src/PasteToWeb2.cpp | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) (limited to 'plugins/PasteIt') diff --git a/plugins/PasteIt/src/Options.cpp b/plugins/PasteIt/src/Options.cpp index d44e6ca6ca..5b93158781 100644 --- a/plugins/PasteIt/src/Options.cpp +++ b/plugins/PasteIt/src/Options.cpp @@ -534,7 +534,7 @@ INT_PTR CALLBACK Options::DlgProcOptsConfigure(HWND hwndDlg, UINT msg, WPARAM wP SelectLbConfigure(hwndDlg, -1, optsConfigureData); optsConfigureData->tempFormats = pasteToWebs[optsConfigureData->page]->GetDefFormats(); for (std::list::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) { - ListBox_AddString(lb, it->name.c_str()); + ListBox_AddString(lb, TranslateW(it->name.c_str())); } } } @@ -823,8 +823,8 @@ void Options::Load() } } -WebOptions::WebOptions(int serv) - : server(serv), +WebOptions::WebOptions(int serv) : + server(serv), formats(pasteToWebs[serv]->GetDefFormats()), sendFileName(true), isSendFileName(true), diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp index 7091b635b1..3c2fdf7df8 100644 --- a/plugins/PasteIt/src/PasteIt.cpp +++ b/plugins/PasteIt/src/PasteIt.cpp @@ -90,7 +90,7 @@ std::wstring GetFile() static void PasteIt(MCONTACT hContact, int mode) { - PasteToWeb* pasteToWeb = pasteToWebs[Options::instance->defWeb]; + PasteToWeb *pasteToWeb = pasteToWebs[Options::instance->defWeb]; if (mode == FROM_CLIPBOARD) { pasteToWeb->FromClipboard(); } @@ -118,7 +118,7 @@ static void PasteIt(MCONTACT hContact, int mode) dbei.szModule = szProto; dbei.timestamp = (uint32_t)time(0); dbei.cbBlob = (uint32_t)mir_strlen(pasteToWeb->szFileLink) + 1; - dbei.pBlob = (uint8_t*)pasteToWeb->szFileLink; + dbei.pBlob = (uint8_t *)pasteToWeb->szFileLink; db_event_add(hContact, &dbei); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)pasteToWeb->szFileLink); } diff --git a/plugins/PasteIt/src/PasteToWeb.cpp b/plugins/PasteIt/src/PasteToWeb.cpp index a819d2ef66..a350ca3bbb 100644 --- a/plugins/PasteIt/src/PasteToWeb.cpp +++ b/plugins/PasteIt/src/PasteToWeb.cpp @@ -35,9 +35,9 @@ struct FromClipboardData struct FromFileData { - char* content; + char *content; int contentLen; - wchar_t* contentW; + wchar_t *contentW; UINT codepage; std::wstring *fileName; int page; @@ -51,7 +51,7 @@ INT_PTR CALLBACK DlgProcFromClipboard(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { - FromClipboardData* data = (FromClipboardData*)lParam; + FromClipboardData *data = (FromClipboardData *)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); int ts = 4; Edit_SetTabStops(GetDlgItem(hwndDlg, IDC_CLIPBOARD_DATA), 1, &ts); @@ -66,7 +66,7 @@ INT_PTR CALLBACK DlgProcFromClipboard(HWND hwndDlg, UINT msg, WPARAM wParam, LPA sel = i; ++i; } - + if (!Options::instance->webOptions[data->page]->formats.empty()) ComboBox_SetCurSel(cb, sel); } @@ -75,7 +75,7 @@ INT_PTR CALLBACK DlgProcFromClipboard(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) { if (LOWORD(wParam) == IDOK) { - FromClipboardData *clipboardData = (FromClipboardData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + FromClipboardData *clipboardData = (FromClipboardData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); int sel = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_FORMAT)); for (std::list::iterator it = Options::instance->webOptions[clipboardData->page]->formats.begin(); it != Options::instance->webOptions[clipboardData->page]->formats.end(); ++it) { if (sel-- <= 0) { @@ -100,7 +100,7 @@ INT_PTR CALLBACK DlgProcFromClipboard(HWND hwndDlg, UINT msg, WPARAM wParam, LPA void RecodeDlg(HWND hwndDlg) { ShowWindow(GetDlgItem(hwndDlg, IDC_RECODE), SW_HIDE); - FromFileData *fromFileData = (FromFileData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + FromFileData *fromFileData = (FromFileData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); unsigned int cp = Options::GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), false, fromFileData->codepage); mir_free(fromFileData->contentW); int cbLen = 0; @@ -109,10 +109,10 @@ void RecodeDlg(HWND hwndDlg) else cbLen = MultiByteToWideChar(cp, 0, fromFileData->content, fromFileData->contentLen, nullptr, 0); - fromFileData->contentW = (wchar_t*)mir_alloc(sizeof(wchar_t)*(cbLen + 1)); + fromFileData->contentW = (wchar_t *)mir_alloc(sizeof(wchar_t) * (cbLen + 1)); if (fromFileData->contentW != nullptr) { if (cp == 1200) - memcpy_s(fromFileData->contentW, sizeof(wchar_t)*(cbLen + 1), fromFileData->content, sizeof(wchar_t)*cbLen); + memcpy_s(fromFileData->contentW, sizeof(wchar_t) * (cbLen + 1), fromFileData->content, sizeof(wchar_t) * cbLen); else if (cp == 1201) { for (int i = 0; i < cbLen; ++i) fromFileData->contentW[i] = ((unsigned char)fromFileData->content[i * 2] << 8) | (unsigned char)fromFileData->content[i * 2 + 1]; @@ -133,7 +133,7 @@ INT_PTR CALLBACK DlgProcFromFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { - FromFileData *fromFileData = (FromFileData*)lParam; + FromFileData *fromFileData = (FromFileData *)lParam; int ts = 4; Edit_SetTabStops(GetDlgItem(hwndDlg, IDC_FILE_DATA), 1, &ts); SetDlgItemText(hwndDlg, IDC_FILE_DATA, fromFileData->contentW); @@ -169,7 +169,7 @@ INT_PTR CALLBACK DlgProcFromFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) { if (LOWORD(wParam) == IDOK) { - FromFileData *fromFileData = (FromFileData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + FromFileData *fromFileData = (FromFileData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); int sel = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_FORMAT)); for (std::list::iterator it = Options::instance->webOptions[fromFileData->page]->formats.begin(); it != Options::instance->webOptions[fromFileData->page]->formats.end(); ++it) { if (sel-- <= 0) { @@ -205,7 +205,7 @@ INT_PTR CALLBACK DlgProcFromFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l ShowWindow(GetDlgItem(hwndDlg, IDC_RECODE), SW_SHOW); } else if (HIWORD(wParam) == CBN_KILLFOCUS) { - FromFileData *fromFileData = (FromFileData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + FromFileData *fromFileData = (FromFileData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); Options::GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), true, fromFileData->codepage); } } @@ -259,7 +259,7 @@ void PasteToWeb::FromClipboard() isFile = 1; if (df->fWide) { // Unicode - wchar_t* file = (wchar_t*)((uint8_t*)obj + df->pFiles); + wchar_t *file = (wchar_t *)((uint8_t *)obj + df->pFiles); size_t len = mir_wstrlen(file); if (*(file + len + 1) == L'\0') { str.append(file, file + len); @@ -270,7 +270,7 @@ void PasteToWeb::FromClipboard() } else { // ANSI - char* file = (char*)obj + df->pFiles; + char *file = (char *)obj + df->pFiles; size_t len = mir_strlen(file); if (*(file + len + 1) == '\0') { LPWSTR wStr = mir_a2u_cp(file, CP_ACP); @@ -327,7 +327,7 @@ void PasteToWeb::FromFile(std::wstring file) } DWORD readed; fromFileData.contentLen = fileSize.LowPart; - fromFileData.content = (char*)mir_alloc(fromFileData.contentLen); + fromFileData.content = (char *)mir_alloc(fromFileData.contentLen); if (!ReadFile(hFile, fromFileData.content, fromFileData.contentLen, &readed, nullptr)) { mir_free(fromFileData.content); fromFileData.content = nullptr; @@ -375,10 +375,10 @@ void PasteToWeb::FromFile(std::wstring file) } if (cbLen > 0) { - fromFileData.contentW = (wchar_t*)mir_alloc(sizeof(wchar_t)*(cbLen + 1)); + fromFileData.contentW = (wchar_t *)mir_alloc(sizeof(wchar_t) * (cbLen + 1)); if (fromFileData.contentW != nullptr) { if (fromFileData.codepage == 1200) { - memcpy_s(fromFileData.contentW, sizeof(wchar_t)*(cbLen + 1), fromFileData.content, sizeof(wchar_t)*cbLen); + memcpy_s(fromFileData.contentW, sizeof(wchar_t) * (cbLen + 1), fromFileData.content, sizeof(wchar_t) * cbLen); } else if (fromFileData.codepage == 1201) { for (int i = 0; i < cbLen; ++i) { @@ -416,10 +416,10 @@ void PasteToWeb::FromFile(std::wstring file) extern HNETLIBUSER g_hNetlibUser; -char* PasteToWeb::SendToWeb(char* url, std::map& headers, std::wstring content) +char *PasteToWeb::SendToWeb(char *url, std::map &headers, std::wstring content) { int cbLen = WideCharToMultiByte(CP_UTF8, 0, content.c_str(), -1, nullptr, 0, nullptr, nullptr); - char* contentBytes = (char*)mir_alloc(cbLen); + char *contentBytes = (char *)mir_alloc(cbLen); if (contentBytes == nullptr) return nullptr; @@ -432,7 +432,7 @@ char* PasteToWeb::SendToWeb(char* url, std::map& heade } NETLIBHTTPREQUEST nlhr = { 0 }; - NETLIBHTTPHEADER* httpHeaders = new NETLIBHTTPHEADER[nHeaders]; + NETLIBHTTPHEADER *httpHeaders = new NETLIBHTTPHEADER[nHeaders]; nlhr.cbSize = sizeof(nlhr); nlhr.requestType = REQUEST_POST; nlhr.flags = NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT | NLHPIF_HTTP11; @@ -441,10 +441,10 @@ char* PasteToWeb::SendToWeb(char* url, std::map& heade nlhr.pData = contentBytes; nlhr.dataLength = cbLen; nHeaders = 0; - std::list mallBuf; + std::list mallBuf; for (std::map::iterator it = headers.begin(); it != headers.end(); ++it) { - char* b1 = new char[it->first.length() + 1]; - char* b2 = new char[it->second.length() + 1]; + char *b1 = new char[it->first.length() + 1]; + char *b2 = new char[it->second.length() + 1]; mir_strncpy(b1, it->first.c_str(), it->first.length() + 1); mir_strncpy(b2, it->second.c_str(), it->second.length() + 1); httpHeaders[nHeaders].szName = b1; @@ -465,7 +465,7 @@ char* PasteToWeb::SendToWeb(char* url, std::map& heade } delete[] httpHeaders; - for (std::list::iterator it = mallBuf.begin(); it != mallBuf.end(); ++it) + for (std::list::iterator it = mallBuf.begin(); it != mallBuf.end(); ++it) delete *it; mir_free(contentBytes); diff --git a/plugins/PasteIt/src/PasteToWeb1.cpp b/plugins/PasteIt/src/PasteToWeb1.cpp index 706f6c2171..f59a38b8cf 100644 --- a/plugins/PasteIt/src/PasteToWeb1.cpp +++ b/plugins/PasteIt/src/PasteToWeb1.cpp @@ -224,7 +224,7 @@ PasteFormat PasteToWeb1::formats[] = PasteFormat PasteToWeb1::defFormats[] = { - { L"text", L"None" }, + { L"text", LPGENW("None") }, { L"xml", L"XML" }, { L"html4strict", L"HTML" }, { L"html5", L"HTML 5" }, diff --git a/plugins/PasteIt/src/PasteToWeb2.cpp b/plugins/PasteIt/src/PasteToWeb2.cpp index e77def7eb0..57d89ab0c6 100644 --- a/plugins/PasteIt/src/PasteToWeb2.cpp +++ b/plugins/PasteIt/src/PasteToWeb2.cpp @@ -20,7 +20,7 @@ along with this program. If not, see . PasteFormat PasteToWeb2::defFormats[] = { - { L"text", L"Text" }, + { L"text", LPGENW("Text") }, { L"xml", L"XML" }, { L"html", L"HTML" }, { L"js", L"JavaScript" }, -- cgit v1.2.3