+ ModestMailOperationPrivate *priv;
+
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE (msg_info->mail_op);
+ priv->done++;
+
+ if (TNY_IS_MSG (msg)) {
+ TnyHeader *header = tny_msg_get_header (msg);
+
+ if (header) {
+ ModestMailOperationState *state;
+ state = modest_mail_operation_clone_state (msg_info->mail_op);
+ msg_info->sum_total_bytes += tny_header_get_message_size (header);
+ state->bytes_done = msg_info->sum_total_bytes;
+ state->bytes_total = msg_info->total_bytes;
+
+ /* Notify the status change. Only notify about changes
+ referred to bytes */
+ g_signal_emit (G_OBJECT (msg_info->mail_op),
+ signals[PROGRESS_CHANGED_SIGNAL],
+ 0, state, NULL);
+
+ g_object_unref (header);
+ g_slice_free (ModestMailOperationState, state);
+ }
+ }
+
+ if (priv->done == priv->total) {
+ TnyList *new_headers;
+ UpdateAccountInfo *info;
+
+ /* After getting all the messages send the ones in the
+ outboxes */
+ info = (UpdateAccountInfo *) msg_info->user_data;
+ update_account_send_mail (info);
+
+ /* Check if the operation was a success */
+ if (!priv->error)
+ priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
+
+ /* Call the user callback and free */
+ new_headers = tny_iterator_get_list (msg_info->more_msgs);
+ update_account_notify_user_and_free (info, new_headers);
+ g_object_unref (new_headers);