aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog63
-rw-r--r--camel/camel-folder-search.c39
-rw-r--r--camel/camel-folder-search.h4
-rw-r--r--camel/camel-folder-summary.c102
-rw-r--r--camel/camel-folder-summary.h15
-rw-r--r--camel/camel-folder.c764
-rw-r--r--camel/camel-folder.h10
-rw-r--r--camel/camel-mime-parser.c4
-rw-r--r--camel/providers/imap/camel-imap-folder.c14
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c481
-rw-r--r--camel/providers/mbox/camel-mbox-store.c2
-rw-r--r--camel/providers/mbox/camel-mbox-summary.c676
-rw-r--r--camel/providers/mbox/camel-mbox-summary.h2
-rw-r--r--camel/providers/mh/camel-mh-folder.c29
-rw-r--r--camel/providers/mh/camel-mh-store.c2
-rw-r--r--camel/providers/vee/camel-vee-folder.c4
16 files changed, 1170 insertions, 1041 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 352f194126..7152df91ba 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,66 @@
+2000-08-11 Not Zed <NotZed@HelixCode.com>
+
+ * camel-mime-parser.c (folder_scan_header): A better way to
+ compress leading whitespace. The code is probably invalid anyway,
+ I dont think it will work across buffer boundaries.
+
+ * providers/mbox/camel-mbox-folder.c (mbox_append_message): And
+ write out proper format From lines here too.
+
+ * providers/mbox/camel-mbox-summary.c
+ (camel_mbox_summary_build_from): New function to build a more
+ compatible mbox "From " line.
+ (camel_mbox_summary_sync): Write From lines in the proper format.
+
+2000-08-10 Not Zed <NotZed@HelixCode.com>
+
+ * providers/mh/camel-mh-store.c (get_folder): Remove warnin g.
+
+ * providers/mbox/camel-mbox-store.c (xrename): Kill some warnings
+ with constification.
+
+ * providers/imap/camel-imap-folder.c (imap_append_message): Fixed
+ for append api change. Eek this routine seriously wastes memory.
+
+ * providers/mh/camel-mh-folder.c (mh_search_free): Impelemnt.
+ (mh_append_message): Fix for api change, and include user flags
+ and tags in new message.
+
+ * providers/vee/camel-vee-folder.c (vee_search_by_expression): Fix
+ for search api change.
+
+ * camel-folder.c (camel_folder_search_free): New function for
+ freeing search results.
+ (search_free): Changed my mind, implement a default that actually
+ does something. Free as to the old interface.
+ (camel_folder_append_message): Changed to accept a
+ camelmessageinfo rather than flags, which just doesn't have enough
+ info in it.
+ (copy_message_to): Change for append_message api change.
+ (move_message_to): Likewise.
+
+ * providers/mbox/camel-mbox-folder.c (mbox_search_free):
+ Implement.
+ (mbox_append_message): Fix for api change, and also copy user
+ flags/tags across to new summary.
+
+ * camel-folder-search.c (search_user_tag): A search expression
+ that returns the current use flag by name.
+ (camel_folder_search_free_result): New function to free the result
+ of a search.
+
+ * camel-folder-summary.c: Bump summary version.
+ (message_info_new):
+ (message_info_load):
+ (message_info_save):
+ (camel_message_info_dup_to):
+ (camel_message_info_free): Added support for arbitrary tag/value
+ pairs (CamelTag's).
+ (camel_tag_get):
+ (camel_tag_set):
+ (camel_tag_list_size):
+ (camel_tag_list_free): Operations for working with CamelTags.
+
2000-08-09 Ettore Perazzoli <ettore@helixcode.com>
* providers/nntp/camel-nntp-folder.c
diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c
index 44eb03faad..5c6fa111bb 100644
--- a/camel/camel-folder-search.c
+++ b/camel/camel-folder-search.c
@@ -42,6 +42,7 @@ static ESExpResult *search_header_contains(struct _ESExp *f, int argc, struct _E
static ESExpResult *search_match_all(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFolderSearch *search);
static ESExpResult *search_body_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search);
static ESExpResult *search_user_flag(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
+static ESExpResult *search_user_tag(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
static ESExpResult *search_dummy(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search);
@@ -92,6 +93,7 @@ camel_folder_search_class_init (CamelFolderSearchClass *klass)
klass->body_contains = search_body_contains;
klass->header_contains = search_header_contains;
klass->user_flag = search_user_flag;
+ klass->user_flag = search_user_tag;
gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
}
@@ -137,6 +139,7 @@ struct {
{ "body-contains", GTK_STRUCT_OFFSET(CamelFolderSearchClass, body_contains), 1 },
{ "header-contains", GTK_STRUCT_OFFSET(CamelFolderSearchClass, header_contains), 1 },
{ "user-flag", GTK_STRUCT_OFFSET(CamelFolderSearchClass, user_flag), 1 },
+ { "user-tag", GTK_STRUCT_OFFSET(CamelFolderSearchClass, user_flag), 1 },
};
void
@@ -246,9 +249,8 @@ camel_folder_search_set_body_index(CamelFolderSearch *search, ibex *index)
* TODO: The interface should probably return summary items instead
* (since they are much more useful to any client).
*
- * Return value: A GPtrArray of strings of all matching messages. Once
- * finished with this, the array AND CONTENTS should be free'd
- * by the caller.
+ * Return value: A GPtrArray of strings of all matching messages.
+ * This must only be freed by camel_folder_search_free_result.
**/
GPtrArray *
camel_folder_search_execute_expression(CamelFolderSearch *search, const char *expr, CamelException *ex)
@@ -305,6 +307,15 @@ camel_folder_search_execute_expression(CamelFolderSearch *search, const char *ex
return matches;
}
+void camel_folder_search_free_result(CamelFolderSearch *search, 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);
+}
+
/* dummy function, returns false always, or an empty match array */
static ESExpResult *
search_dummy(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search)
@@ -513,3 +524,25 @@ static ESExpResult *search_user_flag(struct _ESExp *f, int argc, struct _ESExpRe
return r;
}
+
+static ESExpResult *search_user_tag(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search)
+{
+ ESExpResult *r;
+
+ r(printf("executing user-tag\n"));
+
+ /* are we inside a match-all? */
+ if (search->current) {
+ const char *value = NULL;
+ if (argc == 1) {
+ value = camel_tag_get(&search->current->user_tags, argv[0]->value.string);
+ }
+ r = e_sexp_result_new(ESEXP_RES_STRING);
+ r->value.string = g_strdup(value?value:"");
+ } else {
+ r = e_sexp_result_new(ESEXP_RES_ARRAY_PTR);
+ r->value.ptrarray = g_ptr_array_new();
+ }
+
+ return r;
+}
diff --git a/camel/camel-folder-search.h b/camel/camel-folder-search.h
index eb06af946c..61c8d52a07 100644
--- a/camel/camel-folder-search.h
+++ b/camel/camel-folder-search.h
@@ -72,6 +72,9 @@ struct _CamelFolderSearchClass {
/* (user-flag "flagname" "flagname" ...) If one of user-flag set */
ESExpResult * (*user_flag)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
+
+ /* (user-tag "flagname") Returns the value of a user tag. Can only be used in match-all */
+ ESExpResult * (*user_tag)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
};
guint camel_folder_search_get_type (void);
@@ -82,5 +85,6 @@ void camel_folder_search_set_folder(CamelFolderSearch *search, CamelFolder *fold
void camel_folder_search_set_summary(CamelFolderSearch *search, GPtrArray *summary);
void camel_folder_search_set_body_index(CamelFolderSearch *search, ibex *index);
GPtrArray *camel_folder_search_execute_expression(CamelFolderSearch *search, const char *expr, CamelException *ex);
+void camel_folder_search_free_result(CamelFolderSearch *search, GPtrArray *);
#endif /* ! _CAMEL_FOLDER_SEARCH_H */
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 6a16859f4f..a47d98a46a 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -48,7 +48,7 @@
extern int strdup_count, malloc_count, free_count;
#endif
-#define CAMEL_FOLDER_SUMMARY_VERSION (6)
+#define CAMEL_FOLDER_SUMMARY_VERSION (7)
struct _CamelFolderSummaryPrivate {
GHashTable *filter_charset; /* CamelMimeFilterCharset's indexed by source charset */
@@ -951,6 +951,7 @@ message_info_new(CamelFolderSummary *s, struct _header_raw *h)
mi->to = camel_summary_format_address(h, "to");
mi->cc = camel_summary_format_address(h, "cc");
mi->user_flags = NULL;
+ mi->user_tags = NULL;
mi->date_sent = header_decode_date(header_raw_find(&h, "date", NULL), NULL);
received = header_raw_find(&h, "received", NULL);
if (received)
@@ -1012,6 +1013,16 @@ message_info_load(CamelFolderSummary *s, FILE *in)
g_free(name);
}
+ camel_folder_summary_decode_uint32(in, &count);
+ for (i=0;i<count;i++) {
+ char *name, *value;
+ camel_folder_summary_decode_string(in, &name);
+ camel_folder_summary_decode_string(in, &value);
+ camel_tag_set(&mi->user_tags, name, value);
+ g_free(name);
+ g_free(value);
+ }
+
return mi;
}
@@ -1020,6 +1031,7 @@ message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi)
{
guint32 count;
CamelFlag *flag;
+ CamelTag *tag;
struct _header_references *refs;
io(printf("Saving message info\n"));
@@ -1051,6 +1063,16 @@ message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi)
camel_folder_summary_encode_string(out, flag->name);
flag = flag->next;
}
+
+ count = camel_tag_list_size(&mi->user_tags);
+ camel_folder_summary_encode_uint32(out, count);
+ tag = mi->user_tags;
+ while (tag) {
+ camel_folder_summary_encode_string(out, tag->name);
+ camel_folder_summary_encode_string(out, tag->value);
+ tag = tag->next;
+ }
+
return ferror(out);
}
@@ -1356,6 +1378,76 @@ camel_flag_list_free(CamelFlag **list)
*list = NULL;
}
+const char *camel_tag_get(CamelTag **list, const char *name)
+{
+ CamelTag *tag;
+
+ tag = *list;
+ while (tag) {
+ if (!strcmp(tag->name, name))
+ return (const char *)tag->value;
+ tag = tag->next;
+ }
+ return NULL;
+}
+
+void camel_tag_set(CamelTag **list, const char *name, const char *value)
+{
+ CamelTag *tag, *tmp;
+
+ /* this 'trick' works because tag->next is the first element */
+ tag = (CamelTag *)list;
+ while (tag->next) {
+ tmp = tag->next;
+ if (!strcmp(tmp->name, name)) {
+ if (value == NULL) { /* clear it? */
+ tag->next = tmp->next;
+ g_free(tmp->value);
+ g_free(tmp);
+ } else if (strcmp(tmp->value, value)) { /* has it changed? */
+ g_free(tmp->value);
+ tmp->value = g_strdup(value);
+ }
+ return;
+ }
+ tag = tmp;
+ }
+
+ if (value) {
+ tmp = g_malloc(sizeof(*tmp)+strlen(name));
+ strcpy(tmp->name, name);
+ tmp->value = g_strdup(value);
+ tmp->next = 0;
+ tag->next = tmp;
+ }
+}
+
+int camel_tag_list_size(CamelTag **list)
+{
+ int count=0;
+ CamelTag *tag;
+
+ tag = *list;
+ while (tag) {
+ count++;
+ tag = tag->next;
+ }
+ return count;
+}
+
+void camel_tag_list_free(CamelTag **list)
+{
+ CamelTag *tag, *tmp;
+ tag = *list;
+ while (tag) {
+ tmp = tag->next;
+ g_free(tag->value);
+ g_free(tag);
+ tag = tmp;
+ }
+ *list = NULL;
+}
+
/**
* camel_message_info_dup_to:
* @from: source message info
@@ -1370,6 +1462,7 @@ void
camel_message_info_dup_to(const CamelMessageInfo *from, CamelMessageInfo *to)
{
CamelFlag *flag;
+ CamelTag *tag;
/* Copy numbers */
to->flags = from->flags;
@@ -1393,6 +1486,12 @@ camel_message_info_dup_to(const CamelMessageInfo *from, CamelMessageInfo *to)
flag = flag->next;
}
+ tag = from->user_tags;
+ while (tag) {
+ camel_tag_set(&to->user_tags, tag->name, tag->value);
+ tag = tag->next;
+ }
+
/* FIXME some day */
to->content = NULL;
}
@@ -1414,6 +1513,7 @@ camel_message_info_free(CamelMessageInfo *mi)
g_free(mi->message_id);
header_references_list_clear(&mi->references);
camel_flag_list_free(&mi->user_flags);
+ camel_tag_list_free(&mi->user_tags);
/* FIXME: content info? */
g_free(mi);
}
diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h
index c173a6080b..93438fcd7a 100644
--- a/camel/camel-folder-summary.h
+++ b/camel/camel-folder-summary.h
@@ -79,9 +79,15 @@ enum _CamelMessageFlags {
typedef struct _CamelFlag {
struct _CamelFlag *next;
- char name[1];
+ char name[1]; /* name allocated as part of the structure */
} CamelFlag;
+typedef struct _CamelTag {
+ struct _CamelTag *next;
+ char *value;
+ char name[1]; /* name allocated as part of the structure */
+} CamelTag;
+
/* information about a given object */
typedef struct {
/* public fields */
@@ -102,6 +108,7 @@ typedef struct {
struct _header_references *references; /* from parent to root */
struct _CamelFlag *user_flags;
+ struct _CamelTag *user_tags;
/* tree of content description - NULL if it is not available */
CamelMessageContentInfo *content;
@@ -218,6 +225,12 @@ void camel_flag_set(CamelFlag **list, const char *name, gboolean state);
int camel_flag_list_size(CamelFlag **list);
void camel_flag_list_free(CamelFlag **list);
+/* message tag operations */
+const char *camel_tag_get(CamelTag **list, const char *name);
+void camel_tag_set(CamelTag **list, const char *name, const char *value);
+int camel_tag_list_size(CamelTag **list);
+void camel_tag_list_free(CamelTag **list);
+
/* message info utils */
void camel_message_info_dup_to(const CamelMessageInfo *from, CamelMessageInfo *to);
void camel_message_info_free(CamelMessageInfo *mi);
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 047c814e5e..dd469e78aa 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -36,7 +36,6 @@ static CamelObjectClass *parent_class = NULL;
/* Returns the class for a CamelFolder */
#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT (so)->klass)
-
enum SIGNALS {
FOLDER_CHANGED,
MESSAGE_CHANGED,
@@ -45,98 +44,66 @@ enum SIGNALS {
static guint signals[LAST_SIGNAL] = { 0 };
+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 init (CamelFolder *folder, CamelStore *parent_store,
- CamelFolder *parent_folder, const gchar *name,
- gchar *separator, gboolean path_begins_with_sep,
- CamelException *ex);
-
-static void finalize (GtkObject *object);
-
-
-static void folder_sync (CamelFolder *folder, gboolean expunge,
- CamelException *ex);
-
-static const gchar *get_name (CamelFolder *folder);
-static const gchar *get_full_name (CamelFolder *folder);
+static void finalize(GtkObject * object);
+static void folder_sync(CamelFolder * folder, gboolean expunge, CamelException * ex);
-static gboolean can_hold_folders (CamelFolder *folder);
-static gboolean can_hold_messages (CamelFolder *folder);
-static guint32 get_permanent_flags (CamelFolder *folder);
-static guint32 get_message_flags (CamelFolder *folder, const char *uid);
-static void set_message_flags (CamelFolder *folder, const char *uid,
- guint32 flags, guint32 set);
-static gboolean get_message_user_flag (CamelFolder *folder, const char *uid,
- const char *name);
-static void set_message_user_flag (CamelFolder *folder, const char *uid,
- const char *name, gboolean value);
+static const gchar *get_name(CamelFolder * folder);
+static const gchar *get_full_name(CamelFolder * folder);
+static gboolean can_hold_folders(CamelFolder * folder);
+static gboolean can_hold_messages(CamelFolder * folder);
+static guint32 get_permanent_flags(CamelFolder * folder);
+static guint32 get_message_flags(CamelFolder * folder, const char *uid);
+static void set_message_flags(CamelFolder * folder, const char *uid, guint32 flags, guint32 set);
+static gboolean get_message_user_flag(CamelFolder * folder, const char *uid, const char *name);
+static void set_message_user_flag(CamelFolder * folder, const char *uid, const char *name, gboolean value);
-static GPtrArray *get_subfolder_names (CamelFolder *folder);
-static void free_subfolder_names (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 GPtrArray *get_subfolder_names(CamelFolder * folder);
+static void free_subfolder_names(CamelFolder * folder, GPtrArray * array);
+static CamelFolder *get_subfolder(CamelFolder * folder,
-static gint get_message_count (CamelFolder *folder);
-static gint get_unread_message_count (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 void expunge (CamelFolder *folder,
- CamelException *ex);
+static gint get_message_count(CamelFolder * folder);
+static gint get_unread_message_count(CamelFolder * folder);
+static void expunge(CamelFolder * folder, CamelException * ex);
-static void append_message (CamelFolder *folder, CamelMimeMessage *message,
- guint32 flags, CamelException *ex);
+static void append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex);
+static GPtrArray *get_uids(CamelFolder * folder);
+static void free_uids(CamelFolder * folder, GPtrArray * array);
+static GPtrArray *get_summary(CamelFolder * folder);
+static void free_summary(CamelFolder * folder, GPtrArray * array);
+static CamelMimeMessage *get_message(CamelFolder * folder, const gchar * uid, CamelException * ex);
-static GPtrArray *get_uids (CamelFolder *folder);
-static void free_uids (CamelFolder *folder,
- GPtrArray *array);
-static GPtrArray *get_summary (CamelFolder *folder);
-static void free_summary (CamelFolder *folder,
- GPtrArray *array);
-static CamelMimeMessage *get_message (CamelFolder *folder,
- const gchar *uid,
- CamelException *ex);
+static const CamelMessageInfo *get_message_info(CamelFolder * folder, const char *uid);
-static const CamelMessageInfo *get_message_info (CamelFolder *folder,
- const char *uid);
+static GPtrArray *search_by_expression(CamelFolder * folder, const char *exp, CamelException * ex);
+static void search_free(CamelFolder * folder, GPtrArray * result);
-static GPtrArray *search_by_expression (CamelFolder *folder,
- const char *exp,
- CamelException *ex);
+static void copy_message_to(CamelFolder * source, const char *uid, CamelFolder * dest, CamelException * ex);
-static void copy_message_to (CamelFolder *source,
- const char *uid,
- CamelFolder *dest,
- CamelException *ex);
+static void move_message_to(CamelFolder * source, const char *uid, CamelFolder * dest, CamelException * ex);
-static void move_message_to (CamelFolder *source,
- const char *uid,
- CamelFolder *dest,
- CamelException *ex);
+static void freeze(CamelFolder * folder);
+static void thaw(CamelFolder * folder);
-static void freeze (CamelFolder *folder);
-static void thaw (CamelFolder *folder);
+static void folder_changed(CamelFolder * folder, int type);
+static void message_changed(CamelFolder * folder, const char *uid);
-static void folder_changed (CamelFolder *folder,
- int type);
-static void message_changed (CamelFolder *folder,
- const char *uid);
-
-
-static void
-camel_folder_class_init (CamelFolderClass *camel_folder_class)
+static void camel_folder_class_init(CamelFolderClass * camel_folder_class)
{
- GtkObjectClass *gtk_object_class =
- GTK_OBJECT_CLASS (camel_folder_class);
+ GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS(camel_folder_class);
- parent_class = gtk_type_class (camel_object_get_type ());
+ parent_class = gtk_type_class(camel_object_get_type());
/* virtual method definition */
camel_folder_class->init = init;
@@ -165,6 +132,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
camel_folder_class->get_summary = get_summary;
camel_folder_class->free_summary = free_summary;
camel_folder_class->search_by_expression = search_by_expression;
+ camel_folder_class->search_free = search_free;
camel_folder_class->get_message_info = get_message_info;
camel_folder_class->copy_message_to = copy_message_to;
camel_folder_class->move_message_to = move_message_to;
@@ -176,77 +144,67 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
/* virtual method overload */
gtk_object_class->finalize = finalize;
- signals[FOLDER_CHANGED] =
- gtk_signal_new ("folder_changed",
- GTK_RUN_FIRST,
- gtk_object_class->type,
- GTK_SIGNAL_OFFSET (CamelFolderClass,
- folder_changed),
- gtk_marshal_NONE__INT,
- GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+ signals[FOLDER_CHANGED] =
+ gtk_signal_new("folder_changed",
+ GTK_RUN_FIRST,
+ gtk_object_class->type,
+ GTK_SIGNAL_OFFSET(CamelFolderClass,
+ folder_changed), gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT);
- signals[MESSAGE_CHANGED] =
- gtk_signal_new ("message_changed",
- GTK_RUN_FIRST,
- gtk_object_class->type,
- GTK_SIGNAL_OFFSET (CamelFolderClass,
- message_changed),
- gtk_marshal_NONE__STRING,
- GTK_TYPE_NONE, 1, GTK_TYPE_STRING);
+ signals[MESSAGE_CHANGED] =
+ gtk_signal_new("message_changed",
+ GTK_RUN_FIRST,
+ gtk_object_class->type,
+ GTK_SIGNAL_OFFSET(CamelFolderClass,
+ message_changed),
+ gtk_marshal_NONE__STRING, GTK_TYPE_NONE, 1, GTK_TYPE_STRING);
- gtk_object_class_add_signals (gtk_object_class, signals, LAST_SIGNAL);
+ gtk_object_class_add_signals(gtk_object_class, signals, LAST_SIGNAL);
}
-
-GtkType
-camel_folder_get_type (void)
+GtkType camel_folder_get_type(void)
{
static GtkType camel_folder_type = 0;
- if (!camel_folder_type) {
- GtkTypeInfo camel_folder_info =
- {
+ if (!camel_folder_type) {
+ GtkTypeInfo camel_folder_info = {
"CamelFolder",
- sizeof (CamelFolder),
- sizeof (CamelFolderClass),
+ sizeof(CamelFolder),
+ sizeof(CamelFolderClass),
(GtkClassInitFunc) camel_folder_class_init,
(GtkObjectInitFunc) NULL,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
- camel_folder_type = gtk_type_unique (camel_object_get_type (),
- &camel_folder_info);
+ camel_folder_type = gtk_type_unique(camel_object_get_type(), &camel_folder_info);
}
return camel_folder_type;
}
-
-static void
-finalize (GtkObject *object)
+static void finalize(GtkObject * object)
{
- CamelFolder *camel_folder = CAMEL_FOLDER (object);
+ CamelFolder *camel_folder = CAMEL_FOLDER(object);
GList *m;
- g_free (camel_folder->name);
- g_free (camel_folder->full_name);
+ g_free(camel_folder->name);
+ g_free(camel_folder->full_name);
if (camel_folder->parent_store)
- gtk_object_unref (GTK_OBJECT (camel_folder->parent_store));
+ gtk_object_unref(GTK_OBJECT(camel_folder->parent_store));
if (camel_folder->parent_folder)
- gtk_object_unref (GTK_OBJECT (camel_folder->parent_folder));
+ gtk_object_unref(GTK_OBJECT(camel_folder->parent_folder));
for (m = camel_folder->messages_changed; m; m = m->next)
- g_free (m->data);
- g_list_free (camel_folder->messages_changed);
+ g_free(m->data);
+ g_list_free(camel_folder->messages_changed);
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
+ GTK_OBJECT_CLASS(parent_class)->finalize(object);
}
-
/**
* init: init the folder
* @folder: folder object to initialize
@@ -260,32 +218,31 @@ finalize (GtkObject *object)
* 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)
+init(CamelFolder * folder, CamelStore * parent_store,
+ CamelFolder * parent_folder, const gchar * name,
+ gchar * separator, gboolean path_begins_with_sep, CamelException * ex)
{
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(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);
folder->parent_store = parent_store;
- gtk_object_ref (GTK_OBJECT (parent_store));
+ gtk_object_ref(GTK_OBJECT(parent_store));
folder->parent_folder = parent_folder;
if (parent_folder)
- gtk_object_ref (GTK_OBJECT (parent_folder));
+ gtk_object_ref(GTK_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);
+ 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 */
@@ -293,19 +250,17 @@ init (CamelFolder *folder, CamelStore *parent_store,
folder->full_name = NULL;
if (folder->parent_folder) {
- parent_full_name =
- camel_folder_get_full_name (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);
+ 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);
+ full_name = g_strdup_printf("%s%s", folder->separator, name);
else
- full_name = g_strdup (name);
+ full_name = g_strdup(name);
}
- folder->name = g_strdup (name);
+ folder->name = g_strdup(name);
folder->full_name = full_name;
folder->frozen = 0;
@@ -313,12 +268,9 @@ init (CamelFolder *folder, CamelStore *parent_store,
folder->messages_changed = NULL;
}
-
-static void
-folder_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+static void folder_sync(CamelFolder * folder, gboolean expunge, CamelException * ex)
{
- g_warning ("CamelFolder::sync not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::sync not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
}
/**
@@ -330,18 +282,14 @@ 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 const gchar *
-get_name (CamelFolder *folder)
+static const gchar *get_name(CamelFolder * folder)
{
return folder->name;
}
@@ -355,17 +303,14 @@ get_name (CamelFolder *folder)
*
* Return value: name of the folder
**/
-const gchar *
-camel_folder_get_name (CamelFolder *folder)
+const gchar *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 gchar *get_full_name(CamelFolder * folder)
{
return folder->full_name;
}
@@ -378,45 +323,36 @@ get_full_name (CamelFolder *folder)
*
* Return value: full name of the folder
**/
-const gchar *
-camel_folder_get_full_name (CamelFolder *folder)
+const gchar *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)
+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);
+ g_return_val_if_fail(CAMEL_IS_STORE(folder->parent_store), NULL);
- current_folder_full_name = camel_folder_get_full_name (folder);
+ 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);
+ 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;
}
@@ -435,20 +371,16 @@ get_subfolder (CamelFolder *folder, const gchar *folder_name,
* Return value: the requested folder, or %NULL if the subfolder object
* could not be obtained
**/
-CamelFolder *
-camel_folder_get_subfolder (CamelFolder *folder, const gchar *folder_name,
- gboolean create, CamelException *ex)
+CamelFolder *camel_folder_get_subfolder(CamelFolder * folder, const gchar * folder_name,
+ gboolean create, CamelException * ex)
{
- 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);
+ g_return_val_if_fail(folder_name != NULL, NULL);
- return CF_CLASS (folder)->get_subfolder (folder, folder_name,
- create, ex);
+ return CF_CLASS(folder)->get_subfolder(folder, folder_name, create, ex);
}
-
-static CamelFolder *
-get_parent_folder (CamelFolder *folder)
+static CamelFolder *get_parent_folder(CamelFolder * folder)
{
return folder->parent_folder;
}
@@ -459,17 +391,14 @@ get_parent_folder (CamelFolder *folder)
*
* Return value: the folder's parent
**/
-CamelFolder *
-camel_folder_get_parent_folder (CamelFolder *folder)
+CamelFolder *camel_folder_get_parent_folder(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_parent_folder (folder);
+ return CF_CLASS(folder)->get_parent_folder(folder);
}
-
-static CamelStore *
-get_parent_store (CamelFolder *folder)
+static CamelStore *get_parent_store(CamelFolder * folder)
{
return folder->parent_store;
}
@@ -480,20 +409,16 @@ get_parent_store (CamelFolder *folder)
*
* Return value: the parent store of the folder.
**/
-CamelStore *
-camel_folder_get_parent_store (CamelFolder *folder)
+CamelStore *camel_folder_get_parent_store(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_parent_store (folder);
+ return CF_CLASS(folder)->get_parent_store(folder);
}
-
-static GPtrArray *
-get_subfolder_names (CamelFolder *folder)
+static GPtrArray *get_subfolder_names(CamelFolder * folder)
{
- g_warning ("CamelFolder::get_subfolder_names not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::get_subfolder_names not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
return NULL;
}
@@ -505,20 +430,17 @@ get_subfolder_names (CamelFolder *folder)
* 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)
+GPtrArray *camel_folder_get_subfolder_names(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_subfolder_names (folder);
+ return CF_CLASS(folder)->get_subfolder_names(folder);
}
-
-static void
-free_subfolder_names (CamelFolder *folder, GPtrArray *array)
+static void free_subfolder_names(CamelFolder * folder, GPtrArray * array)
{
- g_warning ("CamelFolder::free_subfolder_names not implemented "
- "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::free_subfolder_names not implemented "
+ "for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
}
/**
@@ -528,23 +450,18 @@ free_subfolder_names (CamelFolder *folder, GPtrArray *array)
*
* Frees the array of names returned by camel_folder_get_subfolder_names().
**/
-void
-camel_folder_free_subfolder_names (CamelFolder *folder, GPtrArray *array)
+void camel_folder_free_subfolder_names(CamelFolder * folder, GPtrArray * array)
{
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_if_fail(CAMEL_IS_FOLDER(folder));
- CF_CLASS (folder)->free_subfolder_names (folder, array);
+ CF_CLASS(folder)->free_subfolder_names(folder, array);
}
-
-static void
-expunge (CamelFolder *folder, CamelException *ex)
+static void expunge(CamelFolder * folder, CamelException * ex)
{
- g_warning ("CamelFolder::expunge not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::expunge not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
}
-
/**
* camel_folder_expunge:
* @folder: the folder
@@ -552,20 +469,16 @@ expunge (CamelFolder *folder, CamelException *ex)
*
* Delete messages which have been marked as "DELETED"
**/
-void
-camel_folder_expunge (CamelFolder *folder, CamelException *ex)
+void camel_folder_expunge(CamelFolder * folder, CamelException * ex)
{
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_if_fail(CAMEL_IS_FOLDER(folder));
- CF_CLASS (folder)->expunge (folder, ex);
+ CF_CLASS(folder)->expunge(folder, ex);
}
-
-static gint
-get_message_count (CamelFolder *folder)
+static gint get_message_count(CamelFolder * folder)
{
- g_warning ("CamelFolder::get_message_count not implemented "
- "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::get_message_count not implemented " "for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
return -1;
}
@@ -575,19 +488,17 @@ get_message_count (CamelFolder *folder)
*
* Return value: the number of messages in the folder, or -1 if unknown.
**/
-gint
-camel_folder_get_message_count (CamelFolder *folder)
+gint camel_folder_get_message_count(CamelFolder * folder)
{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
+ g_return_val_if_fail(CAMEL_IS_FOLDER(folder), -1);
- return CF_CLASS (folder)->get_message_count (folder);
+ return CF_CLASS(folder)->get_message_count(folder);
}
-static gint
-get_unread_message_count (CamelFolder *folder)
+static gint get_unread_message_count(CamelFolder * folder)
{
- g_warning ("CamelFolder::get_unread_message_count not implemented "
- "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::get_unread_message_count not implemented "
+ "for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
return -1;
}
@@ -597,21 +508,16 @@ get_unread_message_count (CamelFolder *folder)
*
* Return value: the number of unread messages in the folder, or -1 if unknown.
**/
-gint
-camel_folder_get_unread_message_count (CamelFolder *folder)
+gint camel_folder_get_unread_message_count(CamelFolder * folder)
{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
+ g_return_val_if_fail(CAMEL_IS_FOLDER(folder), -1);
- return CF_CLASS (folder)->get_unread_message_count (folder);
+ return CF_CLASS(folder)->get_unread_message_count(folder);
}
-
-static void
-append_message (CamelFolder *folder, CamelMimeMessage *message,
- guint32 flags, CamelException *ex)
+static void append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex)
{
- g_warning ("CamelFolder::append_message not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::append_message not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
return;
}
@@ -620,24 +526,19 @@ 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.
* @ex: exception object
*
* Add a message to a folder.
**/
-void
-camel_folder_append_message (CamelFolder *folder,
- CamelMimeMessage *message,
- guint32 flags,
- 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, flags, 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;
}
@@ -650,20 +551,16 @@ get_permanent_flags (CamelFolder *folder)
* stored on a message between sessions. If it includes %CAMEL_FLAG_USER,
* then user-defined flags will be remembered.
**/
-guint32
-camel_folder_get_permanent_flags (CamelFolder *folder)
+guint32 camel_folder_get_permanent_flags(CamelFolder * folder)
{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0);
+ g_return_val_if_fail(CAMEL_IS_FOLDER(folder), 0);
- return CF_CLASS (folder)->get_permanent_flags (folder);
+ return CF_CLASS(folder)->get_permanent_flags(folder);
}
-
-static guint32
-get_message_flags (CamelFolder *folder, const char *uid)
+static guint32 get_message_flags(CamelFolder * folder, const char *uid)
{
- g_warning ("CamelFolder::get_message_flags not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::get_message_flags not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
return 0;
}
@@ -675,21 +572,16 @@ get_message_flags (CamelFolder *folder, const char *uid)
* Return value: the CamelMessageFlags that are set on the indicated
* message.
**/
-guint32
-camel_folder_get_message_flags (CamelFolder *folder, const char *uid)
+guint32 camel_folder_get_message_flags(CamelFolder * folder, const char *uid)
{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0);
+ g_return_val_if_fail(CAMEL_IS_FOLDER(folder), 0);
- return CF_CLASS (folder)->get_message_flags (folder, uid);
+ return CF_CLASS(folder)->get_message_flags(folder, uid);
}
-
-static void
-set_message_flags (CamelFolder *folder, const char *uid,
- guint32 flags, guint32 set)
+static void set_message_flags(CamelFolder * folder, const char *uid, guint32 flags, guint32 set)
{
- g_warning ("CamelFolder::set_message_flags not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::set_message_flags not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
}
/**
@@ -703,22 +595,17 @@ set_message_flags (CamelFolder *folder, const char *uid,
* on the indicated message. (This may or may not persist after the
* folder or store is closed. See camel_folder_get_permanent_flags().)
**/
-void
-camel_folder_set_message_flags (CamelFolder *folder, const char *uid,
- guint32 flags, guint32 set)
+void camel_folder_set_message_flags(CamelFolder * folder, const char *uid, guint32 flags, guint32 set)
{
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_if_fail(CAMEL_IS_FOLDER(folder));
- CF_CLASS (folder)->set_message_flags (folder, uid, flags, set);
+ CF_CLASS(folder)->set_message_flags(folder, uid, flags, set);
}
-
-static gboolean
-get_message_user_flag (CamelFolder *folder, const char *uid,
- const char *name)
+static gboolean get_message_user_flag(CamelFolder * folder, const char *uid, const char *name)
{
- g_warning ("CamelFolder::get_message_user_flag not implemented "
- "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::get_message_user_flag not implemented "
+ "for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
return FALSE;
}
@@ -730,22 +617,17 @@ get_message_user_flag (CamelFolder *folder, const char *uid,
*
* Return value: whether or not the given user flag is set on the message.
**/
-gboolean
-camel_folder_get_message_user_flag (CamelFolder *folder, const char *uid,
- const char *name)
+gboolean camel_folder_get_message_user_flag(CamelFolder * folder, const char *uid, const char *name)
{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0);
+ g_return_val_if_fail(CAMEL_IS_FOLDER(folder), 0);
- return CF_CLASS (folder)->get_message_user_flag (folder, uid, name);
+ return CF_CLASS(folder)->get_message_user_flag(folder, uid, name);
}
-
-static void
-set_message_user_flag (CamelFolder *folder, const char *uid,
- const char *name, gboolean value)
+static void set_message_user_flag(CamelFolder * folder, const char *uid, const char *name, gboolean value)
{
- g_warning ("CamelFolder::set_message_user_flag not implemented "
- "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::set_message_user_flag not implemented "
+ "for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
}
/**
@@ -759,21 +641,16 @@ set_message_user_flag (CamelFolder *folder, const char *uid,
* on the indicated message. (This may or may not persist after the
* folder or store is closed. See camel_folder_get_permanent_flags().)
**/
-void
-camel_folder_set_message_user_flag (CamelFolder *folder, const char *uid,
- const char *name, gboolean value)
+void camel_folder_set_message_user_flag(CamelFolder * folder, const char *uid, const char *name, gboolean value)
{
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_if_fail(CAMEL_IS_FOLDER(folder));
- CF_CLASS (folder)->set_message_user_flag (folder, uid, name, value);
+ CF_CLASS(folder)->set_message_user_flag(folder, uid, name, value);
}
-
-static const CamelMessageInfo *
-get_message_info (CamelFolder *folder, const char *uid)
+static const CamelMessageInfo *get_message_info(CamelFolder * folder, const char *uid)
{
- g_warning ("CamelFolder::get_message_info not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::get_message_info not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
return NULL;
}
@@ -784,33 +661,27 @@ get_message_info (CamelFolder *folder, const char *uid)
*
* Return value: the summary information for the indicated message
**/
-const CamelMessageInfo *
-camel_folder_get_message_info (CamelFolder *folder, const char *uid)
+const CamelMessageInfo *camel_folder_get_message_info(CamelFolder * folder, const char *uid)
{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
- g_return_val_if_fail (uid != NULL, NULL);
+ g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL);
+ g_return_val_if_fail(uid != NULL, NULL);
- return CF_CLASS (folder)->get_message_info (folder, uid);
+ return CF_CLASS(folder)->get_message_info(folder, uid);
}
-
/* TODO: is this function required anyway? */
-gboolean
-camel_folder_has_summary_capability (CamelFolder *folder)
+gboolean camel_folder_has_summary_capability(CamelFolder * folder)
{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
+ g_return_val_if_fail(CAMEL_IS_FOLDER(folder), FALSE);
return folder->has_summary_capability;
}
-
/* UIDs stuff */
-static CamelMimeMessage *
-get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+static CamelMimeMessage *get_message(CamelFolder * folder, const gchar * uid, CamelException * ex)
{
- g_warning ("CamelFolder::get_message not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::get_message not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
return NULL;
}
@@ -826,21 +697,16 @@ get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
*
* Return value: Message corresponding to the UID
**/
-CamelMimeMessage *
-camel_folder_get_message (CamelFolder *folder, const gchar *uid,
- CamelException *ex)
+CamelMimeMessage *camel_folder_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex)
{
- 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_message (folder, uid, ex);
+ return CF_CLASS(folder)->get_message(folder, uid, ex);
}
-
-static GPtrArray *
-get_uids (CamelFolder *folder)
+static GPtrArray *get_uids(CamelFolder * folder)
{
- g_warning ("CamelFolder::get_uids not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::get_uids not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
return NULL;
}
@@ -856,20 +722,16 @@ get_uids (CamelFolder *folder)
* Return value: GPtrArray of UIDs corresponding to the messages
* available in the folder.
**/
-GPtrArray *
-camel_folder_get_uids (CamelFolder *folder)
+GPtrArray *camel_folder_get_uids(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_uids (folder);
+ return CF_CLASS(folder)->get_uids(folder);
}
-
-static void
-free_uids (CamelFolder *folder, GPtrArray *array)
+static void free_uids(CamelFolder * folder, GPtrArray * array)
{
- g_warning ("CamelFolder::free_uids not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::free_uids not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
}
/**
@@ -879,20 +741,16 @@ free_uids (CamelFolder *folder, GPtrArray *array)
*
* Frees the array of UIDs returned by camel_folder_get_uids().
**/
-void
-camel_folder_free_uids (CamelFolder *folder, GPtrArray *array)
+void camel_folder_free_uids(CamelFolder * folder, GPtrArray * array)
{
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_if_fail(CAMEL_IS_FOLDER(folder));
- CF_CLASS (folder)->free_uids (folder, array);
+ CF_CLASS(folder)->free_uids(folder, array);
}
-
-static GPtrArray *
-get_summary (CamelFolder *folder)
+static GPtrArray *get_summary(CamelFolder * folder)
{
- g_warning ("CamelFolder::get_summary not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::get_summary not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
return NULL;
}
@@ -906,20 +764,16 @@ get_summary (CamelFolder *folder)
*
* Return value: an array of CamelMessageInfo
**/
-GPtrArray *
-camel_folder_get_summary (CamelFolder *folder)
+GPtrArray *camel_folder_get_summary(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_summary (folder);
+ return CF_CLASS(folder)->get_summary(folder);
}
-
-static void
-free_summary (CamelFolder *folder, GPtrArray *array)
+static void free_summary(CamelFolder * folder, GPtrArray * array)
{
- g_warning ("CamelFolder::free_summary not implemented for `%s'",
- gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::free_summary not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
}
/**
@@ -929,15 +783,13 @@ free_summary (CamelFolder *folder, GPtrArray *array)
*
* Frees the summary array returned by camel_folder_get_summary().
**/
-void
-camel_folder_free_summary (CamelFolder *folder, GPtrArray *array)
+void camel_folder_free_summary(CamelFolder * folder, GPtrArray * array)
{
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_if_fail(CAMEL_IS_FOLDER(folder));
- CF_CLASS (folder)->free_summary (folder, array);
+ CF_CLASS(folder)->free_summary(folder, array);
}
-
/**
* camel_folder_has_search_capability:
* @folder: Folder object
@@ -946,20 +798,17 @@ camel_folder_free_summary (CamelFolder *folder, GPtrArray *array)
*
* Return value: %TRUE if the folder supports searching
**/
-gboolean
-camel_folder_has_search_capability (CamelFolder *folder)
+gboolean camel_folder_has_search_capability(CamelFolder * folder)
{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
+ g_return_val_if_fail(CAMEL_IS_FOLDER(folder), FALSE);
return folder->has_search_capability;
}
-static GPtrArray *
-search_by_expression (CamelFolder *folder, const char *expression,
- CamelException *ex)
+static GPtrArray *search_by_expression(CamelFolder * folder, const char *expression, CamelException * ex)
{
- g_warning ("CamelFolder::search_by_expression not implemented for "
- "`%s'", gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ g_warning("CamelFolder::search_by_expression not implemented for "
+ "`%s'", gtk_type_name(GTK_OBJECT_TYPE(folder)));
return NULL;
}
@@ -974,33 +823,52 @@ search_by_expression (CamelFolder *folder, const char *expression,
* Return value: a list of uids of matching messages. The caller must
* free the list and each of the elements when it is done.
**/
-GPtrArray *
-camel_folder_search_by_expression (CamelFolder *folder, const char *expression,
- CamelException *ex)
+GPtrArray *camel_folder_search_by_expression(CamelFolder * folder, const char *expression, CamelException * ex)
{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
- g_return_val_if_fail (folder->has_search_capability, NULL);
+ g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL);
+ g_return_val_if_fail(folder->has_search_capability, NULL);
- return CF_CLASS (folder)->search_by_expression (folder, expression, ex);
+ return CF_CLASS(folder)->search_by_expression(folder, expression, ex);
}
+void 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);
+}
-static void
-copy_message_to (CamelFolder *source, const char *uid, CamelFolder *dest,
- CamelException *ex)
+/**
+ * camel_folder_search_free:
+ * @folder:
+ * @result:
+ *
+ * Free the result of a search.
+ **/
+void camel_folder_search_free(CamelFolder * folder, GPtrArray * result)
+{
+ g_return_if_fail(CAMEL_IS_FOLDER(folder));
+ g_return_if_fail(folder->has_search_capability);
+
+ return CF_CLASS(folder)->search_free(folder, result);
+}
+
+static void copy_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 ? info->flags : 0, ex);
- gtk_object_unref (GTK_OBJECT (msg));
- if (camel_exception_is_set (ex))
+ info = camel_folder_get_message_info(source, uid);
+ camel_folder_append_message(dest, msg, info, ex);
+ gtk_object_unref(GTK_OBJECT(msg));
+ if (camel_exception_is_set(ex))
return;
}
@@ -1015,40 +883,34 @@ copy_message_to (CamelFolder *source, const char *uid, CamelFolder *dest,
* @dest folders have the same parent_store, this may be more efficient
* than a camel_folder_append_message().
**/
-void
-camel_folder_copy_message_to (CamelFolder *source, const char *uid,
- CamelFolder *dest, CamelException *ex)
+void camel_folder_copy_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)->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)
+static void 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 ? info->flags : 0, ex);
- gtk_object_unref (GTK_OBJECT (msg));
- if (camel_exception_is_set (ex))
+ info = camel_folder_get_message_info(source, uid);
+ camel_folder_append_message(dest, msg, info, ex);
+ gtk_object_unref(GTK_OBJECT(msg));
+ if (camel_exception_is_set(ex))
return;
- camel_folder_delete_message (source, uid);
+ camel_folder_delete_message(source, uid);
}
/**
@@ -1063,24 +925,19 @@ move_message_to (CamelFolder *source, const char *uid, CamelFolder *dest,
* 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++;
}
@@ -1094,17 +951,14 @@ 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;
@@ -1124,25 +978,23 @@ thaw (CamelFolder *folder)
if (folder->folder_changed) {
folder->folder_changed = FALSE;
- gtk_signal_emit (GTK_OBJECT (folder),
- signals[FOLDER_CHANGED], 0);
+ gtk_signal_emit(GTK_OBJECT(folder), signals[FOLDER_CHANGED], 0);
} else if (folder->messages_changed) {
/* FIXME: would be nice to not emit more than once for
* a given message
*/
for (m = messages; m; m = m->next) {
- gtk_signal_emit_by_name (GTK_OBJECT (folder),
- "message_changed", m->data);
- g_free (m->data);
+ gtk_signal_emit_by_name(GTK_OBJECT(folder), "message_changed", m->data);
+ g_free(m->data);
}
- g_list_free (messages);
+ g_list_free(messages);
return;
}
if (messages) {
for (m = messages; m; m = m->next)
- g_free (m->data);
- g_list_free (messages);
+ g_free(m->data);
+ g_list_free(messages);
}
}
@@ -1153,49 +1005,38 @@ thaw (CamelFolder *folder)
* Thaws the folder and emits any pending folder_changed or
* message_changed signals.
**/
-void
-camel_folder_thaw (CamelFolder *folder)
+void camel_folder_thaw(CamelFolder * folder)
{
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (folder->frozen != 0);
+ g_return_if_fail(CAMEL_IS_FOLDER(folder));
+ g_return_if_fail(folder->frozen != 0);
- CF_CLASS (folder)->thaw (folder);
+ CF_CLASS(folder)->thaw(folder);
}
-
/* Default signal implementations, which block emission when we're
* frozen.
*/
-static void
-folder_changed (CamelFolder *folder, int type)
+static void folder_changed(CamelFolder * folder, int type)
{
if (folder->frozen) {
- gtk_signal_emit_stop (GTK_OBJECT (folder),
- signals[FOLDER_CHANGED]);
+ gtk_signal_emit_stop(GTK_OBJECT(folder), signals[FOLDER_CHANGED]);
folder->folder_changed = TRUE;
}
}
-static void
-message_changed (CamelFolder *folder, const char *uid)
+static void message_changed(CamelFolder * folder, const char *uid)
{
if (folder->frozen) {
- gtk_signal_emit_stop (GTK_OBJECT (folder),
- signals[MESSAGE_CHANGED]);
+ gtk_signal_emit_stop(GTK_OBJECT(folder), signals[MESSAGE_CHANGED]);
/* Only record the UID if it will be useful later. */
if (!folder->folder_changed &&
- gtk_signal_handler_pending (GTK_OBJECT (folder),
- signals[MESSAGE_CHANGED],
- FALSE)) {
- folder->messages_changed =
- g_list_prepend (folder->messages_changed,
- g_strdup (uid));
+ gtk_signal_handler_pending(GTK_OBJECT(folder), signals[MESSAGE_CHANGED], FALSE)) {
+ folder->messages_changed = g_list_prepend(folder->messages_changed, g_strdup(uid));
}
}
}
-
/**
* camel_folder_free_nop:
* @folder: a folder
@@ -1206,8 +1047,7 @@ message_changed (CamelFolder *folder, const char *uid)
* or free_subfolder_names 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)
{
;
}
@@ -1222,10 +1062,9 @@ camel_folder_free_nop (CamelFolder *folder, GPtrArray *array)
* free_subfolder_names 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);
}
/**
@@ -1238,12 +1077,11 @@ camel_folder_free_shallow (CamelFolder *folder, GPtrArray *array)
* free_subfolder_names (but NOT free_summary) 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 bdaebfd242..949dbae52a 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -107,7 +107,7 @@ typedef struct {
void (*append_message) (CamelFolder *folder,
CamelMimeMessage *message,
- guint32 flags,
+ const CamelMessageInfo *info,
CamelException *ex);
guint32 (*get_permanent_flags) (CamelFolder *folder);
@@ -151,8 +151,9 @@ typedef struct {
const char *expression,
CamelException *ex);
- const CamelMessageInfo * (*get_message_info) (CamelFolder *,
- const char *uid);
+ void (*search_free) (CamelFolder *folder, GPtrArray *result);
+
+ const CamelMessageInfo * (*get_message_info) (CamelFolder *, const char *uid);
void (*copy_message_to) (CamelFolder *source,
const char *uid,
@@ -226,7 +227,7 @@ void camel_folder_set_message_user_flag (CamelFolder *folder,
/* message manipulation */
void camel_folder_append_message (CamelFolder *folder,
CamelMimeMessage *message,
- guint32 flags,
+ const CamelMessageInfo *info,
CamelException *ex);
@@ -263,6 +264,7 @@ gboolean camel_folder_has_search_capability (CamelFolder *folder);
GPtrArray * camel_folder_search_by_expression (CamelFolder *folder,
const char *expression,
CamelException *ex);
+void camel_folder_search_free (CamelFolder *folder, GPtrArray *);
/* summary info */
const CamelMessageInfo *camel_folder_get_message_info (CamelFolder *summary,
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index 5917cfda2a..a781479aeb 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -1114,11 +1114,11 @@ retry:
* a single space.
*/
if (*start == ' ' || *start == '\t') {
- static char *space = " ";
do
start++;
while (*start == ' ' || *start == '\t');
- header_append(s, space, space + 1);
+ start--;
+ *start = ' ';
}
}
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 82d133b0ab..9ab729d218 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -74,7 +74,7 @@ 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_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, 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);
@@ -553,7 +553,7 @@ imap_get_unread_message_count (CamelFolder *folder)
}
static void
-imap_append_message (CamelFolder *folder, CamelMimeMessage *message, guint32 flags, CamelException *ex)
+imap_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, CamelException *ex)
{
CamelStore *store = CAMEL_STORE (folder->parent_store);
CamelURL *url = CAMEL_SERVICE (store)->url;
@@ -586,16 +586,18 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message, guint32 fla
folder_path = g_strdup (folder->full_name);
/* create flag string param */
- if (flags) {
- flagstr = g_strconcat (" (", flags & CAMEL_MESSAGE_SEEN ? "\\Seen " : "",
- flags & CAMEL_MESSAGE_DRAFT ? "\\Draft " : "",
- flags & CAMEL_MESSAGE_DELETED ? "\\Answered " : "",
+ if (info && info->flags) {
+ flagstr = g_strconcat (" (", info->flags & CAMEL_MESSAGE_SEEN ? "\\Seen " : "",
+ info->flags & CAMEL_MESSAGE_DRAFT ? "\\Draft " : "",
+ info->flags & CAMEL_MESSAGE_DELETED ? "\\Answered " : "",
NULL);
if (flagstr)
*(flagstr + strlen (flagstr) - 1) = ')';
}
/* FIXME: len isn't really correct I don't think, we need to crlf/dot filter */
+ /* FIXME: Dont copy the message ANOTHER TIME, its already in memory entirely
+ copied, thats bad enough */
status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store),
folder, &result, "APPEND %s%s {%d}\r\n%s",
folder_path, flagstr ? flagstr : "",
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index deb47f6dcf..68e0f5fd28 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -24,8 +24,7 @@
* USA
*/
-
-#include <config.h>
+#include <config.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -49,50 +48,47 @@
#define d(x)
-static CamelFolderClass *parent_class=NULL;
+static CamelFolderClass *parent_class = NULL;
/* Returns the class for a CamelMboxFolder */
#define CMBOXF_CLASS(so) CAMEL_MBOX_FOLDER_CLASS (GTK_OBJECT(so)->klass)
#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass)
#define CMBOXS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass)
+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_init (CamelFolder *folder, CamelStore *parent_store,
- CamelFolder *parent_folder, const gchar *name,
- gchar *separator, gboolean path_begins_with_sep,
- CamelException *ex);
-
-static void mbox_sync (CamelFolder *folder, gboolean expunge, 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);
-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_sync(CamelFolder * folder, gboolean expunge, 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, const CamelMessageInfo *info, 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_expunge(CamelFolder * folder, CamelException * ex);
-static const CamelMessageInfo *mbox_get_message_info (CamelFolder *folder, const char *uid);
+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 GPtrArray *mbox_search_by_expression(CamelFolder * folder, const char *expression, CamelException * ex);
+static void mbox_search_free(CamelFolder * folder, GPtrArray * result);
-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 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);
-static void mbox_finalize (GtkObject *object);
-
-static void
-camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class)
+static void camel_mbox_folder_class_init(CamelMboxFolderClass * camel_mbox_folder_class)
{
- CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_mbox_folder_class);
- GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_folder_class);
+ CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS(camel_mbox_folder_class);
+ GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS(camel_folder_class);
+
+ parent_class = gtk_type_class(camel_folder_get_type());
- parent_class = gtk_type_class (camel_folder_get_type ());
-
/* virtual method definition */
/* virtual method overload */
@@ -112,6 +108,7 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class)
camel_folder_class->get_message = mbox_get_message;
camel_folder_class->search_by_expression = mbox_search_by_expression;
+ camel_folder_class->search_free = mbox_search_free;
camel_folder_class->get_message_info = mbox_get_message_info;
@@ -121,61 +118,57 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class)
camel_folder_class->set_message_user_flag = mbox_set_message_user_flag;
gtk_object_class->finalize = mbox_finalize;
-
+
}
-static void
-mbox_finalize (GtkObject *object)
+static void mbox_finalize(GtkObject * object)
{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (object);
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(object);
- g_free (mbox_folder->folder_file_path);
- g_free (mbox_folder->summary_file_path);
- g_free (mbox_folder->folder_dir_path);
- g_free (mbox_folder->index_file_path);
+ g_free(mbox_folder->folder_file_path);
+ g_free(mbox_folder->summary_file_path);
+ g_free(mbox_folder->folder_dir_path);
+ g_free(mbox_folder->index_file_path);
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
+ GTK_OBJECT_CLASS(parent_class)->finalize(object);
}
-GtkType
-camel_mbox_folder_get_type (void)
+GtkType camel_mbox_folder_get_type(void)
{
static GtkType camel_mbox_folder_type = 0;
-
- if (!camel_mbox_folder_type) {
- GtkTypeInfo camel_mbox_folder_info =
- {
+
+ if (!camel_mbox_folder_type) {
+ GtkTypeInfo camel_mbox_folder_info = {
"CamelMboxFolder",
- sizeof (CamelMboxFolder),
- sizeof (CamelMboxFolderClass),
+ sizeof(CamelMboxFolder),
+ sizeof(CamelMboxFolderClass),
(GtkClassInitFunc) camel_mbox_folder_class_init,
(GtkObjectInitFunc) NULL,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
- camel_mbox_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_mbox_folder_info);
+
+ camel_mbox_folder_type = gtk_type_unique(CAMEL_FOLDER_TYPE, &camel_mbox_folder_info);
}
-
+
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)
+static void
+mbox_init(CamelFolder * folder, CamelStore * parent_store,
+ CamelFolder * parent_folder, const gchar * name, gchar * separator,
+ gboolean path_begins_with_sep, CamelException * ex)
{
- CamelMboxFolder *mbox_folder = (CamelMboxFolder *)folder;
+ CamelMboxFolder *mbox_folder = (CamelMboxFolder *) folder;
const gchar *root_dir_path;
gchar *real_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))
+ 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
@@ -186,238 +179,246 @@ mbox_init (CamelFolder *folder, CamelStore *parent_store,
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;
+ 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;
+ mbox_folder->summary = NULL;
+ mbox_folder->search = NULL;
/* 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);
+ g_free(mbox_folder->folder_file_path);
+ g_free(mbox_folder->folder_dir_path);
+ g_free(mbox_folder->index_file_path);
- root_dir_path = camel_mbox_store_get_toplevel_dir (CAMEL_MBOX_STORE(folder->parent_store));
+ root_dir_path = camel_mbox_store_get_toplevel_dir(CAMEL_MBOX_STORE(folder->parent_store));
- 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);
+ 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);
/* if we have no index file, force it */
forceindex = stat(mbox_folder->index_file_path, &st) == -1;
- mbox_folder->index = ibex_open(mbox_folder->index_file_path, O_CREAT|O_RDWR, 0600);
+ mbox_folder->index = ibex_open(mbox_folder->index_file_path, O_CREAT | O_RDWR, 0600);
if (mbox_folder->index == NULL) {
/* yes, this isn't fatal at all */
- g_warning("Could not open/create index file: %s: indexing not performed",
- strerror(errno));
+ g_warning("Could not open/create index file: %s: indexing not performed", strerror(errno));
}
/* no summary (disk or memory), and we're proverbially screwed */
- mbox_folder->summary = camel_mbox_summary_new (mbox_folder->summary_file_path,
- mbox_folder->folder_file_path, mbox_folder->index);
- if (mbox_folder->summary == NULL
- || camel_mbox_summary_load(mbox_folder->summary, forceindex) == -1) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID, /* FIXME: right error code */
- "Could not create summary");
+ mbox_folder->summary = camel_mbox_summary_new(mbox_folder->summary_file_path,
+ mbox_folder->folder_file_path, mbox_folder->index);
+ if (mbox_folder->summary == NULL || camel_mbox_summary_load(mbox_folder->summary, forceindex) == -1) {
+ camel_exception_set(ex, CAMEL_EXCEPTION_FOLDER_INVALID, /* FIXME: right error code */
+ "Could not create summary");
return;
}
}
-static void
-mbox_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+static void mbox_sync(CamelFolder * folder, gboolean expunge, CamelException * ex)
{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
if (expunge)
- mbox_expunge (folder, ex);
+ mbox_expunge(folder, ex);
else
- camel_mbox_summary_sync (mbox_folder->summary, FALSE, ex);
+ camel_mbox_summary_sync(mbox_folder->summary, FALSE, ex);
/* save index */
if (mbox_folder->index)
ibex_save(mbox_folder->index);
if (mbox_folder->summary)
- camel_folder_summary_save (CAMEL_FOLDER_SUMMARY (mbox_folder->summary));
+ camel_folder_summary_save(CAMEL_FOLDER_SUMMARY(mbox_folder->summary));
}
-static void
-mbox_expunge (CamelFolder *folder, CamelException *ex)
+static void mbox_expunge(CamelFolder * folder, CamelException * ex)
{
- CamelMboxFolder *mbox = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mbox = CAMEL_MBOX_FOLDER(folder);
- camel_mbox_summary_sync (mbox->summary, TRUE, ex);
+ camel_mbox_summary_sync(mbox->summary, TRUE, ex);
/* TODO: check it actually changed */
- gtk_signal_emit_by_name (GTK_OBJECT (folder), "folder_changed", 0);
+ gtk_signal_emit_by_name(GTK_OBJECT(folder), "folder_changed", 0);
}
-static gint
-mbox_get_message_count (CamelFolder *folder)
+static gint mbox_get_message_count(CamelFolder * folder)
{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- g_return_val_if_fail (mbox_folder->summary != NULL, -1);
-
- return camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (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)
+static gint mbox_get_unread_message_count(CamelFolder * folder)
{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
CamelMessageInfo *info;
GPtrArray *infolist;
gint i, max, count = 0;
- g_return_val_if_fail (mbox_folder->summary != NULL, -1);
+ g_return_val_if_fail(mbox_folder->summary != NULL, -1);
- max = camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (mbox_folder->summary));
+ max = camel_folder_summary_count(CAMEL_FOLDER_SUMMARY(mbox_folder->summary));
if (max == -1)
return -1;
- infolist = mbox_get_summary (folder);
-
+ infolist = mbox_get_summary(folder);
+
for (i = 0; i < infolist->len; i++) {
- info = (CamelMessageInfo *) g_ptr_array_index (infolist, i);
+ info = (CamelMessageInfo *) g_ptr_array_index(infolist, i);
if (!(info->flags & CAMEL_MESSAGE_SEEN))
count++;
}
-
+
return count;
}
/* FIXME: this may need some tweaking for performance? */
-static void
-mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, guint32 flags, CamelException *ex)
+static void mbox_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex)
{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
CamelStream *output_stream = NULL, *filter_stream = NULL;
CamelMimeFilter *filter_from = NULL;
+ CamelMessageInfo *newinfo;
struct stat st;
off_t seek = -1;
char *xev, last;
guint32 uid;
+ char *fromline = NULL;
- if (stat (mbox_folder->folder_file_path, &st) != 0)
+ 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);
+ output_stream = camel_stream_fs_new_with_name(mbox_folder->folder_file_path, O_RDWR, 0600);
if (output_stream == NULL)
goto fail;
if (st.st_size) {
- seek = camel_seekable_stream_seek ((CamelSeekableStream *)output_stream, st.st_size - 1, SEEK_SET);
+ seek = camel_seekable_stream_seek((CamelSeekableStream *) output_stream, st.st_size - 1, SEEK_SET);
if (++seek != st.st_size)
goto fail;
/* If the mbox doesn't end with a newline, fix that. */
- if (camel_stream_read (output_stream, &last, 1) != 1)
+ if (camel_stream_read(output_stream, &last, 1) != 1)
goto fail;
if (last != '\n')
- camel_stream_write (output_stream, "\n", 1);
+ camel_stream_write(output_stream, "\n", 1);
} else
seek = 0;
/* assign a new x-evolution header/uid */
- camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution");
- 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_free (xev);
+ camel_medium_remove_header(CAMEL_MEDIUM(message), "X-Evolution");
+ uid = camel_folder_summary_next_uid(CAMEL_FOLDER_SUMMARY(mbox_folder->summary));
+ /* important that the header matches exactly 00000000-0000 */
+ xev = g_strdup_printf("%08x-%04x", uid, info?info->flags&0xffff:0);
+ camel_medium_add_header(CAMEL_MEDIUM(message), "X-Evolution", xev);
+ g_free(xev);
/* we must write this to the non-filtered stream ... */
- if (camel_stream_write_string (output_stream, "From - \n") == -1)
+ fromline = camel_mbox_summary_build_from(CAMEL_MIME_PART(message)->headers);
+ if (camel_stream_write_string(output_stream, fromline) == -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);
- if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), filter_stream) == -1)
+ 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);
+ if (camel_data_wrapper_write_to_stream(CAMEL_DATA_WRAPPER(message), filter_stream) == -1)
goto fail;
- if (camel_stream_close (filter_stream) == -1)
+ if (camel_stream_close(filter_stream) == -1)
goto fail;
/* filter stream ref's the output stream itself, so we need to unref it too */
- gtk_object_unref (GTK_OBJECT (filter_from));
- gtk_object_unref (GTK_OBJECT (filter_stream));
- gtk_object_unref (GTK_OBJECT (output_stream));
+ gtk_object_unref(GTK_OBJECT(filter_from));
+ gtk_object_unref(GTK_OBJECT(filter_stream));
+ gtk_object_unref(GTK_OBJECT(output_stream));
+ g_free(fromline);
/* force a summary update - will only update from the new position, if it can */
- if (camel_mbox_summary_update (mbox_folder->summary, seek) == 0)
- gtk_signal_emit_by_name (GTK_OBJECT (folder), "folder_changed", 0);
+ if (camel_mbox_summary_update(mbox_folder->summary, seek) == 0) {
+ char uidstr[16];
+ sprintf(uidstr, "%u", uid);
+ if (info
+ && (newinfo = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mbox_folder->summary), uidstr))) {
+ CamelFlag *flag = info->user_flags;
+ CamelTag *tag = info->user_tags;
+ while (flag) {
+ camel_flag_set(&newinfo->user_flags, flag->name, TRUE);
+ flag = flag->next;
+ }
+ while (tag) {
+ camel_tag_set(&newinfo->user_tags, tag->name, tag->value);
+ tag = tag->next;
+ }
+ }
+ gtk_signal_emit_by_name(GTK_OBJECT(folder), "folder_changed", 0);
+ }
return;
-fail:
- if (camel_exception_is_set (ex)) {
- camel_exception_setv (ex, camel_exception_get_id (ex),
- "Cannot append message to mbox file: %s",
- camel_exception_get_description (ex));
+ fail:
+ if (camel_exception_is_set(ex)) {
+ camel_exception_setv(ex, camel_exception_get_id(ex),
+ "Cannot append message to mbox file: %s", camel_exception_get_description(ex));
} else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Cannot append message to mbox file: %s",
- g_strerror (errno));
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
+ "Cannot append message to mbox file: %s", g_strerror(errno));
}
if (filter_stream) {
- /*camel_stream_close (filter_stream);*/
- gtk_object_unref (GTK_OBJECT (filter_stream));
+ /*camel_stream_close (filter_stream); */
+ gtk_object_unref(GTK_OBJECT(filter_stream));
}
if (output_stream)
- gtk_object_unref (GTK_OBJECT (output_stream));
+ gtk_object_unref(GTK_OBJECT(output_stream));
if (filter_from)
- gtk_object_unref (GTK_OBJECT (filter_from));
+ gtk_object_unref(GTK_OBJECT(filter_from));
+
+ g_free(fromline);
/* make sure the file isn't munged by us */
if (seek != -1) {
- int fd = open (mbox_folder->folder_file_path, O_WRONLY, 0600);
-
+ int fd = open(mbox_folder->folder_file_path, O_WRONLY, 0600);
+
if (fd != -1) {
- ftruncate (fd, st.st_size);
+ ftruncate(fd, st.st_size);
close(fd);
}
}
}
-static GPtrArray *
-mbox_get_uids (CamelFolder *folder)
+static GPtrArray *mbox_get_uids(CamelFolder * folder)
{
GPtrArray *array;
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
int i, count;
- count = camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (mbox_folder->summary));
- array = g_ptr_array_new ();
- g_ptr_array_set_size (array, count);
+ count = camel_folder_summary_count(CAMEL_FOLDER_SUMMARY(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 (
- CAMEL_FOLDER_SUMMARY (mbox_folder->summary), i);
- array->pdata[i] = g_strdup (info->info.uid);
+ CamelMboxMessageInfo *info =
+ (CamelMboxMessageInfo *) camel_folder_summary_index(CAMEL_FOLDER_SUMMARY(mbox_folder->summary), i);
+
+ array->pdata[i] = g_strdup(info->info.uid);
}
-
+
return array;
}
-static GPtrArray *
-mbox_get_subfolder_names (CamelFolder *folder)
+static GPtrArray *mbox_get_subfolder_names(CamelFolder * folder)
{
/* No subfolders. */
- return g_ptr_array_new ();
+ return g_ptr_array_new();
}
-static CamelMimeMessage *
-mbox_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+static CamelMimeMessage *mbox_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex)
{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
CamelStream *message_stream = NULL;
CamelMimeMessage *message = NULL;
CamelMboxMessageInfo *info;
@@ -426,7 +427,7 @@ mbox_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
int len;
/* get the message summary info */
- info = (CamelMboxMessageInfo *)camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mbox_folder->summary), uid);
+ info = (CamelMboxMessageInfo *) camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mbox_folder->summary), uid);
if (info == NULL) {
errno = ENOENT;
@@ -434,148 +435,142 @@ mbox_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
}
/* if this has no content, its an error in the library */
- g_assert (info->info.content);
- g_assert (info->frompos != -1);
+ g_assert(info->info.content);
+ 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);
+ message_stream = camel_stream_fs_new_with_name(mbox_folder->folder_file_path, O_RDONLY, 0);
if (message_stream == NULL)
goto fail;
/* we use a parser to verify the message is correct, and in the correct position */
- parser = camel_mime_parser_new ();
- camel_mime_parser_init_with_stream (parser, message_stream);
- gtk_object_unref (GTK_OBJECT (message_stream));
- camel_mime_parser_scan_from (parser, TRUE);
-
- camel_mime_parser_seek (parser, info->frompos, SEEK_SET);
- if (camel_mime_parser_step (parser, &buffer, &len) != HSCAN_FROM) {
- g_warning ("File appears truncated");
+ parser = camel_mime_parser_new();
+ camel_mime_parser_init_with_stream(parser, message_stream);
+ gtk_object_unref(GTK_OBJECT(message_stream));
+ camel_mime_parser_scan_from(parser, TRUE);
+
+ camel_mime_parser_seek(parser, info->frompos, SEEK_SET);
+ if (camel_mime_parser_step(parser, &buffer, &len) != HSCAN_FROM) {
+ g_warning("File appears truncated");
goto fail;
}
- if (camel_mime_parser_tell_start_from (parser) != info->frompos) {
- g_warning ("Summary doesn't match the folder contents! eek!\n"
- " expecting offset %ld got %ld", (long int)info->frompos,
- (long int)camel_mime_parser_tell_start_from (parser));
+ if (camel_mime_parser_tell_start_from(parser) != info->frompos) {
+ g_warning("Summary doesn't match the folder contents! eek!\n"
+ " expecting offset %ld got %ld", (long int)info->frompos,
+ (long int)camel_mime_parser_tell_start_from(parser));
errno = EINVAL;
goto fail;
}
- message = camel_mime_message_new ();
- if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (message), parser) == -1) {
- g_warning ("Construction failed");
+ message = camel_mime_message_new();
+ if (camel_mime_part_construct_from_parser(CAMEL_MIME_PART(message), parser) == -1) {
+ g_warning("Construction failed");
goto fail;
}
- gtk_object_unref (GTK_OBJECT (parser));
+ gtk_object_unref(GTK_OBJECT(parser));
return message;
-fail:
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "Cannot get message: %s",
- g_strerror(errno));
+ fail:
+ camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, "Cannot get message: %s", g_strerror(errno));
if (parser)
- gtk_object_unref (GTK_OBJECT (parser));
+ gtk_object_unref(GTK_OBJECT(parser));
if (message)
- gtk_object_unref (GTK_OBJECT (message));
+ gtk_object_unref(GTK_OBJECT(message));
return NULL;
}
-GPtrArray *
-mbox_get_summary (CamelFolder *folder)
+GPtrArray *mbox_get_summary(CamelFolder * folder)
{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- return CAMEL_FOLDER_SUMMARY (mbox_folder->summary)->messages;
+ return CAMEL_FOLDER_SUMMARY(mbox_folder->summary)->messages;
}
/* get a single message info, by uid */
-static const CamelMessageInfo *
-mbox_get_message_info (CamelFolder *folder, const char *uid)
+static const CamelMessageInfo *mbox_get_message_info(CamelFolder * folder, const char *uid)
{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- return camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mbox_folder->summary), uid);
+ return camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mbox_folder->summary), uid);
}
-static GPtrArray *
-mbox_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex)
+static GPtrArray *mbox_search_by_expression(CamelFolder * folder, const char *expression, CamelException * ex)
{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
if (mbox_folder->search == NULL) {
- mbox_folder->search = camel_folder_search_new ();
+ mbox_folder->search = camel_folder_search_new();
}
- camel_folder_search_set_folder (mbox_folder->search, folder);
+ camel_folder_search_set_folder(mbox_folder->search, folder);
if (mbox_folder->summary) {
/* FIXME: dont access summary array directly? */
- camel_folder_search_set_summary (mbox_folder->search,
- CAMEL_FOLDER_SUMMARY (mbox_folder->summary)->messages);
+ camel_folder_search_set_summary(mbox_folder->search,
+ CAMEL_FOLDER_SUMMARY(mbox_folder->summary)->messages);
}
-
- camel_folder_search_set_body_index (mbox_folder->search, mbox_folder->index);
- return camel_folder_search_execute_expression (mbox_folder->search, expression, ex);
+ camel_folder_search_set_body_index(mbox_folder->search, mbox_folder->index);
+
+ return camel_folder_search_execute_expression(mbox_folder->search, expression, ex);
}
-static guint32
-mbox_get_message_flags (CamelFolder *folder, const char *uid)
+static void mbox_search_free(CamelFolder * folder, GPtrArray * result)
+{
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
+
+ camel_folder_search_free_result(mbox_folder->search, result);
+}
+
+static guint32 mbox_get_message_flags(CamelFolder * folder, const char *uid)
{
CamelMessageInfo *info;
- CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mf = CAMEL_MBOX_FOLDER(folder);
- info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid);
- g_return_val_if_fail (info != NULL, 0);
+ info = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mf->summary), uid);
+ 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)
+static void mbox_set_message_flags(CamelFolder * folder, const char *uid, guint32 flags, guint32 set)
{
CamelMessageInfo *info;
- CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mf = CAMEL_MBOX_FOLDER(folder);
- info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid);
- g_return_if_fail (info != NULL);
+ info = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mf->summary), uid);
+ 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));
+ 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);
+ 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)
+static gboolean mbox_get_message_user_flag(CamelFolder * folder, const char *uid, const char *name)
{
CamelMessageInfo *info;
- CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxFolder *mf = CAMEL_MBOX_FOLDER(folder);
- info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid);
- g_return_val_if_fail (info != NULL, FALSE);
+ info = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mf->summary), uid);
+ g_return_val_if_fail(info != NULL, FALSE);
- return camel_flag_get (&info->user_flags, name);
+ 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)
+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);
+ CamelMboxFolder *mf = CAMEL_MBOX_FOLDER(folder);
- info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid);
- g_return_if_fail (info != NULL);
+ info = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mf->summary), uid);
+ g_return_if_fail(info != NULL);
- camel_flag_set (&info->user_flags, name, value);
+ 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);
+ 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/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c
index e3396a7965..475fbd1352 100644
--- a/camel/providers/mbox/camel-mbox-store.c
+++ b/camel/providers/mbox/camel-mbox-store.c
@@ -221,7 +221,7 @@ delete_folder (CamelStore *store, const char *folder_name, CamelException *ex)
}
}
-static int xrename(char *oldp, char *newp, char *prefix, char *suffix, CamelException *ex)
+static int xrename(const char *oldp, const char *newp, const char *prefix, const char *suffix, CamelException *ex)
{
struct stat st;
char *old = g_strconcat(prefix, oldp, suffix, 0);
diff --git a/camel/providers/mbox/camel-mbox-summary.c b/camel/providers/mbox/camel-mbox-summary.c
index 4c826dbc28..fc1eacafe7 100644
--- a/camel/providers/mbox/camel-mbox-summary.c
+++ b/camel/providers/mbox/camel-mbox-summary.c
@@ -40,18 +40,19 @@ struct _CamelMboxSummaryPrivate {
#define _PRIVATE(o) (((CamelMboxSummary *)(o))->priv)
-static int summary_header_load (CamelFolderSummary *, FILE *);
-static int summary_header_save (CamelFolderSummary *, FILE *);
+static int summary_header_load(CamelFolderSummary *, FILE *);
+static int summary_header_save(CamelFolderSummary *, FILE *);
+
+static CamelMessageInfo *message_info_new(CamelFolderSummary *, struct _header_raw *);
+static CamelMessageInfo *message_info_new_from_parser(CamelFolderSummary *, CamelMimeParser *);
+static CamelMessageInfo *message_info_load(CamelFolderSummary *, FILE *);
+static int message_info_save(CamelFolderSummary *, FILE *, CamelMessageInfo *);
-static CamelMessageInfo * message_info_new (CamelFolderSummary *, struct _header_raw *);
-static CamelMessageInfo * message_info_new_from_parser (CamelFolderSummary *, CamelMimeParser *);
-static CamelMessageInfo * message_info_load (CamelFolderSummary *, FILE *);
-static int message_info_save (CamelFolderSummary *, FILE *, CamelMessageInfo *);
/*static void message_info_free (CamelFolderSummary *, CamelMessageInfo *);*/
-static void camel_mbox_summary_class_init (CamelMboxSummaryClass *klass);
-static void camel_mbox_summary_init (CamelMboxSummary *obj);
-static void camel_mbox_summary_finalise (GtkObject *obj);
+static void camel_mbox_summary_class_init(CamelMboxSummaryClass * klass);
+static void camel_mbox_summary_init(CamelMboxSummary *obj);
+static void camel_mbox_summary_finalise(GtkObject * obj);
static CamelFolderSummaryClass *camel_mbox_summary_parent;
@@ -61,52 +62,51 @@ enum SIGNALS {
static guint signals[LAST_SIGNAL] = { 0 };
-guint
-camel_mbox_summary_get_type (void)
+guint camel_mbox_summary_get_type(void)
{
static guint type = 0;
-
+
if (!type) {
GtkTypeInfo type_info = {
"CamelMboxSummary",
- sizeof (CamelMboxSummary),
- sizeof (CamelMboxSummaryClass),
+ sizeof(CamelMboxSummary),
+ sizeof(CamelMboxSummaryClass),
(GtkClassInitFunc) camel_mbox_summary_class_init,
(GtkObjectInitFunc) camel_mbox_summary_init,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL
};
-
- type = gtk_type_unique (camel_folder_summary_get_type (), &type_info);
+
+ type = gtk_type_unique(camel_folder_summary_get_type(), &type_info);
}
-
+
return type;
}
static void
-camel_mbox_summary_class_init (CamelMboxSummaryClass *klass)
+camel_mbox_summary_class_init(CamelMboxSummaryClass * klass)
{
GtkObjectClass *object_class = (GtkObjectClass *) klass;
CamelFolderSummaryClass *sklass = (CamelFolderSummaryClass *) klass;
-
- camel_mbox_summary_parent = gtk_type_class (camel_folder_summary_get_type ());
+
+ camel_mbox_summary_parent = gtk_type_class(camel_folder_summary_get_type());
object_class->finalize = camel_mbox_summary_finalise;
sklass->summary_header_load = summary_header_load;
sklass->summary_header_save = summary_header_save;
- sklass->message_info_new = message_info_new;
+ sklass->message_info_new = message_info_new;
sklass->message_info_new_from_parser = message_info_new_from_parser;
sklass->message_info_load = message_info_load;
sklass->message_info_save = message_info_save;
- /*sklass->message_info_free = message_info_free;*/
+ /*sklass->message_info_free = message_info_free; */
- gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+ gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL);
}
static void
-camel_mbox_summary_init (CamelMboxSummary *obj)
+camel_mbox_summary_init(CamelMboxSummary *obj)
{
struct _CamelMboxSummaryPrivate *p;
struct _CamelFolderSummary *s = (CamelFolderSummary *)obj;
@@ -122,13 +122,13 @@ camel_mbox_summary_init (CamelMboxSummary *obj)
}
static void
-camel_mbox_summary_finalise (GtkObject *obj)
+camel_mbox_summary_finalise(GtkObject * obj)
{
- CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY (obj);
+ CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY(obj);
- g_free (mbs->folder_path);
+ g_free(mbs->folder_path);
- ((GtkObjectClass *)(camel_mbox_summary_parent))->finalize(GTK_OBJECT (obj));
+ ((GtkObjectClass *) (camel_mbox_summary_parent))->finalize(GTK_OBJECT(obj));
}
/**
@@ -139,204 +139,203 @@ camel_mbox_summary_finalise (GtkObject *obj)
* Return value: A new CamelMboxSummary widget.
**/
CamelMboxSummary *
-camel_mbox_summary_new (const char *filename, const char *mbox_name, ibex *index)
+camel_mbox_summary_new(const char *filename, const char *mbox_name, ibex * index)
{
- CamelMboxSummary *new = CAMEL_MBOX_SUMMARY (gtk_type_new (camel_mbox_summary_get_type ()));
-
+ CamelMboxSummary *new = CAMEL_MBOX_SUMMARY(gtk_type_new(camel_mbox_summary_get_type()));
+
if (new) {
/* ?? */
- camel_folder_summary_set_build_content (CAMEL_FOLDER_SUMMARY (new), TRUE);
- camel_folder_summary_set_filename (CAMEL_FOLDER_SUMMARY (new), filename);
- new->folder_path = g_strdup (mbox_name);
+ camel_folder_summary_set_build_content(CAMEL_FOLDER_SUMMARY(new), TRUE);
+ camel_folder_summary_set_filename(CAMEL_FOLDER_SUMMARY(new), filename);
+ new->folder_path = g_strdup(mbox_name);
new->index = index;
}
return new;
}
static int
-summary_header_load (CamelFolderSummary *s, FILE *in)
+summary_header_load(CamelFolderSummary *s, FILE * in)
{
- CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY (s);
+ CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY(s);
- if (((CamelFolderSummaryClass *)camel_mbox_summary_parent)->summary_header_load (s, in) == -1)
+ if (((CamelFolderSummaryClass *) camel_mbox_summary_parent)->summary_header_load(s, in) == -1)
return -1;
- return camel_folder_summary_decode_uint32 (in, &mbs->folder_size);
+ return camel_folder_summary_decode_uint32(in, &mbs->folder_size);
}
static int
-summary_header_save (CamelFolderSummary *s, FILE *out)
+summary_header_save(CamelFolderSummary *s, FILE * out)
{
- CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY (s);
+ CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY(s);
- if (((CamelFolderSummaryClass *)camel_mbox_summary_parent)->summary_header_save (s, out) == -1)
+ if (((CamelFolderSummaryClass *) camel_mbox_summary_parent)->summary_header_save(s, out) == -1)
return -1;
- return camel_folder_summary_encode_uint32 (out, mbs->folder_size);
+ return camel_folder_summary_encode_uint32(out, mbs->folder_size);
}
static int
-header_evolution_decode (const char *in, guint32 *uid, guint32 *flags)
+header_evolution_decode(const char *in, guint32 * uid, guint32 * flags)
{
- char *header;
-
- if (in && (header = header_token_decode(in))) {
- if (strlen (header) == strlen ("00000000-0000")
- && sscanf (header, "%08x-%04x", uid, flags) == 2) {
- g_free (header);
- return *uid;
- }
- g_free (header);
- }
-
- return -1;
+ char *header;
+
+ if (in && (header = header_token_decode(in))) {
+ if (strlen(header) == strlen("00000000-0000")
+ && sscanf(header, "%08x-%04x", uid, flags) == 2) {
+ g_free(header);
+ return *uid;
+ }
+ g_free(header);
+ }
+
+ return -1;
}
static char *
-header_evolution_encode (guint32 uid, guint32 flags)
+header_evolution_encode(guint32 uid, guint32 flags)
{
- return g_strdup_printf ("%08x-%04x", uid, flags & 0xffff);
+ return g_strdup_printf("%08x-%04x", uid, flags & 0xffff);
}
static CamelMessageInfo *
-message_info_new (CamelFolderSummary *s, struct _header_raw *h)
+message_info_new(CamelFolderSummary *s, struct _header_raw *h)
{
CamelMessageInfo *mi;
- mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_new (s, h);
+ mi = ((CamelFolderSummaryClass *) camel_mbox_summary_parent)->message_info_new(s, h);
if (mi) {
const char *xev;
guint32 uid, flags;
- CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi;
+ CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *) mi;
- xev = header_raw_find (&h, "X-Evolution", NULL);
+ xev = header_raw_find(&h, "X-Evolution", NULL);
if (xev && header_evolution_decode(xev, &uid, &flags) != -1) {
- g_free (mi->uid);
- mi->uid = g_strdup_printf ("%u", uid);
+ g_free(mi->uid);
+ mi->uid = g_strdup_printf("%u", uid);
mi->flags = flags;
} else {
/* to indicate it has no xev header? */
mi->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED | CAMEL_MESSAGE_FOLDER_NOXEV;
- mi->uid = g_strdup_printf ("%u", camel_folder_summary_next_uid (s));
+ mi->uid = g_strdup_printf("%u", camel_folder_summary_next_uid(s));
}
mbi->frompos = -1;
}
-
+
return mi;
}
static CamelMessageInfo *
-message_info_new_from_parser (CamelFolderSummary *s, CamelMimeParser *mp)
+message_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser * mp)
{
CamelMessageInfo *mi;
- CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY (s);
+ CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY(s);
- mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_new_from_parser (s, mp);
+ mi = ((CamelFolderSummaryClass *) camel_mbox_summary_parent)->message_info_new_from_parser(s, mp);
if (mi) {
- CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi;
+ CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *) mi;
- mbi->frompos = camel_mime_parser_tell_start_from (mp);
+ mbi->frompos = camel_mime_parser_tell_start_from(mp);
/* do we want to index this message as we add it, as well? */
- if (mbs->index_force
- || (mi->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0
+ if (mbs->index_force || (mi->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0
|| !ibex_contains_name(mbs->index, mi->uid)) {
-
- camel_folder_summary_set_index (s, mbs->index);
+ camel_folder_summary_set_index(s, mbs->index);
} else {
- camel_folder_summary_set_index (s, NULL);
+ camel_folder_summary_set_index(s, NULL);
}
}
-
+
return mi;
}
static CamelMessageInfo *
-message_info_load (CamelFolderSummary *s, FILE *in)
+message_info_load(CamelFolderSummary *s, FILE * in)
{
CamelMessageInfo *mi;
- io (printf ("loading mbox message info\n"));
+ io(printf("loading mbox message info\n"));
- mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_load (s, in);
+ mi = ((CamelFolderSummaryClass *) camel_mbox_summary_parent)->message_info_load(s, in);
if (mi) {
- CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi;
+ CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *) mi;
- camel_folder_summary_decode_uint32 (in, &mbi->frompos);
+ camel_folder_summary_decode_uint32(in, &mbi->frompos);
}
-
+
return mi;
}
static int
-message_info_save (CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi)
+message_info_save(CamelFolderSummary *s, FILE * out, CamelMessageInfo * mi)
{
- CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi;
+ CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *) mi;
- io (printf ("saving mbox message info\n"));
+ io(printf("saving mbox message info\n"));
- ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_save (s, out, mi);
+ ((CamelFolderSummaryClass *) camel_mbox_summary_parent)->message_info_save(s, out, mi);
- return camel_folder_summary_encode_uint32 (out, mbi->frompos);
+ return camel_folder_summary_encode_uint32(out, mbi->frompos);
}
static int
-summary_rebuild (CamelMboxSummary *mbs, off_t offset)
+summary_rebuild(CamelMboxSummary *mbs, off_t offset)
{
- CamelFolderSummary *s = CAMEL_FOLDER_SUMMARY (mbs);
+ CamelFolderSummary *s = CAMEL_FOLDER_SUMMARY(mbs);
CamelMimeParser *mp;
int fd;
int ok = 0;
- fd = open (mbs->folder_path, O_RDONLY);
+ fd = open(mbs->folder_path, O_RDONLY);
if (fd == -1) {
- printf ("%s failed to open: %s", mbs->folder_path, strerror (errno));
+ printf("%s failed to open: %s", mbs->folder_path, strerror(errno));
return -1;
}
-
- mp = camel_mime_parser_new ();
- camel_mime_parser_init_with_fd (mp, fd);
- camel_mime_parser_scan_from (mp, TRUE);
- camel_mime_parser_seek (mp, offset, SEEK_SET);
+
+ mp = camel_mime_parser_new();
+ camel_mime_parser_init_with_fd(mp, fd);
+ camel_mime_parser_scan_from(mp, TRUE);
+ camel_mime_parser_seek(mp, offset, SEEK_SET);
if (offset > 0) {
- if (camel_mime_parser_step (mp, NULL, NULL) == HSCAN_FROM) {
- if (camel_mime_parser_tell_start_from (mp) != offset) {
- g_warning ("The next message didn't start where I expected\nbuilding summary from start");
- camel_mime_parser_drop_step (mp);
+ if (camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM) {
+ if (camel_mime_parser_tell_start_from(mp) != offset) {
+ g_warning
+ ("The next message didn't start where I expected\nbuilding summary from start");
+ camel_mime_parser_drop_step(mp);
offset = 0;
- camel_mime_parser_seek (mp, offset, SEEK_SET);
- camel_folder_summary_clear (CAMEL_FOLDER_SUMMARY (mbs));
+ camel_mime_parser_seek(mp, offset, SEEK_SET);
+ camel_folder_summary_clear(CAMEL_FOLDER_SUMMARY(mbs));
} else {
- camel_mime_parser_unstep (mp);
+ camel_mime_parser_unstep(mp);
}
} else {
- gtk_object_unref (GTK_OBJECT (mp));
+ gtk_object_unref(GTK_OBJECT(mp));
/* end of file - no content? */
return -1;
}
}
- while (camel_mime_parser_step (mp, NULL, NULL) == HSCAN_FROM) {
+ while (camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM) {
CamelMessageInfo *info;
- info = camel_folder_summary_add_from_parser (CAMEL_FOLDER_SUMMARY (mbs), mp);
+ info = camel_folder_summary_add_from_parser(CAMEL_FOLDER_SUMMARY(mbs), mp);
if (info == NULL) {
- printf ("Could not build info from file?\n");
+ printf("Could not build info from file?\n");
ok = -1;
break;
}
- g_assert (camel_mime_parser_step (mp, NULL, NULL) == HSCAN_FROM_END);
+ g_assert(camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM_END);
}
- gtk_object_unref (GTK_OBJECT (mp));
-
+ gtk_object_unref(GTK_OBJECT(mp));
+
/* update the file size/mtime in the summary */
if (ok != -1) {
struct stat st;
- if (stat (mbs->folder_path, &st) == 0) {
+ if (stat(mbs->folder_path, &st) == 0) {
mbs->folder_size = st.st_size;
s->time = st.st_mtime;
}
@@ -346,12 +345,12 @@ summary_rebuild (CamelMboxSummary *mbs, off_t offset)
}
int
-camel_mbox_summary_update (CamelMboxSummary *mbs, off_t offset)
+camel_mbox_summary_update(CamelMboxSummary *mbs, off_t offset)
{
int ret;
mbs->index_force = FALSE;
- ret = summary_rebuild (mbs, offset);
+ ret = summary_rebuild(mbs, offset);
#if 0
#warning "Saving full summary and index after every summarisation is slow ..."
@@ -366,9 +365,9 @@ camel_mbox_summary_update (CamelMboxSummary *mbs, off_t offset)
}
int
-camel_mbox_summary_load (CamelMboxSummary *mbs, int forceindex)
+camel_mbox_summary_load(CamelMboxSummary *mbs, int forceindex)
{
- CamelFolderSummary *s = CAMEL_FOLDER_SUMMARY (mbs);
+ CamelFolderSummary *s = CAMEL_FOLDER_SUMMARY(mbs);
struct stat st;
int ret = 0;
off_t minstart;
@@ -376,15 +375,15 @@ camel_mbox_summary_load (CamelMboxSummary *mbs, int forceindex)
mbs->index_force = forceindex;
/* is the summary out of date? */
- if (stat (mbs->folder_path, &st) == -1) {
- camel_folder_summary_clear (s);
- printf ("Cannot summarise folder: '%s': %s\n", mbs->folder_path, strerror(errno));
+ if (stat(mbs->folder_path, &st) == -1) {
+ camel_folder_summary_clear(s);
+ printf("Cannot summarise folder: '%s': %s\n", mbs->folder_path, strerror(errno));
return -1;
}
- if (forceindex || camel_folder_summary_load (s) == -1) {
- camel_folder_summary_clear (s);
- ret = summary_rebuild (mbs, 0);
+ if (forceindex || camel_folder_summary_load(s) == -1) {
+ camel_folder_summary_clear(s);
+ ret = summary_rebuild(mbs, 0);
} else {
minstart = st.st_size;
#if 0
@@ -392,10 +391,11 @@ camel_mbox_summary_load (CamelMboxSummary *mbs, int forceindex)
/* TODO: For this to work, it has to check that the message is
indexable, and contains content ... maybe it cannot be done
properly? */
- for (i=0;i<camel_folder_summary_count(s);i++) {
+ for (i = 0; i < camel_folder_summary_count(s); i++) {
CamelMessageInfo *mi = camel_folder_summary_index(s, i);
+
if (!ibex_contains_name(mbs->index, mi->uid)) {
- minstart = ((CamelMboxMessageInfo *)mi)->frompos;
+ minstart = ((CamelMboxMessageInfo *) mi)->frompos;
printf("Found unindexed message: %s\n", mi->uid);
break;
}
@@ -405,28 +405,28 @@ camel_mbox_summary_load (CamelMboxSummary *mbs, int forceindex)
if (st.st_size == mbs->folder_size && st.st_mtime == s->time) {
if (minstart < st.st_size) {
/* FIXME: Only clear the messages and reindex from this point forward */
- camel_folder_summary_clear (s);
- ret = summary_rebuild (mbs, 0);
+ camel_folder_summary_clear(s);
+ ret = summary_rebuild(mbs, 0);
}
} else {
if (mbs->folder_size < st.st_size) {
if (minstart < mbs->folder_size) {
/* FIXME: only make it rebuild as necessary */
- camel_folder_summary_clear (s);
- ret = summary_rebuild (mbs, 0);
+ camel_folder_summary_clear(s);
+ ret = summary_rebuild(mbs, 0);
} else {
- ret = summary_rebuild (mbs, mbs->folder_size);
+ ret = summary_rebuild(mbs, mbs->folder_size);
/* If that fails, it might be because a message was changed
* rather than appended... so try again from the beginning.
*/
if (ret == -1) {
- camel_folder_summary_clear (s);
- ret = summary_rebuild (mbs, 0);
+ camel_folder_summary_clear(s);
+ ret = summary_rebuild(mbs, 0);
}
}
} else {
- camel_folder_summary_clear (s);
- ret = summary_rebuild (mbs, 0);
+ camel_folder_summary_clear(s);
+ ret = summary_rebuild(mbs, 0);
}
}
}
@@ -434,53 +434,53 @@ camel_mbox_summary_load (CamelMboxSummary *mbs, int forceindex)
if (ret != -1) {
mbs->folder_size = st.st_size;
s->time = st.st_mtime;
- if (camel_folder_summary_save (s) == -1)
- g_warning("Could not save summary: %s", strerror (errno));
+ if (camel_folder_summary_save(s) == -1)
+ g_warning("Could not save summary: %s", strerror(errno));
if (mbs->index)
- ibex_save (mbs->index);
+ ibex_save(mbs->index);
}
return ret;
}
static int
-header_write (int fd, struct _header_raw *header, char *xevline)
+header_write(int fd, struct _header_raw *header, char *xevline)
{
- struct iovec iv[4];
- int outlen = 0, len;
+ struct iovec iv[4];
+ int outlen = 0, len;
- iv[1].iov_base = ":";
- iv[1].iov_len = 1;
- iv[3].iov_base = "\n";
- iv[3].iov_len = 1;
+ iv[1].iov_base = ":";
+ iv[1].iov_len = 1;
+ iv[3].iov_base = "\n";
+ iv[3].iov_len = 1;
- while (header) {
- if (strcasecmp (header->name, "X-Evolution")) {
+ while (header) {
+ if (strcasecmp(header->name, "X-Evolution")) {
iv[0].iov_base = header->name;
iv[0].iov_len = strlen(header->name);
iv[2].iov_base = header->value;
iv[2].iov_len = strlen(header->value);
-
+
do {
len = writev(fd, iv, 4);
} while (len == -1 && errno == EINTR);
-
+
if (len == -1)
return -1;
outlen += len;
}
- header = header->next;
- }
+ header = header->next;
+ }
- iv[0].iov_base = "X-Evolution: ";
- iv[0].iov_len = strlen (iv[0].iov_base);
- iv[1].iov_base = xevline;
- iv[1].iov_len = strlen (xevline);
- iv[2].iov_base = "\n\n";
- iv[2].iov_len = 2;
+ iv[0].iov_base = "X-Evolution: ";
+ iv[0].iov_len = strlen(iv[0].iov_base);
+ iv[1].iov_base = xevline;
+ iv[1].iov_len = strlen(xevline);
+ iv[2].iov_base = "\n\n";
+ iv[2].iov_len = 2;
do {
- len = writev (fd, iv, 3);
+ len = writev(fd, iv, 3);
} while (len == -1 && errno == EINTR);
if (len == -1)
@@ -488,66 +488,133 @@ header_write (int fd, struct _header_raw *header, char *xevline)
outlen += 1;
- d(printf ("Wrote %d bytes of headers\n", outlen));
+ d(printf("Wrote %d bytes of headers\n", outlen));
- return outlen;
+ return outlen;
}
static int
copy_block(int fromfd, int tofd, off_t start, size_t bytes)
{
- char buffer[4096];
- int written = 0;
+ char buffer[4096];
+ int written = 0;
- d(printf ("writing %d bytes ... ", bytes));
+ d(printf("writing %d bytes ... ", bytes));
if (lseek(fromfd, start, SEEK_SET) != start)
return -1;
- while (bytes > 0) {
- int toread, towrite;
+ while (bytes > 0) {
+ int toread, towrite;
- toread = bytes;
- if (bytes > 4096)
- toread = 4096;
- else
- toread = bytes;
+ toread = bytes;
+ if (bytes > 4096)
+ toread = 4096;
+ else
+ toread = bytes;
do {
- towrite = read (fromfd, buffer, toread);
+ towrite = read(fromfd, buffer, toread);
} while (towrite == -1 && errno == EINTR);
if (towrite == -1)
return -1;
- /* check for 'end of file' */
- if (towrite == 0) {
- d(printf ("end of file?\n"));
- break;
+ /* check for 'end of file' */
+ if (towrite == 0) {
+ d(printf("end of file?\n"));
+ break;
}
do {
- toread = write (tofd, buffer, towrite);
+ toread = write(tofd, buffer, towrite);
} while (toread == -1 && errno == EINTR);
if (toread == -1)
return -1;
- written += toread;
- bytes -= toread;
- }
+ written += toread;
+ bytes -= toread;
+ }
- d(printf ("written %d bytes\n", written));
+ d(printf("written %d bytes\n", written));
- return written;
+ return written;
+}
+
+static char *tz_months[] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+
+static char *tz_days[] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+};
+
+/* tries to build a From line, based on message headers */
+char *
+camel_mbox_summary_build_from(struct _header_raw *header)
+{
+ GString *out = g_string_new("From ");
+ char *ret;
+ const char *tmp;
+ time_t thetime;
+ int offset;
+ struct tm tm;
+
+ tmp = header_raw_find(&header, "Sender", NULL);
+ if (tmp == NULL)
+ tmp = header_raw_find(&header, "From", NULL);
+ if (tmp != NULL) {
+ struct _header_address *addr = header_address_decode(tmp);
+
+ tmp = NULL;
+ if (addr) {
+ if (addr->type == HEADER_ADDRESS_NAME) {
+ g_string_append(out, addr->v.addr);
+ tmp = "";
+ }
+ header_address_unref(addr);
+ }
+ }
+ if (tmp == NULL) {
+ g_string_append(out, "unknown@nodomain.now.au");
+ }
+
+ /* try use the received header to get the date */
+ tmp = header_raw_find(&header, "Received", NULL);
+ if (tmp) {
+ tmp = strrchr(tmp, ';');
+ if (tmp)
+ tmp++;
+ }
+
+ /* if there isn't one, try the Date field */
+ if (tmp == NULL)
+ tmp = header_raw_find(&header, "Date", NULL);
+
+ thetime = header_decode_date(tmp, &offset);
+
+ thetime += ((offset / 100) * (60 * 60)) + (offset % 100) * 60;
+
+ /* a pseudo, but still bogus attempt at thread safing the function */
+ memcpy(&tm, gmtime(&thetime), sizeof(tm));
+
+ g_string_sprintfa(out, " %s %s %d %02d:%02d:%02d %4d\n",
+ tz_days[tm.tm_wday],
+ tz_months[tm.tm_mon], tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_year + 1900);
+
+ ret = out->str;
+ g_string_free(out, FALSE);
+ return ret;
}
int
-camel_mbox_summary_sync (CamelMboxSummary *mbs, gboolean expunge, CamelException *ex)
+camel_mbox_summary_sync(CamelMboxSummary *mbs, gboolean expunge, CamelException *ex)
{
CamelMimeParser *mp = NULL;
int i, count;
CamelMboxMessageInfo *info;
- CamelFolderSummary *s = CAMEL_FOLDER_SUMMARY (mbs);
+ CamelFolderSummary *s = CAMEL_FOLDER_SUMMARY(mbs);
int fd = -1, fdout = -1;
off_t offset = 0;
char *tmpname = NULL;
@@ -557,260 +624,249 @@ camel_mbox_summary_sync (CamelMboxSummary *mbs, gboolean expunge, CamelException
guint32 uid, flags;
int quick = TRUE, work = FALSE;
struct stat st;
+ char *fromline;
/* make sure we're in sync */
- count = camel_folder_summary_count (s);
+ count = camel_folder_summary_count(s);
if (count > 0) {
- CamelMessageInfo *mi = camel_folder_summary_index (s, count - 1);
- camel_mbox_summary_update (mbs, mi->content->endpos);
+ CamelMessageInfo *mi = camel_folder_summary_index(s, count - 1);
+
+ camel_mbox_summary_update(mbs, mi->content->endpos);
} else {
- camel_mbox_summary_update (mbs, 0);
+ camel_mbox_summary_update(mbs, 0);
}
/* check if we have any work to do */
- d(printf ("Performing sync, %d messages in inbox\n", count));
+ d(printf("Performing sync, %d messages in inbox\n", count));
for (i = 0; quick && i < count; i++) {
- info = (CamelMboxMessageInfo *)camel_folder_summary_index (s, i);
- if ((expunge && (info->info.flags & CAMEL_MESSAGE_DELETED)) ||
- (info->info.flags & CAMEL_MESSAGE_FOLDER_NOXEV))
+ info = (CamelMboxMessageInfo *) camel_folder_summary_index(s, i);
+ if ((expunge && (info->info.flags & CAMEL_MESSAGE_DELETED))
+ || (info->info.flags & CAMEL_MESSAGE_FOLDER_NOXEV))
quick = FALSE;
else
work |= (info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0;
}
- d(printf ("Options: %s %s %s\n", expunge ? "expunge" : "", quick ? "quick" : "", work ? "Work" : ""));
+ d(printf("Options: %s %s %s\n", expunge ? "expunge" : "", quick ? "quick" : "", work ? "Work" : ""));
if (quick && !work)
return 0;
- fd = open (mbs->folder_path, O_RDWR);
+ fd = open(mbs->folder_path, O_RDWR);
if (fd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not open summary %s", mbs->folder_path);
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Could not open summary %s", mbs->folder_path);
return -1;
}
- mp = camel_mime_parser_new ();
- camel_mime_parser_scan_from (mp, TRUE);
- camel_mime_parser_init_with_fd (mp, fd);
+ mp = camel_mime_parser_new();
+ camel_mime_parser_scan_from(mp, TRUE);
+ camel_mime_parser_init_with_fd(mp, fd);
if (!quick) {
- tmpname = alloca (strlen (mbs->folder_path) + 5);
- sprintf (tmpname, "%s.tmp", mbs->folder_path);
- d(printf ("Writing tmp file to %s\n", tmpname));
- retry_out:
- fdout = open (tmpname, O_WRONLY | O_CREAT | O_EXCL, 0600);
+ tmpname = alloca(strlen(mbs->folder_path) + 5);
+ sprintf(tmpname, "%s.tmp", mbs->folder_path);
+ d(printf("Writing tmp file to %s\n", tmpname));
+ retry_out:
+ fdout = open(tmpname, O_WRONLY | O_CREAT | O_EXCL, 0600);
if (fdout == -1) {
if (errno == EEXIST)
if (unlink(tmpname) != -1)
goto retry_out;
-
- free (tmpname);
+
+ free(tmpname);
tmpname = NULL;
- g_warning ("Something failed (yo!)");
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Cannot open temporary mailbox: %s", strerror (errno));
+ g_warning("Something failed (yo!)");
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Cannot open temporary mailbox: %s",
+ strerror(errno));
goto error;
}
}
for (i = 0; i < count; i++) {
off_t frompos, bodypos, lastpos;
+
/* This has to be an int, not an off_t, because that's
* what camel_mime_parser_header returns... FIXME.
*/
int xevoffset;
- info = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i);
+ info = (CamelMboxMessageInfo *) camel_folder_summary_index(s, i);
- g_assert (info);
+ g_assert(info);
- d(printf ("Looking at message %s\n", info->info.uid));
+ d(printf("Looking at message %s\n", info->info.uid));
if (expunge && info->info.flags & CAMEL_MESSAGE_DELETED) {
- d(printf ("Deleting %s\n", info->info.uid));
+ d(printf("Deleting %s\n", info->info.uid));
- g_assert (!quick);
+ g_assert(!quick);
offset -= (info->info.content->endpos - info->frompos);
if (mbs->index)
- ibex_unindex (mbs->index, info->info.uid);
- camel_folder_summary_remove (s, (CamelMessageInfo *)info);
+ ibex_unindex(mbs->index, info->info.uid);
+ camel_folder_summary_remove(s, (CamelMessageInfo *) info);
count--;
i--;
info = NULL;
} else if (info->info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV | CAMEL_MESSAGE_FOLDER_FLAGGED)) {
int xevok = FALSE;
- d(printf ("Updating header for %s flags = %08x\n", info->info.uid, info->info.flags));
+ d(printf("Updating header for %s flags = %08x\n", info->info.uid, info->info.flags));
/* find the next message, header parts */
- camel_mime_parser_seek (mp, info->frompos, SEEK_SET);
- if (camel_mime_parser_step (mp, &buffer, &len) != HSCAN_FROM) {
- g_warning ("camel_mime_parser_step failed (1)");
+ camel_mime_parser_seek(mp, info->frompos, SEEK_SET);
+ if (camel_mime_parser_step(mp, &buffer, &len) != HSCAN_FROM) {
+ g_warning("camel_mime_parser_step failed (1)");
goto error;
}
- if (camel_mime_parser_tell_start_from (mp) != info->frompos) {
- g_warning ("Summary/mbox mismatch, aborting sync");
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Summary mismatch, aborting sync");
+ if (camel_mime_parser_tell_start_from(mp) != info->frompos) {
+ g_warning("Summary/mbox mismatch, aborting sync");
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Summary mismatch, aborting sync");
goto error;
}
-
- if (camel_mime_parser_step (mp, &buffer, &len) == HSCAN_FROM_END) {
- g_warning ("camel_mime_parser_step failed (2)");
+
+ if (camel_mime_parser_step(mp, &buffer, &len) == HSCAN_FROM_END) {
+ g_warning("camel_mime_parser_step failed (2)");
goto error;
}
/* Check if the X-Evolution header is valid. */
- xev = camel_mime_parser_header (mp, "X-Evolution", &xevoffset);
- if (xev && header_evolution_decode (xev, &uid, &flags) != -1)
+ xev = camel_mime_parser_header(mp, "X-Evolution", &xevoffset);
+ if (xev && header_evolution_decode(xev, &uid, &flags) != -1)
xevok = TRUE;
- xevnew = header_evolution_encode (strtoul (info->info.uid, NULL, 10), info->info.flags & 0xffff);
+ xevnew = header_evolution_encode(strtoul(info->info.uid, NULL, 10), info->info.flags & 0xffff);
if (quick) {
if (!xevok) {
- g_warning ("The summary told me I had an X-Evolution header, but i dont!");
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Summary mismatch, X-Evolution header missing");
+ g_warning("The summary told me I had an X-Evolution header, but i dont!");
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
+ "Summary mismatch, X-Evolution header missing");
goto error;
}
- buffer = g_strdup_printf ("X-Evolution: %s", xevnew);
- lastpos = lseek (fd, 0, SEEK_CUR);
- lseek (fd, xevoffset, SEEK_SET);
+ buffer = g_strdup_printf("X-Evolution: %s", xevnew);
+ lastpos = lseek(fd, 0, SEEK_CUR);
+ lseek(fd, xevoffset, SEEK_SET);
do {
- len = write (fd, buffer, strlen (buffer));
+ len = write(fd, buffer, strlen(buffer));
} while (len == -1 && errno == EINTR);
- lseek (fd, lastpos, SEEK_SET);
- g_free (buffer);
+ lseek(fd, lastpos, SEEK_SET);
+ g_free(buffer);
if (len == -1) {
- g_warning ("Yahoo! len == -1");
+ g_warning("Yahoo! len == -1");
goto error;
}
} else {
- frompos = lseek (fdout, 0, SEEK_CUR);
- write (fdout, "From -\n", strlen("From -\n"));
- if (header_write (fdout, camel_mime_parser_headers_raw (mp), xevnew) == -1) {
- d(printf ("Error writing to tmp mailbox\n"));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Error writing to temp mailbox: %s",
- strerror (errno));
+ frompos = lseek(fdout, 0, SEEK_CUR);
+ fromline = camel_mbox_summary_build_from(camel_mime_parser_headers_raw(mp));
+ write(fdout, fromline, strlen(fromline));
+ g_free(fromline);
+ if (header_write(fdout, camel_mime_parser_headers_raw(mp), xevnew) == -1) {
+ d(printf("Error writing to tmp mailbox\n"));
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
+ "Error writing to temp mailbox: %s", strerror(errno));
goto error;
}
- bodypos = lseek (fdout, 0, SEEK_CUR);
- d(printf ("pos = %d, endpos = %d, bodypos = %d\n",
- (int) info->info.content->pos,
- (int) info->info.content->endpos,
- (int) info->info.content->bodypos));
- if (copy_block (fd, fdout, info->info.content->bodypos,
- info->info.content->endpos - info->info.content->bodypos) == -1) {
- g_warning ("Cannot copy data to output fd");
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Cannot copy data to output fd: %s",
- strerror (errno));
+ bodypos = lseek(fdout, 0, SEEK_CUR);
+ d(printf("pos = %d, endpos = %d, bodypos = %d\n",
+ (int)info->info.content->pos,
+ (int)info->info.content->endpos,
+ (int)info->info.content->bodypos));
+ if (copy_block(fd, fdout, info->info.content->bodypos,
+ info->info.content->endpos - info->info.content->bodypos) == -1) {
+ g_warning("Cannot copy data to output fd");
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
+ "Cannot copy data to output fd: %s", strerror(errno));
goto error;
}
info->frompos = frompos;
offset = bodypos - info->info.content->bodypos;
}
info->info.flags &= 0xffff;
- g_free (xevnew);
+ g_free(xevnew);
xevnew = NULL;
- camel_mime_parser_drop_step (mp);
- camel_mime_parser_drop_step (mp);
+ camel_mime_parser_drop_step(mp);
+ camel_mime_parser_drop_step(mp);
} else {
if (!quick) {
- if (copy_block (fd, fdout, info->frompos,
- info->info.content->endpos - info->frompos) == -1) {
- g_warning ("Cannot copy data to output fd");
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Cannot copy data to output fd: %s",
- strerror (errno));
+ if (copy_block(fd, fdout, info->frompos, info->info.content->endpos - info->frompos) == -1) {
+ g_warning("Cannot copy data to output fd");
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
+ "Cannot copy data to output fd: %s", strerror(errno));
goto error;
}
/* update from pos here? */
info->frompos += offset;
} else {
- d(printf ("Nothing to do for this message\n"));
+ d(printf("Nothing to do for this message\n"));
}
}
if (!quick && info != NULL && offset != 0) {
- d(printf ("offsetting content: %d\n", (int) offset));
- camel_folder_summary_offset_content (info->info.content, offset);
- d(printf ("pos = %d, endpos = %d, bodypos = %d\n",
- (int) info->info.content->pos,
- (int) info->info.content->endpos,
- (int) info->info.content->bodypos));
+ d(printf("offsetting content: %d\n", (int)offset));
+ camel_folder_summary_offset_content(info->info.content, offset);
+ d(printf("pos = %d, endpos = %d, bodypos = %d\n",
+ (int)info->info.content->pos,
+ (int)info->info.content->endpos,
+ (int)info->info.content->bodypos));
}
}
- d(printf ("Closing folders\n"));
+ d(printf("Closing folders\n"));
- if (close (fd) == -1) {
- g_warning ("Cannot close source folder: %s", strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not close source folder %s: %s",
- mbs->folder_path, strerror (errno));
+ if (close(fd) == -1) {
+ g_warning("Cannot close source folder: %s", strerror(errno));
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Could not close source folder %s: %s",
+ mbs->folder_path, strerror(errno));
goto error;
}
if (!quick) {
- if (close (fdout) == -1) {
- g_warning ("Cannot close tmp folder: %s", strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not close temp folder: %s",
- strerror (errno));
+ if (close(fdout) == -1) {
+ g_warning("Cannot close tmp folder: %s", strerror(errno));
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Could not close temp folder: %s",
+ strerror(errno));
goto error;
}
- if (rename (tmpname, mbs->folder_path) == -1) {
- g_warning ("Cannot rename folder: %s", strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not rename folder: %s",
- strerror (errno));
+ if (rename(tmpname, mbs->folder_path) == -1) {
+ g_warning("Cannot rename folder: %s", strerror(errno));
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Could not rename folder: %s",
+ strerror(errno));
goto error;
}
tmpname = NULL;
if (mbs->index)
- ibex_save (mbs->index);
+ ibex_save(mbs->index);
}
- if (stat (mbs->folder_path, &st) == -1) {
- g_warning ("Hmm... stat(mbs->folder_path, &st) == -1");
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Unknown error: %s",
- strerror (errno));
+ if (stat(mbs->folder_path, &st) == -1) {
+ g_warning("Hmm... stat(mbs->folder_path, &st) == -1");
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Unknown error: %s", strerror(errno));
goto error;
}
- camel_folder_summary_touch (s);
+ camel_folder_summary_touch(s);
s->time = st.st_mtime;
mbs->folder_size = st.st_size;
- camel_folder_summary_save (s);
+ camel_folder_summary_save(s);
+
+ gtk_object_unref(GTK_OBJECT(mp));
- gtk_object_unref (GTK_OBJECT (mp));
-
return 0;
- error:
+ error:
if (fd != -1)
- close (fd);
-
+ close(fd);
+
if (fdout != -1)
- close (fdout);
-
- g_free (xevnew);
-
+ close(fdout);
+
+ g_free(xevnew);
+
if (tmpname)
- unlink (tmpname);
+ unlink(tmpname);
if (mp)
- gtk_object_unref (GTK_OBJECT (mp));
+ gtk_object_unref(GTK_OBJECT(mp));
return -1;
}
-
-
-
-
-
diff --git a/camel/providers/mbox/camel-mbox-summary.h b/camel/providers/mbox/camel-mbox-summary.h
index fb31002320..b4e59fa343 100644
--- a/camel/providers/mbox/camel-mbox-summary.h
+++ b/camel/providers/mbox/camel-mbox-summary.h
@@ -74,6 +74,8 @@ int camel_mbox_summary_load(CamelMboxSummary *mbs, int forceindex);
int camel_mbox_summary_update(CamelMboxSummary *mbs, off_t offset);
/* perform a folder sync or expunge, if needed */
int camel_mbox_summary_sync (CamelMboxSummary *mbs, gboolean expunge, CamelException *ex);
+/* generate a From line from headers */
+char *camel_mbox_summary_build_from(struct _header_raw *header);
#endif /* ! _CAMEL_MBOX_SUMMARY_H */
diff --git a/camel/providers/mh/camel-mh-folder.c b/camel/providers/mh/camel-mh-folder.c
index 6f85fb756a..b10c8b1a65 100644
--- a/camel/providers/mh/camel-mh-folder.c
+++ b/camel/providers/mh/camel-mh-folder.c
@@ -60,7 +60,7 @@ static void mh_init(CamelFolder * folder, CamelStore * parent_store,
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, guint32 flags, CamelException * ex);
+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_summary(CamelFolder * folder);
@@ -71,6 +71,7 @@ static void mh_expunge(CamelFolder * folder, CamelException * ex);
static const CamelMessageInfo *mh_get_message_info(CamelFolder * folder, const char *uid);
static GPtrArray *mh_search_by_expression(CamelFolder * folder, const char *expression, CamelException * ex);
+static void mh_search_free(CamelFolder *folder, GPtrArray *result);
static guint32 mh_get_message_flags(CamelFolder * folder, const char *uid);
static void mh_set_message_flags(CamelFolder * folder, const char *uid, guint32 flags, guint32 set);
@@ -105,6 +106,7 @@ static void camel_mh_folder_class_init(CamelMhFolderClass * camel_mh_folder_clas
camel_folder_class->get_message = mh_get_message;
camel_folder_class->search_by_expression = mh_search_by_expression;
+ camel_folder_class->search_free = mh_search_free;
camel_folder_class->get_message_info = mh_get_message_info;
@@ -268,12 +270,13 @@ static gint mh_get_unread_message_count(CamelFolder * folder)
return count;
}
-static void mh_append_message(CamelFolder * folder, CamelMimeMessage * message, guint32 flags, CamelException * ex)
+static void mh_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex)
{
CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
CamelStream *output_stream = NULL;
char *name = NULL;
char *uid = NULL;
+ CamelMessageInfo *newinfo;
/* FIXME: probably needs additional locking */
@@ -298,6 +301,21 @@ static void mh_append_message(CamelFolder * folder, CamelMimeMessage * message,
/* index/summarise the message. Yes this re-reads it, its just simpler */
camel_mh_summary_add(mh_folder->summary, uid, TRUE);
+ if (info
+ && (newinfo = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mh_folder->summary), uid))) {
+ CamelFlag *flag = info->user_flags;
+ CamelTag *tag = info->user_tags;
+
+ newinfo->flags = info->flags;
+ while (flag) {
+ camel_flag_set(&newinfo->user_flags, flag->name, TRUE);
+ flag = flag->next;
+ }
+ while (tag) {
+ camel_tag_set(&newinfo->user_tags, tag->name, tag->value);
+ tag = tag->next;
+ }
+ }
gtk_signal_emit_by_name(GTK_OBJECT(folder), "folder_changed", 0);
g_free(name);
g_free(uid);
@@ -431,6 +449,13 @@ static GPtrArray *mh_search_by_expression(CamelFolder * folder, const char *expr
return camel_folder_search_execute_expression(mh_folder->search, expression, ex);
}
+static void mh_search_free(CamelFolder *folder, GPtrArray *result)
+{
+ CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder);
+
+ camel_folder_search_free_result(mh_folder->search, result);
+}
+
static guint32 mh_get_message_flags(CamelFolder * folder, const char *uid)
{
CamelMessageInfo *info;
diff --git a/camel/providers/mh/camel-mh-store.c b/camel/providers/mh/camel-mh-store.c
index 5ab4bcc59d..42f3b474f6 100644
--- a/camel/providers/mh/camel-mh-store.c
+++ b/camel/providers/mh/camel-mh-store.c
@@ -111,8 +111,6 @@ static CamelFolder *get_folder(CamelStore * store, const char *folder_name, gboo
printf("getting folder: %s\n", name);
if (stat(name, &st) == -1) {
- int fd;
-
printf("doesn't exist ...\n");
if (errno != ENOENT) {
diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c
index 2676b34ba0..18eb49bc98 100644
--- a/camel/providers/vee/camel-vee-folder.c
+++ b/camel/providers/vee/camel-vee-folder.c
@@ -385,9 +385,7 @@ vee_search_by_expression(CamelFolder *folder, const char *expression, CamelExcep
char *uid = matches->pdata[i];
g_ptr_array_add(result, g_strdup_printf("%p:%s", f, uid));
}
- g_ptr_array_add (matches, NULL);
- g_strfreev((char **)matches->pdata);
- g_ptr_array_free(matches, FALSE);
+ camel_folder_search_free(f, matches);
node = g_list_next(node);
}
return result;