- }
-
- out:
- /* Notify about operation end. Note that the info could be
- freed before this idle happens, but the mail operation will
- be still alive */
- g_idle_add (notify_update_account_queue, info->mail_op);
-
- /* Frees */
- g_object_unref (query);
- g_object_unref (all_folders);
- g_object_unref (info->account);
- g_object_unref (info->transport_account);
- g_slice_free (UpdateAccountInfo, info);
-
- return NULL;
-}
-
-gboolean
-modest_mail_operation_update_account (ModestMailOperation *self,
- const gchar *account_name)
-{
- GThread *thread;
- UpdateAccountInfo *info;
- ModestMailOperationPrivate *priv;
- TnyStoreAccount *modest_account;
- TnyTransportAccount *transport_account;
-
- g_return_val_if_fail (MODEST_IS_MAIL_OPERATION (self), FALSE);
- g_return_val_if_fail (account_name, FALSE);
-
- /* Init mail operation. Set total and done to 0, and do not
- update them, this way the progress objects will know that
- we have no clue about the number of the objects */
- priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
- priv->total = 0;
- priv->done = 0;
- priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
-
- /* Get the Modest account */
- modest_account = (TnyStoreAccount *)
- modest_tny_account_store_get_tny_account_by_account (modest_runtime_get_account_store (),
- account_name,
- TNY_ACCOUNT_TYPE_STORE);
-
- if (!modest_account) {
- priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
- g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
- MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND,
- "cannot get tny store account for %s\n", account_name);
- modest_mail_operation_notify_end (self);
- return FALSE;
- }
-
- /* Get the transport account, we can not do it in the thread
- due to some problems with dbus */
- transport_account = (TnyTransportAccount *)
- modest_tny_account_store_get_transport_account_for_open_connection (modest_runtime_get_account_store(),
- account_name);
- if (!transport_account) {
- priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
- g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
- MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND,
- "cannot get tny transport account for %s\n", account_name);
- modest_mail_operation_notify_end (self);
- return FALSE;
- }
-
- /* Create the helper object */
- info = g_slice_new (UpdateAccountInfo);
- info->mail_op = self;
- info->account = modest_account;
- info->transport_account = transport_account;
-
- thread = g_thread_create (update_account_thread, info, FALSE, NULL);
-
- return TRUE;
-}
-
-ModestMailOperationStatus
-modest_mail_operation_get_status (ModestMailOperation *self)
-{
- ModestMailOperationPrivate *priv;
-
- g_return_val_if_fail (self, MODEST_MAIL_OPERATION_STATUS_INVALID);
- g_return_val_if_fail (MODEST_IS_MAIL_OPERATION (self),
- MODEST_MAIL_OPERATION_STATUS_INVALID);
-
- priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
- return priv->status;
-}
-
-const GError *
-modest_mail_operation_get_error (ModestMailOperation *self)
-{
- ModestMailOperationPrivate *priv;
-
- g_return_val_if_fail (self, NULL);
- g_return_val_if_fail (MODEST_IS_MAIL_OPERATION (self), NULL);
-
- priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
- return priv->error;
-}
-
-gboolean
-modest_mail_operation_cancel (ModestMailOperation *self)
-{
- ModestMailOperationPrivate *priv;
-
- if (!MODEST_IS_MAIL_OPERATION (self)) {
- g_warning ("%s: invalid parametter", G_GNUC_FUNCTION);
- return FALSE;
- }
-
- priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
-
- /* TODO: Tinymail does not support cancel operation */
-/* tny_account_cancel (); */
-
- /* Set new status */
- priv->status = MODEST_MAIL_OPERATION_STATUS_CANCELED;
-
- /* Notify about operation end */
- modest_mail_operation_notify_end (self);
-
- return TRUE;
-}
-
-guint
-modest_mail_operation_get_task_done (ModestMailOperation *self)
-{
- ModestMailOperationPrivate *priv;