* 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 0274da54fe17ef7bdf8c210c651ec77850a2b8f7..50414c009108dc40672aba4dc0f31aeebd706771 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
 2002-10-14 [melvin]    0.8.5claws35
 
        * src/compose.c
index e4e15dfcf65d1bb068dd5e4e394b2e50846a184a..93ae7e3551f6103aa8b9b9db85cc07967e8739a8 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
 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
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 58ce96305d9ea0f2846f0eeb044c480b7b891956..953b1625240bb86ce7de2ddd812d34f2fd4a1379 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;
 Folder *folder_new(FolderType type, const gchar *name, const gchar *path)
 {
        Folder *folder = NULL;
+       FolderItem *item;
 
        name = name ? name : path;
        switch (type) {
 
        name = name ? name : path;
        switch (type) {
@@ -92,13 +93,17 @@ Folder *folder_new(FolderType type, const gchar *name, const gchar *path)
                return NULL;
        }
 
                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)
 {
        return folder;
 }
 
 static void folder_init(Folder *folder, const gchar *name)
 {
-       FolderItem *item;
-
        g_return_if_fail(folder != NULL);
 
        folder_set_name(folder, name);
        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->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;
        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;
        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,
 }
 
 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;
 
 {
        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);
                item = g_new0(FolderItem, 1);
-               break;
-       default:
-               return NULL;
        }
 
        g_return_val_if_fail(item != NULL, 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);
 
 
        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);
        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)
 }
 
 void folder_set_ui_func(Folder *folder, FolderUIFunc func, gpointer data)
index dde2f22b10305301dde0bd42d4c4d2f8c50bf531..2620c893dbbed9964ec083abb32ccbe30bdc1cd5 100644 (file)
@@ -133,6 +133,9 @@ struct _Folder
                                         FolderItem     *item,
                                         gboolean        use_cache);
 */
                                         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);
        gchar *  (*fetch_msg)           (Folder         *folder,
                                         FolderItem     *item,
                                         gint            num);
index 62398e8050baf613eff95cf063a065b21a10cae9..2024a5a14869b5084359c9614831c82a5a85269d 100644 (file)
        }                                                       \
 }
 
        }                                                       \
 }
 
+struct _IMAPFolderItem
+{
+       FolderItem item;
+
+       guint lastuid;
+       GSList *uid_list;
+};
+
 static GList *session_list = NULL;
 
 static gint imap_cmd_count = 0;
 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);
 
                                         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,
 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->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;
        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;
 }
 
        ((IMAPFolder *)folder)->selected_folder = NULL;
 }
 
-FolderItem *imap_folder_item_new()
+static FolderItem *imap_folder_item_new(Folder *folder)
 {
        IMAPFolderItem *item;
        
 {
        IMAPFolderItem *item;
        
@@ -349,12 +363,14 @@ FolderItem *imap_folder_item_new()
        return (FolderItem *)item;
 }
 
        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);
 {
        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)
 }
 
 static gboolean imap_reset_uid_lists_func(GNode *node, gpointer data)
index 927f1ee4d52d61c0d29fe3e622982b2b22c20e3c..b7871e66eedb05d6e4dc4ad42b7b1932f14ab7de 100644 (file)
@@ -70,14 +70,6 @@ struct _IMAPNameSpace
        gchar separator;
 };
 
        gchar separator;
 };
 
-struct _IMAPFolderItem
-{
-       FolderItem item;
-
-       guint lastuid;
-       GSList *uid_list;
-};
-
 #define IMAP_SUCCESS   0
 #define IMAP_SOCKET    2
 #define IMAP_AUTHFAIL  3
 #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);
 
                                         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);
 Session *imap_session_new              (const PrefsAccount *account);
 void imap_session_destroy              (Session        *session);
 void imap_session_destroy_all          (void);