+void StatusNotifierItem::showMessage(const QString &title, const QString &message_, SystemTray::MessageIcon icon, int timeout, uint notificationId) {
+ QString message = message_;
+ if(_notificationsClient->isValid()) {
+ if(_notificationsClientSupportsMarkup)
+ message = Qt::escape(message);
+
+ QStringList actions;
+ if(_notificationsClientSupportsActions)
+ actions << "activate" << "View";
+
+ // we always queue notifications right now
+ QDBusReply<uint> reply = _notificationsClient->Notify(title, 0, "quassel", title, message, actions, QVariantMap(), timeout);
+ if(reply.isValid()) {
+ uint dbusid = reply.value();
+ _notificationsIdMap.insert(dbusid, notificationId);
+ _lastNotificationsDBusId = dbusid;
+ }
+ } else
+ StatusNotifierItemParent::showMessage(title, message, icon, timeout, notificationId);
+}
+
+void StatusNotifierItem::closeMessage(uint notificationId) {
+ foreach(uint dbusid, _notificationsIdMap.keys()) {
+ if(_notificationsIdMap.value(dbusid) == notificationId) {
+ _notificationsIdMap.remove(dbusid);
+ _notificationsClient->CloseNotification(dbusid);
+ }
+ }
+ _lastNotificationsDBusId = 0;
+}
+
+void StatusNotifierItem::notificationClosed(uint dbusid, uint reason) {
+ Q_UNUSED(reason)
+ _lastNotificationsDBusId = 0;
+ emit messageClosed(_notificationsIdMap.take(dbusid));
+}
+
+void StatusNotifierItem::notificationInvoked(uint dbusid, const QString &action) {
+ Q_UNUSED(action)
+ emit messageClicked(_notificationsIdMap.value(dbusid, 0));
+}
+