diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-05-15 04:44:44 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-05-20 01:07:20 +0800 |
commit | f6f11a1da2dfa2c7616cd18b36a44fefd66f0c75 (patch) | |
tree | 94091b064fd126c1e23a2ed019561b9842111a78 /em-format | |
parent | 7d3ce25e9f3575560e331529edf55661eab92d2f (diff) | |
download | gsoc2013-evolution-f6f11a1da2dfa2c7616cd18b36a44fefd66f0c75.tar gsoc2013-evolution-f6f11a1da2dfa2c7616cd18b36a44fefd66f0c75.tar.gz gsoc2013-evolution-f6f11a1da2dfa2c7616cd18b36a44fefd66f0c75.tar.bz2 gsoc2013-evolution-f6f11a1da2dfa2c7616cd18b36a44fefd66f0c75.tar.lz gsoc2013-evolution-f6f11a1da2dfa2c7616cd18b36a44fefd66f0c75.tar.xz gsoc2013-evolution-f6f11a1da2dfa2c7616cd18b36a44fefd66f0c75.tar.zst gsoc2013-evolution-f6f11a1da2dfa2c7616cd18b36a44fefd66f0c75.zip |
EMailPart: Store validity pairs in a GQueue.
Diffstat (limited to 'em-format')
-rw-r--r-- | em-format/e-mail-formatter-attachment.c | 26 | ||||
-rw-r--r-- | em-format/e-mail-formatter-print-headers.c | 2 | ||||
-rw-r--r-- | em-format/e-mail-formatter-secure-button.c | 12 | ||||
-rw-r--r-- | em-format/e-mail-part.c | 25 | ||||
-rw-r--r-- | em-format/e-mail-part.h | 6 |
5 files changed, 41 insertions, 30 deletions
diff --git a/em-format/e-mail-formatter-attachment.c b/em-format/e-mail-formatter-attachment.c index 25df816186..54647edd4a 100644 --- a/em-format/e-mail-formatter-attachment.c +++ b/em-format/e-mail-formatter-attachment.c @@ -126,21 +126,25 @@ emfe_attachment_format (EMailFormatterExtension *extension, if ((context->mode == E_MAIL_FORMATTER_MODE_NORMAL) || (context->mode == E_MAIL_FORMATTER_MODE_PRINTING) || (context->mode == E_MAIL_FORMATTER_MODE_ALL_HEADERS)) { - if (part->validities) { - GSList *lst; + GList *head, *link; - for (lst = part->validities; lst; lst = lst->next) { - EMailPartValidityPair *pair = lst->data; + head = g_queue_peek_head_link (&part->validities); - if (!pair) - continue; + for (link = head; link != NULL; link = g_list_next (link)) { + EMailPartValidityPair *pair = link->data; - if ((pair->validity_type & E_MAIL_PART_VALIDITY_SIGNED) != 0) - e_attachment_set_signed (empa->attachment, pair->validity->sign.status); + if (pair == NULL) + continue; - if ((pair->validity_type & E_MAIL_PART_VALIDITY_ENCRYPTED) != 0) - e_attachment_set_encrypted (empa->attachment, pair->validity->encrypt.status); - } + if ((pair->validity_type & E_MAIL_PART_VALIDITY_SIGNED) != 0) + e_attachment_set_signed ( + empa->attachment, + pair->validity->sign.status); + + if ((pair->validity_type & E_MAIL_PART_VALIDITY_ENCRYPTED) != 0) + e_attachment_set_encrypted ( + empa->attachment, + pair->validity->encrypt.status); } store = find_attachment_store (context->part_list, part->id); diff --git a/em-format/e-mail-formatter-print-headers.c b/em-format/e-mail-formatter-print-headers.c index a79dfa1f70..03d35c300c 100644 --- a/em-format/e-mail-formatter-print-headers.c +++ b/em-format/e-mail-formatter-print-headers.c @@ -130,7 +130,7 @@ emfpe_headers_format (EMailFormatterExtension *extension, for (link = head; link != NULL; link = g_list_next (link)) { EMailPart *mail_part = link->data; - if (!mail_part->validities) + if (g_queue_is_empty (&mail_part->validities)) continue; if (!g_str_has_prefix (mail_part->id, part_id_prefix)) diff --git a/em-format/e-mail-formatter-secure-button.c b/em-format/e-mail-formatter-secure-button.c index 571b90d220..442a6d3e26 100644 --- a/em-format/e-mail-formatter-secure-button.c +++ b/em-format/e-mail-formatter-secure-button.c @@ -428,7 +428,7 @@ emfe_secure_button_get_widget (EMailFormatterExtension *extension, GHashTable *params) { GtkWidget *grid; - GSList *lst; + GList *head, *link; g_return_val_if_fail (part != NULL, NULL); @@ -440,15 +440,17 @@ emfe_secure_button_get_widget (EMailFormatterExtension *extension, "hexpand", TRUE, NULL); - for (lst = part->validities; lst; lst = lst->next) { - EMailPartValidityPair *pair = lst->data; + head = g_queue_peek_head_link (&part->validities); + + for (link = head; link != NULL; link = g_list_next (link)) { + EMailPartValidityPair *pair = link->data; GtkWidget *widget; - if (!pair) + if (pair == NULL) continue; widget = secure_button_get_widget_for_validity (pair->validity); - if (widget) { + if (widget != NULL) { gtk_widget_set_halign (widget, GTK_ALIGN_FILL); gtk_widget_set_hexpand (widget, TRUE); gtk_container_add (GTK_CONTAINER (grid), widget); diff --git a/em-format/e-mail-part.c b/em-format/e-mail-part.c index 657b677cb9..9e280e07bf 100644 --- a/em-format/e-mail-part.c +++ b/em-format/e-mail-part.c @@ -53,6 +53,8 @@ mail_part_validity_pair_free (gpointer ptr) static void mail_part_free (EMailPart *part) { + EMailPartValidityPair *pair; + if (!part) return; @@ -71,10 +73,8 @@ mail_part_free (EMailPart *part) part->mime_type = NULL; } - if (part->validities) { - g_slist_free_full (part->validities, mail_part_validity_pair_free); - part->validities = NULL; - } + while ((pair = g_queue_pop_head (&part->validities)) != NULL) + mail_part_validity_pair_free (pair); if (part->priv->free_func) { part->priv->free_func (part); @@ -180,12 +180,17 @@ static EMailPartValidityPair * mail_part_find_validity_pair (EMailPart *part, guint32 validity_type) { - GSList *lst; + GList *head, *link; + + head = g_queue_peek_head_link (&part->validities); + + for (link = head; link != NULL; link = g_list_next (link)) { + EMailPartValidityPair *pair = link->data; - for (lst = part->validities; lst; lst = lst->next) { - EMailPartValidityPair *pair = lst->data; + if (pair == NULL) + continue; - if (pair && (pair->validity_type & validity_type) == validity_type) + if ((pair->validity_type & validity_type) == validity_type) return pair; } @@ -213,7 +218,7 @@ e_mail_part_update_validity (EMailPart *part, g_return_if_fail (part != NULL); pair = mail_part_find_validity_pair (part, validity_type & (E_MAIL_PART_VALIDITY_PGP | E_MAIL_PART_VALIDITY_SMIME)); - if (pair) { + if (pair != NULL) { pair->validity_type |= validity_type; camel_cipher_validity_envelope (pair->validity, validity); } else { @@ -221,7 +226,7 @@ e_mail_part_update_validity (EMailPart *part, pair->validity_type = validity_type; pair->validity = camel_cipher_validity_clone (validity); - part->validities = g_slist_append (part->validities, pair); + g_queue_push_tail (&part->validities, pair); } } diff --git a/em-format/e-mail-part.h b/em-format/e-mail-part.h index 774828eb23..3d59d46087 100644 --- a/em-format/e-mail-part.h +++ b/em-format/e-mail-part.h @@ -36,7 +36,7 @@ typedef struct _EMailPartPrivate EMailPartPrivate; typedef void (*EMailPartDOMBindFunc) (EMailPart *part, WebKitDOMElement *element); -enum { +typedef enum { E_MAIL_PART_VALIDITY_NONE = 0, E_MAIL_PART_VALIDITY_PGP = 1 << 0, E_MAIL_PART_VALIDITY_SMIME = 1 << 1, @@ -47,7 +47,7 @@ enum { typedef struct _EMailPartValidityPair EMailPartValidityPair; struct _EMailPartValidityPair { - guint32 validity_type; /* E_MAIL_PART_VALIDITY_ * flags */ + EMailPartValidityFlags validity_type; CamelCipherValidity *validity; }; @@ -61,7 +61,7 @@ struct _EMailPart { gchar *cid; gchar *mime_type; - GSList *validities; /* EMailPartValidityPair pointer */ + GQueue validities; /* element-type: EMailPartValidityPair */ gint is_attachment: 1; |