summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-01-13 12:29:47 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-01-13 12:29:47 +0000
commit340ca22306f0d4e6b6781e4062238ba6c2314738 (patch)
treebd2a894d866fe2b05f9c87dfb8ac8f51a35624dd
parente626238220f222993485281cb130bea9ee5eb364 (diff)
downloadtelepathy-haze-340ca22306f0d4e6b6781e4062238ba6c2314738.tar.gz
remove use of TpContactsMixin and Contacts interface
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=50093 Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> [added telepathy-glib 0.99.6 dependency] Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r--configure.ac2
-rw-r--r--src/connection-aliasing.c29
-rw-r--r--src/connection-aliasing.h9
-rw-r--r--src/connection-avatars.c29
-rw-r--r--src/connection-avatars.h9
-rw-r--r--src/connection-capabilities.c35
-rw-r--r--src/connection-capabilities.h11
-rw-r--r--src/connection-presence.c1
-rw-r--r--src/connection.c51
-rw-r--r--src/connection.h2
10 files changed, 97 insertions, 81 deletions
diff --git a/configure.ac b/configure.ac
index b5542e3..4519d14 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,7 @@ PKG_CHECK_MODULES(DBUS_GLIB,[dbus-glib-1 >= 0.73])
AC_DEFINE([TP_SEAL_ENABLE], [], [Prevent to use sealed variables])
AC_DEFINE([TP_VERSION_MIN_REQUIRED], [TP_VERSION_1_0], [Ignore post 1.0 deprecations])
AC_DEFINE([TP_VERSION_MAX_ALLOWED], [TP_VERSION_1_0], [Prevent post 1.0 APIs])
-PKG_CHECK_MODULES([TP_GLIB], [telepathy-glib-1 >= 0.99.5, telepathy-glib-1-dbus >= 0.99.5])
+PKG_CHECK_MODULES([TP_GLIB], [telepathy-glib-1 >= 0.99.6, telepathy-glib-1-dbus >= 0.99.6])
dnl MIN_REQUIRED must stay to 2.30 because of GValueArray
AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_30], [Ignore post 2.30 deprecations])
diff --git a/src/connection-aliasing.c b/src/connection-aliasing.c
index ba74236..510e815 100644
--- a/src/connection-aliasing.c
+++ b/src/connection-aliasing.c
@@ -353,31 +353,22 @@ haze_connection_aliasing_class_init (GObjectClass *object_class)
PURPLE_CALLBACK (blist_node_aliased_cb), NULL);
}
-static void
-fill_contact_attributes (GObject *object,
- const GArray *contacts,
- GHashTable *attributes_hash)
+gboolean
+haze_connection_aliasing_fill_contact_attributes (HazeConnection *self,
+ const gchar *dbus_interface,
+ TpHandle handle,
+ TpContactAttributeMap *attributes)
{
- HazeConnection *self = HAZE_CONNECTION (object);
- guint i;
-
- for (i = 0; i < contacts->len; i++)
+ if (!tp_strdiff (dbus_interface, TP_IFACE_CONNECTION_INTERFACE_ALIASING1))
{
- TpHandle handle = g_array_index (contacts, guint, i);
GValue *value = tp_g_value_slice_new (G_TYPE_STRING);
g_value_set_string (value, get_alias (self, handle));
- /* this steals the GValue */
- tp_contacts_mixin_set_contact_attribute (attributes_hash, handle,
- TP_IFACE_CONNECTION_INTERFACE_ALIASING1 "/alias", value);
+ tp_contact_attribute_map_take_sliced_gvalue (attributes, handle,
+ TP_TOKEN_CONNECTION_INTERFACE_ALIASING1_ALIAS, value);
+ return TRUE;
}
-}
-void
-haze_connection_aliasing_init (GObject *object)
-{
- tp_contacts_mixin_add_contact_attributes_iface (object,
- TP_IFACE_CONNECTION_INTERFACE_ALIASING1,
- fill_contact_attributes);
+ return FALSE;
}
diff --git a/src/connection-aliasing.h b/src/connection-aliasing.h
index 6bc565a..82c4fd5 100644
--- a/src/connection-aliasing.h
+++ b/src/connection-aliasing.h
@@ -25,13 +25,20 @@
#include <glib-object.h>
#include <telepathy-glib/telepathy-glib.h>
+#include "connection.h"
+
void haze_connection_aliasing_iface_init (gpointer g_iface,
gpointer iface_data);
void haze_connection_aliasing_class_init (GObjectClass *object_class);
-void haze_connection_aliasing_init (GObject *object);
extern TpDBusPropertiesMixinPropImpl *haze_connection_aliasing_properties;
void haze_connection_aliasing_properties_getter (GObject *object,
GQuark interface, GQuark name, GValue *value, gpointer getter_data);
+gboolean haze_connection_aliasing_fill_contact_attributes (
+ HazeConnection *self,
+ const gchar *dbus_interface,
+ TpHandle handle,
+ TpContactAttributeMap *attributes);
+
#endif
diff --git a/src/connection-avatars.c b/src/connection-avatars.c
index c20a2c4..53d1c17 100644
--- a/src/connection-avatars.c
+++ b/src/connection-avatars.c
@@ -513,33 +513,24 @@ haze_connection_avatars_class_init (GObjectClass *object_class)
PURPLE_CALLBACK (buddy_icon_changed_cb), NULL);
}
-static void
-fill_contact_attributes (GObject *object,
- const GArray *contacts,
- GHashTable *attributes_hash)
+gboolean
+haze_connection_avatars_fill_contact_attributes (HazeConnection *self,
+ const gchar *dbus_interface,
+ TpHandle handle,
+ TpContactAttributeMap *attributes)
{
- HazeConnection *self = HAZE_CONNECTION (object);
- guint i;
-
- for (i = 0; i < contacts->len; i++)
+ if (!tp_strdiff (dbus_interface, TP_IFACE_CONNECTION_INTERFACE_AVATARS1))
{
- TpHandle handle = g_array_index (contacts, guint, i);
gchar *token = get_handle_token (self, handle);
GValue *value = tp_g_value_slice_new (G_TYPE_STRING);
g_assert (token != NULL);
g_value_set_string (value, token);
- /* this steals the GValue */
- tp_contacts_mixin_set_contact_attribute (attributes_hash, handle,
- TP_IFACE_CONNECTION_INTERFACE_AVATARS1 "/token", value);
+ tp_contact_attribute_map_take_sliced_gvalue (attributes, handle,
+ TP_TOKEN_CONNECTION_INTERFACE_AVATARS1_TOKEN, value);
+ return TRUE;
}
-}
-void
-haze_connection_avatars_init (GObject *object)
-{
- tp_contacts_mixin_add_contact_attributes_iface (object,
- TP_IFACE_CONNECTION_INTERFACE_AVATARS1,
- fill_contact_attributes);
+ return FALSE;
}
diff --git a/src/connection-avatars.h b/src/connection-avatars.h
index 8ac37ab..471ebd2 100644
--- a/src/connection-avatars.h
+++ b/src/connection-avatars.h
@@ -27,9 +27,10 @@
#include <libpurple/purple.h>
+#include "connection.h"
+
void haze_connection_avatars_iface_init (gpointer g_iface, gpointer iface_data);
void haze_connection_avatars_class_init (GObjectClass *object_class);
-void haze_connection_avatars_init (GObject *object);
extern TpDBusPropertiesMixinPropImpl *haze_connection_avatars_properties;
void haze_connection_avatars_properties_getter (GObject *object,
@@ -45,4 +46,10 @@ void haze_connection_get_icon_spec_requirements (PurpleBuddyIconSpec *icon_spec,
guint *max_width,
guint *max_bytes);
+gboolean haze_connection_avatars_fill_contact_attributes (
+ HazeConnection *self,
+ const gchar *dbus_interface,
+ TpHandle handle,
+ TpContactAttributeMap *attributes);
+
#endif
diff --git a/src/connection-capabilities.c b/src/connection-capabilities.c
index 281d669..1195c1f 100644
--- a/src/connection-capabilities.c
+++ b/src/connection-capabilities.c
@@ -94,18 +94,16 @@ haze_connection_get_handle_contact_capabilities (HazeConnection *self,
return arr;
}
-static void
-conn_capabilities_fill_contact_attributes_contact_caps (
- GObject *obj,
- const GArray *contacts,
- GHashTable *attributes_hash)
+gboolean
+haze_connection_contact_capabilities_fill_contact_attributes (
+ HazeConnection *self,
+ const gchar *dbus_interface,
+ TpHandle handle,
+ TpContactAttributeMap *attributes)
{
- HazeConnection *self = HAZE_CONNECTION (obj);
- guint i;
-
- for (i = 0; i < contacts->len; i++)
+ if (!tp_strdiff (dbus_interface,
+ TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1))
{
- TpHandle handle = g_array_index (contacts, TpHandle, i);
GPtrArray *array;
array = haze_connection_get_handle_contact_capabilities (self, handle);
@@ -116,13 +114,18 @@ conn_capabilities_fill_contact_attributes_contact_caps (
TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST);
g_value_take_boxed (val, array);
- tp_contacts_mixin_set_contact_attribute (attributes_hash,
- handle, TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1 "/capabilities",
+ tp_contact_attribute_map_take_sliced_gvalue (attributes,
+ handle,
+ TP_TOKEN_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1_CAPABILITIES,
val);
}
else
g_ptr_array_free (array, TRUE);
+
+ return TRUE;
}
+
+ return FALSE;
}
void
@@ -137,11 +140,3 @@ haze_connection_contact_capabilities_iface_init (gpointer g_iface,
IMPLEMENT(update_capabilities);
#undef IMPLEMENT
}
-
-void
-haze_connection_capabilities_init (GObject *object)
-{
- tp_contacts_mixin_add_contact_attributes_iface (object,
- TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1,
- conn_capabilities_fill_contact_attributes_contact_caps);
-}
diff --git a/src/connection-capabilities.h b/src/connection-capabilities.h
index e98bf98..f795e74 100644
--- a/src/connection-capabilities.h
+++ b/src/connection-capabilities.h
@@ -23,8 +23,17 @@
#include <glib-object.h>
+#include <telepathy-glib/telepathy-glib.h>
+
+#include "connection.h"
+
void haze_connection_contact_capabilities_iface_init (gpointer g_iface,
gpointer iface_data);
-void haze_connection_capabilities_init (GObject *object);
+
+gboolean haze_connection_contact_capabilities_fill_contact_attributes (
+ HazeConnection *self,
+ const gchar *dbus_interface,
+ TpHandle handle,
+ TpContactAttributeMap *attributes);
#endif
diff --git a/src/connection-presence.c b/src/connection-presence.c
index ddc5809..23e267a 100644
--- a/src/connection-presence.c
+++ b/src/connection-presence.c
@@ -340,5 +340,4 @@ haze_connection_presence_init (GObject *object)
{
tp_presence_mixin_init (object, G_STRUCT_OFFSET (HazeConnection,
presence));
- tp_presence_mixin_register_with_contacts_mixin (object);
}
diff --git a/src/connection.c b/src/connection.c
index 8af1c47..08e7757 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -72,8 +72,6 @@ G_DEFINE_TYPE_WITH_CODE(HazeConnection,
haze_connection_avatars_iface_init);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1,
haze_connection_contact_capabilities_iface_init);
- 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,
@@ -99,7 +97,6 @@ static const gchar * implemented_interfaces[] = {
TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
TP_IFACE_CONNECTION_INTERFACE_PRESENCE1,
TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1,
- TP_IFACE_CONNECTION_INTERFACE_CONTACTS,
/* TODO: This is a lie. Not all protocols supported by libpurple
* actually have the concept of a user-settable alias, but
* there's no way for the UI to know (yet).
@@ -748,7 +745,6 @@ haze_connection_constructor (GType type,
HazeConnection *self = HAZE_CONNECTION (
G_OBJECT_CLASS (haze_connection_parent_class)->constructor (
type, n_construct_properties, construct_params));
- TpBaseConnection *base_conn = TP_BASE_CONNECTION (self);
GObject *object = (GObject *) self;
HazeConnectionPrivate *priv = self->priv;
@@ -760,18 +756,9 @@ haze_connection_constructor (GType type,
priv->disconnecting = FALSE;
- tp_contacts_mixin_init (object,
- G_STRUCT_OFFSET (HazeConnection, contacts));
- tp_base_connection_register_with_contacts_mixin (base_conn);
-
self->contact_list = HAZE_CONTACT_LIST (
g_object_new (HAZE_TYPE_CONTACT_LIST, "connection", self, NULL));
- tp_base_contact_list_mixin_register_with_contacts_mixin (
- TP_BASE_CONTACT_LIST (self->contact_list), base_conn);
- haze_connection_aliasing_init (object);
- haze_connection_avatars_init (object);
- haze_connection_capabilities_init (object);
haze_connection_presence_init (object);
haze_connection_mail_init (object);
@@ -803,7 +790,6 @@ haze_connection_finalize (GObject *object)
HazeConnection *self = HAZE_CONNECTION (object);
HazeConnectionPrivate *priv = self->priv;
- tp_contacts_mixin_finalize (object);
tp_presence_mixin_finalize (object);
g_strfreev (self->acceptable_avatar_mime_types);
@@ -820,6 +806,39 @@ haze_connection_finalize (GObject *object)
}
static void
+haze_connection_fill_contact_attributes (TpBaseConnection *base,
+ const gchar *dbus_interface,
+ TpHandle handle,
+ TpContactAttributeMap *attributes)
+{
+ HazeConnection *self = HAZE_CONNECTION (base);
+
+ if (haze_connection_aliasing_fill_contact_attributes (self,
+ dbus_interface, handle, attributes))
+ return;
+
+ if (haze_connection_avatars_fill_contact_attributes (self,
+ dbus_interface, handle, attributes))
+ return;
+
+ if (haze_connection_contact_capabilities_fill_contact_attributes (self,
+ dbus_interface, handle, attributes))
+ return;
+
+ if (tp_base_contact_list_fill_contact_attributes (
+ TP_BASE_CONTACT_LIST (self->contact_list),
+ dbus_interface, handle, attributes))
+ return;
+
+ if (tp_presence_mixin_fill_contact_attributes ((GObject *) self,
+ dbus_interface, handle, attributes))
+ return;
+
+ TP_BASE_CONNECTION_CLASS (haze_connection_parent_class)->
+ fill_contact_attributes (base, dbus_interface, handle, attributes);
+}
+
+static void
haze_connection_class_init (HazeConnectionClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -867,6 +886,8 @@ haze_connection_class_init (HazeConnectionClass *klass)
base_class->shut_down = _haze_connection_shut_down;
base_class->get_interfaces_always_present =
haze_connection_get_interfaces_always_present;
+ base_class->fill_contact_attributes =
+ haze_connection_fill_contact_attributes;
param_spec = g_param_spec_boxed ("parameters", "gchar * => GValue",
"Connection parameters (password, etc.)",
@@ -900,8 +921,6 @@ haze_connection_class_init (HazeConnectionClass *klass)
tp_dbus_properties_mixin_class_init (object_class,
G_STRUCT_OFFSET (HazeConnectionClass, properties_class));
- tp_contacts_mixin_class_init (object_class,
- G_STRUCT_OFFSET (HazeConnectionClass, contacts_class));
tp_base_contact_list_mixin_class_init (base_class);
haze_connection_presence_class_init (object_class);
diff --git a/src/connection.h b/src/connection.h
index 0eef922..2046add 100644
--- a/src/connection.h
+++ b/src/connection.h
@@ -39,7 +39,6 @@ typedef struct _HazeConnectionClass HazeConnectionClass;
struct _HazeConnectionClass {
TpBaseConnectionClass parent_class;
TpDBusPropertiesMixinClass properties_class;
- TpContactsMixinClass contacts_class;
TpPresenceMixinClass presence_class;
};
@@ -52,7 +51,6 @@ struct _HazeConnection {
HazeImChannelFactory *im_factory;
TpSimplePasswordManager *password_manager;
- TpContactsMixin contacts;
TpPresenceMixin presence;
gchar **acceptable_avatar_mime_types;