[evolution/wip/gsettings] Bug #586461 - Remove signature also from HTML formatted emails on reply
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/gsettings] Bug #586461 - Remove signature also from HTML formatted emails on reply
- Date: Wed, 29 Jun 2011 17:17:37 +0000 (UTC)
commit 45c0f292624ea40f8b0debf7b5a5f60053c419ef
Author: Milan Crha <mcrha redhat com>
Date: Wed Mar 9 17:41:47 2011 +0100
Bug #586461 - Remove signature also from HTML formatted emails on reply
em-format/em-format-quote.c | 22 +++++++++++++++++++---
em-format/em-stripsig-filter.c | 13 +++++++++++--
em-format/em-stripsig-filter.h | 3 ++-
3 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/em-format/em-format-quote.c b/em-format/em-format-quote.c
index e2eb9d3..e54ecf6 100644
--- a/em-format/em-format-quote.c
+++ b/em-format/em-format-quote.c
@@ -623,7 +623,7 @@ emfq_text_plain (EMFormat *emf,
filtered_stream = camel_stream_filter_new (stream);
if ((emfq->flags & EM_FORMAT_QUOTE_KEEP_SIG) == 0) {
- sig_strip = em_stripsig_filter_new ();
+ sig_strip = em_stripsig_filter_new (TRUE);
camel_stream_filter_add (
CAMEL_STREAM_FILTER (filtered_stream), sig_strip);
g_object_unref (sig_strip);
@@ -674,6 +674,7 @@ emfq_text_enriched (EMFormat *emf,
camel_stream_write_string (stream, "<br><hr><br>", cancellable, NULL);
em_format_format_text (
emf, filtered_stream, CAMEL_DATA_WRAPPER (part), cancellable);
+ camel_stream_flush (filtered_stream, cancellable, NULL);
g_object_unref (filtered_stream);
}
@@ -687,8 +688,23 @@ emfq_text_html (EMFormat *emf,
{
camel_stream_write_string (
stream, "\n<!-- text/html -->\n", cancellable, NULL);
- em_format_format_text (
- emf, stream, (CamelDataWrapper *)part, cancellable);
+
+ if ((EM_FORMAT_QUOTE (emf)->flags & EM_FORMAT_QUOTE_KEEP_SIG) == 0) {
+ CamelMimeFilter *sig_strip;
+ CamelStream *filtered_stream;
+
+ filtered_stream = camel_stream_filter_new (stream);
+
+ sig_strip = em_stripsig_filter_new (FALSE);
+ camel_stream_filter_add (CAMEL_STREAM_FILTER (filtered_stream), sig_strip);
+ g_object_unref (sig_strip);
+
+ em_format_format_text (emf, filtered_stream, (CamelDataWrapper *) part, cancellable);
+ camel_stream_flush (filtered_stream, cancellable, NULL);
+ g_object_unref (filtered_stream);
+ } else {
+ em_format_format_text (emf, stream, (CamelDataWrapper *)part, cancellable);
+ }
}
static void
diff --git a/em-format/em-stripsig-filter.c b/em-format/em-stripsig-filter.c
index 38b74b8..bbca2f6 100644
--- a/em-format/em-stripsig-filter.c
+++ b/em-format/em-stripsig-filter.c
@@ -61,6 +61,9 @@ strip_signature (CamelMimeFilter *filter,
if ((inend - inptr) >= 4 && !strncmp (inptr, "-- \n", 4)) {
start = inptr;
inptr += 4;
+ } else if (!stripsig->text_plain_only && (inend - inptr) >= 7 && !g_ascii_strncasecmp (inptr, "-- <BR>", 7)) {
+ start = inptr;
+ inptr += 7;
} else {
while (inptr < inend && *inptr != '\n')
inptr++;
@@ -142,13 +145,19 @@ em_stripsig_filter_init (EMStripSigFilter *filter)
/**
* em_stripsig_filter_new:
+ * @text_plain_only: Whether should look for a text/plain signature
+ * delimiter "-- \n" only or also an HTML signature delimiter "-- <BR>".
*
* Creates a new stripsig filter.
*
* Returns a new stripsig filter.
**/
CamelMimeFilter *
-em_stripsig_filter_new (void)
+em_stripsig_filter_new (gboolean text_plain_only)
{
- return g_object_new (EM_TYPE_STRIPSIG_FILTER, NULL);
+ EMStripSigFilter *filter = g_object_new (EM_TYPE_STRIPSIG_FILTER, NULL);
+
+ filter->text_plain_only = text_plain_only;
+
+ return CAMEL_MIME_FILTER (filter);
}
diff --git a/em-format/em-stripsig-filter.h b/em-format/em-stripsig-filter.h
index f841727..5ca4491 100644
--- a/em-format/em-stripsig-filter.h
+++ b/em-format/em-stripsig-filter.h
@@ -53,6 +53,7 @@ struct _EMStripSigFilter {
CamelMimeFilter parent;
guint32 midline:1;
+ guint32 text_plain_only:1;
};
struct _EMStripSigFilterClass {
@@ -61,7 +62,7 @@ struct _EMStripSigFilterClass {
GType em_stripsig_filter_get_type (void);
CamelMimeFilter *
- em_stripsig_filter_new (void);
+ em_stripsig_filter_new (gboolean text_plain_only);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]