talons

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

commit fdc4bd531cf10e88b140b509d4998b76ec8c077a
parent 17a2e58047a50a92b60ba544673b4ecc365a9420
Author: Oliver Lowe <o@olowe.co>
Date:   Fri,  5 Sep 2025 17:00:24 +1000

Dump more globals used once

Diffstat:
Msrc/account.c | 35++++++++++++-----------------------
Msrc/common/defs.h | 33---------------------------------
Msrc/common/utils.c | 22+++-------------------
Msrc/folder.c | 15++++++---------
Msrc/gtk/gtkutils.c | 5+----
Msrc/imap.c | 7++-----
Msrc/main.c | 1-
Msrc/manual.c | 58++++------------------------------------------------------
Msrc/manual.h | 5+++--
Msrc/prefs_account.c | 28++++++++--------------------
Msrc/prefs_account.h | 2+-
Msrc/prefs_common.c | 12+++---------
Msrc/prefs_common.h | 1-
Msrc/prefs_themes.c | 2+-
Msrc/summaryview.c | 2+-
15 files changed, 45 insertions(+), 183 deletions(-)

diff --git a/src/account.c b/src/account.c @@ -1016,23 +1016,11 @@ static void account_clone(GtkWidget *widget, gpointer data) #undef ACP_FDUP #undef ACP_FASSIGN -static void account_empty_cache(PrefsAccount *ac_prefs) +void account_empty_cache(const char *server) { - gchar *cache_dir; - - cache_dir = prefs_account_cache_dir(ac_prefs, FALSE); - if (cache_dir == NULL) - return; /* no cache dir, nothing to do */ - + char *cache_dir = prefs_account_cache_dir(server, NULL); if (is_dir_exist(cache_dir) && remove_dir_recursive(cache_dir) < 0) { g_warning("can't remove directory '%s'", cache_dir); - } else { - gchar *server_dir = prefs_account_cache_dir(ac_prefs, TRUE); - if (g_rmdir(server_dir) == 0) - debug_print("Removed empty cache server directory\n"); - else - debug_print("Cache server directory not empty: not removed\n"); - g_free(server_dir); } g_free(cache_dir); } @@ -1040,7 +1028,6 @@ static void account_empty_cache(PrefsAccount *ac_prefs) static void account_delete(GtkWidget *widget, gpointer data) { PrefsAccount *ac_prefs; - gchar buf[BUFFSIZE]; GList *list; Folder *folder; @@ -1048,12 +1035,14 @@ static void account_delete(GtkWidget *widget, gpointer data) if (ac_prefs == NULL) return; - g_snprintf(buf, sizeof(buf), - _("Do you really want to delete the account '%s'?"), - ac_prefs->account_name ? ac_prefs->account_name : - _("(Untitled)")); - if (alertpanel_full(_("Delete account"), buf, - NULL, _("_Cancel"), "edit-delete-symbolic", _("_Delete"), + char msg[BUFSIZ]; + char *name = ac_prefs->account_name; + if (!name) + strlcpy(msg, "Do you really want to delete this account?", sizeof(msg)); + else + snprintf(msg, sizeof(msg), "Do you really want to delete the account '%s'?", name); + if (alertpanel_full("Delete account", msg, + NULL, "_Cancel", "edit-delete-symbolic", "_Delete", NULL, NULL, ALERTFOCUS_FIRST, FALSE, NULL, ALERT_WARNING) != G_ALERTALTERNATE) return; @@ -1089,8 +1078,8 @@ static void account_delete(GtkWidget *widget, gpointer data) passwd_store_delete_block(PWS_ACCOUNT, uid); g_free(uid); - debug_print("Removing cache directory of this account...\n"); - account_empty_cache(ac_prefs); + if (ac_prefs->protocol == A_IMAP4) + account_empty_cache(ac_prefs->recv_server); folder_write_list(); } diff --git a/src/common/defs.h b/src/common/defs.h @@ -24,62 +24,34 @@ #define QUEUE_DIR "queue" #define DRAFT_DIR "draft" #define TRASH_DIR "trash" -#define TAGS_DIR "tagsdb" #define RC_DIR ".claws-mail" -#define IMAP_CACHE_DIR "imapcache" -#define HEADER_CACHE_DIR "headercache" -#define MIME_TMP_DIR "mimetmp" #define COMMON_RC "clawsrc" #define ACCOUNT_RC "accountrc" #define OAUTH2_RC "oauth2rc" #define CUSTOM_HEADER_RC "customheaderrc" #define DISPLAY_HEADER_RC "dispheaderrc" #define FOLDERITEM_RC "folderitemrc" -#define FILTERING_RC "filteringrc" -#define MATCHER_RC "matcherrc" #define MENU_RC "menurc" -#define TAGS_RC "tagsrc" #define PASSWORD_STORE_RC "passwordstorerc" -#define MESSAGE_SEARCH_HISTORY "messagesearch_history" #define COMPOSE_SAVE_TO_HISTORY "compose_save_to_history" -#define ADDRESSBOOK_CUSTOM_ATTRIBUTES "attributesrc" -#define TEMPLATE_DIR "templates" -#define TMP_DIR "tmp" #define ADDRESS_BOOK "addressbook.xml" #define ADDRBOOK_DIR "addrbook" -#define MANUAL_HTML_INDEX "claws-mail-manual.html" #define HOMEPAGE_URI "https://www.claws-mail.org/" -#define MANUAL_URI "https://www.claws-mail.org/documentation.php" -#define FAQ_URI "https://www.claws-mail.org/faq/index.php" -#define BUGZILLA_URI "https://www.thewildbeast.co.uk/claws-mail/bugzilla/enter_bug.cgi" -#define THEMES_URI "https://www.claws-mail.org/themes.php" -#define TOOLS_URI "https://www.claws-mail.org/tools.php" -#define MAILING_LIST_URI "https://www.claws-mail.org/MLs.php" -#define WELCOME_MSG_ADDR "noreply@claws-mail.org" #define USERS_ML_URI "https://lists.claws-mail.org/cgi-bin/mailman/listinfo/users" -#define GPL_URI "https://www.gnu.org/licenses/gpl.html" #define DONATE_URI "https://www.claws-mail.org/donations.php" -#define CONFIG_VERSIONS_URI "https://www.claws-mail.org/cvc.php" #define RELEASE_NOTES_FILE "RELEASE_NOTES" #define FOLDER_LIST "folderlist.xml" -#define CACHE_FILE ".claws_cache" -#define MARK_FILE ".claws_mark" -#define TAGS_FILE ".claws_tags" #define CACHE_VERSION 24 #define MARK_VERSION 2 -#define TAGS_VERSION 1 #define ACTIONS_RC "actionsrc" #define COMMAND_HISTORY "command_history" #define DEFAULT_SIGNATURE ".signature" #define DEFAULT_INC_PATH "/usr/bin/mh/inc" -#define DEFAULT_INC_PROGRAM "inc" #define DEFAULT_SENDMAIL_CMD "/usr/sbin/sendmail -t -i" #define DEFAULT_BROWSER_CMD "firefox '%s'" #define DEFAULT_EDITOR_CMD "gedit '%s'" -#define DEFAULT_IMAGE_VIEWER_CMD "display '%s'" -#define DEFAULT_AUDIO_PLAYER_CMD "play '%s'" #define BUFFSIZE 8192 @@ -88,15 +60,12 @@ #define BORDER_WIDTH 2 #define CTREE_INDENT 18 #define FOLDER_SPACING 4 -#define MAX_ENTRY_LENGTH 8191 #define COLOR_DIM ((double)35000 / 65535) #define UI_REFRESH_INTERVAL 50000 /* usec */ -#define FOLDER_UPDATE_INTERVAL 1500 /* msec */ #define PROGRESS_UPDATE_INTERVAL 200 /* msec */ #define SESSION_TIMEOUT_INTERVAL 60 /* sec */ #define MAX_HISTORY_SIZE 32 #define HSPACING_NARROW 4 -#define HSPACING_NARROW_2 2 #define VSPACING 10 #define VSPACING_NARROW 4 #define VSPACING_NARROW_2 2 @@ -105,8 +74,6 @@ #define DEFAULT_PIXMAP_THEME "INTERNAL_DEFAULT" -#define AVATAR_NONE 0 -#define AVATAR_XFACE 1 #define AVATAR_FACE 2 #endif /* __DEFS_H__ */ diff --git a/src/common/utils.c b/src/common/utils.c @@ -1446,24 +1446,12 @@ const gchar *get_mail_base_dir(void) return get_home_dir(); } -const gchar *get_imap_cache_dir(void) -{ - static gchar *imap_cache_dir = NULL; - - if (!imap_cache_dir) - imap_cache_dir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, - IMAP_CACHE_DIR, NULL); - - return imap_cache_dir; -} - const gchar *get_mime_tmp_dir(void) { static gchar *mime_tmp_dir = NULL; if (!mime_tmp_dir) - mime_tmp_dir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, - MIME_TMP_DIR, NULL); + mime_tmp_dir = g_strconcat(get_rc_dir(), "/mimetmp", NULL); return mime_tmp_dir; } @@ -1473,9 +1461,7 @@ const gchar *get_template_dir(void) static gchar *template_dir = NULL; if (!template_dir) - template_dir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, - TEMPLATE_DIR, NULL); - + template_dir = g_strconcat(get_rc_dir(), "/templates", NULL); return template_dir; } @@ -1494,9 +1480,7 @@ const gchar *get_tmp_dir(void) static gchar *tmp_dir = NULL; if (!tmp_dir) - tmp_dir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, - TMP_DIR, NULL); - + tmp_dir = g_strconcat(get_rc_dir(), "/tmp", NULL); return tmp_dir; } diff --git a/src/folder.c b/src/folder.c @@ -3837,7 +3837,7 @@ static gchar *folder_item_get_cache_file(FolderItem *item) cm_return_val_if_fail(path != NULL, NULL); if (!is_dir_exist(path)) make_dir_hier(path); - file = g_strconcat(path, G_DIR_SEPARATOR_S, CACHE_FILE, NULL); + file = g_strconcat(path, "/.claws_cache", NULL); g_free(path); return file; @@ -3856,12 +3856,14 @@ static gchar *folder_item_get_mark_file(FolderItem *item) cm_return_val_if_fail(path != NULL, NULL); if (!is_dir_exist(path)) make_dir_hier(path); - file = g_strconcat(path, G_DIR_SEPARATOR_S, MARK_FILE, NULL); + file = g_strconcat(path, "/.claws_mark", NULL); g_free(path); return file; } +const char *tags_dir = ".claws_tags"; + static gchar *folder_item_get_tags_file(FolderItem *item) { gchar *path; @@ -3878,16 +3880,11 @@ static gchar *folder_item_get_tags_file(FolderItem *item) identifier = folder_item_get_identifier(item); cm_return_val_if_fail(identifier != NULL, NULL); - path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, - TAGS_DIR, G_DIR_SEPARATOR_S, - identifier, NULL); - + path = g_strconcat(get_rc_dir(), "/tagsdb/", identifier, NULL); g_free(identifier); - if (!is_dir_exist(path)) make_dir_hier(path); - - file = g_strconcat(path, G_DIR_SEPARATOR_S, TAGS_FILE, NULL); + file = g_strconcat(path, "/.claws_tags", NULL); g_free(path); diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c @@ -92,10 +92,7 @@ void gtkut_stock_button_add_help(GtkWidget *bbox, GtkWidget **help_btn) gtk_widget_set_can_default(*help_btn, TRUE); gtk_box_pack_end(GTK_BOX (bbox), *help_btn, TRUE, TRUE, 0); - gtk_button_box_set_child_secondary(GTK_BUTTON_BOX (bbox), - *help_btn, TRUE); - gtk_widget_set_sensitive(*help_btn, - manual_available(MANUAL_MANUAL_CLAWS)); + gtk_button_box_set_child_secondary(GTK_BUTTON_BOX (bbox), *help_btn, TRUE); gtk_widget_show(*help_btn); } diff --git a/src/imap.c b/src/imap.c @@ -2530,13 +2530,10 @@ static gchar *imap_item_get_path(Folder *folder, FolderItem *item) g_return_val_if_fail(folder != NULL, NULL); g_return_val_if_fail(folder->account != NULL, NULL); g_return_val_if_fail(item != NULL, NULL); - folder_path = prefs_account_cache_dir(folder->account, FALSE); - - g_return_val_if_fail(folder_path != NULL, NULL); + folder_path = prefs_account_cache_dir(folder->account->recv_server, folder->account->userid); item_path = g_strdup(item->path); - - if (g_path_is_absolute(folder_path)) { + if (g_path_is_absolute(folder_path)) { if (item_path) path = g_strconcat(folder_path, G_DIR_SEPARATOR_S, item_path, NULL); diff --git a/src/main.c b/src/main.c @@ -429,7 +429,6 @@ int main(int argc, char *argv[]) CHDIR_RETURN_VAL_IF_FAIL(get_rc_dir(), 1); MAKE_DIR_IF_NOT_EXIST(get_mail_base_dir()); - MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir()); MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir()); MAKE_DIR_IF_NOT_EXIST(get_tmp_dir()); diff --git a/src/manual.c b/src/manual.c @@ -23,7 +23,6 @@ #include <string.h> #include <locale.h> -#include "prefs_common.h" #include "manual.h" #include "utils.h" @@ -64,62 +63,13 @@ static gchar *get_local_path_with_locale(gchar *rootpath) return dir; } -gboolean manual_available(ManualType type) -{ - gboolean ret = FALSE; - gchar *dir = NULL, *uri = NULL; - - switch (type) { - case MANUAL_MANUAL_CLAWS: - dir = get_local_path_with_locale("/dev/null"); // TODO: was MANUALDIR - if (dir != NULL) { - uri = g_strconcat(dir, G_DIR_SEPARATOR_S, MANUAL_HTML_INDEX, NULL); - g_free(dir); - if (is_file_exist(uri)) - ret = TRUE; - else - ret = FALSE; - g_free(uri); - } - break; - default: - ret = FALSE; - } - - return ret; -} - void manual_open(ManualType type, gchar *url_anchor) { - gchar *uri = NULL; - gchar *dir; - - switch (type) { - case MANUAL_MANUAL_CLAWS: - dir = get_local_path_with_locale("/dev/null"); // TODO: was MANUALDIR - if (dir != NULL) { - gchar *tmp_anchor = NULL; - if (url_anchor && *url_anchor != '\0') - tmp_anchor = g_strconcat("#", url_anchor, NULL); - uri = g_strconcat("file://", - dir, G_DIR_SEPARATOR_S, MANUAL_HTML_INDEX, - tmp_anchor, - NULL); - g_free(tmp_anchor); - g_free(dir); - } else { - uri = g_strconcat(MANUAL_URI, NULL); - } - break; - case MANUAL_FAQ_CLAWS: - uri = g_strconcat(FAQ_URI, NULL); - break; - - default: - break; + if (type == MANUAL_FAQ_CLAWS) { + open_uri("https://www.claws-mail.org/faq/index.php", "xdg-open '%s'"); + return; } - open_uri(uri, prefs_common_get_uri_cmd()); - g_free(uri); + open_uri("https://www.claws-mail.org/documentation.php", "xdg-open '%s'"); } void manual_open_with_anchor_cb(GtkWidget *widget, gchar *url_anchor) diff --git a/src/manual.h b/src/manual.h @@ -14,12 +14,14 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * */ #ifndef __MANUAL_H__ #define __MANUAL_H__ +#include <gtk/gtk.h> + typedef enum { MANUAL_MANUAL_CLAWS, @@ -37,7 +39,6 @@ typedef enum #define MANUAL_ANCHOR_PLUGINS "adv_plugins" #define MANUAL_ANCHOR_TAGS "adv_tags" -gboolean manual_available (ManualType type); void manual_open (ManualType type, gchar *url_anchor); void manual_open_with_anchor_cb(GtkWidget *widget, gchar *url_anchor); diff --git a/src/prefs_account.c b/src/prefs_account.c @@ -4680,27 +4680,15 @@ void prefs_account_unregister_page(PrefsPage *page) prefs_pages = g_slist_remove(prefs_pages, page); } -gchar *prefs_account_cache_dir(PrefsAccount *ac_prefs, gboolean for_server) +char *prefs_account_cache_dir(const char *server, const char *userid) { - gchar *dir = NULL; - - if (ac_prefs->protocol == A_IMAP4) { - if (for_server) { - dir = g_strconcat(get_imap_cache_dir(), - G_DIR_SEPARATOR_S, - ac_prefs->recv_server, - NULL); - } else { - dir = g_strconcat(get_imap_cache_dir(), - G_DIR_SEPARATOR_S, - ac_prefs->recv_server, - G_DIR_SEPARATOR_S, - ac_prefs->userid, - NULL); - } - } - - return dir; + char dir[PATH_MAX]; + snprintf(dir, sizeof(dir), "%s/imapcache/%s", get_rc_dir(), server); + if (userid == NULL) + return strdup(dir); + strlcat(dir, "/", sizeof(dir)); + strlcat(dir, userid, sizeof(dir)); + return strdup(dir); } static void prefs_account_receive_itv_spinbutton_value_changed_cb(GtkWidget *w, gpointer data) diff --git a/src/prefs_account.h b/src/prefs_account.h @@ -217,6 +217,6 @@ gchar *prefs_account_generate_msgid(PrefsAccount *account); void prefs_account_register_page (PrefsPage *page); void prefs_account_unregister_page (PrefsPage *page); -gchar *prefs_account_cache_dir (PrefsAccount *ac_prefs, gboolean for_server); +char *prefs_account_cache_dir (const char *server, const char *userid); #endif /* PREFS_ACCOUNT_H */ diff --git a/src/prefs_common.c b/src/prefs_common.c @@ -978,7 +978,7 @@ void prefs_common_read_config(void) prefs_common.mime_open_cmd_history = prefs_common_read_history(COMMAND_HISTORY); prefs_common.message_search_history = - prefs_common_read_history(MESSAGE_SEARCH_HISTORY); + prefs_common_read_history("messagesearch_history"); prefs_common.compose_save_to_history = prefs_common_read_history(COMPOSE_SAVE_TO_HISTORY); } @@ -1056,14 +1056,8 @@ void prefs_common_write_config(void) { prefs_write_config(param, "Common", COMMON_RC); - prefs_common_save_history(COMMAND_HISTORY, - prefs_common.mime_open_cmd_history); - prefs_common_save_history(COMPOSE_SAVE_TO_HISTORY, - prefs_common.compose_save_to_history); - - prefs_common_save_history_to_dir(ADDRBOOK_DIR, - ADDRESSBOOK_CUSTOM_ATTRIBUTES, - prefs_common.addressbook_custom_attributes); + prefs_common_save_history(COMMAND_HISTORY, prefs_common.mime_open_cmd_history); + prefs_common_save_history(COMPOSE_SAVE_TO_HISTORY, prefs_common.compose_save_to_history); } /* make a copy of string 'in' into buffer 'out'. un-escape \ sequences. diff --git a/src/prefs_common.h b/src/prefs_common.h @@ -339,7 +339,6 @@ struct _PrefsCommon gboolean addressbook_use_editaddress_dialog; gint addressbook_hpaned_pos; gint addressbook_vpaned_pos; - GList *addressbook_custom_attributes; /* Interface */ LayoutType layout_mode; diff --git a/src/prefs_themes.c b/src/prefs_themes.c @@ -888,7 +888,7 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin gtk_box_pack_start (GTK_BOX (hbox3), btn_install, FALSE, FALSE, 0); gtk_widget_set_can_default (btn_install, TRUE); - btn_more = gtk_link_button_new_with_label(THEMES_URI, _("Get more...")); + btn_more = gtk_link_button_new_with_label("https://www.claws-mail.org/themes.php", "Get more..."); gtk_widget_show (btn_more); gtk_box_pack_start (GTK_BOX (hbox3), btn_more, FALSE, FALSE, 0); diff --git a/src/summaryview.c b/src/summaryview.c @@ -514,7 +514,7 @@ SummaryView *summary_create(MainWindow *mainwin) statlabel_folder = gtk_label_new(""); gtk_widget_show(statlabel_folder); - gtk_box_pack_start(GTK_BOX(hbox_l), statlabel_folder, FALSE, FALSE, HSPACING_NARROW_2); + gtk_box_pack_start(GTK_BOX(hbox_l), statlabel_folder, FALSE, FALSE, 2); statlabel_select = gtk_label_new(""); gtk_widget_show(statlabel_select); gtk_box_pack_start(GTK_BOX(hbox_l), statlabel_select, FALSE, FALSE, 12);