From 9d87fdf6dbed98492bfc215dcc18b027b7dbdba0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Artur=20=C5=9Awigo=C5=84?= Date: Tue, 15 Feb 2022 11:03:10 +0100 Subject: [PATCH] [AT-SPI] Add Socket interface Change-Id: I199c18011d24f7984e5f4cb95b5e626a418ab2ec --- .../adaptor-framework/accessibility-bridge.h | 7 ++ dali/devel-api/adaptor-framework/accessibility.cpp | 2 + dali/devel-api/atspi-interfaces/accessible.h | 10 ++- dali/devel-api/atspi-interfaces/socket.h | 77 ++++++++++++++++++++++ dali/devel-api/file.list | 1 + dali/internal/accessibility/bridge/accessible.cpp | 11 ++++ dali/internal/accessibility/bridge/bridge-impl.cpp | 5 +- .../accessibility/bridge/bridge-object.cpp | 15 +++++ dali/internal/accessibility/bridge/bridge-object.h | 5 ++ .../accessibility/bridge/bridge-socket.cpp | 47 +++++++++++++ dali/internal/accessibility/bridge/bridge-socket.h | 57 ++++++++++++++++ dali/internal/accessibility/bridge/dummy-atspi.cpp | 4 ++ dali/internal/accessibility/bridge/dummy-atspi.h | 4 ++ dali/internal/accessibility/file.list | 1 + 14 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 dali/devel-api/atspi-interfaces/socket.h create mode 100644 dali/internal/accessibility/bridge/bridge-socket.cpp create mode 100644 dali/internal/accessibility/bridge/bridge-socket.h diff --git a/dali/devel-api/adaptor-framework/accessibility-bridge.h b/dali/devel-api/adaptor-framework/accessibility-bridge.h index ba26501..a35fe31 100644 --- a/dali/devel-api/adaptor-framework/accessibility-bridge.h +++ b/dali/devel-api/adaptor-framework/accessibility-bridge.h @@ -249,6 +249,13 @@ struct DALI_ADAPTOR_API Bridge virtual void EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type) = 0; /** + * @brief Emits "org.a11y.atspi.Socket.Available" event on AT-SPI bus. + * + * @param obj Accessible object + */ + virtual void EmitSocketAvailable(Accessible* obj) = 0; + + /** * @brief Emits state-changed event on at-spi bus. * * @param[in] obj The accessible object diff --git a/dali/devel-api/adaptor-framework/accessibility.cpp b/dali/devel-api/adaptor-framework/accessibility.cpp index 196ab60..2a2088b 100644 --- a/dali/devel-api/adaptor-framework/accessibility.cpp +++ b/dali/devel-api/adaptor-framework/accessibility.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -238,6 +239,7 @@ AtspiInterfaces Accessible::DoGetInterfaces() const interfaces[AtspiInterface::HYPERLINK] = dynamic_cast(this); interfaces[AtspiInterface::HYPERTEXT] = dynamic_cast(this); interfaces[AtspiInterface::SELECTION] = dynamic_cast(this); + interfaces[AtspiInterface::SOCKET] = dynamic_cast(this); interfaces[AtspiInterface::TEXT] = dynamic_cast(this); interfaces[AtspiInterface::VALUE] = dynamic_cast(this); diff --git a/dali/devel-api/atspi-interfaces/accessible.h b/dali/devel-api/atspi-interfaces/accessible.h index b0b3ba1..c41f6bf 100644 --- a/dali/devel-api/atspi-interfaces/accessible.h +++ b/dali/devel-api/atspi-interfaces/accessible.h @@ -157,6 +157,14 @@ public: void EmitMovedOutOfScreen(ScreenRelativeMoveType type); /** + * @brief Emits "org.a11y.atspi.Socket.Available" signal. + */ + // This belongs to Dali::Accessibility::Socket. However, all Emit*() helpers + // are here in Accessible, regardless of what interface they belong to (perhaps + // to spare a dynamic_cast if used like this: Accessible::Get()->Emit*(...)). + void EmitSocketAvailable(); + + /** * @brief Emits "highlighted" event. * * @param[in] event The enumerated window event @@ -327,7 +335,7 @@ public: virtual std::vector GetRelationSet() = 0; /** - * @brief Gets internal Actor to be saved before. + * @brief Gets the Actor associated with this Accessible (if there is one). * * @return The internal Actor */ diff --git a/dali/devel-api/atspi-interfaces/socket.h b/dali/devel-api/atspi-interfaces/socket.h new file mode 100644 index 0000000..0e74694 --- /dev/null +++ b/dali/devel-api/atspi-interfaces/socket.h @@ -0,0 +1,77 @@ +#ifndef DALI_ADAPTOR_ATSPI_SOCKET_H +#define DALI_ADAPTOR_ATSPI_SOCKET_H + +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// INTERNAL INCLUDES +#include + +namespace Dali::Accessibility +{ +/** + * @brief A Socket is the root of the AT-SPI tree that can be embedded as a subtree + * in the tree belonging to another process (the Plug). The Plug initiates the Plug-Socket + * connection by calling Embed() and terminates it by calling Unembed(). + * + * See AT_SPI2_CORE/xml/Socket.xml for a description of this interface in XML format. + */ +class DALI_ADAPTOR_API Socket : public virtual Accessible +{ +public: + /** + * @brief Establishes the Plug-Socket connection. + * + * @param plug Address of the Plug (remote parent) + * @return Address of the Socket + */ + virtual Address Embed(Address plug) = 0; + + /** + * @brief Terminates the Plug-Socket connection. + * + * @param plug Address of the Plug (remote parent) + */ + virtual void Unembed(Address plug) = 0; + + /** + * @brief Downcasts an Accessible to a Socket. + * + * @param obj The Accessible + * @return A Socket or null + * + * @see Dali::Accessibility::Accessible::DownCast() + */ + static inline Socket* DownCast(Accessible* obj); +}; + +namespace Internal +{ +template<> +struct AtspiInterfaceTypeHelper +{ + using Type = Socket; +}; +} // namespace Internal + +inline Socket* Socket::DownCast(Accessible* obj) +{ + return Accessible::DownCast(obj); +} + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_SOCKET_H diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index 6719a2f..edef100 100755 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -151,6 +151,7 @@ SET( devel_api_atspi_interfaces_header_files ${adaptor_devel_api_dir}/atspi-interfaces/hyperlink.h ${adaptor_devel_api_dir}/atspi-interfaces/hypertext.h ${adaptor_devel_api_dir}/atspi-interfaces/selection.h + ${adaptor_devel_api_dir}/atspi-interfaces/socket.h ${adaptor_devel_api_dir}/atspi-interfaces/text.h ${adaptor_devel_api_dir}/atspi-interfaces/value.h ) diff --git a/dali/internal/accessibility/bridge/accessible.cpp b/dali/internal/accessibility/bridge/accessible.cpp index aaf2584..403bcc4 100644 --- a/dali/internal/accessibility/bridge/accessible.cpp +++ b/dali/internal/accessibility/bridge/accessible.cpp @@ -20,6 +20,7 @@ //INTERNAL INCLUDES #include #include +#include #include #include #include @@ -116,6 +117,16 @@ void Accessible::EmitMovedOutOfScreen(ScreenRelativeMoveType type) } } +void Accessible::EmitSocketAvailable() +{ + DALI_ASSERT_DEBUG(Socket::DownCast(this)); + + if(auto bridgeData = GetBridgeData()) + { + bridgeData->mBridge->EmitSocketAvailable(this); + } +} + void Accessible::Emit(WindowEvent event, unsigned int detail) { if(auto bridgeData = GetBridgeData()) diff --git a/dali/internal/accessibility/bridge/bridge-impl.cpp b/dali/internal/accessibility/bridge/bridge-impl.cpp index e5bc0ca..e2cb01c 100644 --- a/dali/internal/accessibility/bridge/bridge-impl.cpp +++ b/dali/internal/accessibility/bridge/bridge-impl.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -67,7 +68,8 @@ class BridgeImpl : public virtual BridgeBase, public BridgeSelection, public BridgeApplication, public BridgeHypertext, - public BridgeHyperlink + public BridgeHyperlink, + public BridgeSocket { DBus::DBusClient mAccessibilityStatusClient; DBus::DBusClient mRegistryClient; @@ -326,6 +328,7 @@ public: BridgeApplication::RegisterInterfaces(); BridgeHypertext::RegisterInterfaces(); BridgeHyperlink::RegisterInterfaces(); + BridgeSocket::RegisterInterfaces(); RegisterOnBridge(&mApplication); diff --git a/dali/internal/accessibility/bridge/bridge-object.cpp b/dali/internal/accessibility/bridge/bridge-object.cpp index fc1834b..3efe6cb 100644 --- a/dali/internal/accessibility/bridge/bridge-object.cpp +++ b/dali/internal/accessibility/bridge/bridge-object.cpp @@ -300,3 +300,18 @@ void BridgeObject::EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType {0}, {"", "root"}); } + +void BridgeObject::EmitSocketAvailable(Accessible* obj) +{ + if(!IsUp() || obj->IsHidden()) + { + return; + } + + mDbusServer.emit2( + GetAccessiblePath(obj), + Accessible::GetInterfaceName(AtspiInterface::SOCKET), + "Available", + obj->GetAddress(), + {"", "root"}); +} diff --git a/dali/internal/accessibility/bridge/bridge-object.h b/dali/internal/accessibility/bridge/bridge-object.h index 69ca828..7d402b1 100644 --- a/dali/internal/accessibility/bridge/bridge-object.h +++ b/dali/internal/accessibility/bridge/bridge-object.h @@ -85,6 +85,11 @@ protected: */ void EmitMovedOutOfScreen(Dali::Accessibility::Accessible* obj, Dali::Accessibility::ScreenRelativeMoveType type) override; + /** + * @copydoc Dali::Accessibility::Bridge::EmitSocketAvailable() + */ + void EmitSocketAvailable(Dali::Accessibility::Accessible* obj) override; + protected: DBus::DBusInterfaceDescription::SignalId mStateChanged; }; diff --git a/dali/internal/accessibility/bridge/bridge-socket.cpp b/dali/internal/accessibility/bridge/bridge-socket.cpp new file mode 100644 index 0000000..fdbae8c --- /dev/null +++ b/dali/internal/accessibility/bridge/bridge-socket.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +using namespace Dali::Accessibility; + +void BridgeSocket::RegisterInterfaces() +{ + DBus::DBusInterfaceDescription desc{Accessible::GetInterfaceName(AtspiInterface::SOCKET)}; + + AddFunctionToInterface(desc, "Embed", &BridgeSocket::Embed); + AddFunctionToInterface(desc, "Unembed", &BridgeSocket::Unembed); + + mDbusServer.addInterface("/", desc, true); +} + +Socket* BridgeSocket::FindSelf() const +{ + return FindCurrentObjectWithInterface(); +} + +DBus::ValueOrError
BridgeSocket::Embed(Address plug) +{ + return FindSelf()->Embed(plug); +} + +DBus::ValueOrError BridgeSocket::Unembed(Address plug) +{ + FindSelf()->Unembed(plug); + return {}; +} diff --git a/dali/internal/accessibility/bridge/bridge-socket.h b/dali/internal/accessibility/bridge/bridge-socket.h new file mode 100644 index 0000000..6034700 --- /dev/null +++ b/dali/internal/accessibility/bridge/bridge-socket.h @@ -0,0 +1,57 @@ +#ifndef DALI_INTERNAL_ACCESSIBILITY_BRIDGE_SOCKET_H +#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_SOCKET_H + +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include + +/** + * @brief The BridgeSocket class contains glue code for Accessibility::Socket. + */ +class BridgeSocket : public virtual BridgeBase +{ +protected: + BridgeSocket() = default; + + /** + * @brief Registers Socket methods as a DBus interface. + */ + void RegisterInterfaces(); + + /** + * @brief Returns the Socket object of the currently executed DBus method call. + * + * @return The Socket object + */ + Dali::Accessibility::Socket* FindSelf() const; + +public: + /** + * @copydoc Dali::Accessibility::Socket::Embed() + */ + DBus::ValueOrError Embed(Dali::Accessibility::Address plug); + + /** + * @copydoc Dali::Accessibility::Socket::Unembed() + */ + DBus::ValueOrError Unembed(Dali::Accessibility::Address plug); +}; + +#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_SOCKET_H diff --git a/dali/internal/accessibility/bridge/dummy-atspi.cpp b/dali/internal/accessibility/bridge/dummy-atspi.cpp index c37840d..3e6b302 100644 --- a/dali/internal/accessibility/bridge/dummy-atspi.cpp +++ b/dali/internal/accessibility/bridge/dummy-atspi.cpp @@ -132,6 +132,10 @@ void Accessibility::Accessible::EmitMovedOutOfScreen(Accessibility::ScreenRelati { } +void Accessibility::Accessible::EmitSocketAvailable() +{ +} + void Accessibility::Accessible::FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks) { } diff --git a/dali/internal/accessibility/bridge/dummy-atspi.h b/dali/internal/accessibility/bridge/dummy-atspi.h index 81b287d..4fd0678 100644 --- a/dali/internal/accessibility/bridge/dummy-atspi.h +++ b/dali/internal/accessibility/bridge/dummy-atspi.h @@ -122,6 +122,10 @@ struct DummyBridge : Dali::Accessibility::Bridge { } + void EmitSocketAvailable(Accessibility::Accessible* obj) override + { + } + void EmitStateChanged(Accessibility::Accessible* obj, Accessibility::State state, int newValue, int reserved) override { } diff --git a/dali/internal/accessibility/file.list b/dali/internal/accessibility/file.list index 59ffcc2..14a6ba8 100755 --- a/dali/internal/accessibility/file.list +++ b/dali/internal/accessibility/file.list @@ -61,6 +61,7 @@ SET( adaptor_accessibility_atspi_bridge_src_files ${adaptor_accessibility_dir}/bridge/bridge-impl.cpp ${adaptor_accessibility_dir}/bridge/bridge-object.cpp ${adaptor_accessibility_dir}/bridge/bridge-selection.cpp + ${adaptor_accessibility_dir}/bridge/bridge-socket.cpp ${adaptor_accessibility_dir}/bridge/bridge-text.cpp ${adaptor_accessibility_dir}/bridge/bridge-value.cpp ${adaptor_accessibility_dir}/bridge/component.cpp -- 2.7.4