Mercurial > libervia-pubsub
changeset 280:798cb8962c0b
MAM (XEP-0313) support: first draft
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 09 Jan 2015 10:57:10 +0100 |
parents | 7c820a8e4b00 |
children | 30895c49ebd2 |
files | sat_pubsub/const.py sat_pubsub/mam.py sat_pubsub/tap.py |
diffstat | 3 files changed, 70 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/sat_pubsub/const.py Fri Jan 09 10:56:38 2015 +0100 +++ b/sat_pubsub/const.py Fri Jan 09 10:57:10 2015 +0100 @@ -70,3 +70,4 @@ FLAG_RETRACT_ALLOW_PUBLISHER = True # XXX: see the method BackendService._doRetractAllowPublisher FLAG_ENABLE_RSM = True VAL_RSM_MAX_DEFAULT = 10 +FLAG_ENABLE_MAM = True
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sat_pubsub/mam.py Fri Jan 09 10:57:10 2015 +0100 @@ -0,0 +1,63 @@ +#!/usr/bin/python +#-*- coding: utf-8 -*- + +""" +XMPP Message Archive Management protocol. + +This protocol is specified in +U{XEP-0313<http://xmpp.org/extensions/xep-0313.html>}. +""" + +from zope.interface import implements +from wokkel.mam import MAMPrefs, IMAMResource +from wokkel.rsm import RSMResponse + + +class MAMResource(object): + + implements(IMAMResource) + + def onArchiveRequest(self, mam, rsm, requestor): + """ + + @param mam: The MAM <query/> request. + @type mam: L{MAMQueryReques<wokkel.mam.MAMQueryRequest>} + + @param rsm: The RSM request. + @type rsm: L{RSMRequest<wokkel.rsm.RSMRequest>} + + @param requestor: JID of the requestor. + @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>} + + @return: The RSM answer. + @rtype: L{RSMResponse<wokkel.rsm.RSMResponse>} + """ + # TODO: send the archived messages + return RSMResponse() + + def onPrefsGetRequest(self, requestor): + """ + + @param requestor: JID of the requestor. + @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>} + + @return: The current settings. + @rtype: L{wokkel.mam.MAMPrefs} + """ + # TODO: return the actual current settings + return MAMPrefs() + + def onPrefsSetRequest(self, prefs, requestor): + """ + + @param prefs: The new settings to set. + @type prefs: L{wokkel.mam.MAMPrefs} + + @param requestor: JID of the requestor. + @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>} + + @return: The settings that have actually been set. + @rtype: L{wokkel.mam.MAMPrefs} + """ + # TODO: set the new settings and return them + return MAMPrefs()
--- a/sat_pubsub/tap.py Fri Jan 09 10:56:38 2015 +0100 +++ b/sat_pubsub/tap.py Fri Jan 09 10:57:10 2015 +0100 @@ -66,6 +66,7 @@ from sat_pubsub.backend import BackendService from sat_pubsub.remote_roster import RosterClient + class Options(usage.Options): optParameters = [ ('jid', None, 'pubsub', 'JID this component will be available at'), @@ -149,4 +150,9 @@ rc.setHandlerParent(cs) bs.roster = rc + if const.FLAG_ENABLE_MAM: + mam_resource = MAMResource() + mam_s = mam.MAMService(mam_resource) + mam_s.setHandlerParent(cs) + return s