[evolution-data-server] Fix nntp folder tree building
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Fix nntp folder tree building
- Date: Mon, 28 Jun 2010 11:09:58 +0000 (UTC)
commit 32148c9499bb7fad55ca11d1c1528332511ec5d6
Author: David Woodhouse <David Woodhouse intel com>
Date: Sat Jun 26 16:03:35 2010 +0100
Fix nntp folder tree building
When it creates a 'virtual' NOSELECT|CHILDREN folder to fill a gap in
the hierarchy, it doesn't correctly insert that into the tree if it is a
top-level folder (i.e. last == NULL).
Once you fix that bug, you end up with two identical copies of the
tree-insertion code. I moved that out into a separate function.
camel/providers/nntp/camel-nntp-store.c | 65 ++++++++++++++-----------------
1 files changed, 29 insertions(+), 36 deletions(-)
---
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 56e70dd..8d66e30 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -707,6 +707,33 @@ nntp_store_get_subscribed_folder_info (CamelNNTPStore *store, const gchar *top,
return first;
}
+static CamelFolderInfo *
+tree_insert(CamelFolderInfo *root, CamelFolderInfo *last, CamelFolderInfo *fi)
+{
+ CamelFolderInfo *kfi;
+
+ if (!root)
+ root = fi;
+ else if (!last) {
+ kfi = root;
+ while (kfi->next)
+ kfi = kfi->next;
+ kfi->next = fi;
+ fi->parent = kfi->parent;
+ } else {
+ if (!last->child) {
+ last->child = fi;
+ fi->parent = last;
+ } else {
+ kfi = last->child;
+ while (kfi->next)
+ kfi = kfi->next;
+ kfi->next = fi;
+ fi->parent = last;
+ }
+ }
+ return root;
+}
/* returns new root */
static CamelFolderInfo *
nntp_push_to_hierarchy (CamelURL *base_url, CamelFolderInfo *root, CamelFolderInfo *pfi, GHashTable *known)
@@ -742,21 +769,8 @@ nntp_push_to_hierarchy (CamelURL *base_url, CamelFolderInfo *root, CamelFolderIn
camel_url_free (url);
g_hash_table_insert (known, fi->full_name, fi);
- if (last) {
- if (!last->child) {
- last->child = fi;
- fi->parent = last;
- } else {
- kfi = last->child;
- while (kfi->next)
- kfi = kfi->next;
- kfi->next = fi;
- fi->parent = last;
- }
- }
+ root = tree_insert(root, last, fi);
last = fi;
- if (!root)
- root = fi;
} else {
last = kfi;
}
@@ -768,28 +782,7 @@ nntp_push_to_hierarchy (CamelURL *base_url, CamelFolderInfo *root, CamelFolderIn
g_free (pfi->name);
pfi->name = g_strdup (name);
- if (!root) {
- root = pfi;
- } else if (!last) {
- kfi = root;
- while (kfi->next)
- kfi = kfi->next;
- kfi->next = pfi;
- pfi->parent = kfi->parent;
- } else {
- if (!last->child) {
- last->child = pfi;
- pfi->parent = last;
- } else {
- kfi = last->child;
- while (kfi->next)
- kfi = kfi->next;
- kfi->next = pfi;
- pfi->parent = last;
- }
- }
-
- return root;
+ return tree_insert(root, last, pfi);
}
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]