[evolution] Add e_mail_part_id_has_suffix().



commit 5fd22430809036acf607d3d3cd5f4b32c1f1cc81
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat May 18 11:02:20 2013 -0400

    Add e_mail_part_id_has_suffix().

 em-format/e-mail-formatter-message-rfc822.c       |    6 +++---
 em-format/e-mail-formatter-print.c                |    4 ++--
 em-format/e-mail-formatter-quote-message-rfc822.c |    6 +++---
 em-format/e-mail-formatter-quote.c                |    4 ++--
 em-format/e-mail-formatter.c                      |   12 ++++++------
 em-format/e-mail-part.c                           |   10 ++++++++++
 em-format/e-mail-part.h                           |    2 ++
 7 files changed, 28 insertions(+), 16 deletions(-)
---
diff --git a/em-format/e-mail-formatter-message-rfc822.c b/em-format/e-mail-formatter-message-rfc822.c
index 8e7b1ce..01b67c6 100644
--- a/em-format/e-mail-formatter-message-rfc822.c
+++ b/em-format/e-mail-formatter-message-rfc822.c
@@ -90,7 +90,7 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension,
                        p_id = e_mail_part_get_id (p);
 
                        /* Check for nested rfc822 messages */
-                       if (g_str_has_suffix (p->id, ".rfc822")) {
+                       if (e_mail_part_id_has_suffix (p, ".rfc822")) {
                                gchar *sub_end = g_strconcat (p_id, ".end", NULL);
 
                                while (link != NULL) {
@@ -152,13 +152,13 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension,
                        const gchar *p_id;
 
                        /* Skip attachment bar */
-                       if (g_str_has_suffix (part->id, ".attachment-bar"))
+                       if (e_mail_part_id_has_suffix (part, ".attachment-bar"))
                                continue;
 
                        p_id = e_mail_part_get_id (p);
 
                        /* Check for nested rfc822 messages */
-                       if (g_str_has_suffix (p->id, ".rfc822")) {
+                       if (e_mail_part_id_has_suffix (p, ".rfc822")) {
                                gchar *sub_end = g_strconcat (p_id, ".end", NULL);
 
                                while (link != NULL) {
diff --git a/em-format/e-mail-formatter-print.c b/em-format/e-mail-formatter-print.c
index 7ad03be..ccbdeea 100644
--- a/em-format/e-mail-formatter-print.c
+++ b/em-format/e-mail-formatter-print.c
@@ -137,7 +137,7 @@ mail_formatter_print_run (EMailFormatter *formatter,
                        break;
 
                if (part->is_hidden && !part->is_error) {
-                       if (g_str_has_suffix (part->id, ".rfc822")) {
+                       if (e_mail_part_id_has_suffix (part, ".rfc822")) {
                                link = e_mail_formatter_find_rfc822_end_iter (link);
                        }
 
@@ -163,7 +163,7 @@ mail_formatter_print_run (EMailFormatter *formatter,
                 * jump to the end of the message, because content
                 * of the whole message has been formatted by
                 * message_rfc822 formatter */
-               if (ok && g_str_has_suffix (part->id, ".rfc822")) {
+               if (ok && e_mail_part_id_has_suffix (part, ".rfc822")) {
                        link = e_mail_formatter_find_rfc822_end_iter (link);
 
                        continue;
diff --git a/em-format/e-mail-formatter-quote-message-rfc822.c 
b/em-format/e-mail-formatter-quote-message-rfc822.c
index ae09a02..ae1d3a4 100644
--- a/em-format/e-mail-formatter-quote-message-rfc822.c
+++ b/em-format/e-mail-formatter-quote-message-rfc822.c
@@ -89,10 +89,10 @@ emfqe_message_rfc822_format (EMailFormatterExtension *extension,
                p_id = e_mail_part_get_id (p);
 
                /* Skip attachment bar */
-               if (g_str_has_suffix (p->id, ".attachment-bar"))
+               if (e_mail_part_id_has_suffix (p, ".attachment-bar"))
                        continue;
 
-               if (g_str_has_suffix (p->id, ".headers.")) {
+               if (e_mail_part_id_has_suffix (p, ".headers.")) {
                        if (qc->qf_flags & E_MAIL_FORMATTER_QUOTE_FLAG_HEADERS) {
                                e_mail_formatter_format_as (
                                        formatter, context, part, stream,
@@ -104,7 +104,7 @@ emfqe_message_rfc822_format (EMailFormatterExtension *extension,
                }
 
                /* Check for nested rfc822 messages */
-               if (g_str_has_suffix (p->id, ".rfc822")) {
+               if (e_mail_part_id_has_suffix (p, ".rfc822")) {
                        gchar *sub_end = g_strconcat (p_id, ".end", NULL);
 
                        while (link != NULL) {
diff --git a/em-format/e-mail-formatter-quote.c b/em-format/e-mail-formatter-quote.c
index f810f23..837b810 100644
--- a/em-format/e-mail-formatter-quote.c
+++ b/em-format/e-mail-formatter-quote.c
@@ -105,12 +105,12 @@ mail_formatter_quote_run (EMailFormatter *formatter,
        for (link = head; link != NULL; link = g_list_next (link)) {
                EMailPart *part = E_MAIL_PART (link->data);
 
-               if (g_str_has_suffix (part->id, ".headers") &&
+               if (e_mail_part_id_has_suffix (part, ".headers") &&
                   !(qf_context->qf_flags & E_MAIL_FORMATTER_QUOTE_FLAG_HEADERS)) {
                        continue;
                }
 
-               if (g_str_has_suffix (part->id, ".rfc822")) {
+               if (e_mail_part_id_has_suffix (part, ".rfc822")) {
                        link = e_mail_formatter_find_rfc822_end_iter (link);
                        continue;
                }
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index fb1c069..e2e6da7 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -405,7 +405,7 @@ mail_formatter_run (EMailFormatter *formatter,
                        break;
 
                if (part->is_hidden && !part->is_error) {
-                       if (g_str_has_suffix (part->id, ".rfc822")) {
+                       if (e_mail_part_id_has_suffix (part, ".rfc822")) {
                                link = e_mail_formatter_find_rfc822_end_iter (link);
                        }
 
@@ -429,7 +429,7 @@ mail_formatter_run (EMailFormatter *formatter,
                         * jump to the end of the message, because content
                         * of the whole message has been formatted by
                         * message_rfc822 formatter */
-                       if (ok && g_str_has_suffix (part->id, ".rfc822")) {
+                       if (ok && e_mail_part_id_has_suffix (part, ".rfc822")) {
                                link = e_mail_formatter_find_rfc822_end_iter (link);
 
                                if (link == NULL)
@@ -444,8 +444,8 @@ mail_formatter_run (EMailFormatter *formatter,
 
                if (!ok) {
                        /* We don't want to source these */
-                       if (g_str_has_suffix (part->id, ".headers") ||
-                           g_str_has_suffix (part->id, "attachment-bar"))
+                       if (e_mail_part_id_has_suffix (part, ".headers") ||
+                           e_mail_part_id_has_suffix (part, "attachment-bar"))
                                continue;
 
                        e_mail_formatter_format_as (
@@ -460,11 +460,11 @@ mail_formatter_run (EMailFormatter *formatter,
                        /* If we just wrote source of a rfc822 message, then jump
                         * behind the message (otherwise source of all parts
                         * would be rendered twice) */
-                       if (g_str_has_suffix (part->id, ".rfc822")) {
+                       if (e_mail_part_id_has_suffix (part, ".rfc822")) {
 
                                do {
                                        part = link->data;
-                                       if (g_str_has_suffix (part->id, ".rfc822.end"))
+                                       if (e_mail_part_id_has_suffix (part, ".rfc822.end"))
                                                break;
 
                                        link = g_list_next (link);
diff --git a/em-format/e-mail-part.c b/em-format/e-mail-part.c
index 95e4929..945175c 100644
--- a/em-format/e-mail-part.c
+++ b/em-format/e-mail-part.c
@@ -211,6 +211,16 @@ e_mail_part_id_has_prefix (EMailPart *part,
        return g_str_has_prefix (part->id, prefix);
 }
 
+gboolean
+e_mail_part_id_has_suffix (EMailPart *part,
+                           const gchar *suffix)
+{
+       g_return_val_if_fail (part != NULL, FALSE);
+       g_return_val_if_fail (suffix != NULL, FALSE);
+
+       return g_str_has_suffix (part->id, suffix);
+}
+
 static EMailPartValidityPair *
 mail_part_find_validity_pair (EMailPart *part,
                               guint32 validity_type)
diff --git a/em-format/e-mail-part.h b/em-format/e-mail-part.h
index 8a71d3b..769d5bb 100644
--- a/em-format/e-mail-part.h
+++ b/em-format/e-mail-part.h
@@ -101,6 +101,8 @@ void                e_mail_part_set_cid             (EMailPart *part,
                                                 const gchar *cid);
 gboolean       e_mail_part_id_has_prefix       (EMailPart *part,
                                                 const gchar *prefix);
+gboolean       e_mail_part_id_has_suffix       (EMailPart *part,
+                                                const gchar *suffix);
 void           e_mail_part_update_validity     (EMailPart *part,
                                                 CamelCipherValidity *validity,
                                                 guint32 validity_type);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]