summaryrefslogtreecommitdiff
path: root/sleekxmpp/basexmpp.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-06-05 16:54:26 -0700
committerLance Stout <lancestout@gmail.com>2012-06-18 22:00:33 -0700
commit181aea737d5bce9479795b58c29b5a92da3bd48b (patch)
tree75fed30d668542593e12a208bc88775c19d6d6b6 /sleekxmpp/basexmpp.py
parentee702f40710219290508f95ac01df50a96d04f3c (diff)
downloadslixmpp-181aea737d5bce9479795b58c29b5a92da3bd48b.tar.gz
slixmpp-181aea737d5bce9479795b58c29b5a92da3bd48b.tar.bz2
slixmpp-181aea737d5bce9479795b58c29b5a92da3bd48b.tar.xz
slixmpp-181aea737d5bce9479795b58c29b5a92da3bd48b.zip
Add initial support for xml:lang for streams and stanza plugins.
Remaining items are suitable default actions for language supporting interfaces.
Diffstat (limited to 'sleekxmpp/basexmpp.py')
-rw-r--r--sleekxmpp/basexmpp.py11
1 files changed, 9 insertions, 2 deletions
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.