Update of /cvsroot/mahogany/M/src/classes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5464/src/classes
Modified Files:
MessageView.cpp
Log Message:
show full headers in colour and with URL detection too (and don't show the configured
headers when showing all of them anyhow)
Index: MessageView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/MessageView.cpp,v
retrieving revision 1.153
retrieving revision 1.154
diff -b -u -2 -r1.153 -r1.154
--- MessageView.cpp 13 Jul 2004 21:58:41 -0000 1.153
+++ MessageView.cpp 14 Jul 2004 18:20:56 -0000 1.154
@@ -1151,4 +1151,113 @@
void
+MessageView::ShowHeader(const String& name,
+ const String& valueOrig,
+ wxFontEncoding encHeader)
+{
+ m_viewer->ShowHeaderName(name);
+
+ String value(valueOrig);
+ wxFontEncoding encReal = encHeader;
+ if ( encHeader != wxFONTENCODING_SYSTEM )
+ {
+ // convert the string to an encoding we can show, if needed
+ EnsureAvailableTextEncoding(&encReal, &value);
+ }
+
+ // don't highlight URLs in headers which contain message IDs or other things
+ // which look just like the URLs but, in fact, are not ones
+ bool highlightURLs = m_ProfileValues.highlightURLs;
+ String nameUpper(name.Upper());
+ if ( highlightURLs )
+ {
+ if ( nameUpper == _T("IN-REPLY-TO") ||
+ nameUpper == _T("REFERENCES") ||
+ nameUpper == _T("CONTENT-ID") ||
+ nameUpper == _T("MESSAGE-ID") ||
+ nameUpper == _T("RESENT-MESSAGE-ID") )
+ {
+ highlightURLs = false;
+ }
+ }
+
+ do
+ {
+ String before,
+ url,
+ urlText;
+
+ if ( highlightURLs )
+ {
+ before = strutil_findurl(value, url);
+
+ // for headers (usually) containing addresses with personal names try
+ // to detect the personal names as well
+ if ( *url.c_str() == _T('<') &&
+ (nameUpper == _T("FROM") ||
+ nameUpper == _T("TO") ||
+ nameUpper == _T("CC") ||
+ nameUpper == _T("BCC") ||
+ nameUpper == _T("RESENT-FROM") ||
+ nameUpper == _T("RESENT-TO")) )
+ {
+ urlText = url;
+
+ // try to find the personal name as well by going backwards
+ // until we reach the previous address
+ bool inQuotes = false,
+ stop = false;
+
+ while ( !before.empty() )
+ {
+ wxChar ch = before.Last();
+ switch ( ch )
+ {
+ case _T('"'):
+ inQuotes = !inQuotes;
+ break;
+
+ case _T(','):
+ case _T(';'):
+ if ( !inQuotes )
+ stop = true;
+ }
+
+ if ( stop )
+ break;
+
+ urlText.insert((size_t)0, (size_t)1, ch);
+ before.erase(before.length() - 1);
+ }
+ }
+ else // not a mail address
+ {
+ // use the URL itself as label
+ urlText = url;
+ }
+ }
+ else // no URL highlighting
+ {
+ before = value;
+ value.clear();
+ }
+
+ // do this even if "before" is empty if we have to change the
+ // encoding (it will affect the URL following it)
+ if ( !before.empty() || encReal != wxFONTENCODING_SYSTEM )
+ {
+ m_viewer->ShowHeaderValue(before, encReal);
+ }
+
+ if ( !url.empty() )
+ {
+ m_viewer->ShowHeaderURL(urlText, url);
+ }
+ }
+ while ( !value.empty() );
+
+ m_viewer->EndHeader();
+}
+
+void
MessageView::ShowHeaders()
{
@@ -1158,7 +1267,15 @@
if ( m_ProfileValues.showHeaders )
{
- m_viewer->ShowRawHeaders(m_mailMessage->GetHeader());
- }
+ HeaderIterator headers(m_mailMessage->GetHeader());
+ String name,
+ value;
+ while ( headers.GetNext(&name, &value, HeaderIterator::MultiLineOk) )
+ {
+ ShowHeader(name, value, wxFONTENCODING_SYSTEM);
+ }
+ }
+ else
+ {
// retrieve all headers at once instead of calling Message::GetHeaderLine()
// many times: this is incomparably faster with remote servers (one round
@@ -1473,8 +1590,8 @@
const String& name = headerNames[n];
- // there can be more than one line in each header in which case we show
- // each line of the value on a separate line -- although this is wrong
- // because there could be a single header with a multiline value as well,
- // this is the best we can do considering that GetHeaderLine()
+ // there can be more than one line in each header in which case we
+ // show each line of the value on a separate line -- although this is
+ // wrong because there could be a single header with a multiline value
+ // as well, this is the best we can do considering that GetHeaderLine
// concatenates the values of all headers with the same name anyhow
wxArrayString values = wxStringTokenize(value, _T("\n"));
@@ -1483,98 +1600,16 @@
for ( size_t line = 0; line < linesCount; ++line )
{
- m_viewer->ShowHeaderName(name);
-
- String value = values[line];
-
- wxFontEncoding encReal = encHeader;
- if ( encHeader != wxFONTENCODING_SYSTEM )
- {
- // convert the string to an encoding we can show, if needed
- EnsureAvailableTextEncoding(&encReal, &value);
- }
-
- // don't highlight the message IDs which looks just like the URLs but,
- // in fact, are not ones (the test is for Message-Id and Content-Id
- // headers only right now but we use a wildcard in case there are some
- // other similar ones)
- bool highlightURLs = m_ProfileValues.highlightURLs &&
- !name.Upper().Matches(_T("*-ID"));
- do
- {
- String before,
- url,
- urlText;
-
- if ( highlightURLs )
- {
- before = strutil_findurl(value, url);
-
- if ( *url.c_str() == _T('<') )
- {
- urlText = url;
-
- // try to find the personal name as well by going backwards
- // until we reach the previous address
- bool inQuotes = false,
- stop = false;
-
- while ( !before.empty() )
- {
- wxChar ch = before.Last();
- switch ( ch )
- {
- case _T('"'):
- inQuotes = !inQuotes;
- break;
-
- case _T(','):
- case _T(';'):
- if ( !inQuotes )
- stop = true;
- }
-
- if ( stop )
- break;
-
- urlText.insert((size_t)0, (size_t)1, ch);
- before.erase(before.length() - 1);
- }
- }
- else // not a mail address
- {
- // use the URL itself as label
- urlText = url;
+ ShowHeader(name, values[line], encHeader);
}
}
- else // no URL highlighting
- {
- before = value;
- value.clear();
- }
- // do this even if "before" is empty if we have to change the
- // encoding (it will affect the URL following it)
- if ( !before.empty() || encReal != wxFONTENCODING_SYSTEM )
- {
- m_viewer->ShowHeaderValue(before, encReal);
- }
-
- if ( !url.empty() )
- {
- m_viewer->ShowHeaderURL(urlText, url);
- }
- }
- while ( !value.empty() );
- }
-
- m_viewer->EndHeader();
+ // NB: some broken mailers don't create correct "Content-Type" header,
+ // but they may yet give us the necessary info in the other headers
+ // so we assume the header encoding as the default encoding for the
+ // body
+ m_encodingAuto = encInHeaders;
}
m_viewer->EndHeaders();
-
- // NB: some broken mailers don't create correct "Content-Type" header,
- // but they may yet give us the necessary info in the other headers so
- // we assume the header encoding as the default encoding for the body
- m_encodingAuto = encInHeaders;
}
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates