evolution-data-server r8612 - trunk/camel/providers/imap4
- From: fejj svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8612 - trunk/camel/providers/imap4
- Date: Wed, 2 Apr 2008 20:18:01 +0100 (BST)
Author: fejj
Date: Wed Apr 2 20:18:00 2008
New Revision: 8612
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8612&view=rev
Log:
2007-05-31 Jeffrey Stedfast <fejj novell com>
* camel-imap4-store.c (imap4_build_folder_info): Add "ghost"
folder info's if needed in order to make sure the folder-info tree
is complete.
Modified:
trunk/camel/providers/imap4/ChangeLog
trunk/camel/providers/imap4/camel-imap4-store.c
Modified: trunk/camel/providers/imap4/camel-imap4-store.c
==============================================================================
--- trunk/camel/providers/imap4/camel-imap4-store.c (original)
+++ trunk/camel/providers/imap4/camel-imap4-store.c Wed Apr 2 20:18:00 2008
@@ -1175,6 +1175,84 @@
}
}
+static char *
+list_parent (camel_imap4_list_t *mbox)
+{
+ const char *d;
+
+ if (!(d = strrchr (mbox->name, mbox->delim)))
+ return NULL;
+
+ return g_strndup (mbox->name, d - mbox->name);
+}
+
+/* bloody glib... GPtrArray doesn't have an insert method */
+static void
+array_insert (GPtrArray *array, int index, void *data)
+{
+ int i;
+
+ if ((index + 1) == array->len) {
+ /* special case, adding to the end of the array */
+ g_ptr_array_add (array, data);
+ return;
+ }
+
+ if (index >= array->len) {
+ /* special case, adding past the end of the array */
+ g_ptr_array_set_size (array, index + 1);
+ array->pdata[index] = data;
+ return;
+ }
+
+ g_ptr_array_set_size (array, array->len + 1);
+
+ /* shift all elements starting at @index 1 position to the right */
+ for (i = array->len - 2; i >= index; i--)
+ array->pdata[i + 1] = array->pdata[i];
+
+ array->pdata[index] = data;
+}
+
+static void
+list_add_ghosts (GPtrArray *array)
+{
+ camel_imap4_list_t *mbox;
+ GHashTable *list_hash;
+ char delim, *parent;
+ int i = 0;
+
+ list_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+ while (i < array->len) {
+ mbox = array->pdata[i];
+ if ((parent = list_parent (mbox))) {
+ if (!g_hash_table_lookup (list_hash, parent)) {
+ /* ghost folder, insert a fake LIST info w/ a \NoSelect flag */
+ delim = mbox->delim;
+ mbox = g_new (camel_imap4_list_t, 1);
+ mbox->flags = CAMEL_FOLDER_NOSELECT;
+ mbox->name = parent;
+ mbox->delim = delim;
+
+ g_hash_table_insert (list_hash, parent, mbox);
+
+ array_insert (array, i, mbox);
+ continue;
+ } else {
+ /* already exists */
+ g_free (parent);
+ }
+ }
+
+ g_hash_table_insert (list_hash, mbox->name, mbox);
+
+ i++;
+ }
+
+ g_hash_table_destroy (list_hash);
+}
+
static void
imap4_status (CamelStore *store, CamelFolderInfo *fi)
{
@@ -1275,7 +1353,8 @@
g_ptr_array_sort (array, (GCompareFunc) list_sort);
list_remove_duplicates (array);
-
+ list_add_ghosts (array);
+
url = camel_url_copy (engine->url);
if (!strcmp (top, "") && (flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]