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

Contents of /trunk/Src/wptFileVerifyDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 328 - (show annotations)
Fri Sep 25 16:07:38 2009 UTC (15 years, 5 months ago) by twoaday
File size: 3747 byte(s)


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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26