[git] GpgOL - branch, async-enc, updated. gpgol-2.0.6-61-ge07ab6c

by Andre Heinecke cvs at cvs.gnupg.org
Mon Mar 5 11:49:02 CET 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, async-enc has been updated
       via  e07ab6c300589dcc8de0129051ce0800f772a52c (commit)
       via  2d069391aa5c5bace8a5460f0bdb60a1e015642a (commit)
       via  bd2a79d9661a5e204a56e7b64da785b04ece1583 (commit)
      from  ab5232cb52e4265be48c1d4d977aae45ad91f844 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e07ab6c300589dcc8de0129051ce0800f772a52c
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Mar 5 11:46:11 2018 +0100

    Implement Load / Save for WKS States
    
    * src/wks-helper.cpp (WKSHelper::load, WKSHelper::save): Implement.
    (WKSHelper::check_published): New.
    (do_check): Also check for published.
    (WKSHelper::update_last_checked): New.
    (WKSHelper::start_check): Handle saved states.

diff --git a/src/wks-helper.cpp b/src/wks-helper.cpp
index 6d9f9e2..16d42ba 100644
--- a/src/wks-helper.cpp
+++ b/src/wks-helper.cpp
@@ -30,6 +30,7 @@
 #include <sstream>
 
 #include <unistd.h>
+#include <stdlib.h>
 
 #include <gpg-error.h>
 #include <gpgme++/key.h>
@@ -37,6 +38,7 @@
 #include <gpgme++/context.h>
 
 #define CHECK_MIN_INTERVAL (60 * 60 * 24 * 7)
+#define WKS_REG_KEY "webkey"
 
 #define DEBUG_WKS 1
 
@@ -142,6 +144,54 @@ get_wks_client_path ()
   return std::string ();
 }
 
+static bool
+check_published (const std::string &mbox)
+{
+  const auto wksPath = get_wks_client_path ();
+
+  if (wksPath.empty())
+    {
+      return 0;
+    }
+
+  std::vector<std::string> args;
+
+  args.push_back (wksPath);
+  args.push_back (std::string ("--status-fd"));
+  args.push_back (std::string ("1"));
+  args.push_back (std::string ("--check"));
+  args.push_back (mbox);
+
+  // Spawn the process
+  auto ctx = GpgME::Context::createForEngine (GpgME::SpawnEngine);
+
+  if (!ctx)
+    {
+      TRACEPOINT;
+      return false;
+    }
+
+  GpgME::Data mystdin, mystdout, mystderr;
+
+  char **cargs = vector_to_cArray (args);
+
+  GpgME::Error err = ctx->spawn (cargs[0], const_cast <const char **> (cargs),
+                                 mystdin, mystdout, mystderr,
+                                 GpgME::Context::SpawnNone);
+  release_cArray (cargs);
+
+  if (err)
+    {
+      log_debug ("%s:%s: WKS client spawn code: %i asString: %s",
+                 SRCNAME, __func__, err.code(), err.asString());
+      return false;
+    }
+  auto data = mystdout.toString ();
+  rtrim (data);
+
+  return data == "[GNUPG:] SUCCESS";
+}
+
 static DWORD WINAPI
 do_check (LPVOID arg)
 {
@@ -192,29 +242,26 @@ do_check (LPVOID arg)
 
   bool success = data == "[GNUPG:] SUCCESS";
   // TODO Figure out NeedsPublish state.
-  const auto state = success ? WKSHelper::NeedsPublish : WKSHelper::NotSupported;
+  auto state = success ? WKSHelper::NeedsPublish : WKSHelper::NotSupported;
+  bool isPublished = false;
+
   if (success)
     {
       log_debug ("%s:%s: WKS client: '%s' is supported",
                  SRCNAME, __func__, mbox.c_str ());
+      isPublished = check_published (mbox);
     }
 
-  WKSHelper::instance()->update_state (mbox, state);
-
-  gpgrt_lock_lock (&wks_lock);
-  auto tit = s_last_checked.find(mbox);
-  auto now = time (0);
-  if (tit != s_last_checked.end())
-    {
-      tit->second = now;
-    }
-  else
+  if (isPublished)
     {
-      s_last_checked.insert (std::make_pair (mbox, now));
+      log_debug ("%s:%s: WKS client: '%s' is published",
+                 SRCNAME, __func__, mbox.c_str ());
+      state = WKSHelper::IsPublished;
     }
-  gpgrt_lock_unlock (&wks_lock);
 
-  WKSHelper::instance()->save ();
+  WKSHelper::instance()->update_state (mbox, state, false);
+  WKSHelper::instance()->update_last_checked (mbox, time (0));
+
   return 0;
 }
 
@@ -222,11 +269,25 @@ do_check (LPVOID arg)
 void
 WKSHelper::start_check (const std::string &mbox, bool forced) const
 {
+  const auto state = get_state (mbox);
+
+  if (!forced && (state != NotChecked && state != NotSupported))
+    {
+      log_debug ("%s:%s: Check aborted because its neither "
+                 "not supported nor not checked.",
+                 SRCNAME, __func__);
+      return;
+    }
+
   auto lastTime = get_check_time (mbox);
   auto now = time (0);
-  if (!forced && lastTime && difftime (lastTime, now) < CHECK_MIN_INTERVAL)
+
+  if (!forced && (state == NotSupported && lastTime &&
+                  difftime (now, lastTime) < CHECK_MIN_INTERVAL))
     {
       /* Data is new enough */
+      log_debug ("%s:%s: Check aborted because last checked is too recent.",
+                 SRCNAME, __func__);
       return;
     }
 
@@ -247,13 +308,54 @@ WKSHelper::start_check (const std::string &mbox, bool forced) const
 void
 WKSHelper::load () const
 {
-  // TODO
+  /* Map of mbox'es to states. states are <state>;<last_checked> */
+  const auto map = get_registry_subkeys (WKS_REG_KEY);
+
+  for (const auto &pair: map)
+    {
+      const auto mbox = pair.first;
+      const auto states = gpgol_split (pair.second, ';');
+
+      if (states.size() != 2)
+        {
+          log_error ("%s:%s: Invalid state '%s' for '%s'",
+                     SRCNAME, __func__, mbox.c_str (), pair.second.c_str ());
+          continue;
+        }
+
+      WKSState state = (WKSState) strtol (states[0].c_str (), nullptr, 10);
+      time_t update_time = (time_t) strtol (states[1].c_str (), nullptr, 10);
+
+      update_state (mbox, state, false);
+      update_last_checked (mbox, update_time, false);
+    }
 }
 
 void
 WKSHelper::save () const
 {
-  // TODO
+  gpgrt_lock_lock (&wks_lock);
+  for (const auto &pair: s_states)
+    {
+      auto state = std::to_string (pair.second) + ';';
+
+      const auto it = s_last_checked.find (pair.first);
+      if (it != s_last_checked.end ())
+        {
+          state += std::to_string (it->second);
+        }
+      else
+        {
+          state += '0';
+        }
+      if (store_extension_subkey_value (WKS_REG_KEY, pair.first.c_str (),
+                                        state.c_str ()))
+        {
+          log_error ("%s:%s: Failed to store state.",
+                     SRCNAME, __func__);
+        }
+    }
+  gpgrt_lock_unlock (&wks_lock);
 }
 
 static DWORD WINAPI
@@ -278,7 +380,8 @@ WKSHelper::allow_notify (int sleepTimeMS) const
       if (pair.second == ConfirmationSeen ||
           pair.second == NeedsPublish)
         {
-          auto *args = new std::pair<char *, int> (strdup (pair.first.c_str()), sleepTimeMS);
+          auto *args = new std::pair<char *, int> (strdup (pair.first.c_str()),
+                                                   sleepTimeMS);
           CloseHandle (CreateThread (nullptr, 0, do_notify,
                                      args, 0,
                                      nullptr));
@@ -309,7 +412,7 @@ WKSHelper::notify (const char *cBox) const
         }
       else
         {
-           update_state (mbox, PublishDenied);
+          update_state (mbox, PublishDenied);
         }
       return;
     }
@@ -406,7 +509,8 @@ WKSHelper::start_publish (const std::string &mbox) const
 }
 
 void
-WKSHelper::update_state (const std::string &mbox, WKSState state) const
+WKSHelper::update_state (const std::string &mbox, WKSState state,
+                         bool store) const
 {
   gpgrt_lock_lock (&wks_lock);
   auto it = s_states.find(mbox);
@@ -420,6 +524,33 @@ WKSHelper::update_state (const std::string &mbox, WKSState state) const
       s_states.insert (std::make_pair (mbox, state));
     }
   gpgrt_lock_unlock (&wks_lock);
+
+  if (store)
+    {
+      save ();
+    }
+}
+
+void
+WKSHelper::update_last_checked (const std::string &mbox, time_t time,
+                                bool store) const
+{
+  gpgrt_lock_lock (&wks_lock);
+  auto it = s_last_checked.find(mbox);
+  if (it != s_last_checked.end())
+    {
+      it->second = time;
+    }
+  else
+    {
+      s_last_checked.insert (std::make_pair (mbox, time));
+    }
+  gpgrt_lock_unlock (&wks_lock);
+
+  if (store)
+    {
+      save ();
+    }
 }
 
 int
diff --git a/src/wks-helper.h b/src/wks-helper.h
index a6429f7..be3ae7b 100644
--- a/src/wks-helper.h
+++ b/src/wks-helper.h
@@ -48,8 +48,8 @@ public:
       {
         NotChecked, /*<-- Supported state was not checked */
         NotSupported, /* <-- WKS is not supported for this address */
-        Supported, /* <-- WKS is supported for this address */
         NeedsPublish, /* <-- There was no key published for this address */
+        IsPublished, /* <-- WKS is supported for this address and published */
         ConfirmationSeen, /* A confirmation request was seen for this mail addres. */
         NeedsUpdate, /* <-- Not yet implemeted. */
         RequestSent, /* <-- A publishing request has been sent. */
@@ -99,7 +99,11 @@ public:
     void save () const;
 
     /** Update or insert a state in the static maps. */
-    void update_state (const std::string &mbox, WKSState state) const;
+    void update_state (const std::string &mbox, WKSState state, bool save = true) const;
+
+    /** Update or insert last_checked in the static maps. */
+    void update_last_checked (const std::string &mbox, time_t last_checked,
+                              bool save = true) const;
 
     /** Create / Build / Send Mail
       returns 0 on success.

commit 2d069391aa5c5bace8a5460f0bdb60a1e015642a
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Mar 5 11:45:51 2018 +0100

    Add helpers to store string map in registry
    
    * src/common.c (store_extension_subkey_value): New.
    (GPGOL_REGPATH): Move into header.
    * src/common.h: Expose store_extension_subkey_value.
    * src/cpphelp.cpp (get_registry_subkeys): New.
    (gpgol_split): New Helper.
    * src/cpphelp.h: Update accordingly.

diff --git a/src/common.c b/src/common.c
index 8997b16..adda352 100644
--- a/src/common.c
+++ b/src/common.c
@@ -40,9 +40,6 @@
 
 #include "dialogs.h"
 
-/* Registry path to store plugin settings */
-#define GPGOL_REGPATH "Software\\GNU\\GpgOL"
-
 HINSTANCE glob_hinst = NULL;
 
 void
@@ -1178,3 +1175,16 @@ load_extension_value (const char *key, char **val)
 {
   return load_config_value (HKEY_CURRENT_USER, GPGOL_REGPATH, key, val);
 }
+
+int
+store_extension_subkey_value (const char *subkey,
+                              const char *key,
+                              const char *val)
+{
+  int ret;
+  char *path;
+  gpgrt_asprintf (&path, "%s\\%s", GPGOL_REGPATH, subkey);
+  ret = store_config_value (HKEY_CURRENT_USER, path, key, val);
+  xfree (path);
+  return ret;
+}
diff --git a/src/common.h b/src/common.h
index ed7b87a..c8e32df 100644
--- a/src/common.h
+++ b/src/common.h
@@ -39,6 +39,9 @@
 # define MIME_UI_DEFAULT 0
 #endif
 
+/* Registry path to store plugin settings */
+#define GPGOL_REGPATH "Software\\GNU\\GpgOL"
+
 #ifdef __cplusplus
 extern "C" {
 #if 0
@@ -60,6 +63,11 @@ const char *default_homedir (void);
 char *get_data_dir (void);
 char *get_gpg4win_dir (void);
 
+int store_extension_value (const char *key, const char *val);
+int store_extension_subkey_value (const char *subkey, const char *key,
+                                  const char *val);
+int load_extension_value (const char *key, char **val);
+
 /* Get a temporary filename with and its name */
 wchar_t *get_tmp_outfile (wchar_t *name, HANDLE *outHandle);
 
@@ -81,8 +89,6 @@ const char *get_pubkey_algo_str (gpgme_pubkey_algo_t id);
 
 /*-- config-dialog.c --*/
 void config_dialog_box (HWND parent);
-int store_extension_value (const char *key, const char *val);
-int load_extension_value (const char *key, char **val);
 
 /*-- verify-dialog.c --*/
 int verify_dialog_box (gpgme_protocol_t protocol,
diff --git a/src/cpphelp.cpp b/src/cpphelp.cpp
index 85c8db3..8d38feb 100644
--- a/src/cpphelp.cpp
+++ b/src/cpphelp.cpp
@@ -21,15 +21,21 @@
 
 #include "config.h"
 
-#include <algorithm>
 #include "cpphelp.h"
 
+#include <algorithm>
+#include <sstream>
+#include <vector>
+#include <iterator>
+
 #include "common.h"
 
 #include <gpgme++/context.h>
 #include <gpgme++/error.h>
 #include <gpgme++/configuration.h>
 
+#include <windows.h>
+
 void
 release_cArray (char **carray)
 {
@@ -111,3 +117,110 @@ in_de_vs_mode()
   vs_mode = false;
   return false;
 }
+
+std::map<std::string, std::string>
+get_registry_subkeys (const char *path)
+{
+  HKEY theKey;
+  std::map<std::string, std::string> ret;
+
+  std::string regPath = GPGOL_REGPATH;
+  regPath += "\\";
+  regPath += path;
+
+  if (RegOpenKeyEx (HKEY_CURRENT_USER,
+                    regPath.c_str (),
+                    0, KEY_ENUMERATE_SUB_KEYS | KEY_READ,
+                    &theKey) != ERROR_SUCCESS)
+    {
+      TRACEPOINT;
+      return ret;
+    }
+
+  DWORD values = 0,
+        maxValueName = 0,
+        maxValueLen = 0;
+
+  DWORD err = RegQueryInfoKey (theKey,
+                               nullptr,
+                               nullptr,
+                               nullptr,
+                               nullptr,
+                               nullptr,
+                               nullptr,
+                               &values,
+                               &maxValueName,
+                               &maxValueLen,
+                               nullptr,
+                               nullptr);
+
+  if (err != ERROR_SUCCESS)
+    {
+      TRACEPOINT;
+      RegCloseKey (theKey);
+      return ret;
+    }
+
+  /* Add space for NULL */
+  maxValueName++;
+  maxValueLen++;
+
+  char name[maxValueName + 1];
+  char value[maxValueLen + 1];
+  for (int i = 0; i < values; i++)
+    {
+      DWORD nameLen = maxValueName;
+      err = RegEnumValue (theKey, i,
+                          name,
+                          &nameLen,
+                          nullptr,
+                          nullptr,
+                          nullptr,
+                          nullptr);
+
+      if (err != ERROR_SUCCESS)
+        {
+          TRACEPOINT;
+          continue;
+        }
+
+      DWORD type;
+      DWORD valueLen = maxValueLen;
+      err = RegQueryValueEx (theKey, name,
+                             NULL, &type,
+                             (BYTE*)value, &valueLen);
+
+      if (err != ERROR_SUCCESS)
+        {
+          TRACEPOINT;
+          continue;
+        }
+      if (type != REG_SZ)
+        {
+          TRACEPOINT;
+          continue;
+        }
+      ret.insert (std::make_pair (std::string (name, nameLen),
+                                  std::string (value, valueLen)));
+    }
+  RegCloseKey (theKey);
+  return ret;
+}
+
+template<typename Out> void
+internal_split (const std::string &s, char delim, Out result) {
+  std::stringstream ss(s);
+  std::string item;
+  while (std::getline (ss, item, delim))
+    {
+      *(result++) = item;
+    }
+}
+
+std::vector<std::string>
+gpgol_split (const std::string &s, char delim)
+{
+  std::vector<std::string> elems;
+  internal_split (s, delim, std::back_inserter (elems));
+  return elems;
+}
diff --git a/src/cpphelp.h b/src/cpphelp.h
index bbf68e0..51ffe80 100644
--- a/src/cpphelp.h
+++ b/src/cpphelp.h
@@ -23,6 +23,7 @@
 
 #include <string>
 #include <vector>
+#include <map>
 
 /* Stuff that should be in common but is c++ so it does not fit in there. */
 
@@ -39,4 +40,8 @@ char **vector_to_cArray (const std::vector<std::string> &vec);
 /* Check if we are in de_vs mode. */
 bool in_de_vs_mode ();
 
+/* Get a map of all subkey value pairs in a registry key */
+std::map<std::string, std::string> get_registry_subkeys (const char *path);
+
+std::vector<std::string> gpgol_split(const std::string &s, char delim);
 #endif // CPPHELP_H

commit bd2a79d9661a5e204a56e7b64da785b04ece1583
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Mar 2 14:32:08 2018 +0100

    Move registry helper code into common
    
    * src/common.c (load_extension_value, store_extension_value),
    (store_config_value, load_config_value, expand_path): Moved
    from config-dialog.c
    * src/config-dialog.c: Remove moved functions.

diff --git a/src/common.c b/src/common.c
index 724aebe..8997b16 100644
--- a/src/common.c
+++ b/src/common.c
@@ -40,6 +40,9 @@
 
 #include "dialogs.h"
 
+/* Registry path to store plugin settings */
+#define GPGOL_REGPATH "Software\\GNU\\GpgOL"
+
 HINSTANCE glob_hinst = NULL;
 
 void
@@ -1057,3 +1060,121 @@ gpgol_message_box (HWND parent, const char *utf8_text,
   xfree (w_caption);
   return ret;
 }
+
+static char*
+expand_path (const char *path)
+{
+  DWORD len;
+  char *p;
+
+  len = ExpandEnvironmentStrings (path, NULL, 0);
+  if (!len)
+    {
+      return NULL;
+    }
+  len += 1;
+  p = xcalloc (1, len+1);
+  if (!p)
+    {
+      return NULL;
+    }
+  len = ExpandEnvironmentStrings (path, p, len);
+  if (!len)
+    {
+      xfree (p);
+      return NULL;
+    }
+  return p;
+}
+
+static int
+load_config_value (HKEY hk, const char *path, const char *key, char **val)
+{
+  HKEY h;
+  DWORD size=0, type;
+  int ec;
+
+  *val = NULL;
+  if (hk == NULL)
+    {
+      hk = HKEY_CURRENT_USER;
+    }
+  ec = RegOpenKeyEx (hk, path, 0, KEY_READ, &h);
+  if (ec != ERROR_SUCCESS)
+    {
+      return -1;
+    }
+
+  ec = RegQueryValueEx(h, key, NULL, &type, NULL, &size);
+  if (ec != ERROR_SUCCESS)
+    {
+      RegCloseKey (h);
+      return -1;
+    }
+  if (type == REG_EXPAND_SZ)
+    {
+      char tmp[256];
+      RegQueryValueEx (h, key, NULL, NULL, (BYTE*)tmp, &size);
+      *val = expand_path (tmp);
+    }
+  else
+    {
+      *val = xcalloc(1, size+1);
+      ec = RegQueryValueEx (h, key, NULL, &type, (BYTE*)*val, &size);
+      if (ec != ERROR_SUCCESS)
+        {
+          xfree (*val);
+          *val = NULL;
+          RegCloseKey (h);
+          return -1;
+        }
+    }
+  RegCloseKey (h);
+  return 0;
+}
+
+static int
+store_config_value (HKEY hk, const char *path, const char *key, const char *val)
+{
+  HKEY h;
+  int type;
+  int ec;
+
+  if (hk == NULL)
+    {
+      hk = HKEY_CURRENT_USER;
+    }
+  ec = RegCreateKeyEx (hk, path, 0, NULL, REG_OPTION_NON_VOLATILE,
+                       KEY_ALL_ACCESS, NULL, &h, NULL);
+  if (ec != ERROR_SUCCESS)
+    {
+      log_debug_w32 (ec, "creating/opening registry key `%s' failed", path);
+      return -1;
+    }
+  type = strchr (val, '%')? REG_EXPAND_SZ : REG_SZ;
+  ec = RegSetValueEx (h, key, 0, type, (const BYTE*)val, strlen (val));
+  if (ec != ERROR_SUCCESS)
+    {
+      log_debug_w32 (ec, "saving registry key `%s'->`%s' failed", path, key);
+      RegCloseKey(h);
+      return -1;
+    }
+  RegCloseKey(h);
+  return 0;
+}
+
+/* Store a key in the registry with the key given by @key and the
+   value @value. */
+int
+store_extension_value (const char *key, const char *val)
+{
+  return store_config_value (HKEY_CURRENT_USER, GPGOL_REGPATH, key, val);
+}
+
+/* Load a key from the registry with the key given by @key. The value is
+   returned in @val and needs to freed by the caller. */
+int
+load_extension_value (const char *key, char **val)
+{
+  return load_config_value (HKEY_CURRENT_USER, GPGOL_REGPATH, key, val);
+}
diff --git a/src/config-dialog.c b/src/config-dialog.c
index 14573d2..b2663f7 100644
--- a/src/config-dialog.c
+++ b/src/config-dialog.c
@@ -23,108 +23,11 @@
 #include <windows.h>
 #include <shellapi.h>
 #include <shlobj.h>
-#include <time.h>
-#include <sys/stat.h>
-#include <unistd.h>
 
 #include "common.h"
 #include "gpgol-ids.h"
 #include "dialogs.h"
 
-
-/* Registry path to store plugin settings */
-#define GPGOL_REGPATH "Software\\GNU\\GpgOL"
-
-
-static char*
-expand_path (const char *path)
-{
-    DWORD len;
-    char *p;
-
-    len = ExpandEnvironmentStrings (path, NULL, 0);
-    if (!len)
-	return NULL;
-    len += 1;
-    p = xcalloc (1, len+1);
-    if (!p)
-	return NULL;
-    len = ExpandEnvironmentStrings (path, p, len);
-    if (!len) {
-	xfree (p);
-	return NULL;
-    }
-    return p; 
-}
-
-static int
-load_config_value (HKEY hk, const char *path, const char *key, char **val)
-{
-    HKEY h;
-    DWORD size=0, type;
-    int ec;
-
-    *val = NULL;
-    if (hk == NULL)
-	hk = HKEY_CURRENT_USER;
-    ec = RegOpenKeyEx (hk, path, 0, KEY_READ, &h);
-    if (ec != ERROR_SUCCESS)
-	return -1;
-
-    ec = RegQueryValueEx(h, key, NULL, &type, NULL, &size);
-    if (ec != ERROR_SUCCESS) {
-	RegCloseKey (h);
-	return -1;
-    }
-    if (type == REG_EXPAND_SZ) {
-	char tmp[256]; /* XXX: do not use a static buf */
-	RegQueryValueEx (h, key, NULL, NULL, (BYTE*)tmp, &size);
-	*val = expand_path (tmp);
-    }
-    else {
-	*val = xcalloc(1, size+1);
-	ec = RegQueryValueEx (h, key, NULL, &type, (BYTE*)*val, &size);
-	if (ec != ERROR_SUCCESS) {
-	    xfree (*val);
-	    *val = NULL;
-	    RegCloseKey (h);
-	    return -1;
-	}
-    }
-    RegCloseKey (h);
-    return 0;
-}
-
-
-static int
-store_config_value (HKEY hk, const char *path, const char *key, const char *val)
-{
-  HKEY h;
-  int type;
-  int ec;
-  
-  if (hk == NULL)
-    hk = HKEY_CURRENT_USER;
-  ec = RegCreateKeyEx (hk, path, 0, NULL, REG_OPTION_NON_VOLATILE,
-                       KEY_ALL_ACCESS, NULL, &h, NULL);
-  if (ec != ERROR_SUCCESS)
-    {
-      log_debug_w32 (ec, "creating/opening registry key `%s' failed", path);
-      return -1;
-    }
-  type = strchr (val, '%')? REG_EXPAND_SZ : REG_SZ;
-  ec = RegSetValueEx (h, key, 0, type, (const BYTE*)val, strlen (val));
-  if (ec != ERROR_SUCCESS)
-    {
-      log_debug_w32 (ec, "saving registry key `%s'->`%s' failed", path, key);
-      RegCloseKey(h);
-      return -1;
-    }
-  RegCloseKey(h);
-  return 0;
-}
-
-
 /* To avoid writing a dialog template for each language we use gettext
    for the labels and hope that there is enough space in the dialog to
    fit teh longest translation.  */
@@ -139,8 +42,8 @@ config_dlg_set_labels (HWND dlg)
 
   for (i=0; labels[i].itemid; i++)
     SetDlgItemText (dlg, labels[i].itemid, _(labels[i].label));
-  
-}  
+
+}
 
 static BOOL CALLBACK
 config_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -150,7 +53,7 @@ config_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
   const char *s;
 
   (void)lparam;
-  
+
   switch (msg) 
     {
     case WM_INITDIALOG:
@@ -159,23 +62,21 @@ config_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
       SetDlgItemText (dlg, IDC_DEBUG_LOGFILE, s? s:"");
       config_dlg_set_labels (dlg);
       break;
-      
+
     case WM_COMMAND:
       switch (LOWORD (wparam)) 
         {
-	case IDOK:
+        case IDOK:
           n = GetDlgItemText (dlg, IDC_DEBUG_LOGFILE, name, MAX_PATH-1);
           set_log_file (n>0?name:NULL);
           EndDialog (dlg, TRUE);
           break;
-	}
+        }
       break;
     }
-  
   return FALSE;
 }
 
-
 /* Display GPG configuration dialog. */
 void
 config_dialog_box (HWND parent)
@@ -193,21 +94,3 @@ config_dialog_box (HWND parent)
   (void)config_dlg_proc;
 #endif
 }
-
-
-
-/* Store a key in the registry with the key given by @key and the 
-   value @value. */
-int
-store_extension_value (const char *key, const char *val)
-{
-    return store_config_value (HKEY_CURRENT_USER, GPGOL_REGPATH, key, val);
-}
-
-/* Load a key from the registry with the key given by @key. The value is
-   returned in @val and needs to freed by the caller. */
-int
-load_extension_value (const char *key, char **val)
-{
-    return load_config_value (HKEY_CURRENT_USER, GPGOL_REGPATH, key, val);
-}

-----------------------------------------------------------------------

Summary of changes:
 src/common.c        | 131 ++++++++++++++++++++++++++++++++++++++++
 src/common.h        |  10 ++-
 src/config-dialog.c | 129 ++-------------------------------------
 src/cpphelp.cpp     | 115 ++++++++++++++++++++++++++++++++++-
 src/cpphelp.h       |   5 ++
 src/wks-helper.cpp  | 171 ++++++++++++++++++++++++++++++++++++++++++++++------
 src/wks-helper.h    |   8 ++-
 7 files changed, 421 insertions(+), 148 deletions(-)


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list