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

Annotation of /trunk/Src/wptFileVerifyDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (hide annotations)
Wed Oct 12 10:04:26 2005 UTC (19 years, 4 months ago) by twoaday
File size: 4650 byte(s)
First testing phase finished.
Provide bug fixes for a lot of (minor) problems.

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26