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

Diff of /trunk/Src/wptPINDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 224 by twoaday, Wed Nov 30 10:22:00 2005 UTC revision 225 by twoaday, Tue Jun 6 13:37:59 2006 UTC
# Line 1  Line 1 
1  /* wptPINDlg.cpp - PIN callback for smart cards  /* wptPINDlg.cpp - PIN callback for smart cards
2   *      Copyright (C) 2003, 2004, 2005 Timo Schulz   *      Copyright (C) 2003, 2004, 2005, 2006 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
# Line 36  Line 36 
36  BOOL CALLBACK  BOOL CALLBACK
37  pin_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  pin_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
38  {  {
39      static int hide = 1;      static pin_cb_ctx_s *pin;
40      static pin_cb_ctx_s * pin;      const char *s;
     const char * s;  
41      int n, len;      int n, len;
42    
43      switch (msg) {      switch (msg) {
44      case WM_INITDIALOG:      case WM_INITDIALOG:
         hide = 1;  
45          pin = (struct pin_cb_ctx_s *)lparam;          pin = (struct pin_cb_ctx_s *)lparam;
46          if (!pin)          if (!pin)
47              BUG (0);              BUG (0);
# Line 51  pin_cb_dlg_proc (HWND dlg, UINT msg, WPA Line 49  pin_cb_dlg_proc (HWND dlg, UINT msg, WPA
49              s = pin->info_text;              s = pin->info_text;
50          else          else
51              s = _("Please enter the PIN");              s = _("Please enter the PIN");
52            CheckDlgButton (dlg, IDC_PIN_HIDE, BST_CHECKED);
53          SetDlgItemText (dlg, IDC_PIN_HIDE, _("&Hide Typing"));          SetDlgItemText (dlg, IDC_PIN_HIDE, _("&Hide Typing"));
54          SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));          SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
55          CheckDlgButton (dlg, IDC_PIN_HIDE, BST_CHECKED);          SetDlgItemText (dlg, IDOK, _("&OK"));
56          SetDlgItemText (dlg, IDC_PIN_INFO, s);          SetDlgItemText (dlg, IDC_PIN_INFO, s);
57          center_window (dlg, NULL);          center_window (dlg, NULL);
58          SetFocus (GetDlgItem (dlg, IDC_PIN_VALUE ));          SetFocus (GetDlgItem (dlg, IDC_PIN_VALUE));
59          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
60          return FALSE;          return FALSE;
61                    
62      case WM_COMMAND:      case WM_COMMAND:
63          if (HIWORD (wparam) == BN_CLICKED && LOWORD (wparam) == IDC_PIN_HIDE) {          if (HIWORD (wparam) == BN_CLICKED && LOWORD (wparam) == IDC_PIN_HIDE) {
64              HWND hwnd = GetDlgItem (dlg, IDC_PIN_VALUE);              HWND hwnd = GetDlgItem (dlg, IDC_PIN_VALUE);
65              hide ^= 1;              int hide = IsDlgButtonChecked (dlg, IDC_PIN_HIDE);
66    
67              SendMessage (hwnd, EM_SETPASSWORDCHAR, hide? '*' : 0, 0);              SendMessage (hwnd, EM_SETPASSWORDCHAR, hide? '*' : 0, 0);
68              SetFocus (hwnd);              SetFocus (hwnd);
69          }          }
70          switch( LOWORD( wparam ) ) {          switch (LOWORD (wparam)) {
71          case IDOK:          case IDOK:
72              n = SendDlgItemMessage( dlg, IDC_PIN_VALUE, WM_GETTEXTLENGTH, 0, 0 );              n = SendDlgItemMessage (dlg, IDC_PIN_VALUE, WM_GETTEXTLENGTH, 0, 0);
73              if( !n ) {              if (!n) {
74                  msg_box( dlg, _("Please enter a PIN."), _("PIN"), MB_ERR );                  msg_box (dlg, _("Please enter a PIN."), _("PIN"), MB_ERR);
75                  return FALSE;                  return FALSE;
76              }              }
77              if (!pin->which || pin->which == CARD_ADMIN_PIN) {              if (!pin->which || pin->which == CARD_ADMIN_PIN) {
# Line 79  pin_cb_dlg_proc (HWND dlg, UINT msg, WPA Line 79  pin_cb_dlg_proc (HWND dlg, UINT msg, WPA
79                  pin->apin = new char[n+2];                  pin->apin = new char[n+2];
80                  if (!pin->apin)                  if (!pin->apin)
81                      BUG (0);                      BUG (0);
82                  len = GetDlgItemText( dlg, IDC_PIN_VALUE, pin->apin, n+1 );                  len = GetDlgItemText (dlg, IDC_PIN_VALUE, pin->apin, n+1);
83                  if (len < 8) {                  if (len < 8) {
84                      msg_box (dlg, _("'Admin PIN' must be at least 8 characters long."),                      msg_box (dlg, _("'Admin PIN' must be at least 8 characters long."),
85                               _("PIN"), MB_ERR);                               _("PIN"), MB_ERR);
# Line 97  pin_cb_dlg_proc (HWND dlg, UINT msg, WPA Line 97  pin_cb_dlg_proc (HWND dlg, UINT msg, WPA
97                  sfree_if_alloc (pin->upin);                  sfree_if_alloc (pin->upin);
98                  pin->upin = new char[n+2];                  pin->upin = new char[n+2];
99                  if (!pin->upin)                  if (!pin->upin)
100                      BUG( NULL );                      BUG (NULL);
101                  len = GetDlgItemText( dlg, IDC_PIN_VALUE, pin->upin, n+1 );                  len = GetDlgItemText (dlg, IDC_PIN_VALUE, pin->upin, n+1);
102                  if (len < 6) {                  if (len < 6) {
103                      msg_box( dlg, _("'User PIN' must be at least 6 characters long."),                      msg_box( dlg, _("'User PIN' must be at least 6 characters long."),
104                               _("PIN"), MB_ERR );                               _("PIN"), MB_ERR );

Legend:
Removed from v.224  
changed lines
  Added in v.225

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26