1 |
/* wptGPGOptDlg.cpp - WinPT GnuPG Options |
/* wptGPGOptDlg.cpp - WinPT GnuPG GPG Config |
2 |
* Copyright (C) 2001, 2002, 2003 Timo Schulz |
* Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
40 |
switch( msg ) { |
switch( msg ) { |
41 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
42 |
optbuf = get_gnupg_config (); |
optbuf = get_gnupg_config (); |
43 |
if( !optbuf ) |
if (!optbuf) |
44 |
dlg_fatal_error( dlg, _("Could not load GnuPG config file!") ); |
dlg_fatal_error( dlg, _("Could not load GnuPG config file!") ); |
45 |
|
SetDlgItemText( dlg, IDC_GPGOPT_FILE, optbuf); |
46 |
#ifndef LANG_DE |
#ifndef LANG_DE |
47 |
SetWindowText( dlg, _("GnuPG Options" ) ); |
SetWindowText( dlg, _("GnuPG GPG Config" ) ); |
|
SetDlgItemText( dlg, IDC_GPGOPT_FILE, optbuf ); |
|
48 |
SetDlgItemText( dlg, IDC_GPGOPT_SAVE, _("&Save") ); |
SetDlgItemText( dlg, IDC_GPGOPT_SAVE, _("&Save") ); |
49 |
SetDlgItemText( dlg, IDC_GPGOPT_LOAD, _("&Load") ); |
SetDlgItemText( dlg, IDC_GPGOPT_LOAD, _("&Load") ); |
50 |
#endif |
#endif |
65 |
BUG( dlg); |
BUG( dlg); |
66 |
nbytes = GetDlgItemText( dlg, IDC_GPGOPT_FILE, optbuf, nbytes ); |
nbytes = GetDlgItemText( dlg, IDC_GPGOPT_FILE, optbuf, nbytes ); |
67 |
if( !nbytes ) { |
if( !nbytes ) { |
68 |
msg_box( dlg, _("The 'gpg.conf' file is not loaded."), _("Options"), MB_ERR ); |
msg_box( dlg, _("The 'gpg.conf' file is not loaded."), _("GPG Config"), MB_ERR ); |
69 |
free_if_alloc( optbuf ); |
free_if_alloc( optbuf ); |
70 |
return FALSE; |
return FALSE; |
71 |
} |
} |
72 |
optbuf[nbytes] = '\0'; |
optbuf[nbytes] = '\0'; |
73 |
if( check_gnupg_options( optbuf ) ) { |
if( check_gnupg_options( optbuf ) ) { |
74 |
msg_box( dlg, _("File contains invalid GnuPG keywords!"), _("Options"), MB_ERR ); |
msg_box( dlg, _("File contains invalid GnuPG keywords!"), _("GPG Config"), MB_ERR ); |
75 |
free_if_alloc( optbuf ); |
free_if_alloc( optbuf ); |
76 |
return FALSE; |
return FALSE; |
77 |
} |
} |
78 |
if( set_gnupg_options( optbuf, strlen( optbuf ) ) ) { |
if( set_gnupg_options( optbuf, strlen( optbuf ) ) ) { |
79 |
msg_box( dlg, _("Could not save GnuPG options file."), _("Options"), MB_ERR ); |
msg_box( dlg, _("Could not save GnuPG config file."), _("GPG Config"), MB_ERR ); |
80 |
free_if_alloc( optbuf ); |
free_if_alloc( optbuf ); |
81 |
return FALSE; |
return FALSE; |
82 |
} |
} |
83 |
msg_box( dlg, _("Successfully saved."), _("Options"), MB_OK ); |
msg_box( dlg, _("Successfully saved."), _("GPG Config"), MB_OK ); |
84 |
free_if_alloc( optbuf ); |
free_if_alloc( optbuf ); |
85 |
return TRUE; |
return TRUE; |
86 |
|
|
87 |
case IDC_GPGOPT_LOAD: |
case IDC_GPGOPT_LOAD: |
88 |
if( GetDlgItemText(dlg, IDC_GPGOPT_FILE, t, sizeof t - 1 ) ) { |
if( GetDlgItemText(dlg, IDC_GPGOPT_FILE, t, sizeof t - 1 ) ) { |
89 |
id = msg_box( dlg, _("Current data will be lost!\n" |
id = msg_box( dlg, _("Current data will be lost!\n" |
90 |
"Are you sure?"), _("Options"), MB_INFO|MB_YESNO ); |
"Are you sure?"), _("GPG Config"), MB_INFO|MB_YESNO ); |
91 |
if( id == IDNO ) |
if (id == IDNO) |
92 |
return TRUE; |
return TRUE; |
93 |
} |
} |
94 |
optbuf = get_gnupg_config (); |
optbuf = get_gnupg_config (); |
95 |
if( !optbuf ) |
if (!optbuf) |
96 |
msg_box( dlg, _("Could not load GnuPG options file!"), _("Options"), MB_ERR ); |
msg_box (dlg, _("Could not load GnuPG config file!"), _("GPG Config"), MB_ERR); |
97 |
SetDlgItemText( dlg, IDC_GPGOPT_FILE, optbuf ); |
SetDlgItemText (dlg, IDC_GPGOPT_FILE, optbuf); |
98 |
free_if_alloc( optbuf ); |
free_if_alloc (optbuf); |
99 |
return TRUE; |
return TRUE; |
100 |
|
|
101 |
case IDCANCEL: |
case IDCANCEL: |