aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-ops.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-18 07:50:33 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-18 21:25:59 +0800
commitf0a011f941bab3f6ac7228be4e1bec86a0de0d2a (patch)
treed5c64c9fc9922775171aa623223c0666bd833e64 /mail/mail-ops.c
parentb3b917365ff2e813df0503e94267f2cb3bab4255 (diff)
downloadgsoc2013-evolution-f0a011f941bab3f6ac7228be4e1bec86a0de0d2a.tar.gz
gsoc2013-evolution-f0a011f941bab3f6ac7228be4e1bec86a0de0d2a.tar.zst
gsoc2013-evolution-f0a011f941bab3f6ac7228be4e1bec86a0de0d2a.zip
Remove mail_save_messages().
Use e_mail_folder_save_messages() instead.
Diffstat (limited to 'mail/mail-ops.c')
-rw-r--r--mail/mail-ops.c169
1 files changed, 0 insertions, 169 deletions
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 1438805321..ad86c772d6 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -1725,175 +1725,6 @@ mail_empty_trash (EMailSession *session,
mail_msg_slow_ordered_push (m);
}
-/* ** SAVE MESSAGES ******************************************************* */
-
-struct _save_messages_msg {
- MailMsg base;
-
- CamelFolder *folder;
- GPtrArray *uids;
- gchar *path;
- void (*done)(CamelFolder *folder, GPtrArray *uids, gchar *path, gpointer data);
- gpointer data;
-};
-
-static gchar *
-save_messages_desc (struct _save_messages_msg *m)
-{
- return g_strdup_printf(ngettext("Saving %d message",
- "Saving %d messages", m->uids->len),
- m->uids->len);
-}
-
-static void
-save_prepare_part (CamelMimePart *mime_part)
-{
- CamelDataWrapper *wrapper;
- gint parts, i;
-
- wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
- if (!wrapper)
- return;
-
- if (CAMEL_IS_MULTIPART (wrapper)) {
- parts = camel_multipart_get_number (CAMEL_MULTIPART (wrapper));
- for (i = 0; i < parts; i++) {
- CamelMimePart *part = camel_multipart_get_part (CAMEL_MULTIPART (wrapper), i);
-
- save_prepare_part (part);
- }
- } else {
- if (CAMEL_IS_MIME_MESSAGE (wrapper)) {
- /* prepare the message parts' subparts */
- save_prepare_part (CAMEL_MIME_PART (wrapper));
- } else {
- CamelContentType *type;
-
- /* We want to save textual parts as 8bit instead of encoded */
- type = camel_data_wrapper_get_mime_type_field (wrapper);
- if (camel_content_type_is (type, "text", "*"))
- camel_mime_part_set_encoding (mime_part, CAMEL_TRANSFER_ENCODING_8BIT);
- }
- }
-}
-
-static void
-save_messages_exec (struct _save_messages_msg *m,
- GCancellable *cancellable,
- GError **error)
-{
- CamelStream *filtered_stream;
- CamelMimeFilter *from_filter;
- CamelStream *stream;
- gint i;
- gchar *from, *path;
-
- if (strstr (m->path, "://"))
- path = m->path;
- else
- path = g_filename_to_uri (m->path, NULL, NULL);
-
- stream = camel_stream_vfs_new_with_uri (path, CAMEL_STREAM_VFS_CREATE);
- from_filter = camel_mime_filter_from_new ();
- filtered_stream = camel_stream_filter_new (stream);
- camel_stream_filter_add (
- CAMEL_STREAM_FILTER (filtered_stream), from_filter);
- g_object_unref (from_filter);
-
- if (path != m->path)
- g_free (path);
-
- for (i=0; i<m->uids->len; i++) {
- CamelMimeMessage *message;
- gint pc = ((i+1) * 100) / m->uids->len;
-
- message = camel_folder_get_message_sync (
- m->folder, m->uids->pdata[i],
- cancellable, error);
- camel_operation_progress (cancellable, pc);
- if (message == NULL)
- break;
-
- save_prepare_part (CAMEL_MIME_PART (message));
-
- /* we need to flush after each stream write since we are writing to the same fd */
- from = camel_mime_message_build_mbox_from (message);
- if (camel_stream_write_string (
- stream, from,
- cancellable, error) == -1
- || camel_stream_flush (
- stream, cancellable, error) == -1
- || camel_data_wrapper_write_to_stream_sync (
- (CamelDataWrapper *) message,
- (CamelStream *) filtered_stream,
- cancellable, error) == -1
- || camel_stream_flush (
- (CamelStream *) filtered_stream,
- cancellable, error) == -1
- || camel_stream_write_string (
- stream, "\n",
- cancellable, error) == -1
- || camel_stream_flush (stream,
- cancellable, error) == -1) {
- g_prefix_error (
- error, _("Error saving messages to: %s:\n"),
- m->path);
- g_free (from);
- g_object_unref ((CamelObject *) message);
- break;
- }
- g_free (from);
- g_object_unref (message);
- }
-
- g_object_unref (filtered_stream);
- g_object_unref (stream);
-}
-
-static void
-save_messages_done (struct _save_messages_msg *m)
-{
- if (m->done)
- m->done (m->folder, m->uids, m->path, m->data);
-}
-
-static void
-save_messages_free (struct _save_messages_msg *m)
-{
- em_utils_uids_free (m->uids);
- g_object_unref (m->folder);
- g_free (m->path);
-}
-
-static MailMsgInfo save_messages_info = {
- sizeof (struct _save_messages_msg),
- (MailMsgDescFunc) save_messages_desc,
- (MailMsgExecFunc) save_messages_exec,
- (MailMsgDoneFunc) save_messages_done,
- (MailMsgFreeFunc) save_messages_free
-};
-
-gint
-mail_save_messages (CamelFolder *folder, GPtrArray *uids, const gchar *path,
- void (*done) (CamelFolder *folder, GPtrArray *uids, gchar *path, gpointer data), gpointer data)
-{
- struct _save_messages_msg *m;
- gint id;
-
- m = mail_msg_new (&save_messages_info);
- m->folder = folder;
- g_object_ref (folder);
- m->uids = uids;
- m->path = g_strdup (path);
- m->data = data;
- m->done = done;
-
- id = m->base.seq;
- mail_msg_unordered_push (m);
-
- return id;
-}
-
/* ** Execute Shell Command ***************************************************** */
void