diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-03 12:48:51 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-03 12:48:51 +0100 |
commit | 099643f59fdabfb47f0aeeb542b158924bf9a3a3 (patch) | |
tree | 02fa20d35780caee5127932b82bc155796703a8d | |
parent | 39de01f31a830ad3b5ba73b89c434c0fc1c9ac7b (diff) |
Replace TelepathyGLib.asv_get_string with our own implementationnext-decore
I want to move functions that deal with dbus-glib types to the -dbus
sub-library, which doesn't have Vala bindings. Folks' use of it is
not its usual purpose.
-rw-r--r-- | backends/telepathy/lib/tpf-persona-store.vala | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala index 97c8e836..602f96bc 100644 --- a/backends/telepathy/lib/tpf-persona-store.vala +++ b/backends/telepathy/lib/tpf-persona-store.vala @@ -1269,6 +1269,25 @@ public class Tpf.PersonaStore : Folks.PersonaStore return this._ensure_persona_for_contact (contact); } + private static string? details_get_string (HashTable<string, Value?> details, + string key) + { + unowned Value? v = details.lookup (key); + + if (v != null && v.holds (typeof (string))) + { + return v.get_string (); + } + else + { + /* FIXME: is it considered to be programmer error to pass + * { "contact": not_a_string } to add_persona_from_details? + * For now I'm preserving the existing behaviour of + * tp_asv_get_string() */ + return null; + } + } + /** * Add a new {@link Persona} to the PersonaStore. * @@ -1285,7 +1304,8 @@ public class Tpf.PersonaStore : Folks.PersonaStore public override async Folks.Persona? add_persona_from_details ( HashTable<string, Value?> details) throws Folks.PersonaStoreError { - var contact_id = TelepathyGLib.asv_get_string (details, "contact"); + var contact_id = details_get_string (details, "contact"); + if (contact_id == null) { throw new PersonaStoreError.INVALID_ARGUMENT ( @@ -1296,7 +1316,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore } // Optional message to pass to the new persona - var add_message = TelepathyGLib.asv_get_string (details, "message"); + var add_message = details_get_string (details, "message"); if (add_message == "") add_message = null; |