~ubuntu-branches/ubuntu/wily/evolution-data-server/wily

« back to all changes in this revision

Viewing changes to addressbook/libebook-contacts/e-contact.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2015-07-20 13:34:59 UTC
  • mfrom: (1.1.126) (1.2.48 sid)
  • Revision ID: package-import@ubuntu.com-20150720133459-g6y46hnu5ewtoz08
Tags: 3.16.4-0ubuntu2
debian/patches/0001-Bug-752373-Monthly-events-do-not-recur-correctly.patch:
Cherry-pick patch from upstream to fix events not recurring correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
5
5
 * Copyright (C) 2012 Intel Corporation
6
6
 *
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.
10
10
 *
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.
15
15
 *
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/>.
18
18
 *
19
 
 * Authors:
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>
22
21
 */
23
22
 
24
23
/**
372
371
                GParamFlags flags;
373
372
 
374
373
                /* Verify the table is correctly ordered */
375
 
                g_assert (ii == field_info[ii].field_id);
 
374
                g_return_if_fail (ii == field_info[ii].field_id);
376
375
 
377
376
                flags = G_PARAM_READABLE |
378
377
                        G_PARAM_STATIC_NICK |
1471
1470
 *
1472
1471
 * Returns: Whether the @field_id is of a string type.
1473
1472
 *
1474
 
 * Since: 3.14
 
1473
 * Since: 3.16
1475
1474
 **/
1476
1475
gboolean
1477
1476
e_contact_field_is_string (EContactField field_id)
1806
1805
e_contact_get_attributes (EContact *contact,
1807
1806
                          EContactField field_id)
1808
1807
{
 
1808
        EContactField set[1];
 
1809
        set[0] = field_id;
 
1810
        return e_contact_get_attributes_set (contact, set, 1);
 
1811
}
 
1812
 
 
1813
/**
 
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
 
1818
 *
 
1819
 * Gets a list of the vcard attributes for @contact's @field_ids.
 
1820
 *
 
1821
 * Returns: (transfer full) (element-type EVCardAttribute): A #GList of pointers
 
1822
 * to #EVCardAttribute, owned by the caller.
 
1823
 *
 
1824
 * Since: 3.16
 
1825
 **/
 
1826
GList *
 
1827
e_contact_get_attributes_set (EContact *contact,
 
1828
                              const EContactField field_ids[],
 
1829
                              gint size)
 
1830
{
1809
1831
        GList *l = NULL;
1810
1832
        GList *attrs, *a;
1811
 
        const EContactFieldInfo *info = NULL;
 
1833
        gint ii;
 
1834
        EContactFieldInfo **infos;
1812
1835
 
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);
1815
1839
 
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]];
 
1844
        }
1817
1845
 
1818
1846
        attrs = e_vcard_get_attributes (E_VCARD (contact));
1819
1847
 
1823
1851
 
1824
1852
                name = e_vcard_attribute_get_name (attr);
1825
1853
 
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));
 
1857
                                break;
 
1858
                        }
1828
1859
                }
1829
1860
        }
1830
1861
 
 
1862
        g_free (infos);
 
1863
 
1831
1864
        return g_list_reverse (l);
1832
1865
}
1833
1866