コード例 #1
0
ファイル: pubsub.py プロジェクト: josejamilena/headstock
    def unsubscribe(self, url=URL):
        stanza_id = generate_unique()
        iq = Stanza.set_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")
        E(u"unsubscribe",
          attributes={
              u"jid": self.client.jid.nodeid(),
              u"node": url
          },
          parent=pubsub,
          namespace=XMPP_PUBSUB_NS)

        self.client.register_on_iq(self.subscribe,
                                   type="result",
                                   id=stanza_id,
                                   once=True)
        self.client.send_stanza(iq)
コード例 #2
0
ファイル: __init__.py プロジェクト: Lawouach/conductor
 def unregister(self):
     stanza_id = generate_unique()
     iq = Stanza.set_iq(stanza_id=stanza_id)
     query = E(u'query', namespace=XMPP_IBR_NS, parent=iq)
     E(u'remove', namespace=XMPP_IBR_NS, parent=query)
     self.client.register_on_iq(self.unregistered, type=u'result',
                                id=stanza_id, once=True)
     self.client.send_stanza(iq)
コード例 #3
0
 def unregister(self):
     stanza_id = generate_unique()
     iq = Stanza.set_iq(stanza_id=stanza_id)
     query = E(u'query', namespace=XMPP_IBR_NS, parent=iq)
     E(u'remove', namespace=XMPP_IBR_NS, parent=query)
     self.client.register_on_iq(self.unregistered,
                                type=u'result',
                                id=stanza_id,
                                once=True)
     self.client.send_stanza(iq)
コード例 #4
0
ファイル: __init__.py プロジェクト: Lawouach/conductor
    def handle_registration(self, e):
        iq = Stanza.set_iq(stanza_id=e.xml_parent.get_attribute_value('id'))
        query = E(u'query', namespace=XMPP_IBR_NS, parent=iq)
        E(u'username', content=self.settings.username, namespace=XMPP_IBR_NS, parent=query)
        E(u'password', content=self.settings.password, namespace=XMPP_IBR_NS, parent=query)

        self.client.register_on_iq(self.registered, type=u'result',
                                   id=e.xml_parent.get_attribute_value('id'), once=True)
        
        self.client.send_stanza(iq)
コード例 #5
0
ファイル: stream.py プロジェクト: AlexSnet/headstock
    def handle_binding(self, e):
        """
        Handle the JID binding request by returning
        the full JID.
        """
        iq = Stanza.set_iq(stanza_id=generate_unique())
        bind = E(u'bind', namespace=XMPP_BIND_NS, parent=iq)
        if self.jid.resource != None:
            E(u'resource', content=self.jid.resource,
              namespace=XMPP_BIND_NS, parent=bind)

        return iq
コード例 #6
0
    def handle_binding(self, e):
        """
        Handle the JID binding request by returning
        the full JID.
        """
        iq = Stanza.set_iq(stanza_id=generate_unique())
        bind = E(u'bind', namespace=XMPP_BIND_NS, parent=iq)
        if self.jid.resource != None:
            E(u'resource',
              content=self.jid.resource,
              namespace=XMPP_BIND_NS,
              parent=bind)

        return iq
コード例 #7
0
ファイル: pubsub.py プロジェクト: AlexSnet/headstock
    def unsubscribe(self, url=URL):
        stanza_id = generate_unique()
        iq = Stanza.set_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")
        E(u"unsubscribe", attributes={u"jid": self.client.jid.nodeid(),
                                      u"node": url},
          parent=pubsub, namespace=XMPP_PUBSUB_NS)

        self.client.register_on_iq(self.subscribe, type="result",
                                   id=stanza_id, once=True)
        self.client.send_stanza(iq)
コード例 #8
0
    def handle_registration(self, e):
        iq = Stanza.set_iq(stanza_id=e.xml_parent.get_attribute_value('id'))
        query = E(u'query', namespace=XMPP_IBR_NS, parent=iq)
        E(u'username',
          content=self.settings.username,
          namespace=XMPP_IBR_NS,
          parent=query)
        E(u'password',
          content=self.settings.password,
          namespace=XMPP_IBR_NS,
          parent=query)

        self.client.register_on_iq(self.registered,
                                   type=u'result',
                                   id=e.xml_parent.get_attribute_value('id'),
                                   once=True)

        self.client.send_stanza(iq)
コード例 #9
0
ファイル: register.py プロジェクト: josejamilena/headstock
    def handle_registration(self, e):
        """
        Handler called when the server sends the registration form and returns the
        same form filled with at least the username and password.
        
        ``e`` :class:`bridge.Element` instance representing the dispatched stanza
        """
        iq = Stanza.set_iq(stanza_id=e.xml_parent.get_attribute_value('id'))
        query = E(u'query', namespace=XMPP_IBR_NS, parent=iq)
        E(u'username', content=self.username, namespace=XMPP_IBR_NS, parent=query)
        E(u'password', content=self.password, namespace=XMPP_IBR_NS, parent=query)
        if self.email:
            E(u'email', content=self.email, namespace=XMPP_IBR_NS, parent=query)

        self.client.register_on_iq(self.handle_register_success, type=u'result',
                                   id=e.xml_parent.get_attribute_value('id'), once=True)
        
        return iq
コード例 #10
0
ファイル: stream.py プロジェクト: AlexSnet/headstock
    def handle_session(self, e):
        """
        Handles the session elements received by the server.

        If the type of the response is `result` it raises
        :class:`headstock.error.HeadstockAuthenticationSuccess` instance
        handled by the client indicating the session is ready.

        Otherwise returns the session stanza indicating the
        client wishes to start a session.
        """
        if e.xml_parent and e.xml_parent.get_attribute_value('type') == 'result':
            raise HeadstockSessionBound()
        
        iq = Stanza.set_iq(stanza_id=generate_unique())
        E(u'session', namespace=XMPP_SESSION_NS, parent=iq)
        
        return iq
コード例 #11
0
    def handle_session(self, e):
        """
        Handles the session elements received by the server.

        If the type of the response is `result` it raises
        :class:`headstock.error.HeadstockAuthenticationSuccess` instance
        handled by the client indicating the session is ready.

        Otherwise returns the session stanza indicating the
        client wishes to start a session.
        """
        if e.xml_parent and e.xml_parent.get_attribute_value(
                'type') == 'result':
            raise HeadstockSessionBound()

        iq = Stanza.set_iq(stanza_id=generate_unique())
        E(u'session', namespace=XMPP_SESSION_NS, parent=iq)

        return iq
コード例 #12
0
ファイル: stanza_test.py プロジェクト: josejamilena/headstock
    def test_set_iq(self):
        stanza = Stanza.set_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="set" id="i" from="bob" />"""
        self.assertEqual(stanza.xml(), xml)