aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/imap/camel-imap-folder.c97
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c120
-rw-r--r--camel/providers/nntp/camel-nntp-folder.c55
-rw-r--r--camel/providers/pop3/camel-pop3-folder.c205
-rw-r--r--camel/providers/pop3/camel-pop3-folder.h1
-rw-r--r--camel/providers/vee/camel-vee-folder.c65
6 files changed, 229 insertions, 314 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 3dab6179cb..a8e4a7d602 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -69,35 +69,31 @@ static void imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex
static void imap_expunge (CamelFolder *folder, CamelException *ex);
static gint imap_get_message_count_internal (CamelFolder *folder, CamelException *ex);
-static gint imap_get_message_count (CamelFolder *folder, CamelException *ex);
-static gint imap_get_unread_message_count (CamelFolder *folder, CamelException *ex);
+static gint imap_get_message_count (CamelFolder *folder);
+static gint imap_get_unread_message_count (CamelFolder *folder);
static CamelMimeMessage *imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
static void imap_append_message (CamelFolder *folder, CamelMimeMessage *message, guint32 flags, CamelException *ex);
static void imap_copy_message_to (CamelFolder *source, const char *uid, CamelFolder *destination, CamelException *ex);
static void imap_move_message_to (CamelFolder *source, const char *uid, CamelFolder *destination, CamelException *ex);
-static void imap_delete_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
static gboolean imap_parse_subfolder_line (gchar *buf, gchar *namespace, gchar **flags, gchar **sep, gchar **folder);
static GPtrArray *imap_get_subfolder_names_internal (CamelFolder *folder, CamelException *ex);
-static GPtrArray *imap_get_subfolder_names (CamelFolder *folder, CamelException *ex);
+static GPtrArray *imap_get_subfolder_names (CamelFolder *folder);
-static GPtrArray *imap_get_uids (CamelFolder *folder, CamelException *ex);
+static GPtrArray *imap_get_uids (CamelFolder *folder);
static GPtrArray *imap_get_summary_internal (CamelFolder *folder, CamelException *ex);
-static GPtrArray *imap_get_summary (CamelFolder *folder, CamelException *ex);
+static GPtrArray *imap_get_summary (CamelFolder *folder);
static const CamelMessageInfo *imap_get_message_info (CamelFolder *folder, const char *uid);
static GPtrArray *imap_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex);
/* flag methods */
-static guint32 imap_get_permanent_flags (CamelFolder *folder, CamelException *ex);
-static guint32 imap_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex);
-static void imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set,
- CamelException *ex);
-static gboolean imap_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name,
- CamelException *ex);
+static guint32 imap_get_message_flags (CamelFolder *folder, const char *uid);
+static void imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set);
+static gboolean imap_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name);
static void imap_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name,
- gboolean value, CamelException *ex);
+ gboolean value);
static void
@@ -118,13 +114,12 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
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_deep;
+ camel_folder_class->free_subfolder_names = 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;
camel_folder_class->get_message = imap_get_message;
camel_folder_class->append_message = imap_append_message;
- camel_folder_class->delete_message = imap_delete_message;
camel_folder_class->copy_message_to = imap_copy_message_to;
camel_folder_class->move_message_to = imap_move_message_to;
@@ -134,7 +129,6 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
camel_folder_class->search_by_expression = imap_search_by_expression;
- camel_folder_class->get_permanent_flags = imap_get_permanent_flags;
camel_folder_class->get_message_flags = imap_get_message_flags;
camel_folder_class->set_message_flags = imap_set_message_flags;
camel_folder_class->get_message_user_flag = imap_get_message_user_flag;
@@ -416,7 +410,7 @@ imap_get_message_count_internal (CamelFolder *folder, CamelException *ex)
}
static gint
-imap_get_message_count (CamelFolder *folder, CamelException *ex)
+imap_get_message_count (CamelFolder *folder)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
@@ -427,7 +421,7 @@ imap_get_message_count (CamelFolder *folder, CamelException *ex)
}
static gint
-imap_get_unread_message_count (CamelFolder *folder, CamelException *ex)
+imap_get_unread_message_count (CamelFolder *folder)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelMessageInfo *info;
@@ -440,7 +434,7 @@ imap_get_unread_message_count (CamelFolder *folder, CamelException *ex)
if (!imap_folder->summary)
return 0;
- infolist = imap_get_summary (folder, ex);
+ infolist = imap_get_summary (folder);
for (i = 0; i < infolist->len; i++) {
info = (CamelMessageInfo *) g_ptr_array_index (infolist, i);
@@ -600,19 +594,19 @@ imap_move_message_to (CamelFolder *source, const char *uid, CamelFolder *destina
return;
}
- imap_set_message_flags (source, uid, CAMEL_MESSAGE_DELETED, ~(info->flags), ex);
+ imap_set_message_flags (source, uid, CAMEL_MESSAGE_DELETED, ~(info->flags));
camel_imap_folder_changed (destination, ex);
}
static GPtrArray *
-imap_get_uids (CamelFolder *folder, CamelException *ex)
+imap_get_uids (CamelFolder *folder)
{
CamelMessageInfo *info;
GPtrArray *array, *infolist;
gint i, count;
- infolist = imap_get_summary (folder, ex);
+ infolist = imap_get_summary (folder);
count = infolist->len;
array = g_ptr_array_new ();
@@ -763,30 +757,13 @@ imap_get_subfolder_names_internal (CamelFolder *folder, CamelException *ex)
}
static GPtrArray *
-imap_get_subfolder_names (CamelFolder *folder, CamelException *ex)
+imap_get_subfolder_names (CamelFolder *folder)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
return imap_folder->lsub;
}
-static void
-imap_delete_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
-{
- CamelMessageInfo *info;
-
- if (!(info = (CamelMessageInfo *)imap_get_message_info (folder, uid))) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not set flags for message %s on IMAP server %s: %s",
- uid, service->url->host, "Unknown error");
- return;
- }
-
- imap_set_message_flags (folder, uid, CAMEL_MESSAGE_DELETED, ~(info->flags), ex);
-}
-
static CamelMimeMessage *
imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
{
@@ -1181,7 +1158,7 @@ imap_get_summary_internal (CamelFolder *folder, CamelException *ex)
}
static GPtrArray *
-imap_get_summary (CamelFolder *folder, CamelException *ex)
+imap_get_summary (CamelFolder *folder)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
@@ -1204,6 +1181,7 @@ imap_get_message_info (CamelFolder *folder, const char *uid)
if (imap_folder->summary) {
int max, i;
+ /* FIXME: use a hash table like the mbox provider does */
max = imap_folder->summary->len;
for (i = 0; i < max; i++) {
info = g_ptr_array_index (imap_folder->summary, i);
@@ -1417,42 +1395,23 @@ imap_search_by_expression (CamelFolder *folder, const char *expression, CamelExc
}
static guint32
-imap_get_permanent_flags (CamelFolder *folder, CamelException *ex)
-{
- /* return permamnant flags */
- return folder->permanent_flags;
-}
-
-static guint32
-imap_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex)
+imap_get_message_flags (CamelFolder *folder, const char *uid)
{
- CamelMessageInfo *info;
+ const CamelMessageInfo *info;
- if (!(info = (CamelMessageInfo *)imap_get_message_info (folder, uid))) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not get flags for message %s on IMAP server %s: %s",
- uid, service->url->host, "Unknown error");
- return 0;
- }
+ info = imap_get_message_info (folder, uid);
+ g_return_val_if_fail (info != NULL, 0);
return info->flags;
}
static void
-imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set, CamelException *ex)
+imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set)
{
CamelMessageInfo *info;
- if (!(info = (CamelMessageInfo *)imap_get_message_info (folder, uid))) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not set flags for message %s on IMAP server %s: %s",
- uid, service->url->host, "Unknown error");
- return;
- }
+ info = (CamelMessageInfo*)imap_get_message_info (folder, uid);
+ g_return_if_fail (info != NULL);
info->flags = (info->flags & ~flags) | (set & flags) | CAMEL_MESSAGE_FOLDER_FLAGGED;
@@ -1460,13 +1419,13 @@ imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, gui
}
static gboolean
-imap_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name, CamelException *ex)
+imap_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name)
{
return FALSE;
}
static void
-imap_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value, CamelException *ex)
+imap_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value)
{
gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid);
}
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index 6e94456b8b..deb47f6dcf 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -63,26 +63,24 @@ static void mbox_init (CamelFolder *folder, CamelStore *parent_store,
CamelException *ex);
static void mbox_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
-static gint mbox_get_message_count (CamelFolder *folder, CamelException *ex);
-static gint mbox_get_unread_message_count (CamelFolder *folder, CamelException *ex);
+static gint mbox_get_message_count (CamelFolder *folder);
+static gint mbox_get_unread_message_count (CamelFolder *folder);
static void mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, guint32 flags, 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 GPtrArray *mbox_get_uids (CamelFolder *folder);
+static GPtrArray *mbox_get_subfolder_names (CamelFolder *folder);
+static GPtrArray *mbox_get_summary (CamelFolder *folder);
static CamelMimeMessage *mbox_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
static void mbox_expunge (CamelFolder *folder, CamelException *ex);
-static void mbox_delete_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
-
static const CamelMessageInfo *mbox_get_message_info (CamelFolder *folder, const char *uid);
static GPtrArray *mbox_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex);
-static guint32 mbox_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex);
-static void mbox_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set, CamelException *ex);
-static gboolean mbox_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name, CamelException *ex);
-static void mbox_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value, CamelException *ex);
+static guint32 mbox_get_message_flags (CamelFolder *folder, const char *uid);
+static void mbox_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set);
+static gboolean mbox_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name);
+static void mbox_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value);
static void mbox_finalize (GtkObject *object);
@@ -112,7 +110,6 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class)
camel_folder_class->expunge = mbox_expunge;
camel_folder_class->get_message = mbox_get_message;
- camel_folder_class->delete_message = mbox_delete_message;
camel_folder_class->search_by_expression = mbox_search_by_expression;
@@ -263,31 +260,30 @@ mbox_expunge (CamelFolder *folder, CamelException *ex)
}
static gint
-mbox_get_message_count (CamelFolder *folder, CamelException *ex)
+mbox_get_message_count (CamelFolder *folder)
{
CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
- g_assert (folder);
- g_assert (mbox_folder->summary);
+ g_return_val_if_fail (mbox_folder->summary != NULL, -1);
return camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (mbox_folder->summary));
}
static gint
-mbox_get_unread_message_count (CamelFolder *folder, CamelException *ex)
+mbox_get_unread_message_count (CamelFolder *folder)
{
CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
CamelMessageInfo *info;
GPtrArray *infolist;
gint i, max, count = 0;
- g_return_val_if_fail (folder != NULL, -1);
+ g_return_val_if_fail (mbox_folder->summary != NULL, -1);
max = camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (mbox_folder->summary));
if (max == -1)
return -1;
- infolist = mbox_get_summary (folder, ex);
+ infolist = mbox_get_summary (folder);
for (i = 0; i < infolist->len; i++) {
info = (CamelMessageInfo *) g_ptr_array_index (infolist, i);
@@ -335,7 +331,6 @@ mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, guint32 fla
uid = camel_folder_summary_next_uid (CAMEL_FOLDER_SUMMARY (mbox_folder->summary));
xev = g_strdup_printf ("%08x-%04x", uid, flags);
camel_medium_add_header (CAMEL_MEDIUM (message), "X-Evolution", xev);
- g_print ("%s -- %s\n", __FUNCTION__, xev);
g_free (xev);
/* we must write this to the non-filtered stream ... */
@@ -394,7 +389,7 @@ fail:
}
static GPtrArray *
-mbox_get_uids (CamelFolder *folder, CamelException *ex)
+mbox_get_uids (CamelFolder *folder)
{
GPtrArray *array;
CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
@@ -413,25 +408,12 @@ mbox_get_uids (CamelFolder *folder, CamelException *ex)
}
static GPtrArray *
-mbox_get_subfolder_names (CamelFolder *folder, CamelException *ex)
+mbox_get_subfolder_names (CamelFolder *folder)
{
/* No subfolders. */
return g_ptr_array_new ();
}
-static void
-mbox_delete_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
-{
- const CamelMessageInfo *info;
- CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder);
-
- info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid);
- if (info) {
- mbox_set_message_flags (folder, uid, CAMEL_MESSAGE_DELETED, ~(info->flags), ex);
- camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary));
- }
-}
-
static CamelMimeMessage *
mbox_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
{
@@ -503,7 +485,7 @@ fail:
}
GPtrArray *
-mbox_get_summary (CamelFolder *folder, CamelException *ex)
+mbox_get_summary (CamelFolder *folder)
{
CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
@@ -541,77 +523,59 @@ mbox_search_by_expression (CamelFolder *folder, const char *expression, CamelExc
}
static guint32
-mbox_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex)
+mbox_get_message_flags (CamelFolder *folder, const char *uid)
{
CamelMessageInfo *info;
CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder);
info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid);
- if (info) {
- return info->flags;
- } else {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "No such message %s in %s.", uid,
- folder->name);
- return 0;
- }
+ g_return_val_if_fail (info != NULL, 0);
+
+ return info->flags;
}
static void
mbox_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags,
- guint32 set, CamelException *ex)
+ guint32 set)
{
CamelMessageInfo *info;
CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder);
info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid);
- if (info) {
- info->flags = (info->flags & ~flags) | (set & flags) |
- CAMEL_MESSAGE_FOLDER_FLAGGED;
- camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary));
-
- gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid);
- } else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "No such message %s in %s.", uid,
- folder->name);
- }
+ g_return_if_fail (info != NULL);
+
+ info->flags = (info->flags & ~flags) | (set & flags) |
+ CAMEL_MESSAGE_FOLDER_FLAGGED;
+ camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary));
+
+ gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid);
}
static gboolean
mbox_get_message_user_flag (CamelFolder *folder, const char *uid,
- const char *name, CamelException *ex)
+ const char *name)
{
CamelMessageInfo *info;
CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder);
info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid);
- if (info)
- return camel_flag_get (&info->user_flags, name);
- else {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "No such message %s in %s.", uid,
- folder->name);
- return FALSE;
- }
+ g_return_val_if_fail (info != NULL, FALSE);
+
+ return camel_flag_get (&info->user_flags, name);
}
-static void mbox_set_message_user_flag (CamelFolder *folder, const char *uid,
- const char *name, gboolean value,
- CamelException *ex)
+static void
+mbox_set_message_user_flag (CamelFolder *folder, const char *uid,
+ const char *name, gboolean value)
{
CamelMessageInfo *info;
CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder);
info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid);
- if (info) {
- camel_flag_set (&info->user_flags, name, value);
- info->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED;
- camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary));
- gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid);
- } else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "No such message %s in %s.", uid,
- folder->name);
- }
+ g_return_if_fail (info != NULL);
+
+ camel_flag_set (&info->user_flags, name, value);
+ info->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED;
+ camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary));
+ gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid);
}
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index 8384327cd9..b1d0a919d5 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -70,7 +70,7 @@ nntp_folder_init (CamelFolder *folder, CamelStore *parent_store,
parent_class->init (folder, parent_store, parent_folder,
name, separator, path_begins_with_sep,
ex);
- if (camel_exception_get_id (ex)) return;
+ if (camel_exception_is_set (ex)) return;
/* set flags */
@@ -130,9 +130,8 @@ nntp_folder_sync (CamelFolder *folder, gboolean expunge,
camel_folder_summary_save (CAMEL_NNTP_FOLDER(folder)->summary);
- store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder, ex));
- if (!camel_exception_is_set (ex))
- camel_nntp_newsrc_write (store->newsrc);
+ store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder));
+ camel_nntp_newsrc_write (store->newsrc);
}
static const gchar *
@@ -160,7 +159,7 @@ nntp_folder_get_subfolder (CamelFolder *folder,
}
static gint
-nntp_folder_get_message_count (CamelFolder *folder, CamelException *ex)
+nntp_folder_get_message_count (CamelFolder *folder)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER(folder);
@@ -171,7 +170,7 @@ nntp_folder_get_message_count (CamelFolder *folder, CamelException *ex)
}
static guint32
-nntp_folder_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex)
+nntp_folder_get_message_flags (CamelFolder *folder, const char *uid)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
CamelMessageInfo *info = camel_folder_summary_uid (nntp_folder->summary, uid);
@@ -181,7 +180,7 @@ nntp_folder_get_message_flags (CamelFolder *folder, const char *uid, CamelExcept
static void
nntp_folder_set_message_flags (CamelFolder *folder, const char *uid,
- guint32 flags, guint32 set, CamelException *ex)
+ guint32 flags, guint32 set)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
CamelMessageInfo *info = camel_folder_summary_uid (nntp_folder->summary, uid);
@@ -191,16 +190,14 @@ nntp_folder_set_message_flags (CamelFolder *folder, const char *uid,
if (set & CAMEL_MESSAGE_SEEN) {
CamelNNTPStore *store;
int article_num;
- CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder, ex));
+ CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder));
- if (!camel_exception_is_set (ex)) {
- sscanf (uid, "%d", &article_num);
+ sscanf (uid, "%d", &article_num);
- camel_nntp_newsrc_mark_article_read (nntp_store->newsrc,
- nntp_folder->group_name,
- article_num);
- }
- }
+ camel_nntp_newsrc_mark_article_read (nntp_store->newsrc,
+ nntp_folder->group_name,
+ article_num);
+ }
camel_folder_summary_touch (nntp_folder->summary);
}
@@ -220,10 +217,7 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *
char *message_id;
/* get the parent store */
- parent_store = camel_folder_get_parent_store (folder, ex);
- if (camel_exception_get_id (ex)) {
- return NULL;
- }
+ parent_store = camel_folder_get_parent_store (folder);
message_id = strchr (uid, ',') + 1;
status = camel_nntp_command (CAMEL_NNTP_STORE( parent_store ), NULL, "ARTICLE %s", message_id);
@@ -297,17 +291,8 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *
return message;
}
-static void
-nntp_folder_delete_message (CamelFolder *folder,
- const gchar *uid,
- CamelException *ex)
-{
- g_assert (0);
-}
-
static GPtrArray *
-nntp_folder_get_uids (CamelFolder *folder,
- CamelException *ex)
+nntp_folder_get_uids (CamelFolder *folder)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
GPtrArray *out;
@@ -327,8 +312,7 @@ nntp_folder_get_uids (CamelFolder *folder,
}
static GPtrArray *
-nntp_folder_get_summary (CamelFolder *folder,
- CamelException *ex)
+nntp_folder_get_summary (CamelFolder *folder)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
@@ -336,10 +320,10 @@ nntp_folder_get_summary (CamelFolder *folder,
}
static GPtrArray *
-nntp_folder_get_subfolder_names (CamelFolder *folder, CamelException *ex)
+nntp_folder_get_subfolder_names (CamelFolder *folder)
{
if (!strcmp (folder->name, "/")) {
- CamelStore *store = camel_folder_get_parent_store (folder, ex);
+ CamelStore *store = camel_folder_get_parent_store (folder);
GPtrArray *array = camel_nntp_newsrc_get_subscribed_group_names (CAMEL_NNTP_STORE (store)->newsrc);
return array;
}
@@ -352,10 +336,8 @@ static void
nntp_folder_free_subfolder_names (CamelFolder *folder, GPtrArray *subfolders)
{
if (subfolders) {
- CamelException *ex = camel_exception_new ();
- CamelStore *store = camel_folder_get_parent_store (folder, ex);
+ CamelStore *store = camel_folder_get_parent_store (folder);
camel_nntp_newsrc_free_group_names (CAMEL_NNTP_STORE (store)->newsrc, subfolders);
- camel_exception_free (ex);
}
}
@@ -404,7 +386,6 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class)
camel_folder_class->set_message_flags = nntp_folder_set_message_flags;
camel_folder_class->get_message_flags = nntp_folder_get_message_flags;
camel_folder_class->get_message = nntp_folder_get_message;
- camel_folder_class->delete_message = nntp_folder_delete_message;
camel_folder_class->get_uids = nntp_folder_get_uids;
camel_folder_class->free_uids = camel_folder_free_deep;
camel_folder_class->get_summary = nntp_folder_get_summary;
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 713cb646d5..415ec4cd71 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -41,14 +41,15 @@ static void pop3_finalize (GtkObject *object);
static void pop3_sync (CamelFolder *folder, gboolean expunge,
CamelException *ex);
-static gint pop3_get_message_count (CamelFolder *folder, CamelException *ex);
-static GPtrArray *pop3_get_uids (CamelFolder *folder, CamelException *ex);
+static gint pop3_get_message_count (CamelFolder *folder);
+static GPtrArray *pop3_get_uids (CamelFolder *folder);
static CamelMimeMessage *pop3_get_message (CamelFolder *folder,
const char *uid,
CamelException *ex);
-static void pop3_delete_message (CamelFolder *folder, const char *uid,
- CamelException *ex);
+static void pop3_set_message_flags (CamelFolder *folder, const char *uid,
+ guint32 flags, guint32 set);
+static GPtrArray *parse_listing (int count, char *data);
static void
camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class)
@@ -68,7 +69,7 @@ camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class)
camel_folder_class->free_uids = camel_folder_free_nop;
camel_folder_class->get_message = pop3_get_message;
- camel_folder_class->delete_message = pop3_delete_message;
+ camel_folder_class->set_message_flags = pop3_set_message_flags;
object_class->finalize = pop3_finalize;
}
@@ -76,15 +77,12 @@ camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class)
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;
folder->has_summary_capability = FALSE;
folder->has_search_capability = FALSE;
-
- pop3_folder->uids = NULL;
}
GtkType
@@ -116,27 +114,105 @@ pop3_finalize (GtkObject *object)
{
CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (object);
- g_ptr_array_free (pop3_folder->uids, TRUE);
+ camel_folder_free_deep (NULL, pop3_folder->uids);
+ g_free (pop3_folder->flags);
}
CamelFolder *
camel_pop3_folder_new (CamelStore *parent, CamelException *ex)
{
- CamelFolder *folder =
- CAMEL_FOLDER (gtk_object_new (camel_pop3_folder_get_type (),
- NULL));
+ CamelPop3Store *pop3_store = CAMEL_POP3_STORE (parent);
+ CamelPop3Folder *pop3_folder;
+ GPtrArray *uids;
+ int status, count;
+ char *data;
+
+ status = camel_pop3_command (pop3_store, &data, "STAT");
+ if (status != CAMEL_POP3_OK) {
+ CamelService *service = CAMEL_SERVICE (parent);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ "Could not get message count from POP "
+ "server %s: %s.", service->url->host,
+ data ? data : "Unknown error");
+ g_free (data);
+ return NULL;
+ }
+
+ count = atoi (data);
+ g_free (data);
+
+ if (pop3_store->supports_uidl != FALSE) {
+ status = camel_pop3_command (pop3_store, NULL, "UIDL");
+ if (status != CAMEL_POP3_OK)
+ pop3_store->supports_uidl = FALSE;
+ }
- CF_CLASS (folder)->init (folder, parent, NULL, "inbox", "/", TRUE, ex);
- return folder;
+ if (pop3_store->supports_uidl == FALSE) {
+ int i;
+
+ uids = g_ptr_array_new ();
+ g_ptr_array_set_size (uids, count);
+
+ for (i = 0; i < count; i++)
+ uids->pdata[i] = g_strdup_printf ("%d", i + 1);
+ } else {
+ data = camel_pop3_command_get_additional_data (pop3_store, ex);
+ if (camel_exception_is_set (ex))
+ return NULL;
+
+ uids = parse_listing (count, data);
+ g_free (data);
+
+ if (!uids) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ "Could not open folder: message "
+ "listing was incomplete.");
+ return NULL;
+ }
+ }
+
+ pop3_folder = gtk_type_new (CAMEL_POP3_FOLDER_TYPE);
+ CF_CLASS (pop3_folder)->init ((CamelFolder *)pop3_folder, parent,
+ NULL, "inbox", "/", TRUE, ex);
+ pop3_folder->uids = uids;
+ pop3_folder->flags = g_new0 (guint32, uids->len);
+
+ return (CamelFolder *)pop3_folder;
}
static void
pop3_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
{
- if (expunge)
- camel_pop3_store_expunge (CAMEL_POP3_STORE (folder->parent_store), ex);
+ CamelPop3Folder *pop3_folder;
+ CamelPop3Store *pop3_store;
+ int i, status;
+ char *resp;
+
+ if (!expunge)
+ return;
+
+ pop3_folder = CAMEL_POP3_FOLDER (folder);
+ pop3_store = CAMEL_POP3_STORE (folder->parent_store);
+
+ for (i = 0; i < pop3_folder->uids->len; i++) {
+ if (pop3_folder->flags[i] & CAMEL_MESSAGE_DELETED) {
+ status = camel_pop3_command (pop3_store, &resp,
+ "DELE %d", i);
+ if (status != CAMEL_POP3_OK) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ "Unable to sync folder"
+ "%s%s", resp ? ": " : "",
+ resp ? resp : "");
+ g_free (resp);
+ return;
+ }
+ }
+ }
+
+ camel_pop3_store_expunge (pop3_store, ex);
}
+
static GPtrArray *
parse_listing (int count, char *data)
{
@@ -169,14 +245,10 @@ parse_listing (int count, char *data)
}
static int
-uid_to_number (CamelFolder *folder, const char *uid, CamelException *ex)
+uid_to_number (CamelPop3Folder *pop3_folder, const char *uid)
{
- CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder);
int i;
- if (!pop3_get_uids (folder, ex))
- return -1;
-
for (i = 0; i < pop3_folder->uids->len; i++) {
if (!strcmp (uid, pop3_folder->uids->pdata[i]))
return i + 1;
@@ -194,9 +266,12 @@ pop3_get_message (CamelFolder *folder, const char *uid, CamelException *ex)
CamelStream *msgstream;
CamelMimeMessage *msg;
- num = uid_to_number (folder, uid, ex);
- if (num == -1)
+ num = uid_to_number (CAMEL_POP3_FOLDER (folder), uid);
+ if (num == -1) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ "No message with uid %s", uid);
return NULL;
+ }
status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store),
&result, "RETR %d", num);
@@ -226,7 +301,8 @@ pop3_get_message (CamelFolder *folder, const char *uid, CamelException *ex)
g_free (body);
msg = camel_mime_message_new ();
- camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), CAMEL_STREAM (msgstream));
+ camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg),
+ CAMEL_STREAM (msgstream));
gtk_object_unref (GTK_OBJECT (msgstream));
@@ -234,95 +310,32 @@ pop3_get_message (CamelFolder *folder, const char *uid, CamelException *ex)
}
static void
-pop3_delete_message (CamelFolder *folder, const char *uid,
- CamelException *ex)
+pop3_set_message_flags (CamelFolder *folder, const char *uid,
+ guint32 flags, guint32 set)
{
- int status, num;
- char *resp;
+ CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder);
+ int num;
- num = uid_to_number (folder, uid, ex);
+ num = uid_to_number (pop3_folder, uid);
if (num == -1)
return;
- status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store),
- &resp, "DELE %d", num);
- if (status != CAMEL_POP3_OK) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "Unable to delete message %s%s%s",
- uid, resp ? ": " : "",
- resp ? resp : "");
- }
- g_free (resp);
+ pop3_folder->flags[num] =
+ (pop3_folder->flags[num] & ~flags) | (set & flags);
}
static gint
-pop3_get_message_count (CamelFolder *folder, CamelException *ex)
+pop3_get_message_count (CamelFolder *folder)
{
CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder);
- if (!pop3_get_uids (folder, ex))
- return -1;
-
return pop3_folder->uids->len;
}
static GPtrArray *
-pop3_get_uids (CamelFolder *folder, CamelException *ex)
+pop3_get_uids (CamelFolder *folder)
{
- CamelPop3Store *pop3_store = CAMEL_POP3_STORE (folder->parent_store);
CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder);
- int count, status;
- char *data;
-
- if (pop3_folder->uids)
- return pop3_folder->uids;
-
- status = camel_pop3_command (pop3_store, &data, "STAT");
- if (status != CAMEL_POP3_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not get message count from POP "
- "server %s: %s.", service->url->host,
- data ? data : "Unknown error");
- g_free (data);
- return NULL;
- }
-
- count = atoi (data);
- g_free (data);
-
- if (pop3_store->supports_uidl != FALSE) {
- status = camel_pop3_command (pop3_store, NULL, "UIDL");
- if (status != CAMEL_POP3_OK)
- pop3_store->supports_uidl = FALSE;
- }
-
- if (pop3_store->supports_uidl == FALSE) {
- int i;
-
- pop3_folder->uids = g_ptr_array_new ();
- g_ptr_array_set_size (pop3_folder->uids, count);
-
- for (i = 0; i < count; i++) {
- pop3_folder->uids->pdata[i] =
- g_strdup_printf ("%d", i + 1);
- }
-
- return pop3_folder->uids;
- }
-
- data = camel_pop3_command_get_additional_data (pop3_store, ex);
- if (camel_exception_is_set (ex))
- return NULL;
-
- pop3_folder->uids = parse_listing (count, data);
- g_free (data);
-
- if (!pop3_folder->uids) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "UID listing from server was "
- "incomplete.");
- }
return pop3_folder->uids;
}
diff --git a/camel/providers/pop3/camel-pop3-folder.h b/camel/providers/pop3/camel-pop3-folder.h
index 874c7a3a04..89c16c4c89 100644
--- a/camel/providers/pop3/camel-pop3-folder.h
+++ b/camel/providers/pop3/camel-pop3-folder.h
@@ -46,6 +46,7 @@ typedef struct {
CamelFolder parent_object;
GPtrArray *uids;
+ guint32 *flags;
} CamelPop3Folder;
diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c
index 54417bac64..8c9109db91 100644
--- a/camel/providers/vee/camel-vee-folder.c
+++ b/camel/providers/vee/camel-vee-folder.c
@@ -45,20 +45,20 @@ static void vee_init (CamelFolder *folder, CamelStore *parent_store,
CamelException *ex);
static void vee_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
-static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex);
-GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex);
+static GPtrArray *vee_get_uids (CamelFolder *folder);
+GPtrArray *vee_get_summary (CamelFolder *folder);
-static gint vee_get_message_count (CamelFolder *folder, CamelException *ex);
-static gint vee_get_unread_message_count (CamelFolder *folder, CamelException *ex);
+static gint vee_get_message_count (CamelFolder *folder);
+static gint vee_get_unread_message_count (CamelFolder *folder);
static CamelMimeMessage *vee_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
static const CamelMessageInfo *vee_get_message_info (CamelFolder *folder, const char *uid);
static GPtrArray *vee_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex);
-static guint32 vee_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex);
-static void vee_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set, CamelException *ex);
-static gboolean vee_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name, CamelException *ex);
-static void vee_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value, CamelException *ex);
+static guint32 vee_get_message_flags (CamelFolder *folder, const char *uid);
+static void vee_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set);
+static gboolean vee_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name);
+static void vee_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value);
static void camel_vee_folder_class_init (CamelVeeFolderClass *klass);
@@ -278,7 +278,7 @@ vee_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
;
}
-static gint vee_get_message_count (CamelFolder *folder, CamelException *ex)
+static gint vee_get_message_count (CamelFolder *folder)
{
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
@@ -286,7 +286,7 @@ static gint vee_get_message_count (CamelFolder *folder, CamelException *ex)
}
static gint
-vee_get_unread_message_count (CamelFolder *folder, CamelException *ex)
+vee_get_unread_message_count (CamelFolder *folder)
{
CamelVeeFolder *vee_folder = CAMEL_VEE_FOLDER (folder);
CamelMessageInfo *info;
@@ -308,18 +308,12 @@ vee_get_unread_message_count (CamelFolder *folder, CamelException *ex)
static gboolean
get_real_message (CamelFolder *folder, const char *uid,
- CamelFolder **out_folder, const char **out_uid,
- CamelException *ex)
+ CamelFolder **out_folder, const char **out_uid)
{
CamelVeeMessageInfo *mi;
mi = (CamelVeeMessageInfo *)vee_get_message_info(folder, uid);
- if (mi == NULL) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "No such message %s in %s", uid,
- folder->name);
- return FALSE;
- }
+ g_return_val_if_fail (mi != NULL, FALSE);
*out_folder = mi->folder;
*out_uid = strchr(mi->info.uid, ':')+1;
@@ -331,13 +325,17 @@ static CamelMimeMessage *vee_get_message (CamelFolder *folder, const gchar *uid,
const char *real_uid;
CamelFolder *real_folder;
- if (!get_real_message (folder, uid, &real_folder, &real_uid, ex))
+ if (!get_real_message (folder, uid, &real_folder, &real_uid)) {
+ camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ "No such message %s in %s", uid,
+ folder->name);
return NULL;
+ }
return camel_folder_get_message (real_folder, real_uid, ex);
}
-GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex)
+GPtrArray *vee_get_summary (CamelFolder *folder)
{
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
@@ -351,7 +349,7 @@ static const CamelMessageInfo *vee_get_message_info (CamelFolder *f, const char
return g_hash_table_lookup(vf->messages_uid, uid);
}
-static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex)
+static GPtrArray *vee_get_uids (CamelFolder *folder)
{
GPtrArray *result;
int i;
@@ -395,55 +393,54 @@ vee_search_by_expression(CamelFolder *folder, const char *expression, CamelExcep
}
static guint32
-vee_get_message_flags(CamelFolder *folder, const char *uid, CamelException *ex)
+vee_get_message_flags(CamelFolder *folder, const char *uid)
{
const char *real_uid;
CamelFolder *real_folder;
- if (!get_real_message (folder, uid, &real_folder, &real_uid, ex))
+ if (!get_real_message (folder, uid, &real_folder, &real_uid))
return 0;
- return camel_folder_get_message_flags(real_folder, real_uid, ex);
+ return camel_folder_get_message_flags(real_folder, real_uid);
}
static void
vee_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags,
- guint32 set, CamelException *ex)
+ guint32 set)
{
const char *real_uid;
CamelFolder *real_folder;
- if (!get_real_message (folder, uid, &real_folder, &real_uid, ex))
+ if (!get_real_message (folder, uid, &real_folder, &real_uid))
return;
- camel_folder_set_message_flags(real_folder, real_uid, flags, set, ex);
+ camel_folder_set_message_flags(real_folder, real_uid, flags, set);
}
static gboolean
vee_get_message_user_flag(CamelFolder *folder, const char *uid,
- const char *name, CamelException *ex)
+ const char *name)
{
const char *real_uid;
CamelFolder *real_folder;
- if (!get_real_message (folder, uid, &real_folder, &real_uid, ex))
+ if (!get_real_message (folder, uid, &real_folder, &real_uid))
return FALSE;
- return camel_folder_get_message_user_flag(real_folder, real_uid, name, ex);
+ return camel_folder_get_message_user_flag(real_folder, real_uid, name);
}
static void
vee_set_message_user_flag(CamelFolder *folder, const char *uid,
- const char *name, gboolean value,
- CamelException *ex)
+ const char *name, gboolean value)
{
const char *real_uid;
CamelFolder *real_folder;
- if (!get_real_message (folder, uid, &real_folder, &real_uid, ex))
+ if (!get_real_message (folder, uid, &real_folder, &real_uid))
return;
- return camel_folder_set_message_user_flag(real_folder, real_uid, name, value, ex);
+ return camel_folder_set_message_user_flag(real_folder, real_uid, name, value);
}