Line length clean up in notifications_manager_linux

This commit is contained in:
Ilya Fedin 2023-10-02 15:47:15 +04:00 committed by John Preston
parent 5c4f006550
commit a757e07c3a

View File

@ -42,6 +42,8 @@ constexpr auto kObjectPath = "/org/freedesktop/Notifications";
constexpr auto kInterface = kService; constexpr auto kInterface = kService;
constexpr auto kPropertiesInterface = "org.freedesktop.DBus.Properties"; constexpr auto kPropertiesInterface = "org.freedesktop.DBus.Properties";
using PropertyMap = std::map<Glib::ustring, Glib::VariantBase>;
struct ServerInformation { struct ServerInformation {
Glib::ustring name; Glib::ustring name;
Glib::ustring vendor; Glib::ustring vendor;
@ -123,7 +125,8 @@ void StartServiceAsync(Fn<void()> callback) {
}; };
const auto errorName = const auto errorName =
Gio::DBus::ErrorUtils::get_remote_error(e).raw(); Gio::DBus::ErrorUtils::get_remote_error(e)
.raw();
if (!ranges::contains( if (!ranges::contains(
NotSupportedErrors, NotSupportedErrors,
@ -192,21 +195,21 @@ void GetServerInformation(Fn<void(const ServerInformation &)> callback) {
Noexcept([&] { Noexcept([&] {
const auto reply = connection->call_finish(result); const auto reply = connection->call_finish(result);
const auto name = reply.get_child( const auto name = reply
0 .get_child(0)
).get_dynamic<Glib::ustring>(); .get_dynamic<Glib::ustring>();
const auto vendor = reply.get_child( const auto vendor = reply
1 .get_child(1)
).get_dynamic<Glib::ustring>(); .get_dynamic<Glib::ustring>();
const auto version = reply.get_child( const auto version = reply
2 .get_child(2)
).get_dynamic<Glib::ustring>(); .get_dynamic<Glib::ustring>();
const auto specVersion = reply.get_child( const auto specVersion = reply
3 .get_child(3)
).get_dynamic<Glib::ustring>(); .get_dynamic<Glib::ustring>();
callback(ServerInformation{ callback(ServerInformation{
name, name,
@ -241,11 +244,9 @@ void GetCapabilities(Fn<void(const std::vector<Glib::ustring> &)> callback) {
Core::Sandbox::Instance().customEnterFromEventLoop([&] { Core::Sandbox::Instance().customEnterFromEventLoop([&] {
Noexcept([&] { Noexcept([&] {
callback( callback(
connection->call_finish( connection->call_finish(result)
result .get_child(0)
).get_child( .get_dynamic<std::vector<Glib::ustring>>()
0
).get_dynamic<std::vector<Glib::ustring>>()
); );
}, [&] { }, [&] {
callback({}); callback({});
@ -275,12 +276,10 @@ void GetInhibited(Fn<void(bool)> callback) {
Core::Sandbox::Instance().customEnterFromEventLoop([&] { Core::Sandbox::Instance().customEnterFromEventLoop([&] {
Noexcept([&] { Noexcept([&] {
callback( callback(
connection->call_finish( connection->call_finish(result)
result .get_child(0)
).get_child( .get_dynamic<Glib::Variant<bool>>()
0 .get()
).get_dynamic<Glib::Variant<bool>>(
).get()
); );
}, [&] { }, [&] {
callback(false); callback(false);
@ -458,35 +457,43 @@ bool NotificationData::init(
Core::Sandbox::Instance().customEnterFromEventLoop([&] { Core::Sandbox::Instance().customEnterFromEventLoop([&] {
Noexcept([&] { Noexcept([&] {
if (signal_name == "ActionInvoked") { if (signal_name == "ActionInvoked") {
const auto id = parameters.get_child(0).get_dynamic<uint>(); const auto id = parameters
.get_child(0)
.get_dynamic<uint>();
const auto actionName = parameters.get_child( const auto actionName = parameters
1 .get_child(1)
).get_dynamic<Glib::ustring>(); .get_dynamic<Glib::ustring>();
actionInvoked(id, actionName); actionInvoked(id, actionName);
} else if (signal_name == "ActivationToken") { } else if (signal_name == "ActivationToken") {
const auto id = parameters.get_child(0).get_dynamic<uint>(); const auto id = parameters
.get_child(0)
.get_dynamic<uint>();
const auto token = parameters.get_child( const auto token = parameters
1 .get_child(1)
).get_dynamic<Glib::ustring>(); .get_dynamic<Glib::ustring>();
activationToken(id, token); activationToken(id, token);
} else if (signal_name == "NotificationReplied") { } else if (signal_name == "NotificationReplied") {
const auto id = parameters.get_child(0).get_dynamic<uint>(); const auto id = parameters
.get_child(0)
.get_dynamic<uint>();
const auto text = parameters.get_child( const auto text = parameters
1 .get_child(1)
).get_dynamic<Glib::ustring>(); .get_dynamic<Glib::ustring>();
notificationReplied(id, text); notificationReplied(id, text);
} else if (signal_name == "NotificationClosed") { } else if (signal_name == "NotificationClosed") {
const auto id = parameters.get_child(0).get_dynamic<uint>(); const auto id = parameters
.get_child(0)
.get_dynamic<uint>();
const auto reason = parameters.get_child( const auto reason = parameters
1 .get_child(1)
).get_dynamic<uint>(); .get_dynamic<uint>();
notificationClosed(id, reason); notificationClosed(id, reason);
} }
@ -637,14 +644,13 @@ void NotificationData::show() {
_hints, _hints,
-1, -1,
}), }),
crl::guard(weak, [=](const Glib::RefPtr<Gio::AsyncResult> &result) { crl::guard(weak, [=](
const Glib::RefPtr<Gio::AsyncResult> &result) {
Core::Sandbox::Instance().customEnterFromEventLoop([&] { Core::Sandbox::Instance().customEnterFromEventLoop([&] {
Noexcept([&] { Noexcept([&] {
_notificationId = connection->call_finish( _notificationId = connection->call_finish(result)
result .get_child(0)
).get_child( .get_dynamic<uint>();
0
).get_dynamic<uint>();
}, [&] { }, [&] {
_manager->clearNotification(_id); _manager->clearNotification(_id);
}); });
@ -966,20 +972,19 @@ Manager::Private::Private(not_null<Manager*> manager)
const Glib::VariantContainerBase &parameters) { const Glib::VariantContainerBase &parameters) {
Core::Sandbox::Instance().customEnterFromEventLoop([&] { Core::Sandbox::Instance().customEnterFromEventLoop([&] {
Noexcept([&] { Noexcept([&] {
const auto interface = parameters.get_child( const auto interface = parameters
0 .get_child(0)
).get_dynamic<Glib::ustring>(); .get_dynamic<Glib::ustring>();
if (interface != kInterface) { if (interface != kInterface) {
return; return;
} }
_inhibited = parameters.get_child( _inhibited = parameters
1 .get_child(1)
).get_dynamic<std::map<Glib::ustring, Glib::VariantBase>>( .get_dynamic<PropertyMap>()
).at( .at("Inhibited")
"Inhibited" .get_dynamic<bool>();
).get_dynamic<bool>();
}); });
}); });
}), }),