diff options
author | bertrand <Bertrand.Guiheneuf@aful.org> | 1999-08-04 02:08:04 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-08-04 02:08:04 +0800 |
commit | 0f2d4dd1153bb7491c5494843d959148a31a895d (patch) | |
tree | f2d88dcc56a504498f59979c01e97729a7c53afc /camel/providers/MH | |
parent | b9daf0016bc3d7244ced57dd88f63c1fd6debbac (diff) | |
download | gsoc2013-evolution-0f2d4dd1153bb7491c5494843d959148a31a895d.tar gsoc2013-evolution-0f2d4dd1153bb7491c5494843d959148a31a895d.tar.gz gsoc2013-evolution-0f2d4dd1153bb7491c5494843d959148a31a895d.tar.bz2 gsoc2013-evolution-0f2d4dd1153bb7491c5494843d959148a31a895d.tar.lz gsoc2013-evolution-0f2d4dd1153bb7491c5494843d959148a31a895d.tar.xz gsoc2013-evolution-0f2d4dd1153bb7491c5494843d959148a31a895d.tar.zst gsoc2013-evolution-0f2d4dd1153bb7491c5494843d959148a31a895d.zip |
Started implementing mh store/folder as a test provider. Next will be pop3.
1999-08-03 bertrand <Bertrand.Guiheneuf@aful.org>
* camel/providers/MH/camel-mh-folder.c (_create):
implemented.
(_delete): started implementation.
* camel/camel-folder.c (_get_folder): default implementation
calls camel_store_get_folder ().
* camel/providers/MH/camel-mh-folder.c (_init_with_store):
implemented.
* camel/camel-folder.h (struct _CamelFolder):
remove useless exist_on_store field.
* camel/camel-folder.c (_exists):
do not use exist_on_store field.
svn path=/trunk/; revision=1073
Diffstat (limited to 'camel/providers/MH')
-rw-r--r-- | camel/providers/MH/camel-mh-folder.c | 102 |
1 files changed, 98 insertions, 4 deletions
diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c index 2db3a74e8e..206636578b 100644 --- a/camel/providers/MH/camel-mh-folder.c +++ b/camel/providers/MH/camel-mh-folder.c @@ -24,6 +24,11 @@ #include "camel-mh-folder.h" #include "camel-mh-store.h" #include "gstring-util.h" +#include <sys/stat.h> +#include <unistd.h> +#include <sys/types.h> +#include <fcntl.h> + static CamelFolderClass *parent_class=NULL; @@ -34,16 +39,23 @@ static CamelFolderClass *parent_class=NULL; #define CMHS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) static void _set_name(CamelFolder *folder, const gchar *name); - +static void _init_with_store (CamelFolder *folder, CamelStore *parent_store); +static gboolean _exists (CamelFolder *folder); +static gboolean _create(CamelFolder *folder); static void camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class) { + CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS(camel_mh_folder_class); + parent_class = gtk_type_class (camel_folder_get_type ()); - + /* virtual method definition */ /* virtual method overload */ - CAMEL_FOLDER_CLASS(camel_mh_folder_class)->set_name = _set_name; + camel_folder_class->init_with_store = _init_with_store; + camel_folder_class->set_name = _set_name; + camel_folder_class->exists = _exists; + } @@ -77,6 +89,20 @@ camel_mh_folder_get_type (void) } + + +static void +_init_with_store (CamelFolder *folder, CamelStore *parent_store) +{ + /* call parent method */ + parent_class->init_with_store (folder, parent_store); + + folder->can_hold_messages = TRUE; + folder->can_hold_folders = TRUE; +} + + + /** * camel_mh_folder_set_name: set the name of an MH folder * @folder: the folder to set the name @@ -88,10 +114,10 @@ camel_mh_folder_get_type (void) static void _set_name (CamelFolder *folder, const gchar *name) { + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); const gchar *root_dir_path; gchar *full_name; const gchar *parent_full_name; - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); gchar separator; g_assert(folder); @@ -110,3 +136,71 @@ _set_name (CamelFolder *folder, const gchar *name) } + + +static gboolean +_exists (CamelFolder *folder) +{ + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); + struct stat stat_buf; + gint stat_error; + gboolean exists; + + g_assert (folder); + + if (!mh_folder->directory_path) return FALSE; + + stat_error = stat (mh_folder->directory_path, &stat_buf); + if (stat_error == -1) return FALSE; + + exists = S_ISDIR(stat_buf.st_mode); + return exists; +} + + +static gboolean +_create(CamelFolder *folder) +{ + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); + const gchar *directory_path; + mode_t dir_mode = S_IRWXU; + gint mkdir_error; + + g_assert(folder); + + /* call default implementation */ + parent_class->create (folder); + + directory_path = mh_folder->directory_path; + if (!directory_path) return FALSE; + + if (camel_folder_exists (folder)) return TRUE; + + mkdir_error = mkdir (directory_path, dir_mode); + return (mkdir_error == -1); +} + + + +static gboolean +_delete (CamelFolder *folder, gboolean recurse) +{ + + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); + const gchar *directory_path; + gint rmdir_error; + + g_assert(folder); + + /* call default implementation */ + parent_class->delete (folder, recurse); + + directory_path = mh_folder->directory_path; + if (!directory_path) return FALSE; + + if (!camel_folder_exists (folder)) return TRUE; + + + rmdir_error = rmdir (directory_path); + +} |