SF.net SVN: mahogany: [7179] trunk/M/src/classes/MessageView.cpp

[email protected]
Newsgroups gmane.mail.mahogany.cvs
Message-ID <[email protected]>
Revision: 7179
          http://svn.sourceforge.net/mahogany/?rev=7179&view=rev
Author:   vadz
Date:     2006-12-23 14:42:58 -0800 (Sat, 23 Dec 2006)

Log Message:
-----------
hack to use HTML viewer for multipart/related messages with HTML and image parts

Modified Paths:
--------------
    trunk/M/src/classes/MessageView.cpp

Modified: trunk/M/src/classes/MessageView.cpp
===================================================================
--- trunk/M/src/classes/MessageView.cpp	2006-12-22 15:52:47 UTC (rev 7178)
+++ trunk/M/src/classes/MessageView.cpp	2006-12-23 22:42:58 UTC (rev 7179)
@@ -2492,7 +2492,10 @@
 {
    PartContent_Text = 0x01,
    PartContent_Image = 0x02,
-   PartContent_HTML = 0x04
+   PartContent_HTML = 0x04,
+
+   // this one is set when we have images only used by HTML part of the message
+   PartContent_HTMLImage = 0x08
 };
 
 int
@@ -2515,12 +2518,30 @@
 
          case MimeType::MULTIPART:
             {
+               // the automatic viewer determination logic is the same for
+               // multipart/alternative and multipart/mixed and we don't really
+               // support anything else for now (except multipart/related which
+               // is accounted for below)
                for ( const MimePart *partChild = mimepart->GetNested();
                      partChild;
                      partChild = partChild->GetNext() )
                {
                   contents |= DeterminePartContent(partChild);
                }
+
+               if ( type.GetSubType() == _T("RELATED") )
+               {
+                  // this is, of course, just a particular cas but a very
+                  // common one so we handle the situation when we have
+                  // multipart/related with an HTML part and an image part
+                  // specially: this almost certainly means that the images can
+                  // be seen *only* when HTML is viewed
+                  if ( (contents & PartContent_HTML) &&
+                           (contents & PartContent_Image) )
+                  {
+                     contents |= PartContent_HTMLImage;
+                  }
+               }
             }
             break;
 
@@ -2567,9 +2588,13 @@
    if ( contents & PartContent_HTML )
    {
       // use HTML viewer when the user prefers HTML to plain text or when there
-      // is nothing but HTML
+      // is nothing but HTML or when we have images embedded in HTML (so they
+      // won't be shown if we don't use the HTML viewer) and we do want to see
+      // images inline
       if ( m_ProfileValues.preferHTML ||
-            (!(contents & PartContent_Text) && m_ProfileValues.allowHTML) )
+            (!(contents & PartContent_Text) && m_ProfileValues.allowHTML) ||
+               ((contents & PartContent_HTMLImage) &&
+                  m_ProfileValues.allowImages) )
       {
          viewerName = _T("HtmlViewer");
       }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.