Add set_info disco handler.
This commit is contained in:
parent
5ef0b96d5c
commit
4df1641689
2 changed files with 27 additions and 8 deletions
|
@ -111,12 +111,12 @@ class xep_0030(base_plugin):
|
|||
self.use_cache = self.config.get('use_cache', True)
|
||||
self.wrap_results = self.config.get('wrap_results', False)
|
||||
|
||||
self._disco_ops = ['get_info', 'set_identities', 'set_features',
|
||||
'get_items', 'set_items', 'del_items',
|
||||
'add_identity', 'del_identity', 'add_feature',
|
||||
'del_feature', 'add_item', 'del_item',
|
||||
'del_identities', 'del_features',
|
||||
'cache_info', 'get_cached_info']
|
||||
self._disco_ops = [
|
||||
'get_info', 'set_info', 'set_identities', 'set_features',
|
||||
'get_items', 'set_items', 'del_items', 'add_identity',
|
||||
'del_identity', 'add_feature', 'del_feature', 'add_item',
|
||||
'del_item', 'del_identities', 'del_features', 'cache_info',
|
||||
'get_cached_info']
|
||||
|
||||
self.default_handlers = {}
|
||||
self._handlers = {}
|
||||
|
@ -344,6 +344,15 @@ class xep_0030(base_plugin):
|
|||
block=kwargs.get('block', True),
|
||||
callback=kwargs.get('callback', None))
|
||||
|
||||
def set_info(self, jid=None, node=None, info=None):
|
||||
"""
|
||||
Set the disco#info data for a JID/node based on an existing
|
||||
disco#info stanza.
|
||||
"""
|
||||
if isinstance(info, Iq):
|
||||
info = info['disco_info']
|
||||
self._run_node_handler('set_info', jid, node, None, info)
|
||||
|
||||
def get_items(self, jid=None, node=None, local=False, **kwargs):
|
||||
"""
|
||||
Retrieve the disco#items results from a given JID/node combination.
|
||||
|
|
|
@ -134,7 +134,17 @@ class StaticDisco(object):
|
|||
else:
|
||||
return self.get_node(jid, node)['info']
|
||||
|
||||
def del_info(self, jid, node, data):
|
||||
def set_info(self, jid, node, ifrom, data):
|
||||
"""
|
||||
Set the entire info stanza for a JID/node at once.
|
||||
|
||||
The data parameter is a disco#info substanza.
|
||||
"""
|
||||
with self.lock:
|
||||
self.add_node(jid, node)
|
||||
self.get_node(jid, node)['info'] = data
|
||||
|
||||
def del_info(self, jid, node, ifrom, data):
|
||||
"""
|
||||
Reset the info stanza for a given JID/node combination.
|
||||
|
||||
|
@ -163,7 +173,7 @@ class StaticDisco(object):
|
|||
"""
|
||||
Replace the stored items data for a JID/node combination.
|
||||
|
||||
The data parameter may provided:
|
||||
The data parameter may provide:
|
||||
items -- A set of items in tuple format.
|
||||
"""
|
||||
with self.lock:
|
||||
|
|
Loading…
Reference in a new issue