[telepathy-gabble/master] get the language from location updates
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Thu Aug 6 07:56:11 PDT 2009
---
src/conn-location.c | 8 ++++++++
tests/twisted/test-location.py | 6 +++++-
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/conn-location.c b/src/conn-location.c
index 94f6fac..08c45b4 100644
--- a/src/conn-location.c
+++ b/src/conn-location.c
@@ -308,6 +308,7 @@ update_location_from_msg (GabbleConnection *conn,
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *) conn, TP_HANDLE_TYPE_CONTACT);
NodeIter i;
+ const gchar *lang;
TpHandle contact = tp_handle_lookup (contact_repo, from, NULL, NULL);
@@ -317,6 +318,13 @@ update_location_from_msg (GabbleConnection *conn,
DEBUG ("LocationsUpdate for %s:", from);
+ lang = lm_message_node_get_attribute (node, "xml:lang");
+ if (lang != NULL)
+ {
+ g_hash_table_insert (location, g_strdup ("language"),
+ tp_g_value_slice_new_string (lang));
+ }
+
for (i = node_iter (node); i; i = node_iter_next (i))
{
LmMessageNode *subloc_node = node_iter_data (i);
diff --git a/tests/twisted/test-location.py b/tests/twisted/test-location.py
index 2697a4e..ea6ebc9 100644
--- a/tests/twisted/test-location.py
+++ b/tests/twisted/test-location.py
@@ -119,14 +119,18 @@ def test(q, bus, conn, stream):
result['from'] = 'bob at foo.com'
query = result.firstChildElement()
geoloc = query.addElement((ns.GEOLOC, 'geoloc'))
+ geoloc['xml:lang'] = 'en'
geoloc.addElement('lat', content='1.234')
geoloc.addElement('lon', content='5.678')
stream.send(result)
- q.expect_many(
+ _, update_event = q.expect_many(
EventPattern('dbus-return', method='GetLocations'),
EventPattern('dbus-signal', signal='LocationUpdated'))
+ handle, location = update_event.args
+ assertEquals(location['language'], 'en')
+
# Get location again, only GetLocation should get fired
handle = conn.RequestHandles(1, ['bob at foo.com'])[0]
call_async(q, conn.Location, 'GetLocations', [handle])
--
1.5.6.5
More information about the telepathy-commits
mailing list