4
4
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
5
5
* Copyright (C) 2012 Intel Corporation
7
* This library is free software you can redistribute it and/or modify it
7
* This library is free software: you can redistribute it and/or modify it
8
8
* under the terms of the GNU Lesser General Public License as published by
9
9
* the Free Software Foundation.
11
11
* This library is distributed in the hope that it will be useful, but
12
12
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14
14
* for more details.
16
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this library; if not, see <http://www.gnu.org/licenses/>.
17
* along with this library. If not, see <http://www.gnu.org/licenses/>.
20
* Chris Toshok (toshok@ximian.com)
21
* Tristan Van Berkom <tristanvb@openismus.com>
19
* Authors: Chris Toshok (toshok@ximian.com)
20
* Tristan Van Berkom <tristanvb@openismus.com>
1806
1805
e_contact_get_attributes (EContact *contact,
1807
1806
EContactField field_id)
1808
EContactField set[1];
1810
return e_contact_get_attributes_set (contact, set, 1);
1814
* e_contact_get_attributes_set:
1815
* @contact: an #EContact
1816
* @field_ids: an array of #EContactField
1817
* @size: number of elements in field_ids
1819
* Gets a list of the vcard attributes for @contact's @field_ids.
1821
* Returns: (transfer full) (element-type EVCardAttribute): A #GList of pointers
1822
* to #EVCardAttribute, owned by the caller.
1827
e_contact_get_attributes_set (EContact *contact,
1828
const EContactField field_ids[],
1809
1831
GList *l = NULL;
1810
1832
GList *attrs, *a;
1811
const EContactFieldInfo *info = NULL;
1834
EContactFieldInfo **infos;
1813
1836
g_return_val_if_fail (contact && E_IS_CONTACT (contact), NULL);
1814
g_return_val_if_fail (field_id >= 1 && field_id < E_CONTACT_FIELD_LAST, NULL);
1837
g_return_val_if_fail (size > 0, NULL);
1838
g_return_val_if_fail (size < E_CONTACT_FIELD_LAST, NULL);
1816
info = &field_info[field_id];
1840
infos = g_new0 (EContactFieldInfo *, size);
1841
for (ii = 0; ii < size; ii++) {
1842
g_return_val_if_fail (field_ids[ii] >= 1 && field_ids[ii] < E_CONTACT_FIELD_LAST, NULL);
1843
infos[ii] = (EContactFieldInfo *) &field_info[field_ids[ii]];
1818
1846
attrs = e_vcard_get_attributes (E_VCARD (contact));
1824
1852
name = e_vcard_attribute_get_name (attr);
1826
if (!g_ascii_strcasecmp (name, info->vcard_field_name)) {
1827
l = g_list_prepend (l, e_vcard_attribute_copy (attr));
1854
for (ii = 0; ii < size; ii++) {
1855
if (!g_ascii_strcasecmp (name, infos[ii]->vcard_field_name)) {
1856
l = g_list_prepend (l, e_vcard_attribute_copy (attr));
1831
1864
return g_list_reverse (l);