summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2012-08-08 10:14:48 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-08-08 10:14:48 +0100
commit7e9e54e35a6f0b09de5467c385f018dbb0a3ef11 (patch)
tree0c9b478b19412493c2a6d0aa0d00385d6f48103b
parent8af1530e4d240f241b802c81e8989d200fe354ad (diff)
downloadtelepathy-logger-7e9e54e35a6f0b09de5467c385f018dbb0a3ef11.tar.gz
all: use a client factory instead of creating TpAccounts directly
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--telepathy-logger/dbus-service.c55
-rw-r--r--tests/dbus/test-log-manager.c8
-rw-r--r--tests/dbus/test-tpl-log-store-pidgin.c8
-rw-r--r--tests/dbus/test-tpl-log-store-sqlite.c8
-rw-r--r--tests/dbus/test-tpl-log-store-xml.c41
5 files changed, 84 insertions, 36 deletions
diff --git a/telepathy-logger/dbus-service.c b/telepathy-logger/dbus-service.c
index 9300c0e..e373983 100644
--- a/telepathy-logger/dbus-service.c
+++ b/telepathy-logger/dbus-service.c
@@ -32,6 +32,7 @@
#include <telepathy-logger/text-event.h>
#include <telepathy-logger/log-manager.h>
#include <telepathy-logger/log-manager-internal.h>
+#include <telepathy-logger/observer-internal.h>
#include <extensions/extensions.h>
@@ -753,22 +754,35 @@ tpl_dbus_service_clear_account (TplSvcLogger *logger,
DBusGMethodInvocation *context)
{
TplDBusService *self = TPL_DBUS_SERVICE (logger);
- TpDBusDaemon *bus;
+ TplObserver *observer = NULL;
+ TpClientFactory *factory = NULL;
TpAccount *account;
GError *error = NULL;
g_return_if_fail (TPL_IS_DBUS_SERVICE (self));
g_return_if_fail (context != NULL);
- bus = tp_dbus_daemon_dup (&error);
- if (bus == NULL)
+ observer = _tpl_observer_dup (&error);
+ if (observer == NULL)
{
- DEBUG ("Unable to acquire the bus daemon: %s", error->message);
+ DEBUG ("Unable to duplicate observer: %s", error->message);
dbus_g_method_return_error (context, error);
goto out;
}
- account = tp_account_new (bus, account_path, &error);
+ g_object_get (observer,
+ "factory", &factory,
+ NULL);
+ if (factory == NULL)
+ {
+ error = g_error_new (TP_ERROR, TP_ERROR_NOT_AVAILABLE,
+ "Unable to get client factory from observer");
+ DEBUG ("%s", error->message);
+ dbus_g_method_return_error (context, error);
+ goto out;
+ }
+
+ account = tp_client_factory_ensure_account (factory, account_path, NULL, &error);
if (account == NULL)
{
DEBUG ("Unable to acquire the account for %s: %s", account_path,
@@ -784,8 +798,8 @@ tpl_dbus_service_clear_account (TplSvcLogger *logger,
tpl_svc_logger_return_from_clear_account (context);
out:
- if (bus != NULL)
- g_object_unref (bus);
+ tp_clear_object (&observer);
+ tp_clear_object (&factory);
g_clear_error (&error);
}
@@ -799,7 +813,8 @@ tpl_dbus_service_clear_entity (TplSvcLogger *logger,
DBusGMethodInvocation *context)
{
TplDBusService *self = TPL_DBUS_SERVICE (logger);
- TpDBusDaemon *bus;
+ TplObserver *observer = NULL;
+ TpClientFactory *factory = NULL;
TpAccount *account;
TplEntity *entity;
GError *error = NULL;
@@ -808,15 +823,27 @@ tpl_dbus_service_clear_entity (TplSvcLogger *logger,
g_return_if_fail (context != NULL);
g_return_if_fail (!TPL_STR_EMPTY (identifier));
- bus = tp_dbus_daemon_dup (&error);
- if (bus == NULL)
+ observer = _tpl_observer_dup (&error);
+ if (observer == NULL)
+ {
+ DEBUG ("Unable to duplicate observer: %s", error->message);
+ dbus_g_method_return_error (context, error);
+ goto out;
+ }
+
+ g_object_get (observer,
+ "factory", &factory,
+ NULL);
+ if (factory == NULL)
{
- DEBUG ("Unable to acquire the bus daemon: %s", error->message);
+ error = g_error_new (TP_ERROR, TP_ERROR_NOT_AVAILABLE,
+ "Unable to get client factory from observer");
+ DEBUG ("%s", error->message);
dbus_g_method_return_error (context, error);
goto out;
}
- account = tp_account_new (bus, account_path, &error);
+ account = tp_client_factory_ensure_account (factory, account_path, NULL, &error);
if (account == NULL)
{
DEBUG ("Unable to acquire the account for %s: %s", account_path,
@@ -836,8 +863,8 @@ tpl_dbus_service_clear_entity (TplSvcLogger *logger,
tpl_svc_logger_return_from_clear_account (context);
out:
- if (bus != NULL)
- g_object_unref (bus);
+ tp_clear_object (&observer);
+ tp_clear_object (&factory);
g_clear_error (&error);
}
diff --git a/tests/dbus/test-log-manager.c b/tests/dbus/test-log-manager.c
index 768419c..f345c8b 100644
--- a/tests/dbus/test-log-manager.c
+++ b/tests/dbus/test-log-manager.c
@@ -156,6 +156,7 @@ setup_service (TestCaseFixture* fixture,
GValue *boxed_params;
GHashTable *params = (GHashTable *) user_data;
GError *error = NULL;
+ TpClientFactory *factory;
g_assert (params != NULL);
@@ -184,7 +185,10 @@ setup_service (TestCaseFixture* fixture,
tp_dbus_daemon_register_object (fixture->dbus, account_path,
fixture->account_service);
- fixture->account = tp_account_new (fixture->dbus, account_path, NULL);
+ factory = tp_automatic_client_factory_new (fixture->dbus);
+
+ fixture->account = tp_client_factory_ensure_account (factory, account_path,
+ NULL, NULL);
g_assert (fixture->account != NULL);
tp_proxy_prepare_async (fixture->account, account_features,
account_prepare_cb, fixture);
@@ -194,6 +198,8 @@ setup_service (TestCaseFixture* fixture,
TP_ACCOUNT_FEATURE_CORE));
tp_g_value_slice_free (boxed_params);
+
+ g_object_unref (factory);
}
diff --git a/tests/dbus/test-tpl-log-store-pidgin.c b/tests/dbus/test-tpl-log-store-pidgin.c
index 3760cc5..2af5323 100644
--- a/tests/dbus/test-tpl-log-store-pidgin.c
+++ b/tests/dbus/test-tpl-log-store-pidgin.c
@@ -118,6 +118,7 @@ setup_service (PidginTestCaseFixture* fixture,
GValue *boxed_params;
GHashTable *params = (GHashTable *) user_data;
GError *error = NULL;
+ TpClientFactory *factory;
g_assert (params != NULL);
@@ -146,7 +147,10 @@ setup_service (PidginTestCaseFixture* fixture,
tp_dbus_daemon_register_object (fixture->dbus, account_path,
fixture->account_service);
- fixture->account = tp_account_new (fixture->dbus, account_path, NULL);
+ factory = tp_automatic_client_factory_new (fixture->dbus);
+
+ fixture->account = tp_client_factory_ensure_account (factory, account_path,
+ NULL, NULL);
g_assert (fixture->account != NULL);
tp_proxy_prepare_async (fixture->account, account_features,
account_prepare_cb, fixture);
@@ -156,6 +160,8 @@ setup_service (PidginTestCaseFixture* fixture,
TP_ACCOUNT_FEATURE_CORE));
tp_g_value_slice_free (boxed_params);
+
+ g_object_unref (factory);
}
static void
diff --git a/tests/dbus/test-tpl-log-store-sqlite.c b/tests/dbus/test-tpl-log-store-sqlite.c
index f23e832..b531d96 100644
--- a/tests/dbus/test-tpl-log-store-sqlite.c
+++ b/tests/dbus/test-tpl-log-store-sqlite.c
@@ -12,6 +12,7 @@ main (int argc, char **argv)
TpDBusDaemon *bus;
TpAccount *account;
GError *error = NULL;
+ TpClientFactory *factory;
g_type_init ();
@@ -20,9 +21,11 @@ main (int argc, char **argv)
bus = tp_dbus_daemon_dup (&error);
g_assert_no_error (error);
- account = tp_account_new (bus,
+ factory = tp_automatic_client_factory_new (bus);
+
+ account = tp_client_factory_ensure_account (factory,
TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/danielle_2emadeley_40collabora_2eco_2euk0",
- &error);
+ NULL, &error);
g_assert_no_error (error);
store = _tpl_log_store_sqlite_dup ();
@@ -33,5 +36,6 @@ main (int argc, char **argv)
g_object_unref (store);
g_object_unref (account);
+ g_object_unref (factory);
g_object_unref (bus);
}
diff --git a/tests/dbus/test-tpl-log-store-xml.c b/tests/dbus/test-tpl-log-store-xml.c
index ead136a..070709c 100644
--- a/tests/dbus/test-tpl-log-store-xml.c
+++ b/tests/dbus/test-tpl-log-store-xml.c
@@ -20,6 +20,7 @@ typedef struct
gchar *tmp_basedir;
TplLogStore *store;
TpDBusDaemon *bus;
+ TpClientFactory *factory;
} XmlTestCaseFixture;
@@ -60,6 +61,9 @@ setup (XmlTestCaseFixture* fixture,
fixture->bus = tp_tests_dbus_daemon_dup_or_die ();
g_assert (fixture->bus != NULL);
+ fixture->factory = tp_automatic_client_factory_new (fixture->bus);
+ g_assert (fixture->factory != NULL);
+
tp_debug_divert_messages (g_getenv ("TPL_LOGFILE"));
#ifdef ENABLE_DEBUG
@@ -104,8 +108,9 @@ teardown (XmlTestCaseFixture *fixture,
g_free (fixture->tmp_basedir);
}
- if (fixture->store == NULL)
- g_object_unref (fixture->store);
+ tp_clear_object (&fixture->store);
+ tp_clear_object (&fixture->factory);
+ tp_clear_object (&fixture->bus);
}
@@ -157,9 +162,9 @@ test_clear_account (XmlTestCaseFixture *fixture,
tpl_log_manager_search_free (hits);
- account = tp_account_new (fixture->bus,
+ account = tp_client_factory_ensure_account (fixture->factory,
TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/test2_40collabora_2eco_2euk0",
- &error);
+ NULL, &error);
g_assert_no_error (error);
g_assert (account != NULL);
@@ -224,9 +229,9 @@ test_clear_entity (XmlTestCaseFixture *fixture,
tpl_log_manager_search_free (hits);
- account = tp_account_new (fixture->bus,
+ account = tp_client_factory_ensure_account (fixture->factory,
TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/test2_40collabora_2eco_2euk0",
- &error);
+ NULL, &error);
g_assert_no_error (error);
g_assert (account != NULL);
@@ -312,9 +317,9 @@ test_add_text_event (XmlTestCaseFixture *fixture,
GList *events;
gint64 timestamp = time (NULL);
- account = tp_account_new (fixture->bus,
+ account = tp_client_factory_ensure_account (fixture->factory,
TP_ACCOUNT_OBJECT_PATH_BASE "idle/irc/me",
- &error);
+ NULL, &error);
g_assert_no_error (error);
g_assert (account != NULL);
@@ -483,9 +488,9 @@ test_add_superseding_event (XmlTestCaseFixture *fixture,
GList *superseded;
gint64 timestamp = time (NULL);
- account = tp_account_new (fixture->bus,
+ account = tp_client_factory_ensure_account (fixture->factory,
TP_ACCOUNT_OBJECT_PATH_BASE "idle/irc/me",
- &error);
+ NULL, &error);
g_assert_no_error (error);
g_assert (account != NULL);
@@ -735,9 +740,9 @@ test_add_call_event (XmlTestCaseFixture *fixture,
GList *events;
gint64 timestamp = time (NULL);
- account = tp_account_new (fixture->bus,
+ account = tp_client_factory_ensure_account (fixture->factory,
TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/me",
- &error);
+ NULL, &error);
g_assert_no_error (error);
g_assert (account != NULL);
@@ -871,15 +876,15 @@ test_exists (XmlTestCaseFixture *fixture,
TplEntity *user2, *user3;
GError *error = NULL;
- account1 = tp_account_new (fixture->bus,
+ account1 = tp_client_factory_ensure_account (fixture->factory,
TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/test2_40collabora_2eco_2euk0",
- &error);
+ NULL, &error);
g_assert_no_error (error);
g_assert (account1 != NULL);
- account2 = tp_account_new (fixture->bus,
+ account2 = tp_client_factory_ensure_account (fixture->factory,
TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/user_40collabora_2eco_2euk",
- &error);
+ NULL, &error);
g_assert_no_error (error);
g_assert (account1 != NULL);
@@ -928,9 +933,9 @@ test_get_events_for_date (XmlTestCaseFixture *fixture,
GError *error = NULL;
gint idx;
- account = tp_account_new (fixture->bus,
+ account = tp_client_factory_ensure_account (fixture->factory,
TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/user_40collabora_2eco_2euk",
- &error);
+ NULL, &error);
g_assert_no_error (error);
g_assert (account != NULL);