X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodest-mail-operation.c;h=4d16d48c6b4980839e56a7a35909316e5844160a;hb=496807ff6115d8f387ceaf88ad4a3c4b737141b8;hp=19274c687f76df2a98a29597809e099a2c468352;hpb=45cb983bddff407659d517414bf5ecbca8aea382;p=modest diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index 19274c6..4d16d48 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -417,6 +417,7 @@ modest_mail_operation_cancel (ModestMailOperation *self) /* Cancel the mail operation. We need to wrap it between this start/stop operations to allow following calls to the account */ + g_return_val_if_fail (priv->account, FALSE); tny_account_cancel (priv->account); return canceled; @@ -671,6 +672,7 @@ modest_mail_operation_create_msg (ModestMailOperation *self, info->from = g_strdup (from); info->to = g_strdup (to); info->cc = g_strdup (cc); + info->bcc = g_strdup (bcc); info->subject = g_strdup (subject); info->plain_body = g_strdup (plain_body); info->html_body = g_strdup (html_body); @@ -716,6 +718,7 @@ modest_mail_operation_send_new_mail_cb (ModestMailOperation *self, 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); } } @@ -997,10 +1000,11 @@ recurse_folders (TnyFolderStore *store, TnyFolderStoreQuery *query, TnyList *all while (!tny_iterator_is_done (iter)) { TnyFolderStore *folder = (TnyFolderStore*) tny_iterator_get_current (iter); - - tny_list_prepend (all_folders, G_OBJECT (folder)); - recurse_folders (folder, query, all_folders); - g_object_unref (G_OBJECT (folder)); + if (folder) { + tny_list_prepend (all_folders, G_OBJECT (folder)); + recurse_folders (folder, query, all_folders); + g_object_unref (G_OBJECT (folder)); + } tny_iterator_next (iter); } @@ -1155,11 +1159,17 @@ update_account_thread (gpointer thr_user_data) 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)) + /* + 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 */ @@ -1178,8 +1188,10 @@ update_account_thread (gpointer thr_user_data) iter = tny_list_create_iterator (all_folders); while (!tny_iterator_is_done (iter)) { TnyFolderStore *folder = TNY_FOLDER_STORE (tny_iterator_get_current (iter)); - - recurse_folders (folder, query, all_folders); + if (folder) { + recurse_folders (folder, query, all_folders); + g_object_unref (folder); + } tny_iterator_next (iter); } g_object_unref (G_OBJECT (iter)); @@ -1245,7 +1257,9 @@ update_account_thread (gpointer thr_user_data) g_object_unref (observer); observer = NULL; - g_object_unref (G_OBJECT (folder)); + if (folder) + g_object_unref (G_OBJECT (folder)); + if (priv->error) priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED; @@ -1584,9 +1598,12 @@ modest_mail_operation_remove_folder (ModestMailOperation *self, trash_folder = modest_tny_account_get_special_folder (account, TNY_FOLDER_TYPE_TRASH); /* TODO: error_handling */ - modest_mail_operation_xfer_folder (self, folder, + if (trash_folder) { + modest_mail_operation_xfer_folder (self, folder, TNY_FOLDER_STORE (trash_folder), TRUE, NULL, NULL); + g_object_unref (trash_folder); + } } else { TnyFolderStore *parent = tny_folder_get_folder_store (folder); @@ -1753,7 +1770,9 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self, 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; @@ -2219,7 +2238,10 @@ get_msgs_full_thread (gpointer thr_user_data) MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND, "Error trying to get a message. No folder found for header"); } - g_object_unref (header); + + if (header) + g_object_unref (header); + tny_iterator_next (iter); } @@ -2264,10 +2286,16 @@ modest_mail_operation_get_msgs_full (ModestMailOperation *self, if (tny_list_get_length (header_list) >= 1) { iter = tny_list_create_iterator (header_list); header = TNY_HEADER (tny_iterator_get_current (iter)); - folder = tny_header_get_folder (header); - priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder)); - g_object_unref (header); - g_object_unref (folder); + if (header) { + folder = tny_header_get_folder (header); + if (folder) { + priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder)); + + g_object_unref (folder); + } + + g_object_unref (header); + } if (tny_list_get_length (header_list) == 1) { g_object_unref (iter); @@ -2291,9 +2319,12 @@ modest_mail_operation_get_msgs_full (ModestMailOperation *self, if (iter != NULL) { while (!tny_iterator_is_done (iter) && size_ok) { header = TNY_HEADER (tny_iterator_get_current (iter)); - if (tny_header_get_message_size (header) >= max_size) - size_ok = FALSE; - g_object_unref (header); + if (header) { + if (tny_header_get_message_size (header) >= max_size) + size_ok = FALSE; + g_object_unref (header); + } + tny_iterator_next (iter); } g_object_unref (iter); @@ -2463,12 +2494,12 @@ modest_mail_operation_xfer_msgs (ModestMailOperation *self, XferMsgsAsynUserCallback user_callback, gpointer user_data) { - ModestMailOperationPrivate *priv; - TnyIterator *iter; - TnyFolder *src_folder; - XFerMsgAsyncHelper *helper; - TnyHeader *header; - ModestTnyFolderRules rules; + ModestMailOperationPrivate *priv = NULL; + TnyIterator *iter = NULL; + TnyFolder *src_folder = NULL; + XFerMsgAsyncHelper *helper = NULL; + TnyHeader *header = NULL; + ModestTnyFolderRules rules = 0; const gchar *id1 = NULL; const gchar *id2 = NULL; gboolean same_folder = FALSE; @@ -2498,8 +2529,11 @@ modest_mail_operation_xfer_msgs (ModestMailOperation *self, /* Get source folder */ iter = tny_list_create_iterator (headers); header = TNY_HEADER (tny_iterator_get_current (iter)); - src_folder = tny_header_get_folder (header); - g_object_unref (header); + if (header) { + src_folder = tny_header_get_folder (header); + g_object_unref (header); + } + g_object_unref (iter); /* Check folder source and destination */