summaryrefslogtreecommitdiff
path: root/backends/dummy/lib/dummy-full-persona.vala
blob: 8330abb679444057308f04b1e95ad1a63196202a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
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
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
/*
 * Copyright (C) 2013 Philip Withnall
 * Copyright (C) 2013 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:
 *       Philip Withnall <philip@tecnocode.co.uk>
 *       Travis Reitter <travis.reitter@collabora.co.uk>
 *       Marco Barisione <marco.barisione@collabora.co.uk>
 *       Raul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
 */

using Folks;
using Gee;
using GLib;

/**
 * A persona subclass representing a single ‘full’ contact.
 *
 * This mocks up a ‘full’ persona which implements all the available property
 * interfaces provided by libfolks. This is in contrast with
 * {@link FolksDummy.Persona}, which provides a base class implementing none of
 * libfolks’ interfaces.
 *
 * The full dummy persona can be used to simulate a persona from most libfolks
 * backends, if writing a custom {@link FolksDummy.Persona} subclass is not an
 * option.
 *
 * There are two sides to this class’ interface: the normal methods required by
 * the libfolks ‘details’ interfaces, such as
 * {@link Folks.GenderDetails.change_gender},
 * and the backend methods which should be called by test driver code to
 * simulate changes in the backing store providing this persona, such as
 * {@link FullPersona.update_gender}. For example, test driver code should call
 * {@link FullPersona.update_nickname} to simulate the user editing a contact’s
 * nickname in an online address book which is being exposed to libfolks. The
 * ``update_``, ``register_`` and ``unregister_`` prefixes are commonly used for
 * backend methods.
 *
 * The API in {@link FolksDummy} is unstable and may change wildly. It is
 * designed mostly for use by libfolks unit tests.
 *
 * @since UNRELEASED
 */
public class FolksDummy.FullPersona : FolksDummy.Persona,
    AntiLinkable,
    AvatarDetails,
    BirthdayDetails,
    EmailDetails,
    FavouriteDetails,
    GenderDetails,
    GroupDetails,
    ImDetails,
    LocalIdDetails,
    NameDetails,
    NoteDetails,
    PhoneDetails,
    RoleDetails,
    UrlDetails,
    PostalAddressDetails,
    WebServiceDetails
{
  /**
   * Create a new ‘full’ persona.
   *
   * Create a new persona for the {@link FolksDummy.PersonaStore} ``store``,
   * with the given construct-only properties.
   *
   * @param store the store which will contain the persona
   * @param contact_id a unique free-form string identifier for the persona
   * @param is_user ``true`` if the persona represents the user, ``false``
   * otherwise
   * @param linkable_properties an array of names of the properties which should
   * be used for linking this persona to others
   *
   * @since UNRELEASED
   */
  public FullPersona (PersonaStore store, string contact_id,
      bool is_user = false, string[] linkable_properties = {})
    {
      base (store, contact_id, is_user, linkable_properties);
    }

  construct
    {
      this._local_ids_ro = this._local_ids.read_only_view;
      this._postal_addresses_ro = this._postal_addresses.read_only_view;
      this._email_addresses_ro = this._email_addresses.read_only_view;
      this._phone_numbers_ro = this._phone_numbers.read_only_view;
      this._notes_ro = this._notes.read_only_view;
      this._urls_ro = this._urls.read_only_view;
      this._groups_ro = this._groups.read_only_view;
      this._roles_ro = this._roles.read_only_view;
      this._anti_links_ro = this._anti_links.read_only_view;
    }

  private HashMultiMap<string, WebServiceFieldDetails> _web_service_addresses =
      new HashMultiMap<string, WebServiceFieldDetails> (
          null, null,
          AbstractFieldDetails<string>.hash_static,
          AbstractFieldDetails<string>.equal_static);

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public MultiMap<string, WebServiceFieldDetails> web_service_addresses
    {
      get { return this._web_service_addresses; }
      set { this.change_web_service_addresses.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_web_service_addresses (
      MultiMap<string, WebServiceFieldDetails> web_service_addresses)
          throws PropertyError
    {
      yield this.change_property ("web-service-addresses", () =>
        {
          this.update_web_service_addresses (web_service_addresses);
        });
    }

  private HashSet<string> _local_ids = new HashSet<string> ();
  private Set<string> _local_ids_ro;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public Set<string> local_ids
    {
      get
        {
          if (this._local_ids.contains (this.iid) == false)
            {
              this._local_ids.add (this.iid);
            }
          return this._local_ids_ro;
        }
      set { this.change_local_ids.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_local_ids (Set<string> local_ids)
      throws PropertyError
    {
      yield this.change_property ("local-ids", () =>
        {
          this.update_local_ids (local_ids);
        });
    }

  private HashSet<PostalAddressFieldDetails> _postal_addresses =
      new HashSet<PostalAddressFieldDetails> ();
  private Set<PostalAddressFieldDetails> _postal_addresses_ro;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public Set<PostalAddressFieldDetails> postal_addresses
    {
      get { return this._postal_addresses_ro; }
      set { this.change_postal_addresses.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_postal_addresses (
      Set<PostalAddressFieldDetails> postal_addresses) throws PropertyError
    {
      yield this.change_property ("postal-addresses", () =>
        {
          this.update_postal_addresses (postal_addresses);
        });
    }

  private HashSet<PhoneFieldDetails> _phone_numbers =
      new HashSet<PhoneFieldDetails> ();
  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); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_phone_numbers (
      Set<PhoneFieldDetails> phone_numbers) throws PropertyError
    {
      yield this.change_property ("phone-numbers", () =>
        {
          this.update_phone_numbers (phone_numbers);
        });
    }

  private HashSet<EmailFieldDetails>? _email_addresses =
      new HashSet<EmailFieldDetails> (
          AbstractFieldDetails<string>.hash_static,
          AbstractFieldDetails<string>.equal_static);
  private Set<EmailFieldDetails> _email_addresses_ro;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public Set<EmailFieldDetails> email_addresses
    {
      get { return this._email_addresses_ro; }
      set { this.change_email_addresses.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_email_addresses (
      Set<EmailFieldDetails> email_addresses) throws PropertyError
    {
      yield this.change_property ("email-addresses", () =>
        {
          this.update_email_addresses (email_addresses);
        });
    }

  private HashSet<NoteFieldDetails> _notes = new HashSet<NoteFieldDetails> ();
  private Set<NoteFieldDetails> _notes_ro;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public Set<NoteFieldDetails> notes
    {
      get { return this._notes_ro; }
      set { this.change_notes.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_notes (Set<NoteFieldDetails> notes)
      throws PropertyError
    {
      yield this.change_property ("notes", () =>
        {
          this.update_notes (notes);
        });
    }

  private LoadableIcon? _avatar = null;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public LoadableIcon? avatar
    {
      get { return this._avatar; }
      set { this.change_avatar.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_avatar (LoadableIcon? avatar) throws PropertyError
    {
      yield this.change_property ("avatar", () =>
        {
          this.update_avatar (avatar);
        });
    }

  private StructuredName? _structured_name = null;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public StructuredName? structured_name
    {
      get { return this._structured_name; }
      set { this.change_structured_name.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_structured_name (StructuredName? structured_name)
      throws PropertyError
    {
      yield this.change_property ("structured-name", () =>
        {
          this.update_structured_name (structured_name);
        });
    }

  private string _full_name = "";

  /**
   * {@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
    {
      yield this.change_property ("full-name", () =>
        {
          this.update_full_name (full_name);
        });
    }

  private string _nickname = "";

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

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_nickname (string nickname) throws PropertyError
    {
      yield this.change_property ("nickname", () =>
        {
          this.update_nickname (nickname);
        });
    }

  private Gender _gender = Gender.UNSPECIFIED;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public Gender gender
    {
      get { return this._gender; }
      set { this.change_gender.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_gender (Gender gender) throws PropertyError
    {
      yield this.change_property ("gender", () =>
        {
          this.update_gender (gender);
        });
    }

  private HashSet<UrlFieldDetails> _urls = new HashSet<UrlFieldDetails> ();
  private Set<UrlFieldDetails> _urls_ro;
  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public Set<UrlFieldDetails> urls
    {
      get { return this._urls_ro; }
      set { this.change_urls.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_urls (Set<UrlFieldDetails> urls) throws PropertyError
    {
      yield this.change_property ("urls", () =>
        {
          this.update_urls (urls);
        });
    }

  private HashMultiMap<string, ImFieldDetails> _im_addresses =
      new HashMultiMap<string, ImFieldDetails> (null, null,
          AbstractFieldDetails<string>.hash_static,
          AbstractFieldDetails<string>.equal_static);

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public MultiMap<string, ImFieldDetails> im_addresses
    {
      get { return this._im_addresses; }
      set { this.change_im_addresses.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_im_addresses (
      MultiMap<string, ImFieldDetails> im_addresses) throws PropertyError
    {
      yield this.change_property ("im-addresses", () =>
        {
          this.update_im_addresses (im_addresses);
        });
    }

  private HashSet<string> _groups = new HashSet<string> ();
  private Set<string> _groups_ro;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public Set<string> groups
    {
      get { return this._groups_ro; }
      set { this.change_groups.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_group (string group, bool is_member)
      throws GLib.Error
    {
      /* Nothing to do? */
      if ((is_member == true && this._groups.contains (group) == true) ||
          (is_member == false && this._groups.contains (group) == false))
        {
          return;
        }

      /* Replace the current set of groups with a modified one. */
      var new_groups = new HashSet<string> ();
      foreach (var category_name in this._groups)
        {
          new_groups.add (category_name);
        }

      if (is_member == false)
        {
          new_groups.remove (group);
        }
      else
        {
          new_groups.add (group);
        }

      yield this.change_groups (new_groups);
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_groups (Set<string> groups) throws PropertyError
    {
      yield this.change_property ("groups", () =>
        {
          this.update_groups (groups);
        });
    }

  private string? _calendar_event_id = null;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public string? calendar_event_id
    {
      get { return this._calendar_event_id; }
      set { this.change_calendar_event_id.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_calendar_event_id (string? calendar_event_id)
      throws PropertyError
    {
      yield this.change_property ("calendar-event-id", () =>
        {
          this.update_calendar_event_id (calendar_event_id);
        });
    }

  private DateTime? _birthday = null;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public DateTime? birthday
    {
      get { return this._birthday; }
      set { this.change_birthday.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_birthday (DateTime? bday)
      throws PropertyError
    {
      yield this.change_property ("birthday", () =>
        {
          this.update_birthday (bday);
        });
    }

  private HashSet<RoleFieldDetails> _roles = new HashSet<RoleFieldDetails> ();
  private Set<RoleFieldDetails> _roles_ro;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public Set<RoleFieldDetails> roles
    {
      get { return this._roles_ro; }
      set { this.change_roles.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_roles (Set<RoleFieldDetails> roles)
      throws PropertyError
    {
      yield this.change_property ("roles", () =>
        {
          this.update_roles (roles);
        });
    }

  private bool _is_favourite = false;

  /**
   * Whether this contact is a user-defined favourite.
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public bool is_favourite
    {
      get { return this._is_favourite; }
      set { this.change_is_favourite.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_is_favourite (bool is_favourite) throws PropertyError
    {
      yield this.change_property ("is-favourite", () =>
        {
          this.update_is_favourite (is_favourite);
        });
    }

  private HashSet<string> _anti_links = new HashSet<string> ();
  private Set<string> _anti_links_ro;

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  [CCode (notify = false)]
  public Set<string> anti_links
    {
      get { return this._anti_links_ro; }
      set { this.change_anti_links.begin (value); }
    }

  /**
   * {@inheritDoc}
   *
   * @since UNRELEASED
   */
  public async void change_anti_links (Set<string> anti_links)
      throws PropertyError
    {
      yield this.change_property ("anti-links", () =>
        {
          this.update_anti_links (anti_links);
        });
    }


  /*
   * All the functions below here are to be used by testing code rather than by
   * libfolks clients. They form the interface which would normally be between
   * the Persona and a web service or backing store of some kind.
   */


  private HashSet<T> _dup_to_hash_set<T> (Set<T> input_set)
    {
      var output_set = new HashSet<T> ();
      output_set.add_all (input_set);
      return output_set;
    }

  private HashMultiMap<S, T> _dup_to_hash_multi_map<S, T> (
      MultiMap<S, T> input_multi_map)
    {
      var output_multi_map = new HashMultiMap<S, T> ();

      var iter = input_multi_map.map_iterator ();
      while (iter.next () == true)
          output_multi_map.set (iter.get_key (), iter.get_value ());

      return output_multi_map;
    }

  /**
   * Update persona's gender.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.GenderDetails.gender} property. It is intended to be used for
   * testing code which consumes this property. If the property value changes,
   * this results in a property change notification on the persona.
   *
   * @param gender persona's new gender
   * @since UNRELEASED
   */
  public void update_gender (Gender gender)
    {
      if (this._gender != gender)
        {
          this._gender = gender;
          this.notify_property ("gender");
        }
    }

  /**
   * Update persona's birthday calendar event ID.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.BirthdayDetails.calendar_event_id} property. It is intended to
   * be used for testing code which consumes this property. If the property
   * value changes, this results in a property change notification on the
   * persona.
   *
   * @param calendar_event_id persona's new birthday calendar event ID
   * @since UNRELEASED
   */
  public void update_calendar_event_id (string? calendar_event_id)
    {
      if (calendar_event_id != this._calendar_event_id)
        {
          this._calendar_event_id = calendar_event_id;
          this.notify_property ("calendar-event-id");
        }
    }

  /**
   * Update persona's birthday.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.BirthdayDetails.birthday} property. It is intended to be used
   * for testing code which consumes this property. If the property value
   * changes, this results in a property change notification on the persona.
   *
   * @param birthday persona's new birthday
   * @since UNRELEASED
   */
  public void update_birthday (DateTime? birthday)
    {
      if ((this._birthday == null) != (birthday == null) ||
          (this._birthday != null && birthday != null &&
              !((!) this._birthday).equal ((!) birthday)))
        {
          this._birthday = birthday;
          this.notify_property ("birthday");
        }
    }

  /**
   * Update persona's roles.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.RoleDetails.roles} property. It is intended to be used for
   * testing code which consumes this property. If the property value changes,
   * this results in a property change notification on the persona.
   *
   * @param roles persona's new roles
   * @since UNRELEASED
   */
  public void update_roles (Set<RoleFieldDetails> roles)
    {
      if (!Folks.Internal.equal_sets<RoleFieldDetails> (roles, this._roles))
        {
          this._roles = this._dup_to_hash_set<RoleFieldDetails> (roles);
          this._roles_ro = this._roles.read_only_view;
          this.notify_property ("roles");
        }
    }

  /**
   * Update persona's groups.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.GroupDetails.groups} property. It is intended to be used for
   * testing code which consumes this property. If the property value changes,
   * this results in a property change notification on the persona.
   *
   * @param groups persona's new groups
   * @since UNRELEASED
   */
  public void update_groups (Set<string> groups)
    {
      if (!Folks.Internal.equal_sets<string> (groups, this._groups))
        {
          this._groups = this._dup_to_hash_set<string> (groups);
          this._groups_ro = this._groups.read_only_view;
          this.notify_property ("groups");
        }
    }

  /**
   * Update persona's web service addresses.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.WebServiceDetails.web_service_addresses} property. It is
   * intended to be used for testing code which consumes this property. If the
   * property value changes, this results in a property change notification on
   * the persona.
   *
   * @param web_service_addresses persona's new web service addresses
   * @since UNRELEASED
   */
  public void update_web_service_addresses (
      MultiMap<string, WebServiceFieldDetails> web_service_addresses)
    {
      if (!Utils.multi_map_str_afd_equal (web_service_addresses,
              this._web_service_addresses))
        {
          this._web_service_addresses =
              this._dup_to_hash_multi_map<string, WebServiceFieldDetails> (
                  web_service_addresses);
          this.notify_property ("web-service-addresses");
        }
    }

  /**
   * Update persona's e-mail addresses.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.EmailDetails.email_addresses} property. It is intended to be
   * used for testing code which consumes this property. If the property value
   * changes, this results in a property change notification on the persona.
   *
   * @param email_addresses persona's new e-mail addresses
   * @since UNRELEASED
   */
  public void update_email_addresses (Set<EmailFieldDetails> email_addresses)
    {
      if (!Folks.Internal.equal_sets<EmailFieldDetails> (email_addresses,
               this._email_addresses))
        {
          this._email_addresses =
              this._dup_to_hash_set<EmailFieldDetails> (email_addresses);
          this._email_addresses_ro = this._email_addresses.read_only_view;
          this.notify_property ("email-addresses");
       }
    }

  /**
   * Update persona's notes.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.NoteDetails.notes} property. It is intended to be used for
   * testing code which consumes this property. If the property value changes,
   * this results in a property change notification on the persona.
   *
   * @param notes persona's new notes
   * @since UNRELEASED
   */
  public void update_notes (Set<NoteFieldDetails> notes)
    {
      if (!Folks.Internal.equal_sets<NoteFieldDetails> (notes, this._notes))
        {
          this._notes = this._dup_to_hash_set<NoteFieldDetails> (notes);
          this._notes_ro = this._notes.read_only_view;
          this.notify_property ("notes");
        }
    }

  /**
   * Update persona's full name.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.NameDetails.full_name} property. It is intended to be used for
   * testing code which consumes this property. If the property value changes,
   * this results in a property change notification on the persona.
   *
   * @param full_name persona's new full name
   * @since UNRELEASED
   */
  public void update_full_name (string full_name)
    {
      if (this._full_name != full_name)
        {
          this._full_name = full_name;
          this.notify_property ("full-name");
        }
    }

  /**
   * Update persona's nickname.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.NameDetails.nickname} property. It is intended to be used for
   * testing code which consumes this property. If the property value changes,
   * this results in a property change notification on the persona.
   *
   * @param nickname persona's new nickname
   * @since UNRELEASED
   */
  public void update_nickname (string nickname)
    {
      if (this._nickname != nickname)
        {
          this._nickname = nickname;
          this.notify_property ("nickname");
        }
    }

  /**
   * Update persona's structured name.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.NameDetails.structured_name} property. It is intended to be
   * used for testing code which consumes this property. If the property value
   * changes, this results in a property change notification on the persona.
   *
   * @param structured_name persona's new structured name
   * @since UNRELEASED
   */
  public void update_structured_name (StructuredName? structured_name)
    {
      if (structured_name != null && !((!) structured_name).is_empty ())
        {
          this._structured_name = (!) structured_name;
          this.notify_property ("structured-name");
        }
      else if (this._structured_name != null)
        {
          this._structured_name = null;
          this.notify_property ("structured-name");
        }
    }

  /**
   * Update persona's avatar.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.AvatarDetails.avatar} property. It is intended to be used for
   * testing code which consumes this property. If the property value changes,
   * this results in a property change notification on the persona.
   *
   * @param avatar persona's new avatar
   * @since UNRELEASED
   */
  public void update_avatar (LoadableIcon? avatar)
    {
      if ((this._avatar == null) != (avatar == null) ||
          (this._avatar != null && avatar != null &&
              !((!) this._avatar).equal ((!) avatar)))
        {
          this._avatar = avatar;
          this.notify_property ("avatar");
        }
    }

  /**
   * Update persona's URIs.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.UrlDetails.urls} property. It is intended to be used for
   * testing code which consumes this property. If the property value changes,
   * this results in a property change notification on the persona.
   *
   * @param urls persona's new URIs
   * @since UNRELEASED
   */
  public void update_urls (Set<UrlFieldDetails> urls)
    {
      if (!Utils.set_afd_equal (urls, this._urls))
        {
          this._urls = this._dup_to_hash_set<UrlFieldDetails> (urls);
          this._urls_ro = this._urls.read_only_view;
          this.notify_property ("urls");
        }
    }

  /**
   * Update persona's IM addresses.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.ImDetails.im_addresses} property. It is intended to be used
   * for testing code which consumes this property. If the property value
   * changes, this results in a property change notification on the persona.
   *
   * @param im_addresses persona's new IM addresses
   * @since UNRELEASED
   */
  public void update_im_addresses (
      MultiMap<string, ImFieldDetails> im_addresses)
    {
      if (!Utils.multi_map_str_afd_equal (im_addresses,
              this._im_addresses))
        {
          this._im_addresses =
              this._dup_to_hash_multi_map<string, ImFieldDetails> (
                  im_addresses);
          this.notify_property ("im-addresses");
        }
    }

  /**
   * Update persona's phone numbers.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.PhoneDetails.phone_numbers} property. It is intended to be
   * used for testing code which consumes this property. If the property value
   * changes, this results in a property change notification on the persona.
   *
   * @param phone_numbers persona's new phone numbers
   * @since UNRELEASED
   */
  public void update_phone_numbers (Set<PhoneFieldDetails> phone_numbers)
    {
      if (!Folks.Internal.equal_sets<PhoneFieldDetails> (phone_numbers,
              this._phone_numbers))
        {
          this._phone_numbers =
              this._dup_to_hash_set<PhoneFieldDetails> (phone_numbers);
          this._phone_numbers_ro = this._phone_numbers.read_only_view;
          this.notify_property ("phone-numbers");
        }
   }

  /**
   * Update persona's postal addresses.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.PostalAddressDetails.postal_addresses} property. It is
   * intended to be used for testing code which consumes this property. If the
   * property value changes, this results in a property change notification on
   * the persona.
   *
   * @param postal_addresses persona's new postal addresses
   * @since UNRELEASED
   */
  public void update_postal_addresses (
      Set<PostalAddressFieldDetails> postal_addresses)
    {
      if (!Folks.Internal.equal_sets<PostalAddressFieldDetails> (
              postal_addresses, this._postal_addresses))
        {
          this._postal_addresses =
              this._dup_to_hash_set<PostalAddressFieldDetails> (
                  postal_addresses);
          this._postal_addresses_ro = this._postal_addresses.read_only_view;
          this.notify_property ("postal-addresses");
        }
    }

  /**
   * Update persona's local IDs.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.LocalIdDetails.local_ids} property. It is intended to be used
   * for testing code which consumes this property. If the property value
   * changes, this results in a property change notification on the persona.
   *
   * @param local_ids persona's new local IDs
   * @since UNRELEASED
   */
  public void update_local_ids (Set<string> local_ids)
    {
      if (!Folks.Internal.equal_sets<string> (local_ids, this.local_ids))
        {
          this._local_ids = this._dup_to_hash_set<string> (local_ids);
          this._local_ids_ro = this._local_ids.read_only_view;
          this.notify_property ("local-ids");
        }
    }

  /**
   * Update persona's status as a favourite.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.FavouriteDetails.is_favourite} property. It is intended to be
   * used for testing code which consumes this property. If the property value
   * changes, this results in a property change notification on the persona.
   *
   * @param is_favourite persona's new status as a favourite
   * @since UNRELEASED
   */
  public void update_is_favourite (bool is_favourite)
    {
      if (is_favourite != this._is_favourite)
        {
          this._is_favourite = is_favourite;
          this.notify_property ("is-favourite");
        }
    }

  /**
   * Update persona's anti-links.
   *
   * This simulates a backing-store-side update of the persona's
   * {@link Folks.AntiLinkable.anti_links} property. It is intended to be used
   * for testing code which consumes this property. If the property value
   * changes, this results in a property change notification on the persona.
   *
   * @param anti_links persona's new anti-links
   * @since UNRELEASED
   */
  public void update_anti_links (Set<string> anti_links)
    {
      if (!Folks.Internal.equal_sets<string> (anti_links, this._anti_links))
        {
          this._anti_links = this._dup_to_hash_set<string> (anti_links);
          this._anti_links_ro = this._anti_links.read_only_view;
          this.notify_property ("anti-links");
        }
    }
}