diff options
Diffstat (limited to 'plugins/New_GPG')
-rwxr-xr-x | plugins/New_GPG/src/gpg_wrapper.cpp | 8 | ||||
-rwxr-xr-x | plugins/New_GPG/src/init.cpp | 56 | ||||
-rwxr-xr-x | plugins/New_GPG/src/log.cpp | 2 | ||||
-rwxr-xr-x | plugins/New_GPG/src/main.cpp | 26 | ||||
-rwxr-xr-x | plugins/New_GPG/src/messages.cpp | 12 | ||||
-rwxr-xr-x | plugins/New_GPG/src/options.cpp | 80 | ||||
-rwxr-xr-x | plugins/New_GPG/src/ui.cpp | 104 | ||||
-rwxr-xr-x | plugins/New_GPG/src/utilities.cpp | 72 |
8 files changed, 180 insertions, 180 deletions
diff --git a/plugins/New_GPG/src/gpg_wrapper.cpp b/plugins/New_GPG/src/gpg_wrapper.cpp index f0dbbbf704..ca0a7a694f 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(NULL, MODULENAME, "szGpgBinPath", L""); + wchar_t *bin_path = UniGetContactSettingUtf(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(NULL, MODULENAME, "szHomePath", L""); + wchar_t *home_dir = UniGetContactSettingUtf(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(NULL, MODULENAME, "szGpgBinPath", L""); + wchar_t *bin_path = UniGetContactSettingUtf(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(NULL, MODULENAME, "szHomePath", L""); + wchar_t *home_dir = UniGetContactSettingUtf(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 194e7f6f94..8b074c96e7 100755 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -70,34 +70,34 @@ void InitIconLib(); void init_vars() { - globals.bAppendTags = db_get_b(NULL, MODULENAME, "bAppendTags", 0) != 0; - globals.bStripTags = db_get_b(NULL, MODULENAME, "bStripTags", 0) != 0; - globals.inopentag = UniGetContactSettingUtf(NULL, MODULENAME, "szInOpenTag", L"<GPGdec>"); - globals.inclosetag = UniGetContactSettingUtf(NULL, MODULENAME, "szInCloseTag", L"</GPGdec>"); - globals.outopentag = UniGetContactSettingUtf(NULL, MODULENAME, "szOutOpenTag", L"<GPGenc>"); - globals.outclosetag = UniGetContactSettingUtf(NULL, MODULENAME, "szOutCloseTag", L"</GPGenc>"); - globals.bDebugLog = db_get_b(NULL, MODULENAME, "bDebugLog", 0) != 0; - globals.bAutoExchange = db_get_b(NULL, MODULENAME, "bAutoExchange", 0) != 0; - globals.bSameAction = db_get_b(NULL, MODULENAME, "bSameAction", 0) != 0; - globals.password = UniGetContactSettingUtf(NULL, MODULENAME, "szKeyPassword", L""); + 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.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.debuglog.init(); - globals.bJabberAPI = db_get_b(NULL, MODULENAME, "bJabberAPI", true) != 0; - globals.bPresenceSigning = db_get_b(NULL, MODULENAME, "bPresenceSigning", 0) != 0; - globals.bFileTransfers = db_get_b(NULL, MODULENAME, "bFileTransfers", 0) != 0; - globals.firstrun_rect.left = db_get_dw(NULL, MODULENAME, "FirstrunWindowX", 0); - globals.firstrun_rect.top = db_get_dw(NULL, MODULENAME, "FirstrunWindowY", 0); - globals.key_password_rect.left = db_get_dw(NULL, MODULENAME, "PasswordWindowX", 0); - globals.key_password_rect.top = db_get_dw(NULL, MODULENAME, "PasswordWindowY", 0); - globals.key_gen_rect.left = db_get_dw(NULL, MODULENAME, "KeyGenWindowX", 0); - globals.key_gen_rect.top = db_get_dw(NULL, MODULENAME, "KeyGenWindowY", 0); - globals.load_key_rect.left = db_get_dw(NULL, MODULENAME, "LoadKeyWindowX", 0); - globals.load_key_rect.top = db_get_dw(NULL, MODULENAME, "LoadKeyWindowY", 0); - globals.import_key_rect.left = db_get_dw(NULL, MODULENAME, "ImportKeyWindowX", 0); - globals.import_key_rect.top = db_get_dw(NULL, MODULENAME, "ImportKeyWindowY", 0); - globals.new_key_rect.left = db_get_dw(NULL, MODULENAME, "NewKeyWindowX", 0); - globals.new_key_rect.top = db_get_dw(NULL, MODULENAME, "NewKeyWindowY", 0); - globals.load_existing_key_rect.left = db_get_dw(NULL, MODULENAME, "LoadExistingKeyWindowX", 0); - globals.load_existing_key_rect.top = db_get_dw(NULL, MODULENAME, "LoadExistingKeyWindowY", 0); + globals.bJabberAPI = g_plugin.getByte("bJabberAPI", true) != 0; + globals.bPresenceSigning = g_plugin.getByte("bPresenceSigning", 0) != 0; + globals.bFileTransfers = g_plugin.getByte("bFileTransfers", 0) != 0; + globals.firstrun_rect.left = g_plugin.getDword("FirstrunWindowX", 0); + globals.firstrun_rect.top = g_plugin.getDword("FirstrunWindowY", 0); + globals.key_password_rect.left = g_plugin.getDword("PasswordWindowX", 0); + globals.key_password_rect.top = g_plugin.getDword("PasswordWindowY", 0); + globals.key_gen_rect.left = g_plugin.getDword("KeyGenWindowX", 0); + globals.key_gen_rect.top = g_plugin.getDword("KeyGenWindowY", 0); + globals.load_key_rect.left = g_plugin.getDword("LoadKeyWindowX", 0); + globals.load_key_rect.top = g_plugin.getDword("LoadKeyWindowY", 0); + globals.import_key_rect.left = g_plugin.getDword("ImportKeyWindowX", 0); + globals.import_key_rect.top = g_plugin.getDword("ImportKeyWindowY", 0); + globals.new_key_rect.left = g_plugin.getDword("NewKeyWindowX", 0); + globals.new_key_rect.top = g_plugin.getDword("NewKeyWindowY", 0); + globals.load_existing_key_rect.left = g_plugin.getDword("LoadExistingKeyWindowX", 0); + globals.load_existing_key_rect.top = g_plugin.getDword("LoadExistingKeyWindowY", 0); globals.tabsrmm_used = isTabsrmmUsed(); globals.bold_font = CreateFont(14, 0, 0, 0, 600, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, L"Arial"); } @@ -105,7 +105,7 @@ void init_vars() static int OnModulesLoaded(WPARAM, LPARAM) { FirstRun(); - if (!db_get_b(NULL, MODULENAME, "FirstRun", 1)) + if (!g_plugin.getByte("FirstRun", 1)) InitCheck(); StatusIconData sid = {}; diff --git a/plugins/New_GPG/src/log.cpp b/plugins/New_GPG/src/log.cpp index c5f704ec57..93fe0f43d5 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(NULL, MODULENAME, "szLogFilePath", L"C:\\GPGdebug.log"); + path = UniGetContactSettingUtf(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 42d754f6d5..81e162fff5 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -20,7 +20,7 @@ void FirstRun() { - if (!db_get_b(NULL, MODULENAME, "FirstRun", 1)) + if (!g_plugin.getByte("FirstRun", 1)) return; CDlgGpgBinOpts *d = new CDlgGpgBinOpts; d->Show(); @@ -30,13 +30,13 @@ void InitCheck() { { // parse gpg output - wchar_t *current_home = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); - db_set_ws(NULL, MODULENAME, "szHomePath", L""); //we do not need home for gpg binary validation + wchar_t *current_home = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + g_plugin.setWString("szHomePath", L""); //we do not need home for gpg binary validation globals.gpg_valid = isGPGValid(); - db_set_ws(NULL, MODULENAME, "szHomePath", current_home); //return current home dir back + 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(NULL, MODULENAME, "szHomePath", L""); + wchar_t *home_dir = UniGetContactSettingUtf(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(NULL, MODULENAME, "szHomePath", L""); + home_dir = UniGetContactSettingUtf(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(NULL, MODULENAME, acc.c_str(), ""); + keyid = UniGetContactSettingUtf(0, MODULENAME, acc.c_str(), ""); if (keyid[0]) { question = Translate("Your secret key with ID: "); mir_free(keyid); - keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); + keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); if ((p = out.find(keyid)) == string::npos) { question += keyid; question += Translate(" for account "); @@ -173,9 +173,9 @@ void InitCheck() } } question = Translate("Your secret key with ID: "); - keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); - char *key = UniGetContactSettingUtf(NULL, MODULENAME, "GPGPubKey", ""); - if (!db_get_b(NULL, MODULENAME, "FirstRun", 1) && (!keyid[0] || !key[0])) { + keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + char *key = UniGetContactSettingUtf(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) { CDlgFirstRun *d = new CDlgFirstRun; @@ -235,7 +235,7 @@ void InitCheck() mir_free(key); } { - wchar_t *path = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); + wchar_t *path = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); DWORD dwFileAttr = GetFileAttributes(path); if (dwFileAttr != INVALID_FILE_ATTRIBUTES) { dwFileAttr &= ~FILE_ATTRIBUTE_READONLY; @@ -290,7 +290,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) std::vector<wstring> cmd; wchar_t tmp2[MAX_PATH] = { 0 }; { - wcsncpy(tmp2, ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L"")), MAX_PATH - 1); + wcsncpy(tmp2, ptrW(UniGetContactSettingUtf(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); diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index fc16bf8d73..526227ae1f 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(NULL, MODULENAME, "szHomePath", L"")); + ptrW ptszHomePath(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"")); wstring encfile = toUTF16(get_random(10)); wstring decfile = toUTF16(get_random(10)); { @@ -120,12 +120,12 @@ static void RecvMsgSvc_func(RecvParams *param) string dbsetting = "szKey_"; dbsetting += inkeyid; dbsetting += "_Password"; - pass = UniGetContactSettingUtf(NULL, MODULENAME, dbsetting.c_str(), L""); + pass = UniGetContactSettingUtf(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(NULL, MODULENAME, "szKeyPassword", L""); + pass = UniGetContactSettingUtf(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(NULL, MODULENAME, "szHomePath", L"")); + ptrW ptmp(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"")); mir_wstrcpy(tmp2, ptmp); mir_free(ptmp); mir_wstrcat(tmp2, L"\\"); @@ -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(NULL, MODULENAME, "GPGPubKey", "")); + ptrA tmp(UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", "")); if (tmp[0]) { int enc_state = db_get_b(ccs->hContact, MODULENAME, "GPGEncryption", 0); if (enc_state) @@ -643,7 +643,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) mir_free(tmp2); } { - wchar_t *tmp2 = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); + wchar_t *tmp2 = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); path = tmp2; cmd.push_back(std::wstring(tmp2) + L"\\tmp\\" + file); mir_free(tmp2); diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index dbf212737c..abf4af389d 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -106,23 +106,23 @@ public: i++; } } - edit_LOG_FILE_EDIT.SetText(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szLogFilePath", L""))); + edit_LOG_FILE_EDIT.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szLogFilePath", L""))); - check_DEBUG_LOG.SetState(db_get_b(NULL, MODULENAME, "bDebugLog", 0)); + check_DEBUG_LOG.SetState(g_plugin.getByte("bDebugLog", 0)); check_JABBER_API.Enable(); check_AUTO_EXCHANGE.Enable(globals.bJabberAPI); { string keyinfo = Translate("Default private key ID"); keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); + char *keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_CURRENT_KEY.SetTextA(keyinfo.c_str()); } - check_JABBER_API.SetState(db_get_b(NULL, MODULENAME, "bJabberAPI", 1)); - check_FILE_TRANSFERS.SetState(db_get_b(NULL, MODULENAME, "bFileTransfers", 0)); - check_AUTO_EXCHANGE.SetState(db_get_b(NULL, MODULENAME, "bAutoExchange", 0)); + check_JABBER_API.SetState(g_plugin.getByte("bJabberAPI", 1)); + check_FILE_TRANSFERS.SetState(g_plugin.getByte("bFileTransfers", 0)); + check_AUTO_EXCHANGE.SetState(g_plugin.getByte("bAutoExchange", 0)); //TODO: get rid of following s..t //////////////// @@ -136,19 +136,19 @@ public: bool OnApply() override { - db_set_b(NULL, MODULENAME, "bDebugLog", globals.bDebugLog = check_DEBUG_LOG.GetState()); + g_plugin.setByte("bDebugLog", globals.bDebugLog = check_DEBUG_LOG.GetState()); if (globals.bDebugLog) globals.debuglog.init(); - db_set_b(NULL, MODULENAME, "bJabberAPI", globals.bJabberAPI = check_JABBER_API.GetState()); - bool old_bFileTransfers = db_get_b(NULL, MODULENAME, "bFileTransfers", 0) != 0; - db_set_b(NULL, MODULENAME, "bFileTransfers", globals.bFileTransfers = check_FILE_TRANSFERS.GetState()); + g_plugin.setByte("bJabberAPI", globals.bJabberAPI = check_JABBER_API.GetState()); + bool old_bFileTransfers = g_plugin.getByte("bFileTransfers", 0) != 0; + g_plugin.setByte("bFileTransfers", globals.bFileTransfers = check_FILE_TRANSFERS.GetState()); if (globals.bFileTransfers != old_bFileTransfers) { - db_set_b(NULL, MODULENAME, "bSameAction", 0); + g_plugin.setByte("bSameAction", 0); globals.bSameAction = false; } - db_set_b(NULL, MODULENAME, "bAutoExchange", globals.bAutoExchange = check_AUTO_EXCHANGE.GetState()); - db_set_ws(NULL, MODULENAME, "szLogFilePath", ptrW(edit_LOG_FILE_EDIT.GetText())); + g_plugin.setByte("bAutoExchange", globals.bAutoExchange = check_AUTO_EXCHANGE.GetState()); + g_plugin.setWString("szLogFilePath", ptrW(edit_LOG_FILE_EDIT.GetText())); return true; } @@ -284,7 +284,7 @@ public: void onClick_COPY_KEY(CCtrlButton*) { if (OpenClipboard(m_hwnd)) { - char *szKey = UniGetContactSettingUtf(NULL, MODULENAME, "GPGPubKey", ""); + char *szKey = UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", ""); std::string str = szKey; mir_free(szKey); boost::algorithm::replace_all(str, "\n", "\r\n"); @@ -386,26 +386,26 @@ public: bool OnInitDialog() override { - edit_BIN_PATH.SetText(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szGpgBinPath", L"gpg.exe"))); - edit_HOME_DIR.SetText(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L"gpg"))); + edit_BIN_PATH.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); + edit_HOME_DIR.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"gpg"))); return true; } bool OnApply() override { wchar_t tmp[8192]; - db_set_ws(NULL, MODULENAME, "szGpgBinPath", edit_BIN_PATH.GetText()); + g_plugin.setWString("szGpgBinPath", edit_BIN_PATH.GetText()); mir_wstrncpy(tmp, edit_HOME_DIR.GetText(), 8191); while (tmp[mir_wstrlen(tmp) - 1] == '\\') tmp[mir_wstrlen(tmp) - 1] = '\0'; - db_set_ws(NULL, MODULENAME, "szHomePath", tmp); + g_plugin.setWString("szHomePath", tmp); return true; } void onClick_SET_BIN_PATH(CCtrlButton*) { GetFilePath(TranslateT("Choose gpg.exe"), "szGpgBinPath", L"*.exe", TranslateT("EXE Executables")); - CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szGpgBinPath", L"gpg.exe"))); + CMStringW tmp(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); edit_BIN_PATH.SetText(tmp); bool gpg_exists = false; { @@ -413,8 +413,8 @@ public: gpg_exists = true; if (gpg_exists) { bool bad_version = false; - wchar_t *tmp_path = UniGetContactSettingUtf(NULL, MODULENAME, "szGpgBinPath", L""); - db_set_ws(NULL, MODULENAME, "szGpgBinPath", tmp); + wchar_t *tmp_path = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L""); + g_plugin.setWString("szGpgBinPath", tmp); string out; DWORD code; std::vector<wstring> cmd; @@ -428,7 +428,7 @@ public: globals.gpg_valid = true; gpg_launcher(params); globals.gpg_valid = old_gpg_state; - db_set_ws(NULL, MODULENAME, "szGpgBinPath", tmp_path); + g_plugin.setWString("szGpgBinPath", tmp_path); mir_free(tmp_path); string::size_type p1 = out.find("(GnuPG) "); if (p1 != string::npos) { @@ -455,7 +455,7 @@ public: void onClick_SET_HOME_DIR(CCtrlButton*) { GetFolderPath(TranslateT("Set home directory")); - CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""))); + CMStringW tmp(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""))); edit_HOME_DIR.SetText(tmp); wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -479,34 +479,34 @@ public: bool OnInitDialog() override { - check_APPEND_TAGS.SetState(db_get_b(NULL, MODULENAME, "bAppendTags", 0)); - check_STRIP_TAGS.SetState(db_get_b(NULL, MODULENAME, "bStripTags", 0)); - edit_IN_OPEN_TAG.SetText(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szInOpenTag", L"<GPGdec>"))); - edit_IN_CLOSE_TAG.SetText(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szInCloseTag", L"</GPGdec>"))); - edit_OUT_OPEN_TAG.SetText(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szOutOpenTag", L"<GPGenc>"))); - edit_OUT_CLOSE_TAG.SetText(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szOutCloseTag", L"</GPGenc>"))); + 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>"))); return true; } bool OnApply() override { - db_set_b(NULL, MODULENAME, "bAppendTags", globals.bAppendTags = check_APPEND_TAGS.GetState()); - db_set_b(NULL, MODULENAME, "bStripTags", globals.bStripTags = check_STRIP_TAGS.GetState()); + g_plugin.setByte("bAppendTags", globals.bAppendTags = check_APPEND_TAGS.GetState()); + g_plugin.setByte("bStripTags", globals.bStripTags = check_STRIP_TAGS.GetState()); { wchar_t *tmp = mir_wstrdup(edit_IN_OPEN_TAG.GetText()); - db_set_ws(NULL, MODULENAME, "szInOpenTag", tmp); + g_plugin.setWString("szInOpenTag", tmp); mir_free(globals.inopentag); globals.inopentag = tmp; tmp = mir_wstrdup(edit_IN_CLOSE_TAG.GetText()); - db_set_ws(NULL, MODULENAME, "szInCloseTag", tmp); + g_plugin.setWString("szInCloseTag", tmp); mir_free(globals.inclosetag); globals.inclosetag = tmp; tmp = mir_wstrdup(edit_OUT_OPEN_TAG.GetText()); - db_set_ws(NULL, MODULENAME, "szOutOpenTag", tmp); + g_plugin.setWString("szOutOpenTag", tmp); mir_free(globals.outopentag); globals.outopentag = tmp; tmp = mir_wstrdup(edit_OUT_CLOSE_TAG.GetText()); - db_set_ws(NULL, MODULENAME, "szOutCloseTag", tmp); + g_plugin.setWString("szOutCloseTag", tmp); mir_free(globals.outclosetag); globals.outclosetag = tmp; } @@ -530,14 +530,14 @@ public: bool OnInitDialog() override { - check_PRESCENSE_SUBSCRIPTION.SetState(db_get_b(NULL, MODULENAME, "bPresenceSigning", 0)); + check_PRESCENSE_SUBSCRIPTION.SetState(g_plugin.getByte("bPresenceSigning", 0)); check_PRESCENSE_SUBSCRIPTION.Enable(globals.bJabberAPI); return true; } bool OnApply() override { - db_set_b(NULL, MODULENAME, "bPresenceSigning", globals.bPresenceSigning = check_PRESCENSE_SUBSCRIPTION.GetState()); + g_plugin.setByte("bPresenceSigning", globals.bPresenceSigning = check_PRESCENSE_SUBSCRIPTION.GetState()); return true; } @@ -677,8 +677,8 @@ public: virtual void OnDestroy() override { GetWindowRect(m_hwnd, &globals.load_key_rect); - db_set_dw(NULL, MODULENAME, "LoadKeyWindowX", globals.load_key_rect.left); - db_set_dw(NULL, MODULENAME, "LoadKeyWindowY", globals.load_key_rect.top); + g_plugin.setDword("LoadKeyWindowX", globals.load_key_rect.left); + g_plugin.setDword("LoadKeyWindowY", globals.load_key_rect.top); edit_p_PubKeyEdit = nullptr; } @@ -742,7 +742,7 @@ public: DWORD exitcode; { MCONTACT hcnt = db_mc_tryMeta(hContact); - ptmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); + ptmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); wcsncpy(tmp2, ptmp, MAX_PATH - 1); mir_free(ptmp); mir_wstrncat(tmp2, L"\\", _countof(tmp2) - mir_wstrlen(tmp2)); diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp index 8ec4ca30b8..fdf68a5bff 100755 --- a/plugins/New_GPG/src/ui.cpp +++ b/plugins/New_GPG/src/ui.cpp @@ -37,7 +37,7 @@ CDlgEncryptedFileMsgBox::CDlgEncryptedFileMsgBox() : void CDlgEncryptedFileMsgBox::onClick_IGNORE(CCtrlButton*) { if (chk_REMEMBER.GetState()) { - db_set_b(NULL, MODULENAME, "bSameAction", 1); + g_plugin.setByte("bSameAction", 1); globals.bSameAction = true; } this->Close(); @@ -47,9 +47,9 @@ void CDlgEncryptedFileMsgBox::onClick_DECRYPT(CCtrlButton*) { globals.bDecryptFiles = true; if (chk_REMEMBER.GetState()) { - db_set_b(NULL, MODULENAME, "bFileTransfers", 1); + g_plugin.setByte("bFileTransfers", 1); globals.bFileTransfers = true; - db_set_b(NULL, MODULENAME, "bSameAction", 0); + g_plugin.setByte("bSameAction", 0); globals.bSameAction = false; } this->Close(); @@ -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(NULL, MODULENAME, "szKeyPassword", L""); + wchar_t *pass = UniGetContactSettingUtf(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(NULL, MODULENAME, dbsetting.c_str(), L""); + pass = UniGetContactSettingUtf(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(NULL, MODULENAME, "KeyID", ""); + char *keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_KEY_ID.SetTextA(keyinfo.c_str()); @@ -445,32 +445,32 @@ void CDlgFirstRun::onClick_DELETE_KEY(CCtrlButton*) { char *buf = mir_strdup(combo_ACCOUNT.GetTextA()); if (!mir_strcmp(buf, Translate("Default"))) { - db_unset(NULL, MODULENAME, "GPGPubKey"); - db_unset(NULL, MODULENAME, "KeyID"); - db_unset(NULL, MODULENAME, "KeyComment"); - db_unset(NULL, MODULENAME, "KeyMainName"); - db_unset(NULL, MODULENAME, "KeyMainEmail"); - db_unset(NULL, MODULENAME, "KeyType"); + g_plugin.delSetting("GPGPubKey"); + g_plugin.delSetting("KeyID"); + g_plugin.delSetting("KeyComment"); + g_plugin.delSetting("KeyMainName"); + g_plugin.delSetting("KeyMainEmail"); + g_plugin.delSetting("KeyType"); } else { std::string acc_str = buf; acc_str += "_GPGPubKey"; - db_unset(NULL, MODULENAME, acc_str.c_str()); + g_plugin.delSetting(acc_str.c_str()); acc_str = buf; acc_str += "_KeyMainName"; - db_unset(NULL, MODULENAME, acc_str.c_str()); + g_plugin.delSetting(acc_str.c_str()); acc_str = buf; acc_str += "_KeyID"; - db_unset(NULL, MODULENAME, acc_str.c_str()); + g_plugin.delSetting(acc_str.c_str()); acc_str = buf; acc_str += "_KeyComment"; - db_unset(NULL, MODULENAME, acc_str.c_str()); + g_plugin.delSetting(acc_str.c_str()); acc_str = buf; acc_str += "_KeyMainEmail"; - db_unset(NULL, MODULENAME, acc_str.c_str()); + g_plugin.delSetting(acc_str.c_str()); acc_str = buf; acc_str += "_KeyType"; - db_unset(NULL, MODULENAME, acc_str.c_str()); + g_plugin.delSetting(acc_str.c_str()); } if (buf) mir_free(buf); @@ -520,20 +520,20 @@ void CDlgFirstRun::onClick_OK(CCtrlButton*) { char *buf = mir_strdup(combo_ACCOUNT.GetTextA()); if (!mir_strcmp(buf, Translate("Default"))) { - db_set_s(NULL, MODULENAME, "GPGPubKey", out.c_str()); - db_set_ws(NULL, MODULENAME, "KeyMainName", name); - db_set_ws(NULL, MODULENAME, "KeyID", fp); + g_plugin.setString("GPGPubKey", out.c_str()); + g_plugin.setWString("KeyMainName", name); + g_plugin.setWString("KeyID", fp); } else { std::string acc_str = buf; acc_str += "_GPGPubKey"; - db_set_s(NULL, MODULENAME, acc_str.c_str(), out.c_str()); + g_plugin.setString(acc_str.c_str(), out.c_str()); acc_str = buf; acc_str += "_KeyMainName"; - db_set_ws(NULL, MODULENAME, acc_str.c_str(), name); + g_plugin.setWString(acc_str.c_str(), name); acc_str = buf; acc_str += "_KeyID"; - db_set_ws(NULL, MODULENAME, acc_str.c_str(), fp); + g_plugin.setWString(acc_str.c_str(), fp); } if (!mir_strcmp(buf, Translate("Default"))) { wstring keyinfo = TranslateT("Default private key ID"); @@ -552,7 +552,7 @@ void CDlgFirstRun::onClick_OK(CCtrlButton*) dbsetting += keyid; mir_free(keyid); dbsetting += "_Password"; - db_set_ws(NULL, MODULENAME, dbsetting.c_str(), passwd); + g_plugin.setWString(dbsetting.c_str(), passwd); } mir_free(passwd); delete[] name; @@ -569,7 +569,7 @@ void CDlgFirstRun::onChange_ACCOUNT(CCtrlCombo*) if (!mir_strcmp(buf, Translate("Default"))) { string keyinfo = Translate("key ID"); keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); + char *keyid = UniGetContactSettingUtf(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(NULL, MODULENAME, acc_str.c_str(), ""); + char *keyid = UniGetContactSettingUtf(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()); @@ -605,8 +605,8 @@ void CDlgFirstRun::onChange_KEY_LIST(CCtrlListView::TEventInfo *ev) //TODO: chec void CDlgFirstRun::OnDestroy() { GetWindowRect(m_hwnd, &globals.firstrun_rect); - db_set_dw(NULL, MODULENAME, "FirstrunWindowX", globals.firstrun_rect.left); - db_set_dw(NULL, MODULENAME, "FirstrunWindowY", globals.firstrun_rect.top); + g_plugin.setDword("FirstrunWindowX", globals.firstrun_rect.left); + g_plugin.setDword("FirstrunWindowY", globals.firstrun_rect.top); } void CDlgFirstRun::refresh_key_list() @@ -730,7 +730,7 @@ void CDlgFirstRun::refresh_key_list() setting += pa->szModuleName; setting += ")"; setting += "_KeyID"; - wchar_t *str = UniGetContactSettingUtf(NULL, MODULENAME, setting.c_str(), L""); + wchar_t *str = UniGetContactSettingUtf(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(NULL, 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 = 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""); 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); @@ -807,7 +807,7 @@ bool CDlgGpgBinOpts::OnInitDialog() edit_BIN_PATH.SetText(tmp); if (gpg_exists/* && lang_exists*/) { - db_set_ws(NULL, MODULENAME, "szGpgBinPath", tmp); + g_plugin.setWString("szGpgBinPath", tmp); string out; DWORD code; std::vector<wstring> cmd; @@ -821,7 +821,7 @@ bool CDlgGpgBinOpts::OnInitDialog() globals.gpg_valid = true; gpg_launcher(params); globals.gpg_valid = _gpg_valid; //TODO: check this - db_unset(NULL, MODULENAME, "szGpgBinPath"); + g_plugin.delSetting("szGpgBinPath"); string::size_type p1 = out.find("(GnuPG) "); if (p1 != string::npos) { p1 += mir_strlen("(GnuPG) "); @@ -837,7 +837,7 @@ bool CDlgGpgBinOpts::OnInitDialog() } } { - ptrW tmp(UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L"")); + ptrW tmp(UniGetContactSettingUtf(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(NULL, MODULENAME, "szGpgBinPath", L"gpg.exe"))); + CMStringW tmp(ptrW(UniGetContactSettingUtf(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(NULL, MODULENAME, "szHomePath", L""))); + CMStringW tmp(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""))); edit_HOME_DIR.SetText(tmp); wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -893,7 +893,7 @@ void CDlgGpgBinOpts::onClick_OK(CCtrlButton*) if (gpg_validate_paths(edit_BIN_PATH.GetText(), edit_HOME_DIR.GetText())) { gpg_save_paths(edit_BIN_PATH.GetText(), edit_HOME_DIR.GetText()); globals.gpg_valid = true; - db_set_b(NULL, MODULENAME, "FirstRun", 0); + g_plugin.setByte("FirstRun", 0); this->Hide(); CDlgFirstRun *d = new CDlgFirstRun; d->Show(); @@ -907,9 +907,9 @@ void CDlgGpgBinOpts::onClick_GENERATE_RANDOM(CCtrlButton*) gpg_save_paths(edit_BIN_PATH.GetText(), edit_HOME_DIR.GetText()); globals.gpg_valid = true; if (gpg_use_new_random_key()) { - db_set_b(NULL, MODULENAME, "bAutoExchange", globals.bAutoExchange = chk_AUTO_EXCHANGE.GetState()); + g_plugin.setByte("bAutoExchange", globals.bAutoExchange = chk_AUTO_EXCHANGE.GetState()); globals.gpg_valid = true; - db_set_b(NULL, MODULENAME, "FirstRun", 0); + g_plugin.setByte("FirstRun", 0); this->Close(); } } @@ -957,8 +957,8 @@ bool CDlgNewKey::OnInitDialog() void CDlgNewKey::OnDestroy() { GetWindowRect(m_hwnd, &globals.new_key_rect); - db_set_dw(NULL, MODULENAME, "NewKeyWindowX", globals.new_key_rect.left); - db_set_dw(NULL, MODULENAME, "NewKeyWindowY", globals.new_key_rect.top); + g_plugin.setDword("NewKeyWindowX", globals.new_key_rect.left); + g_plugin.setDword("NewKeyWindowY", globals.new_key_rect.top); } void CDlgNewKey::onClick_IMPORT(CCtrlButton*) @@ -1081,7 +1081,7 @@ void CDlgKeyGen::onClick_OK(CCtrlButton*) mir_free(tmp); } { //generating key file - wchar_t *tmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); + wchar_t *tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); char *tmp2;// = mir_u2a(tmp); path = tmp; mir_free(tmp); @@ -1175,8 +1175,8 @@ void CDlgKeyGen::onClick_CANCEL(CCtrlButton*) void CDlgKeyGen::OnDestroy() { GetWindowRect(m_hwnd, &globals.key_gen_rect); - db_set_dw(NULL, MODULENAME, "KeyGenWindowX", globals.key_gen_rect.left); - db_set_dw(NULL, MODULENAME, "KeyGenWindowY", globals.key_gen_rect.top); + g_plugin.setDword("KeyGenWindowX", globals.key_gen_rect.left); + g_plugin.setDword("KeyGenWindowY", globals.key_gen_rect.top); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -1298,8 +1298,8 @@ bool CDlgLoadExistingKey::OnInitDialog() void CDlgLoadExistingKey::OnDestroy() { GetWindowRect(m_hwnd, &globals.load_existing_key_rect); - db_set_dw(NULL, MODULENAME, "LoadExistingKeyWindowX", globals.load_existing_key_rect.left); - db_set_dw(NULL, MODULENAME, "LoadExistingKeyWindowY", globals.load_existing_key_rect.top); + g_plugin.setDword("LoadExistingKeyWindowX", globals.load_existing_key_rect.left); + g_plugin.setDword("LoadExistingKeyWindowY", globals.load_existing_key_rect.top); } void CDlgLoadExistingKey::onClick_OK(CCtrlButton*) @@ -1382,8 +1382,8 @@ bool CDlgImportKey::OnInitDialog() void CDlgImportKey::OnDestroy() { GetWindowRect(m_hwnd, &globals.import_key_rect); - db_set_dw(NULL, MODULENAME, "ImportKeyWindowX", globals.import_key_rect.left); - db_set_dw(NULL, MODULENAME, "ImportKeyWindowY", globals.import_key_rect.top); + g_plugin.setDword("ImportKeyWindowX", globals.import_key_rect.left); + g_plugin.setDword("ImportKeyWindowY", globals.import_key_rect.top); } void CDlgImportKey::onClick_IMPORT(CCtrlButton*) @@ -1438,8 +1438,8 @@ void CDlgKeyPasswordMsgBox::OnDestroy() { mir_free(inkeyid); GetWindowRect(m_hwnd, &globals.key_password_rect); - db_set_dw(NULL, MODULENAME, "PasswordWindowX", globals.key_password_rect.left); - db_set_dw(NULL, MODULENAME, "PasswordWindowY", globals.key_password_rect.top); + g_plugin.setDword("PasswordWindowX", globals.key_password_rect.left); + g_plugin.setDword("PasswordWindowY", globals.key_password_rect.top); } void CDlgKeyPasswordMsgBox::onClick_OK(CCtrlButton*) @@ -1452,10 +1452,10 @@ void CDlgKeyPasswordMsgBox::onClick_OK(CCtrlButton*) string dbsetting = "szKey_"; dbsetting += inkeyid; dbsetting += "_Password"; - db_set_ws(NULL, MODULENAME, dbsetting.c_str(), tmp); + g_plugin.setWString(dbsetting.c_str(), tmp); } else - db_set_ws(NULL, MODULENAME, "szKeyPassword", tmp); + g_plugin.setWString("szKeyPassword", tmp); } if (globals.password) mir_free(globals.password); diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index fed328235e..bbb140f0c7 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -74,7 +74,7 @@ void GetFilePath(wchar_t *WindowTittle, char *szSetting, wchar_t *szExt, wchar_t ofn.nMaxFileTitle = MAX_PATH; if (!GetOpenFileName(&ofn)) return; - db_set_ws(0, MODULENAME, szSetting, str); + g_plugin.setWString(szSetting, str); } wchar_t* GetFilePath(wchar_t *WindowTittle, wchar_t *szExt, wchar_t *szExtDesc, bool save_file) @@ -121,7 +121,7 @@ void GetFolderPath(wchar_t *WindowTittle) if (pidl != nullptr) { wchar_t path[MAX_PATH]; if (SHGetPathFromIDList(pidl, path)) { - db_set_ws(NULL, MODULENAME, "szHomePath", path); + g_plugin.setWString("szHomePath", path); } IMalloc * imalloc = nullptr; if (SUCCEEDED(SHGetMalloc(&imalloc))) { @@ -156,10 +156,10 @@ INT_PTR SendKey(WPARAM w, LPARAM) key_id_str += "_KeyID"; acc_str += "_GPGPubKey"; } - szMessage = UniGetContactSettingUtf(NULL, MODULENAME, acc_str.empty() ? "GPGPubKey" : acc_str.c_str(), ""); + szMessage = UniGetContactSettingUtf(0, MODULENAME, acc_str.empty() ? "GPGPubKey" : acc_str.c_str(), ""); if (!szMessage[0]) { mir_free(szMessage); - szMessage = UniGetContactSettingUtf(NULL, MODULENAME, "GPGPubKey", ""); //try to get default key as fallback in any way + szMessage = UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", ""); //try to get default key as fallback in any way } } if (szMessage[0]) { @@ -167,10 +167,10 @@ INT_PTR SendKey(WPARAM w, LPARAM) db_set_b(hContact, MODULENAME, "GPGEncryption", 0); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)szMessage); std::string msg = "Public key "; - char *keyid = UniGetContactSettingUtf(NULL, MODULENAME, key_id_str.c_str(), ""); + char *keyid = UniGetContactSettingUtf(0, MODULENAME, key_id_str.c_str(), ""); if (!keyid[0]) { mir_free(keyid); - keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); + keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); } msg += keyid; mir_free(keyid); @@ -229,10 +229,10 @@ int OnPreBuildContactMenu(WPARAM w, LPARAM) setting += ")"; setting += "_KeyID"; } - char *keyid = UniGetContactSettingUtf(NULL, MODULENAME, setting.c_str(), ""); + char *keyid = UniGetContactSettingUtf(0, MODULENAME, setting.c_str(), ""); if (!keyid[0]) { mir_free(keyid); - keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); + keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); } wchar_t buf[128] = { 0 }; mir_snwprintf(buf, L"%s: %s", TranslateT("Send public key"), toUTF16(keyid).c_str()); @@ -319,12 +319,12 @@ int onProtoAck(WPARAM, LPARAM l) string dbsetting = "szKey_"; dbsetting += keyid; dbsetting += "_Password"; - pass = UniGetContactSettingUtf(NULL, MODULENAME, dbsetting.c_str(), L""); + pass = UniGetContactSettingUtf(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(NULL, MODULENAME, "szKeyPassword", L""); + pass = UniGetContactSettingUtf(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"); } @@ -669,7 +669,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) } if (globals.bPresenceSigning && nodename && wcsstr(nodename, L"status")) { - wchar_t *path_c = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); + wchar_t *path_c = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); wstring path_out = path_c; wstring file = toUTF16(get_random(10)); mir_free(path_c); @@ -693,10 +693,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(NULL, MODULENAME, setting, ""); + inkeyid = UniGetContactSettingUtf(0, MODULENAME, setting, ""); if (!inkeyid[0]) { mir_free(inkeyid); - inkeyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); + inkeyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); } ptrW pass; @@ -704,14 +704,14 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) string dbsetting = "szKey_"; dbsetting += inkeyid; dbsetting += "_Password"; - pass = UniGetContactSettingUtf(NULL, MODULENAME, dbsetting.c_str(), L""); + pass = UniGetContactSettingUtf(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(NULL, MODULENAME, "szKeyPassword", L""); + pass = UniGetContactSettingUtf(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 +730,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) } cmd.push_back(L"--local-user"); - path_c = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", L""); + path_c = UniGetContactSettingUtf(0, MODULENAME, "KeyID", L""); cmd.push_back(path_c); cmd.push_back(L"--default-key"); cmd.push_back(path_c); @@ -832,7 +832,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(NULL, MODULENAME, "szHomePath", L""); + wchar_t *path_c = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); wstring path_out = path_c, status_file_out = path_c; mir_free(path_c); path_out += L"\\tmp\\"; @@ -972,8 +972,8 @@ bool isContactHaveKey(MCONTACT hContact) bool isGPGKeyExist() { - wchar_t *id = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", L""); - char *key = UniGetContactSettingUtf(NULL, MODULENAME, "GPGPubKey", ""); + wchar_t *id = UniGetContactSettingUtf(0, MODULENAME, "KeyID", L""); + char *key = UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", ""); if (id[0] && key[0]) { mir_free(id); mir_free(key); @@ -987,7 +987,7 @@ bool isGPGValid() { wchar_t *tmp = nullptr; bool gpg_exists = false, is_valid = true; - tmp = UniGetContactSettingUtf(NULL, MODULENAME, "szGpgBinPath", L""); + tmp = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L""); boost::filesystem::path p(tmp); if (boost::filesystem::exists(p) && boost::filesystem::is_regular_file(p)) @@ -1018,7 +1018,7 @@ bool isGPGValid() } if (gpg_exists) { - db_set_ws(NULL, MODULENAME, "szGpgBinPath", tmp); + g_plugin.setWString("szGpgBinPath", tmp); mir_free(tmp); tmp = nullptr; string out; @@ -1046,7 +1046,7 @@ bool isGPGValid() { wstring path_ = _wgetenv(L"APPDATA"); path_ += L"\\GnuPG"; - tmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", (wchar_t*)path_.c_str()); + tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", (wchar_t*)path_.c_str()); } if(tmp) mir_free(tmp); */ @@ -1212,7 +1212,7 @@ int handleEnum(const char *szSetting, void *lParam) { if (!*(bool*)lParam && szSetting[0] && StriStr(szSetting, "tabsrmm")) { bool f = false, *found = (bool*)lParam; - f = !db_get_b(NULL, "PluginDisable", szSetting, 0); + f = !db_get_b(0, "PluginDisable", szSetting, 0); if (f) *found = f; } @@ -1595,7 +1595,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) string output; DWORD exitcode; { - ptmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); + ptmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); path = ptmp; mir_free(ptmp); wstring rand = toUTF16(get_random(10)); @@ -1700,7 +1700,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) string output; DWORD exitcode; { - ptmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); + ptmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); wcsncpy(tmp2, ptmp, MAX_PATH - 1); mir_free(ptmp); mir_wstrncat(tmp2, L"\\", _countof(tmp2) - mir_wstrlen(tmp2)); @@ -1813,7 +1813,7 @@ void clean_temp_dir() wstring path = toUTF16(mir_path); SetCurrentDirectoryA(mir_path); delete[] mir_path; - wchar_t *tmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); + wchar_t *tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); path += tmp; mir_free(tmp); path += L"\\tmp"; @@ -1847,7 +1847,7 @@ bool gpg_validate_paths(wchar_t *gpg_bin_path, wchar_t *gpg_home_path) } { bool bad_version = false; - db_set_ws(NULL, MODULENAME, "szGpgBinPath", tmp.c_str()); + g_plugin.setWString("szGpgBinPath", tmp.c_str()); string out; DWORD code; std::vector<wstring> cmd; @@ -1861,7 +1861,7 @@ bool gpg_validate_paths(wchar_t *gpg_bin_path, wchar_t *gpg_home_path) globals.gpg_valid = true; gpg_launcher(params); globals.gpg_valid = _gpg_valid; //TODO: check this - db_unset(NULL, MODULENAME, "szGpgBinPath"); + g_plugin.delSetting("szGpgBinPath"); string::size_type p1 = out.find("(GnuPG) "); if (p1 != string::npos) { p1 += mir_strlen("(GnuPG) "); @@ -1884,7 +1884,7 @@ bool gpg_validate_paths(wchar_t *gpg_bin_path, wchar_t *gpg_home_path) return false; } { - wchar_t *path = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); + wchar_t *path = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); DWORD dwFileAttr = GetFileAttributes(path); if (dwFileAttr != INVALID_FILE_ATTRIBUTES) { dwFileAttr &= ~FILE_ATTRIBUTE_READONLY; @@ -1897,8 +1897,8 @@ bool gpg_validate_paths(wchar_t *gpg_bin_path, wchar_t *gpg_home_path) void gpg_save_paths(wchar_t *gpg_bin_path, wchar_t *gpg_home_path) { - db_set_ws(NULL, MODULENAME, "szGpgBinPath", gpg_bin_path); - db_set_ws(NULL, MODULENAME, "szHomePath", gpg_home_path); + g_plugin.setWString("szGpgBinPath", gpg_bin_path); + g_plugin.setWString("szHomePath", gpg_home_path); } bool gpg_use_new_random_key(char *account_name, wchar_t *gpg_bin_path, wchar_t *gpg_home_dir) @@ -1913,7 +1913,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(NULL, MODULENAME, "szHomePath", L""); + tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); path = tmp; if (!gpg_home_dir) mir_free(tmp); @@ -1991,16 +1991,16 @@ bool gpg_use_new_random_key(char *account_name, wchar_t *gpg_bin_path, wchar_t * out.erase(s, 1); if (!mir_strcmp(account_name, Translate("Default"))) { - db_set_s(NULL, MODULENAME, "GPGPubKey", out.c_str()); - db_set_ws(NULL, MODULENAME, "KeyID", path.c_str()); + g_plugin.setString("GPGPubKey", out.c_str()); + g_plugin.setWString("KeyID", path.c_str()); } else { std::string acc_str = account_name; acc_str += "_GPGPubKey"; - db_set_s(NULL, MODULENAME, acc_str.c_str(), out.c_str()); + g_plugin.setString(acc_str.c_str(), out.c_str()); acc_str = account_name; acc_str += "_KeyID"; - db_set_ws(NULL, MODULENAME, acc_str.c_str(), path.c_str()); + g_plugin.setWString(acc_str.c_str(), path.c_str()); } } return true; |