/* Cancel the mail operation. We need to wrap it between this
start/stop operations to allow following calls to the
account */
- if (priv->account)
- tny_account_cancel (priv->account);
+ g_return_val_if_fail (priv->account, FALSE);
+ tny_account_cancel (priv->account);
return canceled;
}
gpointer userdata)
{
SendNewMailInfo *info = (SendNewMailInfo *) userdata;
- TnyFolder *folder;
+ TnyFolder *draft_folder = NULL;
+ TnyFolder *outbox_folder = NULL;
TnyHeader *header;
if (!msg) {
/* Call mail operation */
modest_mail_operation_send_mail (self, info->transport_account, msg);
- folder = modest_tny_account_get_special_folder (TNY_ACCOUNT (info->transport_account), TNY_FOLDER_TYPE_DRAFTS);
- if (folder) {
- if (info->draft_msg != NULL) {
- header = tny_msg_get_header (info->draft_msg);
- /* Note: This can fail (with a warning) if the message is not really already in a folder,
- * because this function requires it to have a UID. */
- tny_folder_remove_msg (folder, header, NULL);
- tny_header_set_flags (header, TNY_HEADER_FLAG_DELETED);
- tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN);
- g_object_unref (header);
- g_object_unref (folder);
- }
+ /* Remove old mail from its source folder */
+ draft_folder = modest_tny_account_get_special_folder (TNY_ACCOUNT (info->transport_account), TNY_FOLDER_TYPE_DRAFTS);
+ outbox_folder = modest_tny_account_get_special_folder (TNY_ACCOUNT (info->transport_account), TNY_FOLDER_TYPE_OUTBOX);
+ if (info->draft_msg != NULL) {
+ TnyFolder *folder = NULL;
+ TnyFolder *src_folder = NULL;
+ TnyFolderType folder_type;
+ folder = tny_msg_get_folder (info->draft_msg);
+ if (folder == NULL) goto end;
+ folder_type = modest_tny_folder_guess_folder_type (folder);
+ if (folder_type == TNY_FOLDER_TYPE_OUTBOX)
+ src_folder = outbox_folder;
+ else
+ src_folder = draft_folder;
+
+ /* Note: This can fail (with a warning) if the message is not really already in a folder,
+ * because this function requires it to have a UID. */
+ header = tny_msg_get_header (info->draft_msg);
+ tny_folder_remove_msg (src_folder, header, NULL);
+ tny_header_set_flags (header, TNY_HEADER_FLAG_DELETED);
+ tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN);
+ g_object_unref (header);
+ g_object_unref (folder);
}
end:
if (info->draft_msg)
g_object_unref (info->draft_msg);
+ if (draft_folder)
+ g_object_unref (draft_folder);
+ if (outbox_folder)
+ g_object_unref (outbox_folder);
if (info->transport_account)
g_object_unref (info->transport_account);
g_slice_free (SendNewMailInfo, info);
TnyMsg *msg,
gpointer userdata)
{
+ TnyFolder *src_folder = NULL;
TnyFolder *folder = NULL;
TnyHeader *header = NULL;
ModestMailOperationPrivate *priv = NULL;
if (info->draft_msg != NULL) {
header = tny_msg_get_header (info->draft_msg);
+ src_folder = tny_header_get_folder (header);
/* Remove the old draft expunging it */
- tny_folder_remove_msg (folder, header, NULL);
+ tny_folder_remove_msg (src_folder, header, NULL);
tny_header_set_flags (header, TNY_HEADER_FLAG_DELETED);
tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN);
- tny_folder_sync (folder, FALSE, &(priv->error)); /* FALSE --> don't expunge */
+ tny_folder_sync (src_folder, TRUE, &(priv->error)); /* expunge */
g_object_unref (header);
}
end:
if (folder)
g_object_unref (G_OBJECT(folder));
+ if (src_folder)
+ g_object_unref (G_OBJECT(src_folder));
if (info->edit_window)
g_object_unref (G_OBJECT(info->edit_window));
if (info->draft_msg)
priv->account = g_object_ref (info->account);
/*
- * for POP3, we do a logout-login upon send/receive -- many POP-servers (like Gmail) do not
- * show any updates unless we do that
+ * Previousl, we did this for POP3, to do a logout-login upon send/receive,
+ * because many POP-servers (like Gmail) do not
+ * show any updates unless we do that.
+ * But that didn't work with gmail anyway,
+ * and tinymail now takes care of this itself by disconnecting
+ * automatically after using the connection.
*/
+ /*
if (!first_time && TNY_IS_CAMEL_POP_STORE_ACCOUNT (priv->account))
tny_camel_pop_store_account_reconnect (TNY_CAMEL_POP_STORE_ACCOUNT(priv->account));
+ */
/* Get all the folders. We can do it synchronously because
we're already running in a different thread than the UI */
{
if (TNY_IS_ACCOUNT (into) &&
modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (into)) &&
- modest_tny_local_folders_account_extra_folder_exists (MODEST_TNY_LOCAL_FOLDERS_ACCOUNT (into),
- new_name)) {
+ modest_tny_local_folders_account_folder_name_in_use (MODEST_TNY_LOCAL_FOLDERS_ACCOUNT (into),
+ new_name)) {
priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
MODEST_MAIL_OPERATION_ERROR_FOLDER_RULES,
parent_rules = modest_tny_folder_get_rules (TNY_FOLDER (parent));
/* The moveable restriction is applied also to copy operation */
- if ((!TNY_IS_FOLDER_STORE (parent)) || (rules & MODEST_FOLDER_RULES_FOLDER_NON_MOVEABLE)) {
+ if ((gpointer) parent == (gpointer) folder ||
+ (!TNY_IS_FOLDER_STORE (parent)) ||
+ (rules & MODEST_FOLDER_RULES_FOLDER_NON_MOVEABLE)) {
printf("DEBUG: %s: Not allowing the move.\n", __FUNCTION__);
/* Set status failed and set an error */
priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
info->callback = user_callback;
info->userdata = user_data;
+ tny_camel_mem_stream_get_type ();
+
thread = g_thread_create (get_mime_part_size_thread, info, FALSE, NULL);
}
}
/* Free */
-/* g_object_unref (helper->mail_op); */
g_slice_free (RefreshAsyncHelper, helper);
/* Notify about operation end */
/* Create the helper */
helper = g_slice_new0 (RefreshAsyncHelper);
- helper->mail_op = g_object_ref (self);
+ helper->mail_op = self;
helper->user_callback = user_callback;
helper->user_data = user_data;