aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap/camel-imap-folder.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-10-30 11:24:15 +0800
committerDan Winship <danw@src.gnome.org>2000-10-30 11:24:15 +0800
commitd4656431e9de8e6e3ab526d71323f0d0543c587e (patch)
tree59b0ff39e227e6079d696c3dd29c8e1e0344dec2 /camel/providers/imap/camel-imap-folder.c
parent9e6c10a18be76719fbba41c36c61abc9c1542710 (diff)
downloadgsoc2013-evolution-d4656431e9de8e6e3ab526d71323f0d0543c587e.tar
gsoc2013-evolution-d4656431e9de8e6e3ab526d71323f0d0543c587e.tar.gz
gsoc2013-evolution-d4656431e9de8e6e3ab526d71323f0d0543c587e.tar.bz2
gsoc2013-evolution-d4656431e9de8e6e3ab526d71323f0d0543c587e.tar.lz
gsoc2013-evolution-d4656431e9de8e6e3ab526d71323f0d0543c587e.tar.xz
gsoc2013-evolution-d4656431e9de8e6e3ab526d71323f0d0543c587e.tar.zst
gsoc2013-evolution-d4656431e9de8e6e3ab526d71323f0d0543c587e.zip
Improved IMAP namespace handling: leave the namespace in the
folder names rather than constantly prepending it and stripping it off. Also some subscription fixes. * camel-store.c (camel_folder_info_build): Fix for the case where @top isn't in @folders. * providers/imap/camel-imap-folder.c (camel_imap_folder_new): Add a "short_name" argument rather than figuring it out ourselves. (imap_get_full_name): Implementation of CamelFolder::get_full_name that strips off namespace so the user doesn't have to see it. (imap_append_message, imap_copy_message_to, imap_move_message_to): Use folder->full_name rather than calling camel_imap_store_get_folder_path. * providers/imap/camel-imap-utils.c (imap_parse_list_response): Update this: make @flags a bitmask and @sep a char rather than a string. Make all of the out arguments optional. Handle literals in the server response. * providers/imap/camel-imap-store.c (imap_connect): Do a better job of getting the correct dir_sep for the namespace we're using. Construct a base_url here that will be used by get_folder_info. (camel_imap_store_folder_path): Removed (imap_folder_exists): Add an argument to return the short name of the folder (parsed out of the LIST response). Update for imap_parse_list_response change. (get_folder): Update for the various other changes. (get_folder_info): Update for the various other changes. Be more consistent about the returned layout: put everything underneath the "namespace" directory, including INBOX, even if it doesn't belong there. Don't destroy the list of subscribed folders until we've actually gotten the new list. (folder_subscribed, subscribe_folder, unsubscribe_folder): Use folder_name directly rather than camel_imap_store_folder_Path. * providers/imap/camel-imap-command.c (camel_imap_command): Update for folder name changes. svn path=/trunk/; revision=6256
Diffstat (limited to 'camel/providers/imap/camel-imap-folder.c')
-rw-r--r--camel/providers/imap/camel-imap-folder.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 46d80c6e29..c25006e5a6 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -65,6 +65,7 @@ static CamelFolderClass *parent_class = NULL;
static void imap_finalize (CamelObject *object);
static void imap_refresh_info (CamelFolder *folder, CamelException *ex);
static void imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
+static const char *imap_get_full_name (CamelFolder *folder);
static void imap_expunge (CamelFolder *folder, CamelException *ex);
/* message counts */
@@ -113,6 +114,7 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
camel_folder_class->refresh_info = imap_refresh_info;
camel_folder_class->sync = imap_sync;
camel_folder_class->expunge = imap_expunge;
+ camel_folder_class->get_full_name = imap_get_full_name;
camel_folder_class->get_uids = imap_get_uids;
camel_folder_class->free_uids = camel_folder_free_nop;
@@ -169,22 +171,17 @@ camel_imap_folder_get_type (void)
CamelFolder *
camel_imap_folder_new (CamelStore *parent, const char *folder_name,
- const char *summary_file, CamelException *ex)
+ const char *short_name, const char *summary_file,
+ CamelException *ex)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (parent);
CamelFolder *folder = CAMEL_FOLDER (camel_object_new (camel_imap_folder_get_type ()));
CamelImapFolder *imap_folder = (CamelImapFolder *)folder;
CamelImapResponse *response;
- const char *dir_sep, *short_name, *resp;
+ const char *resp;
guint32 validity = 0;
int i;
- dir_sep = CAMEL_IMAP_STORE (parent)->dir_sep;
- short_name = strrchr (folder_name, *dir_sep);
- if (short_name)
- short_name++;
- else
- short_name = folder_name;
camel_folder_construct (folder, parent, folder_name, short_name);
response = camel_imap_command (imap_store, folder, ex, NULL);
@@ -393,6 +390,21 @@ imap_expunge (CamelFolder *folder, CamelException *ex)
imap_sync (folder, TRUE, ex);
}
+static const char *
+imap_get_full_name (CamelFolder *folder)
+{
+ CamelURL *url = ((CamelService *)folder->parent_store)->url;
+ int len;
+
+ if (!url->path || !*url->path)
+ return folder->full_name;
+ len = strlen (url->path + 1);
+ if (!strncmp (url->path + 1, folder->full_name, len) &&
+ strlen (folder->full_name) > len + 1)
+ return folder->full_name + len + 1;
+ return folder->full_name;
+}
+
static gint
imap_get_message_count (CamelFolder *folder)
{
@@ -428,9 +440,7 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message,
CamelMimeFilter *crlf_filter;
CamelStreamFilter *streamfilter;
GByteArray *ba;
- char *folder_path, *flagstr, *result;
-
- folder_path = camel_imap_store_folder_path (store, folder->full_name);
+ char *flagstr, *result;
/* create flag string param */
if (info && info->flags)
@@ -455,9 +465,8 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message,
camel_object_unref (CAMEL_OBJECT (memstream));
response = camel_imap_command (store, NULL, ex, "APPEND %s%s%s {%d}",
- folder_path, flagstr ? " " : "",
+ folder->full_name, flagstr ? " " : "",
flagstr ? flagstr : "", ba->len);
- g_free (folder_path);
g_free (flagstr);
if (!response) {
@@ -486,13 +495,10 @@ imap_copy_message_to (CamelFolder *source, const char *uid,
{
CamelImapStore *store = CAMEL_IMAP_STORE (source->parent_store);
CamelImapResponse *response;
- char *folder_path;
- folder_path = camel_imap_store_folder_path (store, destination->full_name);
response = camel_imap_command (store, source, ex, "UID COPY %s \"%s\"",
- uid, folder_path);
+ uid, destination->full_name);
camel_imap_response_free (response);
- g_free (folder_path);
/* FIXME: This should go away once folder_changed is being
* emitted by camel_imap_folder_changed on appends again.
@@ -509,13 +515,10 @@ imap_move_message_to (CamelFolder *source, const char *uid,
{
CamelImapStore *store = CAMEL_IMAP_STORE (source->parent_store);
CamelImapResponse *response;
- char *folder_path;
- folder_path = camel_imap_store_folder_path (store, destination->full_name);
response = camel_imap_command (store, source, ex, "UID COPY %s \"%s\"",
- uid, folder_path);
+ uid, destination->full_name);
camel_imap_response_free (response);
- g_free (folder_path);
if (camel_exception_is_set (ex))
return;