/[winpt]/trunk/Src/wptGPGOptDlg.cpp
ViewVC logotype

Diff of /trunk/Src/wptGPGOptDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 48 by werner, Mon Oct 31 21:14:11 2005 UTC revision 256 by twoaday, Sat Aug 5 10:31:06 2006 UTC
# Line 17  Line 17 
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  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
21  #include <config.h>  #include <config.h>
22  #endif  #endif
# Line 35  Line 34 
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)  {
47      case WM_INITDIALOG:        case WM_INITDIALOG:  
48          optbuf = get_gnupg_config ();          optbuf = get_gnupg_config ();
49          if (!optbuf)          if (!optbuf) {
50              dlg_fatal_error (dlg,  _("Could not load GnuPG config file!"));              msg_box (dlg,  _("Could not load GnuPG config file!"),
51                         _("GPG Config"), MB_ERR);
52                EndDialog (dlg, FALSE);
53                return TRUE;
54            }
55          SetDlgItemText (dlg, IDC_GPGOPT_FILE, optbuf);          SetDlgItemText (dlg, IDC_GPGOPT_FILE, optbuf);
         #ifndef LANG_DE  
56          SetWindowText (dlg, _("GnuPG Configuration File" ));          SetWindowText (dlg, _("GnuPG Configuration File" ));
57          SetDlgItemText (dlg, IDC_GPGOPT_SAVE, _("&Save"));          SetDlgItemText (dlg, IDC_GPGOPT_SAVE, _("&Save"));
58          SetDlgItemText (dlg, IDC_GPGOPT_LOAD, _("&Load"));          SetDlgItemText (dlg, IDC_GPGOPT_LOAD, _("&Load"));
59          #endif          SetDlgItemText (dlg, IDCANCEL, _("&Exit"));
60          free_if_alloc( optbuf );          free_if_alloc (optbuf);
61          SetForegroundWindow( dlg );          SetForegroundWindow (dlg);
62          return TRUE;          return TRUE;
63                    
     case WM_SYSCOMMAND:  
         if( LOWORD (wparam) == SC_CLOSE )  
             EndDialog(dlg, TRUE);  
         return FALSE;  
           
64      case WM_COMMAND:      case WM_COMMAND:
65          switch( LOWORD( wparam ) ) {          switch( LOWORD( wparam ) ) {
66          case IDC_GPGOPT_SAVE:                        case IDC_GPGOPT_SAVE:              
67              optbuf = new char[nbytes + 1];              optbuf = new char[nbytes + 1];
68              if( !optbuf )              if (!optbuf)
69                  BUG( dlg);                  BUG (0);
70              nbytes = GetDlgItemText( dlg, IDC_GPGOPT_FILE, optbuf, nbytes );              nbytes = GetDlgItemText (dlg, IDC_GPGOPT_FILE, optbuf, nbytes);
71              if( !nbytes ) {              if (!nbytes) {
72                  msg_box( dlg, _("The 'gpg.conf' file is not loaded."), _("GPG Config"), MB_ERR );                  msg_box (dlg, _("The 'gpg.conf' file is not loaded."), _("GPG Config"), MB_ERR);
73                  free_if_alloc( optbuf );                  free_if_alloc (optbuf);
74                  return FALSE;                            return FALSE;          
75              }              }
76              optbuf[nbytes] = '\0';              optbuf[nbytes] = '\0';
77              if( check_gnupg_options( optbuf ) ) {              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              }              }
# Line 104  gpgopt_dlg_proc (HWND dlg, UINT msg, WPA Line 103  gpgopt_dlg_proc (HWND dlg, UINT msg, WPA
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;

Legend:
Removed from v.48  
changed lines
  Added in v.256

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26