def subscription(self, e): iq = Stanza.get_iq(self.client.jid, u"firehoser.superfeedr.com") E(u"query", namespace=XMPP_DISCO_ITEMS_NS, parent=iq, attributes={u'node': e.get_attribute_value('node')}) self.client.send_stanza(iq)
def fetch(self, e): stanza_id = generate_unique() iq = Stanza.get_iq(self.client.jid, u"firehoser.superfeedr.com", stanza_id=stanza_id) pubsub = E(u"pubsub", namespace=XMPP_PUBSUB_NS, parent=iq) A(u"superfeedr", prefix=u"xmlns", namespace=XMLNS_NS, parent=pubsub, value=u"http://superfeedr.com/xmpp-pubsub-ext") sub = E(u"subscriptions", attributes={u"jid": unicode(self.client.jid)}, parent=pubsub, namespace=XMPP_PUBSUB_NS) A(u"page", value=u"1", prefix=u"superfeedr", parent=sub, namespace=u"http://superfeedr.com/xmpp-pubsub-ext") self.client.register_on_iq(self.subscriptions, type="result", id=stanza_id, once=True) self.client.send_stanza(iq)
def ask_roster(self): """ Creates and returns the IQ stanza to query the entity's roster. """ iq = Stanza.get_iq(from_jid=unicode(self.jid), stanza_id=generate_unique()) E(u'query', namespace=XMPP_ROSTER_NS, parent=iq) return iq
def register(self, e): """ Handler called when the `<register xmlns="http://jabber.org/features/iq-register" />` stanza is received and the client required the registration process. Returns a stanza indicating the client is indeed requesting the registration process from the server. ``e`` :class:`bridge.Element` instance representing the dispatched stanza """ iq = Stanza.get_iq(stanza_id=generate_unique()) E(u'register', namespace=XMPP_IBR_NS, parent=iq) return iq
def subscriptions(self, e): iq = Stanza.get_iq(self.client.jid, u"firehoser.superfeedr.com") E(u"query", namespace=XMPP_DISCO_ITEMS_NS, parent=iq) self.client.send_stanza(iq)
def register(self, e): iq = Stanza.get_iq(stanza_id=generate_unique()) E(u'register', namespace=XMPP_IBR_NS, parent=iq) self.client.send_stanza(iq)
def test_uniq_id(self): xml1 = Stanza.get_iq().xml() xml2 = Stanza.get_iq().xml() self.assertNotEqual(xml1, xml2)
def test_get_iq(self): stanza = Stanza.get_iq(from_jid="bob", to_jid="alice", stanza_id="i") xml = """<?xml version="1.0" encoding="UTF-8"?> <iq xmlns="jabber:client" to="alice" type="get" id="i" from="bob" />""" self.assertEqual(stanza.xml(), xml)