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

Diff of /trunk/Src/wptCardManager.cpp

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

revision 28 by twoaday, Thu Oct 20 12:35:59 2005 UTC revision 36 by werner, Thu Oct 27 15:25:13 2005 UTC
# Line 1  Line 1 
1  /* wptCardManager.cpp  /* wptCardManager.cpp
2   *      Copyright (C) 2003, 2005 Timo Schulz   *      Copyright (C) 2003, 2005 Timo Schulz
3   *      Copyright (C) 2005 g10 Code GmbH   *      Copyright (C) 2005 g10 Code GmbH
4   *   *
5   * This file is part of WinPT.   * This file is part of WinPT.
6   *   *
7   * WinPT is free software; you can redistribute it and/or modify   * WinPT is free software; you can redistribute it and/or modify
8   * it under the terms of the GNU General Public License as published by   * it under the terms of the GNU General Public License as published by
9   * the Free Software Foundation; either version 2 of the License, or   * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.   * (at your option) any later version.
11   *   *
12   * WinPT is distributed in the hope that it will be useful,   * WinPT is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15   * GNU General Public License for more details.   * GNU General Public License for more details.
16   *   *
17   * You should have received a copy of the GNU General Public License   * You should have received a copy of the GNU General Public License
18   * along with WinPT; if not, write to the Free Software Foundation,   * along with WinPT; if not, write to the Free Software Foundation,
19   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20   */   */
21    
22  #include <stdio.h>  #ifdef HAVE_CONFIG_H
23  #include <windows.h>  #include <config.h>
24    #endif
25  #include "wptTypes.h"  
26  #include "wptW32API.h"  #include <stdio.h>
27  #include "wptVersion.h"  #include <stdio.h>
28  #include "wptNLS.h"  #include <windows.h>
29  #include "wptGPG.h"  
30  #include "wptCard.h"  #include "wptTypes.h"
31  #include "../resource.h"  #include "wptW32API.h"
32    #include "wptVersion.h"
33    #include "wptNLS.h"
34  /* Dialog box procedure for the card callback. */  #include "wptGPG.h"
35  static BOOL CALLBACK  #include "wptCard.h"
36  card_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  #include "../resource.h"
37  {  
38      static card_cb_s * ctx;  
39    /* Dialog box procedure for the card callback. */
40      switch( msg ) {  static BOOL CALLBACK
41      case WM_INITDIALOG:  card_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
42          ctx = (struct card_cb_s *)lparam;  {
43          if( !ctx )      static card_cb_s * ctx;
44              BUG( NULL );  
45          switch (ctx->code) {      switch( msg ) {
46          case CARD_CTL_INSERT:      case WM_INITDIALOG:
47              ShowWindow (GetDlgItem (dlg, IDC_CCTRL_VAL), FALSE);          ctx = (struct card_cb_s *)lparam;
48              SetDlgItemText (dlg, IDC_CCTRL_MSG,          if( !ctx )
49                              _("Please insert the OpenPGP smart card\n"              BUG( NULL );
50                                "Press OK to continue or Cancel"));          switch (ctx->code) {
51              break;          case CARD_CTL_INSERT:
52          }              ShowWindow (GetDlgItem (dlg, IDC_CCTRL_VAL), FALSE);
53          center_window (dlg, NULL);              SetDlgItemText (dlg, IDC_CCTRL_MSG,
54          SetForegroundWindow (dlg);                              _("Please insert the OpenPGP smart card\n"
55          break;                                "Press OK to continue or Cancel"));
56                break;
57      case WM_COMMAND:          }
58          switch (LOWORD (wparam)) {          center_window (dlg, NULL);
59          case IDOK:          SetForegroundWindow (dlg);
60              strcpy (ctx->val, "\r\n");          break;
61              EndDialog( dlg, TRUE );  
62              break;      case WM_COMMAND:
63            switch (LOWORD (wparam)) {
64          case IDCANCEL:          case IDOK:
65              strcpy (ctx->val, "c");              strcpy (ctx->val, "\r\n");
66              ctx->cancel = 1;              EndDialog( dlg, TRUE );
67              EndDialog (dlg, FALSE);              break;
68              break;  
69          }          case IDCANCEL:
70          break;              strcpy (ctx->val, "c");
71      }              ctx->cancel = 1;
72                EndDialog (dlg, FALSE);
73      return FALSE;              break;
74  }          }
75            break;
76        }
77  const char*  
78  card_callback (int code, void *opaque)      return FALSE;
79  {  }
80      struct card_cb_s *ctx = (struct card_cb_s *)opaque;  
81    
82      if (!ctx)  const char*
83          return NULL;  card_callback (int code, void *opaque)
84    {
85      if (!ctx->init) {      struct card_cb_s *ctx = (struct card_cb_s *)opaque;
86          memset (ctx->val, 0, sizeof (ctx->val));  
87          ctx->code = code;      if (!ctx)
88          DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CARD_CTRL, glob_hwnd,          return NULL;
89                          card_cb_dlg_proc, (LPARAM)ctx);  
90          ctx->init = 0;      if (!ctx->init) {
91      }          memset (ctx->val, 0, sizeof (ctx->val));
92            ctx->code = code;
93      return ctx->val;          DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CARD_CTRL, glob_hwnd,
94  }                          card_cb_dlg_proc, (LPARAM)ctx);
95            ctx->init = 0;
96        }
97    
98        return ctx->val;
99    }

Legend:
Removed from v.28  
changed lines
  Added in v.36

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26