diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | backends/key-file/kf-persona-store.vala | 4 | ||||
-rw-r--r-- | backends/key-file/kf-persona.vala | 42 | ||||
-rw-r--r-- | backends/libsocialweb/lib/swf-persona.vala | 11 | ||||
-rw-r--r-- | backends/tracker/lib/trf-persona-store.vala | 28 | ||||
-rw-r--r-- | backends/tracker/lib/trf-persona.vala | 17 | ||||
-rw-r--r-- | folks/individual-aggregator.vala | 25 | ||||
-rw-r--r-- | folks/individual.vala | 27 | ||||
-rw-r--r-- | folks/web-service-details.vala | 11 | ||||
-rw-r--r-- | tools/inspect/utils.vala | 12 |
10 files changed, 80 insertions, 99 deletions
@@ -13,6 +13,8 @@ API changes: * 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 ========================================================= diff --git a/backends/key-file/kf-persona-store.vala b/backends/key-file/kf-persona-store.vala index aa8f6d3..d1121c9 100644 --- a/backends/key-file/kf-persona-store.vala +++ b/backends/key-file/kf-persona-store.vala @@ -306,9 +306,9 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore : 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; diff --git a/backends/key-file/kf-persona.vala b/backends/key-file/kf-persona.vala index 187a38a..b5b9811 100644 --- a/backends/key-file/kf-persona.vala +++ b/backends/key-file/kf-persona.vala @@ -35,7 +35,7 @@ public class Folks.Backends.Kf.Persona : Folks.Persona, { 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 = { @@ -144,7 +144,7 @@ public class Folks.Backends.Kf.Persona : Folks.Persona, /** * {@inheritDoc} */ - public HashMap<string, LinkedHashSet<string>> web_service_addresses + public MultiMap<string, string> web_service_addresses { get { return this._web_service_addresses; } @@ -152,7 +152,7 @@ public class Folks.Backends.Kf.Persona : Folks.Persona, 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 { @@ -167,21 +167,22 @@ public class Folks.Backends.Kf.Persona : Folks.Persona, /* 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; @@ -213,9 +214,7 @@ public class Folks.Backends.Kf.Persona : Folks.Persona, 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 @@ -240,15 +239,13 @@ public class Folks.Backends.Kf.Persona : Folks.Persona, 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; } @@ -308,11 +305,10 @@ public class Folks.Backends.Kf.Persona : Folks.Persona, } 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); diff --git a/backends/libsocialweb/lib/swf-persona.vala b/backends/libsocialweb/lib/swf-persona.vala index 9b0259a..bf25d11 100644 --- a/backends/libsocialweb/lib/swf-persona.vala +++ b/backends/libsocialweb/lib/swf-persona.vala @@ -98,8 +98,8 @@ public class Swf.Persona : Folks.Persona, 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} @@ -113,7 +113,7 @@ public class Swf.Persona : Folks.Persona, /** * {@inheritDoc} */ - public HashMap<string, LinkedHashSet<string>> web_service_addresses + public MultiMap<string, string> web_service_addresses { get { return this._web_service_addresses; } private set {} @@ -208,10 +208,7 @@ public class Swf.Persona : Folks.Persona, } } - 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); } diff --git a/backends/tracker/lib/trf-persona-store.vala b/backends/tracker/lib/trf-persona-store.vala index ba98f73..cca6488 100644 --- a/backends/tracker/lib/trf-persona-store.vala +++ b/backends/tracker/lib/trf-persona-store.vala @@ -666,8 +666,8 @@ public class Trf.PersonaStore : Folks.PersonaStore 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); @@ -720,14 +720,14 @@ public class Trf.PersonaStore : Folks.PersonaStore /** * 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 != "") { @@ -755,15 +755,14 @@ public class Trf.PersonaStore : Folks.PersonaStore /** * 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) @@ -772,12 +771,9 @@ public class Trf.PersonaStore : Folks.PersonaStore 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); } } @@ -1867,7 +1863,7 @@ public class Trf.PersonaStore : Folks.PersonaStore } 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, diff --git a/backends/tracker/lib/trf-persona.vala b/backends/tracker/lib/trf-persona.vala index 3ed52bb..2e97827 100644 --- a/backends/tracker/lib/trf-persona.vala +++ b/backends/tracker/lib/trf-persona.vala @@ -330,12 +330,13 @@ public class Trf.Persona : Folks.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 @@ -432,11 +433,10 @@ public class Trf.Persona : Folks.Persona, } 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); @@ -828,7 +828,8 @@ public class Trf.Persona : Folks.Persona, 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; } diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala index 7943698..7ca4767 100644 --- a/folks/individual-aggregator.vala +++ b/folks/individual-aggregator.vala @@ -983,8 +983,7 @@ public class Folks.IndividualAggregator : Object /* `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> (); @@ -1009,21 +1008,19 @@ public class Folks.IndividualAggregator : Object 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); } } @@ -1048,7 +1045,7 @@ public class Folks.IndividualAggregator : Object 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), diff --git a/folks/individual.vala b/folks/individual.vala index 727e277..2281a54 100644 --- a/folks/individual.vala +++ b/folks/individual.vala @@ -100,7 +100,7 @@ public class Folks.Individual : Object, * 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. @@ -429,7 +429,7 @@ public class Folks.Individual : Object, /** * {@inheritDoc} */ - public HashMap<string, LinkedHashSet<string>> web_service_addresses + public MultiMap<string, string> web_service_addresses { get { return this._web_service_addresses; } private set {} @@ -599,8 +599,7 @@ public class Folks.Individual : Object, 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; @@ -954,27 +953,25 @@ public class Folks.Individual : Object, 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); } } } diff --git a/folks/web-service-details.vala b/folks/web-service-details.vala index 7b47090..8770f76 100644 --- a/folks/web-service-details.vala +++ b/folks/web-service-details.vala @@ -29,20 +29,17 @@ using Gee; 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; } diff --git a/tools/inspect/utils.vala b/tools/inspect/utils.vala index fd1b69f..1127b8f 100644 --- a/tools/inspect/utils.vala +++ b/tools/inspect/utils.vala @@ -297,21 +297,19 @@ private class Folks.Inspect.Utils 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) { |