diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-08 14:04:52 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-08 14:06:51 +0100 |
commit | f6542638a5377e6659740bd5001db1b2ae15d90f (patch) | |
tree | 550e3e65f8d0c18459734c01ebfb7ad4a256bb96 | |
parent | 088316de37454d6f7d5644c4da91f8ec9e572f58 (diff) |
TpBaseConnectionManager:protocols: remove
It has a dbus-glib type, and by not using
tp_dbus_properties_mixin_getter_gobject_properties(), we can avoid it.
It is not used in Folks, Empathy, MC or the "big 5" CMs.
-rw-r--r-- | telepathy-glib/base-connection-manager.c | 127 |
1 files changed, 73 insertions, 54 deletions
diff --git a/telepathy-glib/base-connection-manager.c b/telepathy-glib/base-connection-manager.c index c310dc5f5..537963537 100644 --- a/telepathy-glib/base-connection-manager.c +++ b/telepathy-glib/base-connection-manager.c @@ -278,6 +278,22 @@ tp_base_connection_manager_constructor (GType type, return (GObject *) self; } +static GStrv +tp_base_connection_manager_dup_interfaces (TpBaseConnectionManager *self) +{ + TpBaseConnectionManagerClass *cls = TP_BASE_CONNECTION_MANAGER_GET_CLASS ( + self); + GPtrArray *interfaces = cls->get_interfaces (self); + GStrv ret; + + /* make sure there's a terminating NULL */ + g_ptr_array_add (interfaces, NULL); + ret = g_strdupv ((GStrv) interfaces->pdata); + + g_ptr_array_unref (interfaces); + return ret; +} + static void tp_base_connection_manager_get_property (GObject *object, guint property_id, @@ -285,8 +301,6 @@ tp_base_connection_manager_get_property (GObject *object, GParamSpec *pspec) { TpBaseConnectionManager *self = TP_BASE_CONNECTION_MANAGER (object); - TpBaseConnectionManagerClass *cls = TP_BASE_CONNECTION_MANAGER_GET_CLASS ( - object); switch (property_id) { @@ -295,39 +309,8 @@ tp_base_connection_manager_get_property (GObject *object, break; case PROP_INTERFACES: - { - GPtrArray *interfaces = cls->get_interfaces (self); - - /* make sure there's a terminating NULL */ - g_ptr_array_add (interfaces, NULL); - g_value_set_boxed (value, interfaces->pdata); - - g_ptr_array_unref (interfaces); - } - break; - - case PROP_PROTOCOLS: - { - GHashTable *map = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, (GDestroyNotify) g_hash_table_unref); - GHashTableIter iter; - gpointer name, protocol; - - g_hash_table_iter_init (&iter, self->priv->protocols); - - while (g_hash_table_iter_next (&iter, &name, &protocol)) - { - GHashTable *props; - - g_object_get (protocol, - "immutable-properties", &props, - NULL); - - g_hash_table_insert (map, g_strdup (name), props); - } - - g_value_take_boxed (value, map); - } + g_value_take_boxed (value, + tp_base_connection_manager_dup_interfaces (self)); break; default: @@ -376,12 +359,64 @@ tp_base_connection_manager_get_interfaces (TpBaseConnectionManager *self) return interfaces; } +enum { + DBUSPROP_0, + DBUSPROP_INTERFACES, + DBUSPROP_PROTOCOLS, + N_DBUSPROPS +}; + +static void +tp_base_connection_manager_get_cm_property (GObject *object, + GQuark iface, + GQuark name, + GValue *value, + gpointer getter_data) +{ + TpBaseConnectionManager *self = TP_BASE_CONNECTION_MANAGER (object); + + switch (GPOINTER_TO_UINT (getter_data)) + { + case DBUSPROP_INTERFACES: + g_value_take_boxed (value, + tp_base_connection_manager_dup_interfaces (self)); + break; + + case DBUSPROP_PROTOCOLS: + { + GHashTable *map = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, (GDestroyNotify) g_hash_table_unref); + GHashTableIter iter; + gpointer protocol_name, protocol; + + g_hash_table_iter_init (&iter, self->priv->protocols); + + while (g_hash_table_iter_next (&iter, &protocol_name, &protocol)) + { + GHashTable *props; + + g_object_get (protocol, + "immutable-properties", &props, + NULL); + + g_hash_table_insert (map, g_strdup (protocol_name), props); + } + + g_value_take_boxed (value, map); + } + break; + + default: + g_return_if_reached (); + } +} + static void tp_base_connection_manager_class_init (TpBaseConnectionManagerClass *klass) { static TpDBusPropertiesMixinPropImpl cm_properties[] = { - { "Protocols", "protocols", NULL }, - { "Interfaces", "interfaces", NULL }, + { "Protocols", GUINT_TO_POINTER (DBUSPROP_PROTOCOLS), NULL }, + { "Interfaces", GUINT_TO_POINTER (DBUSPROP_INTERFACES), NULL }, { NULL } }; GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -429,21 +464,6 @@ tp_base_connection_manager_class_init (TpBaseConnectionManagerClass *klass) G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /** - * TpBaseConnectionManager:protocols: - * - * The Protocol objects available on this ConnectionManager. - * - * Since: 0.11.11 - */ - g_object_class_install_property (object_class, PROP_PROTOCOLS, - g_param_spec_boxed ("protocols", - "ConnectionManager.Protocols", - "The set of protocols available on this Connection, other than " - "ConnectionManager itself", - TP_HASH_TYPE_PROTOCOL_PROPERTIES_MAP, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - - /** * TpBaseConnectionManager::no-more-connections: * * Emitted when the table of active connections becomes empty. @@ -461,8 +481,7 @@ tp_base_connection_manager_class_init (TpBaseConnectionManagerClass *klass) tp_dbus_properties_mixin_class_init (object_class, 0); tp_dbus_properties_mixin_implement_interface (object_class, TP_IFACE_QUARK_CONNECTION_MANAGER, - tp_dbus_properties_mixin_getter_gobject_properties, NULL, - cm_properties); + tp_base_connection_manager_get_cm_property, NULL, cm_properties); } static void |