* Bug 662285 — Error with email -> im_addresses when updating a contact
* Bug 662433 — AbstractFieldDetails.equal() is ambiguous about checking
parameters.
+* Bug 660908 — Add favourites support to EDS backend
API changes:
* Add AbstractFieldDetails.id to identify instances of details
* Deprecate NoteFieldDetails.uid in favor of AbstractFieldDetails.id
* Deprecate Role.uid in favor of AbstractFieldDetails.id
* Add AbstractFieldDetails.values_equal() to compare values (but not parameters)
+* Implement FavouriteDetails on Edsf.Persona
Behavior changes:
* PostalAddress.equal() now ignores PostalAddress.uid
* - PersonaStore.detail_key (PersonaDetail.FULL_NAME)
* - PersonaStore.detail_key (PersonaDetail.GENDER)
* - PersonaStore.detail_key (PersonaDetail.IM_ADDRESSES)
+ * - PersonaStore.detail_key (PersonaDetail.IS_FAVOURITE)
* - PersonaStore.detail_key (PersonaDetail.PHONE_NUMBERS)
* - PersonaStore.detail_key (PersonaDetail.POSTAL_ADDRESSES)
* - PersonaStore.detail_key (PersonaDetail.ROLES)
(Set<RoleFieldDetails>) v.get_object ();
yield this._set_contact_roles (contact, roles);
}
+ else if (k == Folks.PersonaStore.detail_key (
+ PersonaDetail.IS_FAVOURITE))
+ {
+ bool is_fav = v.get_boolean ();
+ yield this._set_contact_is_favourite (contact, is_fav);
+ }
}
Edsf.Persona? persona = null;
{
string[] fields = supported_fields.split (",");
- /* We always support local-ids, web-service-addresses and
- * gender because we use custom vCard attributes for them. */
+ /* We always support local-ids, web-service-addresses, gender
+ * and favourite because we use custom vCard attributes for
+ * them. */
prop_set.add (Folks.PersonaStore.detail_key (
PersonaDetail.LOCAL_IDS));
prop_set.add (Folks.PersonaStore.detail_key (
PersonaDetail.WEB_SERVICE_ADDRESSES));
prop_set.add (Folks.PersonaStore.detail_key (
PersonaDetail.GENDER));
+ prop_set.add (Folks.PersonaStore.detail_key (
+ PersonaDetail.IS_FAVOURITE));
foreach (unowned string field in fields)
{
contact.add_attribute ((owned) new_attr);
}
+ internal async void _set_is_favourite (Edsf.Persona persona,
+ bool is_favourite) throws PropertyError
+ {
+ if (!("is-favourite" in this._always_writeable_properties))
+ {
+ throw new PropertyError.NOT_WRITEABLE (
+ _("The contact cannot be marked as favourite."));
+ }
+
+ yield this._set_contact_is_favourite (persona.contact, is_favourite);
+ yield this._commit_modified_property (persona, "is-favourite");
+ }
+
+ private async void _set_contact_is_favourite (E.Contact contact,
+ bool is_favourite)
+ {
+ unowned VCardAttribute attr = contact.get_attribute ("X-FOLKS-FAVOURITE");
+ if (attr != null)
+ {
+ contact.remove_attribute (attr);
+ }
+
+ if (is_favourite)
+ {
+ var new_attr = new VCardAttribute (null, "X-FOLKS-FAVOURITE");
+ new_attr.add_value ("true");
+ contact.add_attribute ((owned) new_attr);
+ }
+ }
+
private async void _set_contact_avatar (E.Contact contact,
LoadableIcon? avatar) throws PropertyError
{
AvatarDetails,
BirthdayDetails,
EmailDetails,
+ FavouriteDetails,
GenderDetails,
GroupDetails,
ImDetails,
private HashMultiMap<string, WebServiceFieldDetails> _web_service_addresses;
+ private bool _is_favourite;
+
/**
* The e-d-s contact represented by this Persona
*/
}
/**
+ * 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
+ {
+ if (this._is_favourite == is_favourite)
+ {
+ return;
+ }
+
+ yield ((Edsf.PersonaStore) this.store)._set_is_favourite (this,
+ is_favourite);
+ }
+
+ /**
* Build a IID.
*
* @param store_id the {@link PersonaStore.id}
this._update_gender ();
this._update_birthday ();
this._update_roles ();
+ this._update_favourite ();
this.thaw_notify ();
}
}
}
+ private void _update_favourite ()
+ {
+ bool is_fav = false;
+
+ var fav = this.contact.get_attribute ("X-FOLKS-FAVOURITE");
+ if (fav != null)
+ {
+ var val = fav.get_value ();
+ if (val.down () == "true")
+ {
+ is_fav = true;
+ }
+ }
+
+ if (is_fav != this._is_favourite)
+ {
+ this._is_favourite = is_fav;
+ this.notify_property ("is-favourite");
+ }
+ }
+
internal static void * _get_property_from_contact (E.Contact contact,
string prop_name)
{