45 |
#include "wptCryptdisk.h" |
#include "wptCryptdisk.h" |
46 |
#include "wptCardEdit.h" |
#include "wptCardEdit.h" |
47 |
|
|
48 |
|
|
49 |
|
void update_keycache (HWND hwnd); |
50 |
|
|
51 |
static int cmd = 0; |
static int cmd = 0; |
52 |
static int wipe_contents = 0; |
static int wipe_contents = 0; |
53 |
|
|
292 |
gpg_card_t card; |
gpg_card_t card; |
293 |
|
|
294 |
card = gpg_card_load (); |
card = gpg_card_load (); |
295 |
if (card) { |
if (!card) |
296 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_CARD_EDIT, |
return; |
297 |
GetDesktopWindow (), card_edit_dlg_proc, |
|
298 |
(LPARAM)card, |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_CARD_EDIT, |
299 |
_("Card Edit"), IDS_WINPT_CARD_EDIT); |
GetDesktopWindow (), card_edit_dlg_proc, |
300 |
gpg_card_release (card); |
(LPARAM)card, |
301 |
} |
_("Card Edit"), IDS_WINPT_CARD_EDIT); |
302 |
|
gpg_card_release (card); |
303 |
} |
} |
304 |
|
|
305 |
|
|
318 |
} |
} |
319 |
|
|
320 |
|
|
321 |
|
static void |
322 |
|
init_common_controls (void) |
323 |
|
{ |
324 |
|
INITCOMMONCONTROLSEX cce; |
325 |
|
|
326 |
|
/* date control, toolbar, trackbar, ... */ |
327 |
|
cce.dwSize = sizeof (INITCOMMONCONTROLSEX); |
328 |
|
cce.dwICC = ICC_DATE_CLASSES|ICC_BAR_CLASSES; |
329 |
|
InitCommonControlsEx (&cce); |
330 |
|
} |
331 |
|
|
332 |
|
|
333 |
/* Main message loop for the tray window. */ |
/* Main message loop for the tray window. */ |
334 |
LRESULT CALLBACK |
LRESULT CALLBACK |
335 |
winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
337 |
static NOTIFYICONDATA NID; |
static NOTIFYICONDATA NID; |
338 |
static DWORD cookie; |
static DWORD cookie; |
339 |
static int use_hotkey = 0; |
static int use_hotkey = 0; |
340 |
INITCOMMONCONTROLSEX cce; |
static int manual_shutdown = 0; |
|
LPARAM param; |
|
341 |
HWND wnd; |
HWND wnd; |
342 |
gpgme_error_t err; |
gpgme_error_t err; |
343 |
curr_wnd_ctx currwnd = {0}; |
curr_wnd_ctx currwnd = {0}; |
360 |
msg_box (hwnd, _("Could not set current window mode hooks."), |
msg_box (hwnd, _("Could not set current window mode hooks."), |
361 |
_("WinPT Error"), MB_OK); |
_("WinPT Error"), MB_OK); |
362 |
mapi_init (); |
mapi_init (); |
363 |
/* init common controls: date control. */ |
init_common_controls (); |
|
cce.dwSize = sizeof (INITCOMMONCONTROLSEX); |
|
|
cce.dwICC = ICC_DATE_CLASSES; |
|
|
InitCommonControlsEx (&cce); |
|
364 |
html_help_init (&cookie); |
html_help_init (&cookie); |
365 |
LoadLibrary ("RichEd32.Dll"); |
LoadLibrary ("RichEd32.Dll"); |
366 |
|
manual_shutdown = 0; |
367 |
break; |
break; |
368 |
|
|
369 |
case WM_ENDSESSION: |
case WM_ENDSESSION: |
370 |
case WM_DESTROY: |
case WM_DESTROY: |
371 |
case WM_CLOSE: |
case WM_CLOSE: |
372 |
case WM_QUIT: |
case WM_QUIT: |
|
cryptdisk_cleanup (); |
|
373 |
mapi_deinit (); |
mapi_deinit (); |
374 |
wsock_end (); |
wsock_end (); |
375 |
keycache_release (1); |
keycache_release (1); |
376 |
gnupg_backup_keyrings (); |
gnupg_backup_keyrings (reg_prefs.auto_backup, reg_prefs.backup.mode); |
377 |
free_reg_prefs (); |
free_reg_prefs (); |
378 |
free_gnupg_table (); |
free_gnupg_table (); |
379 |
hotkeys_unregister (hwnd); |
hotkeys_unregister (hwnd); |
382 |
html_help_deinit (cookie); |
html_help_deinit (cookie); |
383 |
if (!gpg_clip_istext_avail (&has_data) && has_data) { |
if (!gpg_clip_istext_avail (&has_data) && has_data) { |
384 |
int chk = get_reg_winpt_flag ("WipeClipboard"); |
int chk = get_reg_winpt_flag ("WipeClipboard"); |
385 |
if (chk == -1 && msg != WM_ENDSESSION) |
if (chk == -1 && manual_shutdown) |
386 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP, |
387 |
GetDesktopWindow (), confirm_delclipboard_dlg, |
GetDesktopWindow (), confirm_delclipboard_dlg, |
388 |
0); |
0); |
409 |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT)); |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT)); |
410 |
popup = GetSubMenu (hm, 0); |
popup = GetSubMenu (hm, 0); |
411 |
|
|
412 |
set_menu_text( popup, ID_WINPT_FILE, _("File Manager") ); |
set_menu_text (popup, ID_WINPT_FILE, _("File Manager")); |
413 |
set_menu_text( popup, ID_WINPT_KEY, _("Key Manager") ); |
set_menu_text (popup, ID_WINPT_KEY, _("Key Manager")); |
414 |
set_menu_text( popup, ID_WINPT_CARD, _("Card Manager") ); |
set_menu_text (popup, ID_WINPT_CARD, _("Card Manager")); |
415 |
if (!scard_support) |
if (!scard_support) |
416 |
set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED); |
set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED); |
|
if (!cryptdisk_available ()) { |
|
|
set_menu_state (popup, ID_WINPT_CDISKNEW, MF_DISABLED|MF_GRAYED); |
|
|
set_menu_state (popup, ID_WINPT_CDISKMOUNT, MF_DISABLED|MF_GRAYED); |
|
|
set_menu_state (popup, ID_WINPT_CDISKUNMOUNT, MF_DISABLED|MF_GRAYED); |
|
|
} |
|
|
|
|
417 |
set_menu_text (popup, ID_WINPT_EDIT, _("Edit Clipboard")); |
set_menu_text (popup, ID_WINPT_EDIT, _("Edit Clipboard")); |
418 |
set_menu_text (popup, ID_WINPT_ABOUT, _("About...")); |
set_menu_text (popup, ID_WINPT_ABOUT, _("About...")); |
419 |
set_menu_text (popup, ID_WINPT_QUIT, _("Exit")); |
set_menu_text (popup, ID_WINPT_QUIT, _("Exit")); |
513 |
case ID_WINPT_SIGN: |
case ID_WINPT_SIGN: |
514 |
case ID_WINPT_SIGNENCRYPT: |
case ID_WINPT_SIGNENCRYPT: |
515 |
case ID_WINPT_DECRYPT_VERIFY: |
case ID_WINPT_DECRYPT_VERIFY: |
516 |
err = gpg_clip_istext_avail( &has_data ); |
err = gpg_clip_istext_avail (&has_data); |
517 |
if( err ) { |
if (err) { |
518 |
msg_box( hwnd, gpgme_strerror( err ),_("Clipboard"), MB_ERR ); |
msg_box (hwnd, gpgme_strerror (err),_("Clipboard"), MB_ERR); |
519 |
break; |
break; |
520 |
} |
} |
521 |
if( !has_data ) { |
if (!has_data) { |
522 |
msg_box( hwnd, winpt_strerror (WPTERR_CLIP_EMPTY),_("Clipboard"), MB_ERR ); |
msg_box (hwnd, winpt_strerror (WPTERR_CLIP_EMPTY), |
523 |
|
_("Clipboard"), MB_ERR); |
524 |
break; |
break; |
525 |
} |
} |
526 |
clip_gpg_dlg (hwnd, (int)wparam); |
clip_gpg_dlg (hwnd, (int)wparam); |
527 |
break; |
break; |
528 |
|
|
529 |
/** Current window operations **/ |
/** Current window operations **/ |
530 |
case ID_WINPT_CURRWND_SYMENC: |
case ID_WINPT_CURRWND_SYMENC: |
531 |
case ID_WINPT_CURRWND_ENCRYPT: |
case ID_WINPT_CURRWND_ENCRYPT: |
563 |
ShowWindow (wnd, SW_RESTORE); |
ShowWindow (wnd, SW_RESTORE); |
564 |
if (wnd) |
if (wnd) |
565 |
SetForegroundWindow (wnd); |
SetForegroundWindow (wnd); |
|
param = 0; |
|
|
if (cmd) |
|
|
param = (LPARAM)cmd; |
|
566 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC, |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC, |
567 |
GetDesktopWindow(), keymanager_dlg_proc, param, |
GetDesktopWindow(), keymanager_dlg_proc, |
568 |
|
cmd != 0? (LPARAM)cmd : 0, |
569 |
_("Key Manager"), IDS_WINPT_KEYMISC); |
_("Key Manager"), IDS_WINPT_KEYMISC); |
570 |
cmd = 0; |
cmd = 0; |
571 |
break; |
break; |
593 |
break; |
break; |
594 |
|
|
595 |
case ID_WINPT_GPGPREFS: |
case ID_WINPT_GPGPREFS: |
596 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, GetDesktopWindow(), |
rc = dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, |
597 |
gpgprefs_dlg_proc, 0, |
GetDesktopWindow(), gpgprefs_dlg_proc, 0, |
598 |
_("GnuPG Preferences"), IDS_WINPT_GPGPREFS); |
_("GnuPG Preferences"), IDS_WINPT_GPGPREFS); |
599 |
|
if (rc == TRUE) |
600 |
|
update_keycache (GetDesktopWindow ()); |
601 |
break; |
break; |
|
|
|
|
case ID_WINPT_CDISKNEW: |
|
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_NEW, |
|
|
GetDesktopWindow (), cryptdisk_new_dlg_proc, 0); |
|
|
break; |
|
|
|
|
|
case ID_WINPT_CDISKMOUNT: |
|
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_MOUNT, |
|
|
GetDesktopWindow (), cryptdisk_mount_dlg_proc, 0); |
|
|
break; |
|
|
|
|
|
case ID_WINPT_CDISKUNMOUNT: |
|
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_UMOUNT, |
|
|
GetDesktopWindow (), cryptdisk_umount_dlg_proc, 0); |
|
|
break; |
|
|
|
|
|
case ID_WINPT_CDISKUMOUNTALL: |
|
|
cryptdisk_unmount (0, 0); |
|
|
break; |
|
602 |
|
|
603 |
case ID_WINPT_QUIT: |
case ID_WINPT_QUIT: |
604 |
|
manual_shutdown = 1; |
605 |
SendMessage (hwnd, WM_DESTROY, 0, 0); |
SendMessage (hwnd, WM_DESTROY, 0, 0); |
606 |
break; |
break; |
607 |
} |
} |