diff options
-rwxr-xr-x | src/icons.cpp | 4 | ||||
-rwxr-xr-x | src/init.cpp | 17 | ||||
-rwxr-xr-x | src/main.cpp | 154 | ||||
-rwxr-xr-x | src/options.cpp | 4 | ||||
-rwxr-xr-x | src/utilities.cpp | 13 |
5 files changed, 61 insertions, 131 deletions
diff --git a/src/icons.cpp b/src/icons.cpp index a1d02df..3f89da2 100755 --- a/src/icons.cpp +++ b/src/icons.cpp @@ -141,11 +141,11 @@ void RefreshContactListIcons() {
extern HANDLE g_hCLIcon;
CallService(MS_CLUI_LISTBEGINREBUILD,0,0);
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ HANDLE hContact = db_find_first();
while (hContact)
{
setClistIcon(hContact);
- hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
+ hContact = db_find_next(hContact);
}
CallService(MS_CLUI_LISTENDREBUILD,0,0);
}
diff --git a/src/init.cpp b/src/init.cpp index 6c66793..24f8fe2 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -169,13 +169,6 @@ extern "C" int __declspec(dllexport) Load() return 0;
}
-int AddContact(WPARAM w, LPARAM l)
-{
- CallService(MS_PROTO_ADDTOCONTACT,w,(LPARAM)szGPGModuleName);
- return 0;
-}
-
-
static int OnModulesLoaded(WPARAM wParam,LPARAM lParam)
{
@@ -257,21 +250,13 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) CreateProtoServiceFunction(szGPGModuleName, PSS_FILE, (MIRANDASERVICE)onSendFile);
CreateProtoServiceFunction(szGPGModuleName, PSS_FILE"W", (MIRANDASERVICE)onSendFile);
-
- for (HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0))
- if (!CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)szGPGModuleName))
- CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)szGPGModuleName);
-
- HookEvent(ME_DB_CONTACT_ADDED,AddContact);
-
-
return 0;
}
extern list<wstring> transfers;
extern "C" int __declspec(dllexport) Unload(void)
{
-// for (HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0))
+// for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
// DBDeleteContactSetting(hContact, szGPGModuleName, "KeyID_Prescense");
if(!transfers.empty())
{
diff --git a/src/main.cpp b/src/main.cpp index 0908fc9..b38d57c 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -238,30 +238,23 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR } else { - char setting[64]; - PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)buf); - std::string acc_str; - if(acc) - { - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_GPGPubKey"; - DBWriteContactSettingString(NULL, szGPGModuleName, acc_str.c_str(), out.c_str()); - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_KeyMainName"; - DBWriteContactSettingTString(NULL, szGPGModuleName, acc_str.c_str(), name); - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_KeyID"; - DBWriteContactSettingTString(NULL, szGPGModuleName, acc_str.c_str(), fp); - } + std::string acc_str = buf; + acc_str += "_GPGPubKey"; + DBWriteContactSettingString(NULL, szGPGModuleName, acc_str.c_str(), out.c_str()); + acc_str = buf; + acc_str += "_KeyMainName"; + DBWriteContactSettingTString(NULL, szGPGModuleName, acc_str.c_str(), name); + acc_str = buf; + acc_str += "_KeyID"; + DBWriteContactSettingTString(NULL, szGPGModuleName, acc_str.c_str(), fp); + } + if(!strcmp(buf, Translate("Default"))) + { + wstring keyinfo = TranslateT("Default private key id"); + keyinfo += _T(": "); + keyinfo += (fp[0])?fp:_T("not set"); + extern HWND hwndCurKey_p; + SetWindowText(hwndCurKey_p, keyinfo.c_str()); } } TCHAR passwd[64]; @@ -275,13 +268,6 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR dbsetting += "_Password"; DBWriteContactSettingTString(NULL, szGPGModuleName, dbsetting.c_str(), passwd); } - { - wstring keyinfo = TranslateT("Default private key id"); - keyinfo += _T(": "); - keyinfo += (fp[0])?fp:_T("not set"); - extern HWND hwndCurKey_p; - SetWindowText(hwndCurKey_p, keyinfo.c_str()); - } delete [] name; } bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange"); @@ -445,48 +431,24 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR } else { - char setting[64]; - PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)buf); - std::string acc_str; - if(acc) - { - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_GPGPubKey"; - DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_KeyMainName"; - DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_KeyID"; - DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_KeyComment"; - DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_KeyMainEmail"; - DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_KeyType"; - DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); - } + std::string acc_str = buf; + acc_str += "_GPGPubKey"; + DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); + acc_str = buf; + acc_str += "_KeyMainName"; + DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); + acc_str = buf; + acc_str += "_KeyID"; + DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); + acc_str = buf; + acc_str += "_KeyComment"; + DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); + acc_str = buf; + acc_str += "_KeyMainEmail"; + DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); + acc_str = buf; + acc_str += "_KeyType"; + DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str()); } } ListView_DeleteItem(hwndList, itemnum); @@ -601,24 +563,12 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR } else { - char setting[64]; - PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)buf); - std::string acc_str; - if(acc) - { - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_GPGPubKey"; - DBWriteContactSettingString(NULL, szGPGModuleName, acc_str.c_str(), out.c_str()); - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_KeyID"; - DBWriteContactSettingTString(NULL, szGPGModuleName, acc_str.c_str(), fp); - } + std::string acc_str = buf; + acc_str += "_GPGPubKey"; + DBWriteContactSettingString(NULL, szGPGModuleName, acc_str.c_str(), out.c_str()); + acc_str = buf; + acc_str += "_KeyID"; + DBWriteContactSettingTString(NULL, szGPGModuleName, acc_str.c_str(), fp); } } extern HWND hwndCurKey_p; @@ -644,22 +594,12 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR { string keyinfo = Translate("key id"); keyinfo += ": "; - char setting[64]; - PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)buf); - std::string acc_str; - if(acc) - { - acc_str = toUTF8(acc->tszAccountName); - acc_str += "("; - acc_str += acc->szModuleName; - acc_str += ")" ; - acc_str += "_KeyID"; - char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, acc_str.c_str(), ""); - keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set"); - mir_free(keyid); - SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str()); - } - + std::string acc_str= buf; + acc_str += "_KeyID"; + char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, acc_str.c_str(), ""); + keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set"); + mir_free(keyid); + SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str()); } } break; diff --git a/src/options.cpp b/src/options.cpp index af33060..bbb454a 100755 --- a/src/options.cpp +++ b/src/options.cpp @@ -145,7 +145,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);
int i = 1, iRow = 0;
bool isContactHaveKey(HANDLE);
- for(HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact != NULL; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0))
+ for(HANDLE hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) {
if(isContactHaveKey(hContact))
{
@@ -241,7 +241,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP ismetacontact = true;
}
tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", "");
- for(HANDLE hcnttmp = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hcnttmp != NULL; hcnttmp = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hcnttmp, 0))
+ for(HANDLE hcnttmp = db_find_first(); hcnttmp != NULL; hcnttmp = db_find_next(hcnttmp)) {
if(hcnttmp != hContact)
{
diff --git a/src/utilities.cpp b/src/utilities.cpp index ef808b4..566bc87 100755 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -196,7 +196,7 @@ INT_PTR SendKey(WPARAM w, LPARAM l) char *szMessage; { LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)proto); + PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)proto); std::string acc_str; if(acc) { @@ -206,7 +206,12 @@ INT_PTR SendKey(WPARAM w, LPARAM l) acc_str += ")" ; acc_str += "_GPGPubKey"; } - szMessage = UniGetContactSettingUtf(hContact, szGPGModuleName, acc_str.empty()?"GPGPubKey":acc_str.c_str(), ""); + szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, 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 + } } if(szMessage[0]) { @@ -1353,7 +1358,7 @@ INT_PTR ExportGpGKeys(WPARAM w, LPARAM l) int exported_keys = 0; if(!file.is_open()) return 1; //TODO: handle error - for(HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { char *k = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", ""); if(!k[0]) @@ -1621,7 +1626,7 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) if(acc.length()) { const char * uid = (const char*)CallProtoService(acc.c_str(), PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); - for(HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, (LPARAM)acc.c_str()); hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, (LPARAM)acc.c_str())) + for(HANDLE hContact = db_find_first(acc.c_str()); hContact; hContact = db_find_next(hContact, acc.c_str())) { DBVARIANT dbv = {0}; DBCONTACTGETSETTING dbcgs = {0}; |