void BubbleManager::bubbleDismissed(int id)
{
    m_bubble->setVisible(false);
    Q_EMIT NotificationClosed(id, BubbleManager::Dismissed);

    consumeEntities();
}
void BubbleManager::bubbleActionInvoked(uint id, QString actionId)
{
    m_bubble->setVisible(false);
    Q_EMIT ActionInvoked(id, actionId);
    Q_EMIT NotificationClosed(id, BubbleManager::Closed);
    consumeEntities();
}
Esempio n. 3
0
void NotificationsEngine::userClosedNotification(uint id)
{
    const QString source = QString("notification %1").arg(id);
    // if we don't have that notification in our list,
    // it was already closed, so don't emit
    if (m_activeNotifications.remove(source) > 0) {
        removeSource(source);
        emit NotificationClosed(id, 2);
    }
}
RazorNotificationPrivate::RazorNotificationPrivate(const QString& summary, RazorNotification* parent) :
    mId(0),
    mSummary(summary),
    mTimeout(-1),
    q_ptr(parent)
{
    mInterface = new OrgFreedesktopNotificationsInterface("org.freedesktop.Notifications",
                                                          "/org/freedesktop/Notifications",
                                                          QDBusConnection::sessionBus(), this);
    connect(mInterface, SIGNAL(NotificationClosed(uint, uint)), this, SLOT(notificationClosed(uint,uint)));
    connect(mInterface, SIGNAL(ActionInvoked(uint,QString)), this, SLOT(handleAction(uint,QString)));
}
void NotificationsEngine::timerEvent(QTimerEvent *event)
{
    const QString source = m_timeouts.value(event->timerId());
    if (!source.isEmpty()) {
        killTimer(event->timerId());
        m_sourceTimers.remove(source);
        m_timeouts.remove(event->timerId());
        removeSource(source);
        emit NotificationClosed(source.split(" ").last().toInt(), 1);
        return;
    }

    Plasma::DataEngine::timerEvent(event);
}
bool DbusPopupHandler::initObjects()
{
	if (!initNotifyInterface())
		return false;

	FServerInfo = new ServerInfo;

	QDBusMessage replyCaps = FNotifyInterface->call(QDBus::Block, "GetCapabilities");
	if (replyCaps.type() != QDBusMessage::ErrorMessage)
	{
		for (int i=0; i<replyCaps.arguments().at(0).toStringList().count(); i++)
			LOG_INFO(QString("Capabilities: %1").arg(replyCaps.arguments().at(0).toStringList().at(i)));
		FServerInfo->capabilities = replyCaps.arguments().at(0).toStringList();
		FAllowActions = FServerInfo->capabilities.contains("actions");
	}
	else
		LOG_WARNING(QString("Capabilities: DBus Error: %1").arg(replyCaps.errorMessage()));

	QDBusMessage replyInfo = FNotifyInterface->call(QDBus::Block, "GetServerInformation");
	if (replyInfo.type() != QDBusMessage::ErrorMessage)
	{
		for (int i=0; i<replyInfo.arguments().count(); i++)
			LOG_INFO(QString("Server Information: %1").arg(replyInfo.arguments().at(i).toString()));

		FServerInfo->name = replyInfo.arguments().at(0).toString();
		FServerInfo->vendor = replyInfo.arguments().at(1).toString();
		FServerInfo->version = replyInfo.arguments().at(2).toString();
		FServerInfo->spec_version = replyInfo.arguments().at(3).toString();

	}
	else
		LOG_WARNING(QString("Server Information: DBus Error: %1").arg(replyInfo.errorMessage()));

	if (FAllowActions)
	{
		connect(FNotifyInterface,SIGNAL(ActionInvoked(uint,QString)),this,SLOT(onActionInvoked(uint,QString)));
		connect(FNotifyInterface,SIGNAL(NotificationClosed(uint,uint)),this,SLOT(onNotificationClosed(uint,uint)));
		LOG_INFO(QLatin1String("Actions supported."));
	}
	else
		LOG_INFO(QLatin1String("Actions not supported."));

	FNotifications->insertNotificationHandler(NHO_DBUSPOPUP, this);

	return true;
}
Esempio n. 7
0
Notifyd::Notifyd(QObject* parent)
    : QObject(parent),
      mId(0)
{
    m_area = new NotificationArea();
    ReloadSettings();

    connect(this, SIGNAL(notificationAdded(uint,QString,QString,QString,QString,int,QStringList,QVariantMap)),
            m_area->layout(), SLOT(addNotification(uint,QString,QString,QString,QString,int,QStringList,QVariantMap)));
    connect(this, SIGNAL(notificationClosed(uint, uint)),
            m_area->layout(), SLOT(removeNotification(uint, uint)));
    // feedback for original caller
    connect(m_area->layout(), SIGNAL(notificationClosed(uint,uint)),
            this, SIGNAL(NotificationClosed(uint,uint)));
    connect(m_area->layout(), SIGNAL(actionInvoked(uint, QString)),
            this, SIGNAL(ActionInvoked(uint,QString)));

}
Esempio n. 8
0
NotifyObject::NotifyObject(MainWindow *mainWin) : QObject(mainWin)
{
    this->mainWin = mainWin;

    // DBus interfaces

    QDBusConnection dbus = QDBusConnection::sessionBus();

    notifierBus = new DBusNotificationsIf(HD_NOTIFICATION_MANAGER_DBUS_NAME,
                                          HD_NOTIFICATION_MANAGER_DBUS_PATH,
                                          dbus,this);

    sndVibBus = new DBusNokiaHildonSVNDIf(HD_SV_NOTIFICATION_DAEMON_DBUS_NAME,
                                          HD_SV_NOTIFICATION_DAEMON_DBUS_PATH,
                                          dbus,this);

    connect(notifierBus,SIGNAL(ActionInvoked(uint,QString)),
            this,SLOT(notifyCallback(uint,QString)));

    connect(notifierBus,SIGNAL(NotificationClosed(uint,uint)),
            this,SLOT(deleteNotify(uint,uint)));
}
void BubbleManager::bubbleReplacedByOther(int id)
{
    Q_EMIT NotificationClosed(id, BubbleManager::Unknown);
}
void NotificationsEngine::userClosedNotification(uint id)
{
    removeSource(QString("notification %1").arg(id));
    emit NotificationClosed(id, 2);
}
Esempio n. 11
0
StatusNotifierItem::StatusNotifierItem(QWidget *parent)
    : StatusNotifierItemParent(parent)
#if QT_VERSION >= 0x050000
    , _iconThemeDir{QDir::tempPath() + QLatin1String{"/quassel-sni-XXXXXX"}}
#endif
{
    static bool registered = []() -> bool {
        qDBusRegisterMetaType<DBusImageStruct>();
        qDBusRegisterMetaType<DBusImageVector>();
        qDBusRegisterMetaType<DBusToolTipStruct>();
        return true;
    }();
    Q_UNUSED(registered)

    setMode(Mode::StatusNotifier);

    connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(onVisibilityChanged(bool)));
    connect(this, SIGNAL(modeChanged(Mode)), this, SLOT(onModeChanged(Mode)));
    connect(this, SIGNAL(stateChanged(State)), this, SLOT(onStateChanged(State)));

    trayMenu()->installEventFilter(this);

    // Create a temporary directory that holds copies of the tray icons. That way, visualizers can find our icons.
    // For Qt4 the relevant icons are installed in hicolor already, so nothing to be done.
#if QT_VERSION >= 0x050000
    if (_iconThemeDir.isValid()) {
        _iconThemePath = _iconThemeDir.path();
    }
    else {
        qWarning() << "Could not create temporary directory for themed tray icons!";
    }
#endif

    connect(this, SIGNAL(iconsChanged()), this, SLOT(refreshIcons()));
    refreshIcons();

    // Our own SNI service
    _statusNotifierItemDBus = new StatusNotifierItemDBus(this);
    connect(this, SIGNAL(currentIconNameChanged()), _statusNotifierItemDBus, SIGNAL(NewIcon()));
    connect(this, SIGNAL(currentIconNameChanged()), _statusNotifierItemDBus, SIGNAL(NewAttentionIcon()));
    connect(this, SIGNAL(toolTipChanged(QString, QString)), _statusNotifierItemDBus, SIGNAL(NewToolTip()));

    // Service watcher to keep track of the StatusNotifierWatcher service
    QDBusServiceWatcher *watcher = new QDBusServiceWatcher(kSniWatcherService,
                                                           QDBusConnection::sessionBus(),
                                                           QDBusServiceWatcher::WatchForOwnerChange,
                                                           this);
    connect(watcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)), SLOT(serviceChange(QString, QString, QString)));

    // Client instance for StatusNotifierWatcher
    _statusNotifierWatcher = new org::kde::StatusNotifierWatcher(kSniWatcherService,
                                                                 kSniWatcherPath,
                                                                 QDBusConnection::sessionBus(),
                                                                 this);
    connect(_statusNotifierWatcher, SIGNAL(StatusNotifierHostRegistered()), SLOT(checkForRegisteredHosts()));
    connect(_statusNotifierWatcher, SIGNAL(StatusNotifierHostUnregistered()), SLOT(checkForRegisteredHosts()));

    // Client instance for notifications
    _notificationsClient = new org::freedesktop::Notifications(kXdgNotificationsService,
                                                               kXdgNotificationsPath,
                                                               QDBusConnection::sessionBus(),
                                                               this);
    connect(_notificationsClient, SIGNAL(NotificationClosed(uint, uint)), SLOT(notificationClosed(uint, uint)));
    connect(_notificationsClient, SIGNAL(ActionInvoked(uint, QString)), SLOT(notificationInvoked(uint, QString)));

    if (_notificationsClient->isValid()) {
        QStringList desktopCapabilities = _notificationsClient->GetCapabilities();
        _notificationsClientSupportsMarkup = desktopCapabilities.contains("body-markup");
        _notificationsClientSupportsActions = desktopCapabilities.contains("actions");
    }

#ifdef HAVE_DBUSMENU
    new QuasselDBusMenuExporter(menuObjectPath(), trayMenu(), _statusNotifierItemDBus->dbusConnection()); // will be added as menu child
#endif
}