aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
diff options
context:
space:
mode:
Diffstat (limited to 'em-format')
-rw-r--r--em-format/e-mail-part-list.c4
-rw-r--r--em-format/e-mail-part.c54
-rw-r--r--em-format/e-mail-part.h6
3 files changed, 62 insertions, 2 deletions
diff --git a/em-format/e-mail-part-list.c b/em-format/e-mail-part-list.c
index c866e6a559..bcf7490634 100644
--- a/em-format/e-mail-part-list.c
+++ b/em-format/e-mail-part-list.c
@@ -289,7 +289,7 @@ e_mail_part_list_add_part (EMailPartList *part_list,
EMailPart *part)
{
g_return_if_fail (E_IS_MAIL_PART_LIST (part_list));
- g_return_if_fail (part != NULL);
+ g_return_if_fail (E_IS_MAIL_PART (part));
g_mutex_lock (&part_list->priv->queue_lock);
@@ -298,6 +298,8 @@ e_mail_part_list_add_part (EMailPartList *part_list,
g_object_ref (part));
g_mutex_unlock (&part_list->priv->queue_lock);
+
+ e_mail_part_set_part_list (part, part_list);
}
EMailPart *
diff --git a/em-format/e-mail-part.c b/em-format/e-mail-part.c
index abd405d677..b4ba2b3eb7 100644
--- a/em-format/e-mail-part.c
+++ b/em-format/e-mail-part.c
@@ -31,11 +31,14 @@
#include <string.h>
+#include "e-mail-part-list.h"
+
#define E_MAIL_PART_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_MAIL_PART, EMailPartPrivate))
struct _EMailPartPrivate {
+ GWeakRef part_list;
CamelMimePart *mime_part;
gchar *id;
@@ -51,7 +54,8 @@ enum {
PROP_ID,
PROP_IS_ATTACHMENT,
PROP_MIME_PART,
- PROP_MIME_TYPE
+ PROP_MIME_TYPE,
+ PROP_PART_LIST
};
G_DEFINE_TYPE (
@@ -127,6 +131,12 @@ mail_part_set_property (GObject *object,
E_MAIL_PART (object),
g_value_get_string (value));
return;
+
+ case PROP_PART_LIST:
+ e_mail_part_set_part_list (
+ E_MAIL_PART (object),
+ g_value_get_object (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -173,6 +183,13 @@ mail_part_get_property (GObject *object,
e_mail_part_get_mime_type (
E_MAIL_PART (object)));
return;
+
+ case PROP_PART_LIST:
+ g_value_take_object (
+ value,
+ e_mail_part_ref_part_list (
+ E_MAIL_PART (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -185,6 +202,8 @@ mail_part_dispose (GObject *object)
priv = E_MAIL_PART_GET_PRIVATE (object);
+ g_weak_ref_set (&priv->part_list, NULL);
+
g_clear_object (&priv->mime_part);
/* Chain up to parent's dispose() method. */
@@ -278,6 +297,17 @@ e_mail_part_class_init (EMailPartClass *class)
NULL,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_PART_LIST,
+ g_param_spec_object (
+ "part-list",
+ "Part List",
+ "The part list that owns the part",
+ E_TYPE_MAIL_PART_LIST,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
}
static void
@@ -400,6 +430,28 @@ e_mail_part_set_mime_type (EMailPart *part,
g_object_notify (G_OBJECT (part), "mime-type");
}
+EMailPartList *
+e_mail_part_ref_part_list (EMailPart *part)
+{
+ g_return_val_if_fail (E_IS_MAIL_PART (part), NULL);
+
+ return g_weak_ref_get (&part->priv->part_list);
+}
+
+void
+e_mail_part_set_part_list (EMailPart *part,
+ EMailPartList *part_list)
+{
+ g_return_if_fail (E_IS_MAIL_PART (part));
+
+ if (part_list != NULL)
+ g_return_if_fail (E_IS_MAIL_PART_LIST (part_list));
+
+ g_weak_ref_set (&part->priv->part_list, part_list);
+
+ g_object_notify (G_OBJECT (part), "part-list");
+}
+
gboolean
e_mail_part_get_is_attachment (EMailPart *part)
{
diff --git a/em-format/e-mail-part.h b/em-format/e-mail-part.h
index f710f4021a..75057c2ee5 100644
--- a/em-format/e-mail-part.h
+++ b/em-format/e-mail-part.h
@@ -47,6 +47,8 @@
G_BEGIN_DECLS
+struct _EMailPartList;
+
typedef struct _EMailPart EMailPart;
typedef struct _EMailPartClass EMailPartClass;
typedef struct _EMailPartPrivate EMailPartPrivate;
@@ -106,6 +108,10 @@ CamelMimePart * e_mail_part_ref_mime_part (EMailPart *part);
const gchar * e_mail_part_get_mime_type (EMailPart *part);
void e_mail_part_set_mime_type (EMailPart *part,
const gchar *mime_type);
+struct _EMailPartList *
+ e_mail_part_ref_part_list (EMailPart *part);
+void e_mail_part_set_part_list (EMailPart *part,
+ struct _EMailPartList *part_list);
gboolean e_mail_part_get_is_attachment (EMailPart *part);
void e_mail_part_set_is_attachment (EMailPart *part,
gboolean is_attachment);