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

Contents of /trunk/Src/wptGPGOptDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Mon Jan 31 11:02:21 2005 UTC (20 years, 1 month ago) by twoaday
File size: 3841 byte(s)
WinPT initial checkin.


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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26