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

Annotation of /trunk/Src/wptGPGOptDlg.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: 3895 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 22 /* wptGPGOptDlg.cpp - WinPT GnuPG GPG Config
2     * 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 "wptTypes.h"
24     #include "wptNLS.h"
25     #include "wptGPG.h"
26     #include "wptCommonCtl.h"
27     #include "wptContext.h" /* for passphrase_s */
28     #include "wptDlgs.h"
29     #include "wptW32API.h"
30     #include "wptErrors.h"
31     #include "../resource.h"
32    
33    
34 twoaday 32 /* Dialog box procedure for the GPG config file. */
35 twoaday 2 BOOL CALLBACK
36 twoaday 32 gpgopt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
37 twoaday 2 {
38     int id, nbytes = 8192;
39     char t[4], *optbuf = NULL;
40    
41 twoaday 32 switch (msg) {
42 twoaday 2 case WM_INITDIALOG:
43     optbuf = get_gnupg_config ();
44 twoaday 22 if (!optbuf)
45 twoaday 32 dlg_fatal_error (dlg, _("Could not load GnuPG config file!"));
46     SetDlgItemText (dlg, IDC_GPGOPT_FILE, optbuf);
47 twoaday 2 #ifndef LANG_DE
48 twoaday 32 SetWindowText (dlg, _("GnuPG Configuration File" ));
49     SetDlgItemText (dlg, IDC_GPGOPT_SAVE, _("&Save"));
50     SetDlgItemText (dlg, IDC_GPGOPT_LOAD, _("&Load"));
51 twoaday 2 #endif
52     free_if_alloc( optbuf );
53     SetForegroundWindow( dlg );
54     return TRUE;
55    
56     case WM_SYSCOMMAND:
57     if( LOWORD (wparam) == SC_CLOSE )
58     EndDialog(dlg, TRUE);
59     return FALSE;
60    
61     case WM_COMMAND:
62     switch( LOWORD( wparam ) ) {
63     case IDC_GPGOPT_SAVE:
64     optbuf = new char[nbytes + 1];
65     if( !optbuf )
66     BUG( dlg);
67     nbytes = GetDlgItemText( dlg, IDC_GPGOPT_FILE, optbuf, nbytes );
68     if( !nbytes ) {
69 twoaday 22 msg_box( dlg, _("The 'gpg.conf' file is not loaded."), _("GPG Config"), MB_ERR );
70 twoaday 2 free_if_alloc( optbuf );
71     return FALSE;
72     }
73     optbuf[nbytes] = '\0';
74     if( check_gnupg_options( optbuf ) ) {
75 twoaday 22 msg_box( dlg, _("File contains invalid GnuPG keywords!"), _("GPG Config"), MB_ERR );
76 twoaday 2 free_if_alloc( optbuf );
77     return FALSE;
78     }
79     if( set_gnupg_options( optbuf, strlen( optbuf ) ) ) {
80 twoaday 22 msg_box( dlg, _("Could not save GnuPG config file."), _("GPG Config"), MB_ERR );
81 twoaday 2 free_if_alloc( optbuf );
82     return FALSE;
83     }
84 twoaday 22 msg_box( dlg, _("Successfully saved."), _("GPG Config"), MB_OK );
85 twoaday 2 free_if_alloc( optbuf );
86     return TRUE;
87    
88     case IDC_GPGOPT_LOAD:
89     if( GetDlgItemText(dlg, IDC_GPGOPT_FILE, t, sizeof t - 1 ) ) {
90     id = msg_box( dlg, _("Current data will be lost!\n"
91 twoaday 22 "Are you sure?"), _("GPG Config"), MB_INFO|MB_YESNO );
92     if (id == IDNO)
93 twoaday 2 return TRUE;
94     }
95     optbuf = get_gnupg_config ();
96 twoaday 22 if (!optbuf)
97     msg_box (dlg, _("Could not load GnuPG config file!"), _("GPG Config"), MB_ERR);
98     SetDlgItemText (dlg, IDC_GPGOPT_FILE, optbuf);
99     free_if_alloc (optbuf);
100 twoaday 2 return TRUE;
101    
102     case IDCANCEL:
103     EndDialog( dlg, FALSE );
104     return FALSE;
105     }
106     break;
107     }
108    
109     return 0;
110 twoaday 32 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26