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

Annotation of /trunk/Src/wptCardManager.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26