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

List:       kde-devel
Subject:    Async action with helper in KAuth
From:       Yichao Yu <yyc1992 () gmail ! com>
Date:       2012-11-12 19:20:28
Message-ID: CAMvDr+QCzhhxnjgNF_1AT6XrfgQS1vNa_ySmiSsuwx5yBqXDag () mail ! gmail ! com
[Download RAW message or body]

I am trying to write a pykde4 app that use a kauth helper
asynchronously, following the tutorial by code is

        action = KAuth.Action(action_id)
        action.setHelperID(helper_id)
        action.setArguments(args)
        if hasattr(callback, "__call__"):
            # the new-style signal connecting somehow doesn't work here..
            QObject.connect(action.watcher(),
                            SIGNAL("actionPerformed(const
KAuth::ActionReply&)"),
                            lambda reply: callback(reply.succeeded()))
        action.setExecutesAsync(True)
        reply = action.execute()
        if reply.failed():
            return False
        return True

however, although synchronous action works perfect, the "early reply"
for asynchronous action always fails with error code 3.
After googled for solution, I have found someone was having the same
problem with me[1] in cpp and claimed the longaction example in the
tutorial doesn't works either.
I checkout out the code for KAuth and found out the following lines
in` ActionReply Action::execute(const QString &helperID) const`

    if (d->async) {
        if (hasHelper()) {
            // It makes no sense
            return ActionReply::InvalidActionReply;
        }

which gives the right error code and can explain why only the async
action fails. The comment says "makes no sense", but doesn't say
why.... can anyone explain the reason?? And I cannot found the
description for this anywhere in the tutorial (e.g. some backend may
not support async action with helper at all.....), if it really
doesn't make sense to do this (which I really doubt....) I guess it
would be better to add it...

THX.


[1] http://forum.kde.org/viewtopic.php?f=43&t=94801

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

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