diff options
Diffstat (limited to 'utilities.cpp')
-rw-r--r-- | utilities.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/utilities.cpp b/utilities.cpp index d59a7cb..28bb51e 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -375,7 +375,9 @@ int onSendFile(WPARAM w, LPARAM l) DWORD code; pxResult result; char *keyid = UniGetContactSettingUtf(ccs->hContact, szGPGModuleName, "KeyID", ""); - wstring cmd = _T("-r "); + wstring cmd = _T("--batch --yes -r "); + if(DBGetContactSettingByte(ccs->hContact, szGPGModuleName, "bAlwaysTrust", 0)) + cmd += _T("--trust-model always "); TCHAR *szKeyid = mir_a2t(keyid); cmd += szKeyid; mir_free(szKeyid); @@ -401,19 +403,40 @@ int onSendFile(WPARAM w, LPARAM l) params.code = &code; params.result = &result; boost::thread *gpg_thread = new boost::thread(boost::bind(&pxEexcute_thread, ¶ms)); - if(!gpg_thread->timed_join(boost::posix_time::minutes(10))) + if(!gpg_thread->timed_join(boost::posix_time::seconds(180))) { delete gpg_thread; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; } + if(out.find("There is no assurance this key belongs to the named user") != string::npos) + { + out.clear(); + if(MessageBox(0, _T("We trying to encrypt with untrusted key, do you want to trust this key permanently ?"), _T("Warning"), MB_YESNO) == IDYES) + { + DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "bAlwaysTrust", 1); + cmd.insert(0, _T("--trust-model always ")); + gpg_execution_params params; + pxResult result; + params.cmd = &cmd; + params.useless = ""; + params.out = &out; + params.code = &code; + params.result = &result; + boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); + if(!gpg_thread.timed_join(boost::posix_time::seconds(180))) + { + gpg_thread.~thread(); + debuglog<<time_str()<<": GPG execution timed out, aborted\n"; + } + } + } mir_free(file[i]); file[i]=mir_wstrdup(path_out.c_str()); mir_free(file_out); transfers.push_back(path_out); } } - - return CallService(PSS_FILE, w, l); + return CallService(ccs->szProtoService, w, l); } void storeOutput(HANDLE ahandle, string *output) |