[svn] GpgOL - r262 - in trunk: doc src
svn author wk
cvs at cvs.gnupg.org
Wed Jul 30 19:53:39 CEST 2008
Author: wk
Date: 2008-07-30 19:53:36 +0200 (Wed, 30 Jul 2008)
New Revision: 262
Modified:
trunk/doc/gpgol.texi
trunk/src/ChangeLog
trunk/src/Makefile.am
trunk/src/engine-assuan.c
trunk/src/ext-commands.cpp
trunk/src/ext-commands.h
trunk/src/gpgol.def
trunk/src/mapihelp.cpp
trunk/src/mapihelp.h
trunk/src/ol-ext-callback.cpp
trunk/src/olflange.cpp
trunk/src/olflange.h
Log:
Started with Revert code.
Improved version check.
[The diff below has been truncated]
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2008-06-27 18:10:42 UTC (rev 261)
+++ trunk/src/ChangeLog 2008-07-30 17:53:36 UTC (rev 262)
@@ -1,3 +1,17 @@
+2008-07-30 Werner Koch <wk at g10code.com>
+
+ * olflange.cpp (Install): Improve version check.
+
+ * revert.cpp, revert.h: New.
+ * mapihelp.cpp (mapi_attachment_to_body): New.
+ (mapi_get_old_message_class): New.
+ (mapi_change_message_class): Do not release newvalue when saving
+ the old class.
+ * olflange.cpp (parse_version_number, parse_version_string)
+ (compare_versions, gpgol_check_version): New.
+ * ext-commands.cpp (DoCommand): Support a "revert message class"
+ debug command.
+
2008-06-27 Werner Koch <wk at g10code.com>
* mapihelp.cpp (get_gpgololdmsgclass_tag): New.
Modified: trunk/doc/gpgol.texi
===================================================================
--- trunk/doc/gpgol.texi 2008-06-27 18:10:42 UTC (rev 261)
+++ trunk/doc/gpgol.texi 2008-07-30 17:53:36 UTC (rev 262)
@@ -167,7 +167,7 @@
@item GpgOL Old Msg Class
This is a STRING8 property which saves the original PR_MESSAGE_CLASS
-before GpgOL chnages it.
+before GpgOL changes it.
@item GpgOL Attach Type
This is a property of type LONG and used to further describe the
@@ -280,8 +280,7 @@
@code{Install Directory} (as described above). This Registry entry
gives the actual command name relative to this directory. If the key
does not exist, is is first searched below @code{HKLM} and then it
-defaults to @code{bin/kleopatra.exe} (FIXME: The final name will be just
- at code{kleopatra.exe}).
+defaults to @code{kleopatra.exe}.
@item HKCU\Software\GNU\GpgOL:enableDebug
Setting this key to the string @code{1} enables a few extra features in
@@ -307,7 +306,7 @@
Print data lines while parsing MIME.
@end table
You may use the regular C-syntax for entering the value. As an
-alternative you may use the names ofthe flags, separated by space or
+alternative you may use the names of the flags, separated by space or
comma.
@@ -486,7 +485,7 @@
@end itemize
Instead of deleting it should be sufficient to make sure
-that such PR_BODYs are not update and don't make it to the disk or a
+that such PR_BODYs are not updated and don't make it to the disk or a
strage server.
Implementing such a feature would really help with end-to-end encryption
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2008-06-27 18:10:42 UTC (rev 261)
+++ trunk/src/Makefile.am 2008-07-30 17:53:36 UTC (rev 262)
@@ -35,6 +35,7 @@
myexchext.h \
display.cpp display.h \
message.cpp message.h \
+ revert.cpp revert.h \
mimeparser.c mimeparser.h \
mimemaker.c mimemaker.h \
msgcache.c msgcache.h \
Modified: trunk/src/engine-assuan.c
===================================================================
--- trunk/src/engine-assuan.c 2008-06-27 18:10:42 UTC (rev 261)
+++ trunk/src/engine-assuan.c 2008-07-30 17:53:36 UTC (rev 262)
@@ -349,9 +349,8 @@
xfree (uiserver);
if (extra_arglen && access (name, F_OK))
{
- /* Kleopatra iis not nstalled: Try GPA instead but if it is
- also not available still return the Kleopatra
- filename. */
+ /* Kleopatra is not installed: Try GPA instead but if it is
+ also not available return the Kleopatra filename. */
const char gpaserver[] = "gpa.exe";
char *name2;
@@ -526,7 +525,7 @@
}
-/* end the optiona session information. */
+/* Send the optional session information. */
static void
send_session_info (assuan_context_t ctx, engine_filter_t filter)
{
Modified: trunk/src/ext-commands.cpp
===================================================================
--- trunk/src/ext-commands.cpp 2008-06-27 18:10:42 UTC (rev 261)
+++ trunk/src/ext-commands.cpp 2008-07-30 17:53:36 UTC (rev 262)
@@ -39,8 +39,8 @@
#include "message.h"
#include "engine.h"
#include "ext-commands.h"
+#include "revert.h"
-
#define TRACEPOINT() do { log_debug ("%s:%s:%d: tracepoint\n", \
SRCNAME, __func__, __LINE__); \
} while (0)
@@ -110,6 +110,7 @@
m_nCmdDebug0 = 0;
m_nCmdDebug1 = 0;
m_nCmdDebug2 = 0;
+ m_nCmdDebug3 = 0;
m_toolbar_info = NULL;
m_hWnd = NULL;
@@ -532,6 +533,8 @@
&m_nCmdDebug0,
opt.enable_debug? "GpgOL Debug-1 (open_inspector)":"", &m_nCmdDebug1,
opt.enable_debug? "GpgOL Debug-2 (change msg class)":"", &m_nCmdDebug2,
+ opt.enable_debug? "GpgOL Debug-3 (revert message class)":"",
+ &m_nCmdDebug3,
NULL);
add_toolbar (pTBEArray, nTBECnt,
@@ -792,6 +795,22 @@
ul_release (message, __func__, __LINE__);
ul_release (mdb, __func__, __LINE__);
}
+ else if (opt.enable_debug && nCommandID == m_nCmdDebug3
+ && m_lContext == EECONTEXT_READNOTEMESSAGE)
+ {
+ log_debug ("%s:%s: command Debug3 (revert_message_class) called\n",
+ SRCNAME, __func__);
+ hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message);
+ if (SUCCEEDED (hr))
+ {
+ int rc = gpgol_message_revert (message, 1,
+ KEEP_OPEN_READWRITE|FORCE_SAVE);
+ log_debug ("%s:%s: gpgol_message_revert returns %d\n",
+ SRCNAME, __func__, rc);
+ }
+ ul_release (message, __func__, __LINE__);
+ ul_release (mdb, __func__, __LINE__);
+ }
else
{
if (debug_commands)
Modified: trunk/src/ext-commands.h
===================================================================
--- trunk/src/ext-commands.h 2008-06-27 18:10:42 UTC (rev 261)
+++ trunk/src/ext-commands.h 2008-07-30 17:53:36 UTC (rev 262)
@@ -50,6 +50,7 @@
UINT m_nCmdDebug0;
UINT m_nCmdDebug1;
UINT m_nCmdDebug2;
+ UINT m_nCmdDebug3;
/* A list of all active toolbar items. */
toolbar_info_t m_toolbar_info;
Modified: trunk/src/gpgol.def
===================================================================
--- trunk/src/gpgol.def 2008-06-27 18:10:42 UTC (rev 261)
+++ trunk/src/gpgol.def 2008-07-30 17:53:36 UTC (rev 262)
@@ -6,3 +6,8 @@
ExchEntryPoint = ExchEntryPoint at 0 @1
DllRegisterServer = DllRegisterServer at 0 @2 PRIVATE
DllUnregisterServer = DllUnregisterServer at 0 @3 PRIVATE
+
+ gpgol_check_version = gpgol_check_version at 4 @11
+ gpgol_message_revert = gpgol_message_revert at 12 @12
+
+
Modified: trunk/src/mapihelp.cpp
===================================================================
--- trunk/src/mapihelp.cpp 2008-06-27 18:10:42 UTC (rev 261)
+++ trunk/src/mapihelp.cpp 2008-07-30 17:53:36 UTC (rev 262)
@@ -951,7 +951,7 @@
else
{
/* Save old message class if not yet done. (The second
- consition is just a failsafe check). */
+ condition is just a failsafe check). */
if (!get_gpgololdmsgclass_tag (message, &tag)
&& PROP_TYPE (propval->ulPropTag) == PT_STRING8)
{
@@ -968,7 +968,6 @@
prop.ulPropTag = tag;
prop.Value.lpszA = propval->Value.lpszA;
hr = message->SetProps (1, &prop, NULL);
- xfree (newvalue);
if (hr)
{
log_error ("%s:%s: can't save old message class: hr=%#lx\n",
@@ -982,7 +981,7 @@
/* Change message class. */
log_debug ("%s:%s: setting message class to `%s'\n",
- SRCNAME, __func__, newvalue);
+ SRCNAME, __func__, newvalue);
prop.ulPropTag = PR_MESSAGE_CLASS_A;
prop.Value.lpszA = newvalue;
hr = message->SetProps (1, &prop, NULL);
@@ -1009,7 +1008,7 @@
/* Return the message class. This function will never return NULL so
- it is only useful for debugging. Caller needs to release the
+ it is mostly useful for debugging. Caller needs to release the
returned string. */
char *
mapi_get_message_class (LPMESSAGE message)
@@ -1040,8 +1039,42 @@
return retstr;
}
+/* Return the old message class. This function returns NULL if no old
+ message class has been saved. Caller needs to release the returned
+ string. */
+char *
+mapi_get_old_message_class (LPMESSAGE message)
+{
+ HRESULT hr;
+ ULONG tag;
+ LPSPropValue propval = NULL;
+ char *retstr;
+ if (!message)
+ return NULL;
+
+ if (get_gpgololdmsgclass_tag (message, &tag))
+ return NULL;
+ hr = HrGetOneProp ((LPMAPIPROP)message, tag, &propval);
+ if (FAILED (hr))
+ {
+ log_error ("%s:%s: HrGetOneProp() failed: hr=%#lx\n",
+ SRCNAME, __func__, hr);
+ return NULL;
+ }
+
+ if ( PROP_TYPE (propval->ulPropTag) == PT_STRING8 )
+ retstr = xstrdup (propval->Value.lpszA);
+ else
+ retstr = NULL;
+
+ MAPIFreeBuffer (propval);
+ return retstr;
+}
+
+
+
/* Return the sender of the message. According to the specs this is
an UTF-8 string; we rely on that the UI server handles
internationalized domain names. */
@@ -1615,8 +1648,8 @@
/* Return an attachment as a new IStream object. Returns NULL on
- failure. If R_ATATCH is not NULL the actual attachment will not be
- released by stored at that address; the caller needs to release it
+ failure. If R_ATTACH is not NULL the actual attachment will not be
+ released but stored at that address; the caller needs to release it
in this case. */
LPSTREAM
mapi_get_attach_as_stream (LPMESSAGE message, mapi_attach_item_t *item,
@@ -1807,7 +1840,7 @@
}
-/* Mark this attachment as the orginal MOSS message. We set a custom
+/* Mark this attachment as the original MOSS message. We set a custom
property as well as the hidden flag. */
int
mapi_mark_moss_attach (LPMESSAGE message, mapi_attach_item_t *item)
@@ -1828,13 +1861,6 @@
return -1;
}
- if (FAILED (hr))
- {
- log_error ("%s:%s: can't map %s property: hr=%#lx\n",
- SRCNAME, __func__, "GpgOL Attach Type", hr);
- goto leave;
- }
-
if (get_gpgolattachtype_tag (message, &prop.ulPropTag) )
goto leave;
prop.Value.l = ATTACHTYPE_MOSS;
@@ -1977,7 +2003,7 @@
return 0; /* No. */
/* We return False if we have an unknown signature status (?) or the
- message has been setn by us and not yet checked (@). */
+ message has been sent by us and not yet checked (@). */
if (PROP_TYPE (propval->ulPropTag) == PT_STRING8)
yes = !(propval->Value.lpszA && (!strcmp (propval->Value.lpszA, "?")
|| !strcmp (propval->Value.lpszA, "@")));
@@ -2109,7 +2135,7 @@
}
-/* Set the GpgOl charset t an asstachment.
+/* Set the GpgOl charset property to an attachment.
Note that this function does not call SaveChanges. */
int
mapi_set_gpgol_charset (LPMESSAGE obj, const char *charset)
@@ -2535,3 +2561,89 @@
return 0;
}
+
+/* Copy the attachment ITEM of the message MESSAGE verbatim to the
+ PR_BODY property. Returns 0 on success. This function does not
+ call SaveChanges. */
+int
+mapi_attachment_to_body (LPMESSAGE message, mapi_attach_item_t *item)
+{
+ int result = -1;
+ HRESULT hr;
+ LPATTACH att = NULL;
+ LPSTREAM instream = NULL;
+ LPSTREAM outstream = NULL;
+ LPUNKNOWN punk;
+
+ if (!message || !item || item->end_of_table || item->mapipos == -1)
+ return -1; /* Error. */
+
+ hr = message->OpenAttach (item->mapipos, NULL, MAPI_BEST_ACCESS, &att);
+ if (FAILED (hr))
+ {
+ log_error ("%s:%s: can't open attachment at %d: hr=%#lx",
+ SRCNAME, __func__, item->mapipos, hr);
+ goto leave;
+ }
+ if (item->method != ATTACH_BY_VALUE)
+ {
+ log_error ("%s:%s: attachment: method not supported", SRCNAME, __func__);
+ goto leave;
+ }
+
+ hr = att->OpenProperty (PR_ATTACH_DATA_BIN, &IID_IStream,
+ 0, 0, (LPUNKNOWN*) &instream);
+ if (FAILED (hr))
+ {
+ log_error ("%s:%s: can't open data stream of attachment: hr=%#lx",
+ SRCNAME, __func__, hr);
+ goto leave;
+ }
+
+
+ punk = (LPUNKNOWN)outstream;
+ hr = message->OpenProperty (PR_BODY_A, &IID_IStream, 0,
+ MAPI_CREATE|MAPI_MODIFY, &punk);
+ if (FAILED (hr))
+ {
+ log_error ("%s:%s: can't open body stream for update: hr=%#lx",
+ SRCNAME, __func__, hr);
+ goto leave;
+ }
+ outstream = (LPSTREAM)punk;
+
+ {
+ ULARGE_INTEGER cb;
+ cb.QuadPart = 0xffffffffffffffffll;
+ hr = instream->CopyTo (outstream, cb, NULL, NULL);
+ }
+ if (hr)
+ {
+ log_error ("%s:%s: can't copy streams: hr=%#lx\n",
+ SRCNAME, __func__, hr);
+ goto leave;
+ }
+ hr = outstream->Commit (0);
+ if (hr)
+ {
+ log_error ("%s:%s: commiting output stream failed: hr=%#lx",
+ SRCNAME, __func__, hr);
+ goto leave;
+ }
+ result = 0;
+
+ leave:
+ if (outstream)
+ {
+ if (result)
+ outstream->Revert ();
+ outstream->Release ();
+ }
+ if (instream)
+ instream->Release ();
+ if (att)
+ att->Release ();
+ return result;
+}
+
+
Modified: trunk/src/mapihelp.h
===================================================================
--- trunk/src/mapihelp.h 2008-06-27 18:10:42 UTC (rev 261)
+++ trunk/src/mapihelp.h 2008-07-30 17:53:36 UTC (rev 262)
@@ -112,6 +112,7 @@
int mapi_change_message_class (LPMESSAGE message, int sync_override);
char *mapi_get_message_class (LPMESSAGE message);
+char *mapi_get_old_message_class (LPMESSAGE message);
char *mapi_get_sender (LPMESSAGE message);
msgtype_t mapi_get_message_type (LPMESSAGE message);
int mapi_to_mime (LPMESSAGE message, const char *filename);
@@ -158,6 +159,8 @@
int *r_ishtml, int *r_protected);
+int mapi_attachment_to_body (LPMESSAGE message, mapi_attach_item_t *item);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/src/ol-ext-callback.cpp
===================================================================
--- trunk/src/ol-ext-callback.cpp 2008-06-27 18:10:42 UTC (rev 261)
+++ trunk/src/ol-ext-callback.cpp 2008-07-30 17:53:36 UTC (rev 262)
@@ -75,7 +75,7 @@
wchar_t *wname;
const char *s;
- log_debug ("%s:%s: looking for `%s'\n", SRCNAME, __func__, name);
+ // log_debug ("%s:%s: looking for `%s'\n", SRCNAME, __func__, name);
pCb = NULL;
pObj = NULL;
@@ -136,8 +136,8 @@
if (r_dispid)
*r_dispid = dispid;
- log_debug ("%s:%s: got IDispatch=%p dispid=%u\n",
- SRCNAME, __func__, pDisp, (unsigned int)dispid);
+ //log_debug ("%s:%s: got IDispatch=%p dispid=%u\n",
+ // SRCNAME, __func__, pDisp, (unsigned int)dispid);
return pDisp;
}
@@ -277,8 +277,8 @@
else if (aVariant.bstrVal)
{
result = wchar_to_utf8 (aVariant.bstrVal);
- log_debug ("%s:%s: `%s' is `%s'",
- SRCNAME, __func__, key, result);
+ //log_debug ("%s:%s: `%s' is `%s'",
+ // SRCNAME, __func__, key, result);
/* From MSDN (Invoke): It is up to the caller to free the return value.*/
SysFreeString (aVariant.bstrVal);
}
Modified: trunk/src/olflange.cpp
===================================================================
--- trunk/src/olflange.cpp 2008-06-27 18:10:42 UTC (rev 261)
+++ trunk/src/olflange.cpp 2008-07-30 17:53:36 UTC (rev 262)
@@ -48,6 +48,7 @@
#include "property-sheets.h"
#include "attached-file-events.h"
#include "item-events.h"
+#include "ol-ext-callback.h"
/* The GUID for this plugin. */
#define CLSIDSTR_GPGOL "{42d30988-1a3a-11da-c687-000d6080e735}"
@@ -283,7 +284,84 @@
}
+static const char*
+parse_version_number (const char *s, int *number)
+{
+ int val = 0;
+ if (*s == '0' && digitp (s+1))
+ return NULL; /* Leading zeros are not allowed. */
+ for (; digitp (s); s++)
+ {
+ val *= 10;
+ val += *s - '0';
+ }
+ *number = val;
+ return val < 0 ? NULL : s;
+}
+
+static const char *
+parse_version_string (const char *s, int *major, int *minor, int *micro)
+{
+ s = parse_version_number (s, major);
+ if (!s || *s != '.')
+ return NULL;
+ s++;
+ s = parse_version_number (s, minor);
+ if (!s || *s != '.')
+ return NULL;
+ s++;
+ s = parse_version_number (s, micro);
+ if (!s)
+ return NULL;
+ return s; /* Patchlevel. */
+}
+
+static const char *
+compare_versions (const char *my_version, const char *req_version)
+{
+ int my_major, my_minor, my_micro;
+ int rq_major, rq_minor, rq_micro;
More information about the Gnupg-commits
mailing list