Changeset 6:283b6997cf7d


Ignore:
Timestamp:
Oct 4, 2007, 9:47:22 AM (14 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@13
Message:

Support services on a JID.

Author: ralphm
Fixes #2.

Location:
wokkel
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • wokkel/component.py

    r1 r6  
    2828            if domish.IElement.providedBy(obj) and \
    2929                    not obj.getAttribute('from'):
    30                 obj['from'] = self.xmlstream.thisHost
     30                obj['from'] = self.xmlstream.thisEntity.full()
    3131            old_send(obj)
    3232
  • wokkel/disco.py

    r5 r6  
    8585
    8686    def _onDiscoInfo(self, iq):
     87        requestor = jid.internJID(iq["from"])
    8788        target = jid.internJID(iq["to"])
    88         requestor = jid.internJID(iq["from"])
    8989        nodeIdentifier = iq.query.getAttribute("node")
    9090
     
    107107        for handler in self.parent:
    108108            if IDisco.providedBy(handler):
    109                 dl.append(handler.getDiscoInfo(target, requestor,
     109                dl.append(handler.getDiscoInfo(requestor, target,
    110110                                               nodeIdentifier))
    111111
     
    115115
    116116    def _onDiscoItems(self, iq):
     117        requestor = jid.internJID(iq["from"])
    117118        target = jid.internJID(iq["to"])
    118         requestor = jid.internJID(iq["from"])
    119119        nodeIdentifier = iq.query.getAttribute("node")
    120120
     
    134134        for handler in self.parent:
    135135            if IDisco.providedBy(handler):
    136                 dl.append(handler.getDiscoItems(target, requestor,
     136                dl.append(handler.getDiscoItems(requestor, target,
    137137                                                nodeIdentifier))
    138138
  • wokkel/generic.py

    r2 r6  
    6868        iq.handled = True
    6969
    70     def getDiscoInfo(self, target, requestor, node):
     70    def getDiscoInfo(self, requestor, target, node):
    7171        if not node:
    7272            return defer.succeed(set([disco.DiscoFeature(NS_VERSION)]))
    7373
    74     def getDiscoItems(self, target, requestor, node):
     74    def getDiscoItems(self, requestor, target, node):
    7575        return defer.succeed([])
  • wokkel/iwokkel.py

    r4 r6  
    105105    """
    106106
    107     def getDiscoInfo(target, requestor, nodeIdentifier=None):
     107    def getDiscoInfo(requestor, target, nodeIdentifier=None):
    108108        """
    109109        Get identity and features from this entity, node.
     
    111111        @param requestor: The entity the request originated from.
    112112        @type requestor: L{jid.JID}
     113        @param target: The target entity to which the request is made.
     114        @type target: L{jid.JID}
    113115        @param nodeIdentifier: The optional identifier of the node at this
    114116                               entity to retrieve the identify and features of.
     
    117119        """
    118120
    119     def getDiscoItems(target, requestor, nodeIdentifier=None):
     121    def getDiscoItems(requestor, target, nodeIdentifier=None):
    120122        """
    121123        Get contained items for this entity, node.
     
    123125        @param requestor: The entity the request originated from.
    124126        @type requestor: L{jid.JID}
     127        @param target: The target entity to which the request is made.
     128        @type target: L{jid.JID}
    125129        @param nodeIdentifier: The optional identifier of the node at this
    126130                               entity to retrieve the identify and features of.
     
    132136class IPubSubClient(Interface):
    133137
    134     def itemsReceived(notifier, node, items):
     138    def itemsReceived(recipient, service, nodeIdentifier, items):
    135139        """
    136140        Called when items have been received from a node.
    137141
    138         @param notifier: the entity from which the notification was received.
    139         @type notifier: L{jid.JID}
    140         @param node: identifier of the node the items belong to.
    141         @type node: C{unicode}
    142         @param items: list of received items as domish elements.
     142        @param recipient: The entity to which the notification was sent.
     143        @type recipient: L{jid.JID}
     144        @param service: The entity from which the notification was received.
     145        @type service: L{jid.JID}
     146        @param nodeIdentifier: Identifier of the node the items belong to.
     147        @type nodeIdentifier: C{unicode}
     148        @param items: List of received items as domish elements.
    143149        @type items: C{list} of L{domish.Element}
    144150        """
    145151
    146     def createNode(node=None):
     152    def createNode(service, nodeIdentifier=None):
    147153        """
    148154        Create a new publish subscribe node.
    149155
    150         @param node: optional suggestion for the new node's identifier. If
    151                      omitted, the creation of an instant node will be
    152                      attempted.
    153         @type node: L{unicode}
     156        @param service: The publish-subscribe service entity.
     157        @type service: L{jid.JID}
     158        @param nodeIdentifier: Optional suggestion for the new node's
     159                               identifier. If omitted, the creation of an
     160                               instant node will be attempted.
     161        @type nodeIdentifier: L{unicode}
    154162        @return: a deferred that fires with the identifier of the newly created
    155163                 node. Note that this can differ from the suggested identifier
     
    159167        """
    160168
    161     def deleteNode(node):
     169    def deleteNode(service, nodeIdentifier):
    162170        """
    163171        Delete a node.
    164172
    165         @param node: identifier of the node to be deleted.
    166         @type node: L{unicode}
    167         @rtype: L{defer.Deferred}
    168         """
    169 
    170     def subscribe(node, subscriber):
     173        @param service: The publish-subscribe service entity.
     174        @type service: L{jid.JID}
     175        @param nodeIdentifier: Identifier of the node to be deleted.
     176        @type nodeIdentifier: L{unicode}
     177        @rtype: L{defer.Deferred}
     178        """
     179
     180    def subscribe(service, nodeIdentifier, subscriber):
    171181        """
    172182        Subscribe to a node with a given JID.
    173183
    174         @param node: identifier of the node to subscribe to.
    175         @type node: L{unicode}
     184        @param service: The publish-subscribe service entity.
     185        @type service: L{jid.JID}
     186        @param nodeIdentifier: Identifier of the node to subscribe to.
     187        @type nodeIdentifier: L{unicode}
    176188        @param subscriber: JID to subscribe to the node.
    177189        @type subscriber: L{jid.JID}
     
    179191        """
    180192
    181     def publish(requestor, node, items=[]):
     193    def publish(service, nodeIdentifier, items=[]):
    182194        """
    183195        Publish to a node.
     
    187199        actions only signify a change in some resource.
    188200
    189         @param node: identifier of the node to publish to.
    190         @type node: L{unicode}
    191         @param items: list of item elements.
     201        @param service: The publish-subscribe service entity.
     202        @type service: L{jid.JID}
     203        @param nodeIdentifier: Identifier of the node to publish to.
     204        @type nodeIdentifier: L{unicode}
     205        @param items: List of item elements.
    192206        @type items: L{list} of L{Item}
    193207        @rtype: L{defer.Deferred}
     
    205219    """
    206220
    207     def notifyPublish(entity, nodeIdentifier, notifications):
     221    def notifyPublish(service, nodeIdentifier, notifications):
    208222        """
    209223        Send out notifications for a publish event.
    210224
    211         @param entity: The entity the notifications will originate from.
    212         @type entity: L{jid.JID}
     225        @param service: The entity the notifications will originate from.
     226        @type service: L{jid.JID}
    213227        @param nodeIdentifier: The identifier of the node that was published
    214228                               to.
     
    220234        """
    221235
    222     def publish(requestor, nodeIdentifier, items):
     236    def publish(requestor, service, nodeIdentifier, items):
    223237        """
    224238        Called when a publish request has been received.
     
    226240        @param requestor: The entity the request originated from.
    227241        @type requestor: L{jid.JID}
     242        @param service: The entity the request was addressed to.
     243        @type service: L{jid.JID}
    228244        @param nodeIdentifier: The identifier of the node to publish to.
    229245        @type nodeIdentifier: C{unicode}
     
    234250        """
    235251
    236     def subscribe(requestor, nodeIdentifier, subscriber):
     252    def subscribe(requestor, service, nodeIdentifier, subscriber):
    237253        """
    238254        Called when a subscribe request has been received.
     
    240256        @param requestor: The entity the request originated from.
    241257        @type requestor: L{jid.JID}
     258        @param service: The entity the request was addressed to.
     259        @type service: L{jid.JID}
    242260        @param nodeIdentifier: The identifier of the node to subscribe to.
    243261        @type nodeIdentifier: C{unicode}
     
    249267        """
    250268
    251     def unsubscribe(requestor, nodeIdentifier, subscriber):
     269    def unsubscribe(requestor, service, nodeIdentifier, subscriber):
    252270        """
    253271        Called when a subscribe request has been received.
     
    255273        @param requestor: The entity the request originated from.
    256274        @type requestor: L{jid.JID}
     275        @param service: The entity the request was addressed to.
     276        @type service: L{jid.JID}
    257277        @param nodeIdentifier: The identifier of the node to unsubscribe from.
    258278        @type nodeIdentifier: C{unicode}
     
    264284        """
    265285
    266     def subscriptions(requestor):
     286    def subscriptions(requestor, service):
    267287        """
    268288        Called when a subscriptions retrieval request has been received.
     
    270290        @param requestor: The entity the request originated from.
    271291        @type requestor: L{jid.JID}
     292        @param service: The entity the request was addressed to.
     293        @type service: L{jid.JID}
    272294        @return: A deferred that fires with a C{list} of suscriptions as
    273295                 C{tuple}s of (node identifier as C{unicode}, subscriber as
     
    277299        """
    278300
    279     def affiliations(requestor):
     301    def affiliations(requestor, service):
    280302        """
    281303        Called when a affiliations retrieval request has been received.
     
    283305        @param requestor: The entity the request originated from.
    284306        @type requestor: L{jid.JID}
     307        @param service: The entity the request was addressed to.
     308        @type service: L{jid.JID}
    285309        @return: A deferred that fires with a C{list} of affiliations as
    286310                 C{tuple}s of (node identifier as C{unicode}, affiliation state
     
    290314        """
    291315
    292     def create(requestor, nodeIdentifier):
     316    def create(requestor, service, nodeIdentifier):
    293317        """
    294318        Called when a node creation request has been received.
     
    296320        @param requestor: The entity the request originated from.
    297321        @type requestor: L{jid.JID}
     322        @param service: The entity the request was addressed to.
     323        @type service: L{jid.JID}
    298324        @param nodeIdentifier: The suggestion for the identifier of the node to
    299325                               be created. If the request did not include a
     
    306332        """
    307333
    308     def getDefaultConfiguration(requestor):
     334    def getDefaultConfiguration(requestor, service):
    309335        """
    310336        Called when a default node configuration request has been received.
     
    312338        @param requestor: The entity the request originated from.
    313339        @type requestor: L{jid.JID}
     340        @param service: The entity the request was addressed to.
     341        @type service: L{jid.JID}
    314342        @return: A deferred that fires with a C{dict} representing the default
    315343                 node configuration. Keys are C{str}s that represent the
     
    319347        """
    320348
    321     def getConfiguration(requestor, nodeIdentifier):
     349    def getConfiguration(requestor, service, nodeIdentifier):
    322350        """
    323351        Called when a node configuration retrieval request has been received.
     
    325353        @param requestor: The entity the request originated from.
    326354        @type requestor: L{jid.JID}
     355        @param service: The entity the request was addressed to.
     356        @type service: L{jid.JID}
    327357        @param nodeIdentifier: The identifier of the node to retrieve the
    328358                               configuration from.
     
    334364        """
    335365
    336     def setConfiguration(requestor, nodeIdentifier, options):
     366    def setConfiguration(requestor, service, nodeIdentifier, options):
    337367        """
    338368        Called when a node configuration change request has been received.
     
    340370        @param requestor: The entity the request originated from.
    341371        @type requestor: L{jid.JID}
     372        @param service: The entity the request was addressed to.
     373        @type service: L{jid.JID}
    342374        @param nodeIdentifier: The identifier of the node to change the
    343375                               configuration of.
     
    348380        """
    349381
    350     def items(requestor, nodeIdentifier, maxItems, itemIdentifiers):
     382    def items(requestor, service, nodeIdentifier, maxItems, itemIdentifiers):
    351383        """
    352384        Called when a items retrieval request has been received.
     
    354386        @param requestor: The entity the request originated from.
    355387        @type requestor: L{jid.JID}
     388        @param service: The entity the request was addressed to.
     389        @type service: L{jid.JID}
    356390        @param nodeIdentifier: The identifier of the node to retrieve items
    357391                               from.
     
    359393        """
    360394
    361     def retract(requestor, nodeIdentifier, itemIdentifiers):
     395    def retract(requestor, service, nodeIdentifier, itemIdentifiers):
    362396        """
    363397        Called when a item retraction request has been received.
     
    365399        @param requestor: The entity the request originated from.
    366400        @type requestor: L{jid.JID}
     401        @param service: The entity the request was addressed to.
     402        @type service: L{jid.JID}
    367403        @param nodeIdentifier: The identifier of the node to retract items
    368404                               from.
     
    370406        """
    371407
    372     def purge(requestor, nodeIdentifier):
     408    def purge(requestor, service, nodeIdentifier):
    373409        """
    374410        Called when a node purge request has been received.
     
    376412        @param requestor: The entity the request originated from.
    377413        @type requestor: L{jid.JID}
     414        @param service: The entity the request was addressed to.
     415        @type service: L{jid.JID}
    378416        @param nodeIdentifier: The identifier of the node to be purged.
    379417        @type nodeIdentifier: C{unicode}
    380418        """
    381419
    382     def delete(requestor, nodeIdentifier):
     420    def delete(requestor, service, nodeIdentifier):
    383421        """
    384422        Called when a node deletion request has been received.
     
    386424        @param requestor: The entity the request originated from.
    387425        @type requestor: L{jid.JID}
     426        @param service: The entity the request was addressed to.
     427        @type service: L{jid.JID}
    388428        @param nodeIdentifier: The identifier of the node to be delete.
    389429        @type nodeIdentifier: C{unicode}
    390430        """
    391 
    392 
  • wokkel/pubsub.py

    r2 r6  
    222222    def _onItems(self, message):
    223223        try:
    224             notifier = jid.JID(message["from"])
    225             node = message.event.items["node"]
     224            service = jid.JID(message["from"])
     225            recipient = jid.JID(message["to"])
     226            nodeIdentifier = message.event.items["node"]
    226227        except KeyError:
    227228            return
     
    230231                         if element.name == 'item']
    231232
    232         self.itemsReceived(notifier, node, items)
    233 
    234     def itemsReceived(self, notifier, node, items):
     233        self.itemsReceived(recipient, service, nodeIdentifier, items)
     234
     235    def itemsReceived(self, recipient, service, nodeIdentifier, items):
    235236        pass
    236237
    237     def createNode(self, service, node=None):
    238         request = CreateNode(self.xmlstream, node)
     238    def createNode(self, service, nodeIdentifier=None):
     239        request = CreateNode(self.xmlstream, nodeIdentifier)
    239240
    240241        def cb(iq):
     
    243244            except AttributeError:
    244245                # the suggested node identifier was accepted
    245                 new_node = node
     246                new_node = nodeIdentifier
    246247            return new_node
    247248
    248249        return request.send(service).addCallback(cb)
    249250
    250     def deleteNode(self, service, node):
    251         return DeleteNode(self.xmlstream, node).send(service)
    252 
    253     def subscribe(self, service, node, subscriber):
    254         request = Subscribe(self.xmlstream, node, subscriber)
     251    def deleteNode(self, service, nodeIdentifier):
     252        return DeleteNode(self.xmlstream, nodeIdentifier).send(service)
     253
     254    def subscribe(self, service, nodeIdentifier, subscriber):
     255        request = Subscribe(self.xmlstream, nodeIdentifier, subscriber)
    255256
    256257        def cb(iq):
     
    269270        return request.send(service).addCallback(cb)
    270271
    271     def publish(self, service, node, items=[]):
    272         request = Publish(self.xmlstream, node)
     272    def publish(self, service, nodeIdentifier, items=[]):
     273        request = Publish(self.xmlstream, nodeIdentifier)
    273274        for item in items:
    274275            request.command.addChild(item)
     
    343344        self.xmlstream.addObserver(PUBSUB_OWNER_SET, self.handleRequest)
    344345
    345     def getDiscoInfo(self, target, requestor, nodeIdentifier):
     346    def getDiscoInfo(self, requestor, target, nodeIdentifier):
    346347        info = []
    347348
     
    379380            return d
    380381
    381     def getDiscoItems(self, target, requestor, nodeIdentifier):
     382    def getDiscoItems(self, requestor, target, nodeIdentifier):
    382383        if nodeIdentifier or self.hideNodes:
    383384            return defer.succeed([])
     
    390391    def _onPublish(self, iq):
    391392        requestor = jid.internJID(iq["from"]).userhostJID()
     393        service = jid.internJID(iq["to"])
    392394
    393395        try:
     
    401403                items.append(element)
    402404
    403         return self.publish(requestor, nodeIdentifier, items)
     405        return self.publish(requestor, service, nodeIdentifier, items)
    404406
    405407    def _onSubscribe(self, iq):
    406408        requestor = jid.internJID(iq["from"]).userhostJID()
     409        service = jid.internJID(iq["to"])
    407410
    408411        try:
     
    421424            return response
    422425
    423         d = self.subscribe(requestor, nodeIdentifier, subscriber)
     426        d = self.subscribe(requestor, service, nodeIdentifier, subscriber)
    424427        d.addCallback(toResponse)
    425428        return d
     
    427430    def _onUnsubscribe(self, iq):
    428431        requestor = jid.internJID(iq["from"]).userhostJID()
     432        service = jid.internJID(iq["to"])
    429433
    430434        try:
     
    434438            raise BadRequest
    435439
    436         return self.unsubscribe(requestor, nodeIdentifier, subscriber)
     440        return self.unsubscribe(requestor, service, nodeIdentifier, subscriber)
    437441
    438442    def _onOptionsGet(self, iq):
     
    444448    def _onSubscriptions(self, iq):
    445449        requestor = jid.internJID(iq["from"]).userhostJID()
     450        service = jid.internJID(iq["to"])
    446451
    447452        def toResponse(result):
     
    455460            return response
    456461
    457         d = self.subscriptions(requestor)
     462        d = self.subscriptions(requestor, service)
    458463        d.addCallback(toResponse)
    459464        return d
     
    461466    def _onAffiliations(self, iq):
    462467        requestor = jid.internJID(iq["from"]).userhostJID()
     468        service = jid.internJID(iq["to"])
    463469
    464470        def toResponse(result):
     
    473479            return response
    474480
    475         d = self.affiliations(requestor)
     481        d = self.affiliations(requestor, service)
    476482        d.addCallback(toResponse)
    477483        return d
     
    479485    def _onCreate(self, iq):
    480486        requestor = jid.internJID(iq["from"]).userhostJID()
     487        service = jid.internJID(iq["to"])
    481488        nodeIdentifier = iq.pubsub.create.getAttribute("node")
    482489
     
    490497                return None
    491498
    492         d = self.create(requestor, nodeIdentifier)
     499        d = self.create(requestor, service, nodeIdentifier)
    493500        d.addCallback(toResponse)
    494501        return d
     
    504511    def _onDefault(self, iq):
    505512        requestor = jid.internJID(iq["from"]).userhostJID()
     513        service = jid.internJID(iq["to"])
    506514
    507515        def toResponse(options):
     
    511519            return response
    512520
    513         d = self.getDefaultConfiguration(requestor)
     521        d = self.getDefaultConfiguration(requestor, service)
    514522        d.addCallback(toResponse)
    515523        return d
     
    517525    def _onConfigureGet(self, iq):
    518526        requestor = jid.internJID(iq["from"]).userhostJID()
     527        service = jid.internJID(iq["to"])
    519528        nodeIdentifier = iq.pubsub.configure.getAttribute("node")
    520529
     
    529538            return response
    530539
    531         d = self.getConfiguration(requestor, nodeIdentifier)
     540        d = self.getConfiguration(requestor, service, nodeIdentifier)
    532541        d.addCallback(toResponse)
    533542        return d
     
    535544    def _onConfigureSet(self, iq):
    536545        requestor = jid.internJID(iq["from"]).userhostJID()
     546        service = jid.internJID(iq["to"])
    537547        nodeIdentifier = iq.pubsub.configure["node"]
    538548
     
    566576            if options["FORM_TYPE"] == NS_PUBSUB + "#node_config":
    567577                del options["FORM_TYPE"]
    568                 return self.setConfiguration(requestor, nodeIdentifier,
    569                                              options)
     578                return self.setConfiguration(requestor, service,
     579                                             nodeIdentifier, options)
    570580
    571581        raise BadRequest
     
    573583    def _onItems(self, iq):
    574584        requestor = jid.internJID(iq["from"]).userhostJID()
     585        service = jid.internJID(iq["to"])
    575586
    576587        try:
     
    605616            return response
    606617
    607         d = self.items(requestor, nodeIdentifier, maxItems, itemIdentifiers)
     618        d = self.items(requestor, service, nodeIdentifier, maxItems,
     619                       itemIdentifiers)
    608620        d.addCallback(toResponse)
    609621        return d
     
    611623    def _onRetract(self, iq):
    612624        requestor = jid.internJID(iq["from"]).userhostJID()
     625        service = jid.internJID(iq["to"])
    613626
    614627        try:
     
    625638                    raise BadRequest
    626639
    627         return self.retract(requestor, nodeIdentifier, itemIdentifiers)
     640        return self.retract(requestor, service, nodeIdentifier,
     641                            itemIdentifiers)
    628642
    629643    def _onPurge(self, iq):
    630644        requestor = jid.internJID(iq["from"]).userhostJID()
     645        service = jid.internJID(iq["to"])
    631646
    632647        try:
     
    635650            raise BadRequest
    636651
    637         return self.purge(requestor, nodeIdentifier)
     652        return self.purge(requestor, service, nodeIdentifier)
    638653
    639654    def _onDelete(self, iq):
    640655        requestor = jid.internJID(iq["from"]).userhostJID()
     656        service = jid.internJID(iq["to"])
    641657
    642658        try:
     
    645661            raise BadRequest
    646662
    647         return self.delete(requestor, nodeIdentifier)
     663        return self.delete(requestor, service, nodeIdentifier)
    648664
    649665    def _onAffiliationsGet(self, iq):
     
    661677    # public methods
    662678
    663     def notifyPublish(self, entity, nodeIdentifier, notifications):
     679    def notifyPublish(self, service, nodeIdentifier, notifications):
    664680
    665681        print notifications
    666682        for recipient, items in notifications:
    667683            message = domish.Element((None, "message"))
    668             message["from"] = entity.full()
     684            message["from"] = service.full()
    669685            message["to"] = recipient.full()
    670686            event = message.addElement((NS_PUBSUB_EVENT, "event"))
     
    674690            self.send(message)
    675691
    676     def getNodeInfo(self, requestor, nodeIdentifier):
     692    def getNodeInfo(self, requestor, service, nodeIdentifier):
    677693        return None
    678694
    679     def getNodes(self, requestor):
     695    def getNodes(self, requestor, service):
    680696        return []
    681697
    682     def publish(self, requestor, nodeIdentifier, items):
     698    def publish(self, requestor, service, nodeIdentifier, items):
    683699        raise Unsupported('publish')
    684700
    685     def subscribe(self, requestor, nodeIdentifier, subscriber):
     701    def subscribe(self, requestor, service, nodeIdentifier, subscriber):
    686702        raise Unsupported('subscribe')
    687703
    688     def unsubscribe(self, requestor, nodeIdentifier, subscriber):
     704    def unsubscribe(self, requestor, service, nodeIdentifier, subscriber):
    689705        raise Unsupported('subscribe')
    690706
    691     def subscriptions(self, requestor):
     707    def subscriptions(self, requestor, service):
    692708        raise Unsupported('retrieve-subscriptions')
    693709
    694     def affiliations(self, requestor):
     710    def affiliations(self, requestor, service):
    695711        raise Unsupported('retrieve-affiliations')
    696712
    697     def create(self, requestor, nodeIdentifier):
     713    def create(self, requestor, service, nodeIdentifier):
    698714        raise Unsupported('create-nodes')
    699715
    700     def getDefaultConfiguration(self, requestor):
     716    def getDefaultConfiguration(self, requestor, service):
    701717        raise Unsupported('retrieve-default')
    702718
    703     def getConfiguration(self, requestor, nodeIdentifier):
     719    def getConfiguration(self, requestor, service, nodeIdentifier):
    704720        raise Unsupported('config-node')
    705721
    706     def setConfiguration(self, requestor, nodeIdentifier, options):
     722    def setConfiguration(self, requestor, service, nodeIdentifier, options):
    707723        raise Unsupported('config-node')
    708724
    709     def items(self, requestor, nodeIdentifier, maxItems, itemIdentifiers):
     725    def items(self, requestor, service, nodeIdentifier, maxItems,
     726                    itemIdentifiers):
    710727        raise Unsupported('retrieve-items')
    711728
    712     def retract(self, requestor, nodeIdentifier, itemIdentifiers):
     729    def retract(self, requestor, service, nodeIdentifier, itemIdentifiers):
    713730        raise Unsupported('retract-items')
    714731
    715     def purge(self, requestor, nodeIdentifier):
     732    def purge(self, requestor, service, nodeIdentifier):
    716733        raise Unsupported('purge-nodes')
    717734
    718     def delete(self, requestor, nodeIdentifier):
     735    def delete(self, requestor, service, nodeIdentifier):
    719736        raise Unsupported('delete-nodes')
    720 
  • wokkel/test/test_disco.py

    r1 r6  
    77
    88from twisted.internet import defer
    9 from twisted.test import proto_helpers
    109from twisted.trial import unittest
    1110from twisted.words.xish.xmlstream import XmlStreamFactory
     
    2221    implements(disco.IDisco)
    2322
    24     def getDiscoInfo(self, nodeIdentifier):
     23    def getDiscoInfo(self, requestor, target, nodeIdentifier):
    2524        if nodeIdentifier is None:
    2625            return defer.succeed([
    27                 disco.Identity('dummy', 'generic', 'Generic Dummy Entity'),
    28                 disco.Feature('jabber:iq:version')
     26                disco.DiscoIdentity('dummy', 'generic', 'Generic Dummy Entity'),
     27                disco.DiscoFeature('jabber:iq:version')
    2928            ])
    3029        else:
     
    3534        factory = XmlStreamFactory()
    3635        sm = StreamManager(factory)
    37         sm.addHandler(disco.DiscoHandler())
    38         sm.addHandler(DiscoResponder())
     36        disco.DiscoHandler().setHandlerParent(sm)
     37        DiscoResponder().setHandlerParent(sm)
    3938        xs = factory.buildProtocol(None)
    40         xs.transport = proto_helpers.StringTransport()
     39        output = []
     40        xs.send = output.append
    4141        xs.connectionMade()
     42        xs.dispatch(xs, "//event/stream/authd")
    4243        xs.dataReceived("<stream>")
    43         xs.dataReceived("""<iq from='test@example.com' type='get'>
     44        xs.dataReceived("""<iq from='test@example.com' to='example.com'
     45                               type='get'>
    4446                             <query xmlns='%s'/>
    4547                           </iq>""" % NS_DISCO_INFO)
     48        reply = output[0]
     49        self.assertEqual(NS_DISCO_INFO, reply.query.uri)
     50        self.assertEqual(NS_DISCO_INFO, reply.query.identity.uri)
     51        self.assertEqual('dummy', reply.query.identity['category'])
     52        self.assertEqual('generic', reply.query.identity['type'])
     53        self.assertEqual('Generic Dummy Entity', reply.query.identity['name'])
     54        self.assertEqual(NS_DISCO_INFO, reply.query.feature.uri)
     55        self.assertEqual('jabber:iq:version', reply.query.feature['var'])
     56
  • wokkel/test/test_pubsub.py

    r4 r6  
    2626        iq = domish.Element((None, 'iq'))
    2727        iq['from'] = 'user@example.org'
     28        iq['to'] = 'pubsub.example.org'
    2829        iq['type'] = 'set'
    2930        iq.addElement(('http://jabber.org/protocol/pubsub', 'pubsub'))
     
    4546        iq['type'] = 'set'
    4647        iq['from'] = 'user@example.org'
     48        iq['to'] = 'pubsub.example.org'
    4749        iq.addElement(('http://jabber.org/protocol/pubsub', 'pubsub'))
    4850        iq.pubsub.addElement('publish')
     
    5052        handler.handleRequest(iq)
    5153
    52         self.assertEqual((JID('user@example.org'), 'test', []), handler.args)
     54        self.assertEqual((JID('user@example.org'),
     55                          JID('pubsub.example.org'), 'test', []), handler.args)
    5356
    5457    def test_onOptionsGet(self):
     
    5760        iq = domish.Element((None, 'iq'))
    5861        iq['from'] = 'user@example.org'
     62        iq['to'] = 'pubsub.example.org'
    5963        iq['type'] = 'get'
    6064        iq.addElement(('http://jabber.org/protocol/pubsub', 'pubsub'))
Note: See TracChangeset for help on using the changeset viewer.