From f23e372af133cfdcb1347bf5676bf74057828392 Mon Sep 17 00:00:00 2001 From: Wonki Kim Date: Tue, 23 Jun 2020 15:50:16 +0900 Subject: [PATCH] aurum: implement an atspi action for uiobject 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 | 12 ++++++ libaurum/inc/UiObject.h | 6 +++ libaurum/src/AccessibleNode.cc | 50 ++++++++++++++++++++++ libaurum/src/UiObject.cc | 6 +++ .../src/Commands/ClickCommand.cc | 16 ++++++- 5 files changed, 89 insertions(+), 1 deletion(-) diff --git a/libaurum/inc/AccessibleNode.h b/libaurum/inc/AccessibleNode.h index 2b1b3eb..11dfcc8 100644 --- a/libaurum/inc/AccessibleNode.h +++ b/libaurum/inc/AccessibleNode.h @@ -349,6 +349,12 @@ public: */ bool isActive() const; + /** + * @brief TBD + * @since_tizen 5.5 + */ + std::vector 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 diff --git a/libaurum/inc/UiObject.h b/libaurum/inc/UiObject.h index e83b384..b56470e 100644 --- a/libaurum/inc/UiObject.h +++ b/libaurum/inc/UiObject.h @@ -246,6 +246,12 @@ public: * @brief TBD * @since_tizen 5.5 */ + bool DoAtspiActivate() const; + + /** + * @brief TBD + * @since_tizen 5.5 + */ void refresh() const; private: diff --git a/libaurum/src/AccessibleNode.cc b/libaurum/src/AccessibleNode.cc index 3ec0d33..dd07b01 100644 --- a/libaurum/src/AccessibleNode.cc +++ b/libaurum/src/AccessibleNode.cc @@ -1,6 +1,7 @@ #include "AccessibleNode.h" #include #include +#include #include #include "config.h" @@ -405,3 +406,52 @@ void AccessibleNode::setValue(std::string text) const NULL); } } + +std::vector AccessibleNode::getActions() const +{ + std::vector 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 diff --git a/libaurum/src/UiObject.cc b/libaurum/src/UiObject.cc index 67691c4..12502cb 100644 --- a/libaurum/src/UiObject.cc +++ b/libaurum/src/UiObject.cc @@ -244,6 +244,12 @@ void UiObject::longClick(const unsigned int intv) const const_cast(mDevice)->click(midPoint.x, midPoint.y, intv); } +bool UiObject::DoAtspiActivate() const +{ + return mNode->doAction("activate"); +} + + const AccessibleNode *UiObject::getAccessibleNode() const { if (mNode == nullptr) throw; diff --git a/org.tizen.aurum-bootstrap/src/Commands/ClickCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/ClickCommand.cc index ab67763..2b152e1 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/ClickCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/ClickCommand.cc @@ -34,6 +34,7 @@ std::unique_ptr 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::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::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; } -- 2.7.4