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

Contents of /trunk/Src/wptKeyserverSearchDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (show annotations)
Thu Oct 27 15:25:13 2005 UTC (19 years, 4 months ago) by werner
File size: 4357 byte(s)
First set of changes to use autotools for building.
1 /* wptKeyserverSearchDlg.cpp - Keyserver Searching
2 * Copyright (C) 2001-2005 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
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24
25 #include <windows.h>
26 #include <windows.h>
27 #include <stdio.h>
28
29 #include "../resource.h"
30 #include "wptCommonCtl.h"
31 #include "wptKeyserver.h"
32 #include "wptErrors.h"
33 #include "wptTypes.h"
34 #include "wptGPG.h"
35 #include "wptContext.h" /* for passphrase_s */
36 #include "wptDlgs.h"
37 #include "wptNLS.h"
38
39
40 BOOL CALLBACK
41 hkpsearch_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
42 {
43 static listview_ctrl_t lv = NULL;
44 static keyserver_ctx * ksc;
45 keyserver_key key;
46 struct listview_column_s keysearch[] = {
47 {0, 48, (char *)_("Size")},
48 {1, 64, (char *)_("Key ID")},
49 {2, 72, (char *)_("Creation")},
50 {3, 256, (char *)_("User ID")},
51 {0, 0, NULL}
52 };
53 char t[32], info[384];
54 int i, rc;
55 int conn_fd = 0;
56
57 switch (msg)
58 {
59 case WM_INITDIALOG:
60 ksc = (keyserver_ctx *)lparam;
61 if (!ksc)
62 dlg_fatal_error (dlg, "Could not get dialog param.");
63 #ifndef LANG_DE
64 SetWindowText (dlg, _("Keyserver Searching"));
65 #endif
66 SetDlgItemText (dlg, IDC_HKPSEARCH_RECV, _("&Receive"));
67 _snprintf (info, sizeof (info) - 1,
68 _("Connect to '%s' to search for \"%s\""),
69 ksc->name, ksc->pattern);
70 SetDlgItemText (dlg, IDC_HKPSEARCH_INFO, info);
71 listview_new (&lv);
72 lv->ctrl = GetDlgItem (dlg, IDC_HKPSEARCH_LIST);
73 for (i = 0; keysearch[i].width; i++)
74 listview_add_column (lv, &keysearch[i]);
75 listview_set_ext_style (lv);
76 rc = kserver_search_init (ksc->name, ksc->port, ksc->pattern, &conn_fd);
77 if (rc) {
78 msg_box (dlg, winpt_strerror (rc), _("Keyserver - search init"), MB_ERR);
79 EndDialog (dlg, FALSE);
80 return FALSE;
81 }
82 rc = kserver_search_chkresp (conn_fd);
83 if (rc) {
84 msg_box (dlg, winpt_strerror (rc), _("Keyserver - check response"), MB_ERR);
85 closesocket (conn_fd);
86 EndDialog (dlg, FALSE);
87 return FALSE;
88 }
89 for (;;) {
90 rc = kserver_search (conn_fd, &key);
91 if (rc)
92 break;
93 if (!key.bits)
94 continue;
95 _snprintf (t, sizeof (t) - 1, "%d", key.bits);
96 listview_add_item (lv, " ");
97 listview_add_sub_item (lv, 0, 0, t);
98 listview_add_sub_item (lv, 0, 1, key.keyid);
99 listview_add_sub_item (lv, 0, 2, key.date);
100 listview_add_sub_item (lv, 0, 3, key.uid);
101 }
102 closesocket (conn_fd);
103 SetForegroundWindow (dlg);
104 return TRUE;
105
106 case WM_DESTROY:
107 if (lv) {
108 listview_release (lv);
109 lv = NULL;
110 }
111 return FALSE;
112
113 case WM_SYSCOMMAND:
114 if (LOWORD (wparam) == SC_CLOSE)
115 EndDialog (dlg, TRUE);
116 return FALSE;
117
118 case WM_COMMAND:
119 switch (LOWORD (wparam)) {
120 case IDOK:
121 EndDialog (dlg, TRUE);
122 return TRUE;
123
124 case IDCANCEL:
125 EndDialog (dlg, FALSE);
126 return FALSE;
127
128 case IDC_HKPSEARCH_RECV:
129 if ((i = listview_get_curr_pos (lv)) == -1) {
130 msg_box (dlg, _("Please select a key."), _("Keyserver"), MB_ERR);
131 return FALSE;
132 }
133 listview_get_item_text (lv, i, 1, t, sizeof (t) -1);
134 hkp_recv_key (dlg, ksc->name, ksc->port, t, 0, 0);
135 return TRUE;
136 }
137 break;
138 }
139
140 return FALSE;
141 } /* hkpsearch_dlg_proc */

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26