1 |
/* wptKeylist.h - Keylist element |
/* wptKeylist.h - Keylist element |
2 |
* Copyright (C) 2001-2005 Timo Schulz |
* Copyright (C) 2001-2006, 2009 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 |
* WinPT is free software; you can redistribute it and/or |
7 |
* modify it under the terms of the GNU General Public License |
* modify it under the terms of the GNU General Public License |
8 |
* as published by the Free Software Foundation; either version 2 |
* as published by the Free Software Foundation; either version 2 |
9 |
* of the License, or (at your option) any later version. |
* of the License, or (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 GNU |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
* General Public License for more details. |
* General Public License for more details. |
15 |
* |
*/ |
16 |
* You should have received a copy of the GNU General Public License |
#ifndef WPT_KEYLIST_H |
17 |
* along with WinPT; if not, write to the Free Software Foundation, |
#define WPT_KEYLIST_H |
18 |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
19 |
*/ |
#include "wptFileManager.h" |
20 |
#ifndef WPT_KEYLIST_H |
|
21 |
#define WPT_KEYLIST_H |
/* Available sort-by modes. */ |
22 |
|
enum key_sort_t { |
23 |
/* Available sort-by modes. */ |
KEY_SORT_USERID = 0, |
24 |
enum { |
KEY_SORT_KEYID = 1, |
25 |
KEY_SORT_USERID = 0, |
KEY_SORT_IS_SECRET = 2, |
26 |
KEY_SORT_KEYID = 1, |
KEY_SORT_LEN = 3, |
27 |
KEY_SORT_IS_SECRET = 2, |
KEY_SORT_VALIDITY = 5, |
28 |
KEY_SORT_LEN = 3, |
KEY_SORT_OTRUST = 6, |
29 |
KEY_SORT_VALIDITY = 5, |
KEY_SORT_CREATED = 7, |
30 |
KEY_SORT_OTRUST = 6, |
KEY_SORT_ALGO = 8, |
31 |
KEY_SORT_CREATED = 7, |
|
32 |
KEY_SORT_ALGO = 8 |
/* special attributes for signatures */ |
33 |
}; |
SIG_SORT_CLASS = 30, |
34 |
|
SIG_SORT_EXPIRE = 31 |
35 |
/* Valid keylist modes. */ |
}; |
36 |
enum { |
|
37 |
KEYLIST_ALL = 0, |
/* Valid keylist modes. */ |
38 |
KEYLIST_LIST = 1, |
enum keylist_mode_t { |
39 |
KEYLIST_ENCRYPT = 2, |
KEYLIST_ALL = 0, |
40 |
KEYLIST_ENCRYPT_MIN = 4, |
KEYLIST_LIST = 1, |
41 |
KEYLIST_SIGN = 8, |
KEYLIST_ENCRYPT = 2, /* obsolete */ |
42 |
KEYLIST_FLAG_FILE = 16, |
KEYLIST_ENCRYPT_MIN = 4, |
43 |
KEYLIST_FLAG_SHORT = 32 |
KEYLIST_SIGN = 8, |
44 |
}; |
KEYLIST_FLAG_FILE = 16, |
45 |
|
KEYLIST_FLAG_SHORT = 32 |
46 |
/* All possible key flags. */ |
}; |
47 |
enum { |
|
48 |
KEYFLAG_NONE = 0, |
/* All possible key flags. */ |
49 |
KEYFLAG_EXPIRED = 1, |
enum key_flag_t { |
50 |
KEYFLAG_REVOKED = 2, |
KEYFLAG_NONE = 0, |
51 |
KEYFLAG_DISABLED = 4 |
KEYFLAG_EXPIRED = 1, |
52 |
}; |
KEYFLAG_REVOKED = 2, |
53 |
|
KEYFLAG_DISABLED = 4 |
54 |
/* Signature verification context for a file. */ |
}; |
55 |
struct file_sig_ctx_s { |
|
56 |
char *file; /* plaintext file name */ |
/* Symbolic column IDs. */ |
57 |
gpgme_signature_t sig; /* the actual signature */ |
enum km_col_t { |
58 |
unsigned use_uid:1; /* 1=if the user id from context should be used. */ |
KM_COL_UID = 0, |
59 |
const char *user_id; |
KM_COL_KEYID = 1, |
60 |
}; |
KM_COL_TYPE = 2, |
61 |
typedef struct file_sig_ctx_s *file_sig_ctx_t; |
KM_COL_SIZE = 3, |
62 |
|
KM_COL_CIPHER = 4, |
63 |
/*-- keylist.c --*/ |
KM_COL_VALID = 5, |
64 |
const char* get_key_pubalgo (gpgme_pubkey_algo_t alg); |
KM_COL_TRUST = 6, |
65 |
const char * get_key_algo( gpgme_key_t key, int keyidx ); |
KM_COL_CREAT = 7, |
66 |
const char * get_key_created( long timestamp ); |
KM_COL_DESC = 8 |
67 |
const char * get_key_expire_date( long timestamp ); |
}; |
68 |
const char * get_key_type( gpgme_key_t key ); |
|
69 |
const char * get_key_size( gpgme_key_t key, int keyidx ); |
/* Symbolic column IDs for sig lists */ |
70 |
const char * get_key_fpr( gpgme_key_t key ); |
enum siglist_col_t { |
71 |
const char * get_key_trust (gpgme_key_t key, int uididx, int listmode); |
SL_COL_UID = 0, |
72 |
const char * get_key_trust2 (gpgme_key_t key, int val, int uididx, int listmode); |
SL_COL_VALID = 1, |
73 |
const char * get_key_trust_str (int val); |
SL_COL_CLASS = 2, |
74 |
int find_secret_key( gpgme_key_t key ); |
SL_COL_CREATE = 3, |
75 |
|
SL_COL_KEYID = 4, |
76 |
gpgme_user_id_t get_nth_userid (gpgme_key_t key, int idx); |
SL_COL_EXPIRE = 5, |
77 |
int count_userids (gpgme_key_t key); |
SL_COL_ALGO = 6 |
78 |
gpgme_subkey_t get_nth_key (gpgme_key_t key, int idx); |
}; |
79 |
int count_subkeys (gpgme_key_t key); |
|
80 |
gpgme_key_sig_t get_selfsig (gpgme_user_id_t uid, const char *keyid, int first); |
/* Icon for the key types. */ |
81 |
|
enum key_image_t { |
82 |
listview_ctrl_t keylist_load( HWND ctrl, gpg_keycache_t pubkc, gpg_keycache_t seckc, |
KEY_IMG_PUB = 0, |
83 |
int mode, int sortby ); |
KEY_IMG_PAIR= 1, |
84 |
int keylist_reload( listview_ctrl_t lv, gpg_keycache_t c, int mode, int sortby ); |
KEY_IMG_SORT_DOWN = 2, |
85 |
void keylist_delete( listview_ctrl_t lv ); |
KEY_IMG_SORT_UP |
86 |
int keylist_add_key (listview_ctrl_t lv, int mode, gpgme_key_t key); |
}; |
87 |
void keylist_upd_key (listview_ctrl_t lv, int pos, gpgme_key_t key); |
|
88 |
gpgme_key_t* keylist_get_recipients( listview_ctrl_t lv, |
|
89 |
int *r_force_trust, int *r_count ); |
struct keylist_ctrl_s { |
90 |
gpgme_key_t* keylist_enum_recipients( listview_ctrl_t lv, int listype, int *r_count ); |
listview_ctrl_t lv; |
91 |
int keylist_sort( listview_ctrl_t lv, int sortby ); |
gpgme_key_t *keys; |
92 |
|
unsigned int nkeys; |
93 |
/*-- wptImportList.cpp --*/ |
}; |
94 |
int implist_build( listview_ctrl_t *lv, HWND ctrl ); |
typedef struct keylist_ctrl_s *keylist_ctrl_t; |
95 |
int implist_load( listview_ctrl_t lv, const char *file, |
|
96 |
int *r_revcerts, int *r_seckeys ); |
/*-- wptKeylist.cpp --*/ |
97 |
void implist_delete( listview_ctrl_t lv ); |
const char* get_key_pubalgo2 (gpgme_pubkey_algo_t alg); |
98 |
|
const char* get_key_pubalgo (gpgme_pubkey_algo_t alg); |
99 |
/*-- wptSigList.cpp --*/ |
const char* get_key_algo (gpgme_key_t key, int keyidx); |
100 |
listview_ctrl_t siglist_load( HWND ctrl, const char *keyid ); |
const char* get_key_created (long timestamp); |
101 |
void siglist_delete( listview_ctrl_t lv ); |
const char* get_key_expire_date (long timestamp); |
102 |
|
const char* get_key_type (gpgme_key_t key); |
103 |
/*-- wptVerifyList.cpp --*/ |
const char* get_key_size (gpgme_key_t key, int keyidx); |
104 |
int verlist_build (listview_ctrl_t *lv, HWND ctrl, int fm_mode); |
const char* get_key_fpr (gpgme_key_t key); |
105 |
void verlist_delete (listview_ctrl_t lv); |
const char* get_key_trust (gpgme_key_t key, int uididx, int listmode); |
106 |
void verlist_alloc (listview_ctrl_t lv, int nentries ); |
const char* get_key_trust2 (gpgme_key_t key, int val, int uididx, int listmode); |
107 |
int verlist_add_sig (listview_ctrl_t lv, gpgme_signature_t sig); |
const char* get_key_trust_str (int val); |
108 |
int verlist_add_sig_log (listview_ctrl_t lv, file_sig_ctx_t log); |
const char* get_keyid_from_fpr (const char *fpr); |
109 |
|
char* get_key_desc (gpgme_key_t key); |
110 |
/*-- seclist --*/ |
|
111 |
struct keylist_s { |
gpgme_user_id_t get_nth_userid (gpgme_key_t key, int idx); |
112 |
struct keylist_s * next; |
int count_userids (gpgme_key_t key); |
113 |
gpgme_key_t key; |
gpgme_subkey_t get_nth_key (gpgme_key_t key, int idx); |
114 |
}; |
int count_subkeys (gpgme_key_t key); |
115 |
typedef struct keylist_s *keylist_t; |
gpgme_key_sig_t get_selfsig (gpgme_key_sig_t sigs, const char *keyid, |
116 |
|
int first); |
117 |
void seclist_destroy (keylist_t * list); |
|
118 |
void seclist_init (HWND dlg, int ctlid, int flags, keylist_t * ret_list); |
keylist_ctrl_t keylist_load (HWND ctrl, gpg_keycache_t pubkc, |
119 |
int seclist_select_key (HWND dlg, int ctlid, gpgme_key_t * ret_key); |
gpg_keycache_t seckc, |
120 |
|
int mode, int sortby); |
121 |
#endif /* WPT_KEYLIST_H */ |
int keylist_reload (keylist_ctrl_t lv, gpg_keycache_t c, int mode, |
122 |
|
int sortby); |
123 |
|
void keylist_delete (keylist_ctrl_t lv); |
124 |
|
int keylist_add_key (keylist_ctrl_t lv, int mode, |
125 |
|
struct keycache_s *ctx, gpgme_key_t key); |
126 |
|
void keylist_upd_key (keylist_ctrl_t lv, int pos, |
127 |
|
struct keycache_s *ctx, gpgme_key_t key); |
128 |
|
void keylist_upd_col (keylist_ctrl_t lv, int col); |
129 |
|
gpgme_key_t* keylist_get_recipients (keylist_ctrl_t lv, |
130 |
|
int *r_force_trust, size_t *r_count); |
131 |
|
gpgme_key_t* keylist_enum_recipients (keylist_ctrl_t lv, int listype, |
132 |
|
size_t *r_count); |
133 |
|
int keylist_sort (keylist_ctrl_t lv, int sortby); |
134 |
|
void keylist_sync (keylist_ctrl_t kl); |
135 |
|
|
136 |
|
/*-- wptImportList.cpp --*/ |
137 |
|
void implist_build (listview_ctrl_t *lv, HWND ctrl); |
138 |
|
int implist_load (listview_ctrl_t lv, const char *file, |
139 |
|
int *r_revcerts, int *r_seckeys); |
140 |
|
void implist_delete (listview_ctrl_t lv); |
141 |
|
|
142 |
|
/*-- wptSigList.cpp --*/ |
143 |
|
listview_ctrl_t siglist_load (HWND ctrl, const char *keyid); |
144 |
|
void siglist_delete (listview_ctrl_t lv); |
145 |
|
void siglist_sort (listview_ctrl_t sigl, int sortby); |
146 |
|
|
147 |
|
/*-- wptVerifyList.cpp --*/ |
148 |
|
/* Verify list control context. */ |
149 |
|
struct verlist_ctrl_s { |
150 |
|
listview_ctrl_t lv; /* list view control. */ |
151 |
|
HWND infctl; /* handle to the optional sig info control. */ |
152 |
|
}; |
153 |
|
typedef struct verlist_ctrl_s *verlist_ctrl_t; |
154 |
|
|
155 |
|
void verlist_build (verlist_ctrl_t *vlv, HWND ctrl, int fm_mode); |
156 |
|
void verlist_delete (verlist_ctrl_t vlv); |
157 |
|
void verlist_alloc (verlist_ctrl_t vlv, int nentries ); |
158 |
|
void verlist_set_info_control (verlist_ctrl_t vlv, HWND infctl); |
159 |
|
int verlist_add_sig (verlist_ctrl_t vlv, gpgme_signature_t sig); |
160 |
|
int verlist_add_sig_log (verlist_ctrl_t vlv, file_sig_ctx_t log); |
161 |
|
|
162 |
|
/*-- seclist --*/ |
163 |
|
struct keylist_s { |
164 |
|
struct keylist_s *next; |
165 |
|
gpgme_key_t key; |
166 |
|
}; |
167 |
|
typedef struct keylist_s *keylist_t; |
168 |
|
|
169 |
|
void seclist_destroy (keylist_t * list); |
170 |
|
void seclist_init (HWND dlg, int ctlid, int flags, keylist_t * ret_list); |
171 |
|
int seclist_select_key (HWND dlg, int ctlid, gpgme_key_t * ret_key); |
172 |
|
|
173 |
|
/*-- notification handler --*/ |
174 |
|
LRESULT keylist_listview_notify (HWND hwnd, gpgme_key_t *keys, |
175 |
|
int ctlid, LPARAM lparam); |
176 |
|
|
177 |
|
#endif /* WPT_KEYLIST_H */ |