aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-01-17 08:35:55 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-01-17 08:35:55 +0000
commit4405c245a1c3608f76e48fe64bab1122cfdad64b (patch)
tree2fe300963f584cda964ac68c347d17a378ab1da2 /libsylph
parent4136cc09224f82a99016a9af275564372c868a4a (diff)
implemented the automatic filtering of IMAP4 INBOX folder.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1491 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/folder.c18
-rw-r--r--libsylph/folder.h7
-rw-r--r--libsylph/imap.c45
-rw-r--r--libsylph/imap.h2
-rw-r--r--libsylph/mh.c44
-rw-r--r--libsylph/mh.h2
-rw-r--r--libsylph/news.c3
-rw-r--r--libsylph/news.h2
-rw-r--r--libsylph/prefs_account.c4
-rw-r--r--libsylph/prefs_account.h4
10 files changed, 115 insertions, 16 deletions
diff --git a/libsylph/folder.c b/libsylph/folder.c
index ba6a3a59..7d0cabd2 100644
--- a/libsylph/folder.c
+++ b/libsylph/folder.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2005 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -968,6 +968,22 @@ GSList *folder_item_get_msg_list(FolderItem *item, gboolean use_cache)
return folder->klass->get_msg_list(folder, item, use_cache);
}
+GSList *folder_item_get_uncached_msg_list(FolderItem *item)
+{
+ Folder *folder;
+
+ g_return_val_if_fail(item != NULL, NULL);
+ g_return_val_if_fail(item->folder->klass->get_uncached_msg_list != NULL,
+ NULL);
+
+ folder = item->folder;
+
+ if (item->stype == F_VIRTUAL)
+ return NULL;
+
+ return folder->klass->get_uncached_msg_list(folder, item);
+}
+
gchar *folder_item_fetch_msg(FolderItem *item, gint num)
{
Folder *folder;
diff --git a/libsylph/folder.h b/libsylph/folder.h
index a5083c2e..1c8cd09d 100644
--- a/libsylph/folder.h
+++ b/libsylph/folder.h
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2005 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -154,6 +154,9 @@ struct _FolderClass
GSList * (*get_msg_list) (Folder *folder,
FolderItem *item,
gboolean use_cache);
+ GSList * (*get_uncached_msg_list)
+ (Folder *folder,
+ FolderItem *item);
/* return value is filename encoding */
gchar * (*fetch_msg) (Folder *folder,
FolderItem *item,
@@ -367,6 +370,8 @@ gint folder_item_scan (FolderItem *item);
void folder_item_scan_foreach (GHashTable *table);
GSList *folder_item_get_msg_list (FolderItem *item,
gboolean use_cache);
+GSList *folder_item_get_uncached_msg_list
+ (FolderItem *item);
/* return value is filename encoding */
gchar *folder_item_fetch_msg (FolderItem *item,
gint num);
diff --git a/libsylph/imap.c b/libsylph/imap.c
index 4ecb3778..9eda5599 100644
--- a/libsylph/imap.c
+++ b/libsylph/imap.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -100,6 +100,9 @@ static gint imap_fetch_flags (IMAPSession *session,
static GSList *imap_get_msg_list (Folder *folder,
FolderItem *item,
gboolean use_cache);
+static GSList *imap_get_uncached_msg_list
+ (Folder *folder,
+ FolderItem *item);
static gchar *imap_fetch_msg (Folder *folder,
FolderItem *item,
gint uid);
@@ -381,6 +384,7 @@ static FolderClass imap_class =
imap_create_tree,
imap_get_msg_list,
+ imap_get_uncached_msg_list,
imap_fetch_msg,
imap_get_msginfo,
imap_add_msg,
@@ -857,14 +861,16 @@ static gint imap_fetch_flags(IMAPSession *session, GArray **uids,
return ok;
}
-static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
- gboolean use_cache)
+static GSList *imap_get_msg_list_full(Folder *folder, FolderItem *item,
+ gboolean use_cache,
+ gboolean uncached_only)
{
GSList *mlist = NULL;
IMAPSession *session;
gint ok, exists = 0, recent = 0, unseen = 0;
guint32 uid_validity = 0;
guint32 first_uid = 0, last_uid = 0;
+ GSList *newlist = NULL;
g_return_val_if_fail(folder != NULL, NULL);
g_return_val_if_fail(item != NULL, NULL);
@@ -1040,7 +1046,6 @@ static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
}
if (begin > 0 && begin <= last_uid) {
- GSList *newlist;
newlist = imap_get_uncached_messages
(session, item, begin, last_uid,
exists - item->total, TRUE);
@@ -1057,6 +1062,7 @@ static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
last_uid = procmsg_get_last_num_in_msg_list(mlist);
item->cache_dirty = TRUE;
item->mark_dirty = TRUE;
+ newlist = mlist;
}
mlist = procmsg_sort_msg_list(mlist, item->sort_key, item->sort_type);
@@ -1078,11 +1084,42 @@ static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
}
catch:
+ if (uncached_only) {
+ GSList *cur;
+
+ if (newlist == NULL) {
+ procmsg_msg_list_free(mlist);
+ return NULL;
+ }
+ if (mlist == newlist)
+ return newlist;
+ for (cur = mlist; cur != NULL; cur = cur->next) {
+ if (cur->next == newlist) {
+ cur->next = NULL;
+ procmsg_msg_list_free(mlist);
+ return newlist;
+ }
+ }
+ procmsg_msg_list_free(mlist);
+ return NULL;
+ }
+
return mlist;
}
#undef THROW
+static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
+ gboolean use_cache)
+{
+ return imap_get_msg_list_full(folder, item, use_cache, FALSE);
+}
+
+static GSList *imap_get_uncached_msg_list(Folder *folder, FolderItem *item)
+{
+ return imap_get_msg_list_full(folder, item, TRUE, TRUE);
+}
+
static gchar *imap_fetch_msg(Folder *folder, FolderItem *item, gint uid)
{
gchar *path, *filename;
diff --git a/libsylph/imap.h b/libsylph/imap.h
index d6db69e2..a7c27fd8 100644
--- a/libsylph/imap.h
+++ b/libsylph/imap.h
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2005 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/libsylph/mh.c b/libsylph/mh.c
index 7a97f4a3..12c1c966 100644
--- a/libsylph/mh.c
+++ b/libsylph/mh.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -56,6 +56,8 @@ static void mh_folder_destroy (Folder *folder);
static GSList *mh_get_msg_list (Folder *folder,
FolderItem *item,
gboolean use_cache);
+static GSList *mh_get_uncached_msg_list(Folder *folder,
+ FolderItem *item);
static gchar *mh_fetch_msg (Folder *folder,
FolderItem *item,
gint num);
@@ -143,6 +145,7 @@ static FolderClass mh_class =
mh_create_tree,
mh_get_msg_list,
+ mh_get_uncached_msg_list,
mh_fetch_msg,
mh_get_msginfo,
mh_add_msg,
@@ -191,12 +194,13 @@ static void mh_folder_init(Folder *folder, const gchar *name, const gchar *path)
folder_local_folder_init(folder, name, path);
}
-static GSList *mh_get_msg_list(Folder *folder, FolderItem *item,
- gboolean use_cache)
+static GSList *mh_get_msg_list_full(Folder *folder, FolderItem *item,
+ gboolean use_cache, gboolean uncached_only)
{
GSList *mlist;
GHashTable *msg_table;
time_t cur_mtime;
+ GSList *newlist = NULL;
#ifdef MEASURE_TIME
GTimer *timer;
#endif
@@ -218,7 +222,7 @@ static GSList *mh_get_msg_list(Folder *folder, FolderItem *item,
item->cache_dirty = TRUE;
}
} else if (use_cache) {
- GSList *newlist, *cur, *next;
+ GSList *cur, *next;
gboolean strict_cache_check = prefs_common.strict_cache_check;
if (item->stype == F_QUEUE || item->stype == F_DRAFT)
@@ -251,6 +255,7 @@ static GSList *mh_get_msg_list(Folder *folder, FolderItem *item,
} else {
mlist = mh_get_uncached_msgs(NULL, item);
item->cache_dirty = TRUE;
+ newlist = mlist;
}
procmsg_set_flags(mlist, item);
@@ -277,9 +282,40 @@ static GSList *mh_get_msg_list(Folder *folder, FolderItem *item,
procmsg_write_flags_list(item, mlist);
}
+ if (uncached_only) {
+ GSList *cur;
+
+ if (newlist == NULL) {
+ procmsg_msg_list_free(mlist);
+ return NULL;
+ }
+ if (mlist == newlist)
+ return newlist;
+ for (cur = mlist; cur != NULL; cur = cur->next) {
+ if (cur->next == newlist) {
+ cur->next = NULL;
+ procmsg_msg_list_free(mlist);
+ return newlist;
+ }
+ }
+ procmsg_msg_list_free(mlist);
+ return NULL;
+ }
+
return mlist;
}
+static GSList *mh_get_msg_list(Folder *folder, FolderItem *item,
+ gboolean use_cache)
+{
+ return mh_get_msg_list_full(folder, item, use_cache, FALSE);
+}
+
+static GSList *mh_get_uncached_msg_list(Folder *folder, FolderItem *item)
+{
+ return mh_get_msg_list_full(folder, item, TRUE, TRUE);
+}
+
static gchar *mh_fetch_msg(Folder *folder, FolderItem *item, gint num)
{
gchar *path;
diff --git a/libsylph/mh.h b/libsylph/mh.h
index adea89bb..32cb5907 100644
--- a/libsylph/mh.h
+++ b/libsylph/mh.h
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2005 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/libsylph/news.c b/libsylph/news.c
index e17e86c5..3a0ab688 100644
--- a/libsylph/news.c
+++ b/libsylph/news.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -134,6 +134,7 @@ static FolderClass news_class =
NULL,
news_get_article_list,
+ NULL,
news_fetch_msg,
news_get_msginfo,
NULL,
diff --git a/libsylph/news.h b/libsylph/news.h
index d6d01a30..8adcb2f6 100644
--- a/libsylph/news.h
+++ b/libsylph/news.h
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2005 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/libsylph/prefs_account.c b/libsylph/prefs_account.c
index d9fb433a..c9eee518 100644
--- a/libsylph/prefs_account.c
+++ b/libsylph/prefs_account.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -63,6 +63,8 @@ static PrefParam param[] = {
{"filter_on_receive", "TRUE", &tmp_ac_prefs.filter_on_recv, P_BOOL},
{"imap_check_inbox_only", "FALSE", &tmp_ac_prefs.imap_check_inbox_only,
P_BOOL},
+ {"imap_filter_inbox_on_receive", "FALSE",
+ &tmp_ac_prefs.imap_filter_inbox_on_recv, P_BOOL},
{"imap_auth_method", "0", &tmp_ac_prefs.imap_auth_type, P_ENUM},
{"max_nntp_articles", "300", &tmp_ac_prefs.max_nntp_articles, P_INT},
{"receive_at_get_all", "TRUE", &tmp_ac_prefs.recv_at_getall, P_BOOL},
diff --git a/libsylph/prefs_account.h b/libsylph/prefs_account.h
index 8c848f64..1e9bd4b0 100644
--- a/libsylph/prefs_account.h
+++ b/libsylph/prefs_account.h
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -92,7 +92,9 @@ struct _PrefsAccount
gchar *inbox;
gboolean imap_check_inbox_only;
+ gboolean imap_filter_inbox_on_recv;
gint imap_auth_type;
+
gint max_nntp_articles;
gboolean recv_at_getall;