diff options
author | <robert.mcqueen@collabora.co.uk> | 2006-01-19 06:11:59 +0000 |
---|---|---|
committer | <robert.mcqueen@collabora.co.uk> | 2006-01-19 06:11:59 +0000 |
commit | e36acfef2a00081e2cc667544b7f890976847414 (patch) | |
tree | 5f3b18321aeb061e58d9e3a9378fec76b3ab1c1c | |
parent | fc3b4773f01f17abd566d0f6e012a809e510a48b (diff) |
list pending messages in IM channel
-rw-r--r-- | src/gabble-im-channel.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/gabble-im-channel.c b/src/gabble-im-channel.c index 076d3d91c..782524270 100644 --- a/src/gabble-im-channel.c +++ b/src/gabble-im-channel.c @@ -539,6 +539,53 @@ gboolean gabble_im_channel_get_interfaces (GabbleIMChannel *obj, gchar *** ret, */ gboolean gabble_im_channel_list_pending_messages (GabbleIMChannel *obj, GPtrArray ** ret, GError **error) { + GabbleIMChannelPrivate *priv; + guint count; + GPtrArray *messages; + GList *cur; + + g_assert (GABBLE_IS_IM_CHANNEL (obj)); + + priv = GABBLE_IM_CHANNEL_GET_PRIVATE (obj); + + count = g_queue_get_length (priv->pending_messages); + messages = g_ptr_array_sized_new (count); + dbus_g_collection_set_signature (messages, "(uuuus)"); + + for (cur = g_queue_peek_head_link(priv->pending_messages); + cur != NULL; + cur = cur->next) + { + GabbleIMPendingMessage *msg = (GabbleIMPendingMessage *) cur->data; + GValueArray *vals; + + vals = g_value_array_new (5); + + g_value_array_append (vals, NULL); + g_value_init (g_value_array_get_nth (vals, 0), G_TYPE_UINT); + g_value_set_uint (g_value_array_get_nth (vals, 0), msg->id); + + g_value_array_append (vals, NULL); + g_value_init (g_value_array_get_nth (vals, 1), G_TYPE_UINT); + g_value_set_uint (g_value_array_get_nth (vals, 1), msg->timestamp); + + g_value_array_append (vals, NULL); + g_value_init (g_value_array_get_nth (vals, 2), G_TYPE_UINT); + g_value_set_uint (g_value_array_get_nth (vals, 2), msg->sender); + + g_value_array_append (vals, NULL); + g_value_init (g_value_array_get_nth (vals, 3), G_TYPE_UINT); + g_value_set_uint (g_value_array_get_nth (vals, 3), msg->type); + + g_value_array_append (vals, NULL); + g_value_init (g_value_array_get_nth (vals, 4), G_TYPE_STRING); + g_value_set_string (g_value_array_get_nth (vals, 4), msg->text); + + g_ptr_array_add (messages, vals); + } + + *ret = messages; + return TRUE; } |