aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-07-10 06:40:49 +0800
committerDan Winship <danw@src.gnome.org>2000-07-10 06:40:49 +0800
commit90d51074c9c7c5284e3ff3e0a0eb4b5f5d96761f (patch)
treeab290885dfa6763006ef2480643e918725810448
parentb90d829757ffe516f8853ddd462f64220cc46b07 (diff)
downloadgsoc2013-evolution-90d51074c9c7c5284e3ff3e0a0eb4b5f5d96761f.tar
gsoc2013-evolution-90d51074c9c7c5284e3ff3e0a0eb4b5f5d96761f.tar.gz
gsoc2013-evolution-90d51074c9c7c5284e3ff3e0a0eb4b5f5d96761f.tar.bz2
gsoc2013-evolution-90d51074c9c7c5284e3ff3e0a0eb4b5f5d96761f.tar.lz
gsoc2013-evolution-90d51074c9c7c5284e3ff3e0a0eb4b5f5d96761f.tar.xz
gsoc2013-evolution-90d51074c9c7c5284e3ff3e0a0eb4b5f5d96761f.tar.zst
gsoc2013-evolution-90d51074c9c7c5284e3ff3e0a0eb4b5f5d96761f.zip
New function to copy a header_references structure.
* camel-mime-utils.c (header_references_dup): New function to copy a header_references structure. * camel-folder-summary.c (camel_message_info_dup_to): New function to (deep) copy the data from one CamelMessageInfo into another. (camel_message_info_free): And free the data. * providers/vee/camel-vee-folder.c (vee_sync): Implement. (empty). (vee_search_by_expression): belatedly update for camel_folder_search change. (vee_folder_build): belatedly update for camel_folder_search change. Use camel_message_info_dup_to and camel_message_info_free (in particular, so that we get message_id and references info so vfolders can be threaded). (vee_folder_build_folder): Ditto. svn path=/trunk/; revision=4024
-rw-r--r--camel/ChangeLog18
-rw-r--r--camel/camel-folder-summary.c71
-rw-r--r--camel/camel-folder-summary.h4
-rw-r--r--camel/camel-mime-utils.c17
-rw-r--r--camel/camel-mime-utils.h1
-rw-r--r--camel/providers/vee/camel-vee-folder.c115
6 files changed, 145 insertions, 81 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index fc221f7b8d..7802970b25 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,21 @@
+2000-07-09 Dan Winship <danw@helixcode.com>
+
+ * camel-mime-utils.c (header_references_dup): New function to copy
+ a header_references structure.
+
+ * camel-folder-summary.c (camel_message_info_dup_to): New function
+ to (deep) copy the data from one CamelMessageInfo into another.
+ (camel_message_info_free): And free the data.
+
+ * providers/vee/camel-vee-folder.c (vee_sync): Implement. (empty).
+ (vee_search_by_expression): belatedly update for
+ camel_folder_search change.
+ (vee_folder_build): belatedly update for camel_folder_search
+ change. Use camel_message_info_dup_to and camel_message_info_free
+ (in particular, so that we get message_id and references info so
+ vfolders can be threaded).
+ (vee_folder_build_folder): Ditto.
+
2000-07-08 Jeffrey Stedfast <fejj@helixcode.com>
* providers/nntp/camel-nntp-folder.c:
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 1558616653..73de29986a 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -1054,15 +1054,7 @@ message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi)
static void
message_info_free(CamelFolderSummary *s, CamelMessageInfo *mi)
{
- g_free(mi->uid);
- g_free(mi->subject);
- g_free(mi->from);
- g_free(mi->to);
- g_free(mi->cc);
- g_free(mi->message_id);
- header_references_list_clear(&mi->references);
- camel_flag_list_free(&mi->user_flags);
- g_free(mi);
+ camel_message_info_free(mi);
}
static CamelMessageContentInfo *
@@ -1357,6 +1349,67 @@ camel_flag_list_free(CamelFlag **list)
*list = NULL;
}
+/**
+ * camel_message_info_dup_to:
+ * @from: source message info
+ * @to: destination message info
+ *
+ * Duplicates the contents of one CamelMessageInfo structure into another.
+ * (The destination is assumed to be empty: its contents are not freed.)
+ * The slightly odd interface is to allow this to be used to initialize
+ * "subclasses" of CamelMessageInfo.
+ **/
+void
+camel_message_info_dup_to(const CamelMessageInfo *from, CamelMessageInfo *to)
+{
+ CamelFlag *flag;
+
+ /* Copy numbers */
+ to->flags = from->flags;
+ to->size = from->size;
+ to->date_sent = from->date_sent;
+ to->date_received = from->date_received;
+
+ /* Copy strings */
+ to->subject = g_strdup(from->subject);
+ to->from = g_strdup(from->from);
+ to->to = g_strdup(from->to);
+ to->cc = g_strdup(from->cc);
+ to->uid = g_strdup(from->uid);
+ to->message_id = g_strdup(from->message_id);
+
+ /* Copy structures */
+ to->references = header_references_dup(from->references);
+ flag = from->user_flags;
+ while (flag) {
+ camel_flag_set(&to->user_flags, flag->name, TRUE);
+ flag = flag->next;
+ }
+
+ /* FIXME some day */
+ to->content = NULL;
+}
+
+/**
+ * camel_message_info_free:
+ * @mi: the message info
+ *
+ * Frees a CamelMessageInfo and its contents.
+ **/
+void
+camel_message_info_free(CamelMessageInfo *mi)
+{
+ g_free(mi->uid);
+ g_free(mi->subject);
+ g_free(mi->from);
+ g_free(mi->to);
+ g_free(mi->cc);
+ g_free(mi->message_id);
+ header_references_list_clear(&mi->references);
+ camel_flag_list_free(&mi->user_flags);
+ /* FIXME: content info? */
+ g_free(mi);
+}
#if 0
static void
diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h
index d7f20962c4..c173a6080b 100644
--- a/camel/camel-folder-summary.h
+++ b/camel/camel-folder-summary.h
@@ -218,4 +218,8 @@ 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 info utils */
+void camel_message_info_dup_to(const CamelMessageInfo *from, CamelMessageInfo *to);
+void camel_message_info_free(CamelMessageInfo *mi);
+
#endif /* ! _CAMEL_FOLDER_SUMMARY_H */
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index af9c9a7972..dbf4e4bfc3 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -1692,7 +1692,7 @@ header_references_list_clear(struct _header_references **list)
struct _header_references *
header_references_decode(const char *in)
{
- const char *inptr = in, *intmp;
+ const char *inptr = in;
struct _header_references *head = NULL, *node;
char *id, *word;
@@ -1721,6 +1721,21 @@ header_references_decode(const char *in)
return head;
}
+struct _header_references *
+header_references_dup(const struct _header_references *list)
+{
+ struct _header_references *new = NULL, *tmp;
+
+ while (list) {
+ tmp = g_new(struct _header_references, 1);
+ tmp->next = new;
+ tmp->id = g_strdup(list->id);
+ new = tmp;
+ list = list->next;
+ }
+ return new;
+}
+
struct _header_address *
header_mailbox_decode(const char *in)
{
diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h
index 90ac722834..4d8d6bb9ea 100644
--- a/camel/camel-mime-utils.h
+++ b/camel/camel-mime-utils.h
@@ -150,6 +150,7 @@ struct _header_references *header_references_decode(const char *in);
void header_references_list_clear(struct _header_references **list);
void header_references_list_append_asis(struct _header_references **list, char *ref);
int header_references_list_size(struct _header_references **list);
+struct _header_references *header_references_dup(const struct _header_references *list);
/* decode the mime-type header */
void header_mime_decode(const char *in, int *maj, int *min);
diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c
index 9df922c832..745e9a78ea 100644
--- a/camel/providers/vee/camel-vee-folder.c
+++ b/camel/providers/vee/camel-vee-folder.c
@@ -42,6 +42,7 @@ static void vee_init (CamelFolder *folder, CamelStore *parent_store,
CamelFolder *parent_folder, const gchar *name,
gchar *separator, gboolean path_begins_with_sep,
CamelException *ex);
+static void vee_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex);
GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex);
@@ -51,7 +52,7 @@ static gint vee_get_message_count (CamelFolder *folder, CamelException *ex);
static CamelMimeMessage *vee_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
static const CamelMessageInfo *vee_get_message_info (CamelFolder *folder, const char *uid);
-static GList *vee_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex);
+static GPtrArray *vee_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex);
static guint32 vee_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex);
static void vee_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set, CamelException *ex);
@@ -107,6 +108,7 @@ camel_vee_folder_class_init (CamelVeeFolderClass *klass)
printf("vfolder class init\n");
folder_class->init = vee_init;
+ folder_class->sync = vee_sync;
folder_class->get_uids = vee_get_uids;
folder_class->get_summary = vee_get_summary;
@@ -277,6 +279,12 @@ static void vee_init (CamelFolder *folder, CamelStore *parent_store,
vee_folder_build(vf, ex);
}
+static void
+vee_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+{
+ ;
+}
+
static gint vee_get_message_count (CamelFolder *folder, CamelException *ex)
{
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
@@ -350,10 +358,11 @@ static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex)
return result;
}
-static GList *
+static GPtrArray *
vee_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex)
{
- GList *result = NULL, *node;
+ GList *node;
+ GPtrArray *matches, *result;
char *expr;
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
@@ -362,15 +371,15 @@ vee_search_by_expression(CamelFolder *folder, const char *expression, CamelExcep
node = p->folders;
while (node) {
CamelFolder *f = node->data;
- GList *matches, *match;
+ int i;
+
matches = camel_folder_search_by_expression(f, vf->expression, ex);
- match = matches;
- while (match) {
- char *uid = match->data;
- result = g_list_prepend(result, g_strdup_printf("%p:%s", f, uid));
- match = g_list_next(match);
+ for (i = 0; i < matches->len; i++) {
+ char *uid = matches->pdata[i];
+ g_ptr_array_add(result, g_strdup_printf("%p:%s", f, uid));
}
- g_list_free(matches);
+ g_strfreev((char **)matches->pdata);
+ g_ptr_array_free(matches, FALSE);
node = g_list_next(node);
}
return result;
@@ -448,13 +457,8 @@ vee_folder_build(CamelVeeFolder *vf, CamelException *ex)
int i;
for (i=0;i<vf->messages->len;i++) {
- CamelVeeMessageInfo *mi = g_ptr_array_index(vf->messages, i);
- g_free(mi->info.subject);
- g_free(mi->info.to);
- g_free(mi->info.from);
- g_free(mi->info.uid);
- camel_flag_list_free(&mi->info.user_flags);
- g_free(mi);
+ CamelMessageInfo *mi = g_ptr_array_index(vf->messages, i);
+ camel_message_info_free(mi);
}
}
@@ -465,43 +469,32 @@ vee_folder_build(CamelVeeFolder *vf, CamelException *ex)
node = p->folders;
while (node) {
- GList *matches, *match;
+ GPtrArray *matches;
CamelFolder *f = node->data;
CamelVeeMessageInfo *mi;
const CamelMessageInfo *info;
CamelFlag *flag;
+ int i;
printf("searching folder: (%s)%s\n",
gtk_type_name(((GtkObject *)f)->klass->type),
camel_folder_get_full_name(f));
matches = camel_folder_search_by_expression(f, vf->expression, ex);
- match = matches;
- while (match) {
- info = camel_folder_get_message_info(f, match->data);
+ for (i = 0; i < matches->len; i++) {
+ info = camel_folder_get_message_info(f, matches->pdata[i]);
if (info) {
mi = g_malloc0(sizeof(*mi));
- mi->info.subject = g_strdup(info->subject);
- mi->info.to = g_strdup(info->to);
- mi->info.from = g_strdup(info->from);
+ camel_message_info_dup_to(info, (CamelMessageInfo *)mi);
+ g_free (mi->info.uid);
mi->info.uid = g_strdup_printf("%p:%s", f, info->uid);
- mi->info.flags = info->flags;
- mi->info.size = info->size;
- mi->info.date_sent = info->date_sent;
- mi->info.date_received = info->date_received;
- flag = info->user_flags;
- while (flag) {
- camel_flag_set(&mi->info.user_flags, flag->name, TRUE);
- flag = flag->next;
- }
- mi->info.content = NULL;
mi->folder = f;
g_ptr_array_add(messages, mi);
g_hash_table_insert(messages_uid, mi->info.uid, mi);
}
- match = g_list_next(match);
}
- g_list_free(matches);
+ g_strfreev((char **)matches->pdata);
+ g_ptr_array_free(matches, FALSE);
node = g_list_next(node);
}
@@ -518,7 +511,7 @@ vee_folder_build(CamelVeeFolder *vf, CamelException *ex)
static void
vee_folder_build_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
{
- GList *matches, *match;
+ GPtrArray *matches;
CamelFolder *f = source;
CamelVeeMessageInfo *mi;
const CamelMessageInfo *info;
@@ -526,24 +519,16 @@ vee_folder_build_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException
GPtrArray *messages;
GHashTable *messages_uid;
+ int i;
- {
- int i;
+ for (i=0;i<vf->messages->len;i++) {
+ CamelVeeMessageInfo *mi = g_ptr_array_index(vf->messages, i);
+ if (mi->folder == source) {
+ g_hash_table_remove(vf->messages_uid, mi->info.uid);
+ g_ptr_array_remove_index_fast(vf->messages, i);
- for (i=0;i<vf->messages->len;i++) {
- CamelVeeMessageInfo *mi = g_ptr_array_index(vf->messages, i);
- if (mi->folder == source) {
- g_hash_table_remove(vf->messages_uid, mi->info.uid);
- g_ptr_array_remove_index_fast(vf->messages, i);
-
- g_free(mi->info.subject);
- g_free(mi->info.to);
- g_free(mi->info.from);
- g_free(mi->info.uid);
- camel_flag_list_free(&mi->info.user_flags);
- g_free(mi);
- i--;
- }
+ camel_message_info_free((CamelMessageInfo *)mi);
+ i--;
}
}
@@ -551,32 +536,20 @@ vee_folder_build_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException
messages_uid = vf->messages_uid;
matches = camel_folder_search_by_expression(f, vf->expression, ex);
- match = matches;
- while (match) {
- info = camel_folder_get_message_info(f, match->data);
+ for (i = 0; i < matches->len; i++) {
+ info = camel_folder_get_message_info(f, matches->pdata[i]);
if (info) {
mi = g_malloc0(sizeof(*mi));
- mi->info.subject = g_strdup(info->subject);
- mi->info.to = g_strdup(info->to);
- mi->info.from = g_strdup(info->from);
+ camel_message_info_dup_to(info, (CamelMessageInfo*)mi);
+ g_free (mi->info.uid);
mi->info.uid = g_strdup_printf("%p:%s", f, info->uid);
- mi->info.flags = info->flags;
- mi->info.size = info->size;
- mi->info.date_sent = info->date_sent;
- mi->info.date_received = info->date_received;
- flag = info->user_flags;
- while (flag) {
- camel_flag_set(&mi->info.user_flags, flag->name, TRUE);
- flag = flag->next;
- }
- mi->info.content = NULL;
mi->folder = f;
g_ptr_array_add(messages, mi);
g_hash_table_insert(messages_uid, mi->info.uid, mi);
}
- match = g_list_next(match);
}
- g_list_free(matches);
+ g_strfreev((char **)matches->pdata);
+ g_ptr_array_free(matches, FALSE);
}