/[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 32 by twoaday, Mon Oct 24 08:03:48 2005 UTC
# Line 36  Line 36 
36  #include "../resource.h"  #include "../resource.h"
37    
38    
39    /* Dialog IDs of all hotkeys. */
40  static int hotkeys[] = {  static int hotkeys[] = {
41      IDC_PREFS_CLIP_ENCRYPT,      IDC_PREFS_CLIP_ENCRYPT,
42      IDC_PREFS_CLIP_DECRYPT_VERIFY,      IDC_PREFS_CLIP_DECRYPT_VERIFY,
# Line 49  static int hotkeys[] = { Line 50  static int hotkeys[] = {
50  };  };
51    
52    
53    /* Check that the given hotkey is in A..Z or a..z. */
54  static int  static int
55  check_hotkey (char * key)  check_hotkey (char * key)
56  {  {
# Line 59  check_hotkey (char * key) Line 61  check_hotkey (char * key)
61          return 1;          return 1;
62      }      }
63      return 0;      return 0;
64  } /* check_hotkey */  }
65    
66    
67    /* Disable all hotkey controls in the dialog @dlg if val is 1. */
68  static void  static void
69  disable_hotkey_items (HWND dlg, int val)  disable_hotkey_items (HWND dlg, int val)
70  {  {
# Line 69  disable_hotkey_items (HWND dlg, int val) Line 72  disable_hotkey_items (HWND dlg, int val)
72      int i, id;      int i, id;
73            
74      for (i=0; (id = hotkeys[i]); i++)      for (i=0; (id = hotkeys[i]); i++)
75          EnableWindow( GetDlgItem( dlg, id ), mode );          EnableWindow (GetDlgItem (dlg, id), mode);
76  } /* disable_hotkey_items */  }
77    
78    
79    
80    /* En- or disable the backup items in the dialog @dlg.
81       If val != 0 activate them, disable them otherwise. */
82  static void  static void
83  enable_backup_items (HWND dlg, int val)  enable_backup_items (HWND dlg, int val)
84  {  {
# Line 82  enable_backup_items (HWND dlg, int val) Line 88  enable_backup_items (HWND dlg, int val)
88      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKUSER), mode);      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKUSER), mode);
89      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), mode);      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), mode);
90      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), mode);      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), mode);
91  } /* enable_backup_items */  }
92    
93    
94    /* Initialize the combox in the dialog @dlg with the valid list modes. */
95  static void  static void
96  set_keylist_mode (HWND dlg)  init_keylist_modes (HWND dlg)
97  {  {
98      HWND cb = GetDlgItem (dlg, IDC_PREFS_LISTMODE);      HWND cb = GetDlgItem (dlg, IDC_PREFS_LISTMODE);
99      combox_add_string (cb, (char *)"NORMAL");      combox_add_string (cb, (char *)"NORMAL");
100      combox_add_string (cb, (char *)"MINIMAL");      combox_add_string (cb, (char *)"MINIMAL");
101      SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.keylist_mode, 0);      SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.keylist_mode, 0);
102  } /* set_keylist_mode */  }
103    
104    
105    /* Initialize the combobox in the dialog @dlg with the valid wipe modes. */
106  static void  static void
107  set_wipe_mode (HWND dlg)  init_wipe_modes (HWND dlg)
108  {  {
109      HWND cb = GetDlgItem (dlg, IDC_PREFS_WIPEMODE);      HWND cb = GetDlgItem (dlg, IDC_PREFS_WIPEMODE);
110      combox_add_string (cb, (char *)"Simple");      combox_add_string (cb, (char *)"Simple");
111      combox_add_string (cb, (char *)"DoD");      combox_add_string (cb, (char *)"DoD");
112      combox_add_string (cb, (char *)"Gutmann");      combox_add_string (cb, (char *)"Gutmann");
113      SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.wipe_mode, 0);      SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.wipe_mode, 0);
114  } /* set_wipe_mode */  }
115    
116    
117    /* Dialog box procedure for the WinPT preferences. */
118  BOOL CALLBACK  BOOL CALLBACK
119  prefs_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  prefs_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
120  {  {
# Line 117  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 126  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
126            
127      switch ( msg ) {      switch ( msg ) {
128      case WM_INITDIALOG:      case WM_INITDIALOG:
129  #ifndef LANG_DE      #ifndef LANG_DE
130          SetWindowText( dlg, _("WinPT Preferences") );          SetWindowText (dlg, _("WinPT Preferences"));
131          SetDlgItemText( dlg, IDC_PREFS_SECMODE, _("Do not use any &temporary files") );          SetDlgItemText (dlg, IDC_PREFS_SECMODE, _("Do not use any &temporary files"));
132          SetDlgItemText( dlg, IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext") );          SetDlgItemText (dlg, IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext"));
133          SetDlgItemText( dlg, IDC_PREFS_WWINFO, _("Word wrap cleartext &signatures at column") );          SetDlgItemText (dlg, IDC_PREFS_WWINFO, _("Word wrap cleartext &signatures at column"));
134          SetDlgItemText( dlg, IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)") );          SetDlgItemText (dlg, IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)"));
135  #endif          SetDlgItemText (dlg, IDC_PREFS_TRUST, _("Skip key validation and assume that keys are always fully trusted"));
136            SetDlgItemText (dlg, IDC_PREFS_AUTOBACKUP, _("&Automatic keyring backup when WinPT closes"));
137            SetDlgItemText (dlg, IDC_PREFS_BAKHOME, _("Backup to GPG &home folder"));
138            SetDlgItemText (dlg, IDC_PREFS_BAKUSER, _("Backup to:"));
139        #endif
140          SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, reg_prefs.cache_time, TRUE );          SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, reg_prefs.cache_time, TRUE );
141          SetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, reg_prefs.word_wrap, TRUE );          SetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, reg_prefs.word_wrap, TRUE );
142          if (reg_prefs.backup.path)          if (reg_prefs.backup.path)
# Line 149  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 162  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
162                          reg_prefs.backup.mode==2? BST_CHECKED : BST_UNCHECKED );                          reg_prefs.backup.mode==2? BST_CHECKED : BST_UNCHECKED );
163          if( reg_prefs.no_hotkeys )          if( reg_prefs.no_hotkeys )
164              disable_hotkey_items( dlg, 1 );              disable_hotkey_items( dlg, 1 );
165          if( !reg_prefs.auto_backup )          if (!reg_prefs.auto_backup)
166              enable_backup_items( dlg, 0 );              enable_backup_items (dlg, 0);
167          EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKPATH ),          EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH),
168                        reg_prefs.backup.mode==1?FALSE : TRUE );                        reg_prefs.backup.mode==1?FALSE : TRUE);
169          EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKSELECT ),          EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT),
170                        reg_prefs.backup.mode==1? FALSE : TRUE );                        reg_prefs.backup.mode==1? FALSE : TRUE);
171          set_keylist_mode( dlg );          init_keylist_modes (dlg);
172          set_wipe_mode( dlg );          init_wipe_modes (dlg);
173          center_window( dlg, NULL );          center_window (dlg, NULL);
174          SetForegroundWindow( dlg );          SetForegroundWindow (dlg);
175          return TRUE;          return TRUE;
176                    
177      case WM_SYSCOMMAND:      case WM_SYSCOMMAND:
178          if( LOWORD( wparam ) == SC_CLOSE )          if (LOWORD (wparam) == SC_CLOSE)
179              EndDialog( dlg, TRUE );              EndDialog (dlg, TRUE);
180          return FALSE;          return FALSE;
181                    
182      case WM_COMMAND:      case WM_COMMAND:
# Line 233  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 246  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
246                                  "a good idea to cache the passphrase more than one hour."),                                  "a good idea to cache the passphrase more than one hour."),
247                                  _("Preferences"), MB_ERR );                                  _("Preferences"), MB_ERR );
248                  SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, 0, FALSE );                  SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, 0, FALSE );
249                  return FALSE;                  return TRUE;
250              }              }
251              if (reg_prefs.cache_time != rc)              if (reg_prefs.cache_time != rc)
252                  agent_flush_cache ();                  agent_flush_cache ();
# Line 243  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 256  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
256                  reg_prefs.word_wrap = 0;                  reg_prefs.word_wrap = 0;
257              else if( rc > 80 ) {              else if( rc > 80 ) {
258                  msg_box( dlg, _("Please enter a value between 1-80."), _("Preferences"), MB_ERR );                  msg_box( dlg, _("Please enter a value between 1-80."), _("Preferences"), MB_ERR );
259                  return FALSE;                  return TRUE;
260              }              }
261              reg_prefs.word_wrap = rc;              reg_prefs.word_wrap = rc;
262              reg_prefs.use_tmpfiles = IsDlgButtonChecked( dlg, IDC_PREFS_SECMODE )? 0 : 1;              reg_prefs.use_tmpfiles = IsDlgButtonChecked( dlg, IDC_PREFS_SECMODE )? 0 : 1;
# Line 255  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 268  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
268                      || dir_exist_check( path ) ) {                      || dir_exist_check( path ) ) {
269                      msg_box( dlg, _("The specified backup folder is invalid."),                      msg_box( dlg, _("The specified backup folder is invalid."),
270                               _("Preferences"), MB_ERR );                               _("Preferences"), MB_ERR );
271                      return FALSE;                      return TRUE;
272                  }                  }
273                  free_if_alloc (reg_prefs.backup.path);                  free_if_alloc (reg_prefs.backup.path);
274                  p = reg_prefs.backup.path = m_strdup (path);                  p = reg_prefs.backup.path = m_strdup (path);
# Line 269  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 282  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
282                                       "Create new default config file?"),                                       "Create new default config file?"),
283                           _("Preferences"), MB_ERR|MB_YESNO);                           _("Preferences"), MB_ERR|MB_YESNO);
284                  if (rc == IDNO)                  if (rc == IDNO)
285                      return FALSE;                      return TRUE;
286                  else                  else
287                  {                  {
288                      char cwd[256], * fn;                      char cwd[256], * fn;
# Line 332  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 345  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
345      }      }
346            
347      return FALSE;      return FALSE;
348  } /* prefs_dlg_proc */  }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26