1 |
/* wptKeyserverDlg.cpp - Keyserver dialog |
/* wptKeyserverDlg.cpp - Keyserver dialog |
2 |
* Copyright (C) 2000-2006 Timo Schulz |
* Copyright (C) 2000-2007 Timo Schulz |
3 |
* Copyright (C) 2005, 2006 g10 Code GmbH |
* Copyright (C) 2005, 2006 g10 Code GmbH |
4 |
* |
* |
5 |
* This file is part of WinPT. |
* This file is part of WinPT. |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
|
* |
|
|
* You should have received a copy of the GNU General Public License |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
16 |
*/ |
*/ |
17 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
18 |
#include <config.h> |
#include <config.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 *gpg; |
GPGME gpg; |
81 |
gpgme_error_t ec; |
gpgme_error_t ec; |
82 |
char *rawkey = NULL; |
char *rawkey = NULL; |
83 |
char msg[256]; |
char msg[256]; |
84 |
|
|
85 |
gpg = new GPGME (); |
gpg.setArmor (true); |
86 |
gpg->setArmor (true); |
ec = gpg.exportToBuffer (pattern, &rawkey); |
|
ec = gpg->exportToBuffer (pattern, &rawkey); |
|
87 |
if (ec) { |
if (ec) { |
88 |
msg_box (dlg, gpgme_strerror (ec), _("Export"), MB_ERR); |
msg_box (dlg, gpgme_strerror (ec), _("Export"), MB_ERR); |
89 |
goto leave; |
goto leave; |
96 |
goto leave; |
goto leave; |
97 |
} |
} |
98 |
|
|
99 |
_snprintf (msg, sizeof (msg) -1, _("Key '%s' successfully sent"), pattern); |
_snprintf (msg, DIM (msg) -1, _("Key '%s' successfully sent"), pattern); |
100 |
status_box (dlg, msg, _("GnuPG status")); |
status_box (dlg, msg, _("GnuPG status")); |
101 |
|
|
102 |
leave: |
leave: |
|
delete gpg; |
|
103 |
free_if_alloc (rawkey); |
free_if_alloc (rawkey); |
104 |
return ec? -1 : 0; |
return ec? -1 : 0; |
105 |
} |
} |
170 |
{ |
{ |
171 |
gpgme_import_result_t import_res = NULL; |
gpgme_import_result_t import_res = NULL; |
172 |
gpgme_error_t err; |
gpgme_error_t err; |
173 |
GPGME *gpg = NULL; |
GPGME gpg; |
174 |
char *rawkey = NULL; |
char *rawkey = NULL; |
175 |
size_t keylen = 0; |
size_t keylen = 0; |
176 |
int rc; |
int rc; |
207 |
msg_box (dlg, _("This is not a valid OpenPGP key."), |
msg_box (dlg, _("This is not a valid OpenPGP key."), |
208 |
_("Keyserver"), MB_ERR); |
_("Keyserver"), MB_ERR); |
209 |
goto leave; |
goto leave; |
210 |
} |
} |
211 |
gpg = new GPGME (); |
err = gpg.importFromBuffer (rawkey); |
|
err = gpg->importFromBuffer (rawkey); |
|
212 |
if (err) { |
if (err) { |
213 |
msg_box (dlg, gpgme_strerror (err), _("Import"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Import"), MB_ERR); |
214 |
goto leave; |
goto leave; |
215 |
} |
} |
216 |
import_res = gpg->importGetResult (); |
import_res = gpg.importGetResult (); |
217 |
if (import_res && r_fpr) |
if (import_res && r_fpr) |
218 |
*r_fpr = m_strdup (import_res->imports->fpr); |
*r_fpr = m_strdup (import_res->imports->fpr); |
219 |
|
|
229 |
|
|
230 |
leave: |
leave: |
231 |
free_if_alloc (rawkey); |
free_if_alloc (rawkey); |
|
if (gpg != NULL) |
|
|
delete gpg; |
|
232 |
return rc; |
return rc; |
233 |
} |
} |
234 |
|
|
695 |
notify = (NMHDR *)lparam; |
notify = (NMHDR *)lparam; |
696 |
if (!notify) |
if (!notify) |
697 |
break; |
break; |
698 |
if (notify->code == NM_CLICK |
if (notify->code == (UINT)NM_CLICK |
699 |
&& notify->idFrom == IDC_KEYSERVER_LIST) |
&& notify->idFrom == (UINT)IDC_KEYSERVER_LIST) |
700 |
lv_idx = listview_get_curr_pos (lv); |
lv_idx = listview_get_curr_pos (lv); |
701 |
else if (notify->code == NM_RCLICK && |
else if (notify->code == (UINT)NM_RCLICK && |
702 |
notify->idFrom == IDC_KEYSERVER_LIST) { |
notify->idFrom == (UINT)IDC_KEYSERVER_LIST) { |
703 |
POINT p; |
POINT p; |
704 |
GetCursorPos (&p); |
GetCursorPos (&p); |
705 |
HMENU hm, pop; |
HMENU hm, pop; |