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