From 4b9dbd4269daf414066e5c7a15b992e3efedbfb2 Mon Sep 17 00:00:00 2001 From: 7 Date: Wed, 17 Oct 2001 22:44:27 +0000 Subject: New function to clone a folderinfo tree. 2001-10-17 * camel-store.c (camel_folder_info_clone): New function to clone a folderinfo tree. svn path=/trunk/; revision=13740 --- camel/ChangeLog | 5 +++++ camel/camel-store.c | 36 +++++++++++++++++++++++++++++++++++- camel/camel-store.h | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 8a13bcc98f..d638cf6671 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,8 @@ +2001-10-17 + + * camel-store.c (camel_folder_info_clone): New function to clone a + folderinfo tree. + 2001-10-17 Jeffrey Stedfast * providers/local/camel-mh-folder.c (mh_append_message): Same as diff --git a/camel/camel-store.c b/camel/camel-store.c index 4bc5de3f83..3cd695f1bc 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -838,7 +838,41 @@ camel_folder_info_build (GPtrArray *folders, const char *namespace, top = fi; } - return top; + return top; +} + +static CamelFolderInfo *folder_info_clone_rec(CamelFolderInfo *fi, CamelFolderInfo *parent) +{ + CamelFolderInfo *info; + + info = g_malloc(sizeof(*info)); + info->parent = parent; + info->url = g_strdup(fi->url); + info->name = g_strdup(fi->name); + info->full_name = g_strdup(fi->full_name); + info->path = g_strdup(fi->path); + info->unread_message_count = fi->unread_message_count; + + if (fi->sibling) + info->sibling = folder_info_clone_rec(fi->sibling, parent); + else + info->sibling = NULL; + + if (fi->child) + info->child = folder_info_clone_rec(fi->child, info); + else + info->child = NULL; + + return info; +} + +CamelFolderInfo * +camel_folder_info_clone(CamelFolderInfo *fi) +{ + if (fi == NULL) + return NULL; + + return folder_info_clone_rec(fi, NULL); } gboolean diff --git a/camel/camel-store.h b/camel/camel-store.h index 8f7f566d3a..2cb1e4c7fb 100644 --- a/camel/camel-store.h +++ b/camel/camel-store.h @@ -183,6 +183,7 @@ CamelFolderInfo *camel_folder_info_build (GPtrArray *folders, const char *namespace, char separator, gboolean short_names); +CamelFolderInfo *camel_folder_info_clone (CamelFolderInfo *fi); gboolean camel_store_supports_subscriptions (CamelStore *store); -- cgit v1.2.3