static void ibus_bus_connect (IBusBus *bus) { IBusBusPrivate *priv; priv = IBUS_BUS_GET_PRIVATE (bus); /* destry old connection at first */ if (priv->connection != NULL) { ibus_object_destroy ((IBusObject *)priv->connection); g_assert (priv->connection == NULL); } if (ibus_get_address () != NULL) { priv->connection = ibus_connection_open (ibus_get_address ()); } if (priv->connection) { ibus_bus_hello (bus); g_signal_connect (priv->connection, "destroy", (GCallback) _connection_destroy_cb, bus); g_signal_emit (bus, bus_signals[CONNECTED], 0); if (priv->watch_dbus_signal) { ibus_bus_watch_dbus_signal (bus); } /** Watch ibus signals. */ const gchar *rule = "type='signal'," "path='" IBUS_PATH_IBUS "'," "interface='" IBUS_INTERFACE_IBUS "'"; ibus_bus_add_match (bus, rule); g_signal_connect (priv->connection, "ibus-signal", (GCallback) _connection_ibus_signal_cb, bus); } }
static void ibus_bus_connect (IBusBus *bus) { IBusBusPrivate *priv; priv = IBUS_BUS_GET_PRIVATE (bus); #if 0 socket_path = ibus_get_socket_path (); if (stat (socket_path, &buf) != 0) { g_warning ("Can not get stat from %s!", socket_path); return; } if (buf.st_uid != ibus_get_daemon_uid ()) { g_warning ("The owner of %s is not %s!", socket_path, ibus_get_user_name ()); return; } if (priv->connection != NULL) { ibus_object_destroy ((IBusObject *) priv->connection); } #endif if (ibus_get_address () != NULL) { priv->connection = ibus_connection_open (ibus_get_address ()); } if (priv->connection) { ibus_bus_hello (bus); g_signal_connect (priv->connection, "destroy", (GCallback) _connection_destroy_cb, bus); g_signal_emit (bus, bus_signals[CONNECTED], 0); if (priv->watch_dbus_signal) { ibus_bus_watch_dbus_signal (bus); } } }
void ibus_bus_set_watch_dbus_signal (IBusBus *bus, gboolean watch) { g_assert (IBUS_IS_BUS (bus)); IBusBusPrivate *priv; priv = IBUS_BUS_GET_PRIVATE (bus); if (priv->watch_dbus_signal == watch) return; priv->watch_dbus_signal = watch; if (ibus_bus_is_connected (bus)) { if (watch) { ibus_bus_watch_dbus_signal (bus); } else { ibus_bus_unwatch_dbus_signal (bus); } } }