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

List:       kjsembed
Subject:    [kjsembed] Forward attachment with kmail, DCOP and KJS
From:       Matej Cepl <ceplm () seznam ! cz>
Date:       2005-09-02 22:32:23
Message-ID: 200509030032.24087.ceplm () seznam ! cz
[Download RAW message or body]

Hi,

I have here bash script for forwarding stdin as an attachment 
(useful for KMail filter which sends current message to some 
address for registering message as spam/ham). However, it 
doesn't work well, because (I think) calling of dcop doesn't 
wait on return, so quite often message goes out without an 
attachment (see attached). Now, I hope that KJS script may 
behave better (using kjscmd 0.3 from KDE 3.4.1) and anyway, I 
would love to learn kjscmd scripting more. So I tried the 
attached, but I cannot seem to be able to send a message. When 
run I get an error:

chelcicky:.programky$ cat frwd-attach.js \
	| ./frwd-attach.js a v b e s
.frwd-attach: WARNING: addBindingsClass() \
	KJSEmbed::KJSEmbedPart not known
.frwd-attach: WARNING: addBindingsClass() \
	KJSEmbed::Bindings::Config not known
.frwd-attach: WARNING: addBindingsClass() \
	KApplication not known
TypeError - Value undefined (result of expression rec.call) \
	is not an object. Cannot be called.
chelcicky:.programky$

Could anybody help me to make this script, or it is not possible 
currently?

Thanks a lot,

Matej

-- 
Matej Cepl, http://www.ceplovi.cz/matej/blog/
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
 
It would be very good idea.
   -- Gandhi, when asked what he thinks about Western
      civilization?

["frwd-attach.js" (application/x-javascript)]
["frwd-attach.sh" (application/x-shellscript)]

#!/bin/sh
set -x
TO="$1"
CC="$2"
BCC="$3"
BODY="${4:-Forwarded message}"

tempfile=$(tempfile /tmp/$0XXXXXX)
# copy message to temporary file
cat >${tempfile}

SUBJECT="FWD: $(grep '^Subject: ' $tempfile | head -1 | sed -e 's/^Subject: //')"

# background processing (kmail filters are synchronous)
(
# invoke dcop to create composer with message as attachment (hidden)
ref=$(dcop kmail KMailIface openComposer "$TO" "$CC" "$BCC" "$SUBJECT" "$BODY" 1)
# add attachment
dcop "$ref" addAttachment "$tempfile" "Message"

# send the mesage (immediate)
dcop "$ref" send 1
# wait a bit to be sure that kmail gets the attachment
sleep 2
# clean up
rm -f $tempfile
) &

_______________________________________________
kjsembed mailing list
kjsembed@kde.org
https://mail.kde.org/mailman/listinfo/kjsembed


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

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