# HG changeset patch # User souliane # Date 1420797430 -3600 # Node ID 798cb8962c0bf970aa7dc2d1fd26e13fd7ff0fa3 # Parent 7c820a8e4b008416abe43c5ab26e5bcd6a0302ef MAM (XEP-0313) support: first draft diff -r 7c820a8e4b00 -r 798cb8962c0b sat_pubsub/const.py --- 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 diff -r 7c820a8e4b00 -r 798cb8962c0b sat_pubsub/mam.py --- /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}. +""" + +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 request. + @type mam: L{MAMQueryReques} + + @param rsm: The RSM request. + @type rsm: L{RSMRequest} + + @param requestor: JID of the requestor. + @type requestor: L{JID} + + @return: The RSM answer. + @rtype: L{RSMResponse} + """ + # TODO: send the archived messages + return RSMResponse() + + def onPrefsGetRequest(self, requestor): + """ + + @param requestor: JID of the requestor. + @type requestor: L{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} + + @return: The settings that have actually been set. + @rtype: L{wokkel.mam.MAMPrefs} + """ + # TODO: set the new settings and return them + return MAMPrefs() diff -r 7c820a8e4b00 -r 798cb8962c0b sat_pubsub/tap.py --- 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