[evolution-data-server] Add e_contact_get_attributes_set() for changes in bug #340075



commit e231b07f52378c34cb3640ff59abad6f18c10a03
Author: Christian Schaarschmidt <schaarsc gmx de>
Date:   Wed Apr 2 11:03:31 2014 +0200

    Add e_contact_get_attributes_set() for changes in bug #340075

 addressbook/libebook-contacts/e-contact.c |   44 +++++++++++++++++++++++++---
 addressbook/libebook-contacts/e-contact.h |    6 +++-
 docs/reference/eds/eds-sections.txt       |    1 +
 3 files changed, 45 insertions(+), 6 deletions(-)
---
diff --git a/addressbook/libebook-contacts/e-contact.c b/addressbook/libebook-contacts/e-contact.c
index a2a5ac4..fa03786 100644
--- a/addressbook/libebook-contacts/e-contact.c
+++ b/addressbook/libebook-contacts/e-contact.c
@@ -1780,14 +1780,43 @@ GList *
 e_contact_get_attributes (EContact *contact,
                           EContactField field_id)
 {
+       EContactField set[1];
+       set[0] = field_id;
+       return e_contact_get_attributes_set (contact, set, 1);
+}
+
+/**
+ * e_contact_get_attributes_set:
+ * @contact: an #EContact
+ * @field_ids: an array of #EContactField
+ * @size: number of elements in field_ids
+ *
+ * Gets a list of the vcard attributes for @contact's @field_ids.
+ *
+ * Returns: (transfer full) (element-type EVCardAttribute): A #GList of pointers
+ * to #EVCardAttribute, owned by the caller.
+ *
+ * Since: 3.14
+ **/
+GList *
+e_contact_get_attributes_set (EContact *contact,
+                              const EContactField field_ids[],
+                              gint size)
+{
        GList *l = NULL;
        GList *attrs, *a;
-       const EContactFieldInfo *info = NULL;
+       gint ii;
+       EContactFieldInfo **infos;
 
        g_return_val_if_fail (contact && E_IS_CONTACT (contact), NULL);
-       g_return_val_if_fail (field_id >= 1 && field_id < E_CONTACT_FIELD_LAST, NULL);
+       g_return_val_if_fail (size > 0, NULL);
+       g_return_val_if_fail (size < E_CONTACT_FIELD_LAST, NULL);
 
-       info = &field_info[field_id];
+       infos = g_new0 (EContactFieldInfo *, size);
+       for (ii = 0; ii < size; ii++) {
+               g_return_val_if_fail (field_ids[ii] >= 1 && field_ids[ii] < E_CONTACT_FIELD_LAST, NULL);
+               infos[ii] = (EContactFieldInfo *) &field_info[field_ids[ii]];
+       }
 
        attrs = e_vcard_get_attributes (E_VCARD (contact));
 
@@ -1797,11 +1826,16 @@ e_contact_get_attributes (EContact *contact,
 
                name = e_vcard_attribute_get_name (attr);
 
-               if (!g_ascii_strcasecmp (name, info->vcard_field_name)) {
-                       l = g_list_prepend (l, e_vcard_attribute_copy (attr));
+               for (ii = 0; ii < size; ii++) {
+                       if (!g_ascii_strcasecmp (name, infos[ii]->vcard_field_name)) {
+                               l = g_list_prepend (l, e_vcard_attribute_copy (attr));
+                               break;
+                       }
                }
        }
 
+       g_free (infos);
+
        return g_list_reverse (l);
 }
 
diff --git a/addressbook/libebook-contacts/e-contact.h b/addressbook/libebook-contacts/e-contact.h
index dbd9778..b5d771b 100644
--- a/addressbook/libebook-contacts/e-contact.h
+++ b/addressbook/libebook-contacts/e-contact.h
@@ -358,10 +358,14 @@ void              e_contact_set                   (EContact *contact,
                                                 EContactField field_id,
                                                 gconstpointer value);
 
-/* the following two calls return and take a GList of
+/* the following three calls return and take a GList of
  * EVCardAttribute*'s. */
 GList *                e_contact_get_attributes        (EContact *contact,
                                                 EContactField field_id);
+GList *                e_contact_get_attributes_set    (EContact *contact,
+                                                const EContactField field_ids[],
+                                                gint size);
+
 void           e_contact_set_attributes        (EContact *contact,
                                                 EContactField field_id,
                                                 GList *attributes);
diff --git a/docs/reference/eds/eds-sections.txt b/docs/reference/eds/eds-sections.txt
index 29ef52c..30684c9 100644
--- a/docs/reference/eds/eds-sections.txt
+++ b/docs/reference/eds/eds-sections.txt
@@ -1733,6 +1733,7 @@ e_contact_get
 e_contact_get_const
 e_contact_set
 e_contact_get_attributes
+e_contact_get_attributes_set
 e_contact_set_attributes
 e_contact_date_new
 e_contact_date_from_string


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