[next] telepathy-glib: Fix text channels using TpMessageMixin without ChatState

Xavier Claessens xclaesse at kemper.freedesktop.org
Wed May 9 13:10:55 PDT 2012


Module: telepathy-glib
Branch: next
Commit: 9098e91b0a0ef8f166024e73502977e11a041ff2
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=9098e91b0a0ef8f166024e73502977e11a041ff2

Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Wed May  9 22:08:04 2012 +0200

Fix text channels using TpMessageMixin without ChatState

---

 docs/reference/telepathy-glib-sections.txt |    1 +
 examples/cm/echo-message-parts/chan.c      |    1 +
 telepathy-glib/message-mixin.c             |   33 ++++++++++++++++++++++------
 telepathy-glib/message-mixin.h             |    2 +
 4 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 9ab85be..87917b1 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -2070,6 +2070,7 @@ tp_message_mixin_clear
 <SUBSECTION>
 TpMessageMixinSendChatStateImpl
 tp_message_mixin_chat_state_iface_init
+tp_message_mixin_chat_state_init_dbus_properties
 tp_message_mixin_change_chat_state
 tp_message_mixin_implement_send_chat_state
 tp_message_mixin_maybe_send_gone
diff --git a/examples/cm/echo-message-parts/chan.c b/examples/cm/echo-message-parts/chan.c
index 4732579..b030c86 100644
--- a/examples/cm/echo-message-parts/chan.c
+++ b/examples/cm/echo-message-parts/chan.c
@@ -359,6 +359,7 @@ example_echo_2_channel_class_init (ExampleEcho2ChannelClass *klass)
       sms_props);
 
   tp_message_mixin_init_dbus_properties (object_class);
+  tp_message_mixin_chat_state_init_dbus_properties (object_class);
 }
 
 static void
diff --git a/telepathy-glib/message-mixin.c b/telepathy-glib/message-mixin.c
index c46efdd..8cc3704 100644
--- a/telepathy-glib/message-mixin.c
+++ b/telepathy-glib/message-mixin.c
@@ -47,8 +47,11 @@
  * not, any attempt to send a message will fail with NotImplemented.
  *
  * To support chat state, you must call
- * tp_message_mixin_implement_send_chat_state() in the constructor function, and
- * include the following in the fourth argument of G_DEFINE_TYPE_WITH_CODE():
+ * tp_message_mixin_implement_send_chat_state() in the constructor function. In
+ * the class_init function, call
+ * tp_message_mixin_chat_state_init_dbus_properties() to hook this mixin into
+ * the D-Bus properties mixin class. Finally, include the following in the
+ * fourth argument of G_DEFINE_TYPE_WITH_CODE():
  *
  * <informalexample><programlisting>
  *  G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_CHAT_STATE,
@@ -965,21 +968,37 @@ tp_message_mixin_init_dbus_properties (GObjectClass *cls)
       { "DeliveryReportingSupport", NULL, NULL },
       { NULL }
   };
-  static TpDBusPropertiesMixinPropImpl chat_state_props[] = {
-      { "ChatStates", NULL, NULL },
-      { NULL }
-  };
 
   tp_dbus_properties_mixin_implement_interface (cls,
       TP_IFACE_QUARK_CHANNEL_TYPE_TEXT,
       tp_message_mixin_get_dbus_property, NULL, props);
+}
+
+/**
+ * tp_message_mixin_chat_state_init_dbus_properties:
+ * @cls: The class of an object with this mixin
+ *
+ * Set up a #TpDBusPropertiesMixinClass to use this mixin's implementation
+ * of the text channel interface's properties.
+ *
+ * This uses tp_message_mixin_get_dbus_property() as the property getter
+ * and sets a list of the supported properties for it.
+ *
+ * Since: 0.UNRELEASED
+ */
+void
+tp_message_mixin_chat_state_init_dbus_properties (GObjectClass *cls)
+{
+  static TpDBusPropertiesMixinPropImpl chat_state_props[] = {
+      { "ChatStates", NULL, NULL },
+      { NULL }
+  };
 
   tp_dbus_properties_mixin_implement_interface (cls,
       TP_IFACE_QUARK_CHANNEL_INTERFACE_CHAT_STATE,
       tp_message_mixin_get_dbus_property, NULL, chat_state_props);
 }
 
-
 /**
  * tp_message_mixin_get_dbus_property:
  * @object: An object with this mixin
diff --git a/telepathy-glib/message-mixin.h b/telepathy-glib/message-mixin.h
index 4696f4f..89532e9 100644
--- a/telepathy-glib/message-mixin.h
+++ b/telepathy-glib/message-mixin.h
@@ -89,6 +89,8 @@ void tp_message_mixin_maybe_send_gone (GObject *object);
 void tp_message_mixin_iface_init (gpointer g_iface, gpointer iface_data);
 void tp_message_mixin_chat_state_iface_init (gpointer g_iface,
     gpointer iface_data);
+_TP_AVAILABLE_IN_UNRELEASED
+void tp_message_mixin_chat_state_init_dbus_properties (GObjectClass *cls);
 
 void tp_message_mixin_init (GObject *obj, gsize offset,
     TpBaseConnection *connection);



More information about the telepathy-commits mailing list