From e0db8851abe880553f48a0b2454dde293ffb22b2 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Mon, 2 Jul 2012 23:26:17 +0300 Subject: =?UTF-8?q?added=20ability=20to=20set=20private=20key=20for=20each?= =?UTF-8?q?=20protocol=20(#50=20=09=D0=A1=D0=B2=D0=BE=D0=B9=20=D0=BA=D0=BB?= =?UTF-8?q?=D1=8E=D1=87=20=D0=B4=D0=BB=D1=8F=20=D0=BA=D0=B0=D0=B6=D0=B4?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=83=D1=87=D0=B5=D1=82=D0=BD=D0=BE=D0=B9=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 137 insertions(+), 19 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index dce18cd..dcb0384 100755 --- a/main.cpp +++ b/main.cpp @@ -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: -- cgit v1.2.3