/* Copyright (c) 2013, 2014 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "entrepriseheaderstyle.h" #include "header/headerstyle_util.h" #include "header/headerstrategy.h" #include using KPIMUtils::LinkLocator; #include #include #include #include #include #include #include #include using namespace MessageCore; using KPIMUtils::LinkLocator; using namespace MessageViewer; namespace MessageViewer { QString EnterpriseHeaderStyle::format( KMime::Message *message ) const { if ( !message ) return QString(); const HeaderStrategy *strategy = headerStrategy(); if ( !strategy ) { strategy = HeaderStrategy::brief(); } // The direction of the header is determined according to the direction // of the application layout. // However, the direction of the message subject within the header is // determined according to the contents of the subject itself. Since // the "Re:" and "Fwd:" prefixes would always cause the subject to be // considered left-to-right, they are ignored when determining its // direction. // colors depend on if it is encapsulated or not QColor fontColor( Qt::white ); QString linkColor = QLatin1String("class =\"white\""); const QColor activeColor = KColorScheme( QPalette::Active, KColorScheme::Selection ). background().color(); QColor activeColorDark = activeColor.dark(130); // reverse colors for encapsulated if( !isTopLevel() ){ activeColorDark = activeColor.dark(50); fontColor = QColor(Qt::black); linkColor = QLatin1String("class =\"black\""); } QString imgpath( KStandardDirs::locate("data",QLatin1String("libmessageviewer/pics/")) ); imgpath.prepend( QLatin1String("file:///") ); imgpath.append(QLatin1String("enterprise_")); const QString borderSettings( QLatin1String(" padding-top: 0px; padding-bottom: 0px; border-width: 0px ") ); QString headerStr; // 3D borders if(isTopLevel()) headerStr += QLatin1String("
 
" "
 
"); headerStr += QLatin1String("
") + MessageViewer::HeaderStyleUtil::dateString( message, isPrinting(), /* shortDate */ false ) + QLatin1String("
" // #0057ae " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n") + attachment + QLatin1String(" \n" " \n" " \n" " \n" " \n" "
\n"); headerStr += QLatin1String("
\n" "\n" "
\n"); headerStr += QLatin1String(" \n"); // subject if ( strategy->showHeader( QLatin1String("subject") ) ) { headerStr += QLatin1String(" \n" " \n" " \n" " \n"); } // from if ( strategy->showHeader( QLatin1String("from") ) ) { // We by design use the stripped mail address here, it is more enterprise-like. QString fromPart = StringUtil::emailAddrAsAnchor( message->from(), StringUtil::DisplayNameOnly, linkColor ); if ( !vCardName().isEmpty() ) fromPart += QLatin1String("  ') + i18n("[vCard]") + QLatin1String(""); //TDDO strategy date //if ( strategy->showHeader( "date" ) ) headerStr += QLatin1String(" \n" " \n" " " " "); } // to line if ( strategy->showHeader( QLatin1String("to") ) ) { headerStr += QLatin1String(" " " " " " " \n"); } // cc line, if any if ( strategy->showHeader( QLatin1String("cc") ) && message->cc( false ) ) { headerStr += QLatin1String(" " " " " " " \n"); } // bcc line, if any if ( strategy->showHeader( QLatin1String("bcc") ) && message->bcc( false ) ) { headerStr += QLatin1String(" " " " " " " \n"); } // attachments QString attachment; if( isTopLevel() ) { attachment = QLatin1String("" "" ""); } // header-bottom headerStr += QLatin1String("
"); headerStr += MessageViewer::HeaderStyleUtil::subjectString( message )+ QLatin1String("
")+i18n("From: ")+QLatin1String("")+ fromPart +QLatin1String("
") + i18n("To: ") + QLatin1String("") + StringUtil::emailAddrAsAnchor( message->to(), StringUtil::DisplayFullAddress, linkColor ) + QLatin1String("
") + i18n("CC: ") + QLatin1String("") + StringUtil::emailAddrAsAnchor( message->cc(), StringUtil::DisplayFullAddress, linkColor ) + QLatin1String("
") + i18n("BCC: ") + QLatin1String("") + StringUtil::emailAddrAsAnchor( message->bcc(), StringUtil::DisplayFullAddress, linkColor ) + QLatin1String("
" "" "
" "
" "
" "
" "
\n" "
\n" " \n" "
\n"); if ( isPrinting() ) { //provide a bit more left padding when printing //kolab/issue3254 (printed mail cut at the left side) headerStr += QLatin1String("
"); } else { headerStr += QLatin1String("
"); } // TODO // spam status // ### iterate over the rest of strategy->headerToDisplay() (or // ### all headers if DefaultPolicy == Display) (elsewhere, too) return headerStr; } }