aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c186
-rw-r--r--camel/providers/nntp/camel-nntp-folder.c18
-rw-r--r--camel/providers/pop3/camel-pop3-folder.c84
-rw-r--r--camel/providers/pop3/camel-pop3-folder.h3
-rw-r--r--camel/providers/vee/camel-vee-folder.c35
5 files changed, 107 insertions, 219 deletions
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index a67d2ee67e..707fea1206 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -66,11 +66,12 @@ static gboolean mbox_exists (CamelFolder *folder, CamelException *ex);
static gboolean mbox_create(CamelFolder *folder, CamelException *ex);
static gboolean mbox_delete (CamelFolder *folder, gboolean recurse, CamelException *ex);
static gboolean mbox_delete_messages (CamelFolder *folder, CamelException *ex);
-static GList *mbox_list_subfolders (CamelFolder *folder, CamelException *ex);
-static CamelMimeMessage *mbox_get_message_by_number (CamelFolder *folder, gint number, CamelException *ex);
static gint mbox_get_message_count (CamelFolder *folder, CamelException *ex);
static void mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
-static GList *mbox_get_uid_list (CamelFolder *folder, CamelException *ex);
+static GPtrArray *mbox_get_uids (CamelFolder *folder, CamelException *ex);
+static GPtrArray *mbox_get_subfolder_names (CamelFolder *folder, CamelException *ex);
+static GPtrArray *mbox_get_summary (CamelFolder *folder, CamelException *ex);
+static void mbox_free_summary (CamelFolder *folder, GPtrArray *array);
static CamelMimeMessage *mbox_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex);
static void mbox_expunge (CamelFolder *folder, CamelException *ex);
@@ -81,7 +82,6 @@ static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *mes
static void mbox_delete_message_by_uid(CamelFolder *folder, const gchar *uid, CamelException *ex);
-GPtrArray *summary_get_message_info (CamelFolder *folder, int first, int count);
static const CamelMessageInfo *mbox_summary_get_by_uid(CamelFolder *f, const char *uid);
static GList *mbox_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex);
@@ -106,11 +106,12 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class)
camel_folder_class->create = mbox_create;
camel_folder_class->delete = mbox_delete;
camel_folder_class->delete_messages = mbox_delete_messages;
- camel_folder_class->list_subfolders = mbox_list_subfolders;
- camel_folder_class->get_message_by_number = mbox_get_message_by_number;
camel_folder_class->get_message_count = mbox_get_message_count;
camel_folder_class->append_message = mbox_append_message;
- camel_folder_class->get_uid_list = mbox_get_uid_list;
+ camel_folder_class->get_uids = mbox_get_uids;
+ camel_folder_class->get_subfolder_names = mbox_get_subfolder_names;
+ camel_folder_class->get_summary = mbox_get_summary;
+ camel_folder_class->free_summary = mbox_free_summary;
camel_folder_class->expunge = mbox_expunge;
camel_folder_class->get_message_by_uid = mbox_get_message_by_uid;
@@ -118,7 +119,6 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class)
camel_folder_class->search_by_expression = mbox_search_by_expression;
- camel_folder_class->get_message_info = summary_get_message_info;
camel_folder_class->summary_get_by_uid = mbox_summary_get_by_uid;
gtk_object_class->finalize = mbox_finalize;
@@ -179,7 +179,6 @@ mbox_init (CamelFolder *folder, CamelStore *parent_store,
folder->can_hold_messages = TRUE;
folder->can_hold_folders = TRUE;
folder->has_summary_capability = TRUE;
- folder->has_uid_capability = TRUE;
folder->has_search_capability = TRUE;
folder->permanent_flags = CAMEL_MESSAGE_ANSWERED |
@@ -577,125 +576,6 @@ mbox_delete_messages (CamelFolder *folder, CamelException *ex)
}
-/* FIXME: cleanup */
-static GList *
-mbox_list_subfolders (CamelFolder *folder, CamelException *ex)
-{
- GList *subfolder_name_list = NULL;
-
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
- const gchar *folder_dir_path;
- gboolean folder_exists;
-
- struct stat stat_buf;
- gint stat_error = 0;
- gchar *entry_name;
- gchar *full_entry_name;
- gchar *real_folder_name;
- struct dirent *dir_entry;
- DIR *dir_handle;
- gboolean folder_suffix_found;
-
-
- /* check if the folder object exists */
- if (!folder) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_NULL,
- "folder object is NULL");
- return FALSE;
- }
-
-
- /* in the case the folder does not exist,
- raise an exception */
- folder_exists = camel_folder_exists (folder, ex);
- if (camel_exception_get_id (ex)) return FALSE;
-
- if (!folder_exists) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "Inexistant folder.");
- return FALSE;
- }
-
-
- /* get the mbox subfolders directories */
- folder_dir_path = mbox_folder->folder_file_path;
- if (!folder_dir_path) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "Invalid folder path. Use set_name ?");
- return FALSE;
- }
-
-
- dir_handle = opendir (folder_dir_path);
-
- /* read the first entry in the directory */
- dir_entry = readdir (dir_handle);
- while ((stat_error != -1) && (dir_entry != NULL)) {
-
- /* get the name of the next entry in the dir */
- entry_name = dir_entry->d_name;
- full_entry_name = g_strdup_printf ("%s/%s", folder_dir_path, entry_name);
- stat_error = stat (full_entry_name, &stat_buf);
- g_free (full_entry_name);
-
- /* is it a directory ? */
- if ((stat_error != -1) && S_ISDIR (stat_buf.st_mode)) {
- /* yes, add it to the list */
- if (entry_name[0] != '.') {
- /* if the folder is a netscape folder, remove the
- ".sdb" from the name */
- real_folder_name = string_prefix (entry_name, ".sdb", &folder_suffix_found);
- /* stick here the tests for other folder suffixes if any */
-
- if (!folder_suffix_found) real_folder_name = g_strdup (entry_name);
-
- /* add the folder name to the list */
- subfolder_name_list = g_list_append (subfolder_name_list,
- real_folder_name);
- }
- }
- /* read next entry */
- dir_entry = readdir (dir_handle);
- }
-
- closedir (dir_handle);
-
- return subfolder_name_list;
-
-
-
- /* io exception handling */
- switch (errno) {
- case EACCES :
-
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "Unable to list the directory. Full Error text is : %s ",
- strerror (errno));
- break;
-
- case ENOENT :
- case ENOTDIR :
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
- "Invalid mbox folder path. Full Error text is : %s ",
- strerror (errno));
- break;
-
- default :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- "Unable to delete the mbox folder.");
-
- }
-
- g_list_free (subfolder_name_list);
- return NULL;
-}
-
static gint
mbox_get_message_count (CamelFolder *folder, CamelException *ex)
{
@@ -789,40 +669,29 @@ fail:
}
}
-static GList *
-mbox_get_uid_list (CamelFolder *folder, CamelException *ex)
+static GPtrArray *
+mbox_get_uids (CamelFolder *folder, CamelException *ex)
{
- GList *uid_list = NULL;
+ GPtrArray *array;
CamelMboxFolder *mbox_folder = (CamelMboxFolder *)folder;
int i, count;
- /* FIXME: how are these allocated strings ever free'd? */
count = camel_folder_summary_count((CamelFolderSummary *)mbox_folder->summary);
+ array = g_ptr_array_new ();
+ g_ptr_array_set_size (array, count);
for (i=0;i<count;i++) {
CamelMboxMessageInfo *info = (CamelMboxMessageInfo *)camel_folder_summary_index((CamelFolderSummary *)mbox_folder->summary, i);
- uid_list = g_list_prepend(uid_list, g_strdup(info->info.uid));
+ array->pdata[i] = g_strdup(info->info.uid);
}
- return uid_list;
+ return array;
}
-static CamelMimeMessage *
-mbox_get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
+static GPtrArray *
+mbox_get_subfolder_names (CamelFolder *folder, CamelException *ex)
{
- CamelMboxFolder *mbox_folder = (CamelMboxFolder *)folder;
- CamelMboxMessageInfo *info;
-
- g_warning("YOUR CODE SHOULD NOT BE GETTING MESSAGES BY NUMBER, CHANGE IT");
-
- info = (CamelMboxMessageInfo *)camel_folder_summary_index((CamelFolderSummary *)mbox_folder->summary, number);
- if (info == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- "No such message %d in folder `%s'.",
- number, folder->name);
- return NULL;
- }
-
- return mbox_get_message_by_uid (folder, info->info.uid, ex);
+ /* No subfolders. */
+ return g_ptr_array_new ();
}
static void
@@ -948,19 +817,18 @@ fail:
return NULL;
}
-/* get message info for a range of messages */
-GPtrArray *summary_get_message_info (CamelFolder *folder, int first, int count)
+GPtrArray *
+mbox_get_summary (CamelFolder *folder, CamelException *ex)
{
- GPtrArray *array = g_ptr_array_new();
- int i, maxcount;
CamelMboxFolder *mbox_folder = (CamelMboxFolder *)folder;
- maxcount = camel_folder_summary_count((CamelFolderSummary *)mbox_folder->summary);
- maxcount = MIN(count, maxcount);
- for (i=first;i<maxcount;i++)
- g_ptr_array_add(array, camel_folder_summary_index((CamelFolderSummary *)mbox_folder->summary, i));
+ return ((CamelFolderSummary *)mbox_folder->summary)->messages;
+}
- return array;
+void
+mbox_free_summary (CamelFolder *folder, GPtrArray *array)
+{
+ /* no-op */
}
/* get a single message info, by uid */
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index 067849712c..8bc623add7 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -71,7 +71,7 @@ static GList *_list_subfolders (CamelFolder *folder, CamelException *ex);
static CamelMimeMessage *_get_message_by_number (CamelFolder *folder, gint number, CamelException *ex);
static gint _get_message_count (CamelFolder *folder, CamelException *ex);
static void _append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
-static GList *_get_uid_list (CamelFolder *folder, CamelException *ex);
+static GPtrArray *_get_uid_array (CamelFolder *folder, CamelException *ex);
static CamelMimeMessage *_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex);
#if 0
static void _expunge (CamelFolder *folder, CamelException *ex);
@@ -101,7 +101,7 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class)
camel_folder_class->delete_messages = _delete_messages;
camel_folder_class->list_subfolders = _list_subfolders;
camel_folder_class->get_message_count = _get_message_count;
- camel_folder_class->get_uid_list = _get_uid_list;
+ camel_folder_class->get_uid_array = _get_uid_array;
camel_folder_class->get_message_by_uid = _get_message_by_uid;
#if 0
camel_folder_class->append_message = _append_message;
@@ -487,23 +487,25 @@ _append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException
-static GList *
-_get_uid_list (CamelFolder *folder, CamelException *ex)
+static GPtrArray *
+_get_uid_array (CamelFolder *folder, CamelException *ex)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
- GPtrArray *message_info_array;
+ GPtrArray *message_info_array, *out;
CamelMessageInfo *message_info;
- GList *uid_list = NULL;
int i;
message_info_array = nntp_folder->summary->messages;
+
+ out = g_ptr_array_new ();
+ g_ptr_array_set_size (out, message_info_array->len);
for (i=0; i<message_info_array->len; i++) {
message_info = (CamelMessageInfo *)(message_info_array->pdata) + i;
- uid_list = g_list_prepend (uid_list, g_strdup (message_info->uid));
+ out->pdata[i] = g_strdup (message_info->uid);
}
- return uid_list;
+ return out;
}
static CamelMimeMessage *
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 838f247ac6..45687e4f33 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -30,6 +30,7 @@
#include "camel-mime-message.h"
#include <stdlib.h>
+#include <string.h>
#define CF_CLASS(o) (CAMEL_FOLDER_CLASS (GTK_OBJECT (o)->klass))
static CamelFolderClass *parent_class;
@@ -39,13 +40,14 @@ static void pop3_open (CamelFolder *folder, CamelFolderOpenMode mode,
static void pop3_close (CamelFolder *folder, gboolean expunge,
CamelException *ex);
static gboolean delete_messages (CamelFolder *folder, CamelException *ex);
-static gboolean has_message_number_capability (CamelFolder *folder);
-static CamelMimeMessage *get_message_by_number (CamelFolder *folder,
- gint number,
- CamelException *ex);
-static void delete_message_by_number (CamelFolder *folder, gint number,
- CamelException *ex);
+
static gint get_message_count (CamelFolder *folder, CamelException *ex);
+static GPtrArray *get_uids (CamelFolder *folder, CamelException *ex);
+static CamelMimeMessage *get_message_by_uid (CamelFolder *folder,
+ const char *uid,
+ CamelException *ex);
+static void delete_message_by_uid (CamelFolder *folder, const char *uid,
+ CamelException *ex);
static void
@@ -60,33 +62,28 @@ camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class)
camel_folder_class->open = pop3_open;
camel_folder_class->close = pop3_close;
camel_folder_class->delete_messages = delete_messages;
- camel_folder_class->has_message_number_capability =
- has_message_number_capability;
- camel_folder_class->get_message_by_number =
- get_message_by_number;
- camel_folder_class->delete_message_by_number =
- delete_message_by_number;
- camel_folder_class->get_message_count =
- get_message_count;
-}
+ camel_folder_class->get_message_count = get_message_count;
+ camel_folder_class->get_uids = get_uids;
+
+ camel_folder_class->get_message_by_uid = get_message_by_uid;
+ camel_folder_class->delete_message_by_uid = delete_message_by_uid;
+}
static void
camel_pop3_folder_init (gpointer object, gpointer klass)
{
+ CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (object);
CamelFolder *folder = CAMEL_FOLDER (object);
folder->can_hold_messages = TRUE;
folder->can_hold_folders = FALSE;
-
- /* Hi. I'm CamelPop3Folder. I'm useless. */
folder->has_summary_capability = FALSE;
- folder->has_uid_capability = FALSE;
folder->has_search_capability = FALSE;
-}
-
+ pop3_folder->count = -1;
+}
GtkType
@@ -168,14 +165,8 @@ delete_messages (CamelFolder *folder, CamelException *ex)
}
-static gboolean
-has_message_number_capability (CamelFolder *folder)
-{
- return TRUE;
-}
-
static CamelMimeMessage *
-get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
+get_message_by_uid (CamelFolder *folder, const char *uid, CamelException *ex)
{
int status;
char *result, *body;
@@ -183,7 +174,7 @@ get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
CamelMimeMessage *msg;
status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store),
- &result, "RETR %d", number);
+ &result, "RETR %d", atoi (uid));
if (status != CAMEL_POP3_OK) {
CamelService *service = CAMEL_SERVICE (folder->parent_store);
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
@@ -216,17 +207,18 @@ get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
}
static void
-delete_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
+delete_message_by_uid (CamelFolder *folder, const char *uid,
+ CamelException *ex)
{
int status;
char *resp;
status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store),
- &resp, "DELE %d", number);
+ &resp, "DELE %d", atoi (uid));
if (status != CAMEL_POP3_OK) {
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "Unable to delete message %d%s%s",
- number, resp ? ": " : "",
+ "Unable to delete message %s%s%s",
+ uid, resp ? ": " : "",
resp ? resp : "");
}
g_free (resp);
@@ -235,9 +227,13 @@ delete_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
static gint
get_message_count (CamelFolder *folder, CamelException *ex)
{
- int status, count;
+ CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder);
+ int status;
char *result;
+ if (pop3_folder->count != -1)
+ return pop3_folder->count;
+
status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store),
&result, "STAT");
if (status != CAMEL_POP3_OK) {
@@ -251,7 +247,25 @@ get_message_count (CamelFolder *folder, CamelException *ex)
return -1;
}
- count = atoi (result);
+ pop3_folder->count = atoi (result);
g_free (result);
- return count;
+ return pop3_folder->count;
+}
+
+static GPtrArray *
+get_uids (CamelFolder *folder, CamelException *ex)
+{
+ int count, i;
+ GPtrArray *array;
+
+ count = get_message_count (folder, ex);
+ if (count == -1)
+ return NULL;
+
+ array = g_ptr_array_new ();
+ g_ptr_array_set_size (array, count);
+ for (i = 0; i < count; i++)
+ array->pdata[i] = g_strdup_printf ("%d", i + 1);
+
+ return array;
}
diff --git a/camel/providers/pop3/camel-pop3-folder.h b/camel/providers/pop3/camel-pop3-folder.h
index 4199e30ead..2a478dc283 100644
--- a/camel/providers/pop3/camel-pop3-folder.h
+++ b/camel/providers/pop3/camel-pop3-folder.h
@@ -45,6 +45,9 @@ extern "C" {
typedef struct {
CamelFolder parent_object;
+ CamelMessageInfo *msg_info;
+ int count;
+
} CamelPop3Folder;
diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c
index d759fd30eb..88e48134a3 100644
--- a/camel/providers/vee/camel-vee-folder.c
+++ b/camel/providers/vee/camel-vee-folder.c
@@ -46,12 +46,13 @@ static void vee_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelExcept
static void vee_close (CamelFolder *folder, gboolean expunge, CamelException *ex);
static gboolean vee_exists (CamelFolder *folder, CamelException *ex);
-static GList *vee_get_uid_list (CamelFolder *folder, CamelException *ex);
+static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex);
+GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex);
+void vee_free_summary (CamelFolder *folder, GPtrArray *array);
static gint vee_get_message_count (CamelFolder *folder, CamelException *ex);
static CamelMimeMessage *vee_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex);
-GPtrArray *vee_summary_get_message_info (CamelFolder *folder, int first, int count);
static const CamelMessageInfo *vee_summary_get_by_uid(CamelFolder *f, const char *uid);
@@ -106,10 +107,11 @@ camel_vee_folder_class_init (CamelVeeFolderClass *klass)
folder_class->close = vee_close;
folder_class->exists = vee_exists;
- folder_class->get_uid_list = vee_get_uid_list;
+ folder_class->get_uids = vee_get_uids;
+ folder_class->get_summary = vee_get_summary;
+ folder_class->free_summary = vee_free_summary;
folder_class->get_message_by_uid = vee_get_message_by_uid;
- folder_class->get_message_info = vee_summary_get_message_info;
folder_class->summary_get_by_uid = vee_summary_get_by_uid;
folder_class->get_message_count = vee_get_message_count;
@@ -163,7 +165,6 @@ static void vee_init (CamelFolder *folder, CamelStore *parent_store,
folder->can_hold_messages = TRUE;
folder->can_hold_folders = FALSE;
folder->has_summary_capability = TRUE;
- folder->has_uid_capability = TRUE;
folder->has_search_capability = TRUE;
/* FIXME: what to do about user flags if the subfolder doesn't support them? */
@@ -223,18 +224,16 @@ static CamelMimeMessage *vee_get_message_by_uid (CamelFolder *folder, const gcha
return camel_folder_get_message_by_uid(mi->folder, strchr(mi->info.uid, ':')+1, ex);
}
-GPtrArray *vee_summary_get_message_info (CamelFolder *folder, int first, int count)
+GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex)
{
- GPtrArray *result;
- int i, max;
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
- result = g_ptr_array_new();
- max = MIN(vf->messages->len, count+first);
- for (i=first;i<max;i++) {
- g_ptr_array_add(result, g_ptr_array_index(vf->messages, i));
- }
- return result;
+ return vf->messages;
+}
+
+void vee_free_summary (CamelFolder *folder, GPtrArray *array)
+{
+ /* no op */
}
static const CamelMessageInfo *vee_summary_get_by_uid(CamelFolder *f, const char *uid)
@@ -244,15 +243,17 @@ static const CamelMessageInfo *vee_summary_get_by_uid(CamelFolder *f, const char
return g_hash_table_lookup(vf->messages_uid, uid);
}
-static GList *vee_get_uid_list (CamelFolder *folder, CamelException *ex)
+static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex)
{
- GList *result = NULL;
+ GPtrArray *result;
int i;
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
+ result = g_ptr_array_new ();
+ g_ptr_array_set_size (result, vf->messages->len);
for (i=0;i<vf->messages->len;i++) {
CamelMessageInfo *mi = g_ptr_array_index(vf->messages, i);
- result = g_list_prepend(result, g_strdup(mi->uid));
+ result->pdata[i] = g_strdup(mi->uid);
}
return result;