Commit graph

493 commits

Author SHA1 Message Date
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
Nathan Fritz
2e2e16e281 fixes to ping: auto-ping off by default, fixed ping-time of zero bug, fixed class name mismatch 2011-02-15 15:24:58 -08:00
Lance Stout
e4f3b777f9 Reset the roster on disconnect instead of replacing it. 2011-02-14 16:24:49 -05:00
Lance Stout
a278f79bdb Merge branch 'develop' into roster
Conflicts:
	sleekxmpp/clientxmpp.py
2011-02-14 16:18:44 -05:00
Lance Stout
d709f8db65 Use the _build_stanza method. 2011-02-14 13:50:59 -05:00
Lance Stout
75584d7ad7 Remap old method names in a better way.
This should prevent some reference cycles that will cause garbage
collection issues.
2011-02-14 13:49:43 -05:00
Lance Stout
e0f9025e7c More attempts at fixing garbage collection.
Don't keep a reference to stanzas in Callback objects.
2011-02-14 11:30:04 -05:00
Lance Stout
9004e8bbf2 Break references that can prevent garbage collection. 2011-02-14 11:13:41 -05:00
Lance Stout
8b5511c7ec Simplification when removing a deletable handler. 2011-02-13 16:40:04 -05:00
Lance Stout
34f6195ca5 Return the name of the registered callback.
Instead of the actual callback object, return just the name of
the callback object created when using iq.send(callback=..).

This will help prevent memory leaks by not keeping an additional
reference to the object, but still allows for the callback to be
canceled by using self.remove_handler("handler_name").
2011-02-13 16:30:57 -05:00
Lance Stout
70af52d74c Make one-off Callbacks ready for deletion after the prerun step.
Waiting until the actual run step means that the handler is not
marked for deletion when checked in the __spawn_event() thread,
causing the callback to stay in the handler list.
2011-02-13 16:28:06 -05:00
Lance Stout
ca2b4a188a Return the registered callback when using iq.send(callback=foo).
Allows for a callback to be canceled by unregistering the
returned handler.
2011-02-12 11:01:43 -05:00
Lance Stout
0d32638379 XMPPError exceptions can keep a stanza's contents.
This allows exceptions to include the original
content of a stanza in the error response by including
the parameter clear=False when raising the exception.
2011-02-11 15:20:26 -05:00
Lance Stout
c4b1212c44 Updated XEP-0199 plugin.
Now has docs and uses the new plugin format.
2011-02-11 00:30:45 -05:00
Nathan Fritz
3463bf46c6 added option to return false on ping error, added ping example 2011-02-10 13:45:35 -08:00
Lance Stout
13a01beb07 Fix same error for get_info default behaviour. 2011-02-09 09:12:44 -05:00
Lance Stout
145f577bde Fix get_items default behaviour. 2011-02-09 08:58:00 -05:00
Florent Le Coz
72ead3d598 Replace the print statement by a log.debug call
This print syntax is deprecated in python3, so
the plugin was working only with python2
2011-02-09 10:02:14 +08:00
Florent Le Coz
4b71fba64c Fix the xep_0009 import (no more relatives)
Also, remove trailing spaces in all files
of this plugin
2011-02-09 10:02:14 +08:00
Lance Stout
606c369173 Some more roster tweaks. 2011-02-08 19:15:50 -05:00
Stefan de Konink
1ed06bebcd This fixes the configuration stuff, because type is form not submit with setNodeConfiguration. 2011-02-07 23:55:46 +08:00
Lance Stout
aa1996eba6 Fixed failing tests from new XEP-0009 plugin 2011-02-07 10:18:15 -05:00
Nathan Fritz
683f717cf7 fixed merge 2011-02-05 04:54:52 -08:00
Lance Stout
3c871920b1 Make the roster backend settable. 2011-02-02 12:05:34 -05:00
Lance Stout
de6170a13d Merge branch 'develop' into roster
Conflicts:
	sleekxmpp/basexmpp.py
2011-02-02 09:13:22 -05:00
Lance Stout
5313338c3a Fixes for XEP-0202 2011-01-31 15:40:00 -05:00
Lance Stout
cd800d636a Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-01-27 16:05:15 -05:00
Lance Stout
40642b2cd1 Make StreamError work properly.
Now uses the correct namespaces and condition names.
2011-01-27 16:02:57 -05:00
Lance Stout
35ef8f9090 Make stanza.plugins an OrderedDict.
This allows you to determine the order in which substanzas
were added in the original XML.
2011-01-27 16:01:35 -05:00
Lance Stout
38dc35840e Recognize stanzas that don't use the default namespace. 2011-01-27 15:59:50 -05:00
Florent Le Coz
b4004cd4d6 xep_0045: fix the 'to' value when configuring room 2011-01-27 09:34:32 +08:00
Lance Stout
0c8a8314b2 Cleanup for stanzabase.
Use stanza.values instead of _get/set_stanza_values where used.

ElementBase stanzas can now use .tag

May use class method tag_name() for stanza classes.

ElementBase now has .clear() method.
2011-01-26 11:27:41 -05:00
Lance Stout
4e757c2b56 Upgraded how subitem works.
May now use register_stanza_plugin(Foo, Bar, iterable=True)
to add to the set of stanza classes used for iterable
substanzas. It is no longer necessary to manually specify
the contents of subitem if the new method is used.
2011-01-26 10:04:36 -05:00
Stefan de Konink
c3be6ea0b2 My hunch is that these should also be updated. 2011-01-23 02:08:29 +08:00
Lance Stout
da332365d4 Make extending stanza objects nicer.
A stanza object may add is_extension = True to its class definition
to provide a single new interface to a parent stanza.

For example:

import sleekxmpp
from sleekxmpp import Iq
from sleekxmpp.xmlstream import ElementBase, register_stanza_plugin, ET

class Foo(ElementBase):
    """
    Test adding just an attribute to a parent stanza.

    Adding subelements works as expected.
    """
    is_extension = True
    interfaces = set(('foo',))
    plugin_attrib = '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, val):
        self.parent()._set_attr('foo', val)

    def get_foo(self):
        return self.parent()._get_attr('foo')

    def del_foo(self):
        self.parent()._del_attr('foo')

register_stanza_plugin(Iq, Foo)

i1 = Iq()
i2 = Iq(xml=ET.fromstring("<iq xmlns='jabber:client' foo='bar' />"))

>>> i1['foo'] = '3'
>>> i1
'3'
>>> i1
'<iq id="0" foo="3" />'
>>> i2
'<iq id="0" foo="bar" />'
>>> i2['foo']
'bar'
>>> del i2['foo']
>>> i2
'<iq id="0" />'
2011-01-19 19:49:13 -05:00
Lance Stout
6f4c2f22f3 Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-01-19 17:50:05 -05:00
Lance Stout
493df57035 Fix thirdparty imports for Python3 2011-01-19 17:49:39 -05:00
Florent Le Coz
897a9ac333 Do not traceback when DNS resolution time out.
Just log that the resolution timed out, and fall back
to the hostname from the JID in this case
2011-01-20 06:34:08 +08:00
Lance Stout
acc2d071ac Fix disco add_item.
If no JID is specified for the item, use xmpp.boundjid.full.
2011-01-19 17:27:53 -05:00
Lance Stout
d3b1f8c476 Fix namespace for Nick stanza. 2011-01-19 16:47:18 -05:00
Lance Stout
f1db2fc156 Fix error in disco add_item.
None values were not being treated properly.
2011-01-19 12:08:28 -05:00
Lance Stout
2004ddd678 Add StreamError stanza and a stream_error event.
Note that the stream may automatically attempt to
reconnect when a stream error is received.
2011-01-16 13:22:52 -05:00
Lance Stout
cb85d4a529 Raise the event 'socket_error' when a socket error occurs.
Will be most useful for debugging and responding to failed
connection attempts.
2011-01-16 13:07:39 -05:00
Lance Stout
ead3af3135 Make it easier to import OrderedDict 2011-01-15 17:15:33 -05:00
Lance Stout
a2891d7608 Fix how disco plugin looks up info and items for clients. 2011-01-15 10:08:35 -05:00
Lance Stout
d7dea0c6cc Add a note for debug statement when running scheduled events.
Fixes the intermittent DEBUG ((),) messages that give no
explanation.

Will now show as:
DEBUG Scheduled event: ((), )
2011-01-14 12:07:25 -05:00
Lance Stout
65931bb384 Merge branch 'develop' into roster 2011-01-13 22:16:46 -05:00
Lance Stout
632827f213 Fix bug in JID class. Attribute .jid now works properly. 2011-01-13 10:21:20 -05:00
Lance Stout
b71550cec7 Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2011-01-13 10:20:34 -05:00
Dann Martens
b68e7bed40 Fixed typo. 2011-01-13 15:04:16 +01:00
Dann Martens
4be6482ff3 Fixed 'nil' bug in unmarshalling. 2011-01-13 13:42:01 +01:00
Dann Martens
0a3a7b5a70 Removed binding XML namespace experiments. 2011-01-13 11:37:58 +01:00
Dann Martens
3a12cdbd13 Introduced new XEP-0009 into develop. 2011-01-13 08:40:53 +01:00
Lance Stout
7d93d1824b Fix setup.py and old_0004.py typo bugs. 2011-01-12 12:22:48 -05:00
Lance Stout
ba0d699d83 Fix ordering error in Iq._set_stanza_values.
If iq['query'] was set before a plugin that used the query
element was set, then the query element was duplicated.
2011-01-12 08:55:33 -05:00
Lance Stout
a5d53b3349 Fix method call error. 2011-01-10 16:33:30 -05:00
Lance Stout
4487a90623 Add self.client_roster to make things simpler for clients. 2011-01-10 16:28:49 -05:00
Lance Stout
05da8cc3d1 Merge branch 'develop' into roster 2011-01-10 16:27:18 -05:00
Te-je Rodgers
fe3f8dde4b added plugin for xep-0249 2011-01-11 04:11:05 +08:00
Lance Stout
23e499998f Merge branch 'develop' into roster 2011-01-09 10:04:09 -05:00
Lance Stout
acdf9e2d22 Need to run post_init properly. 2011-01-09 10:03:32 -05:00
Lance Stout
2076d506b4 Update the XEP-0092 plugin to the new style. 2011-01-08 22:38:13 -05:00
Florent Le Coz
68ce47c905 Allow XEP 0092 to send os information
Doesn't send these information by default, only if provided in the
config dict (as the 'os' key)
2011-01-09 10:08:44 +08:00
Lance Stout
7c7fa0f008 Add support for XEP-0059 to XEP-0030 plugin. 2011-01-08 11:19:31 -05:00
Lance Stout
a8e3657487 Added new XEP-0059 plugin.
Contributed by Erik Reuterborg Larsson (who).
2011-01-08 10:58:47 -05:00
Lance Stout
13a2f719f4 Add reattempt to ClientXMPP.connect 2011-01-07 16:41:31 -05:00
Lance Stout
2908751020 Allow JID objects to be compared with strings.
Two JIDs match if they have the same full JID value.
2011-01-05 20:16:15 -05:00
Lance Stout
c156a4f723 Merge branch 'develop' into roster 2011-01-05 16:53:33 -05:00
Lance Stout
8b29431cde More clarification in docs for XEP-0030 plugin. 2011-01-04 19:39:10 -05:00
Lance Stout
4b145958fa Clarify docs for disco.get_info. 2011-01-04 18:38:21 -05:00
Lance Stout
e08b0054b2 Keep things lined up. 2010-12-29 15:01:50 -05:00
Andrzej Bieniek
596e135a03 Fixed typo in comment. 2010-12-28 21:32:28 +00:00
Lance Stout
e55e213c78 Fix some typos. 2010-12-28 16:17:08 -05:00
Lance Stout
8749f5e09b Make the new XEP-30 plugin retain older API signatures. 2010-12-28 15:43:00 -05:00
Lance Stout
b3353183f3 Added ordereddict implementation to thirdparty.
See http://pypi.python.org/pypi/ordereddict and
http://code.activestate.com/recipes/576693/.
2010-12-21 17:33:31 -05:00
Lance Stout
3657bf6636 Merge branch 'develop' into roster 2010-12-21 11:33:40 -05:00
Lance Stout
f97f6e5985 More documentation for XEP-0030 plugin. 2010-12-21 11:33:03 -05:00
Lance Stout
34c374a1e1 Make tests pass for catching exceptions.
May now use sys.excepthook to catch exceptions
from threaded handlers.
2010-12-17 13:11:03 -05:00
Lance Stout
506eccf84d Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2010-12-17 10:44:32 -05:00
Florent Le Coz
982bf3b2ec RootStanza raises unexpected exceptions
We now raise the unexpected exceptions instead of sending
them on the network.
 - avoids flood (sending a traceback on a MUC, for example…) and
   maybe some security issues.
 - lets you handle the traceback (catch it to handle
   it properly, or with except_hook, etc)
 - an exception cannot be raised without you knowing
2010-12-17 23:43:48 +08:00
Lance Stout
53a5026301 Almost done with xep-30; added more docs. 2010-12-16 23:52:17 -05:00
Lance Stout
0aee445e69 Use daemon threads instead of signals.
Daemonized threads exit once the main program has quit,
and the only threads left running are all daemon threads.

Should fix hanging clients while not trampling over anyone
else's signal handlers.
2010-12-16 22:21:50 -05:00
Lance Stout
adade2e5ec Merge branch 'develop' into roster 2010-12-16 22:03:56 -05:00
Lance Stout
0ea014fe41 Updated the list of plugins in sleekxmpp.plugins.__init__ 2010-12-16 18:29:56 -05:00
Lance Stout
62b190d0ff Fixed specifying 'from' values in XEP-0045 plugin.
Methods now accept either an ifrom or mfrom parameter
to specify a 'from' value. Client connections should not
need to use these, but component connections must use them.
2010-12-16 18:14:33 -05:00
Lance Stout
4b57b8131f Added support for using SSL CA certificates.
Originally provided by Brian Beggs (macdiesel)
and Thom Nichols (tomstrummer).
2010-12-16 17:30:08 -05:00
Lance Stout
988a90a176 Added MUC invite handler to XEP-0045 plugin.
Originally contributed by damium/romeira, with some
modifications.

Also, converted tabs to spaces to prepare for future cleanup.
2010-12-16 16:18:49 -05:00
Lance Stout
67775fb8bd Use boundjid in plugins instead of the deprecated accessors.
Originally contributed by skinkie, with a few modifications.
2010-12-16 15:38:00 -05:00
Lance Stout
e81683beee Some Python 3.1+ compatibility fixes.
Originally contributed by filipegiusti.
2010-12-16 15:29:17 -05:00
Lance Stout
d9c25ee65c Added more options to the make_iq_* methods.
May include a to and from JID in make_iq_* calls.

May pass an existing iq stanza to most of them instead of generating
a new stanza.

make_iq now accepts a 'to' value, 'type' value, and 'query' value to
simplify things a bit more.
2010-12-16 15:25:04 -05:00
Lance Stout
1ebc7f4d4b Implement a few more static node handlers. 2010-12-15 19:22:21 -05:00
Lance Stout
2c5b77ae2e And some more docs. 2010-12-15 18:57:45 -05:00
Lance Stout
d8aae88526 The documentation effort continues.
Also, need to start working on a replacement for the XEP-30 page in the
wiki since the API has changed significantly.
2010-12-15 17:58:15 -05:00
Lance Stout
2f4bdfee1b Update some docs. 2010-12-13 15:58:59 -05:00
Lance Stout
c16913c999 Merge branch 'develop' into roster
Conflicts:
	sleekxmpp/basexmpp.py
2010-12-13 14:36:53 -05:00
Lance Stout
f4451fe6b7 First pass at a new XEP-0030 plugin.
Now with dynamic node handling goodness.

Some things are not quite working yet, in particular:
    set_items
    set_info
    set_identities
    set_features

And still need more unit tests to round things out.
2010-12-09 18:57:27 -05:00
Lance Stout
f474d378ef Add support for using xml:lang values.
Support is only for adding literal XML content
to stanzas. Full support for things like multiple
message bodies with different xml:lang values is
still in the works.
2010-12-07 23:07:40 -05:00
Lance Stout
defc252c7d Fix several errors in SleekTest.
Notably, not sending an expected stanza will not silently pass.
2010-12-07 23:04:37 -05:00
Lance Stout
19bd1e0485 Actually make the Iq callbacks work for real. 2010-12-07 23:04:04 -05:00