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

Contents of /trunk/Src/wptKeygenCBDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (show annotations)
Mon Oct 31 21:14:11 2005 UTC (19 years, 4 months ago) by werner
File size: 3042 byte(s)
More changes.  Compiles again but there are at least gettext issues with
w32-gettext.c.  I can't get a gpg-error build with ENABLE_NLS.

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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26