/[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 327 by twoaday, Fri Dec 8 10:22:17 2006 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, 2006 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   *   *
# Line 12  Line 12 
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.
  *  
  * You should have received a copy of the GNU General Public License  
  * along with WinPT; if not, write to the Free Software Foundation,  
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA  
15   */   */
16    
17  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
18  #include <config.h>  #include <config.h>
19  #endif  #endif
# Line 41  Line 38 
38    
39  /* Dialog IDs of all hotkeys. */  /* Dialog IDs of all hotkeys. */
40  static int hotkeys[] = {  static int hotkeys[] = {
41      IDC_PREFS_CLIP_ENCRYPT,      /* clipboard based */
42        // FIXME: why the wrong order leads to a correct storing
43        // in the registry!? (2,1) should be (1,2)
44      IDC_PREFS_CLIP_DECRYPT_VERIFY,      IDC_PREFS_CLIP_DECRYPT_VERIFY,
45        IDC_PREFS_CLIP_ENCRYPT,    
46        IDC_PREFS_CLIP_SIGN,
47      IDC_PREFS_CLIP_SIGNENC,      IDC_PREFS_CLIP_SIGNENC,
48      IDC_PREFS_CLIP_SIGN,          /* current window based */
49      IDC_PREFS_CWS_ENCRYPT,      IDC_PREFS_CWS_ENCRYPT,
50      IDC_PREFS_CWS_DECRYPT_VERIFY,      IDC_PREFS_CWS_DECRYPT_VERIFY,
51      IDC_PREFS_CWS_SIGN,      IDC_PREFS_CWS_SIGN,
# Line 72  static void Line 73  static void
73  disable_hotkey_items (HWND dlg, int val)  disable_hotkey_items (HWND dlg, int val)
74  {  {
75      int mode = val? FALSE : TRUE;      int mode = val? FALSE : TRUE;
     int i, id;  
76            
77      for (i=0; (id = hotkeys[i]); i++)      for (int i=0; hotkeys[i] != 0; i++)
78          EnableWindow (GetDlgItem (dlg, id), mode);          EnableWindow (GetDlgItem (dlg, hotkeys[i]), mode);
79  }  }
80    
81    
# Line 91  enable_backup_items (HWND dlg, int val) Line 91  enable_backup_items (HWND dlg, int val)
91      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKUSER), mode);      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKUSER), mode);
92      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), mode);      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), mode);
93      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), mode);      EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), mode);
94        EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSECRING), mode);
95  }  }
96    
97  /* Helper function to prepare dialog. */  /* Helper function to prepare dialog. */
# Line 98  static void Line 99  static void
99  on_init_dialog (HWND dlg)  on_init_dialog (HWND dlg)
100  {  {
101      struct gettext_tab_s prefs[] = {      struct gettext_tab_s prefs[] = {
         {IDC_PREFS_SECMODE, _("Do not use any &temporary files")},  
102          {IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext")},          {IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext")},
103          {IDC_PREFS_WWINFO, _("Word wrap cleartext &signatures at column")},          {IDC_PREFS_WWINFO, _("Word wrap cleartext &signatures at column:")},
104          {IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)")},          {IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)")},
105          {IDC_PREFS_TRUST, _("Skip key validation and assume that keys are always fully trusted")},          {IDC_PREFS_TRUST, _("Skip key validation and assume that keys are always fully trusted")},
106          {IDC_PREFS_AUTOBACKUP, _("&Automatic keyring backup when WinPT closes")},          {IDC_PREFS_AUTOBACKUP, _("&Automatic keyring backup when WinPT closes")},
# Line 108  on_init_dialog (HWND dlg) Line 108  on_init_dialog (HWND dlg)
108          {IDC_PREFS_BAKUSER, _("Backup to:")},          {IDC_PREFS_BAKUSER, _("Backup to:")},
109          {IDC_PREFS_KEYLISTINF, _("Select &key list mode")},          {IDC_PREFS_KEYLISTINF, _("Select &key list mode")},
110          {IDC_PREFS_KSINF, _("Keyserver &config")},          {IDC_PREFS_KSINF, _("Keyserver &config")},
111          {IDC_PREFS_CACHEINF, _("Cache &passphrases for 'n' minutes")},          {IDC_PREFS_CACHEINF, _("Cache &passphrases for 'n' minutes:")},
112          {IDC_PREFS_CACHEHINT, _("(CTRL+ALT+F to clear the cache)")},          {IDC_PREFS_CACHEHINT, _("(CTRL+ALT+F to clear the cache)")},
113          {IDC_PREFS_ALLOPTINF, _("General options")},          {IDC_PREFS_ALLOPTINF, _("General options")},
114          {IDC_PREFS_CLIPINF, _("Clipboard hotkeys")},          {IDC_PREFS_CLIPINF, _("Clipboard hotkeys CTRL+ALT")},
115          {IDC_PREFS_CURRINF, _("Current window hotkeys")},          {IDC_PREFS_CURRINF, _("Current window hotkeys CTRL+SHIFT")},
116          {IDC_PREFS_KSELFILE, _("Browse...")},          {IDC_PREFS_KSELFILE, _("Browse...")},
117          {IDC_PREFS_BAKSELECT, _("Browse...")},          {IDC_PREFS_BAKSELECT, _("Browse...")},
118          {IDC_PREFS_EXTINF, _("Default extension for encrypted files")},          {IDC_PREFS_EXTINF, _("Default extension for encrypted files:")},
119          {IDC_PREFS_BAKSECRING, _("&Backup includes secret keyring")},          {IDC_PREFS_BAKSECRING, _("&Backup includes secret keyring")},
120            
121            {IDC_PREFS_CLIP_HT_ENC, _("Encrypt")},
122            {IDC_PREFS_CLIP_HT_DEC, _("Decrypt/Verify")},
123            {IDC_PREFS_CLIP_HT_SIG, _("Sign")},
124            {IDC_PREFS_CLIP_HT_SAE, _("Sign && Encrypt")},  
125            {IDC_PREFS_CW_HT_ENC, _("Encrypt")},
126            {IDC_PREFS_CW_HT_DEC, _("Decrypt/Verify")},
127            {IDC_PREFS_CW_HT_SIG, _("Sign")},
128            {IDC_PREFS_CW_HT_SAE, _("Sign && Encrypt")},
129          {IDCANCEL, _("&Cancel")},          {IDCANCEL, _("&Cancel")},
130      {0, NULL}};          {0, NULL}};
131      int i;      int i;
132      HWND cb;      HWND cb;
133    
# Line 176  BOOL CALLBACK Line 185  BOOL CALLBACK
185  prefs_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  prefs_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
186  {  {
187      int rc;      int rc;
     int i;  
188      char t[3];      char t[3];
189      char path[256], *p;      char path[256], *p;
190            
# Line 185  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 193  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
193          on_init_dialog (dlg);          on_init_dialog (dlg);
194          return TRUE;          return TRUE;
195                    
196      case WM_SYSCOMMAND:      case WM_DESTROY:
197          if (LOWORD (wparam) == SC_CLOSE)          balloon_msg_disable ();
198              EndDialog (dlg, FALSE);          break;
199          return FALSE;          
           
200      case WM_COMMAND:      case WM_COMMAND:
201          switch (HIWORD (wparam)) {          switch (HIWORD (wparam)) {
202          case BN_CLICKED:          case BN_CLICKED:
# Line 206  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 213  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
213                  _("In most cases it is not a good idea to enable this setting.\n"                  _("In most cases it is not a good idea to enable this setting.\n"
214                    "If you know what you are doing, you can enable this flag, otherwise\n"                    "If you know what you are doing, you can enable this flag, otherwise\n"
215                    "it is safe to leave this flag untouched."),                    "it is safe to leave this flag untouched."),
216                    _("Preferences"), MB_ICONWARNING|MB_OK);                    _("Preferences"), MB_WARN);
217                  }                  }
218                  break;                  break;
219    
# Line 249  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 256  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
256                  agent_flush_cache ();                  agent_flush_cache ();
257              }              }
258              else if (rc > 720) {              else if (rc > 720) {
259                  msg_box( dlg, _("Please enter a value that is between 1-720.\nIt is not "                  show_balloon_msg (GetDlgItem (dlg, IDC_PREFS_CACHETIME),
260                                  "a good idea to cache the passphrase more than 12 hours."),                                    _("Please enter a value that is between 1-720.\nIt is not "
261                                  _("Preferences"), MB_ERR);                                      "a good idea to cache the passphrase more than 12 hours."),
262                                      IDI_ERROR);
263                  SetDlgItemInt (dlg, IDC_PREFS_CACHETIME, 0, FALSE);                  SetDlgItemInt (dlg, IDC_PREFS_CACHETIME, 0, FALSE);
264                  return TRUE;                  return FALSE;
265              }              }
266              if (reg_prefs.cache_time != rc)              if (reg_prefs.cache_time != rc)
267                  agent_flush_cache ();                  agent_flush_cache ();
# Line 262  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 270  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
270              if (rc <= 0)              if (rc <= 0)
271                  reg_prefs.word_wrap = 0;                  reg_prefs.word_wrap = 0;
272              else if (rc > 80) {              else if (rc > 80) {
273                  msg_box (dlg, _("Please enter a value between 1-80."),                  show_balloon_msg (GetDlgItem (dlg, IDC_PREFS_WORDWRAP),
274                           _("Preferences"), MB_ERR);                                    _("Please enter a value between 1-80."),
275                  return TRUE;                                    IDI_ERROR);
276                    return FALSE;
277              }              }
278              reg_prefs.default_ext = SendDlgItemMessage (dlg, IDC_PREFS_DEFEXT, CB_GETCURSEL, 0, 0);              reg_prefs.default_ext = SendDlgItemMessage (dlg, IDC_PREFS_DEFEXT, CB_GETCURSEL, 0, 0);
279              reg_prefs.word_wrap = rc;              reg_prefs.word_wrap = rc;
# Line 272  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 281  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
281              reg_prefs.backup.mode = IsDlgButtonChecked (dlg, IDC_PREFS_BAKHOME ) ? 1 :              reg_prefs.backup.mode = IsDlgButtonChecked (dlg, IDC_PREFS_BAKHOME ) ? 1 :
282                                      IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER)? 2 : 0;                                      IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER)? 2 : 0;
283              reg_prefs.backup.include_secr = IsDlgButtonChecked (dlg, IDC_PREFS_BAKSECRING)? 1 : 0;              reg_prefs.backup.include_secr = IsDlgButtonChecked (dlg, IDC_PREFS_BAKSECRING)? 1 : 0;
 #ifdef WINPT_MOBILE  
             /* We cannot allow backups to a specific path outside  
                the USB disk, so we disable it. */  
             if (reg_prefs.backup.mode == 2) {  
                 reg_prefs.backup.mode = 1;  
                 reg_prefs.backup.include_secr = 0;  
             }  
 #endif  
284              if (reg_prefs.backup.mode == 2) {              if (reg_prefs.backup.mode == 2) {
285                  if (!GetDlgItemText (dlg, IDC_PREFS_BAKPATH, path, sizeof (path)-1)                  if (!GetDlgItemText (dlg, IDC_PREFS_BAKPATH, path, DIM (path)-1)
286                      || dir_exist_check (path)) {                      || dir_exist_check (path)) {
287                      msg_box (dlg, _("The specified backup folder is invalid."),                      show_balloon_msg (GetDlgItem (dlg, IDC_PREFS_BAKPATH),
288                               _("Preferences"), MB_ERR);                                        _("The specified backup folder is invalid."),
289                      return TRUE;                                        IDI_ERROR);
290                        return FALSE;
291                  }                  }
292                  free_if_alloc (reg_prefs.backup.path);                  free_if_alloc (reg_prefs.backup.path);
293                  p = reg_prefs.backup.path = m_strdup (path);                  p = reg_prefs.backup.path = m_strdup (path);
                 if (!p)  
                     BUG (0);  
294              }              }
295                            
296              if (IsDlgButtonChecked (dlg, IDC_PREFS_DISABLE_HOTKEYS)) {              if (IsDlgButtonChecked (dlg, IDC_PREFS_DISABLE_HOTKEYS)) {
# Line 299  prefs_dlg_proc (HWND dlg, UINT msg, WPAR Line 299  prefs_dlg_proc (HWND dlg, UINT msg, WPAR
299              }              }
300              else {              else {
301                  reg_prefs.no_hotkeys = 0;                  reg_prefs.no_hotkeys = 0;
302                  for (i = 0; hotkeys[i]; i++) {                  for (int i = 0; hotkeys[i] != 0; i++) {
303                      rc = GetDlgItemText (dlg, hotkeys[i], t, sizeof (t)-1);                      rc = GetDlgItemText (dlg, hotkeys[i], t, DIM (t)-1);
304                      if (rc > 0 && check_hotkey (&t[0]))                      if (rc > 0 && check_hotkey (&t[0]))
305                          hotkey_enable (&wpt_hotkeys[i], t);                          hotkey_enable (&wpt_hotkeys[i], t);
306                      else                      else

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26