From 4fee994638e36662aec5e08b13cd57253fa5c227 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 11 Apr 2011 17:31:27 +0200 Subject: [PATCH] Use tp_proxy_add_interfaces() more --- telepathy-glib/account.c | 21 +-------------------- telepathy-glib/channel-dispatch-operation.c | 17 +---------------- telepathy-glib/channel.c | 17 +---------------- telepathy-glib/connection-manager.c | 27 ++------------------------- 4 files changed, 5 insertions(+), 77 deletions(-) diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c index 551d95f..e7e294e 100644 --- a/telepathy-glib/account.c +++ b/telepathy-glib/account.c @@ -465,26 +465,7 @@ _tp_account_update (TpAccount *account, gboolean status_changed = FALSE; gboolean presence_changed = FALSE; - if (g_hash_table_lookup (properties, "Interfaces") != NULL) - { - gchar **interfaces, **iter; - - interfaces = tp_asv_get_boxed (properties, "Interfaces", G_TYPE_STRV); - - for (iter = interfaces; *iter != NULL; iter++) - { - if (tp_dbus_check_valid_interface_name (*iter, NULL)) - { - GQuark q = g_quark_from_string (*iter); - - tp_proxy_add_interface_by_id ((TpProxy *) account, q); - } - else - { - DEBUG ("\t\tInterface %s not valid", *iter); - } - } - } + tp_proxy_add_interfaces (proxy, tp_asv_get_strv (properties, "Interfaces")); if (g_hash_table_lookup (properties, "ConnectionStatus") != NULL) { diff --git a/telepathy-glib/channel-dispatch-operation.c b/telepathy-glib/channel-dispatch-operation.c index e1018c4..6170883 100644 --- a/telepathy-glib/channel-dispatch-operation.c +++ b/telepathy-glib/channel-dispatch-operation.c @@ -334,25 +334,10 @@ static void maybe_set_interfaces (TpChannelDispatchOperation *self, const gchar **interfaces) { - const gchar **iter; - if (interfaces == NULL) return; - for (iter = interfaces; *iter != NULL; iter++) - { - DEBUG ("- %s", *iter); - - if (tp_dbus_check_valid_interface_name (*iter, NULL)) - { - GQuark q = g_quark_from_string (*iter); - tp_proxy_add_interface_by_id ((TpProxy *) self, q); - } - else - { - DEBUG ("\tInterface %s not valid, ignoring it", *iter); - } - } + tp_proxy_add_interfaces ((TpProxy *) self, interfaces); g_hash_table_insert (self->priv->immutable_properties, g_strdup (TP_PROP_CHANNEL_DISPATCH_OPERATION_INTERFACES), diff --git a/telepathy-glib/channel.c b/telepathy-glib/channel.c index 2270a67..21bfc3f 100644 --- a/telepathy-glib/channel.c +++ b/telepathy-glib/channel.c @@ -558,25 +558,10 @@ static void _tp_channel_maybe_set_interfaces (TpChannel *self, const gchar **interfaces) { - const gchar **iter; - if (interfaces == NULL) return; - for (iter = interfaces; *iter != NULL; iter++) - { - DEBUG ("- %s", *iter); - - if (tp_dbus_check_valid_interface_name (*iter, NULL)) - { - GQuark q = g_quark_from_string (*iter); - tp_proxy_add_interface_by_id ((TpProxy *) self, q); - } - else - { - DEBUG ("\tInterface %s not valid, ignoring it", *iter); - } - } + tp_proxy_add_interfaces ((TpProxy *) self, interfaces); g_hash_table_insert (self->priv->channel_properties, g_strdup (TP_PROP_CHANNEL_INTERFACES), diff --git a/telepathy-glib/connection-manager.c b/telepathy-glib/connection-manager.c index e359988..ae3c006 100644 --- a/telepathy-glib/connection-manager.c +++ b/telepathy-glib/connection-manager.c @@ -705,29 +705,6 @@ tp_connection_manager_update_protocol_structs (TpConnectionManager *self) } static void -tp_connection_manager_add_interfaces (TpConnectionManager *self, - const gchar * const * interfaces) -{ - if (interfaces == NULL) - return; - - for (; *interfaces != NULL; interfaces++) - { - if (tp_dbus_check_valid_interface_name (*interfaces, NULL)) - { - GQuark q = g_quark_from_string (*interfaces); - - tp_proxy_add_interface_by_id ((TpProxy *) self, q); - } - else - { - DEBUG ("Ignoring invalid interface on %s: %s", - tp_proxy_get_object_path (self), *interfaces); - } - } -} - -static void tp_connection_manager_get_all_cb (TpProxy *proxy, GHashTable *properties, const GError *error, @@ -745,7 +722,7 @@ tp_connection_manager_get_all_cb (TpProxy *proxy, { GHashTable *protocols; - tp_connection_manager_add_interfaces (self, + tp_proxy_add_interfaces (proxy, tp_asv_get_strv (properties, "Interfaces")); protocols = tp_asv_get_boxed (properties, "Protocols", @@ -1122,7 +1099,7 @@ tp_connection_manager_idle_read_manager_file (gpointer data) } else { - tp_connection_manager_add_interfaces (self, + tp_proxy_add_interfaces ((TpProxy *) self, (const gchar * const *) interfaces); g_strfreev (interfaces); -- 1.7.4.1