diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-11-02 11:35:04 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-11-02 11:35:04 +0800 |
commit | f351369e5127337eb95185ac764b6744faf4b87f (patch) | |
tree | 57654b3a2d65743b8670b2f583f15639a368616a /camel/providers | |
parent | 24e7b7d5fcfe1d98a912570c554b74ca1a9f0f64 (diff) | |
download | gsoc2013-evolution-f351369e5127337eb95185ac764b6744faf4b87f.tar.gz 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')
-rw-r--r-- | camel/providers/mbox/camel-mbox-folder.c | 25 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-folder.h | 1 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-summary.c | 33 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-summary.h | 5 | ||||
-rw-r--r-- | camel/providers/mh/camel-mh-folder.c | 22 | ||||
-rw-r--r-- | camel/providers/mh/camel-mh-folder.h | 1 | ||||
-rw-r--r-- | camel/providers/mh/camel-mh-summary.c | 5 | ||||
-rw-r--r-- | camel/providers/mh/camel-mh-summary.h | 3 |
8 files changed, 66 insertions, 29 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); diff --git a/camel/providers/mh/camel-mh-folder.c b/camel/providers/mh/camel-mh-folder.c index 5b5c6688d7..a56de4a9c1 100644 --- a/camel/providers/mh/camel-mh-folder.c +++ b/camel/providers/mh/camel-mh-folder.c @@ -125,6 +125,7 @@ static void mh_init(gpointer object, gpointer klass) mh_folder->summary = NULL; mh_folder->search = NULL; + mh_folder->changes = camel_folder_change_info_new(); } static void mh_finalize(CamelObject * object) @@ -138,6 +139,7 @@ static void mh_finalize(CamelObject * object) g_free(mh_folder->summary_file_path); g_free(mh_folder->folder_dir_path); g_free(mh_folder->index_file_path); + camel_folder_change_info_free(mh_folder->changes); } CamelType camel_mh_folder_get_type(void) @@ -222,8 +224,11 @@ static void mh_sync(CamelFolder * folder, gboolean expunge, CamelException * ex) if (expunge) mh_expunge(folder, ex); - else - camel_mh_summary_sync(mh_folder->summary, FALSE, ex); + else { + camel_mh_summary_sync(mh_folder->summary, FALSE, mh_folder->changes, ex); + camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", mh_folder->changes); + camel_folder_change_info_clear(mh_folder->changes); + } /* save index */ if (mh_folder->index) @@ -234,12 +239,11 @@ static void mh_sync(CamelFolder * folder, gboolean expunge, CamelException * ex) static void mh_expunge(CamelFolder * folder, CamelException * ex) { - CamelMhFolder *mh = CAMEL_MH_FOLDER(folder); - - camel_mh_summary_sync(mh->summary, TRUE, ex); + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); - /* TODO: check it actually changed */ - camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", GINT_TO_POINTER (0)); + camel_mh_summary_sync(mh_folder->summary, TRUE, mh_folder->changes, ex); + camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", mh_folder->changes); + camel_folder_change_info_clear(mh_folder->changes); } static gint mh_get_message_count(CamelFolder * folder) @@ -319,7 +323,9 @@ static void mh_append_message(CamelFolder * folder, CamelMimeMessage * message, } } - camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", GPOINTER_TO_INT (0)); + camel_folder_change_info_add_uid(mh_folder->changes, uid); + camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", mh_folder->changes); + camel_folder_change_info_clear(mh_folder->changes); g_free(name); g_free(uid); return; diff --git a/camel/providers/mh/camel-mh-folder.h b/camel/providers/mh/camel-mh-folder.h index bdb1588811..ddfdf2b4aa 100644 --- a/camel/providers/mh/camel-mh-folder.h +++ b/camel/providers/mh/camel-mh-folder.h @@ -52,6 +52,7 @@ typedef struct { ibex *index; /* index for this folder */ CamelMhSummary *summary; CamelFolderSearch *search; /* used to run searches, we just use the real thing (tm) */ + CamelFolderChangeInfo *changes; /* mass changes to the folder */ } CamelMhFolder; typedef struct { diff --git a/camel/providers/mh/camel-mh-summary.c b/camel/providers/mh/camel-mh-summary.c index ce1d597012..c757a9a0a9 100644 --- a/camel/providers/mh/camel-mh-summary.c +++ b/camel/providers/mh/camel-mh-summary.c @@ -248,7 +248,7 @@ int camel_mh_summary_check(CamelMhSummary * mhs, int forceindex) /* sync the summary with the ondisk files. It doesnt store the state in the file, the summary only, == MUCH faster */ -int camel_mh_summary_sync(CamelMhSummary * mhs, int expunge, CamelException *ex) +int camel_mh_summary_sync(CamelMhSummary * mhs, int expunge, CamelFolderChangeInfo *changes, CamelException *ex) { int count, i; CamelMessageInfo *info; @@ -267,8 +267,9 @@ int camel_mh_summary_sync(CamelMhSummary * mhs, int expunge, CamelException *ex info = camel_folder_summary_index((CamelFolderSummary *)mhs, i); if (info && info->flags & CAMEL_MESSAGE_DELETED) { name = g_strdup_printf("%s/%s", mhs->mh_path, info->uid); - (printf("deleting %s\n", name)); + d(printf("deleting %s\n", name)); if (unlink(name) == 0 || errno==ENOENT) { + camel_folder_change_info_remove_uid(changes, info->uid); camel_folder_summary_remove((CamelFolderSummary *)mhs, info); } } diff --git a/camel/providers/mh/camel-mh-summary.h b/camel/providers/mh/camel-mh-summary.h index 28376c5d9b..81aa91b418 100644 --- a/camel/providers/mh/camel-mh-summary.h +++ b/camel/providers/mh/camel-mh-summary.h @@ -22,6 +22,7 @@ #define _CAMEL_MH_SUMMARY_H #include <camel/camel-folder-summary.h> +#include <camel/camel-folder.h> #include <camel/camel-exception.h> #include <libibex/ibex.h> @@ -55,7 +56,7 @@ CamelMhSummary *camel_mh_summary_new (const char *filename, const char *mhdir, i int camel_mh_summary_load(CamelMhSummary * mhs, int forceindex); int camel_mh_summary_check(CamelMhSummary * mhs, int forceindex); int camel_mh_summary_add(CamelMhSummary * mhs, const char *name, int forceindex); -int camel_mh_summary_sync(CamelMhSummary * mhs, int expunge, CamelException *ex); +int camel_mh_summary_sync(CamelMhSummary * mhs, int expunge, CamelFolderChangeInfo *changes, CamelException *ex); #endif /* ! _CAMEL_MH_SUMMARY_H */ |