talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 7eae809d6b7c04211b828782b824414e218c19e6
parent e15a894c7105210c4cc3b14a8975aa321214e5ce
Author: Oliver Lowe <o@olowe.co>
Date:   Wed, 13 Aug 2025 11:36:12 +1000

Write folder_init twice

No need for a whole separate file and functions

Diffstat:
Msrc/Makefile.am | 1-
Msrc/imap.c | 22+++++++---------------
Msrc/news.c | 17++++-------------
Dsrc/remotefolder.c | 40----------------------------------------
Msrc/remotefolder.h | 5-----
5 files changed, 11 insertions(+), 74 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am @@ -172,7 +172,6 @@ claws_mail_SOURCES = \ quote_fmt_lex.l \ quote_fmt_parse.y \ recv.c \ - remotefolder.c \ send_message.c \ setup.c \ sourcewindow.c \ diff --git a/src/imap.c b/src/imap.c @@ -186,10 +186,6 @@ struct _IMAPFolderItem static XMLTag *imap_item_get_xml(Folder *folder, FolderItem *item); static void imap_item_set_xml(Folder *folder, FolderItem *item, XMLTag *tag); -static void imap_folder_init (Folder *folder, - const gchar *name, - const gchar *path); - static Folder *imap_folder_new (const gchar *name, const gchar *path); static void imap_folder_destroy (Folder *folder); @@ -774,8 +770,10 @@ static Folder *imap_folder_new(const gchar *name, const gchar *path) folder = (Folder *)g_new0(IMAPFolder, 1); folder->klass = &imap_class; - imap_folder_init(folder, name, path); - + folder_init(folder, name); + REMOTE_FOLDER(folder)->session = NULL; + IMAP_FOLDER(folder)->search_charset_supported = TRUE; + IMAP_FOLDER(folder)->search_charset = g_strdup(conv_get_locale_charset_str_no_utf8()); return folder; } @@ -786,18 +784,12 @@ static void imap_folder_destroy(Folder *folder) g_free(IMAP_FOLDER(folder)->search_charset); - folder_remote_folder_destroy(REMOTE_FOLDER(folder)); + RemoteFolder *rfolder = REMOTE_FOLDER(folder); + if (rfolder->session) + session_destroy(rfolder->session); imap_done(folder); } -static void imap_folder_init(Folder *folder, const gchar *name, - const gchar *path) -{ - folder_remote_folder_init((Folder *)folder, name, path); - IMAP_FOLDER(folder)->search_charset_supported = TRUE; - IMAP_FOLDER(folder)->search_charset = g_strdup(conv_get_locale_charset_str_no_utf8()); -} - static FolderItem *imap_folder_item_new(Folder *folder) { IMAPFolderItem *item; diff --git a/src/news.c b/src/news.c @@ -89,9 +89,6 @@ struct _NewsSession gchar *group; }; -static void news_folder_init(Folder *folder, const gchar *name, - const gchar *path); - static Folder *news_folder_new (const gchar *name, const gchar *folder); static void news_folder_destroy (Folder *folder); @@ -240,11 +237,9 @@ int news_folder_locked(Folder *folder) static Folder *news_folder_new(const gchar *name, const gchar *path) { Folder *folder; - folder = (Folder *)g_new0(NewsFolder, 1); folder->klass = &news_class; - news_folder_init(folder, name, path); - + folder_init(folder, name); return folder; } @@ -261,13 +256,9 @@ static void news_folder_destroy(Folder *folder) g_free(dir); nntp_done(folder); - folder_remote_folder_destroy(REMOTE_FOLDER(folder)); -} - -static void news_folder_init(Folder *folder, const gchar *name, - const gchar *path) -{ - folder_remote_folder_init(folder, name, path); + RemoteFolder *rfolder = REMOTE_FOLDER(folder); + if (rfolder->session) + session_destroy(rfolder->session); } static void news_session_destroy(Session *session) diff --git a/src/remotefolder.c b/src/remotefolder.c @@ -1,40 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2002-2012 by the Claws Mail Team and 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -#include "config.h" - -#include <glib.h> - -#include "utils.h" -#include "remotefolder.h" - -void folder_remote_folder_init(Folder *folder, const gchar *name, - const gchar *path) -{ - folder_init(folder, name); - REMOTE_FOLDER(folder)->session = NULL; -} - -void folder_remote_folder_destroy(RemoteFolder *rfolder) -{ - cm_return_if_fail(rfolder != NULL); - - if (rfolder->session) - session_destroy(rfolder->session); -} diff --git a/src/remotefolder.h b/src/remotefolder.h @@ -38,9 +38,4 @@ struct _RemoteFolder gboolean connecting; }; -void folder_remote_folder_init (Folder *folder, - const gchar *name, - const gchar *path); -void folder_remote_folder_destroy(RemoteFolder *rfolder); - #endif /* REMOTEFOLDER_H */