diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-20 15:08:48 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-20 15:08:48 +0300 |
commit | 8a74e7495ce5ad39de4f5c25121a84d35df90c36 (patch) | |
tree | 03e5b4870f09a3163306740c2eebee47bc15b042 /plugins/New_GPG/src | |
parent | c5bf7d6123dd1c3b82ccb8fdb1b068077e9d56d4 (diff) |
CMPlugin to receive a reference to PLUGININFOEX
Diffstat (limited to 'plugins/New_GPG/src')
-rw-r--r-- | plugins/New_GPG/src/constants.h | 2 | ||||
-rwxr-xr-x | plugins/New_GPG/src/gpg_wrapper.cpp | 8 | ||||
-rwxr-xr-x | plugins/New_GPG/src/icons.cpp | 4 | ||||
-rwxr-xr-x | plugins/New_GPG/src/init.cpp | 78 | ||||
-rwxr-xr-x | plugins/New_GPG/src/log.cpp | 2 | ||||
-rwxr-xr-x | plugins/New_GPG/src/main.cpp | 72 | ||||
-rwxr-xr-x | plugins/New_GPG/src/messages.cpp | 96 | ||||
-rwxr-xr-x | plugins/New_GPG/src/options.cpp | 206 | ||||
-rwxr-xr-x | plugins/New_GPG/src/srmm.cpp | 16 | ||||
-rwxr-xr-x | plugins/New_GPG/src/stdafx.h | 4 | ||||
-rwxr-xr-x | plugins/New_GPG/src/ui.cpp | 114 | ||||
-rwxr-xr-x | plugins/New_GPG/src/utilities.cpp | 134 |
12 files changed, 369 insertions, 367 deletions
diff --git a/plugins/New_GPG/src/constants.h b/plugins/New_GPG/src/constants.h index be769466c9..0eef3b79a2 100644 --- a/plugins/New_GPG/src/constants.h +++ b/plugins/New_GPG/src/constants.h @@ -1,5 +1,5 @@ #ifndef CONSTANTS_H #define CONSTANTS_H -#define szGPGModuleName "GPG" +#define MODULENAME "GPG" #define PREF_METANODB 0x2000 #endif diff --git a/plugins/New_GPG/src/gpg_wrapper.cpp b/plugins/New_GPG/src/gpg_wrapper.cpp index 06a39a4425..939c0bb6cc 100755 --- a/plugins/New_GPG/src/gpg_wrapper.cpp +++ b/plugins/New_GPG/src/gpg_wrapper.cpp @@ -24,7 +24,7 @@ pxResult pxExecute(std::vector<std::wstring> &aargv, string *aoutput, LPDWORD ae return pxNotConfigured; - wchar_t *bin_path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L""); + wchar_t *bin_path = UniGetContactSettingUtf(NULL, MODULENAME, "szGpgBinPath", L""); { if(!boost::filesystem::exists(bin_path)) { @@ -47,7 +47,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, szGPGModuleName, "szHomePath", L""); + wchar_t *home_dir = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); if(mir_wstrlen(home_dir)) //this check are required for first run gpg binary validation { argv.push_back(L"--homedir"); @@ -173,7 +173,7 @@ pxResult pxExecute_passwd_change(std::vector<std::wstring> &aargv, pxResult *res if(!globals.gpg_valid) return pxNotConfigured; - wchar_t *bin_path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L""); + wchar_t *bin_path = UniGetContactSettingUtf(NULL, MODULENAME, "szGpgBinPath", L""); { if(!boost::filesystem::exists(bin_path)) { @@ -195,7 +195,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, szGPGModuleName, "szHomePath", L""); + wchar_t *home_dir = UniGetContactSettingUtf(NULL, 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/icons.cpp b/plugins/New_GPG/src/icons.cpp index 99c0a6891c..8d6cc66f60 100755 --- a/plugins/New_GPG/src/icons.cpp +++ b/plugins/New_GPG/src/icons.cpp @@ -25,7 +25,7 @@ static IconItem iconList[] = void InitIconLib() { - g_plugin.registerIcon(szGPGModuleName, iconList); + g_plugin.registerIcon(MODULENAME, iconList); } HANDLE IconLibHookIconsChanged(MIRANDAHOOK hook) @@ -50,7 +50,7 @@ void setSrmmIcon(MCONTACT h) MCONTACT hMC = db_mc_tryMeta(hContact); StatusIconData sid = {}; - sid.szModule = szGPGModuleName; + sid.szModule = MODULENAME; sid.hIcon = IcoLib_GetIcon("secured"); sid.dwId = 1; sid.flags = enabled ? 0 : MBF_HIDDEN; diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index db4f6cc28e..cfc89ded5f 100755 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -22,7 +22,7 @@ CMPlugin g_plugin; ///////////////////////////////////////////////////////////////////////////////////////// -PLUGININFOEX pluginInfo={ +PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), __PLUGIN_NAME, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), @@ -35,9 +35,13 @@ PLUGININFOEX pluginInfo={ { 0x4227c050, 0x8d97, 0x48d2, { 0x91, 0xec, 0x6a, 0x95, 0x2b, 0x3d, 0xab, 0x94 } } }; +CMPlugin::CMPlugin() : + PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx) +{} + extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { - return &pluginInfo; + return &pluginInfoEx; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -53,34 +57,34 @@ void InitIconLib(); void init_vars() { - globals.bAppendTags = db_get_b(NULL, szGPGModuleName, "bAppendTags", 0) != 0; - globals.bStripTags = db_get_b(NULL, szGPGModuleName, "bStripTags", 0) != 0; - globals.inopentag = UniGetContactSettingUtf(NULL, szGPGModuleName, "szInOpenTag", L"<GPGdec>"); - globals.inclosetag = UniGetContactSettingUtf(NULL, szGPGModuleName, "szInCloseTag", L"</GPGdec>"); - globals.outopentag = UniGetContactSettingUtf(NULL, szGPGModuleName, "szOutOpenTag", L"<GPGenc>"); - globals.outclosetag = UniGetContactSettingUtf(NULL, szGPGModuleName, "szOutCloseTag", L"</GPGenc>"); - globals.bDebugLog = db_get_b(NULL, szGPGModuleName, "bDebugLog", 0) != 0; - globals.bAutoExchange = db_get_b(NULL, szGPGModuleName, "bAutoExchange", 0) != 0; - globals.bSameAction = db_get_b(NULL, szGPGModuleName, "bSameAction", 0) != 0; - globals.password = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", L""); + 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.debuglog.init(); - globals.bJabberAPI = db_get_b(NULL, szGPGModuleName, "bJabberAPI", true) != 0; - globals.bPresenceSigning = db_get_b(NULL, szGPGModuleName, "bPresenceSigning", 0) != 0; - globals.bFileTransfers = db_get_b(NULL, szGPGModuleName, "bFileTransfers", 0) != 0; - globals.firstrun_rect.left = db_get_dw(NULL, szGPGModuleName, "FirstrunWindowX", 0); - globals.firstrun_rect.top = db_get_dw(NULL, szGPGModuleName, "FirstrunWindowY", 0); - globals.key_password_rect.left = db_get_dw(NULL, szGPGModuleName, "PasswordWindowX", 0); - globals.key_password_rect.top = db_get_dw(NULL, szGPGModuleName, "PasswordWindowY", 0); - globals.key_gen_rect.left = db_get_dw(NULL, szGPGModuleName, "KeyGenWindowX", 0); - globals.key_gen_rect.top = db_get_dw(NULL, szGPGModuleName, "KeyGenWindowY", 0); - globals.load_key_rect.left = db_get_dw(NULL, szGPGModuleName, "LoadKeyWindowX", 0); - globals.load_key_rect.top = db_get_dw(NULL, szGPGModuleName, "LoadKeyWindowY", 0); - globals.import_key_rect.left = db_get_dw(NULL, szGPGModuleName, "ImportKeyWindowX", 0); - globals.import_key_rect.top = db_get_dw(NULL, szGPGModuleName, "ImportKeyWindowY", 0); - globals.new_key_rect.left = db_get_dw(NULL, szGPGModuleName, "NewKeyWindowX", 0); - globals.new_key_rect.top = db_get_dw(NULL, szGPGModuleName, "NewKeyWindowY", 0); - globals.load_existing_key_rect.left = db_get_dw(NULL, szGPGModuleName, "LoadExistingKeyWindowX", 0); - globals.load_existing_key_rect.top = db_get_dw(NULL, szGPGModuleName, "LoadExistingKeyWindowY", 0); + 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.tabsrmm_used = isTabsrmmUsed(); globals.bold_font = CreateFont(14, 0, 0, 0, 600, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, L"Arial"); } @@ -102,11 +106,11 @@ static int OnModulesLoaded(WPARAM, LPARAM) void InitCheck(); void FirstRun(); FirstRun(); - if(!db_get_b(NULL, szGPGModuleName, "FirstRun", 1)) + if(!db_get_b(NULL, MODULENAME, "FirstRun", 1)) InitCheck(); StatusIconData sid = {}; - sid.szModule = szGPGModuleName; + sid.szModule = MODULENAME; sid.flags = MBF_HIDDEN; sid.dwId = 0x00000001; sid.hIcon = IcoLib_GetIcon("secured"); @@ -133,18 +137,18 @@ static int OnModulesLoaded(WPARAM, LPARAM) HookEvent(ME_MSG_WINDOWEVENT, onWindowEvent); HookEvent(ME_MSG_ICONPRESSED, onIconPressed); - Proto_RegisterModule(PROTOTYPE_ENCRYPTION, szGPGModuleName); + Proto_RegisterModule(PROTOTYPE_ENCRYPTION, MODULENAME); - CreateProtoServiceFunction(szGPGModuleName, PSR_MESSAGE, RecvMsgSvc); - CreateProtoServiceFunction(szGPGModuleName, PSS_MESSAGE, SendMsgSvc); - CreateProtoServiceFunction(szGPGModuleName, PSS_FILE, onSendFile); + CreateProtoServiceFunction(MODULENAME, PSR_MESSAGE, RecvMsgSvc); + CreateProtoServiceFunction(MODULENAME, PSS_MESSAGE, SendMsgSvc); + CreateProtoServiceFunction(MODULENAME, PSS_FILE, onSendFile); clean_temp_dir(); return 0; } extern "C" int __declspec(dllexport) Load() { - mir_getLP(&pluginInfo); + mir_getLP(&pluginInfoEx); HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); @@ -195,7 +199,7 @@ extern "C" int __declspec(dllexport) Load() InitIconLib(); - globals.g_hCLIcon = ExtraIcon_RegisterCallback(szGPGModuleName, Translate("GPG encryption status"), "secured", onExtraImageListRebuilding, onExtraImageApplying); + globals.g_hCLIcon = ExtraIcon_RegisterCallback(MODULENAME, Translate("GPG encryption status"), "secured", onExtraImageListRebuilding, onExtraImageApplying); return 0; } diff --git a/plugins/New_GPG/src/log.cpp b/plugins/New_GPG/src/log.cpp index c7d588d03d..598047b5c3 100755 --- a/plugins/New_GPG/src/log.cpp +++ b/plugins/New_GPG/src/log.cpp @@ -73,7 +73,7 @@ void logtofile::init() { if(path) mir_free(path); - path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szLogFilePath", L"C:\\GPGdebug.log"); + path = UniGetContactSettingUtf(NULL, 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 7b93bb6ea7..8975dcb35a 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -21,7 +21,7 @@ void FirstRun() { - if (!db_get_b(NULL, szGPGModuleName, "FirstRun", 1)) + if (!db_get_b(NULL, MODULENAME, "FirstRun", 1)) return; CDlgGpgBinOpts *d = new CDlgGpgBinOpts; d->Show(); @@ -31,13 +31,13 @@ void InitCheck() { { // parse gpg output - wchar_t *current_home = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); - db_set_ws(NULL, szGPGModuleName, "szHomePath", L""); //we do not need home for gpg binary validation + 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 globals.gpg_valid = isGPGValid(); - db_set_ws(NULL, szGPGModuleName, "szHomePath", current_home); //return current home dir back + db_set_ws(NULL, MODULENAME, "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, szGPGModuleName, "szHomePath", L""); + wchar_t *home_dir = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); std::wstring test_path = home_dir; mir_free(home_dir); test_path += L"/"; @@ -92,7 +92,7 @@ void InitCheck() if (result == pxNotFound) return; } - home_dir = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); + home_dir = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); wstring tmp_dir = home_dir; mir_free(home_dir); tmp_dir += L"\\tmp"; @@ -110,11 +110,11 @@ void InitCheck() acc += pa->szModuleName; acc += ")"; acc += "_KeyID"; - keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, acc.c_str(), ""); + keyid = UniGetContactSettingUtf(NULL, MODULENAME, acc.c_str(), ""); if (keyid[0]) { question = Translate("Your secret key with ID: "); mir_free(keyid); - keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); if ((p = out.find(keyid)) == string::npos) { question += keyid; question += Translate(" for account "); @@ -176,9 +176,9 @@ void InitCheck() } } question = Translate("Your secret key with ID: "); - keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); - char *key = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); - if (!db_get_b(NULL, szGPGModuleName, "FirstRun", 1) && (!keyid[0] || !key[0])) { + keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); + char *key = UniGetContactSettingUtf(NULL, MODULENAME, "GPGPubKey", ""); + if (!db_get_b(NULL, MODULENAME, "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) { @@ -241,7 +241,7 @@ void InitCheck() mir_free(key); } { - wchar_t *path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); + wchar_t *path = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); DWORD dwFileAttr = GetFileAttributes(path); if (dwFileAttr != INVALID_FILE_ATTRIBUTES) { dwFileAttr &= ~FILE_ATTRIBUTE_READONLY; @@ -285,27 +285,27 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) for (int i = 0; i < count; i++) { MCONTACT hcnt = db_mc_getSub(hContact, i); if (hcnt) - db_set_ws(hcnt, szGPGModuleName, "GPGPubKey", new_key.c_str()); + db_set_ws(hcnt, MODULENAME, "GPGPubKey", new_key.c_str()); } } - else db_set_ws(metaGetMostOnline(hContact), szGPGModuleName, "GPGPubKey", new_key.c_str()); + else db_set_ws(metaGetMostOnline(hContact), MODULENAME, "GPGPubKey", new_key.c_str()); } - else db_set_ws(hContact, szGPGModuleName, "GPGPubKey", new_key.c_str()); + else db_set_ws(hContact, MODULENAME, "GPGPubKey", new_key.c_str()); // gpg execute block std::vector<wstring> cmd; wchar_t tmp2[MAX_PATH] = { 0 }; { - wcsncpy(tmp2, ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")), MAX_PATH - 1); + wcsncpy(tmp2, ptrW(UniGetContactSettingUtf(NULL, 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), szGPGModuleName, "GPGPubKey", L""); + ptmp = UniGetContactSettingUtf(metaGetMostOnline(hContact), MODULENAME, "GPGPubKey", L""); else - ptmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", L""); + ptmp = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); wfstream f(tmp2, std::ios::out); f << ptmp.get(); @@ -336,7 +336,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) char *tmp = nullptr; string::size_type s = output.find("gpg: key ") + mir_strlen("gpg: key "); string::size_type s2 = output.find(":", s); - db_set_s(hcnt, szGPGModuleName, "KeyID", output.substr(s, s2 - s).c_str()); + db_set_s(hcnt, MODULENAME, "KeyID", output.substr(s, s2 - s).c_str()); s = output.find("“", s2); if (s == string::npos) { s = output.find("\"", s2); @@ -357,7 +357,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s - (uncommon ? 1 : 0)).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s - (uncommon ? 1 : 0)).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(hcnt, szGPGModuleName, "KeyMainName", tmp); + db_set_s(hcnt, MODULENAME, "KeyMainName", tmp); mir_free(tmp); } @@ -371,7 +371,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(hcnt, szGPGModuleName, "KeyComment", tmp); + db_set_s(hcnt, MODULENAME, "KeyComment", tmp); mir_free(tmp); s += 3; s2 = output.find(">", s); @@ -379,7 +379,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(hcnt, szGPGModuleName, "KeyMainEmail", tmp); + db_set_s(hcnt, MODULENAME, "KeyMainEmail", tmp); mir_free(tmp); } } @@ -387,11 +387,11 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s2, s - s2).c_str()); + db_set_s(hcnt, MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str()); mir_free(tmp); } } - db_unset(hcnt, szGPGModuleName, "bAlwatsTrust"); + db_unset(hcnt, MODULENAME, "bAlwatsTrust"); } } } @@ -399,7 +399,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) char *tmp = nullptr; string::size_type s = output.find("gpg: key ") + mir_strlen("gpg: key "); string::size_type s2 = output.find(":", s); - db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyID", output.substr(s, s2 - s).c_str()); + db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyID", output.substr(s, s2 - s).c_str()); s = output.find("“", s2); if (s == string::npos) { s = output.find("\"", s2); @@ -420,7 +420,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s - (uncommon ? 1 : 0)).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s - (uncommon ? 1 : 0)).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainName", tmp); + db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyMainName", tmp); mir_free(tmp); } if ((s = output.find(")", s2)) == string::npos) @@ -433,7 +433,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyComment", tmp); + db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyComment", tmp); mir_free(tmp); s += 3; s2 = output.find(">", s); @@ -441,7 +441,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", tmp); + db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyMainEmail", tmp); mir_free(tmp); } } @@ -449,18 +449,18 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2, s - s2).c_str()); + db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str()); mir_free(tmp); } } - db_unset(metaGetMostOnline(hContact), szGPGModuleName, "bAlwatsTrust"); + db_unset(metaGetMostOnline(hContact), MODULENAME, "bAlwatsTrust"); } } else { char *tmp = nullptr; string::size_type s = output.find("gpg: key ") + mir_strlen("gpg: key "); string::size_type s2 = output.find(":", s); - db_set_s(hContact, szGPGModuleName, "KeyID", output.substr(s, s2 - s).c_str()); + db_set_s(hContact, MODULENAME, "KeyID", output.substr(s, s2 - s).c_str()); s = output.find("“", s2); if (s == string::npos) { s = output.find("\"", s2); @@ -481,7 +481,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s - (uncommon ? 1 : 0)).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s - (uncommon ? 1 : 0)).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(hContact, szGPGModuleName, "KeyMainName", tmp); + db_set_s(hContact, MODULENAME, "KeyMainName", tmp); mir_free(tmp); } if ((s = output.find(")", s2)) == string::npos) @@ -494,7 +494,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(hContact, szGPGModuleName, "KeyComment", tmp); + db_set_s(hContact, MODULENAME, "KeyComment", tmp); mir_free(tmp); s += 3; s2 = output.find(">", s); @@ -502,7 +502,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(hContact, szGPGModuleName, "KeyMainEmail", tmp); + db_set_s(hContact, MODULENAME, "KeyMainEmail", tmp); mir_free(tmp); } } @@ -510,11 +510,11 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2, s - s2).c_str()); + db_set_s(hContact, MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str()); mir_free(tmp); } } - db_unset(hContact, szGPGModuleName, "bAlwatsTrust"); + db_unset(hContact, MODULENAME, "bAlwatsTrust"); } MessageBox(nullptr, toUTF16(output).c_str(), L"", MB_OK); diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index d4086b8f1a..4e8d4926e1 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -44,13 +44,13 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR } else { - db_set_b(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, szGPGModuleName, "GPGEncryption", 1); + db_set_b(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, MODULENAME, "GPGEncryption", 1); setSrmmIcon(hContact); setClistIcon(hContact); } if (isContactHaveKey(hContact)) { - db_set_b(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, szGPGModuleName, "GPGEncryption", 1); + db_set_b(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, MODULENAME, "GPGEncryption", 1); setSrmmIcon(hContact); setClistIcon(hContact); } @@ -66,7 +66,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR boost::algorithm::erase_all(str, "\r"); s2 += mir_wstrlen(L"-----END PGP MESSAGE-----"); - ptrW ptszHomePath(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")); + ptrW ptszHomePath(UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L"")); wstring encfile = toUTF16(get_random(10)); wstring decfile = toUTF16(get_random(10)); { @@ -88,7 +88,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR count += step; if(count >= timeout) { - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); setSrmmIcon(hContact); setClistIcon(hContact); globals.debuglog<<std::string(time_str() + "info: failed to create temporary file for decryption, disabling gpg for contact to avoid deadlock"); @@ -106,19 +106,19 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR std::vector<wstring> cmd; cmd.push_back(L"--batch"); { - char *inkeyid = UniGetContactSettingUtf(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, szGPGModuleName, "InKeyID", ""); + char *inkeyid = UniGetContactSettingUtf(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(NULL, szGPGModuleName, dbsetting.c_str(), L""); + pass = UniGetContactSettingUtf(NULL, 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, szGPGModuleName, "szKeyPassword", L""); + pass = UniGetContactSettingUtf(NULL, 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"); } @@ -163,11 +163,11 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR boost::filesystem::remove(path, e); } HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); + BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0); + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); + db_set_b(hContact, MODULENAME, "GPGEncryption", enc); return; } if (result == pxNotFound) @@ -201,18 +201,18 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR if (globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: failed to decrypt messaage from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " password needed, trying to get one"); if (globals._terminate) { - BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); + BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0); + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); + db_set_b(hContact, MODULENAME, "GPGEncryption", enc); break; } { //save inkey id string::size_type s = out.find(" encrypted with "); s = out.find(" ID ", s); s += mir_strlen(" ID "); - db_set_s(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, szGPGModuleName, "InKeyID", out.substr(s, out.find(",", s) - s).c_str()); + db_set_s(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, MODULENAME, "InKeyID", out.substr(s, out.find(",", s) - s).c_str()); } CDlgKeyPasswordMsgBox *d = new CDlgKeyPasswordMsgBox(hContact); @@ -241,11 +241,11 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR } HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); + BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0); + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); + db_set_b(hContact, MODULENAME, "GPGEncryption", enc); return; } if (result2 == pxNotFound) @@ -270,11 +270,11 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR } HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); + BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0); + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); + db_set_b(hContact, MODULENAME, "GPGEncryption", enc); return; } if (result == pxNotFound) @@ -303,11 +303,11 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR ptrA tmp4((char*)mir_alloc(sizeof(char)*(str1.length() + 1))); mir_strcpy(tmp4, str1.c_str()); HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); + BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0); + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); + db_set_b(hContact, MODULENAME, "GPGEncryption", enc); return; } @@ -346,11 +346,11 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR globals.debuglog << std::string(time_str() + ": info: Failed to decrypt GPG encrypted message."); HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); + BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0); + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); + db_set_b(hContact, MODULENAME, "GPGEncryption", enc); return; } @@ -368,7 +368,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR } } } - if (db_get_b(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, szGPGModuleName, "GPGEncryption", 0)) + if (db_get_b(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, MODULENAME, "GPGEncryption", 0)) { HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags | DBEF_READ)); return; @@ -413,14 +413,14 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) if (globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info(autoexchange): found pubkey block:" + toUTF8(Clist_GetContactDisplayName(ccs->hContact))); s2 += mir_wstrlen(L"-----END PGP PUBLIC KEY BLOCK-----"); - db_set_ws(ccs->hContact, szGPGModuleName, "GPGPubKey", str.substr(s1, s2 - s1).c_str()); + db_set_ws(ccs->hContact, MODULENAME, "GPGPubKey", str.substr(s1, s2 - s1).c_str()); { //gpg execute block std::vector<wstring> cmd; wchar_t tmp2[MAX_PATH] = { 0 }; string output; DWORD exitcode; { - ptrW ptmp(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")); + ptrW ptmp(UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L"")); mir_wstrcpy(tmp2, ptmp); mir_free(ptmp); mir_wstrcat(tmp2, L"\\"); @@ -444,7 +444,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) count += step; if(count >= timeout) { - db_set_b(ccs->hContact, szGPGModuleName, "GPGEncryption", 0); + db_set_b(ccs->hContact, MODULENAME, "GPGEncryption", 0); setSrmmIcon(ccs->hContact); setClistIcon(ccs->hContact); globals.debuglog<<std::string(time_str() + "info: failed to create temporary file for decryption, disabling gpg for contact to avoid deadlock"); @@ -453,7 +453,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) f.open(tmp2, std::ios::out); } } - ptmp = UniGetContactSettingUtf(ccs->hContact, szGPGModuleName, "GPGPubKey", L""); + ptmp = UniGetContactSettingUtf(ccs->hContact, MODULENAME, "GPGPubKey", L""); f << (wchar_t*)ptmp; f.close(); cmd.push_back(L"--batch"); @@ -483,7 +483,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) char *tmp = nullptr; s1 = output.find("gpg: key ") + mir_strlen("gpg: key "); s2 = output.find(":", s1); - db_set_s(ccs->hContact, szGPGModuleName, "KeyID", output.substr(s1, s2 - s1).c_str()); + db_set_s(ccs->hContact, MODULENAME, "KeyID", output.substr(s1, s2 - s1).c_str()); s2 += 2; s1 = output.find("“", s2); if (s1 == string::npos) @@ -500,7 +500,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) tmp = (char*)mir_alloc(output.substr(s1, s2 - s1 - 1).length() + 1); mir_strcpy(tmp, output.substr(s1, s2 - s1 - 1).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(ccs->hContact, szGPGModuleName, "KeyMainName", tmp); + db_set_s(ccs->hContact, MODULENAME, "KeyMainName", tmp); mir_free(tmp); if ((s1 = output.find(")", s2)) == string::npos) s1 = output.find(">", s2); @@ -512,14 +512,14 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) tmp = (char*)mir_alloc(output.substr(s2, s1 - s2).length() + 1); mir_strcpy(tmp, output.substr(s2, s1 - s2).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(ccs->hContact, szGPGModuleName, "KeyComment", tmp); + db_set_s(ccs->hContact, MODULENAME, "KeyComment", tmp); mir_free(tmp); s1 += 3; s2 = output.find(">", s1); tmp = (char*)mir_alloc(output.substr(s1, s2 - s1).length() + 1); mir_strcpy(tmp, output.substr(s1, s2 - s1).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(ccs->hContact, szGPGModuleName, "KeyMainEmail", tmp); + db_set_s(ccs->hContact, MODULENAME, "KeyMainEmail", tmp); mir_free(tmp); } else @@ -527,11 +527,11 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) tmp = (char*)mir_alloc(output.substr(s2, s1 - s2).length() + 1); mir_strcpy(tmp, output.substr(s2, s1 - s2).c_str()); mir_utf8decode(tmp, nullptr); - db_set_s(ccs->hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2, s1 - s2).c_str()); + db_set_s(ccs->hContact, MODULENAME, "KeyMainEmail", output.substr(s2, s1 - s2).c_str()); mir_free(tmp); } - db_set_b(ccs->hContact, szGPGModuleName, "GPGEncryption", 1); - db_set_b(ccs->hContact, szGPGModuleName, "bAlwatsTrust", 1); + db_set_b(ccs->hContact, MODULENAME, "GPGEncryption", 1); + db_set_b(ccs->hContact, MODULENAME, "bAlwatsTrust", 1); setSrmmIcon(ccs->hContact); setClistIcon(ccs->hContact); if (db_mc_isSub(ccs->hContact)) @@ -571,17 +571,17 @@ 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, szGPGModuleName, "GPGPubKey", "")); + ptrA tmp(UniGetContactSettingUtf(NULL, MODULENAME, "GPGPubKey", "")); if (tmp[0]) { - int enc_state = db_get_b(ccs->hContact, szGPGModuleName, "GPGEncryption", 0); + int enc_state = db_get_b(ccs->hContact, MODULENAME, "GPGEncryption", 0); if (enc_state) - db_set_b(ccs->hContact, szGPGModuleName, "GPGEncryption", 0); + db_set_b(ccs->hContact, MODULENAME, "GPGEncryption", 0); string str1 = "-----PGP KEY RESPONSE-----"; str1.append(tmp); ProtoChainSend(ccs->hContact, PSS_MESSAGE, 0, (LPARAM)str1.c_str()); if (enc_state) - db_set_b(ccs->hContact, szGPGModuleName, "GPGEncryption", 1); + db_set_b(ccs->hContact, MODULENAME, "GPGEncryption", 1); } return 0; } @@ -656,7 +656,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) { wchar_t *tmp2; { - char *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", ""); + char *tmp = UniGetContactSettingUtf(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)); @@ -669,7 +669,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) cmd.push_back(L"\"\""); cmd.push_back(L"--no-version"); } - if (db_get_b(hContact, szGPGModuleName, "bAlwaysTrust", 0)) { + if (db_get_b(hContact, MODULENAME, "bAlwaysTrust", 0)) { cmd.push_back(L"--trust-model"); cmd.push_back(L"always"); } @@ -683,7 +683,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) mir_free(tmp2); } { - wchar_t *tmp2 = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); + wchar_t *tmp2 = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); path = tmp2; cmd.push_back(std::wstring(tmp2) + L"\\tmp\\" + file); mir_free(tmp2); @@ -699,7 +699,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) count += step; if(count >= timeout) { - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); //disable encryption + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); //disable encryption setSrmmIcon(hContact); setClistIcon(hContact); globals.debuglog << std::string(time_str() + ": info: failed to create temporary file for encryption, disabling encryption to avoid deadlock"); @@ -735,7 +735,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) if (out.find("There is no assurance this key belongs to the named user") != string::npos) { out.clear(); if (MessageBox(nullptr, TranslateT("We're trying to encrypt with untrusted key. Do you want to trust this key permanently?"), TranslateT("Warning"), MB_YESNO) == IDYES) { - db_set_b(hContact, szGPGModuleName, "bAlwaysTrust", 1); + db_set_b(hContact, MODULENAME, "bAlwaysTrust", 1); std::vector<std::wstring> tmp; tmp.push_back(L"--trust-model"); tmp.push_back(L"always"); @@ -791,7 +791,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) count += step; if(count >= timeout) { - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); //disable encryption + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); //disable encryption setSrmmIcon(hContact); setClistIcon(hContact); globals.debuglog << std::string(time_str() + ": info: gpg failed to encrypt message, disabling encryption to avoid deadlock"); diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index 798b3a660c..650a703c05 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -70,32 +70,32 @@ public: list_USERLIST.SetItemText(row, 4, tmp); mir_free(tmp); - char *tmp2 = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", ""); + char *tmp2 = UniGetContactSettingUtf(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, szGPGModuleName, "KeyMainName", ""); + tmp2 = UniGetContactSettingUtf(hContact, MODULENAME, "KeyMainName", ""); if (!toUTF16(tmp2).empty()) tmp = mir_wstrdup(toUTF16(tmp2).c_str()); else - tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyMainName", L""); + tmp = UniGetContactSettingUtf(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, szGPGModuleName, "KeyMainEmail", ""); + tmp2 = UniGetContactSettingUtf(hContact, MODULENAME, "KeyMainEmail", ""); if (!toUTF16(tmp2).empty()) tmp = mir_wstrdup(toUTF16(tmp2).c_str()); else - tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyMainEmail", L""); + tmp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyMainEmail", L""); mir_free(tmp2); list_USERLIST.SetItemText(row, 3, (mir_wstrlen(tmp) > 1) ? tmp : L"not set"); mir_free(tmp); - if (db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0)) + if (db_get_b(hContact, MODULENAME, "GPGEncryption", 0)) list_USERLIST.SetCheckState(row, 1); user_data[i] = hContact; list_USERLIST.SetColumnWidth(0, LVSCW_AUTOSIZE); @@ -106,23 +106,23 @@ public: i++; } } - edit_LOG_FILE_EDIT.SetText(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szLogFilePath", L""))); + edit_LOG_FILE_EDIT.SetText(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szLogFilePath", L""))); - check_DEBUG_LOG.SetState(db_get_b(NULL, szGPGModuleName, "bDebugLog", 0)); + check_DEBUG_LOG.SetState(db_get_b(NULL, MODULENAME, "bDebugLog", 0)); check_JABBER_API.Enable(); check_AUTO_EXCHANGE.Enable(globals.bJabberAPI); { string keyinfo = Translate("Default private key ID"); keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + char *keyid = UniGetContactSettingUtf(NULL, 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, szGPGModuleName, "bJabberAPI", 1)); - check_FILE_TRANSFERS.SetState(db_get_b(NULL, szGPGModuleName, "bFileTransfers", 0)); - check_AUTO_EXCHANGE.SetState(db_get_b(NULL, szGPGModuleName, "bAutoExchange", 0)); + 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)); //TODO: get rid of following s..t //////////////// @@ -135,19 +135,19 @@ public: virtual void OnApply() override { - db_set_b(NULL, szGPGModuleName, "bDebugLog", globals.bDebugLog = check_DEBUG_LOG.GetState()); + db_set_b(NULL, MODULENAME, "bDebugLog", globals.bDebugLog = check_DEBUG_LOG.GetState()); if (globals.bDebugLog) globals.debuglog.init(); - db_set_b(NULL, szGPGModuleName, "bJabberAPI", globals.bJabberAPI = check_JABBER_API.GetState()); - bool old_bFileTransfers = db_get_b(NULL, szGPGModuleName, "bFileTransfers", 0) != 0; - db_set_b(NULL, szGPGModuleName, "bFileTransfers", globals.bFileTransfers = check_FILE_TRANSFERS.GetState()); + 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()); if (globals.bFileTransfers != old_bFileTransfers) { - db_set_b(NULL, szGPGModuleName, "bSameAction", 0); + db_set_b(NULL, MODULENAME, "bSameAction", 0); globals.bSameAction = false; } - db_set_b(NULL, szGPGModuleName, "bAutoExchange", globals.bAutoExchange = check_AUTO_EXCHANGE.GetState()); - db_set_ws(NULL, szGPGModuleName, "szLogFilePath", ptrW(edit_LOG_FILE_EDIT.GetText())); + db_set_b(NULL, MODULENAME, "bAutoExchange", globals.bAutoExchange = check_AUTO_EXCHANGE.GetState()); + db_set_ws(NULL, MODULENAME, "szLogFilePath", ptrW(edit_LOG_FILE_EDIT.GetText())); } void onClick_DELETE_KEY_BUTTON(CCtrlButton*) @@ -170,10 +170,10 @@ public: hContact = metaGetMostOnline(meta); ismetacontact = true; } - tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", ""); + tmp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyID", ""); for (auto &hcnttmp : Contacts()) { if (hcnttmp != hContact) { - char *tmp2 = UniGetContactSettingUtf(hcnttmp, szGPGModuleName, "KeyID", ""); + char *tmp2 = UniGetContactSettingUtf(hcnttmp, MODULENAME, "KeyID", ""); if (!mir_strcmp(tmp, tmp2)) { mir_free(tmp2); keep = true; @@ -219,35 +219,35 @@ public: for (int i = 0; i < count; i++) { hcnt = db_mc_getSub(meta, i); if (hcnt) { - db_unset(hcnt, szGPGModuleName, "KeyID"); - db_unset(hcnt, szGPGModuleName, "GPGPubKey"); - db_unset(hcnt, szGPGModuleName, "KeyMainName"); - db_unset(hcnt, szGPGModuleName, "KeyType"); - db_unset(hcnt, szGPGModuleName, "KeyMainEmail"); - db_unset(hcnt, szGPGModuleName, "KeyComment"); + db_unset(hcnt, MODULENAME, "KeyID"); + db_unset(hcnt, MODULENAME, "GPGPubKey"); + db_unset(hcnt, MODULENAME, "KeyMainName"); + db_unset(hcnt, MODULENAME, "KeyType"); + db_unset(hcnt, MODULENAME, "KeyMainEmail"); + db_unset(hcnt, MODULENAME, "KeyComment"); setClistIcon(hcnt); setSrmmIcon(hcnt); } } } else { - db_unset(hContact, szGPGModuleName, "KeyID"); - db_unset(hContact, szGPGModuleName, "GPGPubKey"); - db_unset(hContact, szGPGModuleName, "KeyMainName"); - db_unset(hContact, szGPGModuleName, "KeyType"); - db_unset(hContact, szGPGModuleName, "KeyMainEmail"); - db_unset(hContact, szGPGModuleName, "KeyComment"); + db_unset(hContact, MODULENAME, "KeyID"); + db_unset(hContact, MODULENAME, "GPGPubKey"); + db_unset(hContact, MODULENAME, "KeyMainName"); + db_unset(hContact, MODULENAME, "KeyType"); + db_unset(hContact, MODULENAME, "KeyMainEmail"); + db_unset(hContact, MODULENAME, "KeyComment"); setClistIcon(hContact); setSrmmIcon(hContact); } } else { - db_unset(user_data[item_num + 1], szGPGModuleName, "KeyID"); - db_unset(user_data[item_num + 1], szGPGModuleName, "GPGPubKey"); - db_unset(user_data[item_num + 1], szGPGModuleName, "KeyMainName"); - db_unset(user_data[item_num + 1], szGPGModuleName, "KeyType"); - db_unset(user_data[item_num + 1], szGPGModuleName, "KeyMainEmail"); - db_unset(user_data[item_num + 1], szGPGModuleName, "KeyComment"); + db_unset(user_data[item_num + 1], MODULENAME, "KeyID"); + db_unset(user_data[item_num + 1], MODULENAME, "GPGPubKey"); + db_unset(user_data[item_num + 1], MODULENAME, "KeyMainName"); + db_unset(user_data[item_num + 1], MODULENAME, "KeyType"); + db_unset(user_data[item_num + 1], MODULENAME, "KeyMainEmail"); + db_unset(user_data[item_num + 1], MODULENAME, "KeyComment"); setClistIcon(user_data[item_num + 1]); setSrmmIcon(user_data[item_num + 1]); } @@ -267,7 +267,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], szGPGModuleName, "GPGPubKey", L""))); + wstring str(ptrW(UniGetContactSettingUtf(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); @@ -282,7 +282,7 @@ public: void onClick_COPY_KEY(CCtrlButton*) { if (OpenClipboard(m_hwnd)) { - char *szKey = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); + char *szKey = UniGetContactSettingUtf(NULL, MODULENAME, "GPGPubKey", ""); std::string str = szKey; mir_free(szKey); boost::algorithm::replace_all(str, "\n", "\r\n"); @@ -343,9 +343,9 @@ public: void setSrmmIcon(MCONTACT hContact); item_num = hdr->iItem; if (list_USERLIST.GetCheckState(hdr->iItem)) - db_set_b(user_data[item_num + 1], szGPGModuleName, "GPGEncryption", 1); + db_set_b(user_data[item_num + 1], MODULENAME, "GPGEncryption", 1); else - db_set_b(user_data[item_num + 1], szGPGModuleName, "GPGEncryption", 0); + db_set_b(user_data[item_num + 1], MODULENAME, "GPGEncryption", 0); setClistIcon(user_data[item_num + 1]); setSrmmIcon(user_data[item_num + 1]); } @@ -384,24 +384,24 @@ public: virtual void OnInitDialog() override { - edit_BIN_PATH.SetText(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L"gpg.exe"))); - edit_HOME_DIR.SetText(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"gpg"))); + edit_BIN_PATH.SetText(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szGpgBinPath", L"gpg.exe"))); + edit_HOME_DIR.SetText(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L"gpg"))); } virtual void OnApply() override { wchar_t tmp[8192]; - db_set_ws(NULL, szGPGModuleName, "szGpgBinPath", edit_BIN_PATH.GetText()); + db_set_ws(NULL, MODULENAME, "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, szGPGModuleName, "szHomePath", tmp); + db_set_ws(NULL, MODULENAME, "szHomePath", tmp); } void onClick_SET_BIN_PATH(CCtrlButton*) { GetFilePath(TranslateT("Choose gpg.exe"), "szGpgBinPath", L"*.exe", TranslateT("EXE Executables")); - CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L"gpg.exe"))); + CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szGpgBinPath", L"gpg.exe"))); edit_BIN_PATH.SetText(tmp); bool gpg_exists = false; { @@ -409,8 +409,8 @@ public: gpg_exists = true; if (gpg_exists) { bool bad_version = false; - wchar_t *tmp_path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L""); - db_set_ws(NULL, szGPGModuleName, "szGpgBinPath", tmp); + wchar_t *tmp_path = UniGetContactSettingUtf(NULL, MODULENAME, "szGpgBinPath", L""); + db_set_ws(NULL, MODULENAME, "szGpgBinPath", tmp); string out; DWORD code; std::vector<wstring> cmd; @@ -424,7 +424,7 @@ public: globals.gpg_valid = true; gpg_launcher(params); globals.gpg_valid = old_gpg_state; - db_set_ws(NULL, szGPGModuleName, "szGpgBinPath", tmp_path); + db_set_ws(NULL, MODULENAME, "szGpgBinPath", tmp_path); mir_free(tmp_path); string::size_type p1 = out.find("(GnuPG) "); if (p1 != string::npos) { @@ -451,7 +451,7 @@ public: void onClick_SET_HOME_DIR(CCtrlButton*) { GetFolderPath(TranslateT("Set home directory"), "szHomePath"); - CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""))); + CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""))); edit_HOME_DIR.SetText(tmp); wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -475,33 +475,33 @@ public: virtual void OnInitDialog() override { - check_APPEND_TAGS.SetState(db_get_b(NULL, szGPGModuleName, "bAppendTags", 0)); - check_STRIP_TAGS.SetState(db_get_b(NULL, szGPGModuleName, "bStripTags", 0)); - edit_IN_OPEN_TAG.SetText(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szInOpenTag", L"<GPGdec>"))); - edit_IN_CLOSE_TAG.SetText(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szInCloseTag", L"</GPGdec>"))); - edit_OUT_OPEN_TAG.SetText(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szOutOpenTag", L"<GPGenc>"))); - edit_OUT_CLOSE_TAG.SetText(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szOutCloseTag", L"</GPGenc>"))); + 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>"))); } virtual void OnApply() override { - db_set_b(NULL, szGPGModuleName, "bAppendTags", globals.bAppendTags = check_APPEND_TAGS.GetState()); - db_set_b(NULL, szGPGModuleName, "bStripTags", globals.bStripTags = check_STRIP_TAGS.GetState()); + db_set_b(NULL, MODULENAME, "bAppendTags", globals.bAppendTags = check_APPEND_TAGS.GetState()); + db_set_b(NULL, MODULENAME, "bStripTags", globals.bStripTags = check_STRIP_TAGS.GetState()); { wchar_t *tmp = mir_wstrdup(edit_IN_OPEN_TAG.GetText()); - db_set_ws(NULL, szGPGModuleName, "szInOpenTag", tmp); + db_set_ws(NULL, MODULENAME, "szInOpenTag", tmp); mir_free(globals.inopentag); globals.inopentag = tmp; tmp = mir_wstrdup(edit_IN_CLOSE_TAG.GetText()); - db_set_ws(NULL, szGPGModuleName, "szInCloseTag", tmp); + db_set_ws(NULL, MODULENAME, "szInCloseTag", tmp); mir_free(globals.inclosetag); globals.inclosetag = tmp; tmp = mir_wstrdup(edit_OUT_OPEN_TAG.GetText()); - db_set_ws(NULL, szGPGModuleName, "szOutOpenTag", tmp); + db_set_ws(NULL, MODULENAME, "szOutOpenTag", tmp); mir_free(globals.outopentag); globals.outopentag = tmp; tmp = mir_wstrdup(edit_OUT_CLOSE_TAG.GetText()); - db_set_ws(NULL, szGPGModuleName, "szOutCloseTag", tmp); + db_set_ws(NULL, MODULENAME, "szOutCloseTag", tmp); mir_free(globals.outclosetag); globals.outclosetag = tmp; } @@ -524,13 +524,13 @@ public: virtual void OnInitDialog() override { - check_PRESCENSE_SUBSCRIPTION.SetState(db_get_b(NULL, szGPGModuleName, "bPresenceSigning", 0)); + check_PRESCENSE_SUBSCRIPTION.SetState(db_get_b(NULL, MODULENAME, "bPresenceSigning", 0)); check_PRESCENSE_SUBSCRIPTION.Enable(globals.bJabberAPI); } virtual void OnApply() override { - db_set_b(NULL, szGPGModuleName, "bPresenceSigning", globals.bPresenceSigning = check_PRESCENSE_SUBSCRIPTION.GetState()); + db_set_b(NULL, MODULENAME, "bPresenceSigning", globals.bPresenceSigning = check_PRESCENSE_SUBSCRIPTION.GetState()); } void onClick_EXPORT(CCtrlButton*) @@ -603,7 +603,7 @@ public: chk_ENABLE_ENCRYPTION.SetState(1); } if (hcnt) { - wchar_t *tmp = UniGetContactSettingUtf(hcnt, szGPGModuleName, "GPGPubKey", L""); + wchar_t *tmp = UniGetContactSettingUtf(hcnt, MODULENAME, "GPGPubKey", L""); wstring str = tmp; mir_free(tmp); tmp = nullptr; if (!str.empty()) { @@ -618,9 +618,9 @@ public: } } } - // char *tmp = UniGetContactSettingUtf(hcnt, szGPGModuleName, "KeyID_Prescense", ""); + // char *tmp = UniGetContactSettingUtf(hcnt, MODULENAME, "KeyID_Prescense", ""); if (!globals.hcontact_data[hcnt].key_in_prescense.empty()) { - char *tmp2 = UniGetContactSettingUtf(hcnt, szGPGModuleName, "KeyID", ""); + char *tmp2 = UniGetContactSettingUtf(hcnt, MODULENAME, "KeyID", ""); if (!tmp2[0]) { string out; DWORD code; @@ -668,8 +668,8 @@ public: virtual void OnDestroy() override { GetWindowRect(m_hwnd, &globals.load_key_rect); - db_set_dw(NULL, szGPGModuleName, "LoadKeyWindowX", globals.load_key_rect.left); - db_set_dw(NULL, szGPGModuleName, "LoadKeyWindowY", globals.load_key_rect.top); + db_set_dw(NULL, MODULENAME, "LoadKeyWindowX", globals.load_key_rect.left); + db_set_dw(NULL, MODULENAME, "LoadKeyWindowY", globals.load_key_rect.top); edit_p_PubKeyEdit = nullptr; } @@ -716,12 +716,12 @@ public: for (int i = 0; i < count; i++) { MCONTACT hcnt = db_mc_getSub(hContact, i); if (hcnt) - db_set_ws(hcnt, szGPGModuleName, "GPGPubKey", key_buf.substr(ws1, ws2 - ws1).c_str()); + db_set_ws(hcnt, MODULENAME, "GPGPubKey", key_buf.substr(ws1, ws2 - ws1).c_str()); } } - else db_set_ws(metaGetMostOnline(hContact), szGPGModuleName, "GPGPubKey", key_buf.substr(ws1, ws2 - ws1).c_str()); + else db_set_ws(metaGetMostOnline(hContact), MODULENAME, "GPGPubKey", key_buf.substr(ws1, ws2 - ws1).c_str()); } - else db_set_ws(hContact, szGPGModuleName, "GPGPubKey", key_buf.substr(ws1, ws2 - ws1).c_str()); + else db_set_ws(hContact, MODULENAME, "GPGPubKey", key_buf.substr(ws1, ws2 - ws1).c_str()); } tmp = (wchar_t*)mir_alloc(sizeof(wchar_t) * (key_buf.length() + 1)); mir_wstrcpy(tmp, key_buf.substr(ws1, ws2 - ws1).c_str()); @@ -733,14 +733,14 @@ public: DWORD exitcode; { MCONTACT hcnt = db_mc_tryMeta(hContact); - ptmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); + ptmp = UniGetContactSettingUtf(NULL, 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, szGPGModuleName, "GPGPubKey", L""); + ptmp = UniGetContactSettingUtf(hcnt, MODULENAME, "GPGPubKey", L""); wstring str = ptmp; mir_free(ptmp); wstring::size_type s = 0; @@ -771,12 +771,12 @@ public: for (int i = 0; i < count; i++) { MCONTACT hcnt = db_mc_getSub(hContact, i); if (hcnt) - db_unset(hcnt, szGPGModuleName, "bAlwatsTrust"); + db_unset(hcnt, MODULENAME, "bAlwatsTrust"); } } - else db_unset(metaGetMostOnline(hContact), szGPGModuleName, "bAlwatsTrust"); + else db_unset(metaGetMostOnline(hContact), MODULENAME, "bAlwatsTrust"); } - else db_unset(hContact, szGPGModuleName, "bAlwatsTrust"); + else db_unset(hContact, MODULENAME, "bAlwatsTrust"); } { if (output.find("already in secret keyring") != string::npos) { @@ -797,14 +797,14 @@ public: for (int i = 0; i < count; i++) { MCONTACT hcnt = db_mc_getSub(hContact, i); if (hcnt) - db_set_s(hcnt, szGPGModuleName, "KeyID", tmp3); + db_set_s(hcnt, MODULENAME, "KeyID", tmp3); } } else - db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyID", tmp3); + db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyID", tmp3); } else - db_set_s(hContact, szGPGModuleName, "KeyID", tmp3); + db_set_s(hContact, MODULENAME, "KeyID", tmp3); } mir_free(tmp3); } @@ -840,12 +840,12 @@ public: for (int i = 0; i < count; i++) { MCONTACT hcnt = db_mc_getSub(hContact, i); if (hcnt) - db_set_s(hcnt, szGPGModuleName, "KeyMainName", output.substr(s, s2 - s - 1).c_str()); + db_set_s(hcnt, MODULENAME, "KeyMainName", output.substr(s, s2 - s - 1).c_str()); } } - else db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainName", output.substr(s, s2 - s - 1).c_str()); + else db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyMainName", output.substr(s, s2 - s - 1).c_str()); } - else db_set_s(hContact, szGPGModuleName, "KeyMainName", output.substr(s, s2 - s - 1).c_str()); + else db_set_s(hContact, MODULENAME, "KeyMainName", output.substr(s, s2 - s - 1).c_str()); } mir_free(tmp3); } @@ -870,12 +870,12 @@ public: for (int i = 0; i < count; i++) { MCONTACT hcnt = db_mc_getSub(hContact, i); if (hcnt) - db_set_s(hcnt, szGPGModuleName, "KeyComment", output.substr(s2, s - s2).c_str()); + db_set_s(hcnt, MODULENAME, "KeyComment", output.substr(s2, s - s2).c_str()); } } - else db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyComment", output.substr(s2, s - s2).c_str()); + else db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyComment", output.substr(s2, s - s2).c_str()); } - else db_set_s(hContact, szGPGModuleName, "KeyComment", output.substr(s2, s - s2).c_str()); + else db_set_s(hContact, MODULENAME, "KeyComment", output.substr(s2, s - s2).c_str()); } mir_free(tmp3); s += 3; @@ -890,12 +890,12 @@ public: for (int i = 0; i < count; i++) { MCONTACT hcnt = db_mc_getSub(hContact, i); if (hcnt) - db_set_s(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s, s2 - s).c_str()); + db_set_s(hcnt, MODULENAME, "KeyMainEmail", output.substr(s, s2 - s).c_str()); } } - else db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s, s2 - s).c_str()); + else db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyMainEmail", output.substr(s, s2 - s).c_str()); } - else db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s, s2 - s).c_str()); + else db_set_s(hContact, MODULENAME, "KeyMainEmail", output.substr(s, s2 - s).c_str()); } mir_free(tmp3); tmp = mir_wstrdup(toUTF16(output.substr(s, s2 - s)).c_str()); @@ -914,12 +914,12 @@ public: for (int i = 0; i < count; i++) { MCONTACT hcnt = db_mc_getSub(hContact, i); if (hcnt) - db_set_s(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s2, s - s2).c_str()); + db_set_s(hcnt, MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str()); } } - else db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2, s - s2).c_str()); + else db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str()); } - else db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2, s - s2).c_str()); + else db_set_s(hContact, MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str()); } mir_free(tmp3); tmp = mir_wstrdup(toUTF16(output.substr(s2, s - s2)).c_str()); @@ -938,7 +938,7 @@ public: } } if (!hContact) { - wchar_t *fp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", L""); + wchar_t *fp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyID", L""); { string out; DWORD code; @@ -961,7 +961,7 @@ public: while ((s = out.find("\r", s)) != string::npos) { out.erase(s, 1); } - db_set_s(hContact, szGPGModuleName, "GPGPubKey", out.c_str()); + db_set_s(hContact, MODULENAME, "GPGPubKey", out.c_str()); } } tmp = mir_wstrdup(toUTF16(output).c_str()); @@ -979,23 +979,23 @@ public: MCONTACT hcnt = db_mc_getSub(hContact, i); if (hcnt) { if (!isContactSecured(hcnt)) - db_set_b(hcnt, szGPGModuleName, "GPGEncryption", 1); + db_set_b(hcnt, MODULENAME, "GPGEncryption", 1); else - db_set_b(hcnt, szGPGModuleName, "GPGEncryption", 0); + db_set_b(hcnt, MODULENAME, "GPGEncryption", 0); setSrmmIcon(hContact); setClistIcon(hContact); } } } else if (!isContactSecured(hContact)) - db_set_b(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 1); + db_set_b(metaGetMostOnline(hContact), MODULENAME, "GPGEncryption", 1); else - db_set_b(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0); + db_set_b(metaGetMostOnline(hContact), MODULENAME, "GPGEncryption", 0); } else if (!isContactSecured(hContact)) - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 1); + db_set_b(hContact, MODULENAME, "GPGEncryption", 1); else - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); } } this->Close(); @@ -1064,7 +1064,7 @@ int GpgOptInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = {}; odp.szGroup.w = LPGENW("Services"); - odp.szTitle.w = _T(szGPGModuleName); + odp.szTitle.w = _T(MODULENAME); odp.szTab.w = LPGENW("Main"); odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE; diff --git a/plugins/New_GPG/src/srmm.cpp b/plugins/New_GPG/src/srmm.cpp index 0cfa907931..d9e8187c7a 100755 --- a/plugins/New_GPG/src/srmm.cpp +++ b/plugins/New_GPG/src/srmm.cpp @@ -42,14 +42,14 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) else if(db_mc_isSub(hContact)) hMeta = db_mc_getMeta(hContact); StatusIconClickData *sicd = (StatusIconClickData *)lParam; - if(mir_strcmp(sicd->szModule, szGPGModuleName)) + if(mir_strcmp(sicd->szModule, MODULENAME)) return 0; // not our event - BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); + BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0); if(enc) { - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - hMeta?db_set_b(hMeta, szGPGModuleName, "GPGEncryption", 0):0; + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); + hMeta?db_set_b(hMeta, MODULENAME, "GPGEncryption", 0):0; setSrmmIcon(hContact); setClistIcon(hContact); } @@ -64,16 +64,16 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) } else { - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 1); - hMeta?db_set_b(hMeta, szGPGModuleName, "GPGEncryption", 1):0; + db_set_b(hContact, MODULENAME, "GPGEncryption", 1); + hMeta?db_set_b(hMeta, MODULENAME, "GPGEncryption", 1):0; setSrmmIcon(hContact); setClistIcon(hContact); return 0; } if(isContactHaveKey(hContact)) { - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 1); - hMeta?db_set_b(hMeta, szGPGModuleName, "GPGEncryption", 1):0; + db_set_b(hContact, MODULENAME, "GPGEncryption", 1); + hMeta?db_set_b(hMeta, MODULENAME, "GPGEncryption", 1):0; setSrmmIcon(hContact); setClistIcon(hContact); } diff --git a/plugins/New_GPG/src/stdafx.h b/plugins/New_GPG/src/stdafx.h index 2353feb602..77b649545a 100755 --- a/plugins/New_GPG/src/stdafx.h +++ b/plugins/New_GPG/src/stdafx.h @@ -89,9 +89,7 @@ using std::fstream; struct CMPlugin : public PLUGIN<CMPlugin> { - CMPlugin() : - PLUGIN<CMPlugin>(szGPGModuleName) - {} + CMPlugin(); }; #endif diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp index 17699e40e6..69216fcb5a 100755 --- a/plugins/New_GPG/src/ui.cpp +++ b/plugins/New_GPG/src/ui.cpp @@ -40,7 +40,7 @@ void CDlgEncryptedFileMsgBox::onClick_IGNORE(CCtrlButton*) { if (chk_REMEMBER.GetState()) { - db_set_b(NULL, szGPGModuleName, "bSameAction", 1); + db_set_b(NULL, MODULENAME, "bSameAction", 1); globals.bSameAction = true; } this->Close(); @@ -51,9 +51,9 @@ void CDlgEncryptedFileMsgBox::onClick_DECRYPT(CCtrlButton*) globals.bDecryptFiles = true; if (chk_REMEMBER.GetState()) { - db_set_b(NULL, szGPGModuleName, "bFileTransfers", 1); + db_set_b(NULL, MODULENAME, "bFileTransfers", 1); globals.bFileTransfers = true; - db_set_b(NULL, szGPGModuleName, "bSameAction", 0); + db_set_b(NULL, MODULENAME, "bSameAction", 0); globals.bSameAction = false; } this->Close(); @@ -110,7 +110,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, szGPGModuleName, "szKeyPassword", L""); + wchar_t *pass = UniGetContactSettingUtf(NULL, MODULENAME, "szKeyPassword", L""); if (!mir_wstrcmp(pass, edit_OLD_PASSWD.GetText())) old_pass_match = true; mir_free(pass); @@ -120,7 +120,7 @@ void CDlgChangePasswdMsgBox::onClick_OK(CCtrlButton*) string dbsetting = "szKey_"; dbsetting += toUTF8(globals.key_id_global); dbsetting += "_Password"; - pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), L""); + pass = UniGetContactSettingUtf(NULL, MODULENAME, dbsetting.c_str(), L""); if (!mir_wstrcmp(pass, edit_OLD_PASSWD.GetText())) old_pass_match = true; mir_free(pass); @@ -217,7 +217,7 @@ void CDlgFirstRun::OnInitDialog() combo_ACCOUNT.SelectString(TranslateT("Default")); string keyinfo = Translate("key ID"); keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + char *keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_KEY_ID.SetTextA(keyinfo.c_str()); @@ -424,32 +424,32 @@ void CDlgFirstRun::onClick_DELETE_KEY(CCtrlButton*) { char *buf = mir_strdup(combo_ACCOUNT.GetTextA()); if (!mir_strcmp(buf, Translate("Default"))) { - db_unset(NULL, szGPGModuleName, "GPGPubKey"); - db_unset(NULL, szGPGModuleName, "KeyID"); - db_unset(NULL, szGPGModuleName, "KeyComment"); - db_unset(NULL, szGPGModuleName, "KeyMainName"); - db_unset(NULL, szGPGModuleName, "KeyMainEmail"); - db_unset(NULL, szGPGModuleName, "KeyType"); + 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"); } else { std::string acc_str = buf; acc_str += "_GPGPubKey"; - db_unset(NULL, szGPGModuleName, acc_str.c_str()); + db_unset(NULL, MODULENAME, acc_str.c_str()); acc_str = buf; acc_str += "_KeyMainName"; - db_unset(NULL, szGPGModuleName, acc_str.c_str()); + db_unset(NULL, MODULENAME, acc_str.c_str()); acc_str = buf; acc_str += "_KeyID"; - db_unset(NULL, szGPGModuleName, acc_str.c_str()); + db_unset(NULL, MODULENAME, acc_str.c_str()); acc_str = buf; acc_str += "_KeyComment"; - db_unset(NULL, szGPGModuleName, acc_str.c_str()); + db_unset(NULL, MODULENAME, acc_str.c_str()); acc_str = buf; acc_str += "_KeyMainEmail"; - db_unset(NULL, szGPGModuleName, acc_str.c_str()); + db_unset(NULL, MODULENAME, acc_str.c_str()); acc_str = buf; acc_str += "_KeyType"; - db_unset(NULL, szGPGModuleName, acc_str.c_str()); + db_unset(NULL, MODULENAME, acc_str.c_str()); } if (buf) mir_free(buf); @@ -500,20 +500,20 @@ void CDlgFirstRun::onClick_OK(CCtrlButton*) { char *buf = mir_strdup(combo_ACCOUNT.GetTextA()); if (!mir_strcmp(buf, Translate("Default"))) { - db_set_s(NULL, szGPGModuleName, "GPGPubKey", out.c_str()); - db_set_ws(NULL, szGPGModuleName, "KeyMainName", name); - db_set_ws(NULL, szGPGModuleName, "KeyID", fp); + db_set_s(NULL, MODULENAME, "GPGPubKey", out.c_str()); + db_set_ws(NULL, MODULENAME, "KeyMainName", name); + db_set_ws(NULL, MODULENAME, "KeyID", fp); } else { std::string acc_str = buf; acc_str += "_GPGPubKey"; - db_set_s(NULL, szGPGModuleName, acc_str.c_str(), out.c_str()); + db_set_s(NULL, MODULENAME, acc_str.c_str(), out.c_str()); acc_str = buf; acc_str += "_KeyMainName"; - db_set_ws(NULL, szGPGModuleName, acc_str.c_str(), name); + db_set_ws(NULL, MODULENAME, acc_str.c_str(), name); acc_str = buf; acc_str += "_KeyID"; - db_set_ws(NULL, szGPGModuleName, acc_str.c_str(), fp); + db_set_ws(NULL, MODULENAME, acc_str.c_str(), fp); } if (!mir_strcmp(buf, Translate("Default"))) { wstring keyinfo = TranslateT("Default private key ID"); @@ -533,7 +533,7 @@ void CDlgFirstRun::onClick_OK(CCtrlButton*) dbsetting += keyid; mir_free(keyid); dbsetting += "_Password"; - db_set_ws(NULL, szGPGModuleName, dbsetting.c_str(), passwd); + db_set_ws(NULL, MODULENAME, dbsetting.c_str(), passwd); } mir_free(passwd); delete[] name; @@ -549,7 +549,7 @@ void CDlgFirstRun::onChange_ACCOUNT(CCtrlCombo*) if (!mir_strcmp(buf, Translate("Default"))) { string keyinfo = Translate("key ID"); keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + char *keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_KEY_ID.SetTextA(keyinfo.c_str()); @@ -559,7 +559,7 @@ void CDlgFirstRun::onChange_ACCOUNT(CCtrlCombo*) keyinfo += ": "; std::string acc_str = buf; acc_str += "_KeyID"; - char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, acc_str.c_str(), ""); + char *keyid = UniGetContactSettingUtf(NULL, MODULENAME, acc_str.c_str(), ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_KEY_ID.SetTextA(keyinfo.c_str()); @@ -584,8 +584,8 @@ void CDlgFirstRun::onChange_KEY_LIST(CCtrlListView::TEventInfo *ev) //TODO: chec void CDlgFirstRun::OnDestroy() { GetWindowRect(m_hwnd, &globals.firstrun_rect); - db_set_dw(NULL, szGPGModuleName, "FirstrunWindowX", globals.firstrun_rect.left); - db_set_dw(NULL, szGPGModuleName, "FirstrunWindowY", globals.firstrun_rect.top); + db_set_dw(NULL, MODULENAME, "FirstrunWindowX", globals.firstrun_rect.left); + db_set_dw(NULL, MODULENAME, "FirstrunWindowY", globals.firstrun_rect.top); } @@ -710,7 +710,7 @@ void CDlgFirstRun::refresh_key_list() setting += pa->szModuleName; setting += ")"; setting += "_KeyID"; - wchar_t *str = UniGetContactSettingUtf(NULL, szGPGModuleName, setting.c_str(), L""); + wchar_t *str = UniGetContactSettingUtf(NULL, MODULENAME, setting.c_str(), L""); if (key_id == str) { if (!accs.empty()) accs += L","; @@ -772,7 +772,7 @@ void CDlgGpgBinOpts::OnInitDialog() { ptrW tmp; if (!gpg_exists) { - tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "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(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""); 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); @@ -781,7 +781,7 @@ void CDlgGpgBinOpts::OnInitDialog() edit_BIN_PATH.SetText(tmp); if (gpg_exists/* && lang_exists*/) { - db_set_ws(NULL, szGPGModuleName, "szGpgBinPath", tmp); + db_set_ws(NULL, MODULENAME, "szGpgBinPath", tmp); string out; DWORD code; std::vector<wstring> cmd; @@ -795,7 +795,7 @@ void CDlgGpgBinOpts::OnInitDialog() globals.gpg_valid = true; gpg_launcher(params); globals.gpg_valid = _gpg_valid; //TODO: check this - db_unset(NULL, szGPGModuleName, "szGpgBinPath"); + db_unset(NULL, MODULENAME, "szGpgBinPath"); string::size_type p1 = out.find("(GnuPG) "); if (p1 != string::npos) { p1 += mir_strlen("(GnuPG) "); @@ -811,7 +811,7 @@ void CDlgGpgBinOpts::OnInitDialog() } } { - ptrW tmp(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")); + ptrW tmp(UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L"")); if (!tmp[0]) { wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -836,7 +836,7 @@ void 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, szGPGModuleName, "szGpgBinPath", L"gpg.exe"))); + CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szGpgBinPath", L"gpg.exe"))); edit_BIN_PATH.SetText(tmp); wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -850,7 +850,7 @@ void CDlgGpgBinOpts::onClick_SET_BIN_PATH(CCtrlButton*) void CDlgGpgBinOpts::onClick_SET_HOME_DIR(CCtrlButton*) { GetFolderPath(L"Set home directory", "szHomePath"); - CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""))); + CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""))); edit_HOME_DIR.SetText(tmp); wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -867,7 +867,7 @@ void CDlgGpgBinOpts::onClick_OK(CCtrlButton*) { gpg_save_paths(edit_BIN_PATH.GetText(), edit_HOME_DIR.GetText()); globals.gpg_valid = true; - db_set_b(NULL, szGPGModuleName, "FirstRun", 0); + db_set_b(NULL, MODULENAME, "FirstRun", 0); this->Hide(); CDlgFirstRun *d = new CDlgFirstRun; d->Show(); @@ -882,9 +882,9 @@ void CDlgGpgBinOpts::onClick_GENERATE_RANDOM(CCtrlButton*) globals.gpg_valid = true; if (gpg_use_new_random_key()) { - db_set_b(NULL, szGPGModuleName, "bAutoExchange", globals.bAutoExchange = chk_AUTO_EXCHANGE.GetState()); + db_set_b(NULL, MODULENAME, "bAutoExchange", globals.bAutoExchange = chk_AUTO_EXCHANGE.GetState()); globals.gpg_valid = true; - db_set_b(NULL, szGPGModuleName, "FirstRun", 0); + db_set_b(NULL, MODULENAME, "FirstRun", 0); this->Close(); } } @@ -910,9 +910,9 @@ void 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, szGPGModuleName, "GPGPubKey", L""); + wchar_t *tmp = UniGetContactSettingUtf(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(db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0)); + btn_IMPORT_AND_USE.Enable(db_get_b(hContact, MODULENAME, "GPGEncryption", 0)); btn_IMPORT.SetText(tmp[0] ? TranslateT("Replace") : TranslateT("Accept")); mir_free(tmp); tmp = new wchar_t[256]; @@ -923,8 +923,8 @@ void CDlgNewKey::OnInitDialog() void CDlgNewKey::OnDestroy() { GetWindowRect(m_hwnd, &globals.new_key_rect); - db_set_dw(NULL, szGPGModuleName, "NewKeyWindowX", globals.new_key_rect.left); - db_set_dw(NULL, szGPGModuleName, "NewKeyWindowY", globals.new_key_rect.top); + db_set_dw(NULL, MODULENAME, "NewKeyWindowX", globals.new_key_rect.left); + db_set_dw(NULL, MODULENAME, "NewKeyWindowY", globals.new_key_rect.top); } void CDlgNewKey::onClick_IMPORT(CCtrlButton*) { @@ -934,7 +934,7 @@ void CDlgNewKey::onClick_IMPORT(CCtrlButton*) void CDlgNewKey::onClick_IMPORT_AND_USE(CCtrlButton*) { ImportKey(hContact, new_key); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 1); + db_set_b(hContact, MODULENAME, "GPGEncryption", 1); void setSrmmIcon(MCONTACT hContact); void setClistIcon(MCONTACT hContact); setSrmmIcon(hContact); @@ -1042,7 +1042,7 @@ void CDlgKeyGen::onClick_OK(CCtrlButton*) mir_free(tmp); } { //generating key file - wchar_t *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); + wchar_t *tmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); char *tmp2;// = mir_u2a(tmp); path = tmp; mir_free(tmp); @@ -1136,8 +1136,8 @@ void CDlgKeyGen::onClick_CANCEL(CCtrlButton*) void CDlgKeyGen::OnDestroy() { GetWindowRect(m_hwnd, &globals.key_gen_rect); - db_set_dw(NULL, szGPGModuleName, "KeyGenWindowX", globals.key_gen_rect.left); - db_set_dw(NULL, szGPGModuleName, "KeyGenWindowY", globals.key_gen_rect.top); + db_set_dw(NULL, MODULENAME, "KeyGenWindowX", globals.key_gen_rect.left); + db_set_dw(NULL, MODULENAME, "KeyGenWindowY", globals.key_gen_rect.top); } CDlgLoadExistingKey::CDlgLoadExistingKey() : CDlgBase(g_plugin, IDD_LOAD_EXISTING_KEY), @@ -1261,8 +1261,8 @@ void CDlgLoadExistingKey::OnInitDialog() void CDlgLoadExistingKey::OnDestroy() { GetWindowRect(m_hwnd, &globals.load_existing_key_rect); - db_set_dw(NULL, szGPGModuleName, "LoadExistingKeyWindowX", globals.load_existing_key_rect.left); - db_set_dw(NULL, szGPGModuleName, "LoadExistingKeyWindowY", globals.load_existing_key_rect.top); + db_set_dw(NULL, MODULENAME, "LoadExistingKeyWindowX", globals.load_existing_key_rect.left); + db_set_dw(NULL, MODULENAME, "LoadExistingKeyWindowY", globals.load_existing_key_rect.top); } void CDlgLoadExistingKey::onClick_OK(CCtrlButton*) { @@ -1339,8 +1339,8 @@ void CDlgImportKey::OnInitDialog() void CDlgImportKey::OnDestroy() { GetWindowRect(m_hwnd, &globals.import_key_rect); - db_set_dw(NULL, szGPGModuleName, "ImportKeyWindowX", globals.import_key_rect.left); - db_set_dw(NULL, szGPGModuleName, "ImportKeyWindowY", globals.import_key_rect.top); + db_set_dw(NULL, MODULENAME, "ImportKeyWindowX", globals.import_key_rect.left); + db_set_dw(NULL, MODULENAME, "ImportKeyWindowY", globals.import_key_rect.top); } void CDlgImportKey::onClick_IMPORT(CCtrlButton*) { @@ -1374,7 +1374,7 @@ btn_OK(this, IDOK), btn_CANCEL(this, IDCANCEL) } void CDlgKeyPasswordMsgBox::OnInitDialog() { - inkeyid = UniGetContactSettingUtf(hContact, szGPGModuleName, "InKeyID", ""); + inkeyid = UniGetContactSettingUtf(hContact, MODULENAME, "InKeyID", ""); SetWindowPos(m_hwnd, nullptr, globals.key_password_rect.left, globals.key_password_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); { @@ -1389,23 +1389,23 @@ void CDlgKeyPasswordMsgBox::OnDestroy() { mir_free(inkeyid); GetWindowRect(m_hwnd, &globals.key_password_rect); - db_set_dw(NULL, szGPGModuleName, "PasswordWindowX", globals.key_password_rect.left); - db_set_dw(NULL, szGPGModuleName, "PasswordWindowY", globals.key_password_rect.top); + db_set_dw(NULL, MODULENAME, "PasswordWindowX", globals.key_password_rect.left); + db_set_dw(NULL, MODULENAME, "PasswordWindowY", globals.key_password_rect.top); } 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, szGPGModuleName, "InKeyID", ""); + inkeyid = UniGetContactSettingUtf(hContact, MODULENAME, "InKeyID", ""); if (inkeyid && inkeyid[0] && !chk_DEFAULT_PASSWORD.GetState()) { string dbsetting = "szKey_"; dbsetting += inkeyid; dbsetting += "_Password"; - db_set_ws(NULL, szGPGModuleName, dbsetting.c_str(), tmp); + db_set_ws(NULL, MODULENAME, dbsetting.c_str(), tmp); } else - db_set_ws(NULL, szGPGModuleName, "szKeyPassword", tmp); + db_set_ws(NULL, MODULENAME, "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 f8c2531190..aaf36d1e85 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -63,7 +63,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, szGPGModuleName, szSetting, L""); + tmp = UniGetContactSettingUtf(0, MODULENAME, szSetting, L""); wcsncpy(str, tmp, _countof(str) - 1); mir_free(tmp); if (mir_wstrlen(str) < 2) @@ -73,7 +73,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, szGPGModuleName, szSetting, str); + db_set_ws(0, MODULENAME, szSetting, str); } wchar_t *GetFilePath(wchar_t *WindowTittle, wchar_t *szExt, wchar_t *szExtDesc, bool save_file) @@ -120,7 +120,7 @@ void GetFolderPath(wchar_t *WindowTittle, char*) if (pidl != nullptr) { wchar_t path[MAX_PATH]; if (SHGetPathFromIDList(pidl, path)) { - db_set_ws(NULL, szGPGModuleName, "szHomePath", path); + db_set_ws(NULL, MODULENAME, "szHomePath", path); } IMalloc * imalloc = nullptr; if (SUCCEEDED(SHGetMalloc(&imalloc))) { @@ -155,21 +155,21 @@ INT_PTR SendKey(WPARAM w, LPARAM) key_id_str += "_KeyID"; acc_str += "_GPGPubKey"; } - szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, acc_str.empty() ? "GPGPubKey" : acc_str.c_str(), ""); + szMessage = UniGetContactSettingUtf(NULL, MODULENAME, acc_str.empty() ? "GPGPubKey" : acc_str.c_str(), ""); if (!szMessage[0]) { mir_free(szMessage); - szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); //try to get default key as fallback in any way + szMessage = UniGetContactSettingUtf(NULL, MODULENAME, "GPGPubKey", ""); //try to get default key as fallback in any way } } if (szMessage[0]) { - BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); + BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0); + db_set_b(hContact, MODULENAME, "GPGEncryption", 0); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)szMessage); std::string msg = "Public key "; - char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, key_id_str.c_str(), ""); + char *keyid = UniGetContactSettingUtf(NULL, MODULENAME, key_id_str.c_str(), ""); if (!keyid[0]) { mir_free(keyid); - keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); } msg += keyid; mir_free(keyid); @@ -177,7 +177,7 @@ INT_PTR SendKey(WPARAM w, LPARAM) mir_free(szMessage); szMessage = mir_strdup(msg.c_str()); HistoryLog(hContact, db_event(szMessage, 0, 0, DBEF_SENT)); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); + db_set_b(hContact, MODULENAME, "GPGEncryption", enc); } else mir_free(szMessage); @@ -189,20 +189,20 @@ INT_PTR ToggleEncryption(WPARAM w, LPARAM) MCONTACT hContact = (MCONTACT)w; BYTE enc; if (db_mc_isMeta(hContact)) { - enc = db_get_b(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0); + enc = db_get_b(metaGetMostOnline(hContact), MODULENAME, "GPGEncryption", 0); if (MessageBox(nullptr, TranslateT("Do you want to toggle encryption for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES) { int count = db_mc_getSubCount(hContact); for (int i = 0; i < count; i++) { MCONTACT hcnt = db_mc_getSub(hContact, i); if (hcnt) - db_set_b(hcnt, szGPGModuleName, "GPGEncryption", enc ? 0 : 1); + db_set_b(hcnt, MODULENAME, "GPGEncryption", enc ? 0 : 1); } - db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc ? 0 : 1); + db_set_b(hContact, MODULENAME, "GPGEncryption", enc ? 0 : 1); } } else { - enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); - db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc ? 0 : 1); + enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0); + db_set_b(hContact, MODULENAME, "GPGEncryption", enc ? 0 : 1); } void setSrmmIcon(MCONTACT hContact); void setClistIcon(MCONTACT hContact); @@ -228,10 +228,10 @@ int OnPreBuildContactMenu(WPARAM w, LPARAM) setting += ")"; setting += "_KeyID"; } - char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, setting.c_str(), ""); + char *keyid = UniGetContactSettingUtf(NULL, MODULENAME, setting.c_str(), ""); if (!keyid[0]) { mir_free(keyid); - keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + keyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); } wchar_t buf[128] = { 0 }; mir_snwprintf(buf, L"%s: %s", TranslateT("Send public key"), toUTF16(keyid).c_str()); @@ -240,15 +240,15 @@ int OnPreBuildContactMenu(WPARAM w, LPARAM) } int flags; - wchar_t *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", L""); + wchar_t *tmp = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); if (!tmp[0]) { - db_unset(hContact, szGPGModuleName, "GPGEncryption"); + db_unset(hContact, MODULENAME, "GPGEncryption"); flags = CMIF_GRAYED; } else flags = 0; Menu_ModifyItem(globals.hToggleEncryption, - db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0) ? L"Turn off GPG encryption" : L"Turn on GPG encryption", + db_get_b(hContact, MODULENAME, "GPGEncryption", 0) ? L"Turn off GPG encryption" : L"Turn on GPG encryption", INVALID_HANDLE_VALUE, flags); mir_free(tmp); return 0; @@ -313,17 +313,17 @@ int onProtoAck(WPARAM, LPARAM l) boost::filesystem::remove(file); { // password wchar_t *pass = nullptr; - char *keyid = UniGetContactSettingUtf(ack->hContact, szGPGModuleName, "KeyID", ""); + char *keyid = UniGetContactSettingUtf(ack->hContact, MODULENAME, "KeyID", ""); if (mir_strlen(keyid) > 0) { string dbsetting = "szKey_"; dbsetting += keyid; dbsetting += "_Password"; - pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), L""); + pass = UniGetContactSettingUtf(NULL, 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, szGPGModuleName, "szKeyPassword", L""); + pass = UniGetContactSettingUtf(NULL, 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"); } @@ -361,9 +361,9 @@ int onProtoAck(WPARAM, LPARAM l) s += mir_strlen(" ID "); string::size_type s2 = out.find(",", s); if (db_mc_isMeta(ack->hContact)) - db_set_s(metaGetMostOnline(ack->hContact), szGPGModuleName, "InKeyID", out.substr(s, s2 - s).c_str()); + db_set_s(metaGetMostOnline(ack->hContact), MODULENAME, "InKeyID", out.substr(s, s2 - s).c_str()); else - db_set_s(ack->hContact, szGPGModuleName, "InKeyID", out.substr(s, s2 - s).c_str()); + db_set_s(ack->hContact, MODULENAME, "InKeyID", out.substr(s, s2 - s).c_str()); } CDlgKeyPasswordMsgBox *d = new CDlgKeyPasswordMsgBox(ack->hContact); d->DoModal(); @@ -423,7 +423,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, szGPGModuleName, "KeyID", ""); + char *keyid = UniGetContactSettingUtf(hcnt, MODULENAME, "KeyID", ""); wchar_t *szKeyid = mir_a2u(keyid); wchar_t *name = wcsrchr(filename, '\\'); if (!name) @@ -433,7 +433,7 @@ std::wstring encrypt_file(MCONTACT hContact, wchar_t *filename) 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)) { + if (db_get_b(hcnt, MODULENAME, "bAlwaysTrust", 0)) { cmd.push_back(L"--trust-model"); cmd.push_back(L"always"); } @@ -458,7 +458,7 @@ std::wstring encrypt_file(MCONTACT hContact, wchar_t *filename) if (out.find("There is no assurance this key belongs to the named user") != string::npos) { out.clear(); if (MessageBox(nullptr, TranslateT("We're trying to encrypt with untrusted key. Do you want to trust this key permanently?"), TranslateT("Warning"), MB_YESNO) == IDYES) { - db_set_b(hcnt, szGPGModuleName, "bAlwaysTrust", 1); + db_set_b(hcnt, MODULENAME, "bAlwaysTrust", 1); std::vector<std::wstring> tmp; tmp.push_back(L"--trust-model"); tmp.push_back(L"always"); @@ -564,7 +564,7 @@ INT_PTR onSendFile(WPARAM w, LPARAM l) void HistoryLog(MCONTACT hContact, db_event evt) { DBEVENTINFO Event = {}; - Event.szModule = szGPGModuleName; + Event.szModule = MODULENAME; Event.eventType = evt.eventType; Event.flags = evt.flags; if (!evt.timestamp) @@ -671,7 +671,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, szGPGModuleName, "szHomePath", L""); + wchar_t *path_c = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); wstring path_out = path_c; wstring file = toUTF16(get_random(10)); mir_free(path_c); @@ -695,10 +695,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, szGPGModuleName, setting, ""); + inkeyid = UniGetContactSettingUtf(NULL, MODULENAME, setting, ""); if (!inkeyid[0]) { mir_free(inkeyid); - inkeyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + inkeyid = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", ""); } ptrW pass; @@ -706,14 +706,14 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) string dbsetting = "szKey_"; dbsetting += inkeyid; dbsetting += "_Password"; - pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), L""); + pass = UniGetContactSettingUtf(NULL, 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, szGPGModuleName, "szKeyPassword", L""); + pass = UniGetContactSettingUtf(NULL, 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"); } @@ -732,7 +732,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) } cmd.push_back(L"--local-user"); - path_c = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", L""); + path_c = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", L""); cmd.push_back(path_c); cmd.push_back(L"--default-key"); cmd.push_back(path_c); @@ -834,7 +834,7 @@ static JABBER_HANDLER_FUNC PrescenseHandler(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, szGPGModuleName, "szHomePath", L""); + wchar_t *path_c = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); wstring path_out = path_c, status_file_out = path_c; mir_free(path_c); path_out += L"\\tmp\\"; @@ -942,14 +942,14 @@ void AddHandlers() bool isContactSecured(MCONTACT hContact) { - BYTE gpg_enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); + BYTE gpg_enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0); if (!gpg_enc) { if (globals.bDebugLog) globals.debuglog << std::string(time_str() + ": encryption is turned off for " + toUTF8(Clist_GetContactDisplayName(hContact))); return false; } if (!db_mc_isMeta(hContact)) { - wchar_t *key = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", L""); + wchar_t *key = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); if (!key[0]) { mir_free(key); if (globals.bDebugLog) @@ -965,7 +965,7 @@ bool isContactSecured(MCONTACT hContact) bool isContactHaveKey(MCONTACT hContact) { - wchar_t *key = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", L""); + wchar_t *key = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); if (mir_wstrlen(key) > 0) { mir_free(key); return true; @@ -976,8 +976,8 @@ bool isContactHaveKey(MCONTACT hContact) bool isGPGKeyExist() { - wchar_t *id = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", L""); - char *key = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); + wchar_t *id = UniGetContactSettingUtf(NULL, MODULENAME, "KeyID", L""); + char *key = UniGetContactSettingUtf(NULL, MODULENAME, "GPGPubKey", ""); if (id[0] && key[0]) { mir_free(id); mir_free(key); @@ -991,7 +991,7 @@ bool isGPGValid() { wchar_t *tmp = nullptr; bool gpg_exists = false, is_valid = true; - tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L""); + tmp = UniGetContactSettingUtf(NULL, MODULENAME, "szGpgBinPath", L""); boost::filesystem::path p(tmp); if (boost::filesystem::exists(p) && boost::filesystem::is_regular_file(p)) @@ -1022,7 +1022,7 @@ bool isGPGValid() } if (gpg_exists) { - db_set_ws(NULL, szGPGModuleName, "szGpgBinPath", tmp); + db_set_ws(NULL, MODULENAME, "szGpgBinPath", tmp); mir_free(tmp); tmp = nullptr; string out; @@ -1050,7 +1050,7 @@ bool isGPGValid() { wstring path_ = _wgetenv(L"APPDATA"); path_ += L"\\GnuPG"; - tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", (wchar_t*)path_.c_str()); + tmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", (wchar_t*)path_.c_str()); } if(tmp) mir_free(tmp); */ @@ -1079,7 +1079,7 @@ const bool StriStr(const char *str, const char *substr) bool IsOnline(MCONTACT hContact) { - if (db_get_b(hContact, szGPGModuleName, "Status", 0) == ID_STATUS_OFFLINE) + if (db_get_b(hContact, MODULENAME, "Status", 0) == ID_STATUS_OFFLINE) return false; return true; } @@ -1185,7 +1185,7 @@ void send_encrypted_msgs_thread(void *param) { MCONTACT hContact = (MCONTACT)(DWORD_PTR)param; while (true) { - //char *key = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", ""); + //char *key = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", ""); while (!isContactSecured(hContact)) boost::this_thread::sleep(boost::posix_time::seconds(1)); if (!globals.hcontact_data[hContact].msgs_to_send.empty()) { @@ -1249,7 +1249,7 @@ void ExportGpGKeysFunc(int type) return; //TODO: handle error if (!type || type == 2) { for (auto &hContact : Contacts()) { - char *k = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", ""); + char *k = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", ""); std::string key; if (!k[0]) { mir_free(k); @@ -1598,7 +1598,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) string output; DWORD exitcode; { - ptmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); + ptmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); path = ptmp; mir_free(ptmp); wstring rand = toUTF16(get_random(10)); @@ -1635,7 +1635,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) tmp2 = (char*)mir_alloc((output.substr(s, s2 - s).length() + 1) * sizeof(char)); mir_strcpy(tmp2, output.substr(s, s2 - s).c_str()); mir_utf8decode(tmp2, nullptr); - db_set_s(hContact, szGPGModuleName, "KeyID", tmp2); + db_set_s(hContact, MODULENAME, "KeyID", tmp2); mir_free(tmp2); s = output.find("“", s2); if (s == string::npos) { @@ -1653,7 +1653,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) mir_strcpy(tmp2, output.substr(s, s2 - s - 1).c_str()); mir_utf8decode(tmp2, nullptr); if (hContact) { - db_set_s(hContact, szGPGModuleName, "KeyMainName", output.substr(s, s2 - s - 1).c_str()); + db_set_s(hContact, MODULENAME, "KeyMainName", output.substr(s, s2 - s - 1).c_str()); } mir_free(tmp2); if ((s = output.find(")", s2)) == string::npos) @@ -1666,7 +1666,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) mir_strcpy(tmp2, output.substr(s2, s - s2).c_str()); mir_utf8decode(tmp2, nullptr); if (hContact) - db_set_s(hContact, szGPGModuleName, "KeyComment", output.substr(s2, s - s2).c_str()); + db_set_s(hContact, MODULENAME, "KeyComment", output.substr(s2, s - s2).c_str()); mir_free(tmp2); s += 3; s2 = output.find(">", s); @@ -1674,7 +1674,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) mir_strcpy(tmp2, output.substr(s, s2 - s).c_str()); mir_utf8decode(tmp2, nullptr); if (hContact) - db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s, s2 - s).c_str()); + db_set_s(hContact, MODULENAME, "KeyMainEmail", output.substr(s, s2 - s).c_str()); mir_free(tmp2); } else { @@ -1682,12 +1682,12 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) mir_strcpy(tmp2, output.substr(s2, s - s2).c_str()); mir_utf8decode(tmp2, nullptr); if (hContact) - db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2, s - s2).c_str()); + db_set_s(hContact, MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str()); mir_free(tmp2); } } - db_set_b(hContact, szGPGModuleName, "GPGEncryption", 1); - db_set_ws(hContact, szGPGModuleName, "GPGPubKey", toUTF16(key).c_str()); + db_set_b(hContact, MODULENAME, "GPGEncryption", 1); + db_set_ws(hContact, MODULENAME, "GPGPubKey", toUTF16(key).c_str()); } boost::filesystem::remove(path); break; @@ -1703,7 +1703,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) string output; DWORD exitcode; { - ptmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); + ptmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); wcsncpy(tmp2, ptmp, MAX_PATH - 1); mir_free(ptmp); mir_wstrncat(tmp2, L"\\", _countof(tmp2) - mir_wstrlen(tmp2)); @@ -1816,7 +1816,7 @@ void clean_temp_dir() wstring path = toUTF16(mir_path); SetCurrentDirectoryA(mir_path); delete[] mir_path; - wchar_t *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); + wchar_t *tmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); path += tmp; mir_free(tmp); path += L"\\tmp"; @@ -1850,7 +1850,7 @@ bool gpg_validate_paths(wchar_t *gpg_bin_path, wchar_t *gpg_home_path) } { bool bad_version = false; - db_set_ws(NULL, szGPGModuleName, "szGpgBinPath", tmp.c_str()); + db_set_ws(NULL, MODULENAME, "szGpgBinPath", tmp.c_str()); string out; DWORD code; std::vector<wstring> cmd; @@ -1864,7 +1864,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, szGPGModuleName, "szGpgBinPath"); + db_unset(NULL, MODULENAME, "szGpgBinPath"); string::size_type p1 = out.find("(GnuPG) "); if (p1 != string::npos) { p1 += mir_strlen("(GnuPG) "); @@ -1887,7 +1887,7 @@ bool gpg_validate_paths(wchar_t *gpg_bin_path, wchar_t *gpg_home_path) return false; } { - wchar_t *path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""); + wchar_t *path = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); DWORD dwFileAttr = GetFileAttributes(path); if (dwFileAttr != INVALID_FILE_ATTRIBUTES) { dwFileAttr &= ~FILE_ATTRIBUTE_READONLY; @@ -1900,8 +1900,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, szGPGModuleName, "szGpgBinPath", gpg_bin_path); - db_set_ws(NULL, szGPGModuleName, "szHomePath", gpg_home_path); + db_set_ws(NULL, MODULENAME, "szGpgBinPath", gpg_bin_path); + db_set_ws(NULL, MODULENAME, "szHomePath", gpg_home_path); } bool gpg_use_new_random_key(char *account_name, wchar_t *gpg_bin_path, wchar_t *gpg_home_dir) @@ -1916,7 +1916,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, szGPGModuleName, "szHomePath", L""); + tmp = UniGetContactSettingUtf(NULL, MODULENAME, "szHomePath", L""); path = tmp; if (!gpg_home_dir) mir_free(tmp); @@ -1994,17 +1994,17 @@ bool gpg_use_new_random_key(char *account_name, wchar_t *gpg_bin_path, wchar_t * { if (!mir_strcmp(account_name, Translate("Default"))) { - db_set_s(NULL, szGPGModuleName, "GPGPubKey", out.c_str()); - db_set_ws(NULL, szGPGModuleName, "KeyID", path.c_str()); + db_set_s(NULL, MODULENAME, "GPGPubKey", out.c_str()); + db_set_ws(NULL, MODULENAME, "KeyID", path.c_str()); } else { std::string acc_str = account_name; acc_str += "_GPGPubKey"; - db_set_s(NULL, szGPGModuleName, acc_str.c_str(), out.c_str()); + db_set_s(NULL, MODULENAME, acc_str.c_str(), out.c_str()); acc_str = account_name; acc_str += "_KeyID"; - db_set_ws(NULL, szGPGModuleName, acc_str.c_str(), path.c_str()); + db_set_ws(NULL, MODULENAME, acc_str.c_str(), path.c_str()); } } } |