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

Annotation of /trunk/Src/wptFileVerifyDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 68 - (hide annotations)
Sat Nov 5 12:00:55 2005 UTC (19 years, 3 months ago) by twoaday
File size: 4637 byte(s)
More minor changes to avoid GCC warnings.


1 werner 36 /* wptVerifyFileDlg.cpp - (File Manager) Verify file
2     * Copyright (C) 2001, 2002, 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    
27 werner 47 #include "resource.h"
28 werner 36 #include "wptGPG.h"
29     #include "wptW32API.h"
30     #include "wptTypes.h"
31     #include "wptNLS.h"
32     #include "wptVersion.h"
33     #include "wptCommonCtl.h"
34     #include "wptKeylist.h"
35     #include "wptTypes.h"
36     #include "wptKeyserver.h"
37    
38     static listview_ctrl_t dlg_lv = NULL;
39     static HWND dlg_wnd = NULL; /* handle to the dialog box window */
40     static HANDLE dlg_event = NULL; /* event for the dialog. */
41    
42    
43     /* Dialog box procedure to show the verify results of a file. */
44     static BOOL CALLBACK
45     file_verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
46     {
47     static listview_ctrl_t lv = NULL;
48     int rc = 0;
49    
50     switch( msg ) {
51     case WM_INITDIALOG:
52     #ifndef LANG_DE
53     SetWindowText (dlg, _("File Verify"));
54     SetDlgItemText (dlg, IDC_VERIFY_SAVE, _("&Save"));
55     #endif
56     rc = verlist_build (&lv, GetDlgItem (dlg, IDC_VERIFY_SIGLIST), 1);
57     if (rc)
58     BUG (dlg);
59     EnableWindow (GetDlgItem (dlg, IDC_VERIFY_SAVE), FALSE);
60     SetForegroundWindow (dlg);
61     dlg_lv = lv;
62     dlg_wnd = dlg;
63     return TRUE;
64    
65     case WM_DESTROY:
66     if (lv) {
67     listview_release (lv);
68     lv = NULL;
69     }
70     dlg_lv = NULL;
71     dlg_wnd = NULL;
72     return FALSE;
73    
74     case WM_NOTIFY:
75     NMHDR *notify;
76    
77     notify = (NMHDR *)lparam;
78     if (notify && notify->code == NM_DBLCLK &&
79     notify->idFrom == IDC_VERIFY_SIGLIST) {
80     char buf[64];
81     listview_get_item_text (lv, listview_get_curr_pos (lv), 4, buf, 63);
82     if (strlen (buf) == 10 && buf[0] == '0' && buf[1] == 'x') {
83     rc = msg_box (dlg, _("Do you want to retrieve the key?"),
84     _("Verify"), MB_QUEST_ASK);
85     if (rc == IDYES) {
86     if (!hkp_recv_key (dlg, default_keyserver,
87     default_keyserver_port, buf, 0, 0))
88     keycache_reload (dlg);
89     }
90     }
91    
92     }
93     break;
94    
95     case WM_SYSCOMMAND:
96     if (LOWORD (wparam) == SC_CLOSE)
97     EndDialog (dlg, TRUE);
98     return FALSE;
99    
100     case WM_COMMAND:
101     switch (LOWORD (wparam)) {
102     case IDOK:
103     if (dlg_event)
104     SetEvent (dlg_event);
105     EndDialog (dlg, TRUE);
106     return TRUE;
107     }
108     break;
109     }
110    
111     return FALSE;
112 twoaday 32 }
113 werner 36
114    
115     /* Thread which spawns the verify dialog. */
116     static DWORD CALLBACK
117     file_verify_dlg_thread (void *opaque)
118     {
119 twoaday 68 DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_VERIFY,
120     GetActiveWindow(), file_verify_dlg_proc, 0);
121 werner 36 if (dlg_event) {
122     CloseHandle (dlg_event);
123     dlg_event = NULL;
124     }
125    
126     ExitThread (0);
127     return 0;
128     }
129    
130    
131     /* Create the verify dialog asynchronly. */
132     int
133     file_verify_create_dlg (void)
134     {
135     DWORD tid;
136     HANDLE thread_hd;
137     SECURITY_ATTRIBUTES sec_attr;
138    
139     if (dlg_wnd)
140     return 0;
141    
142     memset (&sec_attr, 0, sizeof (sec_attr));
143     sec_attr.bInheritHandle = FALSE;
144     sec_attr.lpSecurityDescriptor = NULL;
145     sec_attr.nLength = sizeof (sec_attr);
146     thread_hd = CreateThread (&sec_attr, 0, file_verify_dlg_thread, NULL, 0, &tid);
147     if (thread_hd == NULL) {
148     msg_box (NULL, "Could not create verify thread.", _("Verify"), MB_ERR);
149     return -1;
150     }
151    
152     return 0;
153     }
154    
155    
156     /* Add the signature + information in @c to the verify dialog. */
157     void
158     file_verify_add_state (file_sig_ctx_t c)
159     {
160     if (dlg_lv)
161     verlist_add_sig_log (dlg_lv, c);
162     }
163    
164    
165     /* Create an event for the verify dialog. */
166     void
167     file_verify_use_event (void)
168     {
169     SECURITY_ATTRIBUTES sec_attr;
170    
171     memset (&sec_attr, 0, sizeof (sec_attr));
172     sec_attr.bInheritHandle = FALSE;
173     sec_attr.nLength = sizeof (sec_attr);
174     dlg_event = CreateEvent (&sec_attr, TRUE, FALSE, NULL);
175     }
176    
177    
178     /* Wait until the verify event is signaled. */
179     void
180     file_verify_wait (void)
181     {
182     WaitForSingleObject (dlg_event, INFINITE);
183     }

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26