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

Legend:
Removed from v.23  
changed lines
  Added in v.85

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26