#include "system_notification.h"
#include <QApplication>
#include <QUrl>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusInterface>


SystemNotification::SystemNotification(QObject *parent) : QObject(parent)
{
    m_interface = new QDBusInterface(QStringLiteral("org.freedesktop.Notifications"),
                                     QStringLiteral("/org/freedesktop/Notifications"),
                                     QStringLiteral("org.freedesktop.Notifications"),
                                     QDBusConnection::sessionBus(),
                                     this);
}


void SystemNotification::sendMessage(const QString &text)
{
    sendMessage(text, tr("Printer Info"));
}

void SystemNotification::sendMessage(
    const QString &text, const QString &title, const int timeout)
{

    QList<QVariant> args;
    // QVariantMap hintsMap;
    QMap<QString, QVariant> hintsMap;

    args << tr("Printer")                 // appname
         << static_cast<unsigned int>(0) // id
         << "kylin-printer"                  // icon
         << title                        // summary
         << text                         // body
         << QStringList()                // actions
         << hintsMap                     // hints
         << timeout;                     // timeout
    m_interface->callWithArgumentList(QDBus::AutoDetect, QStringLiteral("Notify"), args);

}
