def _send_pubsub_conf_request(self,node): query = domish.Element((PUBSUB_OWNER_NS,"pubsub")) query.addChild(domish.Element((None,'configure'),attribs={'node':node.name})) iq = xmlstream.IQ(self.xmlstream,"get") iq.addChild(query) d =iq.send(to=self.component) return d
def start(self): iq = xmlstream.IQ(self.xmlstream, 'set') bind = iq.addElement((NS_XMPP_BIND, 'bind')) resource = self.xmlstream.authenticator.jid.resource if resource: bind.addElement('resource', content=resource) d = iq.send() d.addCallback(self.onBind) return d
def initialize(self): # Send request for auth fields iq = xmlstream.IQ(self.xmlstream, "get") iq.addElement(("jabber:iq:auth", "query")) jid = self.xmlstream.authenticator.jid iq.query.addElement("username", content=jid.user) d = iq.send() d.addCallbacks(self._cbAuthQuery, self._ebAuthQuery) return d
def setUp(self): authenticator = xmlstream.ConnectAuthenticator('otherhost') authenticator.namespace = 'testns' self.xmlstream = xmlstream.XmlStream(authenticator) self.clock = task.Clock() self.xmlstream._callLater = self.clock.callLater self.xmlstream.makeConnection(proto_helpers.StringTransport()) self.xmlstream.dataReceived( "<stream:stream xmlns:stream='http://etherx.jabber.org/streams' " "xmlns='testns' from='otherhost' version='1.0'>") self.iq = xmlstream.IQ(self.xmlstream, 'get')
def setUp(self): self.outlist = [] authenticator = xmlstream.ConnectAuthenticator('otherhost') authenticator.namespace = 'testns' self.xmlstream = xmlstream.XmlStream(authenticator) self.xmlstream.transport = self self.xmlstream.transport.write = self.outlist.append self.xmlstream.connectionMade() self.xmlstream.dataReceived( "<stream:stream xmlns:stream='http://etherx.jabber.org/streams' " "xmlns='testns' from='otherhost' version='1.0'>") self.iq = xmlstream.IQ(self.xmlstream, type='get')
def _send_pubsub_configurtion(self,fields_xml): query = domish.Element((PUBSUB_OWNER_NS,"pubsub")) cfg = domish.Element((None,'configure'),attribs={'node':self.node.name}) query.addChild(cfg) form = domish.Element((JABBER_X_DATA_NS,'x'),attribs={'type':'submit'}) cfg.addChild(form) for field in fields_xml: form.addChild(field) iq = xmlstream.IQ(self.xmlstream,"set") iq.addChild(query) d =iq.send(to=self.component) return d
def test_onFeed(self): """ Test adding a feed through XMPP. """ xc = aggregator.XMPPControl(DummyAggregator()) xc.parent = DummyManager() iq = xmlstream.IQ(None) iq['to'] = '*****@*****.**' iq['from'] = '*****@*****.**' iq.addElement(('http://mimir.ik.nu/protocol/aggregator', 'aggregator')) feed = iq.aggregator.addElement('feed') feed.addElement('handle', content='test') feed.addElement('url', content='http://www.example.org/') xc.onFeed(iq) self.assertEquals(xc.parent.outlist[0]['type'], 'result') self.assertEquals(xc.service.feeds['test'], 'http://www.example.org/')
def _cbAuthQuery(self, iq): jid = self.xmlstream.authenticator.jid password = self.xmlstream.authenticator.password # Construct auth request reply = xmlstream.IQ(self.xmlstream, "set") reply.addElement(("jabber:iq:auth", "query")) reply.query.addElement("username", content = jid.user) reply.query.addElement("resource", content = jid.resource) # Prefer digest over plaintext if DigestAuthQry.matches(iq): digest = xmlstream.hashPassword(self.xmlstream.sid, unicode(password)) reply.query.addElement("digest", content = digest) else: reply.query.addElement("password", content = password) d = reply.send() d.addCallbacks(self._cbAuth, self._ebAuth) return d
def eb(failure): d = xmlstream.IQ(self.xmlstream).send() d.addErrback(eb)
def iq(self, type='get', id=None): r = xmlstream.IQ(self.xmlstream, type) r['from'] = self.host if id is not None: r['id'] = id return r
def start(self): iq = xmlstream.IQ(self.xmlstream, 'set') session = iq.addElement((NS_XMPP_SESSION, 'session')) return iq.send()
def start(self): iq = xmlstream.IQ(self.xmlstream, "set") iq.addElement((NS_XMPP_SESSION, "session")) return iq.send()
def send_iq(self, type, iq_child): iq = xmlstream.IQ(self.xmlstream, type) iq.addChild(iq_child) d = iq.send(to=self.pubsub_component) return d