harbour-tooter/src/notifications.cpp

79 lines
2.6 KiB
C++
Raw Normal View History

2017-10-25 17:30:23 +03:00
/*
* Copyright (C) 2015-2017 kimmoli <kimmo.lindholm@eke.fi>
* All rights reserved.
*
* This file is part of Maira
*
* You may use this file under the terms of BSD license
*/
#include "notifications.h"
Notifications::Notifications(QObject *parent) :
QObject(parent)
{
}
void Notifications::notify(QString appName, QString summary, QString body, bool preview, QString ts, QString issuekey)
{
Notification notif;
QVariantList remoteactions;
if (preview)
{
notif.setPreviewSummary(summary);
notif.setPreviewBody(body);
2020-05-04 10:26:41 +03:00
notif.setCategory("x-harbour.tooterb.activity");
2017-10-25 17:30:23 +03:00
if (issuekey.isEmpty())
{
remoteactions << Notification::remoteAction("default",
QString(),
2020-05-04 10:26:41 +03:00
"ba.dysko.habour.tooterb",
2017-10-25 17:30:23 +03:00
"/",
2020-05-04 10:26:41 +03:00
"ba.dysko.habour.tooterb",
2017-10-25 17:30:23 +03:00
"openapp",
QVariantList());
}
}
else
{
notif.setAppName(appName);
notif.setSummary(summary);
notif.setBody(body);
notif.setItemCount(1);
2020-05-04 10:26:41 +03:00
notif.setCategory("x-harbour.tooterb.activity");
2017-10-25 17:30:23 +03:00
remoteactions << Notification::remoteAction("app",
QString(),
2020-05-04 10:26:41 +03:00
"ba.dysko.habour.tooterb",
2017-10-25 17:30:23 +03:00
"/",
2020-05-04 10:26:41 +03:00
"ba.dysko.habour.tooterb",
2017-10-25 17:30:23 +03:00
"openapp",
QVariantList());
}
notif.setReplacesId(0);
if (!ts.isEmpty())
notif.setHintValue("x-nemo-timestamp", QVariant(ts));
if (!issuekey.isEmpty())
{
QList<QVariant> args;
args.append(QStringList() << issuekey);
remoteactions << Notification::remoteAction("default",
QString(),
2020-05-04 10:26:41 +03:00
"ba.dysko.habour.tooterb",
2017-10-25 17:30:23 +03:00
"/",
2020-05-04 10:26:41 +03:00
"ba.dysko.habour.tooterb",
2017-10-25 17:30:23 +03:00
"showtoot",
args);
}
if (remoteactions.count() > 0)
notif.setRemoteActions(remoteactions);
notif.publish();
}