summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-02-09 15:58:04 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-03-05 12:33:36 +0000
commit7162d30eea3e94894531c1ab6d85b89534cbcada (patch)
treeb2203fd20da0c2f9729f23d405d97e5a8808b192 /examples
parent38b6331ab00d96f81f9eeedeb28a14395f2ff1cb (diff)
downloadtelepathy-glib-7162d30eea3e94894531c1ab6d85b89534cbcada.tar.gz
Use tp_proxy_prepare_async() to prepare connections in example code
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=45842 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'examples')
-rw-r--r--examples/client/extended-client.c28
-rw-r--r--examples/client/inspect-channel.c13
-rw-r--r--examples/client/inspect-connection.c11
-rw-r--r--examples/client/inspect-contact.c11
4 files changed, 36 insertions, 27 deletions
diff --git a/examples/client/extended-client.c b/examples/client/extended-client.c
index 57582fced..724ff2c35 100644
--- a/examples/client/extended-client.c
+++ b/examples/client/extended-client.c
@@ -168,11 +168,21 @@ contacts_ready_cb (TpConnection *conn,
}
static void
-conn_ready (TpConnection *conn,
- GParamSpec *unused,
- gpointer user_data)
+conn_ready (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ GError *error = NULL;
static const gchar * const names[] = { "myself@server", "other@server" };
+ TpConnection *conn = TP_CONNECTION (source);
+
+ if (!tp_proxy_prepare_finish (conn, result, &error))
+ {
+ g_warning ("%s", error->message);
+ g_main_loop_quit (mainloop);
+ g_clear_error (&error);
+ return;
+ }
if (!tp_proxy_has_interface_by_id (conn,
EXAMPLE_IFACE_QUARK_CONNECTION_INTERFACE_HATS))
@@ -214,7 +224,6 @@ cm_requested_connection (TpConnectionManager *manager,
GError *e = NULL;
TpConnection *conn;
TpProxy *proxy = (TpProxy *) manager;
- gboolean ready;
if (die_if (error, "RequestConnection()"))
return;
@@ -235,16 +244,7 @@ cm_requested_connection (TpConnectionManager *manager,
tp_cli_connection_connect_to_status_changed (conn, conn_status_changed,
NULL, NULL, NULL, NULL);
- g_object_get (conn,
- "connection-ready", &ready,
- NULL);
-
- if (ready)
- conn_ready (conn, NULL, NULL);
- else
- g_signal_connect (conn, "notify::connection-ready",
- G_CALLBACK (conn_ready), NULL);
-
+ tp_proxy_prepare_async (conn, NULL, conn_ready, NULL);
tp_cli_connection_call_connect (conn, -1, NULL, NULL, NULL, NULL);
}
diff --git a/examples/client/inspect-channel.c b/examples/client/inspect-channel.c
index 9272a7755..a4987b6d3 100644
--- a/examples/client/inspect-channel.c
+++ b/examples/client/inspect-channel.c
@@ -83,19 +83,22 @@ channel_ready_cb (GObject *source,
}
static void
-connection_ready_cb (TpConnection *connection,
- const GError *ready_error,
+connection_ready_cb (GObject *source,
+ GAsyncResult *result,
gpointer user_data)
{
InspectChannelData *data = user_data;
GError *error = NULL;
+ TpConnection *connection = TP_CONNECTION (source);
TpChannel *channel = NULL;
- if (ready_error != NULL)
+
+ if (!tp_proxy_prepare_finish (connection, result, &error))
{
- g_warning ("%s", ready_error->message);
+ g_warning ("%s", error->message);
data->exit_status = 1;
g_main_loop_quit (data->main_loop);
+ g_clear_error (&error);
return;
}
@@ -175,7 +178,7 @@ main (int argc,
* else has called (or will call) Connect(), so we won't call Connect()
* on it ourselves
*/
- tp_connection_call_when_ready (connection, connection_ready_cb, &data);
+ tp_proxy_prepare_async (connection, NULL, connection_ready_cb, &data);
g_main_loop_run (data.main_loop);
diff --git a/examples/client/inspect-connection.c b/examples/client/inspect-connection.c
index 53fc8b0eb..edf0cfcc4 100644
--- a/examples/client/inspect-connection.c
+++ b/examples/client/inspect-connection.c
@@ -53,16 +53,19 @@ got_channels (TpConnection *connection,
}
static void
-connection_ready_cb (TpConnection *connection,
- const GError *error,
+connection_ready_cb (GObject *source,
+ GAsyncResult *result,
gpointer user_data)
{
GMainLoop *mainloop = user_data;
+ GError *error = NULL;
+ TpConnection *connection = TP_CONNECTION (source);
- if (error != NULL)
+ if (!tp_proxy_prepare_finish (connection, result, &error))
{
g_warning ("%s", error->message);
g_main_loop_quit (mainloop);
+ g_clear_error (&error);
return;
}
@@ -131,7 +134,7 @@ main (int argc,
* else has called (or will call) Connect(), so we won't call Connect()
* on it ourselves
*/
- tp_connection_call_when_ready (connection, connection_ready_cb, mainloop);
+ tp_proxy_prepare_async (connection, NULL, connection_ready_cb, mainloop);
g_main_loop_run (mainloop);
diff --git a/examples/client/inspect-contact.c b/examples/client/inspect-contact.c
index a1d18474c..c1b6bb37d 100644
--- a/examples/client/inspect-contact.c
+++ b/examples/client/inspect-contact.c
@@ -127,8 +127,8 @@ got_contacts_by_id (TpConnection *connection,
}
static void
-connection_ready_cb (TpConnection *connection,
- const GError *error,
+connection_ready_cb (GObject *source,
+ GAsyncResult *result,
gpointer user_data)
{
static TpContactFeature features[] = {
@@ -137,12 +137,15 @@ connection_ready_cb (TpConnection *connection,
TP_CONTACT_FEATURE_PRESENCE
};
InspectContactData *data = user_data;
+ TpConnection *connection = TP_CONNECTION (source);
+ GError *error = NULL;
- if (error != NULL)
+ if (!tp_proxy_prepare_finish (connection, result, &error))
{
g_warning ("%s", error->message);
data->exit_status = 1;
g_main_loop_quit (data->main_loop);
+ g_clear_error (&error);
return;
}
@@ -227,7 +230,7 @@ main (int argc,
* else has called (or will call) Connect(), so we won't call Connect()
* on it ourselves
*/
- tp_connection_call_when_ready (connection, connection_ready_cb, &data);
+ tp_proxy_prepare_async (connection, NULL, connection_ready_cb, &data);
g_main_loop_run (data.main_loop);