Pre-normalize notification daemon versions

This commit is contained in:
Ilya Fedin 2024-03-10 01:55:08 +04:00 committed by John Preston
parent 886847f457
commit 0ec5181566

View file

@ -117,17 +117,16 @@ void StartServiceAsync(Gio::DBusConnection connection, Fn<void()> callback) {
}); });
} }
std::string GetImageKey(const QVersionNumber &specificationVersion) { std::string GetImageKey() {
const auto normalizedVersion = specificationVersion.normalized(); const auto &specVersion = CurrentServerInformation.specVersion;
if (specVersion.isNull()) {
if (normalizedVersion.isNull()) {
LOG(("Native Notification Error: specification version is null")); LOG(("Native Notification Error: specification version is null"));
return {}; return {};
} }
if (normalizedVersion >= QVersionNumber(1, 2)) { if (specVersion >= QVersionNumber(1, 2)) {
return "image-data"; return "image-data";
} else if (normalizedVersion == QVersionNumber(1, 1)) { } else if (specVersion == QVersionNumber(1, 1)) {
return "image_data"; return "image_data";
} }
@ -210,7 +209,8 @@ NotificationData::NotificationData(
, _guid(_application ? std::string(Gio::dbus_generate_guid()) : std::string()) , _guid(_application ? std::string(Gio::dbus_generate_guid()) : std::string())
, _proxy(proxy) , _proxy(proxy)
, _interface(proxy) , _interface(proxy)
, _hints(GLib::VariantDict::new_()) { , _hints(GLib::VariantDict::new_())
, _imageKey(GetImageKey()) {
} }
bool NotificationData::init( bool NotificationData::init(
@ -267,8 +267,6 @@ bool NotificationData::init(
return false; return false;
} }
_imageKey = GetImageKey(CurrentServerInformation.specVersion);
if (HasCapability("body-markup")) { if (HasCapability("body-markup")) {
_title = title.toStdString(); _title = title.toStdString();
@ -706,9 +704,11 @@ void Create(Window::Notifications::System *system) {
std::get<1>(*result), std::get<1>(*result),
std::get<2>(*result), std::get<2>(*result),
QVersionNumber::fromString( QVersionNumber::fromString(
QString::fromStdString(std::get<3>(*result))), QString::fromStdString(std::get<3>(*result))
).normalized(),
QVersionNumber::fromString( QVersionNumber::fromString(
QString::fromStdString(std::get<4>(*result))), QString::fromStdString(std::get<4>(*result))
).normalized(),
}; };
} else { } else {
Gio::DBusErrorNS_::strip_remote_error(result.error()); Gio::DBusErrorNS_::strip_remote_error(result.error());