34 |
#include "resource.h" |
#include "resource.h" |
35 |
|
|
36 |
|
|
37 |
/* Dialog box procedure for the GPG config file. */ |
#define DEF_CFGSIZE 2048 |
38 |
|
|
39 |
|
/* Dialog box procedure for manipulating the GPG config file. */ |
40 |
BOOL CALLBACK |
BOOL CALLBACK |
41 |
gpgopt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
gpgopt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
42 |
{ |
{ |
43 |
int id, nbytes = 8192; |
int id, nbytes = DEF_CFGSIZE; |
44 |
char t[4], *optbuf = NULL; |
char t[4], *optbuf = NULL; |
45 |
|
|
46 |
switch (msg) { |
switch (msg) { |
74 |
return FALSE; |
return FALSE; |
75 |
} |
} |
76 |
optbuf[nbytes] = '\0'; |
optbuf[nbytes] = '\0'; |
77 |
if( check_gnupg_options( optbuf, 1 ) ) { |
if (check_gnupg_options (optbuf, 1)) { |
78 |
msg_box( dlg, _("File contains invalid GnuPG keywords!"), _("GPG Config"), MB_ERR ); |
msg_box (dlg, _("File contains invalid GnuPG keywords!"), _("GPG Config"), MB_ERR); |
79 |
free_if_alloc( optbuf ); |
free_if_alloc (optbuf); |
80 |
return FALSE; |
return FALSE; |
81 |
} |
} |
82 |
if( set_gnupg_options( optbuf, strlen( optbuf ) ) ) { |
if (set_gnupg_options (optbuf, strlen (optbuf))) { |
83 |
msg_box( dlg, _("Could not save GnuPG config file."), _("GPG Config"), MB_ERR ); |
msg_box (dlg, _("Could not save GnuPG config file."), _("GPG Config"), MB_ERR); |
84 |
free_if_alloc( optbuf ); |
free_if_alloc (optbuf); |
85 |
return FALSE; |
return FALSE; |
86 |
} |
} |
87 |
msg_box( dlg, _("Successfully saved."), _("GPG Config"), MB_OK ); |
msg_box (dlg, _("Successfully saved."), _("GPG Config"), MB_OK); |
88 |
free_if_alloc( optbuf ); |
free_if_alloc (optbuf); |
89 |
return TRUE; |
return TRUE; |
90 |
|
|
91 |
case IDC_GPGOPT_LOAD: |
case IDC_GPGOPT_LOAD: |
92 |
if( GetDlgItemText(dlg, IDC_GPGOPT_FILE, t, sizeof t - 1 ) ) { |
if (GetDlgItemText(dlg, IDC_GPGOPT_FILE, t, sizeof (t) - 1)) { |
93 |
id = msg_box( dlg, _("Current data will be lost!\n" |
id = msg_box (dlg, _("Current data will be lost!\n" |
94 |
"Are you sure?"), _("GPG Config"), MB_INFO|MB_YESNO ); |
"Are you sure?"), _("GPG Config"), MB_INFO|MB_YESNO); |
95 |
if (id == IDNO) |
if (id == IDNO) |
96 |
return TRUE; |
return TRUE; |
97 |
} |
} |
103 |
return TRUE; |
return TRUE; |
104 |
|
|
105 |
case IDCANCEL: |
case IDCANCEL: |
106 |
EndDialog( dlg, FALSE ); |
EndDialog (dlg, FALSE); |
107 |
return FALSE; |
return FALSE; |
108 |
} |
} |
109 |
break; |
break; |