1.1 --- a/libxml2dom/xmpp.py Thu Jul 09 20:48:31 2009 +0200
1.2 +++ b/libxml2dom/xmpp.py Sun Feb 27 18:32:58 2011 +0100
1.3 @@ -10,7 +10,7 @@
1.4 See: http://www.xmpp.org/rfcs/rfc3920.html
1.5 See: http://www.xmpp.org/rfcs/rfc3921.html
1.6
1.7 -Copyright (C) 2007 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2007, 2009 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU Lesser General Public License as published by the Free
1.12 @@ -202,7 +202,7 @@
1.13 # NOTE: the specifications.
1.14
1.15 b64value = base64.encodestring("%s\x00%s\x00%s" % (jid, username, password))
1.16 - text = self.ownerDocument.createTextNode(b64value)
1.17 + text = self.ownerDocument.createTextNode(b64value.strip())
1.18 self.appendChild(text)
1.19
1.20 mechanism = property(_mechanism, _setMechanism)
1.21 @@ -361,7 +361,7 @@
1.22 return (self.xpath("session:session") or [None])[0]
1.23
1.24 bind = property(_bind)
1.25 - query = property(_query)
1.26 + registration = query = property(_query)
1.27 session = property(_session)
1.28
1.29 def createBind(self):
1.30 @@ -386,9 +386,18 @@
1.31 self.type = "get"
1.32
1.33 def makeRegistration(self):
1.34 + query = self.createQuery()
1.35 + self.appendChild(query)
1.36 self.id = "register2"
1.37 self.type = "set"
1.38
1.39 + def makeUnregistration(self):
1.40 + query = self.createQuery()
1.41 + self.appendChild(query)
1.42 + query.appendChild(self.ownerDocument.createElement("remove"))
1.43 + self.id = "unreg1"
1.44 + self.type = "set"
1.45 +
1.46 def makeSession(self, host):
1.47 session = self.createSession()
1.48 self.appendChild(session)
1.49 @@ -499,7 +508,23 @@
1.50 if doc is None:
1.51 return None
1.52 else:
1.53 - return doc.documentElement
1.54 + stanza = doc.documentElement
1.55 +
1.56 + # Add implied namespace (from the outermost element).
1.57 + # NOTE: This should possibly use the real namespace details from the
1.58 + # NOTE: stream element.
1.59 +
1.60 + if stanza.namespaceURI is None:
1.61 + new_stanza = self.createStanza(XMPP_CLIENT_NAMESPACE, stanza.name)
1.62 + new_doc = new_stanza.ownerDocument
1.63 + for attribute in stanza.attributes:
1.64 + new_stanza.attributes.setNamedItemNS(attribute)
1.65 + for child in stanza.childNodes:
1.66 + n = new_doc.importNode(child, 1)
1.67 + new_stanza.appendChild(n)
1.68 + stanza = new_stanza
1.69 +
1.70 + return stanza
1.71
1.72 # Stanza creation.
1.73