1 |
/* wptKeyserverDlg.cpp - Keyserver dialog |
/* wptKeyserverDlg.cpp - Keyserver dialog |
2 |
* Copyright (C) 2000-2005 Timo Schulz |
* Copyright (C) 2000-2006 Timo Schulz |
3 |
* Copyright (C) 2005 g10 Code GmbH |
* Copyright (C) 2005 g10 Code GmbH |
4 |
* |
* |
5 |
* This file is part of WinPT. |
* This file is part of WinPT. |
35 |
#include "wptW32API.h" |
#include "wptW32API.h" |
36 |
#include "wptVersion.h" |
#include "wptVersion.h" |
37 |
#include "wptGPG.h" |
#include "wptGPG.h" |
38 |
|
#include "wptGPGME.h" |
39 |
#include "wptKeyManager.h" |
#include "wptKeyManager.h" |
40 |
#include "wptContext.h" /* for passphrase_s */ |
#include "wptContext.h" /* for passphrase_s */ |
41 |
#include "wptDlgs.h" |
#include "wptDlgs.h" |
77 |
int |
int |
78 |
hkp_send_key (HWND dlg, const char *kserver, WORD port, const char *pattern) |
hkp_send_key (HWND dlg, const char *kserver, WORD port, const char *pattern) |
79 |
{ |
{ |
80 |
gpgme_ctx_t ctx; |
GPGME *gpg; |
|
gpgme_data_t keydata; |
|
81 |
gpgme_error_t ec; |
gpgme_error_t ec; |
82 |
char *rawkey = NULL; |
char *rawkey = NULL; |
83 |
char msg[384]; |
char msg[384]; |
|
size_t n; |
|
84 |
|
|
85 |
ec = gpgme_new (&ctx); |
gpg = new GPGME (); |
86 |
if (ec) |
gpg->setArmor (true); |
87 |
BUG (NULL); |
ec = gpg->exportToBuffer (pattern, &rawkey); |
|
gpgme_set_armor (ctx, 1); |
|
|
ec = gpgme_data_new (&keydata); |
|
|
if (ec) |
|
|
BUG (NULL); |
|
|
ec = gpgme_op_export (ctx, pattern, 0, keydata); |
|
88 |
if (ec) { |
if (ec) { |
89 |
msg_box (dlg, gpgme_strerror (ec), _("Export"), MB_ERR); |
msg_box (dlg, gpgme_strerror (ec), _("Export"), MB_ERR); |
90 |
goto leave; |
goto leave; |
91 |
} |
} |
92 |
rawkey = gpgme_data_release_and_get_mem (keydata, &n); |
ec = kserver_sendkey (kserver, port, rawkey, strlen (rawkey)); |
|
ec = kserver_sendkey (kserver, port, rawkey, n); |
|
93 |
if (ec) { |
if (ec) { |
94 |
hkp_err_box (dlg, kserver, port, ec); |
hkp_err_box (dlg, kserver, port, ec); |
95 |
goto leave; |
goto leave; |
99 |
status_box (dlg, msg, _("GnuPG status")); |
status_box (dlg, msg, _("GnuPG status")); |
100 |
|
|
101 |
leave: |
leave: |
102 |
gpgme_release (ctx); |
delete gpg; |
103 |
if (rawkey) |
free_if_alloc (rawkey); |
|
gpgme_free (rawkey); |
|
104 |
return ec? -1 : 0; |
return ec? -1 : 0; |
105 |
} |
} |
106 |
|
|
297 |
|
|
298 |
leave: |
leave: |
299 |
return rc; |
return rc; |
300 |
} /* check_pattern */ |
} |
301 |
|
|
302 |
|
|
303 |
/* Return human readable name for the proxy protocol. */ |
/* Return human readable name for the proxy protocol. */ |
307 |
const char *s; |
const char *s; |
308 |
|
|
309 |
switch (proto) { |
switch (proto) { |
310 |
case PROXY_PROTO_HTTP: s = "HTTP"; break; |
case PROXY_PROTO_NONE: s = ""; break; |
311 |
case PROXY_PROTO_SOCKS5: s = "SOCKS5"; break; |
case PROXY_PROTO_HTTP: s = "HTTP"; break; |
312 |
default: s= "HTTP"; break; |
case PROXY_PROTO_SOCKS5: s = "SOCKS5"; break; |
313 |
|
default: s= "HTTP"; break; |
314 |
} |
} |
315 |
return s; |
return s; |
316 |
} |
} |
317 |
|
|
318 |
|
|
319 |
|
/* Format the proxy host and display it in the dialog. */ |
320 |
static void |
static void |
321 |
set_proxy (HWND dlg) |
set_proxy (HWND dlg) |
322 |
{ |
{ |
722 |
return FALSE; |
return FALSE; |
723 |
} |
} |
724 |
if (proto_nr == KSPROTO_LDAP && strchr (pattern, '@')) { |
if (proto_nr == KSPROTO_LDAP && strchr (pattern, '@')) { |
725 |
msg_box (dlg, _("Only keyids are allowed."), |
msg_box (dlg, _("Only keyids are allowed."), |
726 |
_("Keyserver"), MB_INFO); |
_("Keyserver"), MB_INFO); |
727 |
return FALSE; |
return FALSE; |
728 |
} |
} |