telepathy: Added emit_notification parameter to lazy load _update methods.
eds: Added emit_notification parameter to lazy load _update methods.
Fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=683267
• Bug 683452 — gnome-contacts starts up with an empty address book
• Bug 681476 — folks-inspect could use some methods to set values
• Bug 683390 — Individuals sometimes not removed when disabling their Telepathy account
+• Bug 683267 — Warning when starting in non group mode
API changes:
• Add PropertyError.UNAVAILABLE
{
get
{
- this._update_addresses (true);
+ this._update_addresses (true, false);
return this._postal_addresses_ro;
}
set { this.change_postal_addresses.begin (value); }
{
get
{
- this._update_phones (true);
+ this._update_phones (true, false);
return this._phone_numbers_ro;
}
set { this.change_phone_numbers.begin (value); }
{
get
{
- this._update_emails (true);
+ this._update_emails (true, false);
return this._email_addresses_ro;
}
set { this.change_email_addresses.begin (value); }
{
get
{
- this._update_notes (true);
+ this._update_notes (true, false);
return this._notes_ro;
}
set { this.change_notes.begin (value); }
{
get
{
- this._update_urls (true);
+ this._update_urls (true, false);
return this._urls_ro;
}
set { this.change_urls.begin (value); }
{
get
{
- this._update_groups (true);
+ this._update_groups (true, false);
return this._groups_ro;
}
set { this.change_groups.begin (value); }
{
get
{
- this._update_roles (true);
+ this._update_roles (true, false);
return this._roles_ro;
}
set { this.change_roles.begin (value); }
{
get
{
- this._update_groups (true); /* also checks for favourites */
+ this._update_groups (true, false); /* also checks for favourites */
return this._is_favourite;
}
set { this.change_is_favourite.begin (value); }
}
}
- private void _update_roles (bool create_if_not_exist)
+ private void _update_roles (bool create_if_not_exist, bool emit_notification = true)
{
/* See the comments in Folks.Individual about the lazy instantiation
* strategy for roles. */
if (this._roles == null && create_if_not_exist == false)
{
- this.notify_property ("roles");
+ if (emit_notification)
+ {
+ this.notify_property ("roles");
+ }
return;
}
else if (this._roles == null)
{
this._roles = new_roles;
this._roles_ro = new_roles.read_only_view;
- this.notify_property ("roles");
+ if (emit_notification)
+ {
+ this.notify_property ("roles");
+ }
}
}
}
}
- private void _update_emails (bool create_if_not_exist)
+ private void _update_emails (bool create_if_not_exist, bool emit_notification = true)
{
/* See the comments in Folks.Individual about the lazy instantiation
* strategy for e-mail addresses. */
if (this._email_addresses == null && create_if_not_exist == false)
{
- this.notify_property ("email-addresses");
+ if (emit_notification)
+ {
+ this.notify_property ("email-addresses");
+ }
return;
}
else if (this._email_addresses == null)
if (!Folks.Internal.equal_sets<EmailFieldDetails> (new_email_addresses,
this._email_addresses))
{
- this._email_addresses = new_email_addresses;
- this._email_addresses_ro = new_email_addresses.read_only_view;
- this.notify_property ("email-addresses");
+ this._email_addresses = new_email_addresses;
+ this._email_addresses_ro = new_email_addresses.read_only_view;
+ if (emit_notification)
+ {
+ this.notify_property ("email-addresses");
+ }
}
}
- private void _update_notes (bool create_if_not_exist)
+ private void _update_notes (bool create_if_not_exist, bool emit_notification = true)
{
/* See the comments in Folks.Individual about the lazy instantiation
* strategy for notes. */
if (this._notes == null && create_if_not_exist == false)
{
- this.notify_property ("notes");
+ if (emit_notification)
+ {
+ this.notify_property ("notes");
+ }
return;
}
else if (this._notes == null)
{
this._notes = new_notes;
this._notes_ro = this._notes.read_only_view;
- this.notify_property ("notes");
+ if (emit_notification)
+ {
+ this.notify_property ("notes");
+ }
}
}
}
}
- private void _update_urls (bool create_if_not_exist)
+ private void _update_urls (bool create_if_not_exist, bool emit_notification = true)
{
/* See the comments in Folks.Individual about the lazy instantiation
* strategy for URIs. */
if (this._urls == null && create_if_not_exist == false)
{
- this.notify_property ("urls");
+ if (emit_notification)
+ {
+ this.notify_property ("urls");
+ }
return;
}
else if (this._urls == null)
{
this._urls = new_urls;
this._urls_ro = new_urls.read_only_view;
- this.notify_property ("urls");
+ if (emit_notification)
+ {
+ this.notify_property ("urls");
+ }
}
}
}
}
- private void _update_groups (bool create_if_not_exist)
+ private void _update_groups (bool create_if_not_exist, bool emit_notification = true)
{
/* See the comments in Folks.Individual about the lazy instantiation
* strategy for groups. */
if (this._groups == null && create_if_not_exist == false)
{
- this.notify_property ("groups");
+ if (emit_notification)
+ {
+ this.notify_property ("groups");
+ }
return;
}
else if (this._groups == null)
/* Notify if anything's changed. */
this.freeze_notify ();
- if (added_categories.size != 0 || removed_categories.size != 0)
+ if ((added_categories.size != 0 || removed_categories.size != 0) &&
+ emit_notification)
{
this.notify_property ("groups");
}
- if (this._is_favourite != old_is_favourite)
+ if (this._is_favourite != old_is_favourite && emit_notification)
{
this.notify_property ("is-favourite");
}
if (in_google_personal_group != this._in_google_personal_group)
{
this._in_google_personal_group = in_google_personal_group;
- this.notify_property ("in-google-personal-group");
+ if (emit_notification)
+ {
+ this.notify_property ("in-google-personal-group");
+ }
}
this.thaw_notify ();
return retval;
}
- private void _update_phones (bool create_if_not_exist)
+ private void _update_phones (bool create_if_not_exist, bool emit_notification = true)
{
/* See the comments in Folks.Individual about the lazy instantiation
* strategy for phone numbers. */
{
this._phone_numbers = new_phone_numbers;
this._phone_numbers_ro = new_phone_numbers.read_only_view;
- this.notify_property ("phone-numbers");
+ if (emit_notification)
+ {
+ this.notify_property ("phone-numbers");
+ }
}
}
* are the same and if so instantiate only one PostalAddress
* (with the given types).
*/
- private void _update_addresses (bool create_if_not_exist)
+ private void _update_addresses (bool create_if_not_exist, bool emit_notification = true)
{
/* See the comments in Folks.Individual about the lazy instantiation
* strategy for addresses. */
if (this._postal_addresses == null && create_if_not_exist == false)
{
- this.notify_property ("postal-addresses");
+ if (emit_notification)
+ {
+ this.notify_property ("postal-addresses");
+ }
return;
}
else if (this._postal_addresses == null)
{
this._postal_addresses = new_postal_addresses;
this._postal_addresses_ro = new_postal_addresses.read_only_view;
- this.notify_property ("postal-addresses");
+ if (emit_notification)
+ {
+ this.notify_property ("postal-addresses");
+ }
}
}
{
get
{
- this._contact_notify_contact_info (true);
+ this._contact_notify_contact_info (true, false);
return this._email_addresses_ro;
}
set { this.change_email_addresses.begin (value); }
{
get
{
- this._contact_notify_contact_info (true);
+ this._contact_notify_contact_info (true, false);
return this._phone_numbers_ro;
}
set { this.change_phone_numbers.begin (value); }
}
}
- private void _contact_notify_contact_info (bool create_if_not_exists)
+ private void _contact_notify_contact_info (bool create_if_not_exists, bool emit_notification = true)
{
assert ((
(this._email_addresses == null) &&
* function is called identically for all of them. */
if (this._urls == null && create_if_not_exists == false)
{
- this.notify_property ("email-addresses");
- this.notify_property ("phone-numbers");
- this.notify_property ("urls");
+ if (emit_notification)
+ {
+ this.notify_property ("email-addresses");
+ this.notify_property ("phone-numbers");
+ this.notify_property ("urls");
+ }
return;
}
else if (this._urls == null)
!this._birthday.equal (d.to_utc ())))
{
this._birthday = d.to_utc ();
- this.notify_property ("birthday");
+ if (emit_notification)
+ {
+ this.notify_property ("birthday");
+ }
changed = true;
}
}
if (this._birthday != null)
{
this._birthday = null;
- this.notify_property ("birthday");
+ if (emit_notification)
+ {
+ this.notify_property ("birthday");
+ }
changed = true;
}
}
{
this._email_addresses = new_email_addresses;
this._email_addresses_ro = new_email_addresses.read_only_view;
- this.notify_property ("email-addresses");
+ if (emit_notification)
+ {
+ this.notify_property ("email-addresses");
+ }
changed = true;
}
if (new_full_name != this._full_name)
{
this._full_name = new_full_name;
- this.notify_property ("full-name");
+ if (emit_notification)
+ {
+ this.notify_property ("full-name");
+ }
changed = true;
}
{
this._phone_numbers = new_phone_numbers;
this._phone_numbers_ro = new_phone_numbers.read_only_view;
- this.notify_property ("phone-numbers");
+ if (emit_notification)
+ {
+ this.notify_property ("phone-numbers");
+ }
changed = true;
}
{
this._urls = new_urls;
this._urls_ro = new_urls.read_only_view;
- this.notify_property ("urls");
+ if (emit_notification)
+ {
+ this.notify_property ("urls");
+ }
changed = true;
}
{
get
{
- this._update_urls (true);
+ this._update_urls (true, false);
return this._urls_ro;
}
set { this.change_urls.begin (value); } /* not writeable */
{
get
{
- this._update_phone_numbers (true);
+ this._update_phone_numbers (true, false);
return this._phone_numbers_ro;
}
set { this.change_phone_numbers.begin (value); } /* not writeable */
{
get
{
- this._update_email_addresses (true);
+ this._update_email_addresses (true, false);
return this._email_addresses_ro;
}
set { this.change_email_addresses.begin (value); } /* not writeable */
{
get
{
- this._update_roles (true);
+ this._update_roles (true, false);
return this._roles_ro;
}
set { this.change_roles.begin (value); } /* not writeable */
{
get
{
- this._update_local_ids (true);
+ this._update_local_ids (true, false);
return this._local_ids_ro;
}
set { this.change_local_ids.begin (value); } /* not writeable */
{
get
{
- this._update_notes (true);
+ this._update_notes (true, false);
return this._notes_ro;
}
set { this.change_notes.begin (value); } /* not writeable */
{
get
{
- this._update_postal_addresses (true);
+ this._update_postal_addresses (true, false);
return this._postal_addresses_ro;
}
set { this.change_postal_addresses.begin (value); } /* not writeable */
{
get
{
- this._update_groups (true);
+ this._update_groups (true, false);
return this._groups_ro;
}
set { this.change_groups.begin (value); }
{
get
{
- this._update_im_addresses (true);
+ this._update_im_addresses (true, false);
return this._im_addresses;
}
set { this.change_im_addresses.begin (value); } /* not writeable */
{
get
{
- this._update_web_service_addresses (true);
+ this._update_web_service_addresses (true, false);
return this._web_service_addresses;
}
/* Not writeable: */
*/
private void _update_multi_valued_property (string prop_name,
bool create_if_not_exist, PropertyIsNull prop_is_null,
- CollectionCreator create_collection, MultiValuedPropertySetter setter)
+ CollectionCreator create_collection, MultiValuedPropertySetter setter,
+ bool emit_notification = true)
{
/* If the set of values doesn't exist, and we're not meant to lazily
* create it, then simply emit a notification (since the set might've
/* Notify and return. */
if (create_if_not_exist == false)
{
- this.notify_property (prop_name);
+ if (emit_notification)
+ {
+ this.notify_property (prop_name);
+ }
return;
}
/* Re-populate the collection as the union of the values in the
* individual's personas. */
- if (setter () == true)
+ if (setter () == true && emit_notification)
{
this.notify_property (prop_name);
}
}
- private void _update_groups (bool create_if_not_exist)
+ private void _update_groups (bool create_if_not_exist, bool emit_notification = true)
{
/* If the set of groups doesn't exist, and we're not meant to lazily
* create it, then simply emit a notification (since the set might've
* return. */
if (this._groups == null && create_if_not_exist == false)
{
- this.notify_property ("groups");
+ if (emit_notification)
+ {
+ this.notify_property ("groups");
+ }
return;
}
foreach (var group in new_groups)
{
- if (this._groups.add (group))
+ if (this._groups.add (group) && emit_notification)
{
this.group_changed (group, true);
}
{
unowned string group = (string) l;
this._groups.remove (group);
- this.group_changed (group, false);
+ if (emit_notification)
+ {
+ this.group_changed (group, false);
+ }
});
}
this.trust_level = trust_level;
}
- private void _update_im_addresses (bool create_if_not_exist)
+ private void _update_im_addresses (bool create_if_not_exist, bool emit_notification = true)
{
this._update_multi_valued_property ("im-addresses",
create_if_not_exist, () => { return this._im_addresses == null; },
}
return false;
- });
+ }, emit_notification);
}
- private void _update_web_service_addresses (bool create_if_not_exist)
+ private void _update_web_service_addresses (bool create_if_not_exist, bool emit_notification = true)
{
this._update_multi_valued_property ("web-service-addresses",
create_if_not_exist,
}
return false;
- });
+ }, emit_notification);
}
private void _connect_to_persona (Persona persona)
});
}
- private void _update_urls (bool create_if_not_exist)
+ private void _update_urls (bool create_if_not_exist, bool emit_notification = true)
{
this._update_multi_valued_property ("urls", create_if_not_exist,
() => { return this._urls == null; },
}
return false;
- });
+ }, emit_notification);
}
- private void _update_phone_numbers (bool create_if_not_exist)
+ private void _update_phone_numbers (bool create_if_not_exist, bool emit_notification = true)
{
this._update_multi_valued_property ("phone-numbers", create_if_not_exist,
() => { return this._phone_numbers == null; },
}
return false;
- });
+ }, emit_notification);
}
- private void _update_email_addresses (bool create_if_not_exist)
+ private void _update_email_addresses (bool create_if_not_exist, bool emit_notification = true)
{
this._update_multi_valued_property ("email-addresses",
create_if_not_exist, () => { return this._email_addresses == null; },
}
return false;
- });
+ }, emit_notification);
}
- private void _update_roles (bool create_if_not_exist)
+ private void _update_roles (bool create_if_not_exist, bool emit_notification = true)
{
this._update_multi_valued_property ("roles", create_if_not_exist,
() => { return this._roles == null; },
}
return false;
- });
+ }, emit_notification);
}
- private void _update_local_ids (bool create_if_not_exist)
+ private void _update_local_ids (bool create_if_not_exist, bool emit_notification = true)
{
this._update_multi_valued_property ("local-ids", create_if_not_exist,
() => { return this._local_ids == null; },
}
return false;
- });
+ }, emit_notification);
}
- private void _update_postal_addresses (bool create_if_not_exist)
+ private void _update_postal_addresses (bool create_if_not_exist, bool emit_notification = true)
{
/* FIXME: Detect duplicates somehow? */
this._update_multi_valued_property ("postal-addresses",
}
return false;
- });
+ }, emit_notification);
}
private void _update_birthday ()
});
}
- private void _update_notes (bool create_if_not_exist)
+ private void _update_notes (bool create_if_not_exist, bool emit_notification = true)
{
this._update_multi_valued_property ("notes", create_if_not_exist,
() => { return this._notes == null; },
}
return false;
- });
+ }, emit_notification);
}
private void _set_personas (Set<Persona>? personas,