summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gpg_wrapper.cpp21
-rw-r--r--gpg_wrapper.h13
-rw-r--r--main.cpp260
-rw-r--r--messages.cpp81
-rw-r--r--new_gpg.rc13
-rw-r--r--options.cpp42
-rw-r--r--resource.h3
-rw-r--r--utilities.cpp17
8 files changed, 407 insertions, 43 deletions
diff --git a/gpg_wrapper.cpp b/gpg_wrapper.cpp
index f9f4207..5bcf548 100644
--- a/gpg_wrapper.cpp
+++ b/gpg_wrapper.cpp
@@ -18,7 +18,8 @@
//thx gpg module from Harald Treder, Zakhar V. Bardymov
-pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode)
+
+pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result)
{
extern bool bDebugLog;
extern fstream debuglog;
@@ -38,6 +39,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD
if(errno == ENOENT)
{
mir_free(bin_path);
+ *result = pxNotFound;
return pxNotFound;
}
}
@@ -52,6 +54,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD
success=CreatePipe(&newstdin,&writestdin,&sattrs,0);
if (!success)
{
+ *result = pxCreatePipeFailed;
return pxCreatePipeFailed;
}
@@ -60,6 +63,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD
{
CloseHandle(newstdin);
CloseHandle(writestdin);
+ *result = pxCreatePipeFailed;
return pxCreatePipeFailed;
}
@@ -104,6 +108,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD
CloseHandle(writestdin);
CloseHandle(newstdout);
CloseHandle(readstdout);
+ *result = pxCreateProcessFailed;
return pxCreateProcessFailed;
}
@@ -122,6 +127,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD
success=WriteFile(writestdin,inputpos,size,&transfered,NULL);
inputpos+=transfered;
+ Sleep(200);
}
storeOutput(readstdout,aoutput);
@@ -139,6 +145,17 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD
CloseHandle(newstdout);
CloseHandle(readstdout);
CloseHandle(writestdin);
-
+
+ *result = pxSuccess;
return pxSuccess;
}
+
+void pxEexcute_thread(void *param)
+{
+ gpg_execution_params *params = (gpg_execution_params*)param;
+ pxResult result = pxExecute(params->cmd, params->useless, params->out, params->code, params->result);
+ if(result == pxNotFound)
+ {
+ MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK);
+ }
+} \ No newline at end of file
diff --git a/gpg_wrapper.h b/gpg_wrapper.h
index 9c0d513..6b0baea 100644
--- a/gpg_wrapper.h
+++ b/gpg_wrapper.h
@@ -14,6 +14,17 @@ typedef enum {
}
pxResult;
-pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode);
+pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result);
+
+struct gpg_execution_params
+{
+ wstring *cmd;
+ char *useless;
+ string *out;
+ LPDWORD code;
+ pxResult *result;
+};
+
+void pxEexcute_thread(void *param);
#endif \ No newline at end of file
diff --git a/main.cpp b/main.cpp
index e4a92fc..efed2bc 100644
--- a/main.cpp
+++ b/main.cpp
@@ -78,10 +78,23 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
{//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");
- if(pxExecute(&cmd, "", &out, &code) == pxNotFound)
+ params.cmd = &cmd;
+ params.useless = "";
+ params.out = &out;
+ params.code = &code;
+ params.result = &result;
+ HANDLE gpg_thread = mir_forkthread(pxEexcute_thread, (void*)&params);
+ 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);
break;
@@ -152,7 +165,20 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
DWORD code;
wstring cmd = _T("--batch -a --export ");
cmd += fp;
- 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*)&params);
+ 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);
break;
@@ -181,9 +207,148 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
extern int item_num;
item_num = 0; //black magic here
user_data[1] = 0;
- MessageBox(0, _T("Set secret key in following dialog.\nI do not know if password protected key is work..."), _T("Info"), MB_OK);
ShowLoadPublicKeyDialog();
+ ListView_DeleteAllItems(hwndList);
+ {
+ int i = 1, iRow = 0;
+ item.mask = LVIF_TEXT;
+ item.iItem = i;
+ item.iSubItem = 0;
+ item.pszText = _T("");
+ {//parse gpg output
+ string out;
+ DWORD code;
+ wstring::size_type p = 0, p2 = 0, stop = 0;
+ {
+ wstring cmd = _T("--batch --list-secret-keys");
+ 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*)&params);
+ 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);
+ break;
+ }
+ }
+ while(p != string::npos)
+ {
+ if((p = out.find("sec ", p)) == string::npos)
+ break;
+ p += 5;
+ if(p < stop)
+ break;
+ stop = p;
+ p2 = out.find("/", p) - 1;
+ TCHAR *tmp = mir_utf8decodeW(out.substr(p,p2-p).c_str());
+ item.pszText = tmp;
+ iRow = ListView_InsertItem(hwndList, &item);
+ ListView_SetItemText(hwndList, iRow, 4, tmp);
+ mir_free(tmp);
+ p2+=2;
+ p = out.find(" ", p2);
+ tmp = mir_utf8decodeW(out.substr(p2,p-p2).c_str());
+ ListView_SetItemText(hwndList, iRow, 0, tmp);
+ mir_free(tmp);
+ p = out.find("uid ", p);
+ p2 = out.find_first_not_of(" ", p+5);
+ p = out.find("<", p2);
+ tmp = mir_utf8decodeW(out.substr(p2,p-p2).c_str());
+ ListView_SetItemText(hwndList, iRow, 2, tmp);
+ mir_free(tmp);
+ p++;
+ p2 = out.find(">", p);
+ tmp = mir_utf8decodeW(out.substr(p,p2-p).c_str());
+ ListView_SetItemText(hwndList, iRow, 1, tmp);
+ mir_free(tmp);
+ p = out.find("ssb ", p2) + 6;
+ p = out.find(" ", p) + 1;
+ p2 = out.find("\n", p);
+ tmp = mir_utf8decodeW(out.substr(p,p2-p-1).c_str());
+ ListView_SetItemText(hwndList, iRow, 3, tmp);
+ mir_free(tmp);
+ ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);// not sure about this
+ ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE);
+ ListView_SetColumnWidth(hwndList, 2, LVSCW_AUTOSIZE);
+ ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE);
+ ListView_SetColumnWidth(hwndList, 4, LVSCW_AUTOSIZE);
+ i++;
+ }
+ }
+ }
+ }
+ break;
+ case IDC_DELETE_KEY:
+ ListView_GetItemText(hwndList, itemnum, 0, fp, 16);
+ {
+ string out;
+ DWORD code;
+ wstring cmd = _T("--batch --fingerprint ");
+ cmd += fp;
+ 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*)&params);
+ 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);
+ break;
+ }
+ string::size_type s = out.find("Key fingerprint = ");
+ s += strlen("Key fingerprint = ");
+ string::size_type s2 = out.find("\n", s);
+ TCHAR *fp = NULL;
+ {
+ string tmp = out.substr(s, s2-s-1).c_str();
+ string::size_type p = 0;
+ while((p = tmp.find(" ", p)) != string::npos)
+ {
+ tmp.erase(p, 1);
+ }
+ fp = mir_a2t(tmp.c_str());
+ }
+ cmd.clear();
+ out.clear();
+ cmd += _T("--batch --delete-secret-and-public-key --fingerprint ");
+ cmd += fp;
+ mir_free(fp);
+ gpg_thread = mir_forkthread(pxEexcute_thread, (void*)&params);
+ 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);
+ break;
+ }
}
+ DBDeleteContactSetting(NULL, szGPGModuleName, "GPGPubKey");
+ DBDeleteContactSetting(NULL, szGPGModuleName, "KeyID");
+ DBDeleteContactSetting(NULL, szGPGModuleName, "KeyComment");
+ DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainName");
+ DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainEmail");
+ DBDeleteContactSetting(NULL, szGPGModuleName, "KeyType");
+ ListView_DeleteItem(hwndList, itemnum);
break;
}
break;
@@ -530,10 +695,23 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
wstring cmd;
cmd += _T("--batch --yes --gen-key \"");
cmd += path;
- cmd += _T("\"");
- if(pxExecute(&cmd, "", &out, &code) == pxNotFound)
+ cmd += _T("\"");
+ 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*)&params);
+ if(WaitForSingleObject(gpg_thread, 300000) == 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);
break;
}
}
@@ -550,10 +728,23 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
DWORD code;
string::size_type p = 0, p2 = 0, stop = 0;
{
- wstring cmd = _T("--list-secret-keys");
- if(pxExecute(&cmd, "", &out, &code) == pxNotFound)
+ wstring cmd = _T("--list-secret-keys");
+ 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*)&params);
+ 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);
break;
}
}
@@ -687,10 +878,23 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam,
DWORD code;
string::size_type p = 0, p2 = 0, stop = 0;
{
- wstring cmd = _T("--batch --list-keys");
- if(pxExecute(&cmd, "", &out, &code) == pxNotFound)
+ wstring cmd = _T("--batch --list-keys");
+ 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*)&params);
+ 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);
break;
}
}
@@ -753,7 +957,20 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam,
DWORD code;
wstring cmd = _T("--batch -a --export ");
cmd += id;
- 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*)&params);
+ 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);
break;
@@ -900,8 +1117,21 @@ void ImportKey()
cmd += _T(" --import \"");
cmd += tmp2;
cmd += _T("\"");
- }
- if(pxExecute(&cmd, "", &output, &exitcode) == pxNotFound)
+ }
+ gpg_execution_params params;
+ pxResult result;
+ params.cmd = &cmd;
+ params.useless = "";
+ params.out = &output;
+ params.code = &exitcode;
+ params.result = &result;
+ HANDLE gpg_thread = mir_forkthread(pxEexcute_thread, (void*)&params);
+ 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;
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*)&params);
+ 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*)&params);
+ 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*)&params);
+ 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*)&params);
+ 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*)&params);
+ 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);
diff --git a/new_gpg.rc b/new_gpg.rc
index 47eef95..1ec3e23 100644
--- a/new_gpg.rc
+++ b/new_gpg.rc
@@ -69,13 +69,14 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPT
CAPTION "Set own key"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- DEFPUSHBUTTON "ÎÊ",ID_OK,15,175,50,14,WS_DISABLED
+ DEFPUSHBUTTON "ÎÊ",ID_OK,12,175,50,14,WS_DISABLED
CONTROL "",IDC_KEY_LIST,"SysListView32",LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,23,277,105
- PUSHBUTTON "Generate key",IDC_GENERATE_KEY,13,141,54,14
+ PUSHBUTTON "Generate key",IDC_GENERATE_KEY,11,131,54,14
LTEXT "Select key for use",IDC_STATIC,16,12,186,8
- EDITTEXT IDC_KEY_PASSWORD,205,141,77,14,ES_PASSWORD | ES_AUTOHSCROLL
- RTEXT "Key password:",IDC_STATIC,127,144,76,8
- PUSHBUTTON "Load other",IDC_OTHER,72,141,50,14
+ EDITTEXT IDC_KEY_PASSWORD,94,147,77,14,ES_PASSWORD | ES_AUTOHSCROLL
+ RTEXT "Key password:",IDC_STATIC,12,149,76,8
+ PUSHBUTTON "Load other",IDC_OTHER,68,131,50,14
+ PUSHBUTTON "Delete key",IDC_DELETE_KEY,121,131,46,14
END
IDD_BIN_PATH DIALOGEX 0, 0, 354, 89
@@ -137,7 +138,7 @@ CAPTION "Select existing public key from list"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "ÎÊ",IDOK,7,135,50,14,WS_DISABLED
- PUSHBUTTON "Îòìåíà",IDCANCEL,259,135,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,259,135,50,14
CONTROL "",IDC_EXISTING_KEY_LIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,14,292,113
END
diff --git a/options.cpp b/options.cpp
index 70ffc24..f902d59 100644
--- a/options.cpp
+++ b/options.cpp
@@ -216,12 +216,25 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
ptmp = mir_a2t(tmp);
cmd += ptmp;
mir_free(ptmp);
- if(pxExecute(&cmd, "", &output,&exitcode) == pxNotFound)
- {
- MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK);
+ gpg_execution_params params;
+ pxResult result;
+ params.cmd = &cmd;
+ params.useless = "";
+ params.out = &output;
+ params.code = &exitcode;
+ params.result = &result;
+ HANDLE gpg_thread = mir_forkthread(pxEexcute_thread, (void*)&params);
+ 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);
mir_free(tmp);
break;
- }
+ }
if(output.find("--delete-secret-keys") != string::npos)
MessageBoxA(0, "we have secret key for this public key, do not removing from GPG keyring", "info", MB_OK);
else
@@ -588,11 +601,24 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP
cmd += _T(" --import \"");
cmd += tmp2;
cmd += _T("\"");
- }
- if(pxExecute(&cmd, "", &output, &exitcode) == pxNotFound)
- {
+ }
+ gpg_execution_params params;
+ pxResult result;
+ params.cmd = &cmd;
+ params.useless = "";
+ params.out = &output;
+ params.code = &exitcode;
+ params.result = &result;
+ HANDLE gpg_thread = mir_forkthread(pxEexcute_thread, (void*)&params);
+ 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);
- break;
+ break;
}
mir_free(begin);
mir_free(end);
diff --git a/resource.h b/resource.h
index e0592af..f8ac01d 100644
--- a/resource.h
+++ b/resource.h
@@ -60,6 +60,7 @@
#define IDC_JABBER_API 1049
#define IDC_ENABLE_ENCRYPTION 1050
#define IDC_KEY_FROM 1051
+#define IDC_DELETE_KEY 1052
// Next default values for new objects
//
@@ -67,7 +68,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 114
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1052
+#define _APS_NEXT_CONTROL_VALUE 1053
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/utilities.cpp b/utilities.cpp
index 7d0b241..b07b7ba 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -410,10 +410,23 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU
cmd += _T(" --batch --yes -a -s \"");
cmd += path_out;
cmd += _T("\" ");
- 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*)&params);
+ 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_out.c_str());
path_out += _T(".asc");
f.open(path_out.c_str(), std::ios::in);