Results 1 to 5 of 5

Thread: Result of DBUS call

  1. #1
    Join Date
    Mar 2006
    Posts
    17
    Thanks
    4

    Default Result of DBUS call

    Hi,
    I am writing some app with notification, but currently I am stuck. I wanted to add actions to notifications, but I don't know how to read the result. Here is the code:
    Qt Code:
    1. knotify = new QDBusInterface("org.kde.VisualNotifications", "/VisualNotifications", "org.kde.VisualNotifications");
    2. //some args initialisation
    3. QDBusReply<QString> reply = knotify->callWithArgumentList(QDBus::Block, "Notify", args);
    4. if (reply.isValid())
    5. qDebug() << reply.value();
    6. else
    7. qDebug() << "Error";
    To copy to clipboard, switch view to plain text mode 
    Everything works nicely, popup is shown, but commandline shows "Error" that means QDBusReply is invalid.
    How can I read the result of this function?
    This should return ID of the notification for further usage.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Result of DBUS call

    I think you should listen to the ActionInvoked signal from the notification object.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2006
    Posts
    17
    Thanks
    4

    Default Re: Result of DBUS call

    Thanks for your reply but it is not what I meant. This is gonna be next step, but at first I need to obtain ID of this notification, beacause ActionInvoked returns ID also and then I now how to react on ActionInvoked.

    (with ActionInvoked I get only ID and action number, but I don't know what notification it is.)

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Result of DBUS call

    This works for me:
    Qt Code:
    1. #include <QtGui>
    2. #include <QDBusInterface>
    3. #include <QtDebug>
    4.  
    5. int main(int argc, char **argv){
    6. QApplication app(argc, argv);
    7. QDBusInterface knotify("org.kde.VisualNotifications", "/VisualNotifications", "org.kde.VisualNotifications");
    8. QVariantList args;
    9. args << QString("Appname");
    10. args << QVariant(QVariant::UInt);
    11. args << QVariant(QVariant::String);
    12. args << QString("kde");
    13. args << QString("Summary");
    14. args << QString("Body");
    15. args << QStringList();
    16. args << QVariantMap();
    17. args << 5000;
    18. QDBusMessage call = knotify.callWithArgumentList(QDBus::Block, "Notify", args);
    19. uint id = call.arguments().first().toUInt();
    20. qDebug() << id;
    21. return app.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 

    The return value is integer, so try QDBusReply<uint> instead of QDBusReply<QString>. This works for me as well.
    Last edited by wysota; 27th July 2009 at 18:21.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following 3 users say thank you to wysota for this useful post:

    conexion2000 (28th July 2009), mpele (18th November 2009), Tuxedo (31st March 2017)

  6. #5
    Join Date
    Mar 2006
    Posts
    17
    Thanks
    4

    Default Re: Result of DBUS call

    Quote Originally Posted by wysota View Post
    This works for me:
    Qt Code:
    1. #include <QtGui>
    2. #include <QDBusInterface>
    3. #include <QtDebug>
    4.  
    5. int main(int argc, char **argv){
    6. QApplication app(argc, argv);
    7. QDBusInterface knotify("org.kde.VisualNotifications", "/VisualNotifications", "org.kde.VisualNotifications");
    8. QVariantList args;
    9. args << QString("Appname");
    10. args << QVariant(QVariant::UInt);
    11. args << QVariant(QVariant::String);
    12. args << QString("kde");
    13. args << QString("Summary");
    14. args << QString("Body");
    15. args << QStringList();
    16. args << QVariantMap();
    17. args << 5000;
    18. QDBusMessage call = knotify.callWithArgumentList(QDBus::Block, "Notify", args);
    19. uint id = call.arguments().first().toUInt();
    20. qDebug() << id;
    21. return app.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 

    The return value is integer, so try QDBusReply<uint> instead of QDBusReply<QString>. This works for me as well.
    Bingo! Thanks for help.

Similar Threads

  1. Replies: 4
    Last Post: 14th July 2009, 04:27
  2. need DBus help
    By nrabara in forum Newbie
    Replies: 2
    Last Post: 2nd May 2009, 08:41
  3. DBus on windows?
    By talk2amulya in forum Qt Programming
    Replies: 4
    Last Post: 30th March 2009, 12:11
  4. DBus over Network?
    By shensel in forum Qt Programming
    Replies: 5
    Last Post: 26th March 2009, 12:12
  5. Replies: 1
    Last Post: 13th November 2008, 11:46

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.