Results 1 to 3 of 3

Thread: DBus adaptor and 'const QDBusMessege &messege' argument.

  1. #1
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default DBus adaptor and 'const QDBusMessege &messege' argument.

    Hi,

    In documentation of DBus in qt: Declaring Slots in D-Bus Adaptors 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):
    Qt Code:
    1. class SomeAdaptor : public: QDBusAbstractAdaptor
    2. {
    3. Q_OBJECT
    4. Q_CLASSINFO("D-Bus Interface", "org.some.dbus.iterface.name")
    5. Q_CLASSINFO("D-Bus Introspection", ""
    6. " <interface name=\"org.some.dbus.iterface.name\">\n"
    7. " <method name=\"myMethod\">\n"
    8. " <arg direction=\"in\" type=\"u\" name=\"in\"/>\n"
    9. " <arg direction=\"out\" type=\"b\" name=\"out1\"/>\n"
    10. " <arg direction=\"out\" type=\"s\" name=\"out2\"/>\n"
    11. " </method>\n"
    12. "")
    13.  
    14. public:
    15. .... // standard stuff
    16.  
    17. public Q_SLOTS:
    18. bool myMethod(uint in, QString &out2); // this version works
    19. bool myMethod(uint in, const QDBusMessege &messege, QString &out2); // this version doesn't work
    20. }
    To copy to clipboard, switch view to plain text mode 
    First version of myMethod slot works perfectly! Data are received and send back.
    But when this method is replaced with second version, 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.

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: DBus adaptor and 'const QDBusMessege &messege' argument.

    Update: I've also tried:
    Qt Code:
    1. bool myMethod(uint in, QDBusMessege &messege, QString &out2);
    2. bool myMethod(uint in, QString &out2, const QDBusMessege &messege);
    3. bool myMethod(uint in, QString &out2, QDBusMessege &messege);
    To copy to clipboard, switch view to plain text mode 
    but it doesn't work either.

  3. #3
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: DBus adaptor and 'const QDBusMessege &messege' argument.

    Hi,

    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 which is used like this:
    Qt Code:
    1. class ActualDBusObjectNotAdaptor : public QObject, protected QDBusContext {
    2. // rest is the same
    3. };
    4.  
    5. bool ActualDBusObjectNotAdaptor::myMethod(uint in, QString &out2) {
    6. if (in<0) {
    7. sendErrorReply("Error.string", "User readable messege");
    8. }
    9. .....
    10. }
    To copy to clipboard, switch view to plain text mode 
    So extra parameter is not needed.
    Apparently here in documentations is mistake (it doesn't work as specified) probably some leftover after older version or at least it is incomplete.

Similar Threads

  1. argument parsing
    By deeee in forum Qt Programming
    Replies: 1
    Last Post: 26th May 2010, 22:21
  2. Trouble passing an argument
    By benlyboy in forum Newbie
    Replies: 5
    Last Post: 9th May 2010, 22:49
  3. Replies: 5
    Last Post: 7th January 2010, 10:42
  4. QMap as function argument...
    By cydside in forum Qt Programming
    Replies: 5
    Last Post: 18th April 2009, 17:59
  5. Qt 4.5.0 win opensource and <dbus/dbus.h>
    By YaK in forum Installation and Deployment
    Replies: 2
    Last Post: 22nd March 2009, 11:06

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.