Commit Graph

332 Commits

Author SHA1 Message Date
Lance Stout ad978700fc Merge branch 'develop' into roster 2011-07-27 19:35:42 -07:00
Lance Stout ccc6ab1281 Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-07-05 21:30:16 -07:00
Lance Stout 712da4c46e Add test to check that presence events are firing. 2011-07-05 21:29:31 -07:00
Lance Stout b2d42b1d6c Test no longer applies to latest version of XEP-0066. 2011-07-05 11:18:46 -07:00
Lance Stout 20df6348a4 Merge branch 'develop' into exceptions 2011-07-03 00:39:14 -07:00
Lance Stout 48fb7006f7 Merge branch 'develop' into roster 2011-07-03 00:39:02 -07:00
Lance Stout 9a6eb333e6 Merge branch 'develop' into stream_features 2011-07-03 00:38:22 -07:00
Lance Stout 086bf89d69 Added XEP-0066: Out-of-Band Data 2011-07-03 00:36:36 -07:00
Lance Stout 04def6d925 Merge branch 'develop' into stream_features 2011-07-01 15:19:37 -07:00
Lance Stout 7057984831 Merge branch 'develop' into roster 2011-07-01 15:19:05 -07:00
Lance Stout 2a2ac73845 So using sys.excepthook to catch errors only works once.
The error bubbles through the event processing loop, breaking it and
hanging the application.

Instead, there is now a .exception(e) method on XMLStream which may
be overridden or reassigned that will receive all unhandled exceptions
(read: not XMPPError) from event and stream handlers.
2011-07-01 15:18:10 -07:00
Lance Stout fa716457a5 Merge branch 'develop' into stream_features 2011-06-20 16:27:55 -07:00
Lance Stout 847510c6b5 Merge branch 'develop' into exceptions 2011-06-20 16:27:39 -07:00
Lance Stout 774e0f2022 Merge branch 'develop' into roster 2011-06-20 16:27:25 -07:00
Lance Stout d8d9e8df16 Fix stanza clobbering when replying to errors.
If a stanza handler raised an exception, the exception was processed
and replied by the modified stanza, not a stanza with the original
content.

A copy is now made before handler processing, and if an exception occurs
it is the copy that processes the exception using the original content.
2011-06-20 16:25:56 -07:00
Lance Stout 29d775e675 Integrate roster with BaseXMPP.
Last sent stanzas are saved regardless of if the roster is used
directly or self.send_presence
2011-06-16 16:03:31 -07:00
Lance Stout 8aa4396e44 Begin experimental use of exceptions.
Provides IqTimeout and IqError which are raised when an Iq response
does not arrive in time, or it arrives with type='error'.
2011-06-01 15:17:22 -07:00
Lance Stout 83a73ac9b7 Merge branch 'develop' into stream_features
Conflicts:
	sleekxmpp/clientxmpp.py
2011-05-31 11:05:54 -07:00
Lance Stout 5ed27bf5f6 Merge branch 'develop' into roster 2011-05-31 10:59:14 -07:00
Lance Stout 384e1a92b7 Added support for testind disconnect errors. 2011-05-27 11:01:30 -07:00
Lance Stout ccb0eeefbd Merge branch 'develop' into stream_features 2011-05-25 15:53:33 -07:00
Lance Stout 62bdaab7c7 Merge branch 'develop' into roster 2011-05-25 15:53:24 -07:00
Lance Stout ec9aed5b75 Fix test for get_roster().
Python2.6 has issues passing a Unicode string as a keyword name.
2011-05-25 15:52:42 -07:00
Lance Stout 9851a2a057 Merge branch 'develop' into stream_features 2011-05-20 21:41:44 -04:00
Lance Stout bb2bc64d15 Merge branch 'develop' into roster 2011-05-20 21:40:37 -04:00
Lance Stout 7152d93dd0 Fix test timeout issue.
A better method than using time.sleep is needed.
Maybe use queue.task_done to detect when event processing
has ended? Research time!
2011-05-20 21:38:43 -04:00
Lance Stout baa1eaf73a Fix test for Python3.
Issue of dict_keys vs list data types.
2011-05-20 21:36:09 -04:00
Lance Stout 4bb226147a Make roster test a little more robust. 2011-05-20 21:19:27 -04:00
Lance Stout 4d3593ac86 Merge branch 'develop' into roster
Conflicts:
	tests/test_stream_roster.py
2011-05-20 21:12:53 -04:00
Lance Stout c49a8e9114 Save progress 2011-05-20 17:42:40 -04:00
Lance Stout 6b274a2543 Fix double roster entry issue with Unicode.
JIDs with Unicode values were being encoded by the JID class
instead of leaving them as just Unicode strings.

It may still be a good idea to use

    from __future__ import unicode_literals

pretty much everywhere though.

Fixes issue #88.
2011-05-20 16:48:13 -04:00
Lance Stout e2de82ac8d Merge branch 'develop' into stream_features
Conflicts:
	sleekxmpp/clientxmpp.py
2011-05-20 13:26:21 -04:00
Lance Stout e3b14bc5a9 Merge branch 'develop' into roster
Conflicts:
	sleekxmpp/clientxmpp.py
	tests/test_stream_roster.py
2011-05-20 13:23:48 -04:00
Lance Stout 9f1648328f Resolve timeout errors for get_roster.
See issue #89

Using get_roster will now return the same types of values as
Iq.send. If a timeout occurs, then the event 'roster_timeout'
will be fired. A successful call to get_roster will also
raise the 'roster_received' event.

To ensure that the get_roster call was successful, here
is a pattern to follow:

    def __init__(self, ...):
        ...
        self.add_event_handler('session_start', self.session_start)
        self.add_event_handler('roster_timeout', self.roster_timeout)
        self.add_event_handler('roster_received', self.roster_received)

    def session_start(self, e):
        self.send_presence()
        self.get_roster()

    def roster_timeout(self, e):
        # Optionally increase the timeout period
        self.get_roster(timeout=self.response_timeout * 2)

    def roster_received(self, iq):
        # Do stuff, roster has been initialized.
        ...
2011-05-20 12:56:00 -04:00
Lance Stout 8e9b3d0760 Ensure that the XEP-0086 plugin is loaded.
Since the XEP-0086 plugin auto adds error code values,
it must be reliably loaded or unloaded when certain tests
are run so that stanzas may be matched. In this case, we
ensure that the plugin is used.
2011-05-13 15:28:47 -04:00
Lance Stout b60c51ef13 Merge branch 'develop' into roster 2011-04-08 16:52:20 -04:00
Lance Stout f02b0564e0 Update tests to reflect XEP-0086 correcting error codes. 2011-04-08 16:51:24 -04:00
Lance Stout f125c11a81 Merge branch 'develop' into stream_features 2011-03-24 13:15:09 -04:00
Lance Stout 77601f7262 Merge branch 'develop' into roster 2011-03-24 13:15:00 -04:00
Lance Stout d94811d81d Added new implementation for XEP-0086. 2011-03-24 13:14:26 -04:00
Lance Stout 6d45971411 Allow a stanza plugin to override a parent's interfaces.
Each interface, say foo, may be overridden in three ways:
    set_foo
    get_foo
    del_foo

To declare an override in a plugin, add the class field
overrides as so:
    overrides = ['set_foo', 'del_foo']

Each override must have a matching set_foo(), etc method
for implementing the new behaviour.

To enable the overrides for a particular parent stanza,
pass the option overrides=True to register_stanza_plugin.

    register_stanza_plugin(Stanza, Plugin, overrides=True)

Example code:

class Test(ElementBase):

    name = 'test'
    namespace = 'testing'
    interfaces = set(('foo', 'bar'))
    sub_interfaces = set(('bar',))

class TestOverride(ElementBase):

    name = 'test-override'
    namespace = 'testing'
    plugin_attrib = 'override'
    interfaces = set(('foo',))
    overrides = ['set_foo']

    def setup(self, xml):
        # Don't include an XML element in the parent stanza
        # since we're adding just an attribute.
        # If adding a regular subelement, no need to do this.
        self.xml = ET.Element('')

    def set_foo(self, value):
        print("overrides!")
        self.parent()._set_attr('foo', 'override-%s' % value)

register_stanza_plugin(Test, TestOverride, overrides=True)

Example usage:
>>> t = TestStanza()
>>> t['foo'] = 'bar'
>>> t['foo']
'override-bar'
2011-03-24 12:25:17 -04:00
Lance Stout bf2f2782b7 Merge branch 'develop' into stream_features 2011-03-24 09:36:35 -04:00
Lance Stout d9be51b2ef Merge branch 'develop' into roster 2011-03-24 09:36:26 -04:00
Lance Stout a3d111be12 Added new XEP-0050 implementation.
Backward incompatibility alert!

Please see examples/adhoc_provider.py for how to use the new
plugin implementation, or the test examples in the files
tests/test_stream_xep_0050.py and tests/test_stanza_xep_0050.py.

Major changes:
    - May now have zero-step commands. Useful if a command is
      intended to be a dynamic status report that doesn't
      require any user input.
    - May use payloads other than data forms, such as a
      completely custom stanza type.
    - May include multiple payload items, such as multiple
      data forms, or a form and a custom stanza type.
    - Includes a command user API for calling adhoc commands
      on remote agents and managing the workflow.
    - Added support for note elements.

Todo:
    - Add prev action support.

You may use register_plugin('old_0050') to continue using the
previous XEP-0050 implementation.
2011-03-24 09:35:36 -04:00
Lance Stout 694673b9bd Merge branch 'develop' into stream_features 2011-03-23 10:01:21 -04:00
Lance Stout 393259c24b Merge branch 'develop' into roster 2011-03-23 10:01:10 -04:00
Lance Stout 833f95b53a Cleaned XEP-0249 plugin, added tests. 2011-03-23 10:00:32 -04:00
Lance Stout 306bdd8021 Merge branch 'develop' into stream_features 2011-03-22 20:48:28 -04:00
Lance Stout 756c4c032f Merge branch 'develop' into roster 2011-03-22 20:48:09 -04:00
Lance Stout 4b1fadde4b Updated XEP-0128 plugin to work with the new XEP-0030 plugin.
Required fixing a few bugs in StanzaBase related to iterable
substanzas.
2011-03-22 20:42:43 -04:00