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

Diff of /trunk/Src/wptPreferencesDlg.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 36 by werner, Thu Oct 27 15:25:13 2005 UTC
# Line 1  Line 1 
1  /* wptPreferencesDlg.cpp - Dialog for the preferences  /* wptPreferencesDlg.cpp - Dialog for the preferences
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 <shlobj.h>  #include <config.h>
23    #endif
24  #include "wptNLS.h"  
25  #include "wptGPG.h"  #include <windows.h>
26  #include "wptCommonCtl.h"  #include <windows.h>
27  #include "wptDlgs.h"  #include <shlobj.h>
28  #include "wptTypes.h"  
29  #include "wptErrors.h"  #include "wptNLS.h"
30  #include "wptRegistry.h"  #include "wptGPG.h"
31  #include "wptHotkey.h"  #include "wptCommonCtl.h"
32  #include "wptW32API.h"  #include "wptDlgs.h"
33  #include "wptVersion.h"  #include "wptTypes.h"
34  #include "wptAgent.h"  #include "wptErrors.h"
35  #include "wptKeyserver.h"  #include "wptRegistry.h"
36  #include "../resource.h"  #include "wptHotkey.h"
37    #include "wptW32API.h"
38    #include "wptVersion.h"
39  static int hotkeys[] = {  #include "wptAgent.h"
40      IDC_PREFS_CLIP_ENCRYPT,  #include "wptKeyserver.h"
41      IDC_PREFS_CLIP_DECRYPT_VERIFY,  #include "../resource.h"
42      IDC_PREFS_CLIP_SIGN,  
43      IDC_PREFS_CLIP_SIGNENC,  
44      IDC_PREFS_CWS_ENCRYPT,  /* Dialog IDs of all hotkeys. */
45      IDC_PREFS_CWS_DECRYPT_VERIFY,  static int hotkeys[] = {
46      IDC_PREFS_CWS_SIGN,      IDC_PREFS_CLIP_ENCRYPT,
47      IDC_PREFS_CWS_SIGNENC,      IDC_PREFS_CLIP_DECRYPT_VERIFY,
48      0      IDC_PREFS_CLIP_SIGN,
49  };      IDC_PREFS_CLIP_SIGNENC,
50        IDC_PREFS_CWS_ENCRYPT,
51        IDC_PREFS_CWS_DECRYPT_VERIFY,
52  static int      IDC_PREFS_CWS_SIGN,
53  check_hotkey (char * key)      IDC_PREFS_CWS_SIGNENC,
54  {      0
55      if (*key >= 'A' && *key <= 'Z')  };
56          return 1;  
57      else if (*key >= 'a' && *key <= 'z') {  
58          *key = *key - 32;  /* Check that the given hotkey is in A..Z or a..z. */
59          return 1;  static int
60      }  check_hotkey (char * key)
61      return 0;  {
62  } /* check_hotkey */      if (*key >= 'A' && *key <= 'Z')
63            return 1;
64        else if (*key >= 'a' && *key <= 'z') {
65  static void          *key = *key - 32;
66  disable_hotkey_items (HWND dlg, int val)          return 1;
67  {      }
68      int mode = val? FALSE : TRUE;      return 0;
69      int i, id;  }
70        
71      for (i=0; (id = hotkeys[i]); i++)  
72          EnableWindow( GetDlgItem( dlg, id ), mode );  /* Disable all hotkey controls in the dialog @dlg if val is 1. */
73  } /* disable_hotkey_items */  static void
74    disable_hotkey_items (HWND dlg, int val)
75    {
76  static void      int mode = val? FALSE : TRUE;
77  enable_backup_items (HWND dlg, int val)      int i, id;
78  {      
79      int mode = val? TRUE : FALSE;      for (i=0; (id = hotkeys[i]); i++)
80            EnableWindow (GetDlgItem (dlg, id), mode);
81      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKHOME), mode);  }
82      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKUSER), mode);  
83      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), mode);  
84      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), mode);  
85  } /* enable_backup_items */  /* En- or disable the backup items in the dialog @dlg.
86       If val != 0 activate them, disable them otherwise. */
87    static void
88  static void  enable_backup_items (HWND dlg, int val)
89  set_keylist_mode (HWND dlg)  {
90  {      int mode = val? TRUE : FALSE;
91      HWND cb = GetDlgItem (dlg, IDC_PREFS_LISTMODE);  
92      combox_add_string (cb, (char *)"NORMAL");      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKHOME), mode);
93      combox_add_string (cb, (char *)"MINIMAL");      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKUSER), mode);
94      SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.keylist_mode, 0);      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), mode);
95  } /* set_keylist_mode */      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), mode);
96    }
97    
98  static void  
99  set_wipe_mode (HWND dlg)  /* Initialize the combox in the dialog @dlg with the valid list modes. */
100  {  static void
101      HWND cb = GetDlgItem (dlg, IDC_PREFS_WIPEMODE);  init_keylist_modes (HWND dlg)
102      combox_add_string (cb, (char *)"Simple");  {
103      combox_add_string (cb, (char *)"DoD");      HWND cb = GetDlgItem (dlg, IDC_PREFS_LISTMODE);
104      combox_add_string (cb, (char *)"Gutmann");      combox_add_string (cb, (char *)"NORMAL");
105      SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.wipe_mode, 0);      combox_add_string (cb, (char *)"MINIMAL");
106  } /* set_wipe_mode */      SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.keylist_mode, 0);
107    }
108    
109  BOOL CALLBACK  
110  prefs_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  /* Initialize the combobox in the dialog @dlg with the valid wipe modes. */
111  {  static void
112      int rc;  init_wipe_modes (HWND dlg)
113      int i, id;  {
114      char t[2];      HWND cb = GetDlgItem (dlg, IDC_PREFS_WIPEMODE);
115      char path[256], * p;      combox_add_string (cb, (char *)"Simple");
116      HWND cb;      combox_add_string (cb, (char *)"DoD");
117            combox_add_string (cb, (char *)"Gutmann");
118      switch ( msg ) {      SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.wipe_mode, 0);
119      case WM_INITDIALOG:  }
120  #ifndef LANG_DE  
121          SetWindowText( dlg, _("WinPT Preferences") );  
122          SetDlgItemText( dlg, IDC_PREFS_SECMODE, _("Do not use any &temporary files") );  /* Dialog box procedure for the WinPT preferences. */
123          SetDlgItemText( dlg, IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext") );  BOOL CALLBACK
124          SetDlgItemText( dlg, IDC_PREFS_WWINFO, _("Word wrap cleartext &signatures at column") );  prefs_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
125          SetDlgItemText( dlg, IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)") );  {
126  #endif      int rc;
127          SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, reg_prefs.cache_time, TRUE );      int i, id;
128          SetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, reg_prefs.word_wrap, TRUE );      char t[2];
129          if (reg_prefs.backup.path)      char path[256], * p;
130              SetDlgItemText (dlg, IDC_PREFS_BAKPATH, reg_prefs.backup.path);      HWND cb;
131          if (reg_prefs.kserv_conf)      
132              SetDlgItemText (dlg, IDC_PREFS_KSERVER, reg_prefs.kserv_conf);      switch ( msg ) {
133        case WM_INITDIALOG:
134          for (i=0; (id=hotkeys[i]); i++)      #ifndef LANG_DE
135              SetDlgItemText (dlg, id, reg_hotkeys[i].key);          SetWindowText (dlg, _("WinPT Preferences"));
136          CheckDlgButton( dlg, IDC_PREFS_DISABLE_HOTKEYS,          SetDlgItemText (dlg, IDC_PREFS_SECMODE, _("Do not use any &temporary files"));
137                          reg_prefs.no_hotkeys ? BST_CHECKED : BST_UNCHECKED );          SetDlgItemText (dlg, IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext"));
138          CheckDlgButton( dlg, IDC_PREFS_SECMODE,          SetDlgItemText (dlg, IDC_PREFS_WWINFO, _("Word wrap cleartext &signatures at column"));
139                          reg_prefs.use_tmpfiles ? BST_UNCHECKED : BST_CHECKED );          SetDlgItemText (dlg, IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)"));
140          CheckDlgButton( dlg, IDC_PREFS_VIEWER,          SetDlgItemText (dlg, IDC_PREFS_TRUST, _("Skip key validation and assume that keys are always fully trusted"));
141                          reg_prefs.use_viewer ? BST_CHECKED: BST_UNCHECKED );          SetDlgItemText (dlg, IDC_PREFS_AUTOBACKUP, _("&Automatic keyring backup when WinPT closes"));
142          CheckDlgButton( dlg, IDC_PREFS_TRUST,          SetDlgItemText (dlg, IDC_PREFS_BAKHOME, _("Backup to GPG &home folder"));
143                          reg_prefs.always_trust? BST_CHECKED : BST_UNCHECKED );          SetDlgItemText (dlg, IDC_PREFS_BAKUSER, _("Backup to:"));
144          CheckDlgButton( dlg, IDC_PREFS_AUTOBACKUP,      #endif
145                          reg_prefs.auto_backup? BST_CHECKED : BST_UNCHECKED );          SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, reg_prefs.cache_time, TRUE );
146          CheckDlgButton( dlg, IDC_PREFS_BAKHOME,          SetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, reg_prefs.word_wrap, TRUE );
147                          reg_prefs.backup.mode==1? BST_CHECKED : BST_UNCHECKED );          if (reg_prefs.backup.path)
148          CheckDlgButton( dlg, IDC_PREFS_BAKUSER,              SetDlgItemText (dlg, IDC_PREFS_BAKPATH, reg_prefs.backup.path);
149                          reg_prefs.backup.mode==2? BST_CHECKED : BST_UNCHECKED );          if (reg_prefs.kserv_conf)
150          if( reg_prefs.no_hotkeys )              SetDlgItemText (dlg, IDC_PREFS_KSERVER, reg_prefs.kserv_conf);
151              disable_hotkey_items( dlg, 1 );  
152          if( !reg_prefs.auto_backup )          for (i=0; (id=hotkeys[i]); i++)
153              enable_backup_items( dlg, 0 );              SetDlgItemText (dlg, id, reg_hotkeys[i].key);
154          EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKPATH ),          CheckDlgButton( dlg, IDC_PREFS_DISABLE_HOTKEYS,
155                        reg_prefs.backup.mode==1?FALSE : TRUE );                          reg_prefs.no_hotkeys ? BST_CHECKED : BST_UNCHECKED );
156          EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKSELECT ),          CheckDlgButton( dlg, IDC_PREFS_SECMODE,
157                        reg_prefs.backup.mode==1? FALSE : TRUE );                          reg_prefs.use_tmpfiles ? BST_UNCHECKED : BST_CHECKED );
158          set_keylist_mode( dlg );          CheckDlgButton( dlg, IDC_PREFS_VIEWER,
159          set_wipe_mode( dlg );                          reg_prefs.use_viewer ? BST_CHECKED: BST_UNCHECKED );
160          center_window( dlg, NULL );          CheckDlgButton( dlg, IDC_PREFS_TRUST,
161          SetForegroundWindow( dlg );                          reg_prefs.always_trust? BST_CHECKED : BST_UNCHECKED );
162          return TRUE;          CheckDlgButton( dlg, IDC_PREFS_AUTOBACKUP,
163                                    reg_prefs.auto_backup? BST_CHECKED : BST_UNCHECKED );
164      case WM_SYSCOMMAND:          CheckDlgButton( dlg, IDC_PREFS_BAKHOME,
165          if( LOWORD( wparam ) == SC_CLOSE )                          reg_prefs.backup.mode==1? BST_CHECKED : BST_UNCHECKED );
166              EndDialog( dlg, TRUE );          CheckDlgButton( dlg, IDC_PREFS_BAKUSER,
167          return FALSE;                          reg_prefs.backup.mode==2? BST_CHECKED : BST_UNCHECKED );
168                    if( reg_prefs.no_hotkeys )
169      case WM_COMMAND:              disable_hotkey_items( dlg, 1 );
170          switch( HIWORD(wparam) ) {          if (!reg_prefs.auto_backup)
171          case BN_CLICKED:              enable_backup_items (dlg, 0);
172              switch( (int)LOWORD( wparam ) ) {          EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH),
173              case IDC_PREFS_DISABLE_HOTKEYS:                                    reg_prefs.backup.mode==1?FALSE : TRUE);
174                  reg_prefs.no_hotkeys ^= 1;          EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT),
175                  disable_hotkey_items( dlg, reg_prefs.no_hotkeys );                        reg_prefs.backup.mode==1? FALSE : TRUE);
176                  break;          init_keylist_modes (dlg);
177            init_wipe_modes (dlg);
178              case IDC_PREFS_TRUST:          center_window (dlg, NULL);
179                  reg_prefs.always_trust ^= 1;          SetForegroundWindow (dlg);
180                  if( reg_prefs.always_trust ) {          return TRUE;
181                      msg_box (dlg,          
182                  _("In most cases it is not a good idea to enable this setting.\n"      case WM_SYSCOMMAND:
183                    "If you know what you are doing let this flag enabled, otherwise\n"          if (LOWORD (wparam) == SC_CLOSE)
184                    "it is safe to leave this flag untouched."),              EndDialog (dlg, TRUE);
185                    _("Preferences"), MB_ICONWARNING|MB_OK );          return FALSE;
186                  }          
187                  break;      case WM_COMMAND:
188            switch( HIWORD(wparam) ) {
189              case IDC_PREFS_AUTOBACKUP:          case BN_CLICKED:
190                  reg_prefs.auto_backup ^= 1;                              switch( (int)LOWORD( wparam ) ) {
191                  enable_backup_items (dlg, reg_prefs.auto_backup);              case IDC_PREFS_DISABLE_HOTKEYS:            
192                  if (reg_prefs.auto_backup == 1) {                  reg_prefs.no_hotkeys ^= 1;
193                      if (!IsDlgButtonChecked (dlg, IDC_PREFS_BAKHOME) &&                  disable_hotkey_items( dlg, reg_prefs.no_hotkeys );
194                          !IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER))                  break;
195                          CheckDlgButton (dlg, IDC_PREFS_BAKHOME, BST_CHECKED);  
196                  }              case IDC_PREFS_TRUST:
197                  break;                  reg_prefs.always_trust ^= 1;
198                    if( reg_prefs.always_trust ) {
199              case IDC_PREFS_BAKHOME:                                  msg_box (dlg,
200                  EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), FALSE);                  _("In most cases it is not a good idea to enable this setting.\n"
201                  EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), FALSE);                    "If you know what you are doing let this flag enabled, otherwise\n"
202                  break;                    "it is safe to leave this flag untouched."),
203                      _("Preferences"), MB_ICONWARNING|MB_OK );
204              case IDC_PREFS_BAKUSER:                  }
205                  EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), TRUE);                  break;
206                  EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), TRUE);  
207                  break;              case IDC_PREFS_AUTOBACKUP:
208              }                  reg_prefs.auto_backup ^= 1;                
209              break;                  enable_backup_items (dlg, reg_prefs.auto_backup);
210          }                  if (reg_prefs.auto_backup == 1) {
211          switch( LOWORD( wparam ) ) {                      if (!IsDlgButtonChecked (dlg, IDC_PREFS_BAKHOME) &&
212          case IDC_PREFS_BAKSELECT:                          !IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER))
213              const char *bpath;                          CheckDlgButton (dlg, IDC_PREFS_BAKHOME, BST_CHECKED);
214              bpath = get_folder_dlg (dlg, _("Select GPG backup path"), NULL);                  }
215              if (bpath)                  break;
216                  SetDlgItemText (dlg, IDC_PREFS_BAKPATH, bpath);  
217              break;              case IDC_PREFS_BAKHOME:            
218                    EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), FALSE);
219          case IDC_PREFS_KSELFILE: {                  EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), FALSE);
220              const char * name;                  break;
221              name = get_filename_dlg (dlg, FILE_OPEN, _("Please select a keyserver.conf file"),  
222                                       NULL, NULL);              case IDC_PREFS_BAKUSER:
223              if (name != NULL)                  EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), TRUE);
224                  SetDlgItemText (dlg, IDC_PREFS_KSERVER, name);                  EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), TRUE);
225              break; }                  break;
226                }
227          case IDOK:              break;
228              rc = GetDlgItemInt( dlg, IDC_PREFS_CACHETIME, NULL, FALSE );          }
229              if( !rc )          switch( LOWORD( wparam ) ) {
230                  reg_prefs.cache_time = 0;          case IDC_PREFS_BAKSELECT:
231              else if( rc > 3600 ) {              const char *bpath;
232                  msg_box( dlg, _("Please enter a value that is between 1-3600.\nIt is not "              bpath = get_folder_dlg (dlg, _("Select GPG backup path"), NULL);
233                                  "a good idea to cache the passphrase more than one hour."),              if (bpath)
234                                  _("Preferences"), MB_ERR );                  SetDlgItemText (dlg, IDC_PREFS_BAKPATH, bpath);
235                  SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, 0, FALSE );              break;
236                  return FALSE;  
237              }          case IDC_PREFS_KSELFILE: {
238              if (reg_prefs.cache_time != rc)              const char * name;
239                  agent_flush_cache ();              name = get_filename_dlg (dlg, FILE_OPEN, _("Please select a keyserver.conf file"),
240              reg_prefs.cache_time = rc;                                       NULL, NULL);
241              rc = GetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, NULL, FALSE );              if (name != NULL)
242              if( !rc )                  SetDlgItemText (dlg, IDC_PREFS_KSERVER, name);
243                  reg_prefs.word_wrap = 0;              break; }
244              else if( rc > 80 ) {  
245                  msg_box( dlg, _("Please enter a value between 1-80."), _("Preferences"), MB_ERR );          case IDOK:
246                  return FALSE;              rc = GetDlgItemInt( dlg, IDC_PREFS_CACHETIME, NULL, FALSE );
247              }              if( !rc )
248              reg_prefs.word_wrap = rc;                  reg_prefs.cache_time = 0;
249              reg_prefs.use_tmpfiles = IsDlgButtonChecked( dlg, IDC_PREFS_SECMODE )? 0 : 1;              else if( rc > 3600 ) {
250              reg_prefs.use_viewer = IsDlgButtonChecked( dlg, IDC_PREFS_VIEWER )? 1 : 0;                  msg_box( dlg, _("Please enter a value that is between 1-3600.\nIt is not "
251              reg_prefs.backup.mode = IsDlgButtonChecked( dlg, IDC_PREFS_BAKHOME ) ? 1 :                                  "a good idea to cache the passphrase more than one hour."),
252                                      IsDlgButtonChecked( dlg, IDC_PREFS_BAKUSER )? 2 : 0;                                  _("Preferences"), MB_ERR );
253              if( reg_prefs.backup.mode == 2 ) {                  SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, 0, FALSE );
254                  if( !GetDlgItemText( dlg, IDC_PREFS_BAKPATH, path, sizeof (path)-1 )                  return TRUE;
255                      || dir_exist_check( path ) ) {              }
256                      msg_box( dlg, _("The specified backup folder is invalid."),              if (reg_prefs.cache_time != rc)
257                               _("Preferences"), MB_ERR );                  agent_flush_cache ();
258                      return FALSE;              reg_prefs.cache_time = rc;
259                  }              rc = GetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, NULL, FALSE );
260                  free_if_alloc (reg_prefs.backup.path);              if( !rc )
261                  p = reg_prefs.backup.path = m_strdup (path);                  reg_prefs.word_wrap = 0;
262                  if (!p)              else if( rc > 80 ) {
263                      BUG (0);                  msg_box( dlg, _("Please enter a value between 1-80."), _("Preferences"), MB_ERR );
264              }                  return TRUE;
265              free_if_alloc (reg_prefs.kserv_conf);              }
266              if (!GetDlgItemText (dlg, IDC_PREFS_KSERVER, path, sizeof (path)-1)              reg_prefs.word_wrap = rc;
267                  || file_exist_check (path)) {              reg_prefs.use_tmpfiles = IsDlgButtonChecked( dlg, IDC_PREFS_SECMODE )? 0 : 1;
268                  rc = msg_box (dlg, _("The specified keyserver config file is invalid.\n\n"              reg_prefs.use_viewer = IsDlgButtonChecked( dlg, IDC_PREFS_VIEWER )? 1 : 0;
269                                       "Create new default config file?"),              reg_prefs.backup.mode = IsDlgButtonChecked( dlg, IDC_PREFS_BAKHOME ) ? 1 :
270                           _("Preferences"), MB_ERR|MB_YESNO);                                      IsDlgButtonChecked( dlg, IDC_PREFS_BAKUSER )? 2 : 0;
271                  if (rc == IDNO)              if( reg_prefs.backup.mode == 2 ) {
272                      return FALSE;                  if( !GetDlgItemText( dlg, IDC_PREFS_BAKPATH, path, sizeof (path)-1 )
273                  else                      || dir_exist_check( path ) ) {
274                  {                      msg_box( dlg, _("The specified backup folder is invalid."),
275                      char cwd[256], * fn;                               _("Preferences"), MB_ERR );
276                      FILE * fp = fopen ("keyserver.conf", "wb");                      return TRUE;
277                      if (fp) {                  }
278                          fprintf (fp, "%s\r\n", DEF_HKP_KEYSERVER);                  free_if_alloc (reg_prefs.backup.path);
279                          fclose (fp);                  p = reg_prefs.backup.path = m_strdup (path);
280                      }                  if (!p)
281                      GetCurrentDirectory (DIM (cwd)-1, cwd);                      BUG (0);
282                      fn = make_filename (cwd, "keyserver", "conf");              }
283                      memset (path, 0, sizeof( path));              free_if_alloc (reg_prefs.kserv_conf);
284                      strncpy (path, fn, DIM (path)-1);              if (!GetDlgItemText (dlg, IDC_PREFS_KSERVER, path, sizeof (path)-1)
285                      free_if_alloc (fn);                  || file_exist_check (path)) {
286                  }                  rc = msg_box (dlg, _("The specified keyserver config file is invalid.\n\n"
287              }                                       "Create new default config file?"),
288              p = reg_prefs.kserv_conf = m_strdup (path);                           _("Preferences"), MB_ERR|MB_YESNO);
289              if (!p)                  if (rc == IDNO)
290                  BUG (0);                      return TRUE;
291                    else
292              cb = GetDlgItem( dlg, IDC_PREFS_LISTMODE );                  {
293              reg_prefs.keylist_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 );                      char cwd[256], * fn;
294                        FILE * fp = fopen ("keyserver.conf", "wb");
295              cb = GetDlgItem( dlg, IDC_PREFS_WIPEMODE );                      if (fp) {
296              reg_prefs.wipe_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 );                          fprintf (fp, "%s\r\n", DEF_HKP_KEYSERVER);
297                                        fclose (fp);
298              if (IsDlgButtonChecked (dlg, IDC_PREFS_DISABLE_HOTKEYS)) {                      }
299                  hotkeys_unregister (glob_hwnd);                      GetCurrentDirectory (DIM (cwd)-1, cwd);
300                  reg_prefs.no_hotkeys = 1;                      fn = make_filename (cwd, "keyserver", "conf");
301              }                      memset (path, 0, sizeof( path));
302              else {                      strncpy (path, fn, DIM (path)-1);
303                  reg_prefs.no_hotkeys = 0;                      free_if_alloc (fn);
304                  for( i = 0; (id = hotkeys[i]); i++ ) {                  }
305                      rc = GetDlgItemText( dlg, id, t, 2 );              }
306                      if( rc && check_hotkey( &t[0] ) )              p = reg_prefs.kserv_conf = m_strdup (path);
307                          hotkey_enable( &reg_hotkeys[i], t );              if (!p)
308                      else                  BUG (0);
309                          hotkey_disable( &reg_hotkeys[i] );  
310                  }              cb = GetDlgItem( dlg, IDC_PREFS_LISTMODE );
311                  set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "DisableHotkeys", "0");              reg_prefs.keylist_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 );
312                  reg_prefs.no_hotkeys = 0;  
313              }              cb = GetDlgItem( dlg, IDC_PREFS_WIPEMODE );
314                reg_prefs.wipe_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 );
315              if ((rc = set_reg_winpt_prefs (&reg_prefs)))              
316                  msg_box (dlg, winpt_strerror (rc), _("Preferences"), MB_ERR);              if (IsDlgButtonChecked (dlg, IDC_PREFS_DISABLE_HOTKEYS)) {
317                                hotkeys_unregister (glob_hwnd);
318              if (reg_prefs.no_hotkeys == 0) {                  reg_prefs.no_hotkeys = 1;
319                  hotkeys_unregister (glob_hwnd);              }
320                  hotkeys_modify ();              else {
321                  if ((rc = hotkeys_register (glob_hwnd)))                  reg_prefs.no_hotkeys = 0;
322                      msg_box (NULL, winpt_strerror (rc), _("Hotkeys"), MB_ERR);                  for( i = 0; (id = hotkeys[i]); i++ ) {
323              }                      rc = GetDlgItemText( dlg, id, t, 2 );
324              EndDialog (dlg, TRUE);                      if( rc && check_hotkey( &t[0] ) )
325              return TRUE;                          hotkey_enable( &reg_hotkeys[i], t );
326                                    else
327          case IDCANCEL:                          hotkey_disable( &reg_hotkeys[i] );
328              EndDialog( dlg, FALSE );                  }
329              return FALSE;                  set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "DisableHotkeys", "0");
330          }                  reg_prefs.no_hotkeys = 0;
331          break;              }
332      }  
333                    if ((rc = set_reg_winpt_prefs (&reg_prefs)))
334      return FALSE;                  msg_box (dlg, winpt_strerror (rc), _("Preferences"), MB_ERR);
335  } /* prefs_dlg_proc */              
336                if (reg_prefs.no_hotkeys == 0) {
337                    hotkeys_unregister (glob_hwnd);
338                    hotkeys_modify ();
339                    if ((rc = hotkeys_register (glob_hwnd)))
340                        msg_box (NULL, winpt_strerror (rc), _("Hotkeys"), MB_ERR);
341                }
342                EndDialog (dlg, TRUE);
343                return TRUE;
344                
345            case IDCANCEL:
346                EndDialog( dlg, FALSE );
347                return FALSE;
348            }
349            break;
350        }
351        
352        return FALSE;
353    }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26