*
* Accepted keys for `details` are:
* - PersonaStore.detail_key (PersonaDetail.AVATAR)
+ * - PersonaStore.detail_key (PersonaDetail.BIRTHDAY)
* - PersonaStore.detail_key (PersonaDetail.EMAIL_ADDRESSES)
* - PersonaStore.detail_key (PersonaDetail.FULL_NAME)
* - PersonaStore.detail_key (PersonaDetail.GENDER)
Set<UrlFieldDetails> urls = (Set<UrlFieldDetails>) v.get_object ();
yield this._set_contact_urls (contact, urls);
}
+ else if (k == Folks.PersonaStore.detail_key (PersonaDetail.BIRTHDAY))
+ {
+ var birthday = (DateTime?) v.get_boxed ();
+ yield this._set_contact_birthday (contact, birthday);
+ }
}
Edsf.Persona? persona = null;
contact.set (E.Contact.field_id ("note"), note_str);
}
+ internal async void _set_birthday (Edsf.Persona persona,
+ DateTime? bday) throws PropertyError
+ {
+ if (persona.birthday != null &&
+ bday != null &&
+ persona.birthday.equal (bday))
+ return;
+
+ /* Maybe the current and new b-day are unset */
+ if (persona.birthday == null &&
+ bday == null)
+ return;
+
+ yield this._set_contact_birthday (persona.contact, bday);
+ yield this._commit_modified_property (persona, "birthday");
+ }
+
+ private async void _set_contact_birthday (E.Contact contact,
+ DateTime? bday)
+ {
+ E.ContactDate? contact_bday = null;
+
+ if (bday != null)
+ {
+ contact_bday = new E.ContactDate ();
+ contact_bday.year = (uint) bday.get_year ();
+ contact_bday.month = (uint) bday.get_month ();
+ contact_bday.day = (uint) bday.get_day_of_month ();
+ }
+
+ contact.set (E.Contact.field_id ("birth_date"), contact_bday);
+ }
+
internal async void _set_structured_name (Edsf.Persona persona,
StructuredName? sname) throws PropertyError
{
*/
public class Edsf.Persona : Folks.Persona,
AvatarDetails,
+ BirthdayDetails,
EmailDetails,
GenderDetails,
GroupDetails,
}
/**
+ * {@inheritDoc}
+ *
+ * e-d-s has no equivalent field, so this is unsupported.
+ *
+ * @since UNRELEASED
+ */
+ [CCode (notify = false)]
+ public string? calendar_event_id
+ {
+ get { return null; } /* unsupported */
+ set { this.change_calendar_event_id.begin (value); } /* not writeable */
+ }
+
+ 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 ((Edsf.PersonaStore) this.store)._set_birthday (this,
+ bday);
+ }
+
+ /**
* Build a IID.
*
* @param store_id the {@link PersonaStore.id}
this._update_local_ids ();
this._update_web_services_addresses ();
this._update_gender ();
+ this._update_birthday ();
}
private void _update_params (AbstractFieldDetails details,
}
}
+ private void _update_birthday ()
+ {
+ E.ContactDate? bday = (E.ContactDate?) this._get_property ("birth_date");
+
+ if (bday != null)
+ {
+ /* Since e-d-s stores birthdays as a plain date, we take the
+ * given date in local time and convert it to UTC as mandated
+ * by the BirthdayDetails interface */
+ var d = new DateTime.local ((int) bday.year, (int) bday.month,
+ (int) bday.day, 0, 0, 0.0);
+ if (this._birthday == null ||
+ (this._birthday != null &&
+ !this._birthday.equal (d.to_utc ())))
+ {
+ this._birthday = d.to_utc ();
+ this.notify_property ("birthday");
+ }
+ }
+ else
+ {
+ if (this._birthday != null)
+ {
+ this._birthday = null;
+ this.notify_property ("birthday");
+ }
+ }
+ }
+
private void _update_web_services_addresses ()
{
this._web_service_addresses.clear ();