From 621ab5695185522104d9be7a8982e3d97710ff4f Mon Sep 17 00:00:00 2001 From: nowrep Date: Thu, 25 Jul 2013 11:37:54 +0200 Subject: [PATCH] DBusNotifications: Use non-blocking DBuS calls --- .../desktopnotificationsfactory.cpp | 22 ++++++++++++------- .../desktopnotificationsfactory.h | 8 +++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/lib/desktopnotifications/desktopnotificationsfactory.cpp b/src/lib/desktopnotifications/desktopnotificationsfactory.cpp index 7d5c19cee..eb01866c0 100644 --- a/src/lib/desktopnotifications/desktopnotificationsfactory.cpp +++ b/src/lib/desktopnotifications/desktopnotificationsfactory.cpp @@ -22,6 +22,7 @@ #include #include +#include #if defined(QZ_WS_X11) && !defined(DISABLE_DBUS) #include @@ -92,11 +93,7 @@ void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QS args.append(QStringList()); args.append(QVariantMap()); args.append(m_timeout); - QDBusMessage message = dbus.callWithArgumentList(QDBus::Block, "Notify", args); - QVariantList list = message.arguments(); - if (list.count() > 0) { - m_uint = list.at(0).toInt(); - } + dbus.callWithCallback("Notify", args, this, SLOT(updateLastId(QDBusMessage)), SLOT(error(QDBusError))); #endif break; } @@ -119,10 +116,19 @@ void DesktopNotificationsFactory::nativeNotificationPreview() args.append(QStringList()); args.append(QVariantMap()); args.append(m_timeout); - QDBusMessage message = dbus.callWithArgumentList(QDBus::Block, "Notify", args); - QVariantList list = message.arguments(); + dbus.callWithCallback("Notify", args, this, SLOT(updateLastId(QDBusMessage)), SLOT(error(QDBusError))); +#endif +} + +void DesktopNotificationsFactory::updateLastId(const QDBusMessage &msg) +{ + QVariantList list = msg.arguments(); if (list.count() > 0) { m_uint = list.at(0).toInt(); } -#endif +} + +void DesktopNotificationsFactory::error(const QDBusError &error) +{ + qWarning() << "QDBusError:" << error.message(); } diff --git a/src/lib/desktopnotifications/desktopnotificationsfactory.h b/src/lib/desktopnotifications/desktopnotificationsfactory.h index a7248dc2d..62b30e49e 100644 --- a/src/lib/desktopnotifications/desktopnotificationsfactory.h +++ b/src/lib/desktopnotifications/desktopnotificationsfactory.h @@ -25,11 +25,15 @@ #include class QPixmap; +class QDBusMessage; +class QDBusError; class DesktopNotification; class QT_QUPZILLA_EXPORT DesktopNotificationsFactory : public QObject { + Q_OBJECT + public: enum Type { DesktopNative, PopupWidget }; @@ -42,6 +46,10 @@ public: void showNotification(const QPixmap &icon, const QString &heading, const QString &text); void nativeNotificationPreview(); +private slots: + void updateLastId(const QDBusMessage &msg); + void error(const QDBusError &error); + private: bool m_enabled; int m_timeout;