aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/mh/camel-mh-folder.c
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/mh/camel-mh-folder.c
parent053af645da6e5f74474d13c19ce73d236d9b76a9 (diff)
downloadgsoc2013-evolution-7dcc0325454ed6c71c2532befbb6aadb32391766.tar.gz
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/mh/camel-mh-folder.c')
-rw-r--r--camel/providers/mh/camel-mh-folder.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/camel/providers/mh/camel-mh-folder.c b/camel/providers/mh/camel-mh-folder.c
index 3112e2f4f4..ec434bbcf0 100644
--- a/camel/providers/mh/camel-mh-folder.c
+++ b/camel/providers/mh/camel-mh-folder.c
@@ -53,16 +53,12 @@ static CamelFolderClass *parent_class = NULL;
#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
#define CMHS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-static void mh_init(CamelFolder * folder, CamelStore * parent_store,
- CamelFolder * parent_folder, const gchar * name,
- gchar * separator, gboolean path_begins_with_sep, CamelException * ex);
-
static void mh_sync(CamelFolder * folder, gboolean expunge, CamelException * ex);
static gint mh_get_message_count(CamelFolder * folder);
static gint mh_get_unread_message_count(CamelFolder * folder);
static void mh_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex);
static GPtrArray *mh_get_uids(CamelFolder * folder);
-static GPtrArray *mh_get_subfolder_names(CamelFolder * folder);
+static GPtrArray *mh_get_subfolder_info(CamelFolder * folder);
static GPtrArray *mh_get_summary(CamelFolder * folder);
static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex);
@@ -91,15 +87,14 @@ static void camel_mh_folder_class_init(CamelObjectClass * camel_mh_folder_class)
/* virtual method definition */
/* virtual method overload */
- camel_folder_class->init = mh_init;
camel_folder_class->sync = mh_sync;
camel_folder_class->get_message_count = mh_get_message_count;
camel_folder_class->get_unread_message_count = mh_get_unread_message_count;
camel_folder_class->append_message = mh_append_message;
camel_folder_class->get_uids = mh_get_uids;
camel_folder_class->free_uids = camel_folder_free_deep;
- camel_folder_class->get_subfolder_names = mh_get_subfolder_names;
- camel_folder_class->free_subfolder_names = camel_folder_free_deep;
+ camel_folder_class->get_subfolder_info = mh_get_subfolder_info;
+ camel_folder_class->free_subfolder_info = camel_folder_free_deep;
camel_folder_class->get_summary = mh_get_summary;
camel_folder_class->free_summary = camel_folder_free_nop;
camel_folder_class->expunge = mh_expunge;
@@ -119,6 +114,24 @@ static void camel_mh_folder_class_init(CamelObjectClass * camel_mh_folder_class)
camel_folder_class->set_message_user_tag = mh_set_message_user_tag;
}
+static void mh_init(gpointer object, gpointer klass)
+{
+ CamelFolder *folder = object;
+ CamelMhFolder *mh_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;
+
+ mh_folder->summary = NULL;
+ mh_folder->search = NULL;
+}
+
static void mh_finalize(CamelObject * object)
{
CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(object);
@@ -142,54 +155,38 @@ CamelType camel_mh_folder_get_type(void)
sizeof(CamelMhFolderClass),
(CamelObjectClassInitFunc) camel_mh_folder_class_init,
NULL,
- (CamelObjectInitFunc) NULL,
+ (CamelObjectInitFunc) mh_init,
(CamelObjectFinalizeFunc) mh_finalize);
}
return camel_mh_folder_type;
}
-static void
-mh_init(CamelFolder * folder, CamelStore * parent_store,
- CamelFolder * parent_folder, const gchar * name, gchar * separator,
- gboolean path_begins_with_sep, CamelException * ex)
+CamelFolder *
+camel_mh_folder_new(CamelStore *parent_store, const char *full_name, CamelException *ex)
{
- CamelMhFolder *mh_folder = (CamelMhFolder *) folder;
- const gchar *root_dir_path;
- gchar *real_name;
+ CamelFolder *folder;
+ CamelMhFolder *mh_folder;
+ const char *root_dir_path, *name;
int forceindex;
struct stat st;
- /* 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_MH_FOLDER_TYPE));
+ mh_folder = (CamelMhFolder *)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;
-
- folder->permanent_flags = CAMEL_MESSAGE_ANSWERED |
- CAMEL_MESSAGE_DELETED |
- CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_USER;
-
- mh_folder->summary = NULL;
- mh_folder->search = NULL;
-
- /* now set the name info */
- g_free(mh_folder->folder_file_path);
- g_free(mh_folder->folder_dir_path);
- g_free(mh_folder->index_file_path);
+ name = strrchr(full_name, '/');
+ if (name)
+ name++;
+ else
+ name = full_name;
+ camel_folder_construct (folder, parent_store, full_name, name);
root_dir_path = camel_mh_store_get_toplevel_dir(CAMEL_MH_STORE(folder->parent_store));
- real_name = g_basename(folder->full_name);
- mh_folder->folder_file_path = g_strdup_printf("%s/%s", root_dir_path, real_name);
- mh_folder->summary_file_path = g_strdup_printf("%s/%s/ev-summary", root_dir_path, real_name);
- mh_folder->folder_dir_path = g_strdup_printf("%s/%s", root_dir_path, real_name);
- mh_folder->index_file_path = g_strdup_printf("%s/%s/ev-index.ibex", root_dir_path, real_name);
+ mh_folder->folder_file_path = g_strdup_printf("%s/%s", root_dir_path, full_name);
+ mh_folder->summary_file_path = g_strdup_printf("%s/%s/ev-summary", root_dir_path, full_name);
+ mh_folder->folder_dir_path = g_strdup_printf("%s/%s", root_dir_path, full_name);
+ mh_folder->index_file_path = g_strdup_printf("%s/%s/ev-index.ibex", root_dir_path, full_name);
/* if we have no index file, force it */
forceindex = stat(mh_folder->index_file_path, &st) == -1;
@@ -208,8 +205,11 @@ mh_init(CamelFolder * folder, CamelStore * parent_store,
if (camel_mh_summary_load(mh_folder->summary, forceindex) == -1) {
camel_exception_set(ex, CAMEL_EXCEPTION_FOLDER_INVALID, /* FIXME: right error code */
"Could not load or create summary");
- return;
+ camel_object_unref (CAMEL_OBJECT (folder));
+ return NULL;
}
+
+ return folder;
}
static void mh_sync(CamelFolder * folder, gboolean expunge, CamelException * ex)
@@ -356,7 +356,7 @@ static GPtrArray *mh_get_uids(CamelFolder * folder)
return array;
}
-static GPtrArray *mh_get_subfolder_names(CamelFolder * folder)
+static GPtrArray *mh_get_subfolder_info(CamelFolder * folder)
{
/* FIXME: scan for sub-folders */
/* No subfolders. */