[Telepathy-commits] [telepathy-glib/master] Add tp_text_mixin_receive_with_flags
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Oct 30 11:31:21 PDT 2008
This lets us signal that we have received messages with special flags
(MUC scrollback is the only useful one at the moment).
---
docs/reference/telepathy-glib-sections.txt | 1 +
examples/cm/echo/chan.c | 5 ++-
telepathy-glib/text-mixin.c | 41 +++++++++++++++++++++++----
telepathy-glib/text-mixin.h | 3 ++
4 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index da02be6..514baf9 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -1521,6 +1521,7 @@ tp_text_mixin_class_init
tp_text_mixin_init
tp_text_mixin_set_message_types
tp_text_mixin_finalize
+tp_text_mixin_receive_with_flags
tp_text_mixin_receive
tp_text_mixin_acknowledge_pending_messages
tp_text_mixin_list_pending_messages
diff --git a/examples/cm/echo/chan.c b/examples/cm/echo/chan.c
index aa96148..92d98b2 100644
--- a/examples/cm/echo/chan.c
+++ b/examples/cm/echo/chan.c
@@ -467,8 +467,9 @@ text_send (TpSvcChannelTypeText *iface,
/* Tell the client that the message was submitted for sending */
tp_svc_channel_type_text_emit_sent ((GObject *) self, timestamp, type, text);
- /* Pretend that the remote contact has replied. Normally,
- * you'd call tp_text_mixin_receive in response to network events */
+ /* Pretend that the remote contact has replied. Normally, you'd
+ * call tp_text_mixin_receive or tp_text_mixin_receive_with_flags
+ * in response to network events */
switch (type)
{
diff --git a/telepathy-glib/text-mixin.c b/telepathy-glib/text-mixin.c
index 50ad778..2fbd832 100644
--- a/telepathy-glib/text-mixin.c
+++ b/telepathy-glib/text-mixin.c
@@ -267,12 +267,13 @@ tp_text_mixin_finalize (GObject *obj)
}
/**
- * tp_text_mixin_receive:
+ * tp_text_mixin_receive_with_flags:
* @obj: An object with the text mixin
* @type: The type of message received from the underlying protocol
* @sender: The handle of the message sender
* @timestamp: The time the message was received
* @text: The text of the message
+ * @flags: the message's flags
*
* Add a message to the pending queue and emit Received.
*
@@ -280,11 +281,12 @@ tp_text_mixin_finalize (GObject *obj)
* limit.
*/
gboolean
-tp_text_mixin_receive (GObject *obj,
- TpChannelTextMessageType type,
- TpHandle sender,
- time_t timestamp,
- const char *text)
+tp_text_mixin_receive_with_flags (GObject *obj,
+ TpChannelTextMessageType type,
+ TpHandle sender,
+ time_t timestamp,
+ const char *text,
+ TpChannelTextMessageFlags flags)
{
TpTextMixin *mixin = TP_TEXT_MIXIN (obj);
_PendingMessage *msg;
@@ -298,6 +300,7 @@ tp_text_mixin_receive (GObject *obj,
msg->id = mixin->priv->recv_id++;
msg->timestamp = timestamp;
msg->type = type;
+ msg->flags = flags;
len = strlen (text);
msg->text = g_try_malloc (len + 1);
@@ -336,6 +339,32 @@ tp_text_mixin_receive (GObject *obj,
return TRUE;
}
+
+/**
+ * tp_text_mixin_receive:
+ * @obj: An object with the text mixin
+ * @type: The type of message received from the underlying protocol
+ * @sender: The handle of the message sender
+ * @timestamp: The time the message was received
+ * @text: The text of the message
+ *
+ * Add a message to the pending queue and emit Received. Exactly equivalent
+ * to tp_text_mixin_receive_with_flags() with @flags == 0.
+ *
+ * Returns: %TRUE on success; %FALSE if the message was lost due to the memory
+ * limit.
+ */
+gboolean
+tp_text_mixin_receive (GObject *obj,
+ TpChannelTextMessageType type,
+ TpHandle sender,
+ time_t timestamp,
+ const char *text)
+{
+ return tp_text_mixin_receive_with_flags (obj, type, sender, timestamp, text,
+ 0);
+}
+
static gint
compare_pending_message (gconstpointer haystack,
gconstpointer needle)
diff --git a/telepathy-glib/text-mixin.h b/telepathy-glib/text-mixin.h
index 0c2c6ef..60f2552 100644
--- a/telepathy-glib/text-mixin.h
+++ b/telepathy-glib/text-mixin.h
@@ -87,6 +87,9 @@ void tp_text_mixin_init (GObject *obj, glong offset,
void tp_text_mixin_set_message_types (GObject *obj, ...);
void tp_text_mixin_finalize (GObject *obj);
+gboolean tp_text_mixin_receive_with_flags (GObject *obj,
+ TpChannelTextMessageType type, TpHandle sender, time_t timestamp,
+ const char *text, TpChannelTextMessageFlags flags);
gboolean tp_text_mixin_receive (GObject *obj, TpChannelTextMessageType type,
TpHandle sender, time_t timestamp, const char *text);
gboolean tp_text_mixin_acknowledge_pending_messages (GObject *obj,
--
1.5.6.5
More information about the Telepathy-commits
mailing list