aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-02-15 05:51:33 +0800
committerDan Winship <danw@src.gnome.org>2001-02-15 05:51:33 +0800
commit7d76ff550168871217e6d483f965ce430427c536 (patch)
tree86afc5a45c2b45f79587093267d680704d5d836c /camel/providers/imap
parent3245f9dacf18e68ed5e1bc18226d0ffe65c7bf6c (diff)
downloadgsoc2013-evolution-7d76ff550168871217e6d483f965ce430427c536.tar
gsoc2013-evolution-7d76ff550168871217e6d483f965ce430427c536.tar.gz
gsoc2013-evolution-7d76ff550168871217e6d483f965ce430427c536.tar.bz2
gsoc2013-evolution-7d76ff550168871217e6d483f965ce430427c536.tar.lz
gsoc2013-evolution-7d76ff550168871217e6d483f965ce430427c536.tar.xz
gsoc2013-evolution-7d76ff550168871217e6d483f965ce430427c536.tar.zst
gsoc2013-evolution-7d76ff550168871217e6d483f965ce430427c536.zip
New method to create a folder when you don't know its full name.
* camel-store.c (camel_store_create_folder): New method to create a folder when you don't know its full name. * providers/imap/camel-imap-store.c (create_folder): Implement. svn path=/trunk/; revision=8231
Diffstat (limited to 'camel/providers/imap')
-rw-r--r--camel/providers/imap/camel-imap-store.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index f19d8feb31..d02a2f991e 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -63,6 +63,7 @@ static GList *query_auth_types (CamelService *service, gboolean connect, CamelEx
static guint hash_folder_name (gconstpointer key);
static gint compare_folder_name (gconstpointer a, gconstpointer b);
static CamelFolder *get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex);
+static CamelFolderInfo *create_folder (CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex);
static CamelFolderInfo *get_folder_info (CamelStore *store, const char *top,
gboolean fast, gboolean recursive,
gboolean subscribed_only,
@@ -96,6 +97,7 @@ camel_imap_store_class_init (CamelImapStoreClass *camel_imap_store_class)
camel_store_class->hash_folder_name = hash_folder_name;
camel_store_class->compare_folder_name = compare_folder_name;
camel_store_class->get_folder = get_folder;
+ camel_store_class->create_folder = create_folder;
camel_store_class->get_folder_info = get_folder_info;
camel_store_class->free_folder_info = camel_store_free_folder_info_full;
@@ -681,6 +683,42 @@ get_folder (CamelStore *store, const char *folder_name, guint32 flags,
return new_folder;
}
+static 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);
+}
+
+static CamelFolderInfo *
+create_folder (CamelStore *store, const char *parent_name,
+ const char *folder_name, CamelException *ex)
+{
+ CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
+ CamelFolderInfo *fi;
+ char *full_name;
+
+ if (parent_name)
+ full_name = imap_concat (imap_store, parent_name, folder_name);
+ else
+ full_name = g_strdup (folder_name);
+
+ imap_create (imap_store, full_name, ex);
+ if (camel_exception_is_set (ex)) {
+ g_free (full_name);
+ return NULL;
+ }
+
+ fi = get_folder_info (store, full_name, FALSE, FALSE, FALSE, ex);
+ g_free (full_name);
+ return fi;
+}
+
static CamelFolderInfo *
parse_list_response_as_folder_info (CamelImapStore *imap_store,
const char *response)
@@ -839,14 +877,7 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast,
if (subscribed_only && !imap_store->useful_lsub)
get_subscribed_folders_by_hand (imap_store, name, folders, ex);
else {
- if (*name && name[strlen (name) - 1] != imap_store->dir_sep) {
- pattern = g_strdup_printf ("%s%c%c", name,
- imap_store->dir_sep,
- recursive ? '*' : '%');
- } else {
- pattern = g_strdup_printf ("%s%c", name,
- recursive ? '*' : '%');
- }
+ pattern = imap_concat (imap_store, name, recursive ? "*" : "%");
get_folders (imap_store, pattern, folders, subscribed_only, ex);
g_free (pattern);
}