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

Annotation of /trunk/Src/wptProgressDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (hide annotations)
Mon Mar 7 13:21:36 2005 UTC (19 years, 11 months ago) by twoaday
File size: 3481 byte(s)
2005-03-03  Timo Schulz  <twoaday@g10code.com>
                                                                                
        * wptCardDlg.cpp (card_changepin_dlg_proc): Add item to re-type the
        new PIN. Suggested by Achim.
        Support to show the unmasked PIN.
        Modified TAB-order.
        * wptPINDlg.cpp (pin_cb_dlg_proc): Show unmasked PIN.
 
        * Fixed wrong GPG --command-fd strings. Thanks to Achim.
 
2005-03-04  Timo Schulz  <twoaday@g10code.com>
 
        * GPG asks twice for the new PIN. Thanks to Achim.
        * wptCardDlg.cpp (card_changepin_dlg_proc): Reset the 'safety' pin also.        Only check the passphrase if the backup flag is enabled. Again thanks to        Achim.
 
2005-03-06  Timo Schulz  <twoaday@freakmail.de>
 
        * wptKeySignDlg.cpp (do_fill_seckeylist): Skip secret keys without
        a public key. Noted by Kurt Fitzner.
 


1 twoaday 2 /* wptProgressDlg.cpp - Support for the GPG progress status
2 twoaday 5 * Copyright (C) 2003, 2004, 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     #include <commctrl.h>
23    
24     #include "../resource.h"
25     #include "wptGPG.h"
26     #include "wptTypes.h"
27     #include "wptCommonCtl.h"
28     #include "wptW32API.h"
29     #include "wptContext.h"
30     #include "wptVersion.h"
31    
32     static HWND progress_dlg = NULL;
33    
34     static BOOL CALLBACK
35     progress_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
36     {
37     static progress_filter_s * pfx = NULL;
38    
39     switch (msg) {
40     case WM_INITDIALOG:
41     pfx = (struct progress_filter_s *)lparam;
42     if (!pfx)
43     BUG (0);
44     progress_dlg = dlg;
45     pfx->dlg = dlg;
46     SendDlgItemMessage (dlg, IDC_PROGRESS_BAR, PBM_SETRANGE, 0, MAKELPARAM (0, 100));
47     SetDlgItemInt (pfx->dlg, IDC_PROGRESS_TOTAL, pfx->total, FALSE);
48     SetDlgItemInt (pfx->dlg, IDC_PROGRESS_CURR, pfx->curr, FALSE);
49     SetDlgItemText (pfx->dlg, IDC_PROGRESS_WHAT, pfx->what);
50     center_window2 (dlg, HWND_TOPMOST);
51     center_window (dlg);
52     SetForegroundWindow (dlg);
53     return TRUE;
54     }
55     return FALSE;
56     } /* progress_dlg_proc */
57    
58    
59     static DWORD WINAPI
60     progress_cb_thread (void * opaque)
61     {
62 twoaday 4 struct progress_filter_s * pfx = (struct progress_filter_s *)opaque;
63    
64     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_PROGRESS,
65     opaque? pfx->hwnd : GetActiveWindow (),
66 twoaday 2 progress_dlg_proc, (LPARAM)opaque);
67     return TRUE;
68     } /* progress_cb_thread */
69    
70    
71     void
72     progress_cleanup (progress_filter_s * pfx)
73     {
74     EndDialog (progress_dlg, TRUE);
75     if (!pfx)
76     return;
77     if (pfx->dlg) {
78     EndDialog (pfx->dlg, TRUE);
79     pfx->dlg = NULL;
80     }
81     if (pfx->thread_hd) {
82     CloseHandle (pfx->thread_hd);
83     pfx->thread_hd = NULL;
84     }
85     pfx->curr = 0;
86     pfx->total = 0;
87     pfx->error = 0;
88 twoaday 5 memset (pfx, 0, sizeof *pfx); /*XXX: does this really work? */
89 twoaday 2 }
90    
91    
92     void
93     progress_callback (void * opaque, const char * what, int type, unsigned off, unsigned max)
94     {
95     struct progress_filter_s * pfx = (struct progress_filter_s *)opaque;
96     DWORD tid;
97    
98     if (!pfx || pfx->error)
99     return;
100     pfx->curr = off;
101     pfx->total = max;
102     pfx->what = what;
103     if (!off && !pfx->thread_hd) {
104     pfx->thread_hd = CreateThread (NULL, 0, progress_cb_thread, (void *)pfx, 0, &tid);
105     if (!pfx->thread_hd) {
106     msg_box (NULL, _("Could not create progress thread."), _("WinPT"), MB_ERR);
107     pfx->error = 1;
108     return;
109     }
110     }
111     else if (pfx->dlg) {
112     size_t n = pfx->curr * 100 / pfx->total;
113     SendDlgItemMessage (pfx->dlg, IDC_PROGRESS_BAR, PBM_SETPOS, (WPARAM)n, 0);
114     SetDlgItemInt (pfx->dlg, IDC_PROGRESS_CURR, pfx->curr, FALSE);
115     }
116     if (off >= max)
117     progress_cleanup (pfx);
118     } /* progress_callback */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26