summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sleekxmpp/plugins/jobs.py6
-rw-r--r--sleekxmpp/plugins/xep_0004.py16
-rw-r--r--todo1.06
3 files changed, 26 insertions, 2 deletions
diff --git a/sleekxmpp/plugins/jobs.py b/sleekxmpp/plugins/jobs.py
index bb2e2554..c52e524e 100644
--- a/sleekxmpp/plugins/jobs.py
+++ b/sleekxmpp/plugins/jobs.py
@@ -1,6 +1,7 @@
from . import base
import logging
from xml.etree import cElementTree as ET
+import types
class jobs(base.base_plugin):
def plugin_init(self):
@@ -20,7 +21,7 @@ class jobs(base.base_plugin):
def claimJob(self, host, node, jobid, ifrom=None):
return self._setState(host, node, jobid, ET.Element('{http://andyet.net/protocol/pubsubjob}claimed'))
- def unclaimJob(self, jobid):
+ def unclaimJob(self, host, node, jobid):
return self._setState(host, node, jobid, ET.Element('{http://andyet.net/protocol/pubsubjob}unclaimed'))
def finishJob(self, host, node, jobid, payload=None):
@@ -38,7 +39,8 @@ class jobs(base.base_plugin):
iq['psstate']['item'] = jobid
iq['psstate']['payload'] = state
result = iq.send()
- if result is None or result['type'] != 'result':
+ if result is None or type(result) == types.BooleanType or result['type'] != 'result':
+ logging.error("Unable to change %s:%s to %s" % (node, jobid, state))
return False
return True
diff --git a/sleekxmpp/plugins/xep_0004.py b/sleekxmpp/plugins/xep_0004.py
index 037fc090..86963632 100644
--- a/sleekxmpp/plugins/xep_0004.py
+++ b/sleekxmpp/plugins/xep_0004.py
@@ -23,6 +23,15 @@ class Form(ElementBase):
sub_interfaces = set(('title',))
form_types = set(('cancel', 'form', 'result', 'submit'))
+ def __init__(self, *args, **kwargs):
+ title = None
+ if 'title' in kwargs:
+ title = kwargs['title']
+ del kwargs['title']
+ ElementBase.__init__(self, *args, **kwargs)
+ if title is not None:
+ self['title'] = title
+
def setup(self, xml=None):
if ElementBase.setup(self, xml): #if we had to generate xml
self['type'] = 'form'
@@ -339,6 +348,13 @@ class xep_0004(base.base_plugin):
registerStanzaPlugin(Form, FormField)
registerStanzaPlugin(Message, Form)
+ def makeForm(self, ftype='form', title='', instructions=''):
+ f = Form()
+ f['type'] = ftype
+ f['title'] = title
+ f['instructions'] = instructions
+ return f
+
def post_init(self):
base.base_plugin.post_init(self)
self.xmpp.plugin['xep_0030'].add_feature('jabber:x:data')
diff --git a/todo1.0 b/todo1.0
index 5e9a43e1..593185bc 100644
--- a/todo1.0
+++ b/todo1.0
@@ -48,6 +48,10 @@ conn_tests and sleekxmpp/tests and sleekxmpp/xmlstresm/test.* -> convert to eith
Update setup.py - github url, version #
+scheduler needs unit tests
+
+__init__.py stream:features handler should use new state machine
+
-- PEP8 - all files
@@ -126,6 +130,8 @@ Unit tests
Clean commented code
+Use the new scheduler
+
-- Documentation