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

List:       kmail-devel
Subject:    [PATCH] fixes for filters
From:       Marc Mutz <Marc.Mutz () uni-bielefeld ! de>
Date:       2001-05-04 16:05:26
[Download RAW message or body]

Hi!

[The mouse pointer was just over "send" when I realized that
Ive forgotten to attach the patch :) ]

The attached patch fixes three issues:

1. The filter action "filter app" (now i18n("pipe through"))
   now works again. I've checked it with the following commands:

   a.) "tee ~/DONIT" -> ~/DONIT contains the message
   b.) "perl -p -e 's/Ralf/Norbert/g;'
        -> a message with "Ralf" in the body contained
           (after applying) "Norbert" in place of "Ralf".

   So I guess this action works again.

2. There was a bug in the filter dialog that prevented the
   first click into the filter list box after hitting 'apply'
   from propagating the filter details to the edit widgets.
   It turned out to be a forgotten enableControls() in
   slotApplyFilterChanges().

3. I've fixed what I believe was a bug in the "execute command"
   filter action. I've written about this in an earlier mail.
   It now essentially greps through the command line for
   /%([0-9]+)/, saves the captured ints in a QValueList,
   sorts that list and then uses QString::arg to substitute the
   %n's with the temp file names.

   *However*: KMFilterActionExec (still) seems to be absolutely broken
for anything which actually wants to use the %n mechanism. Just try
"execute command" with "cat %0 > ~/DONIT" and then less ~/DONIT. At
least my less shows '^@' inverted.

The original as well as my implementation uses the following code
snippet to write to the temp file:

KMessagePart msgPart;
msg->bodyPart( n, &msgPart );
kByteArrayToFile( msgPart.bodyDecodedBinary(), tempFileName,
                  false, false, false );

Apart form the fact that there's no documentation about
kByteArrayToFile, adding

kdDebug() << msgPart.bodyDecoded() << endl;

prints nothing! (Yes, the body in fact contains a few lines :-)

I've checked with a brand-new install of LM 8.0 (KDE 2.1.1) and "cat %0"
shows nothing, too.

The problem is that I'm currently lost as to what stream I should be
using. The are all sorts of streams that KTempFile can provide, yet
looking at the Qt and KDElibs docs I cannot determine which one of them
simply writes the QByteArray into a file. QDataSream prepends the byte
array with the length, QTextStream wants to do locale, maybe using FILE*
gives the file in Unicode...?!

Nevertheless, the patch can go into CVS. AFAICS, it's no worse than the
'old' implementation.

Marc


-- 
Marc Mutz <Marc@Mutz.com>     http://EncryptionHOWTO.sourceforge.net/
University of Bielefeld, Dep. of Mathematics / Dep. of Physics

PGP-keyID's:   0xd46ce9ab (RSA), 0x7ae55b9e (DSS/DH)

["kmail-pipe-action-fix-20010504.diff.bz2" (application/octet-stream)]
_______________________________________________
Kmail Developers mailing list
Kmail@master.kde.org
http://master.kde.org/mailman/listinfo/kmail


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

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