Use the new 'Accessibility' bus if the bus address is available
[platform/core/uifw/at-spi2-atk.git] / cspi / spi-registry.c
index ede820d..9629c4f 100644 (file)
@@ -39,9 +39,7 @@ static GArray *desktops;
 int
 SPI_getDesktopCount ()
 {
-  if (!desktops) SPI_getDesktopList (NULL);
-  if (!desktops) return -1;
-  return desktops->len;
+  return 1;
 }
 
 /**
@@ -57,9 +55,8 @@ SPI_getDesktopCount ()
 Accessible*
 SPI_getDesktop (int i)
 {
-  if (!desktops) SPI_getDesktopList (NULL);
-  if (!desktops) return NULL;
-  return cspi_ref_accessible (spi_bus_registry, g_array_index (desktops, char *, i));
+  if (i != 0) return NULL;
+  return cspi_ref_accessible (spi_bus_registry, NULL);
 }
 
 /**
@@ -81,29 +78,16 @@ SPI_getDesktop (int i)
 int
 SPI_getDesktopList (Accessible ***desktop_list)
 {
-  int i;
   Accessible **list;
 
-  if (desktop_list) *desktop_list = NULL;
+  list = g_new0 (Accessible *, 2);
 
-  if (!desktops)
-  {
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_registry, spi_interface_registry, "getDesktopList", NULL, "=>ao", &desktops);
-    if (!desktops) return 0;
-  }
-
-  list = g_new0 (Accessible *, desktops->len + 1);
-
-  if (!desktop_list) return desktops->len;
-  for (i = 0; i < desktops->len; i++)
-    {
-      list [i] = cspi_ref_accessible (spi_bus_registry, g_array_index (desktops, char *, i));
-    }
-  list [i] = NULL;
+  if (!desktop_list) return 1;
+  list [0] = cspi_ref_accessible (spi_bus_registry, NULL);
 
   *desktop_list = list;
 
-  return i;
+  return 1;
 }
 
 /**
@@ -226,7 +210,7 @@ SPI_registerAccessibleKeystrokeListener (AccessibleKeystrokeListener  *listener,
          (dbus_bool_t) ((sync_type & SPI_KEYLISTENER_ALL_WINDOWS)!=0);
 
     dbus_error_init (&error);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "registerKeystrokeListener", &error, "oa(iisi)uu(bbb)=>b", path, key_set, controller_event_mask, key_set, &listener_mode, &retval);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "registerKeystrokeListener", &error, "oa(iisi)uu(bbb)=>b", path, key_set, controller_event_mask, key_events, &listener_mode, &retval);
 
   g_array_free (key_set, TRUE);
   g_free (path);
@@ -265,7 +249,7 @@ SPI_deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener
   controller_event_mask = (dbus_uint32_t) modmask;
 
       key_set = g_array_sized_new (FALSE, TRUE, sizeof (Accessibility_KeyDefinition), 0);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "deregisterKeystrokeListener", &error, "oa(iisi)uu", path, &key_set, key_events, controller_event_mask);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "deregisterKeystrokeListener", &error, "oa(iisi)uu", path, &key_set, key_events, controller_event_mask);
   g_free (path);
   return TRUE;
 }
@@ -310,7 +294,7 @@ SPI_registerDeviceEventListener (AccessibleDeviceListener  *listener,
     }
 
   dbus_error_init (&error);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "registerDeviceEventListener", &error, "ou=>b", path, event_types, &retval);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "registerDeviceEventListener", &error, "ou=>b", path, event_types, &retval);
   g_free (path);
   return retval;
 }
@@ -343,7 +327,7 @@ SPI_deregisterDeviceEventListener (AccessibleDeviceListener *listener,
   event_types |= (1 << Accessibility_BUTTON_RELEASED_EVENT);
 
   dbus_error_init (&error);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "deregisterDeviceEventListener", &error, "ou", path, event_types);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "deregisterDeviceEventListener", &error, "ou", path, event_types);
   g_free (path);
   return TRUE;
 }
@@ -399,7 +383,7 @@ SPI_generateKeyboardEvent (long int keyval,
 
   if (!keystring) keystring = "";
   dbus_error_init (&error);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "generateKeyboardEvent", &error, "isu", keycode, keystring, keysynth_type);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "generateKeyboardEvent", &error, "isu", keycode, keystring, keysynth_type);
 
   return TRUE;
 }
@@ -427,7 +411,7 @@ SPI_generateMouseEvent (long x, long y, char *name)
   DBusError error;
 
   dbus_error_init (&error);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "generateMouseEvent", &error, "iis", x, y, name);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "generateMouseEvent", &error, "iis", x, y, name);
   return TRUE;
 }