[svn] GpgOL - r295 - in trunk: . doc po src
svn author wk
cvs at cvs.gnupg.org
Wed Feb 25 16:05:15 CET 2009
Author: wk
Date: 2009-02-25 16:05:15 +0100 (Wed, 25 Feb 2009)
New Revision: 295
Modified:
trunk/NEWS
trunk/doc/gpgol.texi
trunk/po/de.po
trunk/src/ChangeLog
trunk/src/Makefile.am
trunk/src/ext-commands.cpp
trunk/src/mapihelp.cpp
trunk/src/mapihelp.h
trunk/src/mimemaker.c
trunk/src/myexchext.h
Log:
Save cryto settings in a draft.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2009-01-28 10:27:50 UTC (rev 294)
+++ trunk/src/ChangeLog 2009-02-25 15:05:15 UTC (rev 295)
@@ -1,3 +1,11 @@
+2009-02-25 Werner Koch <wk at g10code.com>
+
+ * mapihelp.cpp (get_gpgoldraftinfo_tag): New.
+ (mapi_get_gpgol_draft_info, mapi_set_gpgol_draft_info): New.
+ * ext-commands.cpp (DoCommand): Save encryption selection.
+ (InstallCommands): Get encryption selection from the draft info.
+ * mimemaker.c (finalize_message): Delete the property.
+
2009-01-28 Werner Koch <wk at g10code.com>
* mimeparser.c (t2body): Take care of x-pkcs7-mime as used by
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2009-01-28 10:27:50 UTC (rev 294)
+++ trunk/NEWS 2009-02-25 15:05:15 UTC (rev 295)
@@ -1,3 +1,9 @@
+Noteworthy changes for version 0.10.19
+===================================================
+
+ * Save the crypto settings in a message draft.
+
+
Noteworthy changes for version 0.10.18 (2009-01-28)
===================================================
Modified: trunk/doc/gpgol.texi
===================================================================
--- trunk/doc/gpgol.texi 2009-01-28 10:27:50 UTC (rev 294)
+++ trunk/doc/gpgol.texi 2009-02-25 15:05:15 UTC (rev 295)
@@ -253,6 +253,11 @@
the orginal message. The content are lines of colon delimited fields.
The specification has not yet been finished.
+ at item GpgOL Draft Info
+This is a property of type STRING8 used to preserve crypto settings in a
+draft message. For details see the function
+ at code{mapi_set_gpgol_draft_info}.
+
@end table
Modified: trunk/po/de.po [not shown]
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-01-28 10:27:50 UTC (rev 294)
+++ trunk/src/Makefile.am 2009-02-25 15:05:15 UTC (rev 295)
@@ -14,6 +14,7 @@
unused_sources = item-events.cpp
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 \
proto-auto.bmp proto-pgpmime.bmp proto-smime.bmp \
@@ -65,6 +66,8 @@
w32-gettext.c w32-gettext.h
+#treeview_SOURCES = treeview.c
+
# W32API 3.2 comes with an unusable libmapi32.a. We build our own
# version. Note the omission of -k (--kill-at) from the DLLTOOL
# command line. We also create our own virtual copies to the _static_
Modified: trunk/src/ext-commands.cpp
===================================================================
--- trunk/src/ext-commands.cpp 2009-01-28 10:27:50 UTC (rev 294)
+++ trunk/src/ext-commands.cpp 2009-02-25 15:05:15 UTC (rev 295)
@@ -387,6 +387,8 @@
DISPPARAMS dispparams;
VARIANT aVariant;
int force_encrypt = 0;
+ char *draft_info = NULL;
+
(void)hMenu;
@@ -494,6 +496,12 @@
xfree (key);
}
+ /* Because we have the message open, we use it to get the draft
+ info property. */
+ if (message)
+ draft_info = mapi_get_gpgol_draft_info (message);
+
+
ul_release (message, __func__, __LINE__);
ul_release (mdb, __func__, __LINE__);
}
@@ -591,13 +599,30 @@
"Sign", IDB_SIGN, m_nCmdSign,
NULL, 0, 0);
-
- m_pExchExt->m_protoSelection = opt.default_protocol;
+ 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_gpgEncrypt = opt.encrypt_default;
+ if (draft_info && draft_info[0] == 'E')
+ m_pExchExt->m_gpgEncrypt = true;
+ else if (draft_info && draft_info[0] == 'e')
+ m_pExchExt->m_gpgEncrypt = false;
+ else
+ m_pExchExt->m_gpgEncrypt = opt.encrypt_default;
- m_pExchExt->m_gpgSign = opt.sign_default;
+ if (draft_info && draft_info[0] && draft_info[1] == 'S')
+ m_pExchExt->m_gpgSign = true;
+ else if (draft_info && draft_info[0] && draft_info[1] == 's')
+ m_pExchExt->m_gpgSign = false;
+ else
+ m_pExchExt->m_gpgSign = opt.sign_default;
+
if (force_encrypt)
m_pExchExt->m_gpgEncrypt = true;
check_menu (eecb, m_nCmdEncrypt, m_pExchExt->m_gpgEncrypt);
@@ -615,6 +640,9 @@
_("Open the certificate manager"), IDB_KEY_MANAGER, m_nCmdKeyManager,
NULL, 0, 0);
}
+
+ xfree (draft_info);
+
return S_FALSE;
}
@@ -868,6 +896,32 @@
ul_release (message, __func__, __LINE__);
ul_release (mdb, __func__, __LINE__);
}
+ else if (nCommandID == EECMDID_SaveMessage
+ && m_lContext == EECONTEXT_SENDNOTEMESSAGE)
+ {
+ char buf[4];
+
+ log_debug ("%s:%s: command SaveMessage called\n", SRCNAME, __func__);
+ buf[0] = m_pExchExt->m_gpgEncrypt? 'E':'e';
+ buf[1] = m_pExchExt->m_gpgSign? 'S':'s';
+ switch (m_pExchExt->m_protoSelection)
+ {
+ case PROTOCOL_UNKNOWN: buf[2] = 'A'; break;
+ case PROTOCOL_OPENPGP: buf[2] = 'P'; break;
+ case PROTOCOL_SMIME: buf[2] = 'X'; break;
+ default: buf[2] = '-'; break;
+ }
+ buf[3] = 0;
+
+ hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message);
+ if (SUCCEEDED (hr))
+ mapi_set_gpgol_draft_info (message, buf);
+ else
+ log_debug ("%s:%s: getObject failed: hr=%#lx\n",SRCNAME, __func__, hr);
+ ul_release (message, __func__, __LINE__);
+ ul_release (mdb, __func__, __LINE__);
+ return S_FALSE; /* Pass on to next handler. */
+ }
else
{
if (debug_commands)
Modified: trunk/src/mapihelp.cpp
===================================================================
--- trunk/src/mapihelp.cpp 2009-01-28 10:27:50 UTC (rev 294)
+++ trunk/src/mapihelp.cpp 2009-02-25 15:05:15 UTC (rev 295)
@@ -223,6 +223,17 @@
}
+/* Return the property tag for GpgOL Draft Info. */
+int
+get_gpgoldraftinfo_tag (LPMESSAGE message, ULONG *r_tag)
+{
+ if (!(*r_tag = create_gpgol_tag (message, L"GpgOL Draft Info", __func__)))
+ return -1;
+ *r_tag |= PT_STRING8;
+ return 0;
+}
+
+
/* Return the tag of the Internet Charset Body property which seems to
hold the PR_BODY as received and thus before charset
conversion. */
@@ -2490,6 +2501,81 @@
}
+
+/* Return GpgOL's draft info string as an allocated string. If no
+ draft info is available, NULL is returned. */
+char *
+mapi_get_gpgol_draft_info (LPMESSAGE msg)
+{
+ HRESULT hr;
+ LPSPropValue propval = NULL;
+ ULONG tag;
+ char *retstr;
+
+ if (get_gpgoldraftinfo_tag (msg, &tag) )
+ return NULL;
+ hr = HrGetOneProp ((LPMAPIPROP)msg, tag, &propval);
+ if (FAILED (hr))
+ return NULL;
+ if (PROP_TYPE (propval->ulPropTag) == PT_STRING8)
+ retstr = xstrdup (propval->Value.lpszA);
+ else
+ retstr = NULL;
+
+ MAPIFreeBuffer (propval);
+ return retstr;
+}
+
+
+/* Set GpgOL's draft info string to STRING. This string is defined as:
+
+ Character 1: 'E' = encrypt selected,
+ 'e' = encrypt not selected.
+ '-' = don't care
+ Character 2: 'S' = sign selected,
+ 's' = sign not selected.
+ '-' = don't care
+ Character 3: 'A' = Auto protocol
+ 'P' = OpenPGP protocol
+ 'X' = S/MIME protocol
+ '-' = don't care
+
+ If string is NULL, the property will get deleted.
+
+ Note that this function does not call SaveChanges. */
+int
+mapi_set_gpgol_draft_info (LPMESSAGE message, const char *string)
+{
+ HRESULT hr;
+ SPropValue prop;
+ SPropTagArray proparray;
+
+ if (get_gpgoldraftinfo_tag (message, &prop.ulPropTag) )
+ return -1;
+ if (string)
+ {
+ prop.Value.lpszA = xstrdup (string);
+ hr = HrSetOneProp (message, &prop);
+ xfree (prop.Value.lpszA);
+ }
+ else
+ {
+ proparray.cValues = 1;
+ proparray.aulPropTag[0] = prop.ulPropTag;
+ hr = message->DeleteProps (&proparray, NULL);
+ }
+ if (hr)
+ {
+ log_error ("%s:%s: can't %s %s property: hr=%#lx\n",
+ SRCNAME, __func__, string?"set":"delete",
+ "GpgOL Draft Info", hr);
+ return -1;
+ }
+
+ return 0;
+}
+
+
/* Return the MIME info as an allocated string. Will never return
NULL. */
char *
Modified: trunk/src/mapihelp.h
===================================================================
--- trunk/src/mapihelp.h 2009-01-28 10:27:50 UTC (rev 294)
+++ trunk/src/mapihelp.h 2009-02-25 15:05:15 UTC (rev 295)
@@ -145,6 +145,10 @@
char *mapi_get_gpgol_charset (LPMESSAGE obj);
int mapi_set_gpgol_charset (LPMESSAGE obj, const char *charset);
+char *mapi_get_gpgol_draft_info (LPMESSAGE msg);
+int mapi_set_gpgol_draft_info (LPMESSAGE message, const char *string);
+
+
int mapi_set_attach_hidden (LPATTACH attach);
int mapi_test_attach_hidden (LPATTACH attach);
Modified: trunk/src/mimemaker.c
===================================================================
--- trunk/src/mimemaker.c 2009-01-28 10:27:50 UTC (rev 294)
+++ trunk/src/mimemaker.c 2009-02-25 15:05:15 UTC (rev 295)
@@ -1075,6 +1075,10 @@
if (delete_all_attachments (message, att_table))
return -1;
+ /* Remove the draft info so that we don't leak the information on
+ whether the message has been signed etc. */
+ mapi_set_gpgol_draft_info (message, NULL);
+
return mapi_save_changes (message, KEEP_OPEN_READWRITE|FORCE_SAVE);
}
Modified: trunk/src/myexchext.h
===================================================================
--- trunk/src/myexchext.h 2009-01-28 10:27:50 UTC (rev 294)
+++ trunk/src/myexchext.h 2009-02-25 15:05:15 UTC (rev 295)
@@ -69,6 +69,7 @@
/* Command IDs. */
+#define EECMDID_SaveMessage 13 /* (name guessed) */
#define EECMDID_PrevMessage 87 /* (name guessed) */
#define EECMDID_NextMessage 88 /* (name guessed) */
#define EECMDID_Format 110
More information about the Gnupg-commits
mailing list