36 |
|
|
37 |
#define rc_ok(rc) ((rc) == ERROR_SUCCESS) |
#define rc_ok(rc) ((rc) == ERROR_SUCCESS) |
38 |
|
|
39 |
|
#define WINPT_REG "Software\\WinPT" |
40 |
|
|
41 |
struct reg_hotkey_s reg_hotkeys[] = { |
struct reg_hotkey_s reg_hotkeys[] = { |
42 |
{"ClipEncrypt", "", 0}, |
{"ClipEncrypt", "", 0}, |
50 |
{NULL, "", 0} |
{NULL, "", 0} |
51 |
}; |
}; |
52 |
|
|
53 |
|
/* Global WinPT registry prefereneces. */ |
54 |
winpt_reg_prefs_s reg_prefs; |
winpt_reg_prefs_s reg_prefs; |
55 |
|
|
|
#define WINPT_REG "Software\\WinPT" |
|
|
|
|
56 |
|
|
57 |
/* Return != 0 if GPG4win is installed. */ |
/* Return != 0 if GPG4win is installed. */ |
58 |
int |
int |
158 |
HKEY reg; |
HKEY reg; |
159 |
char *p = NULL; |
char *p = NULL; |
160 |
char modpath[MAX_PATH+1]; |
char modpath[MAX_PATH+1]; |
161 |
int rc, i, id, n = 0; |
int rc, i, id, n; |
162 |
|
|
163 |
gpg_filetype gpg_filetypes[] = { |
gpg_filetype gpg_filetypes[] = { |
164 |
{_("GPG Detached Signature"), ".sig", 1}, |
{_("GPG Detached Signature"), ".sig", 1}, |
169 |
|
|
170 |
if (created) |
if (created) |
171 |
*created = 0; |
*created = 0; |
172 |
|
if (is_gpgee_installed ()) |
|
p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions"); |
|
|
if ((p && *p == '1') || is_gpgee_installed ()) |
|
173 |
with_ext = 0; |
with_ext = 0; |
|
free_if_alloc (p); |
|
174 |
|
|
|
if (with_ext) { |
|
|
id = msg_box (NULL, _("WinPT can register some GPG file types for you so they can " |
|
|
"be processed with a double click in the explorer.\n" |
|
|
"Do you want to continue?"), _("WinPT"), MB_YESNO|MB_INFO); |
|
|
if (id == IDNO) { |
|
|
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1"); |
|
|
goto start; |
|
|
} |
|
|
for (i = 0; gpg_filetypes[i].ext; i++) { |
|
|
rc = RegOpenKeyEx (HKEY_CLASSES_ROOT, gpg_filetypes[i].ext, 0, KEY_READ, ®); |
|
|
if (rc_ok (rc)) { |
|
|
RegCloseKey (reg); |
|
|
id = log_box (_("WinPT WARNING"), MB_YESNO|MB_INFO, |
|
|
_("It seems there was already a '%s' file type registered by another application.\n" |
|
|
"Do you want to overwrite it?"), gpg_filetypes[i].ext); |
|
|
if (id == IDNO) |
|
|
continue; |
|
|
} |
|
|
regist_single_filetype (&gpg_filetypes[i]); |
|
|
n++; |
|
|
} |
|
|
} |
|
|
|
|
|
start: |
|
175 |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, ®); |
rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, ®); |
176 |
if (rc_ok (rc)) { |
if (rc_ok (rc)) { |
177 |
RegCloseKey (reg); |
RegCloseKey (reg); |
188 |
set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER); |
set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER); |
189 |
} |
} |
190 |
free_if_alloc (p); |
free_if_alloc (p); |
|
if (n) |
|
|
set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" ); |
|
191 |
return 0; |
return 0; |
192 |
} |
} |
193 |
rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, ®); |
rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, ®); |
196 |
if (created) |
if (created) |
197 |
*created = 1; |
*created = 1; |
198 |
RegCloseKey (reg); |
RegCloseKey (reg); |
199 |
if (n > 0 || is_gpgee_installed ()) |
if (with_ext) { |
200 |
set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1"); |
id = msg_box (NULL, _("WinPT can register some GPG file types for you so they can " |
201 |
|
"be processed with a double click in the explorer.\n" |
202 |
|
"Do you want to continue?"), _("WinPT"), MB_YESNO|MB_INFO); |
203 |
|
if (id == IDYES) { |
204 |
|
for (i = 0; gpg_filetypes[i].ext; i++) { |
205 |
|
rc = RegOpenKeyEx (HKEY_CLASSES_ROOT, gpg_filetypes[i].ext, 0, KEY_READ, ®); |
206 |
|
if (rc_ok (rc)) { |
207 |
|
RegCloseKey (reg); |
208 |
|
id = log_box (_("WinPT WARNING"), MB_YESNO|MB_INFO, |
209 |
|
_("It seems there was already a '%s' file type registered by another application.\n" |
210 |
|
"Do you want to overwrite it?"), gpg_filetypes[i].ext); |
211 |
|
if (id == IDNO) |
212 |
|
continue; |
213 |
|
} |
214 |
|
regist_single_filetype (&gpg_filetypes[i]); |
215 |
|
} |
216 |
|
} |
217 |
|
} |
218 |
if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) { |
if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) { |
219 |
while (n-- > 0) { |
while (n-- > 0) { |
220 |
if (modpath[n] == '\\') { |
if (modpath[n] == '\\') { |