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

Annotation of /trunk/Src/wptKeyserverSearchDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 105 - (hide annotations)
Wed Nov 30 10:22:00 2005 UTC (19 years, 3 months ago) by twoaday
File size: 4350 byte(s)
Several cleanups and improved translation.


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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26