98 |
|
|
99 |
|
|
100 |
int |
int |
101 |
hkp_recv_key (HWND dlg, const char *kserver, u16 port, const char *pattern, int proto, int flags) |
hkp_recv_key (HWND dlg, const char *kserver, u16 port, |
102 |
|
const char *pattern, int proto, int flags) |
103 |
{ |
{ |
104 |
gpgme_ctx_t ctx; |
gpgme_ctx_t ctx; |
105 |
gpgme_data_t keydata; |
gpgme_data_t keydata; |
106 |
gpgme_error_t ec; |
gpgme_error_t ec; |
107 |
int rc, import_res[14]; |
int rc, import_res[14]; |
108 |
char * rawkey = NULL, msg[384]; |
char *rawkey = NULL, msg[384]; |
109 |
|
|
110 |
rawkey = new char[MAX_KEYSIZE]; |
rawkey = new char[MAX_KEYSIZE]; |
111 |
if (!rawkey) |
if (!rawkey) |
127 |
if (rc) { |
if (rc) { |
128 |
log_box (_("Keyserver"), MB_ERR, _("Finger key import failed: %s\n"), |
log_box (_("Keyserver"), MB_ERR, _("Finger key import failed: %s\n"), |
129 |
winpt_strerror (rc)); |
winpt_strerror (rc)); |
130 |
free_if_alloc( rawkey ); |
free_if_alloc (rawkey); |
131 |
return rc; |
return rc; |
132 |
} |
} |
133 |
} |
} |
151 |
msg_box( dlg, gpgme_strerror( (gpgme_error_t)rc ), _("Import"), MB_ERR ); |
msg_box( dlg, gpgme_strerror( (gpgme_error_t)rc ), _("Import"), MB_ERR ); |
152 |
goto leave; |
goto leave; |
153 |
} |
} |
154 |
gpgme_get_import_status( ctx, import_res, NULL ); |
gpgme_get_import_status (ctx, import_res, NULL); |
155 |
} |
} |
156 |
|
|
157 |
/* 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 |
158 |
a summarize at the end is presented and not for each key. */ |
a summarize at the end is presented and not for each key. */ |
159 |
if( !(flags & KM_KS_REFRESH) ) { |
if (!(flags & KM_KS_REFRESH)) { |
160 |
if( import_res[GPGME_IMPSTAT_NPKEYS] == 0 ) { |
if (import_res[GPGME_IMPSTAT_NPKEYS] == 0) { |
161 |
_snprintf( msg, sizeof (msg) - 1, |
_snprintf (msg, DIM (msg)-1, |
162 |
_("Key '%s' successfully received but nothing was changed."), pattern ); |
_("Key '%s' successfully received but nothing was changed."), pattern ); |
163 |
status_box( dlg, msg, _("GnuPG Status") ); |
status_box (dlg, msg, _("GnuPG Status")); |
164 |
rc = WPTERR_GENERAL; |
rc = WPTERR_GENERAL; |
165 |
goto leave; |
goto leave; |
166 |
} |
} |
167 |
_snprintf( msg, sizeof (msg) - 1, _("Key '%s' sucessfully received and imported."), pattern ); |
_snprintf (msg, DIM (msg)-1, _("Key '%s' sucessfully received and imported."), pattern); |
168 |
status_box( dlg, msg, _("GnuPG Status") ); |
status_box (dlg, msg, _("GnuPG Status")); |
169 |
} |
} |
170 |
|
|
171 |
leave: |
leave: |
361 |
SetDlgItemText( dlg, IDC_KEYSERVER_SEND, |
SetDlgItemText( dlg, IDC_KEYSERVER_SEND, |
362 |
_("Send key (default is receiving)") ); |
_("Send key (default is receiving)") ); |
363 |
SetDlgItemText( dlg, IDC_KEYSERVER_INFO, |
SetDlgItemText( dlg, IDC_KEYSERVER_INFO, |
364 |
_("Please enter the key ID or email address that belongs to the key")); |
_("Please enter the key ID or email address you search for")); |
365 |
SetDlgItemText( dlg, IDC_KEYSERVER_INDEX, _("&Search") ); |
SetDlgItemText( dlg, IDC_KEYSERVER_INDEX, _("&Search") ); |
366 |
#endif |
#endif |
367 |
set_proxy (dlg); |
set_proxy (dlg); |
449 |
msg_box( dlg, _("Only keyids are allowed."), _("LDAP Keyserver"), MB_INFO ); |
msg_box( dlg, _("Only keyids are allowed."), _("LDAP Keyserver"), MB_INFO ); |
450 |
return FALSE; |
return FALSE; |
451 |
} |
} |
452 |
else if( proto_nr == KSPROTO_FINGER && |
else if (proto_nr == KSPROTO_FINGER) { |
453 |
( strchr( pattern, '@' ) || strchr( pattern, ' ' ) ) ) { |
if (strchr (pattern, '@') || strchr (pattern, ' ')) { |
454 |
msg_box( dlg, _("Only enter the name of the user."), _("FINGER Keyserver"), MB_INFO ); |
msg_box (dlg, _("Only enter the name of the user."), _("FINGER Keyserver"), MB_INFO); |
455 |
return FALSE; |
return FALSE; |
456 |
|
} |
457 |
} |
} |
458 |
else if( check_pattern( pattern ) ) { |
else if( check_pattern( pattern ) ) { |
459 |
msg_box( dlg, _("Only email addresses or keyids are allowed."), _("Keyserver"), MB_INFO ); |
msg_box( dlg, _("Only email addresses or keyids are allowed."), _("HKP Keyserver"), MB_INFO ); |
460 |
return FALSE; |
return FALSE; |
461 |
} |
} |
462 |
rc = hkp_recv_key (dlg, kserver, kserver_get_port (lv), pattern, proto_nr, 0); |
rc = hkp_recv_key (dlg, kserver, kserver_get_port (lv), pattern, proto_nr, 0); |