[at-spi2-core/gi] Various bug fixes



commit 5544649ae7afb697e59ca8e9c2b8694f2a8dea39
Author: Mike Gorse <mgorse novell com>
Date:   Wed Oct 27 12:37:53 2010 -0400

    Various bug fixes

 atspi/Makefile.am         |    2 +
 atspi/atspi-accessible.c  |   27 ++++++++++++++++---
 atspi/atspi-accessible.h  |   11 +------
 atspi/atspi-application.c |   57 ++++++++++++++++++++++++++++++++++++++++
 atspi/atspi-application.h |   57 ++++++++++++++++++++++++++++++++++++++++
 atspi/atspi-misc.c        |   64 +++++++++++++++++++++------------------------
 atspi/atspi-registry.c    |    9 ++----
 7 files changed, 174 insertions(+), 53 deletions(-)
---
diff --git a/atspi/Makefile.am b/atspi/Makefile.am
index ecce49f..83265fc 100644
--- a/atspi/Makefile.am
+++ b/atspi/Makefile.am
@@ -15,6 +15,8 @@ libatspi_la_SOURCES =		\
 	atspi.h			\
 	atspi-accessible.c \
 	atspi-accessible.h \
+	atspi-application.c \
+	atspi-application.h \
 	atspi-constants.h \
 	atspi-event-types.h \
 	atspi-listener.c \
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 2a9d071..f9c6c31 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -31,8 +31,20 @@ atspi_accessible_init (AtspiAccessible *accessible)
 }
 
 static void
+atspi_accessible_finalize (AtspiAccessible *accessible)
+{
+  if (accessible->app)
+    g_object_unref (accessible->app);
+
+  g_free (accessible->path);
+}
+
+static void
 atspi_accessible_class_init (AtspiAccessibleClass *klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = atspi_accessible_finalize;
 }
 /* TODO: Generate following from spec? */
 static const char *role_names [] =
@@ -229,8 +241,8 @@ atspi_accessible_get_child_count (AtspiAccessible *obj, GError *error)
  *
  * Get the #AtspiAccessible child of an #AtspiAccessible object at a given index.
  *
- * Returns: a pointer to the #AtspiAccessible child object at index
- *          @child_index. or NULL on exception
+ * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
+ * index @child_index. or NULL on exception
  **/
 AtspiAccessible *
 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
@@ -392,7 +404,8 @@ atspi_accessible_get_state_set (AtspiAccessible *obj)
  * For typographic, textual, or textually-semantic attributes, see
  * atspi_text_get_attributes instead.
  *
- * Returns: The name-value-pair attributes assigned to this object.
+ * Returns: (transfer full): The name-value-pair attributes assigned to this
+ * object.
  */
 GHashTable *
 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
@@ -1191,7 +1204,10 @@ cspi_object_destroyed (AtspiAccessible *accessible)
   e.type = "object:state-change:defunct";
   e.source = accessible;
   e.detail1 = 1;
+#if 0
+  g_warning ("atspi: TODO: Finish events");
   atspi_dispatch_event (&e);
+#endif
 
     g_free (accessible->path);
 
@@ -1202,12 +1218,15 @@ cspi_object_destroyed (AtspiAccessible *accessible)
 }
 
 AtspiAccessible *
-atspi_accessible_new ()
+atspi_accessible_new (AtspiApplication *app, const gchar *path)
 {
   AtspiAccessible *accessible;
   
   accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
   g_return_val_if_fail (accessible != NULL, NULL);
 
+  accessible->app = g_object_ref (app);
+  accessible->path = g_strdup (path);
+
   return accessible;
 }
diff --git a/atspi/atspi-accessible.h b/atspi/atspi-accessible.h
index dce3d5c..3c0cbd4 100644
--- a/atspi/atspi-accessible.h
+++ b/atspi/atspi-accessible.h
@@ -27,6 +27,7 @@
 
 #include "glib-object.h"
 
+#include "atspi-application.h"
 #include "atspi-constants.h"
 #include "atspi-stateset.h"
 
@@ -37,14 +38,6 @@
 #define ATSPI_IS_ACCESSIBLE_CLASS(klass)             (G_TYPE_CHECK_CLASS_TYPE ((klass), ATSPI_TYPE_ACCESSIBLE))
 #define ATSPI_ACCESSIBLE_GET_CLASS(obj)              (G_TYPE_INSTANCE_GET_CLASS ((obj), ATSPI_TYPE_ACCESSIBLE, AtspiAccessibleClass))
 
-typedef struct _AtspiApplication AtspiApplication;
-struct _AtspiApplication
-{
-  GHashTable *hash;
-  char *bus_name;
-  struct _AtspiAccessible *root;
-};
-
 typedef struct _AtspiAccessible AtspiAccessible;
 struct _AtspiAccessible
 {
@@ -70,7 +63,7 @@ struct _AtspiAccessibleClass
 GType atspi_accessible_get_type (void); 
 
 AtspiAccessible *
-atspi_accessible_new ();
+atspi_accessible_new (AtspiApplication *app, const gchar *path);
 
 gchar * atspi_role_get_name (AtspiRole role);
 
diff --git a/atspi/atspi-application.c b/atspi/atspi-application.c
new file mode 100644
index 0000000..c037c4b
--- /dev/null
+++ b/atspi/atspi-application.c
@@ -0,0 +1,57 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "atspi-private.h"
+
+G_DEFINE_TYPE (AtspiApplication, atspi_application, G_TYPE_OBJECT)
+
+static void
+atspi_application_init (AtspiApplication *application)
+{
+}
+
+static void
+atspi_application_finalize (AtspiApplication *application)
+{
+  if (application->bus_name)
+    g_free (application->bus_name);
+}
+
+static void
+atspi_application_class_init (AtspiApplicationClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = atspi_application_finalize;
+}
+
+AtspiApplication *
+_atspi_application_new (const gchar *bus_name)
+{
+  AtspiApplication *application;
+  
+  application = g_object_new (ATSPI_TYPE_APPLICATION, NULL);
+  if (application)
+    application->bus_name = g_strdup (bus_name);
+  return application;
+}
diff --git a/atspi/atspi-application.h b/atspi/atspi-application.h
new file mode 100644
index 0000000..be3d4e1
--- /dev/null
+++ b/atspi/atspi-application.h
@@ -0,0 +1,57 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2002 Ximian, Inc.
+ *           2002 Sun Microsystems Inc.
+ *           
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _ATSPI_APPLICATION_H_
+#define _ATSPI_APPLICATION_H_
+
+#include "glib-object.h"
+
+#include "atspi-accessible.h"
+
+#define ATSPI_TYPE_APPLICATION                        (atspi_application_get_type ())
+#define ATSPI_APPLICATION(obj)                        (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_APPLICATION, AtspiAccessible))
+#define ATSPI_APPLICATION_CLASS(klass)                (G_TYPE_CHECK_CLASS_CAST ((klass), ATSPI_TYPE_APPLICATION, AtspiAccessibleClass))
+#define ATSPI_IS_APPLICATION(obj)                     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATSPI_TYPE_APPLICATION))
+#define ATSPI_IS_APPLICATION_CLASS(klass)             (G_TYPE_CHECK_CLASS_TYPE ((klass), ATSPI_TYPE_APPLICATION))
+#define ATSPI_APPLICATION_GET_CLASS(obj)              (G_TYPE_INSTANCE_GET_CLASS ((obj), ATSPI_TYPE_APPLICATION, AtspiAccessibleClass))
+
+typedef struct _AtspiApplication AtspiApplication;
+struct _AtspiApplication
+{
+  GObject parent;
+  GHashTable *hash;
+  char *bus_name;
+  struct _AtspiAccessible *root;
+};
+
+typedef struct _AtspiApplicationClass AtspiApplicationClass;
+struct _AtspiApplicationClass
+{
+  GObjectClass parent_class;
+};
+
+AtspiApplication *
+_atspi_application_new (const char *bus_name);
+
+#endif	/* _ATSPI_APPLICATION_H_ */
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index 874d533..94aae8e 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -99,9 +99,12 @@ get_live_refs (void)
   return live_refs;
 }
 
+/* TODO: Add an application parameter */
 DBusConnection *
 _atspi_bus ()
 {
+  if (!bus)
+    atspi_init ();
   return bus;
 }
 
@@ -140,7 +143,7 @@ get_application (const char *bus_name)
   bus_name_dup = g_strdup (bus_name);
   if (!bus_name_dup) return NULL;
   // TODO: change below to something that will send state-change:defunct notification if necessary */
-  app = g_new (AtspiApplication, 1);
+  app = _atspi_application_new (bus_name);
   if (!app) return NULL;
   app->bus_name = bus_name_dup;
   if (APP_IS_REGISTRY (app))
@@ -158,37 +161,29 @@ get_application (const char *bus_name)
 static AtspiAccessible *
 ref_accessible (const char *app_name, const char *path)
 {
-  int id;
-  guint *id_val;
   AtspiApplication *app = get_application (app_name);
   AtspiAccessible *a;
 
   if (!strcmp (path, "/org/a11y/atspi/accessible/root"))
-    return g_object_ref (app->root);
-
-  if (sscanf (path, "/org/a11y/atspi/accessible/%d", &id) != 1)
   {
-    return NULL;
+    if (!app->root)
+    {
+      app->root = atspi_accessible_new (app, atspi_path_root);
+      app->root->accessible_parent = atspi_get_desktop (0);
+    }
+    return g_object_ref (app->root);
   }
 
-  a = g_hash_table_lookup (app->hash, &id);
+  a = g_hash_table_lookup (app->hash, path);
   if (a)
   {
     g_object_ref (a);
     return a;
   }
-  id_val = g_new (guint, 1);
-  if (!id_val) return NULL;
-  *id_val = id;
-  a = atspi_accessible_new ();
+  a = atspi_accessible_new (app, path);
   if (!a)
-  {
-    g_free (id_val);
     return NULL;
-  }
-  a->app = app;
-  a->path = g_strdup_printf ("/org/a11y/atspi/accessible/%d", id);
-  g_hash_table_insert (app->hash, id_val, a);
+  g_hash_table_insert (app->hash, a->path, a);
   g_object_ref (a);	/* for the hash */
   return a;
 }
@@ -233,13 +228,7 @@ handle_remove_accessible (DBusConnection *bus, DBusMessage *message, void *user_
     a->accessible_parent->children = g_list_remove (a->accessible_parent->children, a);
     g_object_unref (a);
   }
-  if (sscanf (a->path, "/org/a11y/atspi/accessible/%d", &id) == 1)
-  {
-    g_warning("atspi: FIX HASH REMOVE");
-    g_hash_table_remove (app->hash, id);
-  }
-  else
-    g_warning ("libspi: Strange path %s\n", a->path);
+  g_hash_table_remove (app->hash, app->bus_name);
   g_object_unref (a);	/* unref our own ref */
   return DBUS_HANDLER_RESULT_HANDLED;
 }
@@ -277,7 +266,10 @@ send_children_changed (AtspiAccessible *parent, AtspiAccessible *child, gboolean
   e.type = (add? "object:children-changed:add": "object:children-changed:remove");
   e.source = parent;
   e.detail1 = g_list_index (parent->children, child);
+#if 0
+  g_warning ("atspi: TODO: Finish events");
   atspi_dispatch_event (&e);
+#endif
 }
 
 static void
@@ -289,7 +281,7 @@ unref_object_and_descendants (AtspiAccessible *obj)
   {
     unref_object_and_descendants (l->data);
   }
-  g_object_unref_internal (obj, TRUE);
+  g_object_unref (obj);
 }
 
 static gboolean
@@ -322,8 +314,9 @@ get_reference_from_iter (DBusMessageIter *iter, const char **app_name, const cha
   DBusMessageIter iter_struct;
 
   dbus_message_iter_recurse (iter, &iter_struct);
-  dbus_message_iter_get_basic (&iter_struct, &app_name);
-  dbus_message_iter_get_basic (&iter_struct, &path);
+  dbus_message_iter_get_basic (&iter_struct, app_name);
+  dbus_message_iter_next (&iter_struct);
+  dbus_message_iter_get_basic (&iter_struct, path);
   dbus_message_iter_next (iter);
 }
 
@@ -347,6 +340,9 @@ add_accessible_from_iter (DBusMessageIter *iter)
   get_reference_from_iter (&iter_struct, &app_name, &path);
   accessible = ref_accessible (app_name, path);
 
+  /* Get application: TODO */
+  dbus_message_iter_next (&iter_struct);
+
   /* get parent */
   get_reference_from_iter (&iter_struct, &app_name, &path);
   accessible->accessible_parent = ref_accessible (app_name, path);
@@ -378,6 +374,7 @@ add_accessible_from_iter (DBusMessageIter *iter)
       g_warning ("Unknown interface %s", iface);
     }
     else accessible->interfaces |= (1 << n);
+    dbus_message_iter_next (&iter_array);
   }
   dbus_message_iter_next (&iter_struct);
 
@@ -426,9 +423,9 @@ add_accessibles (const char *app_name)
   AtspiApplication *app = get_application (app_name);
   /* TODO: Move this functionality into app initializer? */
   dbus_error_init (&error);
-  message = dbus_message_new_method_call (app_name, "/org/a11y/atspi/accessible/cache", atspi_interface_cache, "GetItems");
+  message = dbus_message_new_method_call (app_name, "/org/a11y/atspi/cache", atspi_interface_cache, "GetItems");
   reply = _atspi_dbus_send_with_reply_and_block (message);
-  if (!reply || strcmp (dbus_message_get_signature (reply), "a((so)(so)a(so)assusau)") != 0)
+  if (!reply || strcmp (dbus_message_get_signature (reply), "a((so)(so)(so)a(so)assusau)") != 0)
   {
     g_warning ("at-spi: Error in GetItems");
     return;
@@ -461,13 +458,12 @@ ref_accessible_desktop (AtspiApplication *app)
     g_object_ref (desktop);
     return desktop;
   }
-  desktop = atspi_accessible_new ();
+  desktop = atspi_accessible_new (app, atspi_path_root);
   if (!desktop)
   {
     return NULL;
   }
-  g_hash_table_insert (app->hash, 0, desktop);
-  desktop->app = app;
+  g_hash_table_insert (app->hash, desktop->path, desktop);
   g_object_ref (desktop);	/* for the hash */
   desktop->name = g_strdup ("main");
   dbus_error_init (&error);
@@ -478,7 +474,7 @@ ref_accessible_desktop (AtspiApplication *app)
   if (!message)
     return;
   reply = _atspi_dbus_send_with_reply_and_block (message);
-  if (!reply || strcmp (dbus_message_get_signature (reply), "a(so") != 0)
+  if (!reply || strcmp (dbus_message_get_signature (reply), "a(so)") != 0)
   {
     g_error ("Couldn't get application list: %s", error.message);
     if (reply)
diff --git a/atspi/atspi-registry.c b/atspi/atspi-registry.c
index 2e4763b..3bf5b60 100644
--- a/atspi/atspi-registry.c
+++ b/atspi/atspi-registry.c
@@ -49,8 +49,8 @@ atspi_get_desktop_count ()
  * Get the virtual desktop indicated by index @i.
  * NOTE: currently multiple virtual desktops are not implemented.
  *
- * Returns: a pointer to the 'i-th' virtual desktop's #AtspiAccessible
- * representation.
+ * Returns: (transfer full): a pointer to the 'i-th' virtual desktop's
+ * #AtspiAccessible representation.
  **/
 AtspiAccessible*
 atspi_get_desktop (gint i)
@@ -61,7 +61,6 @@ atspi_get_desktop (gint i)
 
 /**
  * atspi_get_desktop_list:
- * @desktop_list: a pointer to an array of #Accessible references.
  *
  * Get the list of virtual desktops.  On return, @list will point
  *     to a newly-created, NULL terminated array of virtual desktop
@@ -72,10 +71,8 @@ atspi_get_desktop (gint i)
  * Not Yet Implemented : this implementation always returns a single
  * #Accessible desktop.
  *
- * Returns: an integer indicating how many virtual desktops have been
- *          placed in the list pointed to by parameter @list.
+ * Returns: (transfer full): a #GArray of desktops.
  **/
-/* TODO: Make this a garray */
 GArray *
 atspi_get_desktop_list ()
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]