/***************************************************************************
-* Copyright (C) 2005-08 by the Quassel Project *
+* Copyright (C) 2005-09 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include "clientsettings.h"
#include "networkmodel.h"
-DesktopNotificationBackend::DesktopNotificationBackend(QObject *parent) : AbstractNotificationBackend(parent) {
- _configWidget = new ConfigWidget();
-
+DesktopNotificationBackend::DesktopNotificationBackend(QObject *parent)
+ : AbstractNotificationBackend(parent),
+ _lastDbusId(0)
+{
_dbusInterface = new org::freedesktop::Notifications(
"org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
QDBusConnection::sessionBus(), this);
+ if(!_dbusInterface->isValid()) {
+ qWarning() << "DBus notification service not available!";
+ return;
+ }
+
QStringList desktopCapabilities = _dbusInterface->GetCapabilities();
_daemonSupportsMarkup = desktopCapabilities.contains("body-markup");
- _lastDbusId = 0;
connect(_dbusInterface, SIGNAL(NotificationClosed(uint, uint)), SLOT(desktopNotificationClosed(uint, uint)));
connect(_dbusInterface, SIGNAL(ActionInvoked(uint, const QString &)), SLOT(desktopNotificationInvoked(uint, const QString&)));
notificationSettings.notify("DesktopNotification/QueueNotifications", this, SLOT(queueNotificationsChanged(const QVariant &)));
}
-DesktopNotificationBackend::~DesktopNotificationBackend() {
- delete _configWidget;
-}
-
void DesktopNotificationBackend::enabledChanged(const QVariant &v) {
_enabled = v.toBool();
}
}
void DesktopNotificationBackend::notify(const Notification &n) {
- if(_enabled) {
+ if(_enabled && _dbusInterface->isValid() && (n.type == Highlight || n.type == PrivMsg)) {
QStringList actions;
QMap<QString, QVariant> hints;
uint oldId = _queueNotifications ? 0 : _lastDbusId;
- // actions << "click" << "Click Me!";
+ actions << "activate" << "View";
QString title = Client::networkModel()->networkName(n.bufferId) + " - " + Client::networkModel()->bufferName(n.bufferId);
QString message = QString("<%1> %2").arg(n.sender, n.message);
void DesktopNotificationBackend::desktopNotificationInvoked(uint id, const QString & action) {
- Q_UNUSED(id); Q_UNUSED(action);
+ Q_UNUSED(action);
+ foreach(uint ourid, _idMap.keys()) {
+ if(_idMap.value(ourid) != id)
+ continue;
+ emit activated(ourid);
+ return;
+ }
+
+ emit activated();
}
-SettingsPage *DesktopNotificationBackend::configWidget() const {
- return _configWidget;
+SettingsPage *DesktopNotificationBackend::createConfigWidget() const {
+ return new ConfigWidget();
}
/***************************************************************************/