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

Annotation of /trunk/Src/wptProgressDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations)
Sun Feb 6 11:11:40 2005 UTC (20 years ago) by twoaday
File size: 3407 byte(s)
2005-02-02  Timo Schulz  <twoaday@freakmail.de>
                                                                                                                            
        * wptPassphraseDlg.cpp (passwd_dlg_proc): use center_window2, otherwise
        it is invisible.
        * wptPassphraseCB.cpp (passphrase_callback_proc): Do not cache symmetric
        passphrases.
        * Enable the progress dialog for symmetric encryption.
        * wptFileManager.cpp (fm_check_file_type): Also check for 'SYMKEYENC' in
        FM_ENCRYPT mode.
        * WinPT.cpp (WinMain): SETUP_EXISTING implemented.
        * wptGPGPrefsDlg.cpp (gpgprefs_dlg_proc): Reset 'Locale directory' when
        no value is entered.
                                                                                                                            
2005-02-04  Timo Schulz  <twoaday@freakmail.de>
                                                                                                                            
        * wptProgressDlg.cpp (progress_cb_thread): Set root window if available.
        If the progress window survives by accident, it will be closed when the
        File Manager (root window) is closed.
                                                                                                                            


1 twoaday 2 /* wptProgressDlg.cpp - Support for the GPG progress status
2     * Copyright (C) 2003, 2004 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     #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     }
89    
90    
91     void
92     progress_callback (void * opaque, const char * what, int type, unsigned off, unsigned max)
93     {
94     struct progress_filter_s * pfx = (struct progress_filter_s *)opaque;
95     DWORD tid;
96    
97     if (!pfx || pfx->error)
98     return;
99     pfx->curr = off;
100     pfx->total = max;
101     pfx->what = what;
102     if (!off && !pfx->thread_hd) {
103     pfx->thread_hd = CreateThread (NULL, 0, progress_cb_thread, (void *)pfx, 0, &tid);
104     if (!pfx->thread_hd) {
105     msg_box (NULL, _("Could not create progress thread."), _("WinPT"), MB_ERR);
106     pfx->error = 1;
107     return;
108     }
109     }
110     else if (pfx->dlg) {
111     size_t n = pfx->curr * 100 / pfx->total;
112     SendDlgItemMessage (pfx->dlg, IDC_PROGRESS_BAR, PBM_SETPOS, (WPARAM)n, 0);
113     SetDlgItemInt (pfx->dlg, IDC_PROGRESS_CURR, pfx->curr, FALSE);
114     }
115     if (off >= max)
116     progress_cleanup (pfx);
117     } /* progress_callback */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26