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

Annotation of /trunk/Src/wptPINDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 22 - (hide annotations)
Wed Aug 10 11:33:35 2005 UTC (19 years, 6 months ago) by twoaday
File size: 3546 byte(s)
2005-08-06  Timo Schulz  <twoaday@freakmail.de>
 
        * wptGPGME.cpp (keycache_update): Reload OpenPGP parts
        of the secret key.
        (keycache_init): cache name of secret keyring.
        * wptKeyList.cpp (keylist_upd_key): Do not add long keyid.
        (get_key_type): Do not assume 'ultimate' means key pair.
        * wptKeyEditDlgs.cpp (diff_time): New.
        (keyedit_addsubkey_dlg_proc): Changed design and use
        diff_time. Drop checks for invalid keylength (< 1024, > 4096)
        because the combo box automatically handles this.
        * wptKeyManager.cpp (km_set_implicit_trust): Return error code.
        * wptGPG.cpp (get_backup_name): New.
        (gnupg_backup_keyrings): Rotate backup names, from 0..3.
        * wptClipImportDialog.cpp (clip_import_dlg_proc): Free memory.
        * wptKeyManagerDlg.cpp (keymanager_dlg_proc): Use 0x short keyid and
        not the long keyid.


1 twoaday 2 /* wptPINDlg.cpp - PIN callback for smart cards
2 twoaday 5 * Copyright (C) 2003, 2004, 2005 Timo Schulz
3 twoaday 2 *
4     * This file is part of WinPT.
5     *
6     * 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
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * WinPT is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * 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,
18     * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19     */
20     #include <windows.h>
21    
22     #include "../resource.h"
23     #include "wptW32API.h"
24     #include "wptTypes.h"
25     #include "wptGPG.h"
26     #include "wptCommonCtl.h"
27     #include "wptCard.h"
28     #include "wptUTF8.h"
29    
30    
31     BOOL CALLBACK
32     pin_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
33     {
34 twoaday 5 static int hide = 1;
35 twoaday 2 static pin_cb_ctx_s * pin;
36     const char * s;
37     int n, len;
38    
39 twoaday 22 switch (msg) {
40 twoaday 2 case WM_INITDIALOG:
41 twoaday 5 hide = 1;
42 twoaday 2 pin = (struct pin_cb_ctx_s *)lparam;
43     if (!pin)
44     BUG (0);
45     if (pin->info_text)
46     s = pin->info_text;
47     else
48     s = _("Please enter the PIN");
49 twoaday 5 CheckDlgButton (dlg, IDC_PIN_HIDE, BST_CHECKED);
50     SetDlgItemText (dlg, IDC_PIN_INFO, s);
51     center_window (dlg);
52     SetFocus( GetDlgItem (dlg, IDC_PIN_VALUE ));
53     SetForegroundWindow (dlg);
54 twoaday 2 return FALSE;
55    
56     case WM_COMMAND:
57 twoaday 5 if (HIWORD (wparam) == BN_CLICKED && LOWORD (wparam) == IDC_PIN_HIDE) {
58     HWND hwnd = GetDlgItem (dlg, IDC_PIN_VALUE);
59     hide ^= 1;
60     SendMessage (hwnd, EM_SETPASSWORDCHAR, hide? '*' : 0, 0);
61     SetFocus (hwnd);
62     }
63 twoaday 2 switch( LOWORD( wparam ) ) {
64     case IDOK:
65     n = SendDlgItemMessage( dlg, IDC_PIN_VALUE, WM_GETTEXTLENGTH, 0, 0 );
66     if( !n ) {
67     msg_box( dlg, _("Please enter a PIN."), _("PIN"), MB_ERR );
68     return FALSE;
69     }
70     if (!pin->which || pin->which == GPGME_EDITCARD_CHAPIN) {
71     free_if_alloc (pin->apin);
72     pin->apin = new char[n+2];
73     if (!pin->apin)
74     BUG (0);
75     len = GetDlgItemText( dlg, IDC_PIN_VALUE, pin->apin, n+1 );
76     if (len < 8) {
77     msg_box (dlg, _("'Admin PIN' must be at least 8 characters long."),
78     _("PIN"), MB_ERR);
79     free_if_alloc (pin->apin);
80     return FALSE;
81     }
82     if (is_8bit_string (pin->apin)) {
83     msg_box (dlg, _("PIN's are currently limited to US-ASCII"),
84     _("PIN"), MB_ERR);
85     free_if_alloc (pin->apin);
86     return FALSE;
87     }
88     }
89     else if( pin->which == GPGME_EDITCARD_CHUPIN) {
90     free_if_alloc (pin->upin);
91     pin->upin = new char[n+2];
92     if (!pin->upin)
93     BUG( NULL );
94     len = GetDlgItemText( dlg, IDC_PIN_VALUE, pin->upin, n+1 );
95     if (len < 6) {
96     msg_box( dlg, _("'User PIN' must be at least 6 characters long."),
97     _("PIN"), MB_ERR );
98     free_if_alloc( pin->upin );
99     return FALSE;
100     }
101     if (is_8bit_string (pin->upin)) {
102     msg_box (dlg, _("PIN's are currently limited to US-ASCII"),
103     _("PIN"), MB_ERR);
104     free_if_alloc (pin->upin);
105     return FALSE;
106     }
107     }
108     EndDialog( dlg, TRUE );
109     break;
110    
111     case IDCANCEL:
112     pin->apin = NULL;
113     pin->upin = NULL;
114     EndDialog (dlg, FALSE);
115     break;
116     }
117     break;
118     }
119     return FALSE;
120     } /* pin_cb_dlg_proc */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26