From 53fe3e46177d17b4941610de19f5cc6210700cb4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 12 Nov 2018 21:44:56 +0300 Subject: db_* functions replaced with g_plugin calls --- plugins/SecureIM/src/commonheaders.cpp | 40 ++++++++++----------- plugins/SecureIM/src/crypt_dll.cpp | 2 +- plugins/SecureIM/src/crypt_lists.cpp | 4 +-- plugins/SecureIM/src/crypt_misc.cpp | 2 +- plugins/SecureIM/src/crypt_popups.cpp | 34 +++++++++--------- plugins/SecureIM/src/main.cpp | 58 +++++++++++++++--------------- plugins/SecureIM/src/options.cpp | 66 +++++++++++++++++----------------- plugins/SecureIM/src/popupOptions.cpp | 60 +++++++++++++++---------------- plugins/SecureIM/src/splitmsg.cpp | 4 +-- plugins/SecureIM/src/svcs_rsa.cpp | 4 +-- 10 files changed, 137 insertions(+), 137 deletions(-) (limited to 'plugins/SecureIM/src') diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp index b042f486f6..f4ad26a11c 100644 --- a/plugins/SecureIM/src/commonheaders.cpp +++ b/plugins/SecureIM/src/commonheaders.cpp @@ -43,30 +43,30 @@ int myDBWriteStringEncode(MCONTACT hContact, const char *szModule, const char *s void GetFlags() { - bSFT = db_get_b(0, MODULENAME, "sft", 0); - bSOM = db_get_b(0, MODULENAME, "som", 0); - bASI = db_get_b(0, MODULENAME, "asi", 0); - bMCD = db_get_b(0, MODULENAME, "mcd", 0); - bSCM = db_get_b(0, MODULENAME, "scm", 0); - bDGP = db_get_b(0, MODULENAME, "dgp", 0); - bAIP = db_get_b(0, MODULENAME, "aip", 0); - bNOL = db_get_b(0, MODULENAME, "nol", 0); - bAAK = db_get_b(0, MODULENAME, "aak", 0); - bMCM = db_get_b(0, MODULENAME, "mcm", 0); + bSFT = g_plugin.getByte("sft", 0); + bSOM = g_plugin.getByte("som", 0); + bASI = g_plugin.getByte("asi", 0); + bMCD = g_plugin.getByte("mcd", 0); + bSCM = g_plugin.getByte("scm", 0); + bDGP = g_plugin.getByte("dgp", 0); + bAIP = g_plugin.getByte("aip", 0); + bNOL = g_plugin.getByte("nol", 0); + bAAK = g_plugin.getByte("aak", 0); + bMCM = g_plugin.getByte("mcm", 0); } void SetFlags() { - db_set_b(0, MODULENAME, "sft", bSFT); - db_set_b(0, MODULENAME, "som", bSOM); - db_set_b(0, MODULENAME, "asi", bASI); - db_set_b(0, MODULENAME, "mcd", bMCD); - db_set_b(0, MODULENAME, "scm", bSCM); - db_set_b(0, MODULENAME, "dgp", bDGP); - db_set_b(0, MODULENAME, "aip", bAIP); - db_set_b(0, MODULENAME, "nol", bNOL); - db_set_b(0, MODULENAME, "aak", bAAK); - db_set_b(0, MODULENAME, "mcm", bMCM); + g_plugin.setByte("sft", bSFT); + g_plugin.setByte("som", bSOM); + g_plugin.setByte("asi", bASI); + g_plugin.setByte("mcd", bMCD); + g_plugin.setByte("scm", bSCM); + g_plugin.setByte("dgp", bDGP); + g_plugin.setByte("aip", bAIP); + g_plugin.setByte("nol", bNOL); + g_plugin.setByte("aak", bAAK); + g_plugin.setByte("mcm", bMCM); } int msgbox(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) diff --git a/plugins/SecureIM/src/crypt_dll.cpp b/plugins/SecureIM/src/crypt_dll.cpp index afa18459e0..822f479059 100644 --- a/plugins/SecureIM/src/crypt_dll.cpp +++ b/plugins/SecureIM/src/crypt_dll.cpp @@ -89,7 +89,7 @@ BOOL CalculateKeyX(pUinKey ptr, MCONTACT hContact) db_set_blob(hContact, MODULENAME, "offlineKey", buffer, keysize); // store timeout of key in database (2 days) - db_set_dw(hContact, MODULENAME, "offlineKeyTimeout", gettime() + (60 * 60 * 24 * db_get_w(0, MODULENAME, "okt", 2))); + db_set_dw(hContact, MODULENAME, "offlineKeyTimeout", gettime() + (60 * 60 * 24 * g_plugin.getWord("okt", 2))); // key exchange is finished showPopupEC(ptr->hContact); diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp index 34f9306fde..22d2ec4964 100644 --- a/plugins/SecureIM/src/crypt_lists.cpp +++ b/plugins/SecureIM/src/crypt_lists.cpp @@ -5,7 +5,7 @@ LIST arClist(100, NumericKeySortT); void loadSupportedProtocols() { - LPSTR szNames = db_get_sa(0, MODULENAME, "protos"); + LPSTR szNames = g_plugin.getStringA("protos"); if (szNames && strchr(szNames, ':') == nullptr) { LPSTR tmp = (LPSTR)mir_alloc(2048); int j = 0; for (int i = 0; szNames[i]; i++) { @@ -16,7 +16,7 @@ void loadSupportedProtocols() } tmp[j] = '\0'; SAFE_FREE(szNames); szNames = tmp; - db_set_s(0, MODULENAME, "protos", szNames); + g_plugin.setString("protos", szNames); } for (auto &pa : Accounts()) { diff --git a/plugins/SecureIM/src/crypt_misc.cpp b/plugins/SecureIM/src/crypt_misc.cpp index 108e8958b9..6017c25719 100644 --- a/plugins/SecureIM/src/crypt_misc.cpp +++ b/plugins/SecureIM/src/crypt_misc.cpp @@ -7,7 +7,7 @@ static void sttWaitForExchange(LPVOID param) if (!ptr) return; - for (int i = 0; i < db_get_w(0, MODULENAME, "ket", 10) * 10; i++) { + for (int i = 0; i < g_plugin.getWord("ket", 10) * 10; i++) { Sleep(100); if (ptr->waitForExchange != 1) break; diff --git a/plugins/SecureIM/src/crypt_popups.cpp b/plugins/SecureIM/src/crypt_popups.cpp index c57827c6c7..f50b5e308f 100644 --- a/plugins/SecureIM/src/crypt_popups.cpp +++ b/plugins/SecureIM/src/crypt_popups.cpp @@ -14,25 +14,25 @@ void showPopup(LPCSTR lpzText, MCONTACT hContact, HICON hIcon, UINT type) DBVARIANT dbv; if (type == 0) { - colorBack = db_get_dw(0, MODULENAME, "colorKeyb", RGB(230, 230, 255)); - colorText = db_get_dw(0, MODULENAME, "colorKeyt", RGB(0, 0, 0)); - if (!db_get_s(0, MODULENAME, "timeoutKey", &dbv)) { + colorBack = g_plugin.getDword("colorKeyb", RGB(230, 230, 255)); + colorText = g_plugin.getDword("colorKeyt", RGB(0, 0, 0)); + if (!g_plugin.getString("timeoutKey", &dbv)) { timeout = atoi(dbv.pszVal); db_free(&dbv); } } else if (type == 1) { - colorBack = db_get_dw(0, MODULENAME, "colorSecb", RGB(255, 255, 200)); - colorText = db_get_dw(0, MODULENAME, "colorSect", RGB(0, 0, 0)); - if (!db_get_s(0, MODULENAME, "timeoutSec", &dbv)) { + colorBack = g_plugin.getDword("colorSecb", RGB(255, 255, 200)); + colorText = g_plugin.getDword("colorSect", RGB(0, 0, 0)); + if (!g_plugin.getString("timeoutSec", &dbv)) { timeout = atoi(dbv.pszVal); db_free(&dbv); } } else if (type >= 2) { - colorBack = db_get_dw(0, MODULENAME, "colorSRb", RGB(200, 255, 200)); - colorText = db_get_dw(0, MODULENAME, "colorSRt", RGB(0, 0, 0)); - if (!db_get_s(0, MODULENAME, "timeoutSR", &dbv)) { + colorBack = g_plugin.getDword("colorSRb", RGB(200, 255, 200)); + colorText = g_plugin.getDword("colorSRt", RGB(0, 0, 0)); + if (!g_plugin.getString("timeoutSR", &dbv)) { timeout = atoi(dbv.pszVal); db_free(&dbv); } @@ -54,50 +54,50 @@ void showPopup(LPCSTR lpzText, MCONTACT hContact, HICON hIcon, UINT type) void showPopupDCmsg(MCONTACT hContact, LPCSTR msg) { - if (db_get_b(0, MODULENAME, "dc", 1)) + if (g_plugin.getByte("dc", 1)) showPopup(msg, hContact, g_hPOP[POP_PU_DIS], 1); } void showPopupDC(MCONTACT hContact) { - if (db_get_b(0, MODULENAME, "dc", 1)) + if (g_plugin.getByte("dc", 1)) showPopup(sim006, hContact, g_hPOP[POP_PU_DIS], 1); } void showPopupEC(MCONTACT hContact) { - if (db_get_b(0, MODULENAME, "ec", 1)) + if (g_plugin.getByte("ec", 1)) showPopup(sim001, hContact, g_hPOP[POP_PU_EST], 1); } void showPopupKS(MCONTACT hContact) { - if (db_get_b(0, MODULENAME, "ks", 1)) + if (g_plugin.getByte("ks", 1)) showPopup(sim007, hContact, g_hPOP[POP_PU_PRC], 0); } void showPopupKRmsg(MCONTACT hContact, LPCSTR msg) { - if (db_get_b(0, MODULENAME, "kr", 1)) + if (g_plugin.getByte("kr", 1)) showPopup(msg, hContact, g_hPOP[POP_PU_PRC], 0); } void showPopupKR(MCONTACT hContact) { - if (db_get_b(0, MODULENAME, "kr", 1)) + if (g_plugin.getByte("kr", 1)) showPopup(sim008, hContact, g_hPOP[POP_PU_PRC], 0); } void showPopupSM(MCONTACT hContact) { - if (db_get_b(0, MODULENAME, "ss", 0)) + if (g_plugin.getByte("ss", 0)) showPopup(sim009, hContact, g_hPOP[POP_PU_MSS], 2); Skin_PlaySound("OutgoingSecureMessage"); } void showPopupRM(MCONTACT hContact) { - if (db_get_b(0, MODULENAME, "sr", 0)) + if (g_plugin.getByte("sr", 0)) showPopup(sim010, hContact, g_hPOP[POP_PU_MSR], 2); Skin_PlaySound("IncomingSecureMessage"); } diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index 36e6f2067b..297f5eb04e 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -86,25 +86,25 @@ static int onModulesLoaded(WPARAM, LPARAM) char pub_key[4096]; int pub_len; mir_exp->rsa_get_keypair(CPP_MODE_RSA_4096, (PBYTE)&priv_key, &priv_len, (PBYTE)&pub_key, &pub_len); - db_set_blob(NULL, MODULENAME, "rsa_priv", priv_key, priv_len); - db_set_blob(NULL, MODULENAME, "rsa_pub", &pub_key, pub_len); - db_unset(NULL, MODULENAME, "rsa_priv_2048"); - db_unset(NULL, MODULENAME, "rsa_pub_2048"); + db_set_blob(0, MODULENAME, "rsa_priv", priv_key, priv_len); + db_set_blob(0, MODULENAME, "rsa_pub", &pub_key, pub_len); + g_plugin.delSetting("rsa_priv_2048"); + g_plugin.delSetting("rsa_pub_2048"); rsa_4096 = 1; } if (!rsa_4096) mir_forkthread(sttGenerateRSA); - mir_exp->rsa_set_timeout(db_get_w(0, MODULENAME, "ket", 10)); + mir_exp->rsa_set_timeout(g_plugin.getWord("ket", 10)); Sent_NetLog("pgp_init"); - bPGP = db_get_b(0, MODULENAME, "pgp", 0); + bPGP = g_plugin.getByte("pgp", 0); if (bPGP) { //PGP bPGPloaded = pgp_init(); - bUseKeyrings = db_get_b(0, MODULENAME, "ukr", 1); - LPSTR priv = db_get_sa(0, MODULENAME, "pgpPrivKey"); + bUseKeyrings = g_plugin.getByte("ukr", 1); + LPSTR priv = g_plugin.getStringA("pgpPrivKey"); if (priv) { bPGPprivkey = true; if (bPGPloaded) @@ -118,24 +118,24 @@ static int onModulesLoaded(WPARAM, LPARAM) bPGPkeyrings = pgp_open_keyrings(PubRingPath, SecRingPath); } else { - LPSTR tmp = db_get_sa(0, MODULENAME, "pgpPubRing"); + LPSTR tmp = g_plugin.getStringA("pgpPubRing"); if (tmp) { strncpy(PubRingPath, tmp, sizeof(PubRingPath)); mir_free(tmp); } - if (tmp = db_get_sa(0, MODULENAME, "pgpSecRing")) { + if (tmp = g_plugin.getStringA("pgpSecRing")) { strncpy(SecRingPath, tmp, sizeof(SecRingPath)); mir_free(tmp); } if (PubRingPath[0] && SecRingPath[0]) { bPGPkeyrings = pgp_open_keyrings(PubRingPath, SecRingPath); if (bPGPkeyrings) { - db_set_s(0, MODULENAME, "pgpPubRing", PubRingPath); - db_set_s(0, MODULENAME, "pgpSecRing", SecRingPath); + g_plugin.setString("pgpPubRing", PubRingPath); + g_plugin.setString("pgpSecRing", SecRingPath); } else { - db_unset(0, MODULENAME, "pgpPubRing"); - db_unset(0, MODULENAME, "pgpSecRing"); + g_plugin.delSetting("pgpPubRing"); + g_plugin.delSetting("pgpSecRing"); } } } @@ -144,32 +144,32 @@ static int onModulesLoaded(WPARAM, LPARAM) Sent_NetLog("gpg_init"); - bGPG = db_get_b(0, MODULENAME, "gpg", 0); + bGPG = g_plugin.getByte("gpg", 0); if (bGPG) { //GPG bGPGloaded = gpg_init(); char gpgexec[MAX_PATH], gpghome[MAX_PATH]; gpgexec[0] = '\0'; gpghome[0] = '\0'; - LPSTR tmp = db_get_sa(0, MODULENAME, "gpgExec"); + LPSTR tmp = g_plugin.getStringA("gpgExec"); if (tmp) { strncpy(gpgexec, tmp, sizeof(gpgexec)-1); mir_free(tmp); } - if (tmp = db_get_sa(0, MODULENAME, "gpgHome")) { + if (tmp = g_plugin.getStringA("gpgHome")) { strncpy(gpghome, tmp, sizeof(gpghome)-1); mir_free(tmp); } - if (db_get_b(0, MODULENAME, "gpgLogFlag", 0)) { - if (tmp = db_get_sa(0, MODULENAME, "gpgLog")) { + if (g_plugin.getByte("gpgLogFlag", 0)) { + if (tmp = g_plugin.getStringA("gpgLog")) { gpg_set_log(tmp); mir_free(tmp); } } - if (db_get_b(0, MODULENAME, "gpgTmpFlag", 0)) { - if (tmp = db_get_sa(0, MODULENAME, "gpgTmp")) { + if (g_plugin.getByte("gpgTmpFlag", 0)) { + if (tmp = g_plugin.getStringA("gpgTmp")) { gpg_set_tmp(tmp); mir_free(tmp); } @@ -177,17 +177,17 @@ static int onModulesLoaded(WPARAM, LPARAM) bGPGkeyrings = gpg_open_keyrings(gpgexec, gpghome); if (bGPGkeyrings) { - db_set_s(0, MODULENAME, "gpgExec", gpgexec); - db_set_s(0, MODULENAME, "gpgHome", gpghome); + g_plugin.setString("gpgExec", gpgexec); + g_plugin.setString("gpgHome", gpghome); } else { - db_unset(0, MODULENAME, "gpgExec"); - db_unset(0, MODULENAME, "gpgHome"); + g_plugin.delSetting("gpgExec"); + g_plugin.delSetting("gpgHome"); } - bSavePass = db_get_b(0, MODULENAME, "gpgSaveFlag", 0); + bSavePass = g_plugin.getByte("gpgSaveFlag", 0); if (bSavePass) { - if (tmp = db_get_sa(0, MODULENAME, "gpgSave")) { + if (tmp = g_plugin.getStringA("gpgSave")) { gpg_set_passphrases(tmp); mir_free(tmp); } @@ -247,10 +247,10 @@ static int onShutdown(WPARAM, LPARAM) { if (bSavePass) { LPSTR tmp = gpg_get_passphrases(); - db_set_s(0, MODULENAME, "gpgSave", tmp); + g_plugin.setString("gpgSave", tmp); LocalFree(tmp); } - else db_unset(0, MODULENAME, "gpgSave"); + else g_plugin.delSetting("gpgSave"); if (bPGPloaded) pgp_done(); if (bGPGloaded) gpg_done(); diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp index 02e0eb4e02..e1ba269df9 100644 --- a/plugins/SecureIM/src/options.cpp +++ b/plugins/SecureIM/src/options.cpp @@ -678,8 +678,8 @@ INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l PubRingPath[0] = '\0'; SecRingPath[0] = '\0'; bPGPkeyrings = pgp_open_keyrings(PubRingPath, SecRingPath); if (bPGPkeyrings && PubRingPath[0] && SecRingPath[0]) { - db_set_s(0, MODULENAME, "pgpPubRing", PubRingPath); - db_set_s(0, MODULENAME, "pgpSecRing", SecRingPath); + g_plugin.setString("pgpPubRing", PubRingPath); + g_plugin.setString("pgpSecRing", SecRingPath); } SetDlgItemText(hDlg, IDC_KEYRING_STATUS, bPGPkeyrings ? Translate(sim216) : Translate(sim217)); } @@ -700,11 +700,11 @@ INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l if (ShowSelectKeyDlg(hDlg, KeyPath)) { char *priv = LoadKeys(KeyPath, true); if (priv) { - db_set_s(0, MODULENAME, "tpgpPrivKey", priv); + g_plugin.setString("tpgpPrivKey", priv); mir_free(priv); } else { - db_unset(0, MODULENAME, "tpgpPrivKey"); + g_plugin.delSetting("tpgpPrivKey"); } } } @@ -940,12 +940,12 @@ void RefreshGeneralDlg(HWND hDlg, BOOL iInit) char timeout[10]; // Key Exchange Timeout - UINT data = db_get_w(0, MODULENAME, "ket", 10); + UINT data = g_plugin.getWord("ket", 10); mir_itoa(data, timeout, 10); SetDlgItemText(hDlg, IDC_KET, timeout); // Offline Key Timeout - data = db_get_w(0, MODULENAME, "okt", 2); + data = g_plugin.getWord("okt", 2); mir_itoa(data, timeout, 10); SetDlgItemText(hDlg, IDC_OKT, timeout); @@ -1086,27 +1086,27 @@ void RefreshPGPDlg(HWND hDlg, BOOL iInit) void RefreshGPGDlg(HWND hDlg, BOOL iInit) { - LPSTR path = db_get_sa(0, MODULENAME, "gpgExec"); + LPSTR path = g_plugin.getStringA("gpgExec"); if (path) { SetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, path); mir_free(path); } - path = db_get_sa(0, MODULENAME, "gpgHome"); + path = g_plugin.getStringA("gpgHome"); if (path) { SetDlgItemText(hDlg, IDC_GPGHOME_EDIT, path); mir_free(path); } - BOOL bGPGLogFlag = db_get_b(0, MODULENAME, "gpgLogFlag", 0); + BOOL bGPGLogFlag = g_plugin.getByte("gpgLogFlag", 0); CheckDlgButton(hDlg, IDC_LOGGINGON_CBOX, (bGPGLogFlag) ? BST_CHECKED : BST_UNCHECKED); - path = db_get_sa(0, MODULENAME, "gpgLog"); + path = g_plugin.getStringA("gpgLog"); if (path) { SetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, path); mir_free(path); } CheckDlgButton(hDlg, IDC_SAVEPASS_CBOX, (bSavePass) ? BST_CHECKED : BST_UNCHECKED); - BOOL bGPGTmpFlag = db_get_b(0, MODULENAME, "gpgTmpFlag", 0); + BOOL bGPGTmpFlag = g_plugin.getByte("gpgTmpFlag", 0); CheckDlgButton(hDlg, IDC_TMPPATHON_CBOX, (bGPGTmpFlag) ? BST_CHECKED : BST_UNCHECKED); - path = db_get_sa(0, MODULENAME, "gpgTmp"); + path = g_plugin.getStringA("gpgTmp"); if (path) { SetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, path); mir_free(path); @@ -1215,15 +1215,15 @@ void ApplyGeneralSettings(HWND hDlg) // Key Exchange Timeout GetDlgItemText(hDlg, IDC_KET, timeout, 5); tmp = atoi(timeout); if (tmp > 65535) tmp = 65535; - db_set_w(0, MODULENAME, "ket", tmp); - mir_exp->rsa_set_timeout(db_get_w(0, MODULENAME, "ket", 10)); + g_plugin.setWord("ket", tmp); + mir_exp->rsa_set_timeout(g_plugin.getWord("ket", 10)); mir_itoa(tmp, timeout, 10); SetDlgItemText(hDlg, IDC_KET, timeout); // Offline Key Timeout GetDlgItemText(hDlg, IDC_OKT, timeout, 5); tmp = atoi(timeout); if (tmp > 65535) tmp = 65535; - db_set_w(0, MODULENAME, "okt", tmp); + g_plugin.setWord("okt", tmp); mir_itoa(tmp, timeout, 10); SetDlgItemText(hDlg, IDC_OKT, timeout); @@ -1246,12 +1246,12 @@ void ApplyGeneralSettings(HWND hDlg) i = (IsDlgButtonChecked(hDlg, IDC_PGP) == BST_CHECKED); if (i != bPGP) { bPGP = i; tmp++; - db_set_b(0, MODULENAME, "pgp", bPGP); + g_plugin.setByte("pgp", bPGP); } i = (IsDlgButtonChecked(hDlg, IDC_GPG) == BST_CHECKED); if (i != bGPG) { bGPG = i; tmp++; - db_set_b(0, MODULENAME, "gpg", bGPG); + g_plugin.setByte("gpg", bGPG); } if (tmp) msgbox1(hDlg, sim224, MODULENAME, MB_OK | MB_ICONINFORMATION); } @@ -1305,21 +1305,21 @@ void ApplyProtoSettings(HWND hDlg) i = ListView_GetNextItem(hLV, i, LVNI_ALL); } - db_set_s(0, MODULENAME, "protos", szNames); + g_plugin.setString("protos", szNames); } void ApplyPGPSettings(HWND hDlg) { bUseKeyrings = !(IsDlgButtonChecked(hDlg, IDC_NO_KEYRINGS) == BST_CHECKED); - db_set_b(0, MODULENAME, "ukr", bUseKeyrings); + g_plugin.setByte("ukr", bUseKeyrings); - char *priv = db_get_sa(0, MODULENAME, "tpgpPrivKey"); + char *priv = g_plugin.getStringA("tpgpPrivKey"); if (priv) { bPGPprivkey = true; pgp_set_priv_key(priv); - db_set_s(0, MODULENAME, "pgpPrivKey", priv); + g_plugin.setString("pgpPrivKey", priv); mir_free(priv); - db_unset(0, MODULENAME, "tpgpPrivKey"); + g_plugin.delSetting("tpgpPrivKey"); } } @@ -1328,24 +1328,24 @@ void ApplyGPGSettings(HWND hDlg) char tmp[256]; GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, tmp, _countof(tmp)); - db_set_s(0, MODULENAME, "gpgExec", tmp); + g_plugin.setString("gpgExec", tmp); GetDlgItemText(hDlg, IDC_GPGHOME_EDIT, tmp, _countof(tmp)); - db_set_s(0, MODULENAME, "gpgHome", tmp); + g_plugin.setString("gpgHome", tmp); bSavePass = (IsDlgButtonChecked(hDlg, IDC_SAVEPASS_CBOX) == BST_CHECKED); - db_set_b(0, MODULENAME, "gpgSaveFlag", bSavePass); + g_plugin.setByte("gpgSaveFlag", bSavePass); BOOL bgpgLogFlag = (IsDlgButtonChecked(hDlg, IDC_LOGGINGON_CBOX) == BST_CHECKED); - db_set_b(0, MODULENAME, "gpgLogFlag", bgpgLogFlag); + g_plugin.setByte("gpgLogFlag", bgpgLogFlag); GetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, tmp, _countof(tmp)); - db_set_s(0, MODULENAME, "gpgLog", tmp); + g_plugin.setString("gpgLog", tmp); if (bgpgLogFlag) gpg_set_log(tmp); else gpg_set_log(nullptr); BOOL bgpgTmpFlag = (IsDlgButtonChecked(hDlg, IDC_TMPPATHON_CBOX) == BST_CHECKED); - db_set_b(0, MODULENAME, "gpgTmpFlag", bgpgTmpFlag); + g_plugin.setByte("gpgTmpFlag", bgpgTmpFlag); GetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, tmp, _countof(tmp)); - db_set_s(0, MODULENAME, "gpgTmp", tmp); + g_plugin.setString("gpgTmp", tmp); if (bgpgTmpFlag) gpg_set_tmp(tmp); else gpg_set_tmp(nullptr); @@ -1550,14 +1550,14 @@ void ListView_Sort(HWND hLV, LPARAM lParamSort) char t[32]; mir_snprintf(t, "os%02x", (UINT)lParamSort & 0xF0); if ((lParamSort & 0x0F) == 0) - lParamSort = (int)db_get_b(0, MODULENAME, t, lParamSort + 1); + lParamSort = (int)g_plugin.getByte(t, lParamSort + 1); - db_set_b(0, MODULENAME, t, (BYTE)lParamSort); + g_plugin.setByte(t, (BYTE)lParamSort); // restore sort order mir_snprintf(t, "os%02x", (UINT)lParamSort); - int m = db_get_b(0, MODULENAME, t, 0); - if (bChangeSortOrder) { m = !m; db_set_b(0, MODULENAME, t, m); } + int m = g_plugin.getByte(t, 0); + if (bChangeSortOrder) { m = !m; g_plugin.setByte(t, m); } ListView_SortItems(hLV, &CompareFunc, lParamSort | (m << 8)); } diff --git a/plugins/SecureIM/src/popupOptions.cpp b/plugins/SecureIM/src/popupOptions.cpp index f7dd998e49..2091d6294c 100644 --- a/plugins/SecureIM/src/popupOptions.cpp +++ b/plugins/SecureIM/src/popupOptions.cpp @@ -3,22 +3,22 @@ static void RefreshPopupOptionsDlg(HWND hec, HWND hdc, HWND hss, HWND hsr, HWND hks, HWND hkr) { // ec checkbox - SendMessage(hec, BM_SETCHECK, db_get_b(0, MODULENAME, "ec", 1), 0L); + SendMessage(hec, BM_SETCHECK, g_plugin.getByte("ec", 1), 0L); // dc checkbox - SendMessage(hdc, BM_SETCHECK, db_get_b(0, MODULENAME, "dc", 1), 0L); + SendMessage(hdc, BM_SETCHECK, g_plugin.getByte("dc", 1), 0L); // ks checkbox - SendMessage(hks, BM_SETCHECK, db_get_b(0, MODULENAME, "ks", 1), 0L); + SendMessage(hks, BM_SETCHECK, g_plugin.getByte("ks", 1), 0L); // kr checkbox - SendMessage(hkr, BM_SETCHECK, db_get_b(0, MODULENAME, "kr", 1), 0L); + SendMessage(hkr, BM_SETCHECK, g_plugin.getByte("kr", 1), 0L); //ss checkbox - SendMessage(hss, BM_SETCHECK, db_get_b(0, MODULENAME, "ss", 0), 0L); + SendMessage(hss, BM_SETCHECK, g_plugin.getByte("ss", 0), 0L); //sr checkbox - SendMessage(hsr, BM_SETCHECK, db_get_b(0, MODULENAME, "sr", 0), 0L); + SendMessage(hsr, BM_SETCHECK, g_plugin.getByte("sr", 0), 0L); } INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) @@ -41,34 +41,34 @@ INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l char *timeout; //set timeout value for Key - if (db_get_s(0, MODULENAME, "timeoutKey", &dbv) == 0) timeout = dbv.pszVal; + if (g_plugin.getString("timeoutKey", &dbv) == 0) timeout = dbv.pszVal; else timeout = "0"; SetDlgItemText(hDlg, IDC_TIMEKEY, timeout); db_free(&dbv); //set timeout value for SEC - if (db_get_s(0, MODULENAME, "timeoutSec", &dbv) == 0) timeout = dbv.pszVal; + if (g_plugin.getString("timeoutSec", &dbv) == 0) timeout = dbv.pszVal; else timeout = "0"; SetDlgItemText(hDlg, IDC_TIMESEC, timeout); db_free(&dbv); //set timeout value for SR - if (db_get_s(0, MODULENAME, "timeoutSR", &dbv) == 0) timeout = dbv.pszVal; + if (g_plugin.getString("timeoutSR", &dbv) == 0) timeout = dbv.pszVal; else timeout = "0"; SetDlgItemText(hDlg, IDC_TIMESR, timeout); db_free(&dbv); //key color - SendDlgItemMessage(hDlg, IDC_BACKKEY, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorKeyb", RGB(230, 230, 255))); - SendDlgItemMessage(hDlg, IDC_TEXTKEY, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorKeyt", RGB(0, 0, 0))); + SendDlgItemMessage(hDlg, IDC_BACKKEY, CPM_SETCOLOUR, 0, g_plugin.getDword("colorKeyb", RGB(230, 230, 255))); + SendDlgItemMessage(hDlg, IDC_TEXTKEY, CPM_SETCOLOUR, 0, g_plugin.getDword("colorKeyt", RGB(0, 0, 0))); //Session color - SendDlgItemMessage(hDlg, IDC_BACKSEC, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorSecb", RGB(255, 255, 200))); - SendDlgItemMessage(hDlg, IDC_TEXTSEC, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorSect", RGB(0, 0, 0))); + SendDlgItemMessage(hDlg, IDC_BACKSEC, CPM_SETCOLOUR, 0, g_plugin.getDword("colorSecb", RGB(255, 255, 200))); + SendDlgItemMessage(hDlg, IDC_TEXTSEC, CPM_SETCOLOUR, 0, g_plugin.getDword("colorSect", RGB(0, 0, 0))); //SR color - SendDlgItemMessage(hDlg, IDC_BACKSR, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorSRb", RGB(200, 255, 200))); - SendDlgItemMessage(hDlg, IDC_TEXTSR, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorSRt", RGB(0, 0, 0))); + SendDlgItemMessage(hDlg, IDC_BACKSR, CPM_SETCOLOUR, 0, g_plugin.getDword("colorSRb", RGB(200, 255, 200))); + SendDlgItemMessage(hDlg, IDC_TEXTSR, CPM_SETCOLOUR, 0, g_plugin.getDword("colorSRt", RGB(0, 0, 0))); break; case WM_COMMAND: @@ -78,22 +78,22 @@ INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l switch (LOWORD(wParam)) { case IDC_BACKKEY: - db_set_dw(0, MODULENAME, "colorKeyb", color); + g_plugin.setDword("colorKeyb", color); break; case IDC_TEXTKEY: - db_set_dw(0, MODULENAME, "colorKeyt", color); + g_plugin.setDword("colorKeyt", color); break; case IDC_BACKSEC: - db_set_dw(0, MODULENAME, "colorSecb", color); + g_plugin.setDword("colorSecb", color); break; case IDC_TEXTSEC: - db_set_dw(0, MODULENAME, "colorSect", color); + g_plugin.setDword("colorSect", color); break; case IDC_BACKSR: - db_set_dw(0, MODULENAME, "colorSRb", color); + g_plugin.setDword("colorSRb", color); break; case IDC_TEXTSR: - db_set_dw(0, MODULENAME, "colorSRt", color); + g_plugin.setDword("colorSRt", color); break; } return TRUE; @@ -108,45 +108,45 @@ INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l break; case IDC_EC: //set ec checkbox value - db_set_b(0, MODULENAME, "ec", (BYTE)(SendMessage(hec, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); + g_plugin.setByte("ec", (BYTE)(SendMessage(hec, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_DC: //set dc checkbox value - db_set_b(0, MODULENAME, "dc", (BYTE)(SendMessage(hdc, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); + g_plugin.setByte("dc", (BYTE)(SendMessage(hdc, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_SS: //set ss checkbox value - db_set_b(0, MODULENAME, "ss", (BYTE)(SendMessage(hss, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); + g_plugin.setByte("ss", (BYTE)(SendMessage(hss, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_SR: //set sr checkbox value - db_set_b(0, MODULENAME, "sr", (BYTE)(SendMessage(hsr, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); + g_plugin.setByte("sr", (BYTE)(SendMessage(hsr, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_KS: //set indicator checkbox value - db_set_b(0, MODULENAME, "ks", (BYTE)(SendMessage(hks, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); + g_plugin.setByte("ks", (BYTE)(SendMessage(hks, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_KR: //set indicator checkbox value - db_set_b(0, MODULENAME, "kr", (BYTE)(SendMessage(hkr, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); + g_plugin.setByte("kr", (BYTE)(SendMessage(hkr, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_TIMEKEY: //set timeout value GetDlgItemText(hDlg, IDC_TIMEKEY, getTimeout, _countof(getTimeout)); mir_itoa(atoi(getTimeout), getTimeout, 10); - db_set_s(0, MODULENAME, "timeoutKey", getTimeout); + g_plugin.setString("timeoutKey", getTimeout); break; case IDC_TIMESEC: //set timeout value GetDlgItemText(hDlg, IDC_TIMESEC, getTimeout, _countof(getTimeout)); mir_itoa(atoi(getTimeout), getTimeout, 10); - db_set_s(0, MODULENAME, "timeoutSec", getTimeout); + g_plugin.setString("timeoutSec", getTimeout); break; case IDC_TIMESR: //set timeout value GetDlgItemText(hDlg, IDC_TIMESR, getTimeout, _countof(getTimeout)); mir_itoa(atoi(getTimeout), getTimeout, 10); - db_set_s(0, MODULENAME, "timeoutSR", getTimeout); + g_plugin.setString("timeoutSR", getTimeout); break; } diff --git a/plugins/SecureIM/src/splitmsg.cpp b/plugins/SecureIM/src/splitmsg.cpp index 7388d55bb2..c44f546ffe 100644 --- a/plugins/SecureIM/src/splitmsg.cpp +++ b/plugins/SecureIM/src/splitmsg.cpp @@ -9,8 +9,8 @@ LPSTR splitMsg(LPSTR szMsg, int iLen) LPSTR out = (LPSTR)mir_alloc(len * 2); LPSTR buf = out; - WORD msg_id = db_get_w(0, MODULENAME, "msgid", 0) + 1; - db_set_w(0, MODULENAME, "msgid", msg_id); + WORD msg_id = g_plugin.getWord("msgid", 0) + 1; + g_plugin.setWord("msgid", msg_id); size_t part_all = (len + iLen - 1) / iLen; for (size_t part_num = 0; part_numrsa_gen_keypair(CPP_MODE_RSA_4096); mir_exp->rsa_get_keypair(CPP_MODE_RSA_4096, (PBYTE)&priv_key, &priv_len, (PBYTE)&pub_key, &pub_len); - db_set_blob(NULL, MODULENAME, "rsa_priv", priv_key, priv_len); - db_set_blob(NULL, MODULENAME, "rsa_pub", pub_key, pub_len); + db_set_blob(0, MODULENAME, "rsa_priv", priv_key, priv_len); + db_set_blob(0, MODULENAME, "rsa_pub", pub_key, pub_len); rsa_4096 = 1; } -- cgit v1.2.3