38 |
#include "wptKeyManager.h" |
#include "wptKeyManager.h" |
39 |
#include "wptContext.h" /* for passphrase_s */ |
#include "wptContext.h" /* for passphrase_s */ |
40 |
#include "wptDlgs.h" |
#include "wptDlgs.h" |
41 |
|
#include "wptUTF8.h" |
42 |
|
|
43 |
|
|
44 |
#define MAX_KEYSIZE 70000 |
#define MAX_KEYSIZE 70000 |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
/* If the keyserver returned one than more key in a |
/* Show all received keys from the keyserver. */ |
|
keyblob, show the names of all imported keys. */ |
|
108 |
static void |
static void |
109 |
show_imported_keys (gpgme_import_result_t res) |
show_imported_keys (gpgme_import_result_t res) |
110 |
{ |
{ |
114 |
gpgme_ctx_t ctx; |
gpgme_ctx_t ctx; |
115 |
gpgme_error_t err; |
gpgme_error_t err; |
116 |
const char *s; |
const char *s; |
117 |
char *p; |
char *p, *uid; |
118 |
size_t n=0; |
size_t n=0; |
119 |
|
|
120 |
|
if (!res) |
121 |
|
return; |
122 |
|
|
123 |
err = gpgme_data_new (&msg); |
err = gpgme_data_new (&msg); |
124 |
if (err) |
if (err) |
125 |
BUG (NULL); |
BUG (NULL); |
126 |
err = gpgme_new (&ctx); |
err = gpgme_new (&ctx); |
127 |
if (err) |
if (err) |
128 |
BUG (NULL); |
BUG (NULL); |
129 |
s = _("WARNING: multiple keys matched request.\n\n"); |
if (res->considered > 1) { |
130 |
|
s = _("WARNING: multiple keys matched request.\n\n"); |
131 |
|
gpgme_data_write (msg, s, strlen (s)); |
132 |
|
} |
133 |
|
|
134 |
|
if (res->unchanged == res->considered) |
135 |
|
s = _("Key(s) successfully received but nothing was changed."); |
136 |
|
else |
137 |
|
s = _("Key(s) sucessfully received and imported."); |
138 |
gpgme_data_write (msg, s, strlen (s)); |
gpgme_data_write (msg, s, strlen (s)); |
139 |
|
gpgme_data_write (msg, "\n\n", 2); |
140 |
|
|
141 |
for (t=res->imports; t; t = t->next) { |
for (t=res->imports; t; t = t->next) { |
142 |
if (!gpgme_get_key (ctx, t->fpr, &key, 0)) { |
if (!gpgme_get_key (ctx, t->fpr, &key, 0)) { |
143 |
s = key->uids->uid; |
s = uid = utf8_to_wincp2 (key->uids->uid); |
144 |
gpgme_data_write (msg, s, strlen (s)); |
gpgme_data_write (msg, s, strlen (s)); |
145 |
gpgme_data_write (msg, "\n", 1); |
gpgme_data_write (msg, "\n", 1); |
146 |
gpgme_key_release (key); |
gpgme_key_release (key); |
147 |
|
free (uid); |
148 |
} |
} |
149 |
} |
} |
150 |
gpgme_data_write (msg, "\0", 1); |
gpgme_data_write (msg, "\0", 1); |
170 |
gpgme_error_t ec; |
gpgme_error_t ec; |
171 |
gpgme_import_result_t import_res = NULL; |
gpgme_import_result_t import_res = NULL; |
172 |
char *rawkey = NULL; |
char *rawkey = NULL; |
|
char msg[384]; |
|
173 |
int rc; |
int rc; |
174 |
|
|
175 |
/* XXX: implement dynamic buffers. */ |
/* XXX: implement dynamic buffers. */ |
227 |
/* if we use the refresh mode, a lot of keys will be fetched and thus only |
/* if we use the refresh mode, a lot of keys will be fetched and thus only |
228 |
a summarize at the end is presented and not for each key. */ |
a summarize at the end is presented and not for each key. */ |
229 |
if (!(flags & KM_KS_REFRESH)) { |
if (!(flags & KM_KS_REFRESH)) { |
230 |
if (import_res && import_res->considered > 1) |
show_imported_keys (import_res); |
|
show_imported_keys (import_res); |
|
231 |
if (import_res && import_res->unchanged == import_res->considered) { |
if (import_res && import_res->unchanged == import_res->considered) { |
232 |
_snprintf (msg, DIM (msg)-1, |
rc = WPTERR_GENERAL; /* no keys updated. */ |
|
_("Key '%s' successfully received but nothing was changed."), pattern ); |
|
|
status_box (dlg, msg, _("GnuPG Status")); |
|
|
rc = WPTERR_GENERAL; |
|
233 |
goto leave; |
goto leave; |
234 |
} |
} |
|
_snprintf (msg, DIM (msg)-1, _("Key '%s' sucessfully received and imported."), pattern); |
|
|
status_box (dlg, msg, _("GnuPG Status")); |
|
235 |
} |
} |
236 |
|
|
237 |
leave: |
leave: |
238 |
free_if_alloc (rawkey); |
free_if_alloc (rawkey); |
239 |
gpgme_release (ctx); |
gpgme_release (ctx); |