From 9cf9de2a141df9f4ca71cf0282cec79625d52747 Mon Sep 17 00:00:00 2001 From: Jefry Lagrange Date: Wed, 25 May 2011 21:24:01 -0400 Subject: [PATCH] Created Acks builder class --- src/common/xmpp/protocol.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/common/xmpp/protocol.py b/src/common/xmpp/protocol.py index 70027e647..e17ac9315 100644 --- a/src/common/xmpp/protocol.py +++ b/src/common/xmpp/protocol.py @@ -143,6 +143,7 @@ NS_DATA_LAYOUT = 'http://jabber.org/protocol/xdata-layout' # XEP-0141 NS_DATA_VALIDATE = 'http://jabber.org/protocol/xdata-validate' # XEP-0122 NS_XMPP_STREAMS = 'urn:ietf:params:xml:ns:xmpp-streams' NS_RECEIPTS = 'urn:xmpp:receipts' +NS_STREAM_MGMT = 'urn:xmpp:sm:3' # XEP-198 xmpp_stream_error_conditions = ''' bad-format -- -- -- The entity has sent XML that cannot be processed. @@ -978,6 +979,35 @@ class Iq(Protocol): iq.setQueryNS(self.getQueryNS()) return iq +class Acks(Node): + """ + Acknowledgement elements for Stream Management + """ + def __init__(self, nsp=NS_STREAM_MGMT): + + + Node.__init__(self, None, {}, [], None, None,False, None) + + self.setNamespace(nsp) + + def buildAnswer(self, handled): # handled is the number of stanzas handled + self.setName('a') + self.setAttr('h', handled) + + def buildRequest(self): + self.setName('r') + + def buildEnable(self, resume=False): + self.setName('enable') + if resume: + self.setAttr('resume', 'true') + + + def buildResume(self, handled, previd): + self.setName('resume') + self.setAttr('h', handled) + self.setAttr('previd', previd) + class ErrorNode(Node): """ XMPP-style error element