aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/mbox
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-09-20 01:27:09 +0800
committerDan Winship <danw@src.gnome.org>2000-09-20 01:27:09 +0800
commit7dcc0325454ed6c71c2532befbb6aadb32391766 (patch)
tree744535557a2ab1e23278778ac464dcab718e03c1 /camel/providers/mbox
parent053af645da6e5f74474d13c19ce73d236d9b76a9 (diff)
downloadgsoc2013-evolution-7dcc0325454ed6c71c2532befbb6aadb32391766.tar
gsoc2013-evolution-7dcc0325454ed6c71c2532befbb6aadb32391766.tar.gz
gsoc2013-evolution-7dcc0325454ed6c71c2532befbb6aadb32391766.tar.bz2
gsoc2013-evolution-7dcc0325454ed6c71c2532befbb6aadb32391766.tar.lz
gsoc2013-evolution-7dcc0325454ed6c71c2532befbb6aadb32391766.tar.xz
gsoc2013-evolution-7dcc0325454ed6c71c2532befbb6aadb32391766.tar.zst
gsoc2013-evolution-7dcc0325454ed6c71c2532befbb6aadb32391766.zip
Removed (camel_folder_init, camel_folder_construct): New object init
* camel-folder.c: (init): Removed (camel_folder_init, camel_folder_construct): New object init function and public object constructor to replace the old init method in a more Gtk-like fashion. (get_parent_folder, camel_folder_get_parent_folder): Removed. No CamelFolder subclass was ever setting the parent_folder member, no code has ever needed to look at it, and fixing it would actually be pretty hard. (get_subfolder_info, camel_folder_get_subfolder_info): Renamed from ..._names. Deals in CamelFolderInfo now. (free_subfolder_info, camel_folder_free_subfolder_info): Likewise. (get_subfolder, camel_folder_get_subfolder): Removed. CamelFolderInfo contains the subfolder's full name, so this is unnecessary now, and removing it lets us get rid of the CamelFolder separator member, which is needed for the default implementation of this function, but not otherwise needed for most providers. Also, lots of code style fixes. * providers/*: Update CamelFolder subclasses for changes, although none of them fill in the message counts in the CamelFolderInfo yet. svn path=/trunk/; revision=5503
Diffstat (limited to 'camel/providers/mbox')
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c91
-rw-r--r--camel/providers/mbox/camel-mbox-folder.h1
-rw-r--r--camel/providers/mbox/camel-mbox-store.c9
3 files changed, 51 insertions, 50 deletions
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index f924d1d4ab..7aaf9d8593 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -56,9 +56,6 @@ static CamelFolderClass *parent_class = NULL;
#define CMBOXS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-static void mbox_init(CamelFolder *folder, CamelStore * parent_store,
- CamelFolder *parent_folder, const gchar * name,
- gchar * separator, gboolean path_begins_with_sep, CamelException *ex);
static void mbox_refresh_info (CamelFolder *folder, CamelException *ex);
static void mbox_sync(CamelFolder *folder, gboolean expunge, CamelException *ex);
static gint mbox_get_message_count(CamelFolder *folder);
@@ -67,7 +64,7 @@ static void mbox_append_message(CamelFolder *folder, CamelMimeMessage * message,
CamelException *ex);
static GPtrArray *mbox_get_uids(CamelFolder *folder);
-static GPtrArray *mbox_get_subfolder_names(CamelFolder *folder);
+static GPtrArray *mbox_get_subfolder_info(CamelFolder *folder);
static GPtrArray *mbox_get_summary(CamelFolder *folder);
static CamelMimeMessage *mbox_get_message(CamelFolder *folder, const gchar * uid, CamelException *ex);
@@ -98,7 +95,6 @@ camel_mbox_folder_class_init(CamelMboxFolderClass * camel_mbox_folder_class)
/* virtual method definition */
/* virtual method overload */
- camel_folder_class->init = mbox_init;
camel_folder_class->refresh_info = mbox_refresh_info;
camel_folder_class->sync = mbox_sync;
camel_folder_class->get_message_count = mbox_get_message_count;
@@ -106,8 +102,8 @@ camel_mbox_folder_class_init(CamelMboxFolderClass * camel_mbox_folder_class)
camel_folder_class->append_message = mbox_append_message;
camel_folder_class->get_uids = mbox_get_uids;
camel_folder_class->free_uids = camel_folder_free_deep;
- camel_folder_class->get_subfolder_names = mbox_get_subfolder_names;
- camel_folder_class->free_subfolder_names = camel_folder_free_deep;
+ camel_folder_class->get_subfolder_info = mbox_get_subfolder_info;
+ camel_folder_class->free_subfolder_info = camel_folder_free_shallow;
camel_folder_class->get_summary = mbox_get_summary;
camel_folder_class->free_summary = camel_folder_free_nop;
camel_folder_class->expunge = mbox_expunge;
@@ -128,6 +124,26 @@ camel_mbox_folder_class_init(CamelMboxFolderClass * camel_mbox_folder_class)
}
static void
+mbox_init(gpointer object, gpointer klass)
+{
+ CamelFolder *folder = object;
+ CamelMboxFolder *mbox_folder = object;
+
+ folder->can_hold_messages = TRUE;
+ folder->can_hold_folders = TRUE;
+ folder->has_summary_capability = TRUE;
+ folder->has_search_capability = TRUE;
+
+ folder->permanent_flags = CAMEL_MESSAGE_ANSWERED |
+ CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_DRAFT |
+ CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_USER;
+ /* FIXME: we don't actually preserve user flags right now. */
+
+ mbox_folder->summary = NULL;
+ mbox_folder->search = NULL;
+}
+
+static void
mbox_finalize(CamelObject * object)
{
CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(object);
@@ -152,54 +168,45 @@ CamelType camel_mbox_folder_get_type(void)
sizeof(CamelMboxFolderClass),
(CamelObjectClassInitFunc) camel_mbox_folder_class_init,
NULL,
- (CamelObjectInitFunc) NULL,
+ (CamelObjectInitFunc) mbox_init,
(CamelObjectFinalizeFunc) mbox_finalize);
}
return camel_mbox_folder_type;
}
-static void
-mbox_init(CamelFolder *folder, CamelStore * parent_store,
- CamelFolder *parent_folder, const gchar * name, gchar * separator,
- gboolean path_begins_with_sep, CamelException *ex)
+CamelFolder *
+camel_mbox_folder_new(CamelStore *parent_store, const char *full_name, CamelException *ex)
{
- CamelMboxFolder *mbox_folder = (CamelMboxFolder *) folder;
- const gchar *root_dir_path;
- gchar *real_name;
+ CamelFolder *folder;
+ CamelMboxFolder *mbox_folder;
+ const char *root_dir_path, *name;
- /* call parent method */
- parent_class->init(folder, parent_store, parent_folder, name, separator, path_begins_with_sep, ex);
- if (camel_exception_get_id(ex))
- return;
+ folder = CAMEL_FOLDER (camel_object_new (CAMEL_MBOX_FOLDER_TYPE));
+ mbox_folder = (CamelMboxFolder *)folder;
- /* we assume that the parent init
- method checks for the existance of @folder */
- folder->can_hold_messages = TRUE;
- folder->can_hold_folders = TRUE;
- folder->has_summary_capability = TRUE;
- folder->has_search_capability = TRUE;
+ name = strrchr(full_name, '/');
+ if (name)
+ name++;
+ else
+ name = full_name;
- folder->permanent_flags = CAMEL_MESSAGE_ANSWERED |
- CAMEL_MESSAGE_DELETED |
- CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_USER;
- /* FIXME: we don't actually preserve user flags right now. */
+ camel_folder_construct(folder, parent_store, full_name, name);
- mbox_folder->summary = NULL;
- mbox_folder->search = NULL;
+ root_dir_path = camel_mbox_store_get_toplevel_dir(CAMEL_MBOX_STORE(folder->parent_store));
- /* now set the name info */
- g_free(mbox_folder->folder_file_path);
- g_free(mbox_folder->folder_dir_path);
- g_free(mbox_folder->index_file_path);
+ mbox_folder->folder_file_path = g_strdup_printf("%s/%s", root_dir_path, full_name);
+ mbox_folder->summary_file_path = g_strdup_printf("%s/%s-ev-summary", root_dir_path, full_name);
+ mbox_folder->folder_dir_path = g_strdup_printf("%s/%s.sdb", root_dir_path, full_name);
+ mbox_folder->index_file_path = g_strdup_printf("%s/%s.ibex", root_dir_path, full_name);
- root_dir_path = camel_mbox_store_get_toplevel_dir(CAMEL_MBOX_STORE(folder->parent_store));
+ mbox_refresh_info (folder, ex);
+ if (camel_exception_is_set (ex)) {
+ camel_object_unref (CAMEL_OBJECT (folder));
+ folder = NULL;
+ }
- real_name = g_basename(folder->full_name);
- mbox_folder->folder_file_path = g_strdup_printf("%s/%s", root_dir_path, real_name);
- mbox_folder->summary_file_path = g_strdup_printf("%s/%s-ev-summary", root_dir_path, real_name);
- mbox_folder->folder_dir_path = g_strdup_printf("%s/%s.sdb", root_dir_path, real_name);
- mbox_folder->index_file_path = g_strdup_printf("%s/%s.ibex", root_dir_path, real_name);
+ return folder;
}
static void
@@ -432,7 +439,7 @@ mbox_get_uids(CamelFolder *folder)
}
static GPtrArray *
-mbox_get_subfolder_names(CamelFolder *folder)
+mbox_get_subfolder_info(CamelFolder *folder)
{
/* No subfolders. */
return g_ptr_array_new();
diff --git a/camel/providers/mbox/camel-mbox-folder.h b/camel/providers/mbox/camel-mbox-folder.h
index 7c5558f362..4cc91eda75 100644
--- a/camel/providers/mbox/camel-mbox-folder.h
+++ b/camel/providers/mbox/camel-mbox-folder.h
@@ -69,6 +69,7 @@ typedef struct {
/* public methods */
+CamelFolder *camel_mbox_folder_new (CamelStore *parent_store, const char *full_name, CamelException *ex);
/* Standard Camel function */
CamelType camel_mbox_folder_get_type (void);
diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c
index 05e5af406b..0a6c7c2ce1 100644
--- a/camel/providers/mbox/camel-mbox-store.c
+++ b/camel/providers/mbox/camel-mbox-store.c
@@ -106,7 +106,6 @@ static CamelFolder *
get_folder (CamelStore *store, const char *folder_name, gboolean create,
CamelException *ex)
{
- CamelFolder *new_folder;
char *name;
struct stat st;
@@ -151,13 +150,7 @@ get_folder (CamelStore *store, const char *folder_name, gboolean create,
} else
g_free (name);
- new_folder = CAMEL_FOLDER (camel_object_new (CAMEL_MBOX_FOLDER_TYPE));
-
- CF_CLASS (new_folder)->init (new_folder, store, NULL,
- folder_name, "/", TRUE, ex);
- CF_CLASS (new_folder)->refresh_info (new_folder, ex);
-
- return new_folder;
+ return camel_mbox_folder_new (store, folder_name, ex);
}
static void