[evolution-data-server/openismus-work-3-8: 8/43] Added e_vcard_construct_full()



commit 0008b6a776be58ee49ab170d1f524904166ed3e9
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Tue Nov 26 17:11:52 2013 +0900

    Added e_vcard_construct_full()
    
    This new variant allows construction of a vcard from a string
    which is not terminated.

 addressbook/libebook-contacts/e-vcard.c |   30 ++++++++++++++++++++++++++++--
 addressbook/libebook-contacts/e-vcard.h |    1 +
 2 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/addressbook/libebook-contacts/e-vcard.c b/addressbook/libebook-contacts/e-vcard.c
index ab0eafb..9c8f068 100644
--- a/addressbook/libebook-contacts/e-vcard.c
+++ b/addressbook/libebook-contacts/e-vcard.c
@@ -858,14 +858,40 @@ e_vcard_construct_with_uid (EVCard *evc,
                             const gchar *str,
                             const gchar *uid)
 {
+       e_vcard_construct_full (evc, str, -1, uid);
+}
+
+/**
+ * e_vcard_construct_full:
+ * @evc: an existing #EVCard
+ * @str: a vCard string
+ * @len: length of @str, or -1 if @str is %NULL terminated
+ * @uid: (allow-none): a unique ID string
+ *
+ * Similar to e_vcard_construct_with_uid(), but can also
+ * be used with an @str that is not %NULL terminated.
+ *
+ * Since: 3.12
+ **/
+void
+e_vcard_construct_full (EVCard      *evc,
+                       const gchar *str,
+                       gssize       len,
+                       const gchar *uid)
+{
        g_return_if_fail (E_IS_VCARD (evc));
        g_return_if_fail (str != NULL);
        g_return_if_fail (evc->priv->vcard == NULL);
        g_return_if_fail (evc->priv->attributes == NULL);
 
        /* Lazy construction */
-       if (*str)
-               evc->priv->vcard = g_strdup (str);
+       if (*str) {
+
+               if (len < 0)
+                       evc->priv->vcard = g_strdup (str);
+               else
+                       evc->priv->vcard = g_strndup (str, len);
+       }
 
        /* Add UID attribute */
        if (uid) {
diff --git a/addressbook/libebook-contacts/e-vcard.h b/addressbook/libebook-contacts/e-vcard.h
index c3d475c..decd50e 100644
--- a/addressbook/libebook-contacts/e-vcard.h
+++ b/addressbook/libebook-contacts/e-vcard.h
@@ -241,6 +241,7 @@ GType   e_vcard_get_type                     (void);
 
 void    e_vcard_construct                    (EVCard *evc, const gchar *str);
 void    e_vcard_construct_with_uid           (EVCard *evc, const gchar *str, const gchar *uid);
+void    e_vcard_construct_full               (EVCard *evc, const gchar *str, gssize len, const gchar *uid);
 EVCard * e_vcard_new                          (void);
 EVCard * e_vcard_new_from_string              (const gchar *str);
 


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