aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--em-format/em-format.c2
-rw-r--r--mail/em-format-html-display.c29
-rw-r--r--mail/em-format-html.c83
-rw-r--r--mail/em-format-html.h6
4 files changed, 59 insertions, 61 deletions
diff --git a/em-format/em-format.c b/em-format/em-format.c
index 4647a70a79..71740b34c4 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -271,7 +271,7 @@ emf_format_secure (EMFormat *emf,
if (emf->valid == NULL) {
emf->valid = valid;
} else {
- camel_dlist_addtail (&emf->valid_parent->children, (CamelDListNode *) valid);
+ g_queue_push_tail (&emf->valid_parent->children, valid);
camel_cipher_validity_envelope (emf->valid_parent, valid);
}
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 48b62b7960..a0e50863fe 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -214,14 +214,19 @@ efhd_xpkcs7mime_viewcert_clicked (GtkWidget *button,
static void
efhd_xpkcs7mime_add_cert_table (GtkWidget *grid,
- CamelDList *certlist,
+ GQueue *certlist,
struct _smime_pobject *po)
{
- CamelCipherCertInfo *info = (CamelCipherCertInfo *) certlist->head;
- GtkTable *table = (GtkTable *) gtk_table_new (camel_dlist_length (certlist), 2, FALSE);
+ GList *head, *link;
+ GtkTable *table;
gint n = 0;
- while (info->next) {
+ table = (GtkTable *) gtk_table_new (certlist->length, 2, FALSE);
+
+ head = g_queue_peek_head_link (certlist);
+
+ for (link = head; link != NULL; link = g_list_next (link)) {
+ CamelCipherCertInfo *info = link->data;
gchar *la = NULL;
const gchar *l = NULL;
@@ -263,8 +268,6 @@ efhd_xpkcs7mime_add_cert_table (GtkWidget *grid,
#endif
n++;
}
-
- info = info->next;
}
gtk_container_add (GTK_CONTAINER (grid), GTK_WIDGET (table));
@@ -315,7 +318,7 @@ efhd_xpkcs7mime_validity_clicked (GtkWidget *button,
gtk_container_add (GTK_CONTAINER (grid), w);
}
- if (!camel_dlist_empty (&po->valid->sign.signers))
+ if (!g_queue_is_empty (&po->valid->sign.signers))
efhd_xpkcs7mime_add_cert_table (grid, &po->valid->sign.signers, po);
gtk_widget_show_all (grid);
@@ -348,7 +351,7 @@ efhd_xpkcs7mime_validity_clicked (GtkWidget *button,
gtk_container_add (GTK_CONTAINER (grid), w);
}
- if (!camel_dlist_empty (&po->valid->encrypt.encrypters))
+ if (!g_queue_is_empty (&po->valid->encrypt.encrypters))
efhd_xpkcs7mime_add_cert_table (grid, &po->valid->encrypt.encrypters, po);
gtk_widget_show_all (grid);
@@ -639,7 +642,6 @@ efhd_format_secure (EMFormat *emf,
g_free (classid);
if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) {
- gchar *signers;
const gchar *desc;
gint status;
@@ -648,13 +650,8 @@ efhd_format_secure (EMFormat *emf,
g_string_append (buffer, gettext (desc));
- 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) {
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 (" <");
- append (cinfo->email);
- append (">");
+ 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, " <");
+ g_string_append (output_buffer, cinfo->email);
+ g_string_append (output_buffer, ">");
}
- } 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 */
diff --git a/mail/em-format-html.h b/mail/em-format-html.h
index 954a54ea0c..bc6a171255 100644
--- a/mail/em-format-html.h
+++ b/mail/em-format-html.h
@@ -313,9 +313,9 @@ gboolean em_format_html_get_headers_collapsable
void em_format_html_set_headers_collapsable
(EMFormatHTML *efh,
gboolean collapsable);
-
-gchar * em_format_html_format_cert_infos
- (CamelCipherCertInfo *first_cinfo);
+void em_format_html_format_cert_infos
+ (GQueue *cert_infos,
+ GString *output_buffer);
CamelStream * em_format_html_get_cached_image (EMFormatHTML *efh,
const gchar *image_uri);