83 |
int j; |
int j; |
84 |
|
|
85 |
for (j = 0; j < items; j++) { |
for (j = 0; j < items; j++) { |
86 |
if (!strcmp (keyid, ka[j].keyid )) |
if (!strcmp (keyid, ka[j].keyid)) |
87 |
return 1; |
return 1; |
88 |
} |
} |
89 |
return 0; |
return 0; |
155 |
/* Return the self signature of the key @keyid. |
/* Return the self signature of the key @keyid. |
156 |
If first is set, the first self sig will be returned. */ |
If first is set, the first self sig will be returned. */ |
157 |
gpgme_key_sig_t |
gpgme_key_sig_t |
158 |
get_selfsig (gpgme_user_id_t uid, const char *keyid, int first) |
get_selfsig (gpgme_key_sig_t sigs, const char *keyid, int first) |
159 |
{ |
{ |
160 |
gpgme_key_sig_t s, self_sig=NULL; |
gpgme_key_sig_t s, self_sig=NULL; |
161 |
long timestamp=0; |
long timestamp=0; |
164 |
if (strlen (keyid) == 8) |
if (strlen (keyid) == 8) |
165 |
off = 8; |
off = 8; |
166 |
|
|
167 |
for (s = uid->signatures; s; s = s->next) { |
for (s = sigs; s; s = s->next) { |
168 |
if (!strcmp (s->keyid+off, keyid) && s->timestamp > timestamp) { |
if (!strcmp (s->keyid+off, keyid) && s->timestamp > timestamp) { |
169 |
self_sig = s; |
self_sig = s; |
170 |
timestamp = s->timestamp; |
timestamp = s->timestamp; |
176 |
} |
} |
177 |
|
|
178 |
|
|
|
|
|
179 |
const char* |
const char* |
180 |
get_key_algo (gpgme_key_t key, int keyidx) |
get_key_algo (gpgme_key_t key, int keyidx) |
181 |
{ |
{ |
194 |
strcpy (alg, get_key_pubalgo (key->subkeys->pubkey_algo)); |
strcpy (alg, get_key_pubalgo (key->subkeys->pubkey_algo)); |
195 |
n = count_subkeys (key); |
n = count_subkeys (key); |
196 |
if (n > 1) { |
if (n > 1) { |
197 |
k = get_nth_key (key, n-1); |
do { |
198 |
|
k = get_nth_key (key, --n); |
199 |
|
if (k->revoked || k->expired) |
200 |
|
continue; |
201 |
|
else |
202 |
|
break; |
203 |
|
} while (n > 0); |
204 |
subalg = get_key_pubalgo (k->pubkey_algo); |
subalg = get_key_pubalgo (k->pubkey_algo); |
205 |
_snprintf (algo_id, DIM (algo_id)-1, "%s/%s", alg, subalg); |
if (k == key->subkeys) |
206 |
|
_snprintf (algo_id, DIM (algo_id)-1, "%s", subalg); |
207 |
|
else |
208 |
|
_snprintf (algo_id, DIM (algo_id)-1, "%s/%s", alg, subalg); |
209 |
return algo_id; |
return algo_id; |
210 |
} |
} |
211 |
return get_key_pubalgo (key->subkeys->pubkey_algo); |
return get_key_pubalgo (key->subkeys->pubkey_algo); |
221 |
|
|
222 |
if (timestamp < 1) |
if (timestamp < 1) |
223 |
return "????" "-??" "-??"; |
return "????" "-??" "-??"; |
224 |
dat = get_locale_date (timestamp, timebuf, sizeof (timebuf)-1); |
dat = get_locale_date (timestamp, timebuf, DIM (timebuf)-1); |
225 |
if (dat) |
if (dat) |
226 |
return dat; |
return dat; |
227 |
|
/* Fallback if locate date conversion failed. */ |
228 |
warp = localtime (×tamp); |
warp = localtime (×tamp); |
229 |
_snprintf (timebuf, sizeof timebuf - 1, "%04d-%02d-%02d", |
_snprintf (timebuf, DIM (timebuf) - 1, "%04d-%02d-%02d", |
230 |
warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday); |
warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday); |
231 |
return timebuf; |
return timebuf; |
232 |
} |
} |
242 |
|
|
243 |
if (timestamp == 0) |
if (timestamp == 0) |
244 |
return _("Never"); |
return _("Never"); |
245 |
dat = get_locale_date (timestamp, timebuf, sizeof (timebuf)-1); |
dat = get_locale_date (timestamp, timebuf, DIM (timebuf)-1); |
246 |
if (dat) |
if (dat) |
247 |
return dat; |
return dat; |
248 |
warp = localtime (×tamp); |
warp = localtime (×tamp); |
249 |
_snprintf (timebuf, sizeof timebuf -1, "%04d-%02d-%02d", |
_snprintf (timebuf, DIM (timebuf) -1, "%04d-%02d-%02d", |
250 |
warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday); |
warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday); |
251 |
return timebuf; |
return timebuf; |
252 |
} |
} |
283 |
if (n > 1) { |
if (n > 1) { |
284 |
k = get_nth_key (key, n-1); |
k = get_nth_key (key, n-1); |
285 |
size_sub = k->length; |
size_sub = k->length; |
286 |
_snprintf (size_id, sizeof (size_id) - 1, "%d/%d", |
_snprintf (size_id, DIM (size_id) - 1, "%d/%d", |
287 |
size_main, size_sub); |
size_main, size_sub); |
288 |
return size_id; |
return size_id; |
289 |
} |
} |
290 |
_snprintf( size_id, sizeof (size_id) - 1, "%d", size_main ); |
_snprintf (size_id, DIM (size_id) - 1, "%d", size_main); |
291 |
return size_id; |
return size_id; |
292 |
} |
} |
293 |
|
|
312 |
case GPGME_PK_DSA: return "DSA"; |
case GPGME_PK_DSA: return "DSA"; |
313 |
case GPGME_PK_ELG: |
case GPGME_PK_ELG: |
314 |
case GPGME_PK_ELG_E: return "ELG"; |
case GPGME_PK_ELG_E: return "ELG"; |
315 |
case 0: /* XXX: gpgme returned pubkey algo 0 for a RSA made sig. */ |
case 0: /* XXX: do we still need this?? */ |
316 |
case GPGME_PK_RSA: return "RSA"; |
case GPGME_PK_RSA: |
317 |
|
case GPGME_PK_RSA_S: |
318 |
|
case GPGME_PK_RSA_E: return "RSA"; |
319 |
default: return "???"; |
default: return "???"; |
320 |
} |
} |
321 |
return "???"; |
return "???"; |
386 |
case GPGME_VALIDITY_MARGINAL: |
case GPGME_VALIDITY_MARGINAL: |
387 |
return _("Marginal"); |
return _("Marginal"); |
388 |
case GPGME_VALIDITY_FULL: |
case GPGME_VALIDITY_FULL: |
|
case GPGME_VALIDITY_ULTIMATE: |
|
389 |
return _("Full"); |
return _("Full"); |
390 |
|
case GPGME_VALIDITY_ULTIMATE: |
391 |
|
return _("Ultimate"); |
392 |
} |
} |
393 |
return ""; |
return ""; |
394 |
} |
} |
594 |
{7, 72, (char *)_("Creation")}, |
{7, 72, (char *)_("Creation")}, |
595 |
{0, 0, NULL} |
{0, 0, NULL} |
596 |
}; |
}; |
597 |
HICON ico[2]; |
HICON ico[4]; |
598 |
listview_ctrl_t lv; |
listview_ctrl_t lv; |
599 |
listview_column_t col; |
listview_column_t col; |
600 |
int j, n = 0, ext_chk = 0; |
int j, n = 0, ext_chk = 0; |
|
int rc = 0; |
|
|
|
|
|
rc = listview_new (&lv); |
|
|
if (rc) |
|
|
return rc; |
|
601 |
|
|
602 |
lv->ctrl = ctrl; |
listview_new (&lv, ctrl); |
603 |
if (mode & KEYLIST_ENCRYPT_MIN) { |
if (mode & KEYLIST_ENCRYPT_MIN) { |
604 |
col = klist_enc; |
col = klist_enc; |
605 |
n = (DIM(klist_enc) -1); |
n = (DIM (klist_enc) -1); |
606 |
ext_chk = 1; |
ext_chk = 1; |
607 |
} |
} |
608 |
else if ((mode & KEYLIST_SIGN)) { |
else if ((mode & KEYLIST_SIGN)) { |
609 |
col = klist_enc; |
col = klist_enc; |
610 |
n = (DIM(klist_enc) - 1) - 1; |
n = (DIM (klist_enc) - 1) - 1; |
611 |
ext_chk = 1; |
ext_chk = 1; |
612 |
} |
} |
613 |
else { |
else { |
614 |
col = klist; |
col = klist; |
615 |
n = (DIM(klist) - 1); |
n = (DIM (klist) - 1); |
616 |
} |
} |
617 |
|
|
618 |
for (j = 0; j < n; j++) |
for (j = 0; j < n; j++) |
619 |
listview_add_column (lv, &col[j]); |
listview_add_column (lv, &col[j]); |
620 |
listview_set_ext_style (lv); |
listview_set_ext_style (lv); |
621 |
if (ext_chk) |
if (ext_chk) |
622 |
listview_set_chkbox_style (lv); |
listview_set_chkbox_style (lv); |
623 |
ico[0] = LoadIcon (glob_hinst, (LPCTSTR)IDI_PUBKEY); |
ico[0] = LoadIcon (glob_hinst, (LPCTSTR)IDI_PUBKEY); |
624 |
ico[1] = LoadIcon (glob_hinst, (LPCTSTR)IDI_KEYPAIR); |
ico[1] = LoadIcon (glob_hinst, (LPCTSTR)IDI_KEYPAIR); |
625 |
listview_set_image_list (lv, 22, 14, ico, 2); |
ico[2] = LoadIcon (glob_hinst, (LPCTSTR)IDI_SORT_DOWNARROW); |
626 |
|
ico[3] = LoadIcon (glob_hinst, (LPCTSTR)IDI_SORT_UPARROW); |
627 |
|
listview_set_image_list (lv, 22, 14, ico, 4); |
628 |
listview_del_all_items (lv); |
listview_del_all_items (lv); |
629 |
|
|
630 |
*r_lv = lv; |
*r_lv = lv; |
770 |
listview_add_sub_item (lv, 0, idx++, attr); |
listview_add_sub_item (lv, 0, idx++, attr); |
771 |
k = get_nth_key (key, keyidx); |
k = get_nth_key (key, keyidx); |
772 |
if (k && k->keyid) { |
if (k && k->keyid) { |
773 |
_snprintf (fmt, sizeof fmt -1, "0x%s", k->keyid + 8); |
_snprintf (fmt, DIM (fmt) -1, "0x%s", k->keyid + 8); |
774 |
listview_add_sub_item (lv, 0, idx++, fmt); |
listview_add_sub_item (lv, 0, idx++, fmt); |
775 |
} |
} |
776 |
if (list > 0) { |
if (list > 0) { |
831 |
continue; |
continue; |
832 |
switch (col) { |
switch (col) { |
833 |
case KM_COL_KEYID: |
case KM_COL_KEYID: |
834 |
_snprintf (buf, sizeof (buf)-1, "0x%s", key->subkeys->keyid+8); |
_snprintf (buf, DIM (buf)-1, "0x%s", key->subkeys->keyid+8); |
835 |
listview_add_sub_item (lv, i, col, buf); |
listview_add_sub_item (lv, i, col, buf); |
836 |
break; |
break; |
837 |
|
|
1001 |
fully trusted. @r_count returns the number of selected keys. |
fully trusted. @r_count returns the number of selected keys. |
1002 |
Return value: the key list on success, NULL otherwise. */ |
Return value: the key list on success, NULL otherwise. */ |
1003 |
gpgme_key_t* |
gpgme_key_t* |
1004 |
keylist_get_recipients (listview_ctrl_t lv, int *r_force_trust, int *r_count) |
keylist_get_recipients (listview_ctrl_t lv, int *r_force_trust, size_t *r_count) |
1005 |
{ |
{ |
1006 |
key_array_s *ka = NULL; |
key_array_s *ka = NULL; |
1007 |
keycache_s *c; |
keycache_s *c; |
1008 |
gpgme_key_t *keybuf, key; |
gpgme_key_t *keybuf, key; |
1009 |
int count = 0, force_trust = 0; |
size_t count = 0; |
1010 |
|
int force_trust = 0; |
1011 |
int n, j, ka_pos = 0, rc = 0; |
int n, j, ka_pos = 0, rc = 0; |
1012 |
int k_pos=0; |
int k_pos=0; |
1013 |
|
|
1082 |
|
|
1083 |
|
|
1084 |
gpgme_key_t* |
gpgme_key_t* |
1085 |
keylist_enum_recipients (listview_ctrl_t lv, int listype, int *r_count) |
keylist_enum_recipients (listview_ctrl_t lv, int listype, size_t *r_count) |
1086 |
{ |
{ |
1087 |
struct keycache_s *c; |
struct keycache_s *c; |
1088 |
gpgme_key_t *rset; |
gpgme_key_t *rset; |
1089 |
gpgme_key_t key; |
gpgme_key_t key; |
1090 |
int i, n, id, k_pos=0; |
size_t k_pos = 0; |
1091 |
|
int i, n, id; |
1092 |
|
|
1093 |
n = listview_count_items (lv, 0); |
n = listview_count_items (lv, 0); |
1094 |
if (!n) |
if (!n) |