/[winpt]/trunk/Include/wptCardEdit.h
ViewVC logotype

Diff of /trunk/Include/wptCardEdit.h

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

revision 33 by twoaday, Tue Oct 25 07:46:20 2005 UTC revision 37 by werner, Thu Oct 27 19:12:40 2005 UTC
# Line 1  Line 1 
1  /* wptCardEdit.h  /* wptCardEdit.h
2   *      Copyright (C) 2005 Timo Schulz   *      Copyright (C) 2005 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
6   * WinPT is free software; you can redistribute it and/or modify   * 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   * 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   * the Free Software Foundation; either version 2 of the License, or
9   * (at your option) any later version.   * (at your option) any later version.
10   *   *
11   * WinPT is distributed in the hope that it will be useful,   * WinPT is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14   * GNU General Public License for more details.   * GNU General Public License for more details.
15   *   *
16   * You should have received a copy of the GNU General Public License   * You should have received a copy of the GNU General Public License
17   * along with WinPT; if not, write to the Free Software Foundation,   * along with WinPT; if not, write to the Free Software Foundation,
18   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19   */   */
20  #ifndef WPT_CARDEDIT_H  #ifndef WPT_CARDEDIT_H
21  #define WPT_CARDEDIT_H 1  #define WPT_CARDEDIT_H 1
22    
23  /* All valid card commands. */  /* All valid card commands. */
24  enum gpg_editcard_cmd_t {  enum gpg_editcard_cmd_t {
25      GPG_EDITCARD_NAME   = 1,      GPG_EDITCARD_NAME   = 1,
26      GPG_EDITCARD_NAME2  = 2,      GPG_EDITCARD_NAME2  = 2,
27      GPG_EDITCARD_KEYURL = 3,      GPG_EDITCARD_KEYURL = 3,
28      GPG_EDITCARD_LOGIN  = 4,      GPG_EDITCARD_LOGIN  = 4,
29      GPG_EDITCARD_SEX    = 5,      GPG_EDITCARD_SEX    = 5,
30      GPG_EDITCARD_LANG   = 6,      GPG_EDITCARD_LANG   = 6,
31      GPG_EDITCARD_APIN   = 7,      GPG_EDITCARD_APIN   = 7,
32      GPG_EDITCARD_UPIN   = 8,      GPG_EDITCARD_UPIN   = 8,
33      GPG_EDITCARD_GENKEY = 9,      GPG_EDITCARD_GENKEY = 9,
34      GPG_EDITCARD_FETCH  = 10,      GPG_EDITCARD_FETCH  = 10,
35      GPG_EDITCARD_CAFPR  = 11,      GPG_EDITCARD_CAFPR  = 11,
36      GPG_EDITCARD_LIST   = 12,      GPG_EDITCARD_LIST   = 12,
37    
38      GPG_EDITCARD_CHPIN_ID = 20,      GPG_EDITCARD_CHPIN_ID = 20,
39      /* change pin */      /* change pin */
40      GPG_EDITCARD_CHAPIN = 21, /* admin */      GPG_EDITCARD_CHAPIN = 21, /* admin */
41      GPG_EDITCARD_CHUPIN = 22, /* user */      GPG_EDITCARD_CHUPIN = 22, /* user */
42      GPG_EDITCARD_UNBPIN = 23 /* unblock PIN */      GPG_EDITCARD_UNBPIN = 23 /* unblock PIN */
43  };  };
44    
45  /* Possible card results (can be ORed) */  /* Possible card results (can be ORed) */
46  enum card_result_t {  enum card_result_t {
47      GPG_CARDRES_NOCARD = 1, /* no card in the reader */      GPG_CARDRES_NOCARD = 1, /* no card in the reader */
48      GPG_CARDRES_BAD_PIN= 2, /* wrong PIN entered */      GPG_CARDRES_BAD_PIN= 2, /* wrong PIN entered */
49      GPG_CARDRES_CANCEL = 4  /* card was missing and user cancelled. */      GPG_CARDRES_CANCEL = 4  /* card was missing and user cancelled. */
50  };  };
51    
52  /* gpg edit key abstraction class */  /* gpg edit key abstraction class */
53  class GpgCardEdit {  class GpgCardEdit {
54  private:  private:
55      int type;      int type;
56      int result;      int result;
57      gpgme_ctx_t ctx;      gpgme_ctx_t ctx;
58    
59  public:  public:
60      GpgCardEdit (void);      GpgCardEdit (void);
61      ~GpgCardEdit (void);      ~GpgCardEdit (void);
62    
63  public:  public:
64      void setPIN (const char *pin);      void setPIN (const char *pin);
65      void setAdminPIN (const char *admin_pin);      void setAdminPIN (const char *admin_pin);
66      void setNewPIN (const char *new_pin);      void setNewPIN (const char *new_pin);
67      void setKeygenPassphrase (const char *pass);      void setKeygenPassphrase (const char *pass);
68      void setCallback (const char* (*cb)(int code, void *opaque), void *cb_value);      void setCallback (const char* (*cb)(int code, void *opaque), void *cb_value);
69      void setResult (int res);      void setResult (int res);
70      int  getResult (void);      int  getResult (void);
71      void reset (void);      void reset (void);
72      int getType ();      int getType ();
73    
74      gpgme_error_t getCardStatus (gpg_card_t *r_card);      gpgme_error_t getCardStatus (gpg_card_t *r_card);
75      gpgme_error_t genKey (int flags, const char *name,      gpgme_error_t genKey (int flags, const char *name,
76                            const char *email, const char *comment,                            const char *email, const char *comment,
77                            long valid, char **r_key_fpr);                            long valid, char **r_key_fpr);
78      gpgme_error_t changePIN (int type);      gpgme_error_t changePIN (int type);
79    
80      gpgme_error_t updateName (const char *given, const char *sur);      gpgme_error_t updateName (const char *given, const char *sur);
81      gpgme_error_t updateURL (const char *url);      gpgme_error_t updateURL (const char *url);
82      gpgme_error_t updateLogin (const char *login);      gpgme_error_t updateLogin (const char *login);
83      gpgme_error_t updateLanguage (const char *lang);      gpgme_error_t updateLanguage (const char *lang);
84      gpgme_error_t updateSex (char sex);      gpgme_error_t updateSex (char sex);
85    
86      gpgme_error_t doCmd (int cmd, const char *arg1, const char *arg2);      gpgme_error_t doCmd (int cmd, const char *arg1, const char *arg2);
87    
88      gpgme_error_t fetchKey (void);      gpgme_error_t fetchKey (void);
89    
90  public: /* XXX hide the internals */      public: /* XXX hide the internals */    
91      const char *pin;      const char *pin;
92      const char *pin_new;      const char *pin_new;
93      const char *admin_pin;      const char *admin_pin;
94    
95      int cnt;      int cnt;
96      int cancel;      int cancel;
97    
98      struct {      struct {
99          const char *surname;          const char *surname;
100          const char *givenname;          const char *givenname;
101          const char *keyurl;          const char *keyurl;
102          const char *login;          const char *login;
103          const char *lang;                const char *lang;      
104          char        sex;          char        sex;
105      } edit;      } edit;
106    
107      struct {      struct {
108          char *name;          char *name;
109          char *email;          char *email;
110          char *comment;          char *comment;
111          char *expdate;          char *expdate;
112          int  flags;          int  flags;
113          const char *pass;          const char *pass;
114          char *key_fpr;          char *key_fpr;
115      } keygen;      } keygen;
116    
117      const char *(*card_cb) (int code, void * opaque);      const char *(*card_cb) (int code, void * opaque);
118      void *cb_value;      void *cb_value;
119  };  };
120    
121    
122  gpg_card_t    gpg_card_load (void);  gpg_card_t    gpg_card_load (void);
123  void          gpg_card_release (gpg_card_t card);  void          gpg_card_release (gpg_card_t card);
124  gpgme_error_t gpg_card_edit (gpgme_ctx_t ctx, GpgCardEdit *ce);  gpgme_error_t gpg_card_edit (gpgme_ctx_t ctx, GpgCardEdit *ce);
125    
126  #endif  #endif

Legend:
Removed from v.33  
changed lines
  Added in v.37

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26