aboutsummaryrefslogtreecommitdiffstats
path: root/libemail-engine/mail-vfolder.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-07-15 21:45:22 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-07-18 00:08:46 +0800
commit4de572679748a0586b9a9c3bf34c40ea5102e826 (patch)
treefa6815753e6fc1fd8f922b0a42c42a373256598c /libemail-engine/mail-vfolder.c
parent079fc1a78d35d79350b7390ca3a76f65f9f22841 (diff)
downloadgsoc2013-evolution-4de572679748a0586b9a9c3bf34c40ea5102e826.tar
gsoc2013-evolution-4de572679748a0586b9a9c3bf34c40ea5102e826.tar.gz
gsoc2013-evolution-4de572679748a0586b9a9c3bf34c40ea5102e826.tar.bz2
gsoc2013-evolution-4de572679748a0586b9a9c3bf34c40ea5102e826.tar.lz
gsoc2013-evolution-4de572679748a0586b9a9c3bf34c40ea5102e826.tar.xz
gsoc2013-evolution-4de572679748a0586b9a9c3bf34c40ea5102e826.tar.zst
gsoc2013-evolution-4de572679748a0586b9a9c3bf34c40ea5102e826.zip
Add mail_folder_cache_has_folder_info().
Returns whether MailFolderCache has information about the folder described by the CamelStore and folder name. This does not necessarily mean it has the CamelFolder instance, but it at least has some meta-data about it. You can use this function as a folder existence test.
Diffstat (limited to 'libemail-engine/mail-vfolder.c')
-rw-r--r--libemail-engine/mail-vfolder.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/libemail-engine/mail-vfolder.c b/libemail-engine/mail-vfolder.c
index fbddfd8110..afd7a03cad 100644
--- a/libemail-engine/mail-vfolder.c
+++ b/libemail-engine/mail-vfolder.c
@@ -57,6 +57,32 @@ static void rule_changed (EFilterRule *rule, CamelFolder *folder);
/* ********************************************************************** */
+static gboolean
+vfolder_cache_has_folder_info (EMailSession *session,
+ const gchar *folder_uri)
+{
+ MailFolderCache *folder_cache;
+ CamelStore *store = NULL;
+ gchar *folder_name = NULL;
+ gboolean cache_has_info = FALSE;
+
+ folder_cache = e_mail_session_get_folder_cache (session);
+
+ e_mail_folder_uri_parse (
+ CAMEL_SESSION (session), folder_uri,
+ &store, &folder_name, NULL);
+
+ if (store != NULL && folder_name != NULL) {
+ cache_has_info = mail_folder_cache_has_folder_info (
+ folder_cache, store, folder_name);
+ }
+
+ g_clear_object (&store);
+ g_free (folder_name);
+
+ return cache_has_info;
+}
+
static GList *
vfolder_get_include_subfolders_uris (EMailSession *session,
const gchar *base_uri,
@@ -292,17 +318,15 @@ vfolder_adduri_exec (struct _adduri_msg *m,
GError **error)
{
CamelFolder *folder = NULL;
- MailFolderCache *folder_cache;
+ gboolean cache_has_info;
if (vfolder_shutdown)
return;
- folder_cache = e_mail_session_get_folder_cache (m->session);
-
- /* we dont try lookup the cache if we are removing it, its no longer there */
+ cache_has_info = vfolder_cache_has_folder_info (
+ m->session, m->uri[0] == '*' ? m->uri + 1 : m->uri);
- if (!m->remove &&
- !mail_folder_cache_get_folder_from_uri (folder_cache, m->uri[0] == '*' ? m->uri + 1 : m->uri, NULL)) {
+ if (!m->remove && !cache_has_info) {
g_warning (
"Folder '%s' disappeared while I was "
"adding/removing it to/from my vfolder", m->uri);
@@ -767,18 +791,15 @@ rule_add_sources (EMailSession *session,
EMVFolderRule *rule)
{
GList *sources_uri = *sources_urip;
- MailFolderCache *folder_cache;
GList *head, *link;
- folder_cache = e_mail_session_get_folder_cache (session);
-
head = g_queue_peek_head_link (queue);
for (link = head; link != NULL; link = g_list_next (link)) {
const gchar *uri = link->data;
/* always pick fresh folders - they are
* from CamelStore's folders bag anyway */
- if (mail_folder_cache_get_folder_from_uri (folder_cache, uri, NULL)) {
+ if (vfolder_cache_has_folder_info (session, uri)) {
/* "tag" uris with subfolders with a star prefix */
if (!rule || !em_vfolder_rule_source_get_include_subfolders (rule, uri))
sources_uri = g_list_prepend (sources_uri, g_strdup (uri));