[Winpt-commits] r172 - trunk/Src
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Mon Jan 30 14:47:36 CET 2006
Author: twoaday
Date: 2006-01-30 14:47:35 +0100 (Mon, 30 Jan 2006)
New Revision: 172
Modified:
trunk/Src/ChangeLog
trunk/Src/WinPT.cpp
trunk/Src/wptFileManager.cpp
trunk/Src/wptRegistry.cpp
Log:
2006-01-30 Timo Schulz <ts at g10code.de>
* WinPT.cpp (check_readonly_attr): New.
(load_gpg_env): Use it here.
* wptRegistry.cpp (regist_int_winpt): Make sure
the register extension is only offered once to the user.
Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog 2006-01-30 12:53:39 UTC (rev 171)
+++ trunk/Src/ChangeLog 2006-01-30 13:47:35 UTC (rev 172)
@@ -1,3 +1,10 @@
+2006-01-30 Timo Schulz <ts at g10code.de>
+
+ * WinPT.cpp (check_readonly_attr): New.
+ (load_gpg_env): Use it here.
+ * wptRegistry.cpp (regist_int_winpt): Make sure
+ the register extension is only offered once to the user.
+
2006-01-29 Timo Schulz <ts at g10code.de>
* wptKeyPropsDlg.cpp (keyprops_dlg_proc): Allow to use ESC
Modified: trunk/Src/WinPT.cpp
===================================================================
--- trunk/Src/WinPT.cpp 2006-01-30 12:53:39 UTC (rev 171)
+++ trunk/Src/WinPT.cpp 2006-01-30 13:47:35 UTC (rev 172)
@@ -41,7 +41,9 @@
#include "wptCardEdit.h"
#include "wptCrypto.h"
+void remove_crit_file_attrs (const char *fname, int force);
+
HINSTANCE glob_hinst; /* global instance for the dialogs */
HWND glob_hwnd; /* global window handle for the dialogs */
HWND activ_hwnd;
@@ -132,7 +134,23 @@
}
+/* Check gpg files if they are read-only and ask the user
+ if this should be corrected. */
+static void
+check_readonly_attr (const char *homedir)
+{
+ const char *files[] = {"pubring.gpg", "secring.gpg", "trustdb.gpg", NULL};
+ char *file;
+ int i;
+ for (i=0; files[i] != NULL; i++) {
+ file = make_filename (homedir, files[i], NULL);
+ remove_crit_file_attrs (file, 0);
+ free_if_alloc (file);
+ }
+}
+
+
/* Load the GPG environment. On the first start, some
checks are performed to find out in what state GPG is.
Return value: 0 everything OK.
@@ -169,6 +187,7 @@
return (2);
}
}
+ check_readonly_attr (p);
pkr = make_filename (p, "pubring", "gpg");
free_if_alloc (p);
if (!pkr)
Modified: trunk/Src/wptFileManager.cpp
===================================================================
--- trunk/Src/wptFileManager.cpp 2006-01-30 12:53:39 UTC (rev 171)
+++ trunk/Src/wptFileManager.cpp 2006-01-30 13:47:35 UTC (rev 172)
@@ -114,7 +114,7 @@
/* Removes 'critical' attributes from the file @fname.
If @force is 1, the user is not asked for permission. */
-static void
+void
remove_crit_file_attrs (const char *fname, int force)
{
u32 fattr;
Modified: trunk/Src/wptRegistry.cpp
===================================================================
--- trunk/Src/wptRegistry.cpp 2006-01-30 12:53:39 UTC (rev 171)
+++ trunk/Src/wptRegistry.cpp 2006-01-30 13:47:35 UTC (rev 172)
@@ -36,8 +36,8 @@
#define rc_ok(rc) ((rc) == ERROR_SUCCESS)
+#define WINPT_REG "Software\\WinPT"
-
struct reg_hotkey_s reg_hotkeys[] = {
{"ClipEncrypt", "", 0},
{"ClipDecrypt", "", 0},
@@ -50,11 +50,10 @@
{NULL, "", 0}
};
+/* Global WinPT registry prefereneces. */
winpt_reg_prefs_s reg_prefs;
-#define WINPT_REG "Software\\WinPT"
-
/* Return != 0 if GPG4win is installed. */
int
is_gpg4win_installed (void)
@@ -159,7 +158,7 @@
HKEY reg;
char *p = NULL;
char modpath[MAX_PATH+1];
- int rc, i, id, n = 0;
+ int rc, i, id, n;
gpg_filetype gpg_filetypes[] = {
{_("GPG Detached Signature"), ".sig", 1},
@@ -170,36 +169,9 @@
if (created)
*created = 0;
-
- p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions");
- if ((p && *p == '1') || is_gpgee_installed ())
+ if (is_gpgee_installed ())
with_ext = 0;
- free_if_alloc (p);
- 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:
rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, ®);
if (rc_ok (rc)) {
RegCloseKey (reg);
@@ -216,8 +188,6 @@
set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER);
}
free_if_alloc (p);
- if (n)
- set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" );
return 0;
}
rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, ®);
@@ -226,8 +196,25 @@
if (created)
*created = 1;
RegCloseKey (reg);
- if (n > 0 || is_gpgee_installed ())
- set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1");
+ 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 == IDYES) {
+ 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]);
+ }
+ }
+ }
if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) {
while (n-- > 0) {
if (modpath[n] == '\\') {
More information about the Winpt-commits
mailing list