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

Legend:
Removed from v.22  
changed lines
  Added in v.328

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26