diff options
author | Not Zed <NotZed@Ximian.com> | 2004-01-28 16:08:49 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-01-28 16:08:49 +0800 |
commit | 01c6e724a790c1743bfec5d14b107adfa96e91b1 (patch) | |
tree | 51dff57e2a6b144191d3432b583c4a656dd4f0ed /mail/mail-tools.c | |
parent | e9cddebb2ed8e6d0289f883d6a05b2951198bcb0 (diff) | |
download | gsoc2013-evolution-01c6e724a790c1743bfec5d14b107adfa96e91b1.tar.gz gsoc2013-evolution-01c6e724a790c1743bfec5d14b107adfa96e91b1.tar.zst gsoc2013-evolution-01c6e724a790c1743bfec5d14b107adfa96e91b1.zip |
** See bug #53179
2004-01-28 Not Zed <NotZed@Ximian.com>
** See bug #53179
* mail-tools.c (mail_tool_get_local_movemail_path): Fix the
movemail path.
* mail-component.c (load_accounts): hack alert!
* mail-send-recv.c (get_receive_type): hack alert! hardcode mbox:
to be a movemail source.
svn path=/trunk/; revision=24486
Diffstat (limited to 'mail/mail-tools.c')
-rw-r--r-- | mail/mail-tools.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/mail/mail-tools.c b/mail/mail-tools.c index ac04e63c67..0a16a27e0f 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -37,6 +37,7 @@ #include <camel/camel.h> #include <camel/camel-vee-folder.h> +#include <camel/camel-file-utils.h> #include <filter/vfolder-rule.h> #include <filter/vfolder-context.h> @@ -97,22 +98,30 @@ mail_tool_get_trash (const gchar *url, int connect, CamelException *ex) } static char * -mail_tool_get_local_movemail_path (const unsigned char *uri) +mail_tool_get_local_movemail_path (const unsigned char *uri, CamelException *ex) { unsigned char *safe_uri, *c; - char *path; - + char *path, *full; + struct stat st; + safe_uri = g_strdup (uri); for (c = safe_uri; *c; c++) - if (strchr ("/:;=|%&#!*^()\\, ", *c) || !isprint ((int) *c)) + if (strchr("/:;=|%&#!*^()\\, ", *c) || !isprint((int) *c)) *c = '_'; + + path = g_strdup_printf("%s/mail/spool", mail_component_peek_base_directory(NULL)); + if (stat(path, &st) == -1 && camel_mkdir(path, 0777) == -1) { + camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Could not create spool directory `%s': %s"), + path, g_strerror(errno)); + g_free(path); + return NULL; + } + + full = g_strdup_printf("%s/movemail.%s", path, safe_uri); + g_free(path); + g_free(safe_uri); - path = g_strdup_printf ("%s/local/Inbox/movemail.%s", - mail_component_peek_base_directory (mail_component_peek ()), - safe_uri); - g_free (safe_uri); - - return path; + return full; } char * @@ -127,17 +136,19 @@ mail_tool_do_movemail (const char *source_url, CamelException *ex) return NULL; if (strcmp(uri->protocol, "mbox") != 0) { - /* FIXME: use right text here post 1.4 */ + /* This is really only an internal error anyway */ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID, - _("Could not parse URL `%s'"), + _("Trying to movemail a non-mbox source `%s'"), source_url); camel_url_free(uri); return NULL; } /* Set up our destination. */ - dest_path = mail_tool_get_local_movemail_path (source_url); - + dest_path = mail_tool_get_local_movemail_path (source_url, ex); + if (dest_path == NULL) + return NULL; + /* Movemail from source (source_url) to dest_path */ camel_movemail (uri->path, dest_path, ex); camel_url_free(uri); |