summaryrefslogtreecommitdiff
path: root/telepathy-glib/text-channel.c
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-03-02 11:56:52 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-03-02 15:05:58 +0100
commit1c5bee114d5bc1dcd3fd065ae97e8af3c8f36fe9 (patch)
treec2aa3ae650fdaf28d45f9de968f2fd7a37c3aad2 /telepathy-glib/text-channel.c
parentbabb92e35f2f7638d8fe132aa209762cf3a8faf0 (diff)
downloadtelepathy-glib-1c5bee114d5bc1dcd3fd065ae97e8af3c8f36fe9.tar.gz
text-channel: add a message-types property and accessor (#34907)
Diffstat (limited to 'telepathy-glib/text-channel.c')
-rw-r--r--telepathy-glib/text-channel.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/telepathy-glib/text-channel.c b/telepathy-glib/text-channel.c
index bd0a54d8d..0d690a96f 100644
--- a/telepathy-glib/text-channel.c
+++ b/telepathy-glib/text-channel.c
@@ -75,6 +75,7 @@ struct _TpTextChannelPrivate
GStrv supported_content_types;
TpMessagePartSupportFlags message_part_support_flags;
TpDeliveryReportingSupportFlags delivery_reporting_support;
+ GArray *message_types;
/* queue of owned TpSignalledMessage */
GQueue *pending_messages;
@@ -85,7 +86,8 @@ enum
{
PROP_SUPPORTED_CONTENT_TYPES = 1,
PROP_MESSAGE_PART_SUPPORT_FLAGS,
- PROP_DELIVERY_REPORTING_SUPPORT
+ PROP_DELIVERY_REPORTING_SUPPORT,
+ PROP_MESSAGE_TYPES,
};
enum /* signals */
@@ -104,6 +106,7 @@ tp_text_channel_dispose (GObject *obj)
TpTextChannel *self = (TpTextChannel *) obj;
tp_clear_pointer (&self->priv->supported_content_types, g_strfreev);
+ tp_clear_pointer (&self->priv->message_types, g_array_unref);
g_queue_foreach (self->priv->pending_messages, (GFunc) g_object_unref, NULL);
tp_clear_pointer (&self->priv->pending_messages, g_queue_free);
@@ -136,6 +139,11 @@ tp_text_channel_get_property (GObject *object,
tp_text_channel_get_delivery_reporting_support (self));
break;
+ case PROP_MESSAGE_TYPES:
+ g_value_set_boxed (value,
+ tp_text_channel_get_message_types (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -302,6 +310,22 @@ tp_text_channel_constructed (GObject *obj)
"immutable properties");
}
+ self->priv->message_types = tp_asv_get_boxed (props,
+ TP_PROP_CHANNEL_INTERFACE_MESSAGES_MESSAGE_TYPES, DBUS_TYPE_G_UINT_ARRAY);
+ if (self->priv->message_types != NULL)
+ {
+ self->priv->message_types = g_boxed_copy (DBUS_TYPE_G_UINT_ARRAY,
+ self->priv->message_types);
+ }
+ else
+ {
+ self->priv->message_types = g_array_new (FALSE, FALSE,
+ sizeof (TpChannelTextMessageType));
+
+ DEBUG ("Channel doesn't have Messages.MessageTypes in its "
+ "immutable properties");
+ }
+
tp_cli_channel_interface_messages_connect_to_message_sent (chan,
message_sent_cb, NULL, NULL, NULL, &err);
if (err != NULL)
@@ -873,6 +897,22 @@ tp_text_channel_class_init (TpTextChannelClass *klass)
PROP_DELIVERY_REPORTING_SUPPORT, param_spec);
/**
+ * TpTextChannel:message-types:
+ *
+ * A #GArray containing the #TpChannelTextMessageType which may be sent on
+ * this channel.
+ *
+ * Since: 0.13.UNRELEASED
+ */
+ param_spec = g_param_spec_boxed ("message-types",
+ "MessageTypes",
+ "The Messages.MessageTypes property of the channel",
+ DBUS_TYPE_G_UINT_ARRAY,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (gobject_class,
+ PROP_MESSAGE_TYPES, param_spec);
+
+ /**
* TpTextChannel::message-received
* @self: the #TpTextChannel
* @message: a #TpSignalledMessage
@@ -1429,3 +1469,23 @@ tp_text_channel_set_chat_state_finish (TpTextChannel *self,
{
_tp_implement_finish_void (self, tp_text_channel_set_chat_state_finish)
}
+
+/**
+ * tp_text_channel_get_message_types: (skip)
+ * @self: a #TpTextChannel
+ *
+ * Return the #TpTextChannel:message-types property
+ *
+ * Returns: (transfer none) (element-type TelepathyGLib.ChannelTextMessageType):
+ * the value of #TpTextChannel:message-types
+ *
+ * Since: 0.13.UNRELEASED
+ */
+GArray *
+tp_text_channel_get_message_types (TpTextChannel *self)
+{
+ g_return_val_if_fail (TP_IS_TEXT_CHANNEL (self), NULL);
+
+ return self->priv->message_types;
+}
+