[svn] GPGol - r99 - trunk/src

svn author wk cvs at cvs.gnupg.org
Mon Sep 19 12:00:27 CEST 2005


Author: wk
Date: 2005-09-19 12:00:26 +0200 (Mon, 19 Sep 2005)
New Revision: 99

Modified:
   trunk/src/ChangeLog
   trunk/src/display.cpp
   trunk/src/gpgmsg.cpp
   trunk/src/main.c
   trunk/src/watcher.cpp
Log:
Merged Timos changes.

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2005-09-16 11:12:16 UTC (rev 98)
+++ trunk/src/ChangeLog	2005-09-19 10:00:26 UTC (rev 99)
@@ -1,3 +1,12 @@
+2005-09-19  Werner Koch  <wk at g10code.com>
+
+	* main.c (DllMain): Removed debug output; this should not be
+	used before initialization!
+
+	* watcher.cpp: Include config.h.  Removed weird line endings.
+
+	* gpgmsg.cpp (encrypt_and_sign): Call SaveChanges.
+
 2005-09-15  Timo Schulz  <ts at g10code.com>
 
 	* util.h: Provider watcher prototypes.
@@ -40,7 +49,7 @@
 	* gpgmsg.cpp (decryptAttachment, decrypt): Save plaintext back
 	into the MAPI if desired.
 
-g2004-09-08  Timo Schulz  <ts at g10code.com>
+2004-09-08  Timo Schulz  <ts at g10code.com>
 
 	* passphrase-dialog.c (lod_recipbox): Use gpgme directly
 	to resolve the keyids to userids.


Property changes on: trunk/src/display.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/src/gpgmsg.cpp
===================================================================
--- trunk/src/gpgmsg.cpp	2005-09-16 11:12:16 UTC (rev 98)
+++ trunk/src/gpgmsg.cpp	2005-09-19 10:00:26 UTC (rev 99)
@@ -1193,6 +1193,7 @@
 GpgMsgImpl::encrypt_and_sign (HWND hwnd, bool sign_flag)
 {
   log_debug ("%s:%s: enter\n", __FILE__, __func__);
+  HRESULT hr;
   gpgme_key_t *keys = NULL;
   gpgme_key_t sign_key = NULL;
   bool is_html;
@@ -1331,6 +1332,14 @@
         err = set_message_body (message, ciphertext);
       if (err)
         goto leave;
+      hr = message->SaveChanges (KEEP_OPEN_READWRITE|FORCE_SAVE);
+      if (hr != S_OK)
+        {
+          log_error ("%s:%s: SaveChanges(message) failed: hr=%#lx\n",
+                     __FILE__, __func__, hr); 
+          err = gpg_error (GPG_ERR_GENERAL);
+          goto leave;
+        }
     }
 
 
@@ -2256,7 +2265,7 @@
 }
 
 
-/* Sign the attachment with the internal number POS.  TTL is caching
+/* Sign the attachment with the internal number POS.  TTL is the caching
    time for a required passphrase. */
 void
 GpgMsgImpl::signAttachment (HWND hwnd, int pos, gpgme_key_t sign_key, int ttl)


Property changes on: trunk/src/gpgmsg.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2005-09-16 11:12:16 UTC (rev 98)
+++ trunk/src/main.c	2005-09-19 10:00:26 UTC (rev 99)
@@ -81,7 +81,6 @@
 {
   if (reason == DLL_PROCESS_ATTACH)
     {
-      log_debug ("%s: attached to process\n", __func__);
       set_global_hinstance (hinst);
       /* The next call initializes subsystems of gpgme and should be
          done as early as possible.  The actual return value is (the
@@ -101,7 +100,6 @@
   else if (reason == DLL_PROCESS_DETACH)
     {
       watcher_free_hook ();
-      log_debug ("%s: detached from process\n", __func__);
     }
   
   return TRUE;

Modified: trunk/src/watcher.cpp
===================================================================
--- trunk/src/watcher.cpp	2005-09-16 11:12:16 UTC (rev 98)
+++ trunk/src/watcher.cpp	2005-09-19 10:00:26 UTC (rev 99)
@@ -19,176 +19,178 @@
  * 02110-1301, USA.
  */
 
-#include <windows.h>
-#include <stdio.h>
-#include <gpgme.h>
-
-#include "mymapi.h"
-#include "myexchext.h"
-#include "mymapitags.h"
-#include "gpgmsg.hh"
-#include "util.h"
-#include "intern.h"
-
-/* Exchange callback context to retrieve the last message. */
-static LPEXCHEXTCALLBACK g_cb = NULL;
-
-/* The current hook handle. */
-static HHOOK             g_cbt_hook = NULL;
-
-/* MAPI message and storage handle. */
-static LPMESSAGE         g_msg = NULL;
-static LPMDB             g_mdb = NULL;
-static HWND              g_creat_wnd = 0;
-
-static HWND
-find_message_window2 (HWND parent)
-{
-  HWND child;
-
-  if (!parent)
-    return NULL;
-
-  child = GetWindow (parent, GW_CHILD);
-  while (child)
-    {
-      char buf[1024+1];
-      HWND w;
-      size_t len;
-      const char *s;
-      
-      memset (buf, 0, sizeof (buf));
-      GetWindowText (child, buf, sizeof (buf)-1);
-      len = strlen (buf);
-      if (len > 22
-          && (s = strstr (buf, "-----BEGIN PGP "))
-          &&  (!strncmp (s+15, "MESSAGE-----", 12)
-               || !strncmp (s+15, "SIGNED MESSAGE-----", 19)))
-        return child;
-      w = find_message_window2 (child);
-      if (w)
-	{
-	  log_debug ("%s: watcher found message window: %p\n", __func__, w);
-	  return w;
-	}
-      
-      child = GetNextWindow (child, GW_HWNDNEXT);	
-    }
-
-  return NULL;
-}
-
-
-static void
-decrypt_message (HWND hwnd, LPMESSAGE msg)
-{
-  GpgMsg *m = CreateGpgMsg (msg);
-  m->setExchangeCallback ((void *)g_cb);
-  m->decrypt (hwnd);
-  delete m;
-  UlRelease (msg);
-  msg = NULL;
-}
-
-
-/* XXX: describe what we are doing here! */
-
-static LRESULT CALLBACK
-cbt_proc (int code, WPARAM w, LPARAM l)
-{
-  char wclass[128];
-  HWND msgwnd, hwnd;
-
-  if (code < 0)
-    return CallNextHookEx (g_cbt_hook, code, w, l);
-  
-  hwnd = (HWND)w;
-  if (code == HCBT_CREATEWND)
-    {
-      GetClassName (hwnd, wclass, 127);
-      if (strstr (wclass, "rctrl_renwnd32"))
-	{
-	  g_creat_wnd = hwnd;
-	  log_debug ("%s: watch for window %p\n", __func__, hwnd);
-	}
-      
-    }
-  
-  if (code == HCBT_ACTIVATE && g_creat_wnd == hwnd)
-    {
-      log_debug ("%s: %p == %p?\n", __func__, g_creat_wnd, hwnd);
-      g_creat_wnd = NULL;
-      msgwnd = find_message_window2 (hwnd);
-      if (msgwnd && g_msg)
-	{
-	  log_debug ("%s: decrypt_message(%p, %p)\n", __func__, hwnd, g_msg);
-	  decrypt_message (hwnd, g_msg);
-	  UlRelease (g_mdb); 
-	  g_mdb = NULL;
-	}
-    }
-
-    return CallNextHookEx (g_cbt_hook, code, w, l);
-}
-
-
-/* Initialize the CBT hook. */
-extern "C" int
-watcher_init_hook (void)
-{
-  if (g_cbt_hook != NULL)
-    return 0;
-  g_cbt_hook = SetWindowsHookEx (WH_CBT, cbt_proc, glob_hinst, 0);
-  if (!g_cbt_hook)
-    {
-      log_debug ("%s: SetWindowsHookEx failed ec=%d\n", 
-		 __func__, (int)GetLastError ());
-      return -1;
-    }  
-  return 0;
-}
-
-
-/* Remove the CBT hook. */
-extern "C" int
-watcher_free_hook (void)
-{
-  if (g_msg != NULL) 
-    {
-      UlRelease (g_msg);
-      g_msg = NULL;
-    }
-  if (g_mdb != NULL) 
-    {
-      UlRelease (g_mdb);
-      g_mdb = NULL;
-    }
-  if (g_cbt_hook != NULL)
-    {
-      UnhookWindowsHookEx (g_cbt_hook);
-      g_cbt_hook = NULL;
-    }  
-  return 0;
-}
-
-
-/* Set the Exchange callback context. */
-extern "C" void
-watcher_set_callback_ctx (void *cb)
-{     
-  HRESULT hr;
-  
-  g_cb = (LPEXCHEXTCALLBACK)cb;
-
-  if (g_msg != NULL)
-    UlRelease (g_msg);
-  if (g_mdb != NULL)
-    UlRelease (g_mdb);
-  hr = g_cb->GetObject (&g_mdb, (LPMAPIPROP *)&g_msg);
-  if (FAILED (hr)) 
-    {
-      log_debug ("%s: GetObject() failed ec=%lx\n", __func__, hr);
-      g_mdb = NULL;
-      g_msg = NULL;
-    }
-}
+#include <config.h>
+
+#include <windows.h>
+#include <stdio.h>
+#include <gpgme.h>
+
+#include "mymapi.h"
+#include "myexchext.h"
+#include "mymapitags.h"
+#include "gpgmsg.hh"
+#include "util.h"
+#include "intern.h"
+
+/* Exchange callback context to retrieve the last message. */
+static LPEXCHEXTCALLBACK g_cb = NULL;
+
+/* The current hook handle. */
+static HHOOK             g_cbt_hook = NULL;
+
+/* MAPI message and storage handle. */
+static LPMESSAGE         g_msg = NULL;
+static LPMDB             g_mdb = NULL;
+static HWND              g_creat_wnd = 0;
+
+static HWND
+find_message_window2 (HWND parent)
+{
+  HWND child;
+
+  if (!parent)
+    return NULL;
+
+  child = GetWindow (parent, GW_CHILD);
+  while (child)
+    {
+      char buf[1024+1];
+      HWND w;
+      size_t len;
+      const char *s;
+      
+      memset (buf, 0, sizeof (buf));
+      GetWindowText (child, buf, sizeof (buf)-1);
+      len = strlen (buf);
+      if (len > 22
+          && (s = strstr (buf, "-----BEGIN PGP "))
+          &&  (!strncmp (s+15, "MESSAGE-----", 12)
+               || !strncmp (s+15, "SIGNED MESSAGE-----", 19)))
+        return child;
+      w = find_message_window2 (child);
+      if (w)
+	{
+	  log_debug ("%s: watcher found message window: %p\n", __func__, w);
+	  return w;
+	}
+      
+      child = GetNextWindow (child, GW_HWNDNEXT);	
+    }
+
+  return NULL;
+}
+
+
+static void
+decrypt_message (HWND hwnd, LPMESSAGE msg)
+{
+  GpgMsg *m = CreateGpgMsg (msg);
+  m->setExchangeCallback ((void *)g_cb);
+  m->decrypt (hwnd);
+  delete m;
+  UlRelease (msg);
+  msg = NULL;
+}
+
+
+/* XXX: describe what we are doing here! */
+
+static LRESULT CALLBACK
+cbt_proc (int code, WPARAM w, LPARAM l)
+{
+  char wclass[128];
+  HWND msgwnd, hwnd;
+
+  if (code < 0)
+    return CallNextHookEx (g_cbt_hook, code, w, l);
+  
+  hwnd = (HWND)w;
+  if (code == HCBT_CREATEWND)
+    {
+      GetClassName (hwnd, wclass, 127);
+      if (strstr (wclass, "rctrl_renwnd32"))
+	{
+	  g_creat_wnd = hwnd;
+	  log_debug ("%s: watch for window %p\n", __func__, hwnd);
+	}
+      
+    }
+  
+  if (code == HCBT_ACTIVATE && g_creat_wnd == hwnd)
+    {
+      log_debug ("%s: %p == %p?\n", __func__, g_creat_wnd, hwnd);
+      g_creat_wnd = NULL;
+      msgwnd = find_message_window2 (hwnd);
+      if (msgwnd && g_msg)
+	{
+	  log_debug ("%s: decrypt_message(%p, %p)\n", __func__, hwnd, g_msg);
+	  decrypt_message (hwnd, g_msg);
+	  UlRelease (g_mdb); 
+	  g_mdb = NULL;
+	}
+    }
+
+    return CallNextHookEx (g_cbt_hook, code, w, l);
+}
+
+
+/* Initialize the CBT hook. */
+extern "C" int
+watcher_init_hook (void)
+{
+  if (g_cbt_hook != NULL)
+    return 0;
+  g_cbt_hook = SetWindowsHookEx (WH_CBT, cbt_proc, glob_hinst, 0);
+  if (!g_cbt_hook)
+    {
+      log_debug ("%s: SetWindowsHookEx failed ec=%d\n", 
+		 __func__, (int)GetLastError ());
+      return -1;
+    }  
+  return 0;
+}
+
+
+/* Remove the CBT hook. */
+extern "C" int
+watcher_free_hook (void)
+{
+  if (g_msg != NULL) 
+    {
+      UlRelease (g_msg);
+      g_msg = NULL;
+    }
+  if (g_mdb != NULL) 
+    {
+      UlRelease (g_mdb);
+      g_mdb = NULL;
+    }
+  if (g_cbt_hook != NULL)
+    {
+      UnhookWindowsHookEx (g_cbt_hook);
+      g_cbt_hook = NULL;
+    }  
+  return 0;
+}
+
+
+/* Set the Exchange callback context. */
+extern "C" void
+watcher_set_callback_ctx (void *cb)
+{     
+  HRESULT hr;
+  
+  g_cb = (LPEXCHEXTCALLBACK)cb;
+
+  if (g_msg != NULL)
+    UlRelease (g_msg);
+  if (g_mdb != NULL)
+    UlRelease (g_mdb);
+  hr = g_cb->GetObject (&g_mdb, (LPMAPIPROP *)&g_msg);
+  if (FAILED (hr)) 
+    {
+      log_debug ("%s: GetObject() failed ec=%lx\n", __func__, hr);
+      g_mdb = NULL;
+      g_msg = NULL;
+    }
+}


Property changes on: trunk/src/watcher.cpp
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the Gnupg-commits mailing list