diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2012-07-02 23:26:17 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2012-07-02 23:26:17 +0300 |
commit | e0db8851abe880553f48a0b2454dde293ffb22b2 (patch) | |
tree | deb6e0f21d85573f1996f7d9b90562bb0349fb03 /main.cpp | |
parent | 166017ac72e412afef52e42ac5c31679211c8b55 (diff) |
added ability to set private key for each protocol (#50 Свой ключ для каждой учетной записи)
Diffstat (limited to 'main.cpp')
-rwxr-xr-x | main.cpp | 156 |
1 files changed, 137 insertions, 19 deletions
@@ -148,7 +148,27 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM } } } - + { + SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_ADDSTRING, 0, (LPARAM)Translate("Default")); + int count = 0; + PROTOACCOUNT **accounts; + ProtoEnumAccounts(&count, &accounts); + for(int i = 0; i < count; i++) + { + if(StriStr(accounts[i]->szModuleName, "metacontacts")) + continue; + if(StriStr(accounts[i]->szModuleName, "weather")) + continue; + SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_ADDSTRING, 0, (LPARAM)accounts[i]->szModuleName); + } + SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_SELECTSTRING, 0, (LPARAM)Translate("Default"));
+ string keyinfo = Translate("key id");
+ keyinfo += ": ";
+ char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
+ keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set"); + mir_free(keyid); + SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str()); + } return TRUE; } @@ -201,10 +221,30 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM while((s = out.find("\r", s)) != string::npos) { out.erase(s, 1); + }
+ {
+ char buf[64];
+ GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63);
+ if(!strcmp(buf, Translate("Default"))) + { + DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str()); + DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyMainName", name); + DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", fp); + } + 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); + } } - DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str()); - DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyMainName", name); - DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", fp); TCHAR passwd[64]; GetDlgItemText(hwndDlg, IDC_KEY_PASSWORD, passwd, 64); if(passwd[0]) @@ -217,7 +257,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM DBWriteContactSettingTString(NULL, szGPGModuleName, dbsetting.c_str(), passwd); } { - wstring keyinfo = TranslateT("Current private key id"); + wstring keyinfo = TranslateT("Default private key id"); keyinfo += _T(": "); keyinfo += (fp[0])?fp:_T("not set"); extern HWND hwndCurKey_p; @@ -371,13 +411,42 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM } if(result == pxNotFound) break; + }
+ {
+ char buf[64];
+ GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63); + if(!strcmp(buf, Translate("Default"))) + { + DBDeleteContactSetting(NULL, szGPGModuleName, "GPGPubKey"); + DBDeleteContactSetting(NULL, szGPGModuleName, "KeyID"); + DBDeleteContactSetting(NULL, szGPGModuleName, "KeyComment"); + DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainName"); + DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainEmail"); + DBDeleteContactSetting(NULL, szGPGModuleName, "KeyType"); + } + 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); + } } - DBDeleteContactSetting(NULL, szGPGModuleName, "GPGPubKey"); - DBDeleteContactSetting(NULL, szGPGModuleName, "KeyID"); - DBDeleteContactSetting(NULL, szGPGModuleName, "KeyComment"); - DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainName"); - DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainEmail"); - DBDeleteContactSetting(NULL, szGPGModuleName, "KeyType"); ListView_DeleteItem(hwndList, itemnum); break; case IDC_GENERATE_RANDOM: @@ -479,15 +548,60 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM while((s = out.find("\r", s)) != string::npos) { out.erase(s, 1); + }
+ {
+ char buf[64];
+ GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63); + if(!strcmp(buf, Translate("Default"))) + { + DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str()); + DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", fp); + } + 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); + } } - DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str()); - DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", path.c_str()); extern HWND hwndCurKey_p; SetWindowText(hwndCurKey_p, path.c_str()); } } DestroyWindow(hwndDlg); break; + case IDC_ACCOUNT: + {
+ char buf[64];
+ GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63);
+ if(!strcmp(buf, Translate("Default")))
+ {
+ string keyinfo = Translate("key id");
+ keyinfo += ": ";
+ char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
+ keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set");
+ mir_free(keyid); + SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str()); + } + else + { + 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()); + } + } + break; + } break; } @@ -502,12 +616,16 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM itemnum = hdr->iItem; } } -// switch (((LPNMHDR)lParam)->code) - // { -// default: -// break; - -// } +/* switch(LOWORD(wParam)) + { + default: + break; + }; */ +/* switch (((LPNMHDR)lParam)->code) + { + default: + break; + } */ } break; case WM_CLOSE: |