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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26