diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2012-05-18 22:28:05 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2012-05-18 22:28:05 +0300 |
commit | 365d949d8ec2712fbdec479e73e78cbbe80b3399 (patch) | |
tree | 8b3fdf275d6ec5cc92d0ecedbe57cf9cc9617be7 /main.cpp | |
parent | 570935ac486f2e1f5d36ecd07216e1474603c8ce (diff) |
fixed (#33 Settings)
Diffstat (limited to 'main.cpp')
-rwxr-xr-x | main.cpp | 54 |
1 files changed, 32 insertions, 22 deletions
@@ -226,7 +226,8 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM delete [] name; } bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange"); - gpg_configured = isGPGConfigured(); + gpg_valid = isGPGValid(); + gpg_keyexist = isGPGKeyExist(); DestroyWindow(hwndDlg); break; case IDC_OTHER: @@ -570,9 +571,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP if(_waccess(tmp, 0) == -1) { if(errno == ENOENT) - { MessageBox(0, TranslateT("wrong gpg binary location found in system.\nplease choose another location"), TranslateT("Warning"), MB_OK); - } } } } @@ -594,7 +593,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP params.out = &out; params.code = &code; params.result = &result; - gpg_configured = true; + gpg_valid = true; boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) { @@ -603,7 +602,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; } - gpg_configured = false; + gpg_valid = false; DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath"); string::size_type p1 = out.find("(GnuPG) "); if(p1 != string::npos) @@ -714,7 +713,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP params.out = &out; params.code = &code; params.result = &result; - gpg_configured = true; + gpg_valid = true; boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) { @@ -723,7 +722,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP gpg_thread.~thread(); debuglog<<time_str()<<": GPG execution timed out, aborted\n"; } - gpg_configured = false; + gpg_valid = false; DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath"); string::size_type p1 = out.find("(GnuPG) "); if(p1 != string::npos) @@ -760,7 +759,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP } mir_free(path); } - gpg_configured = true; + gpg_valid = true; DBWriteContactSettingByte(NULL, szGPGModuleName, "FirstRun", 0); DestroyWindow(hwndDlg); ShowFirstRunDialog(); @@ -803,7 +802,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP params.out = &out; params.code = &code; params.result = &result; - gpg_configured = true; + gpg_valid = true; boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) { @@ -812,7 +811,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP gpg_thread.~thread(); debuglog<<time_str()<<": GPG execution timed out, aborted\n"; } - gpg_configured = false; + gpg_valid = false; DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath"); string::size_type p1 = out.find("(GnuPG) "); if(p1 != string::npos) @@ -895,7 +894,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP params.out = &out; params.code = &code; params.result = &result; - gpg_configured = true; + gpg_valid = true; boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); if(!gpg_thread.timed_join(boost::posix_time::minutes(10))) { @@ -903,10 +902,10 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP TerminateProcess(params.hProcess, 1); params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted"; - gpg_configured = false; + gpg_valid = false; break; } - gpg_configured = false; + gpg_valid = false; if(result == pxNotFound) break; DeleteFile(path.c_str()); @@ -929,7 +928,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP params.out = &out; params.code = &code; params.result = &result; - gpg_configured = true; + gpg_valid = true; boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) { @@ -937,10 +936,10 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP TerminateProcess(params.hProcess, 1); params.hProcess = NULL; debuglog<<time_str()<<"GPG execution timed out, aborted\n"; - gpg_configured = false; + gpg_valid = false; break; } - gpg_configured = false; + gpg_valid = false; if(result == pxNotFound) break; string::size_type s = 0; @@ -955,7 +954,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP } } bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange"); - gpg_configured = true; + gpg_valid = true; DBWriteContactSettingByte(NULL, szGPGModuleName, "FirstRun", 0); DestroyWindow(hwndDlg); break; @@ -1787,9 +1786,10 @@ void FirstRun() void InitCheck() { {//parse gpg output - gpg_configured = isGPGConfigured(); - if(!gpg_configured) + gpg_valid = isGPGValid(); + if(!gpg_valid) return; + gpg_keyexist = isGPGKeyExist(); string out; DWORD code; pxResult result; @@ -1821,13 +1821,23 @@ void InitCheck() _wmkdir(tmp_dir.c_str()); string question = Translate("Your secret key whith id: "); char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); - question += keyid; - mir_free(keyid); - question += Translate(" deleted from gpg secret keyring\nDo you want to set another key ?"); + char *key = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); void ShowFirstRunDialog(); + if(!keyid[0] || !key[0]) + { + question = Translate("You have not set public key for gpg, it's recommended to do it.\nDo you want to do it now ?"); + if(MessageBoxA(0, question.c_str(), Translate("Own public key warning"), MB_YESNO) == IDYES) + ShowFirstRunDialog(); + } if(out.find(keyid) == string::npos) + { + question += keyid; + question += Translate(" deleted from gpg secret keyring\nDo you want to set another key ?"); if(MessageBoxA(0, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES) ShowFirstRunDialog(); + } + mir_free(keyid); + mir_free(key); } { TCHAR *path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); |