/[winpt]/trunk/Src/wptKeyserverSearchDlg.cpp
ViewVC logotype

Contents of /trunk/Src/wptKeyserverSearchDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 147 - (show annotations)
Fri Jan 13 14:21:16 2006 UTC (19 years, 1 month ago) by twoaday
File size: 4583 byte(s)
2006-11-13  Timo Schulz  <ts@g10code.com>
 
        * wptPreferencesDlg.cpp (prefs_dlg_proc): Changed translation.
        * wptGPGPrefsDlg.cpp (gpgprefs_dlg_proc): Likewise.
        * wptAboutDlgs.cpp (about_dlg_proc): Make sure GPG about
        dialog isn't shown twice.
        * wptKeyCache.cpp (gpg_keycache_next_updated_key): New.
        (gpg_keycache_update_key): Set update flag.
        * wptKeyManagerDlg.cpp (refresh_keylist): New.
        (keymanager_dlg_proc): Use new refresh system for keyservers.
        * wptKeyserverSearchDlg.cpp (kserver_search_dlg_proc):
        Update keycache.
        * wptKeyserverDlg.cpp (hkp_dlg_proc): Likewise.
        * wptKeyserver.cpp (socket_read_ext): New.
        (kserver_recv_key_ext): New.
        (kserver_read_config, kserver_write_config): Removed.
         


1 /* wptKeyserverSearchDlg.cpp - Keyserver Searching
2 * Copyright (C) 2001-2006 Timo Schulz
3 *
4 * This file is part of WinPT.
5 *
6 * WinPT is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * WinPT is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with WinPT; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include <windows.h>
25 #include <stdio.h>
26
27 #include "resource.h"
28 #include "wptCommonCtl.h"
29 #include "wptKeyserver.h"
30 #include "wptErrors.h"
31 #include "wptTypes.h"
32 #include "wptGPG.h"
33 #include "wptContext.h" /* for passphrase_s */
34 #include "wptDlgs.h"
35 #include "wptNLS.h"
36
37
38 int
39 hkp_recv_key2 (HWND dlg, const char *kserver, WORD port,
40 const char *pattern, int proto, char **r_fpr);
41
42
43 /* Dialog box procedur for keyserver searching. */
44 BOOL CALLBACK
45 hkpsearch_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
46 {
47 static listview_ctrl_t lv = NULL;
48 static keyserver_ctx * ksc;
49 keyserver_key key;
50 struct listview_column_s keysearch[] = {
51 {0, 48, (char *)_("Size")},
52 {1, 64, (char *)_("Key ID")},
53 {2, 72, (char *)_("Creation")},
54 {3, 256, (char *)_("User ID")},
55 {0, 0, NULL}
56 };
57 char t[32], info[384], *fpr = NULL;
58 int i, rc;
59 int conn_fd = 0;
60
61 switch (msg) {
62 case WM_INITDIALOG:
63 ksc = (keyserver_ctx *)lparam;
64 if (!ksc)
65 dlg_fatal_error (dlg, "Could not get dialog param.");
66 SetWindowText (dlg, _("Keyserver Searching"));
67 SetDlgItemText (dlg, IDC_HKPSEARCH_RECV, _("&Receive"));
68 SetDlgItemText (dlg, IDOK, _("&Cancel"));
69 _snprintf (info, sizeof (info) - 1,
70 _("Connect to '%s' to search for \"%s\""),
71 ksc->name, ksc->pattern);
72 SetDlgItemText (dlg, IDC_HKPSEARCH_INFO, info);
73 listview_new (&lv);
74 lv->ctrl = GetDlgItem (dlg, IDC_HKPSEARCH_LIST);
75 for (i = 0; keysearch[i].width; i++)
76 listview_add_column (lv, &keysearch[i]);
77 listview_set_ext_style (lv);
78 rc = kserver_search_init (ksc->name, ksc->port, ksc->pattern, &conn_fd);
79 if (rc) {
80 msg_box (dlg, winpt_strerror (rc), _("Keyserver Search"), MB_ERR);
81 EndDialog (dlg, FALSE);
82 return FALSE;
83 }
84 rc = kserver_search_chkresp (conn_fd);
85 if (rc) {
86 msg_box (dlg, winpt_strerror (rc), _("Keyserver Search"), MB_ERR);
87 closesocket (conn_fd);
88 EndDialog (dlg, FALSE);
89 return FALSE;
90 }
91 for (;;) {
92 rc = kserver_search (conn_fd, &key);
93 if (rc)
94 break;
95 if (!key.bits)
96 continue;
97 _snprintf (t, sizeof (t) - 1, "%d", key.bits);
98 listview_add_item (lv, " ");
99 listview_add_sub_item (lv, 0, 0, t);
100 listview_add_sub_item (lv, 0, 1, key.keyid);
101 listview_add_sub_item (lv, 0, 2, key.date);
102 listview_add_sub_item (lv, 0, 3, key.uid);
103 }
104 closesocket (conn_fd);
105 SetForegroundWindow (dlg);
106 return TRUE;
107
108 case WM_DESTROY:
109 if (lv) {
110 listview_release (lv);
111 lv = NULL;
112 }
113 return FALSE;
114
115 case WM_SYSCOMMAND:
116 if (LOWORD (wparam) == SC_CLOSE)
117 EndDialog (dlg, TRUE);
118 return FALSE;
119
120 case WM_COMMAND:
121 switch (LOWORD (wparam)) {
122 case IDOK:
123 EndDialog (dlg, TRUE);
124 return TRUE;
125
126 case IDCANCEL:
127 EndDialog (dlg, FALSE);
128 return FALSE;
129
130 case IDC_HKPSEARCH_RECV:
131 if ((i = listview_get_curr_pos (lv)) == -1) {
132 msg_box (dlg, _("Please select a key."), _("Keyserver Search"), MB_ERR);
133 return FALSE;
134 }
135 listview_get_item_text (lv, i, 1, t, sizeof (t) -1);
136 rc = hkp_recv_key2 (dlg, ksc->name, ksc->port, t, 0, &fpr);
137 if (!rc && fpr != NULL) {
138 keycache_update (0, fpr);
139 free_if_alloc (fpr);
140 }
141 return TRUE;
142 }
143 break;
144 }
145
146 return FALSE;
147 }

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26