Revision: 7353
          http://mahogany.svn.sourceforge.net/mahogany/?rev=7353&view=rev
Author:   vadz
Date:     2007-08-30 13:24:02 -0700 (Thu, 30 Aug 2007)

Log Message:
-----------
added GetDecodedHeaderLine(), use it to show the encoded headers properly in 
the UI

Modified Paths:
--------------
    trunk/M/include/Message.h
    trunk/M/src/classes/ComposeTemplate.cpp
    trunk/M/src/gui/wxFolderView.cpp
    trunk/M/src/mail/AddressCC.cpp
    trunk/M/src/mail/MailFolder.cpp
    trunk/M/src/mail/MailFolderCmn.cpp
    trunk/M/src/mail/Message.cpp
    trunk/M/src/modules/Filters.cpp

Modified: trunk/M/include/Message.h
===================================================================
--- trunk/M/include/Message.h   2007-08-30 17:46:14 UTC (rev 7352)
+++ trunk/M/include/Message.h   2007-08-30 20:24:02 UTC (rev 7353)
@@ -143,8 +143,14 @@
     */
    //@{
 
-   /** get any header line
+   /**
+       Get any header line
 
+       This returns the raw header line content, for the header lines which may
+       contain encoded MIME words, such as subject or any of the headers
+       containing addresses, use GetDecodedHeaderLine() if raw form is not
+       needed.
+
        USE GetHeaderLines() INSTEAD OF MULTIPLE CALLS To GetHeaderLine(),
        IT IS MUCH MORE EFFICIENT AS IT INVOLVES ONLY ONE TRIP TO SERVER!
 
@@ -156,6 +162,15 @@
                       String &value,
                       wxFontEncoding *encoding = NULL) const;
 
+   /**
+      Get the header line after decoding any MIME-encoded words in it.
+
+      @param line name of header line
+      @param value string where result will be stored, or empty string
+      @return true if header was found in the headers
+    */
+   bool GetDecodedHeaderLine(const String& line, String& value) const;
+
    /** Get the values of the specified headers.
 
        @param headers the NULL-terminated array of the headers to retrieve

Modified: trunk/M/src/classes/ComposeTemplate.cpp
===================================================================
--- trunk/M/src/classes/ComposeTemplate.cpp     2007-08-30 17:46:14 UTC (rev 
7352)
+++ trunk/M/src/classes/ComposeTemplate.cpp     2007-08-30 20:24:02 UTC (rev 
7353)
@@ -560,7 +560,7 @@
    // X-Attribution header value overrides everything else if it exists
    if ( msg && READ_CONFIG_BOOL(profile, MP_REPLY_MSGPREFIX_FROM_XATTR) )
    {
-      msg->GetHeaderLine(_T("X-Attribution"), prefix);
+      msg->GetDecodedHeaderLine(_T("X-Attribution"), prefix);
    }
 
    // prepend the senders initials to the reply prefix (this

Modified: trunk/M/src/gui/wxFolderView.cpp
===================================================================
--- trunk/M/src/gui/wxFolderView.cpp    2007-08-30 17:46:14 UTC (rev 7352)
+++ trunk/M/src/gui/wxFolderView.cpp    2007-08-30 20:24:02 UTC (rev 7353)
@@ -5219,7 +5219,7 @@
                   MFolder_obj folder(m_folderName);
 
                   String to;
-                  (void)msg->GetHeaderLine(_T("To"), to);
+                  (void)msg->GetDecodedHeaderLine(_T("To"), to);
 
                   if ( CreateQuickFilter(folder,
                                          msg->From(), msg->Subject(), to,

Modified: trunk/M/src/mail/AddressCC.cpp
===================================================================
--- trunk/M/src/mail/AddressCC.cpp      2007-08-30 17:46:14 UTC (rev 7352)
+++ trunk/M/src/mail/AddressCC.cpp      2007-08-30 20:24:02 UTC (rev 7353)
@@ -502,7 +502,7 @@
       }
    }
 
-   return address;
+   return MIME::DecodeHeader(address);
 }
 
 static String RemoveEmptyListParts(const String &original)

Modified: trunk/M/src/mail/MailFolder.cpp
===================================================================
--- trunk/M/src/mail/MailFolder.cpp     2007-08-30 17:46:14 UTC (rev 7352)
+++ trunk/M/src/mail/MailFolder.cpp     2007-08-30 20:24:02 UTC (rev 7353)
@@ -1070,7 +1070,7 @@
    if ( READ_CONFIG(profile, MP_SET_REPLY_FROM_TO) )
    {
       String to;
-      msg->GetHeaderLine(_T("To"), to);
+      msg->GetDecodedHeaderLine(_T("To"), to);
 
       String from;
       if ( ContainsOwnAddress(to, profile, OwnAddress_From, &from) )

Modified: trunk/M/src/mail/MailFolderCmn.cpp
===================================================================
--- trunk/M/src/mail/MailFolderCmn.cpp  2007-08-30 17:46:14 UTC (rev 7352)
+++ trunk/M/src/mail/MailFolderCmn.cpp  2007-08-30 20:24:02 UTC (rev 7353)
@@ -995,7 +995,7 @@
                break;
 
             case SearchCriterium::SC_CC:
-               msg->GetHeaderLine(_T("CC"), what);
+               msg->GetDecodedHeaderLine(_T("CC"), what);
                break;
 
             default:

Modified: trunk/M/src/mail/Message.cpp
===================================================================
--- trunk/M/src/mail/Message.cpp        2007-08-30 17:46:14 UTC (rev 7352)
+++ trunk/M/src/mail/Message.cpp        2007-08-30 20:24:02 UTC (rev 7353)
@@ -28,6 +28,7 @@
 #include "Message.h"
 
 #include "Address.h"
+#include "mail/MimeDecode.h"
 
 // ============================================================================
 // implementation of Message methods for working with addresses
@@ -114,6 +115,16 @@
    return !value.empty();
 }
 
+bool Message::GetDecodedHeaderLine(const String& line, String& value) const
+{
+   if ( !GetHeaderLine(line, value) )
+      return false;
+
+   value = MIME::DecodeHeader(value);
+
+   return true;
+}
+
 // ----------------------------------------------------------------------------
 // Message creation
 // ----------------------------------------------------------------------------

Modified: trunk/M/src/modules/Filters.cpp
===================================================================
--- trunk/M/src/modules/Filters.cpp     2007-08-30 17:46:14 UTC (rev 7352)
+++ trunk/M/src/modules/Filters.cpp     2007-08-30 20:24:02 UTC (rev 7353)
@@ -2078,7 +2078,7 @@
       return Value(wxEmptyString);
 
    String tostr;
-   msg->GetHeaderLine(_T("To"), tostr);
+   msg->GetDecodedHeaderLine(_T("To"), tostr);
    return Value(tostr);
 }
 


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: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to