diff options
Diffstat (limited to 'camel')
-rw-r--r-- | camel/camel-folder.c | 43 | ||||
-rw-r--r-- | camel/camel-folder.h | 19 | ||||
-rw-r--r-- | camel/camel-service.c | 6 | ||||
-rw-r--r-- | camel/camel-store.c | 6 | ||||
-rw-r--r-- | camel/providers/MH/Makefile.am | 6 | ||||
-rw-r--r-- | camel/providers/MH/camel-mh-folder.c | 51 | ||||
-rw-r--r-- | camel/providers/MH/camel-mh-folder.h | 3 | ||||
-rw-r--r-- | camel/providers/MH/camel-mh-store.c | 89 | ||||
-rw-r--r-- | camel/providers/MH/camel-mh-store.h | 71 |
9 files changed, 261 insertions, 33 deletions
diff --git a/camel/camel-folder.c b/camel/camel-folder.c index 12c2d02db0..e33817b57c 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -24,29 +24,31 @@ #include "camel-folder.h" #include "gstring-util.h" -static GtkObjectClass *camel_folder_parent_class=NULL; +static GtkObjectClass *parent_class=NULL; /* Returns the class for a CamelFolder */ #define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) +static void camel_folder_init_with_store(CamelFolder *folder, CamelStore *parent_store); 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 void camel_folder_set_name(CamelFolder *folder, GString *name_); +static void camel_folder_set_full_name(CamelFolder *folder, GString *name); 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); static gboolean camel_folder_is_open(CamelFolder *folder); -static CamelFolder *camel_folder_get_folder(CamelFolder *folder, GString *folderName); +static CamelFolder *camel_folder_get_folder(CamelFolder *folder, GString *folder_name); static void camel_folder_class_init (CamelFolderClass *camel_folder_class) { - camel_folder_parent_class = gtk_type_class (gtk_object_get_type ()); + parent_class = gtk_type_class (gtk_object_get_type ()); /* virtual method definition */ + camel_folder_class->init_with_store = camel_folder_init_with_store; camel_folder_class->open = camel_folder_open; camel_folder_class->close = camel_folder_close; camel_folder_class->set_name = camel_folder_set_name; @@ -90,6 +92,27 @@ camel_folder_get_type (void) } + + +/** + * camel_folder_init_with_store: init the folder by setting its parent store. + * + * @folder: folder object to initialize + * @parent_store: parent store object of the folder + * + * + **/ +static void +camel_folder_init_with_store(CamelFolder *folder, CamelStore *parent_store) +{ + g_assert(folder); + g_assert(parent_store); + + folder->parent_store = parent_store; +} + + + /** * camel_folder_open: Open a folder * @@ -130,10 +153,10 @@ camel_folder_close(CamelFolder *folder, gboolean expunge) * **/ static void -camel_folder_set_name(CamelFolder *folder, GString *name_string) +camel_folder_set_name(CamelFolder *folder, GString *name) { if (folder->name) g_string_free(folder->name, 0);; - folder->name = name_string; + folder->name = name; } @@ -147,10 +170,10 @@ camel_folder_set_name(CamelFolder *folder, GString *name_string) * **/ static void -camel_folder_set_full_name(CamelFolder *folder, GString *name_string) +camel_folder_set_full_name(CamelFolder *folder, GString *name) { if (folder->full_name) g_string_free(folder->full_name, 0);; - folder->full_name = name_string; + folder->full_name = name; } @@ -250,7 +273,7 @@ camel_folder_is_open(CamelFolder *folder) * could not be created **/ static CamelFolder * -camel_folder_get_folder(CamelFolder *folder, GString *folderName) +camel_folder_get_folder(CamelFolder *folder, GString *folder_name) { g_warning("getFolder called on the abstract CamelFolder class\n"); return NULL; diff --git a/camel/camel-folder.h b/camel/camel-folder.h index e92a58982d..96847eb05c 100644 --- a/camel/camel-folder.h +++ b/camel/camel-folder.h @@ -87,17 +87,18 @@ typedef struct { GtkObjectClass parent_class; /* Virtual methods */ + void (*init_with_store) (CamelFolder *folder, CamelStore *parent_store); 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); - gboolean (*is_open) (CamelFolder *folder); - CamelFolder * (*get_folder) (CamelFolder *folder, GString *folderName); + void (*set_name) (CamelFolder *folder, GString *name); + void (*set_full_name) (CamelFolder *folder, GString *name); + 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); + gboolean (*is_open) (CamelFolder *folder); + CamelFolder * (*get_folder) (CamelFolder *folder, GString *folder_name); } CamelFolderClass; diff --git a/camel/camel-service.c b/camel/camel-service.c index dd909cbb1f..a07f2fa729 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -23,7 +23,7 @@ #include "camel-service.h" -static GtkObjectClass *camel_service_parent_class=NULL; +static GtkObjectClass *parent_class=NULL; /* Returns the class for a CamelService */ #define CSERV_CLASS(so) CAMEL_SERVICE_CLASS (GTK_OBJECT(so)->klass) @@ -36,7 +36,7 @@ static void camel_service_set_connected(CamelService *service, gboolean state); static void camel_service_class_init (CamelServiceClass *camel_service_class) { - camel_service_parent_class = gtk_type_class (gtk_object_get_type ()); + parent_class = gtk_type_class (gtk_object_get_type ()); /* virtual method definition */ camel_service_class->connect = camel_service_connect; @@ -92,7 +92,7 @@ camel_service_get_type (void) * * @service: object to connect **/ -static void +void camel_service_connect(CamelService *service) { diff --git a/camel/camel-store.c b/camel/camel-store.c index d3f693ad93..5723534138 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -23,7 +23,7 @@ #include "camel-store.h" -static GtkObjectClass *camel_store_parent_class=NULL; +static GtkObjectClass *parent_class=NULL; /* Returns the class for a CamelStore */ #define CS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) @@ -37,7 +37,7 @@ static CamelFolder *camel_store_get_default_folder(CamelStore *store); static void camel_store_class_init (CamelStoreClass *camel_store_class) { - camel_store_parent_class = gtk_type_class (camel_service_get_type ()); + parent_class = gtk_type_class (camel_service_get_type ()); /* virtual method definition */ camel_store_class->set_separator = camel_store_set_separator; @@ -72,7 +72,7 @@ camel_store_get_type (void) (GtkClassInitFunc) NULL, }; - camel_store_type = gtk_type_unique (gtk_object_get_type (), &camel_store_info); + camel_store_type = gtk_type_unique (CAMEL_SERVICE_TYPE, &camel_store_info); } return camel_store_type; diff --git a/camel/providers/MH/Makefile.am b/camel/providers/MH/Makefile.am index 9946650188..0f52c9fb40 100644 --- a/camel/providers/MH/Makefile.am +++ b/camel/providers/MH/Makefile.am @@ -12,10 +12,12 @@ INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ $(GTK_INCLUDEDIR) -I$(top_srcdir)/camel libcamelmh_la_SOURCES = \ - camel-mh-folder.c + camel-mh-folder.c \ + camel-mh-store.c libcamelmhinclude_HEADERS = \ - camel-mh-folder.h + camel-mh-folder.h \ + camel-mh-store.h libcamelmh_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c index abaf638df8..d875182564 100644 --- a/camel/providers/MH/camel-mh-folder.c +++ b/camel/providers/MH/camel-mh-folder.c @@ -23,19 +23,24 @@ #include "camel-mh-folder.h" -static CamelMhFolderClass *camel_mh_folder_parent_class=NULL; +static CamelFolderClass *parent_class=NULL; /* Returns the class for a CamelMhFolder */ #define CMHF_CLASS(so) CAMEL_MH_FOLDER_CLASS (GTK_OBJECT(so)->klass) +#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) +#define CMHS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) + +static void camel_mh_folder_set_name(CamelFolder *folder, GString *name); static void camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class) { - camel_mh_folder_parent_class = gtk_type_class (camel_folder_get_type ()); + parent_class = gtk_type_class (camel_folder_get_type ()); /* virtual method definition */ /* virtual method overload */ + CAMEL_FOLDER_CLASS(camel_mh_folder_class)->set_name = camel_mh_folder_set_name; } @@ -53,8 +58,8 @@ camel_mh_folder_get_type (void) GtkTypeInfo camel_mh_folder_info = { "CamelMhFolder", - sizeof (CamelFolder), - sizeof (CamelFolderClass), + sizeof (CamelMhFolder), + sizeof (CamelMhFolderClass), (GtkClassInitFunc) camel_mh_folder_class_init, (GtkObjectInitFunc) NULL, /* reserved_1 */ NULL, @@ -62,10 +67,46 @@ camel_mh_folder_get_type (void) (GtkClassInitFunc) NULL, }; - camel_mh_folder_type = gtk_type_unique (gtk_object_get_type (), &camel_mh_folder_info); + camel_mh_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_mh_folder_info); } return camel_mh_folder_type; } +/** + * camel_mh_folder_set_name: set the name of an MH folder + * @folder: the folder to set the name + * @name: a string representing the (short) name + * + * + * + **/ +static void +camel_mh_folder_set_name(CamelFolder *folder, GString *name) +{ + GString *root_dir_path; + GString *full_dir_path; + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); + gchar separator; + + g_assert(folder); + g_assert(name); + g_assert(folder->parent_store); + + /* call default implementation */ + parent_class->set_name (folder, name); + + if (mh_folder->directory_path) g_string_free (mh_folder->directory_path, 0); + + separator = camel_store_get_separator (folder->parent_store); + + + root_dir_path = camel_mh_store_get_toplevel_dir (CAMEL_MH_STORE(folder->parent_store)); + full_dir_path = g_string_clone(root_dir_path); + g_string_append_c(full_dir_path, separator); + g_string_append_g_string(full_dir_path, name); + mh_folder->directory_path = full_dir_path; + + +} diff --git a/camel/providers/MH/camel-mh-folder.h b/camel/providers/MH/camel-mh-folder.h index 41650c9cf1..2e9fbb47f0 100644 --- a/camel/providers/MH/camel-mh-folder.h +++ b/camel/providers/MH/camel-mh-folder.h @@ -44,7 +44,8 @@ extern "C" { typedef struct { CamelFolder parent_object; - + GString *directory_path; + } CamelMhFolder; diff --git a/camel/providers/MH/camel-mh-store.c b/camel/providers/MH/camel-mh-store.c new file mode 100644 index 0000000000..2a1258a7b9 --- /dev/null +++ b/camel/providers/MH/camel-mh-store.c @@ -0,0 +1,89 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* camel-mh-store.c : class for an mh store */ + +/* + * + * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#include "camel-mh-store.h" +#include "camel-mh-folder.h" + +static GtkObjectClass *parent_class=NULL; + +/* Returns the class for a CamelMhStore */ +#define CS_CLASS(so) CAMEL_MH_STORE_CLASS (GTK_OBJECT(so)->klass) + + + +static void +camel_mh_store_class_init (CamelMhStoreClass *camel_mh_store_class) +{ + parent_class = gtk_type_class (camel_store_get_type ()); + + /* virtual method definition */ + /* virtual method overload */ +} + + + + + + + +GtkType +camel_mh_store_get_type (void) +{ + static GtkType camel_mh_store_type = 0; + + if (!camel_mh_store_type) { + GtkTypeInfo camel_mh_store_info = + { + "CamelMhStore", + sizeof (CamelMhStore), + sizeof (CamelMhStoreClass), + (GtkClassInitFunc) camel_mh_store_class_init, + (GtkObjectInitFunc) NULL, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + camel_mh_store_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_mh_store_info); + } + + return camel_mh_store_type; +} + + + + +/** These evil public functions are here for test only **/ +void +camel_mh_store_set_toplevel_dir(CamelMhStore *store, GString *toplevel) +{ + store->toplevel_dir = toplevel; + CAMEL_STORE(store)->separator = '/'; +} + + +GString * +camel_mh_store_get_toplevel_dir(CamelMhStore *store) +{ + return store->toplevel_dir; +} diff --git a/camel/providers/MH/camel-mh-store.h b/camel/providers/MH/camel-mh-store.h new file mode 100644 index 0000000000..058eb48c64 --- /dev/null +++ b/camel/providers/MH/camel-mh-store.h @@ -0,0 +1,71 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* camel-mhstore.h : class for an mh store */ + +/* + * + * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + + +#ifndef CAMEL_MH_STORE_H +#define CAMEL_MH_STORE_H 1 + + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus }*/ + +#include <gtk/gtk.h> +#include "camel-store.h" + +#define CAMEL_MH_STORE_TYPE (camel_mh_store_get_type ()) +#define CAMEL_MH_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_MH_STORE_TYPE, CamelMhStore)) +#define CAMEL_MH_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MH_STORE_TYPE, CamelMhStoreClass)) +#define IS_CAMEL_MH_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_MH_STORE_TYPE)) + + +typedef struct { + CamelStore parent_object; + + GString *toplevel_dir; + +} CamelMhStore; + + + +typedef struct { + CamelStoreClass parent_class; + + +} CamelMhStoreClass; + + +/* public methods */ + +/* Standard Gtk function */ +GtkType camel_mh_store_get_type (void); + +void camel_mh_store_set_toplevel_dir(CamelMhStore *store, GString *toplevel); +GString *camel_mh_store_get_toplevel_dir(CamelMhStore *store); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* CAMEL_MH_STORE_H */ |