Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/checksums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ QByteArray calcAdler32(QIODevice *device)
}
QByteArray buf(BUFSIZE, Qt::Uninitialized);

unsigned int adler = adler32(0L, Z_NULL, 0);
unsigned int adler = adler32(0L, nullptr, 0);
qint64 size;
while (!device->atEnd()) {
size = device->read(buf.data(), BUFSIZE);
Expand Down
27 changes: 21 additions & 6 deletions src/gui/notifications/dbusnotifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class OCC::DBusNotificationsPrivate
DBusNotifications *q_ptr;

org::freedesktop::Notifications dbusInterface;

QMap<quint32, quint64> _idMap;
};


Expand All @@ -43,8 +45,10 @@ DBusNotifications::DBusNotifications(SystemNotificationManager *parent)

{
Q_D(DBusNotifications);
connect(&d->dbusInterface, &org::freedesktop::Notifications::ActionInvoked, this, [this](uint id, const QString &actionKey) {
qCDebug(lcDbusNotification) << "ActionInvoked" << id << actionKey;
connect(&d->dbusInterface, &org::freedesktop::Notifications::ActionInvoked, this, [this](uint systemId, const QString &actionKey) {
Q_D(DBusNotifications);
const auto id = d->_idMap.value(systemId);
qCDebug(lcDbusNotification) << "ActionInvoked" << id << "SystemId" << systemId << actionKey;
if (auto *notification = activeNotification(id)) {
const qsizetype index = actionKey.toLongLong();
if (index < notification->request().buttons().size()) {
Expand All @@ -55,7 +59,9 @@ DBusNotifications::DBusNotifications(SystemNotificationManager *parent)
}
});

connect(&d->dbusInterface, &org::freedesktop::Notifications::NotificationClosed, this, [this](uint id, uint reason) {
connect(&d->dbusInterface, &org::freedesktop::Notifications::NotificationClosed, this, [this](uint systemId, uint reason) {
Q_D(DBusNotifications);
const auto id = d->_idMap.take(systemId);
if (auto *notification = activeNotification(id)) {
SystemNotification::Result result;
switch (reason) {
Expand All @@ -70,10 +76,10 @@ DBusNotifications::DBusNotifications(SystemNotificationManager *parent)
qCWarning(lcDbusNotification) << "Unsupported close reason" << reason;
break;
}
qCDebug(lcDbusNotification) << "NotificationClosed" << id << reason << result;
qCDebug(lcDbusNotification) << "NotificationClosed" << id << "SystemId" << systemId << reason << result;
finishNotification(notification, result);
} else {
qCDebug(lcDbusNotification) << "Unknown NotificationClicked" << id << reason;
qCDebug(lcDbusNotification) << "Unknown NotificationClicked" << id << "SystemId" << systemId << reason;
Q_EMIT systemNotificationManager() -> unknownNotificationClicked();
}
});
Expand Down Expand Up @@ -103,6 +109,15 @@ void DBusNotifications::notify(const SystemNotificationRequest &notificationRequ
actionList.append(QString::number(id++));
actionList.append(action);
}
d->dbusInterface.Notify(Theme::instance()->appNameGUI(), notificationRequest.id(), Resources::iconToFileSystemUrl(qGuiApp->windowIcon()).toString(),
const auto reply = d->dbusInterface.Notify(Theme::instance()->appNameGUI(), 0, Resources::iconToFileSystemUrl(qGuiApp->windowIcon()).toString(),
notificationRequest.title(), notificationRequest.text(), actionList, hints, -1);

auto *watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [id = notificationRequest.id(), this](QDBusPendingCallWatcher *watcher) {
Q_D(DBusNotifications);
watcher->deleteLater();

QDBusPendingReply<uint> reply = *watcher;
d->_idMap.insert(reply.argumentAt<0>(), id);
});
}
Loading