[evolution-data-server] Bug #651458 - Add getters/settrs for EContactPhoto



commit 876e2b5add7f9ed8269870998cf6a1a49a88e17c
Author: Raul Gutierrez Segales <raul gutierrez segales collabora co uk>
Date:   Mon May 30 11:24:17 2011 +0100

    Bug #651458 - Add getters/settrs for EContactPhoto
    
    This is needed for introspected bindings since gobject-introspection
    can't cope with the current layout of the EContactPhoto structure.

 addressbook/libebook/e-contact.c                   |  108 ++++++++++++++++++++
 addressbook/libebook/e-contact.h                   |   10 ++-
 .../addressbook/libebook/libebook-sections.txt     |    6 +
 .../addressbook/libebook/tmpl/e-contact.sgml       |   53 ++++++++++
 4 files changed, 175 insertions(+), 2 deletions(-)
---
diff --git a/addressbook/libebook/e-contact.c b/addressbook/libebook/e-contact.c
index b3f1c9f..3baf4ed 100644
--- a/addressbook/libebook/e-contact.c
+++ b/addressbook/libebook/e-contact.c
@@ -2013,6 +2013,114 @@ e_contact_photo_copy (EContactPhoto *photo)
 	return photo2;
 }
 
+/**
+ * e_contact_photo_get_inlined:
+ * @photo: an #EContactPhoto
+ * @len: (out caller-allocates) (transfer none): the length of the inlined data
+ *
+ * Gets the @photo's data.
+ *
+ * Returns: (transfer none) (array length=len): the inlined image in the
+ * #EContactPhoto.
+ **/
+const guchar *
+e_contact_photo_get_inlined (EContactPhoto *photo, gsize *len)
+{
+	g_return_val_if_fail (photo != NULL, NULL);
+	g_return_val_if_fail (photo->type == E_CONTACT_PHOTO_TYPE_INLINED, NULL);
+
+	*len = photo->data.inlined.length;
+	return photo->data.inlined.data;
+}
+
+/**
+ * e_contact_photo_set_inlined:
+ * @photo: an #EContactPhoto
+ * @data: (transfer none) (array length=len): the inlined image data
+ * @len: the length of @data
+ *
+ * Sets the @photo's inlined data.
+ **/
+void
+e_contact_photo_set_inlined (EContactPhoto *photo,
+			     const guchar *data, gsize len)
+{
+	g_return_if_fail (photo != NULL);
+	g_return_if_fail (photo->type == E_CONTACT_PHOTO_TYPE_INLINED);
+
+	photo->data.inlined.data = g_malloc (len);
+	memcpy (photo->data.inlined.data, data, len);
+	photo->data.inlined.length = len;
+}
+
+/**
+ * e_contact_photo_get_mime_type:
+ * @photo: an #EContactPhoto
+ *
+ * Gets the @photo's mime type.
+ *
+ * Returns: (transfer none): the mime type of the image
+ **/
+const gchar *
+e_contact_photo_get_mime_type (EContactPhoto *photo)
+{
+	g_return_val_if_fail (photo != NULL, NULL);
+	g_return_val_if_fail (photo->type == E_CONTACT_PHOTO_TYPE_INLINED, NULL);
+
+	return photo->data.inlined.mime_type;
+}
+
+/**
+ * e_contact_photo_set_mime_type:
+ * @photo: an #EContactPhoto
+ * @mime_type: the mime type
+ *
+ * Sets the @photo's mime type.
+ **/
+void
+e_contact_photo_set_mime_type (EContactPhoto *photo, const gchar *mime_type)
+{
+	g_return_if_fail (photo != NULL);
+	g_return_if_fail (photo->type == E_CONTACT_PHOTO_TYPE_INLINED);
+
+	g_free (photo->data.inlined.mime_type);
+	photo->data.inlined.mime_type = g_strdup (mime_type);
+}
+
+/**
+ * e_contact_photo_get_uri:
+ * @photo: an #EContactPhoto
+ *
+ * Gets the @photo's URI.
+ *
+ * Returns: (transfer none): the URI of the image
+ **/
+const gchar *
+e_contact_photo_get_uri (EContactPhoto *photo)
+{
+	g_return_val_if_fail (photo != NULL, NULL);
+	g_return_val_if_fail (photo->type == E_CONTACT_PHOTO_TYPE_URI, NULL);
+
+	return photo->data.uri;
+}
+
+/**
+ * e_contact_photo_set_uri:
+ * @photo: an #EContactPhoto
+ * @uri: the @photo's URI
+ *
+ * Sets the @photo's URI.
+ **/
+void
+e_contact_photo_set_uri (EContactPhoto *photo, const gchar *uri)
+{
+	g_return_if_fail (photo != NULL);
+	g_return_if_fail (photo->type == E_CONTACT_PHOTO_TYPE_URI);
+
+	g_free (photo->data.uri);
+	photo->data.uri = g_strdup (uri);
+}
+
 E_CONTACT_DEFINE_BOXED_TYPE (e_contact_photo, "EContactPhoto")
 
 /**
diff --git a/addressbook/libebook/e-contact.h b/addressbook/libebook/e-contact.h
index 7889837..35e5ad2 100644
--- a/addressbook/libebook/e-contact.h
+++ b/addressbook/libebook/e-contact.h
@@ -331,8 +331,14 @@ EContactName           *e_contact_name_from_string (const gchar *name_str);
 EContactName           *e_contact_name_copy        (EContactName *n);
 void                    e_contact_name_free        (EContactName *name);
 
-GType                   e_contact_photo_get_type   (void);
-void                    e_contact_photo_free       (EContactPhoto *photo);
+GType                   e_contact_photo_get_type      (void);
+void                    e_contact_photo_free          (EContactPhoto *photo);
+const guchar *          e_contact_photo_get_inlined   (EContactPhoto *photo, gsize *len);
+void                    e_contact_photo_set_inlined   (EContactPhoto *photo, const guchar *data, gsize len);
+const gchar *           e_contact_photo_get_mime_type (EContactPhoto *photo);
+void                    e_contact_photo_set_mime_type (EContactPhoto *photo, const gchar *mime_type);
+const gchar *           e_contact_photo_get_uri       (EContactPhoto *photo);
+void                    e_contact_photo_set_uri       (EContactPhoto *photo, const gchar *uri);
 
 GType			e_contact_geo_get_type	   (void);
 void			e_contact_geo_free	   (EContactGeo *geo);
diff --git a/docs/reference/addressbook/libebook/libebook-sections.txt b/docs/reference/addressbook/libebook/libebook-sections.txt
index 0430505..5a5725f 100644
--- a/docs/reference/addressbook/libebook/libebook-sections.txt
+++ b/docs/reference/addressbook/libebook/libebook-sections.txt
@@ -145,6 +145,12 @@ e_contact_name_from_string
 e_contact_name_copy
 e_contact_date_free
 e_contact_name_free
+e_contact_photo_get_inlined
+e_contact_photo_set_inlined
+e_contact_photo_get_mime_type
+e_contact_photo_set_mime_type
+e_contact_photo_get_uri
+e_contact_photo_set_uri
 e_contact_photo_free
 e_contact_geo_free
 e_contact_address_free
diff --git a/docs/reference/addressbook/libebook/tmpl/e-contact.sgml b/docs/reference/addressbook/libebook/tmpl/e-contact.sgml
index 5036399..c2b4f90 100644
--- a/docs/reference/addressbook/libebook/tmpl/e-contact.sgml
+++ b/docs/reference/addressbook/libebook/tmpl/e-contact.sgml
@@ -1010,6 +1010,59 @@ The URI of the contact's calendar.
 
 @photo: 
 
+ 
+<!-- ##### FUNCTION e_contact_photo_get_inlined ##### -->
+<para>
+
+</para>
+
+ photo:
+ len:
+ Returns: 
+
+
+<!-- ##### FUNCTION e_contact_photo_set_inlined ##### -->
+<para>
+
+</para>
+
+ photo:
+ data:
+ len:
+
+<!-- ##### FUNCTION e_contact_photo_get_mime_type ##### -->
+<para>
+
+</para>
+
+ photo:
+ Returns: 
+
+
+<!-- ##### FUNCTION e_contact_photo_set_mime_type ##### -->
+<para>
+
+</para>
+
+ photo:
+ mime_type:
+
+<!-- ##### FUNCTION e_contact_photo_get_uri ##### -->
+<para>
+
+</para>
+
+ photo:
+ Returns: 
+
+
+<!-- ##### FUNCTION e_contact_photo_set_uri ##### -->
+<para>
+
+</para>
+
+ photo:
+ uri:
 
 <!-- ##### FUNCTION e_contact_geo_free ##### -->
 <para>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]