MultiMap<string, string>
* Removed LinkedHashSet in favour of Gee.HashSet
* Backend.persona_stores is now of type Map<string, PersonaStore>
+* GroupDetails.groups is now of type Set<string>
Overview of changes from libfolks 0.4.0 to libfolks 0.5.0
=========================================================
ImDetails,
PresenceDetails
{
- private HashTable<string, bool> _groups;
+ private HashSet<string> _groups;
private bool _is_favourite;
private string _alias;
private HashMultiMap<string, string> _im_addresses;
*
* See {@link Folks.GroupDetails.groups}.
*/
- public HashTable<string, bool> groups
+ public Set<string> groups
{
get { return this._groups; }
set
{
- value.foreach ((k, v) =>
+ foreach (var group in value)
{
- unowned string group = (string) k;
- if (this._groups.lookup (group) == false)
+ if (this._groups.contains (group) == false)
this._change_group (group, true);
- });
+ }
- this._groups.foreach ((k, v) =>
+ foreach (var group in this._groups)
{
- unowned string group = (string) k;
- if (value.lookup (group) == false)
+ if (value.contains (group) == false)
this._change_group (group, true);
- });
+ }
/* Since we're only changing the members of this._groups, rather than
* replacing it with a new instance, we have to manually emit the
if (is_member)
{
- if (this._groups.lookup (group) != true)
+ if (!this._groups.contains (group))
{
- this._groups.insert (group, true);
+ this._groups.add (group);
changed = true;
}
}
}
/* Groups */
- this._groups = new HashTable<string, bool> (str_hash, str_equal);
+ this._groups = new HashSet<string> ();
contact.notify["avatar-file"].connect ((s, p) =>
{
*/
using GLib;
+using Gee;
/**
* Interface for {@link Persona}s or {@link Individual}s which can be grouped
*
* Freeform group IDs are mapped to a boolean which is `true` if the
* contact is a member of the group, and `false` otherwise.
+ *
+ * @since UNRELEASED
*/
- public abstract HashTable<string, bool> groups { get; set; }
+ public abstract Set<string> groups { get; set; }
/**
* Add or remove the contact from the specified group.
{
private bool _is_favourite;
private string _alias;
- private HashTable<string, bool> _groups;
+ private HashSet<string> _groups;
/* These two data structures should store exactly the same set of Personas:
* the Personas contained in this Individual. The HashSet is used for fast
* lookups, whereas the List is used for iteration.
/**
* {@inheritDoc}
*/
- public HashTable<string, bool> groups
+ public Set<string> groups
{
get { return this._groups; }
set
{
- this._groups = value;
this._persona_list.foreach ((p) =>
{
if (p is GroupDetails && ((Persona) p).store.is_writeable == true)
((GroupDetails) p).groups = value;
});
+ this._update_groups ();
}
}
private void _update_groups ()
{
- var new_groups = new HashTable<string, bool> (str_hash, str_equal);
+ var new_groups = new HashSet<string> ();
/* this._groups is null during initial construction */
if (this._groups == null)
- this._groups = new HashTable<string, bool> (str_hash, str_equal);
+ this._groups = new HashSet<string> ();
/* FIXME: this should partition the personas by store (maybe we should
* keep that mapping in general in this class), and execute
{
var persona = (GroupDetails) p;
- persona.groups.foreach ((k, v) =>
+ foreach (var group in persona.groups)
{
- new_groups.insert ((string) k, true);
- });
+ new_groups.add (group);
+ }
}
});
- new_groups.foreach ((k, v) =>
+ foreach (var group in new_groups)
{
- unowned string group = (string) k;
- if (this._groups.lookup (group) != true)
+ if (!this._groups.contains (group))
{
- this._groups.insert (group, true);
- this._groups.foreach ((k, v) =>
+ this._groups.add (group);
+ foreach (var g in this._groups)
{
- unowned string g = (string) k;
debug (" %s", g);
- });
+ }
this.group_changed (group, true);
}
- });
+ }
/* buffer the removals, so we don't remove while iterating */
var removes = new GLib.List<string> ();
- this._groups.foreach ((k, v) =>
+ foreach (var group in this._groups)
{
- unowned string group = (string) k;
- if (new_groups.lookup (group) != true)
+ if (!new_groups.contains (group))
removes.prepend (group);
- });
+ }
removes.foreach ((l) =>
{
assert (((PresenceDetails) i).is_online () == true);
/* Check groups */
- assert (i.groups.size () == 2);
- assert (i.groups.lookup ("Montreal") == true);
- assert (i.groups.lookup ("Francophones") == true);
+ assert (i.groups.size == 2);
+ assert (i.groups.contains ("Montreal") == true);
+ assert (i.groups.contains ("Francophones") == true);
}
assert (removed == null);
}
else if (prop_name == "groups")
{
- HashTable<string, bool> groups =
- (HashTable<string, bool>) prop_value.get_boxed ();
+ Set<string> groups = (Set<string>) prop_value.get_object ();
output_string = "{ ";
bool first = true;
- /* FIXME: This is rather inefficient */
- groups.foreach ((k, v) =>
+ foreach (var group in groups)
{
- if ((bool) v == true)
- {
- if (first == false)
- output_string += ", ";
- output_string += "'%s'".printf ((string) k);
- first = false;
- }
- });
+ if (first == false)
+ output_string += ", ";
+ output_string += "'%s'".printf (group);
+ first = false;
+ }
output_string += " }";
return output_string;