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

Annotation of /trunk/Src/wptPINDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (hide annotations)
Mon Mar 7 13:21:36 2005 UTC (19 years, 11 months ago) by twoaday
File size: 3549 byte(s)
2005-03-03  Timo Schulz  <twoaday@g10code.com>
                                                                                
        * wptCardDlg.cpp (card_changepin_dlg_proc): Add item to re-type the
        new PIN. Suggested by Achim.
        Support to show the unmasked PIN.
        Modified TAB-order.
        * wptPINDlg.cpp (pin_cb_dlg_proc): Show unmasked PIN.
 
        * Fixed wrong GPG --command-fd strings. Thanks to Achim.
 
2005-03-04  Timo Schulz  <twoaday@g10code.com>
 
        * GPG asks twice for the new PIN. Thanks to Achim.
        * wptCardDlg.cpp (card_changepin_dlg_proc): Reset the 'safety' pin also.        Only check the passphrase if the backup flag is enabled. Again thanks to        Achim.
 
2005-03-06  Timo Schulz  <twoaday@freakmail.de>
 
        * wptKeySignDlg.cpp (do_fill_seckeylist): Skip secret keys without
        a public key. Noted by Kurt Fitzner.
 


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    
21     #include <windows.h>
22    
23     #include "../resource.h"
24     #include "wptW32API.h"
25     #include "wptTypes.h"
26     #include "wptGPG.h"
27     #include "wptCommonCtl.h"
28     #include "wptCard.h"
29     #include "wptUTF8.h"
30    
31    
32     BOOL CALLBACK
33     pin_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
34     {
35 twoaday 5 static int hide = 1;
36 twoaday 2 static pin_cb_ctx_s * pin;
37     const char * s;
38     int n, len;
39    
40     switch( msg ) {
41     case WM_INITDIALOG:
42 twoaday 5 hide = 1;
43 twoaday 2 pin = (struct pin_cb_ctx_s *)lparam;
44     if (!pin)
45     BUG (0);
46     if (pin->info_text)
47     s = pin->info_text;
48     else
49     s = _("Please enter the PIN");
50 twoaday 5 CheckDlgButton (dlg, IDC_PIN_HIDE, BST_CHECKED);
51     SetDlgItemText (dlg, IDC_PIN_INFO, s);
52     center_window (dlg);
53     SetFocus( GetDlgItem (dlg, IDC_PIN_VALUE ));
54     SetForegroundWindow (dlg);
55 twoaday 2 return FALSE;
56    
57     case WM_COMMAND:
58 twoaday 5 if (HIWORD (wparam) == BN_CLICKED && LOWORD (wparam) == IDC_PIN_HIDE) {
59     HWND hwnd = GetDlgItem (dlg, IDC_PIN_VALUE);
60     hide ^= 1;
61     SendMessage (hwnd, EM_SETPASSWORDCHAR, hide? '*' : 0, 0);
62     SetFocus (hwnd);
63     }
64 twoaday 2 switch( LOWORD( wparam ) ) {
65     case IDOK:
66     n = SendDlgItemMessage( dlg, IDC_PIN_VALUE, WM_GETTEXTLENGTH, 0, 0 );
67     if( !n ) {
68     msg_box( dlg, _("Please enter a PIN."), _("PIN"), MB_ERR );
69     return FALSE;
70     }
71     if (!pin->which || pin->which == GPGME_EDITCARD_CHAPIN) {
72     free_if_alloc (pin->apin);
73     pin->apin = new char[n+2];
74     if (!pin->apin)
75     BUG (0);
76     len = GetDlgItemText( dlg, IDC_PIN_VALUE, pin->apin, n+1 );
77     if (len < 8) {
78     msg_box (dlg, _("'Admin PIN' must be at least 8 characters long."),
79     _("PIN"), MB_ERR);
80     free_if_alloc (pin->apin);
81     return FALSE;
82     }
83     if (is_8bit_string (pin->apin)) {
84     msg_box (dlg, _("PIN's are currently limited to US-ASCII"),
85     _("PIN"), MB_ERR);
86     free_if_alloc (pin->apin);
87     return FALSE;
88     }
89     }
90     else if( pin->which == GPGME_EDITCARD_CHUPIN) {
91     free_if_alloc (pin->upin);
92     pin->upin = new char[n+2];
93     if (!pin->upin)
94     BUG( NULL );
95     len = GetDlgItemText( dlg, IDC_PIN_VALUE, pin->upin, n+1 );
96     if (len < 6) {
97     msg_box( dlg, _("'User PIN' must be at least 6 characters long."),
98     _("PIN"), MB_ERR );
99     free_if_alloc( pin->upin );
100     return FALSE;
101     }
102     if (is_8bit_string (pin->upin)) {
103     msg_box (dlg, _("PIN's are currently limited to US-ASCII"),
104     _("PIN"), MB_ERR);
105     free_if_alloc (pin->upin);
106     return FALSE;
107     }
108     }
109     EndDialog( dlg, TRUE );
110     break;
111    
112     case IDCANCEL:
113     pin->apin = NULL;
114     pin->upin = NULL;
115     EndDialog (dlg, FALSE);
116     break;
117     }
118     break;
119     }
120     return FALSE;
121     } /* pin_cb_dlg_proc */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26