-
Notifications
You must be signed in to change notification settings - Fork 9
Replace eldbus with gdbus #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,44 +22,65 @@ constexpr char kAtspiDirectReadInterface[] = "org.tizen.DirectReading"; | |
|
|
||
| } // namespace | ||
|
|
||
| static void _accessibilityBusAddressGet(void* data, | ||
| const Eldbus_Message* message, | ||
| Eldbus_Pending* pending) { | ||
| Eldbus_Connection** accessibility_bus = | ||
| static_cast<Eldbus_Connection**>(data); | ||
| const char* error_name = nullptr; | ||
| const char* error_message = nullptr; | ||
| const char* socket_address = nullptr; | ||
|
|
||
| if (eldbus_message_error_get(message, &error_name, &error_message)) { | ||
| FT_LOG(Error) << "Eldbus message error. (" << error_name << " : " | ||
| << error_message << ")"; | ||
| static void _accessibilityBusAddressGet(GObject* source_object, | ||
| GAsyncResult* res, | ||
| gpointer user_data) { | ||
| g_autoptr(GError) error = nullptr; | ||
| g_autoptr(GVariant) result = nullptr; | ||
| GDBusConnection** accessibility_bus = | ||
| static_cast<GDBusConnection**>(user_data); | ||
|
|
||
| GDBusProxy* proxy = G_DBUS_PROXY(source_object); | ||
| result = g_dbus_proxy_call_finish(proxy, res, &error); | ||
|
|
||
| if (error) { | ||
| FT_LOG(Error) << "GDBus message error: " << error->message; | ||
| return; | ||
| } | ||
|
|
||
| if (!eldbus_message_arguments_get(message, "s", &socket_address) || | ||
| !socket_address) { | ||
| const gchar* socket_address = nullptr; | ||
| if (g_variant_is_of_type(result, G_VARIANT_TYPE("(s)"))) { | ||
| g_variant_get(result, "(&s)", &socket_address); | ||
| } | ||
|
|
||
| if (!socket_address) { | ||
| FT_LOG(Error) << "Could not get A11Y Bus socket address."; | ||
| return; | ||
| } | ||
| *accessibility_bus = eldbus_private_address_connection_get(socket_address); | ||
|
|
||
| *accessibility_bus = g_dbus_connection_new_for_address_sync( | ||
| socket_address, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, nullptr, | ||
| nullptr, &error); | ||
|
|
||
| if (error) { | ||
| FT_LOG(Error) << "Failed to connect to A11Y Bus: " << error->message; | ||
| } | ||
| } | ||
|
|
||
| AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger) | ||
| : channel_(std::make_unique<BasicMessageChannel<EncodableValue>>( | ||
| messenger, | ||
| kChannelName, | ||
| &StandardMessageCodec::GetInstance())) { | ||
| eldbus_init(); | ||
| g_autoptr(GError) error = nullptr; | ||
| session_bus_ = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error); | ||
| if (error) { | ||
| FT_LOG(Error) << "Failed to get session bus: " << error->message; | ||
| return; | ||
| } | ||
|
|
||
| session_bus_ = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); | ||
| bus_ = eldbus_object_get(session_bus_, kAccessibilityDbus, | ||
| kAccessibilityDbusPath); | ||
| bus_ = g_dbus_proxy_new_sync(session_bus_, G_DBUS_PROXY_FLAGS_NONE, nullptr, | ||
| kAccessibilityDbus, kAccessibilityDbusPath, | ||
| kAccessibilityDbusInterface, nullptr, &error); | ||
|
|
||
| Eldbus_Message* method = eldbus_object_method_call_new( | ||
| bus_, kAccessibilityDbusInterface, "GetAddress"); | ||
| eldbus_object_send(bus_, method, _accessibilityBusAddressGet, | ||
| &accessibility_bus_, 100); | ||
| if (error) { | ||
| FT_LOG(Error) << "Failed to create proxy: " << error->message; | ||
| return; | ||
| } | ||
|
|
||
| g_dbus_proxy_call(bus_, "GetAddress", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, | ||
| nullptr, (GAsyncReadyCallback)_accessibilityBusAddressGet, | ||
| &accessibility_bus_); | ||
|
|
||
| channel_->SetMessageHandler([&](const auto& message, auto reply) { | ||
| if (std::holds_alternative<EncodableMap>(message)) { | ||
|
|
@@ -72,14 +93,11 @@ AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger) | |
| if (*type == "announce" && data) { | ||
| EncodableValueHolder<std::string> msg(data.value, "message"); | ||
| if (msg && accessibility_bus_) { | ||
| Eldbus_Message* eldbus_message = eldbus_message_method_call_new( | ||
| kAtspiDirectReadBus, kAtspiDirectReadPath, | ||
| kAtspiDirectReadInterface, "ReadCommand"); | ||
| Eldbus_Message_Iter* iter = eldbus_message_iter_get(eldbus_message); | ||
| eldbus_message_iter_arguments_append(iter, "sb", msg->c_str(), | ||
| true); | ||
| eldbus_connection_send(accessibility_bus_, eldbus_message, nullptr, | ||
| nullptr, -1); | ||
| GVariant* params = g_variant_new("(sb)", msg->c_str(), TRUE); | ||
| g_dbus_connection_call( | ||
| accessibility_bus_, kAtspiDirectReadBus, kAtspiDirectReadPath, | ||
| kAtspiDirectReadInterface, "ReadCommand", params, nullptr, | ||
| G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr, nullptr); | ||
|
Comment on lines
94
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| } | ||
| } | ||
| } | ||
|
|
@@ -91,11 +109,20 @@ AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger) | |
| AccessibilityChannel::~AccessibilityChannel() { | ||
| channel_->SetMessageHandler(nullptr); | ||
|
|
||
| eldbus_connection_unref(accessibility_bus_); | ||
| eldbus_connection_unref(session_bus_); | ||
| eldbus_object_unref(bus_); | ||
| if (accessibility_bus_) { | ||
| g_object_unref(accessibility_bus_); | ||
| accessibility_bus_ = nullptr; | ||
| } | ||
|
|
||
| eldbus_shutdown(); | ||
| if (session_bus_) { | ||
| g_object_unref(session_bus_); | ||
| session_bus_ = nullptr; | ||
| } | ||
|
|
||
| if (bus_) { | ||
| g_object_unref(bus_); | ||
| bus_ = nullptr; | ||
| } | ||
| } | ||
|
|
||
| } // namespace flutter | ||
Uh oh!
There was an error while loading. Please reload this page.