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

Annotation of /trunk/Src/wptPINDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (hide annotations)
Mon Oct 31 21:14:11 2005 UTC (19 years, 4 months ago) by werner
File size: 3556 byte(s)
More changes.  Compiles again but there are at least gettext issues with
w32-gettext.c.  I can't get a gpg-error build with ENABLE_NLS.

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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26