Commit graph

794 commits

Author SHA1 Message Date
Nathan Fritz
7fb9d68714 fixed form accessors in pubsub stanzas 2011-08-30 23:10:13 -07:00
Lance Stout
e0a1c477d0 Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-08-30 23:03:51 -07:00
Nathan Fritz
b70565720f fixed test further... but now I have an out of order problem 2011-08-30 23:03:04 -07:00
Lance Stout
33ac0c9dd6 Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-08-30 22:45:08 -07:00
Nathan Fritz
4699bdff60 Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-08-30 22:44:34 -07:00
Nathan Fritz
354641a3ce added publish-options element 2011-08-30 22:44:19 -07:00
Lance Stout
58a43e40c7 Get/set pubsub subscription options. 2011-08-30 22:27:21 -07:00
Lance Stout
13fdab0139 Test and fix XEP-0060 delete_node() 2011-08-30 21:57:11 -07:00
Lance Stout
2ce617b2ce Fix typo 2011-08-30 09:24:46 -07:00
Lance Stout
63e0496c30 Finish up all major actions in the current XEP-0060.
Still need tests and docs.
2011-08-29 23:05:14 -07:00
Lance Stout
850e3bb99b Stub out missing functionality for pubsub 2011-08-29 21:38:41 -07:00
Lance Stout
2d90deb96a The ifrom parameter doesn't need special treatment. 2011-08-26 22:06:32 -07:00
Lance Stout
3fb3f63e51 Add docs + extended Iq send arguments to pubsub methods. 2011-08-26 16:57:37 -07:00
Lance Stout
d12949ff1c Fix typos in XEP-0060, start of docs and tests. 2011-08-26 12:14:57 -07:00
Lance Stout
e3e985220e Simplify the main process loop. 2011-08-25 17:08:20 -07:00
Lance Stout
802dd8393d Make the timeout for event queue checks configurable.
Now defaults xmlstream.WAIT_TIMEOUT, and settable with
self.wait_timeout.

The new default timeout is 1sec instead of 5sec.
2011-08-25 16:45:34 -07:00
Lance Stout
fe6bc31c60 Added XMLStream.configure_dns.
This can be overridden to do custom configuration for the DNS resolver,
or any other DNS related tasks such as calling the system's res_init().
2011-08-25 16:18:26 -07:00
Lance Stout
2162d6042e Session timeout now defaults to 45sec, but can be adjusted.
e.g.

    self.session_timeout = 15

It is also managed by XMLStream instead of ClientXMPP now.
2011-08-25 15:40:13 -07:00
Lance Stout
b8a4ffece9 Handle sending stanzas in chunks if the socket has poor performance. 2011-08-25 15:08:45 -07:00
Lance Stout
d929e0deb2 Shutdown socket before closing. 2011-08-25 13:48:43 -07:00
Lance Stout
4c08c9c524 Update scheduler with locks and ability to remove tasks.
Scheduled tasks must have a unique name.
2011-08-25 13:34:30 -07:00
Lance Stout
63b8444abe Add overridable method self.configure_socket().
Allows for setting app specific socket timeouts and other socket options.
2011-08-25 00:22:26 -07:00
Lance Stout
84f9505a8d Fix handling of DNS exceptions. 2011-08-24 22:40:57 -07:00
Lance Stout
ede59ab40e Clean and get setup.py working once and for all.
Fixes:
    README.rst now included
    Double line spacing removed from long_description
    Source package now includes tests, examples, etc using Manifest.in
    README.rst typos fixed
    Added README.rst section on installing dnspython for Python3
    Version bumped to RC2
    Version is now taken from sleekxmpp.version.__version__ without
        having to pull in the entire library
    Added 'test' command for setup.py
    Simplified testall.py
    Docs build cleanly from source package after installation
2011-08-24 22:09:02 -07:00
Lance Stout
f92f96325a Make Iq exceptions more discoverable and simpler to use.
IqError and IqTimeout now extend XMPPError, so if you don't care
about the difference, you can use:

    try:
        self.do_something_with_iqs()
    except XMPPError:
        # Error? Timeout? I don't care!
        pass

If you do need to distinguish between timeouts and error replies,
you can still continue to use:

    try:
        self.do_somethin_with_iqs()
    except IqError as err:
        pass
    except IqTimeout:
        pass

If you don't catch any Iq errors and you're processing a stanza
then an error response will be sent, just like normal if you raise
XMPPError or any other exception, except that the error messages
will be generic to prevent leaking too much information.
2011-08-19 01:04:20 -07:00
Lance Stout
e02a42a008 Route all unhandled exceptions through XMLStream.exception.
Or through an equivalent override.
2011-08-18 16:12:51 -07:00
Lance Stout
3e51126e18 PEP8 edits 2011-08-18 02:46:48 -07:00
Lance Stout
a714fa82b2 Remove extra, unhelpful presence debug log. 2011-08-18 02:46:08 -07:00
Lance Stout
e86e6eae81 Up the timeout to 30sec instead of 10sec. 2011-08-18 01:10:25 -07:00
Nathan Fritz
f75b6bf955 added inline documentation for new dns methods 2011-08-18 01:04:01 -07:00
Nathan Fritz
fb78bf0996 fixed manual address definition 2011-08-18 00:59:27 -07:00
Lance Stout
cd7cd30b4c Fix exceptions for Python3 2011-08-18 00:47:07 -07:00
Nathan Fritz
4ea22ff69b Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-08-18 00:35:37 -07:00
Nathan Fritz
3853898ab3 DNS is now properly checked and different answers are tried for each reconnect until exhausted 2011-08-18 00:35:18 -07:00
Lance Stout
3fc20e10f5 Add some convenience methods to rosters.
Can now use len(self.client_roster) to get the number of JIDs in
the roster, and self.client_roster.groups() to get a dict of
groups and the JIDs in those groups.
2011-08-18 00:07:37 -07:00
Lance Stout
004eabf809 Update plugins that use Iq stanzas to work with new exceptions. 2011-08-17 21:30:47 -07:00
Lance Stout
62230fc970 Return '' instead of None from form fields with no values. 2011-08-17 21:22:03 -07:00
Lance Stout
9fdd85d9f1 I've seen people complain about Sleek taking so long to disconnect.
Added logging to say that we're waiting for the server to end the stream
from its end.
2011-08-13 08:58:07 -07:00
Lance Stout
331db30f8f Add form.field back in for backwards compatibility. 2011-08-13 08:34:23 -07:00
Lance Stout
017d7ec62b Add tests for setting a form's type to 'submit' or 'cancel'.
Form fields now remember their current type if the type is deleted. This
allows for fields to properly format their values if set after the form
has been changed to the 'submit' type.
2011-08-13 01:28:18 -07:00
Lance Stout
c26b716164 Update XEP-0050 to use new IQ exceptions.
IqError is now caught and forwarded to the command error handler referenced
in the session.

Errors are now caught and processed by the session's error handler
whether or not the results Iq stanza includes the <command> substanza.

Added the option for blocking command calls. The blocking option is set
during start_command with block=True. Subsequent command flow methods use
session['block'] to determine their blocking behaviour.

If you use blocking commands, then you will need to wrap your command calls
in a try/except block for IqTimeout exceptions.
2011-08-13 00:10:06 -07:00
Lance Stout
bd427849fb Reduce the maximum delay between connection retries to 10min. 2011-08-12 17:17:05 -07:00
Lance Stout
484efff156 Merge branch 'develop' into roster
Conflicts:
	setup.py
	sleekxmpp/clientxmpp.py
2011-08-12 16:47:58 -07:00
Nathan Fritz
8f1d0e7a79 Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-08-12 16:36:03 -07:00
Nathan Fritz
88184ff955 fixed indenting and merged in exceptions branch 2011-08-12 16:35:36 -07:00
Nathan Fritz
bd8c110f00 Merge branch 'exceptions' into develop 2011-08-12 16:35:15 -07:00
Nathan Fritz
0050c51124 updated pubsub plugin to use stanzas 2011-08-12 16:32:09 -07:00
Lance Stout
9b7ed73f95 Reorganize XEP-0004.
Changes:
    May now use underscored method names
    form.field is replaced by form['fields']
    form.get_fields no longer accepts use_dict parameter, it always
        returns an OrderedDict now
    form.set_fields will accept either an OrderedDict, or a list
        of (var, dict) tuples as before.
    Setting the form type to 'submit' will remove extra meta data
        from the form fields, leaving just the 'var' and 'value'
    Setting the form type to 'cancel' will remove all fields.
2011-08-11 21:59:55 -07:00
Lance Stout
156b3200e3 Don't include ping stanza in the ping result. 2011-08-10 09:05:43 -07:00
Lance Stout
572becad44 Enable forcing a specififc SASL mech:
xmpp = ClientXMPP(jid, password, {
    'feature_mechanisms': {'use_mech':'PLAIN'}})
2011-08-09 00:51:49 -07:00
Lance Stout
75f23d1130 Fix XEP-0078 using the new stream feature workflow.
Honestly, this is mainly just a demo/proof of concept that we
can handle dependencies and ordering issues with stream features.

DON'T use XEP-0078 if you are able to use the normal SASL method,
which should be the case unless you are dealing with a very old
XMPP server implementation.
2011-08-06 12:30:56 -07:00
Lance Stout
e83fae3a6f Save the stream ID when the stream starts. 2011-08-06 00:44:32 -07:00
Lance Stout
5be5b8c02b If no config for a plugin is given, try using self.plugin_config.
Sleek loads a few plugins by default, which made it difficult to
configure or even disable them.

Now, if a plugin is registered without any configuration, then
sleek will try finding a configuration in self.plugin_config.
2011-08-06 00:41:14 -07:00
Lance Stout
6c4cb2bf00 Merge branch 'master' into develop
Adds hotfix for ANONYMOUS mech support.

Conflicts:
	sleekxmpp/__init__.py
2011-08-05 14:08:32 -07:00
Lance Stout
148a23579c Hotfix for ANONYMOUS mech support.
Updates version to 1.0-Beta6.1
2011-08-05 14:06:58 -07:00
Lance Stout
ea95811c4c The next release will be 1.0 RC1 2011-08-05 09:01:50 -07:00
Lance Stout
47bc50d9fb Cosmetic PEP8 fixes. 2011-08-04 22:37:22 -07:00
Lance Stout
93a4a3f8a0 Fix Python3 issue with dict.has_key() 2011-08-04 22:36:23 -07:00
Lance Stout
b7cd119b0c Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-08-04 21:50:14 -07:00
Nathan Fritz
7f90de887a added block as process option and updated documentation. added typical use example to ClientXMPP. 2011-08-04 21:49:32 -07:00
Lance Stout
6c8a135612 Fix imports using __all__. 2011-08-04 21:49:15 -07:00
Lance Stout
caec2976d7 Fix Python3 bug.
Use int() instead of long()
2011-08-04 20:34:23 -07:00
Lance Stout
4d8933abdf Actually, we can work around needing dateutil.
If dateutil is present, we'll use that. If not, we'll use
some regexes from the fixed_datetime module.
2011-08-04 20:22:07 -07:00
Lance Stout
6eac0606cf Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-08-04 19:07:04 -07:00
Lance Stout
89cffd43f4 Merge branch 'develop' into roster
Conflicts:
	setup.py
2011-08-04 11:52:17 -07:00
Lance Stout
b9764cc120 Clean up and unify tostring once and for all.
Packaging for Python3 just got easier.
2011-08-04 11:41:36 -07:00
Lance Stout
7cd39a6aad Fix imports for xep_0060 2011-08-04 11:38:14 -07:00
Lance Stout
a0767f6af6 Sadly, dateutil is not actually part of the standard lib.
Thus, using the XEP-0082 and XEP-0202 introduces a dependency
on the dateutil package (installable using pip install python-dateutil).

Maybe we'll be able to rework how these plugins work to avoid
needing dateutil, but for now this will have to do.
2011-08-04 00:07:30 -07:00
Nathan Fritz
9ffdba8643 the great xep_0060 re-organization in preperation for rewrite 2011-08-03 23:56:24 -07:00
Lance Stout
9591cd3a7e Merge branch 'stream_features' into develop 2011-08-03 18:35:01 -07:00
Nathan Fritz
db92fa2330 started transition to xep_0060 rewrite 2011-08-03 18:11:00 -07:00
Lance Stout
d94517d9ca Merge branch 'develop' into stream_features 2011-08-03 17:37:15 -07:00
Lance Stout
0bec040cfe Make sure to keep David Cridland's license and copyright. 2011-08-03 17:08:45 -07:00
Lance Stout
3918ddb075 Merge branch 'develop' into stream_features 2011-08-03 17:02:33 -07:00
Lance Stout
d4091dbde6 Integrate a modified version of Dave Cridland's Suelta SASL library. 2011-08-03 17:00:51 -07:00
Lance Stout
d7fe724145 Merge branch 'develop' into exceptions 2011-07-27 19:36:04 -07:00
Lance Stout
ad978700fc Merge branch 'develop' into roster 2011-07-27 19:35:42 -07:00
Lance Stout
e022b2a36c Add support for HTTP Proxy connections. 2011-07-27 19:35:03 -07:00
Lance Stout
ad032e5ed7 Fix error with DNS selection.
Missed a renaming of 'priority' to 'item'
2011-07-27 18:40:57 -07:00
Kim Alvefur
45412fd404 Do a weighted choice among the highest prioritized items based on weight instead of a weighted choice based on priorities. 2011-07-16 11:00:59 +08: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
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
0224d028e7 SASL failure event now includes the failure stanza.
Broke SASL stanzas into separate files.

Fixed typo in feature_bind.
2011-07-02 23:09:29 -07:00
Lance Stout
540d749695 Fix ordering bug when retrieving an error condition. 2011-07-02 22:50:31 -07:00
Lance Stout
219df582da It isn't 2010 anymore.
I keep forgetting to update the copyright on new code.
2011-07-02 22:49:34 -07:00
Lance Stout
b898b14b77 Use a set to track negotiated features.
Added guards to prevent renegotiating STARTTLS or SASL in cases where
servers don't behave properly.
2011-07-02 22:30:55 -07:00
Lance Stout
fba235a801 Simplify SASL mech registration.
Moved SASL registration completely to the feature plugin, instead of
keeping a portion of it in ClientXMPP.
2011-07-02 21:57:50 -07:00
Lance Stout
b0297af38d Finish cleaning up stream feature organization.
Fixed missing references that weren't caught due to leftover pyc
file allowing tests to keep working when they shouldn't have.
2011-07-02 21:43:02 -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
634f5d691b Continued reorganization and streamlining. 2011-07-01 14:45:55 -07:00
Lance Stout
754ac5092a Reorganize features into plugins. 2011-06-30 15:40:22 -07:00
Lance Stout
9ed972ffeb Fix SASL mechanism selection bug.
ANONYMOUS was being treated as PLAIN, mechanism was being chosen
purely from supported mechanisms, not those provided by the server.

Broke nested handler methods into top-level methods.
2011-06-29 14:05:27 -07:00
Lance Stout
3b1f3fddf0 Reorganized stream level stanzas. 2011-06-28 11:06:44 -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
d1e12cd46f Need to store unavailable presence as last sent if broadcasted. 2011-06-18 14:39:17 -07:00
Lance Stout
adf6d49fd1 Store unavailable presence as last sent presence. 2011-06-18 14:36:19 -07:00
Lance Stout
ce145b04ac Integrate roster with ClientXMPP.
Roster updates are now passed through to the roster when using
self.update_roster, etc.
2011-06-16 16:09:15 -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
251a47db8c Split roster.py into a directory. 2011-06-16 14:15:22 -07:00
Lance Stout
393d702e77 Merge branch 'develop' into exceptions 2011-06-15 10:56:49 -07:00
Lance Stout
4efd41f1ba Merge branch 'develop' into stream_features 2011-06-15 10:56:33 -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
a3597d6deb Merge branch 'develop' into roster
Conflicts:
	sleekxmpp/basexmpp.py
2011-06-14 14:24:25 -07:00
Lance Stout
8fada4d015 Merge branch 'develop' into exceptions 2011-06-14 14:18:40 -07:00
Lance Stout
5d11ab269d Merge branch 'develop' into stream_features 2011-06-14 14:10:52 -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
Lance Stout
6d59f55fd4 Merge branch 'develop' into exceptions 2011-06-10 15:15:01 -07:00
Lance Stout
7a60e4b458 Merge branch 'develop' into stream_features 2011-06-10 15:14:51 -07:00
Lance Stout
937dce8e65 Merge branch 'develop' into roster 2011-06-10 15:14:37 -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
5c1562f36b Merge branch 'develop' into exceptions 2011-06-08 10:02:38 -07:00
Lance Stout
823c13707d Merge branch 'develop' into stream_features 2011-06-08 10:02:22 -07:00
Lance Stout
8eb59072b4 Merge branch 'develop' into roster 2011-06-08 10:01:52 -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
20d053807d IqTimeout now references the original sent stanza.
A little extra bit of docs for IqError.
2011-06-01 15:28:33 -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
8f9100c762 Merge branch 'develop' into stream_features 2011-06-01 15:17:13 -07:00
Lance Stout
788a5b73f9 Merge branch 'develop' into roster 2011-06-01 15:17:04 -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
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
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
9851a2a057 Merge branch 'develop' into stream_features 2011-05-20 21:41:44 -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
a269be485f Merge branch 'develop' into stream_features 2011-05-20 13:46:46 -04:00
Lance Stout
d3bd9cd31d Merge branch 'develop' into roster 2011-05-20 13:46:36 -04:00
Lance Stout
6a07e7cbe3 Handle callback return value case. 2011-05-20 13:46:12 -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
8e46aa7054 Merge branch 'develop' into roster 2011-04-26 16:33:32 -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
8a22597180 added has_jid to roster 2011-04-15 17:43:12 -07:00
Nathan Fritz
016aac69f6 Pubsub/Unsubscribe was not getting registered 2011-04-14 17:35:20 -07:00
Nathan Fritz
e919906c8c Pubsub/Unsubscribe was not getting registered 2011-04-14 17:34:33 -07:00
Nathan Fritz
46dc6eac88 remove roster item state responsibility from clients 2011-04-14 16:27:27 -07:00
Lance Stout
b9bf30e095 Merge branch 'develop' into roster 2011-04-11 14:23:39 -04:00
Lance Stout
1d891858b6 Mark scheduler thread as a daemon. 2011-04-11 14:22:32 -04:00
Lance Stout
6b05938573 Merge branch 'develop' into roster 2011-04-08 16:41:45 -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
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
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
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
Lance Stout
a9685a00b3 Merge branch 'develop' into stream_features
Conflicts:
	sleekxmpp/clientxmpp.py
2011-03-22 12:08:27 -04:00
Lance Stout
e1360ae049 Merge branch 'develop' into roster 2011-03-22 12:00:01 -04:00
Lance Stout
86a6b40fd8 Updated doc for connect() 2011-03-22 11:59:27 -04:00
Lance Stout
7ef6abb2a3 May pass use_tls=False to connect().
Will disable the use of TLS for the session.
2011-03-22 11:56:55 -04:00
Lance Stout
af45b51f4f Fix error with session feature. 2011-03-18 17:57:49 -04:00
Lance Stout
566ec8a5f9 Merge branch 'develop' into stream_features
Conflicts:
	sleekxmpp/xmlstream/stanzabase.py
2011-03-18 17:39:43 -04:00
Lance Stout
b048f8d733 Merge branch 'develop' into roster 2011-03-18 17:36:35 -04:00
Lance Stout
dbf6780345 Change namespace inclusion in strings.
ElementBase instances will display the top-most namespace by default.

StanzaBase instances will NOT display the top-most namespace by default.

May pass True or False to __str__ to override.
2011-03-18 17:34:07 -04:00
Lance Stout
450c313340 Fix error in stanza handler registration in XEP-0092. 2011-03-18 17:30:29 -04:00
Lance Stout
f2c99798a6 Merge branch 'develop' into stream_features 2011-03-18 15:51:44 -04:00
Lance Stout
f65f88325b Merge branch 'develop' into roster 2011-03-18 15:51:27 -04:00
Lance Stout
996ca52471 Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-03-18 15:48:38 -04:00
Lance Stout
6244857746 Fix self.disconnect(reconnect=True) not working. 2011-03-18 15:47:21 -04:00
Florent Le Coz
5635265203 Avoid infinite loop on version result
We need to check if type="get". otherwise we will send our version
when we will receive the version of the remote entity, and thus
going in an infinite loop.
2011-03-16 06:45:06 +08:00
Lance Stout
42c8f6ae87 Merge branch 'develop' into roster 2011-02-24 16:19:45 -05:00
Lance Stout
45ccb31356 Remove the occasional warning about XEP-0059 not loaded. 2011-02-24 16:13:44 -05:00
Lance Stout
1a81b2f464 Add tests for XEP-0085, fix some bugs. 2011-02-24 14:15:02 -05:00
Lance Stout
77251452c1 Updated the XEP-0085 plugin.
Can now be used as so:

>>> msg['chat_state']
''
>>> msg
<message />

>>> msg['chat_state'] = 'paused'
>>> msg
<message>
  <paused xmlns="http://jabber.org/protocol/chatstates" />
</message>

>>> msg['chat_state']
'paused'

>>> del msg['chat_state']
>>> msg
<message />
2011-02-24 12:10:29 -05:00
Lance Stout
4df3aa569b Bring back the signal handlers (and the "killed" event).
Now done more responsibly, saving any existing signal handlers
and calling them when an interrupt occurs in addition to the
one Sleek installs.

NOTE: You may need to explicitly use "kill <process id>" in
order to trigger the proper signal handler execution, and
to raise the "killed" event.
2011-02-23 10:20:04 -05:00