+
+ if (transport_account) {
+ ModestTnySendQueue *send_queue;
+ TnyFolder *outbox;
+ guint num_messages;
+
+ send_queue = modest_runtime_get_send_queue (transport_account);
+
+ /* Get outbox folder */
+ outbox = tny_send_queue_get_outbox (TNY_SEND_QUEUE (send_queue));
+ num_messages = tny_folder_get_all_count (outbox);
+ g_object_unref (outbox);
+
+ if (num_messages == 0) {
+ end_operation = TRUE;
+ } else {
+ UpdateAccountSendQueueFlushInfo *send_info;
+
+ end_operation = FALSE;
+ /* Send mails */
+ priv->done = 0;
+ priv->total = num_messages;
+ g_object_unref (priv->account);
+ priv->account = TNY_ACCOUNT (transport_account);
+
+ /* Create the info object */
+ send_info = g_slice_new (UpdateAccountSendQueueFlushInfo);
+ send_info->error_handler = g_signal_connect (send_queue, "error-happened",
+ G_CALLBACK (update_account_on_error_happened_cb),
+ send_info);
+ send_info->sent_handler = g_signal_connect (send_queue, "msg-sent",
+ G_CALLBACK (update_account_on_msg_sent_cb),
+ send_info);
+ send_info->mail_op = g_object_ref (info->mail_op);
+
+ /* 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));
+ }
+ } else {
+ end_operation = TRUE;
+ }