* fixed bugs with XEP 50 for components

* configuration-less nodes
This commit is contained in:
Nathan Fritz 2009-10-29 02:34:23 +00:00
parent 8dbf53594b
commit 44aa526635
6 changed files with 31 additions and 28 deletions

View file

@ -108,6 +108,11 @@ class Form(FieldContainer):
form1.fields[field.var].addOption(option, label) form1.fields[field.var].addOption(option, label)
return form1 return form1
def copy(self):
newform = Form(ftype=self.type)
newform.fromXML(self.getXML(self.type))
return newform
def update(self, form): def update(self, form):
values = form.getValues() values = form.getValues()
for var in values: for var in values:
@ -126,7 +131,7 @@ class Form(FieldContainer):
def setValues(self, values={}): def setValues(self, values={}):
for field in values: for field in values:
if field in self.field: if field in self.field:
if isintance(values[field], list) or isinstance(values[field], tuple): if isinstance(values[field], list) or isinstance(values[field], tuple):
for value in values[field]: for value in values[field]:
self.field[field].setValue(value) self.field[field].setValue(value)
else: else:

View file

@ -39,15 +39,16 @@ class xep_0050(base.base_plugin):
self.xmpp.add_handler("<iq type='set' xmlns='%s'><command xmlns='http://jabber.org/protocol/commands' action='complete'/></iq>" % self.xmpp.default_ns, self.handler_command_complete) self.xmpp.add_handler("<iq type='set' xmlns='%s'><command xmlns='http://jabber.org/protocol/commands' action='complete'/></iq>" % self.xmpp.default_ns, self.handler_command_complete)
self.commands = {} self.commands = {}
self.sessions = {} self.sessions = {}
self.sd = self.xmpp.plugin['xep_0030']
def post_init(self): def post_init(self):
self.xmpp['xep_0030'].add_feature('http://jabber.org/protocol/commands') self.sd.add_feature('http://jabber.org/protocol/commands')
def addCommand(self, node, name, form, pointer=None, multi=False): def addCommand(self, node, name, form, pointer=None, multi=False):
self.xmpp['xep_0030'].add_item(None, name, 'http://jabber.org/protocol/commands', node) self.sd.add_item(None, name, 'http://jabber.org/protocol/commands', node)
self.xmpp['xep_0030'].add_identity('automation', 'command-node', name, node) self.sd.add_identity('automation', 'command-node', name, node)
self.xmpp['xep_0030'].add_feature('http://jabber.org/protocol/commands', node) self.sd.add_feature('http://jabber.org/protocol/commands', node)
self.xmpp['xep_0030'].add_feature('jabber:x:data', node) self.sd.add_feature('jabber:x:data', node)
self.commands[node] = (name, form, pointer, multi) self.commands[node] = (name, form, pointer, multi)
def getNewSession(self): def getNewSession(self):
@ -80,7 +81,7 @@ class xep_0050(base.base_plugin):
in_command = xml.find('{http://jabber.org/protocol/commands}command') in_command = xml.find('{http://jabber.org/protocol/commands}command')
sessionid = in_command.get('sessionid', None) sessionid = in_command.get('sessionid', None)
pointer = self.sessions[sessionid]['next'] pointer = self.sessions[sessionid]['next']
results = self.xmpp['xep_0004'].makeForm('result') results = self.xmpp.plugin['xep_0004'].makeForm('result')
results.fromXML(in_command.find('{jabber:x:data}x')) results.fromXML(in_command.find('{jabber:x:data}x'))
pointer(results,sessionid) pointer(results,sessionid)
self.xmpp.send(self.makeCommand(xml.attrib['from'], in_command.attrib['node'], form=None, id=xml.attrib['id'], sessionid=sessionid, status='completed', actions=[])) self.xmpp.send(self.makeCommand(xml.attrib['from'], in_command.attrib['node'], form=None, id=xml.attrib['id'], sessionid=sessionid, status='completed', actions=[]))
@ -91,7 +92,7 @@ class xep_0050(base.base_plugin):
in_command = xml.find('{http://jabber.org/protocol/commands}command') in_command = xml.find('{http://jabber.org/protocol/commands}command')
sessionid = in_command.get('sessionid', None) sessionid = in_command.get('sessionid', None)
pointer = self.sessions[sessionid]['next'] pointer = self.sessions[sessionid]['next']
results = self.xmpp['xep_0004'].makeForm('result') results = self.xmpp.plugin['xep_0004'].makeForm('result')
results.fromXML(in_command.find('{jabber:x:data}x')) results.fromXML(in_command.find('{jabber:x:data}x'))
form, npointer, next = pointer(results,sessionid) form, npointer, next = pointer(results,sessionid)
self.sessions[sessionid]['next'] = npointer self.sessions[sessionid]['next'] = npointer

View file

@ -18,9 +18,10 @@ class xep_0060(base.base_plugin):
create.set('node', node) create.set('node', node)
pubsub.append(create) pubsub.append(create)
configure = ET.Element('configure') configure = ET.Element('configure')
if config is None: #if config is None:
submitform = self.xmpp.plugin['xep_0004'].makeForm('submit') # submitform = self.xmpp.plugin['xep_0004'].makeForm('submit')
else: #else:
if config is not None:
submitform = config submitform = config
if 'FORM_TYPE' in submitform.field: if 'FORM_TYPE' in submitform.field:
submitform.field['FORM_TYPE'].setValue('http://jabber.org/protocol/pubsub#node_config') submitform.field['FORM_TYPE'].setValue('http://jabber.org/protocol/pubsub#node_config')

View file

@ -16,7 +16,6 @@ class Callback(base.BaseHandler):
self.run(payload, True) self.run(payload, True)
def run(self, payload, instream=False): def run(self, payload, instream=False):
logging.debug("Running %s in %s" % (self.name, self._pointer))
if not self._instream or instream: if not self._instream or instream:
base.BaseHandler.run(self, payload) base.BaseHandler.run(self, payload)
#if self._thread: #if self._thread:

View file

@ -9,14 +9,12 @@ class Waiter(base.BaseHandler):
self._payload = queue.Queue() self._payload = queue.Queue()
def prerun(self, payload): def prerun(self, payload):
logging.debug("Putting into Waiter %s" % self.name)
self._payload.put(payload) self._payload.put(payload)
def run(self, payload): def run(self, payload):
pass pass
def wait(self, timeout=60): def wait(self, timeout=60):
logging.debug("Waiting on %s." % self.name)
try: try:
return self._payload.get(True, timeout) return self._payload.get(True, timeout)
except queue.Empty: except queue.Empty:

View file

@ -94,7 +94,6 @@ class XMLStream(object):
self.socket = ssl.wrap_socket(self.socket) self.socket = ssl.wrap_socket(self.socket)
try: try:
self.socket.connect(self.address) self.socket.connect(self.address)
logging.info("creating filesocket")
self.filesocket = self.socket.makefile('rb', 0) self.filesocket = self.socket.makefile('rb', 0)
self.state.set('connected', True) self.state.set('connected', True)
return True return True