* LinkedHashSet.iterator() now returns a BidirIterator instead of just an
Iterator
* ImDetails.im_addresses is now of type MultiMap<string, string>
+* WebServiceDetails.web_service_addresses is now of type
+ MultiMap<string, string>
Overview of changes from libfolks 0.4.0 to libfolks 0.5.0
=========================================================
: null;
unowned Value? val2 = details.lookup
(this.detail_key (PersonaDetail.WEB_SERVICE_ADDRESSES));
- unowned HashMap<string, LinkedHashSet<string>> web_service_addresses
+ MultiMap<string, string> web_service_addresses
= val2 != null
- ? (HashMap<string, LinkedHashSet<string>>) val2.get_object ()
+ ? (MultiMap<string, string>) val2.get_object ()
: null;
uint im_addresses_size = (im_addresses == null)
? 0 : im_addresses.size;
{
private unowned GLib.KeyFile _key_file;
private HashMultiMap<string, string> _im_addresses;
- private HashMap<string, LinkedHashSet<string>> _web_service_addresses;
+ private HashMultiMap<string, string> _web_service_addresses;
private string _alias;
private const string[] _linkable_properties =
{
/**
* {@inheritDoc}
*/
- public HashMap<string, LinkedHashSet<string>> web_service_addresses
+ public MultiMap<string, string> web_service_addresses
{
get
{ return this._web_service_addresses; }
set
{
/* Remove the current web service addresses from the key file */
- foreach (var web_service in this._web_service_addresses.keys)
+ foreach (var web_service in this._web_service_addresses.get_keys ())
{
try
{
/* Add the new web service addresses to the key file and build a
* table of them to set as the new property value */
- HashMap<string, LinkedHashSet<string>> web_service_addresses =
- new HashMap<string, LinkedHashSet<string>> (str_hash, str_equal);
+ var web_service_addresses = new HashMultiMap<string, string> ();
- foreach (var entry in value.entries)
+ foreach (var web_service in value.get_keys ())
{
- unowned string web_service = (string) entry.key;
- unowned LinkedHashSet<string?> addresses =
- (LinkedHashSet<string?>) entry.value;
+ var addresses = value.get (web_service);
string[] addrs = (string[]) addresses.to_array ();
addrs.length = addresses.size;
this._key_file.set_string_list (this.display_id,
"web-service." + web_service, addrs);
- web_service_addresses.set (web_service, addresses);
+
+ foreach (var address in addresses)
+ {
+ web_service_addresses.set (web_service, address);
+ }
}
this._web_service_addresses = web_service_addresses;
this._key_file = key_file;
this._im_addresses = new HashMultiMap<string, string> ();
- this._web_service_addresses
- = new HashMap<string, LinkedHashSet<string>> (str_hash,
- str_equal);
+ this._web_service_addresses = new HashMultiMap<string, string> ();
/* Load the IM addresses from the key file */
try
unowned string web_service = decomposed_key[1];
var web_service_addresses = this._key_file.get_string_list (
this.display_id, web_service);
-
- var address_set = new LinkedHashSet<string> ();
-
+
foreach (var web_service_address in web_service_addresses)
{
- address_set.add (web_service_address);
+ this._web_service_addresses.set (web_service,
+ web_service_address);
}
-
- this._web_service_addresses.set (web_service, address_set);
+
continue;
}
}
else if (prop_name == "web-service-addresses")
{
- foreach (var entry in this.web_service_addresses.entries)
+ foreach (var web_service in this.web_service_addresses.get_keys ())
{
- unowned string web_service = (string) entry.key;
- unowned LinkedHashSet<string> web_service_addresses =
- (LinkedHashSet<string>) entry.value;
+ var web_service_addresses =
+ this._web_service_addresses.get (web_service);
foreach (string address in web_service_addresses)
callback (web_service + ":" + address);
private HashMultiMap<string, string> _im_addresses =
new HashMultiMap<string, string> ();
- private HashMap<string, LinkedHashSet<string>> _web_service_addresses =
- new HashMap<string, LinkedHashSet<string>> (str_hash, str_equal);
+ private HashMultiMap<string, string> _web_service_addresses =
+ new HashMultiMap<string, string> ();
/**
* {@inheritDoc}
/**
* {@inheritDoc}
*/
- public HashMap<string, LinkedHashSet<string>> web_service_addresses
+ public MultiMap<string, string> web_service_addresses
{
get { return this._web_service_addresses; }
private set {}
}
}
- var web_service_address_array = new LinkedHashSet<string> ();
- web_service_address_array.add (id);
- this._web_service_addresses.set ((owned) service,
- (owned) web_service_address_array);
+ this._web_service_addresses.set (service, id);
update (contact);
}
Folks.PersonaStore.detail_key (
PersonaDetail.WEB_SERVICE_ADDRESSES))
{
- HashMap<string, LinkedHashSet<string>> ws_obj =
- (HashMap<string, LinkedHashSet<string>>) v.get_object ();
+ MultiMap<string, string> ws_obj =
+ (MultiMap<string, string>) v.get_object ();
var ws_addrs = Trf.PersonaStore.serialize_web_services (ws_obj);
/**
* Returns "service1:addr1,addr2;service2:addr3,.."
*
- * @since 0.5.0
+ * @since UNRELEASED
*/
- public static string serialize_web_services (HashMap<string,
- LinkedHashSet<string>> ws_obj)
+ public static string serialize_web_services (
+ MultiMap<string, string> ws_obj)
{
var str = "";
- foreach (var service in ws_obj.keys)
+ foreach (var service in ws_obj.get_keys ())
{
if (str != "")
{
/**
* Transforms "service1:addr1,addr2;service2:addr3,.." to
- * ---> HashMap<string, LinkedHashSet<string>>
+ * ---> HashMultiMap<string, string>
*
- * @since 0.5.0
+ * @since UNRELEASED
*/
- public static HashMap<string, LinkedHashSet<string>> unserialize_web_services
+ public static MultiMap<string, string> unserialize_web_services
(string ws_addrs)
{
- HashMap<string, LinkedHashSet<string>> ret =
- new HashMap<string, LinkedHashSet<string>> ();
+ var ret = new HashMultiMap<string, string> ();
var services = ws_addrs.split (";");
foreach (var service_line in services)
var service_name = service_t[0];
var addrs = service_t[1].split (",");
- var addrs_list = new LinkedHashSet<string> ();
-
- ret.set (service_name, addrs_list);
foreach (var a in addrs)
{
- addrs_list.add (a);
+ ret.set (service_name, a);
}
}
}
internal async void _set_web_service_addrs (Trf.Persona persona,
- HashMap<string, LinkedHashSet<string>> ws_obj)
+ MultiMap<string, string> ws_obj)
{
var ws_addrs = Trf.PersonaStore.serialize_web_services (ws_obj);
yield this._set_tracker_property (persona,
}
}
- private HashMap<string, LinkedHashSet<string>> _web_service_addresses =
- new HashMap<string, LinkedHashSet<string>> (str_hash, str_equal);
+ private HashMultiMap<string, string> _web_service_addresses =
+ new HashMultiMap<string, string> ();
+
/**
* {@inheritDoc}
*/
- public HashMap<string, LinkedHashSet<string>> web_service_addresses
+ public MultiMap<string, string> web_service_addresses
{
get { return this._web_service_addresses; }
set
}
else if (prop_name == "web-service-addresses")
{
- foreach (var entry in this.web_service_addresses.entries)
+ foreach (var web_service in this._web_service_addresses.get_keys ())
{
- unowned string web_service = (string) entry.key;
- unowned LinkedHashSet<string> web_service_addresses =
- (LinkedHashSet<string>) entry.value;
+ var web_service_addresses =
+ this._web_service_addresses.get (web_service);
foreach (string address in web_service_addresses)
callback (web_service + ":" + address);
internal bool _set_web_service_addrs (string ws_addrs)
{
this._web_service_addresses =
- Trf.PersonaStore.unserialize_web_services (ws_addrs);
+ (HashMultiMap<string, string>)
+ Trf.PersonaStore.unserialize_web_services (ws_addrs);
this.notify_property ("web-service-addresses");
return true;
}
/* `protocols_addrs_set` will be passed to the new Kf.Persona */
var protocols_addrs_set = new HashMultiMap<string, string> ();
- var web_service_addrs_set =
- new HashMap<string, LinkedHashSet<string>> (str_hash, str_equal);
+ var web_service_addrs_set = new HashMultiMap<string, string> ();
/* List of local_ids */
var local_ids = new Gee.HashSet<string> ();
if (persona is WebServiceDetails)
{
- foreach (var entry in
- ((WebServiceDetails) persona).web_service_addresses.entries)
+ WebServiceDetails ws_details = (WebServiceDetails) persona;
+
+ /* web_service_addrs_set = union (all personas' WS addresses) */
+ foreach (var web_service in
+ ws_details.web_service_addresses.get_keys ())
{
- unowned string web_service = (string) entry.key;
- unowned LinkedHashSet<string> addresses =
- (LinkedHashSet<string>) entry.value;
+ var ws_addresses =
+ ws_details.web_service_addresses.get (web_service);
- var address_set = web_service_addrs_set.get (web_service);
- if (address_set == null)
+ foreach (var ws_address in ws_addresses)
{
- address_set = new LinkedHashSet<string> ();
- web_service_addrs_set.set (web_service, address_set);
+ web_service_addrs_set.set (web_service, ws_address);
}
-
- address_set.add_all (addresses);
}
}
if (web_service_addrs_set.size > 0)
{
- var web_service_addresses_value = Value (typeof (HashMap));
+ var web_service_addresses_value = Value (typeof (MultiMap));
web_service_addresses_value.set_object (web_service_addrs_set);
details.insert (PersonaStore.detail_key
(PersonaDetail.WEB_SERVICE_ADDRESSES),
* Persona.is_user == true. Iff this is > 0, Individual.is_user == true. */
private uint _persona_user_count = 0;
private HashMultiMap<string, string> _im_addresses;
- private HashMap<string, LinkedHashSet<string>> _web_service_addresses;
+ private HashMultiMap<string, string> _web_service_addresses;
/**
* The trust level of the Individual.
/**
* {@inheritDoc}
*/
- public HashMap<string, LinkedHashSet<string>> web_service_addresses
+ public MultiMap<string, string> web_service_addresses
{
get { return this._web_service_addresses; }
private set {}
public Individual (GLib.List<Persona>? personas)
{
this._im_addresses = new HashMultiMap<string, string> ();
- this._web_service_addresses =
- new HashMap<string, LinkedHashSet<string>> (str_hash, str_equal);
+ this._web_service_addresses = new HashMultiMap<string, string> ();
this._persona_set = new HashSet<Persona> (null, null);
this._stores = new HashMap<PersonaStore, uint> (null, null);
this._gender = Gender.UNSPECIFIED;
private void _update_web_service_addresses ()
{
/* populate the web service addresses as the union of our Personas' addresses */
+ this._web_service_addresses.clear ();
+
foreach (var persona in this.personas)
{
if (persona is WebServiceDetails)
{
var web_service_details = (WebServiceDetails) persona;
- foreach (var entry in
- web_service_details.web_service_addresses.entries)
+ foreach (var cur_web_service in
+ web_service_details.web_service_addresses.get_keys ())
{
- var cur_web_service = (string) entry.key;
- var cur_addresses = (LinkedHashSet<string>) entry.value;
- var web_service_set = this._web_service_addresses.get
- (cur_web_service);
+ var cur_addresses =
+ web_service_details.web_service_addresses.get (
+ cur_web_service);
- if (web_service_set == null)
+ foreach (var address in cur_addresses)
{
- web_service_set = new LinkedHashSet<string> ();
this._web_service_addresses.set (cur_web_service,
- web_service_set);
+ address);
}
-
- web_service_set.add_all (cur_addresses);
}
}
}
public interface Folks.WebServiceDetails : Object
{
/**
- * A mapping of web service to an ordered set of web service addresses.
+ * A mapping of web service to an (unordered) set of web service addresses.
*
* Each mapping is from an arbitrary web service identifier to a set of web
- * service addresses for the contact, listed in preference order.
- * The most-preferred web service address for each web service comes first
- * in that web service's list.
+ * service addresses for the contact, listed in no particular order.
*
* Web service addresses are guaranteed to be unique per web service, but
* not necessarily unique amongst all web services.
*
- * @since 0.5.0
+ * @since UNRELEASED
*/
- public abstract Gee.HashMap<string, LinkedHashSet<string>>
- web_service_addresses
+ public abstract Gee.MultiMap<string, string> web_service_addresses
{
get; set;
}
else if (prop_name == Folks.PersonaStore.detail_key
(PersonaDetail.WEB_SERVICE_ADDRESSES))
{
- HashMap<string, LinkedHashSet<string>> web_service_addresses =
- (HashMap<string, LinkedHashSet<string>>)
- prop_value.get_object ();
+ MultiMap<string, string> web_service_addresses =
+ (MultiMap<string, string>) prop_value.get_object ();
output_string = "{ ";
bool first = true;
- foreach (var entry in web_service_addresses.entries)
+ foreach (var web_service in web_service_addresses.get_keys ())
{
if (first == false)
output_string += ", ";
- output_string += "'%s' : { ".printf ((string) entry.key);
+ output_string += "'%s' : { ".printf (web_service);
first = false;
- LinkedHashSet<string> addresses =
- (LinkedHashSet<string>) entry.value;
+ var addresses = web_service_addresses.get (web_service);
bool _first = true;
foreach (var a in addresses)
{