aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-06-14 13:10:54 +0800
committerDan Winship <danw@src.gnome.org>2000-06-14 13:10:54 +0800
commit9f197c605b64fb2ac740df9445897c5d3bb62447 (patch)
tree723d16a197aac2683b666bb54fb4d6ddbc28da5a /camel/providers
parenta18691c17e9d49d75775d32a4d25dab9147b2ead (diff)
downloadgsoc2013-evolution-9f197c605b64fb2ac740df9445897c5d3bb62447.tar.gz
gsoc2013-evolution-9f197c605b64fb2ac740df9445897c5d3bb62447.tar.zst
gsoc2013-evolution-9f197c605b64fb2ac740df9445897c5d3bb62447.zip
Renamed from camel_mbox_summary_expunge. Takes a gboolean saying whether
* providers/mbox/camel-mbox-summary.c (camel_mbox_summary_sync): Renamed from camel_mbox_summary_expunge. Takes a gboolean saying whether to expunge or just sync the mbox file. Change some g_errors to g_warning so we don't abort. Make the quick X-Evolution updating code lseek around correctly. Update the mbox mtime in the summary file even in the quick case. * providers/mbox/camel-mbox-summary.h: make CAMEL_MESSAGE_FOLDER_NOXEV not conflict with CAMEL_MESSAGE_FOLDER_FLAGGED defined in camel-mime-message.h * providers/mbox/camel-mbox-folder.c (mbox_close): call camel_mbox_summary_sync to save flag state if not expunging. (mbox_expunge): Update for camel_mbox_summary_expunge rename. svn path=/trunk/; revision=3558
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c7
-rw-r--r--camel/providers/mbox/camel-mbox-summary.c43
-rw-r--r--camel/providers/mbox/camel-mbox-summary.h7
3 files changed, 32 insertions, 25 deletions
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index 305935fcdd..07accc5a35 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -243,9 +243,10 @@ mbox_close (CamelFolder *folder, gboolean expunge, CamelException *ex)
/* call parent implementation */
parent_class->close (folder, expunge, ex);
- if (expunge) {
+ if (expunge)
mbox_expunge(folder, ex);
- }
+ else
+ camel_mbox_summary_sync(mbox_folder->summary, FALSE);
/* save index */
if (mbox_folder->index) {
@@ -268,7 +269,7 @@ mbox_expunge (CamelFolder *folder, CamelException *ex)
{
CamelMboxFolder *mbox = (CamelMboxFolder *)folder;
- if (camel_mbox_summary_expunge(mbox->summary) == -1) {
+ if (camel_mbox_summary_sync(mbox->summary, TRUE) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID, /* FIXME: right error code */
"Could not expunge: %s", strerror(errno));
}
diff --git a/camel/providers/mbox/camel-mbox-summary.c b/camel/providers/mbox/camel-mbox-summary.c
index e78bede490..c2fd326104 100644
--- a/camel/providers/mbox/camel-mbox-summary.c
+++ b/camel/providers/mbox/camel-mbox-summary.c
@@ -524,7 +524,7 @@ copy_block(int fromfd, int tofd, off_t start, size_t bytes)
}
int
-camel_mbox_summary_expunge(CamelMboxSummary *mbs)
+camel_mbox_summary_sync(CamelMboxSummary *mbs, gboolean expunge)
{
CamelMimeParser *mp=NULL;
int i, count;
@@ -539,6 +539,7 @@ camel_mbox_summary_expunge(CamelMboxSummary *mbs)
int len;
guint32 uid, flags;
int quick = TRUE, work = FALSE;
+ struct stat st;
/* make sure we're in sync */
count = camel_folder_summary_count(s);
@@ -550,16 +551,17 @@ camel_mbox_summary_expunge(CamelMboxSummary *mbs)
}
/* check if we have any work to do */
- d(printf("Performing expunge, %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 (info->info.flags & (CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_FOLDER_NOXEV))
+ 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\n", quick?"quick":"", work?"Work":""));
+ d(printf("Options: %s %s %s\n", expunge?"expunge":"", quick?"quick":"", work?"Work":""));
if (quick && !work)
return 0;
@@ -588,8 +590,11 @@ camel_mbox_summary_expunge(CamelMboxSummary *mbs)
}
for (i=0;i<count;i++) {
- off_t frompos, bodypos;
- off_t xevoffset;
+ 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);
@@ -619,14 +624,14 @@ camel_mbox_summary_expunge(CamelMboxSummary *mbs)
goto error;
if (camel_mime_parser_tell_start_from(mp) != info->frompos) {
- g_error("Summary/mbox mismatch, aborting expunge");
+ g_warning("Summary/mbox mismatch, aborting sync");
goto error;
}
if (camel_mime_parser_step(mp, &buffer, &len) == HSCAN_FROM_END)
goto error;
- xev = camel_mime_parser_header(mp, "X-Evolution", (int *)&xevoffset);
+ xev = camel_mime_parser_header(mp, "X-Evolution", &xevoffset);
if (xev && header_evolution_decode(xev, &uid, &flags) != -1) {
char name[64];
@@ -640,13 +645,16 @@ camel_mbox_summary_expunge(CamelMboxSummary *mbs)
xevnew = header_evolution_encode(strtoul(info->info.uid, NULL, 10), info->info.flags & 0xffff);
if (quick) {
if (!xevok) {
- g_error("The summary told me I had an X-Evolution header, but i dont!");
+ g_warning("The summary told me I had an X-Evolution header, but i dont!");
goto error;
}
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));
} while (len == -1 && errno == EINTR);
+ lseek (fd, lastpos, SEEK_SET);
g_free(buffer);
if (len == -1) {
goto error;
@@ -706,8 +714,6 @@ camel_mbox_summary_expunge(CamelMboxSummary *mbs)
}
if (!quick) {
- struct stat st;
-
if (close(fdout) == -1) {
g_warning("Cannot close tmp folder: %s", strerror(errno));
goto error;
@@ -719,17 +725,18 @@ camel_mbox_summary_expunge(CamelMboxSummary *mbs)
}
tmpname = 0;
- if (stat(mbs->folder_path, &st) == -1)
- goto error;
-
- camel_folder_summary_touch(s);
- s->time = st.st_mtime;
- mbs->folder_size = st.st_size;
- camel_folder_summary_save(s);
if (mbs->index)
ibex_save(mbs->index);
}
+ if (stat(mbs->folder_path, &st) == -1)
+ goto error;
+
+ camel_folder_summary_touch(s);
+ s->time = st.st_mtime;
+ mbs->folder_size = st.st_size;
+ camel_folder_summary_save(s);
+
gtk_object_unref((GtkObject *)mp);
return 0;
diff --git a/camel/providers/mbox/camel-mbox-summary.h b/camel/providers/mbox/camel-mbox-summary.h
index 6d98fd051d..ad7af33e91 100644
--- a/camel/providers/mbox/camel-mbox-summary.h
+++ b/camel/providers/mbox/camel-mbox-summary.h
@@ -35,8 +35,7 @@ typedef struct _CamelMboxSummaryClass CamelMboxSummaryClass;
/* extra summary flags */
enum {
- CAMEL_MESSAGE_FOLDER_NOXEV = 1<<16,
-/* CAMEL_MESSAGE_FOLDER_FLAGGED = 1<<17,*/
+ CAMEL_MESSAGE_FOLDER_NOXEV = 1<<17,
};
typedef struct _CamelMboxMessageContentInfo {
@@ -72,7 +71,7 @@ CamelMboxSummary *camel_mbox_summary_new (const char *filename, const char
int camel_mbox_summary_load(CamelMboxSummary *mbs, int forceindex);
/* incremental update */
int camel_mbox_summary_update(CamelMboxSummary *mbs, off_t offset);
-/* perform a folder expunge */
-int camel_mbox_summary_expunge(CamelMboxSummary *mbs);
+/* perform a folder sync or expunge, if needed */
+int camel_mbox_summary_sync (CamelMboxSummary *mbs, gboolean expunge);
#endif /* ! _CAMEL_MBOX_SUMMARY_H */