tpf-persona.vala 21.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * Copyright (C) 2010 Collabora Ltd.
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *       Travis Reitter <travis.reitter@collabora.co.uk>
 */

21
using Gee;
22
using GLib;
23
using TelepathyGLib;
24
using Folks;
25

26
27
28
29
/**
 * A persona subclass which represents a single instant messaging contact from
 * Telepathy.
 */
30
public class Tpf.Persona : Folks.Persona,
31
    AliasDetails,
32
    AvatarDetails,
33
    FavouriteDetails,
34
    GroupDetails,
Travis Reitter's avatar
Travis Reitter committed
35
    ImDetails,
36
    NameDetails,
37
    PhoneDetails,
38
    PresenceDetails
39
{
40
  private HashSet<string> _groups;
41
  private Set<string> _groups_ro;
Philip Withnall's avatar
Philip Withnall committed
42
  private bool _is_favourite;
43
  private string _alias; /* must never be null */
44
  private string _full_name; /* must never be null */
45
  private HashMultiMap<string, ImFieldDetails> _im_addresses;
46
  private const string[] _linkable_properties = { "im-addresses" };
47
48
49
50
51
52
  private const string[] _writeable_properties =
    {
      "alias",
      "is-favourite",
      "groups"
    };
53

54
55
56
57
  /* Whether we've finished being constructed; this is used to prevent
   * unnecessary trips to the Telepathy service to tell it about properties
   * being set which are actually just being set from data it's just given us.
   */
58
  private bool _is_constructed = false;
59

60
61
62
63
64
65
66
67
  /**
   * Whether the Persona is in the user's contact list.
   *
   * This will be true for most {@link Folks.Persona}s, but may not be true for
   * personas where {@link Folks.Persona.is_user} is true. If it's false in
   * this case, it means that the persona has been retrieved from the Telepathy
   * connection, but has not been added to the user's contact list.
   *
68
   * @since 0.3.5
69
70
71
   */
  public bool is_in_contact_list { get; set; }

72
73
  private LoadableIcon? _avatar = null;

74
  /**
75
76
   * An avatar for the Persona.
   *
77
   * See {@link Folks.AvatarDetails.avatar}.
78
   *
Travis Reitter's avatar
Travis Reitter committed
79
   * @since 0.6.0
80
   */
81
82
83
84
85
86
  [CCode (notify = false)]
  public LoadableIcon? avatar
    {
      get { return this._avatar; }
      set { this.change_avatar.begin (value); } /* not writeable */
    }
87

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public StructuredName? structured_name
    {
      get { return null; }
      set { this.change_structured_name.begin (value); } /* not writeable */
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public string full_name
    {
      get { return this._full_name; }
      set { this.change_full_name.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_full_name (string full_name) throws PropertyError
    {
      var tpf_store = this.store as Tpf.PersonaStore;

      if (full_name == this._full_name)
        return;

      if (this._is_constructed)
        {
          try
            {
              yield tpf_store.change_user_full_name (this, full_name);
            }
          catch (PersonaStoreError.INVALID_ARGUMENT e1)
            {
              throw new PropertyError.NOT_WRITEABLE (e1.message);
            }
          catch (PersonaStoreError.STORE_OFFLINE e2)
            {
              throw new PropertyError.UNKNOWN_ERROR (e2.message);
            }
          catch (PersonaStoreError e3)
            {
              throw new PropertyError.UNKNOWN_ERROR (e3.message);
            }
        }

      /* the change will be notified when we receive changes to
       * contact.contact_info */
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public string nickname
    {
      get { return ""; }
      set { this.change_nickname.begin (value); } /* not writeable */
    }

160
  /**
161
162
   * The Persona's presence type.
   *
163
   * See {@link Folks.PresenceDetails.presence_type}.
164
   */
165
  public Folks.PresenceType presence_type { get; private set; }
166

167
168
169
170
171
  /**
   * The Persona's presence status.
   *
   * See {@link Folks.PresenceDetails.presence_status}.
   *
Travis Reitter's avatar
Travis Reitter committed
172
   * @since 0.6.0
173
174
175
   */
  public string presence_status { get; private set; }

176
  /**
177
178
   * The Persona's presence message.
   *
179
   * See {@link Folks.PresenceDetails.presence_message}.
180
   */
181
  public string presence_message { get; private set; }
Travis Reitter's avatar
Travis Reitter committed
182

183
184
185
186
187
188
189
190
191
192
  /**
   * The names of the Persona's linkable properties.
   *
   * See {@link Folks.Persona.linkable_properties}.
   */
  public override string[] linkable_properties
    {
      get { return this._linkable_properties; }
    }

193
194
195
  /**
   * {@inheritDoc}
   *
Travis Reitter's avatar
Travis Reitter committed
196
   * @since 0.6.0
197
198
199
200
201
202
   */
  public override string[] writeable_properties
    {
      get { return this._writeable_properties; }
    }

203
  /**
204
205
   * An alias for the Persona.
   *
206
   * See {@link Folks.AliasDetails.alias}.
207
   */
208
  [CCode (notify = false)]
209
210
211
  public string alias
    {
      get { return this._alias; }
212
213
      set { this.change_alias.begin (value); }
    }
214

215
216
217
  /**
   * {@inheritDoc}
   *
Raul Gutierrez Segales's avatar
Raul Gutierrez Segales committed
218
   * @since 0.6.2
219
220
221
222
   */
  public async void change_alias (string alias) throws PropertyError
    {
      if (this._alias == alias)
223
        {
224
225
          return;
        }
226

227
228
229
      if (this._is_constructed)
        {
          yield ((Tpf.PersonaStore) this.store).change_alias (this, alias);
230
        }
231
232
233

      this._alias = alias;
      this.notify_property ("alias");
234
235
    }

236
  /**
237
238
   * Whether this Persona is a user-defined favourite.
   *
239
   * See {@link Folks.FavouriteDetails.is_favourite}.
240
   */
241
  [CCode (notify = false)]
242
  public bool is_favourite
Philip Withnall's avatar
Philip Withnall committed
243
244
    {
      get { return this._is_favourite; }
245
246
      set { this.change_is_favourite.begin (value); }
    }
Philip Withnall's avatar
Philip Withnall committed
247

248
249
250
  /**
   * {@inheritDoc}
   *
Raul Gutierrez Segales's avatar
Raul Gutierrez Segales committed
251
   * @since 0.6.2
252
253
254
255
   */
  public async void change_is_favourite (bool is_favourite) throws PropertyError
    {
      if (this._is_favourite == is_favourite)
Philip Withnall's avatar
Philip Withnall committed
256
        {
257
258
          return;
        }
Philip Withnall's avatar
Philip Withnall committed
259

260
261
262
263
      if (this._is_constructed)
        {
          yield ((Tpf.PersonaStore) this.store).change_is_favourite (this,
              is_favourite);
Philip Withnall's avatar
Philip Withnall committed
264
        }
265
266
267

      this._is_favourite = is_favourite;
      this.notify_property ("is-favourite");
Philip Withnall's avatar
Philip Withnall committed
268
269
    }

270
  /**
271
   * A mapping of IM protocol to an (unordered) set of IM addresses.
272
   *
Travis Reitter's avatar
Travis Reitter committed
273
   * See {@link Folks.ImDetails.im_addresses}.
274
   */
275
  [CCode (notify = false)]
276
  public MultiMap<string, ImFieldDetails> im_addresses
277
278
    {
      get { return this._im_addresses; }
279
      set { this.change_im_addresses.begin (value); }
280
281
    }

282
  /**
283
284
   * A mapping of group ID to whether the contact is a member.
   *
285
   * See {@link Folks.GroupDetails.groups}.
286
   */
287
  [CCode (notify = false)]
288
  public Set<string> groups
289
    {
290
      get { return this._groups_ro; }
291
      set { this.change_groups.begin (value); }
292
293
    }

294
  /**
295
296
   * Add or remove the Persona from the specified group.
   *
297
   * See {@link Folks.GroupDetails.change_group}.
298
   */
299
  public async void change_group (string group, bool is_member)
300
    {
301
      if (this._change_group (group, is_member))
302
        {
303
          Tpf.PersonaStore store = (Tpf.PersonaStore) this.store;
304
          yield store._change_group_membership (this, group, is_member);
305
306
307
308
        }
    }

  private bool _change_group (string group, bool is_member)
309
    {
310
      var changed = false;
311
312
313

      if (is_member)
        {
314
          if (!this._groups.contains (group))
315
            {
316
              this._groups.add (group);
317
318
319
320
321
322
              changed = true;
            }
        }
      else
        changed = this._groups.remove (group);

323
324
325
      if (changed == true)
        this.group_changed (group, is_member);

326
      return changed;
327
328
    }

329
330
331
  /**
   * {@inheritDoc}
   *
Raul Gutierrez Segales's avatar
Raul Gutierrez Segales committed
332
   * @since 0.6.2
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
   */
  public async void change_groups (Set<string> groups) throws PropertyError
    {
      Tpf.PersonaStore store = (Tpf.PersonaStore) this.store;

      foreach (var group1 in groups)
        {
          if (this._groups.contains (group1) == false)
            yield store._change_group_membership (this, group1, true);
        }

      foreach (var group2 in this._groups)
        {
          if (groups.contains (group2) == false)
            yield store._change_group_membership (this, group2, false);
        }

      this.notify_property ("groups");
    }

353
354
  /**
   * The Telepathy contact represented by this persona.
355
356
357
358
359
360
   *
   * Note that this may be `null` if the {@link PersonaStore} providing this
   * {@link Persona} isn't currently available (e.g. due to not being connected
   * to the network). In this case, most other properties of the {@link Persona}
   * are being retrieved from a cache and may not be current (though there's no
   * way to tell this).
361
   */
362
  public Contact? contact { get; construct; }
363

364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
  private HashSet<PhoneFieldDetails> _phone_numbers;
  private Set<PhoneFieldDetails> _phone_numbers_ro;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public Set<PhoneFieldDetails> phone_numbers
    {
      get { return this._phone_numbers_ro; }
      set { this.change_phone_numbers.begin (value); }
    }

379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_phone_numbers (
      Set<PhoneFieldDetails> phone_numbers) throws PropertyError
    {
      yield this._change_details<PhoneFieldDetails> (phone_numbers,
          this._phone_numbers, "tel");
    }

  private async void _change_details<T> (
      Set<AbstractFieldDetails<string>> details,
      Set<AbstractFieldDetails<string>> member_set,
      string field_name)
        throws PropertyError
    {
      var tpf_store = this.store as Tpf.PersonaStore;

      if (Folks.PersonaStore.equal_sets<PhoneFieldDetails> (phone_numbers,
              this._phone_numbers))
        {
          return;
        }

      if (this._is_constructed)
        {
          try
            {
              yield tpf_store._change_user_details (this, details, field_name);
            }
          catch (PersonaStoreError.INVALID_ARGUMENT e1)
            {
              throw new PropertyError.NOT_WRITEABLE (e1.message);
            }
          catch (PersonaStoreError.STORE_OFFLINE e2)
            {
              throw new PropertyError.UNKNOWN_ERROR (e2.message);
            }
          catch (PersonaStoreError e3)
            {
              throw new PropertyError.UNKNOWN_ERROR (e3.message);
            }
        }

      /* the change will be notified when we receive changes to
       * contact.contact_info */
    }

429
430
431
432
433
  /**
   * Create a new persona.
   *
   * Create a new persona for the {@link PersonaStore} `store`, representing
   * the Telepathy contact given by `contact`.
434
435
436
   *
   * @param contact the Telepathy contact being represented by the persona
   * @param store the persona store to place the persona in
437
   */
438
  public Persona (Contact contact, PersonaStore store)
439
    {
440
      unowned string id = contact.get_identifier ();
441
      var connection = contact.connection;
442
      var account = this._account_for_connection (connection);
443
      var uid = this.build_uid (store.type_id, store.id, id);
444

445
      Object (alias: contact.get_alias (),
446
              contact: contact,
447
              display_id: id,
Travis Reitter's avatar
Travis Reitter committed
448
              /* FIXME: This IID format should be moved out to the ImDetails
449
450
451
452
               * interface along with the code in
               * Kf.Persona.linkable_property_to_links(), but that depends on
               * bgo#624842 being fixed. */
              iid: account.get_protocol () + ":" + id,
Travis Reitter's avatar
Travis Reitter committed
453
              uid: uid,
454
              store: store,
455
              is_user: contact.handle == connection.self_handle);
456

457
458
      this._full_name = "";

459
460
      contact.notify["alias"].connect ((s, p) =>
          {
461
462
463
            /* Tp guarantees that aliases are always non-null. */
            assert (this.contact.alias != null);

464
            if (this._alias != this.contact.alias)
465
              {
466
                this._alias = this.contact.alias;
467
468
469
470
                this.notify_property ("alias");
              }
          });

471
472
      debug ("Creating new Tpf.Persona '%s' for service-specific UID '%s': %p",
          uid, id, this);
473
      this._is_constructed = true;
474

475
      /* Set our single IM address */
476
477
478
479
      this._im_addresses = new HashMultiMap<string, ImFieldDetails> (
          null, null,
          (GLib.HashFunc) ImFieldDetails.hash,
          (GLib.EqualFunc) ImFieldDetails.equal);
480

481
482
      try
        {
483
484
485
486
          var im_addr = ImDetails.normalise_im_address (id,
              account.get_protocol ());
          var im_fd = new ImFieldDetails (im_addr);
          this._im_addresses.set (account.get_protocol (), im_fd);
487
        }
Travis Reitter's avatar
Travis Reitter committed
488
      catch (ImDetailsError e)
489
490
491
492
        {
          /* This should never happen…but if it does, warn of it and continue */
          warning (e.message);
        }
493
494

      /* Groups */
495
      this._groups = new HashSet<string> ();
496
      this._groups_ro = this._groups.read_only_view;
497

498
499
500
501
502
      this._phone_numbers = new HashSet<PhoneFieldDetails> (
          (GLib.HashFunc) PhoneFieldDetails.hash,
          (GLib.EqualFunc) PhoneFieldDetails.equal);
      this._phone_numbers_ro = this._phone_numbers.read_only_view;

503
504
      contact.notify["avatar-file"].connect ((s, p) =>
        {
505
          this._contact_notify_avatar ();
506
        });
507
      this._contact_notify_avatar ();
508

509
510
      contact.notify["presence-message"].connect ((s, p) =>
        {
511
          this._contact_notify_presence_message ();
512
513
514
        });
      contact.notify["presence-type"].connect ((s, p) =>
        {
515
          this._contact_notify_presence_type ();
516
        });
517
518
519
520
      contact.notify["presence-status"].connect ((s, p) =>
        {
          this._contact_notify_presence_status ();
        });
521
522
      this._contact_notify_presence_message ();
      this._contact_notify_presence_type ();
523
      this._contact_notify_presence_status ();
524

525
526
      contact.notify["contact-info"].connect ((s, p) =>
        {
527
          this._contact_notify_contact_info ();
528
        });
529
      this._contact_notify_contact_info ();
530

531
532
533
534
535
      ((Tpf.PersonaStore) this.store).group_members_changed.connect (
          (s, group, added, removed) =>
            {
              if (added.find (this) != null)
                this._change_group (group, true);
536

537
538
539
              if (removed.find (this) != null)
                this._change_group (group, false);
            });
540

541
542
543
      ((Tpf.PersonaStore) this.store).group_removed.connect (
          (s, group, error) =>
            {
544
545
546
547
548
549
550
              /* FIXME: Can't use
               * !(error is TelepathyGLib.DBusError.OBJECT_REMOVED) because the
               * GIR bindings don't annotate errors */
              if (error != null &&
                  (error.domain != TelepathyGLib.dbus_errors_quark () ||
                   error.code != TelepathyGLib.DBusError.OBJECT_REMOVED))
                {
551
                  debug ("Group invalidated: %s", error.message);
552
                  this._change_group (group, false);
553
                }
554
            });
555
556
    }

557
  private void _contact_notify_contact_info ()
558
    {
559
      var new_full_name = "";
560
561
562
563
564
565
566
      var new_phone_numbers = new HashSet<PhoneFieldDetails> (
          (GLib.HashFunc) PhoneFieldDetails.hash,
          (GLib.EqualFunc) PhoneFieldDetails.equal);

      var contact_info = this.contact.get_contact_info ();
      foreach (var info in contact_info)
        {
567
568
569
570
571
572
          if (info.field_name == "") {}
          else if (info.field_name == "fn")
            {
              new_full_name = info.field_value[0];
            }
          else if (info.field_name == "tel")
573
            {
574
575
576
577
578
579
              foreach (var phone_num in info.field_value)
                {
                  var parameters = this._afd_params_from_strv (info.parameters);
                  var phone_fd = new PhoneFieldDetails (phone_num, parameters);
                  new_phone_numbers.add (phone_fd);
                }
580
581
582
            }
        }

583
584
585
586
587
588
      if (new_full_name != this._full_name)
        {
          this._full_name = new_full_name;
          this.notify_property ("full-name");
        }

589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
      if (!Folks.PersonaStore.equal_sets<PhoneFieldDetails> (new_phone_numbers,
              this._phone_numbers))
        {
          this._phone_numbers = new_phone_numbers;
          this._phone_numbers_ro = new_phone_numbers.read_only_view;
          this.notify_property ("phone-numbers");
        }
    }

  private MultiMap<string, string> _afd_params_from_strv (string[] parameters)
    {
      var retval = new HashMultiMap<string, string> ();

      foreach (var entry in parameters)
        {
          var tokens = entry.split ("=", 2);
          if (tokens.length == 2)
            {
              retval.set (tokens[0], tokens[1]);
            }
          else
            {
              warning ("Failed to parse vCard parameter from string '%s'",
                  entry);
            }
        }

      return retval;
    }

619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
  /**
   * Create a new persona for the {@link PersonaStore} `store`, representing
   * a cached contact for which we currently have no Telepathy contact.
   *
   * @param store The persona store to place the persona in.
   * @param uid The cached UID of the persona.
   * @param iid The cached IID of the persona.
   * @param im_address The cached IM address of the persona (excluding
   * protocol).
   * @param protocol The cached protocol of the persona.
   * @param groups The cached set of groups the persona is in.
   * @param is_favourite Whether the persona is a favourite.
   * @param alias The cached alias for the persona.
   * @param is_in_contact_list Whether the persona is in the user's contact
   * list.
   * @param is_user Whether the persona is the user.
   * @param avatar The icon for the persona's cached avatar, or `null` if they
   * have no avatar.
   * @return A new {@link Tpf.Persona} representing the cached persona.
   *
Travis Reitter's avatar
Travis Reitter committed
639
   * @since 0.6.0
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
   */
  internal Persona.from_cache (PersonaStore store, string uid, string iid,
      string im_address, string protocol, HashSet<string> groups,
      bool is_favourite, string alias, bool is_in_contact_list, bool is_user,
      LoadableIcon? avatar)
    {
      Object (contact: null,
              display_id: im_address,
              iid: iid,
              uid: uid,
              store: store,
              is_user: is_user);

      debug ("Creating new Tpf.Persona '%s' from cache: %p", uid, this);

      // IM addresses
656
657
658
659
660
661
      this._im_addresses = new HashMultiMap<string, ImFieldDetails> (null, null,
          (GLib.HashFunc) ImFieldDetails.hash,
          (GLib.EqualFunc) ImFieldDetails.equal);

      var im_fd = new ImFieldDetails (im_address);
      this._im_addresses.set (protocol, im_fd);
662
663
664
665
666
667

      // Groups
      this._groups = groups;
      this._groups_ro = this._groups.read_only_view;

      // Other properties
668
669
670
671
672
673
      if (alias == null)
        {
          /* Deal with badly-behaved callers */
          alias = "";
        }

674
675
676
      this._alias = alias;
      this._is_favourite = is_favourite;
      this.is_in_contact_list = is_in_contact_list;
677
      this._avatar = avatar;
678
679
680
681
682
683

      // Make the persona appear offline
      this.presence_type = PresenceType.OFFLINE;
      this.presence_message = "";
    }

684
685
686
687
688
  ~Persona ()
    {
      debug ("Destroying Tpf.Persona '%s': %p", this.uid, this);
    }

689
  private static Account? _account_for_connection (Connection conn)
690
691
    {
      var manager = AccountManager.dup ();
692
      var accounts = manager.get_valid_accounts ();
693
694
695
696

      Account account_found = null;
      accounts.foreach ((l) =>
        {
697
          unowned Account account = (Account) l;
698
          if (account.connection == conn)
699
700
701
702
703
704
705
706
707
            {
              account_found = account;
              return;
            }
        });

      return account_found;
    }

708
  private void _contact_notify_presence_message ()
709
    {
710
      this.presence_message = this.contact.get_presence_message ();
711
712
    }

713
  private void _contact_notify_presence_type ()
714
    {
715
      this.presence_type = Tpf.Persona._folks_presence_type_from_tp (
716
          this.contact.get_presence_type ());
717
718
    }

719
720
721
722
723
  private void _contact_notify_presence_status ()
    {
      this.presence_status = this.contact.get_presence_status ();
    }

724
  private static PresenceType _folks_presence_type_from_tp (
725
      TelepathyGLib.ConnectionPresenceType type)
726
727
728
    {
      switch (type)
        {
729
          case TelepathyGLib.ConnectionPresenceType.AVAILABLE:
730
            return PresenceType.AVAILABLE;
731
          case TelepathyGLib.ConnectionPresenceType.AWAY:
732
            return PresenceType.AWAY;
733
          case TelepathyGLib.ConnectionPresenceType.BUSY:
734
            return PresenceType.BUSY;
735
          case TelepathyGLib.ConnectionPresenceType.ERROR:
736
            return PresenceType.ERROR;
737
          case TelepathyGLib.ConnectionPresenceType.EXTENDED_AWAY:
738
            return PresenceType.EXTENDED_AWAY;
739
          case TelepathyGLib.ConnectionPresenceType.HIDDEN:
740
            return PresenceType.HIDDEN;
741
          case TelepathyGLib.ConnectionPresenceType.OFFLINE:
742
            return PresenceType.OFFLINE;
743
          case TelepathyGLib.ConnectionPresenceType.UNKNOWN:
744
            return PresenceType.UNKNOWN;
745
          case TelepathyGLib.ConnectionPresenceType.UNSET:
746
747
748
749
            return PresenceType.UNSET;
          default:
            return PresenceType.UNKNOWN;
        }
750
    }
751

752
  private void _contact_notify_avatar ()
753
    {
754
      var file = this.contact.avatar_file;
755
756
757
758
759
      Icon? icon = null;

      if (file != null)
        icon = new FileIcon (file);

760
761
762
763
764
      if (this._avatar == null || icon == null || !this._avatar.equal (icon))
        {
          this._avatar = (LoadableIcon) icon;
          this.notify_property ("avatar");
        }
765
    }
766
}