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

Contents of /trunk/Src/wptKeyserverSearchDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Mon Jan 31 11:02:21 2005 UTC (20 years, 1 month ago) by twoaday
File size: 4411 byte(s)
WinPT initial checkin.


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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26