Mercurial > libervia-pubsub
view idavoll/idavoll.py @ 7:a8cfb31dc50c
Implemented fallback for feature-not-implemented.
Implemented custom response for subscription options and node configuration
not implemented.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Sun, 27 Jun 2004 15:08:24 +0000 |
parents | 4cc41776b7d7 |
children | 688992a789e4 |
line wrap: on
line source
from twisted.protocols.jabber import component from twisted.application import service import backend import pubsub import xmpp_error import sys IQ_GET = '/iq[@type="get"]' IQ_SET = '/iq[@type="set"]' VERSION = IQ_GET + '/query[@xmlns="jabber:iq:version"]' class IdavollService(component.Service): def componentConnected(self, xmlstream): self.xmlstream = xmlstream xmlstream.addObserver(VERSION, self.onVersion, 1) xmlstream.addObserver(IQ_GET, self.iqFallback, -1) xmlstream.addObserver(IQ_SET, self.iqFallback, -1) def onVersion(self, iq): print "version?" iq.swapAttributeValues("to", "from") iq["type"] = "result" name = iq.addElement("name", None, 'Idavoll') version = iq.addElement("version", None, '0.1') self.send(iq) iq.handled = True def iqFallback(self, iq): if iq.handled == True: return self.send(xmpp_error.error_from_iq(iq, 'feature-not-implemented')) def makeService(config): serviceCollection = service.MultiService() pss = backend.MemoryBackendService() # set up Jabber Component c = component.buildServiceManager(config["jid"], config["secret"], ("tcp:%s:%s" % (config["rhost"], config["rport"]))) s = component.IService(pss) s.jid = config["jid"] s.setServiceParent(c) s = IdavollService() s.setServiceParent(c) c.setServiceParent(serviceCollection) # other stuff return c