Update of /cvsroot/mahogany/M/src/classes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27696/src/classes
Modified Files:
MessageView.cpp
Log Message:
Improved MIME part selection: now we look inside nested multipart parts, so
that we don't show the text part if we have a multipart/alternative message
with text/plain part and mixed/related subpart containing text/html inside.
Real handling of mixed/related still not implemented though...
Index: MessageView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/MessageView.cpp,v
retrieving revision 1.169
retrieving revision 1.170
diff -b -u -2 -r1.169 -r1.170
--- MessageView.cpp 16 Jan 2006 20:32:27 -0000 1.169
+++ MessageView.cpp 20 Jan 2006 02:01:47 -0000 1.170
@@ -1973,5 +1973,5 @@
// first check for viewer specific formats, next for text, then for
// images and finally show all the rest as generic attachment
- if ( !isAttachment && m_viewer->CanProcess(mimeType) )
+ if ( !isAttachment && CanViewerProcessPart(mimepart) )
{
// as we're going to need its contents, we'll have to download it: check
@@ -2015,18 +2015,25 @@
}
-void
-MessageView::ProcessAllNestedParts(const MimePart *mimepart)
+bool
+MessageView::ProcessAllNestedParts(const MimePart *mimepart,
+ MimePartAction action)
{
+ bool rc = true;
+
const MimePart *partChild = mimepart->GetNested();
while ( partChild )
{
- ProcessPart(partChild);
+ if ( !ProcessPart(partChild, action) )
+ rc = false;
partChild = partChild->GetNext();
}
+
+ return rc;
}
bool
-MessageView::ProcessAlternativeMultiPart(const MimePart *mimepart)
+MessageView::ProcessAlternativeMultiPart(const MimePart *mimepart,
+ MimePartAction action)
{
// find the best subpart we can show
@@ -2043,6 +2050,5 @@
String mimetype = partChild->GetType().GetFull();
- if ( mimetype == _T("TEXT/PLAIN") ||
- m_viewer->CanProcess(mimetype) )
+ if ( mimetype == _T("TEXT/PLAIN") || CanViewerProcessPart(partChild) )
{
// remember this one as the best so far
@@ -2058,7 +2064,5 @@
// the content of an alternative is not necessarily a single
// part, so process it as well.
- ProcessPart(partBest);
-
- return true;
+ return ProcessPart(partBest, action);
}
@@ -2236,35 +2240,63 @@
}
-void
-MessageView::ProcessMultiPart(const MimePart *mimepart, const String& subtype)
+bool
+MessageView::ProcessMultiPart(const MimePart *mimepart,
+ const String& subtype,
+ MimePartAction action)
{
// TODO: support for DIGEST and RELATED
- bool processed;
+ bool processed = false;
if ( subtype == _T("ALTERNATIVE") )
{
- processed = ProcessAlternativeMultiPart(mimepart);
+ processed = ProcessAlternativeMultiPart(mimepart, action);
}
else if ( subtype == _T("SIGNED") )
{
+ switch ( action )
+ {
+ case Part_Show:
processed = ProcessSignedMultiPart(mimepart);
+ break;
+
+ case Part_Test:
+ // all viewers can display signatures
+ processed = true;
+ break;
+
+ default:
+ FAIL_MSG( _T("unknown MIME part processing action") );
+ }
}
else if ( subtype == _T("ENCRYPTED") )
{
+ switch ( action )
+ {
+ case Part_Show:
processed = ProcessEncryptedMultiPart(mimepart);
+ break;
+
+ case Part_Test:
+ // FIXME: this is wrong, we should examine the parts of the
+ // encrypted message
+ processed = true;
+ break;
+
+ default:
+ FAIL_MSG( _T("unknown MIME part processing action") );
}
- else // process all unknown as MIXED (according to the RFC 2047)
- {
- processed = false;
}
+ //else: process all unknown as MIXED (according to the RFC 2047)
if ( !processed )
- ProcessAllNestedParts(mimepart);
+ processed = ProcessAllNestedParts(mimepart, action);
+
+ return processed;
}
-void
-MessageView::ProcessPart(const MimePart *mimepart)
+bool
+MessageView::ProcessPart(const MimePart *mimepart, MimePartAction action)
{
- CHECK_RET( mimepart, _T("MessageView::ProcessPart: NULL mimepart") );
+ CHECK( mimepart, false, _T("MessageView::ProcessPart: NULL mimepart") );
const MimeType type = mimepart->GetType();
@@ -2272,11 +2304,10 @@
{
case MimeType::MULTIPART:
- ProcessMultiPart(mimepart, type.GetSubType());
- break;
+ return ProcessMultiPart(mimepart, type.GetSubType(), action);
case MimeType::MESSAGE:
if ( m_ProfileValues.inlineRFC822 )
{
- ProcessAllNestedParts(mimepart);
+ return ProcessAllNestedParts(mimepart, action);
}
//else: fall through and show it as attachment
@@ -2295,6 +2326,22 @@
case MimeType::CUSTOM5:
case MimeType::CUSTOM6:
+ switch ( action )
+ {
+ case Part_Show:
// a simple part, show it (ShowPart() decides how exactly)
ShowPart(mimepart);
+ return true;
+
+ case Part_Test:
+ {
+ const MimeType type = mimepart->GetType();
+ return (type.GetPrimary() == MimeType::IMAGE &&
+ m_viewer->CanInlineImages()) ||
+ m_viewer->CanProcess(type.GetFull());
+ }
+
+ default:
+ FAIL_MSG( _T("unknown MIME part processing action") );
+ }
break;
@@ -2302,4 +2349,6 @@
FAIL_MSG( _T("unknown MIME type") );
}
+
+ return false;
}
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates