aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-tools.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-09-03 03:44:09 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-09-03 03:44:09 +0800
commite625b9324634c01513b9dfafd165e48408b96418 (patch)
tree6dfcda0857740c8ea2126b941da86b2dd0ac1d76 /mail/mail-tools.c
parent4654c4625e79a0d36ef25d81a0c6f53fcd714837 (diff)
downloadgsoc2013-evolution-e625b9324634c01513b9dfafd165e48408b96418.tar.gz
gsoc2013-evolution-e625b9324634c01513b9dfafd165e48408b96418.tar.zst
gsoc2013-evolution-e625b9324634c01513b9dfafd165e48408b96418.zip
Since POP3 doesn't implement get_message_info, we need to check for info
2000-09-02 Jeffrey Stedfast <fejj@helixcode.com> * mail-tools.c (mail_tool_move_folder_contents): Since POP3 doesn't implement get_message_info, we need to check for info to be NULL. In this case, we need to make our own info structure to pass to append_message and then remember to free it afterward. Should we even bother with get_message_info? And if so, should we then implement get_message_info for POP3? svn path=/trunk/; revision=5182
Diffstat (limited to 'mail/mail-tools.c')
-rw-r--r--mail/mail-tools.c92
1 files changed, 52 insertions, 40 deletions
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index eb20a2ef79..c6d5dcdf57 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -252,25 +252,25 @@ mail_tool_move_folder_contents (CamelFolder *source, CamelFolder *dest, gboolean
CamelUIDCache *cache;
GPtrArray *uids;
int i;
-
+
mail_tool_camel_lock_up();
-
+
camel_object_ref (CAMEL_OBJECT (source));
camel_object_ref (CAMEL_OBJECT (dest));
-
+
/* Get all uids of source */
-
+
mail_op_set_message ("Examining %s", source->full_name);
-
+
uids = camel_folder_get_uids (source);
printf ("mail_tool_move_folder: got %d messages in source\n", uids->len);
-
+
/* If we're using the cache, ... use it */
-
+
if (use_cache) {
GPtrArray *new_uids;
char *url, *p, *filename;
-
+
url = camel_url_to_string (
CAMEL_SERVICE (source->parent_store)->url, FALSE);
for (p = url; *p; p++) {
@@ -281,9 +281,9 @@ mail_tool_move_folder_contents (CamelFolder *source, CamelFolder *dest, gboolean
filename = g_strdup_printf ("%s/config/cache-%s",
evolution_dir, url);
g_free (url);
-
+
cache = camel_uid_cache_new (filename);
-
+
if (cache) {
new_uids = camel_uid_cache_get_new_uids (cache, uids);
camel_folder_free_uids (source, uids);
@@ -295,25 +295,26 @@ mail_tool_move_folder_contents (CamelFolder *source, CamelFolder *dest, gboolean
"receive duplicate "
"messages."), filename);
}
-
+
g_free (filename);
} else
cache = NULL;
-
+
printf ("mail_tool_move_folder: %d of those messages are new\n", uids->len);
-
+
/* Copy the messages */
-
+
for (i = 0; i < uids->len; i++) {
CamelMimeMessage *msg;
- const CamelMessageInfo *info;
-
+ CamelMessageInfo *info;
+ gboolean no_info = FALSE;
+
/* Info */
-
+
mail_op_set_message ("Retrieving message %d of %d", i + 1, uids->len);
-
+
/* Get the message */
-
+
msg = camel_folder_get_message (source, uids->pdata[i], ex);
if (camel_exception_is_set (ex)) {
camel_object_unref (CAMEL_OBJECT (msg));
@@ -321,25 +322,36 @@ mail_tool_move_folder_contents (CamelFolder *source, CamelFolder *dest, gboolean
}
/* Append it to dest */
-
+
mail_op_set_message ("Writing message %d of %d", i + 1, uids->len);
-
- info = camel_folder_get_message_info (source, uids->pdata[i]);
+
+ info = (CamelMessageInfo *) camel_folder_get_message_info (source, uids->pdata[i]);
+ if (!info) {
+ /* FIXME: should we even bother to call get_message_info? */
+ no_info = TRUE;
+ info = g_new0 (CamelMessageInfo, 1);
+ info->flags = 0;
+ }
+
camel_folder_append_message (dest, msg, info, ex);
+
+ if (no_info)
+ g_free (info);
+
if (camel_exception_is_set (ex)) {
camel_object_unref (CAMEL_OBJECT (msg));
goto cleanup;
}
-
+
/* (Maybe) get rid of the message */
-
+
camel_object_unref (CAMEL_OBJECT (msg));
if (!use_cache)
camel_folder_delete_message (source, uids->pdata[i]);
}
-
+
/* All done. Sync n' free. */
-
+
if (cache) {
camel_uid_cache_free_uids (uids);
@@ -348,11 +360,11 @@ mail_tool_move_folder_contents (CamelFolder *source, CamelFolder *dest, gboolean
camel_uid_cache_destroy (cache);
} else
camel_folder_free_uids (source, uids);
-
+
mail_op_set_message ("Saving changes to %s", source->full_name);
-
+
camel_folder_sync (source, TRUE, ex);
-
+
cleanup:
camel_object_unref (CAMEL_OBJECT (source));
camel_object_unref (CAMEL_OBJECT (dest));
@@ -450,42 +462,42 @@ mail_tool_fetch_mail_into_searchable (const char *source_url, gboolean keep_on_s
{
CamelFolder *search_folder = NULL;
CamelFolder *spool_folder = NULL;
-
+
/* If fetching mail from an mbox store, safely copy it to a
* temporary store first.
*/
-
+
if (!strncmp (source_url, "mbox:", 5))
spool_folder = mail_tool_do_movemail (source_url, ex);
else
spool_folder = mail_tool_get_inbox (source_url, ex);
-
+
/* No new mail */
if (spool_folder == NULL)
return NULL;
-
+
if (camel_exception_is_set (ex))
goto cleanup;
-
+
/* can we perform filtering on this source? */
-
+
if (!(spool_folder->has_summary_capability
&& spool_folder->has_search_capability)) {
-
+
/* no :-(. Copy the messages to a local tempbox
* so that the folder browser can search it. */
gchar *url;
-
+
url = mail_tool_get_local_movemail_url();
search_folder = mail_tool_get_folder_from_urlname (url, "movemail", TRUE, ex);
g_free (url);
if (camel_exception_is_set (ex))
goto cleanup;
-
+
mail_tool_move_folder_contents (spool_folder, search_folder, keep_on_server, ex);
if (camel_exception_is_set (ex))
goto cleanup;
-
+
} else {
/* we can search! don't bother movemailing */
search_folder = spool_folder;
@@ -493,7 +505,7 @@ mail_tool_fetch_mail_into_searchable (const char *source_url, gboolean keep_on_s
camel_object_ref (CAMEL_OBJECT (search_folder));
mail_tool_camel_lock_down();
}
-
+
cleanup:
mail_tool_camel_lock_up();
camel_object_unref (CAMEL_OBJECT (spool_folder));