[Commits] [SCM] claws branch, master, updated. 3.16.0-191-g0c28ce4
wwp at claws-mail.org
wwp at claws-mail.org
Thu Jun 7 13:08:00 CEST 2018
The branch, master has been updated
via 0c28ce4c371ae2132cc5b83e418ff36541f3b5ec (commit)
from 494fd9e4405ad4779719618a9e224ea65c0c02b8 (commit)
Summary of changes:
src/account.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++
src/account.h | 5 ++++
src/procmime.c | 7 ++++-
src/quote_fmt_parse.y | 6 +++--
src/textview.c | 23 ++++++++++++++--
5 files changed, 108 insertions(+), 5 deletions(-)
- Log -----------------------------------------------------------------
commit 0c28ce4c371ae2132cc5b83e418ff36541f3b5ec
Author: wwp <wwp at free.fr>
Date: Thu Jun 7 13:06:58 2018 +0200
Make use of all signature separators defined in accounts instead
of just the hardcoded standard one we use.
diff --git a/src/account.c b/src/account.c
index 527b16d..b3a92da 100644
--- a/src/account.c
+++ b/src/account.c
@@ -1925,3 +1925,75 @@ gboolean password_get(const gchar *user,
}
return FALSE;
}
+
+static GSList *account_signatures_list = NULL;
+
+/* create a list of unique signatures from accounts list */
+void account_signatures_matchlist_create(void)
+{
+ GList *cur_ac = NULL;
+ PrefsAccount *ac_prefs = NULL;
+
+ if (account_signatures_list)
+ return;
+
+ account_signatures_list = g_slist_prepend(account_signatures_list, g_strdup("-- "));
+ for (cur_ac = account_get_list();
+ cur_ac != NULL;
+ cur_ac = g_list_next(cur_ac)) {
+ ac_prefs = (PrefsAccount *)cur_ac->data;
+
+ if (ac_prefs->sig_sep && *ac_prefs->sig_sep != '\0') {
+ if (!g_slist_find_custom(account_signatures_list, ac_prefs->sig_sep,
+ (GCompareFunc)strcmp2)) {
+ account_signatures_list = g_slist_prepend(account_signatures_list,
+ g_strdup(ac_prefs->sig_sep));
+ }
+ }
+ }
+}
+
+/* delete the list of signatures created by account_signatures_matchlist_create() */
+void account_signatures_matchlist_delete(void)
+{
+ if (account_signatures_list) {
+ slist_free_strings_full(account_signatures_list);
+ account_signatures_list = NULL;
+ }
+}
+
+/* match a string against all signatures in list, using the specified format */
+gboolean account_signatures_matchlist_str_found(const gchar *str, const gchar *format)
+{
+ gchar *tmp = NULL;
+ gboolean found = FALSE;
+ GSList *item;
+
+ for (item = account_signatures_list;
+ item != NULL && !found;
+ item = g_slist_next(item)) {
+ tmp = g_strdup_printf(format, (gchar *)item->data);
+ found = (strcmp(tmp, str) == 0);
+ g_free(tmp);
+ }
+ return found;
+}
+
+/* match M first char of a string against all signatures in list, using the specified format */
+gboolean account_signatures_matchlist_nchar_found(const gchar *str, const gchar *format)
+{
+ gchar *tmp = NULL;
+ gboolean found = FALSE;
+ GSList *item;
+ gint len;
+
+ for (item = account_signatures_list;
+ item != NULL && !found;
+ item = g_slist_next(item)) {
+ tmp = g_strdup_printf(format, (gchar *)item->data);
+ len = strlen(tmp);
+ found = (strncmp(tmp, str, len) == 0);
+ g_free(tmp);
+ }
+ return found;
+}
diff --git a/src/account.h b/src/account.h
index 4462f66..649366b 100644
--- a/src/account.h
+++ b/src/account.h
@@ -80,4 +80,9 @@ gboolean password_get(const gchar *user,
guint16 port,
gchar **password);
+void account_signatures_matchlist_create (void);
+void account_signatures_matchlist_delete (void);
+gboolean account_signatures_matchlist_str_found (const gchar *str, const gchar *format);
+gboolean account_signatures_matchlist_nchar_found (const gchar *str, const gchar *format);
+
#endif /* __ACCOUNT_H__ */
diff --git a/src/procmime.c b/src/procmime.c
index 080f27c..f53e530 100644
--- a/src/procmime.c
+++ b/src/procmime.c
@@ -52,6 +52,7 @@
#include "alertpanel.h"
#include "timing.h"
#include "privacy.h"
+#include "account.h"
static GHashTable *procmime_get_mime_type_table (void);
static MimeInfo *procmime_scan_file_short(const gchar *filename);
@@ -293,7 +294,7 @@ static int procmime_fclose(FILE *fp)
gint llen = 0; \
strretchomp(lastline); \
llen = strlen(lastline); \
- if (lastline[llen-1] == ' ' && strcmp(lastline,"-- ") && \
+ if (lastline[llen-1] == ' ' && !account_signatures_matchlist_str_found(lastline, "%s") && \
!(llen == 2 && lastline[1] == ' ' && strchr(prefs_common.quote_chars, lastline[0]))) { \
/* this is flowed */ \
if (delsp) \
@@ -381,6 +382,8 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
tmp_file = TRUE;
readend = mimeinfo->offset + mimeinfo->length;
+ account_signatures_matchlist_create(); /* FLUSH_LASTLINE will use it */
+
*buf = '\0';
if (encoding == ENC_QUOTED_PRINTABLE) {
while ((ftell(infp) < readend) && (SC_FGETS(buf, sizeof(buf), infp) != NULL)) {
@@ -502,6 +505,8 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
procmime_fclose(outfp);
procmime_fclose(infp);
+ account_signatures_matchlist_delete();
+
if (err == TRUE) {
return FALSE;
}
diff --git a/src/quote_fmt_parse.y b/src/quote_fmt_parse.y
index dc330c1..03c872a 100644
--- a/src/quote_fmt_parse.y
+++ b/src/quote_fmt_parse.y
@@ -487,10 +487,11 @@ static void quote_fmt_show_msg(MsgInfo *msginfo, const gchar *body,
if (fp == NULL)
g_warning("Can't get text part");
else {
+ account_signatures_matchlist_create();
while (fgets(buf, sizeof(buf), fp) != NULL) {
strcrchomp(buf);
-
- if (!signature && strncmp(buf, "-- \n", 4) == 0)
+
+ if (!signature && account_signatures_matchlist_nchar_found(buf, "%\n"))
break;
if (quoted && quote_str)
@@ -498,6 +499,7 @@ static void quote_fmt_show_msg(MsgInfo *msginfo, const gchar *body,
INSERT(buf);
}
+ account_signatures_matchlist_delete();
fclose(fp);
}
}
diff --git a/src/textview.c b/src/textview.c
index e54b2e8..1ceb031 100644
--- a/src/textview.c
+++ b/src/textview.c
@@ -1081,6 +1081,8 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
procmime_decode_content(mimeinfo);
+ account_signatures_matchlist_create();
+
if (!g_ascii_strcasecmp(mimeinfo->subtype, "html") &&
prefs_common.render_html) {
gchar *filename;
@@ -1162,6 +1164,7 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
fclose(tmpfp);
waitpid(pid, pfd, 0);
g_unlink(fname);
+ account_signatures_matchlist_delete();
return;
}
}
@@ -1191,11 +1194,13 @@ textview_default:
tmpfp = g_fopen(mimeinfo->data.filename, "rb");
if (!tmpfp) {
FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
+ account_signatures_matchlist_delete();
return;
}
if (fseek(tmpfp, mimeinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
fclose(tmpfp);
+ account_signatures_matchlist_delete();
return;
}
debug_print("Viewing text content of type: %s (length: %d)\n", mimeinfo->subtype, mimeinfo->length);
@@ -1205,6 +1210,7 @@ textview_default:
textview_write_line(textview, buf, conv, TRUE);
if (textview->stop_loading) {
fclose(tmpfp);
+ account_signatures_matchlist_delete();
return;
}
wrote += ftell(tmpfp)-i;
@@ -1217,6 +1223,8 @@ textview_default:
fclose(tmpfp);
}
+ account_signatures_matchlist_delete();
+
conv_code_converter_destroy(conv);
procmime_force_encoding(0);
@@ -1253,6 +1261,8 @@ static void textview_show_html(TextView *textview, FILE *fp,
parser = sc_html_parser_new(fp, conv);
cm_return_if_fail(parser != NULL);
+ account_signatures_matchlist_create();
+
while ((str = sc_html_parse(parser)) != NULL) {
if (parser->state == SC_HTML_HREF) {
/* first time : get and copy the URL */
@@ -1277,10 +1287,14 @@ static void textview_show_html(TextView *textview, FILE *fp,
if (lines % 500 == 0)
GTK_EVENTS_FLUSH();
if (textview->stop_loading) {
+ account_signatures_matchlist_delete();
return;
}
}
textview_write_line(textview, "\n", NULL, FALSE);
+
+ account_signatures_matchlist_delete();
+
sc_html_parser_destroy(parser);
}
@@ -1294,16 +1308,21 @@ static void textview_show_ertf(TextView *textview, FILE *fp,
parser = ertf_parser_new(fp, conv);
cm_return_if_fail(parser != NULL);
+ account_signatures_matchlist_create();
+
while ((str = ertf_parse(parser)) != NULL) {
textview_write_line(textview, str, NULL, FALSE);
lines++;
if (lines % 500 == 0)
GTK_EVENTS_FLUSH();
if (textview->stop_loading) {
+ account_signatures_matchlist_delete();
return;
}
}
+ account_signatures_matchlist_delete();
+
ertf_parser_destroy(parser);
}
@@ -1644,8 +1663,8 @@ static void textview_write_line(TextView *textview, const gchar *str,
else if (strncmp(buf, "@@ ", 3) == 0 &&
strcmp(buf+strlen(buf)-4, " @@\n") == 0)
fg_color = "diff-hunk";
- } else if (strcmp(buf,"-- \n") == 0
- || strcmp(buf, "- -- \n") == 0
+ } else if (account_signatures_matchlist_str_found(buf,"%s\n")
+ || account_signatures_matchlist_str_found(buf, "- %s\n")
|| textview->is_in_signature) {
fg_color = "signature";
textview->is_in_signature = TRUE;
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list