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

List:       kde-devel
Subject:    openComposer with kjscmd returns just false
From:       Matej Cepl <ceplm () seznam ! cz>
Date:       2005-09-25 3:08:44
Message-ID: sugh03-b7e.ln1 () chelcicky ! vysocina
[Download RAW message or body]

Hi,

I am not sure which group/email list I should post this to, so there is
crossposting involved -- which list is the correct one (I tried
kjsembed@kde.org, but seems to be really non-responsive)?

Trying to create script for programmatic sending of the current message as
an attachment (usefull for learning remote spam filter) with KJSCmd (see
attached). However, I have troubles to get DCOPRef. When I try this (kjscmd
0.3 with KDE 3.4.1; lines broken for this message only):

var dcop = new DCOPClient(this);
var ret = dcop.call("kmail","KMailIface",\
"openComposer(QString,QString,QString,QString,QString,Boolean)",\
"random@example.com","","","Subject","text",true);
println(ret);

I get 'false'. Does anybody have any idea, what's wrong with this? Of
course, similar call in shell with dcop command line utility returns
DCOPRef.

Thanks for any reply,

Matej

-- 
Matej Cepl, http://www.ceplovi.cz/matej/blog/
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
 
The law, in its majestic equality, forbids the rich as well as
the poor to sleep under bridges, to beg in the streets, and to
steal bread.
    -- Anatole France
["frwd-attach.js" (text/plain)]

#!/usr/bin/env kjscmd
// $Id: frwd-attach.js,v 1.4 2005/09/10 17:43:24 matej Exp $

var tempfile = "/tmp/frwd-attach"+Math.round(Math.random()*1e12);
var stuff = new String();
var stuffLine = new String();
var dcop = new DCOPClient(this);

if ( application.args.length == 0 ) {
    throw 'Usage:\n\tfrwd-attach TO CC BCC BODY';
}
else {
    stuffLine = System.stdin.readLine();
    while (stuffLine != null) {
        stuff += stuffLine + "\n";
        stuffLine = System.stdin.readLine();
    }
    System.writeFile(tempfile,stuff);

    for (line in stuff.split("\n")) {
        if (line.search(/^Subject: /) != -1) {
            var subject = line.replace(/^Subject: /,"");
            println(subject);
            break;
        }
    }

    var cc = "";
    var bcc = "";
    var body = "Forwarded message.";

    if ( application.args.length >= 1 ) {
        to = application.args[0];
    }
    if ( application.args.length >= 2 ) {
        cc = application.args[1];
    }
    if ( application.args.length >= 3 ) {
        bcc = application.args[2];
    }
    if ( application.args.length >= 4 ) {
        body = application.args[3];
    }
}

dcop.attach();
if ( dcop.isAttached() ) {
    var rec = new DCOPRef(this);
    var hidden = new Boolean();
    var fcMark = "openComposer(QString,QString,QString,QString,QString,Boolean)";
    subject = "Test message";
    println(fcMark);println(to);println(cc);println(bcc);
    println(subject);println(body);
    rec = dcop.call("kmail","KMailIface",fcMark,to,cc,bcc,subject,body,true);
    println(rec);
    rec.call("addAttachment",tempfile,"Message");
    rec.call("send",1);
}

application.exec();

 =

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscrib=
e <<


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

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