Fix some missing prototypes
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / event.c
index 4b23c64..2253ec0 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <string.h>
+#include <ctype.h>
 
 #include <atk/atk.h>
 #include <droute/droute.h>
@@ -31,6 +32,9 @@
 #include "accessible-register.h"
 
 #include "common/spi-dbus.h"
+#include "event.h"
+#include "object.h"
+#include "dbus/dbus-glib-lowlevel.h"
 
 static GArray *listener_ids = NULL;
 
@@ -55,6 +59,10 @@ typedef struct _SpiReentrantCallClosure
 static void
 switch_main_context (GMainContext *cnx)
 {
+/* This code won't work on dbus-glib earlier than 0.9.0 because of FDO#30574 */
+  if (spi_global_app_data->app_bus_addr [0] == '\0')
+    return;
+
   GList *list;
 
   dbus_server_setup_with_g_main (spi_global_app_data->server, cnx);
@@ -69,6 +77,7 @@ set_reply (DBusPendingCall * pending, void *user_data)
   SpiReentrantCallClosure* closure = (SpiReentrantCallClosure *) user_data; 
 
   closure->reply = dbus_pending_call_steal_reply (pending);
+  dbus_pending_call_unref (pending);
   switch_main_context (NULL);
   g_main_loop_quit (closure->loop);
 }
@@ -85,7 +94,7 @@ send_and_allow_reentry (DBusConnection * bus, DBusMessage * message)
   closure.loop = g_main_loop_new (main_context, FALSE);
   switch_main_context (main_context);
 
-  if (!dbus_connection_send_with_reply (bus, message, &pending, -1))
+  if (!dbus_connection_send_with_reply (bus, message, &pending, -1) || !pending)
     {
       switch_main_context (NULL);
       return NULL;
@@ -343,6 +352,9 @@ signal_is_needed (const gchar *klass, const gchar *major, const gchar *minor)
   gboolean ret = FALSE;
   GList *list;
 
+  if (!spi_global_app_data->events_initialized)
+    return TRUE;
+
   data [0] = ensure_proper_format (klass + 21);
   data [1] = ensure_proper_format (major);
   data [2] = ensure_proper_format (minor);
@@ -389,8 +401,7 @@ emit_event (AtkObject  *obj,
             void (*append_variant) (DBusMessageIter *, const char *, const void *))
 {
   DBusConnection *bus = spi_global_app_data->bus;
-  const char *path =  spi_register_object_to_path (spi_global_register,
-                                                   G_OBJECT (obj));
+  const char *path;
 
   gchar *cname, *t;
   DBusMessage *sig;
@@ -404,6 +415,8 @@ emit_event (AtkObject  *obj,
   if (!signal_is_needed (klass, major, minor))
     return;
 
+  path =  spi_register_object_to_path (spi_global_register, G_OBJECT (obj));
+
   /*
    * This is very annoying, but as '-' isn't a legal signal
    * name in D-Bus (Why not??!?) The names need converting
@@ -411,7 +424,6 @@ emit_event (AtkObject  *obj,
    */
   cname = signal_name_to_dbus (major);
   sig = dbus_message_new_signal(path, klass, cname);
-  g_free(cname);
 
   dbus_message_iter_init_append(sig, &iter);
 
@@ -426,6 +438,9 @@ emit_event (AtkObject  *obj,
 
   if (g_strcmp0 (cname, "ChildrenChanged") != 0)
     spi_object_lease_if_needed (G_OBJECT (obj));
+
+  g_free(cname);
+  g_free (path);
 }
 
 /*---------------------------------------------------------------------------*/