* src/folder.[ch]
authorChristoph Hohmann <reboot@gmx.ch>
Mon, 14 Oct 2002 21:23:12 +0000 (21:23 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Mon, 14 Oct 2002 21:23:12 +0000 (21:23 +0000)
* src/imap.[ch]
        use virtual functions for folder item new and destroy
        functions

ChangeLog.claws
configure.in
src/folder.c
src/folder.h
src/imap.c
src/imap.h

index 0274da5..50414c0 100644 (file)
@@ -1,3 +1,10 @@
+2002-10-14 [christoph] 0.8.5claws36
+
+       * src/folder.[ch]
+       * src/imap.[ch]
+               use virtual functions for folder item new and destroy
+               functions
+
 2002-10-14 [melvin]    0.8.5claws35
 
        * src/compose.c
index e4e15df..93ae7e3 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws35
+EXTRA_VERSION=claws36
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 58ce963..953b162 100644 (file)
@@ -73,6 +73,7 @@ void folder_item_free_cache           (FolderItem *item);
 Folder *folder_new(FolderType type, const gchar *name, const gchar *path)
 {
        Folder *folder = NULL;
+       FolderItem *item;
 
        name = name ? name : path;
        switch (type) {
@@ -92,13 +93,17 @@ Folder *folder_new(FolderType type, const gchar *name, const gchar *path)
                return NULL;
        }
 
+       /* Create root folder item */
+       item = folder_item_new(folder, name, NULL);
+       item->folder = folder;
+       folder->node = g_node_new(item);
+       folder->data = NULL;
+
        return folder;
 }
 
 static void folder_init(Folder *folder, const gchar *name)
 {
-       FolderItem *item;
-
        g_return_if_fail(folder != NULL);
 
        folder_set_name(folder, name);
@@ -112,6 +117,8 @@ static void folder_init(Folder *folder, const gchar *name)
        folder->trash = NULL;
 
        /* Init Folder functions */
+       folder->item_new = NULL;
+       folder->item_destroy = NULL;
        folder->fetch_msg = NULL;
        folder->fetch_msginfo = NULL;
        folder->fetch_msginfos = NULL;
@@ -119,12 +126,6 @@ static void folder_init(Folder *folder, const gchar *name)
        folder->ui_func = NULL;
        folder->ui_func_data = NULL;
        folder->check_msgnum_validity = NULL;
-
-       /* Create root folder item */
-       item = folder_item_new(folder, name, NULL);
-       item->folder = folder;
-       folder->node = g_node_new(item);
-       folder->data = NULL;
 }
 
 void folder_local_folder_init(Folder *folder, const gchar *name,
@@ -188,17 +189,10 @@ FolderItem *folder_item_new(Folder *folder, const gchar *name, const gchar *path
 {
        FolderItem *item = NULL;
 
-       switch (folder->type) {
-       case F_IMAP:
-               item = imap_folder_item_new();
-               break;
-       case F_MH:
-       case F_NEWS:
-       case F_MBOX:
+       if (folder->item_new) {
+               item = folder->item_new(folder);
+       } else {
                item = g_new0(FolderItem, 1);
-               break;
-       default:
-               return NULL;
        }
 
        g_return_val_if_fail(item != NULL, NULL);
@@ -270,21 +264,18 @@ void folder_item_destroy(FolderItem *item)
 
        debug_print("Destroying folder item %s\n", item->path);
 
-       if (item->folder != NULL) {
-               switch (item->folder->type) {
-               case F_IMAP:
-                       imap_folder_item_destroy(item);
-                       break;
-               default:
-                       break;
-               }
-       }
-
        if (item->cache)
                folder_item_free_cache(item);
        g_free(item->name);
        g_free(item->path);
-       g_free(item);
+
+       if (item->folder != NULL) {
+               if(item->folder->item_destroy) {
+                       item->folder->item_destroy(item->folder, item);
+               } else {
+                       g_free(item);
+               }
+       }
 }
 
 void folder_set_ui_func(Folder *folder, FolderUIFunc func, gpointer data)
index dde2f22..2620c89 100644 (file)
@@ -133,6 +133,9 @@ struct _Folder
                                         FolderItem     *item,
                                         gboolean        use_cache);
 */
+       FolderItem *(*item_new)         (Folder         *folder);
+       void     (*item_destroy)        (Folder         *folder,
+                                        FolderItem     *item);
        gchar *  (*fetch_msg)           (Folder         *folder,
                                         FolderItem     *item,
                                         gint            num);
index 62398e8..2024a5a 100644 (file)
        }                                                       \
 }
 
+struct _IMAPFolderItem
+{
+       FolderItem item;
+
+       guint lastuid;
+       GSList *uid_list;
+};
+
 static GList *session_list = NULL;
 
 static gint imap_cmd_count = 0;
@@ -77,6 +85,10 @@ static void imap_folder_init         (Folder         *folder,
                                         const gchar    *name,
                                         const gchar    *path);
 
+static FolderItem *imap_folder_item_new        (Folder         *folder);
+static void imap_folder_item_destroy   (Folder         *folder,
+                                        FolderItem     *item);
+
 static IMAPSession *imap_session_get   (Folder         *folder);
 
 static gint imap_scan_tree_recursive   (IMAPSession    *session,
@@ -311,6 +323,8 @@ static void imap_folder_init(Folder *folder, const gchar *name,
 /*
        folder->get_msg_list        = imap_get_msg_list;
 */
+       folder->item_new              = imap_folder_item_new;
+       folder->item_destroy          = imap_folder_item_destroy;
        folder->fetch_msg             = imap_fetch_msg;
        folder->add_msg               = imap_add_msg;
        folder->move_msg              = imap_move_msg;
@@ -338,7 +352,7 @@ static void imap_folder_init(Folder *folder, const gchar *name,
        ((IMAPFolder *)folder)->selected_folder = NULL;
 }
 
-FolderItem *imap_folder_item_new()
+static FolderItem *imap_folder_item_new(Folder *folder)
 {
        IMAPFolderItem *item;
        
@@ -349,12 +363,14 @@ FolderItem *imap_folder_item_new()
        return (FolderItem *)item;
 }
 
-void imap_folder_item_destroy(FolderItem *_item)
+static void imap_folder_item_destroy(Folder *folder, FolderItem *_item)
 {
        IMAPFolderItem *item = (IMAPFolderItem *)_item;
 
        g_return_if_fail(item != NULL);
        g_slist_free(item->uid_list);
+
+       g_free(_item);
 }
 
 static gboolean imap_reset_uid_lists_func(GNode *node, gpointer data)
index 927f1ee..b7871e6 100644 (file)
@@ -70,14 +70,6 @@ struct _IMAPNameSpace
        gchar separator;
 };
 
-struct _IMAPFolderItem
-{
-       FolderItem item;
-
-       guint lastuid;
-       GSList *uid_list;
-};
-
 #define IMAP_SUCCESS   0
 #define IMAP_SOCKET    2
 #define IMAP_AUTHFAIL  3
@@ -107,9 +99,6 @@ Folder       *imap_folder_new                (const gchar    *name,
                                         const gchar    *path);
 void    imap_folder_destroy            (Folder         *folder);
 
-FolderItem *imap_folder_item_new       ();
-void imap_folder_item_destroy          (FolderItem *item);
-
 Session *imap_session_new              (const PrefsAccount *account);
 void imap_session_destroy              (Session        *session);
 void imap_session_destroy_all          (void);