[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde
Subject:    [kde] PATCH: kmail and fancy headers - custom logo
From:       Ladislav Strojil <Ladislav.Strojil () seznam ! cz>
Date:       2001-12-13 11:00:19
[Download RAW message or body]

Hi,

I have already posted this to KDE newsgroup. But this is slightly modified 
version based on filter actions.

I include a patch for KMail 1.3.2 that allows you to choose custom picture to 
be displayed in fancy headers of your individual emails.

The way it works is by defining new filter action called "set image".

So you have the power of KMail's filters to choose which mails should get 
special image. 

You can e.g. create a filter: 
if "From" contains the name of my true and only love, then "set image" to 
"heart.png" (included :-)). When you later view messages from your true and 
only love, heart will be displayed instead of that K logo. (But maybe your 
true and only love is KDE itself, then stick with with that logo :-))

Image files are looked for in following dirs
$KDEHOME/share/apps/kmail/pics/
and then
$KDEDIR/share/apps/kmail/pics/

If specified file cannot be found, default logo is used instead.

If you however prefix filename with absolute path (ie. starting with / ), no 
checking is done and if file does not exist, no image is displayed.

You can use any pictures KDE is able to display (xpm, png, gif, jpg etc.)

To apply this patch, grab sources for KMail (from kdenetwork package) and 
then do:

$ cd $KDESRC/kdenetwork/kmail
$ patch < /path/to/patch/kmail.patch
$ make
$ make install

Enjoy,
Lada

-- 
    ~       Ladislav Strojil, MFF UK
  ' v '               
 //   \\	      
/(     )\    Powered by Penguin.
  ^ ' ^

["kmail.patch" (text/x-diff)]

*** kmreaderwin.cpp	Thu Dec 13 11:16:02 2001
--- new/kmreaderwin.cpp	Thu Dec 13 11:10:13 2001
***************
*** 764,767 ****
--- 764,768 ----
  {
    QString str;
+   QString pic;
    QString vcname;
    KMMessagePart aMsgPart;
***************
*** 819,824 ****
  
    case HdrFancy:
      mViewer->write(QString("<table><tr><td><img src=") +
! 		   locate("data", "kmail/pics/kdelogo.xpm") +
                     "></td><td hspace=\"50\"><b style=\"font-size:160%\">");
      mViewer->write(strToHtml(mMsg->subject()) + "</b><br>");
--- 820,828 ----
  
    case HdrFancy:
+     pic=mMsg->headerField("X-KDE-KM-Image").stripWhiteSpace();
+     if (!pic.isEmpty()&&pic[0]!='/') pic.prepend("kmail/pics/");
+ 	if (pic.isEmpty()||locate("data",pic)==QString::null) pic="kmail/pics/kdelogo.xpm";
      mViewer->write(QString("<table><tr><td><img src=") +
!                  locate("data", pic) + 
                     "></td><td hspace=\"50\"><b style=\"font-size:160%\">");
      mViewer->write(strToHtml(mMsg->subject()) + "</b><br>");
*** kmfilteraction.cpp	Thu Dec 13 11:16:02 2001
--- new/kmfilteraction.cpp	Thu Dec 13 11:22:05 2001
***************
*** 464,467 ****
--- 464,497 ----
  
  //=============================================================================
+ // KMFilterActionSetImage - set image to...
+ // Specify image file to be used when displaying fancy header
+ //=============================================================================
+ class KMFilterActionImage: public KMFilterActionWithString
+ {
+ public:
+   KMFilterActionImage();
+   virtual ReturnCode process(KMMessage* msg) const;
+   static KMFilterAction* newAction(void);
+ };
+ 
+ KMFilterAction* KMFilterActionImage::newAction(void)
+ {
+   return (new KMFilterActionImage);
+ }
+ 
+ KMFilterActionImage::KMFilterActionImage()
+   : KMFilterActionWithString( "set image", i18n("set image") )
+ {
+ }
+ 
+ KMFilterAction::ReturnCode KMFilterActionImage::process(KMMessage* msg) const
+ {
+   if ( mParameter.isEmpty() )
+     return ErrorButGoOn;
+   msg->setHeaderField( "X-KDE-KM-Image", mParameter );
+   return GoOn;
+ }
+ 
+ //=============================================================================
  // KMFilterActionSetTransport - set transport to...
  // Specify mail transport (smtp server) to be used when replying to a message
***************
*** 668,671 ****
--- 698,702 ----
  		 << "Reply-To"
  		 << "Delivered-To"
+ 		 << "X-KDE-KM-Image"
  		 << "X-KDE-PR-Message"
  		 << "X-KDE-PR-Package"
***************
*** 740,743 ****
--- 771,775 ----
  		 << "Reply-To"
  		 << "Delivered-To"
+ 		 << "X-KDE-KM-Image"
  		 << "X-KDE-PR-Message"
  		 << "X-KDE-PR-Package"
***************
*** 868,871 ****
--- 900,904 ----
  		 << "Reply-To"
  		 << "Delivered-To"
+ 		 << "X-KDE-KM-Image"
  		 << "X-KDE-PR-Message"
  		 << "X-KDE-PR-Package"
***************
*** 1258,1261 ****
--- 1291,1295 ----
    insert( KMFilterActionSetStatus::newAction );
    insert( KMFilterActionTransport::newAction );
+   insert( KMFilterActionImage::newAction );
    insert( KMFilterActionReplyTo::newAction );
    insert( KMFilterActionForward::newAction );
["heart.png" (image/png)]
___________________________________________________
This message is from the kde mailing list.
Account management:  http://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic