1 |
twoaday |
26 |
/* wptCardEdit.h |
2 |
|
|
* Copyright (C) 2005 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 |
twoaday |
23 |
#ifndef WPT_CARDEDIT_H |
21 |
|
|
#define WPT_CARDEDIT_H 1 |
22 |
|
|
|
23 |
|
|
/* All valid card commands. */ |
24 |
|
|
enum { |
25 |
|
|
GPG_EDITCARD_NAME = 1, |
26 |
|
|
GPG_EDITCARD_NAME2 = 2, |
27 |
|
|
GPG_EDITCARD_KEYURL = 3, |
28 |
|
|
GPG_EDITCARD_LOGIN = 4, |
29 |
|
|
GPG_EDITCARD_SEX = 5, |
30 |
|
|
GPG_EDITCARD_LANG = 6, |
31 |
|
|
GPG_EDITCARD_APIN = 7, |
32 |
|
|
GPG_EDITCARD_UPIN = 8, |
33 |
|
|
GPG_EDITCARD_GENKEY = 9, |
34 |
|
|
GPG_EDITCARD_FETCH = 10, |
35 |
|
|
GPG_EDITCARD_CAFPR = 11, |
36 |
|
|
GPG_EDITCARD_LIST = 12, |
37 |
|
|
|
38 |
|
|
GPG_EDITCARD_CHPIN_ID = 20, |
39 |
|
|
/* change pin */ |
40 |
|
|
GPG_EDITCARD_CHAPIN = 21, |
41 |
|
|
GPG_EDITCARD_CHUPIN = 22, |
42 |
|
|
GPG_EDITCARD_UNBPIN = 23 /*unblock PIN*/ |
43 |
|
|
}; |
44 |
|
|
|
45 |
twoaday |
27 |
/* Possible card results (can be ORed) */ |
46 |
twoaday |
26 |
enum { |
47 |
|
|
GPG_CARDRES_NOCARD = 1, /* no card in the reader */ |
48 |
twoaday |
27 |
GPG_CARDRES_BAD_PIN= 2, /* wrong PIN entered */ |
49 |
|
|
GPG_CARDRES_CANCEL = 4 /* card was missing and user cancelled. */ |
50 |
twoaday |
23 |
}; |
51 |
|
|
|
52 |
twoaday |
26 |
/* gpg edit key abstraction class */ |
53 |
twoaday |
23 |
class GpgCardEdit { |
54 |
twoaday |
26 |
private: |
55 |
|
|
int result; |
56 |
|
|
|
57 |
twoaday |
23 |
public: |
58 |
|
|
GpgCardEdit (void); |
59 |
|
|
~GpgCardEdit (void); |
60 |
|
|
|
61 |
|
|
public: |
62 |
|
|
void setPIN (const char *pin); |
63 |
|
|
void setAdminPIN (const char *admin_pin); |
64 |
|
|
void setNewPIN (const char *new_pin); |
65 |
|
|
void setKeygenPassphrase (const char *pass); |
66 |
|
|
void setCallback (const char* (*cb)(int code, void *opaque), void *cb_value); |
67 |
twoaday |
26 |
void setResult (int res); |
68 |
|
|
int getResult (void); |
69 |
|
|
void reset (void); |
70 |
twoaday |
23 |
|
71 |
|
|
gpgme_error_t getCardStatus (gpg_card_t *r_card); |
72 |
|
|
gpgme_error_t genKey (int flags, const char *name, |
73 |
|
|
const char *email, const char *comment, |
74 |
twoaday |
26 |
long valid, char **r_key_fpr); |
75 |
|
|
gpgme_error_t changePIN (int type); |
76 |
twoaday |
23 |
|
77 |
|
|
gpgme_error_t updateName (const char *given, const char *sur); |
78 |
|
|
gpgme_error_t updateURL (const char *url); |
79 |
|
|
gpgme_error_t updateLogin (const char *login); |
80 |
|
|
gpgme_error_t updateLanguage (const char *lang); |
81 |
|
|
gpgme_error_t updateSex (char sex); |
82 |
|
|
|
83 |
|
|
gpgme_error_t doCmd (int cmd, const char *arg1, const char *arg2); |
84 |
|
|
|
85 |
|
|
gpgme_error_t fetchKey (void); |
86 |
|
|
|
87 |
|
|
public: /* XXX */ |
88 |
|
|
gpgme_ctx_t ctx; |
89 |
|
|
const char *pin; |
90 |
|
|
const char *pin_new; |
91 |
|
|
const char *admin_pin; |
92 |
|
|
|
93 |
|
|
int type; |
94 |
|
|
int cnt; |
95 |
|
|
int cancel; |
96 |
|
|
|
97 |
|
|
struct { |
98 |
|
|
const char *surname; |
99 |
|
|
const char *givenname; |
100 |
|
|
const char *keyurl; |
101 |
|
|
const char *login; |
102 |
|
|
const char *lang; |
103 |
|
|
char sex; |
104 |
|
|
} edit; |
105 |
|
|
|
106 |
|
|
struct { |
107 |
|
|
char *name; |
108 |
|
|
char *email; |
109 |
|
|
char *comment; |
110 |
|
|
char *expdate; |
111 |
|
|
int flags; |
112 |
|
|
const char *pass; |
113 |
twoaday |
26 |
char *key_fpr; |
114 |
twoaday |
23 |
} keygen; |
115 |
|
|
|
116 |
|
|
const char *(*card_cb) (int code, void * opaque); |
117 |
|
|
void * cb_value; |
118 |
|
|
}; |
119 |
|
|
|
120 |
|
|
|
121 |
|
|
void gpg_card_release (gpg_card_t card); |
122 |
|
|
gpgme_error_t gpg_card_edit (gpgme_ctx_t ctx, GpgCardEdit *ce); |
123 |
twoaday |
26 |
gpg_card_t gpg_card_load (void); |
124 |
twoaday |
23 |
|
125 |
|
|
#endif |