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

Annotation of /trunk/Src/wptFileVerifyDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 219 - (hide annotations)
Sat May 27 08:56:00 2006 UTC (18 years, 9 months ago) by twoaday
File size: 4450 byte(s)
2006-05-25  Timo Schulz  <ts@g10code.de>
                                                                                
        * wptGPGUtil.cpp (gpg_rebuild_cache): Return error code.
        * wptGPGME.cpp (winpt_get_seckey): Fix off-by-one bug.
        * wptVerifyList.cpp (verlist_build): New argument type.
        Change all callers.
        (verlist_set_info_control): New.
        (verlist_set_additional_info): New.
        * wptFileVerifyDlg.cpp (file_verify_dlg_proc): Adjust code.
        * wptClipVerifyDlg.cpp (clip_verify_dlg_proc): Likewise.
        * wptFileCBS.cpp (read_cb, write_cb): Add logging.
                                                                                


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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26