aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/imap.c15
-rw-r--r--libsylph/mh.c13
-rw-r--r--libsylph/news.c10
-rw-r--r--libsylph/procmsg.c47
-rw-r--r--libsylph/procmsg.h8
5 files changed, 90 insertions, 3 deletions
diff --git a/libsylph/imap.c b/libsylph/imap.c
index b2458adf..5461b10a 100644
--- a/libsylph/imap.c
+++ b/libsylph/imap.c
@@ -1031,8 +1031,10 @@ static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
newlist = imap_get_uncached_messages
(session, item, begin, last_uid,
exists - item->total, TRUE);
- if (newlist)
+ if (newlist) {
item->cache_dirty = TRUE;
+ item->mark_dirty = TRUE;
+ }
mlist = g_slist_concat(mlist, newlist);
}
} else {
@@ -1041,6 +1043,7 @@ static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
TRUE);
last_uid = procmsg_get_last_num_in_msg_list(mlist);
item->cache_dirty = TRUE;
+ item->mark_dirty = TRUE;
}
item->mtime = uid_validity;
@@ -1049,9 +1052,19 @@ static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
item->last_num = last_uid;
+ if (item->mark_queue)
+ item->mark_dirty = TRUE;
+
debug_print("cache_dirty: %d, mark_dirty: %d\n",
item->cache_dirty, item->mark_dirty);
+ if (!item->opened) {
+ if (item->cache_dirty)
+ procmsg_write_cache_list(item, mlist);
+ if (item->mark_dirty)
+ procmsg_write_flags_list(item, mlist);
+ }
+
catch:
return mlist;
}
diff --git a/libsylph/mh.c b/libsylph/mh.c
index 8015d5ba..9cb12425 100644
--- a/libsylph/mh.c
+++ b/libsylph/mh.c
@@ -249,12 +249,13 @@ static GSList *mh_get_msg_list(Folder *folder, FolderItem *item,
item->cache_dirty = TRUE;
}
- item->mtime = cur_mtime;
-
procmsg_set_flags(mlist, item);
mlist = procmsg_sort_msg_list(mlist, item->sort_key, item->sort_type);
+ if (item->mark_queue)
+ item->mark_dirty = TRUE;
+
#ifdef MEASURE_TIME
g_timer_stop(timer);
g_print("%s: %s: elapsed time: %f sec\n",
@@ -264,6 +265,14 @@ static GSList *mh_get_msg_list(Folder *folder, FolderItem *item,
debug_print("cache_dirty: %d, mark_dirty: %d\n",
item->cache_dirty, item->mark_dirty);
+ if (!item->opened) {
+ item->mtime = cur_mtime;
+ if (item->cache_dirty)
+ procmsg_write_cache_list(item, mlist);
+ if (item->mark_dirty)
+ procmsg_write_flags_list(item, mlist);
+ }
+
return mlist;
}
diff --git a/libsylph/news.c b/libsylph/news.c
index e54f37d0..0c1ab053 100644
--- a/libsylph/news.c
+++ b/libsylph/news.c
@@ -342,9 +342,19 @@ static GSList *news_get_article_list(Folder *folder, FolderItem *item,
alist = procmsg_sort_msg_list(alist, item->sort_key, item->sort_type);
+ if (item->mark_queue)
+ item->mark_dirty = TRUE;
+
debug_print("cache_dirty: %d, mark_dirty: %d\n",
item->cache_dirty, item->mark_dirty);
+ if (!item->opened) {
+ if (item->cache_dirty)
+ procmsg_write_cache_list(item, alist);
+ if (item->mark_dirty)
+ procmsg_write_flags_list(item, alist);
+ }
+
return alist;
}
diff --git a/libsylph/procmsg.c b/libsylph/procmsg.c
index 6c5f59fd..e93774ba 100644
--- a/libsylph/procmsg.c
+++ b/libsylph/procmsg.c
@@ -489,6 +489,53 @@ void procmsg_write_flags(MsgInfo *msginfo, FILE *fp)
WRITE_CACHE_DATA_INT(flags, fp);
}
+void procmsg_write_cache_list(FolderItem *item, GSList *mlist)
+{
+ FILE *fp;
+ GSList *cur;
+
+ g_return_if_fail(item != NULL);
+
+ debug_print("Writing summary cache (%s)\n", item->path);
+
+ fp = procmsg_open_cache_file(item, DATA_WRITE);
+ if (fp == NULL)
+ return;
+
+ for (cur = mlist; cur != NULL; cur = cur->next) {
+ MsgInfo *msginfo = (MsgInfo *)cur->data;
+ procmsg_write_cache(msginfo, fp);
+ }
+
+ fclose(fp);
+ item->cache_dirty = FALSE;
+}
+
+void procmsg_write_flags_list(FolderItem *item, GSList *mlist)
+{
+ FILE *fp;
+ GSList *cur;
+
+ g_return_if_fail(item != NULL);
+
+ debug_print("Writing summary flags (%s)\n", item->path);
+
+ fp = procmsg_open_mark_file(item, DATA_WRITE);
+ if (fp == NULL)
+ return;
+
+ for (cur = mlist; cur != NULL; cur = cur->next) {
+ MsgInfo *msginfo = (MsgInfo *)cur->data;
+ procmsg_write_flags(msginfo, fp);
+ }
+
+ if (item->mark_queue)
+ procmsg_flush_mark_queue(item, fp);
+
+ fclose(fp);
+ item->mark_dirty = FALSE;
+}
+
void procmsg_flush_mark_queue(FolderItem *item, FILE *fp)
{
MsgInfo *flaginfo;
diff --git a/libsylph/procmsg.h b/libsylph/procmsg.h
index 780fe3de..8cae4440 100644
--- a/libsylph/procmsg.h
+++ b/libsylph/procmsg.h
@@ -221,10 +221,16 @@ GSList *procmsg_sort_msg_list (GSList *mlist,
FolderSortType sort_type);
gint procmsg_get_last_num_in_msg_list(GSList *mlist);
void procmsg_msg_list_free (GSList *mlist);
+
void procmsg_write_cache (MsgInfo *msginfo,
FILE *fp);
void procmsg_write_flags (MsgInfo *msginfo,
FILE *fp);
+void procmsg_write_cache_list (FolderItem *item,
+ GSList *mlist);
+void procmsg_write_flags_list (FolderItem *item,
+ GSList *mlist);
+
void procmsg_flush_mark_queue (FolderItem *item,
FILE *fp);
void procmsg_add_mark_queue (FolderItem *item,
@@ -233,6 +239,7 @@ void procmsg_add_mark_queue (FolderItem *item,
void procmsg_add_flags (FolderItem *item,
gint num,
MsgFlags flags);
+
void procmsg_get_mark_sum (FolderItem *item,
gint *new,
gint *unread,
@@ -240,6 +247,7 @@ void procmsg_get_mark_sum (FolderItem *item,
gint *min,
gint *max,
gint first);
+
FILE *procmsg_open_cache_file (FolderItem *item,
DataOpenMode mode);
FILE *procmsg_open_mark_file (FolderItem *item,