summaryrefslogtreecommitdiff
path: root/sleekxmpp/basexmpp.py
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/basexmpp.py')
-rw-r--r--sleekxmpp/basexmpp.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py
index e3c7bc5a..3cf949a7 100644
--- a/sleekxmpp/basexmpp.py
+++ b/sleekxmpp/basexmpp.py
@@ -15,7 +15,7 @@ import logging
import sleekxmpp
from sleekxmpp import plugins
-from sleekxmpp.stanza import Message, Presence, Iq, Error
+from sleekxmpp.stanza import Message, Presence, Iq, Error, StreamError
from sleekxmpp.stanza.roster import Roster
from sleekxmpp.stanza.nick import Nick
from sleekxmpp.stanza.htmlim import HTMLIM
@@ -128,6 +128,10 @@ class BaseXMPP(XMLStream):
Callback('Presence',
MatchXPath("{%s}presence" % self.default_ns),
self._handle_presence))
+ self.register_handler(
+ Callback('Stream Error',
+ MatchXPath("{%s}error" % self.stream_ns),
+ self._handle_stream_error))
self.add_event_handler('presence_subscribe',
self._handle_subscribe)
@@ -135,9 +139,10 @@ class BaseXMPP(XMLStream):
self._handle_disconnected)
# Set up the XML stream with XMPP's root stanzas.
- self.registerStanza(Message)
- self.registerStanza(Iq)
- self.registerStanza(Presence)
+ self.register_stanza(Message)
+ self.register_stanza(Iq)
+ self.register_stanza(Presence)
+ self.register_stanza(StreamError)
# Initialize a few default stanza plugins.
register_stanza_plugin(Iq, Roster)
@@ -245,24 +250,24 @@ class BaseXMPP(XMLStream):
"""Create a Presence stanza associated with this stream."""
return Presence(self, *args, **kwargs)
- def make_iq(self, id=0, ifrom=None, ito=None, itype=None, query=None):
+ 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.
Arguments:
- id -- An ideally unique ID value for this stanza thread.
- Defaults to 0.
- ifrom -- The from JID to use for this stanza.
- ito -- The destination JID for this stanza.
- type -- The Iq's type, one of: get, set, result, or error.
- query -- Optional namespace for adding a query element.
+ id -- An ideally unique ID value for this stanza thread.
+ Defaults to 0.
+ ifrom -- The from JID to use for this stanza.
+ ito -- The destination JID for this stanza.
+ itype -- The Iq's type, one of: get, set, result, or error.
+ iquery -- Optional namespace for adding a query element.
"""
iq = self.Iq()
iq['id'] = str(id)
iq['to'] = ito
iq['from'] = ifrom
iq['type'] = itype
- iq['query'] = query
+ iq['query'] = iquery
return iq
def make_iq_get(self, queryxmlns=None, ito=None, ifrom=None, iq=None):
@@ -579,6 +584,9 @@ class BaseXMPP(XMLStream):
"""When disconnected, reset the roster"""
self.roster = {}
+ def _handle_stream_error(self, error):
+ self.event('stream_error', error)
+
def _handle_message(self, msg):
"""Process incoming message stanzas."""
self.event('message', msg)