summaryrefslogtreecommitdiff
path: root/plugins/New_GPG
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/New_GPG')
-rwxr-xr-xplugins/New_GPG/src/main.cpp14
-rwxr-xr-xplugins/New_GPG/src/messages.cpp46
-rwxr-xr-xplugins/New_GPG/src/options.cpp50
-rwxr-xr-xplugins/New_GPG/src/srmm.cpp8
-rwxr-xr-xplugins/New_GPG/src/ui.cpp4
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp34
6 files changed, 78 insertions, 78 deletions
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp
index 81e162fff5..c9fd96bcdf 100755
--- a/plugins/New_GPG/src/main.cpp
+++ b/plugins/New_GPG/src/main.cpp
@@ -284,7 +284,7 @@ void ImportKey(MCONTACT hContact, std::wstring new_key)
}
else db_set_ws(metaGetMostOnline(hContact), MODULENAME, "GPGPubKey", new_key.c_str());
}
- else db_set_ws(hContact, MODULENAME, "GPGPubKey", new_key.c_str());
+ else g_plugin.setWString(hContact, "GPGPubKey", new_key.c_str());
// gpg execute block
std::vector<wstring> cmd;
@@ -454,7 +454,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(hContact, MODULENAME, "KeyID", output.substr(s, s2 - s).c_str());
+ g_plugin.setString(hContact, "KeyID", output.substr(s, s2 - s).c_str());
s = output.find("“", s2);
if (s == string::npos) {
s = output.find("\"", s2);
@@ -475,7 +475,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, MODULENAME, "KeyMainName", tmp);
+ g_plugin.setString(hContact, "KeyMainName", tmp);
mir_free(tmp);
}
if ((s = output.find(")", s2)) == string::npos)
@@ -488,7 +488,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, MODULENAME, "KeyComment", tmp);
+ g_plugin.setString(hContact, "KeyComment", tmp);
mir_free(tmp);
s += 3;
s2 = output.find(">", s);
@@ -496,7 +496,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, MODULENAME, "KeyMainEmail", tmp);
+ g_plugin.setString(hContact, "KeyMainEmail", tmp);
mir_free(tmp);
}
}
@@ -504,11 +504,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, MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str());
+ g_plugin.setString(hContact, "KeyMainEmail", output.substr(s2, s - s2).c_str());
mir_free(tmp);
}
}
- db_unset(hContact, MODULENAME, "bAlwatsTrust");
+ g_plugin.delSetting(hContact, "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 526227ae1f..1189fca923 100755
--- a/plugins/New_GPG/src/messages.cpp
+++ b/plugins/New_GPG/src/messages.cpp
@@ -95,7 +95,7 @@ static void RecvMsgSvc_func(RecvParams *param)
::Sleep(step);
count += step;
if (count >= timeout) {
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0);
+ g_plugin.setByte(hContact, "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");
@@ -167,11 +167,11 @@ static void RecvMsgSvc_func(RecvParams *param)
boost::filesystem::remove(path, e);
}
HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
- BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0);
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0);
+ BYTE enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
+ g_plugin.setByte(hContact, "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, MODULENAME, "GPGEncryption", enc);
+ g_plugin.setByte(hContact, "GPGEncryption", enc);
delete param;
return;
}
@@ -192,11 +192,11 @@ static void RecvMsgSvc_func(RecvParams *param)
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, MODULENAME, "GPGEncryption", 0);
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0);
+ BYTE enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
+ g_plugin.setByte(hContact, "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, MODULENAME, "GPGEncryption", enc);
+ g_plugin.setByte(hContact, "GPGEncryption", enc);
break;
}
{ //save inkey id
@@ -230,11 +230,11 @@ static void RecvMsgSvc_func(RecvParams *param)
}
HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
- BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0);
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0);
+ BYTE enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
+ g_plugin.setByte(hContact, "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, MODULENAME, "GPGEncryption", enc);
+ g_plugin.setByte(hContact, "GPGEncryption", enc);
delete param;
return;
}
@@ -257,11 +257,11 @@ static void RecvMsgSvc_func(RecvParams *param)
}
HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
- BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0);
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0);
+ BYTE enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
+ g_plugin.setByte(hContact, "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, MODULENAME, "GPGEncryption", enc);
+ g_plugin.setByte(hContact, "GPGEncryption", enc);
delete param;
return;
}
@@ -289,11 +289,11 @@ static void RecvMsgSvc_func(RecvParams *param)
ptrA tmp4((char*)mir_alloc(sizeof(char)*(str1.length() + 1)));
mir_strcpy(tmp4, str1.c_str());
HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
- BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0);
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0);
+ BYTE enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
+ g_plugin.setByte(hContact, "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, MODULENAME, "GPGEncryption", enc);
+ g_plugin.setByte(hContact, "GPGEncryption", enc);
delete param;
return;
}
@@ -329,11 +329,11 @@ static void RecvMsgSvc_func(RecvParams *param)
globals.debuglog << std::string(time_str() + ": info: Failed to decrypt GPG encrypted message.");
HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
- BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0);
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0);
+ BYTE enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
+ g_plugin.setByte(hContact, "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, MODULENAME, "GPGEncryption", enc);
+ g_plugin.setByte(hContact, "GPGEncryption", enc);
delete param;
return;
}
@@ -629,7 +629,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, MODULENAME, "bAlwaysTrust", 0)) {
+ if (g_plugin.getByte(hContact, "bAlwaysTrust", 0)) {
cmd.push_back(L"--trust-model");
cmd.push_back(L"always");
}
@@ -658,7 +658,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
::Sleep(step);
count += step;
if (count >= timeout) {
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0); //disable encryption
+ g_plugin.setByte(hContact, "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");
@@ -693,7 +693,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, MODULENAME, "bAlwaysTrust", 1);
+ g_plugin.setByte(hContact, "bAlwaysTrust", 1);
std::vector<std::wstring> tmp;
tmp.push_back(L"--trust-model");
tmp.push_back(L"always");
@@ -739,7 +739,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
f.open(path.c_str(), std::ios::in | std::ios::ate | std::ios::binary);
count += step;
if (count >= timeout) {
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0); //disable encryption
+ g_plugin.setByte(hContact, "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 abf4af389d..b42c4f8d30 100755
--- a/plugins/New_GPG/src/options.cpp
+++ b/plugins/New_GPG/src/options.cpp
@@ -95,7 +95,7 @@ public:
mir_free(tmp);
- if (db_get_b(hContact, MODULENAME, "GPGEncryption", 0))
+ if (g_plugin.getByte(hContact, "GPGEncryption", 0))
list_USERLIST.SetCheckState(row, 1);
user_data[i] = hContact;
list_USERLIST.SetColumnWidth(0, LVSCW_AUTOSIZE);
@@ -233,12 +233,12 @@ public:
}
}
else {
- 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");
+ g_plugin.delSetting(hContact, "KeyID");
+ g_plugin.delSetting(hContact, "GPGPubKey");
+ g_plugin.delSetting(hContact, "KeyMainName");
+ g_plugin.delSetting(hContact, "KeyType");
+ g_plugin.delSetting(hContact, "KeyMainEmail");
+ g_plugin.delSetting(hContact, "KeyComment");
setClistIcon(hContact);
setSrmmIcon(hContact);
}
@@ -730,7 +730,7 @@ public:
}
else db_set_ws(metaGetMostOnline(hContact), MODULENAME, "GPGPubKey", key_buf.substr(ws1, ws2 - ws1).c_str());
}
- else db_set_ws(hContact, MODULENAME, "GPGPubKey", key_buf.substr(ws1, ws2 - ws1).c_str());
+ else g_plugin.setWString(hContact, "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());
@@ -785,7 +785,7 @@ public:
}
else db_unset(metaGetMostOnline(hContact), MODULENAME, "bAlwatsTrust");
}
- else db_unset(hContact, MODULENAME, "bAlwatsTrust");
+ else g_plugin.delSetting(hContact, "bAlwatsTrust");
}
{
if (output.find("already in secret keyring") != string::npos) {
@@ -813,7 +813,7 @@ public:
db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyID", tmp3);
}
else
- db_set_s(hContact, MODULENAME, "KeyID", tmp3);
+ g_plugin.setString(hContact, "KeyID", tmp3);
}
mir_free(tmp3);
}
@@ -849,12 +849,12 @@ public:
for (int i = 0; i < count; i++) {
MCONTACT hcnt = db_mc_getSub(hContact, i);
if (hcnt)
- db_set_s(hcnt, MODULENAME, "KeyMainName", output.substr(s, s2 - s - 1).c_str());
+ g_plugin.setString(hcnt, "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 g_plugin.setString(metaGetMostOnline(hContact), "KeyMainName", output.substr(s, s2 - s - 1).c_str());
}
- else db_set_s(hContact, MODULENAME, "KeyMainName", output.substr(s, s2 - s - 1).c_str());
+ else g_plugin.setString(hContact, "KeyMainName", output.substr(s, s2 - s - 1).c_str());
}
mir_free(tmp3);
}
@@ -879,12 +879,12 @@ public:
for (int i = 0; i < count; i++) {
MCONTACT hcnt = db_mc_getSub(hContact, i);
if (hcnt)
- db_set_s(hcnt, MODULENAME, "KeyComment", output.substr(s2, s - s2).c_str());
+ g_plugin.setString(hcnt, "KeyComment", output.substr(s2, s - s2).c_str());
}
}
- else db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyComment", output.substr(s2, s - s2).c_str());
+ else g_plugin.setString(metaGetMostOnline(hContact), "KeyComment", output.substr(s2, s - s2).c_str());
}
- else db_set_s(hContact, MODULENAME, "KeyComment", output.substr(s2, s - s2).c_str());
+ else g_plugin.setString(hContact, "KeyComment", output.substr(s2, s - s2).c_str());
}
mir_free(tmp3);
s += 3;
@@ -899,12 +899,12 @@ public:
for (int i = 0; i < count; i++) {
MCONTACT hcnt = db_mc_getSub(hContact, i);
if (hcnt)
- db_set_s(hcnt, MODULENAME, "KeyMainEmail", output.substr(s, s2 - s).c_str());
+ g_plugin.setString(hcnt, "KeyMainEmail", output.substr(s, s2 - s).c_str());
}
}
- else db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyMainEmail", output.substr(s, s2 - s).c_str());
+ else g_plugin.setString(metaGetMostOnline(hContact), "KeyMainEmail", output.substr(s, s2 - s).c_str());
}
- else db_set_s(hContact, MODULENAME, "KeyMainEmail", output.substr(s, s2 - s).c_str());
+ else g_plugin.setString(hContact, "KeyMainEmail", output.substr(s, s2 - s).c_str());
}
mir_free(tmp3);
tmp = mir_wstrdup(toUTF16(output.substr(s, s2 - s)).c_str());
@@ -923,12 +923,12 @@ public:
for (int i = 0; i < count; i++) {
MCONTACT hcnt = db_mc_getSub(hContact, i);
if (hcnt)
- db_set_s(hcnt, MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str());
+ g_plugin.setString(hcnt, "KeyMainEmail", output.substr(s2, s - s2).c_str());
}
}
- else db_set_s(metaGetMostOnline(hContact), MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str());
+ else g_plugin.setString(metaGetMostOnline(hContact), "KeyMainEmail", output.substr(s2, s - s2).c_str());
}
- else db_set_s(hContact, MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str());
+ else g_plugin.setString(hContact, "KeyMainEmail", output.substr(s2, s - s2).c_str());
}
mir_free(tmp3);
tmp = mir_wstrdup(toUTF16(output.substr(s2, s - s2)).c_str());
@@ -970,7 +970,7 @@ public:
while ((s = out.find("\r", s)) != string::npos) {
out.erase(s, 1);
}
- db_set_s(hContact, MODULENAME, "GPGPubKey", out.c_str());
+ g_plugin.setString(hContact, "GPGPubKey", out.c_str());
}
}
tmp = mir_wstrdup(toUTF16(output).c_str());
@@ -1002,9 +1002,9 @@ public:
db_set_b(metaGetMostOnline(hContact), MODULENAME, "GPGEncryption", 0);
}
else if (!isContactSecured(hContact))
- db_set_b(hContact, MODULENAME, "GPGEncryption", 1);
+ g_plugin.setByte(hContact, "GPGEncryption", 1);
else
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0);
+ g_plugin.setByte(hContact, "GPGEncryption", 0);
}
}
this->Close();
diff --git a/plugins/New_GPG/src/srmm.cpp b/plugins/New_GPG/src/srmm.cpp
index 129cb29570..7adf54ff34 100755
--- a/plugins/New_GPG/src/srmm.cpp
+++ b/plugins/New_GPG/src/srmm.cpp
@@ -41,9 +41,9 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam)
if (mir_strcmp(sicd->szModule, MODULENAME))
return 0; // not our event
- BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0);
+ BYTE enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
if (enc) {
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0);
+ g_plugin.setByte(hContact, "GPGEncryption", 0);
hMeta ? db_set_b(hMeta, MODULENAME, "GPGEncryption", 0) : 0;
setSrmmIcon(hContact);
setClistIcon(hContact);
@@ -56,14 +56,14 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam)
ShowLoadPublicKeyDialog();
}
else {
- db_set_b(hContact, MODULENAME, "GPGEncryption", 1);
+ g_plugin.setByte(hContact, "GPGEncryption", 1);
hMeta ? db_set_b(hMeta, MODULENAME, "GPGEncryption", 1) : 0;
setSrmmIcon(hContact);
setClistIcon(hContact);
return 0;
}
if (isContactHaveKey(hContact)) {
- db_set_b(hContact, MODULENAME, "GPGEncryption", 1);
+ g_plugin.setByte(hContact, "GPGEncryption", 1);
hMeta ? db_set_b(hMeta, MODULENAME, "GPGEncryption", 1) : 0;
setSrmmIcon(hContact);
setClistIcon(hContact);
diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp
index fdf68a5bff..e651779b50 100755
--- a/plugins/New_GPG/src/ui.cpp
+++ b/plugins/New_GPG/src/ui.cpp
@@ -944,7 +944,7 @@ bool CDlgNewKey::OnInitDialog()
SetWindowPos(m_hwnd, nullptr, globals.new_key_rect.left, globals.new_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
wchar_t *tmp = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L"");
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, MODULENAME, "GPGEncryption", 0));
+ btn_IMPORT_AND_USE.Enable(g_plugin.getByte(hContact, "GPGEncryption", 0));
btn_IMPORT.SetText(tmp[0] ? TranslateT("Replace") : TranslateT("Accept"));
mir_free(tmp);
tmp = new wchar_t[256];
@@ -970,7 +970,7 @@ void CDlgNewKey::onClick_IMPORT(CCtrlButton*)
void CDlgNewKey::onClick_IMPORT_AND_USE(CCtrlButton*)
{
ImportKey(hContact, new_key);
- db_set_b(hContact, MODULENAME, "GPGEncryption", 1);
+ g_plugin.setByte(hContact, "GPGEncryption", 1);
void setSrmmIcon(MCONTACT hContact);
void setClistIcon(MCONTACT hContact);
setSrmmIcon(hContact);
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index bbb140f0c7..84096558b8 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -163,8 +163,8 @@ INT_PTR SendKey(WPARAM w, LPARAM)
}
}
if (szMessage[0]) {
- BYTE enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0);
- db_set_b(hContact, MODULENAME, "GPGEncryption", 0);
+ BYTE enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
+ g_plugin.setByte(hContact, "GPGEncryption", 0);
ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)szMessage);
std::string msg = "Public key ";
char *keyid = UniGetContactSettingUtf(0, MODULENAME, key_id_str.c_str(), "");
@@ -178,7 +178,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, MODULENAME, "GPGEncryption", enc);
+ g_plugin.setByte(hContact, "GPGEncryption", enc);
}
else mir_free(szMessage);
@@ -198,12 +198,12 @@ INT_PTR ToggleEncryption(WPARAM w, LPARAM)
if (hcnt)
db_set_b(hcnt, MODULENAME, "GPGEncryption", enc ? 0 : 1);
}
- db_set_b(hContact, MODULENAME, "GPGEncryption", enc ? 0 : 1);
+ g_plugin.setByte(hContact, "GPGEncryption", enc ? 0 : 1);
}
}
else {
- enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0);
- db_set_b(hContact, MODULENAME, "GPGEncryption", enc ? 0 : 1);
+ enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
+ g_plugin.setByte(hContact, "GPGEncryption", enc ? 0 : 1);
}
void setSrmmIcon(MCONTACT hContact);
void setClistIcon(MCONTACT hContact);
@@ -243,13 +243,13 @@ int OnPreBuildContactMenu(WPARAM w, LPARAM)
int flags;
wchar_t *tmp = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L"");
if (!tmp[0]) {
- db_unset(hContact, MODULENAME, "GPGEncryption");
+ g_plugin.delSetting(hContact, "GPGEncryption");
flags = CMIF_GRAYED;
}
else flags = 0;
Menu_ModifyItem(globals.hToggleEncryption,
- db_get_b(hContact, MODULENAME, "GPGEncryption", 0) ? L"Turn off GPG encryption" : L"Turn on GPG encryption",
+ g_plugin.getByte(hContact, "GPGEncryption", 0) ? L"Turn off GPG encryption" : L"Turn on GPG encryption",
INVALID_HANDLE_VALUE, flags);
mir_free(tmp);
return 0;
@@ -938,7 +938,7 @@ void AddHandlers()
bool isContactSecured(MCONTACT hContact)
{
- BYTE gpg_enc = db_get_b(hContact, MODULENAME, "GPGEncryption", 0);
+ BYTE gpg_enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
if (!gpg_enc) {
if (globals.bDebugLog)
globals.debuglog << std::string(time_str() + ": encryption is turned off for " + toUTF8(Clist_GetContactDisplayName(hContact)));
@@ -1075,7 +1075,7 @@ const bool StriStr(const char *str, const char *substr)
bool IsOnline(MCONTACT hContact)
{
- if (db_get_b(hContact, MODULENAME, "Status", 0) == ID_STATUS_OFFLINE)
+ if (g_plugin.getByte(hContact, "Status", 0) == ID_STATUS_OFFLINE)
return false;
return true;
}
@@ -1632,7 +1632,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, MODULENAME, "KeyID", tmp2);
+ g_plugin.setString(hContact, "KeyID", tmp2);
mir_free(tmp2);
s = output.find("“", s2);
if (s == string::npos) {
@@ -1650,7 +1650,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, MODULENAME, "KeyMainName", output.substr(s, s2 - s - 1).c_str());
+ g_plugin.setString(hContact, "KeyMainName", output.substr(s, s2 - s - 1).c_str());
}
mir_free(tmp2);
if ((s = output.find(")", s2)) == string::npos)
@@ -1663,7 +1663,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, MODULENAME, "KeyComment", output.substr(s2, s - s2).c_str());
+ g_plugin.setString(hContact, "KeyComment", output.substr(s2, s - s2).c_str());
mir_free(tmp2);
s += 3;
s2 = output.find(">", s);
@@ -1671,7 +1671,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, MODULENAME, "KeyMainEmail", output.substr(s, s2 - s).c_str());
+ g_plugin.setString(hContact, "KeyMainEmail", output.substr(s, s2 - s).c_str());
mir_free(tmp2);
}
else {
@@ -1679,12 +1679,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, MODULENAME, "KeyMainEmail", output.substr(s2, s - s2).c_str());
+ g_plugin.setString(hContact, "KeyMainEmail", output.substr(s2, s - s2).c_str());
mir_free(tmp2);
}
}
- db_set_b(hContact, MODULENAME, "GPGEncryption", 1);
- db_set_ws(hContact, MODULENAME, "GPGPubKey", toUTF16(key).c_str());
+ g_plugin.setByte(hContact, "GPGEncryption", 1);
+ g_plugin.setWString(hContact, "GPGPubKey", toUTF16(key).c_str());
}
boost::filesystem::remove(path);
break;