From 35fb5624bbedf36e88c1ccf099bdc75955b2d234 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 6 Jul 2011 14:05:22 +0200 Subject: [PATCH] Add tp_message_get_pending_message_id() We use to say that this wasn't needed because TpTextChannel is already doing the ID -> TpMessage lookup but at least the logger and Empathy need it so it's probably worth it. https://bugs.freedesktop.org/show_bug.cgi?id=39000 --- docs/reference/telepathy-glib-sections.txt | 1 + telepathy-glib/message.c | 25 +++++++++++++++++++++++-- telepathy-glib/message.h | 2 ++ tests/dbus/cm-message.c | 4 ++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index a04315c..3ac39dc 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -2291,6 +2291,7 @@ tp_message_get_token tp_message_is_delivery_report tp_message_is_rescued tp_message_is_scrollback +tp_message_get_pending_message_id tp_message_is_mutable tp_message_append_part diff --git a/telepathy-glib/message.c b/telepathy-glib/message.c index 18508f4..9f0a2d6 100644 --- a/telepathy-glib/message.c +++ b/telepathy-glib/message.c @@ -1048,13 +1048,34 @@ tp_message_is_delivery_report (TpMessage *self) return valid; } +/** + * tp_message_get_pending_message_id: + * @self: a message + * @valid: (out): either %NULL, or a location in which to store %TRUE if @self + * contains a pending message ID. + * + * Return the incoming message ID of @self. Only incoming messages have such + * ID, for outgoing ones this function returns 0 and set @valid to %FALSE. + * + * Returns: the incoming message ID. + * + * Since: 0.15.UNRELEASED + */ +guint32 +tp_message_get_pending_message_id (TpMessage *self, + gboolean *valid) +{ + g_return_val_if_fail (TP_IS_MESSAGE (self), FALSE); + + return tp_asv_get_uint32 (tp_message_peek (self, 0), + "pending-message-id", valid); +} + /* * Omitted for now: * * sender-nickname - perhaps better done in TpSignalledMessage, so we can use * the TpContact's nickname if the message doesn't specify? * - * pending-message-id - special-purpose, should be encapsulated - * * delivery reporting stuff other than "is this a report?" - later */ diff --git a/telepathy-glib/message.h b/telepathy-glib/message.h index ca590d9..395522f 100644 --- a/telepathy-glib/message.h +++ b/telepathy-glib/message.h @@ -95,6 +95,8 @@ gboolean tp_message_is_rescued (TpMessage *self); const gchar *tp_message_get_supersedes (TpMessage *self); const gchar *tp_message_get_specific_to_interface (TpMessage *self); gboolean tp_message_is_delivery_report (TpMessage *self); +guint32 tp_message_get_pending_message_id (TpMessage *self, + gboolean *valid); G_END_DECLS diff --git a/tests/dbus/cm-message.c b/tests/dbus/cm-message.c index 39e6549..be277ef 100644 --- a/tests/dbus/cm-message.c +++ b/tests/dbus/cm-message.c @@ -49,6 +49,7 @@ test_new_from_parts (Test *test, TpHandle sender; TpMessage *msg; const GHashTable *part; + gboolean valid; parts = g_ptr_array_sized_new (2); g_ptr_array_set_free_func (parts, (GDestroyNotify) g_hash_table_unref); @@ -63,6 +64,7 @@ test_new_from_parts (Test *test, "message-sent", G_TYPE_INT64, G_GINT64_CONSTANT (42), "message-received", G_TYPE_INT64, G_GINT64_CONSTANT (666), "scrollback", G_TYPE_BOOLEAN, TRUE, + "pending-message-id", G_TYPE_UINT, 666, NULL)); g_ptr_array_add (parts, tp_asv_new ( @@ -102,6 +104,8 @@ test_new_from_parts (Test *test, g_assert_cmpstr (tp_message_get_supersedes (msg), ==, NULL); g_assert_cmpstr (tp_message_get_specific_to_interface (msg), ==, NULL); g_assert_cmpint (tp_message_is_delivery_report (msg), ==, FALSE); + g_assert_cmpuint (tp_message_get_pending_message_id (msg, &valid), ==, 666); + g_assert (valid); g_object_unref (msg); } -- 1.7.4.1