plugin XEP-0059: added "parseExtra" method to easily handle RSM argument coming from bridge.
This commit is contained in:
parent
0b8e750956
commit
7d82242b74
1 changed files with 30 additions and 8 deletions
|
|
@ -33,25 +33,47 @@ from zope.interface import implements
|
|||
|
||||
|
||||
PLUGIN_INFO = {
|
||||
C.PI_NAME: "Result Set Management",
|
||||
C.PI_IMPORT_NAME: "XEP-0059",
|
||||
C.PI_TYPE: "XEP",
|
||||
C.PI_PROTOCOLS: ["XEP-0059"],
|
||||
C.PI_MAIN: "XEP_0059",
|
||||
C.PI_HANDLER: "yes",
|
||||
C.PI_DESCRIPTION: _("""Implementation of Result Set Management"""),
|
||||
C.PI_NAME: u"Result Set Management",
|
||||
C.PI_IMPORT_NAME: u"XEP-0059",
|
||||
C.PI_TYPE: u"XEP",
|
||||
C.PI_PROTOCOLS: [u"XEP-0059"],
|
||||
C.PI_MAIN: u"XEP_0059",
|
||||
C.PI_HANDLER: u"yes",
|
||||
C.PI_DESCRIPTION: _(u"""Implementation of Result Set Management"""),
|
||||
}
|
||||
|
||||
RSM_PREFIX = u"rsm_"
|
||||
|
||||
|
||||
class XEP_0059(object):
|
||||
# XXX: RSM management is done directly in Wokkel.
|
||||
|
||||
def __init__(self, host):
|
||||
log.info(_("Result Set Management plugin initialization"))
|
||||
log.info(_(u"Result Set Management plugin initialization"))
|
||||
|
||||
def getHandler(self, client):
|
||||
return XEP_0059_handler()
|
||||
|
||||
def parseExtra(self, extra):
|
||||
"""Parse extra dictionnary to retrieve RSM arguments
|
||||
|
||||
@param extra(dict): data for parse
|
||||
@return (rsm.RSMRequest, None): request with parsed arguments
|
||||
or None if no RSM arguments have been found
|
||||
"""
|
||||
rsm_args = {}
|
||||
for arg in (u"max", u"after", u"before", u"index"):
|
||||
try:
|
||||
argname = "max_" if arg == u"max" else arg
|
||||
rsm_args[argname] = extra.pop(RSM_PREFIX + arg)
|
||||
except KeyError:
|
||||
continue
|
||||
|
||||
if rsm_args:
|
||||
return rsm.RSMRequest(**rsm_args)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class XEP_0059_handler(xmlstream.XMPPHandler):
|
||||
implements(iwokkel.IDisco)
|
||||
|
|
|
|||
Loading…
Reference in a new issue