summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/event_index.rst56
-rw-r--r--sleekxmpp/clientxmpp.py1
-rw-r--r--sleekxmpp/componentxmpp.py4
-rw-r--r--sleekxmpp/features/feature_bind/bind.py2
-rw-r--r--sleekxmpp/features/feature_mechanisms/mechanisms.py1
-rw-r--r--sleekxmpp/features/feature_session/session.py2
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py7
-rw-r--r--tests/test_stream_roster.py17
8 files changed, 45 insertions, 45 deletions
diff --git a/docs/event_index.rst b/docs/event_index.rst
index 2c5dfd39..ee8f5a95 100644
--- a/docs/event_index.rst
+++ b/docs/event_index.rst
@@ -6,14 +6,20 @@ Event Index
connected
- **Data:** ``{}``
- - **Source:** :py:class:`~sleekxmpp.clientxmpp.ClientXMPP`
+ - **Source:** :py:class:`~sleekxmpp.xmlstream.XMLstream`
Signal that a connection has been made with the XMPP server, but a session
has not yet been established.
+ connection_failed
+ - **Data:** ``{}`` or ``Failure Stanza`` if available
+ - **Source:** :py:class:`~sleekxmpp.xmlstream.XMLstream`
+
+ Signal that a connection can not be established after number of attempts.
+
changed_status
- **Data:** :py:class:`~sleekxmpp.Presence`
- - **Source:** :py:class:`~sleekxmpp.BaseXMPP`
+ - **Source:** :py:class:`~sleekxmpp.roster.item.RosterItem`
Triggered when a presence stanza is received from a JID with a show type
different than the last presence stanza from the same JID.
@@ -65,8 +71,8 @@ Event Index
disconnected
- **Data:** ``{}``
- - **Source:** :py:class:`~sleekxmpp.ClientXMPP`
-
+ - **Source:** :py:class:`~sleekxmpp.xmlstream.XMLstream`
+
Signal that the connection with the XMPP server has been lost.
entity_time
@@ -93,16 +99,16 @@ Event Index
got_online
- **Data:** :py:class:`~sleekxmpp.Presence`
- - **Source:** :py:class:`~sleekxmpp.BaseXMPP`
-
+ - **Source:** :py:class:`~sleekxmpp.roster.item.RosterItem`
+
If a presence stanza is received from a JID which was previously marked as
offline, and the presence has a show type of '``chat``', '``dnd``', '``away``',
or '``xa``', then this event is triggered as well.
got_offline
- **Data:** :py:class:`~sleekxmpp.Presence`
- - **Source:** :py:class:`~sleekxmpp.BaseXMPP`
-
+ - **Source:** :py:class:`~sleekxmpp.roster.item.RosterItem`
+
Signal that an unavailable presence stanza has been received from a JID.
groupchat_invite
@@ -110,7 +116,7 @@ Event Index
- **Source:**
groupchat_direct_invite
- - **Data:** :py:class:`~sleekxmpp.Message`
+ - **Data:** :py:class:`~sleekxmpp.Message`
- **Source:** :py:class:`~sleekxmpp.plugins.xep_0249.direct`
groupchat_message
@@ -147,18 +153,18 @@ Event Index
sure to check the message type in order to handle error messages.
message_form
- - **Data:** :py:class:`~sleekxmpp.plugins.xep_0004.Form`
- - **Source:** :py:class:`~sleekxmpp.plugins.xep_0004.xep_0004`
-
+ - **Data:** :py:class:`~sleekxmpp.plugins.xep_0004.Form`
+ - **Source:** :py:class:`~sleekxmpp.plugins.xep_0004.xep_0004`
+
Currently the same as :term:`message_xform`.
message_xform
- - **Data:** :py:class:`~sleekxmpp.plugins.xep_0004.Form`
- - **Source:** :py:class:`~sleekxmpp.plugins.xep_0004.xep_0004`
-
+ - **Data:** :py:class:`~sleekxmpp.plugins.xep_0004.Form`
+ - **Source:** :py:class:`~sleekxmpp.plugins.xep_0004.xep_0004`
+
Triggered whenever a data form is received inside a message.
- mucc::[room]::got_offline
+ muc::[room]::got_offline
- **Data:**
- **Source:**
@@ -187,8 +193,8 @@ Event Index
A presence stanza with a type of '``error``' is received.
presence_form
- - **Data:** :py:class:`~sleekxmpp.plugins.xep_0004.Form`
- - **Source:** :py:class:`~sleekxmpp.plugins.xep_0004.xep_0004`
+ - **Data:** :py:class:`~sleekxmpp.plugins.xep_0004.Form`
+ - **Source:** :py:class:`~sleekxmpp.plugins.xep_0004.xep_0004`
This event is present in the XEP-0004 plugin code, but is currently not used.
@@ -229,22 +235,20 @@ Event Index
A presence stanza with a type of '``unsubscribed``' is received.
roster_update
- - **Data:** :py:class:`~sleekxmpp.stanza.Roster`
- - **Source:** :py:class:`~sleekxmpp.ClientXMPP`
+ - **Data:** :py:class:`~sleekxmpp.stanza.Roster`
+ - **Source:** :py:class:`~sleekxmpp.ClientXMPP`
An IQ result containing roster entries is received.
sent_presence
- **Data:** ``{}``
- - **Source:** :py:class:`BaseXMPP <sleekxmpp.BaseXMPP>`
+ - **Source:** :py:class:`~sleekxmpp.roster.multi.Roster`
Signal that an initial presence stanza has been written to the XML stream.
session_end
- **Data:** ``{}``
- - **Source:** :py:class:`ClientXMPP <sleekxmpp.ClientXMPP>`,
- :py:class:`ComponentXMPP <sleekxmpp.ComponentXMPP>`
- :py:class:`XEP-0078 <sleekxmpp.plugins.xep_0078>`
+ - **Source:** :py:class:`~sleekxmpp.xmlstream.XMLstream`
Signal that a connection to the XMPP server has been lost and the current
stream session has ended. Currently equivalent to :term:`disconnected`, but
@@ -256,14 +260,14 @@ Event Index
session_start
- **Data:** ``{}``
- - **Source:** :py:class:`ClientXMPP <sleekxmpp.ClientXMPP>`,
+ - **Source:** :py:class:`ClientXMPP <sleekxmpp.ClientXMPP>`,
:py:class:`ComponentXMPP <sleekxmpp.ComponentXMPP>`
:py:class:`XEP-0078 <sleekxmpp.plugins.xep_0078>`
Signal that a connection to the XMPP server has been made and a session has been established.
socket_error
- - **Data:** ``Socket`` exception object
+ - **Data:** ``Socket`` exception object
- **Source:** :py:class:`~sleekxmpp.xmlstream.XMLstream`
stream_error
diff --git a/sleekxmpp/clientxmpp.py b/sleekxmpp/clientxmpp.py
index ae3803ef..905e1944 100644
--- a/sleekxmpp/clientxmpp.py
+++ b/sleekxmpp/clientxmpp.py
@@ -248,7 +248,6 @@ class ClientXMPP(BaseXMPP):
callback = lambda resp: self._handle_roster(resp)
response = iq.send(block, timeout, callback)
- self.event('roster_received', response)
if block:
self._handle_roster(response)
diff --git a/sleekxmpp/componentxmpp.py b/sleekxmpp/componentxmpp.py
index 44f82e96..5284f9d4 100644
--- a/sleekxmpp/componentxmpp.py
+++ b/sleekxmpp/componentxmpp.py
@@ -158,8 +158,8 @@ class ComponentXMPP(BaseXMPP):
"""
self.session_bind_event.set()
self.session_started_event.set()
- self.event("session_bind", self.boundjid, direct=True)
- self.event("session_start")
+ self.event('session_bind', self.boundjid, direct=True)
+ self.event('session_start')
def _handle_probe(self, pres):
self.roster[pres['to']][pres['from']].handle_probe(pres)
diff --git a/sleekxmpp/features/feature_bind/bind.py b/sleekxmpp/features/feature_bind/bind.py
index d2adc27b..bc145620 100644
--- a/sleekxmpp/features/feature_bind/bind.py
+++ b/sleekxmpp/features/feature_bind/bind.py
@@ -62,4 +62,4 @@ class FeatureBind(BasePlugin):
log.debug("Established Session")
self.xmpp.sessionstarted = True
self.xmpp.session_started_event.set()
- self.xmpp.event("session_start")
+ self.xmpp.event('session_start')
diff --git a/sleekxmpp/features/feature_mechanisms/mechanisms.py b/sleekxmpp/features/feature_mechanisms/mechanisms.py
index 81b997eb..58ed9b91 100644
--- a/sleekxmpp/features/feature_mechanisms/mechanisms.py
+++ b/sleekxmpp/features/feature_mechanisms/mechanisms.py
@@ -171,6 +171,7 @@ class FeatureMechanisms(BasePlugin):
except sasl.SASLNoAppropriateMechanism:
log.error("No appropriate login method.")
self.xmpp.event("no_auth", direct=True)
+ self.xmpp.event("failed_auth", direct=True)
self.attempted_mechs = set()
return self.xmpp.disconnect()
except StringPrepError:
diff --git a/sleekxmpp/features/feature_session/session.py b/sleekxmpp/features/feature_session/session.py
index c799a763..ceadd5f3 100644
--- a/sleekxmpp/features/feature_session/session.py
+++ b/sleekxmpp/features/feature_session/session.py
@@ -51,4 +51,4 @@ class FeatureSession(BasePlugin):
log.debug("Established Session")
self.xmpp.sessionstarted = True
self.xmpp.session_started_event.set()
- self.xmpp.event("session_start")
+ self.xmpp.event('session_start')
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 289e3a21..1c0b84b9 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -559,7 +559,7 @@ class XMLStream(object):
self.set_socket(self.socket, ignore=True)
#this event is where you should set your application state
- self.event("connected", direct=True)
+ self.event('connected', direct=True)
return True
except (Socket.error, ssl.SSLError) as serr:
error_msg = "Could not connect to %s:%s. Socket Error #%s: %s"
@@ -610,6 +610,7 @@ class XMLStream(object):
lines = resp.split('\r\n')
if '200' not in lines[0]:
self.event('proxy_error', resp)
+ self.event('connection_failed', direct=True)
log.error('Proxy Error: %s', lines[0])
return False
@@ -717,7 +718,7 @@ class XMLStream(object):
self.event('socket_error', serr, direct=True)
finally:
#clear your application state
- self.event("disconnected", direct=True)
+ self.event('disconnected', direct=True)
return True
def abort(self):
@@ -1130,6 +1131,8 @@ class XMLStream(object):
event queue. All event handlers will run in the
same thread.
"""
+ log.debug("Event triggered: " + name)
+
handlers = self.__event_handlers.get(name, [])
for handler in handlers:
#TODO: Data should not be copied, but should be read only,
diff --git a/tests/test_stream_roster.py b/tests/test_stream_roster.py
index 652ea1ce..3d1447a3 100644
--- a/tests/test_stream_roster.py
+++ b/tests/test_stream_roster.py
@@ -19,16 +19,9 @@ class TestStreamRoster(SleekTest):
"""Test handling roster requests."""
self.stream_start(mode='client', jid='tester@localhost')
- events = []
-
- def roster_received(iq):
- events.append('roster_received')
+ roster_updates = []
- def roster_update(iq):
- events.append('roster_update')
-
- self.xmpp.add_event_handler('roster_received', roster_received)
- self.xmpp.add_event_handler('roster_update', roster_update)
+ self.xmpp.add_event_handler('roster_update', roster_updates.append)
# Since get_roster blocks, we need to run it in a thread.
t = threading.Thread(name='get_roster', target=self.xmpp.get_roster)
@@ -66,8 +59,8 @@ class TestStreamRoster(SleekTest):
# Give the event queue time to process.
time.sleep(.1)
- self.failUnless(events == ['roster_received', 'roster_update'],
- "Wrong roster events fired: %s" % events)
+ self.failUnless(len(roster_updates) == 1,
+ "Wrong number of roster_update events fired: %s (should be 1)" % len(roster_updates))
def testRosterSet(self):
"""Test handling pushed roster updates."""
@@ -156,7 +149,7 @@ class TestStreamRoster(SleekTest):
"""Test rejecting a roster push from an unauthorized source."""
self.stream_start()
self.recv("""
- <iq to='tester@localhost' from="malicious_user@localhost"
+ <iq to='tester@localhost' from="malicious_user@localhost"
type="set" id="1">
<query xmlns="jabber:iq:roster">
<item jid="user@localhost"