* Bug 655917 — Rebase EmailDetails.email_addresses upon an
AbstractFieldDetails-derived class
* Bug 655374 — Un-break avatar tests
+* Bug 655919 — Rebase NoteDetails.notes upon an AbstractFieldDetails-derived
+ class
API changes:
* Swf.Persona retains and exposes its libsocialweb Contact
* Remove PostalAddress.types (obsoleted by PostalAddressFieldDetails.parameters)
* Add and use ImFieldDetails for ImDetails.im_addresses
* Add and use EmailFieldDetails for EmailFieldDetails.email_addresses
+* Add and use NoteFieldDetails for NoteFieldDetails.notes
+* Remove Note class (obsoleted by NoteFieldDetails)
Overview of changes from libfolks 0.5.1 to libfolks 0.5.2
=========================================================
}
else if (k == Folks.PersonaStore.detail_key (PersonaDetail.NOTES))
{
- var notes = (Gee.HashSet<Note>) v.get_object ();
+ var notes = (Gee.HashSet<NoteFieldDetails>) v.get_object ();
yield this._set_contact_notes (contact, notes);
}
else if (k == Folks.PersonaStore.detail_key (PersonaDetail.GENDER))
}
internal async void _set_notes (Edsf.Persona persona,
- Set<Note> notes)
+ Set<NoteFieldDetails> notes)
{
try
{
}
}
- private async void _set_contact_notes (E.Contact contact, Set<Note> notes)
+ private async void _set_contact_notes (E.Contact contact,
+ Set<NoteFieldDetails> notes)
{
string note_str = "";
foreach (var note in notes)
{
note_str += ". ";
}
- note_str += note.content;
+ note_str += note.value;
}
contact.set (E.Contact.field_id ("note"), note_str);
private Set<FieldDetails> _phone_numbers_ro;
private HashSet<EmailFieldDetails> _email_addresses;
private Set<EmailFieldDetails> _email_addresses_ro;
- private HashSet<Note> _notes;
- private Set<Note> _notes_ro;
+ private HashSet<NoteFieldDetails> _notes;
+ private Set<NoteFieldDetails> _notes_ro;
private static HashTable<string, E.ContactField> _im_eds_map = null;
private HashSet<PostalAddressFieldDetails> _postal_addresses;
*
* @since 0.5.UNRELEASED
*/
- public Set<Note> notes
+ public Set<NoteFieldDetails> notes
{
get { return this._notes_ro; }
set
(GLib.HashFunc) EmailFieldDetails.hash,
(GLib.EqualFunc) EmailFieldDetails.equal);
this._email_addresses_ro = this._email_addresses.read_only_view;
- this._notes = new HashSet<Note> ();
+ this._notes = new HashSet<NoteFieldDetails> (
+ (GLib.HashFunc) NoteFieldDetails.hash,
+ (GLib.EqualFunc) NoteFieldDetails.equal);
this._notes_ro = this._notes.read_only_view;
this._urls = new HashSet<FieldDetails> ();
this._urls_ro = this._urls.read_only_view;
string n = (string) this._get_property ("note");
if (n != null && n != "")
{
- var note = new Note (n);
+ var note = new NoteFieldDetails (n);
this._notes.add (note);
}
}
else if (k == Folks.PersonaStore.detail_key (PersonaDetail.NOTES))
{
- var notes = (Gee.HashSet<Note>) v.get_object ();
+ var notes = (Gee.HashSet<NoteFieldDetails>) v.get_object ();
foreach (var n in notes)
{
builder.subject ("_:p");
builder.predicate (Trf.OntologyDefs.NCO_NOTE);
- builder.object_string (n.content);
+ builder.object_string (n.value);
}
}
else if (k == Folks.PersonaStore.detail_key (
}
internal async void _set_notes (Folks.Persona persona,
- Set<Note> notes)
+ Set<NoteFieldDetails> notes)
{
const string del_t = "DELETE { " +
"?p " + Trf.OntologyDefs.NCO_NOTE + " ?n " +
{
builder.subject ("?contact");
builder.predicate (Trf.OntologyDefs.NCO_NOTE);
- builder.object_string (n.content);
+ builder.object_string (n.value);
}
builder.insert_close ();
}
}
- private HashSet<Note> _notes;
- private Set<Note> _notes_ro;
+ private HashSet<NoteFieldDetails> _notes;
+ private Set<NoteFieldDetails> _notes_ro;
/**
* {@inheritDoc}
*/
- public Set<Note> notes
+ public Set<NoteFieldDetails> notes
{
get { return this._notes_ro; }
set
this._roles = new HashSet<Role> ((GLib.HashFunc) Role.hash,
(GLib.EqualFunc) Role.equal);
this._roles_ro = this._roles.read_only_view;
- this._notes = new HashSet<Note> ((GLib.HashFunc) Note.hash,
- (GLib.EqualFunc) Note.equal);
+ this._notes = new HashSet<NoteFieldDetails> (
+ (GLib.HashFunc) NoteFieldDetails.hash,
+ (GLib.EqualFunc) NoteFieldDetails.equal);
this._notes_ro = this._notes.read_only_view;
this._urls = new HashSet<FieldDetails> ((GLib.HashFunc) FieldDetails.hash,
(GLib.EqualFunc) FieldDetails.equal);
{
if (note_content != null)
{
- var note = new Note (note_content);
+ var note = new NoteFieldDetails (note_content);
this._notes.add ((owned) note);
}
else
public string? calendar_event_id { get; set; }
- private HashSet<Note> _notes;
- private Set<Note> _notes_ro;
+ private HashSet<NoteFieldDetails> _notes;
+ private Set<NoteFieldDetails> _notes_ro;
/**
* {@inheritDoc}
*/
- public Set<Note> notes
+ public Set<NoteFieldDetails> notes
{
get { return this._notes_ro; }
private set
(GLib.HashFunc) PostalAddressFieldDetails.hash,
(GLib.EqualFunc) PostalAddressFieldDetails.equal);
this._postal_addresses_ro = this._postal_addresses.read_only_view;
- this._notes = new HashSet<Note>
- ((GLib.HashFunc) Note.hash, (GLib.EqualFunc) Note.equal);
+ this._notes = new HashSet<NoteFieldDetails> (
+ (GLib.HashFunc) NoteFieldDetails.hash,
+ (GLib.EqualFunc) NoteFieldDetails.equal);
this._notes_ro = this._notes.read_only_view;
this.personas = personas;
using GLib;
/**
- * Representation of a Note that might be attached to a {@link Persona}.
+ * Object representing a note that can have some parameters associated with it.
*
- * @since 0.4.0
+ * See {@link Folks.AbstractFieldDetails} for details on common parameter names
+ * and values.
+ *
+ * @since UNRELEASED
*/
-public class Folks.Note : Object
+public class Folks.NoteFieldDetails : AbstractFieldDetails<string>
{
/**
- * The note's content.
- */
- public string content { get; set; }
-
- /**
* The UID of the note (if any).
*/
public string uid { get; set; }
/**
- * Default constructor.
+ * Create a new NoteFieldDetails.
+ *
+ * @param value the value of the field
+ * @param parameters initial parameters. See
+ * {@link AbstractFieldDetails.parameters}. A `null` value is equivalent to a
+ * empty map of parameters.
*
- * @param content the note's content
- * @param uid the note's UID (may be null)
- * @return a new Note
+ * @return a new NoteFieldDetails
*
- * @since 0.4.0
+ * @since UNRELEASED
*/
- public Note (string content, string? uid = null)
+ public NoteFieldDetails (string value,
+ MultiMap<string, string>? parameters = null,
+ string? uid = null)
{
- if (uid == null)
- {
- uid = "";
- }
-
- Object (uid: uid,
- content: content);
+ this.value = value;
+ if (parameters != null)
+ this.parameters = parameters;
+ this.uid = uid;
}
/**
- * Compare if 2 notes are equal. This compares both their {@link Note.content}
- * and {@link Note.uid} (if set).
+ * {@inheritDoc}
*
- * @param a a note to compare
- * @param b another note to compare
- * @return `true` if the notes are equal, `false` otherwise
+ * @since UNRELEASED
*/
- public static bool equal (Note a, Note b)
+ public override bool equal (AbstractFieldDetails<string> that)
{
- return (a.uid == b.uid && a.content == b.content);
+ var that_nfd = that as NoteFieldDetails;
+
+ if (that_nfd == null)
+ return false;
+
+ return (this.uid == that_nfd.uid && this.value == that_nfd.value);
}
/**
- * Hash function for the class. Suitable for use as a hash table key.
+ * {@inheritDoc}
*
- * @param r a note to hash
- * @return hash value for the note instance
+ * @since UNRELEASED
*/
- public static uint hash (Note r)
+ public override uint hash ()
{
- return r.uid.hash () + r.content.hash ();
+ uint retval = 0;
+
+ if (this.value != null)
+ retval += this.value.hash ();
+
+ if (this.uid != null)
+ retval += this.uid.hash ();
+
+ return retval;
}
}
*
* @since 0.5.1
*/
- public abstract Set<Note> notes { get; set; }
+ public abstract Set<NoteFieldDetails> notes { get; set; }
}
Folks.PersonaStore.detail_key (PersonaDetail.STRUCTURED_NAME),
(owned) v7);
- Value? v8 = Value (typeof (Set<Note>));
- var notes = new HashSet<Note> ();
- var note = new Note(this._note);
+ Value? v8 = Value (typeof (Set<NoteFieldDetails>));
+ var notes = new HashSet<NoteFieldDetails> (
+ (GLib.HashFunc) NoteFieldDetails.hash,
+ (GLib.EqualFunc) NoteFieldDetails.equal);
+ var note = new NoteFieldDetails (this._note);
notes.add (note);
v8.set_object (notes);
details.insert (
foreach (var note in i.notes)
{
- if (note.content == this._note)
+ if (note.equal (new NoteFieldDetails (this._note)))
{
this._properties_found.replace ("note", true);
break;
foreach (var p in i.personas)
{
- var notes = new HashSet<Note> ();
- var note = new Note(this._note);
+ var notes = new HashSet<NoteFieldDetails> ();
+ var note = new NoteFieldDetails (this._note);
notes.add (note);
((NoteDetails) p).notes = notes;
}
Folks.Individual i = (Folks.Individual) individual_obj;
foreach (var note in i.notes)
{
- if (note.content == this._note)
+ if (note.equal (new NoteFieldDetails (this._note)))
{
this._found_after_update = true;
this._main_loop.quit ();
details.insert (
Folks.PersonaStore.detail_key (PersonaDetail.IM_ADDRESSES), v9);
- Value? v10 = Value (typeof (Set<Note>));
- var notes = new HashSet<Note> ();
- Note n1 = new Note (this._note_1);
- notes.add (n1);
+ Value? v10 = Value (typeof (Set<NoteFieldDetails>));
+ var notes = new HashSet<NoteFieldDetails> (
+ (GLib.HashFunc) NoteFieldDetails.hash,
+ (GLib.EqualFunc) NoteFieldDetails.equal);
+ NoteFieldDetails note_fd_1 = new NoteFieldDetails (this._note_1);
+ notes.add (note_fd_1);
v10.set_object (notes);
details.insert (Folks.PersonaStore.detail_key (PersonaDetail.NOTES),
(owned) v10);
foreach (var n in i.notes)
{
- if (n.content == this._note_1)
+ if (n.equal (new NoteFieldDetails (this._note_1)))
{
this._properties_found.replace ("note-1", true);
}
i.notify["notes"].connect (this._notify_note_cb);
foreach (var n in i.notes)
{
- if (n.content == this._note)
+ if (n.equal (new NoteFieldDetails (this._note)))
{
this._found_note = true;
this._main_loop.quit ();
Folks.Individual individual = (Folks.Individual) individual_obj;
foreach (var n in individual.notes)
{
- if (n.content == this._note)
+ if (n.equal (new NoteFieldDetails (this._note)))
{
this._found_note = true;
this._main_loop.quit ();
private IndividualAggregator _aggregator;
private string _persona_fullname;
private bool _note_found;
- private Note _note;
+ private NoteFieldDetails _note;
public SetNotesTests ()
{
c1.set (Trf.OntologyDefs.NCO_FULLNAME, this._persona_fullname);
this._tracker_backend.add_contact (c1);
- this._note = new Note ("some note");
+ this._note = new NoteFieldDetails ("some note");
this._tracker_backend.set_up ();
{
i.notify["notes"].connect (this._notify_notes_cb);
- Gee.HashSet<Note> notes = new HashSet<Note>
- ((GLib.HashFunc) Note.hash, (GLib.EqualFunc) Note.equal);
- var n = new Note ("some note");
+ Gee.HashSet<NoteFieldDetails> notes =
+ new HashSet<NoteFieldDetails> (
+ (GLib.HashFunc) NoteFieldDetails.hash,
+ (GLib.EqualFunc) NoteFieldDetails.equal);
+ var n = new NoteFieldDetails ("some note");
notes.add ((owned) n);
foreach (var p in i.personas)
{
foreach (var n in i.notes)
{
- if (Note.equal (n, this._note))
+ if (n.equal (this._note))
{
this._note_found = true;
this._main_loop.quit ();
}
else if (prop_name == "notes")
{
- Set<Note> notes = (Set<Note>) prop_value.get_object ();
+ Set<NoteFieldDetails> notes =
+ prop_value.get_object () as Set<NoteFieldDetails>;
output_string = "{ ";
bool first = true;