Revision: 7471
http://mahogany.svn.sourceforge.net/mahogany/?rev=7471&view=rev
Author: vadz
Date: 2008-05-04 13:40:22 -0700 (Sun, 04 May 2008)
Log Message:
-----------
improve the display of the embedded mail messages (bug 932)
Modified Paths:
--------------
trunk/M/CHANGES
trunk/M/doc/Manual.htex
trunk/M/include/MessageView.h
trunk/M/include/Moptions.h
trunk/M/src/classes/MessageView.cpp
trunk/M/src/classes/Moptions.cpp
trunk/M/src/gui/wxOptionsDlg.cpp
trunk/M/src/modules/HtmlViewer.cpp
Modified: trunk/M/CHANGES
===================================================================
--- trunk/M/CHANGES 2008-05-04 19:07:22 UTC (rev 7470)
+++ trunk/M/CHANGES 2008-05-04 20:40:22 UTC (rev 7471)
@@ -9,6 +9,7 @@
Release 0.68 '' September xx, 2007
---------------------------------------
+2008-05-04 VZ: Improve the display of the embedded messages.
2008-05-04 VZ: Allow toggling tool/status bars and showing full-screen.
2008-05-02 VZ: Add support for server-side spam filters.
2008-04-25 VZ: Add support for filtering on individual headers to the GUI.
Modified: trunk/M/doc/Manual.htex
===================================================================
--- trunk/M/doc/Manual.htex 2008-05-04 19:07:22 UTC (rev 7470)
+++ trunk/M/doc/Manual.htex 2008-05-04 20:40:22 UTC (rev 7471)
@@ -81,6 +81,9 @@
is much simpler now, but is helpful for training the server-side
filters as using the \MenuCmd{Message|Spam} menu commands can now be
configured to do the right thing.
+ \item Improve the display of the embedded messages: now their headers can be
+ displayed inline too, see the new options in the message view
+ preferences dialog page.
\end{itemize}
\subsubsection{0.67 against 0.66}
Modified: trunk/M/include/MessageView.h
===================================================================
--- trunk/M/include/MessageView.h 2008-05-04 19:07:22 UTC (rev 7470)
+++ trunk/M/include/MessageView.h 2008-05-04 20:40:22 UTC (rev 7471)
@@ -30,6 +30,7 @@
class ASMailFolder;
class ClickableInfo;
+class HeaderIterator;
class MessageViewer;
class Message;
class MEventData;
@@ -368,9 +369,15 @@
/// show all headers?
bool showHeaders:1;
- /// inline MESSAGE/RFC822 attachments?
- bool inlineRFC822:1;
+ /// inline embedded MESSAGE/RFC822 attachments?
+ bool inlineEmbedded:1;
+ /// put decorations around embedded messages?
+ bool decorateEmbedded:1;
+
+ /// show headers for the embedded messages?
+ bool showEmbeddedHeaders:1;
+
/// inline TEXT/PLAIN attachments?
bool inlinePlainText:1;
@@ -531,13 +538,19 @@
void
ShowSelectedHeaders(const wxArrayString& headers, ViewableInfoFromHeaders
*vi);
- /// show all headers matching the array elements (which can contain
wildcards)
+ /// show all headers from headerIterator matching the names in the array
+ /// (which can contain wildcards)
void
- ShowMatchingHeaders(const wxArrayString& headers, ViewableInfoFromHeaders
*vi);
+ ShowMatchingHeaders(HeaderIterator headerIterator,
+ const wxArrayString& headers,
+ ViewableInfoFromHeaders *vi);
/// show information collected in vi while examining the headers
void ShowInfoFromHeaders(const ViewableInfoFromHeaders& vi);
+ /// return a colon separated list of names of the headers we should display
+ String GetHeaderNamesToDisplay() const;
+
/**
Possible values for the second parameter of ProcessPart.
*/
@@ -603,15 +616,30 @@
/// show a text part
void ShowTextPart(const MimePart *part);
- /// show a text
- void ShowText(String textPart, wxFontEncoding textEnc =
wxFONTENCODING_SYSTEM);
+ /// show a text (passed by value as it is modified inside)
+ void ShowText(String textPart,
+ wxFontEncoding textEnc = wxFONTENCODING_SYSTEM);
+ /// show a [single line of] text terminated by a new line
+ void ShowTextLine(const String& text = String(),
+ wxFontEncoding textEnc = wxFONTENCODING_SYSTEM)
+ {
+ ShowText(text + "\r\n", textEnc);
+ }
+
/// show an attachment
void ShowAttachment(const MimePart *part);
/// show an inline image
void ShowImage(const MimePart *part);
+ /// helper of ShowEmbeddedMessageStart/End()
+ void ShowEmbeddedMessageSeparator();
+
+ /// functions used before/after embedded message
+ void ShowEmbeddedMessageStart(const MimePart& part);
+ void ShowEmbeddedMessageEnd(const MimePart& part);
+
/// return the clickable info object (basicly a label) for this part
ClickableInfo *GetClickableInfo(const MimePart *part) const;
Modified: trunk/M/include/Moptions.h
===================================================================
--- trunk/M/include/Moptions.h 2008-05-04 19:07:22 UTC (rev 7470)
+++ trunk/M/include/Moptions.h 2008-05-04 20:40:22 UTC (rev 7471)
@@ -249,6 +249,8 @@
extern const MOption MP_VIEW_WRAPMARGIN;
extern const MOption MP_PLAIN_IS_TEXT;
extern const MOption MP_RFC822_IS_TEXT;
+extern const MOption MP_RFC822_DECORATE;
+extern const MOption MP_RFC822_SHOW_HEADERS;
extern const MOption MP_SHOW_XFACES;
extern const MOption MP_INLINE_GFX;
extern const MOption MP_INLINE_GFX_EXTERNAL;
@@ -908,6 +910,10 @@
#define MP_PLAIN_IS_TEXT_NAME "PlainIsText"
/// show MESSAGE/RFC822 as inlined text?
#define MP_RFC822_IS_TEXT_NAME "Rfc822IsText"
+/// show decorations around inlined MESSAGE/RFC822 text?
+#define MP_RFC822_DECORATE_NAME "Rfc822AsTextDecorate"
+/// show headers of the inlined MESSAGE/RFC822 text?
+#define MP_RFC822_SHOW_HEADERS_NAME "Rfc822AsTextHeaders"
/// show XFaces?
#define MP_SHOW_XFACES_NAME "ShowXFaces"
/// show graphics inline
@@ -1768,6 +1774,10 @@
#define MP_PLAIN_IS_TEXT_DEFVAL 1l
/// show MESSAGE/RFC822 as text?
#define MP_RFC822_IS_TEXT_DEFVAL 0l
+/// show decorations around inlined MESSAGE/RFC822 text?
+#define MP_RFC822_DECORATE_DEFVAL 1L
+/// show headers of the inlined MESSAGE/RFC822 text?
+#define MP_RFC822_SHOW_HEADERS_DEFVAL 1L
/// show XFaces?
#define MP_SHOW_XFACES_DEFVAL 1
/// show graphics inline
Modified: trunk/M/src/classes/MessageView.cpp
===================================================================
--- trunk/M/src/classes/MessageView.cpp 2008-05-04 19:07:22 UTC (rev 7470)
+++ trunk/M/src/classes/MessageView.cpp 2008-05-04 20:40:22 UTC (rev 7471)
@@ -136,6 +136,8 @@
extern const MOption MP_PLAIN_IS_TEXT;
extern const MOption MP_REPLY_QUOTE_SELECTION;
extern const MOption MP_RFC822_IS_TEXT;
+extern const MOption MP_RFC822_DECORATE;
+extern const MOption MP_RFC822_SHOW_HEADERS;
extern const MOption MP_SHOWHEADERS;
extern const MOption MP_SHOW_XFACES;
extern const MOption MP_TIFF2PS;
@@ -509,7 +511,9 @@
fontSize = -1;
showHeaders =
- inlineRFC822 =
+ inlineEmbedded =
+ decorateEmbedded =
+ showEmbeddedHeaders =
inlinePlainText =
showFaces =
highlightURLs =
@@ -533,7 +537,10 @@
CMP(HeaderNameCol) && CMP(HeaderValueCol) &&
CMP(fontDesc) &&
(!fontDesc.empty() || (CMP(fontFamily) && CMP(fontSize))) &&
- CMP(showHeaders) && CMP(inlineRFC822) && CMP(inlinePlainText) &&
+ CMP(showHeaders) &&
+ CMP(inlineEmbedded) && (!inlineEmbedded ||
+ (CMP(decorateEmbedded) && CMP(showEmbeddedHeaders))) &&
+ CMP(inlinePlainText) &&
CMP(inlineGFX) && CMP(showExtImages) &&
CMP(highlightURLs) && (!highlightURLs || CMP(UrlCol)) &&
// even if these fields are different, they don't change our
@@ -1204,7 +1211,11 @@
settings->showHeaders = READ_CONFIG_BOOL(profile, MP_SHOWHEADERS);
settings->inlinePlainText = READ_CONFIG_BOOL(profile, MP_PLAIN_IS_TEXT);
- settings->inlineRFC822 = READ_CONFIG_BOOL(profile, MP_RFC822_IS_TEXT);
+ settings->inlineEmbedded = READ_CONFIG_BOOL(profile, MP_RFC822_IS_TEXT);
+ settings->decorateEmbedded =
+ READ_CONFIG_BOOL(profile, MP_RFC822_DECORATE);
+ settings->showEmbeddedHeaders =
+ READ_CONFIG_BOOL(profile, MP_RFC822_SHOW_HEADERS);
// we set inlineGFX to 0 if we don't inline graphics at all and to the
// max size limit of graphics to show inline otherwise (-1 if no limit)
@@ -1408,13 +1419,14 @@
}
void
-MessageView::ShowMatchingHeaders(const wxArrayString& headersToShow,
+MessageView::ShowMatchingHeaders(HeaderIterator headerIterator,
+ const wxArrayString& headersToShow,
ViewableInfoFromHeaders *vi)
{
wxArrayString headerNames,
headerValues;
wxArrayInt headerEncodings;
- size_t countHeaders = m_mailMessage->GetHeaderIterator().GetAllDecoded
+ size_t countHeaders = headerIterator.GetAllDecoded
(
&headerNames,
&headerValues,
@@ -1849,6 +1861,21 @@
#endif // HAVE_XFACES
}
+String
+MessageView::GetHeaderNamesToDisplay() const
+{
+ // get all the headers we need to display
+ wxString headers = READ_CONFIG(GetProfile(), MP_MSGVIEW_HEADERS);
+
+ // ignore trailing colon as it would result in a dummy empty name after
+ // splitting (and unfortunately this extra colon can occur as some old M
+ // versions had it in the default value of MP_MSGVIEW_HEADERS by mistake)
+ if ( !headers.empty() && *headers.rbegin() == ':' )
+ headers.erase(headers.length() - 1);
+
+ return headers;
+}
+
void
MessageView::ShowHeaders()
{
@@ -1863,29 +1890,28 @@
}
else // show just the selected headers
{
- // get all the headers we need to display
- wxString headers = READ_CONFIG(GetProfile(), MP_MSGVIEW_HEADERS);
+ const String headers = GetHeaderNamesToDisplay();
+ if ( !headers.empty() )
+ {
+ const wxArrayString headersArray = strutil_restore_array(headers);
- // ignore trailing colon as it would result in a dummy empty name after
- // splitting (and unfortunately this extra colon can occur as some old M
- // versions had it in the default value of MP_MSGVIEW_HEADERS by mistake)
- if ( !headers.empty() && *headers.rbegin() == ':' )
- headers.erase(headers.length() - 1);
-
- if ( headers.empty() )
- return;
-
- const wxArrayString headersArray = strutil_restore_array(headers);
-
- // if we are using wildcards we need to examine all the headers anyhow so
- // just do it, otherwise we can retrieve just the headers we need (this
- // can make a huge difference, the default headers typically are ~100
- // bytes while the entire message header is commonly 2-3KB and sometimes
- // more)
- if ( headers.find_first_of("*?") != String::npos )
- ShowMatchingHeaders(headersArray, &vi);
- else
- ShowSelectedHeaders(headersArray, &vi);
+ // if we are using wildcards we need to examine all the headers anyhow
+ // so just do it, otherwise we can retrieve just the headers we need
+ // (this can make a huge difference, the default headers typically are
+ // ~100 bytes while the entire message header is commonly 2-3KB and
+ // sometimes more and, even more importantly, we can already have the
+ // envelope headers and if this is all we display we can avoid another
+ // trip to server completely)
+ if ( headers.find_first_of("*?") != String::npos )
+ {
+ ShowMatchingHeaders(m_mailMessage->GetHeaderIterator(),
+ headersArray, &vi);
+ }
+ else
+ {
+ ShowSelectedHeaders(headersArray, &vi);
+ }
+ }
}
// display anything requiring special treatment that we found in the headers
@@ -1995,6 +2021,50 @@
}
// ----------------------------------------------------------------------------
+// MessageView embedded messages display
+// ----------------------------------------------------------------------------
+
+// TODO: make this stuff configurable, e.g. by having an option specifying the
+// template to use and using MessageTemplateVarExpander here
+
+void MessageView::ShowEmbeddedMessageSeparator()
+{
+ if ( m_ProfileValues.decorateEmbedded )
+ ShowTextLine(wxString(80, '_'));
+}
+
+void MessageView::ShowEmbeddedMessageStart(const MimePart& part)
+{
+ ShowEmbeddedMessageSeparator();
+
+ if ( !m_ProfileValues.showEmbeddedHeaders )
+ return;
+
+ const MimePart * const nested = part.GetNested();
+ if ( nested )
+ {
+ const wxArrayString
+ displayHeaders = strutil_restore_array(GetHeaderNamesToDisplay());
+ if ( !displayHeaders.empty() )
+ {
+ m_viewer->StartHeaders();
+
+ ViewableInfoFromHeaders vi;
+ ShowMatchingHeaders(nested->GetHeaders(), displayHeaders, &vi);
+
+ ShowInfoFromHeaders(vi);
+
+ m_viewer->EndHeaders();
+ }
+ }
+}
+
+void MessageView::ShowEmbeddedMessageEnd(const MimePart& part)
+{
+ ShowEmbeddedMessageSeparator();
+}
+
+// ----------------------------------------------------------------------------
// MessageView attachments and images handling
// ----------------------------------------------------------------------------
@@ -2448,13 +2518,13 @@
pgpInfo->SetLog(log);
- ShowText("\r\n");
+ ShowTextLine();
m_viewer->InsertClickable(pgpInfo->GetBitmap(),
pgpInfo,
pgpInfo->GetColour());
- ShowText("\r\n");
+ ShowTextLine();
factory->DecRef();
@@ -2532,13 +2602,13 @@
pgpInfo->SetLog(log);
- ShowText("\r\n");
+ ShowTextLine();
m_viewer->InsertClickable(pgpInfo->GetBitmap(),
pgpInfo,
pgpInfo->GetColour());
- ShowText("\r\n");
+ ShowTextLine();
factory->DecRef();
@@ -2616,9 +2686,17 @@
return ProcessMultiPart(mimepart, type.GetSubType(), action);
case MimeType::MESSAGE:
- if ( m_ProfileValues.inlineRFC822 )
+ if ( m_ProfileValues.inlineEmbedded )
{
- return ProcessAllNestedParts(mimepart, action);
+ if ( action == Part_Show )
+ ShowEmbeddedMessageStart(*mimepart);
+
+ const bool rc = ProcessAllNestedParts(mimepart, action);
+
+ if ( action == Part_Show )
+ ShowEmbeddedMessageEnd(*mimepart);
+
+ return rc;
}
//else: fall through and show it as attachment
@@ -2752,7 +2830,7 @@
switch ( type.GetPrimary() )
{
case MimeType::MESSAGE:
- if ( !m_ProfileValues.inlineRFC822 )
+ if ( !m_ProfileValues.inlineEmbedded )
break;
//else: fall through and handle it as embedded multipart
Modified: trunk/M/src/classes/Moptions.cpp
===================================================================
--- trunk/M/src/classes/Moptions.cpp 2008-05-04 19:07:22 UTC (rev 7470)
+++ trunk/M/src/classes/Moptions.cpp 2008-05-04 20:40:22 UTC (rev 7471)
@@ -310,6 +310,8 @@
const MOption MP_VIEW_WRAPMARGIN;
const MOption MP_PLAIN_IS_TEXT;
const MOption MP_RFC822_IS_TEXT;
+const MOption MP_RFC822_DECORATE;
+const MOption MP_RFC822_SHOW_HEADERS;
const MOption MP_SHOW_XFACES;
const MOption MP_INLINE_GFX;
const MOption MP_INLINE_GFX_EXTERNAL;
@@ -729,6 +731,8 @@
DEFINE_OPTION(MP_VIEW_WRAPMARGIN),
DEFINE_OPTION(MP_PLAIN_IS_TEXT),
DEFINE_OPTION(MP_RFC822_IS_TEXT),
+ DEFINE_OPTION(MP_RFC822_DECORATE),
+ DEFINE_OPTION(MP_RFC822_SHOW_HEADERS),
DEFINE_OPTION(MP_SHOW_XFACES),
DEFINE_OPTION(MP_INLINE_GFX),
DEFINE_OPTION(MP_INLINE_GFX_EXTERNAL),
Modified: trunk/M/src/gui/wxOptionsDlg.cpp
===================================================================
--- trunk/M/src/gui/wxOptionsDlg.cpp 2008-05-04 19:07:22 UTC (rev 7470)
+++ trunk/M/src/gui/wxOptionsDlg.cpp 2008-05-04 20:40:22 UTC (rev 7471)
@@ -398,7 +398,10 @@
ConfigField_MessageViewInlineGraphicsSize,
ConfigField_MessageViewInlineGraphicsExternal,
ConfigField_MessageViewPlainIsText,
+ ConfigField_MessageViewRfc822InlineHelp,
ConfigField_MessageViewRfc822IsText,
+ ConfigField_MessageViewRfc822Decorate,
+ ConfigField_MessageViewRfc822ShowHeaders,
ConfigField_ViewWrapMargin,
ConfigField_ViewWrapAuto,
#ifdef OS_UNIX
@@ -1541,7 +1544,14 @@
{ gettext_noop("But only if size is less than (kb)"), Field_Number,
ConfigField_MessageViewInlineGraphics },
{ gettext_noop("&Enable showing external images"), Field_Bool,
ConfigField_MessageViewInlineGraphics },
{ gettext_noop("Display &text attachments inline"),Field_Bool, -1 },
- { gettext_noop("Display &mail messages as text"),Field_Bool, -1 },
+ { gettext_noop("Mahogany may display embedded mail messages directly "
+ "inline in the main message text\n"
+ "and you may choose whether they should be separated from "
+ "the surrounding text and\n"
+ "whether their headers should be displayed."),
Field_Message, -1 },
+ { gettext_noop("Display embedded &messages inline"),Field_Bool, -1 },
+ { gettext_noop("Put &separator lines around them"),Field_Bool,
ConfigField_MessageViewRfc822IsText },
+ { gettext_noop("Show embedded messages &headers"),Field_Bool,
ConfigField_MessageViewRfc822IsText },
{ gettext_noop("&Wrap margin"), Field_Number, -1,
},
{ gettext_noop("Wra&p lines automatically"), Field_Bool, -1,
},
#ifdef OS_UNIX
@@ -2138,7 +2148,10 @@
CONFIG_ENTRY(MP_INLINE_GFX_SIZE),
CONFIG_ENTRY(MP_INLINE_GFX_EXTERNAL),
CONFIG_ENTRY(MP_PLAIN_IS_TEXT),
+ CONFIG_NONE(), // embedded mail messages help
CONFIG_ENTRY(MP_RFC822_IS_TEXT),
+ CONFIG_ENTRY(MP_RFC822_DECORATE),
+ CONFIG_ENTRY(MP_RFC822_SHOW_HEADERS),
CONFIG_ENTRY(MP_VIEW_WRAPMARGIN),
CONFIG_ENTRY(MP_VIEW_AUTOMATIC_WORDWRAP),
#ifdef OS_UNIX
Modified: trunk/M/src/modules/HtmlViewer.cpp
===================================================================
--- trunk/M/src/modules/HtmlViewer.cpp 2008-05-04 19:07:22 UTC (rev 7470)
+++ trunk/M/src/modules/HtmlViewer.cpp 2008-05-04 20:40:22 UTC (rev 7471)
@@ -134,6 +134,9 @@
bool ShouldInlineImage(const String& url) const;
private:
+ // called by StartHeaders() first time it's called on a new message
+ void StartMessage();
+
// HTML helpers
// ------------
@@ -159,6 +162,7 @@
// wxScrolledWindow
void EmulateKeyPress(int keycode);
+
// the viewer window
HtmlViewerWindow *m_window;
@@ -890,11 +894,7 @@
m_nImage = 0;
}
-// ----------------------------------------------------------------------------
-// header showing
-// ----------------------------------------------------------------------------
-
-void HtmlViewer::StartHeaders()
+void HtmlViewer::StartMessage()
{
// set the default attributes
const ProfileValues& profileValues = GetOptions();
@@ -925,8 +925,20 @@
m_htmlText << _T("<tt>");
m_htmlEnd.Prepend(_T("</tt>"));
}
+}
- // the next header is going to be the first one
+// ----------------------------------------------------------------------------
+// header showing
+// ----------------------------------------------------------------------------
+
+void HtmlViewer::StartHeaders()
+{
+ // this can be called multiple times for display of the embedded message
+ // headers, only start the message once
+ if ( m_htmlText.empty() )
+ StartMessage();
+
+ // the next header will be the first one
m_firstheader = true;
}
@@ -993,6 +1005,8 @@
{
// close the headers table
m_htmlText += _T("</table>");
+
+ m_firstheader = true;
}
//else: we had no headers at all
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates