aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-05-13 23:44:24 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-05-15 03:20:14 +0800
commit2c5d0444bb11eb2594d30085db510d2b000ac22a (patch)
treec8d8a607888799257d1fa43334a1258906f162f9
parent232a3cd15dd2020934b55b106da2fba23dec2705 (diff)
downloadgsoc2013-evolution-2c5d0444bb11eb2594d30085db510d2b000ac22a.tar
gsoc2013-evolution-2c5d0444bb11eb2594d30085db510d2b000ac22a.tar.gz
gsoc2013-evolution-2c5d0444bb11eb2594d30085db510d2b000ac22a.tar.bz2
gsoc2013-evolution-2c5d0444bb11eb2594d30085db510d2b000ac22a.tar.lz
gsoc2013-evolution-2c5d0444bb11eb2594d30085db510d2b000ac22a.tar.xz
gsoc2013-evolution-2c5d0444bb11eb2594d30085db510d2b000ac22a.tar.zst
gsoc2013-evolution-2c5d0444bb11eb2594d30085db510d2b000ac22a.zip
Add e_mail_formatter_header_copy().
Duplicates an EMailFormatterHeader struct.
-rw-r--r--em-format/e-mail-formatter.c60
-rw-r--r--em-format/e-mail-formatter.h3
2 files changed, 42 insertions, 21 deletions
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index 1794231b3d..938cfc6937 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -1474,25 +1474,25 @@ GQueue *
e_mail_formatter_dup_headers (EMailFormatter *formatter)
{
GQueue *header_list;
- GList *link;
+ GList *head, *link;
g_return_val_if_fail (E_IS_MAIL_FORMATTER (formatter), NULL);
g_mutex_lock (&formatter->priv->property_lock);
header_list = g_queue_new ();
- for (link = g_queue_peek_head_link ((GQueue *) e_mail_formatter_get_headers (formatter));
- link;
- link = g_list_next (link)) {
- EMailFormatterHeader *h = link->data, *copy;
- if (!h)
- continue;
+ head = g_queue_peek_head_link (formatter->priv->header_list);
- copy = e_mail_formatter_header_new (h->name, h->value);
- copy->flags = h->flags;
+ for (link = head; link != NULL; link = g_list_next (link)) {
+ const EMailFormatterHeader *header = link->data;
+ EMailFormatterHeader *copy;
- g_queue_push_tail (header_list, copy);
+ /* FIXME Need to guarantee this is never NULL. */
+ if (header != NULL) {
+ copy = e_mail_formatter_header_copy (header);
+ g_queue_push_tail (header_list, copy);
+ }
}
g_mutex_unlock (&formatter->priv->property_lock);
@@ -1565,30 +1565,35 @@ e_mail_formatter_add_header (EMailFormatter *formatter,
const gchar *value,
EMailFormatterHeaderFlags flags)
{
- EMailFormatterHeader *header;
+ EMailFormatterHeader header;
g_return_if_fail (E_IS_MAIL_FORMATTER (formatter));
g_return_if_fail (name != NULL && *name != '\0');
- header = e_mail_formatter_header_new (name, value);
- header->flags = flags;
+ header.name = (gchar *) name;
+ header.value = (gchar *) value;
+ header.flags = flags;
- g_mutex_lock (&formatter->priv->property_lock);
- g_queue_push_tail (formatter->priv->header_list, header);
- g_mutex_unlock (&formatter->priv->property_lock);
-
- g_signal_emit (formatter, signals[NEED_REDRAW], 0, NULL);
+ e_mail_formatter_add_header_struct (formatter, &header);
}
void
e_mail_formatter_add_header_struct (EMailFormatter *formatter,
const EMailFormatterHeader *header)
{
+ EMailFormatterHeader *copy;
+
g_return_if_fail (E_IS_MAIL_FORMATTER (formatter));
g_return_if_fail (header != NULL);
- e_mail_formatter_add_header (
- formatter, header->name, header->value, header->flags);
+ g_mutex_lock (&formatter->priv->property_lock);
+
+ copy = e_mail_formatter_header_copy (header);
+ g_queue_push_tail (formatter->priv->header_list, copy);
+
+ g_mutex_unlock (&formatter->priv->property_lock);
+
+ g_signal_emit (formatter, signals[NEED_REDRAW], 0, NULL);
}
void
@@ -1659,6 +1664,21 @@ e_mail_formatter_header_new (const gchar *name,
return header;
}
+EMailFormatterHeader *
+e_mail_formatter_header_copy (const EMailFormatterHeader *header)
+{
+ EMailFormatterHeader *copy;
+
+ g_return_val_if_fail (header != NULL, NULL);
+
+ copy = g_new0 (EMailFormatterHeader, 1);
+ copy->name = g_strdup (header->name);
+ copy->value = g_strdup (header->value);
+ copy->flags = header->flags;
+
+ return copy;
+}
+
void
e_mail_formatter_header_free (EMailFormatterHeader *header)
{
diff --git a/em-format/e-mail-formatter.h b/em-format/e-mail-formatter.h
index ca87246aeb..fcadfaacc2 100644
--- a/em-format/e-mail-formatter.h
+++ b/em-format/e-mail-formatter.h
@@ -253,7 +253,8 @@ void e_mail_formatter_remove_header_struct
EMailFormatterHeader *
e_mail_formatter_header_new (const gchar *name,
const gchar *value);
-
+EMailFormatterHeader *
+ e_mail_formatter_header_copy (const EMailFormatterHeader *header);
void e_mail_formatter_header_free (EMailFormatterHeader *header);
G_END_DECLS