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

Annotation of /trunk/Src/wptKeygenCBDlg.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: 3116 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 /* wptKeygenDlg.cpp - Key callback generation dialog
2 twoaday 23 * Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz
3 twoaday 2 *
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 "wptTypes.h"
25     #include "wptW32API.h"
26     #include "wptVersion.h"
27     #include "wptNLS.h"
28     #include "wptErrors.h"
29    
30 twoaday 23 /* Handle to the progress dialog. */
31 twoaday 2 static HWND dlg_hwnd = NULL;
32    
33    
34 twoaday 23 /* Dialog box param for the keygen progress. */
35 twoaday 2 static BOOL CALLBACK
36 twoaday 23 keygen_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
37 twoaday 2 {
38 twoaday 23 switch (msg) {
39 twoaday 2 case WM_INITDIALOG:
40 twoaday 32 SetDlgItemText (dlg, IDC_KEYPROG_CB, "");
41     SetForegroundWindow (dlg);
42     center_window (dlg, NULL);
43 twoaday 2 dlg_hwnd = dlg;
44     return TRUE;
45 twoaday 23
46     case WM_DESTROY:
47     dlg_hwnd = NULL;
48 twoaday 32 break;
49 twoaday 2 }
50    
51     return FALSE;
52 twoaday 23 }
53 twoaday 2
54    
55 twoaday 23 /* Thread to start the progress dialog (async). */
56 twoaday 2 static DWORD WINAPI
57 twoaday 23 keygen_cb_thread (void *opaque)
58 twoaday 2 {
59 twoaday 32 DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYPROG,
60     GetActiveWindow (), keygen_cb_dlg_proc, NULL);
61 twoaday 23 ExitThread (0);
62 twoaday 2 return 0;
63 twoaday 23 }
64 twoaday 2
65    
66 twoaday 23 /* Create the progress thread. */
67 twoaday 2 int
68 twoaday 23 keygen_cb_dlg_create (void)
69 twoaday 2 {
70     DWORD tid;
71     HANDLE thread_hd;
72     SECURITY_ATTRIBUTES sec_attr;
73    
74 twoaday 23 memset (&sec_attr, 0, sizeof sec_attr);
75 twoaday 2 sec_attr.bInheritHandle = FALSE;
76     sec_attr.lpSecurityDescriptor = NULL;
77     sec_attr.nLength = sizeof sec_attr;
78 twoaday 23 thread_hd = CreateThread (&sec_attr, 0, keygen_cb_thread, NULL, 0, &tid);
79     if (!thread_hd) {
80 twoaday 32 msg_box (NULL, "Could not create key generation thread",
81     _("Key Generation"), MB_ERR);
82 twoaday 2 return WPTERR_GENERAL;
83     }
84    
85     return 0;
86 twoaday 23 }
87 twoaday 2
88 twoaday 32
89 twoaday 23 /* Destroy the progress dialog and cleanup. */
90 twoaday 2 void
91 twoaday 23 keygen_cb_dlg_destroy (void)
92 twoaday 2 {
93 twoaday 23 if (dlg_hwnd) {
94     EndDialog (dlg_hwnd, TRUE);
95 twoaday 2 dlg_hwnd = NULL;
96     }
97 twoaday 23 }
98 twoaday 2
99    
100 twoaday 23 /* GPGME progress callback function. */
101 twoaday 2 void
102 twoaday 23 keygen_cb (void * opaque, const char * what, int type, int curretn, int total)
103 twoaday 2 {
104     static char cb[8192] = {0};
105     static int cb_pos = 0;
106    
107     if (!opaque && !what && !type && !curretn && !total) {
108     memset (cb, 0, sizeof cb);
109     cb_pos = 0;
110     return;
111     }
112    
113     if (cb_pos >= (DIM (cb)-1))
114     cb_pos = 0;
115     cb[cb_pos] = (char)type;
116     cb_pos++;
117     cb[cb_pos] = '\0';
118    
119     SetDlgItemText (dlg_hwnd, IDC_KEYPROG_CB, cb);
120 twoaday 23 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26