summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-03-31 17:27:13 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-03-31 17:27:17 +0100
commit1a173e10bc4a86b7fdcdc9bbb71ec061aebc14fe (patch)
tree2a10612f29ff9cbd439cabe3a288ac8e4682bd33
parent45235af57917d7574ab094462bd18e4a415364f9 (diff)
parent50e64b7c852f6c84bc940e3690df463b35fc8435 (diff)
Merge branches 'trivia' and 'deprecations'
Reviewed-by: Danielle Madeley <danielle.madeley@collabora.co.uk> Bug: http://bugs.freedesktop.org/show_bug.cgi?id=22206 Bug: http://bugs.freedesktop.org/show_bug.cgi?id=27375
-rw-r--r--docs/reference/Makefile.am4
-rw-r--r--examples/client/extended-client.c172
-rw-r--r--examples/client/inspect-channel.c190
-rw-r--r--examples/client/inspect-connection.c47
-rw-r--r--examples/client/inspect-contact.c117
-rw-r--r--examples/cm/callable/media-channel.c7
-rw-r--r--examples/cm/channelspecific/room.c7
-rw-r--r--examples/cm/contactlist/contact-list.c10
-rw-r--r--examples/cm/echo-message-parts/chan.c7
-rw-r--r--examples/cm/echo/chan.c7
-rw-r--r--telepathy-glib/Makefile.am15
-rw-r--r--telepathy-glib/account-manager-internal.h9
-rw-r--r--telepathy-glib/account-manager.c54
-rw-r--r--telepathy-glib/account-manager.h3
-rw-r--r--telepathy-glib/account.c64
-rw-r--r--telepathy-glib/account.h3
-rw-r--r--telepathy-glib/channel-dispatch-operation.h3
-rw-r--r--telepathy-glib/channel-dispatcher.h3
-rw-r--r--telepathy-glib/channel-request.h3
-rw-r--r--telepathy-glib/channel.c3
-rw-r--r--telepathy-glib/channel.h5
-rw-r--r--telepathy-glib/client.h3
-rw-r--r--telepathy-glib/connection-manager.h3
-rw-r--r--telepathy-glib/connection.c6
-rw-r--r--telepathy-glib/connection.h5
-rw-r--r--telepathy-glib/dbus-daemon.h1
-rw-r--r--telepathy-glib/dbus.h3
-rw-r--r--telepathy-glib/debug.h7
-rw-r--r--telepathy-glib/defs.h9
-rw-r--r--telepathy-glib/media-interfaces.h1
-rw-r--r--telepathy-glib/proxy.h2
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/dbus/Makefile.am1
-rw-r--r--tests/dbus/account-manager.c6
-rw-r--r--tests/dbus/account.c4
-rw-r--r--tests/dbus/call-cancellation.c25
-rw-r--r--tests/dbus/call-example.c3
-rw-r--r--tests/dbus/callable-example.c3
-rw-r--r--tests/dbus/channel-dispatch-operation.c3
-rw-r--r--tests/dbus/channel-dispatcher.c5
-rw-r--r--tests/dbus/channel-introspect.c2
-rw-r--r--tests/dbus/channel-request.c2
-rw-r--r--tests/dbus/cli-group.c2
-rw-r--r--tests/dbus/client.c5
-rw-r--r--tests/dbus/cm.c5
-rw-r--r--tests/dbus/connection-bug-18845.c2
-rw-r--r--tests/dbus/connection-error.c2
-rw-r--r--tests/dbus/connection-getinterfaces-failure.c2
-rw-r--r--tests/dbus/connection-handles.c2
-rw-r--r--tests/dbus/connection-inject-bug16307.c2
-rw-r--r--tests/dbus/connection.c290
-rw-r--r--tests/dbus/contacts-bug-19101.c2
-rw-r--r--tests/dbus/contacts-mixin.c2
-rw-r--r--tests/dbus/contacts.c2
-rw-r--r--tests/dbus/disconnection.c18
-rw-r--r--tests/dbus/example-no-protocols.c84
-rw-r--r--tests/dbus/finalized-in-invalidated-handler.c2
-rw-r--r--tests/dbus/get-interface-after-invalidate.c5
-rw-r--r--tests/dbus/group-mixin.c2
-rw-r--r--tests/dbus/handle-repo.c4
-rw-r--r--tests/dbus/invalidated-while-invoking-signals.c2
-rw-r--r--tests/dbus/message-mixin.c2
-rw-r--r--tests/dbus/params-cm.c3
-rw-r--r--tests/dbus/properties.c6
-rw-r--r--tests/dbus/self-handle.c2
-rw-r--r--tests/dbus/self-presence.c2
-rw-r--r--tests/dbus/text-mixin.c2
-rw-r--r--tests/dbus/text-respawn.c2
-rw-r--r--tests/dbus/unsupported-interface.c4
-rw-r--r--tests/lib/simple-conn.c30
-rw-r--r--tests/lib/textchan-group.c8
-rw-r--r--tests/lib/textchan-null.c8
-rw-r--r--tests/lib/util.c86
-rw-r--r--tests/lib/util.h7
-rw-r--r--tools/glib-client-gen.py7
-rw-r--r--tools/telepathy.am3
76 files changed, 862 insertions, 573 deletions
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index 8ad310f18..69c800bda 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -27,7 +27,9 @@ SCANGOBJ_OPTIONS=
# Extra options to supply to gtkdoc-scan.
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
-SCAN_OPTIONS=--deprecated-guards=TP_DISABLE_DEPRECATED
+SCAN_OPTIONS=\
+ --deprecated-guards=TP_DISABLE_DEPRECATED \
+ --ignore-decorators=_TP_GNUC_DEPRECATED
# Extra options to supply to gtkdoc-mkdb.
# e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml
diff --git a/examples/client/extended-client.c b/examples/client/extended-client.c
index a2179cd97..79683efc2 100644
--- a/examples/client/extended-client.c
+++ b/examples/client/extended-client.c
@@ -38,58 +38,33 @@ die_if (const GError *error, const gchar *context)
}
static void
-conn_ready (TpConnection *conn,
- GParamSpec *unused,
- gpointer user_data)
+disconnect_cb (TpConnection *conn,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
{
- GError *error = NULL;
- GArray *handles;
- const gchar *names[] = { "myself@server", "other@server", NULL };
- GPtrArray *hats;
- guint i;
- GHashTable *asv;
-
- if (!tp_proxy_has_interface_by_id (conn,
- EXAMPLE_IFACE_QUARK_CONNECTION_INTERFACE_HATS))
- {
- g_warning ("Connection does not support Hats interface");
- g_main_loop_quit (mainloop);
- return;
- }
-
- /* Get handles for myself and someone else */
-
- tp_cli_connection_run_request_handles (conn, -1, TP_HANDLE_TYPE_CONTACT,
- names, &handles, &error, NULL);
-
- if (die_if (error, "RequestHandles()"))
- {
- g_error_free (error);
- return;
- }
+ if (die_if (error, "Disconnect()"))
+ return;
- asv = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
- (GDestroyNotify) tp_g_value_slice_free);
- g_hash_table_insert (asv, "previous-owner",
- tp_g_value_slice_new_static_string ("Shadowman"));
- example_cli_connection_interface_hats_run_set_hat (conn, -1,
- "red", EXAMPLE_HAT_STYLE_FEDORA, asv, &error, NULL);
- g_hash_table_destroy (asv);
+ main_ret = 0;
+ g_main_loop_quit (mainloop);
+}
- if (die_if (error, "SetHat()"))
- {
- g_error_free (error);
- return;
- }
+typedef struct {
+ TpContact *contacts[2];
+} ContactPair;
- example_cli_connection_interface_hats_run_get_hats (conn, -1,
- handles, &hats, &error, NULL);
+static void
+got_hats_cb (TpConnection *conn,
+ const GPtrArray *hats,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ guint i;
if (die_if (error, "GetHats()"))
- {
- g_error_free (error);
- return;
- }
+ return;
for (i = 0; i < hats->len; i++)
{
@@ -104,19 +79,110 @@ conn_ready (TpConnection *conn,
3))));
}
- g_array_free (handles, TRUE);
- g_boxed_free (EXAMPLE_ARRAY_TYPE_CONTACT_HAT_LIST, hats);
+ tp_cli_connection_call_disconnect (conn, -1, disconnect_cb,
+ NULL, NULL, NULL);
+}
- tp_cli_connection_run_disconnect (conn, -1, &error, NULL);
+static void
+set_hat_cb (TpConnection *conn,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ ContactPair *pair = user_data;
+ GArray *handles = NULL;
+ TpHandle handle;
- if (die_if (error, "Disconnect()"))
+ if (die_if (error, "SetHat()"))
+ return;
+
+ handles = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), 2);
+ handle = tp_contact_get_handle (pair->contacts[0]);
+ g_array_append_val (handles, handle);
+ handle = tp_contact_get_handle (pair->contacts[1]);
+ g_array_append_val (handles, handle);
+
+ example_cli_connection_interface_hats_call_get_hats (conn, -1,
+ handles, got_hats_cb, NULL, NULL, NULL);
+}
+
+static void
+contact_pair_free (gpointer p)
+{
+ ContactPair *pair = p;
+
+ g_object_unref (pair->contacts[0]);
+ g_object_unref (pair->contacts[1]);
+ g_slice_free (ContactPair, pair);
+}
+
+static void
+contacts_ready_cb (TpConnection *conn,
+ guint n_contacts,
+ TpContact * const *contacts,
+ const gchar * const *requested_ids,
+ GHashTable *failed_id_errors,
+ const GError *general_error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ GHashTableIter iter;
+ gpointer k, v;
+ GHashTable *asv;
+ ContactPair *pair;
+
+ /* This runs if tp_connection_get_contacts_by_id failed completely (e.g.
+ * the CM crashed) */
+ if (die_if (general_error, "tp_connection_get_contacts_by_id()"))
+ return;
+
+ /* If any making a TpContact for one of the requested IDs fails, they'll
+ * be present in this hash table with an error as value */
+ g_hash_table_iter_init (&iter, failed_id_errors);
+
+ while (g_hash_table_iter_next (&iter, &k, &v))
{
- g_error_free (error);
+ const gchar *failed_id = k;
+ const GError *contact_error = v;
+
+ if (die_if (contact_error, failed_id))
+ return;
+ }
+
+ asv = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
+ (GDestroyNotify) tp_g_value_slice_free);
+ g_hash_table_insert (asv, "previous-owner",
+ tp_g_value_slice_new_static_string ("Shadowman"));
+
+ pair = g_slice_new0 (ContactPair);
+ pair->contacts[0] = g_object_ref (contacts[0]);
+ pair->contacts[1] = g_object_ref (contacts[1]);
+
+ example_cli_connection_interface_hats_call_set_hat (conn, -1,
+ "red", EXAMPLE_HAT_STYLE_FEDORA, asv,
+ set_hat_cb, pair, contact_pair_free, NULL);
+
+ g_hash_table_destroy (asv);
+}
+
+static void
+conn_ready (TpConnection *conn,
+ GParamSpec *unused,
+ gpointer user_data)
+{
+ static const gchar * const names[] = { "myself@server", "other@server" };
+
+ if (!tp_proxy_has_interface_by_id (conn,
+ EXAMPLE_IFACE_QUARK_CONNECTION_INTERFACE_HATS))
+ {
+ g_warning ("Connection does not support Hats interface");
+ g_main_loop_quit (mainloop);
return;
}
- main_ret = 0;
- g_main_loop_quit (mainloop);
+ /* Get contact objects for myself and someone else */
+ tp_connection_get_contacts_by_id (conn, 2, names, 0, NULL,
+ contacts_ready_cb, NULL, NULL, NULL);
}
static void
diff --git a/examples/client/inspect-channel.c b/examples/client/inspect-channel.c
index dd120ebff..e1ff8609e 100644
--- a/examples/client/inspect-channel.c
+++ b/examples/client/inspect-channel.c
@@ -13,19 +13,116 @@
#include <telepathy-glib/telepathy-glib.h>
-int
-main (int argc,
- char **argv)
+typedef struct {
+ int exit_status;
+ GMainLoop *main_loop;
+ const gchar *object_path;
+} InspectChannelData;
+
+static void
+channel_ready_cb (TpChannel *channel,
+ const GError *error,
+ gpointer user_data)
{
+ InspectChannelData *data = user_data;
guint handle_type, handle;
gchar *channel_type;
gchar **interfaces, **iter;
- const gchar *conn_name, *object_path;
+
+ if (error != NULL)
+ {
+ g_warning ("%s", error->message);
+ data->exit_status = 1;
+ g_main_loop_quit (data->main_loop);
+ return;
+ }
+
+ g_object_get (channel,
+ "channel-type", &channel_type,
+ "handle-type", &handle_type,
+ "handle", &handle,
+ "interfaces", &interfaces,
+ NULL);
+
+ printf ("Type: %s\n", channel_type);
+ printf ("Handle: of type %u, #%u\n", handle_type, handle);
+ puts ("Interfaces:");
+
+ for (iter = interfaces; iter != NULL && *iter != NULL; iter++)
+ {
+ printf ("\t%s\n", *iter);
+ }
+
+ g_free (channel_type);
+ g_strfreev (interfaces);
+
+ if (tp_proxy_has_interface_by_id (channel,
+ TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP))
+ {
+ const TpIntSet *members = tp_channel_group_get_members (channel);
+ TpIntSetIter group_iter;
+
+ printf ("Group members:\n");
+
+ tp_intset_iter_init (&group_iter, members);
+
+ while (tp_intset_iter_next (&group_iter))
+ {
+ printf ("\tcontact #%u\n", group_iter.element);
+ }
+ }
+
+ data->exit_status = 0;
+ g_main_loop_quit (data->main_loop);
+}
+
+static void
+connection_ready_cb (TpConnection *connection,
+ const GError *ready_error,
+ gpointer user_data)
+{
+ InspectChannelData *data = user_data;
+ GError *error = NULL;
+ TpChannel *channel = NULL;
+
+ if (ready_error != NULL)
+ {
+ g_warning ("%s", ready_error->message);
+ data->exit_status = 1;
+ g_main_loop_quit (data->main_loop);
+ return;
+ }
+
+ channel = tp_channel_new (connection, data->object_path, NULL,
+ TP_UNKNOWN_HANDLE_TYPE, 0, &error);
+
+ if (channel == NULL)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ data->exit_status = 1;
+ g_main_loop_quit (data->main_loop);
+ return;
+ }
+
+ tp_channel_call_when_ready (channel, channel_ready_cb, data);
+
+ /* the channel will remain referenced as long as it has calls pending on
+ * it */
+ g_object_unref (channel);
+}
+
+
+
+int
+main (int argc,
+ char **argv)
+{
+ InspectChannelData data = { 1, NULL, NULL };
+ const gchar *conn_name;
TpDBusDaemon *daemon = NULL;
TpConnection *connection = NULL;
- TpChannel *channel = NULL;
GError *error = NULL;
- int ret = 0;
g_type_init ();
tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG"));
@@ -41,7 +138,7 @@ main (int argc,
}
conn_name = argv[1];
- object_path = argv[2];
+ data.object_path = argv[2];
daemon = tp_dbus_daemon_dup (&error);
@@ -49,7 +146,7 @@ main (int argc,
{
g_warning ("%s", error->message);
g_error_free (error);
- ret = 1;
+ data.exit_status = 1;
goto out;
}
@@ -58,84 +155,33 @@ main (int argc,
else
connection = tp_connection_new (daemon, conn_name, NULL, &error);
- if (connection == NULL ||
- !tp_connection_run_until_ready (connection, FALSE, &error, NULL))
+ if (connection == NULL)
{
g_warning ("%s", error->message);
g_error_free (error);
- ret = 1;
+ data.exit_status = 1;
goto out;
}
- channel = tp_channel_new (connection, object_path, NULL,
- TP_UNKNOWN_HANDLE_TYPE, 0, &error);
+ data.main_loop = g_main_loop_new (NULL, FALSE);
- if (channel == NULL || !tp_channel_run_until_ready (channel, &error, NULL))
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- ret = 1;
- goto out;
- }
+ /* for this example I assume it's an existing connection on which someone
+ * 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);
- g_object_get (channel,
- "channel-type", &channel_type,
- "handle-type", &handle_type,
- "handle", &handle,
- "interfaces", &interfaces,
- NULL);
-
- printf ("Type: %s\n", channel_type);
- printf ("Handle: of type %u, #%u\n", handle_type, handle);
- puts ("Interfaces:");
-
- for (iter = interfaces; iter != NULL && *iter != NULL; iter++)
- {
- printf ("\t%s\n", *iter);
- }
-
- g_free (channel_type);
- g_strfreev (interfaces);
-
- if (tp_proxy_has_interface_by_id (channel,
- TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP))
- {
- GArray *members;
-
- printf ("Group members:\n");
- /* An example of a reentrant blocking call. This re-enters the
- * main loop and dispatches events until the call completes */
- if (tp_cli_channel_interface_group_run_get_members (channel, -1,
- /* If GetMembers had any "in" arguments they'd go here */
- &members, &error, NULL))
- {
- guint i;
-
- for (i = 0; i < members->len; i++)
- {
- printf("\tcontact #%u\n", g_array_index (members, guint, i));
- }
-
- g_array_free (members, TRUE);
- }
- else
- {
- printf ("\t[error: %s]\n", error->message);
- g_error_free (error);
- ret = 1;
- goto out;
- }
- }
+ g_main_loop_run (data.main_loop);
out:
if (daemon != NULL)
g_object_unref (daemon);
+ if (data.main_loop != NULL)
+ g_main_loop_unref (data.main_loop);
+
if (connection != NULL)
g_object_unref (connection);
- if (channel != NULL)
- g_object_unref (channel);
-
- return ret;
+ return data.exit_status;
}
diff --git a/examples/client/inspect-connection.c b/examples/client/inspect-connection.c
index 9ac1bb114..d9df16119 100644
--- a/examples/client/inspect-connection.c
+++ b/examples/client/inspect-connection.c
@@ -13,6 +13,8 @@
#include <telepathy-glib/telepathy-glib.h>
+static int exit_status = 1;
+
static void
got_channels (TpConnection *connection,
const GPtrArray *channels,
@@ -48,6 +50,28 @@ got_channels (TpConnection *connection,
g_main_loop_quit (mainloop);
}
+static void
+connection_ready_cb (TpConnection *connection,
+ const GError *error,
+ gpointer user_data)
+{
+ GMainLoop *mainloop = user_data;
+
+ if (error != NULL)
+ {
+ g_warning ("%s", error->message);
+ g_main_loop_quit (mainloop);
+ return;
+ }
+
+ printf ("Connection ready\n");
+
+ tp_cli_connection_call_list_channels (connection, -1,
+ /* If ListChannels() needed any arguments, they'd go here */
+ got_channels, g_main_loop_ref (mainloop),
+ (GDestroyNotify) g_main_loop_unref, NULL);
+}
+
int
main (int argc,
char **argv)
@@ -57,7 +81,6 @@ main (int argc,
GMainLoop *mainloop = NULL;
TpDBusDaemon *daemon = NULL;
GError *error = NULL;
- int ret = 1;
g_type_init ();
tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG"));
@@ -95,28 +118,20 @@ main (int argc,
connection = tp_connection_new (daemon, bus_name, object_path, &error);
- /* for this example I assume it's an existing connection on which someone
- * else has called (or will call) Connect(), so we won't call Connect()
- * on it ourselves
- */
- if (connection == NULL ||
- !tp_connection_run_until_ready (connection, FALSE, &error, NULL))
+ if (connection == NULL)
{
g_warning ("%s", error->message);
g_error_free (error);
goto out;
}
- printf ("Connection ready\n");
-
- /* An example non-blocking call */
- tp_cli_connection_call_list_channels (connection, -1,
- /* If ListChannels() needed any arguments, they'd go here */
- got_channels, g_main_loop_ref (mainloop),
- (GDestroyNotify) g_main_loop_unref, NULL);
+ /* for this example I assume it's an existing connection on which someone
+ * 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);
g_main_loop_run (mainloop);
- ret = 0;
out:
if (connection != NULL)
@@ -128,5 +143,5 @@ out:
if (daemon != NULL)
g_object_unref (daemon);
- return ret;
+ return exit_status;
}
diff --git a/examples/client/inspect-contact.c b/examples/client/inspect-contact.c
index 8664e4dfe..c774aac0f 100644
--- a/examples/client/inspect-contact.c
+++ b/examples/client/inspect-contact.c
@@ -13,6 +13,12 @@
#include <telepathy-glib/telepathy-glib.h>
+typedef struct {
+ const gchar *to_inspect;
+ int exit_status;
+ GMainLoop *main_loop;
+} InspectContactData;
+
static void
display_contact (TpContact *contact)
{
@@ -45,12 +51,14 @@ got_contacts_by_handle (TpConnection *connection,
gpointer user_data,
GObject *weak_object)
{
- GMainLoop *mainloop = user_data;
+ InspectContactData *data = user_data;
if (error == NULL)
{
guint i;
+ data->exit_status = 0;
+
for (i = 0; i < n_contacts; i++)
{
display_contact (contacts[i]);
@@ -59,14 +67,16 @@ got_contacts_by_handle (TpConnection *connection,
for (i = 0; i < n_invalid; i++)
{
g_warning ("Invalid handle %u", invalid[i]);
+ data->exit_status = 1;
}
}
else
{
g_warning ("Error getting contacts: %s", error->message);
+ data->exit_status = 1;
}
- g_main_loop_quit (mainloop);
+ g_main_loop_quit (data->main_loop);
}
static void
@@ -79,7 +89,7 @@ got_contacts_by_id (TpConnection *connection,
gpointer user_data,
GObject *weak_object)
{
- GMainLoop *mainloop = user_data;
+ InspectContactData *data = user_data;
if (error == NULL)
{
@@ -87,6 +97,8 @@ got_contacts_by_id (TpConnection *connection,
GHashTableIter hash_iter;
gpointer key, value;
+ data->exit_status = 0;
+
for (i = 0; i < n_contacts; i++)
{
display_contact (contacts[i]);
@@ -100,14 +112,58 @@ got_contacts_by_id (TpConnection *connection,
GError *e = value;
g_warning ("Invalid ID \"%s\": %s", id, e->message);
+ data->exit_status = 1;
}
}
else
{
g_warning ("Error getting contacts: %s", error->message);
+ data->exit_status = 1;
}
- g_main_loop_quit (mainloop);
+ g_main_loop_quit (data->main_loop);
+}
+
+static void
+connection_ready_cb (TpConnection *connection,
+ const GError *error,
+ gpointer user_data)
+{
+ static TpContactFeature features[] = {
+ TP_CONTACT_FEATURE_ALIAS,
+ TP_CONTACT_FEATURE_AVATAR_TOKEN,
+ TP_CONTACT_FEATURE_PRESENCE
+ };
+ InspectContactData *data = user_data;
+
+ if (error != NULL)
+ {
+ g_warning ("%s", error->message);
+ data->exit_status = 1;
+ g_main_loop_quit (data->main_loop);
+ return;
+ }
+
+ if (data->to_inspect == NULL)
+ {
+ TpHandle self_handle = tp_connection_get_self_handle (connection);
+
+ tp_connection_get_contacts_by_handle (connection,
+ 1, &self_handle,
+ sizeof (features) / sizeof (features[0]), features,
+ got_contacts_by_handle,
+ data, NULL, NULL);
+ }
+ else
+ {
+ const gchar *contacts[] = { data->to_inspect, NULL };
+
+ tp_connection_get_contacts_by_id (connection,
+ 1, contacts,
+ sizeof (features) / sizeof (features[0]), features,
+ got_contacts_by_id,
+ data, NULL, NULL);
+ }
}
int
@@ -116,15 +172,9 @@ main (int argc,
{
const gchar *bus_name, *object_path;
TpConnection *connection = NULL;
- GMainLoop *mainloop = NULL;
+ InspectContactData data = { NULL, 1, NULL };
TpDBusDaemon *daemon = NULL;
GError *error = NULL;
- static TpContactFeature features[] = {
- TP_CONTACT_FEATURE_ALIAS,
- TP_CONTACT_FEATURE_AVATAR_TOKEN,
- TP_CONTACT_FEATURE_PRESENCE
- };
- int ret = 1;
g_type_init ();
tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG"));
@@ -151,6 +201,8 @@ main (int argc,
bus_name = argv[1];
}
+ data.to_inspect = argv[2];
+
daemon = tp_dbus_daemon_dup (&error);
if (daemon == NULL)
@@ -161,49 +213,28 @@ main (int argc,
connection = tp_connection_new (daemon, bus_name, object_path, &error);
- if (connection == NULL ||
- !tp_connection_run_until_ready (connection, FALSE, &error, NULL))
+ if (connection == NULL)
{
g_warning ("%s", error->message);
goto out;
}
- g_message ("Connection ready\n");
-
- mainloop = g_main_loop_new (NULL, FALSE);
-
- if (argv[2] == NULL)
- {
- guint self_handle = tp_connection_get_self_handle (connection);
+ data.main_loop = g_main_loop_new (NULL, FALSE);
- tp_connection_get_contacts_by_handle (connection,
- 1, &self_handle,
- sizeof (features) / sizeof (features[0]), features,
- got_contacts_by_handle,
- g_main_loop_ref (mainloop),
- (GDestroyNotify) g_main_loop_unref, NULL);
- }
- else
- {
- const gchar *contacts[] = { argv[2], NULL };
-
- tp_connection_get_contacts_by_id (connection,
- 1, contacts,
- sizeof (features) / sizeof (features[0]), features,
- got_contacts_by_id,
- g_main_loop_ref (mainloop),
- (GDestroyNotify) g_main_loop_unref, NULL);
- }
+ /* for this example I assume it's an existing connection on which someone
+ * 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);
- g_main_loop_run (mainloop);
- ret = 0;
+ g_main_loop_run (data.main_loop);
out:
if (error != NULL)
g_error_free (error);
- if (mainloop != NULL)
- g_main_loop_unref (mainloop);
+ if (data.main_loop != NULL)
+ g_main_loop_unref (data.main_loop);
if (connection != NULL)
g_object_unref (connection);
@@ -211,5 +242,5 @@ out:
if (daemon != NULL)
g_object_unref (daemon);
- return ret;
+ return data.exit_status;
}
diff --git a/examples/cm/callable/media-channel.c b/examples/cm/callable/media-channel.c
index ef0d2c769..8516a6595 100644
--- a/examples/cm/callable/media-channel.c
+++ b/examples/cm/callable/media-channel.c
@@ -164,6 +164,7 @@ constructed (GObject *object)
DBusGConnection *bus;
TpIntSet *members;
TpIntSet *local_pending;
+ TpDBusDaemon *dbus_daemon;
if (chain_up != NULL)
chain_up (object);
@@ -171,8 +172,12 @@ constructed (GObject *object)
tp_handle_ref (contact_repo, self->priv->handle);
tp_handle_ref (contact_repo, self->priv->initiator);
- bus = tp_get_bus ();
+ /* we're running under tp_run_connection_manager(), so t_d_d_d can't fail */
+ dbus_daemon = tp_dbus_daemon_dup (NULL);
+ g_assert (dbus_daemon != NULL);
+ bus = tp_proxy_get_dbus_connection (dbus_daemon);
dbus_g_connection_register_g_object (bus, self->priv->object_path, object);
+ g_object_unref (dbus_daemon);
tp_group_mixin_init (object,
G_STRUCT_OFFSET (ExampleCallableMediaChannel, group),
diff --git a/examples/cm/channelspecific/room.c b/examples/cm/channelspecific/room.c
index 42a491623..611c9435f 100644
--- a/examples/cm/channelspecific/room.c
+++ b/examples/cm/channelspecific/room.c
@@ -252,14 +252,19 @@ constructor (GType type,
(self->priv->conn, TP_HANDLE_TYPE_ROOM);
DBusGConnection *bus;
TpHandle self_handle;
+ TpDBusDaemon *dbus_daemon;
tp_handle_ref (room_repo, self->priv->handle);
if (self->priv->initiator != 0)
tp_handle_ref (contact_repo, self->priv->initiator);
- bus = tp_get_bus ();
+ /* we're running under tp_run_connection_manager(), so t_d_d_d can't fail */
+ dbus_daemon = tp_dbus_daemon_dup (NULL);
+ g_assert (dbus_daemon != NULL);
+ bus = tp_proxy_get_dbus_connection (dbus_daemon);
dbus_g_connection_register_g_object (bus, self->priv->object_path, object);
+ g_object_unref (dbus_daemon);
tp_text_mixin_init (object, G_STRUCT_OFFSET (ExampleCSHRoomChannel, text),
contact_repo);
diff --git a/examples/cm/contactlist/contact-list.c b/examples/cm/contactlist/contact-list.c
index 016c1b469..20ddb8602 100644
--- a/examples/cm/contactlist/contact-list.c
+++ b/examples/cm/contactlist/contact-list.c
@@ -122,6 +122,8 @@ constructed (GObject *object)
TpHandle self_handle = self->priv->conn->self_handle;
TpHandleRepoIface *handle_repo = tp_base_connection_get_handles
(self->priv->conn, self->priv->handle_type);
+ DBusGConnection *bus;
+ TpDBusDaemon *dbus_daemon;
if (chain_up != NULL)
chain_up (object);
@@ -129,8 +131,12 @@ constructed (GObject *object)
g_assert (TP_IS_BASE_CONNECTION (self->priv->conn));
g_assert (EXAMPLE_IS_CONTACT_LIST_MANAGER (self->priv->manager));
- dbus_g_connection_register_g_object (tp_get_bus (), self->priv->object_path,
- object);
+ /* we're running under tp_run_connection_manager(), so t_d_d_d can't fail */
+ dbus_daemon = tp_dbus_daemon_dup (NULL);
+ g_assert (dbus_daemon != NULL);
+ bus = tp_proxy_get_dbus_connection (dbus_daemon);
+ dbus_g_connection_register_g_object (bus, self->priv->object_path, object);
+ g_object_unref (dbus_daemon);
tp_handle_ref (handle_repo, self->priv->handle);
tp_group_mixin_init (object, G_STRUCT_OFFSET (ExampleContactListBase, group),
diff --git a/examples/cm/echo-message-parts/chan.c b/examples/cm/echo-message-parts/chan.c
index 2359f1ca4..7018a25ac 100644
--- a/examples/cm/echo-message-parts/chan.c
+++ b/examples/cm/echo-message-parts/chan.c
@@ -195,6 +195,7 @@ constructor (GType type,
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles
(self->priv->conn, TP_HANDLE_TYPE_CONTACT);
DBusGConnection *bus;
+ TpDBusDaemon *dbus_daemon;
static TpChannelTextMessageType const types[] = {
TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION,
@@ -207,8 +208,12 @@ constructor (GType type,
if (self->priv->initiator != 0)
tp_handle_ref (contact_repo, self->priv->initiator);
- bus = tp_get_bus ();
+ /* we're running under tp_run_connection_manager(), so t_d_d_d can't fail */
+ dbus_daemon = tp_dbus_daemon_dup (NULL);
+ g_assert (dbus_daemon != NULL);
+ bus = tp_proxy_get_dbus_connection (dbus_daemon);
dbus_g_connection_register_g_object (bus, self->priv->object_path, object);
+ g_object_unref (dbus_daemon);
tp_message_mixin_init (object, G_STRUCT_OFFSET (ExampleEcho2Channel, text),
self->priv->conn);
diff --git a/examples/cm/echo/chan.c b/examples/cm/echo/chan.c
index 9bab6270a..cc2f2e854 100644
--- a/examples/cm/echo/chan.c
+++ b/examples/cm/echo/chan.c
@@ -88,14 +88,19 @@ constructor (GType type,
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles
(self->priv->conn, TP_HANDLE_TYPE_CONTACT);
DBusGConnection *bus;
+ TpDBusDaemon *dbus_daemon;
tp_handle_ref (contact_repo, self->priv->handle);
if (self->priv->initiator != 0)
tp_handle_ref (contact_repo, self->priv->initiator);
- bus = tp_get_bus ();
+ /* we're running under tp_run_connection_manager(), so t_d_d_d can't fail */
+ dbus_daemon = tp_dbus_daemon_dup (NULL);
+ g_assert (dbus_daemon != NULL);
+ bus = tp_proxy_get_dbus_connection (dbus_daemon);
dbus_g_connection_register_g_object (bus, self->priv->object_path, object);
+ g_object_unref (dbus_daemon);
tp_text_mixin_init (object, G_STRUCT_OFFSET (ExampleEchoChannel, text),
contact_repo);
diff --git a/telepathy-glib/Makefile.am b/telepathy-glib/Makefile.am
index 6c425b2c0..cccd8ccb6 100644
--- a/telepathy-glib/Makefile.am
+++ b/telepathy-glib/Makefile.am
@@ -436,7 +436,7 @@ _gen/tp-cli-%-body.h _gen/tp-cli-%.h: _gen/tp-spec-%.xml \
subclass_assert= ; \
case $* in \
generic) \
- maybe_reentrant=--generate-reentrant; \
+ maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \
;; \
account-manager) \
subclass=--subclass=TpAccountManager; \
@@ -449,7 +449,7 @@ _gen/tp-cli-%-body.h _gen/tp-cli-%.h: _gen/tp-spec-%.xml \
channel) \
subclass=--subclass=TpChannel; \
subclass_assert=--subclass-assert=TP_IS_CHANNEL; \
- maybe_reentrant=--generate-reentrant; \
+ maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \
;; \
channel-dispatcher) \
subclass=--subclass=TpChannelDispatcher; \
@@ -470,27 +470,27 @@ _gen/tp-cli-%-body.h _gen/tp-cli-%.h: _gen/tp-spec-%.xml \
connection-manager) \
subclass=--subclass=TpConnectionManager; \
subclass_assert=--subclass-assert=TP_IS_CONNECTION_MANAGER \
- maybe_reentrant=--generate-reentrant; \
+ maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \
;; \
connection) \
subclass=--subclass=TpConnection; \
subclass_assert=--subclass-assert=TP_IS_CONNECTION; \
- maybe_reentrant=--generate-reentrant; \
+ maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \
;; \
media-session-handler) \
subclass=--subclass=TpMediaSessionHandler; \
subclass_assert=--subclass-assert=TP_IS_MEDIA_SESSION_HANDLER; \
- maybe_reentrant=--generate-reentrant; \
+ maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \
;; \
media-stream-handler) \
subclass=--subclass=TpMediaStreamHandler; \
subclass_assert=--subclass-assert=TP_IS_MEDIA_STREAM_HANDLER; \
- maybe_reentrant=--generate-reentrant; \
+ maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \
;; \
dbus-daemon) \
subclass=--subclass=TpDBusDaemon; \
subclass_assert=--subclass-assert=TP_IS_DBUS_DAEMON; \
- maybe_reentrant=--generate-reentrant; \
+ maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \
;; \
esac; \
$(PYTHON) $(tools_dir)/glib-client-gen.py \
@@ -498,5 +498,6 @@ _gen/tp-cli-%-body.h _gen/tp-cli-%.h: _gen/tp-spec-%.xml \
--group `echo $* | tr - _` \
--iface-quark-prefix=TP_IFACE_QUARK \
--tp-proxy-api=0.7.6 \
+ --deprecation-attribute=_TP_GNUC_DEPRECATED \
$$maybe_reentrant \
$< Tp_Cli _gen/tp-cli-$*
diff --git a/telepathy-glib/account-manager-internal.h b/telepathy-glib/account-manager-internal.h
index 18dbeef75..4ac35c57b 100644
--- a/telepathy-glib/account-manager-internal.h
+++ b/telepathy-glib/account-manager-internal.h
@@ -26,15 +26,6 @@
G_BEGIN_DECLS
-const GQuark * _tp_account_manager_get_requested_features (
- TpAccountManager *manager);
-
-const GQuark * _tp_account_manager_get_actual_features (
- TpAccountManager *manager);
-
-const GQuark * _tp_account_manager_get_missing_features (
- TpAccountManager *manager);
-
G_END_DECLS
#endif
diff --git a/telepathy-glib/account-manager.c b/telepathy-glib/account-manager.c
index 01e960e63..8fa2ad21f 100644
--- a/telepathy-glib/account-manager.c
+++ b/telepathy-glib/account-manager.c
@@ -1492,60 +1492,6 @@ tp_account_manager_prepare_finish (TpAccountManager *manager,
}
/**
- * _tp_account_manager_get_requested_features:
- * @manager: a #TpAccountManager
- *
- * <!-- -->
- *
- * Returns: a 0-terminated list of requested features on @manager
- *
- * Since: 0.9.0
- */
-const GQuark *
-_tp_account_manager_get_requested_features (TpAccountManager *manager)
-{
- g_return_val_if_fail (TP_IS_ACCOUNT_MANAGER (manager), NULL);
-
- return (const GQuark *) manager->priv->requested_features->data;
-}
-
-/**
- * _tp_account_manager_get_actual_features:
- * @manager: a #TpAccountManager
- *
- * <!-- -->
- *
- * Returns: a 0-terminated list of actual features on @manager
- *
- * Since: 0.9.0
- */
-const GQuark *
-_tp_account_manager_get_actual_features (TpAccountManager *manager)
-{
- g_return_val_if_fail (TP_IS_ACCOUNT_MANAGER (manager), NULL);
-
- return (const GQuark *) manager->priv->actual_features->data;
-}
-
-/**
- * _tp_account_manager_get_missing_features:
- * @manager: a #TpAccountManager
- *
- * <!-- -->
- *
- * Returns: a 0-terminated list of missing features on @manager
- *
- * Since: 0.9.0
- */
-const GQuark *
-_tp_account_manager_get_missing_features (TpAccountManager *manager)
-{
- g_return_val_if_fail (TP_IS_ACCOUNT_MANAGER (manager), NULL);
-
- return (const GQuark *) manager->priv->missing_features->data;
-}
-
-/**
* tp_account_manager_enable_restart:
* @manager: a #TpAccountManager
*
diff --git a/telepathy-glib/account-manager.h b/telepathy-glib/account-manager.h
index e5e0ebd6b..151e46ccd 100644
--- a/telepathy-glib/account-manager.h
+++ b/telepathy-glib/account-manager.h
@@ -23,8 +23,9 @@
#define TP_ACCOUNT_MANAGER_H
#include <telepathy-glib/account.h>
-#include <telepathy-glib/proxy.h>
#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/defs.h>
+#include <telepathy-glib/proxy.h>
G_BEGIN_DECLS
diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index f675043b9..b673059ab 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -114,8 +114,6 @@ struct _TpAccountPrivate {
GList *features;
GList *callbacks;
GArray *requested_features;
- GArray *actual_features;
- GArray *missing_features;
};
typedef struct {
@@ -292,9 +290,6 @@ _tp_account_become_ready (TpAccount *self,
f->ready = TRUE;
- if (!_tp_account_feature_in_array (feature, priv->actual_features))
- g_array_append_val (priv->actual_features, feature);
-
/* First, find which callbacks are satisfied and add those items
* from the remove list. */
l = priv->callbacks;
@@ -696,8 +691,6 @@ _tp_account_constructed (GObject *object)
priv->features = NULL;
priv->callbacks = NULL;
priv->requested_features = g_array_new (TRUE, FALSE, sizeof (GQuark));
- priv->actual_features = g_array_new (TRUE, FALSE, sizeof (GQuark));
- priv->missing_features = g_array_new (TRUE, FALSE, sizeof (GQuark));
known_features = _tp_account_get_known_features ();
@@ -863,8 +856,6 @@ _tp_account_finalize (GObject *object)
priv->callbacks = NULL;
g_array_free (priv->requested_features, TRUE);
- g_array_free (priv->actual_features, TRUE);
- g_array_free (priv->missing_features, TRUE);
/* free any data held directly by the object here */
if (G_OBJECT_CLASS (tp_account_parent_class)->finalize != NULL)
@@ -2705,61 +2696,6 @@ tp_account_prepare_finish (TpAccount *account,
return TRUE;
}
-/**
- * _tp_account_get_requested_features:
- * @account: a #TpAccount
- *
- * <!-- -->
- *
- * Returns: a 0-terminated list of features requested on @account
- *
- * Since: 0.9.0
- */
-const GQuark *
-_tp_account_get_requested_features (TpAccount *account)
-{
- g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
-
- return (const GQuark *) account->priv->requested_features->data;
-}
-
-/**
- * _tp_account_get_actual_features:
- * @account: a #TpAccount
- *
- * <!-- -->
- *
- * Returns: a 0-terminated list of actual features on @account
- *
- * Since: 0.9.0
- */
-const GQuark *
-_tp_account_get_actual_features (TpAccount *account)
-{
- g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
-
- return (const GQuark *) account->priv->actual_features->data;
-}
-
-/**
- * _tp_account_get_missing_features:
- * @account: a #TpAccount
- *
- * <!-- -->
- *
- * Returns: a 0-terminated list of missing features from @account
- * that have been requested
- *
- * Since: 0.9.0
- */
-const GQuark *
-_tp_account_get_missing_features (TpAccount *account)
-{
- g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
-
- return (const GQuark *) account->priv->missing_features->data;
-}
-
static void
set_or_free (gchar **target,
gchar *source)
diff --git a/telepathy-glib/account.h b/telepathy-glib/account.h
index 4291bc42c..a5c871ecd 100644
--- a/telepathy-glib/account.h
+++ b/telepathy-glib/account.h
@@ -25,8 +25,9 @@
#include <gio/gio.h>
#include <telepathy-glib/connection.h>
-#include <telepathy-glib/proxy.h>
#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/defs.h>
+#include <telepathy-glib/proxy.h>
G_BEGIN_DECLS
diff --git a/telepathy-glib/channel-dispatch-operation.h b/telepathy-glib/channel-dispatch-operation.h
index 2518b20f0..0eaa0968d 100644
--- a/telepathy-glib/channel-dispatch-operation.h
+++ b/telepathy-glib/channel-dispatch-operation.h
@@ -22,8 +22,9 @@
#ifndef TP_CHANNEL_DISPATCH_OPERATION_H
#define TP_CHANNEL_DISPATCH_OPERATION_H
-#include <telepathy-glib/proxy.h>
#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/defs.h>
+#include <telepathy-glib/proxy.h>
G_BEGIN_DECLS
diff --git a/telepathy-glib/channel-dispatcher.h b/telepathy-glib/channel-dispatcher.h
index 31aa3d06d..b64924aa7 100644
--- a/telepathy-glib/channel-dispatcher.h
+++ b/telepathy-glib/channel-dispatcher.h
@@ -22,8 +22,9 @@
#ifndef TP_CHANNEL_DISPATCHER_H
#define TP_CHANNEL_DISPATCHER_H
-#include <telepathy-glib/proxy.h>
#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/defs.h>
+#include <telepathy-glib/proxy.h>
G_BEGIN_DECLS
diff --git a/telepathy-glib/channel-request.h b/telepathy-glib/channel-request.h
index 9799a4317..7a038d847 100644
--- a/telepathy-glib/channel-request.h
+++ b/telepathy-glib/channel-request.h
@@ -22,8 +22,9 @@
#ifndef TP_CHANNEL_REQUEST_H
#define TP_CHANNEL_REQUEST_H
-#include <telepathy-glib/proxy.h>
#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/defs.h>
+#include <telepathy-glib/proxy.h>
G_BEGIN_DECLS
diff --git a/telepathy-glib/channel.c b/telepathy-glib/channel.c
index 89c3f565c..55d2f3aad 100644
--- a/telepathy-glib/channel.c
+++ b/telepathy-glib/channel.c
@@ -1502,6 +1502,9 @@ finally:
* %FALSE if the channel has become invalid.
*
* Since: 0.7.1
+ * Deprecated: since 0.9.UNRELEASED. Use tp_connection_call_when_ready,
+ * or restructure your program in such a way as to avoid re-entering the
+ * main loop.
*/
gboolean
tp_channel_run_until_ready (TpChannel *self,
diff --git a/telepathy-glib/channel.h b/telepathy-glib/channel.h
index e8751ae01..1da6ca185 100644
--- a/telepathy-glib/channel.h
+++ b/telepathy-glib/channel.h
@@ -23,6 +23,7 @@
#define __TP_CHANNEL_H__
#include <telepathy-glib/connection.h>
+#include <telepathy-glib/defs.h>
#include <telepathy-glib/enums.h>
#include <telepathy-glib/handle.h>
#include <telepathy-glib/intset.h>
@@ -80,8 +81,10 @@ TpChannel *tp_channel_new_from_properties (TpConnection *conn,
const gchar *object_path, const GHashTable *immutable_properties,
GError **error) G_GNUC_WARN_UNUSED_RESULT;
+#ifndef TP_DISABLE_DEPRECATED
gboolean tp_channel_run_until_ready (TpChannel *self, GError **error,
- GMainLoop **loop);
+ GMainLoop **loop) _TP_GNUC_DEPRECATED;
+#endif
typedef void (*TpChannelWhenReadyCb) (TpChannel *channel, const GError *error,
gpointer user_data);
diff --git a/telepathy-glib/client.h b/telepathy-glib/client.h
index 49d5ec937..fce1220dc 100644
--- a/telepathy-glib/client.h
+++ b/telepathy-glib/client.h
@@ -22,8 +22,9 @@
#ifndef TP_CLIENT_H
#define TP_CLIENT_H
-#include <telepathy-glib/proxy.h>
#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/defs.h>
+#include <telepathy-glib/proxy.h>
G_BEGIN_DECLS
diff --git a/telepathy-glib/connection-manager.h b/telepathy-glib/connection-manager.h
index 032f88fd6..3d08da1af 100644
--- a/telepathy-glib/connection-manager.h
+++ b/telepathy-glib/connection-manager.h
@@ -22,8 +22,9 @@
#ifndef __TP_CONNECTION_MANAGER_H__
#define __TP_CONNECTION_MANAGER_H__
-#include <telepathy-glib/proxy.h>
#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/defs.h>
+#include <telepathy-glib/proxy.h>
G_BEGIN_DECLS
diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c
index 4ff4ab855..bf647eecc 100644
--- a/telepathy-glib/connection.c
+++ b/telepathy-glib/connection.c
@@ -349,8 +349,7 @@ tp_connection_got_interfaces_cb (TpConnection *self,
{
GQuark q = g_quark_from_string (*iter);
- tp_proxy_add_interface_by_id ((TpProxy *) self,
- g_quark_from_string (*iter));
+ tp_proxy_add_interface_by_id ((TpProxy *) self, q);
if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACTS)
{
@@ -906,6 +905,9 @@ tp_connection_get_status (TpConnection *self,
* %FALSE if the connection has become invalid.
*
* Since: 0.7.1
+ * Deprecated: since 0.9.UNRELEASED. Use tp_connection_call_when_ready,
+ * or restructure your program in such a way as to avoid re-entering the
+ * main loop.
*/
typedef struct {
diff --git a/telepathy-glib/connection.h b/telepathy-glib/connection.h
index fcacb7c60..fb917f976 100644
--- a/telepathy-glib/connection.h
+++ b/telepathy-glib/connection.h
@@ -22,6 +22,7 @@
#ifndef __TP_CONNECTION_H__
#define __TP_CONNECTION_H__
+#include <telepathy-glib/defs.h>
#include <telepathy-glib/enums.h>
#include <telepathy-glib/handle.h>
#include <telepathy-glib/proxy.h>
@@ -80,9 +81,11 @@ TpHandle tp_connection_get_self_handle (TpConnection *self);
gboolean tp_connection_is_ready (TpConnection *self);
+#ifndef TP_DISABLE_DEPRECATED
gboolean tp_connection_run_until_ready (TpConnection *self,
gboolean connect, GError **error,
- GMainLoop **loop);
+ GMainLoop **loop) _TP_GNUC_DEPRECATED;
+#endif
typedef void (*TpConnectionWhenReadyCb) (TpConnection *connection,
const GError *error, gpointer user_data);
diff --git a/telepathy-glib/dbus-daemon.h b/telepathy-glib/dbus-daemon.h
index f8b14cb01..a77ceec8a 100644
--- a/telepathy-glib/dbus-daemon.h
+++ b/telepathy-glib/dbus-daemon.h
@@ -26,6 +26,7 @@
#error dbus-daemon.h not to be used directly, #include <telepathy-glib/dbus.h>
#endif
+#include <telepathy-glib/defs.h>
#include <telepathy-glib/proxy.h>
G_BEGIN_DECLS
diff --git a/telepathy-glib/dbus.h b/telepathy-glib/dbus.h
index 6c743962c..0da7d6a06 100644
--- a/telepathy-glib/dbus.h
+++ b/telepathy-glib/dbus.h
@@ -23,6 +23,7 @@
#define __TELEPATHY_DBUS_H__
#define __TP_IN_DBUS_H__
+#include <telepathy-glib/defs.h>
#include <telepathy-glib/dbus-daemon.h>
G_BEGIN_DECLS
@@ -127,7 +128,7 @@ void tp_asv_set_strv (GHashTable *asv, const gchar *key, gchar **value);
void tp_asv_dump (GHashTable *asv);
#ifndef TP_DISABLE_DEPRECATED
-DBusGProxy * tp_get_bus_proxy (void) G_GNUC_DEPRECATED;
+DBusGProxy * tp_get_bus_proxy (void) _TP_GNUC_DEPRECATED;
#endif
G_END_DECLS
diff --git a/telepathy-glib/debug.h b/telepathy-glib/debug.h
index 8bc295353..1f7a24dc6 100644
--- a/telepathy-glib/debug.h
+++ b/telepathy-glib/debug.h
@@ -2,6 +2,7 @@
#define __TP_DEBUG_H__
#include <glib.h>
+#include <telepathy-glib/defs.h>
G_BEGIN_DECLS
@@ -16,10 +17,10 @@ void tp_debug_timestamped_log_handler (const gchar *log_domain,
#ifndef TP_DISABLE_DEPRECATED
void tp_debug_set_flags_from_string (const gchar *flags_string)
- G_GNUC_DEPRECATED;
+ _TP_GNUC_DEPRECATED;
void tp_debug_set_flags_from_env (const gchar *var)
- G_GNUC_DEPRECATED;
-void tp_debug_set_all_flags (void) G_GNUC_DEPRECATED;
+ _TP_GNUC_DEPRECATED;
+void tp_debug_set_all_flags (void) _TP_GNUC_DEPRECATED;
#endif
G_END_DECLS
diff --git a/telepathy-glib/defs.h b/telepathy-glib/defs.h
index 777ef0441..a7407261f 100644
--- a/telepathy-glib/defs.h
+++ b/telepathy-glib/defs.h
@@ -109,5 +109,14 @@ G_BEGIN_DECLS
*/
#define TP_CLIENT_OBJECT_PATH_BASE "/org/freedesktop/Telepathy/Client/"
+/* telepathy-glib-specific version of G_GNUC_DEPRECATED so our regression
+ * tests can continue to test deprecated functionality, while avoiding
+ * deprecated bits of other libraries */
+#ifdef _TP_IGNORE_DEPRECATIONS
+#define _TP_GNUC_DEPRECATED /* nothing */
+#else
+#define _TP_GNUC_DEPRECATED G_GNUC_DEPRECATED
+#endif
+
G_END_DECLS
#endif
diff --git a/telepathy-glib/media-interfaces.h b/telepathy-glib/media-interfaces.h
index f6126f14e..6dc601505 100644
--- a/telepathy-glib/media-interfaces.h
+++ b/telepathy-glib/media-interfaces.h
@@ -22,6 +22,7 @@
#ifndef __TP_MEDIA_INTERFACES_H__
#define __TP_MEDIA_INTERFACES_H__
+#include <telepathy-glib/defs.h>
#include <telepathy-glib/proxy.h>
G_BEGIN_DECLS
diff --git a/telepathy-glib/proxy.h b/telepathy-glib/proxy.h
index 24b027f98..a2afe85f8 100644
--- a/telepathy-glib/proxy.h
+++ b/telepathy-glib/proxy.h
@@ -25,6 +25,8 @@
#include <dbus/dbus-glib.h>
#include <glib-object.h>
+#include <telepathy-glib/defs.h>
+
G_BEGIN_DECLS
/* Forward declaration of a subclass - from dbus.h */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 63d6dc816..a5bb46e78 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -85,4 +85,5 @@ AM_CFLAGS = \
$(ERROR_CFLAGS) \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS) \
+ -D_TP_IGNORE_DEPRECATIONS \
$(TP_GLIB_CFLAGS)
diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index 067abd1ae..efed0fa00 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -168,6 +168,7 @@ AM_CFLAGS = \
$(ERROR_CFLAGS) \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS) \
+ -D_TP_IGNORE_DEPRECATIONS \
$(TP_GLIB_CFLAGS)
TESTS_ENVIRONMENT = \
diff --git a/tests/dbus/account-manager.c b/tests/dbus/account-manager.c
index 0af552bf3..e3da91fc7 100644
--- a/tests/dbus/account-manager.c
+++ b/tests/dbus/account-manager.c
@@ -13,6 +13,7 @@
#include <telepathy-glib/defs.h>
#include "tests/lib/simple-account-manager.h"
+#include "tests/lib/util.h"
typedef struct {
GFunc action;
@@ -127,8 +128,7 @@ setup (Test *test,
test->mainloop = g_main_loop_new (NULL, FALSE);
- test->dbus = tp_dbus_daemon_dup (NULL);
- g_assert (test->dbus != NULL);
+ test->dbus = test_dbus_daemon_dup_or_die ();
test->am = NULL;
test->timeout_id = 0;
@@ -142,7 +142,7 @@ setup_service (Test *test,
setup (test, data);
- test->bus = tp_get_bus ();
+ test->bus = tp_proxy_get_dbus_connection (test->dbus);
g_assert (tp_dbus_daemon_request_name (test->dbus,
TP_ACCOUNT_MANAGER_BUS_NAME, FALSE, &test->error));
diff --git a/tests/dbus/account.c b/tests/dbus/account.c
index 70c0b6d72..bffaf4182 100644
--- a/tests/dbus/account.c
+++ b/tests/dbus/account.c
@@ -12,6 +12,8 @@
#include <telepathy-glib/debug.h>
#include <telepathy-glib/defs.h>
+#include "tests/lib/util.h"
+
static void
test_parse_failure (gconstpointer test_data)
{
@@ -80,7 +82,7 @@ setup (Test *test,
gconstpointer data)
{
test->mainloop = g_main_loop_new (NULL, FALSE);
- test->dbus = tp_dbus_daemon_dup (NULL);
+ test->dbus = test_dbus_daemon_dup_or_die ();
g_assert (test->dbus != NULL);
test->account = NULL;
diff --git a/tests/dbus/call-cancellation.c b/tests/dbus/call-cancellation.c
index 5aeedcb23..030002141 100644
--- a/tests/dbus/call-cancellation.c
+++ b/tests/dbus/call-cancellation.c
@@ -8,6 +8,7 @@
#include "tests/lib/myassert.h"
#include "tests/lib/stub-object.h"
+#include "tests/lib/util.h"
/* just for convenience, since it's used a lot */
#define PTR(ui) GUINT_TO_POINTER(ui)
@@ -183,29 +184,29 @@ main (int argc,
/* We use TpDBusDaemon because it's a convenient concrete subclass of
* TpProxy. */
g_message ("Creating proxies");
- a = tp_dbus_daemon_new (tp_get_bus ());
+ a = test_dbus_daemon_dup_or_die ();
g_message ("a=%p", a);
- b = tp_dbus_daemon_new (tp_get_bus ());
+ b = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("b=%p", b);
- c = tp_dbus_daemon_new (tp_get_bus ());
+ c = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("c=%p", c);
- d = tp_dbus_daemon_new (tp_get_bus ());
+ d = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("d=%p", d);
- e = tp_dbus_daemon_new (tp_get_bus ());
+ e = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("e=%p", e);
- f = tp_dbus_daemon_new (tp_get_bus ());
+ f = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("f=%p", f);
- g = tp_dbus_daemon_new (tp_get_bus ());
+ g = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("g=%p", g);
- h = tp_dbus_daemon_new (tp_get_bus ());
+ h = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("h=%p", h);
- i = tp_dbus_daemon_new (tp_get_bus ());
+ i = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("i=%p", i);
- j = tp_dbus_daemon_new (tp_get_bus ());
+ j = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("j=%p", j);
- k = tp_dbus_daemon_new (tp_get_bus ());
+ k = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("k=%p", k);
- z = tp_dbus_daemon_new (tp_get_bus ());
+ z = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("z=%p", z);
/* a survives */
diff --git a/tests/dbus/call-example.c b/tests/dbus/call-example.c
index 48771e584..55229a03a 100644
--- a/tests/dbus/call-example.c
+++ b/tests/dbus/call-example.c
@@ -121,8 +121,7 @@ setup (Test *test,
tp_debug_set_flags ("all");
test->mainloop = g_main_loop_new (NULL, FALSE);
- test->dbus = tp_dbus_daemon_dup (NULL);
- g_assert (test->dbus != NULL);
+ test->dbus = test_dbus_daemon_dup_or_die ();
test->service_cm = EXAMPLE_CALL_CONNECTION_MANAGER (g_object_new (
EXAMPLE_TYPE_CALL_CONNECTION_MANAGER,
diff --git a/tests/dbus/callable-example.c b/tests/dbus/callable-example.c
index 09d850b52..2fdf83adc 100644
--- a/tests/dbus/callable-example.c
+++ b/tests/dbus/callable-example.c
@@ -238,8 +238,7 @@ setup (Test *test,
test->stream_states = g_hash_table_new (NULL, NULL);
test->mainloop = g_main_loop_new (NULL, FALSE);
- test->dbus = tp_dbus_daemon_dup (NULL);
- g_assert (test->dbus != NULL);
+ test->dbus = test_dbus_daemon_dup_or_die ();
test->service_cm = EXAMPLE_CALLABLE_CONNECTION_MANAGER (g_object_new (
EXAMPLE_TYPE_CALLABLE_CONNECTION_MANAGER,
diff --git a/tests/dbus/channel-dispatch-operation.c b/tests/dbus/channel-dispatch-operation.c
index 84c57f6c3..110c8ee90 100644
--- a/tests/dbus/channel-dispatch-operation.c
+++ b/tests/dbus/channel-dispatch-operation.c
@@ -67,8 +67,7 @@ setup (Test *test,
tp_debug_set_flags ("all");
test->mainloop = g_main_loop_new (NULL, FALSE);
- test->dbus = tp_dbus_daemon_dup (NULL);
- g_assert (test->dbus != NULL);
+ test->dbus = test_dbus_daemon_dup_or_die ();
libdbus = dbus_bus_get_private (DBUS_BUS_STARTER, NULL);
g_assert (libdbus != NULL);
diff --git a/tests/dbus/channel-dispatcher.c b/tests/dbus/channel-dispatcher.c
index f350ec82d..13dc1cd7d 100644
--- a/tests/dbus/channel-dispatcher.c
+++ b/tests/dbus/channel-dispatcher.c
@@ -11,6 +11,8 @@
#include <telepathy-glib/channel-dispatcher.h>
#include <telepathy-glib/debug.h>
+#include "tests/lib/util.h"
+
typedef struct {
GMainLoop *mainloop;
TpDBusDaemon *dbus;
@@ -27,8 +29,7 @@ setup (Test *test,
tp_debug_set_flags ("all");
test->mainloop = g_main_loop_new (NULL, FALSE);
- test->dbus = tp_dbus_daemon_dup (NULL);
- g_assert (test->dbus != NULL);
+ test->dbus = test_dbus_daemon_dup_or_die ();
test->cd = NULL;
}
diff --git a/tests/dbus/channel-introspect.c b/tests/dbus/channel-introspect.c
index d630c5158..354e3cdbf 100644
--- a/tests/dbus/channel-introspect.c
+++ b/tests/dbus/channel-introspect.c
@@ -112,7 +112,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = SIMPLE_CONNECTION (g_object_new (SIMPLE_TYPE_CONNECTION,
"account", "me@example.com",
diff --git a/tests/dbus/channel-request.c b/tests/dbus/channel-request.c
index 1699997ba..03c1073cc 100644
--- a/tests/dbus/channel-request.c
+++ b/tests/dbus/channel-request.c
@@ -69,7 +69,7 @@ setup (Test *test,
tp_debug_set_flags ("all");
test->mainloop = g_main_loop_new (NULL, FALSE);
- test->dbus = tp_dbus_daemon_dup (NULL);
+ test->dbus = test_dbus_daemon_dup_or_die ();
g_assert (test->dbus != NULL);
libdbus = dbus_bus_get_private (DBUS_BUS_STARTER, NULL);
diff --git a/tests/dbus/cli-group.c b/tests/dbus/cli-group.c
index ac7458216..0595c222f 100644
--- a/tests/dbus/cli-group.c
+++ b/tests/dbus/cli-group.c
@@ -401,7 +401,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = SIMPLE_CONNECTION (g_object_new (SIMPLE_TYPE_CONNECTION,
"account", "me@example.com",
diff --git a/tests/dbus/client.c b/tests/dbus/client.c
index 2cbf9aa08..030cedf97 100644
--- a/tests/dbus/client.c
+++ b/tests/dbus/client.c
@@ -11,6 +11,8 @@
#include <telepathy-glib/client.h>
#include <telepathy-glib/debug.h>
+#include "tests/lib/util.h"
+
typedef struct {
GMainLoop *mainloop;
TpDBusDaemon *dbus;
@@ -27,8 +29,7 @@ setup (Test *test,
tp_debug_set_flags ("all");
test->mainloop = g_main_loop_new (NULL, FALSE);
- test->dbus = tp_dbus_daemon_dup (NULL);
- g_assert (test->dbus != NULL);
+ test->dbus = test_dbus_daemon_dup_or_die ();
test->client = NULL;
}
diff --git a/tests/dbus/cm.c b/tests/dbus/cm.c
index 3d1ca4514..60df5acea 100644
--- a/tests/dbus/cm.c
+++ b/tests/dbus/cm.c
@@ -13,6 +13,8 @@
#include "examples/cm/echo/connection-manager.h"
+#include "tests/lib/util.h"
+
typedef struct {
GMainLoop *mainloop;
TpDBusDaemon *dbus;
@@ -33,8 +35,7 @@ setup (Test *test,
tp_debug_set_flags ("all");
test->mainloop = g_main_loop_new (NULL, FALSE);
- test->dbus = tp_dbus_daemon_dup (NULL);
- g_assert (test->dbus != NULL);
+ test->dbus = test_dbus_daemon_dup_or_die ();
test->service_cm = EXAMPLE_ECHO_CONNECTION_MANAGER (g_object_new (
EXAMPLE_TYPE_ECHO_CONNECTION_MANAGER,
diff --git a/tests/dbus/connection-bug-18845.c b/tests/dbus/connection-bug-18845.c
index 57098f897..24476f90c 100644
--- a/tests/dbus/connection-bug-18845.c
+++ b/tests/dbus/connection-bug-18845.c
@@ -48,7 +48,7 @@ main (int argc,
tp_debug_set_flags ("all");
mainloop = g_main_loop_new (NULL, FALSE);
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = SIMPLE_CONNECTION (g_object_new (
SIMPLE_TYPE_CONNECTION,
diff --git a/tests/dbus/connection-error.c b/tests/dbus/connection-error.c
index 0baf01088..5b4d1e310 100644
--- a/tests/dbus/connection-error.c
+++ b/tests/dbus/connection-error.c
@@ -109,7 +109,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
mainloop = g_main_loop_new (NULL, FALSE);
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
tp_proxy_subclass_add_error_mapping (TP_TYPE_CONNECTION,
"com.example", example_com_error_quark (), example_com_error_get_type ());
diff --git a/tests/dbus/connection-getinterfaces-failure.c b/tests/dbus/connection-getinterfaces-failure.c
index 4c9c19bd7..3ddf4d117 100644
--- a/tests/dbus/connection-getinterfaces-failure.c
+++ b/tests/dbus/connection-getinterfaces-failure.c
@@ -94,7 +94,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
mainloop = g_main_loop_new (NULL, FALSE);
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = SIMPLE_CONNECTION (g_object_new (
bug15306_connection_get_type (),
diff --git a/tests/dbus/connection-handles.c b/tests/dbus/connection-handles.c
index 37eba3507..abf449455 100644
--- a/tests/dbus/connection-handles.c
+++ b/tests/dbus/connection-handles.c
@@ -310,7 +310,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = SIMPLE_CONNECTION (g_object_new (
SIMPLE_TYPE_CONNECTION,
diff --git a/tests/dbus/connection-inject-bug16307.c b/tests/dbus/connection-inject-bug16307.c
index 21b441927..511e86558 100644
--- a/tests/dbus/connection-inject-bug16307.c
+++ b/tests/dbus/connection-inject-bug16307.c
@@ -40,7 +40,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
mainloop = g_main_loop_new (NULL, FALSE);
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
/* service side */
service_conn = BUG16307_CONNECTION (g_object_new (
diff --git a/tests/dbus/connection.c b/tests/dbus/connection.c
index ea796add8..73ae21a1d 100644
--- a/tests/dbus/connection.c
+++ b/tests/dbus/connection.c
@@ -18,68 +18,130 @@
#include "tests/lib/simple-conn.h"
#include "tests/lib/util.h"
-static GMainLoop *mainloop;
+typedef struct {
+ TpDBusDaemon *dbus;
+ SimpleConnection *service_conn;
+ TpBaseConnection *service_conn_as_base;
+ gchar *conn_name;
+ gchar *conn_path;
+ TpConnection *conn;
+
+ gboolean cwr_ready;
+ GError *cwr_error /* initialized in setup */;
+} Test;
static GError invalidated_for_test = { 0, TP_ERROR_PERMISSION_DENIED,
"No connection for you!" };
static void
-test_run_until_invalid (TpDBusDaemon *dbus,
- SimpleConnection *service_conn,
- const gchar *name,
- const gchar *conn_path)
+setup (Test *test,
+ gconstpointer data)
+{
+ GError *error = NULL;
+
+ invalidated_for_test.domain = TP_ERRORS;
+
+ g_type_init ();
+ tp_debug_set_flags ("all");
+ test->dbus = test_dbus_daemon_dup_or_die ();
+
+ test->service_conn = SIMPLE_CONNECTION (g_object_new (
+ SIMPLE_TYPE_CONNECTION,
+ "account", "me@example.com",
+ "protocol", "simple-protocol",
+ NULL));
+ test->service_conn_as_base = TP_BASE_CONNECTION (test->service_conn);
+ g_assert (test->service_conn != NULL);
+ g_assert (test->service_conn_as_base != NULL);
+
+ g_assert (tp_base_connection_register (test->service_conn_as_base, "simple",
+ &test->conn_name, &test->conn_path, &error));
+ g_assert_no_error (error);
+
+ test->cwr_ready = FALSE;
+ test->cwr_error = NULL;
+}
+
+static void
+teardown (Test *test,
+ gconstpointer data)
{
TpConnection *conn;
+ gboolean ok;
GError *error = NULL;
- conn = tp_connection_new (dbus, name, conn_path, &error);
- MYASSERT (conn != NULL, "");
- test_assert_no_error (error);
- tp_proxy_invalidate ((TpProxy *) conn, &invalidated_for_test);
+ if (test->conn != NULL)
+ {
+ g_object_unref (test->conn);
+ test->conn = NULL;
+ }
+
+ /* disconnect the connection so we don't leak it */
+ conn = tp_connection_new (test->dbus, test->conn_name, test->conn_path,
+ &error);
+ g_assert (conn != NULL);
+ g_assert_no_error (error);
+
+ ok = tp_cli_connection_run_disconnect (conn, -1, &error, NULL);
+ g_assert (ok);
+ g_assert_no_error (error);
+
+ g_assert (!tp_connection_run_until_ready (conn, FALSE, &error, NULL));
+ g_assert_error (error, TP_ERRORS, TP_ERROR_CANCELLED);
+ g_clear_error (&error);
+
+ test->service_conn_as_base = NULL;
+ g_object_unref (test->service_conn);
+ g_free (test->conn_name);
+ g_free (test->conn_path);
+
+ g_object_unref (test->dbus);
+ test->dbus = NULL;
+}
+
+static void
+test_run_until_invalid (Test *test,
+ gconstpointer nil G_GNUC_UNUSED)
+{
+ GError *error = NULL;
- MYASSERT (!tp_connection_run_until_ready (conn, TRUE, &error, NULL),
+ test->conn = tp_connection_new (test->dbus, test->conn_name, test->conn_path,
+ &error);
+ g_assert (test->conn != NULL);
+ g_assert_no_error (error);
+ tp_proxy_invalidate ((TpProxy *) test->conn, &invalidated_for_test);
+
+ MYASSERT (!tp_connection_run_until_ready (test->conn, TRUE, &error, NULL),
"");
- MYASSERT (error != NULL, "");
+ g_assert (error != NULL);
MYASSERT_SAME_ERROR (&invalidated_for_test, error);
g_error_free (error);
-
- g_object_unref (conn);
}
static void
-test_run_until_ready (TpDBusDaemon *dbus,
- SimpleConnection *service_conn,
- const gchar *name,
- const gchar *conn_path)
+test_run_until_ready (Test *test,
+ gconstpointer nil G_GNUC_UNUSED)
{
- TpConnection *conn;
GError *error = NULL;
- conn = tp_connection_new (dbus, name, conn_path, &error);
- MYASSERT (conn != NULL, "");
- test_assert_no_error (error);
+ test->conn = tp_connection_new (test->dbus, test->conn_name, test->conn_path,
+ &error);
+ g_assert (test->conn != NULL);
+ g_assert_no_error (error);
- MYASSERT (tp_connection_run_until_ready (conn, TRUE, &error, NULL),
+ MYASSERT (tp_connection_run_until_ready (test->conn, TRUE, &error, NULL),
"");
- test_assert_no_error (error);
-
- g_object_unref (conn);
+ g_assert_no_error (error);
}
-typedef struct {
- gboolean ready;
- GError *error /* initialized to NULL statically */;
- GMainLoop *mainloop;
-} WhenReadyContext;
-
static void
conn_ready (TpConnection *connection,
const GError *error,
gpointer user_data)
{
- WhenReadyContext *ctx = user_data;
+ Test *test = user_data;
- ctx->ready = TRUE;
+ test->cwr_ready = TRUE;
if (error == NULL)
{
@@ -89,9 +151,9 @@ conn_ready (TpConnection *connection,
g_message ("connection %p ready", connection);
parsed = tp_connection_parse_object_path (connection, &proto, &cm_name);
- MYASSERT (parsed == TRUE, "");
- MYASSERT_SAME_STRING (proto, "simple-protocol");
- MYASSERT_SAME_STRING (cm_name, "simple");
+ g_assert (parsed);
+ g_assert_cmpstr (proto, ==, "simple-protocol");
+ g_assert_cmpstr (cm_name, ==, "simple");
g_free (proto);
g_free (cm_name);
}
@@ -100,139 +162,83 @@ conn_ready (TpConnection *connection,
g_message ("connection %p invalidated: %s #%u \"%s\"", connection,
g_quark_to_string (error->domain), error->code, error->message);
- ctx->error = g_error_copy (error);
+ test->cwr_error = g_error_copy (error);
}
-
- if (ctx->mainloop != NULL)
- g_main_loop_quit (ctx->mainloop);
}
static void
-test_call_when_ready (TpDBusDaemon *dbus,
- SimpleConnection *service_conn,
- const gchar *name,
- const gchar *conn_path)
+test_call_when_ready (Test *test,
+ gconstpointer nil G_GNUC_UNUSED)
{
- TpConnection *conn;
GError *error = NULL;
- WhenReadyContext ctx = { FALSE, NULL, mainloop };
- conn = tp_connection_new (dbus, name, conn_path, &error);
- MYASSERT (conn != NULL, "");
- test_assert_no_error (error);
+ test->conn = tp_connection_new (test->dbus, test->conn_name, test->conn_path,
+ &error);
+ g_assert (test->conn != NULL);
+ g_assert_no_error (error);
- tp_connection_call_when_ready (conn, conn_ready, &ctx);
- g_message ("Entering main loop");
- g_main_loop_run (mainloop);
- g_message ("Leaving main loop");
- MYASSERT (ctx.ready == TRUE, "");
- test_assert_no_error (ctx.error);
+ tp_cli_connection_call_connect (test->conn, -1, NULL, NULL, NULL, NULL);
- /* Connection already ready, so we are called back synchronously */
+ tp_connection_call_when_ready (test->conn, conn_ready, test);
- ctx.ready = FALSE;
- tp_connection_call_when_ready (conn, conn_ready, &ctx);
- MYASSERT (ctx.ready == TRUE, "");
- test_assert_no_error (ctx.error);
+ while (!test->cwr_ready)
+ g_main_context_iteration (NULL, TRUE);
- g_object_unref (conn);
+ g_assert_no_error (test->cwr_error);
+
+ /* Connection already ready here, so we are called back synchronously */
+
+ test->cwr_ready = FALSE;
+ test->cwr_error = NULL;
+ tp_connection_call_when_ready (test->conn, conn_ready, test);
+ g_assert_cmpint (test->cwr_ready, ==, TRUE);
+ g_assert_no_error (test->cwr_error);
}
static void
-test_call_when_invalid (TpDBusDaemon *dbus,
- SimpleConnection *service_conn,
- const gchar *name,
- const gchar *conn_path)
+test_call_when_invalid (Test *test,
+ gconstpointer nil G_GNUC_UNUSED)
{
- TpConnection *conn;
GError *error = NULL;
- WhenReadyContext ctx = { FALSE, NULL, mainloop };
- conn = tp_connection_new (dbus, name, conn_path, &error);
- MYASSERT (conn != NULL, "");
- test_assert_no_error (error);
+ test->conn = tp_connection_new (test->dbus, test->conn_name, test->conn_path,
+ &error);
+ g_assert (test->conn != NULL);
+ g_assert_no_error (error);
/* Connection becomes invalid, so we are called back synchronously */
- ctx.ready = FALSE;
- tp_connection_call_when_ready (conn, conn_ready, &ctx);
- tp_proxy_invalidate ((TpProxy *) conn, &invalidated_for_test);
- MYASSERT (ctx.ready == TRUE, "");
- MYASSERT_SAME_ERROR (&invalidated_for_test, ctx.error);
- g_error_free (ctx.error);
- ctx.error = NULL;
+ tp_connection_call_when_ready (test->conn, conn_ready, test);
+ tp_proxy_invalidate ((TpProxy *) test->conn, &invalidated_for_test);
+ g_assert_cmpint (test->cwr_ready, ==, TRUE);
+ MYASSERT_SAME_ERROR (&invalidated_for_test, test->cwr_error);
+ g_clear_error (&test->cwr_error);
/* Connection already invalid, so we are called back synchronously */
- ctx.ready = FALSE;
- tp_connection_call_when_ready (conn, conn_ready, &ctx);
- MYASSERT (ctx.ready == TRUE, "");
- MYASSERT_SAME_ERROR (&invalidated_for_test, ctx.error);
- g_error_free (ctx.error);
- ctx.error = NULL;
-
- g_object_unref (conn);
+ test->cwr_ready = FALSE;
+ test->cwr_error = NULL;
+ tp_connection_call_when_ready (test->conn, conn_ready, test);
+ g_assert (test->cwr_ready);
+ MYASSERT_SAME_ERROR (&invalidated_for_test, test->cwr_error);
+ g_error_free (test->cwr_error);
+ test->cwr_error = NULL;
}
int
main (int argc,
char **argv)
{
- TpDBusDaemon *dbus;
- SimpleConnection *service_conn;
- TpBaseConnection *service_conn_as_base;
- gchar *name;
- gchar *conn_path;
- GError *error = NULL;
- TpConnection *conn;
-
- invalidated_for_test.domain = TP_ERRORS;
-
- g_type_init ();
- tp_debug_set_flags ("all");
- mainloop = g_main_loop_new (NULL, FALSE);
- dbus = tp_dbus_daemon_new (tp_get_bus ());
-
- service_conn = SIMPLE_CONNECTION (g_object_new (
- SIMPLE_TYPE_CONNECTION,
- "account", "me@example.com",
- "protocol", "simple-protocol",
- NULL));
- service_conn_as_base = TP_BASE_CONNECTION (service_conn);
- MYASSERT (service_conn != NULL, "");
- MYASSERT (service_conn_as_base != NULL, "");
-
- MYASSERT (tp_base_connection_register (service_conn_as_base, "simple",
- &name, &conn_path, &error), "");
- test_assert_no_error (error);
-
- test_run_until_invalid (dbus, service_conn, name, conn_path);
- test_run_until_ready (dbus, service_conn, name, conn_path);
- test_call_when_ready (dbus, service_conn, name, conn_path);
- test_call_when_invalid (dbus, service_conn, name, conn_path);
-
- conn = tp_connection_new (dbus, name, conn_path, &error);
- MYASSERT (conn != NULL, "");
- test_assert_no_error (error);
- MYASSERT (tp_connection_run_until_ready (conn, TRUE, &error, NULL),
- "");
- test_assert_no_error (error);
- MYASSERT (tp_cli_connection_run_disconnect (conn, -1, &error, NULL), "");
- test_assert_no_error (error);
-
- MYASSERT (!tp_connection_run_until_ready (conn, FALSE, &error, NULL), "");
- MYASSERT_SAME_UINT (error->domain, TP_ERRORS);
- MYASSERT_SAME_UINT (error->code, TP_ERROR_CANCELLED);
- g_error_free (error);
- error = NULL;
-
- service_conn_as_base = NULL;
- g_object_unref (service_conn);
- g_free (name);
- g_free (conn_path);
-
- g_object_unref (dbus);
- g_main_loop_unref (mainloop);
-
- return 0;
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add ("/conn/run_until_invalid", Test, NULL, setup,
+ test_run_until_invalid, teardown);
+ g_test_add ("/conn/run_until_ready", Test, NULL, setup,
+ test_run_until_ready, teardown);
+ g_test_add ("/conn/call_when_ready", Test, NULL, setup,
+ test_call_when_ready, teardown);
+ g_test_add ("/conn/call_when_invalid", Test, NULL, setup,
+ test_call_when_invalid, teardown);
+
+ return g_test_run ();
}
diff --git a/tests/dbus/contacts-bug-19101.c b/tests/dbus/contacts-bug-19101.c
index cda5d03ff..d9b31ca59 100644
--- a/tests/dbus/contacts-bug-19101.c
+++ b/tests/dbus/contacts-bug-19101.c
@@ -145,7 +145,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
DEBUG ("a");
service_conn = CONTACTS_CONNECTION (g_object_new (
diff --git a/tests/dbus/contacts-mixin.c b/tests/dbus/contacts-mixin.c
index 408cb9bb7..2f64e15f9 100644
--- a/tests/dbus/contacts-mixin.c
+++ b/tests/dbus/contacts-mixin.c
@@ -156,7 +156,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = CONTACTS_CONNECTION (g_object_new (
CONTACTS_TYPE_CONNECTION,
diff --git a/tests/dbus/contacts.c b/tests/dbus/contacts.c
index 0dc9fd399..35fee47e2 100644
--- a/tests/dbus/contacts.c
+++ b/tests/dbus/contacts.c
@@ -900,7 +900,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = CONTACTS_CONNECTION (g_object_new (
CONTACTS_TYPE_CONNECTION,
diff --git a/tests/dbus/disconnection.c b/tests/dbus/disconnection.c
index 6da182fde..375a13cef 100644
--- a/tests/dbus/disconnection.c
+++ b/tests/dbus/disconnection.c
@@ -172,23 +172,23 @@ main (int argc,
/* We use TpDBusDaemon because it's a convenient concrete subclass of
* TpProxy. */
g_message ("Creating proxies");
- a = tp_dbus_daemon_new (tp_get_bus ());
+ a = test_dbus_daemon_dup_or_die ();
g_message ("a=%p", a);
- b = tp_dbus_daemon_new (tp_get_bus ());
+ b = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("b=%p", b);
- c = tp_dbus_daemon_new (tp_get_bus ());
+ c = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("c=%p", c);
- d = tp_dbus_daemon_new (tp_get_bus ());
+ d = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("d=%p", d);
- e = tp_dbus_daemon_new (tp_get_bus ());
+ e = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("e=%p", e);
- f = tp_dbus_daemon_new (tp_get_bus ());
+ f = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("f=%p", f);
- g = tp_dbus_daemon_new (tp_get_bus ());
+ g = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("g=%p", g);
- h = tp_dbus_daemon_new (tp_get_bus ());
+ h = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("h=%p", h);
- z = tp_dbus_daemon_new (tp_get_bus ());
+ z = tp_dbus_daemon_new (tp_proxy_get_dbus_connection (a));
g_message ("z=%p", z);
/* a survives */
diff --git a/tests/dbus/example-no-protocols.c b/tests/dbus/example-no-protocols.c
index 201fe649f..c95bdac57 100644
--- a/tests/dbus/example-no-protocols.c
+++ b/tests/dbus/example-no-protocols.c
@@ -4,6 +4,8 @@
#include <telepathy-glib/defs.h>
#include <telepathy-glib/errors.h>
+#include "tests/lib/util.h"
+
static void
prepare (void)
{
@@ -63,14 +65,33 @@ time_out (gpointer mainloop)
return FALSE;
}
+static void
+wait_for_name_owner_cb (TpDBusDaemon *dbus_daemon,
+ const gchar *name,
+ const gchar *new_owner,
+ gpointer main_loop)
+{
+ if (new_owner[0] != '\0')
+ g_main_loop_quit (main_loop);
+}
+
+static void
+early_cm_exited (TpConnectionManager *cm,
+ gboolean *saw_exited)
+{
+ *saw_exited = TRUE;
+}
+
int
main (int argc,
char **argv)
{
GMainLoop *mainloop;
- TpConnectionManager *cm;
-
- prepare ();
+ TpConnectionManager *early_cm, *late_cm;
+ TpDBusDaemon *dbus_daemon;
+ gulong handler;
+ GError *error = NULL;
+ gboolean saw_exited;
g_type_init ();
@@ -78,18 +99,61 @@ main (int argc,
mainloop = g_main_loop_new (NULL, FALSE);
- cm = tp_connection_manager_new (tp_dbus_daemon_new (tp_get_bus ()),
- "example_no_protocols", NULL, NULL);
- g_assert (cm != NULL);
-
- g_signal_connect (cm, "got-info",
- G_CALLBACK (connection_manager_got_info), mainloop);
+ dbus_daemon = test_dbus_daemon_dup_or_die ();
g_timeout_add (5000, time_out, mainloop);
+ /* First try making a TpConnectionManager before the CM is available. This
+ * will fail. */
+ early_cm = tp_connection_manager_new (dbus_daemon, "example_no_protocols",
+ NULL, NULL);
+ g_assert (early_cm != NULL);
+
+ /* Failure to introspect is signalled as 'exited' */
+ handler = g_signal_connect (early_cm, "exited",
+ G_CALLBACK (early_cm_exited), &saw_exited);
+
+ test_connection_manager_run_until_readying_fails (early_cm, &error);
+ g_assert (error != NULL);
+ g_assert (tp_proxy_get_invalidated (early_cm) == NULL);
+ g_assert_cmpuint (error->domain, ==, DBUS_GERROR);
+ g_assert_cmpint (error->code, ==, DBUS_GERROR_SERVICE_UNKNOWN);
+ g_clear_error (&error);
+
+ if (!saw_exited)
+ {
+ g_debug ("waiting for 'exited'...");
+
+ while (!saw_exited)
+ g_main_context_iteration (NULL, TRUE);
+ }
+
+ g_signal_handler_disconnect (early_cm, handler);
+
+ /* Now start the connection manager and wait for it to start */
+ prepare ();
+ tp_dbus_daemon_watch_name_owner (dbus_daemon,
+ TP_CM_BUS_NAME_BASE "example_no_protocols", wait_for_name_owner_cb,
+ g_main_loop_ref (mainloop), (GDestroyNotify) g_main_loop_unref);
g_main_loop_run (mainloop);
- g_object_unref (cm);
+ /* This TpConnectionManager works fine. */
+ late_cm = tp_connection_manager_new (dbus_daemon, "example_no_protocols",
+ NULL, NULL);
+ g_assert (late_cm != NULL);
+
+ handler = g_signal_connect (late_cm, "got-info",
+ G_CALLBACK (connection_manager_got_info), mainloop);
+ g_main_loop_run (mainloop);
+ g_signal_handler_disconnect (late_cm, handler);
+
+ /* Now both objects can become ready */
+ test_connection_manager_run_until_ready (early_cm);
+ test_connection_manager_run_until_ready (late_cm);
+
+ g_object_unref (late_cm);
+ g_object_unref (early_cm);
+ g_object_unref (dbus_daemon);
g_main_loop_unref (mainloop);
return 0;
diff --git a/tests/dbus/finalized-in-invalidated-handler.c b/tests/dbus/finalized-in-invalidated-handler.c
index 48cc63b76..a665ed9c1 100644
--- a/tests/dbus/finalized-in-invalidated-handler.c
+++ b/tests/dbus/finalized-in-invalidated-handler.c
@@ -74,7 +74,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
mainloop = g_main_loop_new (NULL, FALSE);
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = SIMPLE_CONNECTION (g_object_new (SIMPLE_TYPE_CONNECTION,
"account", "me@example.com",
diff --git a/tests/dbus/get-interface-after-invalidate.c b/tests/dbus/get-interface-after-invalidate.c
index f1deecee3..059cc8008 100644
--- a/tests/dbus/get-interface-after-invalidate.c
+++ b/tests/dbus/get-interface-after-invalidate.c
@@ -3,6 +3,8 @@
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/proxy-subclass.h>
+#include "tests/lib/util.h"
+
static void
test_get_interface_after_invalidate (void)
{
@@ -11,8 +13,7 @@ test_get_interface_after_invalidate (void)
GError invalidation_reason = { TP_ERRORS, TP_ERROR_NOT_YOURS, "bees!" };
GError *error = NULL;
- bus_daemon = tp_dbus_daemon_dup (NULL);
- g_assert (bus_daemon != NULL);
+ bus_daemon = test_dbus_daemon_dup_or_die ();
tp_proxy_invalidate ((TpProxy *) bus_daemon, &invalidation_reason);
props = tp_proxy_borrow_interface_by_id ((TpProxy *) bus_daemon,
diff --git a/tests/dbus/group-mixin.c b/tests/dbus/group-mixin.c
index 6d3b18bd1..1a4fc66af 100644
--- a/tests/dbus/group-mixin.c
+++ b/tests/dbus/group-mixin.c
@@ -525,7 +525,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = SIMPLE_CONNECTION (g_object_new (SIMPLE_TYPE_CONNECTION,
"account", "me@example.com",
diff --git a/tests/dbus/handle-repo.c b/tests/dbus/handle-repo.c
index 80c9fd5f3..552c741bc 100644
--- a/tests/dbus/handle-repo.c
+++ b/tests/dbus/handle-repo.c
@@ -15,15 +15,13 @@
static void
test_handles (void)
{
- TpDBusDaemon *bus_daemon = tp_dbus_daemon_dup (NULL);
+ TpDBusDaemon *bus_daemon = test_dbus_daemon_dup_or_die ();
TpHandleRepoIface *tp_repo = NULL;
GError *error = NULL;
TpHandle handle = 0;
const gchar *jid = "handle.test@foobar";
const gchar *return_jid;
- g_assert (bus_daemon != NULL);
-
tp_repo = g_object_new (TP_TYPE_DYNAMIC_HANDLE_REPO,
"handle-type", TP_HANDLE_TYPE_CONTACT,
NULL);
diff --git a/tests/dbus/invalidated-while-invoking-signals.c b/tests/dbus/invalidated-while-invoking-signals.c
index 1312b70b6..528b47ab5 100644
--- a/tests/dbus/invalidated-while-invoking-signals.c
+++ b/tests/dbus/invalidated-while-invoking-signals.c
@@ -65,7 +65,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
mainloop = g_main_loop_new (NULL, FALSE);
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service = SIMPLE_CONNECTION (g_object_new (SIMPLE_TYPE_CONNECTION,
"account", "me@example.com",
diff --git a/tests/dbus/message-mixin.c b/tests/dbus/message-mixin.c
index 742f09ef3..54869ddfc 100644
--- a/tests/dbus/message-mixin.c
+++ b/tests/dbus/message-mixin.c
@@ -209,7 +209,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_cm = EXAMPLE_ECHO_2_CONNECTION_MANAGER (g_object_new (
EXAMPLE_TYPE_ECHO_2_CONNECTION_MANAGER,
diff --git a/tests/dbus/params-cm.c b/tests/dbus/params-cm.c
index e966dd734..4fdd012ce 100644
--- a/tests/dbus/params-cm.c
+++ b/tests/dbus/params-cm.c
@@ -61,8 +61,7 @@ setup (Test *test,
tp_debug_set_flags ("all");
test->mainloop = g_main_loop_new (NULL, FALSE);
- test->dbus = tp_dbus_daemon_dup (NULL);
- g_assert (test->dbus != NULL);
+ test->dbus = test_dbus_daemon_dup_or_die ();
test->service_cm = PARAM_CONNECTION_MANAGER (g_object_new (
TYPE_PARAM_CONNECTION_MANAGER,
diff --git a/tests/dbus/properties.c b/tests/dbus/properties.c
index b2c43d6f3..7cc259312 100644
--- a/tests/dbus/properties.c
+++ b/tests/dbus/properties.c
@@ -12,6 +12,7 @@
#include "_gen/svc.h"
#include "tests/lib/myassert.h"
+#include "tests/lib/util.h"
typedef struct _TestProperties {
GObject parent;
@@ -124,6 +125,7 @@ int
main (int argc, char **argv)
{
TestProperties *obj;
+ TpDBusDaemon *dbus_daemon;
DBusGConnection *bus;
TpProxy *proxy;
GValue *value;
@@ -131,7 +133,8 @@ main (int argc, char **argv)
tp_debug_set_flags ("all");
g_type_init ();
- bus = tp_get_bus ();
+ dbus_daemon = test_dbus_daemon_dup_or_die ();
+ bus = tp_proxy_get_dbus_connection (dbus_daemon);
obj = g_object_new (TEST_TYPE_PROPERTIES, NULL);
dbus_g_connection_register_g_object (bus, "/", (GObject *) obj);
@@ -182,6 +185,7 @@ main (int argc, char **argv)
g_object_unref (obj);
g_object_unref (proxy);
+ g_object_unref (dbus_daemon);
return 0;
}
diff --git a/tests/dbus/self-handle.c b/tests/dbus/self-handle.c
index bce822e70..b87d835eb 100644
--- a/tests/dbus/self-handle.c
+++ b/tests/dbus/self-handle.c
@@ -92,7 +92,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = SIMPLE_CONNECTION (g_object_new (
SIMPLE_TYPE_CONNECTION,
diff --git a/tests/dbus/self-presence.c b/tests/dbus/self-presence.c
index e42dbf04d..6a0386719 100644
--- a/tests/dbus/self-presence.c
+++ b/tests/dbus/self-presence.c
@@ -218,7 +218,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = CONTACTS_CONNECTION (g_object_new (
CONTACTS_TYPE_CONNECTION,
diff --git a/tests/dbus/text-mixin.c b/tests/dbus/text-mixin.c
index f38a0d4f6..f4c9a8fd8 100644
--- a/tests/dbus/text-mixin.c
+++ b/tests/dbus/text-mixin.c
@@ -93,7 +93,7 @@ main (int argc,
g_type_init ();
/* tp_debug_set_flags ("all"); */
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = EXAMPLE_ECHO_CONNECTION (g_object_new (
EXAMPLE_TYPE_ECHO_CONNECTION,
diff --git a/tests/dbus/text-respawn.c b/tests/dbus/text-respawn.c
index 505b309e9..c3e204e85 100644
--- a/tests/dbus/text-respawn.c
+++ b/tests/dbus/text-respawn.c
@@ -95,7 +95,7 @@ main (int argc,
g_type_init ();
/* tp_debug_set_flags ("all"); */
- dbus = tp_dbus_daemon_new (tp_get_bus ());
+ dbus = test_dbus_daemon_dup_or_die ();
service_conn = EXAMPLE_ECHO_CONNECTION (g_object_new (
EXAMPLE_TYPE_ECHO_CONNECTION,
diff --git a/tests/dbus/unsupported-interface.c b/tests/dbus/unsupported-interface.c
index da6b12608..f5a8bebe7 100644
--- a/tests/dbus/unsupported-interface.c
+++ b/tests/dbus/unsupported-interface.c
@@ -3,6 +3,7 @@
#include <telepathy-glib/util.h>
#include "tests/lib/myassert.h"
+#include "tests/lib/util.h"
static gboolean had_unsupported = FALSE;
static gboolean had_supported = FALSE;
@@ -74,8 +75,7 @@ main (int argc,
g_type_init ();
tp_debug_set_flags ("all");
- bus_daemon = tp_dbus_daemon_dup (NULL);
- g_assert (bus_daemon != NULL);
+ bus_daemon = test_dbus_daemon_dup_or_die ();
/* this interface is automatically supported... */
MYASSERT (tp_cli_dbus_daemon_run_list_names (bus_daemon, -1, NULL,
diff --git a/tests/lib/simple-conn.c b/tests/lib/simple-conn.c
index a45951b7b..a0bfb9e33 100644
--- a/tests/lib/simple-conn.c
+++ b/tests/lib/simple-conn.c
@@ -37,6 +37,8 @@ enum
struct _SimpleConnectionPrivate
{
gchar *account;
+ guint connect_source;
+ guint disconnect_source;
};
static void
@@ -86,6 +88,16 @@ finalize (GObject *object)
{
SimpleConnection *self = SIMPLE_CONNECTION (object);
+ if (self->priv->connect_source != 0)
+ {
+ g_source_remove (self->priv->connect_source);
+ }
+
+ if (self->priv->disconnect_source != 0)
+ {
+ g_source_remove (self->priv->disconnect_source);
+ }
+
g_free (self->priv->account);
G_OBJECT_CLASS (simple_connection_parent_class)->finalize (object);
@@ -155,9 +167,13 @@ pretend_connected (gpointer data)
conn->self_handle = tp_handle_ensure (contact_repo, self->priv->account,
NULL, NULL);
- tp_base_connection_change_status (conn, TP_CONNECTION_STATUS_CONNECTED,
- TP_CONNECTION_STATUS_REASON_REQUESTED);
+ if (conn->status == TP_CONNECTION_STATUS_CONNECTING)
+ {
+ tp_base_connection_change_status (conn, TP_CONNECTION_STATUS_CONNECTED,
+ TP_CONNECTION_STATUS_REASON_REQUESTED);
+ }
+ self->priv->connect_source = 0;
return FALSE;
}
@@ -174,7 +190,7 @@ start_connecting (TpBaseConnection *conn,
* start connecting, then go to state CONNECTED when finished. Here there
* isn't actually a connection, so we'll fake a connection process that
* takes half a second. */
- g_timeout_add (500, pretend_connected, self);
+ self->priv->connect_source = g_timeout_add (500, pretend_connected, self);
return TRUE;
}
@@ -182,18 +198,24 @@ start_connecting (TpBaseConnection *conn,
static gboolean
pretend_disconnected (gpointer data)
{
+ SimpleConnection *self = SIMPLE_CONNECTION (data);
+
tp_base_connection_finish_shutdown (TP_BASE_CONNECTION (data));
+ self->priv->disconnect_source = 0;
return FALSE;
}
static void
shut_down (TpBaseConnection *conn)
{
+ SimpleConnection *self = SIMPLE_CONNECTION (conn);
+
/* In a real connection manager we'd ask the underlying implementation to
* start shutting down, then call this function when finished. Here there
* isn't actually a connection, so we'll fake a disconnection process that
* takes half a second. */
- g_timeout_add (500, pretend_disconnected, conn);
+ self->priv->disconnect_source = g_timeout_add (500, pretend_disconnected,
+ conn);
}
static void
diff --git a/tests/lib/textchan-group.c b/tests/lib/textchan-group.c
index 82c3f4631..a018f5fa4 100644
--- a/tests/lib/textchan-group.c
+++ b/tests/lib/textchan-group.c
@@ -106,9 +106,15 @@ constructor (GType type,
(self->conn, TP_HANDLE_TYPE_CONTACT);
DBusGConnection *bus;
TpChannelGroupFlags flags = 0;
+ TpDBusDaemon *dbus_daemon;
- bus = tp_get_bus ();
+ /* we're attached to a Connection that has registered on D-Bus, so
+ * t_d_d_d can't fail */
+ dbus_daemon = tp_dbus_daemon_dup (NULL);
+ g_assert (dbus_daemon != NULL);
+ bus = tp_proxy_get_dbus_connection (dbus_daemon);
dbus_g_connection_register_g_object (bus, self->priv->object_path, object);
+ g_object_unref (dbus_daemon);
tp_text_mixin_init (object, G_STRUCT_OFFSET (TestTextChannelGroup, text),
contact_repo);
diff --git a/tests/lib/textchan-null.c b/tests/lib/textchan-null.c
index 507cd867d..b35ec2f25 100644
--- a/tests/lib/textchan-null.c
+++ b/tests/lib/textchan-null.c
@@ -95,11 +95,17 @@ constructor (GType type,
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles
(self->priv->conn, TP_HANDLE_TYPE_CONTACT);
DBusGConnection *bus;
+ TpDBusDaemon *dbus_daemon;
tp_handle_ref (contact_repo, self->priv->handle);
- bus = tp_get_bus ();
+ /* we're attached to a Connection that has registered on D-Bus, so
+ * t_d_d_d can't fail */
+ dbus_daemon = tp_dbus_daemon_dup (NULL);
+ g_assert (dbus_daemon != NULL);
+ bus = tp_proxy_get_dbus_connection (dbus_daemon);
dbus_g_connection_register_g_object (bus, self->priv->object_path, object);
+ g_object_unref (dbus_daemon);
tp_text_mixin_init (object, G_STRUCT_OFFSET (TestTextChannelNull, text),
contact_repo);
diff --git a/tests/lib/util.c b/tests/lib/util.c
index 0df08a3f1..094fd6f37 100644
--- a/tests/lib/util.c
+++ b/tests/lib/util.c
@@ -34,6 +34,57 @@ test_connection_run_until_ready (TpConnection *conn)
g_main_loop_unref (loop);
}
+typedef struct {
+ GMainLoop *loop;
+ GError **error;
+} NotReadyCtx;
+
+static void
+cm_not_ready_cb (TpConnectionManager *cm G_GNUC_UNUSED,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object G_GNUC_UNUSED)
+{
+ NotReadyCtx *ctx = user_data;
+
+ g_assert (error != NULL);
+
+ if (ctx->error != NULL)
+ {
+ *(ctx->error) = g_error_copy (error);
+ }
+
+ g_main_loop_quit (ctx->loop);
+}
+
+void
+test_connection_manager_run_until_readying_fails (TpConnectionManager *cm,
+ GError **error)
+{
+ NotReadyCtx ctx = { NULL, error };
+ const GError *invalidated;
+
+ g_return_if_fail (error == NULL || *error == NULL);
+ g_return_if_fail (!tp_connection_manager_is_ready (cm));
+
+ invalidated = tp_proxy_get_invalidated (cm);
+
+ if (invalidated != NULL)
+ {
+ if (error != NULL)
+ *error = g_error_copy (invalidated);
+
+ return;
+ }
+
+ ctx.loop = g_main_loop_new (NULL, FALSE);
+
+ tp_connection_manager_call_when_ready (cm, cm_not_ready_cb, &ctx, NULL,
+ NULL);
+ g_main_loop_run (ctx.loop);
+ g_main_loop_unref (ctx.loop);
+}
+
static void
cm_ready_cb (TpConnectionManager *cm G_GNUC_UNUSED,
const GError *error,
@@ -60,16 +111,41 @@ test_connection_manager_run_until_ready (TpConnectionManager *cm)
g_main_loop_unref (loop);
}
-void
-test_proxy_run_until_dbus_queue_processed (gpointer proxy)
+TpDBusDaemon *
+test_dbus_daemon_dup_or_die (void)
+{
+ TpDBusDaemon *d = tp_dbus_daemon_dup (NULL);
+
+ /* In a shared library, this would be very bad (see fd.o #18832), but in a
+ * regression test that's going to be run under a temporary session bus,
+ * it's just what we want. */
+ if (d == NULL)
+ {
+ g_error ("Unable to connect to session bus");
+ }
+
+ return d;
+}
+
+static void
+introspect_cb (TpProxy *proxy G_GNUC_UNUSED,
+ const gchar *xml G_GNUC_UNUSED,
+ const GError *error G_GNUC_UNUSED,
+ gpointer user_data,
+ GObject *weak_object G_GNUC_UNUSED)
{
- tp_cli_dbus_introspectable_run_introspect (proxy, -1, NULL, NULL, NULL);
+ g_main_loop_quit (user_data);
}
void
-test_connection_run_until_dbus_queue_processed (TpConnection *connection)
+test_proxy_run_until_dbus_queue_processed (gpointer proxy)
{
- tp_cli_connection_run_get_protocol (connection, -1, NULL, NULL, NULL);
+ GMainLoop *loop = g_main_loop_new (NULL, FALSE);
+
+ tp_cli_dbus_introspectable_call_introspect (proxy, -1, introspect_cb,
+ loop, NULL, NULL);
+ g_main_loop_run (loop);
+ g_main_loop_unref (loop);
}
typedef struct {
diff --git a/tests/lib/util.h b/tests/lib/util.h
index 7e17b6d5b..49937b64f 100644
--- a/tests/lib/util.h
+++ b/tests/lib/util.h
@@ -13,15 +13,20 @@
#include <telepathy-glib/telepathy-glib.h>
+TpDBusDaemon *test_dbus_daemon_dup_or_die (void);
+
void test_proxy_run_until_dbus_queue_processed (gpointer proxy);
-void test_connection_run_until_dbus_queue_processed (TpConnection *connection);
+#define test_connection_run_until_dbus_queue_processed(c) \
+ (test_proxy_run_until_dbus_queue_processed (c))
TpHandle test_connection_run_request_contact_handle (TpConnection *connection,
const gchar *id);
void test_connection_run_until_ready (TpConnection *conn);
void test_connection_manager_run_until_ready (TpConnectionManager *cm);
+void test_connection_manager_run_until_readying_fails (TpConnectionManager *cm,
+ GError **error);
#define test_assert_no_error(e) _test_assert_no_error (e, __FILE__, __LINE__)
diff --git a/tools/glib-client-gen.py b/tools/glib-client-gen.py
index 938a6faff..5263672e3 100644
--- a/tools/glib-client-gen.py
+++ b/tools/glib-client-gen.py
@@ -58,6 +58,8 @@ class Generator(object):
self.generate_reentrant = ('--generate-reentrant' in opts or
'--deprecate-reentrant' in opts)
self.deprecate_reentrant = opts.get('--deprecate-reentrant', None)
+ self.deprecation_attribute = opts.get('--deprecation-attribute',
+ 'G_GNUC_DEPRECATED')
def h(self, s):
if isinstance(s, unicode):
@@ -987,7 +989,7 @@ class Generator(object):
self.h(' GError **error,')
if self.deprecate_reentrant:
- self.h(' GMainLoop **loop) G_GNUC_DEPRECATED;')
+ self.h(' GMainLoop **loop) %s;' % self.deprecation_attribute)
self.h('#endif /* not %s */' % self.deprecate_reentrant)
else:
self.h(' GMainLoop **loop);')
@@ -1193,7 +1195,8 @@ if __name__ == '__main__':
options, argv = gnu_getopt(sys.argv[1:], '',
['group=', 'subclass=', 'subclass-assert=',
'iface-quark-prefix=', 'tp-proxy-api=',
- 'generate-reentrant', 'deprecate-reentrant='])
+ 'generate-reentrant', 'deprecate-reentrant=',
+ 'deprecation-attribute='])
opts = {}
diff --git a/tools/telepathy.am b/tools/telepathy.am
index 93b73d2d2..6e11fc66f 100644
--- a/tools/telepathy.am
+++ b/tools/telepathy.am
@@ -7,7 +7,8 @@ dist-hook:
fi
distcheck-hook:
- @case @VERSION@ in \
+ @test "z$(CHECK_FOR_UNRELEASED)" = z || \
+ case @VERSION@ in \
*.*.*.*) ;; \
*) \
if grep -r UNRELEASED $(CHECK_FOR_UNRELEASED); \