[Telepathy-commits] [telepathy-glib/master] ContactsConnection: claim to support Contacts, and add a subclass that doesn't
Simon McVittie
simon.mcvittie at collabora.co.uk
Fri Oct 31 10:11:57 PDT 2008
The subclass is so we can still test the fallback path through multiple
calls in TpContact, when TpContact has been upgraded to support the fast
path through Contacts.
---
tests/lib/contacts-conn.c | 30 ++++++++++++++++++++++++++++++
tests/lib/contacts-conn.h | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/tests/lib/contacts-conn.c b/tests/lib/contacts-conn.c
index afb8359..725db20 100644
--- a/tests/lib/contacts-conn.c
+++ b/tests/lib/contacts-conn.c
@@ -256,6 +256,7 @@ contacts_connection_class_init (ContactsConnectionClass *klass)
static const gchar *interfaces_always_present[] = {
TP_IFACE_CONNECTION_INTERFACE_ALIASING,
TP_IFACE_CONNECTION_INTERFACE_AVATARS,
+ TP_IFACE_CONNECTION_INTERFACE_CONTACTS,
TP_IFACE_CONNECTION_INTERFACE_PRESENCE,
TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE,
NULL };
@@ -598,3 +599,32 @@ init_avatars (gpointer g_iface,
/* IMPLEMENT(clear_avatar); */
#undef IMPLEMENT
}
+
+
+/* =============== Legacy version (no Contacts interface) ================= */
+
+
+G_DEFINE_TYPE (LegacyContactsConnection, legacy_contacts_connection,
+ CONTACTS_TYPE_CONNECTION);
+
+static void
+legacy_contacts_connection_init (LegacyContactsConnection *self)
+{
+}
+
+static void
+legacy_contacts_connection_class_init (LegacyContactsConnectionClass *klass)
+{
+ /* Leave Contacts out of the interfaces we say are present, so clients
+ * won't use it */
+ static const gchar *interfaces_always_present[] = {
+ TP_IFACE_CONNECTION_INTERFACE_ALIASING,
+ TP_IFACE_CONNECTION_INTERFACE_AVATARS,
+ TP_IFACE_CONNECTION_INTERFACE_PRESENCE,
+ TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE,
+ NULL };
+ TpBaseConnectionClass *base_class =
+ (TpBaseConnectionClass *) klass;
+
+ base_class->interfaces_always_present = interfaces_always_present;
+}
diff --git a/tests/lib/contacts-conn.h b/tests/lib/contacts-conn.h
index e61ad54..a057b1d 100644
--- a/tests/lib/contacts-conn.h
+++ b/tests/lib/contacts-conn.h
@@ -81,6 +81,42 @@ void contacts_connection_change_presences (ContactsConnection *self, guint n,
void contacts_connection_change_avatar_tokens (ContactsConnection *self,
guint n, const TpHandle *handles, const gchar * const *tokens);
+/* Legacy version (no Contacts interface) */
+
+typedef struct _LegacyContactsConnection LegacyContactsConnection;
+typedef struct _LegacyContactsConnectionClass LegacyContactsConnectionClass;
+typedef struct _LegacyContactsConnectionPrivate
+ LegacyContactsConnectionPrivate;
+
+struct _LegacyContactsConnectionClass {
+ ContactsConnectionClass parent_class;
+};
+
+struct _LegacyContactsConnection {
+ ContactsConnection parent;
+
+ LegacyContactsConnectionPrivate *priv;
+};
+
+GType legacy_contacts_connection_get_type (void);
+
+/* TYPE MACROS */
+#define LEGACY_CONTACTS_TYPE_CONNECTION \
+ (legacy_contacts_connection_get_type ())
+#define LEGACY_CONTACTS_CONNECTION(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), LEGACY_CONTACTS_TYPE_CONNECTION, \
+ LegacyContactsConnection))
+#define LEGACY_CONTACTS_CONNECTION_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), LEGACY_CONTACTS_TYPE_CONNECTION, \
+ LegacyContactsConnectionClass))
+#define LEGACY_CONTACTS_IS_CONNECTION(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), LEGACY_CONTACTS_TYPE_CONNECTION))
+#define LEGACY_CONTACTS_IS_CONNECTION_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), LEGACY_CONTACTS_TYPE_CONNECTION))
+#define LEGACY_CONTACTS_CONNECTION_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), LEGACY_CONTACTS_TYPE_CONNECTION, \
+ LegacyContactsConnectionClass))
+
G_END_DECLS
#endif
--
1.5.6.5
More information about the Telepathy-commits
mailing list