diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2008-07-24 17:21:26 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2008-07-24 17:21:26 +0000 |
commit | e7b2a82c37bf87daa711dcf472f21e827aa12122 (patch) | |
tree | 6d72f88e76720a8cacaa339567b33802559401f9 /telepathy-glib/text-mixin.c | |
parent | 7cbd82a8a67d1295a1db0498d6c55ff7593631ef (diff) | |
download | telepathy-glib-e7b2a82c37bf87daa711dcf472f21e827aa12122.tar.gz |
Add tp_text_mixin_has_pending_messages
The proposal of "closed text channels are resurrected if they still have
incoming messages" is much easier to implement if we do this - it's possible
to use tp_text_mixin_list_pending_messages(), but that does wasteful copying.
The idea of returning the first sender handle is that callers can use it
as the initiator of the resurrected channel.
20080724172126-53eee-2562dd209968bb4508582101b89be3db37d178b9.gz
Diffstat (limited to 'telepathy-glib/text-mixin.c')
-rw-r--r-- | telepathy-glib/text-mixin.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/telepathy-glib/text-mixin.c b/telepathy-glib/text-mixin.c index c45be5106..6cd6b72c9 100644 --- a/telepathy-glib/text-mixin.c +++ b/telepathy-glib/text-mixin.c @@ -577,6 +577,33 @@ tp_text_mixin_clear (GObject *obj) } /** + * tp_text_mixin_has_pending_messages: + * @obj: An object with this mixin + * @first_sender: If not %NULL, used to store the sender of the oldest pending + * message + * + * Return whether the channel @obj has unacknowledged messages. If so, and + * @first_sender is not %NULL, the handle of the sender of the first message + * is placed in it, without incrementing the handle's reference count. + * + * Returns: %TRUE if there are pending messages + */ +gboolean +tp_text_mixin_has_pending_messages (GObject *obj, + TpHandle *first_sender) +{ + TpTextMixin *mixin = TP_TEXT_MIXIN (obj); + _PendingMessage *msg = g_queue_peek_head (mixin->priv->pending); + + if (msg != NULL && first_sender != NULL) + { + *first_sender = msg->sender; + } + + return (msg != NULL); +} + +/** * tp_text_mixin_iface_init: * @g_iface: A pointer to the #TpSvcChannelTypeTextClass in an object class * @iface_data: Ignored |