+
+static void
+update_account_send_mail (UpdateAccountInfo *info)
+{
+ TnyTransportAccount *transport_account = NULL;
+
+ /* Get the transport account */
+ transport_account = (TnyTransportAccount *)
+ modest_tny_account_store_get_transport_account_for_open_connection (modest_runtime_get_account_store(),
+ info->account_name);
+
+ if (transport_account) {
+ ModestTnySendQueue *send_queue;
+ TnyFolder *outbox;
+ guint num_messages;
+
+ send_queue = modest_runtime_get_send_queue (transport_account, TRUE);
+ g_object_unref (transport_account);
+
+ if (TNY_IS_SEND_QUEUE (send_queue)) {
+ /* Get outbox folder */
+ outbox = tny_send_queue_get_outbox (TNY_SEND_QUEUE (send_queue));
+ if (outbox) { /* this could fail in some cases */
+ num_messages = tny_folder_get_all_count (outbox);
+ g_object_unref (outbox);
+ } else {
+ g_warning ("%s: could not get outbox", __FUNCTION__);
+ num_messages = 0;
+ }
+
+ if (num_messages != 0) {
+ /* Reenable suspended items */
+ modest_tny_send_queue_wakeup (MODEST_TNY_SEND_QUEUE (send_queue));
+
+ /* Try to send */
+ tny_camel_send_queue_flush (TNY_CAMEL_SEND_QUEUE (send_queue));
+ modest_tny_send_queue_set_requested_send_receive (MODEST_TNY_SEND_QUEUE (send_queue),
+ info->interactive);
+ }
+ }
+ }
+}
+