diff options
Diffstat (limited to 'messages.cpp')
-rw-r--r-- | messages.cpp | 81 |
1 files changed, 73 insertions, 8 deletions
diff --git a/messages.cpp b/messages.cpp index 78994e5..10be19f 100644 --- a/messages.cpp +++ b/messages.cpp @@ -154,29 +154,68 @@ int RecvMsgSvc(WPARAM w, LPARAM l) cmd += _T(" -d -a \"");
cmd += path;
cmd += _T("\"");
- //MessageBox(0, cmd.c_str(), _T("in"), MB_OK);
- if(pxExecute(&cmd, "", &out, &code) == pxNotFound)
+ gpg_execution_params params;
+ pxResult result;
+ 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);
DeleteFile(path.c_str());
return CallService(MS_PROTO_CHAINRECV, w, l);
}
- if(out.find("public key decryption failed: bad passphrase") != string::npos)
+ while(out.find("public key decryption failed: bad passphrase") != string::npos)
{
void ShowLoadKeyPasswordWindow();
ShowLoadKeyPasswordWindow();
+ wstring cmd2 = cmd;
if(password)
{
wstring tmp = _T("--passphrase \"");
tmp += password;
tmp += _T("\" ");
- cmd.insert(0, tmp);
+ cmd2.insert(0, tmp);
+ }
+ out.clear();
+ gpg_execution_params params;
+ pxResult result;
+ params.cmd = &cmd2;
+ 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);
+ DeleteFile(path.c_str());
+ return CallService(MS_PROTO_CHAINRECV, w, l);
}
}
out.clear();
- if(pxExecute(&cmd, "", &out, &code) == pxNotFound)
+ gpg_thread = mir_forkthread(pxEexcute_thread, (void*)¶ms);
+ if(WaitForSingleObject(gpg_thread, 10000) == WAIT_TIMEOUT)
{
- MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK);
+ 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);
DeleteFile(path.c_str());
return CallService(MS_PROTO_CHAINRECV, w, l);
}
@@ -319,7 +358,20 @@ int SendMsgSvc(WPARAM w, LPARAM l) mir_free(tmp);
f.close();
}
- if(pxExecute(&cmd, "", &out, &code) == pxNotFound)
+ gpg_execution_params params;
+ pxResult result;
+ 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 CallService(MS_PROTO_CHAINSEND, w, l);
@@ -331,7 +383,20 @@ int SendMsgSvc(WPARAM w, LPARAM l) {
DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "bAlwaysTrust", 1);
cmd.insert(0, _T("--trust-model always "));
- if(pxExecute(&cmd, "", &out, &code) == pxNotFound)
+ gpg_execution_params params;
+ pxResult result;
+ 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 CallService(MS_PROTO_CHAINSEND, w, l);
|