Hyperlink fixes
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / adaptors / collection-adaptor.c
index e920545..3bf76a3 100644 (file)
 #include <atk/atk.h>
 #include <droute/droute.h>
 
-#include "accessible-register.h"
-#include "accessible-marshaller.h"
-
 #include "common/bitarray.h"
 #include "common/spi-dbus.h"
 #include "common/spi-stateset.h"
 
+#include "accessible-register.h"
+#include "object.h"
+#include "introspection.h"
+
 typedef struct _MatchRulePrivate MatchRulePrivate;
 struct _MatchRulePrivate
 {
@@ -52,27 +53,27 @@ static gboolean
 child_interface_p (AtkObject * child, gchar * repo_id)
 {
   if (!strcasecmp (repo_id, "action"))
-    return atk_is_action (child);
+    return ATK_IS_ACTION (child);
   if (!strcasecmp (repo_id, "component"))
-    return atk_is_component (child);
+    return ATK_IS_COMPONENT (child);
   if (!strcasecmp (repo_id, "editabletext"))
-    return atk_is_editable_text (child);
+    return ATK_IS_EDITABLE_TEXT (child);
   if (!strcasecmp (repo_id, "text"))
-    return atk_is_text (child);
+    return ATK_IS_TEXT (child);
   if (!strcasecmp (repo_id, "hypertext"))
-    return atk_is_hypertext (child);
+    return ATK_IS_HYPERTEXT (child);
   if (!strcasecmp (repo_id, "image"))
-    return atk_is_image (child);
+    return ATK_IS_IMAGE (child);
   if (!strcasecmp (repo_id, "selection"))
-    return atk_is_selection (child);
+    return ATK_IS_SELECTION (child);
   if (!strcasecmp (repo_id, "table"))
-    return atk_is_table (child);
+    return ATK_IS_TABLE (child);
   if (!strcasecmp (repo_id, "value"))
-    return atk_is_value (child);
+    return ATK_IS_VALUE (child);
   if (!strcasecmp (repo_id, "streamablecontent"))
-    return atk_is_streamable_content (child);
+    return ATK_IS_STREAMABLE_CONTENT (child);
   if (!strcasecmp (repo_id, "document"))
-    return atk_is_document (child);
+    return ATK_IS_DOCUMENT (child);
   return FALSE;
 }
 
@@ -85,7 +86,7 @@ match_states_all_p (AtkObject * child, gint * set)
   gint i;
   gboolean ret = TRUE;
 
-  if (set == NULL)
+  if (set == NULL || set[0] == BITARRAY_SEQ_TERM)
     return TRUE;
 
   chs = atk_object_ref_state_set (child);
@@ -111,7 +112,7 @@ match_states_any_p (AtkObject * child, gint * set)
   gint i;
   gboolean ret = FALSE;
 
-  if (set == NULL)
+  if (set == NULL || set[0] == BITARRAY_SEQ_TERM)
     return TRUE;
 
   chs = atk_object_ref_state_set (child);
@@ -136,7 +137,7 @@ match_states_none_p (AtkObject * child, gint * set)
   gint i;
   gboolean ret = TRUE;
 
-  if (set == NULL)
+  if (set == NULL || set[0] == BITARRAY_SEQ_TERM)
     return TRUE;
 
   chs = atk_object_ref_state_set (child);
@@ -537,7 +538,8 @@ sort_order_rev_canonical (MatchRulePrivate * mrp, GList * ls,
   /* Add to the list if it matches */
   if (flag && match_interfaces_lookup (obj, mrp)
       && match_states_lookup (obj, mrp)
-      && match_roles_lookup (obj, mrp) && match_attributes_lookup (obj, mrp))
+      && match_roles_lookup (obj, mrp) && match_attributes_lookup (obj, mrp)
+      && (max == 0 || kount < max))
     {
       ls = g_list_append (ls, obj);
       kount++;
@@ -550,7 +552,7 @@ sort_order_rev_canonical (MatchRulePrivate * mrp, GList * ls,
   indexinparent = atk_object_get_index_in_parent (obj);
   parent = atk_object_get_parent (obj);
 
-  if (indexinparent > 0)
+  if (indexinparent > 0 && (max == 0 || kount < max))
     {
       /* there are still some siblings to visit so get the previous sibling
          and get it's last descendant.
@@ -570,7 +572,7 @@ sort_order_rev_canonical (MatchRulePrivate * mrp, GList * ls,
       kount = sort_order_rev_canonical (mrp, ls, kount, max,
                                         nextobj, TRUE, pobj);
     }
-  else
+  else if (max == 0 || kount < max)
     {
       /* no more siblings so next node must be the parent */
       kount = sort_order_rev_canonical (mrp, ls, kount, max,
@@ -762,8 +764,7 @@ return_and_free_list (DBusMessage * message, GList * ls)
     goto oom;
   for (item = ls; item; item = g_list_next (item))
     {
-      spi_dbus_append_name_and_path (message, &iter_array,
-                                     ATK_OBJECT (item->data), TRUE, FALSE);
+      spi_object_append_reference (&iter_array, ATK_OBJECT (item->data));
     }
   if (!dbus_message_iter_close_container (&iter, &iter_array))
     goto oom;
@@ -844,7 +845,7 @@ inorder (AtkObject * collection, MatchRulePrivate * mrp,
       obj = parent;
     }
 
-  if (kount < max)
+  if (max == 0 || kount < max)
     {
       kount = sort_order_canonical (mrp, ls, kount, max,
                                     obj, i + 1, TRUE, FALSE, TRUE, TRUE);
@@ -871,7 +872,7 @@ GetMatchesInOrder (DBusMessage * message,
 
   ls = g_list_append (ls, current_object);
 
-  obj = atk_dbus_path_to_object (dbus_message_get_path (message));
+  obj = ATK_OBJECT(spi_register_path_to_object (spi_global_register, dbus_message_get_path (message)));
 
   kount = inorder (obj, mrp, ls, 0, count,
                    current_object, TRUE, NULL, traverse);
@@ -903,7 +904,7 @@ GetMatchesInBackOrder (DBusMessage * message,
 
   ls = g_list_append (ls, current_object);
 
-  collection = atk_dbus_path_to_object (dbus_message_get_path (message));
+  collection = ATK_OBJECT(spi_register_path_to_object (spi_global_register, dbus_message_get_path (message)));
 
   kount = sort_order_rev_canonical (mrp, ls, 0, count, current_object,
                                     FALSE, collection);
@@ -933,13 +934,13 @@ GetMatchesTo (DBusMessage * message,
 
   if (recurse)
     {
-      obj = atk_object_get_parent (current_object);
+      obj = ATK_OBJECT (atk_object_get_parent (current_object));
       kount = query_exec (mrp, sortby, ls, 0, count,
                           obj, 0, TRUE, current_object, TRUE, traverse);
     }
   else
     {
-      obj = atk_dbus_path_to_object (dbus_message_get_path (message));
+      obj = ATK_OBJECT (spi_register_path_to_object (spi_global_register, dbus_message_get_path (message)));
       kount = query_exec (mrp, sortby, ls, 0, count,
                           obj, 0, TRUE, current_object, TRUE, traverse);
 
@@ -978,7 +979,7 @@ impl_GetMatchesFrom (DBusConnection * bus, DBusMessage * message,
 
   dbus_message_iter_init (message, &iter);
   dbus_message_iter_get_basic (&iter, &current_object_path);
-  current_object = atk_dbus_path_to_object (current_object_path);
+  current_object = ATK_OBJECT (spi_register_path_to_object (spi_global_register, current_object_path));
   if (!current_object)
     {
       // TODO: object-not-found error
@@ -1042,7 +1043,7 @@ impl_GetMatchesTo (DBusConnection * bus, DBusMessage * message,
 
   dbus_message_iter_init (message, &iter);
   dbus_message_iter_get_basic (&iter, &current_object_path);
-  current_object = atk_dbus_path_to_object (current_object_path);
+  current_object = ATK_OBJECT (spi_register_path_to_object (spi_global_register, current_object_path));
   if (!current_object)
     {
       // TODO: object-not-found error
@@ -1086,7 +1087,7 @@ impl_GetMatchesTo (DBusConnection * bus, DBusMessage * message,
 static DBusMessage *
 impl_GetMatches (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkObject *obj = atk_dbus_path_to_object (dbus_message_get_path (message));
+  AtkObject *obj = ATK_OBJECT (spi_register_path_to_object (spi_global_register, dbus_message_get_path (message)));
   DBusMessageIter iter;
   MatchRulePrivate rule;
   dbus_uint32_t sortby;
@@ -1135,5 +1136,5 @@ void
 spi_initialize_collection (DRoutePath * path)
 {
   droute_path_add_interface (path,
-                             SPI_DBUS_INTERFACE_COLLECTION, methods, NULL);
+                             SPI_DBUS_INTERFACE_COLLECTION, spi_org_a11y_atspi_Collection, methods, NULL);
 };