diff options
author | Peter Williams <peterw@ximian.com> | 2001-08-07 03:00:32 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2001-08-07 03:00:32 +0800 |
commit | f789abbd422604206c386199c80fb5eac8e34733 (patch) | |
tree | d0a1d734f996e2f4bca6aa58d695d6489b0403b0 /camel/providers/imap/camel-imap-utils.c | |
parent | d701d18f51dbc1501cafba55025a7a74466e16cd (diff) | |
download | gsoc2013-evolution-f789abbd422604206c386199c80fb5eac8e34733.tar gsoc2013-evolution-f789abbd422604206c386199c80fb5eac8e34733.tar.gz gsoc2013-evolution-f789abbd422604206c386199c80fb5eac8e34733.tar.bz2 gsoc2013-evolution-f789abbd422604206c386199c80fb5eac8e34733.tar.lz gsoc2013-evolution-f789abbd422604206c386199c80fb5eac8e34733.tar.xz gsoc2013-evolution-f789abbd422604206c386199c80fb5eac8e34733.tar.zst gsoc2013-evolution-f789abbd422604206c386199c80fb5eac8e34733.zip |
Completely hide the namespace from everything external to the IMAP code,
2001-08-06 Peter Williams <peterw@ximian.com>
Completely hide the namespace from everything external to the IMAP
code, which Dan W says is the way it should be.
* providers/imap/camel-imap-command.c
(imap_command_strdup_vprintf): Add a new %F argument, which is like
%S but will add the namespace (for folder names).
(camel_imap_command): Use %F here.
* providers/imap/camel-imap-utils.c (imap_parse_list_response):
Changed to strip out the namespec when returning *folder. In order
to do this we need to be passed the CamelImapStore.
(imap_concat): Move to here from camel-imap-store.c, un-static
(imap_namespace_concat): New function, adds the namespace to the
folder name, unless it's INBOX.
* providers/imap/camel-imap-utils.h: Prototypes.
* providers/imap/camel-imap-store.c (imap_connect_online): Extra
arg to imap_parse_list_response.
(imap_connect_offline): Here too.
(get_folder_status): Use %F.
(get_folder_online): Here too.
(delete_folder): Here too.
(create_folder): Here too, and arg to imap_parse_list_response.
(parse_list_response_as_folder_info): Arg to i_p_l_r.
(get_subscribed_folders_by_hand): Use %F.
(get_folders_online): Here too.
(get_folder_info_online): Instead of checking for NULL @name, check
for name = NULL or "", and set to "" instead of namespace. Pass ""
instead of namespace to camel_folder_info_build.
(subscribe_folder): Use %F.
(unsubscribe_folder): Here too.
* providers/imap/camel-imap-folder.c (imap_get_full_name): This
now just returns folder->full_name.
(do_append): Use %F
(do_copy): Here too.
svn path=/trunk/; revision=11705
Diffstat (limited to 'camel/providers/imap/camel-imap-utils.c')
-rw-r--r-- | camel/providers/imap/camel-imap-utils.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c index f2909fb6a4..944165aebb 100644 --- a/camel/providers/imap/camel-imap-utils.c +++ b/camel/providers/imap/camel-imap-utils.c @@ -27,6 +27,7 @@ #include "camel-imap-utils.h" #include "camel-imap-summary.h" +#include "camel-imap-store.h" #include "camel-folder.h" #define d(x) x @@ -47,6 +48,7 @@ imap_next_word (const char *buf) /** * imap_parse_list_response: + * @store: the IMAP store whose list response we're parsing * @buf: the LIST or LSUB response * @flags: a pointer to a variable to store the flags in, or %NULL * @sep: a pointer to a variable to store the hierarchy separator in, or %NULL @@ -58,7 +60,7 @@ imap_next_word (const char *buf) * Return value: whether or not the response was successfully parsed. **/ gboolean -imap_parse_list_response (const char *buf, int *flags, char *sep, char **folder) +imap_parse_list_response (CamelImapStore *store, const char *buf, int *flags, char *sep, char **folder) { char *word; int len; @@ -114,9 +116,22 @@ imap_parse_list_response (const char *buf, int *flags, char *sep, char **folder) return FALSE; if (folder) { + char *real_name; + int n_len; + /* get the folder name */ word = imap_next_word (word); - *folder = imap_parse_astring (&word, &len); + real_name = imap_parse_astring (&word, &len); + n_len = strlen (store->namespace); + if (!strncmp (real_name, store->namespace, n_len)) + *folder = g_strdup (real_name + n_len); + else if (!g_strcasecmp (real_name, "INBOX")) { + *folder = g_strdup (real_name); + } else { + g_warning ("IMAP folder name \"%s\" does not begin with \"%s\"", real_name, store->namespace); + *folder = g_strdup (real_name); + } + g_free (real_name); return *folder != NULL; } @@ -730,3 +745,28 @@ imap_uid_array_free (GPtrArray *arr) g_free (arr->pdata[i]); g_ptr_array_free (arr, TRUE); } + +char * +imap_concat (CamelImapStore *imap_store, const char *prefix, const char *suffix) +{ + int len; + + len = strlen (prefix); + if (len == 0 || prefix[len - 1] == imap_store->dir_sep) + return g_strdup_printf ("%s%s", prefix, suffix); + else + return g_strdup_printf ("%s%c%s", prefix, imap_store->dir_sep, suffix); +} + +char * +imap_namespace_concat (CamelImapStore *store, const char *name) +{ + if (!name || *name == '\0') + return g_strdup (store->namespace); + + if (!g_strcasecmp (name, "INBOX")) + return g_strdup ("INBOX"); + + return imap_concat (store, store->namespace, name); +} + |