0.9.8claws15
authorChristoph Hohmann <reboot@gmx.ch>
Wed, 31 Dec 2003 20:05:43 +0000 (20:05 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Wed, 31 Dec 2003 20:05:43 +0000 (20:05 +0000)
* src/folder.[ch]
* src/common/xml.[ch]
        keep folderlist.xml data for unloaded FolderClasses

ChangeLog.claws
configure.ac
src/common/xml.c
src/common/xml.h
src/folder.c
src/folder.h

index dd87e2e5d82b1b19cfa944b4409559e675d6fd15..ac0443872c62ad6972abed4672b3f18898e3f2f4 100644 (file)
@@ -1,4 +1,11 @@
+2003-12-31 [christoph] 0.9.8claws15
+
+       * src/folder.[ch]
+       * src/common/xml.[ch]
+               keep folderlist.xml data for unloaded FolderClasses
+
 2003-12-30 [luke]      0.9.8claws14
+
        * src/procheader.[ch]
                o added procheader_get_one_field_asis() that does not do
                  unfolding
index cc3b4a6e84df81f996cbb145e2bc7fada3ab26f5..fa4af2f7d58dc033d940ff77bc1a28163d93c58e 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=14
+EXTRA_VERSION=15
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 3dc940cfd9014a7c15715967e696f182684866bf..aa495c7010550ba25fbf39d96b79db05db32d80f 100644 (file)
@@ -560,7 +560,7 @@ void xml_tag_add_attr(XMLTag *tag, const gchar *name, gchar *value)
        tag->attr = g_list_append(tag->attr, attr);
 }
 
-static void xml_write_node_recursive(GNode *node, FILE *fp)
+static void xml_write_tree_recursive(GNode *node, FILE *fp)
 {
        gint i, depth;
        XMLTag *tag;
@@ -593,7 +593,7 @@ static void xml_write_node_recursive(GNode *node, FILE *fp)
 
                        cur = child;
                        child = cur->next;
-                       xml_write_node_recursive(cur, fp);
+                       xml_write_tree_recursive(cur, fp);
                }
 
                for (i = 0; i < depth; i++)
@@ -603,8 +603,24 @@ static void xml_write_node_recursive(GNode *node, FILE *fp)
                fputs(" />\n", fp);
 }
 
-void xml_write_node(GNode *node, FILE *fp)
+void xml_write_tree(GNode *node, FILE *fp)
 {
-       xml_write_node_recursive(node, fp);
+       xml_write_tree_recursive(node, fp);
 }
 
+static gpointer copy_node_func(gpointer nodedata, gpointer data)
+{
+       XMLNode *xmlnode = (XMLNode *) nodedata;
+       XMLNode *newxmlnode;
+       
+       newxmlnode = g_new0(XMLNode, 1);
+       newxmlnode->tag = xml_copy_tag(xmlnode->tag);
+       newxmlnode->element = g_strdup(xmlnode->element);
+
+       return newxmlnode;
+}
+
+GNode *xml_tree_copy(GNode *node)
+{
+       return g_node_map(node, copy_node_func, NULL);
+}
index f4893a16d75b4974844f3de964bb1cec6ec04039..ba588d2e11d67302a353eecec5944a16d7e73405 100644 (file)
@@ -95,7 +95,8 @@ void xml_free_tag             (XMLTag         *tag);
 void xml_tag_add_attr          (XMLTag         *tag,
                                 const gchar    *name, 
                                 gchar          *value);
-void xml_write_node            (GNode          *node,
+void xml_write_tree            (GNode          *node,
                                 FILE           *fp);
+GNode *xml_copy_tree           (GNode          *node);
 
 #endif /* __XML_H__ */
index 086e56269a6d077ee1cdf897b960be8f424bfdc8..6fe1750f14987510e33b6a557b9664a5c014437c 100644 (file)
@@ -54,6 +54,8 @@
 #include "prefs_account.h"
 
 static GList *folder_list = NULL;
+static GSList *class_list = NULL;
+static GSList *folder_unloaded_list = NULL;
 
 void folder_init               (Folder         *folder,
                                 const gchar    *name);
@@ -71,8 +73,6 @@ void folder_item_read_cache           (FolderItem *item);
 void folder_item_free_cache            (FolderItem *item);
 gint folder_item_scan_full             (FolderItem *item, gboolean filtering);
 
-static GSList *classlist;
-
 void folder_system_init(void)
 {
        folder_register_class(mh_get_class());
@@ -82,13 +82,31 @@ void folder_system_init(void)
 
 GSList *folder_get_class_list(void)
 {
-       return classlist;
+       return class_list;
 }
 
 void folder_register_class(FolderClass *klass)
 {
        debug_print("registering folder class %s\n", klass->idstr);
-       classlist = g_slist_append(classlist, klass);
+       class_list = g_slist_append(class_list, klass);
+}
+
+void folder_unregister_class(FolderClass *klass)
+{
+/*
+       GList *folderlist, *cur;
+*/
+       debug_print("unregistering folder class %s\n", klass->idstr);
+/*
+       folderlist = g_list_copy(folder_get_list());
+       for (cur = folderlist; cur != NULL; cur = g_list_next(cur)) {
+               Folder *folder = (Folder *) cur->data;
+
+               if (folder->klass == klass) {
+                       GNode *xmlnode = folder_
+               }
+       }
+*/
 }
 
 Folder *folder_new(FolderClass *klass, const gchar *name, const gchar *path)
@@ -618,6 +636,9 @@ gint folder_read_list(void)
                folder = folder_get_from_xml(cur);
                if (folder != NULL)
                        folder_add(folder);
+               else
+                       folder_unloaded_list = g_slist_append(folder_unloaded_list,
+                               (gpointer) xml_tree_copy(cur));
                cur = cur->next;
        }
 
@@ -631,6 +652,7 @@ gint folder_read_list(void)
 void folder_write_list(void)
 {
        GList *list;
+       GSList *slist;
        Folder *folder;
        gchar *path;
        PrefFile *pfile;
@@ -662,7 +684,13 @@ void folder_write_list(void)
                        g_node_append(rootnode, node);
        }
 
-       xml_write_node(rootnode, pfile->fp);
+       for (slist = folder_unloaded_list; slist != NULL; slist = g_slist_next(slist)) {
+               GNode *node = (GNode *) slist->data;
+
+               g_node_append(rootnode, xml_tree_copy(node));
+       }
+
+       xml_write_tree(rootnode, pfile->fp);
 
        if (prefs_file_close(pfile) < 0)
                g_warning("failed to write folder list.\n");
@@ -2573,6 +2601,8 @@ static Folder *folder_get_from_xml(GNode *node)
                if (!strcmp(attr->name, "type"))
                        klass = folder_get_class_from_string(attr->value);
        }
+       if (klass == NULL)
+               return NULL;
 
        folder = folder_new(klass, "", "");
        g_return_val_if_fail(folder != NULL, NULL);
index 34cd7b87e311c05a0410778a5280c0f230c85db5..dadb1e9602679db60a298741313405ece9a75159 100644 (file)
@@ -318,6 +318,7 @@ struct _FolderItemUpdateData
 
 void       folder_system_init          (void);
 void       folder_register_class       (FolderClass    *klass);
+void       folder_unregister_class     (FolderClass    *klass);
 Folder     *folder_new                 (FolderClass    *type,
                                         const gchar    *name,
                                         const gchar    *path);