diff options
Diffstat (limited to 'plugins/New_GPG/src')
-rwxr-xr-x | plugins/New_GPG/src/gpg_wrapper.cpp | 8 | ||||
-rwxr-xr-x | plugins/New_GPG/src/init.cpp | 10 | ||||
-rwxr-xr-x | plugins/New_GPG/src/log.cpp | 2 | ||||
-rwxr-xr-x | plugins/New_GPG/src/main.cpp | 22 | ||||
-rwxr-xr-x | plugins/New_GPG/src/messages.cpp | 22 | ||||
-rwxr-xr-x | plugins/New_GPG/src/options.cpp | 52 | ||||
-rwxr-xr-x | plugins/New_GPG/src/ui.cpp | 28 | ||||
-rwxr-xr-x | plugins/New_GPG/src/utilities.cpp | 95 | ||||
-rwxr-xr-x | plugins/New_GPG/src/utilities.h | 2 |
9 files changed, 105 insertions, 136 deletions
diff --git a/plugins/New_GPG/src/gpg_wrapper.cpp b/plugins/New_GPG/src/gpg_wrapper.cpp index ca0a7a694f..53ad7e2c8e 100755 --- a/plugins/New_GPG/src/gpg_wrapper.cpp +++ b/plugins/New_GPG/src/gpg_wrapper.cpp @@ -21,7 +21,7 @@ pxResult pxExecute(std::vector<std::wstring> &aargv, string *aoutput, LPDWORD ae if (!globals.gpg_valid) return pxNotConfigured; - wchar_t *bin_path = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L""); + wchar_t *bin_path = db_get_wsa(0, MODULENAME, "szGpgBinPath", L""); { if (!boost::filesystem::exists(bin_path)) { mir_free(bin_path); @@ -42,7 +42,7 @@ pxResult pxExecute(std::vector<std::wstring> &aargv, string *aoutput, LPDWORD ae env.push_back(L"LC_ALL=English"); env.push_back(L"LANG=C"); argv.push_back(bin_path); - wchar_t *home_dir = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *home_dir = db_get_wsa(0, MODULENAME, "szHomePath", L""); if (mir_wstrlen(home_dir)) //this check are required for first run gpg binary validation { argv.push_back(L"--homedir"); @@ -156,7 +156,7 @@ pxResult pxExecute_passwd_change(std::vector<std::wstring> &aargv, pxResult *res if (!globals.gpg_valid) return pxNotConfigured; - wchar_t *bin_path = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L""); + wchar_t *bin_path = db_get_wsa(0, MODULENAME, "szGpgBinPath", L""); { if (!boost::filesystem::exists(bin_path)) { mir_free(bin_path); @@ -177,7 +177,7 @@ pxResult pxExecute_passwd_change(std::vector<std::wstring> &aargv, pxResult *res env.push_back(L"LC_ALL=English"); argv.push_back(bin_path); argv.push_back(L"--homedir"); - wchar_t *home_dir = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *home_dir = db_get_wsa(0, MODULENAME, "szHomePath", L""); argv.push_back(home_dir); mir_free(home_dir); argv.push_back(L"--display-charset"); diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index 8b074c96e7..5bf008296d 100755 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -72,14 +72,14 @@ void init_vars() { globals.bAppendTags = g_plugin.getByte("bAppendTags", 0) != 0; globals.bStripTags = g_plugin.getByte("bStripTags", 0) != 0; - globals.inopentag = UniGetContactSettingUtf(0, MODULENAME, "szInOpenTag", L"<GPGdec>"); - globals.inclosetag = UniGetContactSettingUtf(0, MODULENAME, "szInCloseTag", L"</GPGdec>"); - globals.outopentag = UniGetContactSettingUtf(0, MODULENAME, "szOutOpenTag", L"<GPGenc>"); - globals.outclosetag = UniGetContactSettingUtf(0, MODULENAME, "szOutCloseTag", L"</GPGenc>"); + globals.inopentag = db_get_wsa(0, MODULENAME, "szInOpenTag", L"<GPGdec>"); + globals.inclosetag = db_get_wsa(0, MODULENAME, "szInCloseTag", L"</GPGdec>"); + globals.outopentag = db_get_wsa(0, MODULENAME, "szOutOpenTag", L"<GPGenc>"); + globals.outclosetag = db_get_wsa(0, MODULENAME, "szOutCloseTag", L"</GPGenc>"); globals.bDebugLog = g_plugin.getByte("bDebugLog", 0) != 0; globals.bAutoExchange = g_plugin.getByte("bAutoExchange", 0) != 0; globals.bSameAction = g_plugin.getByte("bSameAction", 0) != 0; - globals.password = UniGetContactSettingUtf(0, MODULENAME, "szKeyPassword", L""); + globals.password = db_get_wsa(0, MODULENAME, "szKeyPassword", L""); globals.debuglog.init(); globals.bJabberAPI = g_plugin.getByte("bJabberAPI", true) != 0; globals.bPresenceSigning = g_plugin.getByte("bPresenceSigning", 0) != 0; diff --git a/plugins/New_GPG/src/log.cpp b/plugins/New_GPG/src/log.cpp index 93fe0f43d5..ab44baef71 100755 --- a/plugins/New_GPG/src/log.cpp +++ b/plugins/New_GPG/src/log.cpp @@ -75,7 +75,7 @@ void logtofile::init() if (globals.bDebugLog) { if (path) mir_free(path); - path = UniGetContactSettingUtf(0, MODULENAME, "szLogFilePath", L"C:\\GPGdebug.log"); + path = db_get_wsa(0, MODULENAME, "szLogFilePath", L"C:\\GPGdebug.log"); } _bDebugLog = globals.bDebugLog; } diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp index c9fd96bcdf..788254b725 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -30,13 +30,13 @@ void InitCheck() { { // parse gpg output - wchar_t *current_home = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *current_home = db_get_wsa(0, MODULENAME, "szHomePath", L""); g_plugin.setWString("szHomePath", L""); //we do not need home for gpg binary validation globals.gpg_valid = isGPGValid(); g_plugin.setWString("szHomePath", current_home); //return current home dir back mir_free(current_home); bool home_dir_access = false, temp_access = false; - wchar_t *home_dir = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *home_dir = db_get_wsa(0, MODULENAME, "szHomePath", L""); std::wstring test_path = home_dir; mir_free(home_dir); test_path += L"/"; @@ -91,7 +91,7 @@ void InitCheck() if (result == pxNotFound) return; } - home_dir = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + home_dir = db_get_wsa(0, MODULENAME, "szHomePath", L""); wstring tmp_dir = home_dir; mir_free(home_dir); tmp_dir += L"\\tmp"; @@ -109,11 +109,11 @@ void InitCheck() acc += pa->szModuleName; acc += ")"; acc += "_KeyID"; - keyid = UniGetContactSettingUtf(0, MODULENAME, acc.c_str(), ""); + keyid = db_get_sa(0, MODULENAME, acc.c_str(), ""); if (keyid[0]) { question = Translate("Your secret key with ID: "); mir_free(keyid); - keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + keyid = db_get_sa(0, MODULENAME, "KeyID", ""); if ((p = out.find(keyid)) == string::npos) { question += keyid; question += Translate(" for account "); @@ -173,8 +173,8 @@ void InitCheck() } } question = Translate("Your secret key with ID: "); - keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); - char *key = UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", ""); + keyid = db_get_sa(0, MODULENAME, "KeyID", ""); + char *key = db_get_sa(0, MODULENAME, "GPGPubKey", ""); if (!g_plugin.getByte("FirstRun", 1) && (!keyid[0] || !key[0])) { question = Translate("You didn't set a private key.\nWould you like to set it now?"); if (MessageBoxA(nullptr, question.c_str(), Translate("Own private key warning"), MB_YESNO) == IDYES) { @@ -235,7 +235,7 @@ void InitCheck() mir_free(key); } { - wchar_t *path = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *path = db_get_wsa(0, MODULENAME, "szHomePath", L""); DWORD dwFileAttr = GetFileAttributes(path); if (dwFileAttr != INVALID_FILE_ATTRIBUTES) { dwFileAttr &= ~FILE_ATTRIBUTE_READONLY; @@ -290,16 +290,16 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) std::vector<wstring> cmd; wchar_t tmp2[MAX_PATH] = { 0 }; { - wcsncpy(tmp2, ptrW(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"")), MAX_PATH - 1); + wcsncpy(tmp2, ptrW(db_get_wsa(0, MODULENAME, "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); ptrW ptmp; if (db_mc_isMeta(hContact)) - ptmp = UniGetContactSettingUtf(metaGetMostOnline(hContact), MODULENAME, "GPGPubKey", L""); + ptmp = db_get_wsa(metaGetMostOnline(hContact), MODULENAME, "GPGPubKey", L""); else - ptmp = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); + ptmp = db_get_wsa(hContact, MODULENAME, "GPGPubKey", L""); wfstream f(tmp2, std::ios::out); f << ptmp.get(); diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index 1189fca923..de025503ce 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -76,7 +76,7 @@ static void RecvMsgSvc_func(RecvParams *param) boost::algorithm::erase_all(param->str, "\r"); s2 += mir_wstrlen(L"-----END PGP MESSAGE-----"); - ptrW ptszHomePath(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"")); + ptrW ptszHomePath(db_get_wsa(0, MODULENAME, "szHomePath", L"")); wstring encfile = toUTF16(get_random(10)); wstring decfile = toUTF16(get_random(10)); { @@ -114,18 +114,18 @@ static void RecvMsgSvc_func(RecvParams *param) std::vector<wstring> cmd; cmd.push_back(L"--batch"); { - char *inkeyid = UniGetContactSettingUtf(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, MODULENAME, "InKeyID", ""); + char *inkeyid = db_get_sa(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, MODULENAME, "InKeyID", ""); wchar_t *pass = nullptr; if (inkeyid[0]) { string dbsetting = "szKey_"; dbsetting += inkeyid; dbsetting += "_Password"; - pass = UniGetContactSettingUtf(0, MODULENAME, dbsetting.c_str(), L""); + pass = db_get_wsa(0, MODULENAME, dbsetting.c_str(), L""); if (pass[0] && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password in database for key ID: " + inkeyid + ", trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with password"); } else { - pass = UniGetContactSettingUtf(0, MODULENAME, "szKeyPassword", L""); + pass = db_get_wsa(0, MODULENAME, "szKeyPassword", L""); if (pass[0] && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password for all keys in database, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with password"); } @@ -401,7 +401,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) string output; DWORD exitcode; { - ptrW ptmp(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"")); + ptrW ptmp(db_get_wsa(0, MODULENAME, "szHomePath", L"")); mir_wstrcpy(tmp2, ptmp); mir_free(ptmp); mir_wstrcat(tmp2, L"\\"); @@ -431,7 +431,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) f.open(tmp2, std::ios::out); } } - ptmp = UniGetContactSettingUtf(ccs->hContact, MODULENAME, "GPGPubKey", L""); + ptmp = db_get_wsa(ccs->hContact, MODULENAME, "GPGPubKey", L""); f << (wchar_t*)ptmp; f.close(); cmd.push_back(L"--batch"); @@ -541,7 +541,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) if (globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info(autoexchange): received key request from: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact))); - ptrA tmp(UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", "")); + ptrA tmp(db_get_sa(0, MODULENAME, "GPGPubKey", "")); if (tmp[0]) { int enc_state = db_get_b(ccs->hContact, MODULENAME, "GPGEncryption", 0); if (enc_state) @@ -569,7 +569,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) } } else { - wchar_t *jid = UniGetContactSettingUtf(ccs->hContact, proto, "jid", L""); + wchar_t *jid = db_get_wsa(ccs->hContact, proto, "jid", L""); if (jid[0]) { for (auto p : globals.Accounts) { wchar_t *caps = p->getJabberInterface()->GetResourceFeatures(jid); @@ -616,7 +616,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) { wchar_t *tmp2; { - char *tmp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyID", ""); + char *tmp = db_get_sa(hContact, MODULENAME, "KeyID", ""); if (!tmp[0]) { mir_free(tmp); HistoryLog(hContact, db_event("Failed to encrypt message with GPG (not found key for encryption in db)", 0, 0, DBEF_SENT)); @@ -643,7 +643,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) mir_free(tmp2); } { - wchar_t *tmp2 = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *tmp2 = db_get_wsa(0, MODULENAME, "szHomePath", L""); path = tmp2; cmd.push_back(std::wstring(tmp2) + L"\\tmp\\" + file); mir_free(tmp2); @@ -879,7 +879,7 @@ int HookSendMsg(WPARAM w, LPARAM l) } } else { - wchar_t *jid = UniGetContactSettingUtf(hContact, proto, "jid", L""); + wchar_t *jid = db_get_wsa(hContact, proto, "jid", L""); if (jid[0]) { if (globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info(autoexchange): protocol looks like jabber, name: " + toUTF8(Clist_GetContactDisplayName(hContact))); diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index b42c4f8d30..81db5b496b 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -70,26 +70,26 @@ public: list_USERLIST.SetItemText(row, 4, tmp); mir_free(tmp); - char *tmp2 = UniGetContactSettingUtf(hContact, MODULENAME, "KeyID", ""); + char *tmp2 = db_get_sa(hContact, MODULENAME, "KeyID", ""); tmp = mir_a2u(tmp2); mir_free(tmp2); list_USERLIST.SetItemText(row, 1, (mir_wstrlen(tmp) > 1) ? tmp : L"not set"); mir_free(tmp); - tmp2 = UniGetContactSettingUtf(hContact, MODULENAME, "KeyMainName", ""); + tmp2 = db_get_sa(hContact, MODULENAME, "KeyMainName", ""); if (!toUTF16(tmp2).empty()) tmp = mir_wstrdup(toUTF16(tmp2).c_str()); else - tmp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyMainName", L""); + tmp = db_get_wsa(hContact, MODULENAME, "KeyMainName", L""); mir_free(tmp2); list_USERLIST.SetItemText(row, 2, (mir_wstrlen(tmp) > 1) ? tmp : L"not set"); mir_free(tmp); - tmp2 = UniGetContactSettingUtf(hContact, MODULENAME, "KeyMainEmail", ""); + tmp2 = db_get_sa(hContact, MODULENAME, "KeyMainEmail", ""); if (!toUTF16(tmp2).empty()) tmp = mir_wstrdup(toUTF16(tmp2).c_str()); else - tmp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyMainEmail", L""); + tmp = db_get_wsa(hContact, MODULENAME, "KeyMainEmail", L""); mir_free(tmp2); list_USERLIST.SetItemText(row, 3, (mir_wstrlen(tmp) > 1) ? tmp : L"not set"); mir_free(tmp); @@ -106,7 +106,7 @@ public: i++; } } - edit_LOG_FILE_EDIT.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szLogFilePath", L""))); + edit_LOG_FILE_EDIT.SetText(ptrW(db_get_wsa(0, MODULENAME, "szLogFilePath", L""))); check_DEBUG_LOG.SetState(g_plugin.getByte("bDebugLog", 0)); check_JABBER_API.Enable(); @@ -115,7 +115,7 @@ public: { string keyinfo = Translate("Default private key ID"); keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + char *keyid = db_get_sa(0, MODULENAME, "KeyID", ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_CURRENT_KEY.SetTextA(keyinfo.c_str()); @@ -172,10 +172,10 @@ public: hContact = metaGetMostOnline(meta); ismetacontact = true; } - tmp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyID", ""); + tmp = db_get_sa(hContact, MODULENAME, "KeyID", ""); for (auto &hcnttmp : Contacts()) { if (hcnttmp != hContact) { - char *tmp2 = UniGetContactSettingUtf(hcnttmp, MODULENAME, "KeyID", ""); + char *tmp2 = db_get_sa(hcnttmp, MODULENAME, "KeyID", ""); if (!mir_strcmp(tmp, tmp2)) { mir_free(tmp2); keep = true; @@ -269,7 +269,7 @@ public: { wchar_t *tmp = GetFilePath(TranslateT("Export public key"), L"*", TranslateT(".asc pubkey file"), true); if (tmp) { - wstring str(ptrW(UniGetContactSettingUtf(user_data[item_num + 1], MODULENAME, "GPGPubKey", L""))); + wstring str(ptrW(db_get_wsa(user_data[item_num + 1], MODULENAME, "GPGPubKey", L""))); wstring::size_type s = 0; while ((s = str.find(L"\r", s)) != wstring::npos) str.erase(s, 1); @@ -284,7 +284,7 @@ public: void onClick_COPY_KEY(CCtrlButton*) { if (OpenClipboard(m_hwnd)) { - char *szKey = UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", ""); + char *szKey = db_get_sa(0, MODULENAME, "GPGPubKey", ""); std::string str = szKey; mir_free(szKey); boost::algorithm::replace_all(str, "\n", "\r\n"); @@ -386,8 +386,8 @@ public: bool OnInitDialog() override { - edit_BIN_PATH.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); - edit_HOME_DIR.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"gpg"))); + edit_BIN_PATH.SetText(ptrW(db_get_wsa(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); + edit_HOME_DIR.SetText(ptrW(db_get_wsa(0, MODULENAME, "szHomePath", L"gpg"))); return true; } @@ -405,7 +405,7 @@ public: void onClick_SET_BIN_PATH(CCtrlButton*) { GetFilePath(TranslateT("Choose gpg.exe"), "szGpgBinPath", L"*.exe", TranslateT("EXE Executables")); - CMStringW tmp(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); + CMStringW tmp(ptrW(db_get_wsa(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); edit_BIN_PATH.SetText(tmp); bool gpg_exists = false; { @@ -413,7 +413,7 @@ public: gpg_exists = true; if (gpg_exists) { bool bad_version = false; - wchar_t *tmp_path = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L""); + wchar_t *tmp_path = db_get_wsa(0, MODULENAME, "szGpgBinPath", L""); g_plugin.setWString("szGpgBinPath", tmp); string out; DWORD code; @@ -455,7 +455,7 @@ public: void onClick_SET_HOME_DIR(CCtrlButton*) { GetFolderPath(TranslateT("Set home directory")); - CMStringW tmp(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""))); + CMStringW tmp(ptrW(db_get_wsa(0, MODULENAME, "szHomePath", L""))); edit_HOME_DIR.SetText(tmp); wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -481,10 +481,10 @@ public: { check_APPEND_TAGS.SetState(g_plugin.getByte("bAppendTags", 0)); check_STRIP_TAGS.SetState(g_plugin.getByte("bStripTags", 0)); - edit_IN_OPEN_TAG.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szInOpenTag", L"<GPGdec>"))); - edit_IN_CLOSE_TAG.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szInCloseTag", L"</GPGdec>"))); - edit_OUT_OPEN_TAG.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szOutOpenTag", L"<GPGenc>"))); - edit_OUT_CLOSE_TAG.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szOutCloseTag", L"</GPGenc>"))); + edit_IN_OPEN_TAG.SetText(ptrW(db_get_wsa(0, MODULENAME, "szInOpenTag", L"<GPGdec>"))); + edit_IN_CLOSE_TAG.SetText(ptrW(db_get_wsa(0, MODULENAME, "szInCloseTag", L"</GPGdec>"))); + edit_OUT_OPEN_TAG.SetText(ptrW(db_get_wsa(0, MODULENAME, "szOutOpenTag", L"<GPGenc>"))); + edit_OUT_CLOSE_TAG.SetText(ptrW(db_get_wsa(0, MODULENAME, "szOutCloseTag", L"</GPGenc>"))); return true; } @@ -611,7 +611,7 @@ public: chk_ENABLE_ENCRYPTION.SetState(1); } if (hcnt) { - wchar_t *tmp = UniGetContactSettingUtf(hcnt, MODULENAME, "GPGPubKey", L""); + wchar_t *tmp = db_get_wsa(hcnt, MODULENAME, "GPGPubKey", L""); wstring str = tmp; mir_free(tmp); tmp = nullptr; if (!str.empty()) { @@ -626,9 +626,9 @@ public: } } } - // char *tmp = UniGetContactSettingUtf(hcnt, MODULENAME, "KeyID_Prescense", ""); + // char *tmp = db_get_wsa(hcnt, MODULENAME, "KeyID_Prescense", ""); if (!globals.hcontact_data[hcnt].key_in_prescense.empty()) { - char *tmp2 = UniGetContactSettingUtf(hcnt, MODULENAME, "KeyID", ""); + char *tmp2 = db_get_sa(hcnt, MODULENAME, "KeyID", ""); if (!tmp2[0]) { string out; DWORD code; @@ -742,14 +742,14 @@ public: DWORD exitcode; { MCONTACT hcnt = db_mc_tryMeta(hContact); - ptmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + ptmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); wcsncpy(tmp2, ptmp, MAX_PATH - 1); mir_free(ptmp); 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, MODULENAME, "GPGPubKey", L""); + ptmp = db_get_wsa(hcnt, MODULENAME, "GPGPubKey", L""); wstring str = ptmp; mir_free(ptmp); wstring::size_type s = 0; @@ -947,7 +947,7 @@ public: } } if (!hContact) { - wchar_t *fp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyID", L""); + wchar_t *fp = db_get_wsa(hContact, MODULENAME, "KeyID", L""); { string out; DWORD code; diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp index e651779b50..e9bd0aab8d 100755 --- a/plugins/New_GPG/src/ui.cpp +++ b/plugins/New_GPG/src/ui.cpp @@ -114,7 +114,7 @@ void CDlgChangePasswdMsgBox::onClick_OK(CCtrlButton*) new_pass = toUTF8(edit_NEW_PASSWD1.GetText()); old_pass = toUTF8(edit_OLD_PASSWD.GetText()); bool old_pass_match = false; - wchar_t *pass = UniGetContactSettingUtf(0, MODULENAME, "szKeyPassword", L""); + wchar_t *pass = db_get_wsa(0, MODULENAME, "szKeyPassword", L""); if (!mir_wstrcmp(pass, edit_OLD_PASSWD.GetText())) old_pass_match = true; mir_free(pass); @@ -124,7 +124,7 @@ void CDlgChangePasswdMsgBox::onClick_OK(CCtrlButton*) string dbsetting = "szKey_"; dbsetting += toUTF8(globals.key_id_global); dbsetting += "_Password"; - pass = UniGetContactSettingUtf(0, MODULENAME, dbsetting.c_str(), L""); + pass = db_get_wsa(0, MODULENAME, dbsetting.c_str(), L""); if (!mir_wstrcmp(pass, edit_OLD_PASSWD.GetText())) old_pass_match = true; mir_free(pass); @@ -230,7 +230,7 @@ bool CDlgFirstRun::OnInitDialog() combo_ACCOUNT.SelectString(TranslateT("Default")); string keyinfo = Translate("key ID"); keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + char *keyid = db_get_sa(0, MODULENAME, "KeyID", ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_KEY_ID.SetTextA(keyinfo.c_str()); @@ -569,7 +569,7 @@ void CDlgFirstRun::onChange_ACCOUNT(CCtrlCombo*) if (!mir_strcmp(buf, Translate("Default"))) { string keyinfo = Translate("key ID"); keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + char *keyid = db_get_sa(0, MODULENAME, "KeyID", ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_KEY_ID.SetTextA(keyinfo.c_str()); @@ -579,7 +579,7 @@ void CDlgFirstRun::onChange_ACCOUNT(CCtrlCombo*) keyinfo += ": "; std::string acc_str = buf; acc_str += "_KeyID"; - char *keyid = UniGetContactSettingUtf(0, MODULENAME, acc_str.c_str(), ""); + char *keyid = db_get_sa(0, MODULENAME, acc_str.c_str(), ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_KEY_ID.SetTextA(keyinfo.c_str()); @@ -730,7 +730,7 @@ void CDlgFirstRun::refresh_key_list() setting += pa->szModuleName; setting += ")"; setting += "_KeyID"; - wchar_t *str = UniGetContactSettingUtf(0, MODULENAME, setting.c_str(), L""); + wchar_t *str = db_get_wsa(0, MODULENAME, setting.c_str(), L""); if (key_id == str) { if (!accs.empty()) accs += L","; @@ -798,7 +798,7 @@ bool CDlgGpgBinOpts::OnInitDialog() { ptrW tmp; if (!gpg_exists) { - tmp = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", (SHGetValueW(HKEY_CURRENT_USER, L"Software\\GNU\\GnuPG", L"gpgProgram", 0, (void*)path.c_str(), &len) == ERROR_SUCCESS) ? path.c_str() : L""); + tmp = db_get_wsa(0, MODULENAME, "szGpgBinPath", (SHGetValueW(HKEY_CURRENT_USER, L"Software\\GNU\\GnuPG", L"gpgProgram", 0, (void*)path.c_str(), &len) == ERROR_SUCCESS) ? path.c_str() : L""); if (tmp[0]) if (!boost::filesystem::exists((wchar_t*)tmp)) MessageBox(nullptr, TranslateT("Wrong GPG binary location found in system.\nPlease choose another location"), TranslateT("Warning"), MB_OK); @@ -837,7 +837,7 @@ bool CDlgGpgBinOpts::OnInitDialog() } } { - ptrW tmp(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"")); + ptrW tmp(db_get_wsa(0, MODULENAME, "szHomePath", L"")); if (!tmp[0]) { wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -864,7 +864,7 @@ bool CDlgGpgBinOpts::OnInitDialog() void CDlgGpgBinOpts::onClick_SET_BIN_PATH(CCtrlButton*) { GetFilePath(L"Choose gpg.exe", "szGpgBinPath", L"*.exe", L"EXE Executables"); - CMStringW tmp(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); + CMStringW tmp(ptrW(db_get_wsa(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); edit_BIN_PATH.SetText(tmp); wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -877,7 +877,7 @@ void CDlgGpgBinOpts::onClick_SET_BIN_PATH(CCtrlButton*) void CDlgGpgBinOpts::onClick_SET_HOME_DIR(CCtrlButton*) { GetFolderPath(L"Set home directory"); - CMStringW tmp(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""))); + CMStringW tmp(ptrW(db_get_wsa(0, MODULENAME, "szHomePath", L""))); edit_HOME_DIR.SetText(tmp); wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -942,7 +942,7 @@ bool CDlgNewKey::OnInitDialog() { //new_key_hcnt_mutex.unlock(); SetWindowPos(m_hwnd, nullptr, globals.new_key_rect.left, globals.new_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); - wchar_t *tmp = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); + wchar_t *tmp = db_get_wsa(hContact, MODULENAME, "GPGPubKey", L""); lbl_MESSAGE.SetText(tmp[0] ? TranslateT("There is existing key for contact, would you like to replace it with new key?") : TranslateT("New public key was received, do you want to import it?")); btn_IMPORT_AND_USE.Enable(g_plugin.getByte(hContact, "GPGEncryption", 0)); btn_IMPORT.SetText(tmp[0] ? TranslateT("Replace") : TranslateT("Accept")); @@ -1081,7 +1081,7 @@ void CDlgKeyGen::onClick_OK(CCtrlButton*) mir_free(tmp); } { //generating key file - wchar_t *tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *tmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); char *tmp2;// = mir_u2a(tmp); path = tmp; mir_free(tmp); @@ -1422,7 +1422,7 @@ CDlgKeyPasswordMsgBox::CDlgKeyPasswordMsgBox(MCONTACT _hContact) : bool CDlgKeyPasswordMsgBox::OnInitDialog() { - inkeyid = UniGetContactSettingUtf(hContact, MODULENAME, "InKeyID", ""); + inkeyid = db_get_sa(hContact, MODULENAME, "InKeyID", ""); SetWindowPos(m_hwnd, nullptr, globals.key_password_rect.left, globals.key_password_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); @@ -1447,7 +1447,7 @@ void CDlgKeyPasswordMsgBox::onClick_OK(CCtrlButton*) wchar_t *tmp = mir_wstrdup(edit_KEY_PASSWORD.GetText()); if (tmp && tmp[0]) { if (chk_SAVE_PASSWORD.GetState()) { - inkeyid = UniGetContactSettingUtf(hContact, MODULENAME, "InKeyID", ""); + inkeyid = db_get_sa(hContact, MODULENAME, "InKeyID", ""); if (inkeyid && inkeyid[0] && !chk_DEFAULT_PASSWORD.GetState()) { string dbsetting = "szKey_"; dbsetting += inkeyid; diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index 84096558b8..8d8d9c5b18 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -21,35 +21,6 @@ void ShowExportKeysDlg(); void ShowLoadPublicKeyDialog(bool = false); -wchar_t* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule, const char *szSetting, wchar_t *szDef) -{ - DBVARIANT dbv = { DBVT_DELETED }; - wchar_t* szRes = nullptr; - if (db_get_ws(hContact, szModule, szSetting, &dbv)) - return mir_wstrdup(szDef); - else if (dbv.pszVal) - szRes = mir_wstrdup(dbv.pwszVal); - else - szRes = mir_wstrdup(szDef); - - db_free(&dbv); - return szRes; -} - -char* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule, const char *szSetting, char *szDef) -{ - DBVARIANT dbv = { DBVT_DELETED }; - char* szRes = nullptr; - if (db_get_s(hContact, szModule, szSetting, &dbv)) - return mir_strdup(szDef); - else if (dbv.pszVal) - szRes = mir_strdup(dbv.pszVal); - else - szRes = mir_strdup(szDef); - db_free(&dbv); - return szRes; -} - void GetFilePath(wchar_t *WindowTittle, char *szSetting, wchar_t *szExt, wchar_t *szExtDesc) { wchar_t str[MAX_PATH + 2] = { 0 }, *tmp; @@ -64,7 +35,7 @@ void GetFilePath(wchar_t *WindowTittle, char *szSetting, wchar_t *szExt, wchar_t pfilter[mir_wstrlen(pfilter) + 1] = '\0'; pfilter[mir_wstrlen(pfilter) + 2] = '\0'; ofn.lpstrFilter = filter; - tmp = UniGetContactSettingUtf(0, MODULENAME, szSetting, L""); + tmp = db_get_wsa(0, MODULENAME, szSetting, L""); wcsncpy(str, tmp, _countof(str) - 1); mir_free(tmp); if (mir_wstrlen(str) < 2) @@ -156,10 +127,10 @@ INT_PTR SendKey(WPARAM w, LPARAM) key_id_str += "_KeyID"; acc_str += "_GPGPubKey"; } - szMessage = UniGetContactSettingUtf(0, MODULENAME, acc_str.empty() ? "GPGPubKey" : acc_str.c_str(), ""); + szMessage = db_get_sa(0, MODULENAME, acc_str.empty() ? "GPGPubKey" : acc_str.c_str(), ""); if (!szMessage[0]) { mir_free(szMessage); - szMessage = UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", ""); //try to get default key as fallback in any way + szMessage = db_get_sa(0, MODULENAME, "GPGPubKey", ""); //try to get default key as fallback in any way } } if (szMessage[0]) { @@ -167,10 +138,10 @@ INT_PTR SendKey(WPARAM w, LPARAM) g_plugin.setByte(hContact, "GPGEncryption", 0); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)szMessage); std::string msg = "Public key "; - char *keyid = UniGetContactSettingUtf(0, MODULENAME, key_id_str.c_str(), ""); + char *keyid = db_get_sa(0, MODULENAME, key_id_str.c_str(), ""); if (!keyid[0]) { mir_free(keyid); - keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + keyid = db_get_sa(0, MODULENAME, "KeyID", ""); } msg += keyid; mir_free(keyid); @@ -229,10 +200,10 @@ int OnPreBuildContactMenu(WPARAM w, LPARAM) setting += ")"; setting += "_KeyID"; } - char *keyid = UniGetContactSettingUtf(0, MODULENAME, setting.c_str(), ""); + char *keyid = db_get_sa(0, MODULENAME, setting.c_str(), ""); if (!keyid[0]) { mir_free(keyid); - keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + keyid = db_get_sa(0, MODULENAME, "KeyID", ""); } wchar_t buf[128] = { 0 }; mir_snwprintf(buf, L"%s: %s", TranslateT("Send public key"), toUTF16(keyid).c_str()); @@ -241,7 +212,7 @@ int OnPreBuildContactMenu(WPARAM w, LPARAM) } int flags; - wchar_t *tmp = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); + wchar_t *tmp = db_get_wsa(hContact, MODULENAME, "GPGPubKey", L""); if (!tmp[0]) { g_plugin.delSetting(hContact, "GPGEncryption"); flags = CMIF_GRAYED; @@ -314,17 +285,17 @@ int onProtoAck(WPARAM, LPARAM l) boost::filesystem::remove(file); { // password wchar_t *pass = nullptr; - char *keyid = UniGetContactSettingUtf(ack->hContact, MODULENAME, "KeyID", ""); + char *keyid = db_get_sa(ack->hContact, MODULENAME, "KeyID", ""); if (mir_strlen(keyid) > 0) { string dbsetting = "szKey_"; dbsetting += keyid; dbsetting += "_Password"; - pass = UniGetContactSettingUtf(0, MODULENAME, dbsetting.c_str(), L""); + pass = db_get_wsa(0, MODULENAME, dbsetting.c_str(), L""); if (mir_wstrlen(pass) > 0 && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password in database for key ID: " + keyid + ", trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with password"); } else { - pass = UniGetContactSettingUtf(0, MODULENAME, "szKeyPassword", L""); + pass = db_get_wsa(0, MODULENAME, "szKeyPassword", L""); if (mir_wstrlen(pass) > 0 && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password for all keys in database, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with password"); } @@ -424,7 +395,7 @@ std::wstring encrypt_file(MCONTACT hContact, wchar_t *filename) cmd.push_back(L"--batch"); cmd.push_back(L"--tes"); cmd.push_back(L"-r"); - char *keyid = UniGetContactSettingUtf(hcnt, MODULENAME, "KeyID", ""); + char *keyid = db_get_sa(hcnt, MODULENAME, "KeyID", ""); wchar_t *szKeyid = mir_a2u(keyid); wchar_t *name = wcsrchr(filename, '\\'); if (!name) @@ -494,7 +465,7 @@ INT_PTR onSendFile(WPARAM w, LPARAM l) } } else { - wchar_t *jid = UniGetContactSettingUtf(ccs->hContact, proto, "jid", L""); + wchar_t *jid = db_get_wsa(ccs->hContact, proto, "jid", L""); if (jid[0]) { for (auto p : globals.Accounts) { wchar_t *caps = p->getJabberInterface()->GetResourceFeatures(jid); @@ -669,7 +640,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) } if (globals.bPresenceSigning && nodename && wcsstr(nodename, L"status")) { - wchar_t *path_c = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *path_c = db_get_wsa(0, MODULENAME, "szHomePath", L""); wstring path_out = path_c; wstring file = toUTF16(get_random(10)); mir_free(path_c); @@ -693,10 +664,10 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) char setting[64]; mir_snprintf(setting, sizeof(setting) - 1, "%s_KeyID", ji->GetModuleName()); - inkeyid = UniGetContactSettingUtf(0, MODULENAME, setting, ""); + inkeyid = db_get_sa(0, MODULENAME, setting, ""); if (!inkeyid[0]) { mir_free(inkeyid); - inkeyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + inkeyid = db_get_sa(0, MODULENAME, "KeyID", ""); } ptrW pass; @@ -704,14 +675,14 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) string dbsetting = "szKey_"; dbsetting += inkeyid; dbsetting += "_Password"; - pass = UniGetContactSettingUtf(0, MODULENAME, dbsetting.c_str(), L""); + pass = db_get_wsa(0, MODULENAME, dbsetting.c_str(), L""); if (pass[0] && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password in database for key ID: " + inkeyid + ", trying to encrypt message from self with password"); } if (inkeyid && inkeyid[0]) mir_free(inkeyid); else { - pass = UniGetContactSettingUtf(0, MODULENAME, "szKeyPassword", L""); + pass = db_get_wsa(0, MODULENAME, "szKeyPassword", L""); if (pass[0] && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password for all keys in database, trying to encrypt message from self with password"); } @@ -730,7 +701,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) } cmd.push_back(L"--local-user"); - path_c = UniGetContactSettingUtf(0, MODULENAME, "KeyID", L""); + path_c = db_get_wsa(0, MODULENAME, "KeyID", L""); cmd.push_back(path_c); cmd.push_back(L"--default-key"); cmd.push_back(path_c); @@ -832,7 +803,7 @@ static JABBER_HANDLER_FUNC PresenceHandler(IJabberInterface*, HXML node, void*) wstring file = toUTF16(get_random(10)), status_file = toUTF16(get_random(10)); sign += data; sign += L"\n-----END PGP SIGNATURE-----\n"; - wchar_t *path_c = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *path_c = db_get_wsa(0, MODULENAME, "szHomePath", L""); wstring path_out = path_c, status_file_out = path_c; mir_free(path_c); path_out += L"\\tmp\\"; @@ -945,7 +916,7 @@ bool isContactSecured(MCONTACT hContact) return false; } if (!db_mc_isMeta(hContact)) { - wchar_t *key = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); + wchar_t *key = db_get_wsa(hContact, MODULENAME, "GPGPubKey", L""); if (!key[0]) { mir_free(key); if (globals.bDebugLog) @@ -961,7 +932,7 @@ bool isContactSecured(MCONTACT hContact) bool isContactHaveKey(MCONTACT hContact) { - wchar_t *key = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); + wchar_t *key = db_get_wsa(hContact, MODULENAME, "GPGPubKey", L""); if (mir_wstrlen(key) > 0) { mir_free(key); return true; @@ -972,8 +943,8 @@ bool isContactHaveKey(MCONTACT hContact) bool isGPGKeyExist() { - wchar_t *id = UniGetContactSettingUtf(0, MODULENAME, "KeyID", L""); - char *key = UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", ""); + wchar_t *id = db_get_wsa(0, MODULENAME, "KeyID", L""); + char *key = db_get_sa(0, MODULENAME, "GPGPubKey", ""); if (id[0] && key[0]) { mir_free(id); mir_free(key); @@ -987,7 +958,7 @@ bool isGPGValid() { wchar_t *tmp = nullptr; bool gpg_exists = false, is_valid = true; - tmp = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L""); + tmp = db_get_wsa(0, MODULENAME, "szGpgBinPath", L""); boost::filesystem::path p(tmp); if (boost::filesystem::exists(p) && boost::filesystem::is_regular_file(p)) @@ -1046,7 +1017,7 @@ bool isGPGValid() { wstring path_ = _wgetenv(L"APPDATA"); path_ += L"\\GnuPG"; - tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", (wchar_t*)path_.c_str()); + tmp = db_get_wsa(0, MODULENAME, "szHomePath", (wchar_t*)path_.c_str()); } if(tmp) mir_free(tmp); */ @@ -1181,7 +1152,7 @@ void send_encrypted_msgs_thread(void *param) { MCONTACT hContact = (MCONTACT)(DWORD_PTR)param; while (true) { - //char *key = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", ""); + //char *key = db_get_wsa(hContact, MODULENAME, "GPGPubKey", ""); while (!isContactSecured(hContact)) Sleep(1000); @@ -1246,7 +1217,7 @@ void ExportGpGKeysFunc(int type) return; //TODO: handle error if (!type || type == 2) { for (auto &hContact : Contacts()) { - char *k = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", ""); + char *k = db_get_sa(hContact, MODULENAME, "GPGPubKey", ""); std::string key; if (!k[0]) { mir_free(k); @@ -1595,7 +1566,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) string output; DWORD exitcode; { - ptmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + ptmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); path = ptmp; mir_free(ptmp); wstring rand = toUTF16(get_random(10)); @@ -1700,7 +1671,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) string output; DWORD exitcode; { - ptmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + ptmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); wcsncpy(tmp2, ptmp, MAX_PATH - 1); mir_free(ptmp); mir_wstrncat(tmp2, L"\\", _countof(tmp2) - mir_wstrlen(tmp2)); @@ -1813,7 +1784,7 @@ void clean_temp_dir() wstring path = toUTF16(mir_path); SetCurrentDirectoryA(mir_path); delete[] mir_path; - wchar_t *tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *tmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); path += tmp; mir_free(tmp); path += L"\\tmp"; @@ -1884,7 +1855,7 @@ bool gpg_validate_paths(wchar_t *gpg_bin_path, wchar_t *gpg_home_path) return false; } { - wchar_t *path = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *path = db_get_wsa(0, MODULENAME, "szHomePath", L""); DWORD dwFileAttr = GetFileAttributes(path); if (dwFileAttr != INVALID_FILE_ATTRIBUTES) { dwFileAttr &= ~FILE_ATTRIBUTE_READONLY; @@ -1913,7 +1884,7 @@ bool gpg_use_new_random_key(char *account_name, wchar_t *gpg_bin_path, wchar_t * if (gpg_home_dir) tmp = gpg_home_dir; else - tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + tmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); path = tmp; if (!gpg_home_dir) mir_free(tmp); diff --git a/plugins/New_GPG/src/utilities.h b/plugins/New_GPG/src/utilities.h index ffcf265b44..352468789c 100755 --- a/plugins/New_GPG/src/utilities.h +++ b/plugins/New_GPG/src/utilities.h @@ -17,8 +17,6 @@ #ifndef UTILITIES_H #define UTILITIES_H -wchar_t* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule,const char* szSetting, wchar_t* szDef); -char* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule,const char* szSetting, char* szDef); void GetFilePath(wchar_t *WindowTittle, char *szSetting, wchar_t *szExt, wchar_t *szExtDesc); wchar_t *GetFilePath(wchar_t *WindowTittle, wchar_t *szExt, wchar_t *szExtDesc, bool save_file = false); void GetFolderPath(wchar_t *WindowTittle); |