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