Commit graph

542 commits

Author SHA1 Message Date
Lance Stout
b2d42b1d6c Test no longer applies to latest version of XEP-0066. 2011-07-05 11:18:46 -07:00
Lance Stout
1d22a04721 Added support for custom OOB transfer handlers.
Accepting download requests can be done using:

    self['xep_0066'].register_url_handler(handler=self.oob_download)
    # Add jid=... to specify a handler for a particular JID for a
    # componenent.

    def oob_download(self, iq):
        if iq['from'] not in self.custom_oob_whitelist:
            raise XMPPError('not-authorized')
        try:
            data = urllib2.urlopen(iq['oob_transfer']['url'])
            file = open('oob_download', 'w+')
            file.write(data.read())
            file.close()
            data.close()
        except:
            raise XMPPError('item-not-found')
2011-07-05 09:22:17 -07:00
Lance Stout
5efb170e1d Added wait parameter to disconnect.
If wait=True, then the disconnect call will block until
the send queue has emptied.

WARNING: Using wait=True when more stanzas are being added to the
queue than can be processed such that the queue is never empty
will cause the disconnect call to block indefinitely without actually
disconnecting.
2011-07-04 18:47:57 -07:00
Lance Stout
cccccdcc0a Add logging to XEP-0066. 2011-07-03 20:39:03 -07:00
Lance Stout
8d384ce44f Added XEP-0224 Attention plugin. 2011-07-03 20:37:21 -07:00
Lance Stout
4d6e7c7dbb Update version number to beta6.
XEP-0092 now uses sleekxmpp.__version__ as a default version number.
2011-07-03 15:47:12 -07:00
Lance Stout
9c5885c6b6 Let XEP-0202 specify the local timezone offset in the config. 2011-07-03 15:41:22 -07:00
Lance Stout
ec3a14e6d9 Updated XEP-0202 plugin to new format and use XEP-0082. 2011-07-03 15:30:06 -07:00
Lance Stout
c98f5d4450 Fix some bugs in time handling.
Namely, minutes and seconds were reversed.
2011-07-03 13:41:15 -07:00
Lance Stout
2e8e542bc9 Added XEP-0203 Delayed Delivery plugin. 2011-07-03 12:43:34 -07:00
Lance Stout
7ccc67c06d Added XEP-0082 plugin.
This should make things much easier for any stanza that uses timestamps.
2011-07-03 12:21:47 -07:00
Lance Stout
086bf89d69 Added XEP-0066: Out-of-Band Data 2011-07-03 00:36:36 -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
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
58aa944a5e Fix another roster issue.
Caused by same issue of a JID being in the roster, but with an
incomplete entry.
2011-06-15 10:55:36 -07:00
Lance Stout
dd41a85efc Fix issue with components and roster.
If the roster contained a JID, but not any resource presence data, then
an error would occur when accessing self.roster[jid]['presence'].
2011-06-14 14:03:54 -07:00
Nathan Fritz
e2d18170b0 old xep_0050 plugin is now loadable 2011-06-10 04:14:01 +00:00
Lance Stout
e219c0f976 Added session_end event and some docs.
For now, session_end is the same as disconnected, but once support is
added later for stream management, the two events will become distinct.

Plugins should add handlers for session_end for cleaning any session
state.
2011-06-08 10:24:25 -07:00
Lance Stout
4266ee0fa4 Fix XEP-0050 issue with Unicode string type checking. 2011-06-08 10:00:28 -07:00
Lance Stout
3a62908703 Send component handshake immediately. 2011-06-08 10:00:01 -07:00
Lance Stout
1469323350 Cache stanza if sending fails.
The stanza will be sent first once the send queue is reactivated
after session start.

Stanzas sent by skipping the queue will not be cached.
2011-06-01 15:10:44 -07:00
Lance Stout
a81162edd2 Apply connection backoff to reconnect attempts.
Backoff was only being done for the initial connection attempt
before. Now any reconnection will start with a minimum 1 sec
delay which will approximately double between attempts.
2011-05-31 10:55:15 -07:00
Lance Stout
8080b4cae2 Cleanup logging and exception handling.
The syntax and attribute errors raised during a disconnect/reconnect
attempt are now caught and produce nicer log messages.
2011-05-31 10:23:05 -07:00
Lance Stout
1735c194cd Don't use the send queue for stream initialization.
Use the parameter now=True to skip the queue when
sending Iq stanzas, or using xmpp.send().
2011-05-27 17:00:57 -07:00
Lance Stout
6997b2fbf8 Fix typo for SSL certificate use. 2011-05-27 16:39:45 -07:00
Lance Stout
b81ab97900 Add exponential backoff to connection attempts.
Delay will approximately double between attempts (random variation).

See issue #67.
2011-05-27 14:42:40 -07:00
Lance Stout
384e1a92b7 Added support for testind disconnect errors. 2011-05-27 11:01:30 -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
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
4bb226147a Make roster test a little more robust. 2011-05-20 21:19:27 -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
6a07e7cbe3 Handle callback return value case. 2011-05-20 13:46:12 -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
5399fdd3a9 Add support for testing that no stanzas are sent in tests.
Use: self.send(None)
2011-04-26 16:32:58 -04:00
Nathan Fritz
016aac69f6 Pubsub/Unsubscribe was not getting registered 2011-04-14 17:35:20 -07:00
Lance Stout
1d891858b6 Mark scheduler thread as a daemon. 2011-04-11 14:22:32 -04:00
Lance Stout
f02b0564e0 Update tests to reflect XEP-0086 correcting error codes. 2011-04-08 16:51:24 -04:00
Lance Stout
2e1befc8c6 Make setup.py use sleekxmpp.__version__ 2011-04-08 16:41:18 -04:00
Lance Stout
87ccd804ff Add version info.
May now use sleekxmpp.__version__ and sleekxmpp.__version_info__.
2011-04-08 16:39:39 -04:00
Lance Stout
d7ba7cc72a Use underscore method name.
Since camelcase names are aliased to the underscored name at startup,
if the underscored version is replaced later, the camelCase name does
not reflect the change.
2011-04-08 16:14:22 -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
84e2589f22 Left too much unlrelated code in example. 2011-03-24 09:42:54 -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
4916a12b6f Tidy up the examples. 2011-03-23 22:59:21 -04:00
Lance Stout
d6f2e51b05 Allow SleekTest to wait longer when checking for sent stanzas.
Now timeouts at 0.5sec instead of 0.1sec, which should prevent test
failures from stanzas being delayed longer than usual.
2011-03-23 20:23:49 -04:00
Lance Stout
feb7f892ea Fix typo. 2011-03-23 19:00:20 -04:00
Lance Stout
a420771665 Updated todo file again.
Only 11 plugins left to tidy before 1.0!
2011-03-23 10:10:54 -04:00
Lance Stout
f2449009d1 Updated todo file. 2011-03-23 10:00:48 -04:00