From 181aea737d5bce9479795b58c29b5a92da3bd48b Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 5 Jun 2012 16:54:26 -0700 Subject: Add initial support for xml:lang for streams and stanza plugins. Remaining items are suitable default actions for language supporting interfaces. --- sleekxmpp/basexmpp.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'sleekxmpp/basexmpp.py') diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py index 43ea6063..4f48f809 100644 --- a/sleekxmpp/basexmpp.py +++ b/sleekxmpp/basexmpp.py @@ -31,6 +31,7 @@ from sleekxmpp.xmlstream import XMLStream, JID from sleekxmpp.xmlstream import ET, register_stanza_plugin from sleekxmpp.xmlstream.matcher import MatchXPath from sleekxmpp.xmlstream.handler import Callback +from sleekxmpp.xmlstream.stanzabase import XML_NS from sleekxmpp.features import * from sleekxmpp.plugins import PluginManager, register_plugin, load_plugin @@ -180,6 +181,8 @@ class BaseXMPP(XMLStream): :param xml: The incoming stream's root element. """ self.stream_id = xml.get('id', '') + self.stream_version = xml.get('version', '') + self.peer_default_lang = xml.get('{%s}lang' % XML_NS, None) def process(self, *args, **kwargs): """Initialize plugins and begin processing the XML stream. @@ -272,7 +275,9 @@ class BaseXMPP(XMLStream): def Message(self, *args, **kwargs): """Create a Message stanza associated with this stream.""" - return Message(self, *args, **kwargs) + msg = Message(self, *args, **kwargs) + msg['lang'] = self.default_lang + return msg def Iq(self, *args, **kwargs): """Create an Iq stanza associated with this stream.""" @@ -280,7 +285,9 @@ class BaseXMPP(XMLStream): def Presence(self, *args, **kwargs): """Create a Presence stanza associated with this stream.""" - return Presence(self, *args, **kwargs) + pres = Presence(self, *args, **kwargs) + pres['lang'] = self.default_lang + return pres def make_iq(self, id=0, ifrom=None, ito=None, itype=None, iquery=None): """Create a new Iq stanza with a given Id and from JID. -- cgit v1.2.3