23 |
#endif |
#endif |
24 |
|
|
25 |
#include <windows.h> |
#include <windows.h> |
|
#include <windows.h> |
|
26 |
#include <commctrl.h> |
#include <commctrl.h> |
27 |
#include <time.h> |
#include <time.h> |
28 |
|
|
220 |
|
|
221 |
|
|
222 |
const char* |
const char* |
223 |
get_key_created( long timestamp ) |
get_key_created (long timestamp) |
224 |
{ |
{ |
225 |
static char timebuf[128]; |
static char timebuf[128]; |
226 |
struct tm *warp; |
struct tm *warp; |
227 |
|
|
228 |
if (timestamp == 0 || timestamp == -1) |
if (timestamp == 0 || timestamp == -1) |
229 |
return "????-??-??"; |
return "????" "-??" "-??"; |
230 |
warp = localtime( ×tamp ); |
warp = localtime( ×tamp ); |
231 |
_snprintf( timebuf, sizeof timebuf - 1, "%04d-%02d-%02d", |
_snprintf( timebuf, sizeof timebuf - 1, "%04d-%02d-%02d", |
232 |
warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday ); |
warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday ); |
234 |
} /* get_key_created */ |
} /* get_key_created */ |
235 |
|
|
236 |
|
|
237 |
|
/* Return a string presentation of the time @timestamp. */ |
238 |
const char* |
const char* |
239 |
get_key_expire_date (long timestamp) |
get_key_expire_date (long timestamp) |
240 |
{ |
{ |
244 |
if( !timestamp ) |
if( !timestamp ) |
245 |
return _("Never"); |
return _("Never"); |
246 |
warp = localtime( ×tamp ); |
warp = localtime( ×tamp ); |
247 |
_snprintf( timebuf, sizeof timebuf -1, "%04d-%02d-%02d", |
_snprintf (timebuf, sizeof timebuf -1, "%04d-%02d-%02d", |
248 |
warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday ); |
warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday); |
249 |
return timebuf; |
return timebuf; |
250 |
} /* get_key_expire_date */ |
} |
251 |
|
|
252 |
|
|
253 |
const char* |
const char* |
297 |
case GPGME_PK_ELG: |
case GPGME_PK_ELG: |
298 |
case GPGME_PK_ELG_E: return "ELG"; |
case GPGME_PK_ELG_E: return "ELG"; |
299 |
case GPGME_PK_RSA: return "RSA"; |
case GPGME_PK_RSA: return "RSA"; |
300 |
|
default: return "???"; |
301 |
} |
} |
302 |
return "???"; |
return "???"; |
303 |
} |
} |
369 |
} |
} |
370 |
|
|
371 |
|
|
372 |
|
/* Return the status of the key @key. */ |
373 |
char* |
char* |
374 |
get_key_status (gpgme_key_t key, int uididx, int listmode) |
get_key_status (gpgme_key_t key, int uididx, int listmode) |
375 |
{ |
{ |
376 |
gpgme_user_id_t u; |
gpgme_user_id_t u; |
377 |
char fmt[64], * p; |
const char *attr; |
|
const char * attr; |
|
|
int i = 0; |
|
378 |
u32 key_attr =0; |
u32 key_attr =0; |
379 |
|
|
380 |
if (uididx < 0 || count_userids (key) > uididx) |
if (uididx < 0 || count_userids (key) > uididx) |
381 |
uididx = 0; |
uididx = 0; |
|
memset (fmt, 0, sizeof (fmt)); |
|
382 |
if (listmode) { |
if (listmode) { |
383 |
|
const char *s; |
384 |
|
|
385 |
if (key->revoked) |
if (key->revoked) |
386 |
sprintf (fmt, "Revoked"); |
s = _("Revoked"); |
387 |
else if (key->expired) |
else if (key->expired) |
388 |
sprintf (fmt, "Expired"); |
s = _("Expired"); |
389 |
else if (key->disabled) |
else if (key->disabled) |
390 |
sprintf (fmt, "Disabled"); |
s = _("Disabled"); |
391 |
|
else |
392 |
|
s = ""; |
393 |
|
|
394 |
/* if the key has a special status, we don't continue to figure out |
/* if the key has a special status, we don't continue to figure out |
395 |
what any user-id validities. */ |
what any user-id validities. */ |
396 |
if (strlen (fmt) > 0) |
if (*s) |
397 |
return m_strdup (fmt); |
return m_strdup (s); |
398 |
} |
} |
399 |
u = get_nth_userid (key, uididx); |
u = get_nth_userid (key, uididx); |
400 |
key_attr = u->validity; |
key_attr = u->validity; |
401 |
attr = get_key_trust2 (NULL, key_attr, 0, 0); |
attr = get_key_trust2 (NULL, key_attr, 0, 0); |
402 |
p = new char[strlen( attr ) + 2]; |
return m_strdup (attr); |
403 |
if (!p) |
} |
|
BUG (NULL); |
|
|
sprintf (p, "%s", attr); |
|
|
return p; |
|
|
} /* get_key_status */ |
|
404 |
|
|
405 |
|
|
406 |
/* Integer comparsion of @a and @b. |
/* Integer comparsion of @a and @b. |
495 |
static const char* |
static const char* |
496 |
calc_validity (gpg_group_t grp) |
calc_validity (gpg_group_t grp) |
497 |
{ |
{ |
498 |
int level = 0, valid; |
int valid=0; |
499 |
gpg_member_t mbr; |
gpg_member_t mbr; |
500 |
gpgme_key_t key; |
gpgme_key_t key; |
501 |
|
|
548 |
listview_ctrl_t lv; |
listview_ctrl_t lv; |
549 |
listview_column_t col; |
listview_column_t col; |
550 |
int j, n = 0; |
int j, n = 0; |
551 |
int kl_nolist = 0, rc = 0; |
int rc = 0; |
552 |
|
|
553 |
rc = listview_new (&lv); |
rc = listview_new (&lv); |
554 |
if( rc ) |
if( rc ) |
812 |
int |
int |
813 |
keylist_add_key (listview_ctrl_t lv, int mode, gpgme_key_t key) |
keylist_add_key (listview_ctrl_t lv, int mode, gpgme_key_t key) |
814 |
{ |
{ |
815 |
int uids, rc = 0, i, n = 0; |
int uids, rc = 0, i; |
816 |
gpgme_subkey_t k; |
gpgme_subkey_t k; |
817 |
|
|
818 |
|
/* if the entire key is disabled, just return. */ |
819 |
|
if (key->disabled) |
820 |
|
return 0; |
821 |
|
|
822 |
for (k=key->subkeys, i = 0; i < count_subkeys (key); i++, k=k->next) { |
for (k=key->subkeys, i = 0; i < count_subkeys (key); i++, k=k->next) { |
823 |
if (k->invalid) { |
if (k->invalid) { |
824 |
log_debug ("keylist_add_key: invalid key \"%s\"\n", key->uids->name); |
log_debug ("keylist_add_key: invalid key \"%s\"\n", key->uids->name); |
857 |
} |
} |
858 |
} |
} |
859 |
else if (mode & KEYLIST_SIGN) { |
else if (mode & KEYLIST_SIGN) { |
860 |
if ( k->can_sign |
if (k->can_sign |
861 |
&& find_secret_key( key ) |
&& find_secret_key (key) |
862 |
&& key_is_useable (k)) |
&& key_is_useable (k)) { |
|
{ |
|
863 |
rc = do_addkey (lv, key, -1, i, -1); |
rc = do_addkey (lv, key, -1, i, -1); |
864 |
if( rc ) |
if (rc) |
865 |
return rc; |
return rc; |
866 |
} |
} |
867 |
} |
} |
1055 |
gpg_keycache_rewind (kc); |
gpg_keycache_rewind (kc); |
1056 |
|
|
1057 |
while (!gpg_keycache_next_key (kc, 1, &key)) { |
while (!gpg_keycache_next_key (kc, 1, &key)) { |
1058 |
char * inf = NULL, * uid = NULL; |
char *inf = NULL, *uid = NULL; |
1059 |
const char * id; |
const char *id; |
1060 |
const char * keyid; |
const char *keyid; |
1061 |
int algo; |
int algo; |
1062 |
size_t size = 0; |
size_t size = 0; |
1063 |
|
|
1068 |
keyid = key->subkeys->keyid; |
keyid = key->subkeys->keyid; |
1069 |
algo = key->subkeys->pubkey_algo; |
algo = key->subkeys->pubkey_algo; |
1070 |
if (!id || !keyid) |
if (!id || !keyid) |
1071 |
continue; /* fixme: error? */ |
continue; |
1072 |
if (!key_is_useable (key->subkeys)) |
if (key->disabled || !key_is_useable (key->subkeys)) |
1073 |
continue; |
continue; |
1074 |
|
|
1075 |
uid = utf8_to_wincp (id, strlen (id)); |
uid = utf8_to_wincp (id, strlen (id)); |