Example #1
0
static void
ibus_proxy_set_property (IBusProxy      *proxy,
                         guint           prop_id,
                         const GValue   *value,
                         GParamSpec     *pspec)
{
    IBusProxyPrivate *priv;
    priv = IBUS_PROXY_GET_PRIVATE (proxy);

    switch (prop_id) {
    case PROP_NAME:
        g_assert (priv->name == NULL);
        priv->name = g_strdup (g_value_get_string (value));
        break;
    case PROP_PATH:
        g_assert (priv->path == NULL);
        priv->path = g_strdup (g_value_get_string (value));
        break;
    case PROP_INTERFACE:
        g_assert (priv->interface == NULL);
        priv->interface = g_strdup (g_value_get_string (value));
        break;
    case PROP_CONNECTION:
        g_assert (priv->connection == NULL);
        priv->connection = IBUS_CONNECTION (g_value_get_object (value));
        g_object_ref_sink (priv->connection);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (proxy, prop_id, pspec);
    }
}
Example #2
0
void
bus_dbus_impl_dispatch_message (BusDBusImpl  *dbus,
                                IBusMessage  *message)
{
    g_assert (BUS_IS_DBUS_IMPL (dbus));
    g_assert (message != NULL);

    const gchar *destination;
    BusConnection *dest_connection = NULL;

    if (G_UNLIKELY (IBUS_OBJECT_DESTROYED (dbus))) {
        return;
    }

    destination = ibus_message_get_destination (message);

    if (destination != NULL) {
        dest_connection = bus_dbus_impl_get_connection_by_name (dbus, destination);

        if (dest_connection != NULL) {
            ibus_connection_send (IBUS_CONNECTION (dest_connection), message);
        }
        else {
            IBusMessage *reply_message;
            reply_message = ibus_message_new_error_printf (message,
                                                     DBUS_ERROR_SERVICE_UNKNOWN,
                                                     "Can not find service %s",
                                                     destination);
            bus_dbus_impl_dispatch_message (dbus, reply_message);
            ibus_message_unref (reply_message);
        }
    }

    bus_dbus_impl_dispatch_message_by_rule (dbus, message, dest_connection);
}
Example #3
0
IBusConnection *
ibus_connection_new (void)
{
    GObject *object;
    object = g_object_new (IBUS_TYPE_CONNECTION, NULL);
    return IBUS_CONNECTION (object);
}
Example #4
0
gboolean
ibus_service_remove_from_all_connections (IBusService *service)
{
    g_return_val_if_fail (IBUS_IS_SERVICE (service), FALSE);

    IBusServicePrivate *priv;
    priv = IBUS_SERVICE_GET_PRIVATE (service);

    GList *element = priv->connections;
    while (element != NULL) {
        IBusConnection *connection = IBUS_CONNECTION (element->data);

        gboolean retval;
        retval = ibus_connection_unregister_object_path (connection, priv->path);

        g_signal_handlers_disconnect_by_func (connection,
                                              (GCallback) _connection_destroy_cb,
                                              service);
        g_object_unref (connection);
        element = element->next;
    }

    g_list_free (priv->connections);
    priv->connections = NULL;
    return TRUE;
}
Example #5
0
static gboolean
bus_connection_dbus_signal  (BusConnection  *connection,
                             DBusMessage    *message)
{
    gboolean retval;
    retval = IBUS_CONNECTION_CLASS (parent_class)->dbus_signal (
            IBUS_CONNECTION (connection), message);
    return retval;
}
Example #6
0
DBusHandlerResult
_message_function (DBusConnection *dbus_connection,
                   DBusMessage    *message,
                   VTableCallData *data)
{
    gboolean retval;
    IBusConnection *connection;

    connection = IBUS_CONNECTION (dbus_connection_get_data (dbus_connection, _get_slot()));
    retval = data->message_func (connection, message, data->user_data);

    return retval ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
Example #7
0
void
bus_dbus_impl_dispatch_message_by_rule (BusDBusImpl     *dbus,
                                        IBusMessage     *message,
                                        BusConnection   *skip_connection)
{
    g_assert (BUS_IS_DBUS_IMPL (dbus));
    g_assert (message != NULL);
    g_assert (BUS_IS_CONNECTION (skip_connection) || skip_connection == NULL);

    GList *recipients = NULL;
    GList *link = NULL;

    static gint32 data_slot = -1;

    if (G_UNLIKELY (IBUS_OBJECT_DESTROYED (dbus))) {
        return;
    }

    if (data_slot == -1) {
        dbus_message_allocate_data_slot (&data_slot);
    }

    /* If this message has been dispatched by rule, it will be ignored. */
    if (dbus_message_get_data (message, data_slot) != NULL)
        return;

    dbus_message_set_data (message, data_slot, (gpointer) TRUE, NULL);

#if 0
    if (g_strcmp0 (ibus_message_get_member (message), "ValueChanged") == 0) {
        g_debug ("Dispatch ValueChanged");
    }
#endif

    for (link = dbus->rules; link != NULL; link = link->next) {
        GList *list = bus_match_rule_get_recipients (BUS_MATCH_RULE (link->data),
                                                     message);
        recipients = g_list_concat (recipients, list);
    }

    for (link = recipients; link != NULL; link = link->next) {
        BusConnection *connection = BUS_CONNECTION (link->data);
        if (connection != skip_connection) {
            ibus_connection_send (IBUS_CONNECTION (connection), message);
        }
        g_object_unref (connection);
    }
    g_list_free (recipients);
}
Example #8
0
static void
_new_connection_cb (DBusServer      *dbus_server,
                    DBusConnection  *new_connection,
                    IBusServer      *server)
{
    IBusServerPrivate *priv;
    IBusConnection *connection;

    priv = IBUS_SERVER_GET_PRIVATE (server);
    connection = IBUS_CONNECTION (g_object_new (priv->connection_type, NULL));
    ibus_connection_set_connection (connection, new_connection, FALSE);

    g_signal_emit (server, server_signals[NEW_CONNECTION], 0, connection);

    if (g_object_is_floating (connection)) {
        /* release connection if it is still floating */
        g_object_unref (connection);
    }
}
Example #9
0
static gboolean
bus_dbus_impl_ibus_message (BusDBusImpl  *dbus,
                            BusConnection   *connection,
                            IBusMessage     *message)
{
    g_assert (BUS_IS_DBUS_IMPL (dbus));
    g_assert (BUS_IS_CONNECTION (connection));
    g_assert (message != NULL);

    gint i;
    IBusMessage *reply_message = NULL;

    static const struct {
        const gchar *interface;
        const gchar *name;
        IBusMessage *(* handler) (BusDBusImpl *, IBusMessage *, BusConnection *);
    } handlers[] =  {
        /* Introspectable interface */
        { DBUS_INTERFACE_INTROSPECTABLE,
                               "Introspect", _dbus_introspect },
        /* DBus interface */
        { DBUS_INTERFACE_DBUS, "Hello",     _dbus_hello },
        { DBUS_INTERFACE_DBUS, "ListNames", _dbus_list_names },
        { DBUS_INTERFACE_DBUS, "ListActivatableNames",
                                            _dbus_no_implement },
        { DBUS_INTERFACE_DBUS, "NameHasOwner",
                                            _dbus_name_has_owner },
        { DBUS_INTERFACE_DBUS, "StartServiceByName",
                                            _dbus_no_implement },
        { DBUS_INTERFACE_DBUS, "GetNameOwner",
                                            _dbus_get_name_owner },
        { DBUS_INTERFACE_DBUS, "GetConnectionUnixUser",
                                            _dbus_no_implement },
        { DBUS_INTERFACE_DBUS, "AddMatch",  _dbus_add_match },
        { DBUS_INTERFACE_DBUS, "RemoveMatch",
                                            _dbus_remove_match },
        { DBUS_INTERFACE_DBUS, "GetId",     _dbus_get_id },
        { DBUS_INTERFACE_DBUS, "RequestName", _dbus_request_name },
        { DBUS_INTERFACE_DBUS, "ReleaseName", _dbus_release_name },
        { NULL, NULL, NULL }
    };

    ibus_message_set_destination (message, DBUS_SERVICE_DBUS);

    for (i = 0; handlers[i].interface != NULL; i++) {
        if (ibus_message_is_method_call (message,
                                         handlers[i].interface,
                                         handlers[i].name)) {

            reply_message = handlers[i].handler (dbus, message, connection);
            if (reply_message) {

                ibus_message_set_sender (reply_message, DBUS_SERVICE_DBUS);
                ibus_message_set_destination (reply_message,
                                              bus_connection_get_unique_name (connection));
                ibus_message_set_no_reply (reply_message, TRUE);

                ibus_connection_send (IBUS_CONNECTION (connection), reply_message);
                ibus_message_unref (reply_message);
            }

            g_signal_stop_emission_by_name (dbus, "ibus-message");
            return TRUE;
        }
    }

    return parent_class->ibus_message ((IBusService *) dbus,
                                       (IBusConnection *) connection,
                                       message);
}