[svn] GpgOL - r311 - in trunk: . po src
svn author wk
cvs at cvs.gnupg.org
Wed Oct 28 20:26:07 CET 2009
Author: wk
Date: 2009-10-28 20:26:06 +0100 (Wed, 28 Oct 2009)
New Revision: 311
Added:
trunk/src/cmdbarcontrols.cpp
trunk/src/cmdbarcontrols.h
trunk/src/decrypt-mask.bmp
trunk/src/decrypt-verify-mask.bmp
trunk/src/decrypt-verify.bmp
trunk/src/explorers.cpp
trunk/src/explorers.h
trunk/src/inspectors.cpp
trunk/src/inspectors.h
trunk/src/key-manager-mask.bmp
trunk/src/key-manager.bmp
trunk/src/oomhelp.cpp
trunk/src/oomhelp.h
trunk/src/sign-mask.bmp
trunk/src/verify-mask.bmp
trunk/src/verify.bmp
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/configure.ac
trunk/po/de.po
trunk/po/sv.po
trunk/src/ChangeLog
trunk/src/Makefile.am
trunk/src/common.c
trunk/src/common.h
trunk/src/decrypt.bmp
trunk/src/dialogs.h
trunk/src/dialogs.rc
trunk/src/ext-commands.cpp
trunk/src/ext-commands.h
trunk/src/item-events.h
trunk/src/main.c
trunk/src/message-events.cpp
trunk/src/message.cpp
trunk/src/mimemaker.c
trunk/src/myexchext.h
trunk/src/ol-ext-callback.cpp
trunk/src/ol-ext-callback.h
trunk/src/olflange-dlgs.cpp
trunk/src/olflange.cpp
trunk/src/sign.bmp
trunk/src/user-events.cpp
trunk/src/util.h
Log:
A bunch of changes to support better looking icons.
CLeaned up some code and introduced a lot of code to support the OOM.
[The diff below has been truncated]
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-09-28 09:51:56 UTC (rev 310)
+++ trunk/ChangeLog 2009-10-28 19:26:06 UTC (rev 311)
@@ -1,3 +1,7 @@
+2009-10-08 Werner Koch <wk at g10code.com>
+
+ * configure.ac (CFLAGS): Add -fno-strict-aliasing.
+
2009-09-28 Werner Koch <wk at g10code.com>
Release 1.0.1.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2009-09-28 09:51:56 UTC (rev 310)
+++ trunk/src/ChangeLog 2009-10-28 19:26:06 UTC (rev 311)
@@ -1,3 +1,47 @@
+2009-10-28 Werner Koch <wk at g10code.com>
+
+ * ext-commands.cpp: Remove m_nCmdCryptoState and all related code;
+ now handled in inspectors.cpp. Remove m_nCmdKeyManager and all
+ related code; now handled in cmdbarcontrols.cpp.
+
+ * oomhelp.cpp, oomhelp.h, eventsink.h: New.
+ * myexchext.h: Move generic COM+ stuff to oomhelp.h.
+ * explorers.cpp, explorers.h: New.
+ * inspectors.cpp, inspectors.h: New.
+ * cmdbarcontrols.cpp cmdbarcontrols.h: New.
+ * olflange.cpp (install_sinks): New.
+ (Install): Call install_sinks.
+ * main.c (DllMain): Call initialize_inspectors.
+
+ * common.c (fatal_error): New.
+
+2009-10-20 Werner Koch <wk at g10code.com>
+
+ * myexchext.h (IID_IConnectionPoint)
+ (IID_IConnectionPointContainer): Define. There are missing in
+ current wine From ReactOS.
+
+2009-10-19 Werner Koch <wk at g10code.com>
+
+ * message-events.cpp (show_event_object): Move to ..
+ * ol-ext-callback.cpp (show_event_object): .. here.
+ (show_preview_pane): Revert dispparms order to make it work.
+
+ * common.c (mem2str): New.
+
+2009-10-07 Werner Koch <wk at g10code.com>
+
+ * ext-commands.cpp (InstallCommands): Comment out the protocol
+ selection.
+ (DoCommand, Help, QueryHelpText, QueryButtonInfo): Ditto.
+ (update_protocol_menu): Comment out.
+ * main.c (write_options): Do not write the default protocol.
+ (read_options): Always set it to auto.
+ * dialogs.rc: Remove openpgp-by-default and smime-by-default check
+ boxes.
+ * olflange-dlgs.cpp (set_labels): Likewise.
+ (GPGOptionsDlgProc): Likewise.
+
2009-09-25 Werner Koch <wk at g10code.com>
* main.c (read_options): Enable Smime by default.
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2009-09-28 09:51:56 UTC (rev 310)
+++ trunk/NEWS 2009-10-28 19:26:06 UTC (rev 311)
@@ -1,3 +1,15 @@
+Noteworthy changes for version 1.1.0
+===================================================
+
+ * Replaced some ECF code by direct OOM code. This was required to
+ support better icons; i.e. icons not limited to a 16 color palette.
+
+ * New icons.
+
+ * Removed protocol selection. The UI-server is now expected to select
+ the protocol (i.e. the auto selection modus is now the only one).
+
+
Noteworthy changes for version 1.0.1 (2009-09-28)
===================================================
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2009-09-28 09:51:56 UTC (rev 310)
+++ trunk/configure.ac 2009-10-28 19:26:06 UTC (rev 311)
@@ -16,8 +16,8 @@
# Remember to change the version number immediately *after* a release.
# Set my_issvn to "yes" for non-released code. Remember to run an
# "svn up" and "autogen.sh" right before creating a distribution.
-m4_define([my_version], [1.0.1])
-m4_define([my_issvn], [no])
+m4_define([my_version], [1.1.0])
+m4_define([my_issvn], [yes])
m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \
|| echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')]))
@@ -190,8 +190,8 @@
fi
if test "$GCC" = yes; then
- CFLAGS="$CFLAGS -Wall -mms-bitfields"
- CXXFLAGS="$CXXFLAGS -Wall -mms-bitfields"
+ CFLAGS="$CFLAGS -Wall -mms-bitfields -fno-strict-aliasing"
+ CXXFLAGS="$CXXFLAGS -Wall -mms-bitfields -fno-strict-aliasing"
if test "$USE_MAINTAINER_MODE" = "yes"; then
CFLAGS="$CFLAGS -Wcast-align -Wshadow -Wstrict-prototypes"
CFLAGS="$CFLAGS -Wno-format-y2k -Wformat-security"
Modified: trunk/po/de.po [not shown]
Modified: trunk/po/sv.po [not shown]
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-09-28 09:51:56 UTC (rev 310)
+++ trunk/src/Makefile.am 2009-10-28 19:26:06 UTC (rev 311)
@@ -16,9 +16,14 @@
bin_PROGRAMS = gpgol
#treeview
EXTRA_DIST = versioninfo.rc.in mapi32.def $(unused_sources) Outlook.gpl \
- logo.bmp decrypt.bmp encrypt.bmp sign.bmp key_mana.bmp \
+ logo.bmp encrypt.bmp \
proto-auto.bmp proto-pgpmime.bmp proto-smime.bmp \
- cryptostate.bmp
+ cryptostate.bmp \
+ key-manager.bmp key-manager-mask.bmp \
+ decrypt.bmp decrypt-mask.bmp \
+ verify.bmp verify-mask.bmp \
+ decrypt-verify.bmp decrypt-verify-mask.bmp \
+ sign.bmp sign-mask.bmp
EXEEXT = .dll
@@ -63,6 +68,10 @@
property-sheets.cpp property-sheets.h \
item-events.h \
ol-ext-callback.cpp ol-ext-callback.h \
+ oomhelp.cpp oomhelp.h eventsink.h \
+ explorers.cpp explorers.h \
+ inspectors.cpp inspectors.h \
+ cmdbarcontrols.cpp cmdbarcontrols.h \
w32-gettext.c w32-gettext.h
Added: trunk/src/cmdbarcontrols.cpp
===================================================================
--- trunk/src/cmdbarcontrols.cpp (rev 0)
+++ trunk/src/cmdbarcontrols.cpp 2009-10-28 19:26:06 UTC (rev 311)
@@ -0,0 +1,132 @@
+/* cmdbarcontrols.cpp - Code to handle the CommandBarControls
+ * Copyright (C) 2009 g10 Code GmbH
+ *
+ * This file is part of GpgOL.
+ *
+ * GpgOL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GpgOL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <windows.h>
+#include <olectl.h>
+
+#include "common.h"
+#include "oomhelp.h"
+#include "cmdbarcontrols.h"
+#include "inspectors.h"
+#include "engine.h"
+
+#include "eventsink.h"
+
+
+/* Subclass of CommandBarButtonEvents so that we can hook into the
+ Click event. */
+BEGIN_EVENT_SINK(GpgolCommandBarButtonEvents, IOOMCommandBarButtonEvents)
+ STDMETHOD (Click) (THIS_ LPDISPATCH, PBOOL);
+EVENT_SINK_DEFAULT_DTOR(GpgolCommandBarButtonEvents)
+EVENT_SINK_INVOKE(GpgolCommandBarButtonEvents)
+{
+ HRESULT hr;
+ (void)lcid; (void)riid; (void)result; (void)exepinfo; (void)argerr;
+
+ if (dispid == 1 && (flags & DISPATCH_METHOD))
+ {
+ if (!parms)
+ hr = DISP_E_PARAMNOTOPTIONAL;
+ else if (parms->cArgs != 2)
+ hr = DISP_E_BADPARAMCOUNT;
+ else if (parms->rgvarg[0].vt != (VT_BOOL|VT_BYREF)
+ || parms->rgvarg[1].vt != VT_DISPATCH)
+ hr = DISP_E_BADVARTYPE;
+ else
+ {
+ BOOL cancel_default = !!*parms->rgvarg[0].pboolVal;
+ hr = Click (parms->rgvarg[1].pdispVal, (PBOOL)&cancel_default);
+ *parms->rgvarg[0].pboolVal = (cancel_default
+ ? VARIANT_TRUE:VARIANT_FALSE);
+ }
+ }
+ else
+ hr = DISP_E_MEMBERNOTFOUND;
+ return hr;
+}
+END_EVENT_SINK(GpgolCommandBarButtonEvents, IID_IOOMCommandBarButtonEvents)
+
+
+
+
+static int
+tagcmp (const char *a, const char *b)
+{
+ return strncmp (a, b, strlen (b));
+}
+
+
+/* This is the event sink for a button click. */
+STDMETHODIMP
+GpgolCommandBarButtonEvents::Click (LPDISPATCH button, PBOOL cancel_default)
+{
+ char *tag;
+
+ (void)cancel_default;
+ log_debug ("%s:%s: Called", SRCNAME, __func__);
+
+ {
+ char *tmp = get_object_name (button);
+ log_debug ("%s:%s: button is %p (%s)",
+ SRCNAME, __func__, button, tmp? tmp:"(null)");
+ xfree (tmp);
+ }
+
+ tag = get_oom_string (button, "Tag");
+ log_debug ("%s:%s: button's tag is (%s)",
+ SRCNAME, __func__, tag? tag:"(null)");
+ if (!tag)
+ ;
+ else if (!tagcmp (tag, "GpgOL_Start_Key_Manager"))
+ {
+ /* FIXME: We don't have the current window handle. */
+ if (engine_start_keymanager (NULL))
+ MessageBox (NULL, _("Could not start certificate manager"),
+ _("GpgOL"), MB_ICONERROR|MB_OK);
+ }
+ else if (!tagcmp (tag, "GpgOL_Inspector_Crypto_Info"))
+ {
+ /* FIXME: We should invoke the decrypt/verify again. */
+ update_inspector_crypto_info (button);
+#if 0 /* This is the code we used to use. */
+ log_debug ("%s:%s: command CryptoState called\n", SRCNAME, __func__);
+ hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message);
+ if (SUCCEEDED (hr))
+ {
+ if (message_incoming_handler (message, hwnd, true))
+ message_display_handler (eecb, hwnd);
+ }
+ else
+ log_debug_w32 (hr, "%s:%s: command CryptoState failed",
+ SRCNAME, __func__);
+ ul_release (message, __func__, __LINE__);
+ ul_release (mdb, __func__, __LINE__);
+#endif
+
+ }
+
+ xfree (tag);
+ return S_OK;
+}
+
+
Added: trunk/src/cmdbarcontrols.h
===================================================================
--- trunk/src/cmdbarcontrols.h (rev 0)
+++ trunk/src/cmdbarcontrols.h 2009-10-28 19:26:06 UTC (rev 311)
@@ -0,0 +1,63 @@
+/* cmdbarcontrols.h - Defs to handle the CommandBarControls
+ * Copyright (C) 2009 g10 Code GmbH
+ *
+ * This file is part of GpgOL.
+ *
+ * GpgOL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GpgOL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CMDBARCONTROLS_H
+#define CMDBARCONTROLS_H
+
+#include <commctrl.h>
+#include "oomhelp.h"
+
+DEFINE_OLEGUID(IID_IOOMCommandBarButtonEvents, 0x000c0351, 0, 0);
+
+typedef struct IOOMCommandBarButtonEvents IOOMCommandBarButtonEvents;
+typedef IOOMCommandBarButtonEvents *LPOOMCOMMANDBARBUTTONEVENTS;
+
+struct IOOMCommandBarButton;
+typedef IOOMCommandBarButton *LPOOMCOMMANDBARBUTTON;
+
+
+EXTERN_C const IID IID_IOOMCommandBarButtonEvents;
+#undef INTERFACE
+#define INTERFACE IOOMCommandBarButtonEvents
+DECLARE_INTERFACE_(IOOMCommandBarButtonEvents, IDispatch)
+{
+ /*** IUnknown methods ***/
+ STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * lppvObj) PURE;
+ STDMETHOD_(ULONG,AddRef) (THIS) PURE;
+ STDMETHOD_(ULONG,Release) (THIS) PURE;
+
+ /*** IDispatch methods ***/
+ STDMETHOD(GetTypeInfoCount)(THIS_ UINT*) PURE;
+ STDMETHOD(GetTypeInfo)(THIS_ UINT, LCID, LPTYPEINFO*) PURE;
+ STDMETHOD(GetIDsOfNames)(THIS_ REFIID, LPOLESTR*, UINT, LCID, DISPID*) PURE;
+ STDMETHOD(Invoke)(THIS_ DISPID, REFIID, LCID, WORD,
+ DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*) PURE;
+
+ /*** IOOMCommandBarButtonEvents methods ***/
+ /* dispid=1 */
+ STDMETHOD(Click)(THIS_ LPDISPATCH, PBOOL) PURE;
+};
+
+
+
+LPDISPATCH install_GpgolCommandBarButtonEvents_sink (LPDISPATCH button);
+
+
+
+#endif /*CMDBARCONTROLS_H*/
Modified: trunk/src/common.c
===================================================================
--- trunk/src/common.c 2009-09-28 09:51:56 UTC (rev 310)
+++ trunk/src/common.c 2009-10-28 19:26:06 UTC (rev 311)
@@ -223,10 +223,25 @@
void
+fatal_error (const char *format, ...)
+{
+ va_list arg_ptr;
+ char buf[512];
+
+ va_start (arg_ptr, format);
+ vsnprintf (buf, sizeof buf -1, format, arg_ptr);
+ buf[sizeof buf - 1] = 0;
+ va_end (arg_ptr);
+ MessageBox (NULL, buf, "Fatal Error", MB_OK);
+ abort ();
+}
+
+
+void
out_of_core (void)
{
- MessageBox (NULL, "Out of core!", "Fatal Error", MB_OK);
- abort ();
+ MessageBox (NULL, "Out of core!", "Fatal Error", MB_OK);
+ abort ();
}
void*
@@ -391,6 +406,38 @@
}
+/* This function is similar to strncpy(). However it won't copy more
+ than N - 1 characters and makes sure that a Nul is appended. With N
+ given as 0, nothing will happen. With DEST given as NULL, memory
+ will be allocated using xmalloc (i.e. if it runs out of core the
+ function terminates). Returns DEST or a pointer to the allocated
+ memory. */
+char *
+mem2str (char *dest, const void *src, size_t n)
+{
+ char *d;
+ const char *s;
+
+ if (n)
+ {
+ if (!dest)
+ dest = xmalloc (n);
+ d = dest;
+ s = src ;
+ for (n--; n && *s; n--)
+ *d++ = *s++;
+ *d = 0;
+ }
+ else if (!dest)
+ {
+ dest = xmalloc (1);
+ *dest = 0;
+ }
+
+ return dest;
+}
+
+
/* Strip off trailing white spaces from STRING. Returns STRING. */
char *
trim_trailing_spaces (char *string)
Modified: trunk/src/common.h
===================================================================
--- trunk/src/common.h 2009-09-28 09:51:56 UTC (rev 310)
+++ trunk/src/common.h 2009-10-28 19:26:06 UTC (rev 311)
@@ -242,6 +242,10 @@
const char *filename);
+/*-- inspectors.cpp --*/
+int initialize_inspectors (void);
+
+
#ifdef __cplusplus
}
#endif
Added: trunk/src/decrypt-mask.bmp
===================================================================
(Binary files differ)
Property changes on: trunk/src/decrypt-mask.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/decrypt-verify-mask.bmp
===================================================================
(Binary files differ)
Property changes on: trunk/src/decrypt-verify-mask.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/decrypt-verify.bmp
===================================================================
(Binary files differ)
Property changes on: trunk/src/decrypt-verify.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/decrypt.bmp
===================================================================
(Binary files differ)
Modified: trunk/src/dialogs.h
===================================================================
--- trunk/src/dialogs.h 2009-09-28 09:51:56 UTC (rev 310)
+++ trunk/src/dialogs.h 2009-10-28 19:26:06 UTC (rev 311)
@@ -7,18 +7,27 @@
#define DIALOGS_H
-/* Ids used for bitmaps. */
-#define IDB_DECRYPT 3001 /* Not used. */
-#define IDB_ENCRYPT 3002
-#define IDB_SIGN 3003
-#define IDB_ADD_KEYS 3004
-#define IDB_KEY_MANAGER 3005
-#define IDB_BANNER 3006 /* The g10 Code logo. */
-#define IDB_BANNER_HI 3007 /* Not used. */
-#define IDB_CRYPTO_STATE 3008
-#define IDB_PROTO_AUTO 3009
-#define IDB_PROTO_PGPMIME 3010
-#define IDB_PROTO_SMIME 3011
+/* Ids used for bitmaps.
+ Note: FOO_MASK must have a value of FOO + 1. */
+#define IDB_ENCRYPT 3004
+#define IDB_SIGN 3006
+#define IDB_SIGN_MASK 3007
+#define IDB_ADD_KEYS 3008
+#define IDB_KEY_MANAGER 3010
+#define IDB_KEY_MANAGER_MASK 3011
+#define IDB_BANNER 3012 /* The g10 Code logo. */
+#define IDB_BANNER_HI 3014 /* Not used. */
+#define IDB_CRYPTO_STATE 3016
+#define IDB_PROTO_AUTO 3018 /* Not used. */
+#define IDB_PROTO_PGPMIME 3020 /* Not used. */
+#define IDB_PROTO_SMIME 3022 /* Not used. */
+#define IDB_PROTO_SMIME_MASK 3023 /* Not used. */
+#define IDB_DECRYPT 3024
+#define IDB_DECRYPT_MASK 3025
+#define IDB_VERIFY 3026
+#define IDB_VERIFY_MASK 3027
+#define IDB_DECRYPT_VERIFY 3028
+#define IDB_DECRYPT_VERIFY_MASK 3029
/* Ids used for the main config dialog. */
Modified: trunk/src/dialogs.rc
===================================================================
--- trunk/src/dialogs.rc 2009-09-28 09:51:56 UTC (rev 310)
+++ trunk/src/dialogs.rc 2009-10-28 19:26:06 UTC (rev 311)
@@ -28,15 +28,26 @@
/*IDB_DECRYPT BITMAP DISCARDABLE "decrypt.bmp"*/
IDB_ENCRYPT BITMAP DISCARDABLE "encrypt.bmp"
-IDB_SIGN BITMAP DISCARDABLE "sign.bmp"
-IDB_KEY_MANAGER BITMAP DISCARDABLE "key_mana.bmp"
IDB_BANNER BITMAP DISCARDABLE "logo.bmp"
IDB_CRYPTO_STATE BITMAP DISCARDABLE "cryptostate.bmp"
IDB_PROTO_AUTO BITMAP DISCARDABLE "proto-auto.bmp"
IDB_PROTO_PGPMIME BITMAP DISCARDABLE "proto-pgpmime.bmp"
IDB_PROTO_SMIME BITMAP DISCARDABLE "proto-smime.bmp"
+IDB_PROTO_SMIME_MASK BITMAP DISCARDABLE "proto-smime-mask.bmp"
+IDB_KEY_MANAGER BITMAP DISCARDABLE "key-manager.bmp"
+IDB_KEY_MANAGER_MASK BITMAP DISCARDABLE "key-manager-mask.bmp"
+IDB_DECRYPT BITMAP DISCARDABLE "decrypt.bmp"
+IDB_DECRYPT_MASK BITMAP DISCARDABLE "decrypt-mask.bmp"
+IDB_VERIFY BITMAP DISCARDABLE "verify.bmp"
+IDB_VERIFY_MASK BITMAP DISCARDABLE "verify-mask.bmp"
+IDB_DECRYPT_VERIFY BITMAP DISCARDABLE "decrypt-verify.bmp"
+IDB_DECRYPT_VERIFY_MASK BITMAP DISCARDABLE "decrypt-verify-mask.bmp"
+IDB_SIGN BITMAP DISCARDABLE "sign.bmp"
+IDB_SIGN_MASK BITMAP DISCARDABLE "sign-mask.bmp"
+
+
IDD_GPG_OPTIONS DIALOG DISCARDABLE 0, 0, 266, 274
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "GpgOL"
@@ -52,7 +63,7 @@
/* Send options box. */
GROUPBOX "send-options", IDC_G_SEND,
- 9, 40, 250, 58
+ 9, 40, 250, 38
CONTROL "encrypt-by-default", IDC_ENCRYPT_DEFAULT,
"Button", BS_AUTOCHECKBOX | WS_TABSTOP,
@@ -62,17 +73,9 @@
"Button", BS_AUTOCHECKBOX | WS_TABSTOP,
24, 61, 215, 10
- CONTROL "openpgp-by-default", IDC_OPENPGP_DEFAULT,
- "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
- 24, 72, 215, 10
-
- CONTROL "smime-by-default", IDC_SMIME_DEFAULT,
- "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
- 24, 83, 215, 10
-
/* Receive options box. */
GROUPBOX "recv-options", IDC_G_RECV,
- 9, 104, 250, 36
+ 9, 82, 250, 36
/* We have no reliable way to detect the preview window, thus we
don't show this option. */
@@ -82,11 +85,11 @@
CONTROL "prefer-html", IDC_PREFER_HTML,
"Button", BS_AUTOCHECKBOX | WS_TABSTOP,
- 24, 114, 215, 10
+ 24, 94, 215, 10
CONTROL "body-as-attachment", IDC_BODY_AS_ATTACHMENT,
"Button", BS_AUTOCHECKBOX | WS_TABSTOP,
- 24, 125, 215, 10
+ 24, 103, 215, 10
/* Stuff at the lower left corner. */
LTEXT "GpgOL by g10 Code GmbH", IDC_G10CODE_STRING,
Added: trunk/src/explorers.cpp
===================================================================
--- trunk/src/explorers.cpp (rev 0)
+++ trunk/src/explorers.cpp 2009-10-28 19:26:06 UTC (rev 311)
@@ -0,0 +1,164 @@
+/* explorers.cpp - Code to handle the OOM Explorers
+ * Copyright (C) 2009 g10 Code GmbH
+ *
+ * This file is part of GpgOL.
+ *
+ * GpgOL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GpgOL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <windows.h>
+#include <olectl.h>
+
+#include "common.h"
+#include "oomhelp.h"
+#include "explorers.h"
+#include "dialogs.h" /* IDB_xxx */
+#include "cmdbarcontrols.h"
+
+#include "eventsink.h"
+
+BEGIN_EVENT_SINK(GpgolExplorersEvents, IOOMExplorersEvents)
+ STDMETHOD (NewExplorer) (THIS_ LPOOMEXPLORER);
+EVENT_SINK_DEFAULT_DTOR(GpgolExplorersEvents)
+EVENT_SINK_INVOKE(GpgolExplorersEvents)
+{
+ HRESULT hr;
+ (void)lcid; (void)riid; (void)result; (void)exepinfo; (void)argerr;
+
+ if (dispid == 0xf001 && (flags & DISPATCH_METHOD))
+ {
+ if (!parms)
+ hr = DISP_E_PARAMNOTOPTIONAL;
+ else if (parms->cArgs != 1)
+ hr = DISP_E_BADPARAMCOUNT;
+ else if (parms->rgvarg[0].vt != VT_DISPATCH)
+ hr = DISP_E_BADVARTYPE;
+ else
+ hr = NewExplorer ((LPOOMEXPLORER)parms->rgvarg[0].pdispVal);
+ }
+ else
+ hr = DISP_E_MEMBERNOTFOUND;
+ return hr;
+}
+END_EVENT_SINK(GpgolExplorersEvents, IID_IOOMExplorersEvents)
+
+
+
+
+/* The method called by outlook for each new explorer. Note that
+ Outlook sometimes reuses Inspectro objects thus this event is not
+ an indication for a newly opened Explorer. */
+STDMETHODIMP
+GpgolExplorersEvents::NewExplorer (LPOOMEXPLORER explorer)
+{
+ log_debug ("%s:%s: Called", SRCNAME, __func__);
+
+ add_explorer_controls (explorer);
+ return S_OK;
+}
+
+
+/* Add buttons to the explorer. */
+void
+add_explorer_controls (LPOOMEXPLORER explorer)
+{
+ LPDISPATCH pObj, pDisp, pTmp;
+
+ log_debug ("%s:%s: Enter", SRCNAME, __func__);
+
+ /* In theory we should take a lock here to avoid a race between the
+ test for a new control and the creation. However, we are not
+ called from a second thread. */
+
+ /* Check that our controls do not already exist. */
+ pObj = get_oom_object (explorer, "CommandBars");
+ if (!pObj)
+ {
+ log_debug ("%s:%s: CommandBars not found", SRCNAME, __func__);
+ return;
+ }
+ pDisp = get_oom_control_bytag (pObj, "GpgOL_Start_Key_Manager");
+ pObj->Release ();
+ pObj = NULL;
+ if (pDisp)
+ {
+ pDisp->Release ();
+ log_debug ("%s:%s: Leave (Controls are already added)",
+ SRCNAME, __func__);
+ return;
+ }
+
+ /* Fixme: To avoid an extra lookup we should use the CommandBars
+ object to start the search for the controls. I tried this but
+ Outlooked crashed. Quite likely my error but I was not able to
+ find the problem. */
+
+ /* Create the Start-Key-Manager menu entry. */
+ pDisp = get_oom_object (explorer,
+ "CommandBars.FindControl(,30007).get_Controls");
+ if (!pDisp)
+ log_debug ("%s:%s: Menu Popup Extras not found\n", SRCNAME, __func__);
+ else
+ {
+ pTmp = add_oom_button (pDisp);
+ pDisp->Release ();
+ pDisp = pTmp;
+ if (pDisp)
+ {
+ put_oom_string (pDisp, "Tag", "GpgOL_Start_Key_Manager");
+ put_oom_int (pDisp, "Style", msoButtonIconAndCaption );
+ put_oom_string (pDisp, "Caption", _("GnuPG Certificate &Manager"));
+ put_oom_string (pDisp, "TooltipText",
+ _("Open the certificate manager"));
+ put_oom_icon (pDisp, IDB_KEY_MANAGER, 16);
+
+ install_GpgolCommandBarButtonEvents_sink (pDisp);
+ pDisp->Release ();
+ }
+ }
+
+ /* Create the Start-Key-Manager toolbar icon. Not ethat we need to
+ use a different tag name here. If we won't do that event sink
+ would be called twice. */
+ pDisp = get_oom_object (explorer,
+ "CommandBars.Item(Standard).get_Controls");
+ if (!pDisp)
+ log_debug ("%s:%s: CommandBar \"Standard\" not found\n",
+ SRCNAME, __func__);
+ else
+ {
+ pTmp = add_oom_button (pDisp);
+ pDisp->Release ();
+ pDisp = pTmp;
+ if (pDisp)
+ {
+ put_oom_string (pDisp, "Tag", "GpgOL_Start_Key_Manager at t");
+ put_oom_int (pDisp, "Style", msoButtonIcon );
+ put_oom_string (pDisp, "TooltipText",
+ _("Open the certificate manager"));
+ put_oom_icon (pDisp, IDB_KEY_MANAGER, 16);
+
+ install_GpgolCommandBarButtonEvents_sink (pDisp);
+ /* Fixme: store the event sink object somewhere. */
+ pDisp->Release ();
+ }
+ }
+
+ log_debug ("%s:%s: Leave", SRCNAME, __func__);
+}
+
Added: trunk/src/explorers.h
===================================================================
--- trunk/src/explorers.h (rev 0)
+++ trunk/src/explorers.h 2009-10-28 19:26:06 UTC (rev 311)
@@ -0,0 +1,91 @@
+/* explorers.h - Defs to handle the OOM Explorers
+ * Copyright (C) 2009 g10 Code GmbH
+ *
+ * This file is part of GpgOL.
+ *
+ * GpgOL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GpgOL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef EXPLORERS_H
+#define EXPLORERS_H
+
+#include "myexchext.h"
+
+DEFINE_OLEGUID(IID_IOOMExplorer, 0x00063003, 0, 0);
+DEFINE_OLEGUID(IID_IOOMExplorers, 0x0006300A, 0, 0);
+DEFINE_OLEGUID(IID_IOOMExplorersEvents, 0x00063078, 0, 0);
+
+
+typedef struct IOOMExplorer IOOMExplorer;
+typedef IOOMExplorer *LPOOMEXPLORER;
+
+typedef struct IOOMExplorersEvents IOOMExplorersEvents;
+typedef IOOMExplorersEvents *LPOOMEXPLORERSEVENTS;
+
+
+EXTERN_C const IID IID_IOOMExplorer;
+#undef INTERFACE
+#define INTERFACE IOOMExplorer
+DECLARE_INTERFACE_(IOOMExplorer, IDispatch)
+{
+ /*** IUnknown methods ***/
+ STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * lppvObj) PURE;
+ STDMETHOD_(ULONG,AddRef) (THIS) PURE;
+ STDMETHOD_(ULONG,Release) (THIS) PURE;
+
+ /*** IDispatch methods ***/
+ STDMETHOD(GetTypeInfoCount)(THIS_ UINT*) PURE;
+ STDMETHOD(GetTypeInfo)(THIS_ UINT, LCID, LPTYPEINFO*) PURE;
+ STDMETHOD(GetIDsOfNames)(THIS_ REFIID, LPOLESTR*, UINT, LCID, DISPID*) PURE;
+ STDMETHOD(Invoke)(THIS_ DISPID, REFIID, LCID, WORD,
+ DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*) PURE;
+
+ /*** IOOM_Explorer methods ***/
+ /* Activate, Close, .... */
+};
+
+
+EXTERN_C const IID IID_IOOMExplorersEvents;
+#undef INTERFACE
+#define INTERFACE IOOMExplorersEvents
+DECLARE_INTERFACE_(IOOMExplorersEvents, IDispatch)
+{
+ /*** IUnknown methods ***/
+ STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * lppvObj) PURE;
+ STDMETHOD_(ULONG,AddRef) (THIS) PURE;
+ STDMETHOD_(ULONG,Release) (THIS) PURE;
+
+ /*** IDispatch methods ***/
+ STDMETHOD(GetTypeInfoCount)(THIS_ UINT*) PURE;
+ STDMETHOD(GetTypeInfo)(THIS_ UINT, LCID, LPTYPEINFO*) PURE;
+ STDMETHOD(GetIDsOfNames)(THIS_ REFIID, LPOLESTR*, UINT, LCID, DISPID*) PURE;
+ STDMETHOD(Invoke)(THIS_ DISPID, REFIID, LCID, WORD,
+ DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*) PURE;
+
+ /*** IOOMExplorersEvents methods ***/
+ /* dispid=0xf001 */
+ STDMETHOD(NewExplorer)(THIS_ LPOOMEXPLORER) PURE;
+};
+
+
+/* Install an explorers collection event sink in OBJ. Returns the
+ event sink object which must be released by the caller if it is not
+ anymore required. */
+LPDISPATCH install_GpgolExplorersEvents_sink (LPDISPATCH obj);
+
+void add_explorer_controls (LPOOMEXPLORER explorer);
+
+
+
+#endif /*EXPLORERS_H*/
Modified: trunk/src/ext-commands.cpp
===================================================================
--- trunk/src/ext-commands.cpp 2009-09-28 09:51:56 UTC (rev 310)
+++ trunk/src/ext-commands.cpp 2009-10-28 19:26:06 UTC (rev 311)
@@ -40,6 +40,7 @@
#include "engine.h"
#include "ext-commands.h"
#include "revert.h"
+#include "explorers.h"
#define TRACEPOINT() do { log_debug ("%s:%s:%d: tracepoint\n", \
SRCNAME, __func__, __LINE__); \
@@ -103,9 +104,7 @@
m_nCmdProtoSmime = 0;
m_nCmdEncrypt = 0;
m_nCmdSign = 0;
- m_nCmdKeyManager = 0;
m_nCmdRevertFolder = 0;
- m_nCmdCryptoState = 0;
m_nCmdDebug0 = 0;
m_nCmdDebug1 = 0;
m_nCmdDebug2 = 0;
@@ -213,90 +212,8 @@
}
-static void
-check_toolbar (LPEXCHEXTCALLBACK eecb, struct toolbar_info_s *toolbar_info,
- UINT cmd_id, int checked)
-{
- HWND hwnd;
- toolbar_info_t tb_info;
- TBBUTTONINFOA tbb;
- eecb->GetToolbar (EETBID_STANDARD, &hwnd);
- if (debug_commands)
- log_debug ("check_toolbar: eecb=%p cmd_id=%u checked=%d -> hwnd=%p\n",
- eecb, cmd_id, checked, hwnd);
-
- for (tb_info = toolbar_info; tb_info; tb_info = tb_info->next )
- if (tb_info->cmd_id == cmd_id)
- break;
- if (!tb_info)
- {
- log_error ("check_toolbar: no such toolbar button");
- return;
- }
- if (!tb_info->did_qbi)
- {
- if(debug_commands)
- log_debug ("check_toolbar: button(cmd_id=%d) not yet initialized",
- cmd_id);
- return;
- }
-
- tbb.cbSize = sizeof (tbb);
- tbb.dwMask = TBIF_COMMAND | TBIF_STATE | TBIF_STYLE;
- if (!SendMessage (hwnd, TB_GETBUTTONINFO, cmd_id, (LPARAM)&tbb))
- log_error_w32 (-1, "TB_GETBUTTONINFO failed");
- else
- {
- tbb.cbSize = sizeof (tbb);
- tbb.dwMask = TBIF_STATE;
- if (checked)
- tbb.fsState |= TBSTATE_CHECKED;
- else
- tbb.fsState &= ~TBSTATE_CHECKED;
- if (!SendMessage (hwnd, TB_SETBUTTONINFO, cmd_id, (LPARAM)&tbb))
- log_error_w32 (-1, "TB_SETBUTTONINFO failed");
- }
-}
-
-
-static void
-check_menu_toolbar (LPEXCHEXTCALLBACK eecb,
- struct toolbar_info_s *toolbar_info,
- UINT cmd_id, int checked)
-{
- check_menu (eecb, cmd_id, checked);
- check_toolbar (eecb, toolbar_info, cmd_id, checked);
-}
-
-
void
-GpgolExtCommands::update_protocol_menu (LPEXCHEXTCALLBACK eecb)
-{
- if (debug_commands)
- log_debug ("update_protocol_menu called\n");
- switch (m_pExchExt->m_protoSelection)
- {
- case PROTOCOL_OPENPGP:
- check_menu_toolbar (eecb, m_toolbar_info, m_nCmdProtoAuto, FALSE);
- check_menu_toolbar (eecb, m_toolbar_info, m_nCmdProtoPgpmime, TRUE);
- check_menu_toolbar (eecb, m_toolbar_info, m_nCmdProtoSmime, FALSE);
- break;
- case PROTOCOL_SMIME:
- check_menu_toolbar (eecb, m_toolbar_info, m_nCmdProtoAuto, FALSE);
- check_menu_toolbar (eecb, m_toolbar_info, m_nCmdProtoPgpmime, FALSE);
- check_menu_toolbar (eecb, m_toolbar_info, m_nCmdProtoSmime, TRUE);
- break;
- default:
- check_menu_toolbar (eecb, m_toolbar_info, m_nCmdProtoAuto, TRUE);
- check_menu_toolbar (eecb, m_toolbar_info, m_nCmdProtoPgpmime, FALSE);
- check_menu_toolbar (eecb, m_toolbar_info, m_nCmdProtoSmime, FALSE);
- break;
- }
-}
-
-
-void
GpgolExtCommands::add_toolbar (LPTBENTRY tbearr, UINT n_tbearr, ...)
{
va_list arg_ptr;
@@ -365,7 +282,6 @@
-
/* Called by Exchange to install commands and toolbar buttons. Returns
S_FALSE to signal Exchange to continue calling extensions. */
STDMETHODIMP
@@ -396,6 +312,7 @@
log_debug ("%s:%s: context=%s flags=0x%lx\n", SRCNAME, __func__,
ext_context_name (m_lContext), lFlags);
+ show_event_object (eecb, __func__);
/* Outlook 2003 sometimes displays the plaintext and sometimes the
original undecrypted text when doing a reply. This seems to
@@ -509,44 +426,8 @@
/* Now install menu and toolbar items. */
if (m_lContext == EECONTEXT_READNOTEMESSAGE)
{
- int is_encrypted = 0;
- int not_a_gpgol_message = 0;
-
- LPMDB mdb = NULL;
- LPMESSAGE message = NULL;
-
- hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message);
- if (FAILED(hr))
- log_debug ("%s:%s: getObject failed: hr=%#lx\n", SRCNAME, __func__, hr);
- else
- {
- switch (mapi_get_message_type (message))
- {
- case MSGTYPE_GPGOL_MULTIPART_ENCRYPTED:
- case MSGTYPE_GPGOL_OPAQUE_ENCRYPTED:
- case MSGTYPE_GPGOL_PGP_MESSAGE:
- is_encrypted = 1;
- if ( mapi_test_sig_status (message) )
- is_encrypted++;
- break;
- case MSGTYPE_GPGOL:
- case MSGTYPE_SMIME:
- case MSGTYPE_UNKNOWN:
- not_a_gpgol_message = 1;
- break;
- default:
- break;
- }
- }
- ul_release (message, __func__, __LINE__);
- ul_release (mdb, __func__, __LINE__);
-
add_menu (eecb, pnCommandIDBase,
"@", NULL,
- (opt.disable_gpgol || not_a_gpgol_message)?
- "" : _("GpgOL Decrypt/Verify"), &m_nCmdCryptoState,
- opt.enable_debug? "GpgOL Debug-0 (display crypto info)":"",
- &m_nCmdDebug0,
(opt.enable_debug && !opt.disable_gpgol)?
"GpgOL Debug-1 (open_inspector)":"", &m_nCmdDebug1,
(opt.enable_debug && !opt.disable_gpgol)?
@@ -555,58 +436,21 @@
&m_nCmdDebug3,
NULL);
- if (!opt.disable_gpgol && !not_a_gpgol_message)
- add_toolbar (pTBEArray, nTBECnt,
- is_encrypted == 2
- ? _("This is a signed and encrypted message.\n"
- "Click for more information. ")
- : is_encrypted
- ? _("This is an encrypted message.\n"
- "Click for more information. ")
- : _("This is a signed message.\n"
- "Click for more information. "),
- IDB_CRYPTO_STATE, m_nCmdCryptoState,
- NULL, 0, 0);
-
}
else if (m_lContext == EECONTEXT_SENDNOTEMESSAGE && !opt.disable_gpgol)
{
add_menu (eecb, pnCommandIDBase,
"@", NULL,
- _(">GnuPG protocol"), NULL,
- _("auto"), &m_nCmdProtoAuto,
- _("PGP/MIME"),&m_nCmdProtoPgpmime,
- _("S/MIME"), &m_nCmdProtoSmime,
- "<", NULL,
_("&encrypt message with GnuPG"), &m_nCmdEncrypt,
_("&sign message with GnuPG"), &m_nCmdSign,
NULL );
- /* We display the protocol icons only for Outlook 2007 becuase
- there seems to be no way to add a plain menu item. */
- if (get_ol_main_version () > 11)
add_toolbar (pTBEArray, nTBECnt,
"Encrypt", IDB_ENCRYPT, m_nCmdEncrypt,
"Sign", IDB_SIGN, m_nCmdSign,
- "Autoselect", IDB_PROTO_AUTO, m_nCmdProtoAuto,
- "Use PGP/MIME", IDB_PROTO_PGPMIME, m_nCmdProtoPgpmime,
- "Use/MIME", IDB_PROTO_SMIME, m_nCmdProtoSmime,
NULL, 0, 0);
- else
- add_toolbar (pTBEArray, nTBECnt,
- "Encrypt", IDB_ENCRYPT, m_nCmdEncrypt,
- "Sign", IDB_SIGN, m_nCmdSign,
- NULL, 0, 0);
- if (draft_info && strlen (draft_info) >= 3 && draft_info[2] == 'A')
- m_pExchExt->m_protoSelection = PROTOCOL_UNKNOWN;
- else if (draft_info && strlen (draft_info) >= 3 && draft_info[2] == 'P')
- m_pExchExt->m_protoSelection = PROTOCOL_OPENPGP;
- else if (draft_info && strlen (draft_info) >= 3 && draft_info[2] == 'X')
- m_pExchExt->m_protoSelection = PROTOCOL_SMIME;
- else
- m_pExchExt->m_protoSelection = opt.default_protocol;
- update_protocol_menu (eecb);
+ m_pExchExt->m_protoSelection = opt.default_protocol;
if (draft_info && draft_info[0] == 'E')
m_pExchExt->m_gpgEncrypt = true;
@@ -631,13 +475,9 @@
{
add_menu (eecb, pnCommandIDBase,
"@", NULL,
- _("GnuPG Certificate &Manager"), &m_nCmdKeyManager,
_("Remove GpgOL flags from this folder"), &m_nCmdRevertFolder,
NULL);
- add_toolbar (pTBEArray, nTBECnt,
- _("Open the certificate manager"), IDB_KEY_MANAGER, m_nCmdKeyManager,
- NULL, 0, 0);
}
xfree (draft_info);
@@ -664,6 +504,8 @@
SRCNAME, __func__, nCommandID, nCommandID,
ext_context_name (m_lContext), hwnd);
+ show_event_object (eecb, __func__);
+
if (nCommandID == SC_CLOSE && m_lContext == EECONTEXT_READNOTEMESSAGE)
{
/* This is the system close command. Replace it with our own to
@@ -733,57 +575,6 @@
log_debug ("%s:%s: command Forward called\n", SRCNAME, __func__);
return S_FALSE; /* Pass it on. */
}
- else if (nCommandID == m_nCmdCryptoState
- && m_lContext == EECONTEXT_READNOTEMESSAGE)
- {
- log_debug ("%s:%s: command CryptoState called\n", SRCNAME, __func__);
- hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message);
- if (SUCCEEDED (hr))
- {
- if (message_incoming_handler (message, hwnd, true))
- message_display_handler (eecb, hwnd);
- }
- else
- log_debug_w32 (hr, "%s:%s: command CryptoState failed",
- SRCNAME, __func__);
- ul_release (message, __func__, __LINE__);
- ul_release (mdb, __func__, __LINE__);
- }
- else if (nCommandID == m_nCmdProtoAuto
- && m_lContext == EECONTEXT_SENDNOTEMESSAGE)
- {
- log_debug ("%s:%s: command ProtoAuto called\n", SRCNAME, __func__);
- m_pExchExt->m_protoSelection = PROTOCOL_UNKNOWN;
- update_protocol_menu (eecb);
- }
- else if (nCommandID == m_nCmdProtoPgpmime
- && m_lContext == EECONTEXT_SENDNOTEMESSAGE)
- {
- log_debug ("%s:%s: command ProtoPgpmime called\n", SRCNAME, __func__);
- m_pExchExt->m_protoSelection = PROTOCOL_OPENPGP;
- update_protocol_menu (eecb);
- }
- else if (nCommandID == m_nCmdProtoSmime
- && m_lContext == EECONTEXT_SENDNOTEMESSAGE)
- {
- log_debug ("%s:%s: command ProtoSmime called\n", SRCNAME, __func__);
- if (opt.enable_smime)
- {
- m_pExchExt->m_protoSelection = PROTOCOL_SMIME;
- update_protocol_menu (eecb);
- }
- else
- {
- MessageBox (hwnd,
- _("Support for S/MIME has not been enabled.\n"
- "\n"
- "To enable S/MIME support, open the option dialog"
- " and check \"Enable the S/MIME support\". The"
- " option dialog can be found in the main menu at:"
- " Extras->Options->GpgOL.\n"),
- "GpgOL", MB_ICONHAND|MB_OK);
- }
- }
else if (nCommandID == m_nCmdEncrypt
&& m_lContext == EECONTEXT_SENDNOTEMESSAGE)
{
@@ -798,14 +589,6 @@
m_pExchExt->m_gpgSign = !m_pExchExt->m_gpgSign;
check_menu (eecb, m_nCmdSign, m_pExchExt->m_gpgSign);
}
- else if (nCommandID == m_nCmdKeyManager
- && m_lContext == EECONTEXT_VIEWER)
- {
- log_debug ("%s:%s: command KeyManager called\n", SRCNAME, __func__);
- if (engine_start_keymanager (hwnd))
- MessageBox (NULL, _("Could not start certificate manager"),
- _("GpgOL"), MB_ICONERROR|MB_OK);
- }
else if (nCommandID == m_nCmdRevertFolder
&& m_lContext == EECONTEXT_VIEWER)
{
@@ -953,31 +736,12 @@
{
(void)eecb;
- if (nCommandID == m_nCmdProtoAuto
+ show_event_object (eecb, __func__);
+
+ if (nCommandID == m_nCmdEncrypt
&& m_lContext == EECONTEXT_SENDNOTEMESSAGE)
{
MessageBox (m_hWnd,
- _("Select this option to automatically select the protocol."),
- "GpgOL", MB_OK);
- }
- else if (nCommandID == m_nCmdProtoPgpmime
- && m_lContext == EECONTEXT_SENDNOTEMESSAGE)
- {
- MessageBox (m_hWnd,
- _("Select this option to select the PGP/MIME protocol."),
- "GpgOL", MB_OK);
- }
- else if (nCommandID == m_nCmdProtoSmime
- && m_lContext == EECONTEXT_SENDNOTEMESSAGE)
- {
- MessageBox (m_hWnd,
- _("Select this option to select the S/MIME protocol."),
- "GpgOL", MB_OK);
- }
- else if (nCommandID == m_nCmdEncrypt
- && m_lContext == EECONTEXT_SENDNOTEMESSAGE)
- {
- MessageBox (m_hWnd,
_("Select this option to encrypt the message."),
"GpgOL", MB_OK);
}
@@ -988,13 +752,6 @@
_("Select this option to sign the message."),
"GpgOL", MB_OK);
}
- else if (nCommandID == m_nCmdKeyManager
- && m_lContext == EECONTEXT_VIEWER)
- {
- MessageBox (m_hWnd,
- _("Select this option to open the certificate manager"),
- "GpgOL", MB_OK);
- }
else
return S_FALSE;
@@ -1014,44 +771,14 @@
GpgolExtCommands::QueryHelpText(UINT nCommandID, ULONG lFlags,
LPTSTR pszText, UINT nCharCnt)
{
-
- if (nCommandID == m_nCmdProtoAuto
+
+ if (nCommandID == m_nCmdEncrypt
&& m_lContext == EECONTEXT_SENDNOTEMESSAGE)
{
if (lFlags == EECQHT_STATUS)
lstrcpyn (pszText, ".", nCharCnt);
if (lFlags == EECQHT_TOOLTIP)
lstrcpyn (pszText,
- _("Automatically select the protocol for sign/encrypt"),
- nCharCnt);
- }
- else if (nCommandID == m_nCmdProtoPgpmime
- && m_lContext == EECONTEXT_SENDNOTEMESSAGE)
- {
- if (lFlags == EECQHT_STATUS)
- lstrcpyn (pszText, ".", nCharCnt);
- if (lFlags == EECQHT_TOOLTIP)
- lstrcpyn (pszText,
- _("Use PGP/MIME for sign/encrypt"),
- nCharCnt);
- }
- else if (nCommandID == m_nCmdProtoSmime
- && m_lContext == EECONTEXT_SENDNOTEMESSAGE)
- {
- if (lFlags == EECQHT_STATUS)
- lstrcpyn (pszText, ".", nCharCnt);
- if (lFlags == EECQHT_TOOLTIP)
- lstrcpyn (pszText,
- _("Use S/MIME for sign/encrypt"),
- nCharCnt);
- }
- else if (nCommandID == m_nCmdEncrypt
- && m_lContext == EECONTEXT_SENDNOTEMESSAGE)
- {
- if (lFlags == EECQHT_STATUS)
- lstrcpyn (pszText, ".", nCharCnt);
- if (lFlags == EECQHT_TOOLTIP)
- lstrcpyn (pszText,
_("Encrypt message with GnuPG"),
nCharCnt);
}
@@ -1065,16 +792,6 @@
_("Sign message with GnuPG"),
nCharCnt);
}
- else if (nCommandID == m_nCmdKeyManager
- && m_lContext == EECONTEXT_VIEWER)
- {
- if (lFlags == EECQHT_STATUS)
- lstrcpyn (pszText, ".", nCharCnt);
- if (lFlags == EECQHT_TOOLTIP)
- lstrcpyn (pszText,
- _("Open the GpgOL certificate manager"),
- nCharCnt);
- }
else
return S_FALSE;
@@ -1144,25 +861,6 @@
if (m_pExchExt->m_gpgSign)
pTBB->fsState |= TBSTATE_CHECKED;
}
- else if (tb_info->cmd_id == m_nCmdProtoAuto)
- {
- pTBB->fsStyle |= TBSTYLE_CHECK;
- if (m_pExchExt->m_protoSelection != PROTOCOL_OPENPGP
- && m_pExchExt->m_protoSelection != PROTOCOL_SMIME)
- pTBB->fsState |= TBSTATE_CHECKED;
- }
- else if (tb_info->cmd_id == m_nCmdProtoPgpmime)
- {
- pTBB->fsStyle |= TBSTYLE_CHECK;
- if (m_pExchExt->m_protoSelection == PROTOCOL_OPENPGP)
- pTBB->fsState |= TBSTATE_CHECKED;
- }
- else if (tb_info->cmd_id == m_nCmdProtoSmime)
- {
- pTBB->fsStyle |= TBSTYLE_CHECK;
- if (m_pExchExt->m_protoSelection == PROTOCOL_SMIME)
- pTBB->fsState |= TBSTATE_CHECKED;
- }
return S_OK;
}
Modified: trunk/src/ext-commands.h
===================================================================
--- trunk/src/ext-commands.h 2009-09-28 09:51:56 UTC (rev 310)
+++ trunk/src/ext-commands.h 2009-10-28 19:26:06 UTC (rev 311)
@@ -45,9 +45,7 @@
UINT m_nCmdProtoSmime;
UINT m_nCmdEncrypt;
UINT m_nCmdSign;
- UINT m_nCmdKeyManager;
UINT m_nCmdRevertFolder;
- UINT m_nCmdCryptoState;
UINT m_nCmdDebug0;
UINT m_nCmdDebug1;
UINT m_nCmdDebug2;
Added: trunk/src/inspectors.cpp
===================================================================
--- trunk/src/inspectors.cpp (rev 0)
+++ trunk/src/inspectors.cpp 2009-10-28 19:26:06 UTC (rev 311)
@@ -0,0 +1,496 @@
+/* inspectors.cpp - Code to handle OOM Inspectors
+ * Copyright (C) 2009 g10 Code GmbH
+ *
+ * This file is part of GpgOL.
+ *
+ * GpgOL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GpgOL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <windows.h>
+#include <olectl.h>
+
+#include "common.h"
+#include "oomhelp.h"
+#include "myexchext.h"
+#include "inspectors.h"
+#include "dialogs.h" /* IDB_xxx */
+#include "cmdbarcontrols.h"
+
+#include "eventsink.h"
+
+
+/* Event sink for an Inspectors collection object. */
+BEGIN_EVENT_SINK(GpgolInspectorsEvents, IOOMInspectorsEvents)
+ STDMETHOD (NewInspector) (THIS_ LPOOMINSPECTOR);
+EVENT_SINK_DEFAULT_DTOR(GpgolInspectorsEvents)
+EVENT_SINK_INVOKE(GpgolInspectorsEvents)
+{
+ HRESULT hr;
+ (void)lcid; (void)riid; (void)result; (void)exepinfo; (void)argerr;
+
+ if (dispid == 0xf001 && (flags & DISPATCH_METHOD))
+ {
+ if (!parms)
+ hr = DISP_E_PARAMNOTOPTIONAL;
+ else if (parms->cArgs != 1)
+ hr = DISP_E_BADPARAMCOUNT;
+ else if (parms->rgvarg[0].vt != VT_DISPATCH)
+ hr = DISP_E_BADVARTYPE;
+ else
+ hr = NewInspector ((LPOOMINSPECTOR)parms->rgvarg[0].pdispVal);
+ }
+ else
+ hr = DISP_E_MEMBERNOTFOUND;
+ return hr;
+}
+END_EVENT_SINK(GpgolInspectorsEvents, IID_IOOMInspectorsEvents)
+
+
+
+/* Event sink for an Inspector object. */
+BEGIN_EVENT_SINK(GpgolInspectorEvents, IOOMInspectorEvents)
+ STDMETHOD_ (void, Activate) (THIS_);
+ STDMETHOD_ (void, Close) (THIS_);
+ STDMETHOD_ (void, Deactivate) (THIS_);
+EVENT_SINK_DEFAULT_DTOR(GpgolInspectorEvents)
+EVENT_SINK_INVOKE(GpgolInspectorEvents)
+{
+ HRESULT hr = S_OK;
+ (void)lcid; (void)riid; (void)result; (void)exepinfo; (void)argerr;
+
+ if ((dispid == 0xf001 || dispid == 0xf006 || dispid == 0xf008)
+ && (flags & DISPATCH_METHOD))
+ {
+ if (!parms)
+ hr = DISP_E_PARAMNOTOPTIONAL;
+ else if (parms->cArgs != 0)
+ hr = DISP_E_BADPARAMCOUNT;
+ else if (dispid == 0xf001)
+ Activate ();
+ else if (dispid == 0xf006)
+ Deactivate ();
+ else if (dispid == 0xf008)
+ Close ();
+ }
+ else
+ hr = DISP_E_MEMBERNOTFOUND;
+ return hr;
+}
+END_EVENT_SINK(GpgolInspectorEvents, IID_IOOMInspectorEvents)
+
+
+
+/* To avoid messing around with the OOM (adding extra objects as user
+ properties and such), we keep our own information structure about
+ inspectors. */
+struct inspector_info_s
+{
+ /* We are pretty lame and keep all inspectors in a linked list. */
+ struct inspector_info_s *next;
+
+ /* The inspector object. */
+ LPOOMINSPECTOR inspector;
+
+ /* The event sink object. This is used by the event methods to
+ locate the inspector object. */
+ LPOOMINSPECTOREVENTS eventsink;
+
+ /* The event sink object for the crypto info button. */
+ LPDISPATCH crypto_info_sink;
+
+};
+typedef struct inspector_info_s *inspector_info_t;
+
+/* The list of all inspectors and a lock for it. */
+static inspector_info_t all_inspectors;
+static HANDLE all_inspectors_lock;
+
+/* Initialize this module. Returns 0 on success. Called once by dllinit. */
+int
+initialize_inspectors (void)
+{
+ SECURITY_ATTRIBUTES sa;
+
+ memset (&sa, 0, sizeof sa);
+ sa.bInheritHandle = FALSE;
+ sa.lpSecurityDescriptor = NULL;
+ sa.nLength = sizeof sa;
+ all_inspectors_lock = CreateMutex (&sa, FALSE, NULL);
+ return !all_inspectors_lock;
+}
+
+
+/* Acquire the all_inspectors_lock. No error is returned because we
+ can't do anything anyway. */
+static void
+lock_all_inspectors (void)
+{
+ int ec = WaitForSingleObject (all_inspectors_lock, INFINITE);
+ if (ec != WAIT_OBJECT_0)
+ {
+ log_error ("%s:%s: waiting on mutex failed: ec=%#x\n",
+ SRCNAME, __func__, ec);
+ fatal_error ("%s:%s: waiting on mutex failed: ec=%#x\n",
+ SRCNAME, __func__, ec);
+ }
+}
+
+
+/* Release the all_inspectors_lock. No error is returned because this
+ is a fatal error anyway and there is no way to clean up. */
+static void
+unlock_all_inspectors (void)
+{
+ if (!ReleaseMutex (all_inspectors_lock))
+ {
+ log_error_w32 (-1, "%s:%s: ReleaseMutex failed", SRCNAME, __func__);
+ fatal_error ("%s:%s: ReleaseMutex failed", SRCNAME, __func__);
+ }
+}
+
+
+/* Register the inspector object INSPECTOR along with its event SINK. */
+static void
+register_inspector (LPOOMINSPECTOR inspector, LPOOMINSPECTOREVENTS sink)
+{
+ inspector_info_t item;
+
+ item = (inspector_info_t)xcalloc (1, sizeof *item);
+ lock_all_inspectors ();
+ inspector->AddRef ();
+ item->inspector = inspector;
+
+ sink->AddRef ();
+ item->eventsink = sink;
+
+ item->next = all_inspectors;
+ all_inspectors = item;
+
+ unlock_all_inspectors ();
+}
+
+
+/* Deregister the inspector with the event SINK. */
+static void
+deregister_inspector (LPOOMINSPECTOREVENTS sink)
+{
+ inspector_info_t r, rprev;
+
+ if (!sink)
+ return;
+
+ lock_all_inspectors ();
+ for (r = all_inspectors, rprev = NULL; r; rprev = r, r = r->next)
+ if (r->eventsink == sink)
+ {
+ if (!rprev)
+ all_inspectors = r->next;
+ else
+ rprev->next = r->next;
+ r->next = NULL;
+ break;
+ }
+ unlock_all_inspectors ();
+ if (!r)
+ {
More information about the Gnupg-commits
mailing list