aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/mbox
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2000-11-02 11:35:04 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-11-02 11:35:04 +0800
commitf351369e5127337eb95185ac764b6744faf4b87f (patch)
tree57654b3a2d65743b8670b2f583f15639a368616a /camel/providers/mbox
parent24e7b7d5fcfe1d98a912570c554b74ca1a9f0f64 (diff)
downloadgsoc2013-evolution-f351369e5127337eb95185ac764b6744faf4b87f.tar
gsoc2013-evolution-f351369e5127337eb95185ac764b6744faf4b87f.tar.gz
gsoc2013-evolution-f351369e5127337eb95185ac764b6744faf4b87f.tar.bz2
gsoc2013-evolution-f351369e5127337eb95185ac764b6744faf4b87f.tar.lz
gsoc2013-evolution-f351369e5127337eb95185ac764b6744faf4b87f.tar.xz
gsoc2013-evolution-f351369e5127337eb95185ac764b6744faf4b87f.tar.zst
gsoc2013-evolution-f351369e5127337eb95185ac764b6744faf4b87f.zip
Merged in camel-incremental-branch.
2000-11-02 Not Zed <NotZed@HelixCode.com> * Merged in camel-incremental-branch. svn path=/trunk/; revision=6336
Diffstat (limited to 'camel/providers/mbox')
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c25
-rw-r--r--camel/providers/mbox/camel-mbox-folder.h1
-rw-r--r--camel/providers/mbox/camel-mbox-summary.c33
-rw-r--r--camel/providers/mbox/camel-mbox-summary.h5
4 files changed, 46 insertions, 18 deletions
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index b7d97ca56b..3b1f0a5030 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -149,6 +149,7 @@ mbox_finalize(CamelObject * object)
g_free(mbox_folder->folder_dir_path);
g_free(mbox_folder->index_file_path);
+ camel_folder_change_info_free(mbox_folder->changes);
}
CamelType camel_mbox_folder_get_type(void)
@@ -195,6 +196,8 @@ camel_mbox_folder_new(CamelStore *parent_store, const char *full_name, guint32 f
mbox_folder->folder_dir_path = g_strdup_printf("%s/%s.sdb", root_dir_path, full_name);
mbox_folder->index_file_path = g_strdup_printf("%s/%s.ibex", root_dir_path, full_name);
+ mbox_folder->changes = camel_folder_change_info_new();
+
/* if we have no index file, force it */
forceindex = stat(mbox_folder->index_file_path, &st) == -1;
if (flags & CAMEL_STORE_FOLDER_BODY_INDEX) {
@@ -232,8 +235,11 @@ mbox_sync(CamelFolder *folder, gboolean expunge, CamelException *ex)
if (expunge)
mbox_expunge(folder, ex);
- else
- camel_mbox_summary_sync(mbox_folder->summary, FALSE, ex);
+ else {
+ camel_mbox_summary_sync(mbox_folder->summary, FALSE, mbox_folder->changes, ex);
+ camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", mbox_folder->changes);
+ camel_folder_change_info_clear(mbox_folder->changes);
+ }
/* save index */
if (mbox_folder->index)
@@ -245,12 +251,11 @@ mbox_sync(CamelFolder *folder, gboolean expunge, CamelException *ex)
static void
mbox_expunge(CamelFolder *folder, CamelException *ex)
{
- CamelMboxFolder *mbox = CAMEL_MBOX_FOLDER(folder);
-
- camel_mbox_summary_sync(mbox->summary, TRUE, ex);
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- /* TODO: check it actually changed */
- camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", GINT_TO_POINTER(0));
+ camel_mbox_summary_sync(mbox_folder->summary, TRUE, mbox_folder->changes, ex);
+ camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", mbox_folder->changes);
+ camel_folder_change_info_clear(mbox_folder->changes);
}
static gint
@@ -352,7 +357,7 @@ mbox_append_message(CamelFolder *folder, CamelMimeMessage * message, const Camel
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) {
+ if (camel_mbox_summary_update(mbox_folder->summary, seek, mbox_folder->changes) == 0) {
char uidstr[16];
sprintf(uidstr, "%u", uid);
@@ -372,7 +377,8 @@ mbox_append_message(CamelFolder *folder, CamelMimeMessage * message, const Camel
tag = tag->next;
}
}
- camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", GINT_TO_POINTER(0));
+ camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", mbox_folder->changes);
+ camel_folder_change_info_clear(mbox_folder->changes);
}
return;
@@ -469,6 +475,7 @@ mbox_get_message(CamelFolder *folder, const gchar * uid, CamelException *ex)
}
if (camel_mime_parser_tell_start_from(parser) != info->frompos) {
+ /* TODO: This should probably perform a re-sync/etc, and try again? */
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));
diff --git a/camel/providers/mbox/camel-mbox-folder.h b/camel/providers/mbox/camel-mbox-folder.h
index d6e8b0682c..73f51a6d85 100644
--- a/camel/providers/mbox/camel-mbox-folder.h
+++ b/camel/providers/mbox/camel-mbox-folder.h
@@ -56,6 +56,7 @@ typedef struct {
ibex *index; /* index for this folder */
CamelMboxSummary *summary;
CamelFolderSearch *search; /* used to run searches, we just use the real thing (tm) */
+ CamelFolderChangeInfo *changes; /* used to store changes to the folder during processing */
} CamelMboxFolder;
diff --git a/camel/providers/mbox/camel-mbox-summary.c b/camel/providers/mbox/camel-mbox-summary.c
index 93e634084a..8856d37ee8 100644
--- a/camel/providers/mbox/camel-mbox-summary.c
+++ b/camel/providers/mbox/camel-mbox-summary.c
@@ -338,13 +338,29 @@ 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, CamelFolderChangeInfo *changeinfo)
{
- int ret;
+ int ret, i, count;
+ CamelFolderSummary *s = (CamelFolderSummary *)mbs;
+ /* we use the diff function of the change_info to build the update list. */
+ for (i = 0; i < camel_folder_summary_count(s); i++) {
+ CamelMessageInfo *mi = camel_folder_summary_index(s, i);
+
+ camel_folder_change_info_add_source(changeinfo, mi->uid);
+ }
+
+ /* do the actual work */
mbs->index_force = FALSE;
ret = summary_rebuild(mbs, offset);
+ count = camel_folder_summary_count(s);
+ for (i = 0; i < count; i++) {
+ CamelMessageInfo *mi = camel_folder_summary_index(s, i);
+ camel_folder_change_info_add_update(changeinfo, mi->uid);
+ }
+ camel_folder_change_info_build_diff(changeinfo);
+
#if 0
#warning "Saving full summary and index after every summarisation is slow ..."
if (ret != -1) {
@@ -590,7 +606,8 @@ camel_mbox_summary_build_from(struct _header_raw *header)
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));
+ /*memcpy(&tm, gmtime(&thetime), sizeof(tm));*/
+ gmtime_r(&thetime, &tm);
g_string_sprintfa(out, " %s %s %d %02d:%02d:%02d %4d\n",
tz_days[tm.tm_wday],
@@ -602,7 +619,7 @@ camel_mbox_summary_build_from(struct _header_raw *header)
}
int
-camel_mbox_summary_sync(CamelMboxSummary *mbs, gboolean expunge, CamelException *ex)
+camel_mbox_summary_sync(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex)
{
CamelMimeParser *mp = NULL;
int i, count;
@@ -619,13 +636,13 @@ camel_mbox_summary_sync(CamelMboxSummary *mbs, gboolean expunge, CamelException
struct stat st;
char *fromline;
- /* make sure we're in sync */
+ /* make sure we're in sync, after this point we at least have a complete list of id'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);
+ camel_mbox_summary_update(mbs, mi->content->endpos, changeinfo);
} else {
- camel_mbox_summary_update(mbs, 0);
+ camel_mbox_summary_update(mbs, 0, changeinfo);
}
/* check if we have any work to do */
@@ -693,6 +710,8 @@ camel_mbox_summary_sync(CamelMboxSummary *mbs, gboolean expunge, CamelException
offset -= (info->info.content->endpos - info->frompos);
if (mbs->index)
ibex_unindex(mbs->index, info->info.uid);
+ /* remove it from teh change list */
+ camel_folder_change_info_remove_uid(changeinfo, info->info.uid);
camel_folder_summary_remove(s, (CamelMessageInfo *)info);
count--;
i--;
diff --git a/camel/providers/mbox/camel-mbox-summary.h b/camel/providers/mbox/camel-mbox-summary.h
index 2462b72078..f90acc4f35 100644
--- a/camel/providers/mbox/camel-mbox-summary.h
+++ b/camel/providers/mbox/camel-mbox-summary.h
@@ -23,6 +23,7 @@
#define _CAMEL_MBOX_SUMMARY_H
#include <camel/camel-folder-summary.h>
+#include <camel/camel-folder.h>
#include <camel/camel-exception.h>
#include <libibex/ibex.h>
@@ -70,9 +71,9 @@ CamelMboxSummary *camel_mbox_summary_new (const char *filename, const char
/* load/check the summary */
int camel_mbox_summary_load(CamelMboxSummary *mbs, int forceindex);
/* incremental update */
-int camel_mbox_summary_update(CamelMboxSummary *mbs, off_t offset);
+int camel_mbox_summary_update(CamelMboxSummary *mbs, off_t offset, CamelFolderChangeInfo *changeinfo);
/* perform a folder sync or expunge, if needed */
-int camel_mbox_summary_sync (CamelMboxSummary *mbs, gboolean expunge, CamelException *ex);
+int camel_mbox_summary_sync (CamelMboxSummary *mbs, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
/* generate a From line from headers */
char *camel_mbox_summary_build_from(struct _header_raw *header);