aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-05 01:30:17 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-05 01:30:17 +0800
commitbbd88805c2120aec425e133f11a5bb3f5168d9a3 (patch)
tree28435078085ade60b94a34c45947670e15a74773 /camel
parentb92cd47ad5105869b66b2166e2dafecbf8d29c93 (diff)
downloadgsoc2013-evolution-bbd88805c2120aec425e133f11a5bb3f5168d9a3.tar.gz
gsoc2013-evolution-bbd88805c2120aec425e133f11a5bb3f5168d9a3.tar.zst
gsoc2013-evolution-bbd88805c2120aec425e133f11a5bb3f5168d9a3.zip
implemented.
1999-08-04 bertrand <Bertrand.Guiheneuf@aful.org> * camel/providers/MH/camel-mh-folder.c (_list_subfolders): implemented. svn path=/trunk/; revision=1077
Diffstat (limited to 'camel')
-rw-r--r--camel/camel-folder.h7
-rw-r--r--camel/providers/MH/camel-mh-folder.c50
2 files changed, 54 insertions, 3 deletions
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index 40d7d8f303..53ff89e70d 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -48,9 +48,10 @@ typedef enum {
} CamelFolderState;
typedef enum {
- FOLDER_OPEN_UNKNOWN, /* folder open mode is unknown */
- FOLDER_OPEN_READ, /* folder is read only */
- FOLDER_OPEN_READ_WRITE /* folder is read/write */
+ FOLDER_OPEN_UNKNOWN = 0, /* folder open mode is unknown */
+ FOLDER_OPEN_READ = 1, /* folder is read only */
+ FOLDER_OPEN_WRITE = 2, /* folder is write only */
+ FOLDER_OPEN_RW = 3 /* folder is read/write */
} CamelFolderOpenMode;
diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c
index 8027be95b6..ad910f4005 100644
--- a/camel/providers/MH/camel-mh-folder.c
+++ b/camel/providers/MH/camel-mh-folder.c
@@ -47,6 +47,7 @@ static gboolean _exists (CamelFolder *folder);
static gboolean _create(CamelFolder *folder);
static gboolean _delete (CamelFolder *folder, gboolean recurse);
static gboolean _delete_messages (CamelFolder *folder);
+static GList *_list_subfolders (CamelFolder *folder);
static void
camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class)
@@ -62,6 +63,7 @@ camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class)
camel_folder_class->exists = _exists;
camel_folder_class->delete = _delete;
camel_folder_class->delete_messages = _delete_messages;
+ camel_folder_class->list_subfolders = _list_subfolders;
}
@@ -279,6 +281,54 @@ _delete_messages (CamelFolder *folder)
+static GList *
+_list_subfolders(CamelFolder *folder)
+{
+ GList *subfolder_name_list = NULL;
+
+ CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
+ const gchar *directory_path;
+ struct stat stat_buf;
+ gint stat_error = 0;
+ GList *file_list;
+ gchar *entry_name;
+ struct dirent *dir_entry;
+ DIR *dir_handle;
+
+ g_assert(folder);
+
+ /* call default implementation */
+ parent_class->delete_messages (folder);
+
+ directory_path = mh_folder->directory_path;
+ if (!directory_path) return FALSE;
+
+ if (!camel_folder_exists (folder)) return TRUE;
+
+ dir_handle = opendir (directory_path);
+
+ /* read first entry in the directory */
+ dir_entry = readdir (dir_handle);
+ while ((stat_error != -1) && (unlink_error != -1) && (dir_entry != NULL)) {
+
+ /* get the name of the next entry in the dir */
+ entry_name = dir_entry->d_name;
+ stat_error = stat (mh_folder->directory_path, &stat_buf);
+
+ /* is it a directory ? */
+ if ((stat_error != -1) && S_ISDIR (stat_buf.st_mode)) {
+ /* yes, add it to the list */
+ CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::list_subfolders adding %s\n", entry_name);
+ subfolder_name_list = g_list_append (subfolder_name_list, g_strdup (entry_name));
+ }
+ /* read next entry */
+ dir_entry = readdir (dir_handle);
+ }
+
+ closedir (dir_handle);
+
+ return subfolder_name_list;
+}