summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2011-04-19 18:12:15 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2011-04-23 21:59:30 +0100
commit6b5c6befa0a4c392a1ffb6516963a0cbbbb1e4bd (patch)
treef157a0250f238698a0e28ddcbc70b565e93ebfa9 /tools
parent858e80d7649ebe7af0553531a940098f6d3c8449 (diff)
Change ImDetails.im_addresses to be a MultiMap<string, string>
Helps: bgo#640092
Diffstat (limited to 'tools')
-rw-r--r--tools/import-pidgin.vala20
-rw-r--r--tools/inspect/utils.vala14
2 files changed, 11 insertions, 23 deletions
diff --git a/tools/import-pidgin.vala b/tools/import-pidgin.vala
index 9493e70..d293ad9 100644
--- a/tools/import-pidgin.vala
+++ b/tools/import-pidgin.vala
@@ -167,8 +167,7 @@ public class Folks.Importers.Pidgin : Folks.Importer
private async Persona? parse_contact (Xml.Node *contact_node)
{
string alias = null;
- HashTable<string, LinkedHashSet<string>> im_addresses =
- new HashTable<string, LinkedHashSet<string>> (str_hash, str_equal);
+ var im_addresses = new HashMultiMap<string, string> ();
string im_address_string = "";
/* Parse the <buddy> elements beneath <contact> */
@@ -202,23 +201,14 @@ public class Folks.Importers.Pidgin : Folks.Importer
* we need to insert into the Persona's im-addresses property
* for the linking to work. */
string im_address = subiter->get_content ();
-
- LinkedHashSet<string> im_address_set =
- im_addresses.lookup (tp_protocol);
- if (im_address_set == null)
- {
- im_address_set = new LinkedHashSet<string> ();
- im_addresses.insert (tp_protocol, im_address_set);
- }
-
- im_address_set.add (im_address);
+ im_addresses.set (tp_protocol, im_address);
im_address_string += " %s\n".printf (im_address);
}
}
}
/* Don't bother if there's no alias and only one IM address */
- if (im_addresses.size () < 2 &&
+ if (im_addresses.size < 2 &&
(alias == null || alias.strip () == "" ||
alias.strip () == im_address_string.strip ()))
{
@@ -232,8 +222,8 @@ public class Folks.Importers.Pidgin : Folks.Importer
/* Create or update the relevant Persona */
HashTable<string, Value?> details =
new HashTable<string, Value?> (str_hash, str_equal);
- Value im_addresses_value = Value (typeof (HashTable));
- im_addresses_value.set_boxed (im_addresses);
+ Value im_addresses_value = Value (typeof (MultiMap));
+ im_addresses_value.set_object (im_addresses);
details.insert ("im-addresses", im_addresses_value);
Persona persona;
diff --git a/tools/inspect/utils.vala b/tools/inspect/utils.vala
index ca54553..fd1b69f 100644
--- a/tools/inspect/utils.vala
+++ b/tools/inspect/utils.vala
@@ -266,21 +266,19 @@ private class Folks.Inspect.Utils
}
else if (prop_name == "im-addresses")
{
- HashTable<string, LinkedHashSet<string>> im_addresses =
- (HashTable<string, LinkedHashSet<string>>)
- prop_value.get_boxed ();
+ MultiMap<string, string> im_addresses =
+ (MultiMap<string, string>) prop_value.get_object ();
output_string = "{ ";
bool first = true;
- /* FIXME: This is rather inefficient */
- im_addresses.foreach ((k, v) =>
+ foreach (var protocol in im_addresses.get_keys ())
{
if (first == false)
output_string += ", ";
- output_string += "'%s' : { ".printf ((string) k);
+ output_string += "'%s' : { ".printf (protocol);
first = false;
- LinkedHashSet<string> addresses = (LinkedHashSet<string>) v;
+ var addresses = im_addresses.get (protocol);
bool _first = true;
foreach (var a in addresses)
{
@@ -291,7 +289,7 @@ private class Folks.Inspect.Utils
}
output_string += " }";
- });
+ }
output_string += " }";
return output_string;