36 #include "headerstyle.h"
38 #include "headerstrategy.h"
40 #include "linklocator.h"
41 #include "kmmessage.h"
42 #include "spamheaderanalyzer.h"
43 #include "globalsettings.h"
45 #include <libemailfunctions/email.h>
46 #include <libtdepim/kxface.h>
49 #include <mimelib/string.h>
50 #include <mimelib/field.h>
51 #include <mimelib/headers.h>
54 #include <tdelocale.h>
55 #include <tdeglobal.h>
56 #include <tdeimproxy.h>
57 #include <tdeabc/stdaddressbook.h>
58 #include <tdeabc/addresseelist.h>
60 #include <tqdatetime.h>
64 #include <tqapplication.h>
67 #include <kstandarddirs.h>
74 static inline TQString directionOf(
const TQString & str ) {
75 return str.isRightToLeft() ?
"rtl" :
"ltr" ;
82 static TQString convertToHtmlBlock(
const TQString & str,
bool useSpan=
false ) {
83 TQString dir = directionOf( str );
84 TQString format =
"<%1 dir=\"%3\">%4</%2>";
85 return format.arg( useSpan ?
"span" :
"div" )
86 .arg( useSpan ?
"span" :
"div" )
88 .arg( LinkLocator::convertToHtml( str ) );
93 static TQString strToHtml(
const TQString & str,
94 int flags = LinkLocator::PreserveSpaces ) {
95 return LinkLocator::convertToHtml( str, flags );
103 class BriefHeaderStyle :
public HeaderStyle {
104 friend class ::KMail::HeaderStyle;
106 BriefHeaderStyle() : HeaderStyle() {}
107 virtual ~BriefHeaderStyle() {}
110 const char * name()
const {
return "brief"; }
111 const HeaderStyle * next()
const {
return plain(); }
112 const HeaderStyle * prev()
const {
return fancy(); }
114 TQString format(
const KMMessage * message,
const HeaderStrategy * strategy,
115 const TQString & vCardName,
bool printing,
bool topLevel )
const;
118 TQString BriefHeaderStyle::format(
const KMMessage * message,
119 const HeaderStrategy * strategy,
120 const TQString & vCardName,
bool printing,
bool topLevel )
const {
121 Q_UNUSED( topLevel );
122 if ( !message )
return TQString();
124 strategy = HeaderStrategy::brief();
129 TQString dir = TQApplication::reverseLayout() ?
"rtl" :
"ltr" ;
138 if (!message->
subject().isEmpty())
139 subjectDir = directionOf( message->cleanSubject() );
141 subjectDir = directionOf( i18n(
"No Subject") );
147 TDELocale * locale = TDEGlobal::locale();
148 dateTime.setTime_t( message->date() );
149 dateString = locale->formatDateTime( dateTime );
151 dateString = message->
dateStr();
154 TQString headerStr =
"<div class=\"header\" dir=\"" + dir +
"\">\n";
156 if ( strategy->showHeader(
"subject" ) )
157 headerStr +=
"<div dir=\"" + subjectDir +
"\">\n"
158 "<b style=\"font-size:130%\">" +
159 strToHtml( message->
subject() ) +
162 TQStringList headerParts;
164 if ( strategy->showHeader(
"from" ) ) {
165 TQString fromStr = message->
from();
166 if ( fromStr.isEmpty() )
167 fromStr = message->fromStrip();
169 if ( !vCardName.isEmpty() )
170 fromPart +=
" <a href=\"" + vCardName +
"\">" + i18n(
"[vCard]") +
"</a>";
171 headerParts << fromPart;
174 if ( strategy->showHeader(
"cc" ) && !message->
cc().isEmpty() )
177 if ( strategy->showHeader(
"bcc" ) && !message->
bcc().isEmpty() )
180 if ( strategy->showHeader(
"date" ) )
184 headerStr +=
" (" + headerParts.grep( TQRegExp(
"\\S" ) ).join(
",\n" ) +
')';
186 headerStr +=
"</div>\n";
199 class PlainHeaderStyle :
public HeaderStyle {
200 friend class ::KMail::HeaderStyle;
202 PlainHeaderStyle() : HeaderStyle() {}
203 virtual ~PlainHeaderStyle() {}
206 const char * name()
const {
return "plain"; }
207 const HeaderStyle * next()
const {
return fancy(); }
208 const HeaderStyle * prev()
const {
return brief(); }
210 TQString format(
const KMMessage * message,
const HeaderStrategy * strategy,
211 const TQString & vCardName,
bool printing,
bool topLevel )
const;
214 TQString formatAllMessageHeaders(
const KMMessage * message )
const;
217 TQString PlainHeaderStyle::format(
const KMMessage * message,
218 const HeaderStrategy * strategy,
219 const TQString & vCardName,
bool printing,
bool topLevel )
const {
220 Q_UNUSED( topLevel );
221 if ( !message )
return TQString();
223 strategy = HeaderStrategy::rich();
228 TQString dir = ( TQApplication::reverseLayout() ?
"rtl" :
"ltr" );
237 if (!message->
subject().isEmpty())
238 subjectDir = directionOf( message->cleanSubject() );
240 subjectDir = directionOf( i18n(
"No Subject") );
246 TDELocale* locale = TDEGlobal::locale();
247 dateTime.setTime_t( message->date() );
248 dateString = locale->formatDateTime( dateTime );
251 dateString = message->
dateStr();
256 if ( strategy->headersToDisplay().isEmpty()
257 && strategy->defaultPolicy() == HeaderStrategy::Display ) {
260 headerStr= TQString(
"<div class=\"header\" dir=\"ltr\">");
261 headerStr += formatAllMessageHeaders( message );
262 return headerStr +
"</div>";
265 headerStr = TQString(
"<div class=\"header\" dir=\"%1\">").arg(dir);
268 if ( strategy->showHeader(
"subject" ) )
269 headerStr += TQString(
"<div dir=\"%1\"><b style=\"font-size:130%\">" +
270 strToHtml(message->
subject()) +
"</b></div>\n")
273 if ( strategy->showHeader(
"date" ) )
274 headerStr.append(i18n(
"Date: ") + strToHtml(dateString)+
"<br>\n");
280 if ( strategy->showHeader(
"status" ) )
282 TDEABC::AddressBook *addressBook = TDEABC::StdAddressBook::self(
true );
283 TDEABC::AddresseeList addresses = addressBook->findByEmail( KPIM::getFirstEmailAddress( message->
from() ) );
285 tdeabcUid = addresses[0].uid();
286 presence = imProxy->presenceString( tdeabcUid );
290 if ( strategy->showHeader(
"from" ) ) {
291 TQString fromStr = message->
from();
292 if ( fromStr.isEmpty() )
293 fromStr = message->fromStrip();
294 headerStr.append(i18n(
"From: ") +
296 if ( !vCardName.isEmpty() )
297 headerStr.append(
" <a href=\"" + vCardName +
298 "\">" + i18n(
"[vCard]") +
"</a>" );
300 if ( !presence.isEmpty() && strategy->showHeader(
"status" ) )
301 headerStr.append(
" (<span name=\"presence-" + tdeabcUid +
"\">" + presence +
"</span>)" );
304 if ( strategy->showHeader(
"organization" )
305 && !message->
headerField(
"Organization").isEmpty())
306 headerStr.append(
" (" +
307 strToHtml(message->
headerField(
"Organization")) +
")");
308 headerStr.append(
"<br>\n");
311 if ( strategy->showHeader(
"to" ) )
312 headerStr.append(i18n(
"To: ")+
315 if ( strategy->showHeader(
"cc" ) && !message->
cc().isEmpty() )
316 headerStr.append(i18n(
"CC: ")+
319 if ( strategy->showHeader(
"bcc" ) && !message->
bcc().isEmpty() )
320 headerStr.append(i18n(
"BCC: ")+
323 if ( strategy->showHeader(
"reply-to" ) && !message->
replyTo().isEmpty())
324 headerStr.append(i18n(
"Reply to: ")+
327 headerStr +=
"</div>\n";
332 TQString PlainHeaderStyle::formatAllMessageHeaders(
const KMMessage * message )
const {
333 const DwHeaders & headers = message->
headers();
336 for (
const DwField * field = headers.FirstField() ; field ; field = field->Next() ) {
337 result += ( field->FieldNameStr() +
": " ).c_str();
338 result += strToHtml( field->FieldBodyStr().c_str() );
350 class FancyHeaderStyle :
public HeaderStyle {
351 friend class ::KMail::HeaderStyle;
353 FancyHeaderStyle() : HeaderStyle() {}
354 virtual ~FancyHeaderStyle() {}
357 const char * name()
const {
return "fancy"; }
358 const HeaderStyle * next()
const {
return enterprise(); }
359 const HeaderStyle * prev()
const {
return plain(); }
361 TQString format(
const KMMessage * message,
const HeaderStrategy * strategy,
362 const TQString & vCardName,
bool printing,
bool topLevel )
const;
363 static TQString imgToDataUrl(
const TQImage & image,
364 const char *fmt =
"PNG" );
367 static TQString drawSpamMeter(
double percent,
const TQString & filterHeader );
371 TQString FancyHeaderStyle::drawSpamMeter(
double percent,
372 const TQString & filterHeader )
374 TQImage meterBar( 20, 1, 8, 24 );
375 const unsigned short gradient[20][3] = {
397 meterBar.setColor( 21, tqRgb( 255, 255, 255 ) );
398 meterBar.setColor( 22, tqRgb( 170, 170, 170 ) );
403 int max = TQMIN( 20,
static_cast<int>( percent ) / 5 );
404 for (
int i = 0; i < max; ++i ) {
405 meterBar.setColor( i+1, tqRgb( gradient[i][0], gradient[i][1],
407 meterBar.setPixel( i, 0, i+1 );
410 TQString titleText = i18n(
"%1% probability of being spam.\n\nFull report:\n%2")
411 .arg( TQString::number( percent ), filterHeader );
412 return TQString(
"<img src=\"%1\" width=\"%2\" height=\"%3\" style=\"border: 1px solid black;\" title=\"%4\"> ")
413 .arg( imgToDataUrl( meterBar,
"PPM" ), TQString::number( 20 ),
414 TQString::number( 5 ), titleText );
418 TQString FancyHeaderStyle::format(
const KMMessage * message,
419 const HeaderStrategy * strategy,
420 const TQString & vCardName,
bool printing,
bool topLevel )
const {
421 Q_UNUSED( topLevel );
422 if ( !message )
return TQString();
424 strategy = HeaderStrategy::rich();
426 TDEConfigGroup configReader( KMKernel::config(),
"Reader" );
432 TQString dir = ( TQApplication::reverseLayout() ?
"rtl" :
"ltr" );
433 TQString headerStr = TQString(
"<div class=\"fancy header\" dir=\"%1\">\n").arg(dir);
442 if ( !message->
subject().isEmpty() )
443 subjectDir = directionOf( message->cleanSubject() );
445 subjectDir = directionOf( i18n(
"No Subject") );
451 TDELocale* locale = TDEGlobal::locale();
452 dateTime.setTime_t( message->date() );
453 dateString = locale->formatDateTime( dateTime );
456 dateString = message->
dateStr();
466 if ( configReader.readBoolEntry(
"showSpamStatus",
true ) ) {
467 SpamScores scores = SpamHeaderAnalyzer::getSpamScores( message );
468 for ( SpamScoresIterator it = scores.begin(); it != scores.end(); ++it )
469 spamHTML += (*it).agent() +
" " +
470 drawSpamMeter( (*it).score(), (*it).spamHeader() );
480 TDEABC::AddressBook *addressBook = TDEABC::StdAddressBook::self(
true );
481 TDEABC::AddresseeList addresses = addressBook->findByEmail( KPIM::getFirstEmailAddress( message->
from() ) );
485 int photoHeight = 60;
486 if( addresses.count() == 1 )
489 tdeabcUid = addresses[0].uid();
491 if ( imProxy->initialize() ) {
493 presence = imProxy->presenceString( tdeabcUid );
494 if ( !presence.isEmpty() )
496 TQString presenceIcon = TQString::fromLatin1(
" <img src=\"%1\"/>" )
497 .arg( imgToDataUrl( imProxy->presenceIcon( tdeabcUid ).convertToImage() ) );
498 presence += presenceIcon;
502 if ( addresses[0].photo().isIntern() )
506 TQImage photo = addresses[0].photo().data();
507 if ( !photo.isNull() )
509 photoWidth = photo.width();
510 photoHeight = photo.height();
512 if ( photoHeight > 60 ) {
513 double ratio = ( double )photoHeight / (
double )photoWidth;
515 photoWidth = (int)( 60 / ratio );
516 photo = photo.smoothScale( photoWidth, photoHeight );
518 photoURL = imgToDataUrl( photo );
524 photoURL = addresses[0].photo().url();
525 if ( photoURL.startsWith(
"/") )
526 photoURL.prepend(
"file:" );
531 kdDebug( 5006 ) <<
"Multiple / No addressees matched email address; Count is " << addresses.count() << endl;
535 if( photoURL.isEmpty() ) {
537 TQString faceheader = message->
headerField(
"Face" );
538 if ( !faceheader.isEmpty() ) {
541 kdDebug( 5006 ) <<
"Found Face: header" << endl;
543 TQCString facestring = faceheader.utf8();
546 if ( facestring.length() < 993 ) {
547 TQByteArray facearray;
548 KCodecs::base64Decode(facestring, facearray);
551 if ( faceimage.loadFromData( facearray,
"png" ) ) {
553 if ( (48 == faceimage.width()) && (48 == faceimage.height()) ) {
554 photoURL = imgToDataUrl( faceimage );
558 kdDebug( 5006 ) <<
"Face: header image is" << faceimage.width() <<
"by" << faceimage.height() <<
"not 48x48 Pixels" << endl;
561 kdDebug( 5006 ) <<
"Failed to load decoded png from Face: header" << endl;
564 kdDebug( 5006 ) <<
"Face: header too long at " << facestring.length() << endl;
569 if( photoURL.isEmpty() )
573 TQString xfhead = message->
headerField(
"X-Face" );
574 if ( !xfhead.isEmpty() )
577 photoURL = imgToDataUrl( xf.toImage( xfhead ) );
584 if( !photoURL.isEmpty() )
587 userHTML = TQString(
"<img src=\"%1\" width=\"%2\" height=\"%3\">")
588 .arg( photoURL ).arg( photoWidth ).arg( photoHeight );
589 if ( presence.isEmpty() ) {
590 userHTML = TQString(
"<div class=\"senderpic\">") + userHTML +
"</div>";
592 userHTML = TQString(
"<div class=\"senderpic\">"
593 "<a href=\"im:%1\">%2<div class=\"senderstatus\">"
594 "<span name=\"presence-%3\">%4</span></div></a>"
595 "</div>" ).arg( tdeabcUid )
602 if ( !presence.isEmpty() )
603 userHTML = TQString(
"<a href=\"im:%1\"><div class=\"senderstatus\">"
604 "<span name=\"presence-%2\">%3</span></div></a>" )
611 if ( imProxy->imAppsAvailable() )
612 presence =
"<a name=\"launchim\" href=\"kmail:startIMApp\">" + i18n(
"Launch IM") +
"</a></span>";
615 kdDebug( 5006 ) <<
"final presence: '" << presence <<
"'" << endl;
619 if ( GlobalSettings::self()->showCurrentTime() && strategy->showHeader(
"date" ) ) {
620 DwHeaders& header = message->
headers();
621 if ( header.HasDate() ) {
622 DwDateTime& origDate = header.Date();
623 int zone = origDate.Zone();
627 time_t t_now = time((time_t*) 0);
628 #if defined(HAVE_GMTIME_R)
630 gmtime_r(&t_now, &utc);
632 localtime_r(&t_now, &local);
634 struct tm utc = *gmtime(&t_now);
635 struct tm local = *localtime(&t_now);
637 DwUint32 t_local = 0;
638 t_local = 24 * t_local + local.tm_hour;
639 t_local = 60 * t_local + local.tm_min;
640 t_local = 60 * t_local + local.tm_sec;
642 t_utc = 24 * t_utc + utc.tm_hour;
643 t_utc = 60 * t_utc + utc.tm_min;
644 t_utc = 60 * t_utc + utc.tm_sec;
648 TQTime currTime = TQTime::currentTime( TQt::UTC );
653 currTime = currTime.addSecs( zone * 60 );
659 if ( currTime > TQTime( 0, 0, 0 ) && currTime <= TQTime( 6, 0, 0 ) ) {
660 timeofday = i18n(
"Night" );
662 bg_color =
"#000B6B";
663 bg_image =
"url(data:image/png;base64,"
664 "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAyCAIAAAASmSbdAAAAS0lEQVQI11WOsRGAQAzDOG/LHoz9"
665 "kikIcF+kSBxbPs7LoNGVapAI0Zn+O+8NUwldozn6io7G7kdS/5zi7i+BvUM/5uSXlIfzMHx/bmWR"
666 "k++yj9rZAAAAAElFTkSuQmCC)";
668 else if ( currTime > TQTime( 6, 0, 0 ) && currTime <= TQTime( 12, 0, 0 ) ) {
669 timeofday = i18n(
"Morning" );
671 bg_color =
"#00A6FF";
672 bg_image =
"url(data:image/png;base64,"
673 "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAyCAYAAACd+7GKAAAAWklEQVQI122OQQ7DMAzDaP3/dfuO"
674 "pWSHJgva7iZIBk3m/Ew5hexCHVCilewzFHKEbFZqgxJQWyzKhWKl9unqddJj8+L9sl0oR2gUim+o"
675 "zu4uSh7kn67/DNv+C4tsZOtjAWEHAAAAAElFTkSuQmCC)";
677 else if ( currTime > TQTime( 12, 0, 0 ) && currTime <= TQTime( 18, 0, 0 ) ) {
678 timeofday = i18n(
"Afternoon" );
680 bg_color =
"#00A6FF";
681 bg_image =
"url(data:image/png;base64,"
682 "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAyCAYAAACd+7GKAAAAPUlEQVQI132OwQ0AIAwCSfcfw91c"
683 "QsCfRm399HFwoWjdDhMICQhxHSWMQPhkTCoqWRZU2h5i9tr4GZfmV5t3wWUI3h+NugAAAABJRU5E"
687 timeofday = i18n(
"Evening" );
689 bg_color =
"#0014CC";
690 bg_image =
"url(data:image/png;base64,"
691 "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAyCAYAAACd+7GKAAAAWklEQVQI11WOyRHAMAgDNQuUlBrS"
692 "fyFpAfKwje0PwyEt0vN+hVsJpzS6QML2ziWcFI6mZBZNSVDXYehyUgI1XsLI9eimHDH6kW0ddVIO"
693 "xx7JjrtshlbXlLDSD+WhJ+hwqWo8AAAAAElFTkSuQmCC)";
697 if ( TDEGlobal::locale()->use12Clock() ) {
706 timeHTML.append( TQString(
707 "<div id=\"sendersCurrentTime\" style=\""
708 "border:1px solid %1;"
710 "background-image:%3;"
711 "background-position:center left;"
712 "background-repeat:repeat-x;"
718 "margin: 0px 0px 3px 0px;"
719 "\" class=\"curtime\">%4<br />%5<br />%6</div>"
724 .arg( i18n(
"Sender's Current Time:" ) )
725 .arg( currTime.toString( tformat ) )
736 if ( strategy->showHeader(
"subject" ) ) {
737 const int flags = LinkLocator::PreserveSpaces |
738 ( GlobalSettings::self()->showEmoticons() ?
739 LinkLocator::ReplaceSmileys : 0 );
740 headerStr += TQString(
"<div dir=\"%1\">%2</div>\n")
742 .arg(message->
subject().isEmpty()?
744 strToHtml( message->
subject(), flags ));
746 headerStr +=
"<table class=\"outer\"><tr><td width=\"100%\"><table>\n";
751 if ( strategy->showHeader(
"from" ) ) {
752 TQString fromStr = message->
from();
753 if ( fromStr.isEmpty() )
754 fromStr = message->fromStrip();
755 headerStr += TQString(
"<tr><th>%1</th>\n"
759 + ( !message->
headerField(
"Resent-From" ).isEmpty() ?
" "
760 + i18n(
"(resent from %1)")
764 + ( !vCardName.isEmpty() ?
" <a href=\"" + vCardName +
"\">"
765 + i18n(
"[vCard]") +
"</a>"
768 + ( ( !presence.isEmpty() )
769 ?
" (<span name=\"presence-" + tdeabcUid +
"\">" + presence +
"</span>)"
775 + strToHtml(message->headerField(
"Organization"))
780 if ( strategy->showHeader(
"to" ) )
781 headerStr.append(TQString(
"<tr><th>%1</th>\n"
782 "<td>%2</td></tr>\n")
787 if ( strategy->showHeader(
"cc" ) && !message->
cc().isEmpty())
788 headerStr.append(TQString(
"<tr><th>%1</th>\n"
789 "<td>%2</td></tr>\n")
794 if ( strategy->showHeader(
"bcc" ) && !message->
bcc().isEmpty())
795 headerStr.append(TQString(
"<tr><th>%1</th>\n"
796 "<td>%2</td></tr>\n")
800 if ( strategy->showHeader(
"date" ) )
801 headerStr.append(TQString(
"<tr><th>%1</th>\n"
802 "<td dir=\"%2\">%3</td></tr>\n")
804 .arg( directionOf( message->
dateStr() ) )
805 .arg(strToHtml(dateString)));
807 if ( GlobalSettings::self()->showUserAgent() ) {
808 if ( strategy->showHeader(
"user-agent" ) ) {
809 if ( !message->
headerField(
"User-Agent").isEmpty() ) {
810 headerStr.append(TQString(
"<tr><th>%1</th>\n"
811 "<td>%2</td></tr>\n")
812 .arg(i18n(
"User-Agent: "))
813 .arg( strToHtml( message->
headerField(
"User-Agent") ) ) );
817 if ( strategy->showHeader(
"x-mailer" ) ) {
818 if ( !message->
headerField(
"X-Mailer").isEmpty() ) {
819 headerStr.append(TQString(
"<tr><th>%1</th>\n"
820 "<td>%2</td></tr>\n")
821 .arg(i18n(
"X-Mailer: "))
822 .arg( strToHtml( message->
headerField(
"X-Mailer") ) ) );
835 headerStr.append( TQString(
"<tr><td colspan=\"2\"><div id=\"attachmentInjectionPoint\"></div></td></tr>" ) );
837 TQString(
"</table></td><td align=\"center\" valign=\"top\">%1%2</td></tr></table>\n" )
841 if ( !spamHTML.isEmpty() )
842 headerStr.append( TQString(
"<div class=\"spamheader\" dir=\"%1\"><b>%2</b> <span style=\"padding-left: 20px;\">%3</span></div>\n")
843 .arg( subjectDir, i18n(
"Spam Status:"), spamHTML ) );
845 headerStr +=
"</div>\n\n";
849 TQString FancyHeaderStyle::imgToDataUrl(
const TQImage &image,
const char* fmt )
852 TQBuffer buffer( ba );
853 buffer.open( IO_WriteOnly );
854 image.save( &buffer, fmt );
855 return TQString::fromLatin1(
"data:image/%1;base64,%2")
856 .arg( fmt, KCodecs::base64Encode( ba ).data() );
861 class EnterpriseHeaderStyle :
public HeaderStyle {
862 friend class ::KMail::HeaderStyle;
864 EnterpriseHeaderStyle() : HeaderStyle() {}
865 virtual ~EnterpriseHeaderStyle() {}
868 const char * name()
const {
return "enterprise"; }
869 const HeaderStyle * next()
const {
return brief(); }
870 const HeaderStyle * prev()
const {
return fancy(); }
872 TQString format(
const KMMessage * message,
const HeaderStrategy * strategy,
873 const TQString & vCardName,
bool printing,
bool topLevel )
const;
876 TQString EnterpriseHeaderStyle::format(
const KMMessage * message,
877 const HeaderStrategy * strategy,
878 const TQString & vCardName,
bool printing,
bool topLevel )
const {
879 if ( !message )
return TQString();
881 strategy = HeaderStrategy::brief();
886 TQString dir = TQApplication::reverseLayout() ?
"rtl" :
"ltr" ;
895 if (!message->
subject().isEmpty())
896 subjectDir = directionOf( message->cleanSubject() );
898 subjectDir = directionOf( i18n(
"No Subject") );
901 TQColor fontColor(TQt::white);
902 TQString linkColor =
"class =\"white\"";
903 const TQColor activeColor = tqApp->palette().active().highlight();
904 TQColor activeColorDark = activeColor.dark(130);
907 activeColorDark = activeColor.dark(50);
908 fontColor = TQColor(TQt::black);
909 linkColor =
"class =\"black\"";
916 TDELocale * locale = TDEGlobal::locale();
917 dateTime.setTime_t( message->date() );
918 dateString = locale->formatDateTime( dateTime );
920 dateString = message->
dateStr();
923 TQString imgpath(locate(
"data",
"kmail/pics/"));
924 imgpath.append(
"enterprise_");
925 const TQString borderSettings(
" padding-top: 0px; padding-bottom: 0px; border-width: 0px ");
926 TQString headerStr (
"");
931 "<div style=\"position: fixed; top: 0px; left: 0px; background-color: #606060; "
932 "width: 10px; min-height: 100%;\"> </div>"
933 "<div style=\"position: fixed; top: 0px; right: 0px; background-color: #606060; "
934 "width: 10px; min-height: 100%;\"> </div>";
937 "<div style=\"margin-left: 10px; top: 0px;\"><span style=\"font-size: 10px; font-weight: bold;\">"+dateString+
"</span></div>"
939 "<table style=\"background: "+activeColorDark.name()+
"; border-collapse:collapse; top: 14px; min-width: 200px; \" cellpadding=0> \n"
941 " <td style=\"min-width: 6px; background-image: url("+imgpath+
"top_left.png); \"></td> \n"
942 " <td style=\"height: 6px; width: 100%; background: url("+imgpath+
"top.png); \"></td> \n"
943 " <td style=\"min-width: 6px; background: url("+imgpath+
"top_right.png); \"></td> </tr> \n"
945 " <td style=\"min-width: 6px; max-width: 6px; background: url("+imgpath+
"left.png); \"></td> \n"
946 " <td style=\"\"> \n";
949 " <div class=\"noprint\" style=\"z-index: 1; float:right; position: relative; top: -35px; right: 20px ;\">\n"
950 " <img src=\""+imgpath+
"icon.png\">\n"
954 " <table style=\"color: "+fontColor.name()+
" ! important; margin: 1px; border-spacing: 0px;\" cellpadding=0> \n";
958 if ( strategy->showHeader(
"subject" ) ){
961 " <td style=\"font-size: 6px; text-align: right; padding-left: 5px; padding-right: 24px; "+borderSettings+
"\"></td> \n"
962 " <td style=\"font-weight: bolder; font-size: 120%; padding-right: 91px; "+borderSettings+
"\">"+message->
subject()+
"</td> \n"
967 if ( strategy->showHeader(
"from" ) ){
968 TQString fromStr = message->
from();
969 if ( fromStr.isEmpty() )
970 fromStr = message->fromStrip();
973 if ( !vCardName.isEmpty() )
974 fromPart +=
" <a href=\"" + vCardName +
"\" "+linkColor+
">" + i18n(
"[vCard]") +
"</a>";
979 " <td style=\"font-size: 6px; padding-left: 5px; padding-right: 24px; text-align: right; "+borderSettings+
"\">"+i18n(
"From: ")+
"</td> \n"
980 " <td style=\""+borderSettings+
"\">"+ fromPart +
"</td> "
985 if( strategy->showHeader(
"to" ) )
988 " <td style=\"font-size: 6px; text-align: right; padding-left: 5px; padding-right: 24px; " + borderSettings +
"\">" + i18n(
"To: ") +
"</td> "
989 " <td style=\"" + borderSettings +
"\">" +
995 if ( strategy->showHeader(
"cc" ) && !message->
cc().isEmpty() )
998 " <td style=\"font-size: 6px; text-align: right; padding-left: 5px; padding-right: 24px; " + borderSettings +
"\">" + i18n(
"CC: ") +
"</td> "
999 " <td style=\"" + borderSettings +
"\">" +
1005 if ( strategy->showHeader(
"bcc" ) && !message->
bcc().isEmpty() )
1008 " <td style=\"font-size: 6px; text-align: right; padding-left: 5px; padding-right: 24px; " + borderSettings +
"\">" + i18n(
"BCC: ") +
"</td> "
1009 " <td style=\"" + borderSettings +
"\">" +
1018 " <td style=\"min-width: 6px; max-height: 15px; background: url("+imgpath+
"right.png); \"></td> \n"
1021 " <td style=\"min-width: 6px; background: url("+imgpath+
"s_left.png); \"></td> \n"
1022 " <td style=\"height: 35px; width: 80%; background: url("+imgpath+
"sbar.png);\"> \n"
1023 " <img src=\""+imgpath+
"sw.png\" style=\"margin: 0px; height: 30px; overflow:hidden; \"> \n"
1024 " <img src=\""+imgpath+
"sp_right.png\" style=\"float: right; \"> </td> \n"
1025 " <td style=\"min-width: 6px; background: url("+imgpath+
"s_right.png); \"></td> \n"
1034 "<div class=\"noprint\" style=\"position: absolute; top: 60px; right: 20px; width: 91px; height: 200px;\">"
1035 "<div id=\"attachmentInjectionPoint\"></div>"
1042 headerStr +=
"<div style=\"padding: 6px; padding-left: 10px;\">";
1044 headerStr +=
"<div style=\"padding: 6px;\">";
1060 HeaderStyle::HeaderStyle() {
1064 HeaderStyle::~HeaderStyle() {
1068 const HeaderStyle * HeaderStyle::create( Type type ) {
1070 case Brief:
return brief();
1071 case Plain:
return plain();
1072 case Fancy:
return fancy();
1073 case Enterprise:
return enterprise();
1075 kdFatal( 5006 ) <<
"HeaderStyle::create(): Unknown header style ( type == "
1076 << (int)type <<
" ) requested!" << endl;
1080 const HeaderStyle * HeaderStyle::create(
const TQString & type ) {
1081 TQString lowerType = type.lower();
1082 if ( lowerType ==
"brief" )
return brief();
1083 if ( lowerType ==
"plain" )
return plain();
1084 if ( lowerType ==
"enterprise" )
return enterprise();
1091 static const HeaderStyle * briefStyle = 0;
1092 static const HeaderStyle * plainStyle = 0;
1093 static const HeaderStyle * fancyStyle = 0;
1094 static const HeaderStyle * enterpriseStyle = 0;
1096 const HeaderStyle * HeaderStyle::brief() {
1098 briefStyle =
new BriefHeaderStyle();
1102 const HeaderStyle * HeaderStyle::plain() {
1104 plainStyle =
new PlainHeaderStyle();
1108 const HeaderStyle * HeaderStyle::fancy() {
1110 fancyStyle =
new FancyHeaderStyle();
1114 const HeaderStyle * HeaderStyle::enterprise() {
1115 if ( !enterpriseStyle )
1116 enterpriseStyle =
new EnterpriseHeaderStyle();
1117 return enterpriseStyle;
::KIMProxy * imProxy()
Get a reference to KMail's KIMProxy instance.
static KMKernel * self()
normal control stuff
TQString from() const
Get or set the 'From' header field.
TQString bcc() const
Get or set the 'Bcc' header field.
TQString to() const
Get or set the 'To' header field.
TQString subject() const
Get or set the 'Subject' header field.
static TQString emailAddrAsAnchor(const TQString &emailAddr, bool stripped=true, const TQString &cssStyle=TQString(), bool link=true)
Converts the email address(es) to (a) nice HTML mailto: anchor(s).
TQString cc() const
Get or set the 'Cc' header field.
TQString headerField(const TQCString &name) const
Returns the value of a header field with the given name.
TQString replyTo() const
Get or set the 'ReplyTo' header field.
TQCString dateShortStr() const
Returns the message date in asctime format or an empty string if the message lacks a Date header.
DwHeaders & headers() const
get the DwHeaders (make sure to call setNeedsAssembly() function after directly modyfying internal da...
TQString dateStr() const
Get or set the 'Date' header field.