コード例 #1
0
    def _onDiscoInfo(self, iq):
        requestor = jid.internJID(iq["from"])
        target = jid.internJID(iq["to"])
        nodeIdentifier = iq.query.getAttribute("node", '')

        def toResponse(results):
            info = []
            for i in results:
                info.extend(i[1])

            if nodeIdentifier and not info:
                raise error.StanzaError('item-not-found')
            else:
                response = domish.Element((NS_INFO, 'query'))

                for item in info:
                    response.addChild(item)

            return response

        dl = []
        for handler in self.parent:
            if IDisco.providedBy(handler):
                dl.append(
                    handler.getDiscoInfo(requestor, target, nodeIdentifier))

        d = defer.DeferredList(dl, fireOnOneErrback=1, consumeErrors=1)
        d.addCallbacks(toResponse, self._error)
        return d
コード例 #2
0
    def _onDiscoItems(self, iq):
        requestor = jid.internJID(iq["from"])
        target = jid.internJID(iq["to"])
        nodeIdentifier = iq.query.getAttribute("node", '')

        def toResponse(results):
            items = []
            for i in results:
                items.extend(i[1])

            response = domish.Element((NS_ITEMS, 'query'))

            for item in items:
                response.addChild(item)

            return response

        dl = []
        for handler in self.parent:
            if IDisco.providedBy(handler):
                dl.append(
                    handler.getDiscoItems(requestor, target, nodeIdentifier))

        d = defer.DeferredList(dl, fireOnOneErrback=1, consumeErrors=1)
        d.addCallbacks(toResponse, self._error)
        return d
コード例 #3
0
ファイル: disco.py プロジェクト: Urthen/Legacy-FritBot
    def _onDiscoItems(self, iq):
        requestor = jid.internJID(iq["from"])
        target = jid.internJID(iq["to"])
        nodeIdentifier = iq.query.getAttribute("node", '')

        def toResponse(results):
            items = []
            for i in results:
                items.extend(i[1])

            response = domish.Element((NS_ITEMS, 'query'))

            for item in items:
                response.addChild(item)

            return response

        dl = []
        for handler in self.parent:
            if IDisco.providedBy(handler):
                dl.append(handler.getDiscoItems(requestor, target,
                                                nodeIdentifier))

        d = defer.DeferredList(dl, fireOnOneErrback=1, consumeErrors=1)
        d.addCallbacks(toResponse, self._error)
        return d
コード例 #4
0
ファイル: disco.py プロジェクト: Urthen/Legacy-FritBot
    def _onDiscoInfo(self, iq):
        requestor = jid.internJID(iq["from"])
        target = jid.internJID(iq["to"])
        nodeIdentifier = iq.query.getAttribute("node", '')

        def toResponse(results):
            info = []
            for i in results:
                info.extend(i[1])

            if nodeIdentifier and not info:
                raise error.StanzaError('item-not-found')
            else:
                response = domish.Element((NS_INFO, 'query'))

                for item in info:
                    response.addChild(item)

            return response

        dl = []
        for handler in self.parent:
            if IDisco.providedBy(handler):
                dl.append(handler.getDiscoInfo(requestor, target,
                                               nodeIdentifier))

        d = defer.DeferredList(dl, fireOnOneErrback=1, consumeErrors=1)
        d.addCallbacks(toResponse, self._error)
        return d
コード例 #5
0
    def items(self, requestor, target, nodeIdentifier):
        """
        Inspect all sibling protocol handlers for disco items.

        Calls the L{getDiscoItems<IDisco.getDiscoItems>} method on all child
        handlers of the parent, that provide L{IDisco}.

        @param requestor: The entity that sent the request.
        @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
        @param target: The entity the request was sent to.
        @type target: L{JID<twisted.words.protocols.jabber.jid.JID>}
        @param nodeIdentifier: The optional node being queried, or C{''}.
        @type nodeIdentifier: C{unicode}
        @return: Deferred with the gathered results from sibling handlers.
        @rtype: L{defer.Deferred}
        """
        dl = [defer.maybeDeferred(handler.getDiscoItems, requestor, target,
                                                         nodeIdentifier)
              for handler in self.parent
              if IDisco.providedBy(handler)]
        return self._gatherResults(dl)