1 |
werner |
36 |
/* wptFileMangerDlg.cpp - File Manager |
2 |
|
|
* Copyright (C) 2001-2005 Timo Schulz |
3 |
|
|
* |
4 |
|
|
* This file is part of WinPT. |
5 |
|
|
* |
6 |
|
|
* WinPT is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* WinPT is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifdef HAVE_CONFIG_H |
22 |
|
|
#include <config.h> |
23 |
|
|
#endif |
24 |
|
|
|
25 |
|
|
#include <windows.h> |
26 |
|
|
#include <commctrl.h> |
27 |
|
|
#include <sys/stat.h> |
28 |
twoaday |
77 |
#include <stdio.h> |
29 |
werner |
36 |
|
30 |
werner |
47 |
#include "resource.h" |
31 |
werner |
36 |
#include "wptCommonCtl.h" |
32 |
|
|
#include "wptGPG.h" |
33 |
|
|
#include "wptW32API.h" |
34 |
|
|
#include "wptKeylist.h" |
35 |
|
|
#include "wptErrors.h" |
36 |
|
|
#include "wptContext.h" /* for passphrase_s */ |
37 |
|
|
#include "wptDlgs.h" |
38 |
|
|
#include "wptTypes.h" |
39 |
|
|
#include "wptNLS.h" |
40 |
|
|
#include "wptVersion.h" |
41 |
|
|
#include "wptFileManager.h" |
42 |
|
|
#include "wptRegistry.h" |
43 |
werner |
47 |
#include "wptCrypto.h" |
44 |
werner |
36 |
|
45 |
|
|
#define FM_SEPARATOR_ID 10001 |
46 |
|
|
|
47 |
|
|
#define send_cmd_id(hwnd, id) \ |
48 |
|
|
PostMessage ((hwnd), WM_COMMAND, MAKEWPARAM( (id), 0), 0) |
49 |
|
|
|
50 |
|
|
static subclass_s filelist_proc; |
51 |
|
|
|
52 |
|
|
struct thread_ctx_s { |
53 |
|
|
HWND dlg; |
54 |
|
|
HANDLE fd; |
55 |
|
|
char *drive; |
56 |
|
|
}; |
57 |
|
|
typedef struct thread_ctx_s *thread_ctx_t; |
58 |
|
|
|
59 |
|
|
|
60 |
|
|
/* Dialog procedure for selecting recipients for encryption. */ |
61 |
|
|
BOOL CALLBACK |
62 |
|
|
file_encrypt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
63 |
|
|
{ |
64 |
|
|
static listview_ctrl_t lv = NULL; |
65 |
|
|
static fm_state_t c; |
66 |
|
|
static keylist_t list = NULL; |
67 |
|
|
gpg_keycache_t kc; |
68 |
|
|
gpgme_ctx_t ctx; |
69 |
twoaday |
68 |
int force_trust = 0; |
70 |
werner |
36 |
|
71 |
|
|
switch (msg) { |
72 |
|
|
case WM_INITDIALOG: |
73 |
|
|
c = (fm_state_t)lparam; |
74 |
|
|
if (!c) |
75 |
|
|
dlg_fatal_error( dlg, "Could not get dialog state!" ); |
76 |
|
|
kc = keycache_get_ctx (KEYCACHE_PUB); |
77 |
|
|
if (!kc) |
78 |
|
|
BUG (dlg); |
79 |
twoaday |
77 |
SetWindowText (dlg, _("File Encrypt")); |
80 |
|
|
SetDlgItemText (dlg, IDC_ENCRYPT_ARMOR, _("&Text Output")); |
81 |
|
|
SetDlgItemText (dlg, IDC_ENCRYPT_WIPE, _("&Wipe Original")); |
82 |
|
|
|
83 |
|
|
/* XXX: support --hidden-recipient */ |
84 |
|
|
EnableWindow (GetDlgItem (dlg, IDC_ENCRYPT_ANON), FALSE); |
85 |
|
|
|
86 |
werner |
36 |
if (c->req_signer) { |
87 |
|
|
EnableWindow (GetDlgItem (dlg, IDC_ENCRYPT_SIGN), TRUE); |
88 |
|
|
seclist_init (dlg, IDC_ENCRYPT_SECLIST, KEYLIST_FLAG_SHORT, &list); |
89 |
|
|
} |
90 |
|
|
lv = keylist_load (GetDlgItem (dlg, IDC_ENCRYPT_LIST), kc, NULL, |
91 |
twoaday |
77 |
KEYLIST_ENCRYPT|KEYLIST_FLAG_FILE, KEY_SORT_USERID); |
92 |
werner |
36 |
SetForegroundWindow (dlg); |
93 |
|
|
return TRUE; |
94 |
|
|
|
95 |
|
|
case WM_DESTROY: |
96 |
|
|
seclist_destroy (&list); |
97 |
|
|
if (lv) { |
98 |
|
|
keylist_delete (lv); |
99 |
|
|
lv = NULL; |
100 |
|
|
} |
101 |
|
|
return FALSE; |
102 |
|
|
|
103 |
|
|
case WM_NOTIFY: |
104 |
|
|
NMHDR *notify; |
105 |
|
|
notify = (NMHDR *)lparam; |
106 |
twoaday |
77 |
if (notify && notify->code == LVN_COLUMNCLICK |
107 |
|
|
&& notify->idFrom == IDC_ENCRYPT_LIST) { |
108 |
werner |
36 |
NMLISTVIEW *p = (LPNMLISTVIEW) lparam; |
109 |
|
|
int sortby = 0; |
110 |
|
|
|
111 |
twoaday |
77 |
switch (p->iSubItem) { |
112 |
werner |
36 |
case 0: sortby = KEY_SORT_USERID; break; |
113 |
|
|
case 1: sortby = KEY_SORT_KEYID; break; |
114 |
|
|
case 2: sortby = KEY_SORT_LEN; break; |
115 |
|
|
case 4: sortby = KEY_SORT_VALIDITY; break; |
116 |
|
|
default:sortby = KEY_SORT_USERID; break; |
117 |
|
|
} |
118 |
twoaday |
77 |
keylist_sort (lv, sortby); |
119 |
werner |
36 |
} |
120 |
|
|
|
121 |
|
|
case WM_SYSCOMMAND: |
122 |
twoaday |
77 |
if (LOWORD (wparam) == SC_CLOSE) { |
123 |
werner |
36 |
c->cancel = 1; |
124 |
|
|
EndDialog( dlg, TRUE ); |
125 |
|
|
} |
126 |
|
|
return FALSE; |
127 |
|
|
|
128 |
|
|
case WM_COMMAND: |
129 |
|
|
if (HIWORD (wparam) == BN_CLICKED |
130 |
|
|
&& LOWORD (wparam) == IDC_ENCRYPT_SIGN) { |
131 |
twoaday |
77 |
int req_signer = IsDlgButtonChecked (dlg, IDC_ENCRYPT_SIGN); |
132 |
werner |
36 |
EnableWindow (GetDlgItem (dlg, IDC_ENCRYPT_SECLIST), |
133 |
|
|
req_signer? TRUE : FALSE); |
134 |
|
|
} |
135 |
|
|
switch( LOWORD( wparam ) ) { |
136 |
|
|
case IDOK: |
137 |
|
|
ctx = c->ctx; |
138 |
|
|
if (c->recp) |
139 |
|
|
free (c->recp); |
140 |
|
|
c->recp = keylist_get_recipients (lv, &force_trust, &c->n_recp); |
141 |
|
|
if (!c->n_recp) { |
142 |
|
|
msg_box (dlg, _("Please select at least one recipient."), |
143 |
|
|
_("File Encrypt"), MB_ERR); |
144 |
|
|
free (c->recp); |
145 |
|
|
c->recp = NULL; |
146 |
|
|
c->cancel = 1; |
147 |
|
|
return TRUE; |
148 |
|
|
} |
149 |
|
|
if (IsDlgButtonChecked (dlg, IDC_ENCRYPT_SIGN)) { |
150 |
|
|
gpgme_key_t key; |
151 |
|
|
|
152 |
|
|
if (seclist_select_key (dlg, IDC_ENCRYPT_SECLIST, &key)) |
153 |
|
|
return TRUE; |
154 |
|
|
else |
155 |
|
|
gpgme_signers_add (c->ctx, key); |
156 |
|
|
} |
157 |
|
|
|
158 |
|
|
if (IsDlgButtonChecked (dlg, IDC_ENCRYPT_ARMOR)) |
159 |
|
|
gpgme_set_armor (ctx, 1); |
160 |
|
|
if (IsDlgButtonChecked (dlg, IDC_ENCRYPT_WIPE)) |
161 |
|
|
c->wipe = 1; |
162 |
|
|
/* XXX: implement this |
163 |
|
|
if (IsDlgButtonChecked (dlg, IDC_ENCRYPT_ANON)) |
164 |
|
|
; |
165 |
|
|
*/ |
166 |
|
|
c->cancel = 0; |
167 |
|
|
EndDialog (dlg, TRUE); |
168 |
|
|
return TRUE; |
169 |
|
|
|
170 |
|
|
case IDCANCEL: |
171 |
|
|
c->cancel = 1; |
172 |
|
|
EndDialog (dlg, FALSE); |
173 |
|
|
return TRUE; |
174 |
|
|
} |
175 |
|
|
return TRUE; |
176 |
|
|
} |
177 |
|
|
|
178 |
|
|
return FALSE; |
179 |
|
|
} /* file_encrypt_dlg_proc */ |
180 |
|
|
|
181 |
|
|
|
182 |
|
|
BOOL CALLBACK |
183 |
|
|
file_import_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
184 |
|
|
{ |
185 |
|
|
static listview_ctrl_t lv = NULL; |
186 |
|
|
static fm_state_t c; |
187 |
|
|
static int is_revcert = 0, has_seckeys = 0; |
188 |
|
|
|
189 |
|
|
switch( msg ) { |
190 |
|
|
case WM_INITDIALOG: |
191 |
|
|
c = (fm_state_s *)lparam; |
192 |
|
|
if (!c) |
193 |
|
|
dlg_fatal_error( dlg, "Could not get dialog param!" ); |
194 |
|
|
#ifndef LANG_DE |
195 |
|
|
SetWindowText (dlg, _("Key Import")); |
196 |
|
|
#endif |
197 |
|
|
ShowWindow( GetDlgItem( dlg, IDC_IMPORT_KEYMNGT ), WS_DISABLED ); |
198 |
|
|
/* XXX: use the new code */ |
199 |
|
|
implist_build (&lv, GetDlgItem (dlg, IDC_IMPORT_KEYLIST)); |
200 |
|
|
implist_load (lv, c->opaque, &is_revcert, &has_seckeys); |
201 |
|
|
if (!listview_count_items (lv, 0)) { |
202 |
|
|
msg_box (dlg, _("No valid OpenPGP data found."), _("Key Import"), MB_ERR); |
203 |
|
|
c->cancel = 1; |
204 |
|
|
EndDialog (dlg, FALSE); |
205 |
|
|
} |
206 |
|
|
else { |
207 |
|
|
const char *s = "File contain(s) %d key(s)."; |
208 |
|
|
char *p = new char[strlen (s) + 32]; |
209 |
|
|
if (!p) |
210 |
|
|
BUG (0); |
211 |
|
|
sprintf (p, s, listview_count_items (lv, 0)); |
212 |
|
|
SetDlgItemText (dlg, IDC_IMPORT_INFO, p); |
213 |
|
|
free_if_alloc (p); |
214 |
|
|
} |
215 |
|
|
SetForegroundWindow (dlg); |
216 |
|
|
return TRUE; |
217 |
|
|
|
218 |
|
|
case WM_DESTROY: |
219 |
|
|
if (lv) { |
220 |
|
|
listview_release (lv); |
221 |
|
|
lv = NULL; |
222 |
|
|
} |
223 |
|
|
return FALSE; |
224 |
|
|
|
225 |
|
|
case WM_SYSCOMMAND: |
226 |
|
|
if (LOWORD (wparam) == SC_CLOSE) { |
227 |
|
|
c->cancel = 1; |
228 |
|
|
EndDialog (dlg, FALSE); |
229 |
|
|
} |
230 |
|
|
return FALSE; |
231 |
|
|
|
232 |
|
|
case WM_COMMAND: |
233 |
|
|
switch (LOWORD (wparam)) { |
234 |
|
|
case IDC_IMPORT_DOIT: |
235 |
|
|
c->cancel = 0; |
236 |
|
|
c->import.revcert = is_revcert? 1 : 0; |
237 |
|
|
c->import.has_seckey = has_seckeys? 1 : 0; |
238 |
|
|
EndDialog (dlg, TRUE); |
239 |
|
|
return TRUE; |
240 |
|
|
|
241 |
|
|
case IDCANCEL: |
242 |
|
|
c->cancel = 1; |
243 |
|
|
EndDialog (dlg, FALSE); |
244 |
|
|
return FALSE; |
245 |
|
|
} |
246 |
|
|
break; |
247 |
|
|
} |
248 |
|
|
|
249 |
|
|
return FALSE; |
250 |
|
|
} /* file_import_dlg_proc */ |
251 |
|
|
|
252 |
|
|
|
253 |
|
|
BOOL CALLBACK |
254 |
|
|
file_sign_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam ) |
255 |
|
|
{ |
256 |
|
|
static fm_state_t c; |
257 |
|
|
static listview_ctrl_t lv; |
258 |
|
|
gpg_keycache_t kc, sec_kc; |
259 |
|
|
gpgme_key_t key; |
260 |
|
|
int lv_idx; |
261 |
|
|
char signer[32]; |
262 |
|
|
|
263 |
|
|
switch( msg ) { |
264 |
|
|
case WM_INITDIALOG: |
265 |
|
|
c = (fm_state_s *)lparam; |
266 |
|
|
if( c == NULL ) |
267 |
|
|
dlg_fatal_error( dlg, "Could not get dialog state!" ); |
268 |
|
|
#ifndef LANG_DE |
269 |
|
|
SetWindowText (dlg, _("File Sign")); |
270 |
|
|
SetDlgItemText (dlg, IDC_FILE_SIG_ARMOR, _("&Text Output") ); |
271 |
|
|
SetDlgItemText (dlg, IDC_FILE_SIG_NORMAL, _("&Normal Signature")); |
272 |
|
|
SetDlgItemText (dlg, IDC_FILE_SIG_DETACH, _("&Detached Signature")); |
273 |
|
|
SetDlgItemText (dlg, IDC_FILE_SIG_CLEAR, _("&Cleartext Signature")); |
274 |
|
|
#endif |
275 |
|
|
CheckDlgButton (dlg, IDC_FILE_SIG_DETACH, BST_CHECKED); |
276 |
|
|
kc = keycache_get_ctx (KEYCACHE_PUB); |
277 |
|
|
if (!kc) |
278 |
|
|
BUG (dlg); |
279 |
|
|
sec_kc = keycache_get_ctx (KEYCACHE_PRV); |
280 |
|
|
if (!sec_kc) |
281 |
|
|
BUG( dlg ); |
282 |
|
|
lv = keylist_load( GetDlgItem(dlg, IDC_FILE_SIG_LIST), kc, sec_kc, |
283 |
|
|
KEYLIST_SIGN, KEY_SORT_USERID ); |
284 |
|
|
SetForegroundWindow( dlg ); |
285 |
|
|
return TRUE; |
286 |
|
|
|
287 |
|
|
case WM_DESTROY: |
288 |
|
|
if( lv ) { |
289 |
|
|
listview_release( lv ); |
290 |
|
|
lv = NULL; |
291 |
|
|
} |
292 |
|
|
return FALSE; |
293 |
|
|
|
294 |
|
|
case WM_SYSCOMMAND: |
295 |
|
|
if( LOWORD (wparam) == SC_CLOSE ) |
296 |
|
|
EndDialog( dlg, TRUE ); |
297 |
|
|
return FALSE; |
298 |
|
|
|
299 |
|
|
case WM_COMMAND: |
300 |
|
|
switch( LOWORD( wparam ) ) { |
301 |
|
|
case IDOK: |
302 |
|
|
if( IsDlgButtonChecked( dlg, IDC_FILE_SIG_ARMOR ) ) |
303 |
|
|
gpgme_set_armor (c->ctx, 1); |
304 |
|
|
if( IsDlgButtonChecked( dlg, IDC_FILE_SIG_NORMAL ) ) |
305 |
|
|
c->sigmode = GPGME_SIG_MODE_NORMAL; |
306 |
|
|
else if( IsDlgButtonChecked( dlg, IDC_FILE_SIG_DETACH ) ) |
307 |
|
|
c->sigmode = GPGME_SIG_MODE_DETACH; |
308 |
|
|
else if( IsDlgButtonChecked( dlg, IDC_FILE_SIG_CLEAR ) ) |
309 |
|
|
c->sigmode = GPGME_SIG_MODE_CLEAR; |
310 |
|
|
else { |
311 |
|
|
/* default is to produce detached signatures */ |
312 |
|
|
c->sigmode = GPGME_SIG_MODE_DETACH; |
313 |
|
|
} |
314 |
|
|
lv_idx = listview_get_curr_pos( lv ); |
315 |
|
|
if (lv_idx == -1) { |
316 |
|
|
if (listview_count_items (lv, 0) == 1) |
317 |
|
|
lv_idx = 0; |
318 |
|
|
else { |
319 |
|
|
msg_box (dlg, _("Please select a key."), _("Sign"), MB_ERR); |
320 |
|
|
return FALSE; |
321 |
|
|
} |
322 |
|
|
} |
323 |
|
|
listview_get_item_text( lv, lv_idx, 1, signer, sizeof signer-1 ); |
324 |
|
|
if( get_seckey( signer, &key ) ) |
325 |
|
|
BUG( NULL ); |
326 |
|
|
gpgme_signers_clear (c->ctx); |
327 |
|
|
gpgme_signers_add (c->ctx, key); |
328 |
|
|
free_if_alloc (c->opaque); |
329 |
|
|
c->opaque = m_strdup (signer); /* store for later use */ |
330 |
|
|
c->cancel = 0; |
331 |
|
|
if (!c->opaque) |
332 |
|
|
BUG (0); |
333 |
|
|
EndDialog (dlg, TRUE); |
334 |
|
|
return TRUE; |
335 |
|
|
|
336 |
|
|
case IDCANCEL: |
337 |
|
|
c->cancel = 1; |
338 |
|
|
EndDialog (dlg, FALSE); |
339 |
|
|
return FALSE; |
340 |
|
|
} |
341 |
|
|
break; |
342 |
|
|
} |
343 |
|
|
|
344 |
|
|
return FALSE; |
345 |
|
|
} /* file_sign_dlg_proc */ |
346 |
|
|
|
347 |
|
|
|
348 |
|
|
|
349 |
|
|
/* Setup status bar for the main window @dlg. */ |
350 |
|
|
static HWND |
351 |
|
|
setup_status_bar (HWND dlg) |
352 |
|
|
{ |
353 |
|
|
HWND statbar; |
354 |
|
|
RECT r; |
355 |
|
|
int partpos[3]; |
356 |
|
|
int i; |
357 |
|
|
|
358 |
|
|
GetClientRect (dlg, &r); |
359 |
|
|
for (i=1; i <= 3; i++) |
360 |
|
|
partpos[i-1] = r.right/3*i; |
361 |
|
|
|
362 |
|
|
statbar = CreateStatusWindow (WS_CHILD | WS_VISIBLE | CCS_BOTTOM, |
363 |
|
|
"", dlg, FM_SEPARATOR_ID); |
364 |
|
|
ShowWindow (statbar, SW_SHOW); |
365 |
|
|
SendMessage (statbar, SB_SETPARTS, (WPARAM)3, (LPARAM)partpos); |
366 |
|
|
return statbar; |
367 |
|
|
} |
368 |
|
|
|
369 |
|
|
|
370 |
|
|
/* Refresh the status bar text with the selected item from @lv. */ |
371 |
|
|
static void |
372 |
|
|
update_status_bar (HWND statbar, listview_ctrl_t lv) |
373 |
|
|
{ |
374 |
|
|
struct stat st; |
375 |
|
|
char buf[128]; |
376 |
|
|
int n; |
377 |
|
|
|
378 |
|
|
if (!lv) { /* flush */ |
379 |
|
|
SendMessage (statbar, SB_SETTEXT, 1, (LPARAM)"0 KB"); |
380 |
|
|
SendMessage (statbar, SB_SETTEXT, 0, (LPARAM)"0 Objects marked"); |
381 |
|
|
return; |
382 |
|
|
} |
383 |
|
|
n = listview_count_items (lv, 1); |
384 |
|
|
_snprintf (buf, sizeof (buf)-1, "%d Object(s) marked", n); |
385 |
|
|
SendMessage (statbar, SB_SETTEXT, 0, (LPARAM)buf); |
386 |
|
|
listview_get_item_text (lv, listview_get_curr_pos (lv), 1, buf, 127); |
387 |
|
|
if (stat (buf, &st) == 0) { |
388 |
|
|
_snprintf (buf, sizeof (buf)-1, "%d KB", st.st_size/1024); |
389 |
|
|
SendMessage (statbar, SB_SETTEXT, 1, (LPARAM)buf); |
390 |
|
|
} |
391 |
|
|
else |
392 |
|
|
SendMessage (statbar, SB_SETTEXT, 1, (LPARAM)"0 KB"); |
393 |
|
|
} |
394 |
|
|
|
395 |
|
|
|
396 |
|
|
static BOOL CALLBACK |
397 |
|
|
filelist_subclass_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
398 |
|
|
{ |
399 |
|
|
switch (msg) { |
400 |
|
|
case WM_KEYUP: |
401 |
|
|
int virt_key = (int)wparam; |
402 |
|
|
if (virt_key == VK_DELETE) |
403 |
|
|
send_cmd_id (filelist_proc.dlg, ID_FILEMISC_WIPE); |
404 |
|
|
break; |
405 |
|
|
} |
406 |
|
|
return CallWindowProc (filelist_proc.old, dlg, msg, wparam, lparam); |
407 |
|
|
} |
408 |
|
|
|
409 |
|
|
|
410 |
|
|
BOOL CALLBACK |
411 |
|
|
file_manager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
412 |
|
|
{ |
413 |
|
|
static HWND statbar; |
414 |
|
|
static listview_ctrl_t lv = NULL; |
415 |
|
|
static HMENU menu = NULL; |
416 |
|
|
static int always_ontop = 1; |
417 |
|
|
HWND fl; |
418 |
|
|
|
419 |
|
|
switch (msg) { |
420 |
|
|
case WM_INITDIALOG: |
421 |
|
|
always_ontop = 1; |
422 |
|
|
menu = LoadMenu (glob_hinst, (LPCSTR)IDR_WINPT_FILEMISC); |
423 |
|
|
SetWindowText (dlg, _("File Manager (use drag & drop to add files)")); |
424 |
|
|
set_menu_text (menu, ID_FILEMISC_OPEN, _("&Open...") ); |
425 |
|
|
set_menu_text (menu, ID_FILEMISC_ENCRYPT, _("&Encrypt") ); |
426 |
|
|
set_menu_text (menu, ID_FILEMISC_DECRYPT, _("&Decrypt") ); |
427 |
|
|
set_menu_text (menu, ID_FILEMISC_SIGN, _("&Sign") ); |
428 |
|
|
set_menu_text (menu, ID_FILEMISC_SIGNENC, _("Sign && Encrypt") ); |
429 |
|
|
set_menu_text (menu, ID_FILEMISC_VERIFY, _("&Verify") ); |
430 |
|
|
set_menu_text (menu, ID_FILEMISC_SYMENC, _("S&ymmetric") ); |
431 |
|
|
set_menu_text (menu, ID_FILEMISC_IMPORT, _("&Import") ); |
432 |
|
|
set_menu_text (menu, ID_FILEMISC_EXPORT, _("E&xport") ); |
433 |
|
|
set_menu_text (menu, ID_FILEMISC_QUIT, _("Exit")); |
434 |
|
|
set_menu_text (menu, ID_FILEMISC_CLEAR, _("&Reset") ); |
435 |
|
|
set_menu_text (menu, ID_FILEMISC_ONTOP, _("Always on Top")); |
436 |
|
|
set_menu_text (menu, ID_FILEMISC_PASTE, _("&Paste")); |
437 |
|
|
set_menu_text (menu, ID_FILEMISC_SELALL, _("&Select All")); |
438 |
|
|
set_menu_text (menu, ID_FILEMISC_PREFS, _("&Preferences")); |
439 |
|
|
set_menu_text (menu, ID_FILEMISC_SEND, _("Send as Mail")); |
440 |
|
|
set_menu_text (menu, ID_FILEMISC_LIST, _("&List Packets")); |
441 |
|
|
set_menu_text (menu, ID_FILEMISC_WIPE_FREES, _("Wipe Free Space")); |
442 |
|
|
set_menu_text (menu, ID_FILEMISC_WIPE, _("&Wipe")); |
443 |
|
|
|
444 |
|
|
fl = GetDlgItem (dlg, IDC_FILE_LIST); |
445 |
|
|
filelist_proc.dlg = dlg; |
446 |
|
|
filelist_proc.current = (WNDPROC)filelist_subclass_proc; |
447 |
|
|
filelist_proc.old = (WNDPROC)GetWindowLong (fl, GWL_WNDPROC); |
448 |
|
|
if (filelist_proc.old) { |
449 |
|
|
if (!SetWindowLong (fl, GWL_WNDPROC, (LONG)filelist_proc.current)) { |
450 |
|
|
msg_box (dlg, _("Could not set filelist window procedure."), _("Key Manager"), MB_ERR); |
451 |
|
|
BUG (NULL); |
452 |
|
|
} |
453 |
|
|
} |
454 |
|
|
SetMenu (dlg, menu); |
455 |
|
|
fm_build (&lv, GetDlgItem (dlg, IDC_FILE_LIST)); |
456 |
|
|
center_window2 (dlg, NULL, HWND_TOPMOST); |
457 |
|
|
center_window (dlg, NULL); |
458 |
|
|
SetForegroundWindow (dlg); |
459 |
|
|
statbar = setup_status_bar (dlg); |
460 |
|
|
filelist_proc.opaque = (void*)statbar; |
461 |
|
|
return TRUE; |
462 |
|
|
|
463 |
|
|
case WM_DESTROY: |
464 |
|
|
if (lv) { |
465 |
|
|
fm_delete (lv); |
466 |
|
|
lv = NULL; |
467 |
|
|
} |
468 |
|
|
if (menu) { |
469 |
|
|
DestroyMenu (menu); |
470 |
|
|
menu = NULL; |
471 |
|
|
} |
472 |
|
|
return FALSE; |
473 |
|
|
|
474 |
|
|
case WM_DROPFILES: |
475 |
|
|
fm_add_dropped_files (lv, (HDROP)wparam); |
476 |
|
|
return TRUE; |
477 |
|
|
|
478 |
|
|
case WM_NOTIFY: |
479 |
|
|
NMHDR *notify; |
480 |
|
|
int pos; |
481 |
|
|
HMENU hm; |
482 |
|
|
|
483 |
|
|
notify = (NMHDR *)lparam; |
484 |
|
|
if (notify && notify->code == NM_CLICK && |
485 |
|
|
notify->idFrom == IDC_FILE_LIST) |
486 |
|
|
update_status_bar (statbar, lv); |
487 |
|
|
if (notify && notify->code == NM_RCLICK |
488 |
|
|
&& notify->idFrom == IDC_FILE_LIST) { |
489 |
|
|
POINT p; |
490 |
|
|
HMENU popup; |
491 |
|
|
|
492 |
|
|
GetCursorPos (&p); |
493 |
|
|
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_FILEMISC_CTX)); |
494 |
|
|
popup = GetSubMenu (hm, 0); |
495 |
|
|
set_menu_text (popup, ID_FILECTX_ENCRYPT, _("Encrypt")); |
496 |
|
|
set_menu_text (popup, ID_FILECTX_DECRYPT, _("Decrypt")); |
497 |
|
|
set_menu_text (popup, ID_FILECTX_SIGN, _("Sign")); |
498 |
|
|
set_menu_text (popup, ID_FILECTX_SIGNENC, _("Sign && Encrypt")); |
499 |
|
|
set_menu_text (popup, ID_FILECTX_VERIFY, _("Verify")); |
500 |
|
|
set_menu_text (popup, ID_FILECTX_WIPE, _("Wipe")); |
501 |
|
|
set_menu_text (popup, ID_FILECTX_SEND, _("Send as Mail")); |
502 |
|
|
pos = listview_get_curr_pos (lv); |
503 |
|
|
if (fm_check_file_type (lv, pos, FM_DECRYPT)) |
504 |
|
|
set_menu_state (popup, ID_FILECTX_SEND, MF_ENABLED); |
505 |
|
|
if (fm_check_file_type (lv, pos, FM_ENCRYPT)) { |
506 |
|
|
set_menu_state (popup, ID_FILECTX_DECRYPT, MF_GRAYED|MF_DISABLED); |
507 |
|
|
set_menu_state (popup, ID_FILECTX_VERIFY, MF_GRAYED|MF_DISABLED); |
508 |
|
|
} |
509 |
|
|
if (fm_check_file_type (lv, pos, FM_DECRYPT)) { |
510 |
|
|
set_menu_state (popup, ID_FILECTX_ENCRYPT, MF_GRAYED|MF_DISABLED); |
511 |
|
|
set_menu_state (popup, ID_FILECTX_SIGN, MF_GRAYED|MF_DISABLED); |
512 |
|
|
set_menu_state (popup, ID_FILECTX_SIGNENC, MF_GRAYED|MF_DISABLED); |
513 |
|
|
} |
514 |
|
|
if (fm_check_file_type (lv, pos, FM_VERIFY)) { |
515 |
|
|
set_menu_state (popup, ID_FILECTX_VERIFY, MF_ENABLED); |
516 |
|
|
set_menu_state (popup, ID_FILECTX_SIGN, MF_GRAYED|MF_DISABLED); |
517 |
|
|
set_menu_state (popup, ID_FILECTX_SIGNENC, MF_GRAYED|MF_DISABLED); |
518 |
|
|
} |
519 |
|
|
|
520 |
|
|
TrackPopupMenu(popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL); |
521 |
|
|
DestroyMenu (popup); |
522 |
|
|
DestroyMenu (hm); |
523 |
|
|
} |
524 |
|
|
if (notify && notify->code == NM_CLICK |
525 |
|
|
&& notify->idFrom == IDC_FILE_LIST) { |
526 |
|
|
hm = GetMenu (dlg); |
527 |
|
|
pos = listview_get_curr_pos (lv); |
528 |
|
|
if (!fm_check_file_type (lv, pos, FM_DECRYPT)) |
529 |
|
|
set_menu_state (hm, ID_FILEMISC_SEND, MF_GRAYED|MF_DISABLED); |
530 |
|
|
else |
531 |
|
|
set_menu_state (hm, ID_FILEMISC_SEND, MF_ENABLED); |
532 |
|
|
} |
533 |
|
|
return TRUE; |
534 |
|
|
|
535 |
|
|
case WM_SYSCOMMAND: |
536 |
|
|
if( LOWORD( wparam ) == SC_CLOSE ) |
537 |
|
|
EndDialog( dlg, TRUE ); |
538 |
|
|
return FALSE; |
539 |
|
|
|
540 |
|
|
case WM_INITMENUPOPUP: |
541 |
|
|
if ((UINT)LOWORD (lparam) == 0) { |
542 |
twoaday |
68 |
HMENU h = (HMENU)wparam; |
543 |
|
|
set_menu_text_bypos (h, 2, _("&Calc Digest")); |
544 |
werner |
36 |
} |
545 |
|
|
return FALSE; |
546 |
|
|
|
547 |
|
|
case WM_COMMAND: |
548 |
|
|
switch( LOWORD( wparam ) ) { |
549 |
|
|
case ID_FILEMISC_QUIT: |
550 |
|
|
EndDialog (dlg, TRUE); |
551 |
|
|
return TRUE; |
552 |
|
|
|
553 |
|
|
case ID_FILEMISC_WIPE_FREES: |
554 |
|
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SPACE_SECDEL, dlg, |
555 |
twoaday |
65 |
space_wipefrees_dlg_proc, 0); |
556 |
werner |
36 |
break; |
557 |
|
|
|
558 |
|
|
case ID_FILEMISC_SELALL: |
559 |
|
|
listview_select_all (lv); |
560 |
|
|
break; |
561 |
|
|
|
562 |
|
|
case ID_FILEMISC_PASTE: |
563 |
|
|
fm_verify_pasted_detsig (lv, dlg); |
564 |
|
|
break; |
565 |
|
|
|
566 |
|
|
case ID_FILEMISC_ONTOP: |
567 |
|
|
always_ontop ^= 1; |
568 |
|
|
set_menu_state (menu, ID_FILEMISC_ONTOP, |
569 |
|
|
always_ontop == 0? MFS_UNCHECKED : MFS_CHECKED); |
570 |
|
|
center_window2 (dlg, NULL, always_ontop == 0? HWND_NOTOPMOST : HWND_TOPMOST); |
571 |
|
|
break; |
572 |
|
|
|
573 |
|
|
case ID_FILEMISC_SEND: |
574 |
|
|
fm_send_file (lv); |
575 |
|
|
break; |
576 |
|
|
|
577 |
|
|
case ID_FILEMISC_PREFS: |
578 |
|
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_FILE_PREFS, dlg, |
579 |
twoaday |
65 |
file_preferences_dlg_proc, 0); |
580 |
werner |
36 |
break; |
581 |
|
|
|
582 |
|
|
case ID_FILEMISC_LIST: |
583 |
|
|
case ID_FILEMISC_ENCRYPT: |
584 |
|
|
case ID_FILEMISC_SYMENC: |
585 |
|
|
case ID_FILEMISC_DECRYPT: |
586 |
|
|
case ID_FILEMISC_SIGN: |
587 |
|
|
case ID_FILEMISC_SIGNENC: |
588 |
|
|
case ID_FILEMISC_VERIFY: |
589 |
|
|
case ID_FILEMISC_WIPE: |
590 |
twoaday |
77 |
case ID_FILEMISC_ENCRYPT_ZIP: |
591 |
werner |
36 |
fm_parse_files (lv, dlg, LOWORD (wparam)); |
592 |
|
|
SetForegroundWindow (dlg); |
593 |
|
|
return TRUE; |
594 |
|
|
|
595 |
|
|
case ID_FILEMISC_MD_MD5: |
596 |
|
|
case ID_FILEMISC_MD_SHA1: |
597 |
|
|
case ID_FILEMISC_MD_RMD160: |
598 |
|
|
case ID_FILEMISC_MD_SHA256: |
599 |
|
|
int algo; |
600 |
|
|
|
601 |
|
|
switch (LOWORD (wparam)) { |
602 |
|
|
case ID_FILEMISC_MD_MD5: algo = GPGME_MD_MD5; break; |
603 |
|
|
case ID_FILEMISC_MD_SHA1: algo = GPGME_MD_SHA1; break; |
604 |
|
|
case ID_FILEMISC_MD_RMD160: algo = GPGME_MD_RMD160; break; |
605 |
|
|
case ID_FILEMISC_MD_SHA256:algo = GPGME_MD_SHA256; break; |
606 |
twoaday |
68 |
default: algo = GPGME_MD_SHA1; break; |
607 |
werner |
36 |
} |
608 |
|
|
fm_print_md (lv, dlg, algo); |
609 |
|
|
SetForegroundWindow (dlg); |
610 |
|
|
return TRUE; |
611 |
|
|
|
612 |
|
|
case ID_FILEMISC_CLEAR: |
613 |
|
|
listview_del_all( lv ); |
614 |
|
|
return TRUE; |
615 |
|
|
|
616 |
|
|
case ID_FILEMISC_OPEN: |
617 |
|
|
fm_add_opened_files( lv, dlg ); |
618 |
|
|
return TRUE; |
619 |
|
|
|
620 |
|
|
/* context menu entries */ |
621 |
|
|
case ID_FILECTX_ENCRYPT: send_cmd_id( dlg, ID_FILEMISC_ENCRYPT); break; |
622 |
|
|
case ID_FILECTX_DECRYPT: send_cmd_id( dlg, ID_FILEMISC_DECRYPT );break; |
623 |
|
|
case ID_FILECTX_SIGN: send_cmd_id( dlg, ID_FILEMISC_SIGN ); break; |
624 |
|
|
case ID_FILECTX_SIGNENC: send_cmd_id( dlg, ID_FILEMISC_SIGNENC );break; |
625 |
|
|
case ID_FILECTX_VERIFY: send_cmd_id( dlg, ID_FILEMISC_VERIFY ); break; |
626 |
|
|
case ID_FILECTX_WIPE: send_cmd_id( dlg, ID_FILEMISC_WIPE ); break; |
627 |
|
|
case ID_FILECTX_LIST: send_cmd_id( dlg, ID_FILEMISC_LIST ); break; |
628 |
|
|
case ID_FILECTX_SEND: send_cmd_id( dlg, ID_FILEMISC_SEND ); break; |
629 |
twoaday |
77 |
case ID_FILECTX_ENCRYPT_ZIP:send_cmd_id (dlg, ID_FILEMISC_ENCRYPT_ZIP); break; |
630 |
werner |
36 |
} |
631 |
|
|
break; |
632 |
|
|
} |
633 |
|
|
|
634 |
|
|
return FALSE; |
635 |
|
|
} /* file_manager_dlg_proc */ |
636 |
|
|
|
637 |
|
|
|
638 |
|
|
BOOL CALLBACK |
639 |
|
|
file_preferences_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
640 |
|
|
{ |
641 |
|
|
switch (msg) { |
642 |
|
|
case WM_INITDIALOG: |
643 |
|
|
CheckDlgButton (dlg, IDC_FPREFS_PROGRESS, reg_prefs.fm.progress? BST_CHECKED : BST_UNCHECKED); |
644 |
|
|
SetForegroundWindow (dlg); |
645 |
|
|
center_window (dlg, NULL); |
646 |
|
|
break; |
647 |
|
|
|
648 |
|
|
case WM_COMMAND: |
649 |
|
|
switch (LOWORD (wparam)) { |
650 |
|
|
case IDOK: |
651 |
|
|
reg_prefs.fm.progress = IsDlgButtonChecked (dlg, IDC_FPREFS_PROGRESS)? 1 : 0; |
652 |
|
|
set_reg_winpt_prefs (®_prefs); |
653 |
|
|
EndDialog (dlg, TRUE); |
654 |
|
|
break; |
655 |
|
|
|
656 |
|
|
case IDCANCEL: |
657 |
|
|
EndDialog (dlg, FALSE); |
658 |
|
|
break; |
659 |
|
|
} |
660 |
|
|
break; |
661 |
|
|
} |
662 |
|
|
|
663 |
|
|
return FALSE; |
664 |
|
|
} /* file_preferences_dlg_proc */ |
665 |
|
|
|
666 |
|
|
|
667 |
|
|
static void |
668 |
|
|
add_files_from_lv (HWND dlg, listview_ctrl_t lv) |
669 |
|
|
{ |
670 |
|
|
char fname[384+1]; |
671 |
|
|
int i; |
672 |
|
|
|
673 |
|
|
for (i = 0; i < listview_count_items (lv, 0); i++) { |
674 |
|
|
if (!listview_get_item_state (lv, i)) |
675 |
|
|
continue; |
676 |
|
|
listview_get_item_text (lv, i, 1, fname, sizeof (fname)-1); |
677 |
|
|
SendDlgItemMessage (dlg, IDC_SECDEL_FILES, LB_ADDSTRING, |
678 |
twoaday |
68 |
0, (WPARAM)(char *)fname); |
679 |
werner |
36 |
} |
680 |
|
|
} |
681 |
|
|
|
682 |
|
|
|
683 |
|
|
/* Dialog box procedure to confirm that files shall be deleted. */ |
684 |
|
|
BOOL CALLBACK |
685 |
|
|
file_secdel_confirm_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
686 |
|
|
{ |
687 |
|
|
static secdel_confirm_s * ctx; |
688 |
|
|
|
689 |
|
|
switch (msg) { |
690 |
|
|
case WM_INITDIALOG: |
691 |
|
|
ctx = (struct secdel_confirm_s *)lparam; |
692 |
|
|
if (!ctx) |
693 |
|
|
BUG (NULL); |
694 |
|
|
add_files_from_lv (dlg, ctx->lv_files); |
695 |
|
|
SetWindowText (dlg, _("Are you sure you want to secure delete these files?")); |
696 |
|
|
SetDlgItemText (dlg, IDYES, _("&Yes")); |
697 |
|
|
SetDlgItemText (dlg, IDNO, _("&No")); |
698 |
|
|
break; |
699 |
|
|
|
700 |
|
|
case WM_COMMAND: |
701 |
|
|
switch (LOWORD (wparam)) { |
702 |
|
|
case IDYES: |
703 |
|
|
ctx->yes = 1; |
704 |
|
|
EndDialog (dlg, TRUE); |
705 |
|
|
break; |
706 |
|
|
|
707 |
|
|
case IDNO: |
708 |
|
|
ctx->yes = 0; |
709 |
|
|
EndDialog (dlg, FALSE); |
710 |
|
|
break; |
711 |
|
|
} |
712 |
|
|
break; |
713 |
|
|
} |
714 |
|
|
|
715 |
|
|
return FALSE; |
716 |
|
|
} |
717 |
|
|
|
718 |
|
|
|
719 |
|
|
/* Wipe callback. @ctx is a window handle @off is the current offset |
720 |
|
|
and @n is the total size. */ |
721 |
|
|
static void |
722 |
|
|
wipe_cb (void *ctx, ui64 off, ui64 n) |
723 |
|
|
{ |
724 |
|
|
SendDlgItemMessage ((HWND)ctx, IDC_SPACE_PROGRESS, PBM_SETPOS, |
725 |
|
|
(WPARAM) (off*100/n), 0); |
726 |
|
|
SetDlgItemInt ((HWND)ctx, IDC_SPACE_OFF, (UINT)(off/1024), FALSE); |
727 |
|
|
SetDlgItemInt ((HWND)ctx, IDC_SPACE_N, (UINT)(n/1024), FALSE); |
728 |
|
|
} |
729 |
|
|
|
730 |
|
|
|
731 |
|
|
/* Call the wipe free space method asynchron. */ |
732 |
|
|
static DWORD WINAPI |
733 |
|
|
wipe_thread (void *ctx) |
734 |
|
|
{ |
735 |
|
|
thread_ctx_t a = (thread_ctx_t)ctx; |
736 |
|
|
int rc; |
737 |
|
|
|
738 |
|
|
rc = wipe_freespace (a->drive, &a->fd, wipe_cb, a->dlg); |
739 |
|
|
SetDlgItemText (a->dlg, IDC_SPACE_INFO, |
740 |
|
|
rc? _("Operation Status: Error") : |
741 |
|
|
_("Operation Status: Done.")); |
742 |
|
|
if (rc) |
743 |
|
|
msg_box (a->dlg, winpt_strerror (rc), _("Wipe Free Space"), MB_ERR); |
744 |
|
|
else |
745 |
|
|
MessageBeep (MB_OK); |
746 |
|
|
ExitThread (0); |
747 |
|
|
return 0; |
748 |
|
|
} |
749 |
|
|
|
750 |
|
|
|
751 |
|
|
static void |
752 |
|
|
fill_drive_combobox (HWND dlg) |
753 |
|
|
{ |
754 |
|
|
char buf[384], p[16]; |
755 |
|
|
int n, i, j = 0; |
756 |
|
|
|
757 |
|
|
n = GetLogicalDriveStrings (DIM (buf)-1, buf); |
758 |
|
|
while (j < n) { |
759 |
|
|
for (i = 0; buf[j] != '\0'; i++, j++) |
760 |
|
|
p[i] = buf[j]; |
761 |
|
|
p[i] = '\0'; |
762 |
|
|
j++; |
763 |
|
|
if (GetDriveType (p) != DRIVE_CDROM) |
764 |
|
|
SendDlgItemMessage (dlg, IDC_SPACE_DRIVES, CB_ADDSTRING, |
765 |
|
|
0, (LPARAM)(const char *)p); |
766 |
|
|
} |
767 |
|
|
SendDlgItemMessage (dlg, IDC_SPACE_DRIVES, CB_SETCURSEL, 0, 0); |
768 |
|
|
} /* fill_drive_combobox */ |
769 |
|
|
|
770 |
|
|
|
771 |
|
|
static void |
772 |
|
|
update_disc_stats (HWND dlg) |
773 |
|
|
{ |
774 |
|
|
ULARGE_INTEGER caller = {0}, total = {0}, free = {0}; |
775 |
|
|
char buf[128], drive[32], a_total[64] = {0}, a_free[64] = {0}; |
776 |
|
|
int idx; |
777 |
|
|
|
778 |
|
|
idx = SendDlgItemMessage (dlg, IDC_SPACE_DRIVES, CB_GETCURSEL, 0, 0); |
779 |
|
|
GetDlgItemText (dlg, IDC_SPACE_DRIVES, drive, DIM (drive)-1); |
780 |
|
|
if (GetDiskFreeSpaceEx (drive, &caller, &total, &free)) { |
781 |
|
|
_ui64toa (total.QuadPart/1024, a_total, 10); |
782 |
|
|
_ui64toa (free.QuadPart/1024, a_free, 10); |
783 |
|
|
} |
784 |
|
|
_snprintf (buf, DIM (buf)-1, _("Total Capacity: %12sk\n" |
785 |
|
|
"Free Space : %12sk"), a_total, a_free); |
786 |
|
|
SetDlgItemText(dlg, IDC_SPACE_DISC_INFO, buf); |
787 |
|
|
SetDlgItemInt (dlg, IDC_SPACE_OFF, 0, FALSE); |
788 |
|
|
SetDlgItemInt (dlg, IDC_SPACE_N, 0, FALSE); |
789 |
|
|
} /* update_disc_stats */ |
790 |
|
|
|
791 |
|
|
|
792 |
|
|
BOOL CALLBACK |
793 |
|
|
space_wipefrees_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
794 |
|
|
{ |
795 |
|
|
static HANDLE thread_hd = NULL; |
796 |
|
|
static thread_ctx_s ctx; |
797 |
|
|
char drive[32], * p; |
798 |
|
|
int idx; |
799 |
|
|
DWORD tid; |
800 |
|
|
|
801 |
|
|
switch (msg) { |
802 |
|
|
case WM_INITDIALOG: |
803 |
|
|
fill_drive_combobox (dlg); |
804 |
|
|
update_disc_stats (dlg); |
805 |
|
|
center_window (dlg, NULL); |
806 |
|
|
SetForegroundWindow (dlg); |
807 |
|
|
break; |
808 |
|
|
|
809 |
|
|
case WM_DESTROY: |
810 |
|
|
thread_hd = NULL; |
811 |
|
|
free_if_alloc (ctx.drive); |
812 |
|
|
memset (&ctx, 0, sizeof ctx); |
813 |
|
|
break; |
814 |
|
|
|
815 |
|
|
case WM_COMMAND: |
816 |
|
|
if (HIWORD (wparam) == CBN_SELCHANGE) |
817 |
|
|
update_disc_stats (dlg); |
818 |
|
|
switch (LOWORD (wparam)) { |
819 |
|
|
case IDOK: |
820 |
|
|
idx = SendDlgItemMessage (dlg, IDC_SPACE_DRIVES, CB_GETCURSEL, 0, 0); |
821 |
|
|
if (idx != CB_ERR && !thread_hd) { |
822 |
|
|
GetDlgItemText (dlg, IDC_SPACE_DRIVES, drive, DIM (drive)-1); |
823 |
|
|
ctx.dlg = dlg; |
824 |
|
|
ctx.drive = m_strdup (drive); |
825 |
|
|
ctx.fd = NULL; |
826 |
|
|
thread_hd = CreateThread (NULL, 0, wipe_thread, &ctx, 0, &tid); |
827 |
|
|
} |
828 |
|
|
if (WaitForSingleObject (thread_hd, 0) == WAIT_OBJECT_0) { |
829 |
|
|
CloseHandle (thread_hd); |
830 |
|
|
thread_hd = NULL; |
831 |
|
|
EndDialog (dlg, TRUE); |
832 |
|
|
} |
833 |
|
|
break; |
834 |
|
|
|
835 |
|
|
case IDCANCEL: |
836 |
|
|
if (thread_hd) { |
837 |
|
|
WaitForSingleObject (thread_hd, 2000); |
838 |
|
|
TerminateThread (thread_hd, 1); |
839 |
|
|
CloseHandle (thread_hd); |
840 |
|
|
CloseHandle (ctx.fd); |
841 |
|
|
p = make_filename (ctx.drive, "temp_winpt.tmp", NULL); |
842 |
|
|
if (p && !file_exist_check (p)) |
843 |
werner |
47 |
remove (p); |
844 |
werner |
36 |
free_if_alloc (p); |
845 |
|
|
} |
846 |
|
|
EndDialog( dlg, FALSE ); |
847 |
|
|
break; |
848 |
|
|
} |
849 |
|
|
break; |
850 |
|
|
} |
851 |
|
|
|
852 |
|
|
return FALSE; |
853 |
|
|
} /* space_wipefrees_dlg_proc */ |