예제 #1
0
static void
on_new_conn (GObject      *source,
             GAsyncResult *res,
             gpointer      user_data)
{
  GDBusConnection **connection = user_data;
  GError *error = NULL;

  *connection = g_dbus_connection_new_for_address_finish (res, &error);
  g_assert_no_error (error);
}
예제 #2
0
static void
async_got_private_connection_cb (GObject *source_object,
                                 GAsyncResult *res,
                                 gpointer user_data)
{
    AsyncDBusCall *async_call = user_data;
    GDBusConnection *connection, *existing_connection;
    GError *error = NULL;

    connection = g_dbus_connection_new_for_address_finish (res, &error);
    if (!connection)
    {
        async_call->io_error = g_error_copy (error);
        g_error_free (error);
        async_call_finish (async_call);
        return;
    }

    vfs_connection_setup (connection, TRUE);

    /* Maybe we already had a connection? This happens if we requested
     * the same owner several times in parallel.
     * If so, just drop this connection and use that.
     */

    existing_connection = get_connection_for_async (async_call->dbus_id);
    if (existing_connection != NULL)
    {
        async_call->connection = existing_connection;
        /* TODO: watch for the need to manually call g_dbus_connection_close_sync () */
        g_object_unref (connection);
    }
    else
    {
        set_connection_for_async (connection, async_call->dbus_id);
        async_call->connection = connection;
    }

    /* Maybe we were canceled while setting up connection, then
     * avoid doing the operation */
    if (g_cancellable_set_error_if_cancelled (async_call->cancellable, &async_call->io_error))
    {
        async_call_finish (async_call);
        return;
    }

    async_call_finish (async_call);
}
예제 #3
0
static void
evd_dbus_agent_on_new_dbus_connection (GObject      *obj,
                                       GAsyncResult *res,
                                       gpointer      user_data)
{
  GDBusConnection *dbus_conn;
  GError *error = NULL;
  GSimpleAsyncResult *result;
  ObjectData *obj_data;
  ConnData *conn_data;
  ObjConnData *obj_conn_data;

  result = G_SIMPLE_ASYNC_RESULT (user_data);

  obj_conn_data =
    (ObjConnData *) g_simple_async_result_get_op_res_gpointer (result);
  obj_data = obj_conn_data->obj_data;
  conn_data = obj_conn_data->conn_data;

  if ( (dbus_conn = g_dbus_connection_new_for_address_finish (res,
                                                              &error)) == NULL)
    {
      evd_dbus_agent_conn_data_unref (conn_data);
      g_slice_free (ObjConnData, obj_conn_data);

      g_simple_async_result_set_from_error (result, error);
      g_error_free (error);
    }
  else
    {
      guint *conn_id;

      conn_data->conn = dbus_conn;

      conn_id = evd_dbus_agent_bind_connection_to_object (obj_data, obj_conn_data);

      if (conn_data->reuse)
        evd_dbus_agent_cache_conn_in_global_cache (conn_data);

      g_simple_async_result_set_op_res_gpointer (result, conn_id, NULL);
    }

  g_simple_async_result_complete (result);
  g_object_unref (result);
}
예제 #4
0
파일: ext-main.c 프로젝트: cdlscpmv/vimb
static void on_dbus_connection_created(GObject *source_object,
        GAsyncResult *result, gpointer data)
{
    static GDBusNodeInfo *node_info = NULL;
    GDBusConnection *connection;
    GError *error = NULL;

    if (!node_info) {
        node_info = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
    }

    connection = g_dbus_connection_new_for_address_finish(result, &error);
    if (error) {
        g_warning("Failed to connect to UI process: %s", error->message);
        g_error_free(error);
        return;
    }

    /* register the webextension object */
    ext.regid = g_dbus_connection_register_object(
            connection,
            VB_WEBEXTENSION_OBJECT_PATH,
            node_info->interfaces[0],
            &interface_vtable,
            WEBKIT_WEB_EXTENSION(data),
            NULL,
            &error);

    if (!ext.regid) {
        g_warning("Failed to register web extension object: %s", error->message);
        g_error_free(error);
        g_object_unref(connection);
        return;
    }

    emit_page_created_pending(connection);
    ext.connection = connection;
}