Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. DBus adaptor slots with 'const QDBusMessege &messege' argument.
Qt 6.11 is out! See what's new in the release blog

DBus adaptor slots with 'const QDBusMessege &messege' argument.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MarekR22
    wrote on last edited by
    #1

    Hi,

    In documentation of DBus in qt: "Declaring Slots in D-Bus Adaptors":http://doc.trolltech.com/latest/qdbusdeclaringslots.html" information about QDBusMessage parameter can be found.

    I need access to this parameter to be able post errors instead standard output.
    According to this documentation it should look like this (more or less):
    @
    class SomeAdaptor : public: QDBusAbstractAdaptor
    {
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "org.some.dbus.iterface.name")
    Q_CLASSINFO("D-Bus Introspection", ""
    " <interface name="org.some.dbus.iterface.name">\n"
    " <method name="myMethod">\n"
    " <arg direction="in" type="u" name="in"/>\n"
    " <arg direction="out" type="b" name="out1"/>\n"
    " <arg direction="out" type="s" name="out2"/>\n"
    " </method>\n"
    " </interface>\n"
    "")

    public:
    .... // standard stuff

    public Q_SLOTS:
    bool myMethod(uint in, QString &out2); // this version works
    bool myMethod(uint in, const QDBusMessege &messege, QString &out2); // this version doesn't work
    }@
    First version of myMethod slot works perfectly! Data are received and send back.
    But when this method is replaced with second version (as documentation suggested), it doesn't work (client is unable to call method).
    Now what should I do to make it work?
    Should I correct xml data in Q_CLASSINFO("D-Bus Introspection"? If yes, than how?
    Or maybe my declaration of slot is incorrect?
    Documentations says that this argument should be between input and output arguments like in my example.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      You might have to update the Q_CLASSINFO() declaration as the direction of the second argument is incorrect, but from this code I'd be more worried about the fact that QDBusMessage is spelled incorrectly.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MarekR22
        wrote on last edited by
        #3

        Yes I noticed that QDBusMessage was misspelled but only here in my post. In code in such case it would not compile.

        Anyway I've checked all classes related with DBus and I've found nice clear solution, much better than this extra argument. There is class "QDBusContext":http://doc.trolltech.com/latest/qdbuscontext.html which is used like this.
        @class ActualDBusObjectNotAdaptor : public QObject, protected QDBusContext {
        // rest is the same
        };

        bool ActualDBusObjectNotAdaptor::myMethod(uint in, QString &out2) {
        if (in<0) {
        sendErrorReply("Error.string", "User readable messege");
        }
        .....
        }@
        So extra parameter is not needed.
        Apparently "here in documentations":http://doc.trolltech.com/latest/qdbusdeclaringslots.html is mistake (it doesn't work as specified) probably some leftover after older version or at least it is incomplete.
        I will file a bug report.

        Thanks for trying help me.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved