commit e847e2088989ada80de24c9ffbcfa0c9ca59d4f4
parent 7207f4a7942518cc0049afbf48f42a8670f2aa33
Author: Oliver Lowe <o@olowe.co>
Date: Wed, 27 Aug 2025 17:54:37 +1000
Drop Face, X-Face header support
Not used
Diffstat:
9 files changed, 10 insertions(+), 447 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
@@ -48,7 +48,6 @@ claws_mail_SOURCES = \
addritem.c \
advsearch.c \
alertpanel.c \
- autofaces.c \
avatars.c \
compose.c \
customheader.c \
@@ -142,7 +141,6 @@ claws_mailinclude_HEADERS = \
addrharvest.h \
advsearch.h \
alertpanel.h \
- autofaces.h \
avatars.h \
compose.h \
customheader.h \
diff --git a/src/autofaces.c b/src/autofaces.c
@@ -1,119 +0,0 @@
-
-/*
- * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- * Copyright (C) 2008-2012 Ricardo Mones and the Claws Mail team
- *
- * 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/>.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#include "claws-features.h"
-#endif
-
-#include "defs.h"
-
-#include "utils.h"
-#include "autofaces.h"
-#include "file-utils.h"
-
-static gint get_content_for_any_face(gchar *buf, gint len, gchar *anyname, gint maxlen)
-{
- FILE *xfp;
- gchar *xfile;
- gint lastc;
-
- xfile = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, AUTOFACES_DIR,
- G_DIR_SEPARATOR_S, anyname, NULL);
- buf[0] = '\0';
- if ((xfp = g_fopen(xfile, "rb")) == NULL) {
- g_free(xfile);
- debug_print("header content file '%s' not found\n", anyname);
- return -1;
- }
- if (fgets(buf, (len < maxlen)? len: maxlen, xfp) == NULL) {
- fclose(xfp);
- g_free(xfile);
- g_warning("header content file '%s' read failure", anyname);
- return -2;
- }
- lastc = strlen(buf) - 1; /* remove trailing \n */
- buf[lastc] = (buf[lastc] == '\n')? '\0': buf[lastc];
- fclose(xfp);
- g_free(xfile);
-
- return 0;
-}
-
-static gchar * get_any_face_filename_for_account(gchar *facetype, gchar *accountname)
-{
- gchar *name = NULL;
- gchar *what = NULL;
- if (facetype == NULL || accountname == NULL)
- return NULL;
- if (*facetype == '\0' || *accountname == '\0')
- return NULL;
- what = name = g_strdup_printf("%s.%s", facetype, accountname);
- while (*what) {
- switch (*what) {
- case '/':
- case '\\':
- case '<':
- case '>':
- case ':':
- case '?':
- case '*':
- *what = '_';
- break;
- default:
- if (*what <= ' ') {
- *what = '_';
- }
- break;
- }
- ++what;
- }
- return name;
-}
-
-gint get_default_xface(gchar *buf, gint len) {
- return get_content_for_any_face(buf, len, "xface", MAX_XFACE_LEN);
-}
-
-gint get_account_xface(gchar *buf, gint len, gchar *name) {
- gchar *filename = get_any_face_filename_for_account("xface", name);
- if (filename) {
- gint result = get_content_for_any_face(buf, len, filename, MAX_XFACE_LEN);
- g_free(filename);
- return result;
- }
- g_warning("header xface filename invalid");
- return -1;
-}
-
-gint get_default_face(gchar *buf, gint len) {
- return get_content_for_any_face(buf, len, "face", MAX_FACE_LEN);
-}
-
-gint get_account_face(gchar *buf, gint len, gchar *name) {
- gchar *filename = get_any_face_filename_for_account("face", name);
- if (filename) {
- gint result = get_content_for_any_face(buf, len, filename, MAX_FACE_LEN);
- g_free(filename);
- return result;
- }
- g_warning("header face filename invalid");
- return -1;
-}
diff --git a/src/autofaces.h b/src/autofaces.h
@@ -1,32 +0,0 @@
-/*
- * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- * Copyright (C) 2008-2012 Ricardo Mones and the Claws Mail team
- *
- * 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/>.
- *
- */
-
-#ifndef __AUTOFACES_H__
-#define __AUTOFACES_H__
-
-#define MAX_XFACE_LEN 990
-#define MAX_FACE_LEN 990
-#define AUTOFACES_DIR "autofaces"
-
-gint get_default_xface (gchar *buf, gint len);
-gint get_default_face (gchar *buf, gint len);
-gint get_account_xface (gchar *buf, gint len, gchar *name);
-gint get_account_face (gchar *buf, gint len, gchar *name);
-
-#endif /* __AUTOFACES_H__ */
diff --git a/src/compose.c b/src/compose.c
@@ -96,7 +96,6 @@
#include "combobox.h"
#include "hooks.h"
#include "privacy.h"
-#include "autofaces.h"
#include "headers.h"
#include "file-utils.h"
#include "fence.h"
@@ -6491,20 +6490,6 @@ static gchar *compose_get_header(Compose *compose)
}
}
- /* Automatic Faces and X-Faces */
- if (get_account_xface (buf, sizeof(buf), compose->account->account_name) == 0) {
- g_string_append_printf(header, "X-Face: %s\n", buf);
- }
- else if (get_default_xface (buf, sizeof(buf)) == 0) {
- g_string_append_printf(header, "X-Face: %s\n", buf);
- }
- if (get_account_face (buf, sizeof(buf), compose->account->account_name) == 0) {
- g_string_append_printf(header, "Face: %s\n", buf);
- }
- else if (get_default_face (buf, sizeof(buf)) == 0) {
- g_string_append_printf(header, "Face: %s\n", buf);
- }
-
/* get special headers */
for (list = compose->header_list; list; list = list->next) {
ComposeHeaderEntry *headerentry;
diff --git a/src/prefs_common.c b/src/prefs_common.c
@@ -495,10 +495,6 @@ static PrefParam param[] = {
{"display_header", "TRUE", &prefs_common.display_header, P_BOOL,
NULL, NULL, NULL},
- {"display_xface", "TRUE", &prefs_common.display_xface,
- P_BOOL, NULL, NULL, NULL},
- {"save_xface", "TRUE", &prefs_common.save_xface,
- P_BOOL, NULL, NULL, NULL},
{"render_html", "TRUE", &prefs_common.render_html, P_BOOL,
NULL, NULL, NULL},
{"promote_html_part", "FALSE", &prefs_common.promote_html_part, P_BOOL,
diff --git a/src/prefs_common.h b/src/prefs_common.h
@@ -321,8 +321,6 @@ struct _PrefsCommon
gboolean enable_bgcolor;
gboolean recycle_quote_colors;
gboolean display_header;
- gboolean display_xface;
- gboolean save_xface;
gint line_space;
gboolean render_html;
gboolean promote_html_part;
diff --git a/src/prefs_customheader.c b/src/prefs_customheader.c
@@ -543,122 +543,16 @@ static void prefs_custom_header_val_from_file_cb(void)
gchar *contents = NULL;
const gchar *hdr = gtk_entry_get_text(GTK_ENTRY(customhdr.hdr_entry));
- if (!strcmp(hdr, "Face"))
- filename = filesel_select_file_open(_("Choose a PNG file"), NULL);
- else if (!strcmp(hdr, "X-Face"))
- filename = filesel_select_file_open(_("Choose an XBM file"), NULL);
- else
- filename = filesel_select_file_open(_("Choose a text file"), NULL);
-
- if (!strcmp(hdr, "Face") || !strcmp(hdr, "X-Face")) {
- if (filename && is_file_exist(filename)) {
- FILE *fp = NULL;
- gint len;
- gchar inbuf[B64_LINE_SIZE], *outbuf;
- gchar *tmp = NULL;
- gint w, h;
- GdkPixbufFormat *format = gdk_pixbuf_get_file_info(
- filename, &w, &h);
-
- if (format == NULL) {
- alertpanel_error(_("This file isn't an image."));
- g_free(filename);
- return;
- }
- if (w != 48 || h != 48) {
- alertpanel_error(_("The chosen image isn't the correct size (48x48)."));
- g_free(filename);
- return;
- }
- if (!strcmp(hdr, "Face")) {
- if (get_file_size(filename) > 725) {
- alertpanel_error(_("The image is too big; it must be maximum 725 bytes."));
- g_free(filename);
- return;
- }
- if (g_ascii_strcasecmp("png", gdk_pixbuf_format_get_name(format))) {
- alertpanel_error(_("The image isn't in the correct format (PNG)."));
- g_print("%s\n", gdk_pixbuf_format_get_name(format));
- g_free(filename);
- return;
- }
- } else if (!strcmp(hdr, "X-Face")) {
- gchar *tmp = NULL, *cmd = NULL;
- int i = 0;
- if (g_ascii_strcasecmp("xbm", gdk_pixbuf_format_get_name(format))) {
- alertpanel_error(_("The image isn't in the correct format (XBM)."));
- g_print("%s\n", gdk_pixbuf_format_get_name(format));
- g_free(filename);
- return;
- }
- cmd = g_strdup_printf("compface %s", filename);
- tmp = get_command_output(cmd);
- g_free(cmd);
- if (tmp == NULL || *tmp == '\0') {
- alertpanel_error(_("Couldn't call `compface`. Make sure it's in your $PATH."));
- g_free(filename);
- g_free(tmp);
- return;
- }
- if (strstr(tmp, "compface:")) {
- alertpanel_error(_("Compface error: %s"), tmp);
- g_free(filename);
- g_free(tmp);
- return;
- }
- while (tmp[i]) {
- gchar *tmp2 = NULL;
- if (tmp[i] == ' ') {
- i++; continue;
- }
- if (tmp[i] == '\r' || tmp[i] == '\n') {
- i++; continue;
- }
- tmp2 = contents;
- contents = g_strdup_printf("%s%c",tmp2?tmp2:"", tmp[i]);
- g_free(tmp2);
- i++;
- }
- g_free(tmp);
- goto settext;
- }
-
- fp = g_fopen(filename, "rb");
- if (!fp) {
- g_free(filename);
- return;
- }
-
- while ((len = fread(inbuf, sizeof(gchar),
- B64_LINE_SIZE, fp))
- == B64_LINE_SIZE) {
- outbuf = g_base64_encode(inbuf, B64_LINE_SIZE);
-
- tmp = contents;
- contents = g_strconcat(tmp?tmp:"",outbuf, NULL);
- g_free(outbuf);
- g_free(tmp);
- }
- if (len > 0 && feof(fp)) {
- tmp = contents;
- outbuf = g_base64_encode(inbuf, len);
- contents = g_strconcat(tmp?tmp:"",outbuf, NULL);
- g_free(outbuf);
- g_free(tmp);
- }
- fclose(fp);
- }
- } else {
- if (!filename)
- return;
+ filename = filesel_select_file_open(_("Choose a text file"), NULL);
+ if (!filename)
+ return;
- contents = file_read_to_str(filename);
- if (strchr(contents, '\n') || strchr(contents,'\r')) {
- alertpanel_error(_("This file contains newlines."));
- g_free(contents);
- g_free(filename);
- return;
- }
+ contents = file_read_to_str(filename);
+ if (strchr(contents, '\n') || strchr(contents,'\r')) {
+ alertpanel_error(_("This file contains newlines."));
+ g_free(contents);
+ g_free(filename);
+ return;
}
settext:
if (contents && strlen(contents))
@@ -885,16 +779,7 @@ static gboolean prefs_custom_header_selected(GtkTreeSelection *selector,
ENTRY_SET_TEXT(customhdr.hdr_entry, ch->name);
ENTRY_SET_TEXT(customhdr.val_entry, ch->value);
- if (!g_strcmp0("Face",ch->name) && ch->value != NULL) {
- preview = GTK_IMAGE(face_get_from_header (ch->value));
- pixbuf = gtk_image_get_pixbuf(preview);
- gtk_image_set_from_pixbuf (GTK_IMAGE(customhdr.preview), pixbuf);
- gtk_widget_show(customhdr.preview);
- g_object_ref_sink (G_OBJECT(preview));
- }
- else {
- gtk_widget_hide(customhdr.preview);
- }
+ gtk_widget_hide(customhdr.preview);
return TRUE;
}
diff --git a/src/prefs_message.c b/src/prefs_message.c
@@ -47,8 +47,6 @@ typedef struct _MessagePage
GtkWidget *window;
GtkWidget *checkbtn_disphdr;
- GtkWidget *checkbtn_dispxface;
- GtkWidget *checkbtn_savexface;
GtkWidget *checkbtn_html;
GtkWidget *checkbtn_promote_html_part;
@@ -68,8 +66,6 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
GtkWidget *vbox2;
GtkWidget *hbox1;
GtkWidget *checkbtn_disphdr;
- GtkWidget *checkbtn_dispxface;
- GtkWidget *checkbtn_savexface;
GtkWidget *button_edit_disphdr;
GtkWidget *checkbtn_html;
@@ -96,10 +92,6 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
vbox2 = gtkut_get_options_frame(vbox1, &frame, _("Headers"));
- PACK_CHECK_BUTTON(vbox2, checkbtn_dispxface,
- _("Display Face in message view"));
- PACK_CHECK_BUTTON(vbox2, checkbtn_savexface,
- _("Save Face in address book if possible"));
hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
gtk_widget_show (hbox1);
@@ -182,11 +174,6 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
gtk_widget_show (hbox2);
gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_dispxface),
- prefs_common.display_xface);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_savexface),
- prefs_common.save_xface);
-
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_disphdr),
prefs_common.display_header);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_html),
@@ -201,8 +188,6 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
prefs_common.line_space);
prefs_message->window = GTK_WIDGET(window);
- prefs_message->checkbtn_dispxface = checkbtn_dispxface;
- prefs_message->checkbtn_savexface = checkbtn_savexface;
prefs_message->checkbtn_disphdr = checkbtn_disphdr;
prefs_message->checkbtn_html = checkbtn_html;
prefs_message->checkbtn_promote_html_part = checkbtn_promote_html_part;
@@ -217,10 +202,6 @@ static void prefs_message_save(PrefsPage *_page)
{
MessagePage *page = (MessagePage *) _page;
- prefs_common.display_xface = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(page->checkbtn_dispxface));
- prefs_common.save_xface = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(page->checkbtn_savexface));
prefs_common.display_header = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(page->checkbtn_disphdr));
prefs_common.render_html = gtk_toggle_button_get_active(
diff --git a/src/textview.c b/src/textview.c
@@ -1689,56 +1689,6 @@ static GPtrArray *textview_scan_header(TextView *textview, FILE *fp)
return sorted_headers;
}
-static void textview_show_avatar(TextView *textview)
-{
- GtkAllocation allocation;
- GtkTextView *text = GTK_TEXT_VIEW(textview->text);
- MsgInfo *msginfo = textview->messageview->msginfo;
- gint x, wx, wy;
- AvatarRender *avatarr;
-
- if (!prefs_common.display_xface)
- goto bail;
-
- avatarr = avatars_avatarrender_new(msginfo);
- hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST, avatarr);
-
- if (!avatarr->image) {
- avatars_avatarrender_free(avatarr);
- goto bail;
- }
-
- if (textview->image)
- gtk_widget_destroy(textview->image);
-
- textview->image = avatarr->image;
- textview->avatar_type = avatarr->type;
- avatarr->image = NULL; /* avoid destroying */
- avatars_avatarrender_free(avatarr);
-
- gtk_widget_set_name(GTK_WIDGET(textview->image), "textview_avatar");
- gtk_widget_show(textview->image);
-
- gtk_widget_get_allocation(textview->text, &allocation);
- x = allocation.width - WIDTH - 5;
-
- gtk_text_view_buffer_to_window_coords(
- GTK_TEXT_VIEW(textview->text),
- GTK_TEXT_WINDOW_TEXT, x, 5, &wx, &wy);
-
- gtk_text_view_add_child_in_window(text, textview->image,
- GTK_TEXT_WINDOW_TEXT, wx, wy);
-
- gtk_widget_show_all(textview->text);
-
- return;
-bail:
- if (textview->image)
- gtk_widget_destroy(textview->image);
- textview->image = NULL;
- textview->avatar_type = 0;
-}
-
void textview_show_icon(TextView *textview, const gchar *stock_id)
{
GtkAllocation allocation;
@@ -1803,80 +1753,6 @@ static void textview_save_contact_pic(TextView *textview)
g_free(filename);
}
-static void textview_show_contact_pic(TextView *textview)
-{
- MsgInfo *msginfo = textview->messageview->msginfo;
- GtkTextView *text = GTK_TEXT_VIEW(textview->text);
- gint x, wx, wy;
- gchar *filename = NULL;
- GError *error = NULL;
- GdkPixbuf *picture = NULL;
- gint w, h;
- GtkAllocation allocation;
-
- if (!prefs_common.display_xface)
- goto bail;
-
- if (msginfo->extradata && msginfo->extradata->avatars)
- return;
-
- if (textview->image)
- gtk_widget_destroy(textview->image);
-
- filename = addrindex_get_picture_file(msginfo->from);
-
- if (!filename)
- goto bail;
- if (!is_file_exist(filename)) {
- g_free(filename);
- goto bail;
- }
-
- gdk_pixbuf_get_file_info(filename, &w, &h);
-
- if (w > 48 || h > 48)
- picture = gdk_pixbuf_new_from_file_at_scale(filename,
- 48, 48, TRUE, &error);
- else
- picture = gdk_pixbuf_new_from_file(filename, &error);
-
- if (error) {
- debug_print("Failed to import image: %s\n",
- error->message);
- g_error_free(error);
- goto bail;
- }
- g_free(filename);
-
- if (picture) {
- textview->image = gtk_image_new_from_pixbuf(picture);
- g_object_unref(picture);
- }
- cm_return_if_fail(textview->image != NULL);
-
- gtk_widget_set_name(GTK_WIDGET(textview->image), "textview_contact_pic");
- gtk_widget_show(textview->image);
-
- gtk_widget_get_allocation(textview->text, &allocation);
- x = allocation.width - WIDTH - 5;
-
- gtk_text_view_buffer_to_window_coords(
- GTK_TEXT_VIEW(textview->text),
- GTK_TEXT_WINDOW_TEXT, x, 5, &wx, &wy);
-
- gtk_text_view_add_child_in_window(text, textview->image,
- GTK_TEXT_WINDOW_TEXT, wx, wy);
-
- gtk_widget_show_all(textview->text);
-
- return;
-bail:
- if (textview->image)
- gtk_widget_destroy(textview->image);
- textview->image = NULL;
- textview->avatar_type = 0;
-}
-
static void textview_show_header(TextView *textview, GPtrArray *headers)
{
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
@@ -1957,11 +1833,6 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "\n", 1,
"header", NULL);
}
-
- textview_show_avatar(textview);
- if (prefs_common.save_xface)
- textview_save_contact_pic(textview);
- textview_show_contact_pic(textview);
}
gboolean textview_search_string(TextView *textview, const gchar *str,