1 |
/* wptGPGPrefsDlg.cpp - WinPT GnuPG Preferences |
/* wptGPGPrefsDlg.cpp - WinPT GnuPG Preferences |
2 |
* Copyright (C) 2001, 2002, 2003 Timo Schulz |
* Copyright (C) 2001-2005 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
44 |
|
|
45 |
|
|
46 |
BOOL CALLBACK |
BOOL CALLBACK |
47 |
gpgprefs_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam ) |
gpgprefs_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
48 |
{ |
{ |
49 |
char exedir[1024], homedir[1024], optfile[1024]; |
char exedir[1024], homedir[1024], optfile[1024]; |
50 |
char locale_dir[1024]; |
char locale_dir[1024]; |
91 |
if( opt && (e=find_option( opt, "encrypt-to" )) ) |
if( opt && (e=find_option( opt, "encrypt-to" )) ) |
92 |
SetDlgItemText( dlg, IDC_GPGPREFS_ENCTO, e->val ); |
SetDlgItemText( dlg, IDC_GPGPREFS_ENCTO, e->val ); |
93 |
} |
} |
94 |
center_window( dlg ); |
center_window( dlg, NULL ); |
95 |
SetForegroundWindow( dlg ); |
SetForegroundWindow( dlg ); |
96 |
return TRUE; |
return TRUE; |
97 |
|
|
143 |
} |
} |
144 |
} |
} |
145 |
else { |
else { |
146 |
char * t = get_gnupg_cfgfile( ); |
char * t = get_gnupg_cfgfile (); |
147 |
if( t && !file_exist_check(t) ) |
if (t && !file_exist_check (t)) |
148 |
set_reg_entry_gpg( "OptFile", t ); |
set_reg_entry_gpg( "OptFile", t ); |
149 |
else |
free_if_alloc (t); |
|
set_reg_entry_gpg( "OptFile", "" ); |
|
|
free_if_alloc( t ); |
|
150 |
} |
} |
151 |
if ( set_reg_entry_gpg( "HomeDir", homedir ) ) { |
if ( set_reg_entry_gpg( "HomeDir", homedir ) ) { |
152 |
msg_box( dlg, _("Could not save 'HomeDir' in the registry."), _("Preferences"), MB_ERR ); |
msg_box( dlg, _("Could not save 'HomeDir' in the registry."), _("Preferences"), MB_ERR ); |
164 |
msg_box( dlg, _("Could not save 'gpgProgram' in the registry"), _("Preferences"), MB_ERR ); |
msg_box( dlg, _("Could not save 'gpgProgram' in the registry"), _("Preferences"), MB_ERR ); |
165 |
return FALSE; |
return FALSE; |
166 |
} |
} |
167 |
if( GetDlgItemText( dlg, IDC_GPGPREFS_LOCALE, locale_dir, sizeof locale_dir -1 ) ) { |
if( GetDlgItemText( dlg, IDC_GPGPREFS_LOCALE, locale_dir, sizeof (locale_dir) -1 ) ) { |
168 |
if ( dir_exist_check( locale_dir ) ) { |
if (dir_exist_check (locale_dir)) { |
169 |
log_box( _("Preferences"), MB_ERR, "%s: %s", locale_dir, winpt_strerror( WPTERR_DIR_OPEN ) ); |
log_box( _("Preferences"), MB_ERR, "%s: %s", locale_dir, winpt_strerror (WPTERR_DIR_OPEN)); |
170 |
return FALSE; |
return FALSE; |
171 |
} |
} |
172 |
set_reg_entry_mo( locale_dir ); |
set_reg_entry_mo (locale_dir); |
173 |
set_gettext_file( "winpt", locale_dir ); |
set_gettext_file ("winpt", locale_dir); |
174 |
} |
} |
175 |
|
else |
176 |
|
set_reg_entry_mo (""); |
177 |
|
|
178 |
p = get_gnupg_cfgfile( ); |
p = get_gnupg_cfgfile (); |
179 |
if( !p ) { |
if( !p ) { |
180 |
msg_box( dlg, _("Could not get GPG config file"), _("Preferences"), MB_ERR ); |
msg_box( dlg, _("Could not get GPG config file"), _("Preferences"), MB_ERR ); |
181 |
EndDialog( dlg, FALSE ); |
EndDialog( dlg, FALSE ); |
206 |
|
|
207 |
case IDC_GPGPREFS_HOMEDLG: |
case IDC_GPGPREFS_HOMEDLG: |
208 |
const char * home; |
const char * home; |
209 |
|
home = get_folder_dlg (dlg, _("Choose GPG home directory"), NULL); |
210 |
home = get_folder_dlg( dlg, _("Choose GPG home directory"), NULL ); |
if (home) { |
211 |
if( home ) |
SetDlgItemText (dlg, IDC_GPGPREFS_HOMEDIR, home); |
212 |
SetDlgItemText( dlg, IDC_GPGPREFS_HOMEDIR, home ); |
if (GetDlgItemText (dlg, IDC_GPGPREFS_EXEDIR, exedir, DIM (exedir)-1) > 0) |
213 |
|
break; |
214 |
|
char *name = make_filename (home, "gpg", "exe"); |
215 |
|
if (file_exist_check (name) == 0) |
216 |
|
SetDlgItemText (dlg, IDC_GPGPREFS_EXEDIR, name); |
217 |
|
free_if_alloc (name); |
218 |
|
name = make_filename (home, "gpg", "conf"); |
219 |
|
if (file_exist_check (name) == 0) |
220 |
|
SetDlgItemText (dlg, IDC_GPGPREFS_OPTFILE, name); |
221 |
|
free_if_alloc (name); |
222 |
|
} |
223 |
break; |
break; |
224 |
|
|
225 |
case IDC_GPGREFS_EXEDLG: |
case IDC_GPGREFS_EXEDLG: |