File indexing completed on 2024-04-21 03:56:27

0001 /*
0002     SPDX-FileCopyrightText: 2016 Martin Klapetek <mklapetek@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "fake_notifications_server.h"
0008 
0009 NotificationsServer::NotificationsServer(QObject *parent)
0010 {
0011     Q_UNUSED(parent);
0012     counter = 1;
0013 }
0014 
0015 uint NotificationsServer::Notify(const QString &app_name,
0016                                  uint replaces_id,
0017                                  const QString &app_icon,
0018                                  const QString &summary,
0019                                  const QString &body,
0020                                  const QStringList &actions,
0021                                  const QVariantMap &hints,
0022                                  int timeout)
0023 {
0024     NotificationItem i;
0025     i.app_name = app_name;
0026     i.replaces_id = replaces_id;
0027     i.app_icon = app_icon;
0028     i.summary = summary;
0029     i.body = body;
0030     i.actions = actions;
0031     i.hints = hints;
0032     i.timeout = timeout;
0033     i.id = counter;
0034 
0035     notifications.append(i);
0036 
0037     Q_EMIT newNotification();
0038 
0039     return counter++;
0040 }
0041 
0042 void NotificationsServer::CloseNotification(uint id)
0043 {
0044     QList<NotificationItem>::iterator i = notifications.begin();
0045     while (i != notifications.end()) {
0046         if ((*i).id == id) {
0047             notifications.erase(i);
0048             break;
0049         }
0050         i++;
0051     }
0052 
0053     Q_EMIT NotificationClosed(id, 3);
0054 }
0055 
0056 QStringList NotificationsServer::GetCapabilities()
0057 {
0058     return QStringList{QStringLiteral("body-markup"), QStringLiteral("body"), QStringLiteral("actions")};
0059 }
0060 
0061 QString NotificationsServer::GetServerInformation(QString &vendor, QString &version, QString &specVersion)
0062 {
0063     vendor = QStringLiteral("KDE");
0064     version = QStringLiteral("2.0"); // FIXME
0065     specVersion = QStringLiteral("1.1");
0066     return QStringLiteral("TestServer");
0067 }
0068 
0069 #include "moc_fake_notifications_server.cpp"