aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@inria.fr>1999-04-19 03:01:23 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-04-19 03:01:23 +0800
commitb6df9d55cb6d3b348c831f4591398a0acc8247d9 (patch)
tree3b1f0dca459cfede1e137decfb65364e4f7b1c3d
parent39eed88537557a8fab36894ee1bb4ab248f7261a (diff)
downloadgsoc2013-evolution-b6df9d55cb6d3b348c831f4591398a0acc8247d9.tar
gsoc2013-evolution-b6df9d55cb6d3b348c831f4591398a0acc8247d9.tar.gz
gsoc2013-evolution-b6df9d55cb6d3b348c831f4591398a0acc8247d9.tar.bz2
gsoc2013-evolution-b6df9d55cb6d3b348c831f4591398a0acc8247d9.tar.lz
gsoc2013-evolution-b6df9d55cb6d3b348c831f4591398a0acc8247d9.tar.xz
gsoc2013-evolution-b6df9d55cb6d3b348c831f4591398a0acc8247d9.tar.zst
gsoc2013-evolution-b6df9d55cb6d3b348c831f4591398a0acc8247d9.zip
implemented (partially) have to write CamelStore before finishing it.
1999-04-18 bertrand <Bertrand.Guiheneuf@inria.fr> * camel/camel-folder.c: (camel_folder_create): implemented (partially) have to write CamelStore before finishing it. * camel/camel-folder.h (CamelFolder): added full_name field (CamelFolderClass): added set/get_full_name methods Some more work svn path=/trunk/; revision=853
-rw-r--r--ChangeLog9
-rw-r--r--camel/camel-folder.c86
-rw-r--r--camel/camel-folder.h15
-rw-r--r--camel/gstring-util.c18
-rw-r--r--camel/gstring-util.h2
5 files changed, 124 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 9f78ca293c..77121e659a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+1999-04-18 bertrand <Bertrand.Guiheneuf@inria.fr>
+
+ * camel/camel-folder.c:
+ (camel_folder_create): implemented (partially)
+ have to write CamelStore before finishing it.
+
+ * camel/camel-folder.h (CamelFolder): added full_name field
+ (CamelFolderClass): added set/get_full_name methods
+
1999-04-18 bertrand <Bertrand.Guiheneuf@inria.fr>
* camel/camel-folder.c: some work
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index c1af6c7bbe..93b91f94b0 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -22,14 +22,19 @@
*/
#include "camel-folder.h"
+#include "gstring-util.h"
static GtkObjectClass *camel_folder_parent_class=NULL;
+/* Returns the class for a CamelFolder */
+#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass)
static void camel_folder_open(CamelFolder *folder);
static void camel_folder_close(CamelFolder *folder, gboolean expunge);
static void camel_folder_set_name(CamelFolder *folder, GString *name_string);
+static void camel_folder_set_full_name(CamelFolder *folder, GString *name_string);
static GString *camel_folder_get_name(CamelFolder *folder);
+static GString *camel_folder_get_full_name(CamelFolder *folder);
static gboolean camel_folder_can_hold_folders(CamelFolder *folder);
static gboolean camel_folder_can_hold_messages(CamelFolder *folder);
static gboolean camel_folder_exists(CamelFolder *folder);
@@ -132,6 +137,23 @@ camel_folder_set_name(CamelFolder *folder, GString *name_string)
}
+/**
+ * camel_folder_set_full_name : set the (full) name of the folder
+ *
+ * set the name of the folder.
+ * The old name object is freed.
+ *
+ * @name_string: new name of the folder
+ *
+ **/
+static void
+camel_folder_set_full_name(CamelFolder *folder, GString *name_string)
+{
+ if (folder->full_name) g_string_free(folder->full_name, 0);;
+ folder->full_name = name_string;
+}
+
+
/**
* camel_folder_get_name : get the (short) name of the folder
@@ -149,6 +171,22 @@ camel_folder_get_name(CamelFolder *folder)
}
+/**
+ * camel_folder_get_full_name : get the (full) name of the folder
+ *
+ * get the name of the folder. The fully qualified name
+ * can be obtained with the get_full_ame method (not implemented)
+ *
+ * @Return Value: name of the folder
+ *
+ **/
+static GString *
+camel_folder_get_full_name(CamelFolder *folder)
+{
+ return folder->full_name;
+}
+
+
/**
* camel_folder_can_hold_folders : tests if the folder can contain other folders
*
@@ -218,3 +256,51 @@ camel_folder_get_folder(CamelFolder *folder, GString *folderName)
}
+
+
+/**
+ * create : create the folder object on the physical store
+ *
+ * This routine physically creates the folder object on
+ * the store. Having created the object does not
+ * mean the folder physically exists. If it does not
+ * exists, this routine will create it.
+ * if the folder full name contains more than one level
+ * of hierarchy, all folders between the current folder
+ * and the last folder name will be created if not existing.
+ *
+ **/
+static void
+camel_folder_create(CamelFolder *folder)
+{
+ GString *prefix;
+ gchar dich_result;
+ CamelFolder *parent;
+ gchar sep;
+
+#warning Finish it when CamelStore is done
+
+ /*g_assert(folder->parent_store);*/
+ g_assert(folder->name);
+
+ if ( CF_CLASS(folder)->exists(folder) ) return;
+ /* sep = camel_store_get_separator(folder->parent_store); */
+ if (folder->parent_folder) camel_folder_create(folder->parent_folder);
+ else {
+ if (folder->full_name) {
+ dich_result = g_string_right_dichotomy(folder->full_name, sep, &prefix, NULL, STRIP_TRAILING);
+ if (dich_result!='o') {
+ g_warning("I have to handle the case where the path is not OK\n");
+ return;
+ } else {
+ /*
+ parent = camel_store_get_folder(folder->parentStore,prefix);
+ camel_folder_create(parent);
+ [parent free];
+ */
+ }
+ }
+ }
+}
+
+
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index e08b0ab618..12855a054c 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -51,9 +51,9 @@ typedef enum {
} CamelFolderOpenMode;
+typedef struct _CamelFolder CamelFolder;
-
-typedef struct
+struct _CamelFolder
{
GtkObject parent_object;
@@ -64,12 +64,13 @@ typedef struct
CamelFolderOpenMode open_mode;
CamelFolderState open_state;
GString *name;
- /*
- CamelStore *parent_store;
+ GString *full_name;
+#warning uncomment when CamelStore is done
+ /*CamelStore *parent_store;*/
CamelFolder *parent_folder;
- */
-} CamelFolder;
+
+};
@@ -80,7 +81,9 @@ typedef struct {
void (*open) (CamelFolder *object);
void (*close) (CamelFolder *folder, gboolean expunge);
void (*set_name) (CamelFolder *folder, GString *name_string);
+ void (*set_full_name) (CamelFolder *folder, GString *name_string);
GString * (*get_name) (CamelFolder *folder);
+ GString * (*get__full_name) (CamelFolder *folder);
gboolean (*can_hold_folders) (CamelFolder *folder);
gboolean (*can_hold_messages) (CamelFolder *folder);
gboolean (*exists) (CamelFolder *folder);
diff --git a/camel/gstring-util.c b/camel/gstring-util.c
index 9a1357babd..3c9d24d167 100644
--- a/camel/gstring-util.c
+++ b/camel/gstring-util.c
@@ -157,3 +157,21 @@ g_string_right_dichotomy( GString *string, gchar sep, GString **prefix, GString
return 'o';
}
+
+
+/**
+ * g_string_append_g_string : append a GString to another GString
+ *
+ * @dest_string : string which will be appended
+ * @other_string : string to append
+ *
+ **/
+void
+g_string_append_g_string(GString *dest_string, GString *other_string)
+{
+ g_assert(other_string);
+ g_assert(dest_string);
+ g_assert(other_string->str);
+
+ g_string_append(dest_string, other_string->str);
+}
diff --git a/camel/gstring-util.h b/camel/gstring-util.h
index 6f6adde14f..decb6ee064 100644
--- a/camel/gstring-util.h
+++ b/camel/gstring-util.h
@@ -44,6 +44,8 @@ typedef enum {
gboolean g_string_equals(GString *string1, GString *string2);
GString *g_string_clone(GString *string);
+gchar g_string_right_dichotomy( GString *string, gchar sep, GString **prefix, GString **suffix, DichotomyOption options);
+void g_string_append_g_string(GString *dest_string, GString *other_string);
#ifdef __cplusplus