Clean up notification watching a bit
This commit is contained in:
parent
f05fe0b371
commit
2605ce9a89
@ -52,8 +52,6 @@ NotificationsManager::postNotification(const QString &roomid,
|
|||||||
const QString &text,
|
const QString &text,
|
||||||
const QImage &icon)
|
const QImage &icon)
|
||||||
{
|
{
|
||||||
Q_UNUSED(icon)
|
|
||||||
|
|
||||||
QVariantMap hints;
|
QVariantMap hints;
|
||||||
hints["image-data"] = icon;
|
hints["image-data"] = icon;
|
||||||
hints["sound-name"] = "message-new-instant";
|
hints["sound-name"] = "message-new-instant";
|
||||||
@ -75,8 +73,8 @@ NotificationsManager::postNotification(const QString &roomid,
|
|||||||
static QDBusInterface notifyApp("org.freedesktop.Notifications",
|
static QDBusInterface notifyApp("org.freedesktop.Notifications",
|
||||||
"/org/freedesktop/Notifications",
|
"/org/freedesktop/Notifications",
|
||||||
"org.freedesktop.Notifications");
|
"org.freedesktop.Notifications");
|
||||||
auto call = notifyApp.asyncCallWithArgumentList("Notify", argumentList);
|
QDBusPendingCall call = notifyApp.asyncCallWithArgumentList("Notify", argumentList);
|
||||||
auto watcher = new QDBusPendingCallWatcher{QDBusPendingCall{QDBusPendingReply{call}}};
|
auto watcher = new QDBusPendingCallWatcher{call, this};
|
||||||
connect(
|
connect(
|
||||||
watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this, roomid, eventid]() {
|
watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this, roomid, eventid]() {
|
||||||
if (watcher->reply().type() == QDBusMessage::ErrorMessage)
|
if (watcher->reply().type() == QDBusMessage::ErrorMessage)
|
||||||
@ -91,14 +89,11 @@ NotificationsManager::postNotification(const QString &roomid,
|
|||||||
void
|
void
|
||||||
NotificationsManager::closeNotification(uint id)
|
NotificationsManager::closeNotification(uint id)
|
||||||
{
|
{
|
||||||
QList<QVariant> argumentList;
|
|
||||||
argumentList << (uint)id; // replace_id
|
|
||||||
|
|
||||||
static QDBusInterface closeCall("org.freedesktop.Notifications",
|
static QDBusInterface closeCall("org.freedesktop.Notifications",
|
||||||
"/org/freedesktop/Notifications",
|
"/org/freedesktop/Notifications",
|
||||||
"org.freedesktop.Notifications");
|
"org.freedesktop.Notifications");
|
||||||
auto call = closeCall.asyncCallWithArgumentList("CloseNotification", argumentList);
|
auto call = closeCall.asyncCall("CloseNotification", (uint)id); // replace_id
|
||||||
auto watcher = new QDBusPendingCallWatcher{QDBusPendingCall{QDBusPendingReply{call}}};
|
auto watcher = new QDBusPendingCallWatcher{call, this};
|
||||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this]() {
|
connect(watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this]() {
|
||||||
if (watcher->reply().type() == QDBusMessage::ErrorMessage) {
|
if (watcher->reply().type() == QDBusMessage::ErrorMessage) {
|
||||||
qDebug() << "D-Bus Error:" << watcher->reply().errorMessage();
|
qDebug() << "D-Bus Error:" << watcher->reply().errorMessage();
|
||||||
|
Loading…
Reference in New Issue
Block a user