diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-11-06 18:35:37 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-01-13 12:03:57 +0000 |
commit | 755108dd64973c8a4639debc7fd190ec1ebad7fc (patch) | |
tree | 5a7737233e3f26097d7707b2bd97fa5f8839ffb7 /examples | |
parent | cbf3bac0c6709163ca70b2ed2535828503245822 (diff) |
TpBaseConnection: absorb the functionality of the TpContactsMixin
It's a somewhat different "shape" - using a fill_contacts_attribute()
virtual method - so that it's (hopefully) introspectable. This is a
step towards folding Contacts into Connection.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=50093
Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/cm/call/conn.c | 27 | ||||
-rw-r--r-- | examples/cm/call/conn.h | 2 | ||||
-rw-r--r-- | examples/cm/channelspecific/conn.c | 26 | ||||
-rw-r--r-- | examples/cm/channelspecific/conn.h | 2 | ||||
-rw-r--r-- | examples/cm/contactlist/conn.c | 53 | ||||
-rw-r--r-- | examples/cm/contactlist/conn.h | 2 | ||||
-rw-r--r-- | examples/cm/echo-message-parts/conn.c | 26 | ||||
-rw-r--r-- | examples/cm/echo-message-parts/conn.h | 2 | ||||
-rw-r--r-- | examples/cm/extended/conn.c | 22 | ||||
-rw-r--r-- | examples/cm/extended/conn.h | 2 |
10 files changed, 43 insertions, 121 deletions
diff --git a/examples/cm/call/conn.c b/examples/cm/call/conn.c index c3a736f82..2ef63c81f 100644 --- a/examples/cm/call/conn.c +++ b/examples/cm/call/conn.c @@ -34,8 +34,6 @@ G_DEFINE_TYPE_WITH_CODE (ExampleCallConnection, example_call_connection, TP_TYPE_BASE_CONNECTION, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACTS, - tp_contacts_mixin_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_PRESENCE1, tp_presence_mixin_iface_init)) @@ -124,7 +122,6 @@ finalize (GObject *object) { ExampleCallConnection *self = EXAMPLE_CALL_CONNECTION (object); - tp_contacts_mixin_finalize (object); g_free (self->priv->account); g_free (self->priv->presence_message); @@ -215,20 +212,14 @@ shut_down (TpBaseConnection *conn) static void constructed (GObject *object) { - TpBaseConnection *base = TP_BASE_CONNECTION (object); void (*chain_up) (GObject *) = G_OBJECT_CLASS (example_call_connection_parent_class)->constructed; if (chain_up != NULL) chain_up (object); - tp_contacts_mixin_init (object, - G_STRUCT_OFFSET (ExampleCallConnection, contacts_mixin)); - tp_base_connection_register_with_contacts_mixin (base); - tp_presence_mixin_init (object, G_STRUCT_OFFSET (ExampleCallConnection, presence_mixin)); - tp_presence_mixin_register_with_contacts_mixin (object); } static gboolean @@ -390,6 +381,20 @@ get_interfaces_always_present (TpBaseConnection *base) } static void +example_call_connection_fill_contact_attributes (TpBaseConnection *conn, + const gchar *dbus_interface, + TpHandle contact, + TpContactAttributeMap *attributes) +{ + if (tp_presence_mixin_fill_contact_attributes (G_OBJECT (conn), + dbus_interface, contact, attributes)) + return; + + ((TpBaseConnectionClass *) example_call_connection_parent_class)-> + fill_contact_attributes (conn, dbus_interface, contact, attributes); +} + +static void example_call_connection_class_init ( ExampleCallConnectionClass *klass) { @@ -410,6 +415,8 @@ example_call_connection_class_init ( base_class->start_connecting = start_connecting; base_class->shut_down = shut_down; base_class->get_interfaces_always_present = get_interfaces_always_present; + base_class->fill_contact_attributes = + example_call_connection_fill_contact_attributes; param_spec = g_param_spec_string ("account", "Account name", "The username of this user", NULL, @@ -429,8 +436,6 @@ example_call_connection_class_init ( G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING); - tp_contacts_mixin_class_init (object_class, - G_STRUCT_OFFSET (ExampleCallConnectionClass, contacts_mixin)); tp_presence_mixin_class_init (object_class, G_STRUCT_OFFSET (ExampleCallConnectionClass, presence_mixin), status_available, get_contact_statuses, set_own_status, diff --git a/examples/cm/call/conn.h b/examples/cm/call/conn.h index b9e98ad2e..56a252602 100644 --- a/examples/cm/call/conn.h +++ b/examples/cm/call/conn.h @@ -28,7 +28,6 @@ typedef struct _ExampleCallConnectionClassPrivate struct _ExampleCallConnectionClass { TpBaseConnectionClass parent_class; TpPresenceMixinClass presence_mixin; - TpContactsMixinClass contacts_mixin; ExampleCallConnectionClassPrivate *priv; }; @@ -36,7 +35,6 @@ struct _ExampleCallConnectionClass { struct _ExampleCallConnection { TpBaseConnection parent; TpPresenceMixin presence_mixin; - TpContactsMixin contacts_mixin; ExampleCallConnectionPrivate *priv; }; diff --git a/examples/cm/channelspecific/conn.c b/examples/cm/channelspecific/conn.c index 7e48435bd..1c1b854bd 100644 --- a/examples/cm/channelspecific/conn.c +++ b/examples/cm/channelspecific/conn.c @@ -21,11 +21,9 @@ #include "protocol.h" #include "room-manager.h" -G_DEFINE_TYPE_WITH_CODE (ExampleCSHConnection, +G_DEFINE_TYPE (ExampleCSHConnection, example_csh_connection, - TP_TYPE_BASE_CONNECTION, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACTS, - tp_contacts_mixin_iface_init)) + TP_TYPE_BASE_CONNECTION) /* type definition stuff */ @@ -99,7 +97,6 @@ finalize (GObject *object) { ExampleCSHConnection *self = EXAMPLE_CSH_CONNECTION (object); - tp_contacts_mixin_finalize (object); g_free (self->priv->account); G_OBJECT_CLASS (example_csh_connection_parent_class)->finalize (object); @@ -219,21 +216,6 @@ shut_down (TpBaseConnection *conn) tp_base_connection_finish_shutdown (conn); } -static void -constructed (GObject *object) -{ - TpBaseConnection *base = TP_BASE_CONNECTION (object); - void (*chain_up) (GObject *) = - G_OBJECT_CLASS (example_csh_connection_parent_class)->constructed; - - if (chain_up != NULL) - chain_up (object); - - tp_contacts_mixin_init (object, - G_STRUCT_OFFSET (ExampleCSHConnection, contacts_mixin)); - tp_base_connection_register_with_contacts_mixin (base); -} - static const gchar *interfaces_always_present[] = { TP_IFACE_CONNECTION_INTERFACE_REQUESTS, TP_IFACE_CONNECTION_INTERFACE_CONTACTS, @@ -270,7 +252,6 @@ example_csh_connection_class_init (ExampleCSHConnectionClass *klass) GObjectClass *object_class = (GObjectClass *) klass; GParamSpec *param_spec; - object_class->constructed = constructed; object_class->get_property = get_property; object_class->set_property = set_property; object_class->finalize = finalize; @@ -294,7 +275,4 @@ example_csh_connection_class_init (ExampleCSHConnectionClass *klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_SIMULATION_DELAY, param_spec); - - tp_contacts_mixin_class_init (object_class, - G_STRUCT_OFFSET (ExampleCSHConnectionClass, contacts_mixin)); } diff --git a/examples/cm/channelspecific/conn.h b/examples/cm/channelspecific/conn.h index dc056e586..473ed99b1 100644 --- a/examples/cm/channelspecific/conn.h +++ b/examples/cm/channelspecific/conn.h @@ -23,12 +23,10 @@ typedef struct _ExampleCSHConnectionPrivate ExampleCSHConnectionPrivate; struct _ExampleCSHConnectionClass { TpBaseConnectionClass parent_class; - TpContactsMixinClass contacts_mixin; }; struct _ExampleCSHConnection { TpBaseConnection parent; - TpContactsMixin contacts_mixin; ExampleCSHConnectionPrivate *priv; }; diff --git a/examples/cm/contactlist/conn.c b/examples/cm/contactlist/conn.c index e3ddd3391..f0f77b37f 100644 --- a/examples/cm/contactlist/conn.c +++ b/examples/cm/contactlist/conn.c @@ -30,8 +30,6 @@ G_DEFINE_TYPE_WITH_CODE (ExampleContactListConnection, tp_dbus_properties_mixin_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_ALIASING1, init_aliasing); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACTS, - tp_contacts_mixin_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_LIST1, tp_base_contact_list_mixin_list_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_GROUPS1, @@ -119,7 +117,6 @@ finalize (GObject *object) ExampleContactListConnection *self = EXAMPLE_CONTACT_LIST_CONNECTION (object); - tp_contacts_mixin_finalize (object); g_free (self->priv->account); G_OBJECT_CLASS (example_contact_list_connection_parent_class)->finalize ( @@ -235,42 +232,47 @@ shut_down (TpBaseConnection *conn) } static void -aliasing_fill_contact_attributes (GObject *object, - const GArray *contacts, - GHashTable *attributes) +example_contact_list_connection_fill_contact_attributes (TpBaseConnection *conn, + const gchar *dbus_interface, + TpHandle contact, + TpContactAttributeMap *attributes) { ExampleContactListConnection *self = - EXAMPLE_CONTACT_LIST_CONNECTION (object); - guint i; + EXAMPLE_CONTACT_LIST_CONNECTION (conn); - for (i = 0; i < contacts->len; i++) + if (!tp_strdiff (dbus_interface, TP_IFACE_CONNECTION_INTERFACE_ALIASING1)) { - TpHandle contact = g_array_index (contacts, guint, i); - - tp_contacts_mixin_set_contact_attribute (attributes, contact, + tp_contact_attribute_map_set (attributes, contact, TP_TOKEN_CONNECTION_INTERFACE_ALIASING1_ALIAS, - tp_g_value_slice_new_string ( + g_variant_new_string ( example_contact_list_get_alias (self->priv->contact_list, contact))); + return; } + + if (tp_base_contact_list_fill_contact_attributes ( + TP_BASE_CONTACT_LIST (self->priv->contact_list), + dbus_interface, contact, attributes)) + return; + + if (tp_presence_mixin_fill_contact_attributes (G_OBJECT (conn), + dbus_interface, contact, attributes)) + return; + + ((TpBaseConnectionClass *) example_contact_list_connection_parent_class)-> + fill_contact_attributes (conn, dbus_interface, contact, attributes); } static void constructed (GObject *object) { ExampleContactListConnection *self = EXAMPLE_CONTACT_LIST_CONNECTION (object); - TpBaseConnection *base = TP_BASE_CONNECTION (object); void (*chain_up) (GObject *) = G_OBJECT_CLASS (example_contact_list_connection_parent_class)->constructed; if (chain_up != NULL) chain_up (object); - tp_contacts_mixin_init (object, - G_STRUCT_OFFSET (ExampleContactListConnection, contacts_mixin)); - - tp_base_connection_register_with_contacts_mixin (base); - self->priv->contact_list = EXAMPLE_CONTACT_LIST (g_object_new ( EXAMPLE_TYPE_CONTACT_LIST, "connection", self, @@ -282,16 +284,8 @@ constructed (GObject *object) g_signal_connect (self->priv->contact_list, "presence-updated", G_CALLBACK (presence_updated_cb), self); - tp_base_contact_list_mixin_register_with_contacts_mixin ( - TP_BASE_CONTACT_LIST (self->priv->contact_list), base); - - tp_contacts_mixin_add_contact_attributes_iface (object, - TP_IFACE_CONNECTION_INTERFACE_ALIASING1, - aliasing_fill_contact_attributes); - tp_presence_mixin_init (object, G_STRUCT_OFFSET (ExampleContactListConnection, presence_mixin)); - tp_presence_mixin_register_with_contacts_mixin (object); } static gboolean @@ -468,6 +462,8 @@ example_contact_list_connection_class_init ( base_class->start_connecting = start_connecting; base_class->shut_down = shut_down; base_class->get_interfaces_always_present = get_interfaces_always_present; + base_class->fill_contact_attributes = + example_contact_list_connection_fill_contact_attributes; param_spec = g_param_spec_string ("account", "Account name", "The username of this user", NULL, @@ -481,9 +477,6 @@ example_contact_list_connection_class_init ( g_object_class_install_property (object_class, PROP_SIMULATION_DELAY, param_spec); - tp_contacts_mixin_class_init (object_class, - G_STRUCT_OFFSET (ExampleContactListConnectionClass, contacts_mixin)); - tp_presence_mixin_class_init (object_class, G_STRUCT_OFFSET (ExampleContactListConnectionClass, presence_mixin), status_available, get_contact_statuses, set_own_status, diff --git a/examples/cm/contactlist/conn.h b/examples/cm/contactlist/conn.h index 725eb507f..b54524564 100644 --- a/examples/cm/contactlist/conn.h +++ b/examples/cm/contactlist/conn.h @@ -26,14 +26,12 @@ typedef struct _ExampleContactListConnectionPrivate struct _ExampleContactListConnectionClass { TpBaseConnectionClass parent_class; TpPresenceMixinClass presence_mixin; - TpContactsMixinClass contacts_mixin; TpDBusPropertiesMixinClass properties_mixin; }; struct _ExampleContactListConnection { TpBaseConnection parent; TpPresenceMixin presence_mixin; - TpContactsMixin contacts_mixin; ExampleContactListConnectionPrivate *priv; }; diff --git a/examples/cm/echo-message-parts/conn.c b/examples/cm/echo-message-parts/conn.c index 3223a048d..bc444ef07 100644 --- a/examples/cm/echo-message-parts/conn.c +++ b/examples/cm/echo-message-parts/conn.c @@ -19,11 +19,9 @@ #include "im-manager.h" #include "protocol.h" -G_DEFINE_TYPE_WITH_CODE (ExampleEcho2Connection, +G_DEFINE_TYPE (ExampleEcho2Connection, example_echo_2_connection, - TP_TYPE_BASE_CONNECTION, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACTS, - tp_contacts_mixin_iface_init)) + TP_TYPE_BASE_CONNECTION) enum { @@ -84,7 +82,6 @@ finalize (GObject *object) { ExampleEcho2Connection *self = EXAMPLE_ECHO_2_CONNECTION (object); - tp_contacts_mixin_finalize (object); g_free (self->priv->account); G_OBJECT_CLASS (example_echo_2_connection_parent_class)->finalize (object); @@ -189,21 +186,6 @@ get_interfaces_always_present (TpBaseConnection *base) } static void -constructed (GObject *object) -{ - TpBaseConnection *base = TP_BASE_CONNECTION (object); - void (*chain_up) (GObject *) = - G_OBJECT_CLASS (example_echo_2_connection_parent_class)->constructed; - - if (chain_up != NULL) - chain_up (object); - - tp_contacts_mixin_init (object, - G_STRUCT_OFFSET (ExampleEcho2Connection, contacts_mixin)); - tp_base_connection_register_with_contacts_mixin (base); -} - -static void example_echo_2_connection_class_init (ExampleEcho2ConnectionClass *klass) { TpBaseConnectionClass *base_class = @@ -211,7 +193,6 @@ example_echo_2_connection_class_init (ExampleEcho2ConnectionClass *klass) GObjectClass *object_class = (GObjectClass *) klass; GParamSpec *param_spec; - object_class->constructed = constructed; object_class->get_property = get_property; object_class->set_property = set_property; object_class->finalize = finalize; @@ -228,7 +209,4 @@ example_echo_2_connection_class_init (ExampleEcho2ConnectionClass *klass) "The username of this user", NULL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_ACCOUNT, param_spec); - - tp_contacts_mixin_class_init (object_class, - G_STRUCT_OFFSET (ExampleEcho2ConnectionClass, contacts_mixin)); } diff --git a/examples/cm/echo-message-parts/conn.h b/examples/cm/echo-message-parts/conn.h index 12f003663..4f4073ec0 100644 --- a/examples/cm/echo-message-parts/conn.h +++ b/examples/cm/echo-message-parts/conn.h @@ -23,12 +23,10 @@ typedef struct _ExampleEcho2ConnectionPrivate ExampleEcho2ConnectionPrivate; struct _ExampleEcho2ConnectionClass { TpBaseConnectionClass parent_class; - TpContactsMixinClass contacts_mixin; }; struct _ExampleEcho2Connection { TpBaseConnection parent; - TpContactsMixin contacts_mixin; ExampleEcho2ConnectionPrivate *priv; }; diff --git a/examples/cm/extended/conn.c b/examples/cm/extended/conn.c index c53544985..c8dd22e96 100644 --- a/examples/cm/extended/conn.c +++ b/examples/cm/extended/conn.c @@ -28,8 +28,6 @@ static void _hats_iface_init (gpointer, gpointer); G_DEFINE_TYPE_WITH_CODE (ExampleExtendedConnection, example_extended_connection, TP_TYPE_BASE_CONNECTION, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACTS, - tp_contacts_mixin_iface_init); G_IMPLEMENT_INTERFACE (EXAMPLE_TYPE_SVC_CONNECTION_INTERFACE_HATS, _hats_iface_init)) @@ -103,7 +101,6 @@ finalize (GObject *object) { ExampleExtendedConnection *self = EXAMPLE_EXTENDED_CONNECTION (object); - tp_contacts_mixin_finalize (object); g_free (self->priv->account); g_free (self->priv->hat_color); g_hash_table_unref (self->priv->hat_properties); @@ -175,21 +172,6 @@ shut_down (TpBaseConnection *conn) tp_base_connection_finish_shutdown (conn); } -static void -constructed (GObject *object) -{ - TpBaseConnection *base = TP_BASE_CONNECTION (object); - void (*chain_up) (GObject *) = - G_OBJECT_CLASS (example_extended_connection_parent_class)->constructed; - - if (chain_up != NULL) - chain_up (object); - - tp_contacts_mixin_init (object, - G_STRUCT_OFFSET (ExampleExtendedConnection, contacts_mixin)); - tp_base_connection_register_with_contacts_mixin (base); -} - static const gchar *interfaces_always_present[] = { TP_IFACE_CONNECTION_INTERFACE_REQUESTS, TP_IFACE_CONNECTION_INTERFACE_CONTACTS, @@ -227,7 +209,6 @@ example_extended_connection_class_init (ExampleExtendedConnectionClass *klass) GObjectClass *object_class = (GObjectClass *) klass; GParamSpec *param_spec; - object_class->constructed = constructed; object_class->get_property = get_property; object_class->set_property = set_property; object_class->finalize = finalize; @@ -245,9 +226,6 @@ example_extended_connection_class_init (ExampleExtendedConnectionClass *klass) "The username of this user", NULL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_ACCOUNT, param_spec); - - tp_contacts_mixin_class_init (object_class, - G_STRUCT_OFFSET (ExampleExtendedConnectionClass, contacts_mixin)); } static void diff --git a/examples/cm/extended/conn.h b/examples/cm/extended/conn.h index ba0888cd7..dcf7ff524 100644 --- a/examples/cm/extended/conn.h +++ b/examples/cm/extended/conn.h @@ -23,12 +23,10 @@ typedef struct _ExampleExtendedConnectionPrivate ExampleExtendedConnectionPrivat struct _ExampleExtendedConnectionClass { TpBaseConnectionClass parent_class; - TpContactsMixinClass contacts_mixin; }; struct _ExampleExtendedConnection { TpBaseConnection parent; - TpContactsMixin contacts_mixin; ExampleExtendedConnectionPrivate *priv; }; |