aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-folder-utils.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-06 01:25:47 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-06 03:20:22 +0800
commit4d08cc60e5401caba786e74bf6c1fb5bf9424e3f (patch)
tree3dcb53eb794fa177cc3c641dbeb6ad0b033d8e5b /mail/e-mail-folder-utils.c
parentd9ba7c175b630f826a6d928561e2f43189527e22 (diff)
downloadgsoc2013-evolution-4d08cc60e5401caba786e74bf6c1fb5bf9424e3f.tar
gsoc2013-evolution-4d08cc60e5401caba786e74bf6c1fb5bf9424e3f.tar.gz
gsoc2013-evolution-4d08cc60e5401caba786e74bf6c1fb5bf9424e3f.tar.bz2
gsoc2013-evolution-4d08cc60e5401caba786e74bf6c1fb5bf9424e3f.tar.lz
gsoc2013-evolution-4d08cc60e5401caba786e74bf6c1fb5bf9424e3f.tar.xz
gsoc2013-evolution-4d08cc60e5401caba786e74bf6c1fb5bf9424e3f.tar.zst
gsoc2013-evolution-4d08cc60e5401caba786e74bf6c1fb5bf9424e3f.zip
Teach e_mail_folder_uri_parse() to parse 'email://' URIs.
Diffstat (limited to 'mail/e-mail-folder-utils.c')
-rw-r--r--mail/e-mail-folder-utils.c69
1 files changed, 60 insertions, 9 deletions
diff --git a/mail/e-mail-folder-utils.c b/mail/e-mail-folder-utils.c
index bcf649728a..3c87ca4de0 100644
--- a/mail/e-mail-folder-utils.c
+++ b/mail/e-mail-folder-utils.c
@@ -201,18 +201,69 @@ e_mail_folder_uri_parse (CamelSession *session,
if (url == NULL)
return FALSE;
- service = camel_session_get_service_by_url (
- session, url, CAMEL_PROVIDER_STORE);
+ /* This style was used to reference accounts by UID before
+ * CamelServices themselves had UIDs. Some examples are:
+ *
+ * Special cases:
+ *
+ * 'email://local@local/' FOLDER_PATH
+ * 'email://vfolder@local/' FOLDER_PATH
+ *
+ * General case:
+ *
+ * 'email://' ACCOUNT_UID '/' FOLDER_PATH
+ *
+ * Note: ACCOUNT_UID is now equivalent to STORE_UID, and
+ * the STORE_UIDs for the special cases are 'local'
+ * and 'vfolder'.
+ */
+ if (g_strcmp0 (url->protocol, "email") == 0) {
+ gchar *uid = NULL;
+
+ /* Handle the special cases. */
+ if (g_strcmp0 (url->host, "local") == 0) {
+ if (g_strcmp0 (url->user, "local") == 0)
+ uid = g_strdup ("local");
+ if (g_strcmp0 (url->user, "vfolder") == 0)
+ uid = g_strdup ("vfolder");
+ }
+
+ /* Handle the general case. */
+ if (uid == NULL && url->host != NULL) {
+ if (url->user == NULL)
+ uid = g_strdup (url->host);
+ else
+ uid = g_strdup_printf (
+ "%s@%s", url->user, url->host);
+ }
+
+ if (uid != NULL) {
+ service = camel_session_get_service (session, uid);
+ g_free (uid);
+ }
+
+ if (url->path != NULL && *url->path == '/')
+ folder_name = url->path + 1;
+
+ /* CamelFolderInfo URIs used to embed the store's URI, so the
+ * folder name is appended as either a path part or a fragment
+ * part, depending whether the store's URI used the path part.
+ * To determine which it is, you have to check the provider
+ * flags for CAMEL_URL_FRAGMENT_IS_PATH. */
+ } else {
+ service = camel_session_get_service_by_url (
+ session, url, CAMEL_PROVIDER_STORE);
- if (CAMEL_IS_STORE (service)) {
- CamelProvider *provider;
+ if (CAMEL_IS_STORE (service)) {
+ CamelProvider *provider;
- provider = camel_service_get_provider (service);
+ provider = camel_service_get_provider (service);
- if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)
- folder_name = url->fragment;
- else if (url->path != NULL && *url->path == '/')
- folder_name = url->path + 1;
+ if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)
+ folder_name = url->fragment;
+ else if (url->path != NULL && *url->path == '/')
+ folder_name = url->path + 1;
+ }
}
if (CAMEL_IS_STORE (service) && folder_name != NULL) {