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

Annotation of /trunk/Src/wptFileVerifyDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 247 - (hide annotations)
Fri Jul 21 08:19:24 2006 UTC (18 years, 7 months ago) by twoaday
File size: 4510 byte(s)


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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26