Merge "Add atspi_accessible_get_default_label_info" into tizen_4.0
[platform/upstream/at-spi2-core.git] / atspi / atspi-accessible.c
index 40053f2..6612a21 100644 (file)
@@ -346,7 +346,12 @@ atspi_accessible_get_navigable_at_point (AtspiAccessible *root,
   g_return_val_if_fail (root != NULL, NULL);
   do {
     reply = _atspi_dbus_call_partial (root, atspi_interface_accessible, "GetNavigableAtPoint", error, "iiu", d_x, d_y, d_ctype);
-
+    // call failed, error is set, so we bail out
+    if (!reply) {
+      if (deputy) g_object_unref(deputy);
+      if (return_value) g_object_unref(return_value);
+      return NULL;
+    }
     _ATSPI_DBUS_CHECK_SIG (reply, "(so)y(so)", NULL, NULL);
 
     dbus_message_iter_init (reply, &iter);
@@ -560,6 +565,54 @@ atspi_accessible_get_reading_material (AtspiAccessible *obj, GError **error)
   return reading_material;
 }
 
+/**
+ * atspi_accessible_get_default_label_info:
+ * @obj: a pointer to the #AtspiAccessible object would be window.
+ *
+ * Gets default label information
+ *
+ * Returns: default label information to be used screen-reader side.
+ * This is not stable. And this depends on toolkit side UI definition.
+ * The candidate of default label object could be changed by UI definition.
+ * You have to handle all alocated memory as below on screen-reader side.
+ *
+ * AtspiAccessibleDefaultLabelInfo *dli
+ * g_object_unref(dli->obj);
+ * free(dli);
+ **/
+AtspiAccessibleDefaultLabelInfo *
+atspi_accessible_get_default_label_info (AtspiAccessible *obj, GError **error)
+{
+  AtspiAccessibleDefaultLabelInfo *default_label_info = NULL;
+  AtspiAccessible *default_label_object;
+  dbus_uint32_t role;
+  DBusMessage *reply;
+  DBusMessageIter iter;
+
+  g_return_val_if_fail (obj != NULL, NULL);
+
+  reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetDefaultLabelInfo", error, "");
+
+  _ATSPI_DBUS_CHECK_SIG (reply, "(so)u", NULL, NULL);
+
+  default_label_info = calloc(1, sizeof(AtspiAccessibleDefaultLabelInfo));
+  if (!default_label_info)
+  {
+    return default_label_info;
+  }
+
+  dbus_message_iter_init (reply, &iter);
+
+  default_label_object =  _atspi_dbus_return_accessible_from_iter (&iter);
+  default_label_info->obj = default_label_object;
+
+  dbus_message_iter_get_basic (&iter, &role);
+  default_label_info->role = role;
+  dbus_message_iter_next (&iter);
+
+  return default_label_info;
+}
+
 static unsigned char are_objects_on_the_same_bus(AtspiAccessible *obj1, AtspiAccessible *obj2)
 {
   const char *bus_name_1 = obj1->parent.app->bus_name;
@@ -616,7 +669,10 @@ atspi_accessible_get_neighbor (AtspiAccessible *root,
   while(1) {
     const char *path = are_objects_on_the_same_bus(root, start) ? root_path : "";
     DBusMessage *reply = _atspi_dbus_call_partial (start, atspi_interface_accessible, "GetNeighbor", error, "sii", path, (int)direction, (int)search_mode);
+    // call failed, error is set, so we bail out
+    if (!reply) break;
 
+    _ATSPI_DBUS_CHECK_SIG (reply, "(so)y", error, NULL);
     dbus_message_iter_init (reply, &iter);
     AtspiAccessible *ret = _atspi_dbus_return_accessible_from_iter (&iter);
 
@@ -683,7 +739,6 @@ atspi_accessible_get_neighbor (AtspiAccessible *root,
 
     // nothing found
     g_object_unref(start);
-    return_value = NULL;
     break;
   }
   while(!g_queue_is_empty(children_root_stack))