[folks/next] Replace TelepathyGLib.asv_get_string with our own implementation
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks/next] Replace TelepathyGLib.asv_get_string with our own implementation
- Date: Thu, 3 Apr 2014 19:52:58 +0000 (UTC)
commit 099643f59fdabfb47f0aeeb542b158924bf9a3a3
Author: Simon McVittie <simon mcvittie collabora co uk>
Date: Thu Apr 3 12:48:51 2014 +0100
Replace TelepathyGLib.asv_get_string with our own implementation
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.
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 97c8e83..602f96b 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]