aurum: implement an atspi action for uiobject
authorWonki Kim <wonki_.kim@samsung.com>
Tue, 23 Jun 2020 06:50:16 +0000 (15:50 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Sun, 28 Jun 2020 23:59:14 +0000 (08:59 +0900)
atspi accessible object has an "action" interface.
and it is used for invoking event such as "click" for an object through atspi.
this patch implement an atspi action for uiobject

Change-Id: I9289ccfb6bfd0fe994f08fd8dff57fd94603a890

libaurum/inc/AccessibleNode.h
libaurum/inc/UiObject.h
libaurum/src/AccessibleNode.cc
libaurum/src/UiObject.cc
org.tizen.aurum-bootstrap/src/Commands/ClickCommand.cc

index 2b1b3ebe4ba706cd2040eb28f0c23ce87c3ac160..11dfcc8233bcb5158d28954c43abd263ffe78981 100644 (file)
@@ -349,6 +349,12 @@ public:
      */
     bool isActive() const;
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::vector<std::string> getActions() const;
+
 public:
     /**
      * @brief TBD
@@ -374,6 +380,12 @@ public:
      */
     void setValue(std::string text) const;
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    bool doAction(std::string action) const;
+
 private:
     /**
      * @brief TBD
index e83b3843a7ad125f14dd495008cc4d703ac2c87e..b56470ec370f1d3c33c20de11741c37159f55066 100644 (file)
@@ -242,6 +242,12 @@ public:
      */
     void longClick(const unsigned int intv = LOGNCLICK_INTERVAL) const;
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    bool DoAtspiActivate() const;
+
     /**
      * @brief TBD
      * @since_tizen 5.5
index 3ec0d33a71e7c8294376389a2227e04a851476b1..dd07b01ca55c2335818177e084b108fa6e980d61 100644 (file)
@@ -1,6 +1,7 @@
 #include "AccessibleNode.h"
 #include <string.h>
 #include <iostream>
+#include <vector>
 
 #include <loguru.hpp>
 #include "config.h"
@@ -405,3 +406,52 @@ void AccessibleNode::setValue(std::string text) const
                                         NULL);
     }
 }
+
+std::vector<std::string> AccessibleNode::getActions() const
+{
+    std::vector<std::string> result{};
+    const char *name;
+    AtspiAction *action;
+
+    action = atspi_accessible_get_action_iface(mNode.get());
+    if (action) {
+        int a;
+        int n_actions = atspi_action_get_n_actions(action, NULL);
+
+        for (a = 0; a < n_actions; a++) {
+            char *action_name = atspi_action_get_action_name(action, a, NULL);
+            if (!action_name) continue;
+            result.push_back(std::string{action_name});
+            g_free(action_name);
+        }
+        g_object_unref(action);
+    }
+    return result;
+}
+
+bool AccessibleNode::doAction(std::string actionName) const
+{
+    const char *name;
+    AtspiAction *action;
+
+    action = atspi_accessible_get_action_iface(mNode.get());
+    if (action) {
+        int a;
+        int n_actions = atspi_action_get_n_actions(action, NULL);
+
+        for (a = 0; a < n_actions; a++) {
+            char *action_name = atspi_action_get_action_name(action, a, NULL);
+            if (!action_name) return false;
+
+            if (!strcmp(actionName.c_str(), action_name)) {
+                atspi_action_do_action(action, a, NULL);
+                g_free(action_name);
+                g_object_unref(action);
+                return true;
+            }
+            g_free(action_name);
+        }
+        g_object_unref(action);
+    }
+    return false;
+}
\ No newline at end of file
index 67691c46627c52f959455ed01a8ef98417adcfaa..12502cb203bdcc51d726c1fabf65cb1e6a5d3692 100644 (file)
@@ -244,6 +244,12 @@ void UiObject::longClick(const unsigned int intv) const
     const_cast<UiDevice *>(mDevice)->click(midPoint.x, midPoint.y, intv);
 }
 
+bool UiObject::DoAtspiActivate() const
+{
+    return mNode->doAction("activate");
+}
+
+
 const AccessibleNode *UiObject::getAccessibleNode() const
 {
     if (mNode == nullptr) throw;
index ab67763d9f3aeda749875e0d8dd096b264427cf7..2b152e15643446854dbe952507822e2635814970 100644 (file)
@@ -34,6 +34,7 @@ std::unique_ptr<ClickCommand> ClickCommand::createCommand(const ::aurum::ReqClic
 {
     ObjectMapper* mObjMap = ObjectMapper::getInstance();
     UiObject* obj = mObjMap->getElement(mRequest->elementid());
+    LOG_SCOPE_F(INFO, "ClickElementCommand execute %p", obj);
 
     if (obj) {
         obj->click();
@@ -48,6 +49,7 @@ std::unique_ptr<ClickCommand> ClickCommand::createCommand(const ::aurum::ReqClic
 {
     UiDevice* obj = UiDevice::getInstance(DeviceType::DEFAULT);
     const ::aurum::Point& point = mRequest->coordination();
+    LOG_SCOPE_F(INFO, "ClickCoordCommand execute %p @ (%d, %d)", obj, point.x(), point.y());
     obj->click(point.x(), point.y());
     mResponse->set_status(::aurum::RspStatus::OK);
     return grpc::Status::OK;
@@ -55,5 +57,17 @@ std::unique_ptr<ClickCommand> ClickCommand::createCommand(const ::aurum::ReqClic
 
 ::grpc::Status ClickAtspiCommand::execute()
 {
-    return grpc::Status::CANCELLED;
+    ObjectMapper* mObjMap = ObjectMapper::getInstance();
+    UiObject* obj = mObjMap->getElement(mRequest->elementid());
+
+    LOG_SCOPE_F(INFO, "ClickAtspiCommand execute %p", obj);
+
+    if (obj) {
+        if (obj->DoAtspiActivate()) mResponse->set_status(::aurum::RspStatus::OK);
+        else mResponse->set_status(::aurum::RspStatus::ERROR);
+    } else {
+        mResponse->set_status(::aurum::RspStatus::ERROR);
+    }
+
+    return grpc::Status::OK;
 }