[Telepathy-commits] [telepathy-glib/master] Emit PendingMessagesRemoved when appropriate

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Dec 18 10:41:29 PST 2008


20080415193143-53eee-313e810698ebafc45175a91e5b120957eda2723c.gz
---
 telepathy-glib/message-mixin.c |   19 +++++++++++++------
 tests/dbus/message-mixin.c     |   28 ++++++++++++++--------------
 2 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/telepathy-glib/message-mixin.c b/telepathy-glib/message-mixin.c
index 4b3963c..f75598d 100644
--- a/telepathy-glib/message-mixin.c
+++ b/telepathy-glib/message-mixin.c
@@ -508,6 +508,9 @@ tp_message_mixin_acknowledge_pending_messages_async (
         }
     }
 
+  tp_svc_channel_interface_messages_emit_pending_messages_removed (iface,
+      ids);
+
   for (i = 0; i < ids->len; i++)
     {
       item = nodes[i]->data;
@@ -516,9 +519,6 @@ tp_message_mixin_acknowledge_pending_messages_async (
 
       g_queue_remove (mixin->priv->pending, item);
 
-      /* FIXME: need a hook here to send acknowledgements out on the network
-       * if the protocol requires it */
-
       pending_item_free (item, mixin->priv->contact_repo);
     }
 
@@ -572,22 +572,29 @@ tp_message_mixin_list_pending_messages_async (TpSvcChannelTypeText *iface,
 
   if (clear)
     {
+      GArray *ids;
+
       DEBUG ("WARNING: ListPendingMessages(clear=TRUE) is deprecated");
       cur = g_queue_peek_head_link (mixin->priv->pending);
 
+      ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), count);
+
       while (cur != NULL)
         {
           PendingItem *msg = cur->data;
           GList *next = cur->next;
 
-          /* FIXME: need a hook here to send acknowledgements out on the
-           * network if the protocol requires it */
-
+          i = msg->id;
+          g_array_append_val (ids, i);
           g_queue_delete_link (mixin->priv->pending, cur);
           pending_item_free (msg, mixin->priv->contact_repo);
 
           cur = next;
         }
+
+      tp_svc_channel_interface_messages_emit_pending_messages_removed (iface,
+          ids);
+      g_array_free (ids, TRUE);
     }
 
   tp_svc_channel_type_text_return_from_list_pending_messages (context,
diff --git a/tests/dbus/message-mixin.c b/tests/dbus/message-mixin.c
index 79e3dc6..f821762 100644
--- a/tests/dbus/message-mixin.c
+++ b/tests/dbus/message-mixin.c
@@ -279,8 +279,8 @@ main (int argc,
       TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, "Hello, world!",
       &error, NULL);
   /* wait for pending events to be delivered */
-  while (g_main_context_pending (NULL))
-    g_main_context_iteration (NULL, FALSE);
+  while (received_count < 1 || message_received_count < 1)
+    g_main_context_iteration (NULL, TRUE);
 
   MYASSERT_NO_ERROR (error);
   MYASSERT (sent_count == 1, ": %u != 1", sent_count);
@@ -319,8 +319,8 @@ main (int argc,
       TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION, "drinks coffee",
       &error, NULL);
   /* wait for pending events to be delivered */
-  while (g_main_context_pending (NULL))
-    g_main_context_iteration (NULL, FALSE);
+  while (received_count < 1 || message_received_count < 1)
+    g_main_context_iteration (NULL, TRUE);
 
   MYASSERT_NO_ERROR (error);
   MYASSERT (sent_count == 1, ": %u != 1", sent_count);
@@ -360,8 +360,8 @@ main (int argc,
       TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE, "Printer on fire",
       &error, NULL);
   /* wait for pending events to be delivered */
-  while (g_main_context_pending (NULL))
-    g_main_context_iteration (NULL, FALSE);
+  while (received_count < 1 || message_received_count < 1)
+    g_main_context_iteration (NULL, TRUE);
 
   MYASSERT_NO_ERROR (error);
   MYASSERT (sent_count == 1, ": %u != 1", sent_count);
@@ -452,8 +452,8 @@ main (int argc,
       MYASSERT_NO_ERROR (error);
 
       /* wait for pending events to be delivered */
-      while (g_main_context_pending (NULL))
-        g_main_context_iteration (NULL, FALSE);
+      while (received_count < 1 || message_received_count < 1)
+        g_main_context_iteration (NULL, TRUE);
 
       g_print ("Sent message, got token '%s'\n", token);
       g_free (token);
@@ -557,8 +557,8 @@ main (int argc,
       MYASSERT_NO_ERROR (error);
 
       /* wait for pending events to be delivered */
-      while (g_main_context_pending (NULL))
-        g_main_context_iteration (NULL, FALSE);
+      while (received_count < 1 || message_received_count < 1)
+        g_main_context_iteration (NULL, TRUE);
 
       g_print ("Sent message, got token '%s'\n", token);
       g_free (token);
@@ -647,8 +647,8 @@ main (int argc,
       MYASSERT_NO_ERROR (error);
 
       /* wait for pending events to be delivered */
-      while (g_main_context_pending (NULL))
-        g_main_context_iteration (NULL, FALSE);
+      while (received_count < 1 || message_received_count < 1)
+        g_main_context_iteration (NULL, TRUE);
 
       g_print ("Sent message, got token '%s'\n", token);
       g_free (token);
@@ -738,8 +738,8 @@ main (int argc,
       MYASSERT_NO_ERROR (error);
 
       /* wait for pending events to be delivered */
-      while (g_main_context_pending (NULL))
-        g_main_context_iteration (NULL, FALSE);
+      while (received_count < 1 || message_received_count < 1)
+        g_main_context_iteration (NULL, TRUE);
 
       g_print ("Sent message, got token '%s'\n", token);
       g_free (token);
-- 
1.5.6.5




More information about the Telepathy-commits mailing list