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

Annotation of /trunk/Src/wptPINDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (hide annotations)
Mon Oct 24 08:03:48 2005 UTC (19 years, 4 months ago) by twoaday
File size: 3632 byte(s)
2005-10-23  Timo Schulz  <twoaday@g10code.com>
 
        * wptFileManager.cpp (fm_get_file_type): Detect detached sigs.
        * wptKeyList.cpp (keylist_cmp_cb): Take care of expired/revoked keys.
        (get_ext_validity): New.
        * wptFileVerifyDlg.cpp (file_verify_dlg_proc): Several cleanups.
        * wptClipEditDlg.cpp (load_clipboard): Factored out some code into
        this function.
        (load_clipboard_from_file): Likewise.
        (save_clipboard_to_file): New.
        * wptKeyManagerDlg.cpp (keyprops_dlg_proc): Fix stack overflow.

For complete details, see the ChangeLog files.

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 twoaday 23 /* Dialog procedure to reuqest the PIN from the user. */
32 twoaday 2 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 twoaday 22 switch (msg) {
41 twoaday 2 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 32 SetDlgItemText (dlg, IDC_PIN_HIDE, _("&Hide Typing"));
51 twoaday 5 CheckDlgButton (dlg, IDC_PIN_HIDE, BST_CHECKED);
52     SetDlgItemText (dlg, IDC_PIN_INFO, s);
53 twoaday 23 center_window (dlg, NULL);
54 twoaday 5 SetFocus( GetDlgItem (dlg, IDC_PIN_VALUE ));
55     SetForegroundWindow (dlg);
56 twoaday 2 return FALSE;
57    
58     case WM_COMMAND:
59 twoaday 5 if (HIWORD (wparam) == BN_CLICKED && LOWORD (wparam) == IDC_PIN_HIDE) {
60     HWND hwnd = GetDlgItem (dlg, IDC_PIN_VALUE);
61     hide ^= 1;
62     SendMessage (hwnd, EM_SETPASSWORDCHAR, hide? '*' : 0, 0);
63     SetFocus (hwnd);
64     }
65 twoaday 2 switch( LOWORD( wparam ) ) {
66     case IDOK:
67     n = SendDlgItemMessage( dlg, IDC_PIN_VALUE, WM_GETTEXTLENGTH, 0, 0 );
68     if( !n ) {
69     msg_box( dlg, _("Please enter a PIN."), _("PIN"), MB_ERR );
70     return FALSE;
71     }
72 twoaday 23 if (!pin->which || pin->which == CARD_ADMIN_PIN) {
73     sfree_if_alloc (pin->apin);
74 twoaday 2 pin->apin = new char[n+2];
75     if (!pin->apin)
76     BUG (0);
77     len = GetDlgItemText( dlg, IDC_PIN_VALUE, pin->apin, n+1 );
78     if (len < 8) {
79     msg_box (dlg, _("'Admin PIN' must be at least 8 characters long."),
80     _("PIN"), MB_ERR);
81 twoaday 23 sfree_if_alloc (pin->apin);
82 twoaday 26 return TRUE;
83 twoaday 2 }
84     if (is_8bit_string (pin->apin)) {
85     msg_box (dlg, _("PIN's are currently limited to US-ASCII"),
86     _("PIN"), MB_ERR);
87 twoaday 23 sfree_if_alloc (pin->apin);
88 twoaday 26 return TRUE;
89 twoaday 2 }
90     }
91 twoaday 23 else if( pin->which == CARD_USER_PIN) {
92     sfree_if_alloc (pin->upin);
93 twoaday 2 pin->upin = new char[n+2];
94     if (!pin->upin)
95     BUG( NULL );
96     len = GetDlgItemText( dlg, IDC_PIN_VALUE, pin->upin, n+1 );
97     if (len < 6) {
98     msg_box( dlg, _("'User PIN' must be at least 6 characters long."),
99     _("PIN"), MB_ERR );
100 twoaday 23 sfree_if_alloc (pin->upin);
101 twoaday 26 return TRUE;
102 twoaday 2 }
103     if (is_8bit_string (pin->upin)) {
104     msg_box (dlg, _("PIN's are currently limited to US-ASCII"),
105     _("PIN"), MB_ERR);
106 twoaday 23 sfree_if_alloc (pin->upin);
107 twoaday 26 return TRUE;
108 twoaday 2 }
109     }
110 twoaday 26 EndDialog (dlg, TRUE);
111 twoaday 2 break;
112    
113     case IDCANCEL:
114     pin->apin = NULL;
115     pin->upin = NULL;
116     EndDialog (dlg, FALSE);
117     break;
118     }
119     break;
120     }
121     return FALSE;
122 twoaday 23 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26