Fixes NB#125835, added modest_utils_flush_send_queue API.
authorSergio Villar Senin <svillar@igalia.com>
Tue, 30 Jun 2009 16:45:31 +0000 (18:45 +0200)
committerSergio Villar Senin <svillar@igalia.com>
Tue, 30 Jun 2009 17:10:49 +0000 (19:10 +0200)
Allows plugins to request flushes of their send queues

src/modest-utils.c
src/modest-utils.h

index aac37ef..019504c 100644 (file)
@@ -36,6 +36,7 @@
 #include <tny-fs-stream.h>
 #include <tny-camel-account.h>
 #include <tny-status.h>
 #include <tny-fs-stream.h>
 #include <tny-camel-account.h>
 #include <tny-status.h>
+#include <tny-camel-send-queue.h>
 #include <tny-camel-transport-account.h>
 #include <tny-camel-imap-store-account.h>
 #include <tny-camel-pop-store-account.h>
 #include <tny-camel-transport-account.h>
 #include <tny-camel-imap-store-account.h>
 #include <tny-camel-pop-store-account.h>
@@ -1140,3 +1141,24 @@ modest_utils_free_notification_list (GList *notification_list)
        g_list_foreach (notification_list, free_notification_data, NULL);
        g_list_free (notification_list);
 }
        g_list_foreach (notification_list, free_notification_data, NULL);
        g_list_free (notification_list);
 }
+
+void
+modest_utils_flush_send_queue (const gchar *account_id)
+{
+       TnyTransportAccount *account;
+
+       /* Get the transport account */
+       account = (TnyTransportAccount *)
+               modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store (),
+                                                            MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
+                                                            account_id);
+
+       if (account) {
+               ModestTnySendQueue *send_queue = modest_runtime_get_send_queue (account, TRUE);
+
+               /* Flush it! */
+               tny_camel_send_queue_flush ((TnyCamelSendQueue *) send_queue);
+
+               g_object_unref (account);
+       }
+}
index 393f869..0d25831 100644 (file)
@@ -253,4 +253,14 @@ GList *modest_utils_create_notification_list_from_header_list (TnyList *header_l
  * Frees a list of #ModestMsgNotificationData structures
  **/
 void  modest_utils_free_notification_list (GList *notification_list);
  * Frees a list of #ModestMsgNotificationData structures
  **/
 void  modest_utils_free_notification_list (GList *notification_list);
+
+/**
+ * modest_utils_flush_send_queue:
+ * @account_id: the ID of the modest account
+ *
+ * Flushes the send queue of the given account. That will try to send
+ * all the remaining messages in the send queue
+ **/
+void  modest_utils_flush_send_queue (const gchar *account_id);
+
 #endif /*__MODEST_MAEMO_UTILS_H__*/
 #endif /*__MODEST_MAEMO_UTILS_H__*/