169 |
} |
} |
170 |
|
|
171 |
|
|
|
const char* |
|
|
get_key_pubalgo2 (gpgme_pubkey_algo_t alg) |
|
|
{ |
|
|
switch (alg) { |
|
|
case GPGME_PK_DSA: return "D"; |
|
|
case GPGME_PK_RSA: return "R"; |
|
|
case GPGME_PK_ELG: return "G"; |
|
|
default: return "?"; |
|
|
} |
|
|
return "?"; |
|
|
} |
|
172 |
|
|
173 |
const char* |
const char* |
174 |
get_key_algo (gpgme_key_t key, int keyidx) |
get_key_algo (gpgme_key_t key, int keyidx) |
201 |
get_key_created (long timestamp) |
get_key_created (long timestamp) |
202 |
{ |
{ |
203 |
static char timebuf[128]; |
static char timebuf[128]; |
204 |
|
const char *dat; |
205 |
struct tm *warp; |
struct tm *warp; |
206 |
|
|
207 |
if (timestamp == 0 || timestamp == -1) |
if (timestamp == 0 || timestamp == -1) |
208 |
return "????" "-??" "-??"; |
return "????" "-??" "-??"; |
209 |
warp = localtime( ×tamp ); |
dat = get_locale_date (timestamp, timebuf, sizeof (timebuf)-1); |
210 |
_snprintf( timebuf, sizeof timebuf - 1, "%04d-%02d-%02d", |
if (dat) |
211 |
warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday ); |
return dat; |
212 |
|
warp = localtime (×tamp); |
213 |
|
_snprintf (timebuf, sizeof timebuf - 1, "%04d-%02d-%02d", |
214 |
|
warp->tm_year + 1900, warp->tm_mon + 1, warp->tm_mday); |
215 |
return timebuf; |
return timebuf; |
216 |
} /* get_key_created */ |
} |
217 |
|
|
218 |
|
|
219 |
/* Return a string presentation of the time @timestamp. */ |
/* Return a string presentation of the time @timestamp. */ |
242 |
else if (type == 2) |
else if (type == 2) |
243 |
return _("Key Pair (Card)"); |
return _("Key Pair (Card)"); |
244 |
return _("Public Key"); |
return _("Public Key"); |
245 |
} /* get_key_type */ |
} |
246 |
|
|
247 |
|
|
248 |
const char* |
const char* |
268 |
} |
} |
269 |
_snprintf( size_id, sizeof (size_id) - 1, "%d", size_main ); |
_snprintf( size_id, sizeof (size_id) - 1, "%d", size_main ); |
270 |
return size_id; |
return size_id; |
271 |
} /* get_key_size */ |
} |
272 |
|
|
273 |
|
|
274 |
const char* |
const char* |
275 |
|
get_key_pubalgo2 (gpgme_pubkey_algo_t alg) |
276 |
|
{ |
277 |
|
switch (alg) { |
278 |
|
case GPGME_PK_DSA: return "D"; |
279 |
|
case GPGME_PK_RSA: return "R"; |
280 |
|
case GPGME_PK_ELG: return "G"; |
281 |
|
default: return "?"; |
282 |
|
} |
283 |
|
return "?"; |
284 |
|
} |
285 |
|
|
286 |
|
const char* |
287 |
get_key_pubalgo (gpgme_pubkey_algo_t alg) |
get_key_pubalgo (gpgme_pubkey_algo_t alg) |
288 |
{ |
{ |
289 |
switch (alg) { |
switch (alg) { |
325 |
} |
} |
326 |
} |
} |
327 |
return fpr_md; |
return fpr_md; |
328 |
} /* get_key_fpr */ |
} |
329 |
|
|
330 |
|
|
331 |
const char * |
const char * |
547 |
}; |
}; |
548 |
|
|
549 |
struct listview_column_s klist[] = { |
struct listview_column_s klist[] = { |
550 |
{0, 242, (char *)_("User ID")}, |
{0, 240, (char *)_("User ID")}, |
551 |
{1, 78, (char *)_("Key ID")}, |
{1, 78, (char *)_("Key ID")}, |
552 |
{2, 52, (char *)_("Type")}, |
{2, 52, (char *)_("Type")}, |
553 |
{3, 68, (char *)_("Size")}, |
{3, 66, (char *)_("Size")}, |
554 |
{4, 66, (char *)_("Cipher")}, |
{4, 60, (char *)_("Cipher")}, |
555 |
{5, 70, (char *)_("Validity")}, |
{5, 66, (char *)_("Validity")}, |
556 |
{6, 40, (char *)_("Trust")}, |
{6, 58, (char *)_("Trust")}, |
557 |
{7, 72, (char *)_("Creation")}, |
{7, 72, (char *)_("Creation")}, |
558 |
{0, 0, NULL} |
{0, 0, NULL} |
559 |
}; |
}; |
776 |
} |
} |
777 |
|
|
778 |
|
|
779 |
|
/* Update a single column @col but for each element in the |
780 |
|
listview @lv. */ |
781 |
|
void |
782 |
|
keylist_upd_col (listview_ctrl_t lv, int col) |
783 |
|
{ |
784 |
|
gpgme_key_t key; |
785 |
|
const char *s; |
786 |
|
char buf[32]; |
787 |
|
int i; |
788 |
|
|
789 |
|
for (i=0; i < listview_count_items (lv, 0); i++) { |
790 |
|
key = (gpgme_key_t)listview_get_item2 (lv, i); |
791 |
|
if (!key) |
792 |
|
continue; |
793 |
|
switch (col) { |
794 |
|
case KM_COL_KEYID: |
795 |
|
_snprintf (buf, sizeof (buf)-1, "0x%s", key->subkeys->keyid+8); |
796 |
|
listview_add_sub_item (lv, i, col, buf); |
797 |
|
break; |
798 |
|
|
799 |
|
case KM_COL_CIPHER: |
800 |
|
s = get_key_algo (key, 0); |
801 |
|
listview_add_sub_item (lv, i, col, s); |
802 |
|
break; |
803 |
|
|
804 |
|
case KM_COL_TYPE: |
805 |
|
s = find_secret_key (key)? "pub/sec" : "pub"; |
806 |
|
listview_add_sub_item (lv, i, col, s); |
807 |
|
break; |
808 |
|
|
809 |
|
case KM_COL_CREAT: |
810 |
|
s = get_key_created (key->subkeys->timestamp); |
811 |
|
listview_add_sub_item (lv, i, col, s); |
812 |
|
break; |
813 |
|
} |
814 |
|
} |
815 |
|
} |
816 |
|
|
817 |
|
/* Update the listview item at position @pos with the data from |
818 |
|
the key @key. */ |
819 |
void |
void |
820 |
keylist_upd_key (listview_ctrl_t lv, int pos, gpgme_key_t key) |
keylist_upd_key (listview_ctrl_t lv, int pos, gpgme_key_t key) |
821 |
{ |
{ |
822 |
const char *s; |
const char *s; |
823 |
|
char *uid; |
824 |
char tmp[32]; |
char tmp[32]; |
825 |
|
|
826 |
listview_set_item2 (lv, pos, (void *)key); |
listview_set_item2 (lv, pos, (void *)key); |
827 |
/* the only mode we support is KYLIST_LIST in the Key Manager */ |
/* the only mode we support is KYLIST_LIST in the Key Manager */ |
828 |
|
|
829 |
s = key->uids->uid; |
s = key->uids->uid; |
830 |
if (s) |
if (s) { |
831 |
listview_add_sub_item (lv, pos, 0, s); |
uid = utf8_to_wincp2 (s); |
832 |
|
listview_add_sub_item (lv, pos, 0, uid); |
833 |
|
free (uid); |
834 |
|
} |
835 |
|
|
836 |
s = key->subkeys->keyid; |
s = key->subkeys->keyid; |
837 |
if (s) { |
if (s) { |