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

Annotation of /trunk/Src/wptCardManager.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (hide annotations)
Fri Sep 30 10:10:16 2005 UTC (19 years, 5 months ago) by twoaday
File size: 2316 byte(s)
Almost finished phase 1 of the WinPT GPGME port.
Still need more cleanup, comments and tests.


1 twoaday 2 /* wptCardManager.cpp
2     * Copyright (C) 2003 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    
21     #include <stdio.h>
22     #include <windows.h>
23    
24     #include "wptTypes.h"
25     #include "wptW32API.h"
26     #include "wptVersion.h"
27     #include "wptNLS.h"
28     #include "wptGPG.h"
29     #include "wptCard.h"
30     #include "../resource.h"
31    
32    
33     static BOOL CALLBACK
34     card_cb_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam )
35     {
36     static card_cb_s * ctx;
37    
38     switch( msg ) {
39     case WM_INITDIALOG:
40     ctx = (struct card_cb_s *)lparam;
41     if( !ctx )
42     BUG( NULL );
43     switch( ctx->code ) {
44     case 1:
45     ShowWindow( GetDlgItem( dlg, IDC_CCTRL_VAL ), FALSE );
46     SetDlgItemText( dlg, IDC_CCTRL_MSG,
47     _("Please insert the OpenPGP smart card\n"
48     "Press OK to continue or Cancel") );
49     break;
50     }
51 twoaday 23 center_window( dlg, NULL );
52 twoaday 2 SetForegroundWindow( dlg );
53     break;
54    
55     case WM_COMMAND:
56     switch( LOWORD( wparam ) ) {
57     case IDOK:
58     strcpy( ctx->val, "\r\n" );
59     EndDialog( dlg, TRUE );
60     break;
61    
62     case IDCANCEL:
63     strcpy( ctx->val, "c" );
64     ctx->cancel = 1;
65     EndDialog( dlg, FALSE );
66     break;
67     }
68     break;
69     }
70    
71     return FALSE;
72     } /* card_cb_dlg_proc */
73    
74    
75 twoaday 23 const char*
76     card_callback (int code, void * opaque)
77 twoaday 2 {
78 twoaday 23 struct card_cb_s *ctx = (struct card_cb_s *)opaque;
79 twoaday 2
80 twoaday 23 if (!ctx)
81 twoaday 2 return NULL;
82    
83 twoaday 23 if (!ctx->init) {
84 twoaday 2 memset( ctx->val, 0, sizeof ctx->val );
85     ctx->code = code;
86     DialogBoxParam( glob_hinst, (LPCTSTR)IDD_WINPT_CARD_CTRL, glob_hwnd,
87     card_cb_dlg_proc, (LPARAM)ctx );
88     ctx->init = 0;
89     }
90    
91     return ctx->val;
92     } /* card_callback */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26