diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-02 19:31:52 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-02 19:31:52 +0100 |
commit | 77f6895f743fd0d5d9fad7dafb327bee3753486b (patch) | |
tree | 5ccc76d50ba98d0f2e8984d3965e190d0c6ef530 | |
parent | c9631171f8f4c38765dcbcdc552f08e0708976b8 (diff) |
Update for removal of TpDBusDaemonnext-factory
The ubuntu-online-accounts parts are untested, and might not even
compile.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=76828
-rw-r--r-- | libempathy/empathy-client-factory.c | 10 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.c | 1 | ||||
-rw-r--r-- | libempathy/empathy-utils.c | 16 | ||||
-rw-r--r-- | src/empathy-auth-client.c | 13 | ||||
-rw-r--r-- | src/empathy-debug-window.c | 102 | ||||
m--------- | telepathy-account-widgets | 0 | ||||
-rw-r--r-- | tests/empathy-tls-test.c | 18 | ||||
-rw-r--r-- | ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.c | 28 | ||||
-rw-r--r-- | ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.h | 1 | ||||
-rw-r--r-- | ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.c | 26 | ||||
-rw-r--r-- | ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.h | 1 |
11 files changed, 131 insertions, 85 deletions
diff --git a/libempathy/empathy-client-factory.c b/libempathy/empathy-client-factory.c index 960039e1..856c925d 100644 --- a/libempathy/empathy-client-factory.c +++ b/libempathy/empathy-client-factory.c @@ -201,10 +201,10 @@ empathy_client_factory_init (EmpathyClientFactory *self) } static EmpathyClientFactory * -empathy_client_factory_new (TpDBusDaemon *dbus) +empathy_client_factory_new (GDBusConnection *dbus) { return g_object_new (EMPATHY_TYPE_CLIENT_FACTORY, - "dbus-daemon", dbus, + "dbus-connection", dbus, NULL); } @@ -212,16 +212,16 @@ EmpathyClientFactory * empathy_client_factory_dup (void) { static EmpathyClientFactory *singleton = NULL; - TpDBusDaemon *dbus; + GDBusConnection *dbus; GError *error = NULL; if (singleton != NULL) return g_object_ref (singleton); - dbus = tp_dbus_daemon_dup (&error); + dbus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (dbus == NULL) { - g_warning ("Failed to get TpDBusDaemon: %s", error->message); + g_warning ("Failed to get GDBusConnection: %s", error->message); g_error_free (error); return NULL; } diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 8f3f4917..514bbde4 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -1102,7 +1102,6 @@ empathy_tp_chat_new (TpClientFactory *factory, return g_object_new (EMPATHY_TYPE_TP_CHAT, "factory", factory, "connection", conn, - "dbus-daemon", tp_proxy_get_dbus_daemon (conn), "bus-name", tp_proxy_get_bus_name (conn), "object-path", object_path, "channel-properties", immutable_properties, diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index e8140de3..3ed1a0fe 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -76,11 +76,13 @@ void empathy_init (void) { static gboolean initialized = FALSE; - TpAccountManager *am; - EmpathyClientFactory *factory; + static EmpathyClientFactory *factory; if (initialized) - return; + { + g_assert (factory != NULL); + return; + } g_type_init (); @@ -98,11 +100,9 @@ empathy_init (void) initialized = TRUE; factory = empathy_client_factory_dup (); - am = tp_account_manager_new_with_factory (TP_CLIENT_FACTORY (factory)); - tp_account_manager_set_default (am); - - g_object_unref (factory); - g_object_unref (am); + tp_client_factory_set_default (TP_CLIENT_FACTORY (factory)); + /* Deliberately not unreffing @factory so it won't be disposed. It exists + * for the lifetime of our run. */ } xmlNodePtr diff --git a/src/empathy-auth-client.c b/src/empathy-auth-client.c index 2097142b..5ee20dba 100644 --- a/src/empathy-auth-client.c +++ b/src/empathy-auth-client.c @@ -280,7 +280,6 @@ main (int argc, EmpathyAuthFactory *factory; TpDebugSender *debug_sender; TpClientFactory *tp_factory; - TpDBusDaemon *dbus; context = g_option_context_new (N_(" - Empathy authentication client")); g_option_context_add_group (context, gtk_get_option_group (TRUE)); @@ -315,15 +314,21 @@ main (int argc, g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN); #endif - dbus = tp_dbus_daemon_dup (NULL); - tp_factory = tp_client_factory_new (dbus); + tp_factory = tp_client_factory_dup (&error); + + if (tp_factory == NULL) + { + g_printerr ("empathy-auth-client: unable to connect to D-Bus: %s", + error->message); + return EXIT_FAILURE; + } + tp_client_factory_add_account_features_varargs (tp_factory, TP_ACCOUNT_FEATURE_STORAGE, 0); factory = empathy_auth_factory_new (tp_factory); g_object_unref (tp_factory); - g_object_unref (dbus); g_signal_connect (factory, "new-server-tls-handler", G_CALLBACK (auth_factory_new_tls_handler_cb), NULL); diff --git a/src/empathy-debug-window.c b/src/empathy-debug-window.c index cb6ea129..62475657 100644 --- a/src/empathy-debug-window.c +++ b/src/empathy-debug-window.c @@ -89,8 +89,8 @@ struct _EmpathyDebugWindowPriv gboolean view_visible; /* Connection */ - TpDBusDaemon *dbus; - TpProxySignalConnection *name_owner_changed_signal; + GDBusConnection *dbus; + guint name_owner_changed_signal; /* Whether NewDebugMessage will be fired */ gboolean paused; @@ -442,7 +442,7 @@ debug_window_get_messages_cb (GObject *object, static void create_proxy_to_get_messages (EmpathyDebugWindow *self, GtkTreeIter *iter, - TpDBusDaemon *dbus) + TpClientFactory *factory) { gchar *bus_name, *name = NULL; TpDebugClient *new_proxy, *stored_proxy = NULL; @@ -474,7 +474,7 @@ create_proxy_to_get_messages (EmpathyDebugWindow *self, gtk_tree_model_get (GTK_TREE_MODEL (self->priv->service_store), iter, COL_UNIQUE_NAME, &bus_name, -1); - new_proxy = tp_debug_client_new (dbus, bus_name, &error); + new_proxy = tp_client_factory_ensure_debug_client (factory, bus_name, &error); if (new_proxy == NULL) { @@ -643,17 +643,16 @@ refresh_all_buffer (EmpathyDebugWindow *self) else { GError *error = NULL; - TpDBusDaemon *dbus = tp_dbus_daemon_dup (&error); + TpClientFactory *factory = tp_client_factory_dup (&error); if (error != NULL) { - DEBUG ("Failed at duping the dbus daemon: %s", error->message); + DEBUG ("Failed to get client factory: %s", error->message); g_error_free (error); } - create_proxy_to_get_messages (self, &iter, dbus); - - g_object_unref (dbus); + create_proxy_to_get_messages (self, &iter, factory); + g_object_unref (factory); } } @@ -666,7 +665,7 @@ static void debug_window_service_chooser_changed_cb (GtkComboBox *chooser, EmpathyDebugWindow *self) { - TpDBusDaemon *dbus; + TpClientFactory *factory; GError *error = NULL; GtkListStore *stored_active_buffer = NULL; gchar *name = NULL; @@ -708,16 +707,18 @@ debug_window_service_chooser_changed_cb (GtkComboBox *chooser, update_store_filter (self, stored_active_buffer); - dbus = tp_dbus_daemon_dup (&error); + factory = tp_client_factory_dup (&error); if (error != NULL) { - DEBUG ("Failed at duping the dbus daemon: %s", error->message); + DEBUG ("Failed to get client factory: %s", error->message); + g_error_free (error); + } + else + { + create_proxy_to_get_messages (self, &iter, factory); + g_object_unref (factory); } - - create_proxy_to_get_messages (self, &iter, dbus); - - g_object_unref (dbus); finally: g_free (name); @@ -894,24 +895,31 @@ service_dup_display_name (EmpathyDebugWindow *self, } static void -debug_window_get_name_owner_cb (TpDBusDaemon *proxy, - const gchar *out, - const GError *error, - gpointer user_data, - GObject *weak_object) +debug_window_get_name_owner_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { FillServiceChooserData *data = (FillServiceChooserData *) user_data; EmpathyDebugWindow *self = EMPATHY_DEBUG_WINDOW (data->self); GtkTreeIter iter; + GError *error = NULL; + const gchar *out; + GVariant *tuple; self->priv->name_owner_cb_count++; - if (error != NULL) + tuple = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object), + result, &error); + + if (tuple == NULL) { DEBUG ("GetNameOwner failed: %s", error->message); + g_error_free (error); goto OUT; } + g_variant_get (tuple, "(&s)", &out); + if (!debug_window_service_is_in_model (data->self, out, NULL, FALSE)) { char *name; @@ -965,21 +973,31 @@ debug_window_get_name_owner_cb (TpDBusDaemon *proxy, gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->chooser), 0); } + g_variant_unref (tuple); OUT: fill_service_chooser_data_free (data); } static void -debug_window_name_owner_changed_cb (TpDBusDaemon *proxy, - const gchar *arg0, - const gchar *arg1, - const gchar *arg2, - gpointer user_data, - GObject *weak_object) +debug_window_name_owner_changed_cb (GDBusConnection *connection, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) { EmpathyDebugWindow *self = EMPATHY_DEBUG_WINDOW (user_data); ServiceType type; const gchar *name; + const gchar *arg0; + const gchar *arg1; + const gchar *arg2; + + if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(sss)"))) + return; + + g_variant_get (parameters, "(&s&s&s)", &arg0, &arg1, &arg2); if (g_str_has_prefix (arg0, TP_CM_BUS_NAME_BASE)) { @@ -1103,8 +1121,11 @@ add_service (EmpathyDebugWindow *self, data = fill_service_chooser_data_new (self, display_name, type); - tp_cli_dbus_daemon_call_get_name_owner (self->priv->dbus, -1, - bus_name, debug_window_get_name_owner_cb, data, NULL, NULL); + g_dbus_connection_call (self->priv->dbus, "org.freedesktop.DBus", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetNameOwner", + g_variant_new ("(s)", bus_name), G_VARIANT_TYPE ("(s)"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, + debug_window_get_name_owner_cb, data); self->priv->services_detected ++; } @@ -1161,12 +1182,13 @@ static void debug_window_fill_service_chooser (EmpathyDebugWindow *self) { GError *error = NULL; + GDBusConnection *bus; - self->priv->dbus = tp_dbus_daemon_dup (&error); + bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (error != NULL) { - DEBUG ("Failed to dup dbus daemon: %s", error->message); + DEBUG ("Failed to connect to D-Bus: %s", error->message); g_error_free (error); return; } @@ -1175,15 +1197,21 @@ debug_window_fill_service_chooser (EmpathyDebugWindow *self) self->priv->services_detected = 0; self->priv->name_owner_cb_count = 0; - g_dbus_connection_call (tp_proxy_get_dbus_connection (self->priv->dbus), + g_dbus_connection_call (bus, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames", NULL, G_VARIANT_TYPE ("(as)"), G_DBUS_CALL_FLAGS_NONE, 2000, NULL, list_names_cb, g_object_ref (self)); + self->priv->name_owner_changed_signal = - tp_cli_dbus_daemon_connect_to_name_owner_changed (self->priv->dbus, - debug_window_name_owner_changed_cb, self, NULL, NULL, NULL); + g_dbus_connection_signal_subscribe (bus, + "org.freedesktop.DBus", "org.freedesktop.DBus", + "NameOwnerChanged", "/org/freedesktop/DBus", NULL, + G_DBUS_SIGNAL_FLAGS_NONE, debug_window_name_owner_changed_cb, + self, NULL); + + g_object_unref (bus); } static void @@ -2186,8 +2214,8 @@ debug_window_dispose (GObject *object) { EmpathyDebugWindow *self = EMPATHY_DEBUG_WINDOW (object); - if (self->priv->name_owner_changed_signal != NULL) - tp_proxy_signal_connection_disconnect ( + if (self->priv->name_owner_changed_signal != 0) + g_dbus_connection_signal_unsubscribe (self->priv->dbus, self->priv->name_owner_changed_signal); /* Disable Debug on all proxies */ diff --git a/telepathy-account-widgets b/telepathy-account-widgets -Subproject dfe8d99243fc390f55662ece0d40382baa9d70f +Subproject 8e3f1e91d8eb421e01f49d41e9b0222592bd325 diff --git a/tests/empathy-tls-test.c b/tests/empathy-tls-test.c index df4f93a0..535b4ea5 100644 --- a/tests/empathy-tls-test.c +++ b/tests/empathy-tls-test.c @@ -229,7 +229,7 @@ mock_tls_certificate_assert_rejected (MockTLSCertificate *self, #endif static MockTLSCertificate * -mock_tls_certificate_new_and_register (TpDBusDaemon *dbus, +mock_tls_certificate_new_and_register (GDBusConnection *dbus, const gchar *path, ...) { @@ -260,7 +260,7 @@ mock_tls_certificate_new_and_register (TpDBusDaemon *dbus, } va_end (va); - tp_dbus_daemon_register_object (dbus, MOCK_TLS_CERTIFICATE_PATH, cert); + tp_dbus_connection_register_object (dbus, MOCK_TLS_CERTIFICATE_PATH, cert); return cert; } @@ -270,7 +270,8 @@ mock_tls_certificate_new_and_register (TpDBusDaemon *dbus, typedef struct { GMainLoop *loop; - TpDBusDaemon *dbus; + TpClientFactory *factory; + GDBusConnection *dbus; const gchar *dbus_name; MockTLSCertificate *mock; TpTLSCertificate *cert; @@ -286,10 +287,11 @@ setup (Test *test, gconstpointer data) test->loop = g_main_loop_new (NULL, FALSE); - test->dbus = tp_dbus_daemon_dup (&error); + test->dbus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); g_assert_no_error (error); + test->factory = tp_client_factory_new (test->dbus); - test->dbus_name = tp_dbus_daemon_get_unique_name (test->dbus); + test->dbus_name = g_dbus_connection_get_unique_name (test->dbus); test->result = NULL; test->cert = NULL; @@ -312,7 +314,7 @@ teardown (Test *test, gconstpointer data) if (test->mock) { - tp_dbus_daemon_unregister_object (test->dbus, test->mock); + tp_dbus_connection_unregister_object (test->dbus, test->mock); g_object_unref (test->mock); test->mock = NULL; } @@ -328,6 +330,8 @@ teardown (Test *test, gconstpointer data) g_main_loop_unref (test->loop); test->loop = NULL; + g_clear_object (&test->factory); + g_object_unref (test->dbus); test->dbus = NULL; } @@ -383,7 +387,7 @@ ensure_certificate_proxy (Test *test) /* Create and prepare a certificate */ /* We don't use tp_tls_certificate_new() as we don't pass a parent */ test->cert = g_object_new (TP_TYPE_TLS_CERTIFICATE, - "dbus-daemon", test->dbus, + "factory", test->factory, "bus-name", test->dbus_name, "object-path", MOCK_TLS_CERTIFICATE_PATH, NULL); diff --git a/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.c b/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.c index 145aa83e..a0ed3d62 100644 --- a/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.c +++ b/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.c @@ -98,33 +98,37 @@ empathy_accounts_plugin_act_headless (ApPlugin *plugin) } static void +empathy_accounts_plugin_dispose (GObject *obj) +{ + EmpathyAccountsPlugin *self = EMPATHY_ACCOUNTS_PLUGIN (obj); + + g_clear_object (&self->factory); + + G_OBJECT_CLASS (empathy_accounts_plugin_parent_class)->dispose (obj); +} + +static void empathy_accounts_plugin_class_init ( EmpathyAccountsPluginClass *klass) { ApPluginClass *pclass = AP_PLUGIN_CLASS (klass); + GObjectClass *oclass = G_OBJECT_CLASS (klass); pclass->build_widget = empathy_accounts_plugin_build_widget; pclass->delete_account = empathy_accounts_plugin_delete_account; pclass->act_headless = empathy_accounts_plugin_act_headless; + + oclass->dispose = empathy_accounts_plugin_dispose; } static void empathy_accounts_plugin_init (EmpathyAccountsPlugin *self) { - if (tp_account_manager_can_set_default ()) + if (tp_client_factory_can_set_default ()) { - EmpathyClientFactory *factory; - TpAccountManager *am; - - factory = empathy_client_factory_dup (); - am = tp_account_manager_new_with_factory ( - TP_SIMPLE_CLIENT_FACTORY (factory)); - tp_account_manager_set_default (am); - - g_object_unref (factory); - g_object_unref (am); + self->factory = TP_CLIENT_FACTORY (empathy_client_factory_dup ()); + tp_client_factory_set_default (self->factory); } - } GType diff --git a/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.h b/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.h index 8f310259..5f9f043b 100644 --- a/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.h +++ b/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.h @@ -38,6 +38,7 @@ struct _EmpathyAccountsPlugin { /*<private>*/ ApPlugin parent; + TpClientFactory *factory; }; GType empathy_accounts_plugin_get_type (void); diff --git a/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.c b/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.c index c22c6d59..6d9fa348 100644 --- a/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.c +++ b/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.c @@ -52,28 +52,32 @@ empathy_app_plugin_build_widget (ApApplicationPlugin *plugin) } static void +empathy_app_plugin_dispose (GObject *obj) +{ + EmpathyAppPlugin *self = EMPATHY_APP_PLUGIN (obj); + + g_clear_object (&self->factory); + + G_OBJECT_CLASS (empathy_app_plugin_parent_class)->dispose (obj); +} + +static void empathy_app_plugin_class_init (EmpathyAppPluginClass *klass) { ApApplicationPluginClass *app_class = AP_APPLICATION_PLUGIN_CLASS (klass); + GObjectClass *oclass = G_OBJECT_CLASS (klass); app_class->build_widget = empathy_app_plugin_build_widget; + oclass->dispose = empathy_accounts_plugin_dispose; } static void empathy_app_plugin_init (EmpathyAppPlugin *self) { - if (tp_account_manager_can_set_default ()) + if (tp_client_factory_can_set_default ()) { - EmpathyClientFactory *factory; - TpAccountManager *am; - - factory = empathy_client_factory_dup (); - am = tp_account_manager_new_with_factory ( - TP_SIMPLE_CLIENT_FACTORY (factory)); - tp_account_manager_set_default (am); - - g_object_unref (factory); - g_object_unref (am); + self->factory = TP_CLIENT_FACTORY (empathy_client_factory_dup ()); + tp_client_factory_set_default (self->factory); } } diff --git a/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.h b/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.h index 67963967..ec2e6659 100644 --- a/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.h +++ b/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.h @@ -39,6 +39,7 @@ struct _EmpathyAppPlugin { /*<private>*/ ApApplicationPlugin parent; + TpClientFactory *factory; }; GType empathy_app_plugin_get_type (void); |