libaurum: Introduce next/prev/first/last API 68/309968/5
authorHosang Kim <hosang12.kim@samsung.com>
Thu, 18 Apr 2024 11:09:44 +0000 (20:09 +0900)
committerHosang Kim <hosang12.kim@samsung.com>
Mon, 22 Apr 2024 07:26:55 +0000 (16:26 +0900)
Change-Id: Icbf4fda7c3bdf799bc02c5f332ca32bdb7fa5e57

22 files changed:
libaurum/inc/Accessibility/AccessibleNode.h
libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h
libaurum/inc/Impl/Accessibility/AtspiWrapper.h
libaurum/inc/Impl/Accessibility/MockAccessibleNode.h
libaurum/inc/UiObject.h
libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc
libaurum/src/Impl/Accessibility/AtspiWrapper.cc
libaurum/src/Impl/Accessibility/MockAccessibleNode.cc
libaurum/src/UiObject.cc
org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h
org.tizen.aurum-bootstrap/inc/Commands/Commands.h
org.tizen.aurum-bootstrap/inc/Commands/FirstCommand.h [new file with mode: 0644]
org.tizen.aurum-bootstrap/inc/Commands/LastCommand.h [new file with mode: 0644]
org.tizen.aurum-bootstrap/inc/Commands/NextCommand.h [new file with mode: 0644]
org.tizen.aurum-bootstrap/inc/Commands/PrevCommand.h [new file with mode: 0644]
org.tizen.aurum-bootstrap/meson.build
org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc
org.tizen.aurum-bootstrap/src/Commands/FirstCommand.cc [new file with mode: 0644]
org.tizen.aurum-bootstrap/src/Commands/LastCommand.cc [new file with mode: 0644]
org.tizen.aurum-bootstrap/src/Commands/NextCommand.cc [new file with mode: 0644]
org.tizen.aurum-bootstrap/src/Commands/PrevCommand.cc [new file with mode: 0644]
protocol/aurum.proto

index 9a8766d3c2516d77a99a936173b75c07e7bc2194..bee5e665107c472b278edfb91c86255ed7617e01 100644 (file)
@@ -141,6 +141,26 @@ public:
      */
     virtual std::vector<std::shared_ptr<AccessibleNode>> getMatchesInMatches(const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool ealryReturn) const = 0;
 
+    /**
+     * @copydoc UiObject::next()
+     */
+    virtual std::shared_ptr<AccessibleNode> next() const = 0;
+
+    /**
+     * @copydoc UiObject::prev()
+     */
+    virtual std::shared_ptr<AccessibleNode> prev() const = 0;
+
+    /**
+     * @copydoc UiObject::first()
+     */
+    virtual std::shared_ptr<AccessibleNode> first() const = 0;
+
+    /**
+     * @copydoc UiObject::last()
+     */
+    virtual std::shared_ptr<AccessibleNode> last() const = 0;
+
     /**
      * @brief Called by @AccessibleWatcher::notifyAll.
      *        Changes Node property If it's @EventType, @ObjectEventType are matches.
index 33d03d2b5f079420b43660f247358c332a7b21ee..98b1bf7839bf536e7f031379b409bb3aaaf8ad58 100644 (file)
@@ -80,6 +80,26 @@ public:
      */
     std::vector<std::shared_ptr<AccessibleNode>> getMatchesInMatches(const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool ealryReturn) const override;
 
+    /**
+     * @copydoc UiObject::next()
+     */
+    std::shared_ptr<AccessibleNode> next() const override;
+
+        /**
+     * @copydoc UiObject::prev()
+     */
+    std::shared_ptr<AccessibleNode> prev() const override;
+
+        /**
+     * @copydoc UiObject::first()
+     */
+    std::shared_ptr<AccessibleNode> first() const override;
+
+        /**
+     * @copydoc UiObject::last()
+     */
+    std::shared_ptr<AccessibleNode> last() const override;
+
     /**
      * @copydoc AccessibleNode::isValid()
      */
index 38022ea09b526bfe05cb294013f8b8d685de29f0..764c7d3e5fedd5e351f6791f10b36e4c4a1c00a9 100644 (file)
@@ -78,6 +78,7 @@ public:
     static GArray *Atspi_collection_get_matches_in_matches(AtspiCollection *obj, AtspiMatchRule *first_rule, AtspiMatchRule *second_rule, AtspiCollectionSortOrder sortby, gint first_count, gint second_count, gboolean traverse, GError **error);
     static AtspiAccessibleNodeInfo *Atspi_accessible_get_node_info(AtspiAccessible *obj, GError **error);
     static void Atspi_accessible_free_node_info(AtspiAccessibleNodeInfo *node_info);
+    static AtspiAccessible *Atspi_accessible_get_neighbor(AtspiAccessible *root, AtspiAccessible *start, AtspiNeighborSearchDirection direction, GError **error);
 
 private:
     static std::recursive_mutex mMutex;
index 8c137104ca3d122e0ec44f1a6d07933ba7425e07..3a0714a444040cb7e3ff2e15292f8ede8f10cf72 100644 (file)
@@ -79,6 +79,26 @@ public:
      */
     std::vector<std::shared_ptr<AccessibleNode>> getMatchesInMatches(const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool ealryReturn) const override;
 
+    /**
+     * @copydoc UiObject::next()
+     */
+    std::shared_ptr<AccessibleNode> next() const override;
+
+    /**
+     * @copydoc UiObject::prev()
+     */
+    std::shared_ptr<AccessibleNode> prev() const override;
+
+    /**
+     * @copydoc UiObject::first()
+     */
+    std::shared_ptr<AccessibleNode> first() const override;
+
+    /**
+     * @copydoc UiObject::last()
+     */
+    std::shared_ptr<AccessibleNode> last() const override;
+
 public:
     /**
      * @brief TBD
index 51f58a948d3886e3d3fcbdfad523c3524ceb753b..18046dab2787688573e3ebd2697ccc8ffa691629 100644 (file)
@@ -723,6 +723,42 @@ public:
      */
     std::shared_ptr<AccessibleNode> getAccessibleNode() const;
 
+    /**
+     * @brief Gets object's next.
+     *
+     * @return UiObject pointer
+     *
+     * @since_tizen 9.0
+     */
+    std::shared_ptr<UiObject> next() const;
+
+    /**
+     * @brief Gets object's prev.
+     *
+     * @return UiObject pointer
+     *
+     * @since_tizen 9.0
+     */
+    std::shared_ptr<UiObject> prev() const;
+
+    /**
+     * @brief Gets object's first.
+     *
+     * @return UiObject pointer
+     *
+     * @since_tizen 9.0
+     */
+    std::shared_ptr<UiObject> first() const;
+
+    /**
+     * @brief Gets object's last.
+     *
+     * @return UiObject pointer
+     *
+     * @since_tizen 9.0
+     */
+    std::shared_ptr<UiObject> last() const;
+
 private:
     std::shared_ptr<UiDevice> mDevice;
     std::shared_ptr<UiSelector>  mSelector;
index 451946b97d606c37f0e5429cd6bfc30700e59e64..1152510c4e4650bc0717480a966cb6f800462274 100644 (file)
@@ -680,3 +680,69 @@ std::vector<std::shared_ptr<AccessibleNode>> AtspiAccessibleNode::getMatchesInMa
 
     return ret;
 }
+
+std::shared_ptr<AccessibleNode> AtspiAccessibleNode::next() const
+{
+    if (!isValid()) {
+        return nullptr;
+    }
+    AtspiAccessible *app = AtspiWrapper::Atspi_accessible_get_application(mNode, NULL);
+    if (app) {
+        AtspiAccessible *next = AtspiWrapper::Atspi_accessible_get_neighbor(app, mNode, ATSPI_NEIGHBOR_SEARCH_FORWARD, NULL);
+        if (!next) {
+            next =  AtspiWrapper::Atspi_accessible_get_neighbor(app, NULL, ATSPI_NEIGHBOR_SEARCH_FORWARD, NULL);
+        }
+        g_object_unref(app);
+        if (next) return std::make_shared<AtspiAccessibleNode>(next);
+    }
+
+    return nullptr;
+}
+
+std::shared_ptr<AccessibleNode> AtspiAccessibleNode::prev() const
+{
+    if (!isValid()) {
+        return nullptr;
+    }
+    AtspiAccessible *app = AtspiWrapper::Atspi_accessible_get_application(mNode, NULL);
+    if (app) {
+        AtspiAccessible *prev = AtspiWrapper::Atspi_accessible_get_neighbor(app, mNode, ATSPI_NEIGHBOR_SEARCH_BACKWARD, NULL);
+        if (!prev) {
+            prev = AtspiWrapper::Atspi_accessible_get_neighbor(app, NULL, ATSPI_NEIGHBOR_SEARCH_BACKWARD, NULL);
+        }
+        g_object_unref(app);
+        if (prev) return std::make_shared<AtspiAccessibleNode>(prev);
+    }
+
+    return nullptr;
+}
+
+std::shared_ptr<AccessibleNode> AtspiAccessibleNode::first() const
+{
+    if (!isValid()) {
+        return nullptr;
+    }
+    AtspiAccessible *app = AtspiWrapper::Atspi_accessible_get_application(mNode, NULL);
+    if (app) {
+        AtspiAccessible *first = AtspiWrapper::Atspi_accessible_get_neighbor(app, NULL, ATSPI_NEIGHBOR_SEARCH_FORWARD, NULL);
+        g_object_unref(app);
+        if (first) return std::make_shared<AtspiAccessibleNode>(first);
+    }
+
+    return nullptr;
+}
+
+std::shared_ptr<AccessibleNode> AtspiAccessibleNode::last() const
+{
+    if (!isValid()) {
+        return nullptr;
+    }
+    AtspiAccessible *app = AtspiWrapper::Atspi_accessible_get_application(mNode, NULL);
+    if (app) {
+        AtspiAccessible *last = AtspiWrapper::Atspi_accessible_get_neighbor(app, NULL, ATSPI_NEIGHBOR_SEARCH_BACKWARD, NULL);
+        g_object_unref(app);
+        if (last) return std::make_shared<AtspiAccessibleNode>(last);
+    }
+
+    return nullptr;
+}
\ No newline at end of file
index d1b3b62b4815bed0a52ff7fadf4c5fbcb783c93c..4b06ccb911b4305a1902a58a83b6e586d18808fe 100644 (file)
@@ -278,3 +278,10 @@ void AtspiWrapper::Atspi_accessible_free_node_info(AtspiAccessibleNodeInfo *node
     std::unique_lock<std::recursive_mutex> lock(mMutex);
     atspi_accessible_free_node_info(node_info);
 }
+
+AtspiAccessible *AtspiWrapper::Atspi_accessible_get_neighbor(AtspiAccessible *root, AtspiAccessible *start, AtspiNeighborSearchDirection direction, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_neighbor(root, start, direction, error);
+}
+
index e8aa1d51aeee7e4d01e58b900137153c94d18ff3..aa136cfc33dc73767731684cf60acbd7591d2369 100644 (file)
@@ -316,3 +316,23 @@ void MockAccessibleNode::clearActions(void)
 {
     mActionSet.clear();
 }
+
+std::shared_ptr<AccessibleNode> MockAccessibleNode::next() const
+{
+    return nullptr;
+}
+
+std::shared_ptr<AccessibleNode> MockAccessibleNode::prev() const
+{
+    return nullptr;
+}
+
+std::shared_ptr<AccessibleNode> MockAccessibleNode::first() const
+{
+    return nullptr;
+}
+
+std::shared_ptr<AccessibleNode> MockAccessibleNode::last() const
+{
+    return nullptr;
+}
\ No newline at end of file
index a1f6e0c29b25dc84ba9326c0c30d5bd62b2ee5d7..fc18345b610353c5ff602655253aeb286c0f665d 100644 (file)
@@ -494,3 +494,35 @@ std::shared_ptr<AccessibleNode> UiObject::getAccessibleNode() const
     // mDevice->waitForIdle();
     return mNode;
 }
+
+std::shared_ptr<UiObject> UiObject::next() const {
+    auto nextNode = mNode->next();
+    if (nextNode) {
+        return std::make_shared<UiObject>(mDevice, mSelector, nextNode);
+    }
+    return nullptr;
+}
+
+std::shared_ptr<UiObject> UiObject::prev() const {
+    auto prevNode = mNode->prev();
+    if (prevNode) {
+        return std::make_shared<UiObject>(mDevice, mSelector, prevNode);
+    }
+    return nullptr;
+}
+
+std::shared_ptr<UiObject> UiObject::first() const {
+    auto firstNode = mNode->first();
+    if (firstNode) {
+        return std::make_shared<UiObject>(mDevice, mSelector, firstNode);
+    }
+    return nullptr;
+}
+
+std::shared_ptr<UiObject> UiObject::last() const {
+    auto lastNode = mNode->last();
+    if (lastNode) {
+        return std::make_shared<UiObject>(mDevice, mSelector, lastNode);
+    }
+    return nullptr;
+}
\ No newline at end of file
index 04159cc00536f4bdb4dfcbff561d35ec373825f5..584ef7bec4db7eed101c7515ab29e4a90ec879c1 100644 (file)
@@ -135,6 +135,18 @@ public:
     ::grpc::Status moveTo(::grpc::ServerContext *context,
                             const ::aurum::ReqMoveTo *request,
                             ::aurum::RspMoveTo *response) override;
+    ::grpc::Status next(::grpc::ServerContext *context,
+                            const ::aurum::ReqNext *request,
+                            ::aurum::RspNext *response) override;
+    ::grpc::Status prev(::grpc::ServerContext *context,
+                            const ::aurum::ReqPrev *request,
+                            ::aurum::RspPrev *response) override;
+    ::grpc::Status first(::grpc::ServerContext *context,
+                            const ::aurum::ReqFirst *request,
+                            ::aurum::RspFirst *response) override;
+    ::grpc::Status last(::grpc::ServerContext *context,
+                            const ::aurum::ReqLast *request,
+                            ::aurum::RspLast *response) override;
 public:
     int WAIT_TIMEOUT_MS;
 };
index bedd09687b5773a90933ce2cfeb7852ef6adbc69..21f37a812271b0c4226ae7ff2660c87e11a19402 100644 (file)
@@ -47,3 +47,7 @@
 #include "Commands/GetTextMinBoundingRectCommand.h"
 #include "Commands/SetXMLSyncCommand.h"
 #include "Commands/GetAngleCommand.h"
+#include "Commands/NextCommand.h"
+#include "Commands/PrevCommand.h"
+#include "Commands/FirstCommand.h"
+#include "Commands/LastCommand.h"
diff --git a/org.tizen.aurum-bootstrap/inc/Commands/FirstCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/FirstCommand.h
new file mode 100644 (file)
index 0000000..5bb5280
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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.
+ *
+ */
+
+#include "bootstrap.h"
+
+class FirstCommand : public Command {
+protected:
+    const ::aurum::ReqFirst *mRequest;
+    ::aurum::RspFirst *mResponse;
+
+public:
+    FirstCommand(const ::aurum::ReqFirst *request,
+                       ::aurum::RspFirst *response);
+    ::grpc::Status execute() override;
+};
diff --git a/org.tizen.aurum-bootstrap/inc/Commands/LastCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/LastCommand.h
new file mode 100644 (file)
index 0000000..c5ca10f
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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.
+ *
+ */
+
+#include "bootstrap.h"
+
+class LastCommand : public Command {
+protected:
+    const ::aurum::ReqLast *mRequest;
+    ::aurum::RspLast *mResponse;
+
+public:
+    LastCommand(const ::aurum::ReqLast *request,
+                       ::aurum::RspLast *response);
+    ::grpc::Status execute() override;
+};
diff --git a/org.tizen.aurum-bootstrap/inc/Commands/NextCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/NextCommand.h
new file mode 100644 (file)
index 0000000..5b1fc81
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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.
+ *
+ */
+
+#include "bootstrap.h"
+
+class NextCommand : public Command {
+protected:
+    const ::aurum::ReqNext *mRequest;
+    ::aurum::RspNext *mResponse;
+
+public:
+    NextCommand(const ::aurum::ReqNext *request,
+                       ::aurum::RspNext *response);
+    ::grpc::Status execute() override;
+};
diff --git a/org.tizen.aurum-bootstrap/inc/Commands/PrevCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/PrevCommand.h
new file mode 100644 (file)
index 0000000..b4d335d
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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.
+ *
+ */
+
+#include "bootstrap.h"
+
+class PrevCommand : public Command {
+protected:
+    const ::aurum::ReqPrev *mRequest;
+    ::aurum::RspPrev *mResponse;
+
+public:
+    PrevCommand(const ::aurum::ReqPrev *request,
+                       ::aurum::RspPrev *response);
+    ::grpc::Status execute() override;
+};
index 9a9b29b5d141c056826585c64e30bf9528bfcf21..f945c55ad035b97c650c2c0a0f49b12e2253a028 100644 (file)
@@ -50,6 +50,10 @@ bootstrap_svr_src += [
    files('src/Commands/GetTextMinBoundingRectCommand.cc'),
    files('src/Commands/SetXMLSyncCommand.cc'),
    files('src/Commands/GetAngleCommand.cc'),
+   files('src/Commands/NextCommand.cc'),
+   files('src/Commands/PrevCommand.cc'),
+   files('src/Commands/FirstCommand.cc'),
+   files('src/Commands/LastCommand.cc'),
 ]
 
 bootstrap_svr_dep = [
index 1b3fa2f105bdaef48dd316ea8b9c064b2c46bb8a..dd94866de9190c0ee7582596283bd1e8de934519 100644 (file)
@@ -311,4 +311,35 @@ aurumServiceImpl::~aurumServiceImpl()
 {
     std::unique_ptr<MoveToCommand> cmd = std::make_unique<MoveToCommand>(request, response);
     return execute(cmd.get(), true);
+}
+
+::grpc::Status aurumServiceImpl::next(::grpc::ServerContext *context,
+                                         const ::aurum::ReqNext *request,
+                                         ::aurum::RspNext *response)
+{
+    std::unique_ptr<NextCommand> cmd = std::make_unique<NextCommand>(request, response);
+    return execute(cmd.get(), true);
+}
+
+::grpc::Status aurumServiceImpl::prev(::grpc::ServerContext *context,
+                                         const ::aurum::ReqPrev *request,
+                                         ::aurum::RspPrev *response)
+{
+    std::unique_ptr<PrevCommand> cmd = std::make_unique<PrevCommand>(request, response);
+    return execute(cmd.get(), true);
+}
+
+::grpc::Status aurumServiceImpl::first(::grpc::ServerContext *context,
+                                         const ::aurum::ReqFirst *request,
+                                         ::aurum::RspFirst *response)
+{
+    std::unique_ptr<FirstCommand> cmd = std::make_unique<FirstCommand>(request, response);
+    return execute(cmd.get(), true);
+}
+::grpc::Status aurumServiceImpl::last(::grpc::ServerContext *context,
+                                         const ::aurum::ReqLast *request,
+                                         ::aurum::RspLast *response)
+{
+    std::unique_ptr<LastCommand> cmd = std::make_unique<LastCommand>(request, response);
+    return execute(cmd.get(), true);
 }
\ No newline at end of file
diff --git a/org.tizen.aurum-bootstrap/src/Commands/FirstCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/FirstCommand.cc
new file mode 100644 (file)
index 0000000..43e21fb
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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.
+ *
+ */
+
+#include "FirstCommand.h"
+#include "UiObject.h"
+
+FirstCommand::FirstCommand(const ::aurum::ReqFirst *request,
+                               ::aurum::RspFirst *response)
+    : mRequest{request}, mResponse{response}
+{
+}
+
+::grpc::Status FirstCommand::execute()
+{
+    LOGI("First --------------- ");
+
+    ObjectMapper *mObjMap = ObjectMapper::getInstance();
+    std::shared_ptr<UiObject> base = mObjMap->getElement(mRequest->elementid());
+
+    if (!base) {
+        mResponse->set_status(::aurum::RspStatus::ERROR);
+        return grpc::Status::OK;
+    }
+
+    auto found = base->first();
+
+    if (found != nullptr) {
+        UiObject *obj = found.get();
+        obj->refresh();
+        if (mObjMap->getElement(obj->getId()) == nullptr)
+            mObjMap->addElement(std::move(found));
+
+        LOGI("found object : %p elementId:%s", obj, obj->getId().c_str());
+
+        ::aurum::Element *elm = mResponse->mutable_element();
+        elm->set_elementid(obj->getId());
+        elm->set_package(obj->getApplicationPackage());
+
+        ::aurum::Rect   *rect = elm->mutable_geometry();
+        const Rect<int> &size = obj->getScreenBoundingBox();
+        rect->set_x(size.mTopLeft.x);
+        rect->set_y(size.mTopLeft.y);
+        rect->set_width(size.width());
+        rect->set_height(size.height());
+
+        ::aurum::Rect   *windowRect = elm->mutable_windowrelativegeometry();
+        const Rect<int> &windowRelativeSize = obj->getWindowBoundingBox();
+        windowRect->set_x(windowRelativeSize.mTopLeft.x);
+        windowRect->set_y(windowRelativeSize.mTopLeft.y);
+        windowRect->set_width(windowRelativeSize.width());
+        windowRect->set_height(windowRelativeSize.height());
+
+        elm->set_widgettype(obj->getType());
+        elm->set_widgetstyle(obj->getElementStyle());
+
+        elm->set_text(obj->getText());
+        elm->set_xpath(obj->getXPath());
+        elm->set_ocrtext(obj->getOcrText());
+        elm->set_automationid(obj->getAutomationId());
+        elm->set_package(obj->getApplicationPackage());
+        elm->set_role(obj->getRole());
+
+        elm->set_ischecked(obj->isChecked());
+        elm->set_ischeckable(obj->isCheckable());
+        elm->set_isclickable(obj->isClickable());
+        elm->set_isenabled(obj->isEnabled());
+        elm->set_isfocused(obj->isFocused());
+        elm->set_isfocusable(obj->isFocusable());
+        elm->set_isscrollable(obj->isScrollable());
+        elm->set_isselected(obj->isSelected());
+        elm->set_isshowing(obj->isShowing());
+        elm->set_isactive(obj->isActive());
+        elm->set_isvisible(obj->isVisible());
+        elm->set_isselectable(obj->isSelectable());
+        elm->set_ishighlightable(obj->isHighlightable());
+
+        elm->set_minvalue(obj->getMinValue());
+        elm->set_maxvalue(obj->getMaxValue());
+        elm->set_value(obj->getValue());
+        elm->set_increment(obj->getIncrement());
+
+        elm->set_windowangle(obj->getWindowAngle());
+        elm->set_targetangle(obj->getTargetAngle());
+
+        elm->set_interface(obj->getInterface());
+        elm->set_description(obj->getDescription());
+
+        mResponse->set_status(::aurum::RspStatus::OK);
+    } else {
+        mResponse->set_status(::aurum::RspStatus::ERROR);
+    }
+
+    return grpc::Status::OK;
+}
diff --git a/org.tizen.aurum-bootstrap/src/Commands/LastCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/LastCommand.cc
new file mode 100644 (file)
index 0000000..ada839a
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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.
+ *
+ */
+
+#include "LastCommand.h"
+#include "UiObject.h"
+
+LastCommand::LastCommand(const ::aurum::ReqLast *request,
+                               ::aurum::RspLast *response)
+    : mRequest{request}, mResponse{response}
+{
+}
+
+::grpc::Status LastCommand::execute()
+{
+    LOGI("Last --------------- ");
+
+    ObjectMapper *mObjMap = ObjectMapper::getInstance();
+    std::shared_ptr<UiObject> base = mObjMap->getElement(mRequest->elementid());
+
+    if (!base) {
+        mResponse->set_status(::aurum::RspStatus::ERROR);
+        return grpc::Status::OK;
+    }
+
+    auto found = base->last();
+
+    if (found != nullptr) {
+        UiObject *obj = found.get();
+        obj->refresh();
+        if (mObjMap->getElement(obj->getId()) == nullptr)
+            mObjMap->addElement(std::move(found));
+
+        LOGI("found object : %p elementId:%s", obj, obj->getId().c_str());
+
+        ::aurum::Element *elm = mResponse->mutable_element();
+        elm->set_elementid(obj->getId());
+        elm->set_package(obj->getApplicationPackage());
+
+        ::aurum::Rect   *rect = elm->mutable_geometry();
+        const Rect<int> &size = obj->getScreenBoundingBox();
+        rect->set_x(size.mTopLeft.x);
+        rect->set_y(size.mTopLeft.y);
+        rect->set_width(size.width());
+        rect->set_height(size.height());
+
+        ::aurum::Rect   *windowRect = elm->mutable_windowrelativegeometry();
+        const Rect<int> &windowRelativeSize = obj->getWindowBoundingBox();
+        windowRect->set_x(windowRelativeSize.mTopLeft.x);
+        windowRect->set_y(windowRelativeSize.mTopLeft.y);
+        windowRect->set_width(windowRelativeSize.width());
+        windowRect->set_height(windowRelativeSize.height());
+
+        elm->set_widgettype(obj->getType());
+        elm->set_widgetstyle(obj->getElementStyle());
+
+        elm->set_text(obj->getText());
+        elm->set_xpath(obj->getXPath());
+        elm->set_ocrtext(obj->getOcrText());
+        elm->set_automationid(obj->getAutomationId());
+        elm->set_package(obj->getApplicationPackage());
+        elm->set_role(obj->getRole());
+
+        elm->set_ischecked(obj->isChecked());
+        elm->set_ischeckable(obj->isCheckable());
+        elm->set_isclickable(obj->isClickable());
+        elm->set_isenabled(obj->isEnabled());
+        elm->set_isfocused(obj->isFocused());
+        elm->set_isfocusable(obj->isFocusable());
+        elm->set_isscrollable(obj->isScrollable());
+        elm->set_isselected(obj->isSelected());
+        elm->set_isshowing(obj->isShowing());
+        elm->set_isactive(obj->isActive());
+        elm->set_isvisible(obj->isVisible());
+        elm->set_isselectable(obj->isSelectable());
+        elm->set_ishighlightable(obj->isHighlightable());
+
+        elm->set_minvalue(obj->getMinValue());
+        elm->set_maxvalue(obj->getMaxValue());
+        elm->set_value(obj->getValue());
+        elm->set_increment(obj->getIncrement());
+
+        elm->set_windowangle(obj->getWindowAngle());
+        elm->set_targetangle(obj->getTargetAngle());
+
+        elm->set_interface(obj->getInterface());
+        elm->set_description(obj->getDescription());
+
+        mResponse->set_status(::aurum::RspStatus::OK);
+    } else {
+        mResponse->set_status(::aurum::RspStatus::ERROR);
+    }
+
+    return grpc::Status::OK;
+}
diff --git a/org.tizen.aurum-bootstrap/src/Commands/NextCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/NextCommand.cc
new file mode 100644 (file)
index 0000000..038acd5
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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.
+ *
+ */
+
+#include "NextCommand.h"
+#include "UiObject.h"
+
+NextCommand::NextCommand(const ::aurum::ReqNext *request,
+                               ::aurum::RspNext *response)
+    : mRequest{request}, mResponse{response}
+{
+}
+
+::grpc::Status NextCommand::execute()
+{
+    LOGI("Next --------------- ");
+
+    ObjectMapper *mObjMap = ObjectMapper::getInstance();
+    std::shared_ptr<UiObject> base = mObjMap->getElement(mRequest->elementid());
+
+    if (!base) {
+        mResponse->set_status(::aurum::RspStatus::ERROR);
+        return grpc::Status::OK;
+    }
+
+    auto found = base->next();
+
+    if (found != nullptr) {
+        UiObject *obj = found.get();
+        obj->refresh();
+        if (mObjMap->getElement(obj->getId()) == nullptr)
+            mObjMap->addElement(std::move(found));
+
+        LOGI("found object : %p elementId:%s", obj, obj->getId().c_str());
+
+        ::aurum::Element *elm = mResponse->mutable_element();
+        elm->set_elementid(obj->getId());
+        elm->set_package(obj->getApplicationPackage());
+
+        ::aurum::Rect   *rect = elm->mutable_geometry();
+        const Rect<int> &size = obj->getScreenBoundingBox();
+        rect->set_x(size.mTopLeft.x);
+        rect->set_y(size.mTopLeft.y);
+        rect->set_width(size.width());
+        rect->set_height(size.height());
+
+        ::aurum::Rect   *windowRect = elm->mutable_windowrelativegeometry();
+        const Rect<int> &windowRelativeSize = obj->getWindowBoundingBox();
+        windowRect->set_x(windowRelativeSize.mTopLeft.x);
+        windowRect->set_y(windowRelativeSize.mTopLeft.y);
+        windowRect->set_width(windowRelativeSize.width());
+        windowRect->set_height(windowRelativeSize.height());
+
+        elm->set_widgettype(obj->getType());
+        elm->set_widgetstyle(obj->getElementStyle());
+
+        elm->set_text(obj->getText());
+        elm->set_xpath(obj->getXPath());
+        elm->set_ocrtext(obj->getOcrText());
+        elm->set_automationid(obj->getAutomationId());
+        elm->set_package(obj->getApplicationPackage());
+        elm->set_role(obj->getRole());
+
+        elm->set_ischecked(obj->isChecked());
+        elm->set_ischeckable(obj->isCheckable());
+        elm->set_isclickable(obj->isClickable());
+        elm->set_isenabled(obj->isEnabled());
+        elm->set_isfocused(obj->isFocused());
+        elm->set_isfocusable(obj->isFocusable());
+        elm->set_isscrollable(obj->isScrollable());
+        elm->set_isselected(obj->isSelected());
+        elm->set_isshowing(obj->isShowing());
+        elm->set_isactive(obj->isActive());
+        elm->set_isvisible(obj->isVisible());
+        elm->set_isselectable(obj->isSelectable());
+        elm->set_ishighlightable(obj->isHighlightable());
+
+        elm->set_minvalue(obj->getMinValue());
+        elm->set_maxvalue(obj->getMaxValue());
+        elm->set_value(obj->getValue());
+        elm->set_increment(obj->getIncrement());
+
+        elm->set_windowangle(obj->getWindowAngle());
+        elm->set_targetangle(obj->getTargetAngle());
+
+        elm->set_interface(obj->getInterface());
+        elm->set_description(obj->getDescription());
+
+        mResponse->set_status(::aurum::RspStatus::OK);
+    } else {
+        mResponse->set_status(::aurum::RspStatus::ERROR);
+    }
+
+    return grpc::Status::OK;
+}
diff --git a/org.tizen.aurum-bootstrap/src/Commands/PrevCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/PrevCommand.cc
new file mode 100644 (file)
index 0000000..3447b2c
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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.
+ *
+ */
+
+#include "PrevCommand.h"
+#include "UiObject.h"
+
+PrevCommand::PrevCommand(const ::aurum::ReqPrev *request,
+                               ::aurum::RspPrev *response)
+    : mRequest{request}, mResponse{response}
+{
+}
+
+::grpc::Status PrevCommand::execute()
+{
+    LOGI("Prev --------------- ");
+
+    ObjectMapper *mObjMap = ObjectMapper::getInstance();
+    std::shared_ptr<UiObject> base = mObjMap->getElement(mRequest->elementid());
+
+    if (!base) {
+        mResponse->set_status(::aurum::RspStatus::ERROR);
+        return grpc::Status::OK;
+    }
+
+    auto found = base->prev();
+
+    if (found != nullptr) {
+        UiObject *obj = found.get();
+        obj->refresh();
+        if (mObjMap->getElement(obj->getId()) == nullptr)
+            mObjMap->addElement(std::move(found));
+
+        LOGI("found object : %p elementId:%s", obj, obj->getId().c_str());
+
+        ::aurum::Element *elm = mResponse->mutable_element();
+        elm->set_elementid(obj->getId());
+        elm->set_package(obj->getApplicationPackage());
+
+        ::aurum::Rect   *rect = elm->mutable_geometry();
+        const Rect<int> &size = obj->getScreenBoundingBox();
+        rect->set_x(size.mTopLeft.x);
+        rect->set_y(size.mTopLeft.y);
+        rect->set_width(size.width());
+        rect->set_height(size.height());
+
+        ::aurum::Rect   *windowRect = elm->mutable_windowrelativegeometry();
+        const Rect<int> &windowRelativeSize = obj->getWindowBoundingBox();
+        windowRect->set_x(windowRelativeSize.mTopLeft.x);
+        windowRect->set_y(windowRelativeSize.mTopLeft.y);
+        windowRect->set_width(windowRelativeSize.width());
+        windowRect->set_height(windowRelativeSize.height());
+
+        elm->set_widgettype(obj->getType());
+        elm->set_widgetstyle(obj->getElementStyle());
+
+        elm->set_text(obj->getText());
+        elm->set_xpath(obj->getXPath());
+        elm->set_ocrtext(obj->getOcrText());
+        elm->set_automationid(obj->getAutomationId());
+        elm->set_package(obj->getApplicationPackage());
+        elm->set_role(obj->getRole());
+
+        elm->set_ischecked(obj->isChecked());
+        elm->set_ischeckable(obj->isCheckable());
+        elm->set_isclickable(obj->isClickable());
+        elm->set_isenabled(obj->isEnabled());
+        elm->set_isfocused(obj->isFocused());
+        elm->set_isfocusable(obj->isFocusable());
+        elm->set_isscrollable(obj->isScrollable());
+        elm->set_isselected(obj->isSelected());
+        elm->set_isshowing(obj->isShowing());
+        elm->set_isactive(obj->isActive());
+        elm->set_isvisible(obj->isVisible());
+        elm->set_isselectable(obj->isSelectable());
+        elm->set_ishighlightable(obj->isHighlightable());
+
+        elm->set_minvalue(obj->getMinValue());
+        elm->set_maxvalue(obj->getMaxValue());
+        elm->set_value(obj->getValue());
+        elm->set_increment(obj->getIncrement());
+
+        elm->set_windowangle(obj->getWindowAngle());
+        elm->set_targetangle(obj->getTargetAngle());
+
+        elm->set_interface(obj->getInterface());
+        elm->set_description(obj->getDescription());
+
+        mResponse->set_status(::aurum::RspStatus::OK);
+    } else {
+        mResponse->set_status(::aurum::RspStatus::ERROR);
+    }
+
+    return grpc::Status::OK;
+}
index 9ee7ae43018e4843febdf07eeb80cfef747d4046..9bba1ff0b15fbc0630cd79933e75a793c48db79f 100644 (file)
@@ -39,6 +39,10 @@ service Bootstrap {
    rpc setXMLSync(ReqSetXMLSync) returns (RspSetXMLSync) {}
    rpc getAngle(ReqGetAngle) returns (RspGetAngle) {}
    rpc moveTo(ReqMoveTo) returns (RspMoveTo) {}
+   rpc next(ReqNext) returns (RspNext) {}
+   rpc prev(ReqPrev) returns (RspPrev) {}
+   rpc first(ReqFirst) returns (RspFirst) {}
+   rpc last(ReqLast) returns (RspLast) {}
 }
 
 // ------------------------------------ //
@@ -683,3 +687,39 @@ message RspGetAngle {
    int32 windowAngle = 2;
    int32 targetAngle = 3;
 }
+
+message ReqNext {
+   string elementId = 1;
+}
+
+message RspNext {
+   RspStatus status = 1;
+   Element element = 2;
+}
+
+message ReqPrev {
+   string elementId = 1;
+}
+
+message RspPrev {
+   RspStatus status = 1;
+   Element element = 2;
+}
+
+message ReqFirst {
+   string elementId = 1;
+}
+
+message RspFirst {
+   RspStatus status = 1;
+   Element element = 2;
+}
+
+message ReqLast {
+   string elementId = 1;
+}
+
+message RspLast {
+   RspStatus status = 1;
+   Element element = 2;
+}