diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 794b205efc..a10314e75b 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION #include -#include #include #include #endif @@ -31,7 +30,7 @@ constexpr auto kInterface = kService; std::vector GetServerInformation( const std::shared_ptr ¬ificationInterface) { std::vector serverInformation; - auto serverInformationReply = notificationInterface + const auto serverInformationReply = notificationInterface ->call(qsl("GetServerInformation")); if (serverInformationReply.type() == QDBusMessage::ReplyMessage) { @@ -58,7 +57,7 @@ std::vector GetServerInformation( QStringList GetCapabilities( const std::shared_ptr ¬ificationInterface) { - QDBusReply capabilitiesReply = notificationInterface + const QDBusReply capabilitiesReply = notificationInterface ->call(qsl("GetCapabilities")); if (capabilitiesReply.isValid()) { @@ -95,7 +94,7 @@ NotificationData::NotificationData( , _title(title) , _peerId(peerId) , _msgId(msgId) { - auto capabilities = GetCapabilities(_notificationInterface); + const auto capabilities = GetCapabilities(_notificationInterface); if (capabilities.contains(qsl("body-markup"))) { _body = subtitle.isEmpty() @@ -112,17 +111,25 @@ NotificationData::NotificationData( if (capabilities.contains(qsl("actions"))) { _actions << qsl("default") << QString(); - connect(_notificationInterface.get(), - SIGNAL(ActionInvoked(uint, QString)), - this, SLOT(notificationClicked(uint))); + _notificationInterface->connection().connect( + str_const_toString(kService), + str_const_toString(kObjectPath), + str_const_toString(kInterface), + qsl("ActionInvoked"), + this, + SLOT(notificationClicked(uint))); if (capabilities.contains(qsl("inline-reply"))) { _actions << qsl("inline-reply") << tr::lng_notification_reply(tr::now); - connect(_notificationInterface.get(), - SIGNAL(NotificationReplied(uint,QString)), - this, SLOT(notificationReplied(uint,QString))); + _notificationInterface->connection().connect( + str_const_toString(kService), + str_const_toString(kObjectPath), + str_const_toString(kInterface), + qsl("NotificationReplied"), + this, + SLOT(notificationReplied(uint,QString))); } else { // icon name according to https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html _actions << qsl("mail-reply-sender") @@ -153,15 +160,26 @@ NotificationData::NotificationData( _hints["desktop-entry"] = qsl(MACRO_TO_STRING(TDESKTOP_LAUNCHER_BASENAME)); - connect(_notificationInterface.get(), - SIGNAL(NotificationClosed(uint, uint)), - this, SLOT(notificationClosed(uint))); + _notificationInterface->connection().connect( + str_const_toString(kService), + str_const_toString(kObjectPath), + str_const_toString(kInterface), + qsl("NotificationClosed"), + this, + SLOT(notificationClosed(uint))); } bool NotificationData::show() { - QDBusReply notifyReply = _notificationInterface->call(qsl("Notify"), - str_const_toString(AppName), uint(0), QString(), _title, _body, - _actions, _hints, -1); + const QDBusReply notifyReply = _notificationInterface->call( + qsl("Notify"), + str_const_toString(AppName), + uint(0), + QString(), + _title, + _body, + _actions, + _hints, + -1); if (notifyReply.isValid()) { _notificationId = notifyReply.value(); @@ -174,7 +192,7 @@ bool NotificationData::show() { } bool NotificationData::close() { - QDBusReply closeReply = _notificationInterface + const QDBusReply closeReply = _notificationInterface ->call(qsl("CloseNotification"), _notificationId); if (!closeReply.isValid()) { @@ -186,7 +204,7 @@ bool NotificationData::close() { } void NotificationData::setImage(const QString &imagePath) { - auto specificationVersion = ParseSpecificationVersion( + const auto specificationVersion = ParseSpecificationVersion( GetServerInformation(_notificationInterface)); QString imageKey; @@ -211,8 +229,11 @@ void NotificationData::setImage(const QString &imagePath) { return; } - auto image = QImage(imagePath).convertToFormat(QImage::Format_RGBA8888); - QByteArray imageBytes((const char*)image.constBits(), + const auto image = QImage(imagePath) + .convertToFormat(QImage::Format_RGBA8888); + + const QByteArray imageBytes( + (const char*)image.constBits(), image.sizeInBytes()); ImageData imageData; @@ -285,7 +306,7 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, bool Supported() { #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION - static auto Available = QDBusInterface( + static const auto Available = QDBusInterface( str_const_toString(kService), str_const_toString(kObjectPath), str_const_toString(kInterface)).isValid(); @@ -316,10 +337,10 @@ Manager::Private::Private(Manager *manager, Type type) str_const_toString(kInterface))) { qDBusRegisterMetaType(); - auto specificationVersion = ParseSpecificationVersion( + const auto specificationVersion = ParseSpecificationVersion( GetServerInformation(_notificationInterface)); - auto capabilities = GetCapabilities(_notificationInterface); + const auto capabilities = GetCapabilities(_notificationInterface); if (!specificationVersion.isNull()) { LOG(("Notification daemon specification version: %1")