static void
_upload_file_cb (DBusGProxy *proxy,
                 gint opid,
                 GError *error,
                 gpointer userdata)
{
  SwClientServiceCallClosure *closure = (SwClientServiceCallClosure *) userdata;

  if (error) {
    g_simple_async_report_gerror_in_idle (G_OBJECT (closure->service),
                                          (GAsyncReadyCallback) closure->cb,
                                          closure->userdata,
                                          error);
    g_object_unref (closure->service);
    g_slice_free (SwClientServiceCallClosure, closure);
    return;
  }

  closure->opid = opid;

  /* And now wait for the progress signals */
}
Exemple #2
0
/**
 * soup_input_stream_send_async:
 * @stream: a #SoupInputStream
 * @io_priority: the io priority of the request.
 * @cancellable: optional #GCancellable object, %NULL to ignore.
 * @callback: callback to call when the request is satisfied
 * @user_data: the data to pass to callback function
 *
 * Asynchronously sends the HTTP request associated with @stream, and
 * reads the response headers. Call this after soup_input_stream_new()
 * and before the first g_input_stream_read_async() if you want to
 * check the HTTP status code before you start reading.
 **/
void
soup_input_stream_send_async (GInputStream        *stream,
			      int                  io_priority,
			      GCancellable        *cancellable,
			      GAsyncReadyCallback  callback,
			      gpointer             user_data)
{
  GError *error = NULL;

  g_return_if_fail (SOUP_IS_INPUT_STREAM (stream));

  if (!g_input_stream_set_pending (stream, &error))
    {
      g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
					    callback,
					    user_data,
					    error);
      g_error_free (error);
      return;
    }
  soup_input_stream_send_async_internal (stream, io_priority, cancellable,
					 callback, user_data);
}
Exemple #3
0
void
_client_create_tube_async (const gchar *account_path,
    const gchar *contact_id,
    GCancellable *cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data)
{
  GSimpleAsyncResult *simple;
  CreateTubeData *data;
  GHashTable *request;
  TpDBusDaemon *dbus;
  TpAccount *account = NULL;
  TpAccountChannelRequest *acr;
  GError *error = NULL;

  if (g_cancellable_is_cancelled (cancellable))
    {
      g_simple_async_report_error_in_idle (NULL, callback,
          user_data, G_IO_ERROR, G_IO_ERROR_CANCELLED,
          "Operation has been cancelled");
      return;
    }

  dbus = tp_dbus_daemon_dup (&error);
  if (dbus != NULL)
    account = tp_account_new (dbus, account_path, &error);
  if (account == NULL)
    {
      g_simple_async_report_gerror_in_idle (NULL, callback, user_data, error);
      g_clear_error (&error);
      tp_clear_object (&dbus);
      return;
    }

  simple = g_simple_async_result_new (NULL, callback, user_data,
      _client_create_tube_finish);

  data = g_slice_new0 (CreateTubeData);
  data->op_cancellable = g_cancellable_new ();
  if (cancellable != NULL)
    {
      data->global_cancellable = g_object_ref (cancellable);
      data->cancelled_id = g_cancellable_connect (data->global_cancellable,
          G_CALLBACK (create_tube_cancelled_cb), simple, NULL);
    }

  g_simple_async_result_set_op_res_gpointer (simple, data,
      (GDestroyNotify) create_tube_data_free);

  request = tp_asv_new (
      TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
        TP_IFACE_CHANNEL_TYPE_STREAM_TUBE,
      TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
        TP_HANDLE_TYPE_CONTACT,
      TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING,
        contact_id,
      TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING,
        TUBE_SERVICE,
      NULL);

  acr = tp_account_channel_request_new (account, request, G_MAXINT64);
  tp_account_channel_request_create_and_handle_channel_async (acr,
      data->op_cancellable, create_channel_cb, simple);

  g_hash_table_unref (request);
  g_object_unref (dbus);
  g_object_unref (account);
  g_object_unref (acr);
}