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

Diff of /trunk/Src/wptKeygenCBDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 35 by twoaday, Mon Oct 24 08:03:48 2005 UTC revision 36 by werner, Thu Oct 27 15:25:13 2005 UTC
# Line 1  Line 1 
1  /* wptKeygenDlg.cpp - Key callback generation dialog  /* wptKeygenDlg.cpp - Key callback generation dialog
2   *      Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz   *      Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
6   * WinPT is free software; you can redistribute it and/or modify   * 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   * 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   * the Free Software Foundation; either version 2 of the License, or
9   * (at your option) any later version.   * (at your option) any later version.
10   *   *
11   * WinPT is distributed in the hope that it will be useful,   * WinPT is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.   * GNU General Public License for more details.
15   *   *
16   * You should have received a copy of the GNU General Public License   * You should have received a copy of the GNU General Public License
17   * along with WinPT; if not, write to the Free Software Foundation,   * along with WinPT; if not, write to the Free Software Foundation,
18   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19   */   */
20    
21  #include <windows.h>  #ifdef HAVE_CONFIG_H
22    #include <config.h>
23  #include "../resource.h"  #endif
24  #include "wptTypes.h"  
25  #include "wptW32API.h"  #include <windows.h>
26  #include "wptVersion.h"  #include <windows.h>
27  #include "wptNLS.h"  
28  #include "wptErrors.h"  #include "../resource.h"
29    #include "wptTypes.h"
30  /* Handle to the progress dialog. */  #include "wptW32API.h"
31  static HWND dlg_hwnd = NULL;  #include "wptVersion.h"
32    #include "wptNLS.h"
33    #include "wptErrors.h"
34  /* Dialog box param for the keygen progress. */  
35  static BOOL CALLBACK  /* Handle to the progress dialog. */
36  keygen_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  static HWND dlg_hwnd = NULL;
37  {  
38      switch (msg) {  
39      case WM_INITDIALOG:  /* Dialog box param for the keygen progress. */
40          SetDlgItemText (dlg, IDC_KEYPROG_CB, "");  static BOOL CALLBACK
41          SetForegroundWindow (dlg);  keygen_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
42          center_window (dlg, NULL);  {
43          dlg_hwnd = dlg;      switch (msg) {
44          return TRUE;      case WM_INITDIALOG:
45            SetDlgItemText (dlg, IDC_KEYPROG_CB, "");
46      case WM_DESTROY:          SetForegroundWindow (dlg);
47          dlg_hwnd = NULL;          center_window (dlg, NULL);
48          break;          dlg_hwnd = dlg;
49      }          return TRUE;
50        
51      return FALSE;      case WM_DESTROY:
52  }          dlg_hwnd = NULL;
53            break;
54        }
55  /* Thread to start the progress dialog (async). */      
56  static DWORD WINAPI      return FALSE;
57  keygen_cb_thread (void *opaque)  }
58  {  
59      DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYPROG,  
60                      GetActiveWindow (), keygen_cb_dlg_proc, NULL);  /* Thread to start the progress dialog (async). */
61      ExitThread (0);  static DWORD WINAPI
62      return 0;  keygen_cb_thread (void *opaque)
63  }  {
64        DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYPROG,
65                        GetActiveWindow (), keygen_cb_dlg_proc, NULL);
66  /* Create the progress thread. */      ExitThread (0);
67  int      return 0;
68  keygen_cb_dlg_create (void)  }
69  {  
70      DWORD tid;  
71      HANDLE thread_hd;  /* Create the progress thread. */
72      SECURITY_ATTRIBUTES sec_attr;  int
73        keygen_cb_dlg_create (void)
74      memset (&sec_attr, 0, sizeof sec_attr);  {
75      sec_attr.bInheritHandle = FALSE;      DWORD tid;
76      sec_attr.lpSecurityDescriptor = NULL;      HANDLE thread_hd;
77      sec_attr.nLength = sizeof sec_attr;      SECURITY_ATTRIBUTES sec_attr;
78      thread_hd = CreateThread (&sec_attr, 0, keygen_cb_thread, NULL, 0, &tid);      
79      if (!thread_hd) {      memset (&sec_attr, 0, sizeof sec_attr);
80          msg_box (NULL, "Could not create key generation thread",      sec_attr.bInheritHandle = FALSE;
81                   _("Key Generation"), MB_ERR);      sec_attr.lpSecurityDescriptor = NULL;
82          return WPTERR_GENERAL;      sec_attr.nLength = sizeof sec_attr;
83      }        thread_hd = CreateThread (&sec_attr, 0, keygen_cb_thread, NULL, 0, &tid);
84            if (!thread_hd) {
85      return 0;          msg_box (NULL, "Could not create key generation thread",
86  }                   _("Key Generation"), MB_ERR);
87            return WPTERR_GENERAL;
88        }  
89  /* Destroy the progress dialog and cleanup. */      
90  void      return 0;
91  keygen_cb_dlg_destroy (void)  }
92  {  
93      if (dlg_hwnd) {  
94          EndDialog (dlg_hwnd, TRUE);  /* Destroy the progress dialog and cleanup. */
95          dlg_hwnd = NULL;  void
96      }  keygen_cb_dlg_destroy (void)
97  }  {
98        if (dlg_hwnd) {
99            EndDialog (dlg_hwnd, TRUE);
100  /* GPGME progress callback function. */          dlg_hwnd = NULL;
101  void      }
102  keygen_cb (void * opaque, const char * what, int type, int curretn, int total)  }
103  {  
104      static char cb[8192] = {0};  
105      static int cb_pos = 0;  /* GPGME progress callback function. */
106        void
107      if (!opaque && !what && !type && !curretn && !total) {  keygen_cb (void * opaque, const char * what, int type, int curretn, int total)
108          memset (cb, 0, sizeof cb);  {
109          cb_pos = 0;      static char cb[8192] = {0};
110          return;      static int cb_pos = 0;
111      }      
112            if (!opaque && !what && !type && !curretn && !total) {
113      if (cb_pos >= (DIM (cb)-1))          memset (cb, 0, sizeof cb);
114          cb_pos = 0;          cb_pos = 0;
115      cb[cb_pos] = (char)type;          return;
116      cb_pos++;      }
117      cb[cb_pos] = '\0';      
118            if (cb_pos >= (DIM (cb)-1))
119      SetDlgItemText (dlg_hwnd, IDC_KEYPROG_CB, cb);          cb_pos = 0;
120  }      cb[cb_pos] = (char)type;
121        cb_pos++;
122        cb[cb_pos] = '\0';
123        
124        SetDlgItemText (dlg_hwnd, IDC_KEYPROG_CB, cb);
125    }

Legend:
Removed from v.35  
changed lines
  Added in v.36

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26