sync with 0.8.2cvs4 GNU_aspell_last_merge
authorPaul Mangan <paul@claws-mail.org>
Wed, 28 Aug 2002 11:54:45 +0000 (11:54 +0000)
committerPaul Mangan <paul@claws-mail.org>
Wed, 28 Aug 2002 11:54:45 +0000 (11:54 +0000)
18 files changed:
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/about.c
src/compose.c
src/folder.c
src/folder.h
src/imap.c
src/imap.h
src/main.c
src/news.c
src/news.h
src/session.c
src/session.h
src/smtp.c
src/smtp.h
src/utils.c

index 1a33353..09e4a35 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,38 @@
+2002-08-28
+
+       * src/folder.[ch]: folder_get_path(): new. It returns the root path
+         of Folder.
+       * src/imap.c
+         src/news.c
+         imap_folder_destroy()
+         imap_remove_msg()
+         imap_remove_all_msg()
+         news_folder_destroy(): remove cache directories / files when
+         deleting Folder / messages.
+       * src/utils.c:
+         file_exist()
+         is_dir_exist()
+         is_file_entry_exist(): check if the argument is NULL.
+         remove_all_files()
+         remove_numbered_files()
+         remove_expired_files(): fixed memory leaks on error.
+
+2002-08-28
+
+       * src/folder.[ch]
+         src/imap.[ch]
+         src/mh.[ch]
+         src/news.[ch]
+         src/session.[ch]
+         src/smtp.[ch]: made Folder and Session destructor virtual method.
+
 2002-08-27
 
        * src/compose.c: do joining of normal lines only when auto-wrapping.
+       * src/main.c: modified the warning message for GnuPG.
+       * src/about.c: about_create(): modified the compiled-in features
+         list.
+       * configure.in: improved LDAP library checking (thanks to Alfons).
 
 2002-08-26
 
index e26a831..f9c2469 100644 (file)
@@ -1,4 +1,9 @@
-2002-08-29 [colin]     0.8.2claws1
+2002-08-28 [paul]      0.8.2claws2
+
+       * sync with 0.8.2cvs4
+               see ChangeLog 2002-08-27 and 2002-08-28
+
+2002-08-28 [colin]     0.8.2claws1
 
        * src/summary_search.c
                Added "AND search"
index 97de82a..61d259f 100644 (file)
@@ -1,6 +1,38 @@
+2002-08-28
+
+       * src/folder.[ch]: folder_get_path(): ¿·µ¬¡£ Folder ¤Î¥ë¡¼¥È¥Ñ¥¹¤ò
+         ÊÖ¤¹¡£
+       * src/imap.c
+         src/news.c
+         imap_folder_destroy()
+         imap_remove_msg()
+         imap_remove_all_msg()
+         news_folder_destroy(): Folder / ¥á¥Ã¥»¡¼¥¸¤òºï½ü¤¹¤ë¤È¤­¤Ë
+         ¥­¥ã¥Ã¥·¥å¥Ç¥£¥ì¥¯¥È¥ê / ¥Õ¥¡¥¤¥ë¤òºï½ü¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+       * src/utils.c:
+         file_exist()
+         is_dir_exist()
+         is_file_entry_exist(): °ú¿ô¤¬ NULL ¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¡£
+         remove_all_files()
+         remove_numbered_files()
+         remove_expired_files(): ¥¨¥é¡¼»þ¤Î¥á¥â¥ê¥ê¡¼¥¯¤ò½¤Àµ¡£
+
+2002-08-28
+
+       * src/folder.[ch]
+         src/imap.[ch]
+         src/mh.[ch]
+         src/news.[ch]
+         src/session.[ch]
+         src/smtp.[ch]: Folder ¤È Session ¤Î¥Ç¥¹¥È¥é¥¯¥¿¤ò²¾Áۥ᥽¥Ã¥É¤Ë
+         ¤·¤¿¡£
+
 2002-08-27
 
        * src/compose.c: Ä̾ï¹Ô¤Î·ë¹ç¤ò¼«Æ°²þ¹Ô»þ¤Î¤ß¹Ô¤¦¤è¤¦¤Ë¤·¤¿¡£
+       * src/main.c: GnuPG ¤Î·Ù¹ð¥á¥Ã¥»¡¼¥¸¤ò½¤Àµ¡£
+       * src/about.c: about_create(): ¥³¥ó¥Ñ¥¤¥ëºÑµ¡Ç½°ìÍ÷¤ò½¤Àµ¡£
+       * configure.in: LDAP ¥é¥¤¥Ö¥é¥ê¤Î¥Á¥§¥Ã¥¯¤ò²þÎÉ(Alfons ¤µ¤ó thanks)¡£
 
 2002-08-26
 
index c29c038..4aea703 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=8
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws1
+EXTRA_VERSION=claws2
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
@@ -127,7 +127,7 @@ AC_ARG_ENABLE(gpgme,
 AC_MSG_CHECKING([whether to use GPGME])
 if test $ac_cv_enable_gpgme = yes; then
        AC_MSG_RESULT(yes)
-       AM_PATH_GPGME(0.2.3, AC_DEFINE(USE_GPGME), [use_gpgme=no
+       AM_PATH_GPGME(0.3.5, AC_DEFINE(USE_GPGME), [use_gpgme=no
                                                    ac_cv_enable_gpgme=no])
 else
        AC_MSG_RESULT(no)
index 6b83320..03e6305 100644 (file)
@@ -137,16 +137,16 @@ static void about_create(void)
                   " IPv6"
 #endif
 #if HAVE_LIBCOMPFACE
-                  " libcompface"
+                  " compface"
 #endif
 #if HAVE_LIBJCONV
-                  " libjconv"
+                  " jconv"
 #endif
 #if USE_GPGME
-                  " GPGME"
+                  " GnuPG"
 #endif
 #if USE_SSL
-                  " SSL"
+                  " OpenSSL"
 #endif
 #if USE_LDAP
                   " LDAP"
index 896c7a7..6de70e2 100644 (file)
@@ -205,6 +205,8 @@ static void compose_attach_parts            (Compose        *compose,
                                                 MsgInfo        *msginfo);
 static void compose_wrap_line                  (Compose        *compose);
 static void compose_wrap_line_all              (Compose        *compose);
+static void compose_wrap_line_all_full         (Compose        *compose,
+                                                gboolean        autowrap);
 static void compose_set_title                  (Compose        *compose);
 
 static PrefsAccount *compose_current_mail_account(void);
@@ -2328,7 +2330,7 @@ static guint ins_quote(GtkSText *text, guint indent_len,
 
 /* check if we should join the next line */
 static gboolean join_next_line(GtkSText *text, guint start_pos, guint tlen,
-                              guint prev_ilen)
+                              guint prev_ilen, gboolean autowrap)
 {
        guint indent_len, ch_len;
        gboolean do_join = FALSE;
@@ -2336,7 +2338,7 @@ static gboolean join_next_line(GtkSText *text, guint start_pos, guint tlen,
 
        indent_len = get_indent_length(text, start_pos, tlen);
 
-       if (indent_len > 0 && indent_len == prev_ilen) {
+       if ((autowrap || indent_len > 0) && indent_len == prev_ilen) {
                GET_CHAR(start_pos + indent_len, cbuf, ch_len);
                if (ch_len > 0 && (cbuf[0] != '\n'))
                        do_join = TRUE;
@@ -2345,10 +2347,15 @@ static gboolean join_next_line(GtkSText *text, guint start_pos, guint tlen,
        return do_join;
 }
 
+static void compose_wrap_line_all(Compose *compose)
+{
+       compose_wrap_line_all_full(compose, FALSE);
+}
+
 #define STEXT_FREEZE() \
        if (!frozen) { gtk_stext_freeze(text); frozen = TRUE; }
 
-static void compose_wrap_line_all(Compose *compose)
+static void compose_wrap_line_all_full(Compose *compose, gboolean autowrap)
 {
        GtkSText *text = GTK_STEXT(compose->text);
        guint tlen;
@@ -2407,8 +2414,9 @@ static void compose_wrap_line_all(Compose *compose)
                        gchar cb[MB_LEN_MAX];
 
                        /* should we join the next line */
-                       if (i_len != cur_len && do_delete &&
-                           join_next_line(text, cur_pos + 1, tlen, i_len))
+                       if ((autowrap || i_len != cur_len) && do_delete &&
+                           join_next_line
+                               (text, cur_pos + 1, tlen, i_len, autowrap))
                                do_delete = TRUE;
                        else
                                do_delete = FALSE;
@@ -2557,7 +2565,7 @@ static void compose_wrap_line_all(Compose *compose)
                        /* start over with current line */
                        is_new_line = TRUE;
                        line_len = cur_len = 0;
-                       if (i_len)
+                       if (autowrap || i_len > 0)
                                do_delete = TRUE;
                        else
                                do_delete = FALSE;
@@ -6278,6 +6286,7 @@ static void compose_close_cb(gpointer data, guint action, GtkWidget *widget)
                        return;
                }
        }
+
        gtk_widget_destroy(compose->window);
 }
 
@@ -6376,60 +6385,35 @@ static void compose_allsel_cb(Compose *compose)
                        (GTK_EDITABLE(compose->focused_editable), 0, -1);
 }
 
-static void compose_gtk_stext_action_cb(Compose *compose, ComposeCallGtkSTextAction action)
+static void compose_gtk_stext_action_cb(Compose *compose,
+                                       ComposeCallGtkSTextAction action)
 {
-       if (!(compose->focused_editable && GTK_WIDGET_HAS_FOCUS(compose->focused_editable))) return;
-               
-       switch (action) {
-               case COMPOSE_CALL_GTK_STEXT_MOVE_BEGINNING_OF_LINE:
-                       gtk_stext_move_beginning_of_line(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_FORWARD_CHARACTER:
-                       gtk_stext_move_forward_character(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_BACKWARD_CHARACTER:
-                       gtk_stext_move_backward_character(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_FORWARD_WORD:
-                       gtk_stext_move_forward_word(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_BACKWARD_WORD:
-                       gtk_stext_move_backward_word(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_END_OF_LINE:
-                       gtk_stext_move_end_of_line(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_NEXT_LINE:
-                       gtk_stext_move_next_line(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_PREVIOUS_LINE:
-                       gtk_stext_move_previous_line(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_FORWARD_CHARACTER:
-                       gtk_stext_delete_forward_character(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_BACKWARD_CHARACTER:
-                       gtk_stext_delete_backward_character(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_FORWARD_WORD:
-                       gtk_stext_delete_forward_word(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_BACKWARD_WORD:
-                       gtk_stext_delete_backward_word(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_LINE:
-                       gtk_stext_delete_line(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_LINE_N:
-                       gtk_stext_delete_line(GTK_STEXT(compose->focused_editable));
-                       gtk_stext_delete_forward_character(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_TO_LINE_END:
-                       gtk_stext_delete_to_line_end(GTK_STEXT(compose->focused_editable));
-                       break;
-               default:
-                       break;
-       }
+       GtkSText *text = GTK_STEXT(compose->text);
+       static struct {
+               void (*do_action) (GtkSText *text);
+       } action_table[] = {
+               {gtk_stext_move_beginning_of_line},
+               {gtk_stext_move_forward_character},
+               {gtk_stext_move_backward_character},
+               {gtk_stext_move_forward_word},
+               {gtk_stext_move_backward_word},
+               {gtk_stext_move_end_of_line},
+               {gtk_stext_move_next_line},
+               {gtk_stext_move_previous_line},
+               {gtk_stext_delete_forward_character},
+               {gtk_stext_delete_backward_character},
+               {gtk_stext_delete_forward_word},
+               {gtk_stext_delete_backward_word},
+               {gtk_stext_delete_line},
+               {gtk_stext_delete_line}, /* gtk_stext_delete_line_n */
+               {gtk_stext_delete_to_line_end}
+       };
+
+       if (!GTK_WIDGET_HAS_FOCUS(text)) return;
+
+       if (action >= COMPOSE_CALL_GTK_STEXT_MOVE_BEGINNING_OF_LINE &&
+           action <= COMPOSE_CALL_GTK_STEXT_DELETE_TO_LINE_END)
+               action_table[action].do_action(text);
 }
 
 static void compose_grab_focus_cb(GtkWidget *widget, Compose *compose)
@@ -6853,7 +6837,7 @@ static void text_inserted(GtkWidget *widget, const gchar *text,
                gtk_editable_insert_text(editable, text, length, position);
 
        if (prefs_common.autowrap)
-               compose_wrap_line_all(compose);
+               compose_wrap_line_all_full(compose, TRUE);
 
        gtk_signal_handler_unblock_by_func(GTK_OBJECT(widget),
                                           GTK_SIGNAL_FUNC(text_inserted),
index cfb7fb7..baaa2ad 100644 (file)
@@ -144,22 +144,9 @@ void folder_remote_folder_init(Folder *folder, const gchar *name,
 void folder_destroy(Folder *folder)
 {
        g_return_if_fail(folder != NULL);
+       g_return_if_fail(folder->destroy != NULL);
 
-       switch (folder->type) {
-       case F_MBOX:
-               mbox_folder_destroy(MBOX_FOLDER(folder));
-       case F_MH:
-               mh_folder_destroy(MH_FOLDER(folder));
-               break;
-       case F_IMAP:
-               imap_folder_destroy(IMAP_FOLDER(folder));
-               break;
-       case F_NEWS:
-               news_folder_destroy(NEWS_FOLDER(folder));
-               break;
-       default:
-               break;
-       }
+       folder->destroy(folder);
 
        folder_list = g_list_remove(folder_list, folder);
 
@@ -796,42 +783,50 @@ void folder_set_missing_folders(void)
 
 #undef CREATE_FOLDER_IF_NOT_EXIST
 
-gchar *folder_item_get_path(FolderItem *item)
+gchar *folder_get_path(Folder *folder)
 {
-       gchar *folder_path;
        gchar *path;
 
-       g_return_val_if_fail(item != NULL, NULL);
+       g_return_val_if_fail(folder != NULL, NULL);
 
-       if (FOLDER_TYPE(item->folder) == F_MH)
-               folder_path = g_strdup(LOCAL_FOLDER(item->folder)->rootpath);
-       else if (FOLDER_TYPE(item->folder) == F_MBOX) {
-               path = mbox_get_virtual_path(item);
+       if (FOLDER_TYPE(folder) == F_MH)
+               path = g_strdup(LOCAL_FOLDER(folder)->rootpath);
+       else if (FOLDER_TYPE(folder) == F_MBOX) {
+               path = mbox_get_virtual_path(folder);
                if (path == NULL)
                        return NULL;
-               folder_path = g_strconcat(get_mbox_cache_dir(),
+               path = g_strconcat(get_mbox_cache_dir(),
                                          G_DIR_SEPARATOR_S, path, NULL);
-               g_free(path);
-
-               return folder_path;
+               return path;
        }
-       else if (FOLDER_TYPE(item->folder) == F_IMAP) {
-               g_return_val_if_fail(item->folder->account != NULL, NULL);
-               folder_path = g_strconcat(get_imap_cache_dir(),
-                                         G_DIR_SEPARATOR_S,
-                                         item->folder->account->recv_server,
-                                         G_DIR_SEPARATOR_S,
-                                         item->folder->account->userid,
-                                         NULL);
-       } else if (FOLDER_TYPE(item->folder) == F_NEWS) {
-               g_return_val_if_fail(item->folder->account != NULL, NULL);
-               folder_path = g_strconcat(get_news_cache_dir(),
-                                         G_DIR_SEPARATOR_S,
-                                         item->folder->account->nntp_server,
-                                         NULL);
+       else if (FOLDER_TYPE(folder) == F_IMAP) {
+               g_return_val_if_fail(folder->account != NULL, NULL);
+               path = g_strconcat(get_imap_cache_dir(),
+                                  G_DIR_SEPARATOR_S,
+                                  folder->account->recv_server,
+                                  G_DIR_SEPARATOR_S,
+                                  folder->account->userid,
+                                  NULL);
+       } else if (FOLDER_TYPE(folder) == F_NEWS) {
+               g_return_val_if_fail(folder->account != NULL, NULL);
+               path = g_strconcat(get_news_cache_dir(),
+                                  G_DIR_SEPARATOR_S,
+                                  folder->account->nntp_server,
+                                  NULL);
        } else
-               return NULL;
+               path = NULL;
+
+       return path;
+}
+
+gchar *folder_item_get_path(FolderItem *item)
+{
+       gchar *folder_path;
+       gchar *path;
+
+       g_return_val_if_fail(item != NULL, NULL);
 
+       folder_path = folder_get_path(item->folder);
        g_return_val_if_fail(folder_path != NULL, NULL);
 
        if (folder_path[0] == G_DIR_SEPARATOR) {
index 9decece..f9f339d 100644 (file)
@@ -180,6 +180,8 @@ struct _Folder
                                         const gchar    *name);
        gint     (*remove_folder)       (Folder         *folder,
                                         FolderItem     *item);
+
+       void     (*destroy)             (Folder         *folder);
        void     (*update_mark)         (Folder         *folder,
                                         FolderItem     *item);
        void     (*change_flags)        (Folder         *folder,
@@ -322,7 +324,9 @@ FolderItem *folder_get_default_trash        (void);
 FolderItem *folder_get_default_processing (void);
 void folder_set_missing_folders                (void);
 
+gchar *folder_get_path                 (Folder         *folder);
 gchar *folder_item_get_path            (FolderItem     *item);
+
 gint   folder_item_scan                        (FolderItem     *item);
 void   folder_item_scan_foreach                (GHashTable     *table);
 MsgInfo *folder_item_fetch_msginfo     (FolderItem     *item,
index 7270f39..c8fe44f 100644 (file)
@@ -289,10 +289,15 @@ Folder *imap_folder_new(const gchar *name, const gchar *path)
        return folder;
 }
 
-void imap_folder_destroy(IMAPFolder *folder)
+void imap_folder_destroy(Folder *folder)
 {
-       g_free(folder->selected_folder);
-       
+       gchar *dir;
+
+       dir = folder_get_path(folder);
+       if (is_dir_exist(dir))
+               remove_dir_recursive(dir);
+       g_free(dir);
+
        folder_remote_folder_destroy(REMOTE_FOLDER(folder));
 }
 
@@ -323,6 +328,7 @@ static void imap_folder_init(Folder *folder, const gchar *name,
        folder->create_folder         = imap_create_folder;
        folder->rename_folder         = imap_rename_folder;
        folder->remove_folder         = imap_remove_folder;
+       folder->destroy               = imap_folder_destroy;
        folder->check_msgnum_validity = imap_check_msgnum_validity;
 
        folder->get_num_list          = imap_get_num_list;
@@ -510,6 +516,7 @@ Session *imap_session_new(const PrefsAccount *account)
        }
 
        session = g_new(IMAPSession, 1);
+
        SESSION(session)->type             = SESSION_IMAP;
        SESSION(session)->server           = g_strdup(account->recv_server);
        SESSION(session)->sock             = imap_sock;
@@ -517,6 +524,9 @@ Session *imap_session_new(const PrefsAccount *account)
        SESSION(session)->phase            = SESSION_READY;
        SESSION(session)->last_access_time = time(NULL);
        SESSION(session)->data             = NULL;
+
+       SESSION(session)->destroy          = imap_session_destroy;
+
        session->mbox = NULL;
 
        session_list = g_list_append(session_list, session);
@@ -524,12 +534,12 @@ Session *imap_session_new(const PrefsAccount *account)
        return SESSION(session);
 }
 
-void imap_session_destroy(IMAPSession *session)
+void imap_session_destroy(Session *session)
 {
-       sock_close(SESSION(session)->sock);
-       SESSION(session)->sock = NULL;
+       sock_close(session->sock);
+       session->sock = NULL;
 
-       g_free(session->mbox);
+       g_free(IMAP_SESSION(session)->mbox);
 
        session_list = g_list_remove(session_list, session);
 }
@@ -952,6 +962,7 @@ gint imap_remove_msg(Folder *folder, FolderItem *item, gint uid)
        guint32 uid_validity;
        gint ok;
        IMAPSession *session;
+       gchar *dir;
 
        g_return_val_if_fail(folder != NULL, -1);
        g_return_val_if_fail(folder->type == F_IMAP, -1);
@@ -982,6 +993,10 @@ gint imap_remove_msg(Folder *folder, FolderItem *item, gint uid)
                return ok;
        }
 
+       dir = folder_item_get_path(item);
+       remove_numbered_files(dir, uid, uid);
+       g_free(dir);
+
        return IMAP_SUCCESS;
 }
 
@@ -991,6 +1006,7 @@ gint imap_remove_all_msg(Folder *folder, FolderItem *item)
        guint32 uid_validity;
        gint ok;
        IMAPSession *session;
+       gchar *dir;
 
        g_return_val_if_fail(folder != NULL, -1);
        g_return_val_if_fail(item != NULL, -1);
@@ -1022,6 +1038,10 @@ gint imap_remove_all_msg(Folder *folder, FolderItem *item)
                return ok;
        }
 
+       dir = folder_item_get_path(item);
+       remove_all_numbered_files(dir);
+       g_free(dir);
+
        return IMAP_SUCCESS;
 }
 
index 920ff01..8f0538b 100644 (file)
@@ -105,13 +105,13 @@ typedef enum
 
 Folder *imap_folder_new                (const gchar    *name,
                                         const gchar    *path);
-void    imap_folder_destroy            (IMAPFolder     *folder);
+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              (IMAPSession    *session);
+void imap_session_destroy              (Session        *session);
 void imap_session_destroy_all          (void);
 
 GSList *imap_get_msg_list              (Folder         *folder,
index 681c8c9..63f3cdd 100644 (file)
@@ -264,7 +264,7 @@ int main(int argc, char *argv[])
 
                        val = alertpanel_message_with_disable
                                (_("Warning"),
-                                _("GnuPG is not installed properly.\n"
+                                _("GnuPG is not installed properly, or needs to be upgraded.\n"
                                   "OpenPGP support disabled."));
                        if (val & G_ALERTDISABLE)
                                prefs_common.gpg_warning = FALSE;
index d502bb4..9bcc3c7 100644 (file)
@@ -123,8 +123,15 @@ Folder *news_folder_new(const gchar *name, const gchar *path)
        return folder;
 }
 
-void news_folder_destroy(NewsFolder *folder)
+void news_folder_destroy(Folder *folder)
 {
+       gchar *dir;
+
+       dir = folder_get_path(folder);
+       if (is_dir_exist(dir))
+               remove_dir_recursive(dir);
+       g_free(dir);
+
        folder_remote_folder_destroy(REMOTE_FOLDER(folder));
 }
 
@@ -142,6 +149,7 @@ static void news_folder_init(Folder *folder, const gchar *name,
 /*
        folder->scan         = news_scan_group;
 */
+       folder->destroy      = news_folder_destroy;
        folder->remove_msg   = news_remove_msg;
        folder->get_num_list = news_get_num_list;
        folder->fetch_msginfo = news_fetch_msginfo;
@@ -190,18 +198,21 @@ static Session *news_session_new(const gchar *server, gushort port,
        SESSION(session)->phase            = SESSION_READY;
        SESSION(session)->last_access_time = time(NULL);
        SESSION(session)->data             = NULL;
+
+       SESSION(session)->destroy          = news_session_destroy;
+
        session->group = NULL;
 
        return SESSION(session);
 }
 
-void news_session_destroy(NNTPSession *session)
+void news_session_destroy(Session *session)
 {
-       nntp_close(session->nntp_sock);
-       session->nntp_sock = NULL;
-       SESSION(session)->sock = NULL;
+       nntp_close(NNTP_SESSION(session)->nntp_sock);
+       NNTP_SESSION(session)->nntp_sock = NULL;
+       session->sock = NULL;
 
-       g_free(session->group);
+       g_free(NNTP_SESSION(session)->group);
 }
 
 static Session *news_session_new_for_folder(Folder *folder)
index a6d591c..33652ef 100644 (file)
@@ -58,9 +58,9 @@ struct _NewsGroupInfo
 
 Folder *news_folder_new                (const gchar    *name,
                                         const gchar    *folder);
-void    news_folder_destroy            (NewsFolder     *folder);
+void    news_folder_destroy            (Folder         *folder);
 
-void news_session_destroy              (NNTPSession    *session);
+void news_session_destroy              (Session        *session);
 NNTPSession *news_session_get          (Folder         *folder);
 
 GSList *news_get_article_list          (Folder         *folder,
index 391bb17..1af1634 100644 (file)
 #include <glib.h>
 
 #include "session.h"
-#include "imap.h"
-#include "news.h"
-#include "smtp.h"
 
 void session_destroy(Session *session)
 {
        g_return_if_fail(session != NULL);
+       g_return_if_fail(session->destroy != NULL);
 
-       switch (session->type) {
-       case SESSION_IMAP:
-               imap_session_destroy(IMAP_SESSION(session));
-               break;
-       case SESSION_NEWS:
-               news_session_destroy(NNTP_SESSION(session));
-               break;
-       case SESSION_SMTP:
-               smtp_session_destroy(SMTP_SESSION(session));
-               break;
-       default:
-               break;
-       }
-
+       session->destroy(session);
        g_free(session->server);
        g_free(session);
 }
index 39b83c8..9c88f81 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -54,6 +54,8 @@ struct _Session
        time_t last_access_time;
 
        gpointer data;
+
+       void (*destroy)         (Session        *session);
 };
 
 void session_destroy   (Session        *session);
index 8a2399f..d4066fc 100644 (file)
@@ -127,6 +127,9 @@ Session *smtp_session_new(const gchar *server, gushort port,
        SESSION(session)->phase            = SESSION_READY;
        SESSION(session)->last_access_time = 0;
        SESSION(session)->data             = NULL;
+
+       SESSION(session)->destroy          = smtp_session_destroy;
+
        session->avail_auth_type           = avail_auth_type;
        session->user                      = user ? g_strdup(user) : NULL;
        session->pass                      = pass ? g_strdup(pass) :
@@ -135,13 +138,13 @@ Session *smtp_session_new(const gchar *server, gushort port,
        return SESSION(session);
 }
 
-void smtp_session_destroy(SMTPSession *session)
+void smtp_session_destroy(Session *session)
 {
-       sock_close(SESSION(session)->sock);
-       SESSION(session)->sock = NULL;
+       sock_close(session->sock);
+       session->sock = NULL;
 
-       g_free(session->user);
-       g_free(session->pass);
+       g_free(SMTP_SESSION(session)->user);
+       g_free(SMTP_SESSION(session)->pass);
 }
 
 gint smtp_from(SMTPSession *session, const gchar *from,
index e1a8196..0ea9324 100644 (file)
@@ -77,7 +77,7 @@ Session *smtp_session_new     (const gchar    *server,
                                 const gchar    *user,
                                 const gchar    *pass);
 #endif
-void smtp_session_destroy      (SMTPSession    *session);
+void smtp_session_destroy      (Session        *session);
 
 gint smtp_from                 (SMTPSession    *session,
                                 const gchar    *from,
index ed8314c..39b99fe 100644 (file)
@@ -1575,6 +1575,9 @@ gboolean file_exist(const gchar *file, gboolean allow_fifo)
 {
        struct stat s;
 
+       if (file == NULL)
+               return FALSE;
+
        if (stat(file, &s) < 0) {
                if (ENOENT != errno) FILE_OP_ERROR(file, "stat");
                return FALSE;
@@ -1590,6 +1593,9 @@ gboolean is_dir_exist(const gchar *dir)
 {
        struct stat s;
 
+       if (dir == NULL)
+               return FALSE;
+
        if (stat(dir, &s) < 0) {
                if (ENOENT != errno) FILE_OP_ERROR(dir, "stat");
                return FALSE;
@@ -1605,6 +1611,9 @@ gboolean is_file_entry_exist(const gchar *file)
 {
        struct stat s;
 
+       if (file == NULL)
+               return FALSE;
+
        if (stat(file, &s) < 0) {
                if (ENOENT != errno) FILE_OP_ERROR(file, "stat");
                return FALSE;
@@ -1685,11 +1694,13 @@ gint remove_all_files(const gchar *dir)
 
        if (chdir(dir) < 0) {
                FILE_OP_ERROR(dir, "chdir");
+               g_free(prev_dir);
                return -1;
        }
 
        if ((dp = opendir(".")) == NULL) {
                FILE_OP_ERROR(dir, "opendir");
+               g_free(prev_dir);
                return -1;
        }
 
@@ -1726,11 +1737,13 @@ gint remove_numbered_files(const gchar *dir, guint first, guint last)
 
        if (chdir(dir) < 0) {
                FILE_OP_ERROR(dir, "chdir");
+               g_free(prev_dir);
                return -1;
        }
 
        if ((dp = opendir(".")) == NULL) {
                FILE_OP_ERROR(dir, "opendir");
+               g_free(prev_dir);
                return -1;
        }
 
@@ -1775,11 +1788,13 @@ gint remove_expired_files(const gchar *dir, guint hours)
 
        if (chdir(dir) < 0) {
                FILE_OP_ERROR(dir, "chdir");
+               g_free(prev_dir);
                return -1;
        }
 
        if ((dp = opendir(".")) == NULL) {
                FILE_OP_ERROR(dir, "opendir");
+               g_free(prev_dir);
                return -1;
        }