aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/local/camel-maildir-store.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2004-03-13 05:28:41 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-03-13 05:28:41 +0800
commite28d5364ac2716e911c121657a20923682c5b2b2 (patch)
tree3a19fe2fc718a493d67b11498d2668094671b7f3 /camel/providers/local/camel-maildir-store.c
parent3f727f063b1e13a89588f9cd1e5cf45a89c391e1 (diff)
downloadgsoc2013-evolution-e28d5364ac2716e911c121657a20923682c5b2b2.tar
gsoc2013-evolution-e28d5364ac2716e911c121657a20923682c5b2b2.tar.gz
gsoc2013-evolution-e28d5364ac2716e911c121657a20923682c5b2b2.tar.bz2
gsoc2013-evolution-e28d5364ac2716e911c121657a20923682c5b2b2.tar.lz
gsoc2013-evolution-e28d5364ac2716e911c121657a20923682c5b2b2.tar.xz
gsoc2013-evolution-e28d5364ac2716e911c121657a20923682c5b2b2.tar.zst
gsoc2013-evolution-e28d5364ac2716e911c121657a20923682c5b2b2.zip
Fixes for bug #55018.
2004-03-12 Jeffrey Stedfast <fejj@ximian.com> Fixes for bug #55018. * providers/local/camel-local-folder.c (camel_local_folder_construct): Use camel_url_to_string() here too, so we properly encode the fragment. * providers/local/camel-mbox-store.c (get_folder_info): Use CamelURL to properly encode the fi->uri. Pass the CamelURL into scan_dir() so that scan_dir() can re-use it (rather than having to malloc/parse/free for each file/dir) (scan_dir): Use camel_url_to_string(). * providers/local/camel-maildir-store.c (get_folder_info): Same as mbox. (scan_dir): Same as mbox. We also need to set the CAMEL_FOLDER_NOSELECT flag if appropriate. * providers/local/camel-mh-store.c (get_folder_info): Same as mbox and maildir. (folders_scan): Now takes a url argument which we pass off to folder_info_new(). (recursive_scan): Same. (folder_info_new): Use camel_url_to_string(). svn path=/trunk/; revision=25050
Diffstat (limited to 'camel/providers/local/camel-maildir-store.c')
-rw-r--r--camel/providers/local/camel-maildir-store.c64
1 files changed, 37 insertions, 27 deletions
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index 5d0654c6e4..a7c3eb4624 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -222,7 +222,8 @@ static void delete_folder(CamelStore * store, const char *folder_name, CamelExce
g_free(new);
}
-static CamelFolderInfo *camel_folder_info_new(const char *url, const char *full, const char *name)
+static CamelFolderInfo *
+camel_folder_info_new (const char *url, const char *full, const char *name, guint32 flags)
{
CamelFolderInfo *fi;
@@ -232,12 +233,13 @@ static CamelFolderInfo *camel_folder_info_new(const char *url, const char *full,
fi->name = g_strdup(name);
fi->unread = -1;
fi->total = -1;
+ fi->flags = flags;
camel_folder_info_build_path(fi, '/');
-
+
if (!strcmp(full, "."))
fi->flags |= CAMEL_FOLDER_SYSTEM;
- d(printf("Adding maildir info: '%s' '%s' '%s' '%s'\n", fi->path, fi->name, fi->full_name, fi->url));
+ d(printf("Adding maildir info: '%s' '%s' '%s' '%s'\n", fi->path, fi->name, fi->full_name, fi->uri));
return fi;
}
@@ -281,13 +283,16 @@ struct _inode {
};
/* returns number of records found at or below this level */
-static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const char *path, guint32 flags, CamelFolderInfo *parent, CamelFolderInfo **fip, CamelException *ex)
+static int
+scan_dir (CamelStore *store, CamelURL *url, GHashTable *visited, char *root, const char *path, guint32 flags,
+ CamelFolderInfo *parent, CamelFolderInfo **fip, CamelException *ex)
{
DIR *dir;
struct dirent *d;
char *name, *uri, *tmp, *cur, *new;
const char *base;
CamelFolderInfo *fi = NULL;
+ guint32 fi_flags = 0;
struct stat st;
/* look for folders matching the right structure, recursively */
@@ -299,13 +304,11 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
cur = g_strdup_printf("%s/cur", name);
new = g_strdup_printf("%s/new", name);
- if (stat(tmp, &st) == 0 && S_ISDIR(st.st_mode)
- && stat(cur, &st) == 0 && S_ISDIR(st.st_mode)
- && stat(new, &st) == 0 && S_ISDIR(st.st_mode)) {
- uri = g_strdup_printf("maildir:%s#%s", root, path);
- } else
- uri = g_strdup_printf("maildir:%s;noselect=yes#%s", root, path);
-
+ if (!(stat (tmp, &st) == 0 && S_ISDIR (st.st_mode)
+ && stat (cur, &st) == 0 && S_ISDIR (st.st_mode)
+ && stat (new, &st) == 0 && S_ISDIR (st.st_mode)))
+ fi_flags = CAMEL_FOLDER_NOSELECT;
+
base = strrchr(path, '/');
if (base)
base++;
@@ -351,22 +354,25 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
closedir(dir);
}
}
-#endif
- fi = camel_folder_info_new(uri, path, base);
- fill_fi(store, fi, flags);
-
- d(printf("found! uri = %s\n", fi->url));
+#endif
+
+ g_free (tmp);
+ g_free (new);
+ g_free (cur);
+
+ uri = camel_url_to_string (url, 0);
+ fi = camel_folder_info_new (uri, path, base, fi_flags);
+ g_free (uri);
+
+ fill_fi (store, fi, flags);
+
+ d(printf("found! uri = %s\n", fi->uri));
d(printf(" full_name = %s\n name = '%s'\n", fi->full_name, fi->name));
fi->parent = parent;
fi->next = *fip;
*fip = fi;
- g_free(uri);
-
- g_free(tmp);
- g_free(cur);
- g_free(new);
-
+
/* always look further if asked */
if (((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) || parent == NULL)) {
int children = 0;
@@ -401,7 +407,7 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
*inew = in;
g_hash_table_insert(visited, inew, inew);
new = g_strdup_printf("%s/%s", path, d->d_name);
- if (scan_dir(store, visited, root, new, flags, fi, &fi->child, ex) == -1) {
+ if (scan_dir(store, url, visited, root, new, flags, fi, &fi->child, ex) == -1) {
g_free(tmp);
g_free(new);
closedir(dir);
@@ -450,16 +456,20 @@ get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelExcepti
CamelFolderInfo *fi = NULL;
CamelLocalStore *local_store = (CamelLocalStore *)store;
GHashTable *visited;
-
+ CamelURL *url;
+
+ url = camel_url_copy (((CamelService *) store)->url);
+
visited = g_hash_table_new(inode_hash, inode_equal);
-
- if (scan_dir(store, visited, ((CamelService *)local_store)->url->path, top?top:".", flags, NULL, &fi, ex) == -1 && fi != NULL) {
+
+ if (scan_dir(store, url, visited, ((CamelService *)local_store)->url->path, top?top:".", flags, NULL, &fi, ex) == -1 && fi != NULL) {
camel_store_free_folder_info_full(store, fi);
fi = NULL;
}
g_hash_table_foreach(visited, inode_free, NULL);
g_hash_table_destroy(visited);
-
+ camel_url_free (url);
+
return fi;
}