#include <libgnomevfs/gnome-vfs.h>
#include "modest-utils.h"
#include "modest-debug.h"
+#ifdef MODEST_USE_LIBTIME
+#include <clockd/libtime.h>
+#endif
#define KB 1024
self = helper->mail_op;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
- if (cancelled || err)
+ if (cancelled)
goto end;
if (err) {
self = helper->mail_op;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
- if (cancelled || err)
+ if (cancelled)
goto end;
if (err) {
ModestAccountRetrieveType retrieve_type;
TnyList *new_headers = NULL;
gboolean headers_only, ignore_limit;
+ time_t time_to_store;
info = (UpdateAccountInfo *) user_data;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE (info->mail_op);
}
/* Set the last updated as the current time */
- modest_account_mgr_set_last_updated (mgr, tny_account_get_id (priv->account), time (NULL));
+#ifdef MODEST_USE_LIBTIME
+ struct tm utc_tm;
+ time_get_utc (&utc_tm);
+ time_to_store = time_mktime (&utc_tm, "GMT");
+#else
+ time_to_store = time (NULL);
+#endif
+ modest_account_mgr_set_last_updated (mgr, tny_account_get_id (priv->account), time_to_store);
/* Get the message max size */
max_size = modest_conf_get_int (modest_runtime_get_conf (),
}
}
- if (!strcmp (name, " ") || strchr (name, '/')) {
+ if (!priv->error && (!strcmp (name, " ") || strchr (name, '/'))) {
priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
MODEST_MAIL_OPERATION_ERROR_FOLDER_RULES,
/* ******************************************************************* */
void
+modest_mail_operation_find_msg (ModestMailOperation *self,
+ TnyFolder *folder,
+ const gchar *msg_uid,
+ gboolean progress_feedback,
+ GetMsgAsyncUserCallback user_callback,
+ gpointer user_data)
+{
+ GetMsgInfo *helper = NULL;
+ ModestMailOperationPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_MAIL_OPERATION (self));
+ g_return_if_fail (msg_uid != NULL);
+
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
+ priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
+ priv->total = 1;
+ priv->done = 0;
+
+ /* Check memory low */
+ if (_check_memory_low (self)) {
+ if (user_callback)
+ user_callback (self, NULL, FALSE, NULL, priv->error, user_data);
+ modest_mail_operation_notify_end (self);
+ return;
+ }
+
+ /* Get account and set it into mail_operation */
+ priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
+
+ /* Check for cached messages */
+ if (progress_feedback) {
+ priv->op_type = MODEST_MAIL_OPERATION_TYPE_RECEIVE;
+ } else {
+ priv->op_type = MODEST_MAIL_OPERATION_TYPE_UNKNOWN;
+ }
+
+ /* Create the helper */
+ helper = g_slice_new0 (GetMsgInfo);
+ helper->header = NULL;
+ helper->mail_op = g_object_ref (self);
+ helper->user_callback = user_callback;
+ helper->user_data = user_data;
+ helper->destroy_notify = NULL;
+ helper->last_total_bytes = 0;
+ helper->sum_total_bytes = 0;
+ helper->total_bytes = 0;
+ helper->more_msgs = NULL;
+
+ modest_mail_operation_notify_start (self);
+
+ /* notify about the start of the operation */
+ ModestMailOperationState *state;
+ state = modest_mail_operation_clone_state (self);
+ state->done = 0;
+ state->total = 0;
+ g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL],
+ 0, state, NULL);
+ g_slice_free (ModestMailOperationState, state);
+
+ tny_folder_find_msg_async (folder, msg_uid, get_msg_async_cb, get_msg_status_cb, helper);
+}
+
+void
modest_mail_operation_get_msg (ModestMailOperation *self,
TnyHeader *header,
gboolean progress_feedback,
priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
}
+ if (info->header == NULL && msg)
+ info->header = tny_msg_get_header (msg);
/* Call the user callback */
if (info->user_callback)
/* Clean */
if (info->more_msgs)
g_object_unref (info->more_msgs);
- g_object_unref (info->header);
+ if (info->header)
+ g_object_unref (info->header);
g_object_unref (info->mail_op);
g_slice_free (GetMsgInfo, info);
} else if (info->more_msgs) {
local_account = (ModestTnyLocalFoldersAccount *)
modest_tny_account_store_get_local_folders_account (accstore);
- g_object_unref (folder);
- folder = modest_tny_local_folders_account_get_merged_outbox (local_account);
folder_type = modest_tny_folder_get_local_or_mmc_folder_type (folder);
+ if (folder_type == TNY_FOLDER_TYPE_OUTBOX) {
+ g_object_unref (folder);
+ folder = modest_tny_local_folders_account_get_merged_outbox (local_account);
+ }
g_object_unref (local_account);
}