~ubuntu-branches/ubuntu/utopic/evolution-data-server/utopic-proposed

« back to all changes in this revision

Viewing changes to addressbook/libebook/e-destination.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-06-13 12:02:14 UTC
  • mfrom: (1.1.116) (1.2.35 sid)
  • Revision ID: package-import@ubuntu.com-20140613120214-1zx93d8jxwt093aw
Tags: 3.12.2-1ubuntu1
* Merge with Debian, remaining changes:
  - debian/control: build depend on hardening-wrapper
  - Add build-depends and pass configure flag to enable Ubuntu Online
    Accounts support.
  - Filter out -Bsymbolic-functions from LDFLAGS (for future people
    wondering about this change, see e.g. BGO #594473 and duplicates).
  - Enable Ubuntu Online Accounts and split it and GOA into a separate
    package

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 */
11
11
 
12
12
/*
13
 
 * This program is free software; you can redistribute it and/or
14
 
 * modify it under the terms of version 2 of the GNU Lesser General Public
15
 
 * License as published by the Free Software Foundation.
 
13
 * This library is free software you can redistribute it and/or modify it
 
14
 * under the terms of the GNU Lesser General Public License as published by
 
15
 * the Free Software Foundation.
16
16
 *
17
 
 * This program is distributed in the hope that it will be useful,
18
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 
 * GNU Lesser General Public License for more details.
 
17
 * This library is distributed in the hope that it will be useful, but
 
18
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
19
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
20
 *for more details.
21
21
 *
22
22
 * You should have received a copy of the GNU Lesser General Public License
23
 
 * along with this program; if not, write to the Free Software
24
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
25
 
 * USA.
 
23
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
26
24
 */
27
25
 
28
26
/*
144
142
static void
145
143
e_destination_class_init (EDestinationClass *class)
146
144
{
147
 
        GObjectClass *object_class = G_OBJECT_CLASS (class);
 
145
        GObjectClass *object_class;
148
146
 
149
147
        g_type_class_add_private (class, sizeof (EDestinationPrivate));
150
148
 
350
348
                return FALSE;
351
349
}
352
350
 
 
351
static void
 
352
remove_empty_subgroups (EDestination *dest,
 
353
                        GHashTable *lists_hash)
 
354
{
 
355
        EDestination *s_dest;
 
356
        GSList *to_remove = NULL, *siter;
 
357
        GList *iter;
 
358
 
 
359
        if (!dest)
 
360
                return;
 
361
 
 
362
        for (iter = dest->priv->list_dests; iter; iter = g_list_next (iter)) {
 
363
                s_dest = iter->data;
 
364
 
 
365
                remove_empty_subgroups (s_dest, lists_hash);
 
366
 
 
367
                if (g_hash_table_lookup (lists_hash, s_dest) &&
 
368
                    !s_dest->priv->list_dests)
 
369
                        to_remove = g_slist_prepend (to_remove, s_dest);
 
370
        }
 
371
 
 
372
        for (siter = to_remove; siter; siter = g_slist_next (siter)) {
 
373
                s_dest = siter->data;
 
374
 
 
375
                dest->priv->list_dests = g_list_remove (dest->priv->list_dests, s_dest);
 
376
                dest->priv->list_alldests = g_list_remove (dest->priv->list_alldests, s_dest);
 
377
        }
 
378
 
 
379
        g_slist_free_full (to_remove, g_object_unref);
 
380
}
 
381
 
353
382
/**
354
383
 * e_destination_set_contact:
355
384
 * @dest: an #EDestination
383
412
                if (e_contact_get (dest->priv->contact, E_CONTACT_IS_LIST)) {
384
413
                        gint list_length;
385
414
                        GList *attr, *attrs;
386
 
                        GHashTable *hash_table;
 
415
                        GHashTable *hash_table, *lists_hash;
387
416
                        gint list_iterations = 0;
388
417
                        gint lists_count = 0;
389
418
 
390
419
                        hash_table = g_hash_table_new_full (
391
420
                                g_str_hash, g_str_equal,
392
421
                                (GDestroyNotify) g_free, NULL);
 
422
                        lists_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
393
423
 
394
424
                        g_hash_table_insert (hash_table, g_strdup ("0"), dest);
395
425
 
485
515
                                                if (id)
486
516
                                                        g_hash_table_insert (hash_table, g_strdup (id), s_dest);
487
517
                                                lists_count--;
 
518
 
 
519
                                                g_hash_table_insert (lists_hash, s_dest, GINT_TO_POINTER (1));
488
520
                                        }
489
521
 
490
522
                                        if (id) {
520
552
                                }
521
553
                        }
522
554
 
 
555
                        remove_empty_subgroups (dest, lists_hash);
 
556
 
 
557
                        g_hash_table_unref (lists_hash);
523
558
                        g_hash_table_unref (hash_table);
524
559
                        g_list_free (attrs);
525
 
 
526
560
                } else {
527
561
                        /* handle the normal contact case */
528
562
                        /* is there anything to do here? */
532
566
        } else if (dest->priv->email_num != email_num) {
533
567
                /* Splitting here would help the contact lists not rebuiding, so that it remembers ignored values */
534
568
 
 
569
                /* increase ref counter, because e_destination_clear calls g_object_unref, but we want to keep the contact */
 
570
                g_object_ref (contact);
 
571
 
535
572
                e_destination_clear (dest);
536
573
 
537
 
                dest->priv->contact = e_contact_duplicate (contact);
 
574
                dest->priv->contact = contact;
538
575
 
539
576
                dest->priv->contact_uid = e_contact_get (dest->priv->contact, E_CONTACT_UID);
540
577
 
891
928
                        if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) {
892
929
                                const gchar *camel_name = NULL;
893
930
 
894
 
                                camel_internet_address_get (addr, 0, &camel_name, NULL);
895
 
                                priv->name = g_strdup (camel_name);
 
931
                                if (camel_internet_address_get (addr, 0, &camel_name, NULL))
 
932
                                        priv->name = g_strdup (camel_name);
896
933
                        }
897
934
 
898
935
                        g_object_unref (addr);
967
1004
 
968
1005
                        if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) {
969
1006
                                const gchar *camel_email = NULL;
970
 
                                camel_internet_address_get (addr, 0, NULL, &camel_email);
971
 
                                priv->email = g_strdup (camel_email);
 
1007
                                if (camel_internet_address_get (addr, 0, NULL, &camel_email))
 
1008
                                        priv->email = g_strdup (camel_email);
972
1009
                        }
973
1010
 
974
1011
                        g_object_unref (addr);