#include "atspi-gmain.h"
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
/* This value is not fixed, could be changed. */
-#define HASH_TABLE_SIZE_MAX 1000
+#define HASH_TABLE_SIZE_MAX 3000
static void handle_get_items (DBusPendingCall *pending, void *user_data);
dbus_message_iter_get_basic (&iter_struct, &index);
if (index >= 0 && accessible->accessible_parent)
{
- if (index >= accessible->accessible_parent->children->len) {
+ if (index >= accessible->accessible_parent->children->len)
+ {
/* There is no room for this object */
g_ptr_array_set_size (accessible->accessible_parent->children, index + 1);
- } else {
+ }
+ else
+ {
/* This place is already taken - let's free this place with dignity */
- g_object_unref (g_ptr_array_index (accessible->accessible_parent->children, index));
+ if (g_ptr_array_index (accessible->accessible_parent->children, index))
+ g_object_unref (g_ptr_array_index (accessible->accessible_parent->children, index));
}
g_ptr_array_index (accessible->accessible_parent->children, index) = g_object_ref (accessible);
}
BusDataClosure *c = ptr;
dbus_message_unref (c->message);
dbus_connection_unref (c->bus);
- g_free(c);
+ g_free (c);
}
static void
cleanup_deferred_message(void)
{
- g_queue_free_full(deferred_messages, destroy_deferred_message_item);
+ g_queue_free_full (deferred_messages, destroy_deferred_message_item);
deferred_messages = NULL;
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-/*
- * Returns a 'canonicalized' value for DISPLAY,
- * with the screen number stripped off if present.
- *
- * TODO: Avoid having duplicate functions for this here and in at-spi2-atk
- */
-static gchar *
-spi_display_name (void)
-{
- char *canonical_display_name = NULL;
- const gchar *display_env = g_getenv ("AT_SPI_DISPLAY");
-
- if (!display_env)
- {
- display_env = g_getenv ("DISPLAY");
- if (!display_env || !display_env[0])
- return NULL;
- else
- {
- gchar *display_p, *screen_p;
- canonical_display_name = g_strdup (display_env);
- display_p = g_utf8_strrchr (canonical_display_name, -1, ':');
- screen_p = g_utf8_strrchr (canonical_display_name, -1, '.');
- if (screen_p && display_p && (screen_p > display_p))
- {
- *screen_p = '\0';
- }
- }
- }
- else
- {
- canonical_display_name = g_strdup (display_env);
- }
-
- return canonical_display_name;
-}
-
/**
* atspi_init:
*
process_deferred_messages ();
if (!reply)
{
- // TODO: throw exception
+ /* TODO: throw exception */
goto done;
}
}
if (!strcmp (type, "(so)"))
{
- g_object_unref(*(AtspiAccessible**)data);
*((AtspiAccessible **)data) = _atspi_dbus_return_accessible_from_iter (&iter_variant);
}
else
{
if (type [0] == 's')
{
- g_free(*(char**)data);
*(char**) data = NULL;
}
* Gets the IOR from the XDisplay.
*/
#ifdef HAVE_X11
+/*
+ * Returns a 'canonicalized' value for DISPLAY,
+ * with the screen number stripped off if present.
+ *
+ * TODO: Avoid having duplicate functions for this here and in at-spi2-atk
+ */
+static gchar *
+spi_display_name (void)
+{
+ char *canonical_display_name = NULL;
+ const gchar *display_env = g_getenv ("AT_SPI_DISPLAY");
+
+ if (!display_env)
+ {
+ display_env = g_getenv ("DISPLAY");
+ if (!display_env || !display_env[0])
+ return NULL;
+ else
+ {
+ gchar *display_p, *screen_p;
+ canonical_display_name = g_strdup (display_env);
+ display_p = g_utf8_strrchr (canonical_display_name, -1, ':');
+ screen_p = g_utf8_strrchr (canonical_display_name, -1, '.');
+ if (screen_p && display_p && (screen_p > display_p))
+ {
+ *screen_p = '\0';
+ }
+ }
+ }
+ else
+ {
+ canonical_display_name = g_strdup (display_env);
+ }
+
+ return canonical_display_name;
+}
+
static char *
get_accessibility_bus_address_x11 (void)
{
dbus_error_init (&error);
reply = dbus_connection_send_with_reply_and_block (session_bus,
message,
- -1,
+ 15000,
&error);
dbus_message_unref (message);
dbus_connection_add_filter (a11y_bus, screen_reader_filter, NULL, NULL);
return TRUE;
}
+
+gchar *
+_atspi_strdup_and_adjust_for_dbus (const char *s)
+{
+ gchar *d = g_strdup (s);
+ gchar *p;
+ int parts = 0;
+
+ if (!d)
+ return NULL;
+
+ for (p = d; *p; p++)
+ {
+ if (*p == '-')
+ {
+ memmove (p, p + 1, g_utf8_strlen (p, -1));
+ *p = toupper (*p);
+ }
+ else if (*p == ':')
+ {
+ parts++;
+ if (parts == 2)
+ break;
+ p [1] = toupper (p [1]);
+ }
+ }
+
+ d [0] = toupper (d [0]);
+ return d;
+}