43 |
{0} |
{0} |
44 |
}; |
}; |
45 |
|
|
46 |
|
|
47 |
struct reg_hotkey_s reg_hotkeys[] = { |
struct reg_hotkey_s reg_hotkeys[] = { |
48 |
{"ClipEncrypt", "", 0}, |
{"ClipEncrypt", "", 0}, |
49 |
{"ClipDecrypt", "", 0}, |
{"ClipDecrypt", "", 0}, |
61 |
#define WINPT_REG "Software\\WinPT" |
#define WINPT_REG "Software\\WinPT" |
62 |
|
|
63 |
|
|
64 |
|
/* Return != 0 if GPGee is installed. */ |
65 |
|
int |
66 |
|
is_gpgee_installed (void) |
67 |
|
{ |
68 |
|
HKEY hk; |
69 |
|
LONG ec; |
70 |
|
|
71 |
|
ec = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\GPGee", 0, KEY_READ, &hk); |
72 |
|
if (ec == ERROR_SUCCESS) { |
73 |
|
RegCloseKey (hk); |
74 |
|
return -1; |
75 |
|
} |
76 |
|
|
77 |
|
return 0; |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
/* Free all members in the registry preference struct. */ |
82 |
void |
void |
83 |
free_reg_prefs (void) |
free_reg_prefs (void) |
84 |
{ |
{ |
86 |
free_if_alloc (reg_prefs.kserv_conf); |
free_if_alloc (reg_prefs.kserv_conf); |
87 |
free_if_alloc (reg_prefs.homedir); |
free_if_alloc (reg_prefs.homedir); |
88 |
memset (®_prefs, 0, sizeof reg_prefs); |
memset (®_prefs, 0, sizeof reg_prefs); |
89 |
} /* free_reg_prefs */ |
} |
90 |
|
|
91 |
|
|
92 |
/* Register the given WinPT filetype. */ |
/* Register the given WinPT filetype. */ |
99 |
GetModuleFileName (glob_hinst, prog, sizeof (prog)-1); |
GetModuleFileName (glob_hinst, prog, sizeof (prog)-1); |
100 |
_snprintf (icon, sizeof (icon) -1, "%s,%d", prog, gfile->nicon); |
_snprintf (icon, sizeof (icon) -1, "%s,%d", prog, gfile->nicon); |
101 |
return create_file_type (prog, gfile->ext, gfile->descr, icon); |
return create_file_type (prog, gfile->ext, gfile->descr, icon); |
102 |
} /* regist_single_filetype */ |
} |
103 |
|
|
104 |
|
|
105 |
/* Install the GPG related into the W32 resgistry, if the entry already |
/* Install the GPG related into the W32 resgistry, if the entry already |
136 |
|
|
137 |
|
|
138 |
/* Install WinPT into the W32 registry, if the entry already |
/* Install WinPT into the W32 registry, if the entry already |
139 |
exists the function returns immediately.*/ |
exists the function returns immediately. @with_ext can be |
140 |
|
used to register some file types (if 1). @created contains |
141 |
|
1 if the registry key was created. |
142 |
|
Return value: 0 on success. */ |
143 |
int |
int |
144 |
regist_inst_winpt (int with_ext, int * created) |
regist_inst_winpt (int with_ext, int *created) |
145 |
{ |
{ |
146 |
HKEY reg; |
HKEY reg; |
147 |
char * p = NULL; |
char *p = NULL; |
148 |
|
char modpath[MAX_PATH+1]; |
149 |
int rc, i, id, n = 0; |
int rc, i, id, n = 0; |
150 |
|
|
151 |
if( created ) |
if (created) |
152 |
*created = 0; |
*created = 0; |
153 |
|
|
154 |
p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions"); |
p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions"); |
155 |
if (p && *p == '1') |
if ((p && *p == '1') || is_gpgee_installed ()) |
156 |
with_ext = 0; |
with_ext = 0; |
157 |
free_if_alloc( p ); |
free_if_alloc (p); |
158 |
|
|
159 |
if( with_ext ) { |
if (with_ext) { |
160 |
id = msg_box( NULL, _("WinPT can register some GPG file types for you so they can " |
id = msg_box (NULL, _("WinPT can register some GPG file types for you so they can " |
161 |
"be processed with a double click in the explorer.\n" |
"be processed with a double click in the explorer.\n" |
162 |
"Do you want to continue?"), _("WinPT"), MB_YESNO|MB_INFO ); |
"Do you want to continue?"), _("WinPT"), MB_YESNO|MB_INFO); |
163 |
if( id == IDNO ) { |
if (id == IDNO) { |
164 |
set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" ); |
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1"); |
165 |
goto start; |
goto start; |
166 |
} |
} |
167 |
for( i = 0; gpg_filetypes[i].ext; i++ ) { |
for (i = 0; gpg_filetypes[i].ext; i++) { |
168 |
rc = RegOpenKeyEx( HKEY_CLASSES_ROOT, gpg_filetypes[i].ext, 0, KEY_READ, ® ); |
rc = RegOpenKeyEx (HKEY_CLASSES_ROOT, gpg_filetypes[i].ext, 0, KEY_READ, ®); |
169 |
if( rc_ok( rc ) ) { |
if (rc_ok (rc)) { |
170 |
RegCloseKey( reg ); |
RegCloseKey (reg); |
171 |
id = log_box( _("WinPT WARNING"), MB_YESNO|MB_INFO, |
id = log_box (_("WinPT WARNING"), MB_YESNO|MB_INFO, |
172 |
_("It seems there was already a '%s' file type registered by another application.\n" |
_("It seems there was already a '%s' file type registered by another application.\n" |
173 |
"Do you want to overwrite it?"), gpg_filetypes[i].ext ); |
"Do you want to overwrite it?"), gpg_filetypes[i].ext); |
174 |
if( id == IDNO ) |
if (id == IDNO) |
175 |
continue; |
continue; |
176 |
} |
} |
177 |
regist_single_filetype( &gpg_filetypes[i] ); |
regist_single_filetype (&gpg_filetypes[i]); |
178 |
n++; |
n++; |
179 |
} |
} |
180 |
} |
} |
181 |
|
|
182 |
start: |
start: |
183 |
rc = RegOpenKeyEx( HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, ® ); |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, ®); |
184 |
if( rc_ok( rc ) ) { |
if (rc_ok (rc)) { |
185 |
RegCloseKey( reg ); |
RegCloseKey (reg); |
186 |
rc = RegOpenKeyEx( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", 0, KEY_READ, ® ); |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", 0, KEY_READ, ®); |
187 |
if( !rc_ok( rc ) ) { |
if( !rc_ok (rc)) { |
188 |
RegCreateKey( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", ® ); |
RegCreateKey (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", ®); |
189 |
RegCloseKey( reg ); |
RegCloseKey (reg); |
190 |
} |
} |
191 |
p = get_reg_entry_keyserver ("Default"); |
p = get_reg_entry_keyserver ("Default"); |
192 |
if (!p) { |
if (!p) { |
195 |
set_reg_entry_keyserver ("Default_Port", buf); |
set_reg_entry_keyserver ("Default_Port", buf); |
196 |
set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER); |
set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER); |
197 |
} |
} |
198 |
free_if_alloc( p ); |
free_if_alloc (p); |
199 |
if( n ) |
if (n) |
200 |
set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" ); |
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1"); |
201 |
return 0; |
return 0; |
202 |
} |
} |
203 |
rc = RegCreateKey( HKEY_CURRENT_USER, WINPT_REG, ® ); |
rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, ®); |
204 |
if( !rc_ok( rc ) ) |
if (!rc_ok (rc)) |
205 |
return WPTERR_REGISTRY; |
return WPTERR_REGISTRY; |
206 |
if( created ) |
if (created) |
207 |
*created = 1; |
*created = 1; |
208 |
RegCloseKey( reg ); |
RegCloseKey (reg); |
209 |
if( n ) |
if (n) |
210 |
set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" ); |
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1"); |
211 |
|
if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) { |
212 |
|
while (n-- > 0) { |
213 |
|
if (modpath[n] == '\\') { |
214 |
|
modpath[n] = 0; |
215 |
|
break; |
216 |
|
} |
217 |
|
} |
218 |
|
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Install Directory", modpath); |
219 |
|
} |
220 |
return 0; |
return 0; |
221 |
} /* regist_inst_winpt */ |
} |
222 |
|
|
223 |
|
|
224 |
/* Create a new filetype in the W32 registry. |
/* Create a new filetype in the W32 registry. |
397 |
} |
} |
398 |
|
|
399 |
|
|
400 |
|
|
401 |
|
|
402 |
int |
int |
403 |
set_reg_entry_mo (const char * value) |
set_reg_entry_mo (const char * value) |
404 |
{ |
{ |
440 |
{ |
{ |
441 |
char *p, *pp; |
char *p, *pp; |
442 |
const char *lang; |
const char *lang; |
443 |
|
|
444 |
p = get_reg_entry (HKEY_CURRENT_USER, |
p = get_reg_entry (HKEY_CURRENT_USER, |
445 |
"Control Panel\\Mingw32\\NLS", "MODir"); |
"Control Panel\\Mingw32\\NLS", "MODir"); |
446 |
if (p) |
if (p) |
447 |
return p; |
return p; |
448 |
|
|
449 |
lang = get_gettext_langid (); |
lang = get_gettext_langid (); |
450 |
if (!lang) |
if (!lang) |
451 |
return NULL; |
return NULL; |
452 |
pp = new char[strlen ("share\\xxxxx\\locale\\LC_MESSAGES")+8]; |
pp = new char[strlen ("share\\xxxxx\\locale\\LC_MESSAGES")+8]; |
453 |
if (!pp) |
if (!pp) |
454 |
BUG (NULL); |
BUG (NULL); |
455 |
sprintf (pp, "share\\locale\\%s\\LC_MESSAGES", lang); |
sprintf (pp, "share\\locale\\%s\\LC_MESSAGES", lang); |
456 |
p = get_reg_entry_gpg4win (pp); |
p = get_reg_entry_gpg4win (pp); |
493 |
int |
int |
494 |
get_reg_winpt_single (int id) |
get_reg_winpt_single (int id) |
495 |
{ |
{ |
496 |
char * buf = NULL; |
char *buf = NULL; |
497 |
int val = 0; |
int val = 0; |
498 |
|
|
499 |
buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]); |
buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]); |
621 |
int |
int |
622 |
get_reg_winpt_prefs (winpt_reg_prefs_s * opt) |
get_reg_winpt_prefs (winpt_reg_prefs_s * opt) |
623 |
{ |
{ |
624 |
char * val = NULL; |
char *val = NULL; |
625 |
size_t i; |
size_t i; |
626 |
|
|
627 |
for (i=1; i < DIM (cfg); i++) { |
for (i=1; i < DIM (cfg); i++) { |