summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2018-02-11 16:42:59 +0100
committermathieui <mathieui@mathieui.net>2018-02-11 16:42:59 +0100
commite1777263873e96d7189b85a3c57197ab6176fae7 (patch)
tree258ceedbb75dfd51e536e998b0e69cc524dd706b
parent20e88fda50832c8a3412586da58f19df2325fef7 (diff)
downloadslixmpp-e1777263873e96d7189b85a3c57197ab6176fae7.tar.gz
slixmpp-e1777263873e96d7189b85a3c57197ab6176fae7.tar.bz2
slixmpp-e1777263873e96d7189b85a3c57197ab6176fae7.tar.xz
slixmpp-e1777263873e96d7189b85a3c57197ab6176fae7.zip
Fix usage of the 0004 plugin interface
form['fields'] is an ordered list of fields while most plugins expect a dict there. Fixes, among other things, a caps bug.
-rw-r--r--slixmpp/plugins/xep_0004/stanza/form.py2
-rw-r--r--slixmpp/plugins/xep_0060/pubsub.py4
-rw-r--r--slixmpp/plugins/xep_0095/stream_initiation.py2
-rw-r--r--slixmpp/plugins/xep_0115/caps.py12
-rw-r--r--slixmpp/plugins/xep_0222.py4
-rw-r--r--slixmpp/plugins/xep_0223.py2
6 files changed, 13 insertions, 13 deletions
diff --git a/slixmpp/plugins/xep_0004/stanza/form.py b/slixmpp/plugins/xep_0004/stanza/form.py
index 0ae22098..ff1a51fb 100644
--- a/slixmpp/plugins/xep_0004/stanza/form.py
+++ b/slixmpp/plugins/xep_0004/stanza/form.py
@@ -23,7 +23,7 @@ class Form(ElementBase):
namespace = 'jabber:x:data'
name = 'x'
plugin_attrib = 'form'
- interfaces = OrderedSet(('instructions', 'reported', 'title', 'type', 'items', ))
+ interfaces = OrderedSet(('instructions', 'reported', 'title', 'type', 'items', 'values'))
sub_interfaces = {'title'}
form_types = {'cancel', 'form', 'result', 'submit'}
diff --git a/slixmpp/plugins/xep_0060/pubsub.py b/slixmpp/plugins/xep_0060/pubsub.py
index 8d6a2877..adfd908c 100644
--- a/slixmpp/plugins/xep_0060/pubsub.py
+++ b/slixmpp/plugins/xep_0060/pubsub.py
@@ -185,14 +185,14 @@ class XEP_0060(BasePlugin):
if config is not None:
form_type = 'http://jabber.org/protocol/pubsub#node_config'
- if 'FORM_TYPE' in config['fields']:
+ if 'FORM_TYPE' in config.get_fields():
config.field['FORM_TYPE']['value'] = form_type
else:
config.add_field(var='FORM_TYPE',
ftype='hidden',
value=form_type)
if ntype:
- if 'pubsub#node_type' in config['fields']:
+ if 'pubsub#node_type' in config.get_fields():
config.field['pubsub#node_type']['value'] = ntype
else:
config.add_field(var='pubsub#node_type', value=ntype)
diff --git a/slixmpp/plugins/xep_0095/stream_initiation.py b/slixmpp/plugins/xep_0095/stream_initiation.py
index d135ecba..a7987d00 100644
--- a/slixmpp/plugins/xep_0095/stream_initiation.py
+++ b/slixmpp/plugins/xep_0095/stream_initiation.py
@@ -97,7 +97,7 @@ class XEP_0095(BasePlugin):
extension='bad-profile',
extension_ns=SI.namespace)
- neg = iq['si']['feature_neg']['form']['fields']
+ neg = iq['si']['feature_neg']['form'].get_fields()
options = neg['stream-method']['options'] or []
methods = []
for opt in options:
diff --git a/slixmpp/plugins/xep_0115/caps.py b/slixmpp/plugins/xep_0115/caps.py
index 78824c84..b7f29516 100644
--- a/slixmpp/plugins/xep_0115/caps.py
+++ b/slixmpp/plugins/xep_0115/caps.py
@@ -199,8 +199,8 @@ class XEP_0115(BasePlugin):
log.debug("Non form extension found, ignoring for caps")
caps.xml.remove(stanza.xml)
continue
- if 'FORM_TYPE' in stanza['fields']:
- f_type = tuple(stanza['fields']['FORM_TYPE']['value'])
+ if 'FORM_TYPE' in stanza.get_fields():
+ f_type = tuple(stanza.get_fields()['FORM_TYPE']['value'])
form_types.append(f_type)
deduped_form_types.add(f_type)
if len(form_types) != len(deduped_form_types):
@@ -214,7 +214,7 @@ class XEP_0115(BasePlugin):
log.debug("Extra FORM_TYPE data, invalid for caps")
return False
- if stanza['fields']['FORM_TYPE']['type'] != 'hidden':
+ if stanza.get_fields()['FORM_TYPE']['type'] != 'hidden':
log.debug("Field FORM_TYPE type not 'hidden', " + \
"ignoring form for caps")
caps.xml.remove(stanza.xml)
@@ -253,7 +253,7 @@ class XEP_0115(BasePlugin):
for stanza in info['substanzas']:
if isinstance(stanza, self.xmpp['xep_0004'].stanza.Form):
- if 'FORM_TYPE' in stanza['fields']:
+ if 'FORM_TYPE' in stanza.get_fields():
f_type = stanza['values']['FORM_TYPE']
if len(f_type):
f_type = f_type[0]
@@ -265,11 +265,11 @@ class XEP_0115(BasePlugin):
for f_type in sorted_forms:
for form in form_types[f_type]:
S += '%s<' % f_type
- fields = sorted(form['fields'].keys())
+ fields = sorted(form.get_fields().keys())
fields.remove('FORM_TYPE')
for field in fields:
S += '%s<' % field
- vals = form['fields'][field].get_value(convert=False)
+ vals = form.get_fields()[field].get_value(convert=False)
if vals is None:
S += '<'
else:
diff --git a/slixmpp/plugins/xep_0222.py b/slixmpp/plugins/xep_0222.py
index 81daed38..abb10163 100644
--- a/slixmpp/plugins/xep_0222.py
+++ b/slixmpp/plugins/xep_0222.py
@@ -73,11 +73,11 @@ class XEP_0222(BasePlugin):
ftype='hidden',
value='http://jabber.org/protocol/pubsub#publish-options')
- fields = options['fields']
+ fields = options.get_fields()
for field, value in self.profile.items():
if field not in fields:
options.add_field(var=field)
- options['fields'][field]['value'] = value
+ options.get_fields()[field]['value'] = value
return self.xmpp['xep_0163'].publish(stanza, node,
options=options,
diff --git a/slixmpp/plugins/xep_0223.py b/slixmpp/plugins/xep_0223.py
index 566e430b..65d591f6 100644
--- a/slixmpp/plugins/xep_0223.py
+++ b/slixmpp/plugins/xep_0223.py
@@ -78,7 +78,7 @@ class XEP_0223(BasePlugin):
for field, value in self.profile.items():
if field not in fields:
options.add_field(var=field)
- options['fields'][field]['value'] = value
+ options.get_fields()[field]['value'] = value
return self.xmpp['xep_0163'].publish(stanza, node, options=options,
ifrom=ifrom, callback=callback,