1 |
/* wptSigList.cpp - Listview for key signatures |
/* wptSigList.cpp - Listview for key signatures |
2 |
* Copyright (C) 2001-2004 Timo Schulz |
* Copyright (C) 2001-2005 Timo Schulz |
3 |
|
* Copyright (C) 2005 g10 Code GmbH |
4 |
* |
* |
5 |
* This file is part of WinPT. |
* This file is part of WinPT. |
6 |
* |
* |
55 |
}; |
}; |
56 |
int j, rc = 0; |
int j, rc = 0; |
57 |
|
|
58 |
rc = listview_new( &c ); |
rc = listview_new (&c); |
59 |
if( rc ) |
if (rc) |
60 |
return rc; |
return rc; |
61 |
c->ctrl = ctrl; |
c->ctrl = ctrl; |
62 |
for ( j=0; implist[j].fieldname != NULL; j++ ) |
for ( j=0; implist[j].fieldname != NULL; j++ ) |
95 |
} |
} |
96 |
|
|
97 |
|
|
98 |
/* Add an userid signature with the index @idx from the userid @uid |
/* Add an userid signature @ks from the userid @uid to the sig list |
99 |
to the sig list control @lv. |
control @lv. |
100 |
Return value: 0 on success. */ |
Return value: 0 on success. */ |
101 |
static int |
static int |
102 |
siglist_add_key( listview_ctrl_t lv, gpgme_user_id_t uid, int idx) |
siglist_add_key (listview_ctrl_t lv, gpgme_user_id_t uid, gpgme_key_sig_t ks) |
103 |
{ |
{ |
104 |
gpgme_key_sig_t ks; |
gpgme_key_t key=NULL; |
|
gpgme_key_t key=NULL; |
|
105 |
char t[128]; |
char t[128]; |
106 |
const char *attr; |
const char *attr; |
107 |
const char *s; |
const char *s; |
108 |
int rc = 0, key_attr, root = 0; |
int rc = 0, key_attr; |
|
|
|
|
ks = get_nth_uid_sig (uid, idx); |
|
109 |
|
|
110 |
if( !IS_UID_CERT( ks->sig_class ) ) |
if (ks && !IS_UID_CERT (ks->sig_class)) |
111 |
return 0; |
return 0; |
112 |
|
|
113 |
rc = listview_add_item (lv, " "); |
rc = listview_add_item (lv, " "); |
114 |
if( rc ) |
if( rc ) |
115 |
return rc; |
return rc; |
116 |
|
|
117 |
get_pubkey (ks->keyid, &key); |
attr = NULL; |
118 |
if (key) { |
if (!uid) { |
119 |
attr = key->uids->uid; |
get_pubkey (ks->keyid, &key); |
120 |
if( attr && strlen( attr ) ) { |
if (key) |
121 |
char * uid = utf8_to_wincp (attr, strlen (attr)), * p; |
attr = key->uids->uid; |
122 |
p = indent_string( uid, 2 ); |
} |
123 |
listview_add_sub_item( lv, 0, 0, p ); |
else |
124 |
free( uid ); |
attr = uid->uid; |
125 |
free_if_alloc( p ); |
if (attr && strlen (attr)) { |
126 |
} |
char *uid_utf8 = utf8_to_wincp (attr, strlen (attr)); |
127 |
else |
char *p = uid? m_strdup (uid_utf8) : indent_string (uid_utf8, 2); |
128 |
listview_add_sub_item( lv, 0, 0, _(" user ID not found") ); |
listview_add_sub_item (lv, 0, 0, p); |
129 |
|
free (uid_utf8); |
130 |
|
free_if_alloc (p); |
131 |
} |
} |
132 |
|
else |
133 |
|
listview_add_sub_item (lv, 0, 0, _(" user ID not found")); |
134 |
|
|
135 |
if( root ) |
if (uid) |
136 |
return 0; |
return 0; |
137 |
|
|
138 |
switch (gpg_error ((gpg_err_code_t)ks->status)) { |
switch (gpgme_err_code (ks->status)) { |
139 |
case GPG_ERR_NO_ERROR: s = "YES"; break; |
case GPG_ERR_NO_ERROR: s = "YES"; break; |
140 |
case GPG_ERR_NO_PUBKEY: s = "NOKEY"; break; |
case GPG_ERR_NO_PUBKEY: s = "NOKEY"; break; |
141 |
case GPG_ERR_BAD_SIGNATURE:s = "NO"; break; |
case GPG_ERR_BAD_SIGNATURE:s = "NO"; break; |
165 |
|
|
166 |
attr = ks->keyid; |
attr = ks->keyid; |
167 |
if( attr && strlen( attr ) == 16 ) { |
if( attr && strlen( attr ) == 16 ) { |
168 |
_snprintf( t, sizeof t -1, "0x%s", attr + 8 ); |
_snprintf (t, sizeof t -1, "0x%s", attr + 8); |
169 |
listview_add_sub_item( lv, 0, 4, t ); |
listview_add_sub_item( lv, 0, 4, t ); |
170 |
} |
} |
171 |
|
|
191 |
{ |
{ |
192 |
gpgme_key_t key; |
gpgme_key_t key; |
193 |
gpgme_user_id_t u; |
gpgme_user_id_t u; |
194 |
|
gpgme_key_sig_t s; |
195 |
listview_ctrl_t lv; |
listview_ctrl_t lv; |
196 |
int rc = 0, i; |
int rc, i=0; |
197 |
|
|
198 |
if (siglist_build (&lv, ctrl)) |
if (siglist_build (&lv, ctrl)) |
199 |
BUG (NULL); |
BUG (NULL); |
201 |
if (rc) |
if (rc) |
202 |
BUG (NULL); |
BUG (NULL); |
203 |
|
|
204 |
for (u=key->uids; u; u = u->next) { |
/* XXX: the root item is at the end but should come first. */ |
205 |
rc = listview_add_item (lv, " "); |
for (u=key->uids; u; u = u->next) { |
206 |
if( rc ) |
siglist_add_key (lv, u, NULL); |
207 |
break; |
for (s = u->signatures; s; s = s->next) { |
208 |
listview_add_sub_item (lv, 0, 0, u->uid); |
rc = siglist_add_key (lv, NULL, s); |
209 |
for (i=0; i < count_uid_sigs (u); i++) { |
if (rc) |
|
rc = siglist_add_key( lv, u, i ); |
|
|
if( rc ) |
|
210 |
break; |
break; |
211 |
} |
} |
212 |
} |
} |
213 |
if( rc ) { |
if (rc) { |
214 |
siglist_delete( lv ); |
siglist_delete (lv); |
215 |
lv = NULL; |
lv = NULL; |
216 |
} |
} |
217 |
return lv; |
return lv; |