/[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 2 by twoaday, Mon Jan 31 11:02:21 2005 UTC revision 255 by twoaday, Tue Aug 1 16:37:23 2006 UTC
# Line 1  Line 1 
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   *   *
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    #ifdef HAVE_CONFIG_H
21  #include <windows.h>  #include <config.h>
22    #endif
23  #include "wptTypes.h"  
24  #include "wptNLS.h"  #include <windows.h>
25  #include "wptGPG.h"  
26  #include "wptCommonCtl.h"  #include "wptTypes.h"
27  #include "wptContext.h" /* for passphrase_s */  #include "wptNLS.h"
28  #include "wptDlgs.h"  #include "wptGPG.h"
29  #include "wptW32API.h"  #include "wptCommonCtl.h"
30  #include "wptErrors.h"  #include "wptContext.h" /* for passphrase_s */
31  #include "../resource.h"  #include "wptDlgs.h"
32    #include "wptW32API.h"
33    #include "wptErrors.h"
34  BOOL CALLBACK  #include "resource.h"
35  gpgopt_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam )  
36  {        
37      int id, nbytes = 8192;  /* Dialog box procedure for the GPG config file. */
38      char t[4], *optbuf = NULL;  BOOL CALLBACK
39        gpgopt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
40      switch( msg )  {  {      
41      case WM_INITDIALOG:        int id, nbytes = 8192;
42          optbuf = get_gnupg_config ();      char t[4], *optbuf = NULL;
43          if( !optbuf )      
44              dlg_fatal_error( dlg,  _("Could not load GnuPG config file!") );      switch (msg)  {
45          #ifndef LANG_DE      case WM_INITDIALOG:  
46          SetWindowText( dlg, _("GnuPG Options" ) );          optbuf = get_gnupg_config ();
47          SetDlgItemText( dlg, IDC_GPGOPT_FILE, optbuf );          if (!optbuf) {
48          SetDlgItemText( dlg, IDC_GPGOPT_SAVE, _("&Save") );              msg_box (dlg,  _("Could not load GnuPG config file!"),
49          SetDlgItemText( dlg, IDC_GPGOPT_LOAD, _("&Load") );                       _("GPG Config"), MB_ERR);
50          #endif              EndDialog (dlg, FALSE);
51          free_if_alloc( optbuf );              return TRUE;
52          SetForegroundWindow( dlg );          }
53          return TRUE;          SetDlgItemText (dlg, IDC_GPGOPT_FILE, optbuf);
54                    SetWindowText (dlg, _("GnuPG Configuration File" ));
55      case WM_SYSCOMMAND:          SetDlgItemText (dlg, IDC_GPGOPT_SAVE, _("&Save"));
56          if( LOWORD (wparam) == SC_CLOSE )          SetDlgItemText (dlg, IDC_GPGOPT_LOAD, _("&Load"));
57              EndDialog(dlg, TRUE);          SetDlgItemText (dlg, IDCANCEL, _("&Exit"));
58          return FALSE;          free_if_alloc (optbuf);
59                    SetForegroundWindow (dlg);
60      case WM_COMMAND:          return TRUE;
61          switch( LOWORD( wparam ) ) {          
62          case IDC_GPGOPT_SAVE:                    case WM_COMMAND:
63              optbuf = new char[nbytes + 1];          switch( LOWORD( wparam ) ) {
64              if( !optbuf )          case IDC_GPGOPT_SAVE:              
65                  BUG( dlg);              optbuf = new char[nbytes + 1];
66              nbytes = GetDlgItemText( dlg, IDC_GPGOPT_FILE, optbuf, nbytes );              if (!optbuf)
67              if( !nbytes ) {                  BUG (0);
68                  msg_box( dlg, _("The 'gpg.conf' file is not loaded."), _("Options"), MB_ERR );              nbytes = GetDlgItemText (dlg, IDC_GPGOPT_FILE, optbuf, nbytes);
69                  free_if_alloc( optbuf );              if (!nbytes) {
70                  return FALSE;                            msg_box (dlg, _("The 'gpg.conf' file is not loaded."), _("GPG Config"), MB_ERR);
71              }                  free_if_alloc (optbuf);
72              optbuf[nbytes] = '\0';                  return FALSE;          
73              if( check_gnupg_options( optbuf ) ) {              }
74                  msg_box( dlg, _("File contains invalid GnuPG keywords!"), _("Options"), MB_ERR );              optbuf[nbytes] = '\0';
75                  free_if_alloc( optbuf );              if( check_gnupg_options( optbuf, 1 ) ) {
76                  return FALSE;                  msg_box( dlg, _("File contains invalid GnuPG keywords!"), _("GPG Config"), MB_ERR );
77              }                  free_if_alloc( optbuf );
78              if( set_gnupg_options( optbuf, strlen( optbuf ) ) ) {                  return FALSE;
79                  msg_box( dlg, _("Could not save GnuPG options file."), _("Options"), MB_ERR );              }
80                  free_if_alloc( optbuf );              if( set_gnupg_options( optbuf, strlen( optbuf ) ) ) {
81                  return FALSE;                  msg_box( dlg, _("Could not save GnuPG config file."), _("GPG Config"), MB_ERR );
82              }                  free_if_alloc( optbuf );
83              msg_box( dlg, _("Successfully saved."), _("Options"), MB_OK );                  return FALSE;
84              free_if_alloc( optbuf );              }
85              return TRUE;              msg_box( dlg, _("Successfully saved."), _("GPG Config"), MB_OK );
86                            free_if_alloc( optbuf );
87          case IDC_GPGOPT_LOAD:                                return TRUE;
88              if( GetDlgItemText(dlg, IDC_GPGOPT_FILE, t, sizeof t - 1 ) ) {              
89                  id = msg_box( dlg, _("Current data will be lost!\n"          case IDC_GPGOPT_LOAD:                  
90                                       "Are you sure?"), _("Options"), MB_INFO|MB_YESNO );                                      if( GetDlgItemText(dlg, IDC_GPGOPT_FILE, t, sizeof t - 1 ) ) {
91                  if( id == IDNO )                  id = msg_box( dlg, _("Current data will be lost!\n"
92                      return TRUE;                                       "Are you sure?"), _("GPG Config"), MB_INFO|MB_YESNO );                    
93              }                  if (id == IDNO)
94              optbuf = get_gnupg_config ();                      return TRUE;
95              if( !optbuf )              }
96                  msg_box( dlg, _("Could not load GnuPG options file!"), _("Options"), MB_ERR );              optbuf = get_gnupg_config ();
97              SetDlgItemText( dlg, IDC_GPGOPT_FILE, optbuf );              if (!optbuf)
98              free_if_alloc( optbuf );                  msg_box (dlg, _("Could not load GnuPG config file!"), _("GPG Config"), MB_ERR);
99              return TRUE;              SetDlgItemText (dlg, IDC_GPGOPT_FILE, optbuf);
100                            free_if_alloc (optbuf);
101          case IDCANCEL:              return TRUE;
102              EndDialog( dlg, FALSE );              
103              return FALSE;          case IDCANCEL:
104          }              EndDialog( dlg, FALSE );
105          break;              return FALSE;
106      }          }
107                break;
108      return 0;      }
109  } /* gpgopt_dlg_proc */      
110        return 0;
111    }

Legend:
Removed from v.2  
changed lines
  Added in v.255

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26