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 |
|
|
#ifdef HAVE_CONFIG_H |
21 |
|
|
#include <config.h> |
22 |
|
|
#endif |
23 |
|
|
|
24 |
|
|
#include <windows.h> |
25 |
|
|
|
26 |
werner |
47 |
#include "resource.h" |
27 |
werner |
36 |
#include "wptGPG.h" |
28 |
|
|
#include "wptW32API.h" |
29 |
|
|
#include "wptTypes.h" |
30 |
|
|
#include "wptNLS.h" |
31 |
|
|
#include "wptVersion.h" |
32 |
|
|
#include "wptCommonCtl.h" |
33 |
|
|
#include "wptKeylist.h" |
34 |
|
|
#include "wptTypes.h" |
35 |
|
|
#include "wptKeyserver.h" |
36 |
twoaday |
271 |
#include "wptErrors.h" |
37 |
werner |
36 |
|
38 |
twoaday |
219 |
static verlist_ctrl_t dlg_vlv = NULL; |
39 |
werner |
36 |
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 |
twoaday |
219 |
static verlist_ctrl_t vlv = NULL; |
48 |
werner |
36 |
|
49 |
twoaday |
85 |
switch (msg) { |
50 |
werner |
36 |
case WM_INITDIALOG: |
51 |
|
|
SetWindowText (dlg, _("File Verify")); |
52 |
|
|
SetDlgItemText (dlg, IDC_VERIFY_SAVE, _("&Save")); |
53 |
twoaday |
219 |
verlist_build (&vlv, GetDlgItem (dlg, IDC_VERIFY_SIGLIST), 1); |
54 |
|
|
verlist_set_info_control (vlv, GetDlgItem (dlg, IDC_VERIFY_INFO)); |
55 |
werner |
36 |
EnableWindow (GetDlgItem (dlg, IDC_VERIFY_SAVE), FALSE); |
56 |
twoaday |
247 |
ShowWindow (GetDlgItem (dlg, IDC_VERIFY_SIGNOT), SW_HIDE); |
57 |
werner |
36 |
SetForegroundWindow (dlg); |
58 |
twoaday |
219 |
dlg_vlv = vlv; |
59 |
werner |
36 |
dlg_wnd = dlg; |
60 |
|
|
return TRUE; |
61 |
|
|
|
62 |
|
|
case WM_DESTROY: |
63 |
twoaday |
219 |
if (vlv) { |
64 |
|
|
verlist_delete (vlv); |
65 |
|
|
vlv = NULL; |
66 |
werner |
36 |
} |
67 |
twoaday |
219 |
dlg_vlv = NULL; |
68 |
werner |
36 |
dlg_wnd = NULL; |
69 |
|
|
return FALSE; |
70 |
|
|
|
71 |
|
|
case WM_COMMAND: |
72 |
|
|
switch (LOWORD (wparam)) { |
73 |
twoaday |
219 |
case IDCANCEL: |
74 |
|
|
EndDialog (dlg, FALSE); |
75 |
|
|
break; |
76 |
|
|
|
77 |
werner |
36 |
case IDOK: |
78 |
|
|
if (dlg_event) |
79 |
|
|
SetEvent (dlg_event); |
80 |
|
|
EndDialog (dlg, TRUE); |
81 |
|
|
return TRUE; |
82 |
|
|
} |
83 |
|
|
break; |
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
return FALSE; |
87 |
twoaday |
32 |
} |
88 |
werner |
36 |
|
89 |
|
|
|
90 |
|
|
/* Thread which spawns the verify dialog. */ |
91 |
|
|
static DWORD CALLBACK |
92 |
|
|
file_verify_dlg_thread (void *opaque) |
93 |
|
|
{ |
94 |
twoaday |
68 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_VERIFY, |
95 |
|
|
GetActiveWindow(), file_verify_dlg_proc, 0); |
96 |
werner |
36 |
if (dlg_event) { |
97 |
|
|
CloseHandle (dlg_event); |
98 |
|
|
dlg_event = NULL; |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
ExitThread (0); |
102 |
|
|
return 0; |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
|
106 |
|
|
/* Create the verify dialog asynchronly. */ |
107 |
|
|
int |
108 |
|
|
file_verify_create_dlg (void) |
109 |
|
|
{ |
110 |
|
|
DWORD tid; |
111 |
|
|
HANDLE thread_hd; |
112 |
|
|
SECURITY_ATTRIBUTES sec_attr; |
113 |
|
|
|
114 |
|
|
if (dlg_wnd) |
115 |
|
|
return 0; |
116 |
|
|
|
117 |
|
|
memset (&sec_attr, 0, sizeof (sec_attr)); |
118 |
|
|
sec_attr.bInheritHandle = FALSE; |
119 |
|
|
sec_attr.lpSecurityDescriptor = NULL; |
120 |
|
|
sec_attr.nLength = sizeof (sec_attr); |
121 |
twoaday |
195 |
|
122 |
|
|
if (dlg_event == NULL) |
123 |
|
|
dlg_event = CreateEvent (&sec_attr, TRUE, FALSE, NULL); |
124 |
|
|
|
125 |
werner |
36 |
thread_hd = CreateThread (&sec_attr, 0, file_verify_dlg_thread, NULL, 0, &tid); |
126 |
|
|
if (thread_hd == NULL) { |
127 |
|
|
msg_box (NULL, "Could not create verify thread.", _("Verify"), MB_ERR); |
128 |
|
|
return -1; |
129 |
|
|
} |
130 |
|
|
|
131 |
|
|
return 0; |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
|
135 |
|
|
/* Add the signature + information in @c to the verify dialog. */ |
136 |
|
|
void |
137 |
|
|
file_verify_add_state (file_sig_ctx_t c) |
138 |
|
|
{ |
139 |
twoaday |
219 |
if (!dlg_vlv) |
140 |
twoaday |
195 |
return; |
141 |
|
|
ResetEvent (dlg_event); |
142 |
twoaday |
219 |
verlist_add_sig_log (dlg_vlv, c); |
143 |
werner |
36 |
} |
144 |
|
|
|
145 |
|
|
|
146 |
|
|
/* Wait until the verify event is signaled. */ |
147 |
|
|
void |
148 |
|
|
file_verify_wait (void) |
149 |
|
|
{ |
150 |
|
|
WaitForSingleObject (dlg_event, INFINITE); |
151 |
|
|
} |