aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c32
-rw-r--r--camel/providers/pop3/camel-pop3-store.c22
-rw-r--r--camel/providers/sendmail/camel-sendmail-transport.c13
-rw-r--r--camel/providers/vee/camel-vee-folder.c98
-rw-r--r--camel/providers/vee/camel-vee-folder.h2
5 files changed, 125 insertions, 42 deletions
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index 707fea1206..ccf57f02b7 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -602,11 +602,11 @@ mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelExcept
if (stat(mbox_folder->folder_file_path, &st) != 0)
goto fail;
- output_stream = camel_stream_fs_new_with_name (mbox_folder->folder_file_path, O_RDWR, 0600, ex);
+ output_stream = camel_stream_fs_new_with_name (mbox_folder->folder_file_path, O_RDWR, 0600);
if (output_stream == NULL)
goto fail;
- seek = camel_seekable_stream_seek((CamelSeekableStream *)output_stream, st.st_size, SEEK_SET, ex);
+ seek = camel_seekable_stream_seek((CamelSeekableStream *)output_stream, st.st_size, SEEK_SET);
if (seek != st.st_size)
goto fail;
@@ -618,19 +618,17 @@ mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelExcept
g_free(xev);
/* we must write this to the non-filtered stream ... */
- if (camel_stream_write_string (output_stream, "From - \n", ex) == -1)
+ if (camel_stream_write_string (output_stream, "From - \n") == -1)
goto fail;
/* and write the content to the filtering stream, that translated '\nFrom' into '\n>From' */
filter_stream = (CamelStream *)camel_stream_filter_new_with_stream(output_stream);
filter_from = (CamelMimeFilter *)camel_mime_filter_from_new();
camel_stream_filter_add((CamelStreamFilter *)filter_stream, filter_from);
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), filter_stream, ex);
-#warning "we still need stream_close() for this"
- if (!camel_exception_is_set (ex))
- camel_stream_flush (filter_stream, ex);
+ if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), filter_stream) == -1)
+ goto fail;
- if (camel_exception_is_set (ex))
+ if (camel_stream_close (filter_stream) == -1)
goto fail;
/* filter stream ref's the output stream itself, so we need to unref it too */
@@ -659,6 +657,9 @@ fail:
if (output_stream)
gtk_object_unref ((GtkObject *)output_stream);
+ if (filter_from)
+ gtk_object_unref ((GtkObject *)filter_from);
+
/* make sure the file isn't munged by us */
if (seek != -1) {
int fd = open(mbox_folder->folder_file_path, O_WRONLY, 0600);
@@ -760,7 +761,7 @@ mbox_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *
g_assert(info->frompos != -1);
/* where we read from */
- message_stream = camel_stream_fs_new_with_name (mbox_folder->folder_file_path, O_RDONLY, 0, ex);
+ message_stream = camel_stream_fs_new_with_name (mbox_folder->folder_file_path, O_RDONLY, 0);
if (message_stream == NULL)
goto fail;
@@ -800,15 +801,10 @@ mbox_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *
return message;
fail:
- if (camel_exception_is_set (ex)) {
- camel_exception_setv (ex, camel_exception_get_id (ex),
- "Cannot get message: %s",
- camel_exception_get_description (ex));
- } else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "Cannot get message: %s",
- g_strerror(errno));
- }
+ camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ "Cannot get message: %s",
+ g_strerror(errno));
+
if (parser)
gtk_object_unref((GtkObject *)parser);
if (message)
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index ddddf9f59f..bc39d4ab2b 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -33,6 +33,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include "camel-pop3-store.h"
#include "camel-pop3-folder.h"
@@ -376,7 +377,7 @@ pop3_connect (CamelService *service, CamelException *ex)
CAMEL_STREAM_BUFFER_READ);
/* Read the greeting, note APOP timestamp, if any. */
- buf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream), ex);
+ buf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream));
if (!buf) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
"Could not read greeting from POP "
@@ -513,28 +514,25 @@ camel_pop3_command (CamelPop3Store *store, char **ret, char *fmt, ...)
char *cmdbuf, *respbuf;
va_list ap;
int status;
- CamelException *ex = camel_exception_new ();
va_start (ap, fmt);
cmdbuf = g_strdup_vprintf (fmt, ap);
va_end (ap);
/* Send the command */
- camel_stream_printf (store->ostream, ex, "%s\r\n", cmdbuf);
- g_free (cmdbuf);
- if (camel_exception_is_set (ex)) {
+ if (camel_stream_printf (store->ostream, "%s\r\n", cmdbuf) == -1) {
+ g_free (cmdbuf);
if (*ret)
- *ret = g_strdup (camel_exception_get_description (ex));
- camel_exception_free (ex);
+ *ret = g_strdup(strerror(errno));
return CAMEL_POP3_FAIL;
}
+ g_free (cmdbuf);
/* Read the response */
- respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream), ex);
- if (camel_exception_is_set (ex)) {
+ respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream));
+ if (respbuf == NULL) {
if (*ret)
- *ret = g_strdup (camel_exception_get_description (ex));
- camel_exception_free (ex);
+ *ret = g_strdup(strerror(errno));
return CAMEL_POP3_FAIL;
}
if (!strncmp (respbuf, "+OK", 3))
@@ -582,7 +580,7 @@ camel_pop3_command_get_additional_data (CamelPop3Store *store,
data = g_ptr_array_new ();
while (1) {
- buf = camel_stream_buffer_read_line (stream, ex);
+ buf = camel_stream_buffer_read_line (stream);
if (!buf) {
status = CAMEL_POP3_FAIL;
break;
diff --git a/camel/providers/sendmail/camel-sendmail-transport.c b/camel/providers/sendmail/camel-sendmail-transport.c
index a5eeff1a25..3b84d5cb90 100644
--- a/camel/providers/sendmail/camel-sendmail-transport.c
+++ b/camel/providers/sendmail/camel-sendmail-transport.c
@@ -31,6 +31,7 @@
#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>
+#include <string.h>
#include "camel-sendmail-transport.h"
#include "camel-mime-message.h"
@@ -139,15 +140,15 @@ _send_internal (CamelMedium *message, char **argv, CamelException *ex)
/* Parent process. Write the message out. */
close (fd[0]);
out = camel_stream_fs_new_with_fd (fd[1]);
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message),
- out, ex);
- gtk_object_unref (GTK_OBJECT (out));
- if (camel_exception_is_set (ex)) {
- camel_exception_setv (ex, camel_exception_get_id (ex),
+ if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), out) == -1
+ || camel_stream_close(out) == -1) {
+ gtk_object_unref (GTK_OBJECT (out));
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
"Could not send message: %s",
- camel_exception_get_description (ex));
+ strerror(errno));
return FALSE;
}
+ gtk_object_unref (GTK_OBJECT (out));
/* Wait for sendmail to exit. */
while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR)
diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c
index 88e48134a3..3d4050cf19 100644
--- a/camel/providers/vee/camel-vee-folder.c
+++ b/camel/providers/vee/camel-vee-folder.c
@@ -53,7 +53,10 @@ 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);
+static void vee_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
+
static const CamelMessageInfo *vee_summary_get_by_uid(CamelFolder *f, const char *uid);
+static GList *vee_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex);
static void camel_vee_folder_class_init (CamelVeeFolderClass *klass);
@@ -111,10 +114,12 @@ camel_vee_folder_class_init (CamelVeeFolderClass *klass)
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->append_message = vee_append_message;
folder_class->summary_get_by_uid = vee_summary_get_by_uid;
folder_class->get_message_count = vee_get_message_count;
+ folder_class->search_by_expression = vee_search_by_expression;
object_class->finalize = camel_vee_folder_finalise;
@@ -134,6 +139,17 @@ camel_vee_folder_init (CamelVeeFolder *obj)
static void
camel_vee_folder_finalise (GtkObject *obj)
{
+ CamelVeeFolder *vf = (CamelVeeFolder *)obj;
+ struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+ GList *node;
+
+ node = p->folders;
+ while (node) {
+ CamelFolder *f = node->data;
+ gtk_object_unref((GtkObject *)f);
+ node = g_list_next(node);
+ }
+
((GtkObjectClass *)(camel_vee_folder_parent))->finalize((GtkObject *)obj);
}
@@ -152,11 +168,31 @@ camel_vee_folder_new (void)
}
+void
+camel_vee_folder_add_folder(CamelVeeFolder *vf, CamelFolder *sub)
+{
+ struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+
+ gtk_object_ref((GtkObject *)sub);
+ p->folders = g_list_append(p->folders, sub);
+}
+
+
static void vee_init (CamelFolder *folder, CamelStore *parent_store,
CamelFolder *parent_folder, const gchar *name,
gchar separator, 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, ex);
if (camel_exception_get_id (ex))
@@ -177,7 +213,13 @@ static void vee_init (CamelFolder *folder, CamelStore *parent_store,
vf->messages = g_ptr_array_new();
vf->messages_uid = g_hash_table_new(g_str_hash, g_str_equal);
- vf->expression = g_strdup(folder->name);
+ vf->expression = g_strdup_printf("(or\n (match-all (user-flag \"%s\"))\n %s\n)", namepart, searchpart);
+ vf->vname = g_strdup(namepart);
+
+ printf("VFolder expression is %s\n", vf->expression);
+ printf("VFolder full name = %s\n", camel_folder_get_full_name(folder));
+
+ g_free(namepart);
}
static void vee_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex)
@@ -205,6 +247,19 @@ static gboolean vee_exists (CamelFolder *folder, CamelException *ex)
return TRUE;
}
+static void vee_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex)
+{
+ CamelVeeFolder *vf = (CamelVeeFolder *)folder;
+
+ if (message->folder && message->folder->permanent_flags & CAMEL_MESSAGE_USER) {
+ /* set the flag on the message ... */
+ camel_mime_message_set_user_flag(message, vf->vname, TRUE);
+ } else {
+ /* FIXME: error code */
+ camel_exception_setv(ex, 1, "Cannot append this message to virtual folder");
+ }
+}
+
static gint vee_get_message_count (CamelFolder *folder, CamelException *ex)
{
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
@@ -259,13 +314,30 @@ static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex)
return result;
}
-void
-camel_vee_folder_add_folder(CamelVeeFolder *vf, CamelFolder *sub)
+static GList *
+vee_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex)
{
+ GList *result = NULL, *node;
+ char *expr;
+ CamelVeeFolder *vf = (CamelVeeFolder *)folder;
struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
- gtk_object_ref((GtkObject *)sub);
- p->folders = g_list_append(p->folders, sub);
+ expr = g_strdup_printf("(and %s %s)", vf->expression, expression);
+ node = p->folders;
+ while (node) {
+ CamelFolder *f = node->data;
+ GList *matches, *match;
+ matches = camel_folder_search_by_expression(f, vf->expression, ex);
+ match = matches;
+ while (match) {
+ char *uid = match->data;
+ result = g_list_prepend(result, g_strdup_printf("%p:%s", f, uid));
+ match = g_list_next(match);
+ }
+ g_list_free(matches);
+ node = g_list_next(node);
+ }
+ return result;
}
/*
@@ -283,6 +355,19 @@ vee_folder_build(CamelVeeFolder *vf, CamelException *ex)
GPtrArray *messages;
GHashTable *messages_uid;
+ {
+ int i;
+
+ for (i=0;i<vf->messages->len;i++) {
+ CamelVeeMessageInfo *mi = g_ptr_array_index(vf->messages, i);
+ g_free(mi->info.subject);
+ g_free(mi->info.to);
+ g_free(mi->info.from);
+ g_free(mi->info.uid);
+ camel_flag_list_free(&mi->info.user_flags);
+ }
+ }
+
messages = g_ptr_array_new();
messages_uid = g_hash_table_new(g_str_hash, g_str_equal);
@@ -324,8 +409,9 @@ vee_folder_build(CamelVeeFolder *vf, CamelException *ex)
node = g_list_next(node);
}
-#warning "free messages on query update"
+ g_ptr_array_free(vf->messages, TRUE);
vf->messages = messages;
+ g_hash_table_destroy(vf->messages_uid);
vf->messages_uid = messages_uid;
}
diff --git a/camel/providers/vee/camel-vee-folder.h b/camel/providers/vee/camel-vee-folder.h
index 4d82c842ea..ea2a82a25b 100644
--- a/camel/providers/vee/camel-vee-folder.h
+++ b/camel/providers/vee/camel-vee-folder.h
@@ -38,6 +38,8 @@ struct _CamelVeeFolder {
struct _CamelVeeFolderPrivate *priv;
char *expression; /* query expression */
+ char *vname; /* local name */
+ CamelFolder *local; /* local storage for folder */
/* FIXME: Move this to a summary object??? */
GPtrArray *messages; /* message info's */