1 |
/* wptMainProc.cpp - Main window procedure |
/* wptMainProc.cpp - Main window procedure |
2 |
* Copyright (C) 2000-2005 Timo Schulz |
* Copyright (C) 2000-2006 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
6 |
* WinPT is free software; you can redistribute it and/or modify |
* 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 |
* 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 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
* (at your option) any later version. |
10 |
* |
* |
11 |
* WinPT is distributed in the hope that it will be useful, |
* WinPT is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
15 |
* |
* |
16 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
17 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
*/ |
*/ |
20 |
|
|
21 |
#include <windows.h> |
#ifdef HAVE_CONFIG_H |
22 |
#include <commctrl.h> |
#include <config.h> |
23 |
#include <io.h> |
#endif |
24 |
|
|
25 |
#include "../resource.h" |
#include <windows.h> |
26 |
#include "wptTypes.h" |
#include <commctrl.h> |
27 |
#include "wptGPG.h" |
#include <io.h> |
28 |
#include "wptW32API.h" |
|
29 |
#include "wptVersion.h" |
#include "resource.h" |
30 |
#include "wptCommonCtl.h" |
#include "wptTypes.h" |
31 |
#include "wptContext.h" /* for passphrase_s */ |
#include "wptGPG.h" |
32 |
#include "wptDlgs.h" |
#include "wptW32API.h" |
33 |
#include "wptErrors.h" |
#include "wptVersion.h" |
34 |
#include "wptNLS.h" |
#include "wptCommonCtl.h" |
35 |
#include "wptHotkey.h" |
#include "wptContext.h" /* for passphrase_s */ |
36 |
#include "wptRegistry.h" |
#include "wptDlgs.h" |
37 |
#include "wptKeyserver.h" |
#include "wptErrors.h" |
38 |
#include "wptAgent.h" |
#include "wptNLS.h" |
39 |
#include "wptKeyManager.h" |
#include "wptHotkey.h" |
40 |
#include "wptCard.h" |
#include "wptRegistry.h" |
41 |
#include "wptCryptdisk.h" |
#include "wptKeyserver.h" |
42 |
#include "wptCardEdit.h" |
#include "wptAgent.h" |
43 |
|
#include "wptKeyManager.h" |
44 |
extern HWND activ_hwnd; |
#include "wptCard.h" |
45 |
static int cmd = 0; |
#include "wptCryptdisk.h" |
46 |
static int wipe_contents = 0; |
#include "wptCardEdit.h" |
47 |
|
|
48 |
|
static int cmd = 0; |
49 |
/* Dialog box procedure to display all insecure all ElGamal keys. */ |
static int wipe_contents = 0; |
50 |
BOOL CALLBACK |
|
51 |
elgamal_warn_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam ) |
|
52 |
{ |
/* Dialog box procedure to display all insecure all ElGamal keys. */ |
53 |
gpg_keycache_t pc; |
BOOL CALLBACK |
54 |
gpgme_key_t key; |
elgamal_warn_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
55 |
char tmp[128+64+1]; |
{ |
56 |
|
gpg_keycache_t pc; |
57 |
switch( msg ) { |
gpgme_key_t key; |
58 |
case WM_INITDIALOG: |
char tmp[128+64+1]; |
59 |
pc = keycache_get_ctx (1); |
|
60 |
while (!gpg_keycache_next_key (pc, 0, &key)) { |
switch (msg) { |
61 |
if (key->subkeys->pubkey_algo == GPGME_PK_ELG) { |
case WM_INITDIALOG: |
62 |
_snprintf (tmp, sizeof (tmp)-1, "(0x%s) %s", |
pc = keycache_get_ctx (1); |
63 |
key->subkeys->keyid+8, key->uids->uid); |
while (!gpg_keycache_next_key (pc, 0, &key)) { |
64 |
SendDlgItemMessage( dlg, IDC_ELGWARN_LIST, LB_ADDSTRING, |
if (key->subkeys->pubkey_algo == GPGME_PK_ELG) { |
65 |
0, (LPARAM)(const char *) tmp ); |
_snprintf (tmp, sizeof (tmp)-1, "(0x%s) %s", |
66 |
} |
key->subkeys->keyid+8, key->uids->uid); |
67 |
} |
SendDlgItemMessage (dlg, IDC_ELGWARN_LIST, LB_ADDSTRING, |
68 |
gpg_keycache_rewind (pc); |
0, (LPARAM)(const char *) tmp); |
69 |
center_window (dlg, NULL); |
} |
70 |
SetForegroundWindow (dlg); |
} |
71 |
break; |
gpg_keycache_rewind (pc); |
72 |
|
center_window (dlg, NULL); |
73 |
case WM_COMMAND: |
SetForegroundWindow (dlg); |
74 |
switch (LOWORD (wparam)) { |
break; |
75 |
case IDOK: |
|
76 |
EndDialog (dlg, TRUE); |
case WM_COMMAND: |
77 |
break; |
switch (LOWORD (wparam)) { |
78 |
} |
case IDOK: |
79 |
break; |
EndDialog (dlg, TRUE); |
80 |
} |
break; |
81 |
return FALSE; |
} |
82 |
} |
break; |
83 |
|
} |
84 |
|
return FALSE; |
85 |
|
} |
86 |
static int |
|
87 |
cleanup_tmp_files (void) |
|
88 |
{ |
/* Dialog box procedure to confirm to delete the clipboard contents. */ |
89 |
struct _finddata_t dat; |
static BOOL CALLBACK |
90 |
char tmp[384]; |
confirm_delclipboard_dlg (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
91 |
long hd; |
{ |
92 |
|
switch (msg) { |
93 |
if (GetTempPath (sizeof (tmp)-1, tmp) == FALSE || |
case WM_INITDIALOG: |
94 |
SetCurrentDirectory (tmp) == FALSE) { |
SetWindowText (dlg, _("Delete Clipboard Contents")); |
95 |
winpt_errmsg ("GetTempPath", 0); |
SetDlgItemText (dlg, IDC_CONFDELCLIP_BRAIN, _("&Remember the answer")); |
96 |
return WPTERR_GENERAL; |
SetDlgItemText (dlg, IDC_CONFDELCLIP_INFO, _("Do you want to delete the contents from the clipboard?")); |
97 |
} |
SetDlgItemText (dlg, IDYES, _("&Yes")); |
98 |
hd = _findfirst ("gpgmeOUT*", &dat); |
SetDlgItemText (dlg, IDNO, _("&No")); |
99 |
if (hd == -1) |
center_window (dlg, NULL); |
100 |
return 0; |
SetForegroundWindow (dlg); |
101 |
do { |
break; |
102 |
secure_unlink (dat.name, WIPE_MODE_SIMPLE); |
|
103 |
} while (_findnext (hd, &dat) == 0); |
case WM_COMMAND: |
104 |
_findclose (hd); |
switch (LOWORD (wparam)) { |
105 |
return 0; |
case IDYES: |
106 |
} |
wipe_contents = 1; |
107 |
|
if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN)) |
108 |
|
set_reg_winpt_flag ("WipeClipboard", 1); |
109 |
/* Dialog box procedure to confirm to delete the clipboard contents. */ |
EndDialog (dlg, TRUE); |
110 |
static BOOL CALLBACK |
break; |
111 |
confirm_delclipboard_dlg (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
|
112 |
{ |
case IDNO: |
113 |
switch (msg) { |
wipe_contents = 0; |
114 |
case WM_INITDIALOG: |
if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN)) |
115 |
center_window (dlg, NULL); |
set_reg_winpt_flag ("WipeClipboard", 0); |
116 |
SetForegroundWindow (dlg); |
EndDialog (dlg, FALSE); |
117 |
break; |
break; |
118 |
|
} |
119 |
case WM_COMMAND: |
break; |
120 |
switch (LOWORD (wparam)) { |
} |
121 |
case IDYES: |
return FALSE; |
122 |
wipe_contents = 1; |
} |
123 |
if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN)) |
|
124 |
set_reg_winpt_flag ("WipeClipboard", 1); |
|
125 |
EndDialog (dlg, TRUE); |
static gpgme_error_t |
126 |
break; |
currwnd_gpg_dlg (HWND hwnd, UINT id, int *ret_set) |
127 |
|
{ |
128 |
case IDNO: |
gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR); |
129 |
wipe_contents = 0; |
int type; |
130 |
if (IsDlgButtonChecked (dlg, IDC_CONFDELCLIP_BRAIN)) |
|
131 |
set_reg_winpt_flag ("WipeClipboard", 0); |
if (ret_set) |
132 |
EndDialog (dlg, FALSE); |
*ret_set = 1; |
133 |
break; |
switch (id) { |
134 |
} |
case ID_WINPT_CURRWND_SYMENC: |
135 |
break; |
gpg_encrypt_symmetric (); |
136 |
} |
break; |
137 |
return FALSE; |
|
138 |
} |
case ID_WINPT_CURRWND_ENCRYPT: |
139 |
|
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd, |
140 |
|
clip_encrypt_dlg_proc, 0, |
141 |
static gpgme_error_t |
_("Encryption"), IDS_WINPT_ENCRYPT ); |
142 |
currwnd_gpg_dlg (HWND hwnd, UINT id, int *ret_set) |
break; |
143 |
{ |
|
144 |
gpgme_error_t err; |
case ID_WINPT_CURRWND_SIGNENCRYPT: |
145 |
gpg_pgptype_t type; |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd, |
146 |
|
clip_signenc_dlg_proc, 0, |
147 |
if (ret_set) |
_("Sign & Encrypt"), IDS_WINPT_SIGNENC ); |
148 |
*ret_set = 1; |
break; |
149 |
switch (id) { |
|
150 |
case ID_WINPT_CURRWND_SYMENC: |
case ID_WINPT_CURRWND_SIGN: |
151 |
gpg_encrypt_symmetric (); |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd, |
152 |
break; |
clip_sign_dlg_proc, 0, |
153 |
|
_("Signing"), IDS_WINPT_SIGN ); |
154 |
case ID_WINPT_CURRWND_ENCRYPT: |
break; |
155 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd, |
|
156 |
clip_encrypt_dlg_proc, NULL, |
case ID_WINPT_CURRWND_DECRYPT_VERIFY: |
157 |
_("Encryption"), IDS_WINPT_ENCRYPT ); |
err = gpg_clip_get_pgptype (&type); |
158 |
break; |
if (err) { |
159 |
|
msg_box (hwnd, gpgme_strerror (err), _("Clipboard"), MB_ERR); |
160 |
case ID_WINPT_CURRWND_SIGNENCRYPT: |
break; |
161 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd, |
} |
162 |
clip_signenc_dlg_proc, NULL, |
if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) { |
163 |
_("Sign & Encrypt"), IDS_WINPT_SIGNENC ); |
/* It makes only sense to insert the data in the window if it's |
164 |
break; |
really a ciphertext. Verfied data doesn't need this. */ |
165 |
|
err = clip_decrypt_dlg (hwnd); |
166 |
case ID_WINPT_CURRWND_SIGN: |
if (!err && reg_prefs.use_viewer) { |
167 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd, |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
168 |
clip_sign_dlg_proc, NULL, |
GetDesktopWindow(), clip_edit_dlg_proc, 0, |
169 |
_("Signing"), IDS_WINPT_SIGN ); |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT); |
170 |
break; |
if (ret_set) |
171 |
|
*ret_set = 0; |
172 |
case ID_WINPT_CURRWND_DECRYPT_VERIFY: |
} |
173 |
err = gpg_clip_get_pgptype (&type); |
} |
174 |
if (err) { |
else if ((type & PGP_PUBKEY) && !(type & PGP_CLEARSIG)) |
175 |
msg_box (hwnd, gpgme_strerror (err), _("Clipboard"), MB_ERR); |
km_clip_import (GetDesktopWindow ()); |
176 |
break; |
else { |
177 |
} |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
178 |
if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) { |
clip_verify_dlg_proc, 0, |
179 |
/* It makes only sense to insert the data in the window if it's |
_("Verify"), IDS_WINPT_VERIFY ); |
180 |
really a ciphertext. Verfied data doesn't need this. */ |
err = gpg_error (GPG_ERR_EOF); /* make sure window is not updated. */ |
181 |
err = clip_decrypt_dlg (hwnd); |
} |
182 |
if (!err && reg_prefs.use_viewer) { |
break; |
183 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
} |
184 |
GetDesktopWindow(), clip_edit_dlg_proc, NULL, |
|
185 |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT); |
return err; |
186 |
if (ret_set) |
} |
187 |
*ret_set = 0; |
|
188 |
} |
|
189 |
} |
static void |
190 |
else if ((type & PGP_PUBKEY) && !(type & PGP_CLEARSIG)) |
clip_gpg_dlg (HWND hwnd, UINT id) |
191 |
km_clip_import (GetDesktopWindow ()); |
{ |
192 |
else { |
gpgme_error_t err; |
193 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
int type; |
194 |
clip_verify_dlg_proc, NULL, |
|
195 |
_("Verify"), IDS_WINPT_VERIFY ); |
if ((id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT) |
196 |
err = gpg_error (GPG_ERR_EOF); /* make sure window is ot updated. */ |
&& gnupg_access_keyring (0)) { |
197 |
} |
msg_box (hwnd, _("Could not access secret keyring."), _("Sign"), MB_ERR); |
198 |
break; |
return; |
199 |
} |
} |
200 |
|
|
201 |
return err; |
switch( id ) { |
202 |
} |
case ID_WINPT_SYMENC: |
203 |
|
gpg_encrypt_symmetric (); |
204 |
|
break; |
205 |
static void |
|
206 |
clip_gpg_dlg (HWND hwnd, UINT id) |
case ID_WINPT_ENCRYPT: |
207 |
{ |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd, |
208 |
gpgme_error_t err; |
clip_encrypt_dlg_proc, 0, |
209 |
gpg_pgptype_t type; |
_("Encryption"), IDS_WINPT_ENCRYPT ); |
210 |
size_t size = 0; |
break; |
211 |
|
|
212 |
if( (id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT) |
case ID_WINPT_SIGN: |
213 |
&& gnupg_access_keyring (0) ) { |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd, |
214 |
msg_box( hwnd, _("Could not access secret keyring."), _("Sign"), MB_ERR ); |
clip_sign_dlg_proc, 0, |
215 |
return; |
_("Signing"), IDS_WINPT_SIGN ); |
216 |
} |
break; |
217 |
|
|
218 |
switch( id ) { |
case ID_WINPT_SIGNENCRYPT: |
219 |
case ID_WINPT_SYMENC: |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd, |
220 |
gpg_encrypt_symmetric(); |
clip_signenc_dlg_proc, 0, |
221 |
break; |
_("Sign & Encrypt"), IDS_WINPT_SIGNENC ); |
222 |
|
break; |
223 |
case ID_WINPT_ENCRYPT: |
|
224 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd, |
case ID_WINPT_DECRYPT_VERIFY: |
225 |
clip_encrypt_dlg_proc, NULL, |
err = gpg_clip_get_pgptype (&type); |
226 |
_("Encryption"), IDS_WINPT_ENCRYPT ); |
if (err) { |
227 |
break; |
msg_box( hwnd, gpgme_strerror( err ), _("Clipboard"), MB_ERR ); |
228 |
|
break; |
229 |
case ID_WINPT_SIGN: |
} |
230 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd, |
if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) { |
231 |
clip_sign_dlg_proc, NULL, |
err = clip_decrypt_dlg (hwnd); |
232 |
_("Signing"), IDS_WINPT_SIGN ); |
if (!err && reg_prefs.use_viewer) { |
233 |
break; |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
234 |
|
GetDesktopWindow(), clip_edit_dlg_proc, 0, |
235 |
case ID_WINPT_SIGNENCRYPT: |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT ); |
236 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd, |
} |
237 |
clip_signenc_dlg_proc, NULL, |
} |
238 |
_("Sign & Encrypt"), IDS_WINPT_SIGNENC ); |
else if( (type & PGP_SIG) && !(type & PGP_CLEARSIG) ) { |
239 |
break; |
text_input_s input; |
240 |
|
gpgme_data_t sig; |
241 |
case ID_WINPT_DECRYPT_VERIFY: |
|
242 |
err = gpg_clip_get_pgptype (&type); |
memset( &input, 0, sizeof (input) ); |
243 |
if (err) { |
err = gpg_data_new_from_clipboard (&sig, 0); |
244 |
msg_box( hwnd, gpgme_strerror( err ), _("Clipboard"), MB_ERR ); |
if( err ) { |
245 |
break; |
msg_box( hwnd, gpgme_strerror( err ),_("Verify"), MB_ERR ); |
246 |
} |
return; |
247 |
if( (type & PGP_MESSAGE) && !(type & PGP_CLEARSIG) ) { |
} |
248 |
err = clip_decrypt_dlg (hwnd); |
input.type = 0; |
249 |
if (!err && reg_prefs.use_viewer) { |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_TEXT, hwnd, |
250 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
text_input_dlg_proc, (LPARAM)&input, |
251 |
GetDesktopWindow(), clip_edit_dlg_proc, NULL, |
_("Text Input"), IDS_WINPT_TEXT ); |
252 |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT ); |
|
253 |
} |
gpg_data_release_and_set_clipboard( sig, 0 ); |
254 |
} |
if( input.length ) { |
255 |
else if( (type & PGP_SIG) && !(type & PGP_CLEARSIG) ) { |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
256 |
text_input_s input; |
clip_verify_dlg_proc, (LPARAM)&input, |
257 |
gpgme_data_t sig; |
_("Verify"), IDS_WINPT_VERIFY ); |
258 |
|
input.length = 0; |
259 |
memset( &input, 0, sizeof (input) ); |
free_if_alloc( input.data ); |
260 |
err = gpg_data_new_from_clipboard (&sig, 0); |
} |
261 |
if( err ) { |
} |
262 |
msg_box( hwnd, gpgme_strerror( err ),_("Verify"), MB_ERR ); |
else if (type & PGP_CLEARSIG) { |
263 |
return; |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
264 |
} |
clip_verify_dlg_proc, 0, |
265 |
input.type = 0; |
_("Verify"), IDS_WINPT_VERIFY ); |
266 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_TEXT, hwnd, |
} |
267 |
text_input_dlg_proc, (LPARAM)&input, |
else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY)) |
268 |
_("Text Input"), IDS_WINPT_TEXT ); |
km_clip_import (GetDesktopWindow ()); |
269 |
|
else |
270 |
gpg_data_release_and_set_clipboard( sig, 0 ); |
msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR); |
271 |
if( input.length ) { |
} |
272 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
} |
273 |
clip_verify_dlg_proc, (LPARAM)&input, |
|
274 |
_("Verify"), IDS_WINPT_VERIFY ); |
|
275 |
input.length = 0; |
static bool |
276 |
free_if_alloc( input.data ); |
secret_key_available (void) |
277 |
} |
{ |
278 |
} |
gpg_keycache_t sec = keycache_get_ctx (0); |
279 |
else if (type & PGP_CLEARSIG) { |
if (!sec || gpg_keycache_get_size (sec) == 0) |
280 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd, |
return false; |
281 |
clip_verify_dlg_proc, NULL, |
return true; |
282 |
_("Verify"), IDS_WINPT_VERIFY ); |
} |
283 |
} |
|
284 |
else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY)) |
|
285 |
km_clip_import (GetDesktopWindow ()); |
/* Load the Card Manager with the current card. */ |
286 |
else |
static void |
287 |
msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR); |
load_card_manager (void) |
288 |
} |
{ |
289 |
} /* clip_gpg_dlg */ |
gpg_card_t card; |
290 |
|
|
291 |
|
card = gpg_card_load (); |
292 |
gpg_card_t |
if (card) { |
293 |
smartcard_init (void) |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_CARD_EDIT, |
294 |
{ |
GetDesktopWindow (), card_edit_dlg_proc, |
295 |
/* |
(LPARAM)card, |
296 |
pcsc_loadlib (scard_support); |
_("Card Edit"), IDS_WINPT_CARD_EDIT); |
297 |
rc = show_card_status (); |
gpg_card_release (card); |
298 |
if( rc ) |
} |
299 |
break; |
} |
300 |
*/ |
|
301 |
return gpg_load_scard (); |
|
302 |
} |
/* Add the winpt symbol to the task bar. */ |
303 |
|
static void |
304 |
|
add_taskbar_icon (HWND hwnd, NOTIFYICONDATA *nid) |
305 |
/* Add the winpt symbol to the task bar. */ |
{ |
306 |
static void |
nid->cbSize = sizeof (NOTIFYICONDATA); |
307 |
add_taskbar_icon (HWND hwnd, NOTIFYICONDATA *nid) |
nid->uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
308 |
{ |
nid->uCallbackMessage = WM_USER; |
309 |
nid->cbSize = sizeof (NOTIFYICONDATA); |
nid->hWnd = hwnd; |
310 |
nid->uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
nid->hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT)); |
311 |
nid->uCallbackMessage = WM_USER; |
strcpy (nid->szTip, "Windows Privacy Tray v"PGM_VERSION); |
312 |
nid->hWnd = hwnd; |
Shell_NotifyIcon (NIM_ADD, nid); |
313 |
nid->hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT)); |
DestroyIcon (nid->hIcon); |
314 |
strcpy (nid->szTip, "Windows Privacy Tray v"PGM_VERSION); |
} |
315 |
Shell_NotifyIcon (NIM_ADD, nid); |
|
316 |
DestroyIcon (nid->hIcon); |
|
317 |
} |
/* Main message loop for the tray window. */ |
318 |
|
LRESULT CALLBACK |
319 |
|
winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
320 |
/* Main message loop for the tray window. */ |
{ |
321 |
LRESULT CALLBACK |
static NOTIFYICONDATA NID; |
322 |
winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
static int use_hotkey = 0; |
323 |
{ |
INITCOMMONCONTROLSEX cce; |
324 |
static NOTIFYICONDATA NID; |
LPARAM param; |
325 |
static int use_hotkey = 0; |
HWND wnd; |
326 |
reminder_ctx_s ctx; |
gpgme_error_t err; |
327 |
LPARAM param; |
curr_wnd_ctx currwnd = {0}; |
328 |
curr_wnd_ctx currwnd = {0}; |
const char *s; |
329 |
size_t size = 0; |
int rc, set_wc = 0, has_data = 0; |
330 |
int rc, set_wc = 0, has_data = 0; |
|
331 |
INITCOMMONCONTROLSEX cce; |
switch (msg) { |
332 |
gpgme_error_t err; |
case WM_CREATE: |
333 |
gpg_card_t card; |
add_taskbar_icon (hwnd, &NID); |
334 |
|
rc = wsock_init (); |
335 |
switch (msg) { |
if (rc) |
336 |
case WM_CREATE: |
msg_box (NULL, winpt_strerror (rc), "Winsock2 DLL", MB_ERR); |
337 |
add_taskbar_icon (hwnd, &NID); |
if (!reg_prefs.no_hotkeys) { |
338 |
rc = wsock_init (); |
rc = hotkeys_register (hwnd); |
339 |
if (rc) |
if (rc) |
340 |
msg_box (NULL, winpt_strerror (rc), "Winsock2 DLL", MB_ERR); |
msg_box (hwnd, hotkeys_strerror (), winpt_strerror (rc), MB_ERR); |
341 |
if (!reg_prefs.no_hotkeys) { |
} |
342 |
rc = hotkeys_register (hwnd); |
rc = PTD_initialize (); |
343 |
if (rc) |
if (!rc) |
344 |
msg_box (hwnd, hotkeys_strerror (), winpt_strerror (rc), MB_ERR); |
msg_box (hwnd, _("Could not set current window mode hooks."), |
345 |
} |
_("WinPT Error"), MB_OK); |
346 |
rc = PTD_initialize (); |
mapi_init (); |
347 |
if (!rc) |
/* init common controls: date control. */ |
348 |
msg_box (hwnd, _("Could not set current window mode hooks."), |
cce.dwSize = sizeof (INITCOMMONCONTROLSEX); |
349 |
_("WinPT Error"), MB_OK); |
cce.dwICC = ICC_DATE_CLASSES; |
350 |
mapi_init (); |
InitCommonControlsEx (&cce); |
351 |
/* init common controls: date control. */ |
LoadLibrary ("RichEd32.Dll"); |
352 |
cce.dwSize = sizeof (INITCOMMONCONTROLSEX); |
break; |
353 |
cce.dwICC = ICC_DATE_CLASSES; |
|
354 |
InitCommonControlsEx (&cce); |
case WM_ENDSESSION: |
355 |
LoadLibrary ("RichEd32.Dll"); |
case WM_DESTROY: |
356 |
break; |
case WM_CLOSE: |
357 |
|
case WM_QUIT: |
358 |
case WM_ENDSESSION: |
cryptdisk_cleanup (); |
359 |
case WM_DESTROY: |
mapi_deinit (); |
360 |
case WM_CLOSE: |
wsock_end (); |
361 |
case WM_QUIT: |
keycache_release (1); |
362 |
cryptdisk_cleanup (); |
gnupg_backup_keyrings (); |
363 |
mapi_deinit (); |
free_reg_prefs (); |
364 |
wsock_end (); |
free_gnupg_table (); |
365 |
keycache_release (1); |
hotkeys_unregister (hwnd); |
366 |
gnupg_backup_keyrings (); |
PTD_delete (); |
367 |
free_reg_prefs (); |
agent_flush_cache (); |
368 |
free_gnupg_table (); |
if (!gpg_clip_istext_avail (&has_data) && has_data) { |
369 |
hotkeys_unregister (hwnd); |
int chk = get_reg_winpt_flag ("WipeClipboard"); |
370 |
release_file_lock (&mo_file); |
if (chk == -1 && msg != WM_ENDSESSION) |
371 |
PTD_delete (); |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP, |
372 |
agent_flush_cache (); |
GetDesktopWindow (), confirm_delclipboard_dlg, |
373 |
if (!gpg_clip_istext_avail (&has_data) && has_data) { |
0); |
374 |
int chk = get_reg_winpt_flag ("WipeClipboard"); |
if (wipe_contents || chk) |
375 |
if (chk == -1) |
set_clip_text (NULL, " ", 1); |
376 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP, |
wipe_contents = 0; |
377 |
GetDesktopWindow (), confirm_delclipboard_dlg, |
} |
378 |
NULL); |
debug_end (); |
379 |
if (wipe_contents || chk) |
Shell_NotifyIcon (NIM_DELETE, &NID); |
380 |
set_clip_text (NULL, " ", 1); |
PostQuitMessage (0); |
381 |
wipe_contents = 0; |
ExitProcess (0); |
382 |
} |
break; |
383 |
cleanup_tmp_files (); |
|
384 |
Shell_NotifyIcon (NIM_DELETE, &NID); |
case WM_USER: |
385 |
PostQuitMessage (0); |
switch (lparam) { |
386 |
ExitProcess (0); |
case WM_RBUTTONUP: |
387 |
return 0; |
HMENU hm, popup; |
388 |
|
POINT p; |
389 |
case WM_USER: |
|
390 |
switch (lparam) { |
gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1; |
391 |
case WM_RBUTTONUP: |
|
392 |
HMENU hm, popup; |
SetForegroundWindow (hwnd); |
393 |
POINT p; |
GetCursorPos (&p); |
394 |
|
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT)); |
395 |
gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1; |
popup = GetSubMenu (hm, 0); |
396 |
|
|
397 |
SetForegroundWindow (hwnd); |
set_menu_text( popup, ID_WINPT_FILE, _("File Manager") ); |
398 |
GetCursorPos (&p); |
set_menu_text( popup, ID_WINPT_KEY, _("Key Manager") ); |
399 |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT)); |
set_menu_text( popup, ID_WINPT_CARD, _("Card Manager") ); |
400 |
popup = GetSubMenu (hm, 0); |
if (!scard_support) |
401 |
#ifndef LANG_DE |
set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED); |
402 |
set_menu_text( popup, ID_WINPT_FILE, _("File Manager") ); |
if (!cryptdisk_available ()) { |
403 |
set_menu_text( popup, ID_WINPT_KEY, _("Key Manager") ); |
set_menu_state (popup, ID_WINPT_CDISKNEW, MF_DISABLED|MF_GRAYED); |
404 |
set_menu_text( popup, ID_WINPT_CARD, _("Card Manager") ); |
set_menu_state (popup, ID_WINPT_CDISKMOUNT, MF_DISABLED|MF_GRAYED); |
405 |
if (!scard_support) |
set_menu_state (popup, ID_WINPT_CDISKUNMOUNT, MF_DISABLED|MF_GRAYED); |
406 |
set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED); |
} |
407 |
if (!cryptdisk_available ()) { |
|
408 |
set_menu_state (popup, ID_WINPT_CDISKNEW, MF_DISABLED|MF_GRAYED); |
set_menu_text (popup, ID_WINPT_EDIT, _("Edit Clipboard")); |
409 |
set_menu_state (popup, ID_WINPT_CDISKMOUNT, MF_DISABLED|MF_GRAYED); |
set_menu_text (popup, ID_WINPT_ABOUT, _("About...")); |
410 |
set_menu_state (popup, ID_WINPT_CDISKUNMOUNT, MF_DISABLED|MF_GRAYED); |
set_menu_text (popup, ID_WINPT_QUIT, _("Exit")); |
411 |
} |
set_menu_text (popup, ID_WINPT_SYMENC, _("Symmetric")); |
412 |
|
set_menu_text (popup, ID_WINPT_ENCRYPT, _("Encrypt")); |
413 |
set_menu_text( popup, ID_WINPT_EDIT, _("Edit Clipboard") ); |
set_menu_text (popup, ID_WINPT_SIGN, _("Sign")); |
414 |
set_menu_text( popup, ID_WINPT_ABOUT, _("About...") ); |
set_menu_text (popup, ID_WINPT_SIGNENCRYPT, _("Sign && Encrypt")); |
415 |
set_menu_text( popup, ID_WINPT_QUIT, _("Exit") ); |
set_menu_text (popup, ID_WINPT_DECRYPT, _("Decrypt/Verify")); |
416 |
set_menu_text( popup, ID_WINPT_SYMENC, _("Symmetric") ); |
set_menu_text (popup, ID_WINPT_VERIFY, _("Verify")); |
417 |
#if 0 |
set_menu_text (popup, ID_WINPT_CURRWND_ENCRYPT, _("Encrypt")); |
418 |
set_menu_text( popup, ID_WINPT_ENCRYPT, _("Encrypt") ); |
set_menu_text (popup, ID_WINPT_CURRWND_SIGNENCRYPT, _("Sign && Encrypt")); |
419 |
set_menu_text( popup, ID_WINPT_SIGNENCRYPT, _("Sign && Encrypt") ); |
set_menu_text (popup, ID_WINPT_CURRWND_DECRYPT_VERIFY, _("Decrypt/Verify")); |
420 |
set_menu_text( popup, ID_WINPT_DECRYPT, _("Decrypt/Verify") ); |
set_menu_text (popup, ID_WINPT_CURRWND_SIGN, _("Sign")); |
421 |
set_menu_text( popup, ID_WINPT_VERIFY, _("Verify") ); |
if (!secret_key_available ()) { |
422 |
set_menu_text( popup, ID_WINPT_CURRWND_ENCRYPT, _("Encrypt") ); |
set_menu_state (popup, ID_WINPT_SIGN, MF_DISABLED|MF_GRAYED); |
423 |
set_menu_text( popup, ID_WINPT_CURRWND_SIGNENCRYPT, _("Sign && Encrypt") ); |
set_menu_state (popup, ID_WINPT_CURRWND_SIGN, MF_DISABLED|MF_GRAYED); |
424 |
set_menu_text( popup, ID_WINPT_CURRWND_DECRYPT_VERIFY, _("Decrypt/Verify") ); |
set_menu_state (popup, ID_WINPT_SIGNENCRYPT, MF_DISABLED|MF_GRAYED); |
425 |
set_menu_text( popup, ID_WINPT_CURRWND_SIGN, _("Sign") ); |
set_menu_state (popup, ID_WINPT_CURRWND_SIGNENCRYPT, MF_DISABLED|MF_GRAYED); |
426 |
#endif |
} |
427 |
#endif |
/* change popup texts */ |
428 |
TrackPopupMenu( popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL ); |
set_menu_text_bypos (popup, 6, _("Clipboard")); |
429 |
PostMessage( hwnd, WM_USER, 0, 0 ); |
set_menu_text_bypos (popup, 7, _("Current Window")); |
430 |
DestroyMenu( popup ); |
set_menu_text_bypos (popup, 9, _("Preferences")); |
431 |
DestroyMenu( hm ); |
|
432 |
break; |
TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL); |
433 |
|
PostMessage (hwnd, WM_USER, 0, 0); |
434 |
case WM_LBUTTONDBLCLK: |
DestroyMenu (popup); |
435 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_KEY, 0 ); |
DestroyMenu (hm); |
436 |
break; |
break; |
437 |
} |
|
438 |
break; |
case WM_LBUTTONDBLCLK: |
439 |
|
gpg_read_only = gpg_check_permissions (0) == 0? 0 : 1; |
440 |
case WM_HOTKEY: |
SendMessage (hwnd, WM_COMMAND, ID_WINPT_KEY, 0); |
441 |
cmd = 0; |
break; |
442 |
switch( wparam ) { |
} |
443 |
case WPT_CLIP_ENCRYPT_ID: |
break; |
444 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_ENCRYPT, 0 ); |
|
445 |
break; |
case WM_HOTKEY: |
446 |
|
cmd = 0; |
447 |
case WPT_CLIP_DECRYPT_VERIFY_ID: |
switch( wparam ) { |
448 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_DECRYPT_VERIFY, 0 ); |
case WPT_CLIP_ENCRYPT_ID: |
449 |
break; |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_ENCRYPT, 0 ); |
450 |
|
break; |
451 |
case WPT_CLIP_SIGN_ID: |
|
452 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGN, 0 ); |
case WPT_CLIP_DECRYPT_VERIFY_ID: |
453 |
break; |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_DECRYPT_VERIFY, 0 ); |
454 |
|
break; |
455 |
case WPT_CLIP_SIGN_ENCRYPT_ID: |
|
456 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGNENCRYPT, 0 ); |
case WPT_CLIP_SIGN_ID: |
457 |
break; |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGN, 0 ); |
458 |
|
break; |
459 |
case WPT_CURRWND_ENCRYPT_ID: |
|
460 |
use_hotkey = 1; |
case WPT_CLIP_SIGN_ENCRYPT_ID: |
461 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_ENCRYPT, 0 ); |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_SIGNENCRYPT, 0 ); |
462 |
break; |
break; |
463 |
|
|
464 |
case WPT_CURRWND_SIGN_ID: |
case WPT_CURRWND_ENCRYPT_ID: |
465 |
use_hotkey = 1; |
use_hotkey = 1; |
466 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGN, 0 ); |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_ENCRYPT, 0 ); |
467 |
break; |
break; |
468 |
|
|
469 |
case WPT_CURRWND_SIGN_ENCRYPT_ID: |
case WPT_CURRWND_SIGN_ID: |
470 |
use_hotkey = 1; |
use_hotkey = 1; |
471 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGNENCRYPT, 0 ); |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGN, 0 ); |
472 |
break; |
break; |
473 |
|
|
474 |
case WPT_CURRWND_DECRYPT_VERIFY_ID: |
case WPT_CURRWND_SIGN_ENCRYPT_ID: |
475 |
use_hotkey = 1; |
use_hotkey = 1; |
476 |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_DECRYPT_VERIFY, 0 ); |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_SIGNENCRYPT, 0 ); |
477 |
break; |
break; |
478 |
|
|
479 |
case WPT_AGENT_FORGET_ID: |
case WPT_CURRWND_DECRYPT_VERIFY_ID: |
480 |
rc = msg_box( hwnd, _("Remove all passphrases from cache?"), |
use_hotkey = 1; |
481 |
_("WinPT"), MB_YESNO|MB_ICONQUESTION ); |
SendMessage( hwnd, WM_COMMAND, ID_WINPT_CURRWND_DECRYPT_VERIFY, 0 ); |
482 |
if( rc == IDYES ) |
break; |
483 |
agent_flush_cache(); |
|
484 |
break; |
case WPT_AGENT_FORGET_ID: |
485 |
} |
rc = msg_box( hwnd, _("Remove all passphrases from cache?"), |
486 |
break; |
_("WinPT"), MB_YESNO|MB_ICONQUESTION ); |
487 |
|
if( rc == IDYES ) |
488 |
case WM_COMMAND: |
agent_flush_cache(); |
489 |
if( gnupg_access_keyring( 1 ) ) { |
break; |
490 |
if( log_box( "WinPT", MB_ERR|MB_YESNO, |
} |
491 |
_("Could not access public keyring, exit WinPT?") ) == IDYES ) |
break; |
492 |
SendMessage( hwnd, WM_DESTROY, 0, 0 ); |
|
493 |
break; |
case WM_COMMAND: |
494 |
} |
if( gnupg_access_keyring( 1 ) ) { |
495 |
switch( wparam ) { |
if( log_box( "WinPT", MB_ERR|MB_YESNO, |
496 |
/** Clipboard operations **/ |
_("Could not access public keyring, exit WinPT?") ) == IDYES ) |
497 |
case ID_WINPT_SYMENC: |
SendMessage( hwnd, WM_DESTROY, 0, 0 ); |
498 |
case ID_WINPT_ENCRYPT: |
break; |
499 |
case ID_WINPT_SIGN: |
} |
500 |
case ID_WINPT_SIGNENCRYPT: |
switch( wparam ) { |
501 |
case ID_WINPT_DECRYPT_VERIFY: |
/** Clipboard operations **/ |
502 |
err = gpg_clip_istext_avail( &has_data ); |
case ID_WINPT_SYMENC: |
503 |
if( err ) { |
case ID_WINPT_ENCRYPT: |
504 |
msg_box( hwnd, gpgme_strerror( err ),_("Clipboard"), MB_ERR ); |
case ID_WINPT_SIGN: |
505 |
break; |
case ID_WINPT_SIGNENCRYPT: |
506 |
} |
case ID_WINPT_DECRYPT_VERIFY: |
507 |
if( !has_data ) { |
err = gpg_clip_istext_avail( &has_data ); |
508 |
msg_box( hwnd, winpt_strerror (WPTERR_CLIP_EMPTY),_("Clipboard"), MB_ERR ); |
if( err ) { |
509 |
break; |
msg_box( hwnd, gpgme_strerror( err ),_("Clipboard"), MB_ERR ); |
510 |
} |
break; |
511 |
ctx.msecs = 500; |
} |
512 |
window_reminder( &ctx ); |
if( !has_data ) { |
513 |
clip_gpg_dlg( hwnd, (int)wparam ); |
msg_box( hwnd, winpt_strerror (WPTERR_CLIP_EMPTY),_("Clipboard"), MB_ERR ); |
514 |
break; |
break; |
515 |
|
} |
516 |
/** Current window operations **/ |
clip_gpg_dlg (hwnd, (int)wparam); |
517 |
case ID_WINPT_CURRWND_SYMENC: |
break; |
518 |
case ID_WINPT_CURRWND_ENCRYPT: |
|
519 |
case ID_WINPT_CURRWND_SIGNENCRYPT: |
/** Current window operations **/ |
520 |
case ID_WINPT_CURRWND_DECRYPT_VERIFY: |
case ID_WINPT_CURRWND_SYMENC: |
521 |
case ID_WINPT_CURRWND_SIGN: |
case ID_WINPT_CURRWND_ENCRYPT: |
522 |
rc = get_window_contents( hwnd, &currwnd, &use_hotkey ); |
case ID_WINPT_CURRWND_SIGNENCRYPT: |
523 |
if( rc ) { |
case ID_WINPT_CURRWND_DECRYPT_VERIFY: |
524 |
log_box( _("WinPT Error"), MB_ERR, |
case ID_WINPT_CURRWND_SIGN: |
525 |
_("Make sure that the window contains text.\n" |
rc = get_window_contents( hwnd, &currwnd, &use_hotkey ); |
526 |
"%s."), |
if( rc ) { |
527 |
winpt_strerror( WPTERR_CURR_WND ) ); |
log_box( _("WinPT Error"), MB_ERR, |
528 |
break; |
_("Make sure that the window contains text.\n" |
529 |
} |
"%s."), |
530 |
ctx.msecs = 500; |
winpt_strerror( WPTERR_CURR_WND ) ); |
531 |
window_reminder( &ctx ); |
break; |
532 |
rc = currwnd_gpg_dlg( hwnd, (UINT)wparam, &set_wc ); |
} |
533 |
if( !rc && set_wc ) |
rc = currwnd_gpg_dlg (hwnd, (UINT)wparam, &set_wc); |
534 |
set_window_contents( hwnd, &currwnd ); |
if (!rc && set_wc) |
535 |
break; |
set_window_contents (hwnd, &currwnd); |
536 |
|
break; |
537 |
/** File handling **/ |
|
538 |
case ID_WINPT_FILE: |
/** File handling **/ |
539 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_FILE, |
case ID_WINPT_FILE: |
540 |
GetDesktopWindow(), file_manager_dlg_proc, NULL, |
s = _("File Manager (use drag & drop to add files)"); |
541 |
_("File Manager (use drag & drop to add files)"), IDS_WINPT_FILE ); |
wnd = FindWindow (NULL, s); |
542 |
break; |
if (wnd && IsIconic (wnd)) |
543 |
|
ShowWindow (wnd, SW_RESTORE); |
544 |
/** Misc **/ |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_FILE, |
545 |
case ID_WINPT_KEY: |
GetDesktopWindow (), file_manager_dlg_proc, 0, |
546 |
param = NULL; |
s, IDS_WINPT_FILE); |
547 |
if( cmd ) |
break; |
548 |
param = (LPARAM)cmd; |
|
549 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC, |
/** Misc **/ |
550 |
GetDesktopWindow(), keymanager_dlg_proc, param, |
case ID_WINPT_KEY: |
551 |
_("Key Manager"), IDS_WINPT_KEYMISC ); |
wnd = FindWindow (NULL, _("Key Manager")); |
552 |
cmd = 0; |
if (wnd && IsIconic (wnd)) |
553 |
break; |
ShowWindow (wnd, SW_RESTORE); |
554 |
|
param = 0; |
555 |
case ID_WINPT_CARD: |
if (cmd) |
556 |
card = smartcard_init (); |
param = (LPARAM)cmd; |
557 |
if( card ) { |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC, |
558 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CARD_EDIT, |
GetDesktopWindow(), keymanager_dlg_proc, param, |
559 |
GetDesktopWindow(), card_edit_dlg_proc, |
_("Key Manager"), IDS_WINPT_KEYMISC); |
560 |
(LPARAM)card, |
cmd = 0; |
561 |
_("Card Edit"), IDS_WINPT_CARD_EDIT ); |
break; |
562 |
gpg_card_release( card ); card = NULL; |
|
563 |
} |
case ID_WINPT_CARD: |
564 |
break; |
load_card_manager (); |
565 |
|
break; |
566 |
case ID_WINPT_EDIT: |
|
567 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
case ID_WINPT_EDIT: |
568 |
GetDesktopWindow(), clip_edit_dlg_proc, NULL, |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CLIPEDIT, |
569 |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT ); |
GetDesktopWindow(), clip_edit_dlg_proc, 0, |
570 |
break; |
_("Clipboard Editor"), IDS_WINPT_CLIPEDIT ); |
571 |
|
break; |
572 |
case ID_WINPT_ABOUT: |
|
573 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, GetDesktopWindow(), |
case ID_WINPT_ABOUT: |
574 |
about_winpt_dlg_proc, NULL, |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, GetDesktopWindow(), |
575 |
_("About WinPT"), IDS_WINPT_ABOUT ); |
about_winpt_dlg_proc, 0, |
576 |
break; |
_("About WinPT"), IDS_WINPT_ABOUT ); |
577 |
|
break; |
578 |
case ID_WINPT_PREFS: |
|
579 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_PREFS, GetDesktopWindow(), |
case ID_WINPT_PREFS: |
580 |
prefs_dlg_proc, NULL, |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_PREFS, GetDesktopWindow(), |
581 |
_("WinPT Preferences"), IDS_WINPT_PREFS ); |
prefs_dlg_proc, 0, |
582 |
break; |
_("WinPT Preferences"), IDS_WINPT_PREFS ); |
583 |
|
break; |
584 |
case ID_WINPT_GPGPREFS: |
|
585 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, GetDesktopWindow(), |
case ID_WINPT_GPGPREFS: |
586 |
gpgprefs_dlg_proc, NULL, |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, GetDesktopWindow(), |
587 |
_("GnuPG Preferences"), IDS_WINPT_GPGPREFS); |
gpgprefs_dlg_proc, 0, |
588 |
break; |
_("GnuPG Preferences"), IDS_WINPT_GPGPREFS); |
589 |
|
break; |
590 |
case ID_WINPT_CDISKNEW: |
|
591 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_NEW, |
case ID_WINPT_CDISKNEW: |
592 |
GetDesktopWindow (), cryptdisk_new_dlg_proc, NULL); |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_NEW, |
593 |
break; |
GetDesktopWindow (), cryptdisk_new_dlg_proc, 0); |
594 |
|
break; |
595 |
case ID_WINPT_CDISKMOUNT: |
|
596 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_MOUNT, |
case ID_WINPT_CDISKMOUNT: |
597 |
GetDesktopWindow (), cryptdisk_mount_dlg_proc, NULL); |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_MOUNT, |
598 |
break; |
GetDesktopWindow (), cryptdisk_mount_dlg_proc, 0); |
599 |
|
break; |
600 |
case ID_WINPT_CDISKUNMOUNT: |
|
601 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_UMOUNT, |
case ID_WINPT_CDISKUNMOUNT: |
602 |
GetDesktopWindow (), cryptdisk_umount_dlg_proc, NULL); |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_UMOUNT, |
603 |
break; |
GetDesktopWindow (), cryptdisk_umount_dlg_proc, 0); |
604 |
|
break; |
605 |
case ID_WINPT_CDISKUMOUNTALL: |
|
606 |
cryptdisk_unmount (0, 0); |
case ID_WINPT_CDISKUMOUNTALL: |
607 |
break; |
cryptdisk_unmount (0, 0); |
608 |
|
break; |
609 |
case ID_WINPT_QUIT: |
|
610 |
SendMessage (hwnd, WM_DESTROY, 0, 0); |
case ID_WINPT_QUIT: |
611 |
break; |
SendMessage (hwnd, WM_DESTROY, 0, 0); |
612 |
} |
break; |
613 |
break; |
} |
614 |
} |
break; |
615 |
|
} |
616 |
return DefWindowProc (hwnd, msg, wparam, lparam); |
|
617 |
} /* winpt_main_proc */ |
return DefWindowProc (hwnd, msg, wparam, lparam); |
618 |
|
} |