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

Legend:
Removed from v.23  
changed lines
  Added in v.278

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26