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

Annotation of /trunk/Src/wptFileVerifyDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (hide annotations)
Mon Oct 24 08:03:48 2005 UTC (19 years, 4 months ago) by twoaday
File size: 4785 byte(s)
2005-10-23  Timo Schulz  <twoaday@g10code.com>
 
        * wptFileManager.cpp (fm_get_file_type): Detect detached sigs.
        * wptKeyList.cpp (keylist_cmp_cb): Take care of expired/revoked keys.
        (get_ext_validity): New.
        * wptFileVerifyDlg.cpp (file_verify_dlg_proc): Several cleanups.
        * wptClipEditDlg.cpp (load_clipboard): Factored out some code into
        this function.
        (load_clipboard_from_file): Likewise.
        (save_clipboard_to_file): New.
        * wptKeyManagerDlg.cpp (keyprops_dlg_proc): Fix stack overflow.

For complete details, see the ChangeLog files.

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 twoaday 32 static HWND dlg_wnd = NULL; /* handle to the dialog box window */
36     static HANDLE dlg_event = NULL; /* event for the dialog. */
37 twoaday 2
38    
39 twoaday 32 /* Dialog box procedure to show the verify results of a file. */
40 twoaday 2 static BOOL CALLBACK
41     file_verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
42     {
43     static listview_ctrl_t lv = NULL;
44     int rc = 0;
45    
46     switch( msg ) {
47     case WM_INITDIALOG:
48     #ifndef LANG_DE
49     SetWindowText (dlg, _("File Verify"));
50 twoaday 32 SetDlgItemText (dlg, IDC_VERIFY_SAVE, _("&Save"));
51 twoaday 2 #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     return TRUE;
60    
61     case WM_DESTROY:
62     if (lv) {
63     listview_release (lv);
64     lv = NULL;
65     }
66     dlg_lv = NULL;
67     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     listview_get_item_text (lv, listview_get_curr_pos (lv), 4, buf, 63);
78     if (strlen (buf) == 10 && buf[0] == '0' && buf[1] == 'x') {
79 twoaday 32 rc = msg_box (dlg, _("Do you want to retrieve the key?"),
80     _("Verify"), MB_QUEST_ASK);
81 twoaday 2 if (rc == IDYES) {
82 twoaday 32 if (!hkp_recv_key (dlg, default_keyserver,
83     default_keyserver_port, buf, 0, 0))
84 twoaday 2 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 twoaday 32 if (dlg_event)
100 twoaday 2 SetEvent (dlg_event);
101     EndDialog (dlg, TRUE);
102     return TRUE;
103     }
104     break;
105     }
106    
107     return FALSE;
108 twoaday 32 }
109 twoaday 2
110    
111 twoaday 32 /* Thread which spawns the verify dialog. */
112 twoaday 2 static DWORD CALLBACK
113     file_verify_dlg_thread (void *opaque)
114     {
115     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_VERIFY, GetActiveWindow(),
116     file_verify_dlg_proc, NULL);
117 twoaday 32 if (dlg_event) {
118 twoaday 2 CloseHandle (dlg_event);
119 twoaday 32 dlg_event = NULL;
120 twoaday 2 }
121 twoaday 32
122 twoaday 2 ExitThread (0);
123     return 0;
124 twoaday 32 }
125 twoaday 2
126    
127 twoaday 32 /* Create the verify dialog asynchronly. */
128 twoaday 2 int
129     file_verify_create_dlg (void)
130     {
131     DWORD tid;
132     HANDLE thread_hd;
133     SECURITY_ATTRIBUTES sec_attr;
134    
135 twoaday 32 if (dlg_wnd)
136 twoaday 2 return 0;
137    
138     memset (&sec_attr, 0, sizeof (sec_attr));
139     sec_attr.bInheritHandle = FALSE;
140     sec_attr.lpSecurityDescriptor = NULL;
141     sec_attr.nLength = sizeof (sec_attr);
142     thread_hd = CreateThread (&sec_attr, 0, file_verify_dlg_thread, NULL, 0, &tid);
143     if (thread_hd == NULL) {
144     msg_box (NULL, "Could not create verify thread.", _("Verify"), MB_ERR);
145 twoaday 32 return -1;
146 twoaday 2 }
147    
148     return 0;
149 twoaday 32 }
150 twoaday 2
151    
152 twoaday 32 /* Add the signature + information in @c to the verify dialog. */
153     void
154 twoaday 25 file_verify_add_state (file_sig_ctx_t c)
155 twoaday 2 {
156     if (dlg_lv)
157 twoaday 32 verlist_add_sig_log (dlg_lv, c);
158     }
159 twoaday 2
160    
161 twoaday 32 /* Create an event for the verify dialog. */
162 twoaday 2 void
163     file_verify_use_event (void)
164     {
165     SECURITY_ATTRIBUTES sec_attr;
166    
167     memset (&sec_attr, 0, sizeof (sec_attr));
168     sec_attr.bInheritHandle = FALSE;
169     sec_attr.nLength = sizeof (sec_attr);
170     dlg_event = CreateEvent (&sec_attr, TRUE, FALSE, NULL);
171 twoaday 32 }
172 twoaday 2
173    
174 twoaday 32 /* Wait until the verify event is signaled. */
175 twoaday 2 void
176     file_verify_wait (void)
177     {
178     WaitForSingleObject (dlg_event, INFINITE);
179 twoaday 32 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26