summaryrefslogtreecommitdiff
path: root/examples/client
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-09-06 13:02:34 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-09-28 10:15:22 +0200
commitdecd9fd4edff304bf02f6f1c311ec4f4ac740c7e (patch)
tree59e74b76a59223be3f77e8e9a305d3218cfa4df3 /examples/client
parent99b697298fc11b5c5bc5d91eee3cc009495fcf41 (diff)
offerer: port to TpAccountChannelRequest
Diffstat (limited to 'examples/client')
-rw-r--r--examples/client/stream-tubes/offerer.c113
1 files changed, 29 insertions, 84 deletions
diff --git a/examples/client/stream-tubes/offerer.c b/examples/client/stream-tubes/offerer.c
index fa15e913e..f6e092876 100644
--- a/examples/client/stream-tubes/offerer.c
+++ b/examples/client/stream-tubes/offerer.c
@@ -50,19 +50,20 @@ _tube_offered (GObject *tube,
g_debug ("Tube offered");
}
-
static void
-_channel_prepared (GObject *channel,
- GAsyncResult *res,
+_channel_created (GObject *source,
+ GAsyncResult *result,
gpointer user_data)
{
- TpStreamTube *tube;
+ TpChannel *channel;
GError *error = NULL;
+ TpStreamTube *tube;
- tp_proxy_prepare_finish (channel, res, &error);
+ channel = tp_account_channel_request_create_and_handle_channel_finish (
+ TP_ACCOUNT_CHANNEL_REQUEST (source), result, NULL, &error);
g_assert_no_error (error);
- g_debug ("Channel prepared");
+ g_debug ("Channel created: %s", tp_proxy_get_object_path (channel));
tube = tp_stream_tube_new (TP_CHANNEL (channel));
/* the TpStreamTube holds the only reference to @channel */
@@ -74,43 +75,28 @@ _channel_prepared (GObject *channel,
tp_stream_tube_offer_async (tube, NULL, _tube_offered, NULL);
}
-
-static void
-_channel_created (TpConnection *conn,
- const gchar *channel_path,
- GHashTable *props,
- const GError *in_error,
- gpointer user_data,
- GObject *weak_obj)
+int
+main (int argc,
+ const char **argv)
{
- TpChannel *channel;
+ TpDBusDaemon *dbus;
+ TpAccount *account;
+ char *account_path;
GError *error = NULL;
+ TpAccountChannelRequest *req;
+ GHashTable *request;
- g_assert_no_error ((GError *) in_error);
+ g_assert (argc == 3);
- g_debug ("Channel created: %s", channel_path);
+ g_type_init ();
- channel = tp_channel_new_from_properties (conn, channel_path, props,
- &error);
+ dbus = tp_dbus_daemon_dup (&error);
g_assert_no_error (error);
- tp_proxy_prepare_async (channel, NULL, _channel_prepared, NULL);
-}
-
-
-static void
-_connection_prepared (GObject *conn,
- GAsyncResult *res,
- gpointer user_data)
-{
- GHashTable *request;
- GError *error = NULL;
-
- tp_proxy_prepare_finish (conn, res, &error);
+ account_path = g_strconcat (TP_ACCOUNT_OBJECT_PATH_BASE, argv[1], NULL);
+ account = tp_account_new (dbus, account_path, &error);
g_assert_no_error (error);
-
- g_debug ("Connection prepared");
- g_debug ("Requesting channel");
+ g_free (account_path);
request = tp_asv_new (
TP_PROP_CHANNEL_CHANNEL_TYPE,
@@ -123,7 +109,7 @@ _connection_prepared (GObject *conn,
TP_PROP_CHANNEL_TARGET_ID,
G_TYPE_STRING,
- user_data,
+ argv[2],
TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE,
G_TYPE_STRING,
@@ -131,61 +117,20 @@ _connection_prepared (GObject *conn,
NULL);
- tp_cli_connection_interface_requests_call_create_channel (
- TP_CONNECTION (conn), -1,
- request,
- _channel_created,
- NULL, NULL, NULL);
-
- g_hash_table_destroy (request);
-}
+ g_debug ("Offer channel to %s", argv[2]);
+ req = tp_account_channel_request_new (account, request,
+ TP_USER_ACTION_TIME_CURRENT_TIME);
-static void
-_account_prepared (GObject *account,
- GAsyncResult *res,
- gpointer user_data)
-{
- GError *error = NULL;
-
- tp_proxy_prepare_finish (account, res, &error);
- g_assert_no_error (error);
-
- g_debug ("Account prepared");
-
- tp_proxy_prepare_async (tp_account_get_connection (TP_ACCOUNT (account)),
- NULL, _connection_prepared, user_data);
-}
-
-
-int
-main (int argc,
- const char **argv)
-{
- TpDBusDaemon *dbus;
- TpAccount *account;
- char *account_path;
- GError *error = NULL;
-
- g_assert (argc == 3);
-
- g_type_init ();
-
- dbus = tp_dbus_daemon_dup (&error);
- g_assert_no_error (error);
-
- account_path = g_strconcat (TP_ACCOUNT_OBJECT_PATH_BASE, argv[1], NULL);
- account = tp_account_new (dbus, account_path, &error);
- g_assert_no_error (error);
- g_free (account_path);
-
- tp_proxy_prepare_async (account, NULL, _account_prepared,
- (gpointer) argv[2]);
+ tp_account_channel_request_create_and_handle_channel_async (req, NULL,
+ _channel_created, NULL);
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
g_object_unref (account);
+ g_object_unref (req);
+ g_hash_table_unref (request);
g_main_loop_unref (loop);
return 0;