summaryrefslogtreecommitdiff
path: root/plugins/New_GPG
diff options
context:
space:
mode:
authorAlexander Gluzsky <sss123next@list.ru>2012-09-06 17:23:18 +0000
committerAlexander Gluzsky <sss123next@list.ru>2012-09-06 17:23:18 +0000
commit01b0b96f85cd5b4a55adb48cda4a01ba3a2b87fc (patch)
treecfb9f38b98ca45d160c7bae465207366bb57bfd4 /plugins/New_GPG
parent89b5feca3ec270bf1312b108810f95cafa3b6be1 (diff)
logic fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@1539 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/New_GPG')
-rwxr-xr-xplugins/New_GPG/src/main.cpp136
-rwxr-xr-xplugins/New_GPG/src/messages.cpp12
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp21
3 files changed, 108 insertions, 61 deletions
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp
index 1c3574f504..ed31d221ed 100755
--- a/plugins/New_GPG/src/main.cpp
+++ b/plugins/New_GPG/src/main.cpp
@@ -163,6 +163,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
acc += "(";
acc += accounts[i]->szModuleName;
acc += ")";
+ acc += "_KeyID";
SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_ADDSTRING, 0, (LPARAM)acc.c_str());
}
SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_SELECTSTRING, 0, (LPARAM)Translate("Default"));
@@ -238,15 +239,29 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
else
{
char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_GPGPubKey");
- DBWriteContactSettingString(NULL, szGPGModuleName, setting, out.c_str());
- strcpy(setting, buf);
- strcat(setting, "_KeyMainName");
- DBWriteContactSettingTString(NULL, szGPGModuleName, setting, name);
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- DBWriteContactSettingTString(NULL, szGPGModuleName, setting, fp);
+ 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);
+ }
}
}
TCHAR passwd[64];
@@ -431,24 +446,47 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
else
{
char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_GPGPubKey");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyMainName");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyComment");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyMainEmail");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyType");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
+ 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());
+ }
}
}
ListView_DeleteItem(hwndList, itemnum);
@@ -564,12 +602,23 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
else
{
char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_GPGPubKey");
- DBWriteContactSettingString(NULL, szGPGModuleName, setting, out.c_str());
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- DBWriteContactSettingTString(NULL, szGPGModuleName, setting, fp);
+ 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);
+ }
}
}
extern HWND hwndCurKey_p;
@@ -596,12 +645,21 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
string keyinfo = Translate("key id");
keyinfo += ": ";
char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, setting, "");
- keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set");
- mir_free(keyid);
- SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str());
+ 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());
+ }
+
}
}
break;
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp
index 7b7766e3f2..5dc673c024 100755
--- a/plugins/New_GPG/src/messages.cpp
+++ b/plugins/New_GPG/src/messages.cpp
@@ -664,17 +664,7 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags)
wstring file = toUTF16(get_random(10));
wstring path;
extern bool bJabberAPI, bIsMiranda09;
- LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)proto);
- std::string acc_str;
- if(acc)
- {
- acc_str = toUTF8(acc->tszAccountName);
- acc_str += "(";
- acc_str += acc->szModuleName;
- acc_str += ")" ;
- }
- char *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, acc_str.empty()?"KeyID":acc_str.c_str(), "");
+ char *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", "");
if(!tmp[0])
{
mir_free(tmp);
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index c07be132d2..f15fb23706 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -148,19 +148,18 @@ int SendKey(WPARAM w, LPARAM l)
hContact = metaGetMostOnline(hContact);
char *szMessage;
{
- char *proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- char setting[64];
- if(proto)
+ LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)proto);
+ std::string acc_str;
+ if(acc)
{
- strcpy(setting, proto);
- strcat(setting, "_GPGPubKey");
- szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, setting, "");
- }
- if(!szMessage[0])
- {
- mir_free(szMessage);
- szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", "");
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_GPGPubKey";
}
+ char *szMessage = UniGetContactSettingUtf(hContact, szGPGModuleName, acc_str.empty()?"GPGPubKey":acc_str.c_str(), "");
}
if(szMessage[0])
{