[telepathy-gabble/master] SetLocation: support language attribute
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Thu Aug 6 08:14:07 PDT 2009
---
src/conn-location.c | 14 ++++++++++++--
tests/twisted/test-location.py | 12 ++++++++----
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/src/conn-location.c b/src/conn-location.c
index d2d3b90..94f6fac 100644
--- a/src/conn-location.c
+++ b/src/conn-location.c
@@ -133,8 +133,18 @@ create_msg_foreach (gpointer key,
}
else if (G_VALUE_TYPE (value) == G_TYPE_STRING)
{
- lm_message_node_add_child (geoloc, key, g_value_get_string (value));
- DEBUG ("\t - %s: %s", (gchar *) key, g_value_get_string (value));
+ const gchar *str = g_value_get_string (value);
+
+ if (!tp_strdiff (key, "language"))
+ {
+ /* Set the xml:lang */
+ lm_message_node_set_attribute (geoloc, "xml:lang", str);
+ }
+ else
+ {
+ lm_message_node_add_child (geoloc, key, str);
+ }
+ DEBUG ("\t - %s: %s", (gchar *) key, str);
}
else
DEBUG ("\t - Unknown key dropped: %s", (gchar *) key);
diff --git a/tests/twisted/test-location.py b/tests/twisted/test-location.py
index 2aab730..38d3b0d 100644
--- a/tests/twisted/test-location.py
+++ b/tests/twisted/test-location.py
@@ -1,9 +1,9 @@
from gabbletest import exec_test, make_result_iq
-from servicetest import call_async, EventPattern
+from servicetest import call_async, EventPattern, assertEquals
from twisted.words.xish import xpath
import constants as cs
-
+import ns
Rich_Presence_Access_Control_Type_Publish_List = 1
@@ -101,10 +101,14 @@ def test(q, bus, conn, stream):
assert False, "Should have had an error!"
conn.Location.SetLocation({
- 'lat': dbus.Double(0.0, variant_level=1), 'lon': 0.0})
+ 'lat': dbus.Double(0.0, variant_level=1),
+ 'lon': 0.0,
+ 'language': 'en'})
- event = q.expect('stream-iq', predicate=lambda x:
+ event = q.expect('stream-iq', predicate=lambda x:
xpath.queryForNodes("/iq/pubsub/publish/item/geoloc", x.stanza))
+ geoloc = xpath.queryForNodes("/iq/pubsub/publish/item/geoloc", event.stanza)[0]
+ assertEquals(geoloc.getAttribute((ns.XML, 'lang')), 'en')
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