aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog31
-rw-r--r--camel/camel-folder.c438
-rw-r--r--camel/camel-folder.h82
-rw-r--r--camel/providers/imap/camel-imap-folder.c107
-rw-r--r--camel/providers/imap/camel-imap-folder.h3
-rw-r--r--camel/providers/imap/camel-imap-store.c5
-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
-rw-r--r--camel/providers/mh/camel-mh-folder.c88
-rw-r--r--camel/providers/mh/camel-mh-folder.h1
-rw-r--r--camel/providers/mh/camel-mh-store.c21
-rw-r--r--camel/providers/nntp/camel-nntp-folder.c116
-rw-r--r--camel/providers/nntp/camel-nntp-folder.h1
-rw-r--r--camel/providers/nntp/camel-nntp-newsrc.c1
-rw-r--r--camel/providers/nntp/camel-nntp-store.c7
-rw-r--r--camel/providers/nntp/camel-nntp-utils.c8
-rw-r--r--camel/providers/pop3/camel-pop3-folder.c22
-rw-r--r--camel/providers/vee/camel-vee-folder.c105
-rw-r--r--camel/providers/vee/camel-vee-folder.h4
-rw-r--r--camel/providers/vee/camel-vee-store.c7
21 files changed, 502 insertions, 646 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index b769aac279..e49b992228 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,32 @@
+2000-09-19 Dan Winship <danw@helixcode.com>
+
+ * 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.
+
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* camel-folder-search.c, camel-folder-search.h,
@@ -7,7 +36,7 @@
2000-09-17 Dan Winship <danw@helixcode.com>
- * camel-folder-summary.h: update CamelFolderInfo
+ * camel-folder-summary.h: update CamelFolderInfo
* camel-folder-summary.c (camel_folder_info_free): New function to
free the contents of a CamelFolderInfo
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 888845aed8..2904ac26d9 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-folder.c: Abstract class for an email folder */
/*
@@ -36,12 +36,6 @@ static CamelObjectClass *parent_class = NULL;
/* Returns the class for a CamelFolder */
#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-
-static void init (CamelFolder *folder, CamelStore *parent_store,
- CamelFolder *parent_folder, const gchar *name,
- gchar *separator, gboolean path_begins_with_sep,
- CamelException *ex);
-
static void camel_folder_finalize (CamelObject *object);
static void refresh_info (CamelFolder *folder, CamelException *ex);
@@ -51,7 +45,7 @@ static void folder_sync (CamelFolder *folder, gboolean expunge,
static const gchar *get_name (CamelFolder *folder);
static const gchar *get_full_name (CamelFolder *folder);
-
+static CamelStore *get_parent_store (CamelFolder *folder);
static gboolean can_hold_folders (CamelFolder *folder);
static gboolean can_hold_messages (CamelFolder *folder);
@@ -65,15 +59,9 @@ static void set_message_user_flag (CamelFolder *folder, const char *uid,
static const char *get_message_user_tag(CamelFolder *folder, const char *uid, const char *name);
static void set_message_user_tag(CamelFolder *folder, const char *uid, const char *name, const char *value);
-static GPtrArray *get_subfolder_names (CamelFolder *folder);
-static void free_subfolder_names (CamelFolder *folder,
+static GPtrArray *get_subfolder_info (CamelFolder *folder);
+static void free_subfolder_info (CamelFolder *folder,
GPtrArray *array);
-static CamelFolder *get_subfolder (CamelFolder *folder,
- const gchar *folder_name,
- gboolean create,
- CamelException *ex);
-static CamelFolder *get_parent_folder (CamelFolder *folder);
-static CamelStore *get_parent_store (CamelFolder *folder);
static gint get_message_count (CamelFolder *folder);
static gint get_unread_message_count (CamelFolder *folder);
@@ -120,7 +108,7 @@ static void freeze (CamelFolder *folder);
static void thaw (CamelFolder *folder);
static gboolean folder_changed (CamelObject *object,
- /*int type*/gpointer event_data);
+ gpointer event_data);
static gboolean message_changed (CamelObject *object,
/*const char *uid*/gpointer event_data);
@@ -133,18 +121,15 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
parent_class = camel_type_get_global_classfuncs (camel_object_get_type ());
/* virtual method definition */
- camel_folder_class->init = init;
camel_folder_class->sync = folder_sync;
camel_folder_class->refresh_info = refresh_info;
camel_folder_class->get_name = get_name;
camel_folder_class->get_full_name = get_full_name;
+ camel_folder_class->get_parent_store = get_parent_store;
camel_folder_class->can_hold_folders = can_hold_folders;
camel_folder_class->can_hold_messages = can_hold_messages;
- camel_folder_class->get_subfolder = get_subfolder;
- camel_folder_class->get_parent_folder = get_parent_folder;
- camel_folder_class->get_parent_store = get_parent_store;
- camel_folder_class->get_subfolder_names = get_subfolder_names;
- camel_folder_class->free_subfolder_names = free_subfolder_names;
+ camel_folder_class->get_subfolder_info = get_subfolder_info;
+ camel_folder_class->free_subfolder_info = free_subfolder_info;
camel_folder_class->expunge = expunge;
camel_folder_class->get_message_count = get_message_count;
camel_folder_class->get_unread_message_count = get_unread_message_count;
@@ -170,30 +155,20 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
camel_folder_class->thaw = thaw;
/* virtual method overload */
- camel_object_class_declare_event (camel_object_class, "folder_changed", folder_changed);
- camel_object_class_declare_event (camel_object_class, "message_changed", message_changed);
-
- /*
- signals[FOLDER_CHANGED] =
- gt_k_signal_new ("folder_changed",
- GT_K_RUN_FIRST,
- camel_object_class->type,
- GT_K_SIGNAL_OFFSET (CamelFolderClass,
- folder_changed),
- gt_k_marshal_NONE__INT,
- GT_K_TYPE_NONE, 1, GT_K_TYPE_INT);
-
- signals[MESSAGE_CHANGED] =
- gt_k_signal_new ("message_changed",
- GT_K_RUN_FIRST,
- camel_object_class->type,
- GT_K_SIGNAL_OFFSET (CamelFolderClass,
- message_changed),
- gt_k_marshal_NONE__STRING,
- GT_K_TYPE_NONE, 1, GT_K_TYPE_STRING);
-
- camel_object_class_add_signals (camel_object_class, signals, LAST_SIGNAL);
- */
+ camel_object_class_declare_event (camel_object_class,
+ "folder_changed", folder_changed);
+ camel_object_class_declare_event (camel_object_class,
+ "message_changed", message_changed);
+}
+
+static void
+camel_folder_init (gpointer object, gpointer klass)
+{
+ CamelFolder *folder = object;
+
+ folder->frozen = 0;
+ folder->folder_changed = FALSE;
+ folder->messages_changed = NULL;
}
static void
@@ -207,8 +182,6 @@ camel_folder_finalize (CamelObject *object)
if (camel_folder->parent_store)
camel_object_unref (CAMEL_OBJECT (camel_folder->parent_store));
- if (camel_folder->parent_folder)
- camel_object_unref (CAMEL_OBJECT (camel_folder->parent_folder));
for (m = camel_folder->messages_changed; m; m = m->next)
g_free (m->data);
@@ -226,7 +199,7 @@ camel_folder_get_type (void)
sizeof (CamelFolderClass),
(CamelObjectClassInitFunc) camel_folder_class_init,
NULL,
- NULL,
+ (CamelObjectInitFunc) camel_folder_init,
(CamelObjectFinalizeFunc) camel_folder_finalize );
}
@@ -235,67 +208,28 @@ camel_folder_get_type (void)
/**
- * init: init the folder
- * @folder: folder object to initialize
+ * camel_folder_construct:
+ * @folder: folder object to construct
* @parent_store: parent store object of the folder
- * @parent_folder: parent folder of the folder (may be NULL)
- * @name: (short) name of the folder
- * @separator: separator between the parent folder name and this name
- * @ex: a CamelException
+ * @full_name: full name of the folder
+ * @name: short name of the folder
*
- * Initalizes the folder by setting the parent store, parent folder,
- * and name.
+ * Initalizes the folder by setting the parent store and name.
**/
-static void
-init (CamelFolder *folder, CamelStore *parent_store,
- CamelFolder *parent_folder, const gchar *name,
- gchar *separator, gboolean path_begins_with_sep,
- CamelException *ex)
+void
+camel_folder_construct (CamelFolder *folder, CamelStore *parent_store,
+ const char *full_name, const char *name)
{
- gchar *full_name;
- const gchar *parent_full_name;
-
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (CAMEL_IS_STORE (parent_store));
- g_return_if_fail (parent_folder == NULL || CAMEL_IS_FOLDER (parent_folder));
g_return_if_fail (folder->parent_store == NULL);
+ g_return_if_fail (folder->name == NULL);
folder->parent_store = parent_store;
camel_object_ref (CAMEL_OBJECT (parent_store));
- folder->parent_folder = parent_folder;
- if (parent_folder)
- camel_object_ref (CAMEL_OBJECT (parent_folder));
-
- folder->separator = separator;
- folder->path_begins_with_sep = path_begins_with_sep;
-
- /* if the folder already has a name, free it */
- g_free (folder->name);
- g_free (folder->full_name);
-
- /* set those fields to NULL now, so that if an
- exception occurs, they will be set anyway */
- folder->name = NULL;
- folder->full_name = NULL;
-
- if (folder->parent_folder) {
- parent_full_name = camel_folder_get_full_name(folder->parent_folder);
-
- full_name = g_strdup_printf("%s%s%s", parent_full_name, folder->separator, name);
- } else {
- if (path_begins_with_sep)
- full_name = g_strdup_printf("%s%s", folder->separator, name);
- else
- full_name = g_strdup(name);
- }
-
- folder->name = g_strdup(name);
- folder->full_name = full_name;
-
- folder->frozen = 0;
- folder->folder_changed = FALSE;
- folder->messages_changed = NULL;
+ folder->name = g_strdup (name);
+ folder->full_name = g_strdup (full_name);
}
@@ -315,13 +249,15 @@ folder_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
* Sync changes made to a folder to its backing store, possibly expunging
* deleted messages as well.
**/
-void camel_folder_sync(CamelFolder * folder, gboolean expunge, CamelException * ex)
+void
+camel_folder_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
{
- g_return_if_fail(CAMEL_IS_FOLDER(folder));
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
- CF_CLASS(folder)->sync(folder, expunge, ex);
+ CF_CLASS (folder)->sync (folder, expunge, ex);
}
+
static void
refresh_info (CamelFolder *folder, CamelException *ex)
{
@@ -338,14 +274,17 @@ refresh_info (CamelFolder *folder, CamelException *ex)
* (called upon creation and when the store's connection is lost
* and then reestablished).
**/
-void camel_folder_refresh_info (CamelFolder * folder, CamelException * ex)
+void
+camel_folder_refresh_info (CamelFolder *folder, CamelException *ex)
{
- g_return_if_fail(CAMEL_IS_FOLDER(folder));
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
- CF_CLASS(folder)->refresh_info(folder, ex);
+ CF_CLASS (folder)->refresh_info (folder, ex);
}
-static const gchar *get_name(CamelFolder * folder)
+
+static const char *
+get_name (CamelFolder *folder)
{
return folder->name;
}
@@ -359,14 +298,17 @@ static const gchar *get_name(CamelFolder * folder)
*
* Return value: name of the folder
**/
-const gchar *camel_folder_get_name(CamelFolder * folder)
+const char *
+camel_folder_get_name (CamelFolder * folder)
{
- g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL);
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
- return CF_CLASS(folder)->get_name(folder);
+ return CF_CLASS (folder)->get_name (folder);
}
-static const gchar *get_full_name(CamelFolder * folder)
+
+static const char *
+get_full_name (CamelFolder *folder)
{
return folder->full_name;
}
@@ -379,82 +321,78 @@ static const gchar *get_full_name(CamelFolder * folder)
*
* Return value: full name of the folder
**/
-const gchar *camel_folder_get_full_name(CamelFolder * folder)
+const char *
+camel_folder_get_full_name (CamelFolder *folder)
{
- g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL);
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
- return CF_CLASS(folder)->get_full_name(folder);
+ return CF_CLASS (folder)->get_full_name (folder);
}
-static gboolean can_hold_folders(CamelFolder * folder)
+
+static gboolean
+can_hold_folders (CamelFolder * folder)
{
return folder->can_hold_folders;
}
-static gboolean can_hold_messages(CamelFolder * folder)
+static gboolean
+can_hold_messages (CamelFolder * folder)
{
return folder->can_hold_messages;
}
-static CamelFolder *get_subfolder(CamelFolder * folder, const gchar * folder_name, gboolean create, CamelException * ex)
-{
- CamelFolder *new_folder;
- gchar *full_name;
- const gchar *current_folder_full_name;
-
- g_return_val_if_fail(CAMEL_IS_STORE(folder->parent_store), NULL);
- current_folder_full_name = camel_folder_get_full_name(folder);
-
- full_name = g_strdup_printf("%s%s%s", current_folder_full_name, folder->separator, folder_name);
- new_folder = camel_store_get_folder(folder->parent_store, full_name, create, ex);
- g_free(full_name);
-
- return new_folder;
+static GPtrArray *
+get_subfolder_info (CamelFolder *folder)
+{
+ g_warning ("CamelFolder::get_subfolder_info not implemented for `%s'",
+ camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder)));
+ return NULL;
}
/**
- * camel_folder_get_subfolder:
- * @folder: a folder
- * @folder_name: subfolder path
- * @create: whether or not to create the folder if it doesn't exist
- * @ex: a CamelException
- *
- * This method returns a folder object. This folder is a subfolder of
- * the given folder. It is an error to ask for a folder whose name begins
- * with the folder separator character.
+ * camel_folder_get_subfolder_info:
+ * @folder: the folder
*
- * Return value: the requested folder, or %NULL if the subfolder object
- * could not be obtained
+ * Return value: an array containing a CamelFolderInfo for each of
+ * @folder's subfolders. The array should not be modified and must be
+ * freed with camel_folder_free_subfolder_info().
**/
-CamelFolder *camel_folder_get_subfolder(CamelFolder * folder, const gchar * folder_name,
- gboolean create, CamelException * ex)
+GPtrArray *
+camel_folder_get_subfolder_info (CamelFolder *folder)
{
- g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL);
- g_return_val_if_fail(folder_name != NULL, NULL);
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
- return CF_CLASS(folder)->get_subfolder(folder, folder_name, create, ex);
+ return CF_CLASS (folder)->get_subfolder_info (folder);
}
-static CamelFolder *get_parent_folder(CamelFolder * folder)
+
+static void
+free_subfolder_info (CamelFolder *folder, GPtrArray *array)
{
- return folder->parent_folder;
+ g_warning ("CamelFolder::free_subfolder_info not implemented "
+ "for `%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder)));
}
/**
- * camel_folder_get_parent_folder:
- * @folder: folder to get the parent of
+ * camel_folder_free_subfolder_info:
+ * @folder: folder object
+ * @array: the array of subfolder info to free
*
- * Return value: the folder's parent
+ * Frees the array of info returned by camel_folder_get_subfolder_info().
**/
-CamelFolder *camel_folder_get_parent_folder(CamelFolder * folder)
+void
+camel_folder_free_subfolder_info (CamelFolder *folder, GPtrArray *array)
{
- g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL);
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
- return CF_CLASS(folder)->get_parent_folder(folder);
+ CF_CLASS (folder)->free_subfolder_info (folder, array);
}
-static CamelStore *get_parent_store(CamelFolder * folder)
+
+static CamelStore *
+get_parent_store (CamelFolder * folder)
{
return folder->parent_store;
}
@@ -474,54 +412,6 @@ camel_folder_get_parent_store (CamelFolder *folder)
}
-static GPtrArray *
-get_subfolder_names (CamelFolder *folder)
-{
- g_warning ("CamelFolder::get_subfolder_names not implemented for `%s'",
- camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder)));
- return NULL;
-}
-
-/**
- * camel_folder_get_subfolder_names:
- * @folder: the folder
- *
- * Return value: an array containing the names of the folder's
- * subfolders. The array should not be modified and must be freed with
- * camel_folder_free_subfolder_names().
- **/
-GPtrArray *
-camel_folder_get_subfolder_names (CamelFolder *folder)
-{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
-
- return CF_CLASS (folder)->get_subfolder_names (folder);
-}
-
-
-static void
-free_subfolder_names (CamelFolder *folder, GPtrArray *array)
-{
- g_warning ("CamelFolder::free_subfolder_names not implemented "
- "for `%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder)));
-}
-
-/**
- * camel_folder_free_subfolder_names:
- * @folder: folder object
- * @array: the array of subfolder names to free
- *
- * Frees the array of names returned by camel_folder_get_subfolder_names().
- **/
-void
-camel_folder_free_subfolder_names (CamelFolder *folder, GPtrArray *array)
-{
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
-
- CF_CLASS (folder)->free_subfolder_names (folder, array);
-}
-
-
static void
expunge (CamelFolder *folder, CamelException *ex)
{
@@ -546,7 +436,7 @@ camel_folder_expunge (CamelFolder *folder, CamelException *ex)
}
-static gint
+static int
get_message_count (CamelFolder *folder)
{
g_warning ("CamelFolder::get_message_count not implemented "
@@ -560,7 +450,7 @@ get_message_count (CamelFolder *folder)
*
* Return value: the number of messages in the folder, or -1 if unknown.
**/
-gint
+int
camel_folder_get_message_count (CamelFolder *folder)
{
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
@@ -568,7 +458,8 @@ camel_folder_get_message_count (CamelFolder *folder)
return CF_CLASS (folder)->get_message_count (folder);
}
-static gint
+
+static int
get_unread_message_count (CamelFolder *folder)
{
g_warning ("CamelFolder::get_unread_message_count not implemented "
@@ -582,7 +473,7 @@ get_unread_message_count (CamelFolder *folder)
*
* Return value: the number of unread messages in the folder, or -1 if unknown.
**/
-gint
+int
camel_folder_get_unread_message_count (CamelFolder *folder)
{
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
@@ -605,19 +496,25 @@ append_message (CamelFolder *folder, CamelMimeMessage *message,
* camel_folder_append_message: add a message to a folder
* @folder: folder object to add the message to
* @message: message object
- * @info: optional message info with additional flags/etc to set on new message.
+ * @info: message info with additional flags/etc to set on
+ * new message, or %NULL
* @ex: exception object
*
- * Add a message to a folder.
+ * Add a message to a folder. Only the flag and tag data from @info
+ * is used. If @info is %NULL, no flags or tags will be set.
**/
-void camel_folder_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex)
+void
+camel_folder_append_message (CamelFolder *folder, CamelMimeMessage *message,
+ const CamelMessageInfo *info, CamelException *ex)
{
- g_return_if_fail(CAMEL_IS_FOLDER(folder));
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
- CF_CLASS(folder)->append_message(folder, message, info, ex);
+ CF_CLASS (folder)->append_message (folder, message, info, ex);
}
-static guint32 get_permanent_flags(CamelFolder * folder)
+
+static guint32
+get_permanent_flags (CamelFolder *folder)
{
return folder->permanent_flags;
}
@@ -1013,13 +910,13 @@ camel_folder_search_by_expression (CamelFolder *folder, const char *expression,
}
static void
-search_free(CamelFolder * folder, GPtrArray * result)
+search_free (CamelFolder *folder, GPtrArray *result)
{
int i;
for (i = 0; i < result->len; i++)
- g_free(g_ptr_array_index(result, i));
- g_ptr_array_free(result, TRUE);
+ g_free (g_ptr_array_index (result, i));
+ g_ptr_array_free (result, TRUE);
}
/**
@@ -1030,12 +927,12 @@ search_free(CamelFolder * folder, GPtrArray * result)
* Free the result of a search.
**/
void
-camel_folder_search_free(CamelFolder * folder, GPtrArray * result)
+camel_folder_search_free (CamelFolder *folder, GPtrArray *result)
{
- g_return_if_fail(CAMEL_IS_FOLDER(folder));
- g_return_if_fail(folder->has_search_capability);
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_if_fail (folder->has_search_capability);
- return CF_CLASS(folder)->search_free(folder, result);
+ return CF_CLASS (folder)->search_free (folder, result);
}
@@ -1048,14 +945,12 @@ copy_message_to (CamelFolder *source, const char *uid, CamelFolder *dest,
/* Default implementation. */
- msg = camel_folder_get_message(source, uid, ex);
+ msg = camel_folder_get_message (source, uid, ex);
if (!msg)
return;
- info = camel_folder_get_message_info(source, uid);
- camel_folder_append_message(dest, msg, info, ex);
- camel_object_unref(CAMEL_OBJECT (msg));
- if (camel_exception_is_set(ex))
- return;
+ info = camel_folder_get_message_info (source, uid);
+ camel_folder_append_message (dest, msg, info, ex);
+ camel_object_unref (CAMEL_OBJECT (msg));
}
/**
@@ -1078,26 +973,28 @@ camel_folder_copy_message_to (CamelFolder *source, const char *uid,
g_return_if_fail (uid != NULL);
if (source->parent_store == dest->parent_store) {
- return CF_CLASS (source)->copy_message_to(source, uid,dest, ex);
+ return CF_CLASS (source)->copy_message_to (source, uid,
+ dest, ex);
} else
- return copy_message_to(source, uid, dest, ex);
+ return copy_message_to (source, uid, dest, ex);
}
static void
-move_message_to (CamelFolder *source, const char *uid, CamelFolder *dest, CamelException *ex)
+move_message_to (CamelFolder *source, const char *uid,
+ CamelFolder *dest, CamelException *ex)
{
CamelMimeMessage *msg;
const CamelMessageInfo *info;
/* Default implementation. */
- msg = camel_folder_get_message(source, uid, ex);
+ msg = camel_folder_get_message (source, uid, ex);
if (!msg)
return;
- info = camel_folder_get_message_info(source, uid);
- camel_folder_append_message(dest, msg, info, ex);
- camel_object_unref(CAMEL_OBJECT(msg));
+ info = camel_folder_get_message_info (source, uid);
+ camel_folder_append_message (dest, msg, info, ex);
+ camel_object_unref (CAMEL_OBJECT (msg));
if (camel_exception_is_set(ex))
return;
camel_folder_delete_message (source, uid);
@@ -1115,19 +1012,23 @@ move_message_to (CamelFolder *source, const char *uid, CamelFolder *dest, CamelE
* than a camel_folder_append_message() followed by
* camel_folder_delete_message().
**/
-void camel_folder_move_message_to(CamelFolder * source, const char *uid, CamelFolder * dest, CamelException * ex)
+void
+camel_folder_move_message_to (CamelFolder *source, const char *uid,
+ CamelFolder *dest, CamelException *ex)
{
- g_return_if_fail(CAMEL_IS_FOLDER(source));
- g_return_if_fail(CAMEL_IS_FOLDER(dest));
- g_return_if_fail(uid != NULL);
+ g_return_if_fail (CAMEL_IS_FOLDER (source));
+ g_return_if_fail (CAMEL_IS_FOLDER (dest));
+ g_return_if_fail (uid != NULL);
if (source->parent_store == dest->parent_store) {
- return CF_CLASS(source)->move_message_to(source, uid, dest, ex);
+ return CF_CLASS (source)->move_message_to (source, uid,
+ dest, ex);
} else
- return move_message_to(source, uid, dest, ex);
+ return move_message_to (source, uid, dest, ex);
}
-static void freeze(CamelFolder * folder)
+static void
+freeze (CamelFolder *folder)
{
folder->frozen++;
}
@@ -1141,14 +1042,16 @@ static void freeze(CamelFolder * folder)
* When the folder is later thawed with camel_folder_thaw(), the
* suppressed signals will be emitted.
**/
-void camel_folder_freeze(CamelFolder * folder)
+void
+camel_folder_freeze (CamelFolder * folder)
{
- g_return_if_fail(CAMEL_IS_FOLDER(folder));
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
- CF_CLASS(folder)->freeze(folder);
+ CF_CLASS (folder)->freeze (folder);
}
-static void thaw(CamelFolder * folder)
+static void
+thaw (CamelFolder * folder)
{
GList *messages, *m;
@@ -1168,13 +1071,16 @@ static void thaw(CamelFolder * folder)
if (folder->folder_changed) {
folder->folder_changed = FALSE;
- camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", GINT_TO_POINTER(0));
+ camel_object_trigger_event (CAMEL_OBJECT (folder),
+ "folder_changed", NULL);
} else if (messages) {
/* FIXME: would be nice to not emit more than once for
* a given message
*/
for (m = messages; m; m = m->next) {
- camel_object_trigger_event (CAMEL_OBJECT (folder), "message_changed", m->data);
+ camel_object_trigger_event (CAMEL_OBJECT (folder),
+ "message_changed",
+ m->data);
g_free (m->data);
}
g_list_free (messages);
@@ -1206,7 +1112,8 @@ camel_folder_thaw (CamelFolder *folder)
/* Event hooks that block emission when frozen */
-static gboolean folder_changed (CamelObject *obj, /*int type*/gpointer event_data)
+static gboolean
+folder_changed (CamelObject *obj, gpointer event_data)
{
CamelFolder *folder = CAMEL_FOLDER (obj);
@@ -1218,15 +1125,14 @@ static gboolean folder_changed (CamelObject *obj, /*int type*/gpointer event_dat
return TRUE;
}
-static gboolean message_changed (CamelObject *obj, /*const char *uid*/gpointer event_data)
+static gboolean
+message_changed (CamelObject *obj, /*const char *uid*/gpointer event_data)
{
CamelFolder *folder = CAMEL_FOLDER (obj);
if (folder->frozen) {
- /*
- * if g_tk_signal_handler_pending (CAMEL_OBJECT (folder),
- * signals[MESSAGE_CHANGED],
- * FALSE)) {
+ /* FIXME: if there are no hooks attached, we can just
+ * return here.
*/
/* Only record the UID if it will be useful later. */
@@ -1246,14 +1152,15 @@ static gboolean message_changed (CamelObject *obj, /*const char *uid*/gpointer e
/**
* camel_folder_free_nop:
* @folder: a folder
- * @array: an array of uids, subfolder names, or CamelMessageInfo
+ * @array: an array of uids, CamelFolderInfo, or CamelMessageInfo
*
* "Frees" the provided array by doing nothing. Used by CamelFolder
* subclasses as an implementation for free_uids, free_summary,
- * or free_subfolder_names when the returned array is "static"
+ * or free_subfolder_info when the returned array is "static"
* information and should not be freed.
**/
-void camel_folder_free_nop(CamelFolder * folder, GPtrArray * array)
+void
+camel_folder_free_nop (CamelFolder *folder, GPtrArray *array)
{
;
}
@@ -1261,33 +1168,34 @@ void camel_folder_free_nop(CamelFolder * folder, GPtrArray * array)
/**
* camel_folder_free_shallow:
* @folder: a folder
- * @array: an array of uids, subfolder names, or CamelMessageInfo
+ * @array: an array of uids, CamelFolderInfo, or CamelMessageInfo
*
* Frees the provided array but not its contents. Used by CamelFolder
* subclasses as an implementation for free_uids, free_summary, or
- * free_subfolder_names when the returned array needs to be freed
+ * free_subfolder_info when the returned array needs to be freed
* but its contents come from "static" information.
**/
-void camel_folder_free_shallow(CamelFolder * folder, GPtrArray * array)
+void
+camel_folder_free_shallow (CamelFolder *folder, GPtrArray *array)
{
- g_ptr_array_free(array, TRUE);
+ g_ptr_array_free (array, TRUE);
}
/**
* camel_folder_free_deep:
* @folder: a folder
- * @array: an array of uids or subfolder names
+ * @array: an array of uids
*
* Frees the provided array and its contents. Used by CamelFolder
- * subclasses as an implementation for free_uids or
- * free_subfolder_names (but NOT free_summary) when the provided
+ * subclasses as an implementation for free_uids when the provided
* information was created explicitly by the corresponding get_ call.
**/
-void camel_folder_free_deep(CamelFolder * folder, GPtrArray * array)
+void
+camel_folder_free_deep (CamelFolder *folder, GPtrArray *array)
{
int i;
for (i = 0; i < array->len; i++)
- g_free(array->pdata[i]);
- g_ptr_array_free(array, TRUE);
+ g_free (array->pdata[i]);
+ g_ptr_array_free (array, TRUE);
}
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index c78ed28b61..fe1ed75f0c 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -49,15 +49,11 @@ struct _CamelFolder
gboolean folder_changed;
GList *messages_changed;
- gchar *name;
- gchar *full_name;
- gchar *separator;
+ char *name;
+ char *full_name;
CamelStore *parent_store;
- CamelFolder *parent_folder;
- guint32 permanent_flags;
- gboolean path_begins_with_sep;
-
+ guint32 permanent_flags;
gboolean can_hold_folders:1;
gboolean can_hold_messages:1;
gboolean has_summary_capability:1;
@@ -67,47 +63,30 @@ struct _CamelFolder
typedef struct {
CamelObjectClass parent_class;
- /* signals */
- /* Not anymore! bwahahahah!
- * void (*folder_changed) (CamelFolder *, int type);
- * void (*message_changed) (CamelFolder *,
- * const char *uid);
- */
-
/* Virtual methods */
- void (*init) (CamelFolder *folder, CamelStore *parent_store,
- CamelFolder *parent_folder, const gchar *name,
- gchar *separator, gboolean path_begins_with_sep,
- CamelException *ex);
-
void (*refresh_info) (CamelFolder *folder, CamelException *ex);
void (*sync) (CamelFolder *folder, gboolean expunge,
CamelException *ex);
- const gchar * (*get_name) (CamelFolder *folder);
+ const char * (*get_name) (CamelFolder *folder);
+ const char * (*get_full_name) (CamelFolder *folder);
- const gchar * (*get_full_name) (CamelFolder *folder);
+ CamelStore * (*get_parent_store) (CamelFolder *folder);
gboolean (*can_hold_folders) (CamelFolder *folder);
-
gboolean (*can_hold_messages) (CamelFolder *folder);
- CamelFolder * (*get_subfolder) (CamelFolder *folder,
- const gchar *folder_name,
- gboolean create,
- CamelException *ex);
-
- CamelFolder * (*get_parent_folder) (CamelFolder *folder);
-
- CamelStore * (*get_parent_store) (CamelFolder *folder);
+ GPtrArray * (*get_subfolder_info)(CamelFolder *folder);
+ void (*free_subfolder_info) (CamelFolder *folder,
+ GPtrArray *subfolders);
void (*expunge) (CamelFolder *folder,
CamelException *ex);
- gint (*get_message_count) (CamelFolder *folder);
+ int (*get_message_count) (CamelFolder *folder);
- gint (*get_unread_message_count) (CamelFolder *folder);
+ int (*get_unread_message_count) (CamelFolder *folder);
void (*append_message) (CamelFolder *folder,
CamelMimeMessage *message,
@@ -138,13 +117,9 @@ typedef struct {
const char *value);
CamelMimeMessage * (*get_message) (CamelFolder *folder,
- const gchar *uid,
+ const char *uid,
CamelException *ex);
- void (*delete_message) (CamelFolder *folder,
- const gchar *uid,
- CamelException *ex);
-
GPtrArray * (*get_uids) (CamelFolder *folder);
void (*free_uids) (CamelFolder *folder,
GPtrArray *array);
@@ -153,10 +128,6 @@ typedef struct {
void (*free_summary) (CamelFolder *folder,
GPtrArray *summary);
- GPtrArray * (*get_subfolder_names) (CamelFolder *folder);
- void (*free_subfolder_names) (CamelFolder *folder,
- GPtrArray *subfolders);
-
gboolean (*has_search_capability) (CamelFolder *folder);
GPtrArray * (*search_by_expression) (CamelFolder *folder,
@@ -188,13 +159,14 @@ CamelType camel_folder_get_type (void);
/* public methods */
+void camel_folder_construct (CamelFolder *folder,
+ CamelStore *parent_store,
+ const char *full_name,
+ const char *name);
-
-
-CamelFolder * camel_folder_get_subfolder (CamelFolder *folder,
- const gchar *folder_name,
- gboolean create,
- CamelException *ex);
+GPtrArray * camel_folder_get_subfolder_info (CamelFolder *folder);
+void camel_folder_free_subfolder_info (CamelFolder *folder,
+ GPtrArray *array);
void camel_folder_refresh_info (CamelFolder * folder,
CamelException * ex);
@@ -202,7 +174,6 @@ void camel_folder_sync (CamelFolder *folder,
gboolean expunge,
CamelException *ex);
-CamelFolder * camel_folder_get_parent_folder (CamelFolder *folder);
CamelStore * camel_folder_get_parent_store (CamelFolder *folder);
@@ -212,8 +183,8 @@ void camel_folder_expunge (CamelFolder *folder,
/* folder name operations */
-const gchar * camel_folder_get_name (CamelFolder *folder);
-const gchar * camel_folder_get_full_name (CamelFolder *folder);
+const char * camel_folder_get_name (CamelFolder *folder);
+const char * camel_folder_get_full_name (CamelFolder *folder);
/* various properties accessors */
@@ -257,22 +228,17 @@ void camel_folder_append_message (CamelFolder *folder,
gboolean camel_folder_has_summary_capability (CamelFolder *folder);
-gint camel_folder_get_message_count (CamelFolder *folder);
+int camel_folder_get_message_count (CamelFolder *folder);
-gint camel_folder_get_unread_message_count (CamelFolder *folder);
+int camel_folder_get_unread_message_count (CamelFolder *folder);
GPtrArray * camel_folder_get_summary (CamelFolder *folder);
void camel_folder_free_summary (CamelFolder *folder,
GPtrArray *array);
-GPtrArray * camel_folder_get_subfolder_names (CamelFolder *folder);
-void camel_folder_free_subfolder_names (CamelFolder *folder,
- GPtrArray *array);
-
-
/* uid based access operations */
CamelMimeMessage * camel_folder_get_message (CamelFolder *folder,
- const gchar *uid,
+ const char *uid,
CamelException *ex);
#define camel_folder_delete_message(folder, uid) \
camel_folder_set_message_flags (folder, uid, CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED)
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 473659fb84..c6771cfd4c 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -59,10 +59,6 @@
static CamelFolderClass *parent_class = NULL;
-static void imap_init (CamelFolder *folder, CamelStore *parent_store,
- CamelFolder *parent_folder, const gchar *name,
- gchar *separator, gboolean path_begns_with_sep,
- CamelException *ex);
static void imap_finalize (CamelObject *object);
static void imap_refresh_info (CamelFolder *folder, CamelException *ex);
static void imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
@@ -84,8 +80,8 @@ static void imap_move_message_to (CamelFolder *source, const char *uid,
CamelFolder *destination, CamelException *ex);
/* subfolder listing */
-static GPtrArray *imap_get_subfolder_names_internal (CamelFolder *folder, CamelException *ex);
-static GPtrArray *imap_get_subfolder_names (CamelFolder *folder);
+static GPtrArray *imap_get_subfolder_info_internal (CamelFolder *folder, CamelException *ex);
+static GPtrArray *imap_get_subfolder_info (CamelFolder *folder);
/* summary info */
static GPtrArray *imap_get_uids (CamelFolder *folder);
@@ -115,15 +111,14 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
/* virtual method definition */
/* virtual method overload */
- camel_folder_class->init = imap_init;
camel_folder_class->refresh_info = imap_refresh_info;
camel_folder_class->sync = imap_sync;
camel_folder_class->expunge = imap_expunge;
camel_folder_class->get_uids = imap_get_uids;
camel_folder_class->free_uids = camel_folder_free_nop;
- camel_folder_class->get_subfolder_names = imap_get_subfolder_names;
- camel_folder_class->free_subfolder_names = camel_folder_free_nop;
+ camel_folder_class->get_subfolder_info = imap_get_subfolder_info;
+ camel_folder_class->free_subfolder_info = camel_folder_free_nop;
camel_folder_class->get_message_count = imap_get_message_count;
camel_folder_class->get_unread_message_count = imap_get_unread_message_count;
@@ -159,6 +154,16 @@ camel_imap_folder_init (gpointer object, gpointer klass)
imap_folder->summary = NULL;
imap_folder->summary_hash = NULL;
imap_folder->lsub = NULL;
+
+ /* some IMAP daemons support user-flags *
+ * I would not, however, rely on this feature as *
+ * most IMAP daemons do not support all the features */
+ folder->permanent_flags = CAMEL_MESSAGE_SEEN |
+ CAMEL_MESSAGE_ANSWERED |
+ CAMEL_MESSAGE_FLAGGED |
+ CAMEL_MESSAGE_DELETED |
+ CAMEL_MESSAGE_DRAFT |
+ CAMEL_MESSAGE_USER;
}
CamelType
@@ -181,29 +186,23 @@ camel_imap_folder_get_type (void)
}
CamelFolder *
-camel_imap_folder_new (CamelStore *parent, char *folder_name, CamelException *ex)
+camel_imap_folder_new (CamelStore *parent, char *folder_name)
{
CamelFolder *folder = CAMEL_FOLDER (camel_object_new (camel_imap_folder_get_type ()));
CamelURL *url = CAMEL_SERVICE (parent)->url;
- char *dir_sep;
+ char *dir_sep, *short_name;
dir_sep = CAMEL_IMAP_STORE (parent)->dir_sep;
-
- CF_CLASS (folder)->init (folder, parent, NULL, folder_name, dir_sep, FALSE, ex);
-
- if (camel_exception_is_set (ex)) {
- camel_object_unref (CAMEL_OBJECT (folder));
- return NULL;
- }
+ short_name = strrchr (folder_name, *dir_sep);
+ if (short_name)
+ short_name++;
+ else
+ short_name = folder_name;
+ camel_folder_construct (folder, parent, folder_name, short_name);
if (!strcmp (folder_name, url->path + 1))
folder->can_hold_messages = FALSE;
- if (camel_exception_is_set (ex)) {
- camel_object_unref (CAMEL_OBJECT (folder));
- return NULL;
- }
-
return folder;
}
@@ -249,60 +248,22 @@ static void
imap_finalize (CamelObject *object)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (object);
- gint max, i;
+ gint i;
imap_folder_summary_free (imap_folder);
if (imap_folder->lsub) {
- max = imap_folder->lsub->len;
-
- for (i = 0; i < max; i++) {
- g_free (imap_folder->lsub->pdata[i]);
- imap_folder->lsub->pdata[i] = NULL;
- }
+ for (i = 0; i < imap_folder->lsub->len; i++)
+ camel_folder_info_free (imap_folder->lsub->pdata[i]);
g_ptr_array_free (imap_folder->lsub, TRUE);
}
}
-static void
-imap_init (CamelFolder *folder, CamelStore *parent_store, CamelFolder *parent_folder,
- const gchar *name, gchar *separator, gboolean path_begins_with_sep, CamelException *ex)
-{
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
-
- /* 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;
-
- /* 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;
-
- /* some IMAP daemons support user-flags *
- * I would not, however, rely on this feature as *
- * most IMAP daemons do not support all the features */
- folder->permanent_flags = CAMEL_MESSAGE_SEEN |
- CAMEL_MESSAGE_ANSWERED |
- CAMEL_MESSAGE_FLAGGED |
- CAMEL_MESSAGE_DELETED |
- CAMEL_MESSAGE_DRAFT |
- CAMEL_MESSAGE_USER;
-
- imap_folder->search = NULL;
- imap_folder->summary = NULL;
- imap_folder->summary_hash = NULL;
- imap_folder->lsub = NULL;
-}
-
static void
imap_refresh_info (CamelFolder *folder, CamelException *ex)
{
- imap_get_subfolder_names_internal (folder, ex);
+ imap_get_subfolder_info_internal (folder, ex);
if (folder->can_hold_messages)
imap_get_summary_internal (folder, ex);
@@ -613,7 +574,7 @@ imap_get_uids (CamelFolder *folder)
}
static GPtrArray *
-imap_get_subfolder_names_internal (CamelFolder *folder, CamelException *ex)
+imap_get_subfolder_info_internal (CamelFolder *folder, CamelException *ex)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelStore *store = CAMEL_STORE (folder->parent_store);
@@ -622,6 +583,7 @@ imap_get_subfolder_names_internal (CamelFolder *folder, CamelException *ex)
gboolean found_inbox = FALSE;
gint status;
gchar *result, *namespace, *dir_sep;
+ CamelFolderInfo *fi;
g_return_val_if_fail (folder != NULL, g_ptr_array_new ());
@@ -687,9 +649,18 @@ imap_get_subfolder_names_internal (CamelFolder *folder, CamelException *ex)
if (*dir) {
d(fprintf (stderr, "adding folder: %s\n", dir));
+ fi = g_new0 (CamelFolderInfo, 1);
+ fi->full_name = dir;
+ fi->name = strrchr (dir, *sep);
+ if (fi->name)
+ fi->name = g_strdup (fi->name + 1);
+ else
+ fi->name = g_strdup (dir);
+ /* FIXME: read/unread msg count */
+
if (!g_strcasecmp (dir, "INBOX"))
found_inbox = TRUE;
- g_ptr_array_add (listing, dir);
+ g_ptr_array_add (listing, fi);
}
g_free (sep);
@@ -712,7 +683,7 @@ imap_get_subfolder_names_internal (CamelFolder *folder, CamelException *ex)
}
static GPtrArray *
-imap_get_subfolder_names (CamelFolder *folder)
+imap_get_subfolder_info (CamelFolder *folder)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h
index 4df50ed027..3dc10b3682 100644
--- a/camel/providers/imap/camel-imap-folder.h
+++ b/camel/providers/imap/camel-imap-folder.h
@@ -62,8 +62,7 @@ typedef struct {
/* public methods */
-CamelFolder *camel_imap_folder_new (CamelStore *parent, char *folder_name,
- CamelException *ex);
+CamelFolder *camel_imap_folder_new (CamelStore *parent, char *folder_name);
void camel_imap_folder_changed (CamelFolder *folder, gint recent, GPtrArray *expunged,
CamelException *ex);
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 22a89a9751..8dc82ed7e5 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -502,10 +502,7 @@ get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelEx
else
folder_path = g_strdup (folder_name);
- new_folder = camel_imap_folder_new (store, folder_path, ex);
-
- if (camel_exception_is_set (ex))
- return NULL;
+ new_folder = camel_imap_folder_new (store, folder_path);
/* this is the top-level dir, we already know it exists - it has to! */
/* Yes, we use a hard-coded "/" here - this just means top-level directory */
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
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. */
diff --git a/camel/providers/mh/camel-mh-folder.h b/camel/providers/mh/camel-mh-folder.h
index 37ff133c9e..90f2324d11 100644
--- a/camel/providers/mh/camel-mh-folder.h
+++ b/camel/providers/mh/camel-mh-folder.h
@@ -62,6 +62,7 @@ typedef struct {
} CamelMhFolderClass;
/* public methods */
+CamelFolder *camel_mh_folder_new(CamelStore *parent_store, const char *full_name, CamelException *ex);
/* Standard Camel function */
CamelType camel_mh_folder_get_type(void);
diff --git a/camel/providers/mh/camel-mh-store.c b/camel/providers/mh/camel-mh-store.c
index c720cb1c91..e45a5b72e2 100644
--- a/camel/providers/mh/camel-mh-store.c
+++ b/camel/providers/mh/camel-mh-store.c
@@ -98,7 +98,6 @@ const gchar *camel_mh_store_get_toplevel_dir(CamelMhStore * store)
static CamelFolder *get_folder(CamelStore * store, const char *folder_name, gboolean create, CamelException * ex)
{
- CamelFolder *new_folder = NULL;
char *name;
struct stat st;
@@ -110,33 +109,33 @@ static CamelFolder *get_folder(CamelStore * store, const char *folder_name, gboo
if (errno != ENOENT) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
"Could not open folder `%s':" "\n%s", folder_name, g_strerror(errno));
- goto done;
+ g_free (name);
+ return NULL;
}
if (!create) {
camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
"Folder `%s' does not exist.", folder_name);
- goto done;
+ g_free (name);
+ return NULL;
}
printf("creating ...\n");
if (mkdir(name, 0700) != 0) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
"Could not create folder `%s':" "\n%s", folder_name, g_strerror(errno));
- goto done;
+ g_free (name);
+ return NULL;
}
printf("created ok?\n");
} else if (!S_ISDIR(st.st_mode)) {
camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER, "`%s' is not a directory.", name);
- goto done;
+ g_free (name);
+ return NULL;
}
-
- new_folder = CAMEL_FOLDER (camel_object_new(CAMEL_MH_FOLDER_TYPE));
-
- CF_CLASS(new_folder)->init(new_folder, store, NULL, folder_name, "/", TRUE, ex);
-done:
g_free(name);
- return new_folder;
+
+ return camel_mh_folder_new (store, folder_name, ex);
}
static void delete_folder(CamelStore * store, const char *folder_name, CamelException * ex)
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index 6ab92923a2..2206064289 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -57,37 +57,6 @@ static CamelFolderClass *parent_class=NULL;
#define CNNTPS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-static void
-nntp_folder_init (CamelFolder *folder, CamelStore *parent_store,
- CamelFolder *parent_folder, const gchar *name,
- gchar *separator, gboolean path_begins_with_sep,
- CamelException *ex)
-{
- CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
-
- /* call parent method */
- parent_class->init (folder, parent_store, parent_folder,
- name, separator, path_begins_with_sep,
- ex);
- if (camel_exception_is_set (ex)) return;
-
- /* set flags */
-
- if (!strcmp (name, "/")) {
- /* the root folder is the only folder that has "subfolders" */
- folder->can_hold_folders = TRUE;
- folder->can_hold_messages = FALSE;
- }
- else {
- folder->can_hold_folders = FALSE;
- folder->can_hold_messages = TRUE;
- folder->has_summary_capability = TRUE;
- }
-
- /* XX */
- nntp_folder->group_name = g_strdup (strrchr (name, '/') + 1);
-}
-
static void
nntp_refresh_info (CamelFolder *folder, CamelException *ex)
{
@@ -101,7 +70,7 @@ nntp_refresh_info (CamelFolder *folder, CamelException *ex)
nntp_folder->summary_file_path = g_strdup_printf ("%s/%s-ev-summary",
root_dir_path,
- nntp_folder->group_name);
+ folder->name);
nntp_folder->summary = camel_folder_summary_new ();
camel_folder_summary_set_filename (nntp_folder->summary,
@@ -134,16 +103,6 @@ nntp_folder_sync (CamelFolder *folder, gboolean expunge,
camel_nntp_newsrc_write (store->newsrc);
}
-static CamelFolder*
-nntp_folder_get_subfolder (CamelFolder *folder,
- const gchar *folder_name,
- gboolean create,
- CamelException *ex)
-{
- g_assert (0);
- return NULL;
-}
-
static gint
nntp_folder_get_message_count (CamelFolder *folder)
{
@@ -180,7 +139,7 @@ nntp_folder_set_message_flags (CamelFolder *folder, const char *uid,
sscanf (uid, "%d", &article_num);
camel_nntp_newsrc_mark_article_read (nntp_store->newsrc,
- nntp_folder->group_name,
+ folder->name,
article_num);
}
@@ -304,27 +263,34 @@ nntp_folder_get_summary (CamelFolder *folder)
}
static GPtrArray *
-nntp_folder_get_subfolder_names (CamelFolder *folder)
+nntp_folder_get_subfolder_info (CamelFolder *folder)
{
- if (!strcmp (folder->name, "/")) {
- CamelStore *store = camel_folder_get_parent_store (folder);
+ CamelNNTPNewsrc *newsrc;
+ GPtrArray *names, *info;
+ CamelFolderInfo *fi;
+ int i;
- if (CAMEL_NNTP_STORE (store)->newsrc) {
- GPtrArray *array = camel_nntp_newsrc_get_subscribed_group_names (CAMEL_NNTP_STORE (store)->newsrc);
- return array;
- }
- }
-
- return NULL;
-}
+ /* Only top-level folder has subfolders. */
+ if (*folder->name)
+ return NULL;
-static void
-nntp_folder_free_subfolder_names (CamelFolder *folder, GPtrArray *subfolders)
-{
- if (subfolders) {
- CamelStore *store = camel_folder_get_parent_store (folder);
- camel_nntp_newsrc_free_group_names (CAMEL_NNTP_STORE (store)->newsrc, subfolders);
+ newsrc = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder))->newsrc;
+ if (!newsrc)
+ return NULL;
+
+ info = g_ptr_array_new ();
+ names = camel_nntp_newsrc_get_subscribed_group_names (newsrc);
+ for (i = 0; i < names->len; i++) {
+ fi = g_new (CamelFolderInfo, 1);
+ fi->name = fi->full_name = names->pdata[i];
+ /* FIXME */
+ fi->message_count = 0;
+ fi->unread_message_count = 0;
+ g_ptr_array_add (info, fi);
}
+ camel_nntp_newsrc_free_group_names (newsrc, names);
+
+ return info;
}
static GPtrArray*
@@ -360,10 +326,8 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class)
/* virtual method definition */
/* virtual method overload */
- camel_folder_class->init = nntp_folder_init;
camel_folder_class->refresh_info = nntp_refresh_info;
camel_folder_class->sync = nntp_folder_sync;
- camel_folder_class->get_subfolder = nntp_folder_get_subfolder;
camel_folder_class->get_message_count = nntp_folder_get_message_count;
camel_folder_class->set_message_flags = nntp_folder_set_message_flags;
camel_folder_class->get_message_flags = nntp_folder_get_message_flags;
@@ -372,8 +336,8 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class)
camel_folder_class->free_uids = camel_folder_free_deep;
camel_folder_class->get_summary = nntp_folder_get_summary;
camel_folder_class->free_summary = camel_folder_free_nop;
- camel_folder_class->get_subfolder_names = nntp_folder_get_subfolder_names;
- camel_folder_class->free_subfolder_names = nntp_folder_free_subfolder_names;
+ camel_folder_class->get_subfolder_info = nntp_folder_get_subfolder_info;
+ camel_folder_class->free_subfolder_info = camel_folder_free_deep;
camel_folder_class->search_by_expression = nntp_folder_search_by_expression;
camel_folder_class->get_message_info = nntp_folder_get_message_info;
}
@@ -399,12 +363,26 @@ camel_nntp_folder_get_type (void)
CamelFolder *
camel_nntp_folder_new (CamelStore *parent, const char *folder_name, CamelException *ex)
{
- CamelFolder *new_folder = CAMEL_FOLDER (camel_object_new (CAMEL_NNTP_FOLDER_TYPE));
+ CamelFolder *folder = CAMEL_FOLDER (camel_object_new (CAMEL_NNTP_FOLDER_TYPE));
- CF_CLASS (new_folder)->init (new_folder, parent, NULL,
- folder_name, ".", FALSE, ex);
+ camel_folder_construct (folder, parent, folder_name, folder_name);
- CF_CLASS (new_folder)->refresh_info (new_folder, ex);
+ /* set flags */
+ if (!*folder->name) {
+ /* the root folder is the only folder that has "subfolders" */
+ folder->can_hold_folders = TRUE;
+ folder->can_hold_messages = FALSE;
+ }
+ else {
+ folder->can_hold_folders = FALSE;
+ folder->can_hold_messages = TRUE;
+ folder->has_summary_capability = TRUE;
+ }
- return new_folder;
+ camel_folder_refresh_info (folder, ex);
+ if (camel_exception_is_set (ex)) {
+ camel_object_unref (CAMEL_OBJECT (folder));
+ folder = NULL;
+ }
+ return folder;
}
diff --git a/camel/providers/nntp/camel-nntp-folder.h b/camel/providers/nntp/camel-nntp-folder.h
index db1687c907..eed946fb5c 100644
--- a/camel/providers/nntp/camel-nntp-folder.h
+++ b/camel/providers/nntp/camel-nntp-folder.h
@@ -46,7 +46,6 @@ extern "C" {
typedef struct {
CamelFolder parent_object;
- gchar *group_name;
gchar *summary_file_path; /* contains the messages summary */
CamelFolderSummary *summary;
} CamelNNTPFolder;
diff --git a/camel/providers/nntp/camel-nntp-newsrc.c b/camel/providers/nntp/camel-nntp-newsrc.c
index af40308219..a44e42c910 100644
--- a/camel/providers/nntp/camel-nntp-newsrc.c
+++ b/camel/providers/nntp/camel-nntp-newsrc.c
@@ -29,6 +29,7 @@
#include <fcntl.h>
#include <unistd.h>
#include "camel-nntp-newsrc.h"
+#include <camel/camel-folder-summary.h>
typedef struct {
guint low;
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index bedcd3f13c..609520251b 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -296,6 +296,12 @@ nntp_store_get_folder (CamelStore *store, const gchar *folder_name,
return camel_nntp_folder_new (store, folder_name, ex);
}
+static char *
+nntp_store_get_root_folder_name (CamelStore *store, CamelException *ex)
+{
+ return g_strdup ("");
+}
+
static void
finalize (CamelObject *object)
{
@@ -325,6 +331,7 @@ camel_nntp_store_class_init (CamelNNTPStoreClass *camel_nntp_store_class)
camel_service_class->get_name = nntp_store_get_name;
camel_store_class->get_folder = nntp_store_get_folder;
+ camel_store_class->get_root_folder_name = nntp_store_get_root_folder_name;
}
diff --git a/camel/providers/nntp/camel-nntp-utils.c b/camel/providers/nntp/camel-nntp-utils.c
index c741146f26..1a990fb94f 100644
--- a/camel/providers/nntp/camel-nntp-utils.c
+++ b/camel/providers/nntp/camel-nntp-utils.c
@@ -87,7 +87,7 @@ get_OVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
new_info->subject = g_strdup(subject);
new_info->from = g_strdup(from);
- new_info->to = g_strdup(nntp_folder->group_name);
+ new_info->to = g_strdup(folder->name);
new_info->date_sent = header_decode_date(date, NULL);
#if 0
/* XXX do we need to fill in both dates? */
@@ -98,7 +98,7 @@ get_OVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
new_info->message_id = g_strdup(message_id);
if (camel_nntp_newsrc_article_is_read (nntp_store->newsrc,
- nntp_folder->group_name,
+ folder->name,
atoi (split_line[0])))
new_info->flags |= CAMEL_MESSAGE_SEEN;
@@ -222,7 +222,7 @@ camel_nntp_get_headers (CamelStore *store,
int status;
status = camel_nntp_command (nntp_store, ex, &ret,
- "GROUP %s", CAMEL_NNTP_FOLDER (folder)->group_name);
+ "GROUP %s", folder->name);
sscanf (ret, "%d %d %d", &nb_message, &first_message, &last_message);
g_free (ret);
@@ -232,7 +232,7 @@ camel_nntp_get_headers (CamelStore *store,
camel_exception_setv (ex,
CAMEL_EXCEPTION_FOLDER_INVALID,
"group %s not found on server",
- CAMEL_NNTP_FOLDER (folder)->group_name);
+ folder->name);
return;
}
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index f7a86a741c..d367cac1ab 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -76,11 +76,15 @@ static void
camel_pop3_folder_init (gpointer object)
{
CamelFolder *folder = CAMEL_FOLDER (object);
+ CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (object);
folder->can_hold_messages = TRUE;
folder->can_hold_folders = FALSE;
folder->has_summary_capability = FALSE;
folder->has_search_capability = FALSE;
+
+ pop3_folder->uids = NULL;
+ pop3_folder->flags = NULL;
}
CamelType
@@ -113,16 +117,18 @@ pop3_finalize (CamelObject *object)
CamelFolder *
camel_pop3_folder_new (CamelStore *parent, CamelException *ex)
{
- CamelPop3Folder *pop3_folder;
+ CamelFolder *folder;
- pop3_folder = CAMEL_POP3_FOLDER(camel_object_new (CAMEL_POP3_FOLDER_TYPE));
- CF_CLASS (pop3_folder)->init ((CamelFolder *)pop3_folder, parent,
- NULL, "inbox", "/", TRUE, ex);
- pop3_folder->uids = NULL;
- pop3_folder->flags = NULL;
- CF_CLASS (pop3_folder)->refresh_info ((CamelFolder *)pop3_folder, ex);
+ folder = CAMEL_FOLDER (camel_object_new (CAMEL_POP3_FOLDER_TYPE));
+ camel_folder_construct (folder, parent, "inbox", "inbox");
+
+ camel_folder_refresh_info (folder, ex);
+ if (camel_exception_is_set (ex)) {
+ camel_object_unref (CAMEL_OBJECT (folder));
+ folder = NULL;
+ }
- return (CamelFolder *)pop3_folder;
+ return folder;
}
static void
diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c
index 26e6be2667..0be1f152d1 100644
--- a/camel/providers/vee/camel-vee-folder.c
+++ b/camel/providers/vee/camel-vee-folder.c
@@ -39,10 +39,6 @@ struct _CamelVeeFolderPrivate {
#define _PRIVATE(o) (((CamelVeeFolder *)(o))->priv)
-static void vee_init (CamelFolder *folder, CamelStore *parent_store,
- CamelFolder *parent_folder, const gchar *name,
- gchar *separator, gboolean path_begins_with_sep,
- CamelException *ex);
static void vee_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
static GPtrArray *vee_get_uids (CamelFolder *folder);
@@ -95,7 +91,6 @@ camel_vee_folder_class_init (CamelVeeFolderClass *klass)
camel_vee_folder_parent = CAMEL_FOLDER_CLASS(camel_type_get_global_classfuncs (camel_folder_get_type ()));
- folder_class->init = vee_init;
folder_class->sync = vee_sync;
folder_class->get_uids = vee_get_uids;
@@ -120,8 +115,21 @@ static void
camel_vee_folder_init (CamelVeeFolder *obj)
{
struct _CamelVeeFolderPrivate *p;
+ CamelFolder *folder = (CamelFolder *)obj;
p = _PRIVATE(obj) = g_malloc0(sizeof(*p));
+
+ folder->can_hold_messages = TRUE;
+ folder->can_hold_folders = FALSE;
+ folder->has_summary_capability = TRUE;
+ folder->has_search_capability = TRUE;
+
+ /* FIXME: what to do about user flags if the subfolder doesn't support them? */
+ folder->permanent_flags = CAMEL_MESSAGE_ANSWERED |
+ CAMEL_MESSAGE_DELETED |
+ CAMEL_MESSAGE_DRAFT |
+ CAMEL_MESSAGE_FLAGGED |
+ CAMEL_MESSAGE_SEEN;
}
static void
@@ -141,16 +149,49 @@ camel_vee_folder_finalise (CamelObject *obj)
/**
* camel_vee_folder_new:
+ * @parent_store: the parent CamelVeeStore
+ * @name: the vfolder name
+ * @ex: a CamelException
*
* Create a new CamelVeeFolder object.
- *
+ *
* Return value: A new CamelVeeFolder widget.
**/
-CamelVeeFolder *
-camel_vee_folder_new (void)
+CamelFolder *
+camel_vee_folder_new (CamelStore *parent_store, const char *name,
+ CamelException *ex)
{
- CamelVeeFolder *new = CAMEL_VEE_FOLDER ( camel_object_new (camel_vee_folder_get_type ()));
- return new;
+ CamelFolder *folder;
+ CamelVeeFolder *vf;
+ char *namepart, *searchpart;
+
+ folder = CAMEL_FOLDER (camel_object_new (camel_vee_folder_get_type()));
+ vf = (CamelVeeFolder *)folder;
+
+ camel_folder_construct (folder, parent_store, name, name);
+
+ namepart = g_strdup(name);
+ searchpart = strchr(namepart, '?');
+ if (searchpart == NULL) {
+ /* no search, no result! */
+ searchpart = "(body-contains \"=some-invalid_string-sequence=xx\")";
+ } else {
+ *searchpart++ = 0;
+ }
+
+ vf->messages = g_ptr_array_new();
+ vf->messages_uid = g_hash_table_new(g_str_hash, g_str_equal);
+
+ vf->expression = g_strdup(searchpart);
+ vf->vname = namepart;
+
+ vee_folder_build(vf, ex);
+ if (camel_exception_is_set (ex)) {
+ camel_object_unref (CAMEL_OBJECT (folder));
+ return NULL;
+ }
+
+ return folder;
}
static void
@@ -211,50 +252,6 @@ camel_vee_folder_add_folder(CamelVeeFolder *vf, CamelFolder *sub)
}
-static void vee_init (CamelFolder *folder, CamelStore *parent_store,
- CamelFolder *parent_folder, const gchar *name,
- gchar *separator, gboolean path_begins_with_sep,
- CamelException *ex)
-{
- CamelVeeFolder *vf = (CamelVeeFolder *)folder;
- char *namepart, *searchpart;
-
- namepart = g_strdup(name);
- searchpart = strchr(namepart, '?');
- if (searchpart == NULL) {
- /* no search, no result! */
- searchpart = "(body-contains \"=some-invalid_string-sequence=xx\")";
- } else {
- *searchpart++ = 0;
- }
-
- camel_vee_folder_parent->init (folder, parent_store, parent_folder, name, separator, TRUE, ex);
- if (camel_exception_get_id (ex))
- return;
-
- folder->can_hold_messages = TRUE;
- folder->can_hold_folders = FALSE;
- folder->has_summary_capability = TRUE;
- folder->has_search_capability = TRUE;
-
- /* FIXME: what to do about user flags if the subfolder doesn't support them? */
- folder->permanent_flags = CAMEL_MESSAGE_ANSWERED |
- CAMEL_MESSAGE_DELETED |
- CAMEL_MESSAGE_DRAFT |
- CAMEL_MESSAGE_FLAGGED |
- CAMEL_MESSAGE_SEEN;
-
- vf->messages = g_ptr_array_new();
- vf->messages_uid = g_hash_table_new(g_str_hash, g_str_equal);
-
- vf->expression = g_strdup_printf("(or\n (match-all (user-flag \"%s\"))\n %s\n)", namepart, searchpart);
- vf->vname = g_strdup(namepart);
-
- g_free(namepart);
-
- vee_folder_build(vf, ex);
-}
-
static void
vee_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
{
diff --git a/camel/providers/vee/camel-vee-folder.h b/camel/providers/vee/camel-vee-folder.h
index 6f7c788125..2263854912 100644
--- a/camel/providers/vee/camel-vee-folder.h
+++ b/camel/providers/vee/camel-vee-folder.h
@@ -50,7 +50,9 @@ struct _CamelVeeFolderClass {
};
guint camel_vee_folder_get_type (void);
-CamelVeeFolder *camel_vee_folder_new (void);
+CamelFolder *camel_vee_folder_new (CamelStore *parent_store,
+ const char *name,
+ CamelException *ex);
void camel_vee_folder_add_folder(CamelVeeFolder *vf, CamelFolder *sub);
diff --git a/camel/providers/vee/camel-vee-store.c b/camel/providers/vee/camel-vee-store.c
index 8be8298b2c..201c4b1fd8 100644
--- a/camel/providers/vee/camel-vee-store.c
+++ b/camel/providers/vee/camel-vee-store.c
@@ -91,12 +91,7 @@ camel_vee_store_new (void)
static CamelFolder *
vee_get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelException *ex)
{
- CamelFolder *folder;
-
- folder = CAMEL_FOLDER (camel_object_new (camel_vee_folder_get_type()));
-
- ((CamelFolderClass *)(CAMEL_OBJECT_GET_CLASS(folder)))->init (folder, store, NULL, folder_name, "/", TRUE, ex);
- return folder;
+ return camel_vee_folder_new (store, folder_name, ex);
}
static char *