aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-format-html.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-01-29 08:19:38 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-01-30 04:01:12 +0800
commit63eba7c310c6eb45a4a405911b4f0cec1c900afc (patch)
tree45396c72cebd7dbdf85eebdd80e4d6d17bfe8fe3 /mail/em-format-html.c
parent9ff52b74c301d7846f05c9e7603c54dcc698e3b3 (diff)
downloadgsoc2013-evolution-63eba7c310c6eb45a4a405911b4f0cec1c900afc.tar
gsoc2013-evolution-63eba7c310c6eb45a4a405911b4f0cec1c900afc.tar.gz
gsoc2013-evolution-63eba7c310c6eb45a4a405911b4f0cec1c900afc.tar.bz2
gsoc2013-evolution-63eba7c310c6eb45a4a405911b4f0cec1c900afc.tar.lz
gsoc2013-evolution-63eba7c310c6eb45a4a405911b4f0cec1c900afc.tar.xz
gsoc2013-evolution-63eba7c310c6eb45a4a405911b4f0cec1c900afc.tar.zst
gsoc2013-evolution-63eba7c310c6eb45a4a405911b4f0cec1c900afc.zip
Adapt to Camel API changes.
Diffstat (limited to 'mail/em-format-html.c')
-rw-r--r--mail/em-format-html.c83
1 files changed, 42 insertions, 41 deletions
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 8e4769ecf2..107c2ce267 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -1872,18 +1872,11 @@ efh_format_secure (EMFormat *emf,
g_free (classid);
if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) {
- gchar *signers;
-
g_string_append (
buffer, _(smime_sign_table[valid->sign.status].shortdesc));
- signers = em_format_html_format_cert_infos (
- (CamelCipherCertInfo *) valid->sign.signers.head);
- if (signers && *signers) {
- g_string_append_printf (
- buffer, " (%s)", signers);
- }
- g_free (signers);
+ em_format_html_format_cert_infos (
+ &valid->sign.signers, buffer);
}
if (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE) {
@@ -3378,49 +3371,57 @@ efh_format_message (EMFormat *emf,
emf->valid_parent = save_parent;
}
-gchar *
-em_format_html_format_cert_infos (CamelCipherCertInfo *first_cinfo)
+void
+em_format_html_format_cert_infos (GQueue *cert_infos,
+ GString *output_buffer)
{
- GString *res = NULL;
- CamelCipherCertInfo *cinfo;
+ GQueue valid = G_QUEUE_INIT;
+ GList *head, *link;
- if (!first_cinfo)
- return NULL;
+ g_return_if_fail (cert_infos != NULL);
+ g_return_if_fail (output_buffer != NULL);
- #define append(x) G_STMT_START { \
- if (!res) { \
- res = g_string_new (x); \
- } else { \
- g_string_append (res, x); \
- } \
- } G_STMT_END
+ head = g_queue_peek_head_link (cert_infos);
- for (cinfo = first_cinfo; cinfo && cinfo->next; cinfo = cinfo->next) {
- if (!cinfo->name && !cinfo->email)
- continue;
+ /* Make sure we have a valid CamelCipherCertInfo before
+ * appending anything to the output buffer, so we don't
+ * end up with "()". */
+ for (link = head; link != NULL; link = g_list_next (link)) {
+ CamelCipherCertInfo *cinfo = link->data;
+
+ if ((cinfo->name != NULL && *cinfo->name != '\0') ||
+ (cinfo->email != NULL && *cinfo->email != '\0'))
+ g_queue_push_tail (&valid, cinfo);
+ }
- if (res)
- append (", ");
+ if (g_queue_is_empty (&valid))
+ return;
- if (cinfo->name && *cinfo->name) {
- append (cinfo->name);
+ g_string_append (output_buffer, " (");
- if (cinfo->email && *cinfo->email) {
- append (" &lt;");
- append (cinfo->email);
- append ("&gt;");
+ while (!g_queue_is_empty (&valid)) {
+ CamelCipherCertInfo *cinfo;
+
+ cinfo = g_queue_pop_head (&valid);
+
+ if (cinfo->name != NULL && *cinfo->name != '\0') {
+ g_string_append (output_buffer, cinfo->name);
+
+ if (cinfo->email != NULL && *cinfo->email != '\0') {
+ g_string_append (output_buffer, " &lt;");
+ g_string_append (output_buffer, cinfo->email);
+ g_string_append (output_buffer, "&gt;");
}
- } else if (cinfo->email && *cinfo->email) {
- append (cinfo->email);
- }
- }
- #undef append
+ } else if (cinfo->email != NULL && *cinfo->email != '\0') {
+ g_string_append (output_buffer, cinfo->email);
+ }
- if (!res)
- return NULL;
+ if (!g_queue_is_empty (&valid))
+ g_string_append (output_buffer, ", ");
+ }
- return g_string_free (res, FALSE);
+ g_string_append_c (output_buffer, ')');
}
/* unref returned pointer with g_object_unref(), if not NULL */