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

Annotation of /trunk/Src/wptKeyserverSearchDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (hide annotations)
Mon Oct 31 21:14:11 2005 UTC (19 years, 4 months ago) by werner
File size: 4333 byte(s)
More changes.  Compiles again but there are at least gettext issues with
w32-gettext.c.  I can't get a gpg-error build with ENABLE_NLS.

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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26