[Pkg-telepathy-commits] [telepathy-glib-1] 71/212: TpConnectionManager: Take a factory to list CMs
Simon McVittie
smcv at debian.org
Wed May 14 12:08:52 UTC 2014
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian
in repository telepathy-glib-1.
commit 8e989143947360f4f6f1ca7b80e4cb6ebe5259a8
Author: Xavier Claessens <xavier.claessens at collabora.com>
Date: Sat Mar 29 14:11:37 2014 -0400
TpConnectionManager: Take a factory to list CMs
The factory will be used to create TpConnectionManager objects
in the next commit
---
examples/client/inspect-cm.c | 13 ++++++-------
examples/client/list-managers.c | 5 ++++-
telepathy-glib/connection-manager.c | 21 ++++++++++++---------
telepathy-glib/connection-manager.h | 2 +-
tests/dbus/cm.c | 5 ++++-
tests/dbus/list-cm-no-cm.c | 5 ++++-
6 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/examples/client/inspect-cm.c b/examples/client/inspect-cm.c
index c2a1532..7c41d54 100644
--- a/examples/client/inspect-cm.c
+++ b/examples/client/inspect-cm.c
@@ -227,10 +227,10 @@ main (int argc,
char **argv)
{
const gchar *cm_name, *manager_file;
+ TpClientFactory *factory = NULL;
TpConnectionManager *cm = NULL;
GMainLoop *mainloop = NULL;
GError *error = NULL;
- TpDBusDaemon *dbus = NULL;
int ret = 1;
tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG"));
@@ -238,9 +238,8 @@ main (int argc,
if (g_getenv ("EXAMPLE_TIMING") != NULL)
g_log_set_default_handler (tp_debug_timestamped_log_handler, NULL);
- dbus = tp_dbus_daemon_dup (&error);
-
- if (dbus == NULL)
+ factory = tp_client_factory_dup (&error);
+ if (factory == NULL)
{
g_warning ("%s", error->message);
g_error_free (error);
@@ -267,7 +266,7 @@ main (int argc,
}
else
{
- tp_list_connection_managers_async (dbus, list_cb, mainloop);
+ tp_list_connection_managers_async (factory, list_cb, mainloop);
}
g_main_loop_run (mainloop);
@@ -280,8 +279,8 @@ out:
if (mainloop != NULL)
g_main_loop_unref (mainloop);
- if (dbus != NULL)
- g_object_unref (dbus);
+ if (factory != NULL)
+ g_object_unref (factory);
return ret;
}
diff --git a/examples/client/list-managers.c b/examples/client/list-managers.c
index 87109e5..e0cbc60 100644
--- a/examples/client/list-managers.c
+++ b/examples/client/list-managers.c
@@ -58,6 +58,7 @@ main (int argc,
{
ExampleData data = { g_main_loop_new (NULL, FALSE), 0 };
TpDBusDaemon *bus_daemon;
+ TpClientFactory *factory;
GError *error = NULL;
tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG"));
@@ -72,8 +73,10 @@ main (int argc,
goto out;
}
- tp_list_connection_managers_async (bus_daemon,
+ factory = tp_client_factory_new (bus_daemon);
+ tp_list_connection_managers_async (factory,
got_connection_managers, &data);
+ g_object_unref (factory);
g_main_loop_run (data.mainloop);
diff --git a/telepathy-glib/connection-manager.c b/telepathy-glib/connection-manager.c
index b01b65a..a7087b9 100644
--- a/telepathy-glib/connection-manager.c
+++ b/telepathy-glib/connection-manager.c
@@ -39,6 +39,7 @@
#include "telepathy-glib/variant-util.h"
#define DEBUG_FLAG TP_DEBUG_MANAGER
+#include "telepathy-glib/client-factory-internal.h"
#include "telepathy-glib/debug-internal.h"
#include "telepathy-glib/protocol-internal.h"
#include "telepathy-glib/util-internal.h"
@@ -1213,19 +1214,19 @@ tp_connection_manager_activate (TpConnectionManager *self)
typedef struct
{
- TpDBusDaemon *dbus_daemon;
+ TpClientFactory *factory;
/* name -> TpConnectionManager */
GHashTable *cms;
guint n_operations;
} ListCMSData;
static ListCMSData *
-list_cms_data_new (TpDBusDaemon *dbus_daemon)
+list_cms_data_new (TpClientFactory *factory)
{
ListCMSData *data;
data = g_slice_new0 (ListCMSData);
- data->dbus_daemon = g_object_ref (dbus_daemon);
+ data->factory = g_object_ref (factory);
data->cms = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_object_unref);
@@ -1235,7 +1236,7 @@ list_cms_data_new (TpDBusDaemon *dbus_daemon)
static void
list_cms_data_free (ListCMSData *data)
{
- g_object_unref (data->dbus_daemon);
+ g_object_unref (data->factory);
g_hash_table_unref (data->cms);
g_slice_free (ListCMSData, data);
}
@@ -1301,7 +1302,9 @@ handle_list_names_reply (GTask *task,
/* just ignore connection managers with bad names */
cm_name = *iter + strlen (TP_CM_BUS_NAME_BASE);
- cm = tp_connection_manager_new (data->dbus_daemon, cm_name, NULL, NULL);
+ cm = tp_connection_manager_new (
+ tp_client_factory_get_dbus_daemon (data->factory), cm_name, NULL,
+ NULL);
if (cm == NULL)
continue;
@@ -1378,7 +1381,7 @@ out:
/**
* tp_list_connection_managers_async:
- * @dbus_daemon: a #TpDBusDaemon
+ * @factory: a #TpClientFactory
* @callback: a callback to call with a list of CMs
* @user_data: data to pass to @callback
*
@@ -1389,7 +1392,7 @@ out:
* Since: 0.17.6
*/
void
-tp_list_connection_managers_async (TpDBusDaemon *dbus_daemon,
+tp_list_connection_managers_async (TpClientFactory *factory,
GAsyncReadyCallback callback,
gpointer user_data)
{
@@ -1398,10 +1401,10 @@ tp_list_connection_managers_async (TpDBusDaemon *dbus_daemon,
task = g_task_new (NULL, NULL, callback, user_data);
- data = list_cms_data_new (dbus_daemon);
+ data = list_cms_data_new (factory);
g_task_set_task_data (task, data, (GDestroyNotify) list_cms_data_free);
- g_dbus_connection_call (tp_proxy_get_dbus_connection (dbus_daemon),
+ g_dbus_connection_call (tp_client_factory_get_dbus_connection (factory),
"org.freedesktop.DBus", "/", "org.freedesktop.DBus",
"ListActivatableNames",
g_variant_new ("()"),
diff --git a/telepathy-glib/connection-manager.h b/telepathy-glib/connection-manager.h
index e8a65f9..056aefc 100644
--- a/telepathy-glib/connection-manager.h
+++ b/telepathy-glib/connection-manager.h
@@ -89,7 +89,7 @@ TpConnectionManager *tp_connection_manager_new (TpDBusDaemon *dbus,
gboolean tp_connection_manager_activate (TpConnectionManager *self);
_TP_AVAILABLE_IN_0_18
-void tp_list_connection_managers_async (TpDBusDaemon *dbus_daemon,
+void tp_list_connection_managers_async (TpClientFactory *factory,
GAsyncReadyCallback callback,
gpointer user_data);
_TP_AVAILABLE_IN_0_18
diff --git a/tests/dbus/cm.c b/tests/dbus/cm.c
index 9527a9a..46a6425 100644
--- a/tests/dbus/cm.c
+++ b/tests/dbus/cm.c
@@ -31,6 +31,7 @@ typedef ExampleEcho2ConnectionManagerClass MyConnectionManagerClass;
typedef struct {
GMainLoop *mainloop;
TpDBusDaemon *dbus;
+ TpClientFactory *factory;
MyConnectionManager *service_cm;
TpConnectionManager *cm;
@@ -123,6 +124,7 @@ setup (Test *test,
test->mainloop = g_main_loop_new (NULL, FALSE);
test->dbus = tp_tests_dbus_daemon_dup_or_die ();
+ test->factory = tp_client_factory_new (test->dbus);
test->service_cm = tp_tests_object_new_static_class (
my_connection_manager_get_type (),
@@ -143,6 +145,7 @@ teardown (Test *test,
{
g_clear_object (&test->service_cm);
g_clear_object (&test->dbus);
+ g_clear_object (&test->factory);
g_clear_object (&test->cm);
g_clear_object (&test->echo);
g_clear_object (&test->spurious);
@@ -1016,7 +1019,7 @@ test_list (Test *test,
GAsyncResult *res = NULL;
GList *cms;
- tp_list_connection_managers_async (test->dbus, tp_tests_result_ready_cb,
+ tp_list_connection_managers_async (test->factory, tp_tests_result_ready_cb,
&res);
tp_tests_run_until_result (&res);
diff --git a/tests/dbus/list-cm-no-cm.c b/tests/dbus/list-cm-no-cm.c
index 87f312a..a8731a3 100644
--- a/tests/dbus/list-cm-no-cm.c
+++ b/tests/dbus/list-cm-no-cm.c
@@ -17,6 +17,7 @@
typedef struct {
GMainLoop *mainloop;
TpDBusDaemon *dbus;
+ TpClientFactory *factory;
GError *error;
} Test;
@@ -28,6 +29,7 @@ setup (Test *test,
test->mainloop = g_main_loop_new (NULL, FALSE);
test->dbus = tp_tests_dbus_daemon_dup_or_die ();
+ test->factory = tp_client_factory_new (test->dbus);
test->error = NULL;
}
@@ -37,6 +39,7 @@ teardown (Test *test,
gconstpointer data)
{
g_clear_object (&test->dbus);
+ g_clear_object (&test->factory);
g_main_loop_unref (test->mainloop);
test->mainloop = NULL;
}
@@ -48,7 +51,7 @@ test_list_cm_no_cm (Test *test,
GAsyncResult *res = NULL;
GList *cms;
- tp_list_connection_managers_async (test->dbus, tp_tests_result_ready_cb,
+ tp_list_connection_managers_async (test->factory, tp_tests_result_ready_cb,
&res);
tp_tests_run_until_result (&res);
cms = tp_list_connection_managers_finish (res, &test->error);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-glib-1.git
More information about the Pkg-telepathy-commits
mailing list