mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-24 03:00:15 +00:00
Update some docs.
This commit is contained in:
parent
f4451fe6b7
commit
2f4bdfee1b
4 changed files with 74 additions and 21 deletions
|
@ -26,15 +26,23 @@ class xep_0030(base_plugin):
|
||||||
"""
|
"""
|
||||||
XEP-0030: Service Discovery
|
XEP-0030: Service Discovery
|
||||||
|
|
||||||
|
Service discovery in XMPP allows entities to discover information about
|
||||||
|
other agents in the network, such as the feature sets supported by a
|
||||||
|
client, or signposts to other, related entities.
|
||||||
|
|
||||||
|
Also see <http://www.xmpp.org/extensions/xep-0030.html>.
|
||||||
|
|
||||||
Stream Handlers:
|
Stream Handlers:
|
||||||
Disco Info --
|
Disco Info -- Any Iq stanze that includes a query with the
|
||||||
Disco Items --
|
namespace http://jabber.org/protocol/disco#info.
|
||||||
|
Disco Items -- Any Iq stanze that includes a query with the
|
||||||
|
namespace http://jabber.org/protocol/disco#items.
|
||||||
|
|
||||||
Events:
|
Events:
|
||||||
disco_info --
|
disco_info -- Received a disco#info Iq query result.
|
||||||
disco_items --
|
disco_items -- Received a disco#items Iq query result.
|
||||||
disco_info_query --
|
disco_info_query -- Received a disco#info Iq query request.
|
||||||
disco_items_query --
|
disco_items_query -- Received a disco#items Iq query request.
|
||||||
|
|
||||||
Methods:
|
Methods:
|
||||||
set_node_handler --
|
set_node_handler --
|
||||||
|
@ -79,14 +87,45 @@ class xep_0030(base_plugin):
|
||||||
'jid': {},
|
'jid': {},
|
||||||
'node': {}}
|
'node': {}}
|
||||||
|
|
||||||
|
|
||||||
def set_node_handler(self, htype, jid=None, node=None, handler=None):
|
def set_node_handler(self, htype, jid=None, node=None, handler=None):
|
||||||
"""
|
"""
|
||||||
|
Add a node handler for the given hierarchy level and
|
||||||
|
handler type.
|
||||||
|
|
||||||
|
Node handlers are ordered in a hierarchy where the
|
||||||
|
most specific handler is executed. Thus, a fallback,
|
||||||
|
global handler can be used for the majority of cases
|
||||||
|
with a few node specific handler that override the
|
||||||
|
global behavior.
|
||||||
|
|
||||||
|
Node handler hierarchy:
|
||||||
|
JID | Node | Level
|
||||||
|
---------------------
|
||||||
|
None | None | Global
|
||||||
|
Given | None | All nodes for the JID
|
||||||
|
None | Given | Node on self.xmpp.boundjid
|
||||||
|
Given | Given | A single node
|
||||||
|
|
||||||
|
Handler types:
|
||||||
|
get_info
|
||||||
|
get_items
|
||||||
|
set_identities
|
||||||
|
set_features
|
||||||
|
set_items
|
||||||
|
del_info
|
||||||
|
del_items
|
||||||
|
del_identity
|
||||||
|
del_feature
|
||||||
|
del_item
|
||||||
|
add_identity
|
||||||
|
add_feature
|
||||||
|
add_item
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
htype
|
htype -- The operation provided by the handler.
|
||||||
jid
|
jid --
|
||||||
node
|
node --
|
||||||
handler
|
handler --
|
||||||
"""
|
"""
|
||||||
if htype not in self._disco_ops:
|
if htype not in self._disco_ops:
|
||||||
return
|
return
|
||||||
|
@ -102,10 +141,24 @@ class xep_0030(base_plugin):
|
||||||
|
|
||||||
def del_node_handler(self, htype, jid, node):
|
def del_node_handler(self, htype, jid, node):
|
||||||
"""
|
"""
|
||||||
|
Remove a handler type for a JID and node combination.
|
||||||
|
|
||||||
|
The next handler in the hierarchy will be used if one
|
||||||
|
exists. If removing the global handler, make sure that
|
||||||
|
other handlers exist to process existing nodes.
|
||||||
|
|
||||||
|
Node handler hierarchy:
|
||||||
|
JID | Node | Level
|
||||||
|
---------------------
|
||||||
|
None | None | Global
|
||||||
|
Given | None | All nodes for the JID
|
||||||
|
None | Given | Node on self.xmpp.boundjid
|
||||||
|
Given | Given | A single node
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
htype
|
htype -- The type of handler to remove.
|
||||||
jid
|
jid -- The JID from which to remove the handler.
|
||||||
node
|
node -- The node from which to remove the handler.
|
||||||
"""
|
"""
|
||||||
self.set_node_handler(htype, jid, node, None)
|
self.set_node_handler(htype, jid, node, None)
|
||||||
|
|
||||||
|
@ -218,7 +271,7 @@ class xep_0030(base_plugin):
|
||||||
htype -- The handler type to execute.
|
htype -- The handler type to execute.
|
||||||
jid -- The JID requested.
|
jid -- The JID requested.
|
||||||
node -- The node requested.
|
node -- The node requested.
|
||||||
dat -- Optional, custom data to pass to the handler.
|
data -- Optional, custom data to pass to the handler.
|
||||||
"""
|
"""
|
||||||
if jid is None:
|
if jid is None:
|
||||||
jid = self.xmpp.boundjid.full
|
jid = self.xmpp.boundjid.full
|
||||||
|
@ -311,4 +364,3 @@ class xep_0030(base_plugin):
|
||||||
"Using default disco#info feature.")
|
"Using default disco#info feature.")
|
||||||
info.add_feature(info.namespace)
|
info.add_feature(info.namespace)
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,6 @@ from sleekxmpp.xmlstream import ElementBase, ET
|
||||||
class DiscoItems(ElementBase):
|
class DiscoItems(ElementBase):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Example disco#items stanzas:
|
Example disco#items stanzas:
|
||||||
<iq type="get">
|
<iq type="get">
|
||||||
<query xmlns="http://jabber.org/protocol/disco#items" />
|
<query xmlns="http://jabber.org/protocol/disco#items" />
|
||||||
|
|
|
@ -35,6 +35,11 @@ class StaticDisco(object):
|
||||||
|
|
||||||
def __init__(self, xmpp):
|
def __init__(self, xmpp):
|
||||||
"""
|
"""
|
||||||
|
Create a static disco interface. Sets of disco#info and
|
||||||
|
disco#items are maintained for every given JID and node
|
||||||
|
combination. These stanzas are used to store disco
|
||||||
|
information in memory without any additional processing.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
xmpp -- The main SleekXMPP object.
|
xmpp -- The main SleekXMPP object.
|
||||||
"""
|
"""
|
||||||
|
@ -101,7 +106,6 @@ class StaticDisco(object):
|
||||||
data.get('name', None),
|
data.get('name', None),
|
||||||
data.get('lang', None))
|
data.get('lang', None))
|
||||||
|
|
||||||
|
|
||||||
def add_feature(self, jid, node, data=None):
|
def add_feature(self, jid, node, data=None):
|
||||||
self.add_node(jid, node)
|
self.add_node(jid, node)
|
||||||
self.nodes[(jid, node)]['info'].add_feature(data.get('feature', ''))
|
self.nodes[(jid, node)]['info'].add_feature(data.get('feature', ''))
|
||||||
|
@ -124,4 +128,3 @@ class StaticDisco(object):
|
||||||
def del_item(self, jid, node, data=None):
|
def del_item(self, jid, node, data=None):
|
||||||
if (jid, node) in self.nodes:
|
if (jid, node) in self.nodes:
|
||||||
self.nodes[(jid, node)]['items'].del_item(**data)
|
self.nodes[(jid, node)]['items'].del_item(**data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue