comparison src/plugins/plugin_xep_0060.py @ 2206:59d3de85a0cb

plugin XEP-0060: added setNodeAffiliations and its bridge method (psNodeAffiliationsSet)
author Goffi <goffi@goffi.org>
date Sun, 26 Mar 2017 18:06:58 +0200
parents 427391c706eb
children 6a2fa651d7fa
comparison
equal deleted inserted replaced
2205:582359de7268 2206:59d3de85a0cb
88 self.rt_sessions = sat_defer.RTDeferredSessions() 88 self.rt_sessions = sat_defer.RTDeferredSessions()
89 host.bridge.addMethod("psNodeConfigurationGet", ".plugin", in_sign='sss', out_sign='a{ss}', method=self._getNodeConfiguration, async=True) 89 host.bridge.addMethod("psNodeConfigurationGet", ".plugin", in_sign='sss', out_sign='a{ss}', method=self._getNodeConfiguration, async=True)
90 host.bridge.addMethod("psNodeConfigurationSet", ".plugin", in_sign='ssa{ss}s', out_sign='', method=self._setNodeConfiguration, async=True) 90 host.bridge.addMethod("psNodeConfigurationSet", ".plugin", in_sign='ssa{ss}s', out_sign='', method=self._setNodeConfiguration, async=True)
91 host.bridge.addMethod("psAffiliationsGet", ".plugin", in_sign='sss', out_sign='a{ss}', method=self._getAffiliations, async=True) 91 host.bridge.addMethod("psAffiliationsGet", ".plugin", in_sign='sss', out_sign='a{ss}', method=self._getAffiliations, async=True)
92 host.bridge.addMethod("psNodeAffiliationsGet", ".plugin", in_sign='sss', out_sign='a{ss}', method=self._getNodeAffiliations, async=True) 92 host.bridge.addMethod("psNodeAffiliationsGet", ".plugin", in_sign='sss', out_sign='a{ss}', method=self._getNodeAffiliations, async=True)
93 host.bridge.addMethod("psNodeAffiliationsSet", ".plugin", in_sign='ssa{ss}s', out_sign='', method=self._setNodeAffiliations, async=True)
93 host.bridge.addMethod("psDeleteNode", ".plugin", in_sign='sss', out_sign='', method=self._deleteNode, async=True) 94 host.bridge.addMethod("psDeleteNode", ".plugin", in_sign='sss', out_sign='', method=self._deleteNode, async=True)
94 host.bridge.addMethod("psItemGet", ".plugin", in_sign='ssiassa{ss}s', out_sign='(asa{ss})', method=self._getItems, async=True) 95 host.bridge.addMethod("psItemGet", ".plugin", in_sign='ssiassa{ss}s', out_sign='(asa{ss})', method=self._getItems, async=True)
95 host.bridge.addMethod("psRetractItem", ".plugin", in_sign='sssbs', out_sign='', method=self._retractItem, async=True) 96 host.bridge.addMethod("psRetractItem", ".plugin", in_sign='sssbs', out_sign='', method=self._retractItem, async=True)
96 host.bridge.addMethod("psRetractItems", ".plugin", in_sign='ssasbs', out_sign='', method=self._retractItems, async=True) 97 host.bridge.addMethod("psRetractItems", ".plugin", in_sign='ssasbs', out_sign='', method=self._retractItems, async=True)
97 host.bridge.addMethod("psSubscribeToMany", ".plugin", in_sign='a(ss)sa{ss}s', out_sign='s', method=self._subscribeToMany) 98 host.bridge.addMethod("psSubscribeToMany", ".plugin", in_sign='a(ss)sa{ss}s', out_sign='s', method=self._subscribeToMany)
490 491
491 d = request.send(client.xmlstream) 492 d = request.send(client.xmlstream)
492 d.addCallback(cb) 493 d.addCallback(cb)
493 return d 494 return d
494 495
496 def _setNodeAffiliations(self, service_s, nodeIdentifier, affiliations, profile_key=C.PROF_KEY_NONE):
497 client = self.host.getClient(profile_key)
498 affiliations = {jid.JID(jid_): affiliation for jid_, affiliation in affiliations.iteritems()}
499 d = self.setNodeAffiliations(client, jid.JID(service_s) if service_s else None, nodeIdentifier, affiliations)
500 return d
501
502 def setNodeAffiliations(self, client, service, nodeIdentifier, affiliations):
503 """Update affiliations of a node owned by profile
504
505 @param affiliations(dict[jid.JID, unicode]): affiliations to set
506 check https://xmpp.org/extensions/xep-0060.html#affiliations for a list of possible affiliations
507 """
508 request = pubsub.PubSubRequest('affiliationsSet')
509 request.recipient = service
510 request.nodeIdentifier = nodeIdentifier
511 request.affiliations = affiliations
512 d = request.send(client.xmlstream)
513 return d
514
495 def _deleteNode(self, service_s, nodeIdentifier, profile_key): 515 def _deleteNode(self, service_s, nodeIdentifier, profile_key):
496 return self.deleteNode(jid.JID(service_s) if service_s else None, nodeIdentifier, profile_key) 516 return self.deleteNode(jid.JID(service_s) if service_s else None, nodeIdentifier, profile_key)
497 517
498 def deleteNode(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE): 518 def deleteNode(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE):
499 client = self.host.getClient(profile_key) 519 client = self.host.getClient(profile_key)