diff options
author | Radek Doulik <rodo@ximian.com> | 2003-12-01 20:13:00 +0800 |
---|---|---|
committer | Radek Doulik <rodo@src.gnome.org> | 2003-12-01 20:13:00 +0800 |
commit | 9563ccf6be0cdc345a70c1facbc6731a75904554 (patch) | |
tree | 35adb77063041a0fbf1204f1732f4ee5ff0aaf92 | |
parent | 6d9d9416e2dc01ac873ef1af274c56b2e00aa4ca (diff) | |
download | gsoc2013-evolution-9563ccf6be0cdc345a70c1facbc6731a75904554.tar gsoc2013-evolution-9563ccf6be0cdc345a70c1facbc6731a75904554.tar.gz gsoc2013-evolution-9563ccf6be0cdc345a70c1facbc6731a75904554.tar.bz2 gsoc2013-evolution-9563ccf6be0cdc345a70c1facbc6731a75904554.tar.lz gsoc2013-evolution-9563ccf6be0cdc345a70c1facbc6731a75904554.tar.xz gsoc2013-evolution-9563ccf6be0cdc345a70c1facbc6731a75904554.tar.zst gsoc2013-evolution-9563ccf6be0cdc345a70c1facbc6731a75904554.zip |
set SUBSCRIBED and NOINFERIORS flags to special folders, renamed method
2003-12-01 Radek Doulik <rodo@ximian.com>
* camel-store.c (add_special_info): set SUBSCRIBED and NOINFERIORS
flags to special folders, renamed method from
add_vtrash_or_vjunk_info
(camel_store_get_folder_info): call add_special_info directly
2003-11-28 Radek Doulik <rodo@ximian.com>
* camel-store.c (camel_store_get_folder_info): use old code from
mail-ops to add vtrash/vjunk info
svn path=/trunk/; revision=23515
-rw-r--r-- | camel/ChangeLog | 12 | ||||
-rw-r--r-- | camel/camel-store.c | 69 |
2 files changed, 78 insertions, 3 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 3854e75f6f..08b35349e6 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,15 @@ +2003-12-01 Radek Doulik <rodo@ximian.com> + + * camel-store.c (add_special_info): set SUBSCRIBED and NOINFERIORS + flags to special folders, renamed method from + add_vtrash_or_vjunk_info + (camel_store_get_folder_info): call add_special_info directly + +2003-11-28 Radek Doulik <rodo@ximian.com> + + * camel-store.c (camel_store_get_folder_info): use old code from + mail-ops to add vtrash/vjunk info + 2003-11-28 David Woodhouse <dwmw2@redhat.com> * providers/imap/camel-imap-provider.c: Enable GUI option for diff --git a/camel/camel-store.c b/camel/camel-store.c index ee51def91a..4bccf6fc0f 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -689,6 +689,62 @@ get_folder_info (CamelStore *store, const char *top, return NULL; } +static void +add_special_info (CamelStore *store, CamelFolderInfo *info, gchar *name, gchar *full_name, gchar *url_base, gboolean unread_count) +{ + CamelFolderInfo *fi, *vinfo, *parent; + char *uri, *path; + CamelURL *url; + + g_return_if_fail (info != NULL); + + parent = NULL; + for (fi = info; fi; fi = fi->sibling) { + if (!strcmp (fi->name, name)) + break; + parent = fi; + } + + /* create our vTrash/vJunk URL */ + url = camel_url_new (info->url, NULL); + path = g_strdup_printf ("/%s", name); + if (url->fragment) + camel_url_set_fragment (url, path); + else + camel_url_set_path (url, path); + g_free (path); + uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); + camel_url_free (url); + + if (fi) { + /* We're going to replace the physical Trash/Junk folder with our vTrash/vJunk folder */ + vinfo = fi; + g_free (vinfo->full_name); + g_free (vinfo->name); + g_free (vinfo->url); + } else { + /* There wasn't a Trash/Junk folder so create a new folder entry */ + vinfo = g_new0 (CamelFolderInfo, 1); + + g_assert(parent != NULL); + + /* link it into the right spot */ + vinfo->sibling = parent->sibling; + parent->sibling = vinfo; + } + + vinfo->flags |= CAMEL_FOLDER_NOINFERIORS | CAMEL_FOLDER_SUBSCRIBED; + + /* Fill in the new fields */ + vinfo->full_name = g_strdup (full_name); + vinfo->name = g_strdup(vinfo->full_name); + vinfo->url = g_strdup_printf ("%s:%s", url_base, uri); + if (!unread_count) + vinfo->unread_message_count = -1; + vinfo->path = g_strdup_printf("/%s", vinfo->name); + g_free (uri); +} + /** * camel_store_get_folder_info: * @store: a CamelStore @@ -715,7 +771,7 @@ CamelFolderInfo * camel_store_get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelException *ex) { - CamelFolderInfo *ret; + CamelFolderInfo *info; g_return_val_if_fail (CAMEL_IS_STORE (store), NULL); g_return_val_if_fail ((store->flags & CAMEL_STORE_SUBSCRIPTIONS) || @@ -723,10 +779,17 @@ camel_store_get_folder_info (CamelStore *store, const char *top, NULL); CAMEL_STORE_LOCK(store, folder_lock); - ret = CS_CLASS (store)->get_folder_info (store, top, flags, ex); + info = CS_CLASS (store)->get_folder_info (store, top, flags, ex); CAMEL_STORE_UNLOCK(store, folder_lock); - return ret; + if (info) { + if (info->url && (store->flags & CAMEL_STORE_VTRASH)) + add_special_info (store, info, CAMEL_VTRASH_NAME, _("Trash"), "vtrash", FALSE); + if (info->url && (store->flags & CAMEL_STORE_VJUNK)) + add_special_info (store, info, CAMEL_VJUNK_NAME, _("Junk"), "vjunk", TRUE); + } + + return info; } |