libaurum: wrap atspi capi set to adopt lock logic
authorWonki Kim <wonki_.kim@samsung.com>
Tue, 26 Jan 2021 09:42:39 +0000 (18:42 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Tue, 26 Jan 2021 09:45:36 +0000 (18:45 +0900)
there are basically two threads. one is for grpc, and another one is for atspi.
and they call atspi api at the same time, which can cause a problem.
this patch adopt a wrapper class to lock that api set.

Change-Id: I84d55ae67af56cf5be9ff8c9e00b8801a853afa5

libaurum/inc/Impl/Accessibility/AtspiWrapper.h [new file with mode: 0644]
libaurum/src/Accessibility/AccessibleUtils.cc
libaurum/src/Impl/Accessibility/AtspiAccessibleApplication.cc
libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc
libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc
libaurum/src/Impl/Accessibility/AtspiAccessibleWindow.cc
libaurum/src/Impl/Accessibility/AtspiWrapper.cc [new file with mode: 0644]
libaurum/src/Impl/Accessibility/meson.build

diff --git a/libaurum/inc/Impl/Accessibility/AtspiWrapper.h b/libaurum/inc/Impl/Accessibility/AtspiWrapper.h
new file mode 100644 (file)
index 0000000..beac01a
--- /dev/null
@@ -0,0 +1,35 @@
+#pragma once
+#include <atspi/atspi.h>
+#include <mutex>
+
+class AtspiWrapper {
+public:
+    static GArray* Atspi_state_set_get_states(AtspiStateSet *set);
+    static GArray* Atspi_accessible_get_interfaces(AtspiAccessible *node);
+    static gchar* Atspi_accessible_get_name(AtspiAccessible *node, GError **error);
+    static AtspiAccessible* Atspi_get_desktop(int n);
+    static int Atspi_accessible_get_child_count(AtspiAccessible *node, GError **error);
+    static AtspiAccessible* Atspi_accessible_get_child_at_index(AtspiAccessible *node, int index, GError **error);
+    static AtspiAccessible* Atspi_accessible_get_parent(AtspiAccessible *node, GError **error);
+    static AtspiStateSet* Atspi_accessible_get_state_set(AtspiAccessible *node);
+    static gboolean Atspi_state_set_contains(AtspiStateSet *set , AtspiStateType state);
+    static gchar* Atspi_accessible_get_role_name(AtspiAccessible *node, GError **error);
+    static gchar* Atspi_accessible_get_unique_id(AtspiAccessible *node, GError **error);
+    static GHashTable* Atspi_accessible_get_attributes(AtspiAccessible *node, GError **error);
+    static AtspiComponent* Atspi_accessible_get_component_iface(AtspiAccessible *node);
+    static AtspiRect* Atspi_component_get_extents(AtspiComponent *obj, AtspiCoordType ctype, GError **error);
+    static AtspiAction* Atspi_accessible_get_action_iface(AtspiAccessible *node);
+    static int Atspi_action_get_n_actions(AtspiAction* action, GError **error);
+    static gchar* Atspi_action_get_action_name(AtspiAction* action, int index, GError **error);
+    static gboolean Atspi_action_do_action(AtspiAction *action, int index, GError **error);
+    static AtspiEditableText* Atspi_accessible_get_editable_text(AtspiAccessible *node);
+    static gboolean Atspi_editable_text_delete_text(AtspiEditableText*, int start, int end, GError **error);
+    static gboolean Atspi_editable_text_insert_text(AtspiEditableText*, int pos, const gchar *text, int len, GError **error);
+    static AtspiAccessible* Atspi_accessible_get_application (AtspiAccessible *node, GError **error);
+
+    static void lock();
+    static void unlock();
+private:
+    static std::recursive_mutex mMutex;
+    //static std::unique_lock<std::mutex> mLock;
+};
\ No newline at end of file
index f1c19494c65807ab18da5851f71431b098d69e9f..98b2082daaaff89992b6a90067eecddebf3c4791 100644 (file)
@@ -103,7 +103,7 @@ char* state_to_char(AtspiStateType state)
 static void _print_stateset_debug( AtspiStateSet *stateSet)
 {
    if (!stateSet) return;
-   GArray *states = atspi_state_set_get_states(stateSet);
+   GArray *states = AtspiWrapper::Atspi_state_set_get_states(stateSet);
    if (!states) return;
 
    char *state_name = NULL;
index 4c828c7c7940e2867f62dfd97cca5f97c50cac46..79aec79a24b42e4372f4ceea86faa82861cdb0de 100644 (file)
@@ -1,5 +1,7 @@
 #include "AtspiAccessibleApplication.h"
 #include "AtspiAccessibleWindow.h"
+#include "AtspiWrapper.h"
+
 #include <algorithm>
 #include <vector>
 
index ab5c8237bcae454694245c931fa828c105204ffd..436eef8fff11ab676c8fa98ac5b4b62969f703c5 100644 (file)
@@ -1,5 +1,6 @@
 #include "AtspiAccessibleNode.h"
 #include "AccessibleWatcher.h"
+#include "AtspiWrapper.h"
 
 #include <gio/gio.h>
 
@@ -15,7 +16,8 @@ AtspiAccessibleNode::AtspiAccessibleNode(AtspiAccessible *node)
     watcher->attach(shared_from_this());
 
     if (mNode) {
-        GArray *ifaces = atspi_accessible_get_interfaces(mNode);
+        /*
+        GArray *ifaces = AtspiWrapper::Atspi_accessible_get_interfaces(mNode);
         if (ifaces) {
             for (unsigned int i = 0; i < ifaces->len; i++) {
                 char *iface = g_array_index(ifaces, char *, i);
@@ -64,7 +66,8 @@ AtspiAccessibleNode::AtspiAccessibleNode(AtspiAccessible *node)
                 g_free(iface);
             }
             g_array_free(ifaces, FALSE);
-        }
+        }*/
+
         this->refresh();
     } else {
         LOG_F(INFO, "AtspiAccessibleNode Ctor : mNode is null");
@@ -80,17 +83,27 @@ AtspiAccessibleNode::~AtspiAccessibleNode()
 
 int AtspiAccessibleNode::getChildCount() const
 {
-    if (!isValid()) return 0;
-    int count = atspi_accessible_get_child_count(mNode, NULL);
+    AtspiWrapper::lock();
+    if (!isValid()) {
+        AtspiWrapper::unlock();
+        return 0;
+    }
+    int count = AtspiWrapper::Atspi_accessible_get_child_count(mNode, NULL);
+    AtspiWrapper::unlock();
     if (count <= 0) return 0;
     return count;
 }
 
 std::shared_ptr<AccessibleNode> AtspiAccessibleNode::getChildAt(int index) const
 {
-    if (!isValid()) return std::make_shared<AtspiAccessibleNode>(nullptr);
+    AtspiWrapper::lock();
+    if (!isValid()) {
+        AtspiWrapper::unlock();
+        return std::make_shared<AtspiAccessibleNode>(nullptr);
+    }
     LOG_SCOPE_F(INFO, "getChild @ %d from node(%p)", index, mNode);
-    AtspiAccessible *rawChild = atspi_accessible_get_child_at_index(mNode, index, NULL);
+    AtspiAccessible *rawChild = AtspiWrapper::Atspi_accessible_get_child_at_index(mNode, index, NULL);
+    AtspiWrapper::unlock();
     return std::make_shared<AtspiAccessibleNode>(rawChild);
 }
 
@@ -107,8 +120,13 @@ std::vector<std::shared_ptr<AccessibleNode>> AtspiAccessibleNode::getChildren()
 
 std::shared_ptr<AccessibleNode> AtspiAccessibleNode::getParent() const
 {
-    if (!isValid()) std::make_shared<AtspiAccessibleNode>(nullptr);
-    AtspiAccessible *rawParent = atspi_accessible_get_parent(mNode, NULL);
+    AtspiWrapper::lock();
+    if (!isValid()) {
+        AtspiWrapper::unlock();
+        return std::make_shared<AtspiAccessibleNode>(nullptr);
+    }
+    AtspiAccessible *rawParent = AtspiWrapper::Atspi_accessible_get_parent(mNode, NULL);
+    AtspiWrapper::unlock();
     return std::make_shared<AtspiAccessibleNode>(rawParent);
 /*  auto node = AccessibleNode::get(parent);
     if (parent) g_object_unref(parent);
@@ -118,10 +136,10 @@ bool AtspiAccessibleNode::isValid() const
 {
     if(!AccessibleNode::isValid())  return false;
 
-    AtspiStateSet *st = atspi_accessible_get_state_set(mNode);
+    AtspiStateSet *st = AtspiWrapper::Atspi_accessible_get_state_set(mNode);
     if (!st) return false;
-    if (atspi_state_set_contains(st, ATSPI_STATE_INVALID) ||
-        atspi_state_set_contains(st, ATSPI_STATE_DEFUNCT)) {
+    if (AtspiWrapper::Atspi_state_set_contains(st, ATSPI_STATE_INVALID) ||
+        AtspiWrapper::Atspi_state_set_contains(st, ATSPI_STATE_DEFUNCT)) {
         g_object_unref(st);
         return false;
     }
@@ -137,14 +155,15 @@ void* AtspiAccessibleNode::getRawHandler(void) const
 
 void AtspiAccessibleNode::refresh()
 {
+    AtspiWrapper::lock();
     if (isValid()) {
-        gchar *rolename = atspi_accessible_get_role_name(mNode, NULL);
+        gchar *rolename = AtspiWrapper::Atspi_accessible_get_role_name(mNode, NULL);
         if (rolename) {
             mRole = rolename;
             g_free(rolename);
         }
     #ifdef TIZEN
-        gchar *uID = atspi_accessible_get_unique_id(mNode, NULL);
+        gchar *uID = AtspiWrapper::Atspi_accessible_get_unique_id(mNode, NULL);
         if (uID) {
             mId = uID;
             g_free(uID);
@@ -153,12 +172,12 @@ void AtspiAccessibleNode::refresh()
         mId = std::string{"N/A"};
     #endif
 
-        gchar *name = atspi_accessible_get_name(mNode, NULL);
+        gchar *name = AtspiWrapper::Atspi_accessible_get_name(mNode, NULL);
         mText = name;
         mPkg = name;
         g_free(name);
 
-        GHashTable *attributes = atspi_accessible_get_attributes(mNode, NULL);
+        GHashTable *attributes = AtspiWrapper::Atspi_accessible_get_attributes(mNode, NULL);
         if (attributes) {
             char *t = (char*)g_hash_table_lookup(attributes, "type");
             char *s = (char*)g_hash_table_lookup(attributes, "style");
@@ -172,25 +191,26 @@ void AtspiAccessibleNode::refresh()
             free(s);
             free(a);
 
+            LOG_F(INFO, "table unref %p", attributes);
             g_hash_table_unref(attributes);
         }
 
-        AtspiStateSet *st = atspi_accessible_get_state_set(mNode);
+        AtspiStateSet *st = AtspiWrapper::Atspi_accessible_get_state_set(mNode);
         if (st) {
-            GArray *states = atspi_state_set_get_states(st);
+            GArray *states = AtspiWrapper::Atspi_state_set_get_states(st);
             if (states) {
                 AtspiStateType stat;
                 for (unsigned int i = 0; states && (i < states->len); ++i) {
                     stat = g_array_index(states, AtspiStateType, i);
                     setFeatureProperty(stat);
                 }
-                g_array_free(states, 0);
+                g_array_free(states, 1);
             }
             g_object_unref(st);
         }
-        AtspiComponent *component = atspi_accessible_get_component_iface(mNode);
+        AtspiComponent *component = AtspiWrapper::Atspi_accessible_get_component_iface(mNode);
         if (component) {
-            AtspiRect *extent = atspi_component_get_extents(
+            AtspiRect *extent = AtspiWrapper::Atspi_component_get_extents(
                 component, ATSPI_COORD_TYPE_SCREEN, NULL);
             if (extent) {
                 mBoundingBox =
@@ -203,68 +223,93 @@ void AtspiAccessibleNode::refresh()
     } else {
         setFeatureProperty(ATSPI_STATE_INVALID);
     }
+    AtspiWrapper::unlock();
 }
 
 std::vector<std::string> AtspiAccessibleNode::getActions() const
 {
+    AtspiWrapper::lock();
+
     std::vector<std::string> result{};
     AtspiAction *action;
-    if (!isValid()) return result;
+    if (!isValid()) {
+        AtspiWrapper::unlock();
+        return result;
+    }
 
-    action = atspi_accessible_get_action_iface(mNode);
+    action = AtspiWrapper::Atspi_accessible_get_action_iface(mNode);
     if (action) {
         int a;
-        int n_actions = atspi_action_get_n_actions(action, NULL);
+        int n_actions = AtspiWrapper::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);
+            char *action_name = AtspiWrapper::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);
     }
+
+    AtspiWrapper::unlock();
+
     return result;
 }
 
 bool AtspiAccessibleNode::doAction(std::string actionName)
 {
+    AtspiWrapper::lock();
     AtspiAction *action;
-    if (!isValid()) return false;
-    action = atspi_accessible_get_action_iface(mNode);
+
+    if (!isValid()) {
+        AtspiWrapper::unlock();
+        return false;
+    }
+
+    action = AtspiWrapper::Atspi_accessible_get_action_iface(mNode);
     if (action) {
         int a;
-        int n_actions = atspi_action_get_n_actions(action, NULL);
+        int n_actions = AtspiWrapper::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;
+            char *action_name = AtspiWrapper::Atspi_action_get_action_name(action, a, NULL);
+            if (!action_name) {
+                AtspiWrapper::unlock();
+                 return false;
+            }
 
             if (!strcmp(actionName.c_str(), action_name)) {
-                atspi_action_do_action(action, a, NULL);
+                AtspiWrapper::Atspi_action_do_action(action, a, NULL);
                 g_free(action_name);
                 g_object_unref(action);
+                AtspiWrapper::unlock();
                 return true;
             }
             g_free(action_name);
         }
         g_object_unref(action);
     }
+    AtspiWrapper::unlock();
     return false;
 }
 
 void AtspiAccessibleNode::setValue(std::string text)
 {
-    if (!isValid()) return;
+    AtspiWrapper::lock();
+    if (!isValid()){
+        AtspiWrapper::unlock();
+        return;
+    }
 
-    AtspiEditableText *iface = atspi_accessible_get_editable_text(mNode);
+    AtspiEditableText *iface = AtspiWrapper::Atspi_accessible_get_editable_text(mNode);
     LOG_F(INFO,"set Value iface:%p obj:%p text:%s", iface, mNode, text.c_str() );
     if (iface) {
         int len = getText().length();
-        atspi_editable_text_delete_text(iface, 0, len, NULL);
-        atspi_editable_text_insert_text(iface, 0, text.c_str(), text.length(),
+        AtspiWrapper::Atspi_editable_text_delete_text(iface, 0, len, NULL);
+        AtspiWrapper::Atspi_editable_text_insert_text(iface, 0, text.c_str(), text.length(),
                                         NULL);
     }
+    AtspiWrapper::unlock();
 }
 
 void AtspiAccessibleNode::setFeatureProperty(AtspiStateType type)
index f3cdfaa54169a28cd386aaa6ca165776baa856a0..59dfe942636cc7c22927bf6036d3dea1c0845eb8 100644 (file)
@@ -3,7 +3,7 @@
 #include "AtspiAccessibleApplication.h"
 #include "AtspiAccessibleWindow.h"
 #include "AtspiAccessibleNode.h"
-
+#include "AtspiWrapper.h"
 #include <algorithm>
 
 #include <loguru.hpp>
@@ -13,14 +13,14 @@ AtspiEventListener *AtspiAccessibleWatcher::listener = nullptr;
 static bool iShowingNode(AtspiAccessible *node)
 {
     char *name = NULL;
-    if (node) name = atspi_accessible_get_name(node, NULL);
+    if (node) name = AtspiWrapper::Atspi_accessible_get_name(node, NULL);
     else return false;
 
     LOG_SCOPE_F(INFO, "isShowing %s", name);
-    auto stateSet = atspi_accessible_get_state_set(node);
+    auto stateSet = AtspiWrapper::Atspi_accessible_get_state_set(node);
 
-    if (atspi_state_set_contains(stateSet, ATSPI_STATE_ACTIVE)
-        && atspi_state_set_contains(stateSet, ATSPI_STATE_SHOWING)) {
+    if (AtspiWrapper::Atspi_state_set_contains(stateSet, ATSPI_STATE_ACTIVE)
+        && AtspiWrapper::Atspi_state_set_contains(stateSet, ATSPI_STATE_SHOWING)) {
         LOG_F(INFO, "active and showing %p %s", node, name);
         free(name);
         g_object_unref(stateSet);
@@ -41,7 +41,7 @@ findActiveNode(AtspiAccessible *node, int depth,
 
     if (iShowingNode(node)) {
         g_object_ref(node);
-        char *name = atspi_accessible_get_name(node, NULL);
+        char *name = AtspiWrapper::Atspi_accessible_get_name(node, NULL);
         if (name) {
             LOG_SCOPE_F(INFO, "%s", name);
             free(name);
@@ -52,12 +52,12 @@ findActiveNode(AtspiAccessible *node, int depth,
 
     if (depth >= max_depth) return ret;
 
-    int nchild = atspi_accessible_get_child_count(node, NULL);
+    int nchild = AtspiWrapper::Atspi_accessible_get_child_count(node, NULL);
     if (nchild <= 0) return ret;
 
     LOG_F(INFO, "findActiveNode node %p has %d children", node, nchild);
     for (int i = 0; i < nchild; i++) {
-        AtspiAccessible* child = atspi_accessible_get_child_at_index(node, i, NULL);
+        AtspiAccessible* child = AtspiWrapper::Atspi_accessible_get_child_at_index(node, i, NULL);
         LOG_F(INFO, "a child found @ %d : %p", i, child);
         std::vector<AtspiAccessible *> childRet = findActiveNode(child, depth + 1, max_depth);
         ret.insert(ret.end(), childRet.begin(), childRet.end());
@@ -123,6 +123,7 @@ AtspiAccessibleWatcher::~AtspiAccessibleWatcher()
 
 void AtspiAccessibleWatcher::onAtspiEvents(AtspiEvent *event, void *user_data)
 {
+    AtspiWrapper::lock();
     char *name = NULL, *pname = NULL;
     AtspiAccessibleWatcher *instance = (AtspiAccessibleWatcher *)user_data;
 
@@ -132,10 +133,10 @@ void AtspiAccessibleWatcher::onAtspiEvents(AtspiEvent *event, void *user_data)
         return;
     }
 
-    name = atspi_accessible_get_name(event->source, NULL);
-    AtspiAccessible *parent = atspi_accessible_get_parent(event->source, NULL);
+    name = AtspiWrapper::Atspi_accessible_get_name(event->source, NULL);
+    AtspiAccessible *parent = AtspiWrapper::Atspi_accessible_get_parent(event->source, NULL);
     if (parent) {
-        pname = atspi_accessible_get_name(parent, NULL);
+        pname = AtspiWrapper::Atspi_accessible_get_name(parent, NULL);
         g_object_unref(parent);
     }
 
@@ -159,8 +160,7 @@ void AtspiAccessibleWatcher::onAtspiEvents(AtspiEvent *event, void *user_data)
     }
     if (name) free(name);
     if (pname) free(pname);
-
-//    instance->print_debug();
+    AtspiWrapper::unlock();
 }
 
 void AtspiAccessibleWatcher::print_debug()
@@ -222,39 +222,49 @@ void AtspiAccessibleWatcher::onObjectDefunct(AtspiAccessible *node)
 
 int AtspiAccessibleWatcher::getApplicationCount(void) const
 {
-    AtspiAccessible *root = atspi_get_desktop(0);
-    int nchild = atspi_accessible_get_child_count(root, NULL);
+    AtspiWrapper::lock();
+
+    AtspiAccessible *root = AtspiWrapper::Atspi_get_desktop(0);
+    int nchild = AtspiWrapper::Atspi_accessible_get_child_count(root, NULL);
     g_object_unref(root);
+
+    AtspiWrapper::unlock();
+
     if (nchild <= 0) return 0;
     return nchild;
 }
 
 std::shared_ptr<AccessibleApplication> AtspiAccessibleWatcher::getApplicationAt(int index) const
 {
-    AtspiAccessible *root = atspi_get_desktop(0);
-    AtspiAccessible* child = atspi_accessible_get_child_at_index(root, index, NULL);
+    AtspiWrapper::lock();
+    AtspiAccessible *root = AtspiWrapper::Atspi_get_desktop(0);
+    AtspiAccessible* child = AtspiWrapper::Atspi_accessible_get_child_at_index(root, index, NULL);
     g_object_unref(root);
+    AtspiWrapper::unlock();
     return std::make_shared<AtspiAccessibleApplication>(std::make_shared<AtspiAccessibleNode>(child));
 }
 
 std::vector<std::shared_ptr<AccessibleApplication>> AtspiAccessibleWatcher::getApplications(void) const
 {
+    AtspiWrapper::lock();
     LOG_SCOPE_F(INFO, "getApplications for this(%p)", this);
     std::vector<std::shared_ptr<AccessibleApplication>> ret{};
-    AtspiAccessible *root = atspi_get_desktop(0);
-    int nchild = atspi_accessible_get_child_count(root, NULL);
+    AtspiAccessible *root = AtspiWrapper::Atspi_get_desktop(0);
+    int nchild = AtspiWrapper::Atspi_accessible_get_child_count(root, NULL);
     if (nchild <= 0) {
         g_object_unref(root);
+        AtspiWrapper::unlock();
         return ret;
     }
 
     for (int i = 0; i < nchild; i++){
-        AtspiAccessible* child = atspi_accessible_get_child_at_index(root, i, NULL);
+        AtspiAccessible* child = AtspiWrapper::Atspi_accessible_get_child_at_index(root, i, NULL);
         if (child) {
             ret.push_back(std::make_shared<AtspiAccessibleApplication>(std::make_shared<AtspiAccessibleNode>(child)));
         }
     }
     g_object_unref(root);
+    AtspiWrapper::unlock();
     return ret;
 }
 
@@ -263,7 +273,7 @@ bool AtspiAccessibleWatcher::removeFromActivatedList(AtspiAccessible *node)
     LOG_SCOPE_F(INFO,"remove from activelist node %p", node);
     mActivatedWindowList.remove_if([&](auto &n) { return n == node; });
 
-    AtspiAccessible *app = atspi_accessible_get_application(node, NULL);
+    AtspiAccessible *app = AtspiWrapper::Atspi_accessible_get_application(node, NULL);
     LOG_F(INFO, "node:%p, app:%p", node, app);
     if (app) {
         mActivatedApplicationList.remove_if([&](auto &n) { return n == app; });
@@ -281,7 +291,7 @@ bool AtspiAccessibleWatcher::addToActivatedList(AtspiAccessible *node)
     auto iter = mWindowSet.find(node);
     if ( iter == mWindowSet.end()) mWindowSet.insert(node);
 
-    AtspiAccessible *app = atspi_accessible_get_application(node, NULL);
+    AtspiAccessible *app = AtspiWrapper::Atspi_accessible_get_application(node, NULL);
     LOG_F(INFO, "node:%p, app:%p", node, app);
     if (app) {
         mActivatedApplicationList.remove_if([&](auto &n) { if(n == app) { g_object_unref(app); return true;} else return false; });
index 26ed203b9e5e4787d308f256fe617b3e585b1bb8..247ea0d88d2a0e9daa94e8b9bc2f33c74a5938b8 100644 (file)
@@ -1,5 +1,5 @@
 #include "AtspiAccessibleWindow.h"
-
+#include "AtspiWrapper.h"
 
 AtspiAccessibleWindow::AtspiAccessibleWindow(std::shared_ptr<AccessibleApplication> app, std::shared_ptr<AccessibleNode> node)
 : AccessibleWindow(app, node)
diff --git a/libaurum/src/Impl/Accessibility/AtspiWrapper.cc b/libaurum/src/Impl/Accessibility/AtspiWrapper.cc
new file mode 100644 (file)
index 0000000..308b9af
--- /dev/null
@@ -0,0 +1,146 @@
+#include "AtspiWrapper.h"
+
+std::recursive_mutex AtspiWrapper::mMutex = std::recursive_mutex{};
+//std::unique_lock<std::mutex> AtspiWrapper::mLock = std::unique_lock<std::mutex>(mMutex, std::defer_lock);
+
+GArray* AtspiWrapper::Atspi_state_set_get_states(AtspiStateSet *set)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_state_set_get_states(set);
+}
+
+GArray* AtspiWrapper::Atspi_accessible_get_interfaces(AtspiAccessible *node)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_interfaces(node);
+}
+
+gchar* AtspiWrapper::Atspi_accessible_get_name(AtspiAccessible *node, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_name(node, error);
+}
+
+AtspiAccessible* AtspiWrapper::Atspi_get_desktop(int n)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_get_desktop(n);
+}
+
+int AtspiWrapper::Atspi_accessible_get_child_count(AtspiAccessible *node, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_child_count(node, error);
+}
+
+AtspiAccessible* AtspiWrapper::Atspi_accessible_get_child_at_index(AtspiAccessible *node, int index, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_child_at_index(node, index, error);
+}
+
+AtspiAccessible* AtspiWrapper::Atspi_accessible_get_parent(AtspiAccessible *node, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_parent(node, error);
+}
+
+AtspiStateSet* AtspiWrapper::Atspi_accessible_get_state_set(AtspiAccessible *node)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_state_set(node);
+}
+
+gboolean AtspiWrapper::Atspi_state_set_contains(AtspiStateSet *set , AtspiStateType state)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_state_set_contains(set , state);
+}
+
+gchar* AtspiWrapper::Atspi_accessible_get_role_name(AtspiAccessible *node, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_role_name(node, error);
+}
+
+gchar* AtspiWrapper::Atspi_accessible_get_unique_id(AtspiAccessible *node, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_unique_id(node, error);
+}
+
+GHashTable* AtspiWrapper::Atspi_accessible_get_attributes(AtspiAccessible *node, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_attributes(node, error);
+}
+
+AtspiComponent* AtspiWrapper::Atspi_accessible_get_component_iface(AtspiAccessible *node)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_component_iface(node);
+}
+
+AtspiRect* AtspiWrapper::Atspi_component_get_extents(AtspiComponent *obj, AtspiCoordType ctype, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_component_get_extents(obj, ctype, error);
+}
+
+AtspiAction* AtspiWrapper::Atspi_accessible_get_action_iface(AtspiAccessible *node)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_action_iface(node);
+}
+
+int AtspiWrapper::Atspi_action_get_n_actions(AtspiAction* action, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_action_get_n_actions(action, error);
+}
+
+gchar* AtspiWrapper::Atspi_action_get_action_name(AtspiAction* action, int index, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_action_get_action_name(action, index, error);
+}
+
+gboolean AtspiWrapper::Atspi_action_do_action(AtspiAction *action, int index, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_action_do_action(action, index, error);
+}
+
+AtspiEditableText* AtspiWrapper::Atspi_accessible_get_editable_text(AtspiAccessible *node)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_editable_text(node);
+}
+
+gboolean AtspiWrapper::Atspi_editable_text_delete_text(AtspiEditableText* iface, int start, int end, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_editable_text_delete_text(iface, start, end, error);
+}
+
+gboolean AtspiWrapper::Atspi_editable_text_insert_text(AtspiEditableText* iface, int pos, const gchar *text, int len, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_editable_text_insert_text(iface, pos, text, len, error);
+}
+
+AtspiAccessible* AtspiWrapper::Atspi_accessible_get_application (AtspiAccessible *node, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_application(node, error);
+}
+
+void AtspiWrapper::lock()
+{
+    mMutex.lock();
+}
+
+void AtspiWrapper::unlock()
+{
+    mMutex.unlock();
+}
index 5226d6097df0b6a7f60a193f053d911f157d71b5..fd535cc0bc4770aaade04d314fd3d5b4b6a9f0e7 100644 (file)
@@ -3,6 +3,7 @@
         files('AtspiAccessibleWindow.cc'),
         files('AtspiAccessibleNode.cc'),
         files('AtspiAccessibleWatcher.cc'),
+        files('AtspiWrapper.cc'),
     ]
 
     libaurum_src += [