From d728e1e79c7a6e3d7797775de7d9ef0320937422 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 20 Sep 2001 21:28:10 +0000 Subject: And finally here. 2001-09-20 Jeffrey Stedfast * providers/local/camel-spool-folder.c (camel_spool_folder_construct): And finally here. * providers/local/camel-local-folder.c (camel_local_folder_construct): And here. * camel-vee-store.c (vee_get_folder): ANd here too. (vee_get_folder_info): And here. * providers/imap/camel-imap-store.c (create_folder): Use camel_folder_info_build() and do better error checking. (subscribe_folder): Set the path on the folder info. * camel-store.c (camel_folder_info_build): Set the folder-info path if it hasn't already been set by the caller. (camel_folder_info_free): Free the path. * camel-store.h: Added a path member to the FolderInfo type. svn path=/trunk/; revision=13019 --- camel/ChangeLog | 21 +++++++++ camel/camel-store.c | 31 ++++++++++++- camel/camel-store.h | 5 +- camel/camel-vee-store.c | 2 + camel/providers/imap/camel-imap-store.c | 73 ++++++++++++++++++++---------- camel/providers/local/camel-local-folder.c | 1 + camel/providers/local/camel-spool-folder.c | 2 + 7 files changed, 108 insertions(+), 27 deletions(-) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index c4b9c19af7..f826c94d4e 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,24 @@ +2001-09-20 Jeffrey Stedfast + + * providers/local/camel-spool-folder.c + (camel_spool_folder_construct): And finally here. + + * providers/local/camel-local-folder.c + (camel_local_folder_construct): And here. + + * camel-vee-store.c (vee_get_folder): ANd here too. + (vee_get_folder_info): And here. + + * providers/imap/camel-imap-store.c (create_folder): Use + camel_folder_info_build() and do better error checking. + (subscribe_folder): Set the path on the folder info. + + * camel-store.c (camel_folder_info_build): Set the folder-info + path if it hasn't already been set by the caller. + (camel_folder_info_free): Free the path. + + * camel-store.h: Added a path member to the FolderInfo type. + 2001-09-20 Dan Winship * camel-charset-map.c (camel_charset_to_iconv): Nuke debug warning. diff --git a/camel/camel-store.c b/camel/camel-store.c index 7f8dab06b3..adef02a0b3 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -666,12 +666,34 @@ camel_folder_info_free (CamelFolderInfo *fi) camel_folder_info_free (fi->child); g_free (fi->name); g_free (fi->full_name); + g_free (fi->path); g_free (fi->url); g_free (fi); } } +/** + * camel_folder_info_build_path: + * @fi: folder info + * @separator: directory separator + * + * Sets the folder info path based on the folder's full name and + * directory separator. + **/ +void +camel_folder_info_build_path (CamelFolderInfo *fi, char separator) +{ + fi->path = g_strdup (fi->full_name); + if (separator != '/') { + char *p; + + p = fi->path; + while ((p = strchr (p, separator))) + *p = '/'; + } +} + /** * camel_folder_info_build: * @folders: an array of CamelFolderInfo @@ -725,6 +747,11 @@ camel_folder_info_build (GPtrArray *folders, const char *namespace, name = fi->full_name; if (*name == separator) name++; + + /* set the path if it isn't already set */ + if (!fi->path) + camel_folder_info_build_path (fi, separator); + p = strrchr (name, separator); if (p) { pname = g_strndup (name, p - name); @@ -752,6 +779,8 @@ camel_folder_info_build (GPtrArray *folders, const char *namespace, *sep = '\0'; else g_warning ("huh, no \"%c\" in \"%s\"?", separator, fi->url); + + /* FIXME: wtf is this? This is WRONG. Parent folders can be selectable */ camel_url_set_param (url, "noselect", "yes"); pfi->url = camel_url_to_string (url, 0); camel_url_free (url); @@ -776,7 +805,7 @@ camel_folder_info_build (GPtrArray *folders, const char *namespace, fi->sibling = top; top = fi; } - + return top; } diff --git a/camel/camel-store.h b/camel/camel-store.h index 40d34db3cf..8f7f566d3a 100644 --- a/camel/camel-store.h +++ b/camel/camel-store.h @@ -45,8 +45,9 @@ typedef struct _CamelFolderInfo { *sibling, *child; char *url; - char *full_name; char *name; + char *full_name; + char *path; int unread_message_count; } CamelFolderInfo; @@ -176,6 +177,8 @@ void camel_store_free_folder_info_nop (CamelStore *store, CamelFolderInfo *fi); void camel_folder_info_free (CamelFolderInfo *fi); +void camel_folder_info_build_path (CamelFolderInfo *fi, + char separator); CamelFolderInfo *camel_folder_info_build (GPtrArray *folders, const char *namespace, char separator, diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c index 30e4a43f79..48465fc87a 100644 --- a/camel/camel-vee-store.c +++ b/camel/camel-vee-store.c @@ -135,6 +135,7 @@ vee_get_folder (CamelStore *store, const char *folder_name, guint32 flags, Camel fi->url = g_strdup_printf("vfolder:%s#%s", ((CamelService *)store)->url->path, ((CamelFolder *)vf)->full_name); fi->unread_message_count = camel_folder_get_message_count((CamelFolder *)vf); + fi->path = g_strdup (fi->full_name); camel_object_trigger_event(CAMEL_OBJECT(store), "folder_created", fi); camel_folder_info_free(fi); } @@ -212,6 +213,7 @@ vee_get_folder_info(CamelStore *store, const char *top, guint32 flags, CamelExce info->full_name = g_strdup("UNMATCHED"); info->name = g_strdup("UNMATCHED"); info->unread_message_count = -1; + info->path = g_strdup (info->full_name); g_ptr_array_add(data.infos, info); } diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index b58b97fa83..08c871cee3 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -4,7 +4,7 @@ /* * Authors: * Dan Winship - * Jeffrey Stedfast + * Jeffrey Stedfast * * Copyright 2000, 2001 Ximian, Inc. * @@ -1043,10 +1043,12 @@ create_folder (CamelStore *store, const char *parent_name, CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); char *full_name, *resp, *thisone; CamelImapResponse *response; - CamelFolderInfo *root, *fi; + CamelException internal_ex; + CamelFolderInfo *root = NULL; gboolean need_convert; - char **pathnames; - int i, flags; + char **pathnames = NULL; + GPtrArray *folders = NULL; + int i = 0, flags; if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (store), ex)) return NULL; @@ -1077,10 +1079,11 @@ create_folder (CamelStore *store, const char *parent_name, camel_imap_response_free (imap_store, response); + camel_exception_init (&internal_ex); + /* if not, check if we can delete it and recreate it */ if (need_convert) { - gchar *name; - CamelException internal_ex; + char *name; if (get_folder_status (imap_store, parent_name, "MESSAGES")) { camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE, @@ -1089,7 +1092,6 @@ create_folder (CamelStore *store, const char *parent_name, } /* delete the old parent and recreate it */ - camel_exception_init (&internal_ex); delete_folder (store, parent_name, &internal_ex); if (camel_exception_is_set (&internal_ex)) { camel_exception_xfer (ex, &internal_ex); @@ -1116,45 +1118,62 @@ create_folder (CamelStore *store, const char *parent_name, g_free (full_name); if (response) { - CamelFolderInfo *parent; - GPtrArray *folders; - camel_imap_response_free (imap_store, response); /* We have to do this in case we are creating a recursive directory structure */ + i = 0; pathnames = imap_parse_folder_name (imap_store, folder_name); - full_name = imap_concat (imap_store, parent_name, pathnames[0]); - g_free (pathnames[0]); + full_name = imap_concat (imap_store, parent_name, pathnames[i]); + g_free (pathnames[i]); folders = g_ptr_array_new (); + get_folders_online (imap_store, full_name, folders, FALSE, ex); - parent = root = folders->pdata[0]; g_free (full_name); + if (camel_exception_is_set (&internal_ex)) { + camel_exception_xfer (&internal_ex, ex); + goto exception; + } - for (i = 1; parent && pathnames[i]; i++) { + for (i = 1; pathnames[i]; i++) { full_name = imap_concat (imap_store, parent_name, pathnames[i]); g_free (pathnames[i]); - get_folders_online (imap_store, full_name, folders, FALSE, ex); + get_folders_online (imap_store, full_name, folders, FALSE, &internal_ex); + if (camel_exception_is_set (&internal_ex)) { + camel_exception_xfer (&internal_ex, ex); + goto exception; + } g_free (full_name); if (folders->len != i + 1) break; - - fi = folders->pdata[i]; - - fi->parent = parent; - parent->child = fi; - parent = fi; } g_free (pathnames); + + root = camel_folder_info_build (folders, camel_url_get_param (CAMEL_SERVICE (store)->url, "namespace"), + imap_store->dir_sep, TRUE); + g_ptr_array_free (folders, TRUE); - } else - root = NULL; + } return root; + + exception: + + for (/* i is already set */; pathnames && pathnames[i]; i++) + g_free (pathnames[i]); + g_free (pathnames); + + if (folders) { + for (i = 0; i < folders->len; i++) + camel_folder_info_free (folders->pdata[i]); + g_ptr_array_free (folders, TRUE); + } + + return NULL; } static CamelFolderInfo * @@ -1522,13 +1541,17 @@ subscribe_folder (CamelStore *store, const char *folder_name, name = strrchr (folder_name, imap_store->dir_sep); if (name) name++; - + + /* FIXME: we should probably relocate all code that generates + fi->path to a single location and have all code use that */ fi = g_new0 (CamelFolderInfo, 1); fi->full_name = g_strdup (folder_name); fi->name = g_strdup (name); fi->url = g_strdup_printf ("%s/%s", imap_store->base_url, folder_name); fi->unread_message_count = -1; - + + camel_folder_info_build_path (fi, imap_store->dir_sep); + camel_object_trigger_event (CAMEL_OBJECT (store), "folder_created", fi); camel_folder_info_free (fi); } diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c index 927ca105ae..bce610bc70 100644 --- a/camel/providers/local/camel-local-folder.c +++ b/camel/providers/local/camel-local-folder.c @@ -226,6 +226,7 @@ camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, con fi->name = g_strdup (name); fi->url = g_strdup (lf->folder_path); fi->unread_message_count = -1; + fi->path = g_strdup (full_name); camel_object_trigger_event (CAMEL_OBJECT (parent_store), "folder_created", fi); diff --git a/camel/providers/local/camel-spool-folder.c b/camel/providers/local/camel-spool-folder.c index c5e9165917..43b8abec60 100644 --- a/camel/providers/local/camel-spool-folder.c +++ b/camel/providers/local/camel-spool-folder.c @@ -208,6 +208,8 @@ camel_spool_folder_construct(CamelSpoolFolder *lf, CamelStore *parent_store, con fi->name = g_strdup(name); fi->url = g_strdup(lf->folder_path); fi->unread_message_count = camel_folder_get_unread_message_count(folder); + fi->path = g_strdup (full_name); + camel_object_trigger_event(CAMEL_OBJECT(parent_store), "folder_created", fi); camel_folder_info_free (fi); -- cgit v1.2.3