+ priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
+ priv->account = TNY_ACCOUNT (tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE (queue)));
+ priv->op_type = MODEST_MAIL_OPERATION_TYPE_RUN_QUEUE;
+
+ /* Create the helper */
+ helper = g_slice_new0 (RunQueueHelper);
+ helper->queue = g_object_ref (queue);
+ helper->self = g_object_ref (self);
+ helper->stop_handler = g_signal_connect (queue, "queue-stop",
+ G_CALLBACK (run_queue_stop),
+ helper);
+
+ /* Notify operation has started */
+ modest_mail_operation_notify_start (self);
+ g_debug ("%s, run queue started", __FUNCTION__);
+}
+
+static void
+queue_wakeup_callback (ModestTnySendQueue *queue,
+ gboolean cancelled,
+ GError *error,
+ gpointer userdata)
+{
+ ModestMailOperation *mail_op;
+ ModestMailOperationPrivate *priv;
+
+ mail_op = (ModestMailOperation *) userdata;
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE (mail_op);
+
+ priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
+ tny_camel_send_queue_flush (TNY_CAMEL_SEND_QUEUE (queue));
+
+ /* Notify end */
+ modest_mail_operation_notify_end (mail_op);
+ g_object_unref (mail_op);
+}
+
+void
+modest_mail_operation_queue_wakeup (ModestMailOperation *self,
+ ModestTnySendQueue *queue)
+{
+ ModestMailOperationPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_MAIL_OPERATION (self));
+ g_return_if_fail (MODEST_IS_TNY_SEND_QUEUE (queue));
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
+
+ priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
+ priv->account = TNY_ACCOUNT (tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE (queue)));
+ priv->op_type = MODEST_MAIL_OPERATION_TYPE_QUEUE_WAKEUP;
+
+ g_object_ref (self);
+
+ modest_tny_send_queue_wakeup (queue, queue_wakeup_callback, self);
+ modest_mail_operation_notify_start (self);
+}
+
+static void
+shutdown_callback (ModestTnyAccountStore *account_store, gpointer userdata)
+{
+ ModestMailOperation *self = (ModestMailOperation *) userdata;
+ ModestMailOperationPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_MAIL_OPERATION (self));
+ g_return_if_fail (MODEST_IS_TNY_ACCOUNT_STORE (account_store));
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
+