Add fail callback to linux notifications exceptions handler

This commit is contained in:
Ilya Fedin 2022-07-31 11:10:17 +04:00 committed by John Preston
parent 730ee3ae16
commit 66c9587650
1 changed files with 20 additions and 28 deletions

View File

@ -49,9 +49,10 @@ bool ServiceRegistered = false;
std::optional<ServerInformation> CurrentServerInformation;
QStringList CurrentCapabilities;
void Noexcept(Fn<void()> callback) noexcept {
void Noexcept(Fn<void()> callback, Fn<void()> failed = nullptr) noexcept {
try {
callback();
return;
} catch (const Glib::Error &e) {
LOG(("Native Notification Error: %1").arg(
QString::fromStdString(e.what())));
@ -59,6 +60,10 @@ void Noexcept(Fn<void()> callback) noexcept {
LOG(("Native Notification Error: %1").arg(
QString::fromStdString(e.what())));
}
if (failed) {
failed();
}
}
std::unique_ptr<base::Platform::DBus::ServiceWatcher> CreateServiceWatcher() {
@ -206,18 +211,14 @@ void GetServerInformation(
QString::fromStdString(specVersion)),
});
});
return;
}, [&] {
crl::on_main([=] { callback(std::nullopt); });
});
crl::on_main([=] { callback(std::nullopt); });
},
std::string(kService));
return;
}, [&] {
crl::on_main([=] { callback(std::nullopt); });
});
crl::on_main([=] { callback(std::nullopt); });
}
void GetCapabilities(Fn<void(const QStringList &)> callback) {
@ -244,18 +245,14 @@ void GetCapabilities(Fn<void(const QStringList &)> callback) {
crl::on_main([=] {
callback(value);
});
return;
}, [&] {
crl::on_main([=] { callback({}); });
});
crl::on_main([=] { callback({}); });
},
std::string(kService));
return;
}, [&] {
crl::on_main([=] { callback({}); });
});
crl::on_main([=] { callback({}); });
}
void GetInhibited(Fn<void(bool)> callback) {
@ -287,18 +284,14 @@ void GetInhibited(Fn<void(bool)> callback) {
crl::on_main([=] {
callback(value);
});
return;
}, [&] {
crl::on_main([=] { callback(false); });
});
crl::on_main([=] { callback(false); });
},
std::string(kService));
return;
}, [&] {
crl::on_main([=] { callback(false); });
});
crl::on_main([=] { callback(false); });
}
ServerInformation CurrentServerInformationValue() {
@ -586,12 +579,11 @@ void NotificationData::show() {
crl::on_main(weak, [=] {
_notificationId = notificationId;
});
});
if (!_notificationId) {
}, [&] {
crl::on_main(weak, [=] {
_manager->clearNotification(_id);
});
}
});
},
std::string(kService));
}));