diff sat_pubsub/mam.py @ 280:798cb8962c0b

MAM (XEP-0313) support: first draft
author souliane <souliane@mailoo.org>
date Fri, 09 Jan 2015 10:57:10 +0100
parents
children 30895c49ebd2
line wrap: on
line diff
--- /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()