summaryrefslogtreecommitdiff
path: root/plugins/SecureIM/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-06-30 12:16:44 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-06-30 12:16:44 +0000
commit25ec54ea27a7099f33573b260a620ed7273176fe (patch)
tree1810a0cb35d23deeed9ccdaf0ab276a4022f9a41 /plugins/SecureIM/src
parenta546606709e6bb72e01eb38b2c8c8756608fd5d6 (diff)
- db_set_blob used everywhere for writing blobs
- DBCONTACTWRITESETTING left only in the event handlers git-svn-id: http://svn.miranda-ng.org/main/trunk@5191 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SecureIM/src')
-rw-r--r--plugins/SecureIM/src/crypt_dll.cpp14
-rw-r--r--plugins/SecureIM/src/main.cpp21
-rw-r--r--plugins/SecureIM/src/options.cpp11
-rw-r--r--plugins/SecureIM/src/svcs_menu.cpp9
-rw-r--r--plugins/SecureIM/src/svcs_rsa.cpp25
5 files changed, 12 insertions, 68 deletions
diff --git a/plugins/SecureIM/src/crypt_dll.cpp b/plugins/SecureIM/src/crypt_dll.cpp
index 4b3c73c088..05220acf99 100644
--- a/plugins/SecureIM/src/crypt_dll.cpp
+++ b/plugins/SecureIM/src/crypt_dll.cpp
@@ -87,21 +87,11 @@ BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact) {
// store key
cpp_get_keyx(ptr->cntx,buffer);
- DBCONTACTWRITESETTING cws;
- cws.szModule = MODULENAME;
-
// store key in database
- cws.szSetting = "offlineKey";
- cws.value.type = DBVT_BLOB;
- cws.value.cpbVal = keysize;
- cws.value.pbVal = buffer;
- CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws);
+ db_set_blob(hContact, MODULENAME, "offlineKey", buffer, keysize);
// store timeout of key in database (2 days)
- cws.szSetting = "offlineKeyTimeout";
- cws.value.type = DBVT_DWORD;
- cws.value.dVal = gettime()+(60*60*24*db_get_w(0,MODULENAME,"okt",2));
- CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws);
+ db_set_dw(hContact, MODULENAME, "offlineKeyTimeout", gettime()+(60*60*24*db_get_w(0,MODULENAME,"okt",2)));
// key exchange is finished
showPopupEC(ptr->hContact);
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp
index c4c22653af..e07e91669c 100644
--- a/plugins/SecureIM/src/main.cpp
+++ b/plugins/SecureIM/src/main.cpp
@@ -161,24 +161,11 @@ int onModulesLoaded(WPARAM, LPARAM)
char priv_key[4096]; int priv_len;
char pub_key[4096]; int pub_len;
- DBCONTACTWRITESETTING cws;
- cws.szModule = MODULENAME;
- cws.value.type = DBVT_BLOB;
-
exp->rsa_get_keypair(CPP_MODE_RSA_4096,(PBYTE)&priv_key,&priv_len,(PBYTE)&pub_key,&pub_len);
-
- cws.szSetting = "rsa_priv";
- cws.value.pbVal = (PBYTE)&priv_key;
- cws.value.cpbVal = priv_len;
- CallService(MS_DB_CONTACT_WRITESETTING, 0, (LPARAM)&cws);
-
- cws.szSetting = "rsa_pub";
- cws.value.pbVal = (PBYTE)&pub_key;
- cws.value.cpbVal = pub_len;
- CallService(MS_DB_CONTACT_WRITESETTING, 0, (LPARAM)&cws);
-
- db_unset(0, MODULENAME, "rsa_priv_2048");
- db_unset(0, MODULENAME, "rsa_pub_2048");
+ 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");
rsa_4096 = 1;
}
diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp
index 795e88b14c..173447a1bb 100644
--- a/plugins/SecureIM/src/options.cpp
+++ b/plugins/SecureIM/src/options.cpp
@@ -336,15 +336,8 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR
if (!LoadImportRSAKeyDlg(hDlg,pub,0)) return TRUE;
if (exp->rsa_import_pubkey(ptr->cntx,pub)) {
int len;
- exp->rsa_get_pubkey(ptr->cntx,(PBYTE)pub,&len);
-
- DBCONTACTWRITESETTING cws;
- cws.szModule = MODULENAME;
- cws.szSetting = "rsa_pub";
- cws.value.type = DBVT_BLOB;
- cws.value.pbVal = (PBYTE)pub;
- cws.value.cpbVal = len;
- CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)ptr->hContact, (LPARAM)&cws);
+ exp->rsa_get_pubkey(ptr->cntx, (PBYTE)pub, &len);
+ db_set_blob(ptr->hContact, MODULENAME, "rsa_pub", pub, len);
setListViewPUB(hLV,idx,1);
}
diff --git a/plugins/SecureIM/src/svcs_menu.cpp b/plugins/SecureIM/src/svcs_menu.cpp
index 516e941459..f9a22638c3 100644
--- a/plugins/SecureIM/src/svcs_menu.cpp
+++ b/plugins/SecureIM/src/svcs_menu.cpp
@@ -76,14 +76,7 @@ INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam)
PVOID KeyID = pgp_select_keyid(GetForegroundWindow(),szKeyID);
if (szKeyID[0]) {
db_unset((HANDLE)wParam,MODULENAME,"pgp");
- DBCONTACTWRITESETTING cws;
- memset(&cws,0,sizeof(cws));
- cws.szModule = MODULENAME;
- cws.szSetting = "pgp";
- cws.value.type = DBVT_BLOB;
- cws.value.pbVal = (LPBYTE)KeyID;
- cws.value.cpbVal = pgp_size_keyid();
- CallService(MS_DB_CONTACT_WRITESETTING,wParam,(LPARAM)&cws);
+ db_set_blob((HANDLE)wParam, MODULENAME, "pgp", KeyID, pgp_size_keyid());
db_set_b((HANDLE)wParam,MODULENAME,"pgp_mode",0);
db_set_s((HANDLE)wParam,MODULENAME,"pgp_abbr",szKeyID);
del = false;
diff --git a/plugins/SecureIM/src/svcs_rsa.cpp b/plugins/SecureIM/src/svcs_rsa.cpp
index a55a393875..1ef0ecbbb0 100644
--- a/plugins/SecureIM/src/svcs_rsa.cpp
+++ b/plugins/SecureIM/src/svcs_rsa.cpp
@@ -68,13 +68,7 @@ int __cdecl rsa_check_pub(HANDLE context, PBYTE pub, int pubLen, PBYTE sig, int
#endif
}
if (v) {
- DBCONTACTWRITESETTING cws;
- cws.szModule = MODULENAME;
- cws.szSetting = "rsa_pub";
- cws.value.type = DBVT_BLOB;
- cws.value.pbVal = pub;
- cws.value.cpbVal = pubLen;
- CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)ptr->hContact, (LPARAM)&cws);
+ db_set_blob(ptr->hContact, MODULENAME, "rsa_pub", pub, pubLen);
ptr->keyLoaded = true;
}
mir_free(cnm);
@@ -155,23 +149,10 @@ void sttGenerateRSA(LPVOID)
char pub_key[4096]; int pub_len;
exp->rsa_gen_keypair(CPP_MODE_RSA_4096);
-
- DBCONTACTWRITESETTING cws;
- cws.szModule = MODULENAME;
- cws.value.type = DBVT_BLOB;
-
exp->rsa_get_keypair(CPP_MODE_RSA_4096,(PBYTE)&priv_key,&priv_len,(PBYTE)&pub_key,&pub_len);
- cws.szSetting = "rsa_priv";
- cws.value.pbVal = (PBYTE)&priv_key;
- cws.value.cpbVal = priv_len;
- CallService(MS_DB_CONTACT_WRITESETTING, 0, (LPARAM)&cws);
-
- cws.szSetting = "rsa_pub";
- cws.value.pbVal = (PBYTE)&pub_key;
- cws.value.cpbVal = pub_len;
- CallService(MS_DB_CONTACT_WRITESETTING, 0, (LPARAM)&cws);
-
+ db_set_blob(NULL, MODULENAME, "rsa_priv", priv_key, priv_len);
+ db_set_blob(NULL, MODULENAME, "rsa_pub", pub_key, pub_len);
rsa_4096 = 1;
}