diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-09-01 00:50:29 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-09-01 00:50:29 +0300 |
commit | 4f14d10536cd593a332fccdf6b954b8020f0b8d2 (patch) | |
tree | 85d5d5d8ee8b43ede24e1a1172ff3a37d2aeb288 | |
parent | adfbd68fc806c2c1fa79e0e878d2ff76a76bee8b (diff) |
modified: main.cpp
modified: messages.cpp
modified: new_gpg.rc
modified: options.cpp
modified: resource.h
-rw-r--r-- | main.cpp | 48 | ||||
-rw-r--r-- | messages.cpp | 4 | ||||
-rw-r--r-- | new_gpg.rc | 1 | ||||
-rw-r--r-- | options.cpp | 21 | ||||
-rw-r--r-- | resource.h | 3 |
5 files changed, 68 insertions, 9 deletions
@@ -198,6 +198,13 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM else DBDeleteContactSetting(NULL, szGPGModuleName, "szKeyPassword"); DBWriteContactSettingByte(NULL, szGPGModuleName, "FirstRun", 0); + { + wstring keyinfo = _T("Current private key id: "); + keyinfo += (_tcslen(fp) > 0)?fp:_T("not set"); + extern HWND hwndCurKey_p; + SetWindowText(hwndCurKey_p, keyinfo.c_str()); + } + DestroyWindow(hwndDlg); break; case IDC_OTHER: @@ -1091,6 +1098,47 @@ void FirstRun() void InitCheck() { + {//parse gpg output + string out; + DWORD code; + pxResult result; + wstring::size_type p = 0, p2 = 0, stop = 0; + { + gpg_execution_params params; + wstring cmd = _T("--batch --list-secret-keys"); + params.cmd = &cmd; + params.useless = ""; + params.out = &out; + params.code = &code; + params.result = &result; + HANDLE gpg_thread = mir_forkthread(pxEexcute_thread, (void*)¶ms); + if(WaitForSingleObject(gpg_thread, 10000) == WAIT_TIMEOUT) + { + TerminateThread(gpg_thread, 0); + MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + } + if(result == pxNotFound) + { + MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); + return; + } + } + char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + if(strlen(keyid) > 0) + { + string question = "Your secret key whith id: "; + question += keyid; + mir_free(keyid); + question += " deleted from gpg secret keyring\nDo you want to set another key ?"; + void ShowFirstRunDialog(); + if(out.find(keyid) == string::npos) + if(MessageBoxA(0, question.c_str(), "Own secret key warning", MB_YESNO) == IDYES) + ShowFirstRunDialog(); + return; + } + else + mir_free(keyid); + } } void ImportKey() diff --git a/messages.cpp b/messages.cpp index a73205d..4f2fa41 100644 --- a/messages.cpp +++ b/messages.cpp @@ -521,10 +521,10 @@ int TestHook(WPARAM w, LPARAM l) static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - HANDLE hContact = new_key_hcnt; + char *inkeyid = UniGetContactSettingUtf(new_key_hcnt, szGPGModuleName, "InKeyID", ""); CloseHandle(new_key_hcnt_mutex); TCHAR *tmp = NULL; - char *inkeyid = UniGetContactSettingUtf(hContact, szGPGModuleName, "InKeyID", ""); + switch (msg) { case WM_INITDIALOG: @@ -265,6 +265,7 @@ BEGIN PUSHBUTTON "Browse",IDC_LOG_FILE_SET,119,156,50,14
CONTROL "Use jabber api on Miranda IM >= 0.9 (recomended)",IDC_JABBER_API,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,175,181,10
+ LTEXT "Статический",IDC_CURRENT_KEY,97,196,116,8
END
IDD_OPT_GPG_BIN DIALOGEX 0, 0, 282, 214
diff --git a/options.cpp b/options.cpp index 766035e..161a5e5 100644 --- a/options.cpp +++ b/options.cpp @@ -80,13 +80,15 @@ int GpgOptInit(WPARAM wParam,LPARAM lParam) map<int, HANDLE> user_data; int item_num = 0; -HWND hwndList_p; +HWND hwndList_p = NULL; +HWND hwndCurKey_p = NULL; void ShowLoadPublicKeyDialog(); static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hwndList=GetDlgItem(hwndDlg, IDC_USERLIST); hwndList_p = hwndList; + hwndCurKey_p = GetDlgItem(hwndDlg, IDC_CURRENT_KEY); LVCOLUMN col = {0}; LVITEM item = {0}; TCHAR *tmp = NULL; @@ -176,6 +178,13 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA mir_free(tmp); CheckStateLoadDB(hwndDlg, IDC_DEBUG_LOG, "bDebugLog", 0); EnableWindow(GetDlgItem(hwndDlg, IDC_JABBER_API), bIsMiranda09); + { + string keyinfo = "Current private key id: "; + char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + keyinfo += (strlen(keyid) > 0)?keyid:"not set"; + mir_free(keyid); + SetDlgItemTextA(hwndDlg, IDC_CURRENT_KEY, keyinfo.c_str()); + } if(bIsMiranda09) CheckStateLoadDB(hwndDlg, IDC_JABBER_API, "bJabberAPI", 1); return TRUE; @@ -767,7 +776,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP } mir_free(tmp2); tmp = mir_utf8decodeW(output.substr(s,s2-s).c_str()); - if(hContact) + if(hContact && hwndList_p) ListView_SetItemText(hwndList_p, item_num, 1, tmp); mir_free(tmp); s2+=2; @@ -829,7 +838,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP } mir_free(tmp2); tmp = mir_utf8decodeW(output.substr(s,s2-s-1).c_str()); - if(hContact) + if(hContact && hwndList_p) ListView_SetItemText(hwndList_p, item_num, 2, tmp); mir_free(tmp); if((s = output.find(")", s2)) == string::npos) @@ -890,7 +899,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP } mir_free(tmp2); tmp = mir_utf8decodeW(output.substr(s,s2-s).c_str()); - if(hContact) + if(hContact && hwndList_p) ListView_SetItemText(hwndList_p, item_num, 3, tmp); mir_free(tmp); } @@ -922,11 +931,11 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP } mir_free(tmp2); tmp = mir_utf8decodeW(output.substr(s2,s-s2).c_str()); - if(hContact) + if(hContact && hwndList_p) ListView_SetItemText(hwndList_p, item_num, 3, tmp); mir_free(tmp); } - if(hContact) + if(hContact && hwndList_p) { ListView_SetColumnWidth(hwndList_p, 0, LVSCW_AUTOSIZE); ListView_SetColumnWidth(hwndList_p, 1, LVSCW_AUTOSIZE); @@ -62,6 +62,7 @@ #define IDC_KEY_FROM 1051
#define IDC_DELETE_KEY 1052
#define IDC_KEYID 1053
+#define IDC_CURRENT_KEY 1054
// Next default values for new objects
//
@@ -69,7 +70,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 114
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1054
+#define _APS_NEXT_CONTROL_VALUE 1055
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
|