[Telepathy-commits] [telepathy-sofiasip/master] Respond 200 OK for pending messages auto-acked with ListPendingMessages(True)

Mikhail Zabaluev mikhail.zabaluev at nokia.com
Fri Oct 24 10:53:35 PDT 2008


Also, don't leak the pending message data in this case.
Tests expect the 200 responses after ListPendingMessages(True).
---
 src/sip-text-channel.c        |   24 ++++++++++++++++++------
 tests/twisted/test-message.py |    7 +++++++
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/sip-text-channel.c b/src/sip-text-channel.c
index 07d7b21..b19ea7a 100644
--- a/src/sip-text-channel.c
+++ b/src/sip-text-channel.c
@@ -147,6 +147,15 @@ static void tpsip_text_pending_free (TpsipTextPendingMessage *msg,
   g_slice_free (TpsipTextPendingMessage, msg);
 }
 
+static inline void
+tpsip_text_pending_respond (TpsipTextPendingMessage *msg)
+{
+  nua_respond (msg->nh,
+               SIP_200_OK,
+               NUTAG_WITH_SAVED(msg->saved_event),
+               TAG_END());
+}
+
 static void
 tpsip_text_channel_init (TpsipTextChannel *obj)
 {
@@ -551,10 +560,7 @@ tpsip_text_channel_acknowledge_pending_messages(TpSvcChannelTypeText *iface,
 
       g_queue_remove (priv->pending_messages, msg);
 
-      nua_respond (msg->nh,
-                   SIP_200_OK,
-                   NUTAG_WITH_SAVED(msg->saved_event),
-                   TAG_END());
+      tpsip_text_pending_respond (msg);
 
       tpsip_text_pending_free (msg, contact_repo);
     }
@@ -734,9 +740,15 @@ tpsip_text_channel_list_pending_messages(TpSvcChannelTypeText *iface,
 
   if (clear)
     {
+      TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
+          (TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
       while ((cur = g_queue_pop_head_link (priv->pending_messages)) != NULL)
-        tpsip_pending_message_list_add (messages,
-                                        (TpsipTextPendingMessage *) cur->data);
+        {
+          TpsipTextPendingMessage * msg = (TpsipTextPendingMessage *) cur->data;
+          tpsip_pending_message_list_add (messages, msg);
+          tpsip_text_pending_respond (msg);
+          tpsip_text_pending_free (msg, contact_repo);
+        }
     }
   else
     {
diff --git a/tests/twisted/test-message.py b/tests/twisted/test-message.py
index 170b8cd..d22c3ef 100644
--- a/tests/twisted/test-message.py
+++ b/tests/twisted/test-message.py
@@ -156,9 +156,16 @@ def test(q, bus, conn, sip):
 
     iface = dbus.Interface(requested_obj, TEXT_TYPE)
 
+    pending_res = iface.ListPendingMessages(False)
+    assert pending_msgs == pending_res, (pending_msgs, unwrap(pending_res))
+
     pending_res = iface.ListPendingMessages(True)
     assert pending_msgs == pending_res, (pending_msgs, unwrap(pending_res))
 
+    # TODO: match the CSeq
+    q.expect('sip-response', code=200)
+    q.expect('sip-response', code=200)
+
     # There should be no pending messages any more
     pending_res = iface.ListPendingMessages(False)
     assert pending_res == [], pending_res
-- 
1.5.6.5




More information about the Telepathy-commits mailing list