+ inited = TRUE;
+
+ DRoutePath *treepath, *accpath;
+
+ root = atk_get_root ();
+ g_warn_if_fail (root);
+ if (!root)
+ {
+ inited = FALSE;
+ return -1;
+ }
+
+ /* Parse command line options */
+ opt = g_option_context_new (NULL);
+ g_option_context_add_main_entries (opt, atspi_option_entries, NULL);
+ g_option_context_set_ignore_unknown_options (opt, TRUE);
+ if (!g_option_context_parse (opt, argc, argv, &err))
+ g_warning ("AT-SPI Option parsing failed: %s\n", err->message);
+ g_option_context_free (opt);
+
+ /* Allocate global data and do ATK initializations */
+ spi_global_app_data = g_new0 (SpiBridge, 1);
+ spi_global_app_data->root = g_object_ref (root);
+
+ /* Set up D-Bus connection and register bus name */
+ dbus_error_init (&error);
+ spi_global_app_data->bus = atspi_get_a11y_bus ();
+ if (!spi_global_app_data->bus)
+ {
+ g_free (spi_global_app_data);
+ spi_global_app_data = NULL;
+ inited = FALSE;
+ return -1;
+ }
+
+ if (atspi_dbus_name != NULL)
+ {
+ if (dbus_bus_request_name
+ (spi_global_app_data->bus, atspi_dbus_name, 0, &error))
+ {
+ g_print ("AT-SPI Recieved D-Bus name - %s\n", atspi_dbus_name);
+ }
+ else
+ {
+ g_print
+ ("AT-SPI D-Bus name requested but could not be allocated - %s\n",
+ atspi_dbus_name);
+ }
+ }
+
+ spi_global_app_data->main_context = g_main_context_new ();
+
+ atspi_dbus_connection_setup_with_g_main (spi_global_app_data->bus, NULL);
+
+ /* Hook our plug-and socket functions */
+ install_plug_hooks ();
+
+ /*
+ * Create the leasing, register and cache objects.
+ * The order is important here, the cache depends on the
+ * register object.
+ */
+ spi_global_register = g_object_new (SPI_REGISTER_TYPE, NULL);
+ spi_global_leasing = g_object_new (SPI_LEASING_TYPE, NULL);
+ spi_global_cache = g_object_new (SPI_CACHE_TYPE, NULL);
+
+ /* Register droute for routing AT-SPI messages */
+ spi_global_app_data->droute =
+ droute_new ();
+
+ treepath = droute_add_one (spi_global_app_data->droute,
+ "/org/a11y/atspi/cache", spi_global_cache);
+
+ if (!treepath)