summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rwxr-xr-xmain.cpp54
1 files changed, 32 insertions, 22 deletions
diff --git a/main.cpp b/main.cpp
index abd6982..36a037f 100755
--- a/main.cpp
+++ b/main.cpp
@@ -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, &params));
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, &params));
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, &params));
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, &params));
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, &params));
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(""));