DBusMessage *reply;
AtspiAccessible *return_value = NULL;
unsigned char recurse = 0;
+ DBusMessageIter iter;
+ AtspiAccessible *deputy = NULL;
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);
- AtspiAccessible *tmp = _atspi_dbus_return_accessible_and_recurse_info_from_message (reply, &recurse);
- if (!tmp) break;
+ _ATSPI_DBUS_CHECK_SIG (reply, "(so)y(so)", NULL, NULL);
+
+ dbus_message_iter_init (reply, &iter);
+ AtspiAccessible *tmp = _atspi_dbus_return_accessible_from_iter (&iter);
+
+ unsigned char value = 0;
+ dbus_message_iter_get_basic (&iter, &value);
+ dbus_message_iter_next (&iter);
+ recurse = (value != 0);
+
+ /* keep deputy if tmp has deputy */
+ if (!deputy)
+ deputy = _atspi_dbus_return_accessible_from_iter (&iter);
+
+ dbus_message_unref(reply);
+
+ if (!tmp) {
+ if (deputy) {
+ /* TODO: need to check deputy works for return value */
+ if (return_value)
+ g_object_unref(return_value);
+ return deputy;
+ }
+ break;
+ }
+
if (return_value)
g_object_unref(return_value);
return_value = root = tmp;
unsigned char recurse;
GetNeighborSearchMode search_mode = NEIGHBOR_SEARCH_MODE_NORMAL;
GQueue *children_root_stack = g_queue_new();
+ DBusMessageIter iter;
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);
- AtspiAccessible *ret = _atspi_dbus_return_accessible_and_recurse_info_from_message (reply, &recurse);
+
+ dbus_message_iter_init (reply, &iter);
+ AtspiAccessible *ret = _atspi_dbus_return_accessible_from_iter (&iter);
+
+ unsigned char value = 0;
+ dbus_message_iter_get_basic (&iter, &value);
+ dbus_message_iter_next (&iter);
+ recurse = (value != 0);
+
+ dbus_message_unref(reply);
+
// got return value and request for recursive search, it means ret is on another bridge, than start
// thus we're recursing. should the recurse failed to find anything it will end with
if (ret && recurse) {
if (!g_queue_is_empty(children_root_stack)) {
g_object_unref(G_OBJECT(start));
start = g_queue_pop_tail(children_root_stack);
+
search_mode = NEIGHBOR_SEARCH_MODE_CONTINUE_AFTER_FAILED_RECURSING;
continue;
}
g_object_unref(G_OBJECT(start));
start = parent;
}
+
// going up thru parents put us in weird place (we didnt meet root on the way)
// so we bail out
if (!start)
return ref_accessible (app, path);
}
-static AtspiAccessible *
-_atspi_dbus_return_accessible_and_recurse_info_from_message_impl (DBusMessage *message, unsigned char *recurse)
+AtspiAccessible *
+_atspi_dbus_return_accessible_from_message (DBusMessage *message)
{
DBusMessageIter iter;
AtspiAccessible *retval = NULL;
const char *signature;
- const char *expected_signature = recurse ? "(so)y" : "(so)";
- if (!message) return NULL;
+ if (!message)
+ return NULL;
signature = dbus_message_get_signature (message);
- if (!strcmp (signature, expected_signature))
+ if (!strcmp (signature, "(so)"))
{
dbus_message_iter_init (message, &iter);
retval = _atspi_dbus_return_accessible_from_iter (&iter);
- if (recurse) {
- unsigned char value = 0;
- dbus_message_iter_get_basic (&iter, &value);
- dbus_message_iter_next (&iter);
- *recurse = (value != 0);
- }
}
else
{
- g_warning ("AT-SPI: Called _atspi_dbus_return_accessible_from_message with unexpected signature %s", signature);
+ g_warning ("AT-SPI: Called _atspi_dbus_return_accessible_from_message with strange signature %s", signature);
}
dbus_message_unref (message);
return retval;
}
AtspiAccessible *
-_atspi_dbus_return_accessible_from_message (DBusMessage *message)
-{
- return _atspi_dbus_return_accessible_and_recurse_info_from_message_impl(message, NULL);
-}
-
-AtspiAccessible *
-_atspi_dbus_return_accessible_and_recurse_info_from_message(DBusMessage *message, unsigned char *recurse)
-{
- if (recurse == NULL) {
- g_error("AT-SPI: Called _atspi_dbus_return_accessible_and_recurse_info_from_message with NULL argument recurse");
- dbus_message_unref (message);
- return NULL;
- }
- return _atspi_dbus_return_accessible_and_recurse_info_from_message_impl(message, recurse);
-}
-
-AtspiAccessible *
_atspi_dbus_return_accessible_from_iter (DBusMessageIter *iter)
{
const char *app_name, *path;