diff options
author | George Hazan <george.hazan@gmail.com> | 2016-07-27 14:23:31 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-07-27 14:23:31 +0000 |
commit | 2f261839b60692e33d0e160344d0d636d49c90ba (patch) | |
tree | 187921722698b681d29df3f6e60fb18394a5e9d5 /plugins/New_GPG/src | |
parent | 2e931a0b2780587d85f3902468c935f5adba70c8 (diff) |
less TCHARs
git-svn-id: http://svn.miranda-ng.org/main/trunk@17138 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/New_GPG/src')
-rwxr-xr-x | plugins/New_GPG/src/gpg_wrapper.cpp | 2 | ||||
-rwxr-xr-x | plugins/New_GPG/src/main.cpp | 68 | ||||
-rwxr-xr-x | plugins/New_GPG/src/messages.cpp | 32 | ||||
-rwxr-xr-x | plugins/New_GPG/src/options.cpp | 84 | ||||
-rwxr-xr-x | plugins/New_GPG/src/utilities.cpp | 98 |
5 files changed, 142 insertions, 142 deletions
diff --git a/plugins/New_GPG/src/gpg_wrapper.cpp b/plugins/New_GPG/src/gpg_wrapper.cpp index ef52cbe196..5b2b319fa4 100755 --- a/plugins/New_GPG/src/gpg_wrapper.cpp +++ b/plugins/New_GPG/src/gpg_wrapper.cpp @@ -49,7 +49,7 @@ pxResult pxExecute(std::vector<std::wstring> &aargv, string *aoutput, LPDWORD ae env.push_back(L"LANG=C"); argv.push_back(bin_path); wchar_t *home_dir = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); - if(mir_tstrlen(home_dir)) //this check are required for first run gpg binary validation + if(mir_wstrlen(home_dir)) //this check are required for first run gpg binary validation { argv.push_back(L"--homedir"); argv.push_back(home_dir); diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp index d3e7d1679b..bc7c4764ac 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -280,7 +280,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, if (wcschr(name, '(')) { wstring str = name; wstring::size_type p = str.find(L"(") - 1; - mir_tstrcpy(name, str.substr(0, p).c_str()); + mir_wstrcpy(name, str.substr(0, p).c_str()); } } string out; @@ -333,7 +333,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, GetDlgItemText(hwndDlg, IDC_KEY_PASSWORD, passwd, _countof(passwd)); if (passwd[0]) { string dbsetting = "szKey_"; - char *keyid = mir_t2a(fp); + char *keyid = mir_u2a(fp); dbsetting += keyid; mir_free(keyid); dbsetting += "_Password"; @@ -452,7 +452,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, while ((p = tmp.find(" ", p)) != string::npos) tmp.erase(p, 1); - str = mir_a2t(tmp.c_str()); + str = mir_a2u(tmp.c_str()); } cmd.clear(); out.clear(); @@ -661,7 +661,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, char *szKey = (char*)GlobalLock(hMem); if (!szKey) { wchar_t msg[64]; - mir_sntprintf(msg, TranslateT("Failed to lock memory with error %d"), GetLastError()); + mir_snwprintf(msg, TranslateT("Failed to lock memory with error %d"), GetLastError()); MessageBox(0, msg, TranslateT("Error"), MB_OK); GlobalFree(hMem); } @@ -672,7 +672,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, if (!SetClipboardData(CF_OEMTEXT, hMem)) { GlobalFree(hMem); wchar_t msg[64]; - mir_sntprintf(msg, TranslateT("Failed write to clipboard with error %d"), GetLastError()); + mir_snwprintf(msg, TranslateT("Failed write to clipboard with error %d"), GetLastError()); MessageBox(0, msg, TranslateT("Error"), MB_OK); } CloseClipboard(); @@ -687,7 +687,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, //TODO: handle error break; } - char *path = mir_t2a(p); + char *path = mir_u2a(p); delete[] p; std::ofstream file; file.open(path, std::ios::trunc | std::ios::out); @@ -794,16 +794,16 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, PathToAbsolute("\\", mir_path); SetCurrentDirectoryA(mir_path); - ptrT tmp(mir_a2t(mir_path)); + ptrW tmp(mir_a2u(mir_path)); wstring gpg_path(tmp); gpg_path += L"\\GnuPG\\gpg.exe"; wstring gpg_lang_path(tmp); gpg_lang_path += L"\\GnuPG\\gnupg.nls\\en@quot.mo"; if (boost::filesystem::exists(gpg_path)) { gpg_exists = true; - mir_tstrcpy(path, L"GnuPG\\gpg.exe"); + mir_wstrcpy(path, L"GnuPG\\gpg.exe"); } - else mir_tstrcpy(path, gpg_path.c_str()); + else mir_wstrcpy(path, gpg_path.c_str()); if (boost::filesystem::exists(gpg_lang_path)) lang_exists = true; @@ -813,7 +813,7 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, DWORD len = MAX_PATH; bool bad_version = false; { - ptrT tmp; + ptrW tmp; if (!gpg_exists) { tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", (SHGetValue(HKEY_CURRENT_USER, L"Software\\GNU\\GnuPG", L"gpgProgram", 0, path, &len) == ERROR_SUCCESS) ? path : L""); if (tmp[0]) @@ -854,7 +854,7 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, } } { - ptrT tmp(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")); + ptrW tmp(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")); if (!tmp[0]) { mir_free(tmp); char *mir_path = (char*)mir_alloc(sizeof(char) * MAX_PATH); @@ -890,13 +890,13 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, wchar_t *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L"gpg.exe"); SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp); char mir_path[MAX_PATH]; - char *atmp = mir_t2a(tmp); + char *atmp = mir_u2a(tmp); mir_free(tmp); PathToAbsolute("\\", mir_path); char* p_path = NULL; if (StriStr(atmp, mir_path)) { p_path = atmp + mir_strlen(mir_path); - tmp = mir_a2t(p_path); + tmp = mir_a2u(p_path); SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp); } } @@ -907,13 +907,13 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, wchar_t *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); SetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp); char mir_path[MAX_PATH]; - char *atmp = mir_t2a(tmp); + char *atmp = mir_u2a(tmp); mir_free(tmp); PathToAbsolute("\\", mir_path); char* p_path = NULL; if (StriStr(atmp, mir_path)) { p_path = atmp + mir_strlen(mir_path); - tmp = mir_a2t(p_path); + tmp = mir_a2u(p_path); SetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp); } } @@ -967,8 +967,8 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, } db_set_ts(NULL, szGPGModuleName, "szGpgBinPath", tmp); GetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp, _countof(tmp)); - while (tmp[mir_tstrlen(tmp) - 1] == '\\') - tmp[mir_tstrlen(tmp) - 1] = '\0'; + while (tmp[mir_wstrlen(tmp) - 1] == '\\') + tmp[mir_wstrlen(tmp) - 1] = '\0'; if (!tmp[0]) { MessageBox(0, TranslateT("Please set keyring's home directory"), TranslateT("Warning"), MB_OK); break; @@ -1038,8 +1038,8 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, } db_set_ts(NULL, szGPGModuleName, "szGpgBinPath", tmp); GetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp, _countof(tmp)); - while (tmp[mir_tstrlen(tmp) - 1] == '\\') - tmp[mir_tstrlen(tmp) - 1] = '\0'; + while (tmp[mir_wstrlen(tmp) - 1] == '\\') + tmp[mir_wstrlen(tmp) - 1] = '\0'; if (!tmp[0]) { MessageBox(0, TranslateT("Please set keyring's home directory"), TranslateT("Warning"), MB_OK); break; @@ -1196,7 +1196,7 @@ static INT_PTR CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wPara SetDlgItemText(hwndDlg, ID_IMPORT, tmp[0] ? TranslateT("Replace") : TranslateT("Accept")); mir_free(tmp); tmp = new wchar_t[256]; - mir_sntprintf(tmp, 255 * sizeof(wchar_t), TranslateT("Received key from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); + mir_snwprintf(tmp, 255 * sizeof(wchar_t), TranslateT("Received key from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); SetDlgItemText(hwndDlg, IDC_KEY_FROM, tmp); delete[] tmp; } @@ -1269,7 +1269,7 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara { //data sanity checks wchar_t *tmp = (wchar_t*)mir_alloc(sizeof(wchar_t) * 5); GetDlgItemText(hwndDlg, IDC_KEY_TYPE, tmp, 5); - if (mir_tstrlen(tmp) < 3) { + if (mir_wstrlen(tmp) < 3) { mir_free(tmp); tmp = NULL; MessageBox(0, TranslateT("You must set encryption algorithm first"), TranslateT("Error"), MB_OK); break; @@ -1286,7 +1286,7 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara } tmp = (wchar_t*)mir_alloc(sizeof(wchar_t) * 12); GetDlgItemText(hwndDlg, IDC_KEY_EXPIRE_DATE, tmp, 11); - if (mir_tstrlen(tmp) != 10 && tmp[0] != '0') { + if (mir_wstrlen(tmp) != 10 && tmp[0] != '0') { MessageBox(0, TranslateT("Invalid date"), TranslateT("Error"), MB_OK); mir_free(tmp); break; @@ -1294,7 +1294,7 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara mir_free(tmp); tmp = (wchar_t*)mir_alloc(sizeof(wchar_t) * 128); GetDlgItemText(hwndDlg, IDC_KEY_REAL_NAME, tmp, 127); - if (mir_tstrlen(tmp) < 5) { + if (mir_wstrlen(tmp) < 5) { MessageBox(0, TranslateT("Name must contain at least 5 characters"), TranslateT("Error"), MB_OK); mir_free(tmp); break; @@ -1307,7 +1307,7 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara mir_free(tmp); tmp = (wchar_t*)mir_alloc(sizeof(wchar_t) * 128); GetDlgItemText(hwndDlg, IDC_KEY_EMAIL, tmp, 128); - if ((mir_tstrlen(tmp)) < 5 || (!wcschr(tmp, '@')) || (!wcschr(tmp, '.'))) { + if ((mir_wstrlen(tmp)) < 5 || (!wcschr(tmp, '@')) || (!wcschr(tmp, '.'))) { MessageBox(0, TranslateT("Invalid Email"), TranslateT("Error"), MB_OK); mir_free(tmp); break; @@ -1316,7 +1316,7 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara } { //generating key file wchar_t *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); - char *tmp2;// = mir_t2a(tmp); + char *tmp2;// = mir_u2a(tmp); path = tmp; mir_free(tmp); // mir_free(tmp2); @@ -1329,7 +1329,7 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara f << "Key-Type: "; tmp = (wchar_t*)mir_alloc(sizeof(wchar_t) * 5); GetDlgItemText(hwndDlg, IDC_KEY_TYPE, tmp, 5); - tmp2 = mir_t2a(tmp); + tmp2 = mir_u2a(tmp); mir_free(tmp); char *subkeytype = (char*)mir_alloc(6); if (strstr(tmp2, "RSA")) @@ -1714,7 +1714,7 @@ static INT_PTR CALLBACK DlgProcLoadExistingKey(HWND hwndDlg, UINT msg, WPARAM wP if (p2 != std::string::npos) { p2 += mir_strlen("-----END PGP PUBLIC KEY BLOCK-----"); out = out.substr(p1, p2 - p1); - wchar_t *tmp = mir_a2t(out.c_str()); + wchar_t *tmp = mir_a2u(out.c_str()); SetWindowText(hPubKeyEdit, tmp); mir_free(tmp); } @@ -1910,10 +1910,10 @@ void InitCheck() if (!home_dir_access || !temp_access || !gpg_valid) { wchar_t buf[4096]; wcsncpy(buf, gpg_valid ? TranslateT("GPG binary is set and valid (this is good).\n") : TranslateT("GPG binary unset or invalid (plugin will not work).\n"), _countof(buf)); - mir_tstrncat(buf, home_dir_access ? TranslateT("Home dir write access granted (this is good).\n") : TranslateT("Home dir has no write access (plugin most probably will not work).\n"), _countof(buf) - mir_tstrlen(buf)); - mir_tstrncat(buf, temp_access ? TranslateT("Temp dir write access granted (this is good).\n") : TranslateT("Temp dir has no write access (plugin should work, but may have some problems, file transfers will not work)."), _countof(buf) - mir_tstrlen(buf)); + mir_wstrncat(buf, home_dir_access ? TranslateT("Home dir write access granted (this is good).\n") : TranslateT("Home dir has no write access (plugin most probably will not work).\n"), _countof(buf) - mir_wstrlen(buf)); + mir_wstrncat(buf, temp_access ? TranslateT("Temp dir write access granted (this is good).\n") : TranslateT("Temp dir has no write access (plugin should work, but may have some problems, file transfers will not work)."), _countof(buf) - mir_wstrlen(buf)); if (!gpg_valid) - mir_tstrncat(buf, TranslateT("\nGPG will be disabled until you solve these problems"), _countof(buf) - mir_tstrlen(buf)); + mir_wstrncat(buf, TranslateT("\nGPG will be disabled until you solve these problems"), _countof(buf) - mir_wstrlen(buf)); MessageBox(0, buf, TranslateT("GPG plugin problems"), MB_OK); } if (!gpg_valid) @@ -2137,12 +2137,12 @@ void ImportKey() std::vector<wstring> cmd; wchar_t tmp2[MAX_PATH] = { 0 }; { - wcsncpy(tmp2, ptrT(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")), MAX_PATH - 1); - mir_tstrncat(tmp2, L"\\", _countof(tmp2) - mir_tstrlen(tmp2)); - mir_tstrncat(tmp2, L"temporary_exported.asc", _countof(tmp2) - mir_tstrlen(tmp2)); + wcsncpy(tmp2, ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")), MAX_PATH - 1); + mir_wstrncat(tmp2, L"\\", _countof(tmp2) - mir_wstrlen(tmp2)); + mir_wstrncat(tmp2, L"temporary_exported.asc", _countof(tmp2) - mir_wstrlen(tmp2)); boost::filesystem::remove(tmp2); - ptrT ptmp; + ptrW ptmp; if (db_mc_isMeta(hContact)) ptmp = UniGetContactSettingUtf(metaGetMostOnline(hContact), szGPGModuleName, "GPGPubKey", L""); else diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index 7ea7e6f1eb..89e77e782c 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -68,9 +68,9 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR else if (bDebugLog) debuglog << std::string(time_str() + ": info: received encrypted message from: " + toUTF8(pcli->pfnGetContactDisplayName(hContact, 0))); boost::algorithm::erase_all(str, "\r"); - s2 += mir_tstrlen(L"-----END PGP MESSAGE-----"); + s2 += mir_wstrlen(L"-----END PGP MESSAGE-----"); - ptrT ptszHomePath(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")); + ptrW ptszHomePath(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")); wstring encfile = toUTF16(get_random(10)); wstring decfile = toUTF16(get_random(10)); { @@ -100,7 +100,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR } f.open(path.c_str(), std::ios::out); } - char *tmp = mir_t2a(str.substr(s1, s2 - s1).c_str()); + char *tmp = mir_u2a(str.substr(s1, s2 - s1).c_str()); f << tmp; mir_free(tmp); f.close(); @@ -418,7 +418,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) { if (bDebugLog) debuglog << std::string(time_str() + ": info(autoexchange): found pubkey block:" + toUTF8(pcli->pfnGetContactDisplayName(ccs->hContact, 0))); - s2 += mir_tstrlen(L"-----END PGP PUBLIC KEY BLOCK-----"); + s2 += mir_wstrlen(L"-----END PGP PUBLIC KEY BLOCK-----"); db_set_ts(ccs->hContact, szGPGModuleName, "GPGPubKey", str.substr(s1, s2 - s1).c_str()); { //gpg execute block std::vector<wstring> cmd; @@ -426,15 +426,15 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) string output; DWORD exitcode; { - ptrT ptmp(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")); - mir_tstrcpy(tmp2, ptmp); + ptrW ptmp(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")); + mir_wstrcpy(tmp2, ptmp); mir_free(ptmp); - mir_tstrcat(tmp2, L"\\"); - wchar_t *tmp3 = mir_a2t(get_random(5).c_str()); - mir_tstrcat(tmp2, tmp3); - mir_tstrcat(tmp2, L".asc"); + mir_wstrcat(tmp2, L"\\"); + wchar_t *tmp3 = mir_a2u(get_random(5).c_str()); + mir_wstrcat(tmp2, tmp3); + mir_wstrcat(tmp2, L".asc"); mir_free(tmp3); - //mir_tstrcat(tmp2, L"temporary_exported.asc"); + //mir_wstrcat(tmp2, L"temporary_exported.asc"); if(!bDebugLog) { boost::system::error_code e; @@ -565,9 +565,9 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) str.erase(s1, 1); void ShowNewKeyDialog(); if (((s2 = str.find(L"-----END PGP PUBLIC KEY BLOCK-----")) != wstring::npos) && ((s1 = str.find(L"-----BEGIN PGP PUBLIC KEY BLOCK-----")) != wstring::npos)) - s2 += mir_tstrlen(L"-----END PGP PUBLIC KEY BLOCK-----"); + s2 += mir_wstrlen(L"-----END PGP PUBLIC KEY BLOCK-----"); else if (((s2 = str.find(L"-----BEGIN PGP PRIVATE KEY BLOCK-----")) != wstring::npos) && ((s1 = str.find(L"-----END PGP PRIVATE KEY BLOCK-----")) != wstring::npos)) - s2 += mir_tstrlen(L"-----END PGP PRIVATE KEY BLOCK-----"); + s2 += mir_wstrlen(L"-----END PGP PRIVATE KEY BLOCK-----"); new_key.append(str.substr(s1, s2 - s1)); //new_key_hcnt_mutex.lock(); new_key_hcnt = ccs->hContact; @@ -688,7 +688,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) cmd.push_back(L"--batch"); cmd.push_back(L"--yes"); cmd.push_back(L"-eatr"); - tmp2 = mir_a2t(tmp); + tmp2 = mir_a2u(tmp); mir_free(tmp); } cmd.push_back(tmp2); @@ -1040,8 +1040,8 @@ static INT_PTR CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam } if (password) mir_free(password); - password = (wchar_t*)mir_alloc(sizeof(wchar_t)*(mir_tstrlen(tmp) + 1)); - mir_tstrcpy(password, tmp); + password = (wchar_t*)mir_alloc(sizeof(wchar_t)*(mir_wstrlen(tmp) + 1)); + mir_wstrcpy(password, tmp); } mir_free(inkeyid); DestroyWindow(hwndDlg); diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index 68595f9ce9..5a7592f833 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -128,14 +128,14 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L iRow = ListView_InsertItem(hwndList, &item);
ListView_SetItemText(hwndList, iRow, 0, name);
- wchar_t *tmp = mir_a2t(GetContactProto(hContact));
+ wchar_t *tmp = mir_a2u(GetContactProto(hContact));
ListView_SetItemText(hwndList, iRow, 4, tmp);
mir_free(tmp);
char *tmp2 = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", "");
- tmp = mir_a2t(tmp2);
+ tmp = mir_a2u(tmp2);
mir_free(tmp2);
- ListView_SetItemText(hwndList, iRow, 1, (mir_tstrlen(tmp) > 1) ? tmp : L"not set");
+ ListView_SetItemText(hwndList, iRow, 1, (mir_wstrlen(tmp) > 1) ? tmp : L"not set");
mir_free(tmp);
tmp2 = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyMainName", "");
@@ -144,7 +144,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L else
tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyMainName", L"");
mir_free(tmp2);
- ListView_SetItemText(hwndList, iRow, 2, (mir_tstrlen(tmp) > 1) ? tmp : L"not set");
+ ListView_SetItemText(hwndList, iRow, 2, (mir_wstrlen(tmp) > 1) ? tmp : L"not set");
mir_free(tmp);
tmp2 = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyMainEmail", "");
@@ -153,7 +153,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L else
tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyMainEmail", L"");
mir_free(tmp2);
- ListView_SetItemText(hwndList, iRow, 3, (mir_tstrlen(tmp) > 1) ? tmp : L"not set");
+ ListView_SetItemText(hwndList, iRow, 3, (mir_wstrlen(tmp) > 1) ? tmp : L"not set");
mir_free(tmp);
if (db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0))
@@ -169,7 +169,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L }
}
wchar_t *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szLogFilePath", L"");
- SetDlgItemText(hwndDlg, IDC_LOG_FILE_EDIT, (mir_tstrlen(tmp) > 1) ? tmp : L"c:\\GPGdebug.log");
+ SetDlgItemText(hwndDlg, IDC_LOG_FILE_EDIT, (mir_wstrlen(tmp) > 1) ? tmp : L"c:\\GPGdebug.log");
mir_free(tmp);
CheckStateLoadDB(hwndDlg, IDC_DEBUG_LOG, "bDebugLog", 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_JABBER_API), bIsMiranda09);
@@ -230,7 +230,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L cmd.push_back(L"--batch");
cmd.push_back(L"--yes");
cmd.push_back(L"--delete-key");
- ptmp = mir_a2t(tmp);
+ ptmp = mir_a2u(tmp);
cmd.push_back(ptmp);
mir_free(ptmp);
gpg_execution_params params(cmd);
@@ -306,7 +306,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L {
wchar_t *tmp = GetFilePath(TranslateT("Export public key"), L"*", TranslateT(".asc pubkey file"), true);
if (tmp) {
- wstring str(ptrT(UniGetContactSettingUtf(user_data[item_num + 1], szGPGModuleName, "GPGPubKey", L"")));
+ wstring str(ptrW(UniGetContactSettingUtf(user_data[item_num + 1], szGPGModuleName, "GPGPubKey", L"")));
wstring::size_type s = 0;
while ((s = str.find(L"\r", s)) != wstring::npos)
str.erase(s, 1);
@@ -333,7 +333,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L szKey = (char*)GlobalLock(hMem);
if (!szKey) {
wchar_t msg[64];
- mir_sntprintf(msg, TranslateT("Failed to lock memory with error %d"), GetLastError());
+ mir_snwprintf(msg, TranslateT("Failed to lock memory with error %d"), GetLastError());
MessageBox(0, msg, TranslateT("Error"), MB_OK);
GlobalFree(hMem);
}
@@ -346,7 +346,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L if (!SetClipboardData(CF_OEMTEXT, hMem)) {
GlobalFree(hMem);
wchar_t msg[64];
- mir_sntprintf(msg, TranslateT("Failed write to clipboard with error %d"), GetLastError());
+ mir_snwprintf(msg, TranslateT("Failed write to clipboard with error %d"), GetLastError());
MessageBox(0, msg, TranslateT("Error"), MB_OK);
}
CloseClipboard();
@@ -354,13 +354,13 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L }
else {
wchar_t msg[64];
- mir_sntprintf(msg, TranslateT("Failed to open clipboard with error %d"), GetLastError());
+ mir_snwprintf(msg, TranslateT("Failed to open clipboard with error %d"), GetLastError());
MessageBox(0, msg, TranslateT("Error"), MB_OK);
}
break;
case IDC_LOG_FILE_SET:
- SetDlgItemText(hwndDlg, IDC_LOG_FILE_EDIT, ptrT(GetFilePath(TranslateT("Set log file"), L"*", TranslateT("LOG files"), 1)));
+ SetDlgItemText(hwndDlg, IDC_LOG_FILE_EDIT, ptrW(GetFilePath(TranslateT("Set log file"), L"*", TranslateT("LOG files"), 1)));
break;
}
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
@@ -415,8 +415,8 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- SetDlgItemText(hwndDlg, IDC_BIN_PATH, ptrT(UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L"gpg.exe")));
- SetDlgItemText(hwndDlg, IDC_HOME_DIR, ptrT(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"gpg")));
+ SetDlgItemText(hwndDlg, IDC_BIN_PATH, ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L"gpg.exe")));
+ SetDlgItemText(hwndDlg, IDC_HOME_DIR, ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"gpg")));
return TRUE;
case WM_COMMAND:
@@ -464,13 +464,13 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, }
}
char mir_path[MAX_PATH];
- char *atmp = mir_t2a(tmp);
+ char *atmp = mir_u2a(tmp);
mir_free(tmp);
PathToAbsolute("\\", mir_path);
char* p_path = NULL;
if (StriStr(atmp, mir_path)) {
p_path = atmp + mir_strlen(mir_path);
- tmp = mir_a2t(p_path);
+ tmp = mir_a2u(p_path);
SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp);
}
}
@@ -481,13 +481,13 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, wchar_t *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"");
SetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp);
char mir_path[MAX_PATH];
- char *atmp = mir_t2a(tmp);
+ char *atmp = mir_u2a(tmp);
mir_free(tmp);
PathToAbsolute("\\", mir_path);
char* p_path = NULL;
if (StriStr(atmp, mir_path)) {
p_path = atmp + mir_strlen(mir_path);
- tmp = mir_a2t(p_path);
+ tmp = mir_a2u(p_path);
SetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp);
}
mir_free(atmp);
@@ -507,8 +507,8 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, GetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp, _countof(tmp));
db_set_ts(NULL, szGPGModuleName, "szGpgBinPath", tmp);
GetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp, _countof(tmp));
- while (tmp[mir_tstrlen(tmp) - 1] == '\\')
- tmp[mir_tstrlen(tmp) - 1] = '\0';
+ while (tmp[mir_wstrlen(tmp) - 1] == '\\')
+ tmp[mir_wstrlen(tmp) - 1] = '\0';
db_set_ts(NULL, szGPGModuleName, "szHomePath", tmp);
return TRUE;
}
@@ -569,23 +569,23 @@ static INT_PTR CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, GetDlgItemText(hwndDlg, IDC_IN_OPEN_TAG, tmp, _countof(tmp));
db_set_ts(NULL, szGPGModuleName, "szInOpenTag", tmp);
mir_free(inopentag);
- inopentag = (wchar_t*)mir_alloc(sizeof(wchar_t)* (mir_tstrlen(tmp) + 1));
- mir_tstrcpy(inopentag, tmp);
+ inopentag = (wchar_t*)mir_alloc(sizeof(wchar_t)* (mir_wstrlen(tmp) + 1));
+ mir_wstrcpy(inopentag, tmp);
GetDlgItemText(hwndDlg, IDC_IN_CLOSE_TAG, tmp, _countof(tmp));
db_set_ts(NULL, szGPGModuleName, "szInCloseTag", tmp);
mir_free(inclosetag);
- inclosetag = (wchar_t*)mir_alloc(sizeof(wchar_t)* (mir_tstrlen(tmp) + 1));
- mir_tstrcpy(inclosetag, tmp);
+ inclosetag = (wchar_t*)mir_alloc(sizeof(wchar_t)* (mir_wstrlen(tmp) + 1));
+ mir_wstrcpy(inclosetag, tmp);
GetDlgItemText(hwndDlg, IDC_OUT_OPEN_TAG, tmp, _countof(tmp));
db_set_ts(NULL, szGPGModuleName, "szOutOpenTag", tmp);
mir_free(outopentag);
- outopentag = (wchar_t*)mir_alloc(sizeof(wchar_t)* (mir_tstrlen(tmp) + 1));
- mir_tstrcpy(outopentag, tmp);
+ outopentag = (wchar_t*)mir_alloc(sizeof(wchar_t)* (mir_wstrlen(tmp) + 1));
+ mir_wstrcpy(outopentag, tmp);
GetDlgItemText(hwndDlg, IDC_OUT_CLOSE_TAG, tmp, _countof(tmp));
db_set_ts(NULL, szGPGModuleName, "szOutCloseTag", tmp);
mir_free(outclosetag);
- outclosetag = (wchar_t*)mir_alloc(sizeof(wchar_t)*(mir_tstrlen(tmp) + 1));
- mir_tstrcpy(outclosetag, tmp);
+ outclosetag = (wchar_t*)mir_alloc(sizeof(wchar_t)*(mir_wstrlen(tmp) + 1));
+ mir_wstrcpy(outclosetag, tmp);
}
return TRUE;
}
@@ -713,7 +713,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa if ((out.find("-----BEGIN PGP PUBLIC KEY BLOCK-----") != string::npos) && (out.find("-----END PGP PUBLIC KEY BLOCK-----") != string::npos)) {
boost::algorithm::replace_all(out, "\n", "\r\n");
- wchar_t *tmp3 = mir_a2t(out.c_str());
+ wchar_t *tmp3 = mir_a2u(out.c_str());
str.clear();
str.append(tmp3);
mir_free(tmp3);
@@ -758,22 +758,22 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa }
ws1 = 0;
if (((ws2 = key_buf.find(L"-----END PGP PUBLIC KEY BLOCK-----")) != wstring::npos) && ((ws1 = key_buf.find(L"-----BEGIN PGP PUBLIC KEY BLOCK-----")) != wstring::npos)) {
- begin = (wchar_t*)mir_alloc(sizeof(wchar_t) * (mir_tstrlen(L"-----BEGIN PGP PUBLIC KEY BLOCK-----") + 1));
- mir_tstrcpy(begin, L"-----BEGIN PGP PUBLIC KEY BLOCK-----");
- end = (wchar_t*)mir_alloc(sizeof(wchar_t) * (mir_tstrlen(L"-----END PGP PUBLIC KEY BLOCK-----") + 1));
- mir_tstrcpy(end, L"-----END PGP PUBLIC KEY BLOCK-----");
+ begin = (wchar_t*)mir_alloc(sizeof(wchar_t) * (mir_wstrlen(L"-----BEGIN PGP PUBLIC KEY BLOCK-----") + 1));
+ mir_wstrcpy(begin, L"-----BEGIN PGP PUBLIC KEY BLOCK-----");
+ end = (wchar_t*)mir_alloc(sizeof(wchar_t) * (mir_wstrlen(L"-----END PGP PUBLIC KEY BLOCK-----") + 1));
+ mir_wstrcpy(end, L"-----END PGP PUBLIC KEY BLOCK-----");
}
else if (((ws2 = key_buf.find(L"-----END PGP PRIVATE KEY BLOCK-----")) != wstring::npos) && ((ws1 = key_buf.find(L"-----BEGIN PGP PRIVATE KEY BLOCK-----")) != wstring::npos)) {
- begin = (wchar_t*)mir_alloc(sizeof(wchar_t) * (mir_tstrlen(L"-----BEGIN PGP PRIVATE KEY BLOCK-----") + 1));
- mir_tstrcpy(begin, L"-----BEGIN PGP PRIVATE KEY BLOCK-----");
- end = (wchar_t*)mir_alloc(sizeof(wchar_t) * (mir_tstrlen(L"-----END PGP PRIVATE KEY BLOCK-----") + 1));
- mir_tstrcpy(end, L"-----END PGP PRIVATE KEY BLOCK-----");
+ begin = (wchar_t*)mir_alloc(sizeof(wchar_t) * (mir_wstrlen(L"-----BEGIN PGP PRIVATE KEY BLOCK-----") + 1));
+ mir_wstrcpy(begin, L"-----BEGIN PGP PRIVATE KEY BLOCK-----");
+ end = (wchar_t*)mir_alloc(sizeof(wchar_t) * (mir_wstrlen(L"-----END PGP PRIVATE KEY BLOCK-----") + 1));
+ mir_wstrcpy(end, L"-----END PGP PRIVATE KEY BLOCK-----");
}
else {
MessageBox(0, TranslateT("This is not public or private key"), L"INFO", MB_OK);
break;
}
- ws2 += mir_tstrlen(end);
+ ws2 += mir_wstrlen(end);
bool allsubcontacts = false;
{
if (db_mc_isMeta(hContact)) {
@@ -791,7 +791,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa else db_set_ts(hContact, szGPGModuleName, "GPGPubKey", key_buf.substr(ws1, ws2 - ws1).c_str());
}
tmp = (wchar_t*)mir_alloc(sizeof(wchar_t) * (key_buf.length() + 1));
- mir_tstrcpy(tmp, key_buf.substr(ws1, ws2 - ws1).c_str());
+ mir_wstrcpy(tmp, key_buf.substr(ws1, ws2 - ws1).c_str());
{ //gpg execute block
std::vector<wstring> cmd;
wchar_t tmp2[MAX_PATH] = { 0 };
@@ -803,8 +803,8 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa ptmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"");
wcsncpy(tmp2, ptmp, MAX_PATH - 1);
mir_free(ptmp);
- mir_tstrncat(tmp2, L"\\", _countof(tmp2) - mir_tstrlen(tmp2));
- mir_tstrncat(tmp2, L"temporary_exported.asc", _countof(tmp2) - mir_tstrlen(tmp2));
+ mir_wstrncat(tmp2, L"\\", _countof(tmp2) - mir_wstrlen(tmp2));
+ mir_wstrncat(tmp2, L"temporary_exported.asc", _countof(tmp2) - mir_wstrlen(tmp2));
boost::filesystem::remove(tmp2);
wfstream f(tmp2, std::ios::out);
ptmp = UniGetContactSettingUtf(hcnt, szGPGModuleName, "GPGPubKey", L"");
@@ -1105,7 +1105,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa MessageBox(0, TranslateT("There is no public or private key."), TranslateT("Info"), MB_OK);
break;
}
- ws2 += mir_tstrlen(L"-----END PGP PUBLIC KEY BLOCK-----");
+ ws2 += mir_wstrlen(L"-----END PGP PUBLIC KEY BLOCK-----");
SetDlgItemText(hwndDlg, IDC_PUBLIC_KEY_EDIT, key_buf.substr(ws1, ws2 - ws1).c_str());
key_buf.clear();
}
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index 1a169bbcb3..a0359340a9 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -29,11 +29,11 @@ wchar_t* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModu DBVARIANT dbv = { DBVT_DELETED }; wchar_t* szRes = NULL; if (db_get_ts(hContact, szModule, szSetting, &dbv)) - return mir_tstrdup(szDef); + return mir_wstrdup(szDef); else if (dbv.pszVal) - szRes = mir_tstrdup(dbv.ptszVal); + szRes = mir_wstrdup(dbv.ptszVal); else - szRes = mir_tstrdup(szDef); + szRes = mir_wstrdup(szDef); db_free(&dbv); return szRes; @@ -62,15 +62,15 @@ void GetFilePath(wchar_t *WindowTittle, char *szSetting, wchar_t *szExt, wchar_t ofn.Flags = OFN_EXPLORER; ofn.lpstrTitle = TranslateW(WindowTittle); wcsncpy(filter, TranslateW(szExtDesc), _countof(filter) - 1); - pfilter = filter + mir_tstrlen(filter) + 1; - mir_tstrcpy(pfilter, szExt); - pfilter[mir_tstrlen(pfilter) + 1] = '\0'; - pfilter[mir_tstrlen(pfilter) + 2] = '\0'; + pfilter = filter + mir_wstrlen(filter) + 1; + mir_wstrcpy(pfilter, szExt); + pfilter[mir_wstrlen(pfilter) + 1] = '\0'; + pfilter[mir_wstrlen(pfilter) + 2] = '\0'; ofn.lpstrFilter = filter; tmp = UniGetContactSettingUtf(0, szGPGModuleName, szSetting, L""); wcsncpy(str, tmp, _countof(str) - 1); mir_free(tmp); - if (mir_tstrlen(str) < 2) + if (mir_wstrlen(str) < 2) str[0] = '\0'; ofn.lpstrFile = str; ofn.nMaxFile = _MAX_PATH; @@ -88,14 +88,14 @@ wchar_t *GetFilePath(wchar_t *WindowTittle, wchar_t *szExt, wchar_t *szExtDesc, ofn.lStructSize = CDSIZEOF_STRUCT(OPENFILENAME, lpTemplateName); ofn.Flags = OFN_EXPLORER; ofn.lpstrTitle = TranslateW(WindowTittle); - mir_tstrcpy(filter, TranslateW(szExtDesc)); - pfilter = filter + mir_tstrlen(filter) + 1; - mir_tstrcpy(pfilter, szExt); - pfilter[mir_tstrlen(pfilter) + 1] = '\0'; - pfilter[mir_tstrlen(pfilter) + 2] = '\0'; + mir_wstrcpy(filter, TranslateW(szExtDesc)); + pfilter = filter + mir_wstrlen(filter) + 1; + mir_wstrcpy(pfilter, szExt); + pfilter[mir_wstrlen(pfilter) + 1] = '\0'; + pfilter[mir_wstrlen(pfilter) + 2] = '\0'; ofn.lpstrFilter = filter; - mir_tstrcpy(str, L""); - if (mir_tstrlen(str) < 2) + mir_wstrcpy(str, L""); + if (mir_wstrlen(str) < 2) str[0] = '\0'; ofn.lpstrFile = str; ofn.nMaxFile = _MAX_PATH; @@ -238,7 +238,7 @@ int OnPreBuildContactMenu(WPARAM w, LPARAM) keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); } wchar_t buf[128] = { 0 }; - mir_sntprintf(buf, L"%s: %s", TranslateT("Send public key"), toUTF16(keyid).c_str()); + mir_snwprintf(buf, L"%s: %s", TranslateT("Send public key"), toUTF16(keyid).c_str()); mir_free(keyid); Menu_ModifyItem(hSendKey, buf); } @@ -285,7 +285,7 @@ int onProtoAck(WPARAM, LPARAM l) } else { if (f->szCurrentFile && f->szCurrentFile[0]) - filename = mir_utf8decodeT(f->szCurrentFile); + filename = mir_utf8decodeW(f->szCurrentFile); if (!filename) return 0; } @@ -309,7 +309,7 @@ int onProtoAck(WPARAM, LPARAM l) cmd.push_back(L"-o"); wstring file = filename; wstring::size_type p1 = file.rfind(L".gpg"); - file.erase(p1, mir_tstrlen(L".gpg")); + file.erase(p1, mir_wstrlen(L".gpg")); if (boost::filesystem::exists(file)) { if (MessageBox(0, TranslateT("Target file exists, do you want to replace it?"), TranslateT("Warning"), MB_YESNO) == IDNO) return 0; @@ -325,15 +325,15 @@ int onProtoAck(WPARAM, LPARAM l) dbsetting += keyid; dbsetting += "_Password"; pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), L""); - if (mir_tstrlen(pass) > 0 && bDebugLog) + if (mir_wstrlen(pass) > 0 && bDebugLog) debuglog << std::string(time_str() + ": info: found password in database for key ID: " + keyid + ", trying to decrypt message from " + toUTF8(pcli->pfnGetContactDisplayName(ack->hContact, 0)) + " with password"); } else { pass = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", L""); - if (mir_tstrlen(pass) > 0 && bDebugLog) + if (mir_wstrlen(pass) > 0 && bDebugLog) debuglog << std::string(time_str() + ": info: found password for all keys in database, trying to decrypt message from " + toUTF8(pcli->pfnGetContactDisplayName(ack->hContact, 0)) + " with password"); } - if (mir_tstrlen(pass) > 0) { + if (mir_wstrlen(pass) > 0) { cmd.push_back(L"--passphrase"); cmd.push_back(pass); } @@ -432,14 +432,14 @@ std::wstring encrypt_file(MCONTACT hContact, wchar_t *filename) cmd.push_back(L"--tes"); cmd.push_back(L"-r"); char *keyid = UniGetContactSettingUtf(hcnt, szGPGModuleName, "KeyID", ""); - wchar_t *szKeyid = mir_a2t(keyid); + wchar_t *szKeyid = mir_a2u(keyid); wchar_t *name = wcsrchr(filename, '\\'); if (!name) name = filename; else name++; - wchar_t *file_out = new wchar_t[mir_tstrlen(name) + mir_tstrlen(L".gpg") + 1]; - mir_sntprintf(file_out, mir_tstrlen(name) + mir_tstrlen(L".gpg") + 1, L"%s.gpg", name); + wchar_t *file_out = new wchar_t[mir_wstrlen(name) + mir_wstrlen(L".gpg") + 1]; + mir_snwprintf(file_out, mir_wstrlen(name) + mir_wstrlen(L".gpg") + 1, L"%s.gpg", name); cmd.push_back(szKeyid); if (db_get_b(hcnt, szGPGModuleName, "bAlwaysTrust", 0)) { cmd.push_back(L"--trust-model"); @@ -542,7 +542,7 @@ INT_PTR onSendFile(WPARAM w, LPARAM l) continue; std::wstring path_out = encrypt_file(ccs->hContact, file[i]); mir_free(file[i]); - file[i] = mir_tstrdup(path_out.c_str()); + file[i] = mir_wstrdup(path_out.c_str()); transfers.push_back(path_out); } } @@ -553,7 +553,7 @@ INT_PTR onSendFile(WPARAM w, LPARAM l) return 0; //we do not want to send file unencrypted (sometimes ack have wrong info) if (strstr(file[i], ".gpg")) continue; - wchar_t *tmp = mir_utf8decodeT(file[i]); + wchar_t *tmp = mir_utf8decodeW(file[i]); std::wstring path_out = encrypt_file(ccs->hContact, tmp); mir_free(tmp); char* tmp2 = mir_utf8encodeW(path_out.c_str()); @@ -618,11 +618,11 @@ int GetJabberInterface(WPARAM, LPARAM) //get interface for all jabber accounts, if (JIftmp) { (*p)->setJabberInterface(JIftmp); if (accounts[i]->tszAccountName) { - wchar_t* tmp = mir_tstrdup(accounts[i]->tszAccountName); + wchar_t* tmp = mir_wstrdup(accounts[i]->tszAccountName); (*p)->setAccountName(tmp); } else { - wchar_t *tmp = mir_a2t(accounts[i]->szModuleName); + wchar_t *tmp = mir_a2u(accounts[i]->szModuleName); (*p)->setAccountName(tmp); } (*p)->setAccountNumber(a); @@ -657,7 +657,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) if (wcsstr(str, L"-----BEGIN PGP MESSAGE-----") && wcsstr(str, L"-----END PGP MESSAGE-----")) { wstring data = str; xmlSetText(local_node, L"This message is encrypted."); - wstring::size_type p1 = data.find(L"-----BEGIN PGP MESSAGE-----") + mir_tstrlen(L"-----BEGIN PGP MESSAGE-----"); + wstring::size_type p1 = data.find(L"-----BEGIN PGP MESSAGE-----") + mir_wstrlen(L"-----BEGIN PGP MESSAGE-----"); while (data.find(L"Version: ", p1) != wstring::npos) { p1 = data.find(L"Version: ", p1); p1 = data.find(L"\n", p1); @@ -713,7 +713,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) inkeyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); } - ptrT pass; + ptrW pass; if (inkeyid[0]) { string dbsetting = "szKey_"; dbsetting += inkeyid; @@ -778,7 +778,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) break; } if (data.find(L"-----BEGIN PGP SIGNATURE-----") != wstring::npos && data.find(L"-----END PGP SIGNATURE-----") != wstring::npos) { - wstring::size_type p1 = data.find(L"-----BEGIN PGP SIGNATURE-----") + mir_tstrlen(L"-----BEGIN PGP SIGNATURE-----"); + wstring::size_type p1 = data.find(L"-----BEGIN PGP SIGNATURE-----") + mir_wstrlen(L"-----BEGIN PGP SIGNATURE-----"); if (data.find(L"Version: ", p1) != wstring::npos) { p1 = data.find(L"Version: ", p1); p1 = data.find(L"\n", p1); @@ -978,7 +978,7 @@ bool isContactSecured(MCONTACT hContact) bool isContactHaveKey(MCONTACT hContact) { wchar_t *key = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", L""); - if (mir_tstrlen(key) > 0) { + if (mir_wstrlen(key) > 0) { mir_free(key); return true; } @@ -1015,21 +1015,21 @@ bool isGPGValid() wchar_t *mir_path = (wchar_t*)mir_alloc(MAX_PATH * sizeof(wchar_t)); PathToAbsoluteW(L"\\", mir_path); SetCurrentDirectoryW(mir_path); - tmp = mir_tstrdup(mir_path); + tmp = mir_wstrdup(mir_path); mir_free(mir_path); - //mir_realloc(path, (mir_tstrlen(path)+64)*sizeof(wchar_t)); + //mir_realloc(path, (mir_wstrlen(path)+64)*sizeof(wchar_t)); wchar_t *gpg_path = (wchar_t*)mir_alloc(sizeof(wchar_t)*MAX_PATH); - mir_tstrcpy(gpg_path, tmp); - mir_tstrcat(gpg_path, L"\\GnuPG\\gpg.exe"); + mir_wstrcpy(gpg_path, tmp); + mir_wstrcat(gpg_path, L"\\GnuPG\\gpg.exe"); mir_free(tmp); tmp = NULL; p = boost::filesystem::path(gpg_path); if (boost::filesystem::exists(p) && boost::filesystem::is_regular_file(p)) { gpg_exists = true; - mir_tstrcpy(path, L"GnuPG\\gpg.exe"); + mir_wstrcpy(path, L"GnuPG\\gpg.exe"); } mir_free(gpg_path); - tmp = mir_tstrdup(path); + tmp = mir_wstrdup(path); mir_free(path); } @@ -1254,7 +1254,7 @@ void ExportGpGKeysFunc(int type) //TODO: handle error return; } - char *path = mir_t2a(p); + char *path = mir_u2a(p); delete[] p; std::ofstream file; file.open(path, std::ios::trunc | std::ios::out); @@ -1414,11 +1414,11 @@ void ExportGpGKeysFunc(int type) file.close(); wchar_t msg[512]; if (type == 2) - mir_sntprintf(msg, TranslateT("We have successfully exported %d public keys and all private keys."), exported_keys); + mir_snwprintf(msg, TranslateT("We have successfully exported %d public keys and all private keys."), exported_keys); else if (type == 1) - mir_sntprintf(msg, TranslateT("We have successfully exported all private keys.")); + mir_snwprintf(msg, TranslateT("We have successfully exported all private keys.")); else if (!type) - mir_sntprintf(msg, TranslateT("We have successfully exported %d public keys."), exported_keys); + mir_snwprintf(msg, TranslateT("We have successfully exported %d public keys."), exported_keys); MessageBox(NULL, msg, TranslateT("Keys export result"), MB_OK); } @@ -1438,7 +1438,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) } std::ifstream file; { - ptrA szPath(mir_t2a(p)); + ptrA szPath(mir_u2a(p)); delete[] p; file.open(szPath, std::ios::in); @@ -1724,8 +1724,8 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) ptmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); wcsncpy(tmp2, ptmp, MAX_PATH - 1); mir_free(ptmp); - mir_tstrncat(tmp2, L"\\", _countof(tmp2) - mir_tstrlen(tmp2)); - mir_tstrncat(tmp2, L"temporary_exported.asc", _countof(tmp2) - mir_tstrlen(tmp2)); + mir_wstrncat(tmp2, L"\\", _countof(tmp2) - mir_wstrlen(tmp2)); + mir_wstrncat(tmp2, L"temporary_exported.asc", _countof(tmp2) - mir_wstrlen(tmp2)); boost::filesystem::remove(tmp2); wfstream f(tmp2, std::ios::out); f << toUTF16(key).c_str(); @@ -1752,9 +1752,9 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) file.close(); wchar_t msg[512]; if (processed_private_keys) - mir_sntprintf(msg, TranslateT("We have successfully processed %d public keys and some private keys."), processed_keys); + mir_snwprintf(msg, TranslateT("We have successfully processed %d public keys and some private keys."), processed_keys); else - mir_sntprintf(msg, TranslateT("We have successfully processed %d public keys."), processed_keys); + mir_snwprintf(msg, TranslateT("We have successfully processed %d public keys."), processed_keys); MessageBox(NULL, msg, TranslateT("Keys import result"), MB_OK); return 0; } @@ -1910,7 +1910,7 @@ static INT_PTR CALLBACK DlgProcChangePasswd(HWND hwndDlg, UINT msg, WPARAM wPara old_pass = toUTF8(buf); bool old_pass_match = false; wchar_t *pass = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", L""); - if (!mir_tstrcmp(pass, buf)) + if (!mir_wstrcmp(pass, buf)) old_pass_match = true; mir_free(pass); @@ -1920,7 +1920,7 @@ static INT_PTR CALLBACK DlgProcChangePasswd(HWND hwndDlg, UINT msg, WPARAM wPara dbsetting += toUTF8(key_id_global); dbsetting += "_Password"; pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), L""); - if (!mir_tstrcmp(pass, buf)) + if (!mir_wstrcmp(pass, buf)) old_pass_match = true; mir_free(pass); } |