[AT-SPI] Add Socket interface 55/260855/12
authorArtur Świgoń <a.swigon@samsung.com>
Tue, 15 Feb 2022 10:03:10 +0000 (11:03 +0100)
committerArtur Świgoń <a.swigon@samsung.com>
Thu, 24 Feb 2022 15:15:55 +0000 (16:15 +0100)
Change-Id: I199c18011d24f7984e5f4cb95b5e626a418ab2ec

14 files changed:
dali/devel-api/adaptor-framework/accessibility-bridge.h
dali/devel-api/adaptor-framework/accessibility.cpp
dali/devel-api/atspi-interfaces/accessible.h
dali/devel-api/atspi-interfaces/socket.h [new file with mode: 0644]
dali/devel-api/file.list
dali/internal/accessibility/bridge/accessible.cpp
dali/internal/accessibility/bridge/bridge-impl.cpp
dali/internal/accessibility/bridge/bridge-object.cpp
dali/internal/accessibility/bridge/bridge-object.h
dali/internal/accessibility/bridge/bridge-socket.cpp [new file with mode: 0644]
dali/internal/accessibility/bridge/bridge-socket.h [new file with mode: 0644]
dali/internal/accessibility/bridge/dummy-atspi.cpp
dali/internal/accessibility/bridge/dummy-atspi.h
dali/internal/accessibility/file.list

index ba26501..a35fe31 100644 (file)
@@ -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
index 196ab60..2a2088b 100644 (file)
@@ -39,6 +39,7 @@
 #include <dali/devel-api/atspi-interfaces/hyperlink.h>
 #include <dali/devel-api/atspi-interfaces/hypertext.h>
 #include <dali/devel-api/atspi-interfaces/selection.h>
+#include <dali/devel-api/atspi-interfaces/socket.h>
 #include <dali/devel-api/atspi-interfaces/text.h>
 #include <dali/devel-api/atspi-interfaces/value.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
@@ -238,6 +239,7 @@ AtspiInterfaces Accessible::DoGetInterfaces() const
   interfaces[AtspiInterface::HYPERLINK]     = dynamic_cast<const Hyperlink*>(this);
   interfaces[AtspiInterface::HYPERTEXT]     = dynamic_cast<const Hypertext*>(this);
   interfaces[AtspiInterface::SELECTION]     = dynamic_cast<const Selection*>(this);
+  interfaces[AtspiInterface::SOCKET]        = dynamic_cast<const Socket*>(this);
   interfaces[AtspiInterface::TEXT]          = dynamic_cast<const Text*>(this);
   interfaces[AtspiInterface::VALUE]         = dynamic_cast<const Value*>(this);
 
index b0b3ba1..c41f6bf 100644 (file)
@@ -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<Relation> 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 (file)
index 0000000..0e74694
--- /dev/null
@@ -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 <dali/devel-api/atspi-interfaces/accessible.h>
+
+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<AtspiInterface::SOCKET>
+{
+  using Type = Socket;
+};
+} // namespace Internal
+
+inline Socket* Socket::DownCast(Accessible* obj)
+{
+  return Accessible::DownCast<AtspiInterface::SOCKET>(obj);
+}
+
+} // namespace Dali::Accessibility
+
+#endif // DALI_ADAPTOR_ATSPI_SOCKET_H
index 6719a2f..edef100 100755 (executable)
@@ -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
 )
index aaf2584..403bcc4 100644 (file)
@@ -20,6 +20,7 @@
 //INTERNAL INCLUDES
 #include <dali/devel-api/atspi-interfaces/accessible.h>
 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
+#include <dali/devel-api/atspi-interfaces/socket.h>
 #include <dali/internal/accessibility/bridge/accessibility-common.h>
 #include <third-party/libunibreak/linebreak.h>
 #include <third-party/libunibreak/wordbreak.h>
@@ -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())
index e5bc0ca..e2cb01c 100644 (file)
@@ -36,6 +36,7 @@
 #include <dali/internal/accessibility/bridge/bridge-hyperlink.h>
 #include <dali/internal/accessibility/bridge/bridge-object.h>
 #include <dali/internal/accessibility/bridge/bridge-selection.h>
+#include <dali/internal/accessibility/bridge/bridge-socket.h>
 #include <dali/internal/accessibility/bridge/bridge-text.h>
 #include <dali/internal/accessibility/bridge/bridge-value.h>
 #include <dali/internal/accessibility/bridge/bridge-application.h>
@@ -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);
 
index fc1834b..3efe6cb 100644 (file)
@@ -300,3 +300,18 @@ void BridgeObject::EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType
     {0},
     {"", "root"});
 }
+
+void BridgeObject::EmitSocketAvailable(Accessible* obj)
+{
+  if(!IsUp() || obj->IsHidden())
+  {
+    return;
+  }
+
+  mDbusServer.emit2<Address, Address>(
+    GetAccessiblePath(obj),
+    Accessible::GetInterfaceName(AtspiInterface::SOCKET),
+    "Available",
+    obj->GetAddress(),
+    {"", "root"});
+}
index 69ca828..7d402b1 100644 (file)
@@ -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 (file)
index 0000000..fdbae8c
--- /dev/null
@@ -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 <dali/internal/accessibility/bridge/bridge-socket.h>
+
+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<Dali::Accessibility::AtspiInterface::SOCKET>();
+}
+
+DBus::ValueOrError<Address> BridgeSocket::Embed(Address plug)
+{
+  return FindSelf()->Embed(plug);
+}
+
+DBus::ValueOrError<void> 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 (file)
index 0000000..6034700
--- /dev/null
@@ -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 <dali/devel-api/atspi-interfaces/socket.h>
+#include <dali/internal/accessibility/bridge/bridge-base.h>
+
+/**
+ * @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<Dali::Accessibility::Address> Embed(Dali::Accessibility::Address plug);
+
+  /**
+   * @copydoc Dali::Accessibility::Socket::Unembed()
+   */
+  DBus::ValueOrError<void> Unembed(Dali::Accessibility::Address plug);
+};
+
+#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_SOCKET_H
index c37840d..3e6b302 100644 (file)
@@ -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)
 {
 }
index 81b287d..4fd0678 100644 (file)
@@ -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
   {
   }
index 59ffcc2..14a6ba8 100755 (executable)
@@ -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