Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0060.py @ 1367:f71a0fc26886
merged branch frontends_multi_profiles
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 18 Mar 2015 10:52:28 +0100 |
parents | 74d558e6c9fd faa1129559b8 |
children | 069ad98b360d |
comparison
equal
deleted
inserted
replaced
1295:1e3b1f9ad6e2 | 1367:f71a0fc26886 |
---|---|
53 OPT_SUBSCRIPTION_DEPTH = 'pubsub#subscription_depth' | 53 OPT_SUBSCRIPTION_DEPTH = 'pubsub#subscription_depth' |
54 OPT_ROSTER_GROUPS_ALLOWED = 'pubsub#roster_groups_allowed' | 54 OPT_ROSTER_GROUPS_ALLOWED = 'pubsub#roster_groups_allowed' |
55 OPT_PUBLISH_MODEL = 'pubsub#publish_model' | 55 OPT_PUBLISH_MODEL = 'pubsub#publish_model' |
56 | 56 |
57 def __init__(self, host): | 57 def __init__(self, host): |
58 log.info(_("PubSub plugin initialization")) | 58 log.info(_(u"PubSub plugin initialization")) |
59 self.host = host | 59 self.host = host |
60 self.managedNodes = [] | 60 self.managedNodes = [] |
61 self.clients = {} | 61 self.clients = {} |
62 self.node_cache = Sessions(timeout=60, resettable_timeout=False) | 62 self.node_cache = Sessions(timeout=60, resettable_timeout=False) |
63 | 63 |
200 profile, client = self.__getClientNProfile(profile_key, 'get items') | 200 profile, client = self.__getClientNProfile(profile_key, 'get items') |
201 found_nodes = yield self.listNodes(service, profile=profile) | 201 found_nodes = yield self.listNodes(service, profile=profile) |
202 d_dict = {} | 202 d_dict = {} |
203 for publisher, node in data.items(): | 203 for publisher, node in data.items(): |
204 if node not in found_nodes: | 204 if node not in found_nodes: |
205 log.debug("Skip the items retrieval for [{node}]: node doesn't exist".format(node=node)) | 205 log.debug(u"Skip the items retrieval for [{node}]: node doesn't exist".format(node=node)) |
206 continue # avoid pubsub "item-not-found" error | 206 continue # avoid pubsub "item-not-found" error |
207 d_dict[publisher] = self.getItems(service, node, max_items, None, sub_id, rsm, profile) | 207 d_dict[publisher] = self.getItems(service, node, max_items, None, sub_id, rsm, profile) |
208 defer.returnValue(d_dict) | 208 defer.returnValue(d_dict) |
209 | 209 |
210 def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None, profile_key=C.PROF_KEY_NONE): | 210 def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None, profile_key=C.PROF_KEY_NONE): |
246 found_nodes = yield self.listNodes(service, profile=profile) | 246 found_nodes = yield self.listNodes(service, profile=profile) |
247 subscribed_nodes = yield self.listSubscribedNodes(service, profile=profile) | 247 subscribed_nodes = yield self.listSubscribedNodes(service, profile=profile) |
248 d_list = [] | 248 d_list = [] |
249 for nodeIdentifier in (set(nodeIdentifiers) - set(subscribed_nodes)): | 249 for nodeIdentifier in (set(nodeIdentifiers) - set(subscribed_nodes)): |
250 if nodeIdentifier not in found_nodes: | 250 if nodeIdentifier not in found_nodes: |
251 log.debug("Skip the subscription to [{node}]: node doesn't exist".format(node=nodeIdentifier)) | 251 log.debug(u"Skip the subscription to [{node}]: node doesn't exist".format(node=nodeIdentifier)) |
252 continue # avoid sat-pubsub "SubscriptionExists" error | 252 continue # avoid sat-pubsub "SubscriptionExists" error |
253 d_list.append(client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options)) | 253 d_list.append(client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options)) |
254 defer.returnValue(d_list) | 254 defer.returnValue(d_list) |
255 | 255 |
256 def subscriptions(self, service, nodeIdentifier='', profile_key=C.PROF_KEY_NONE): | 256 def subscriptions(self, service, nodeIdentifier='', profile_key=C.PROF_KEY_NONE): |
276 if event.nodeIdentifier == node[0]: | 276 if event.nodeIdentifier == node[0]: |
277 node[1](event, self.parent.profile) | 277 node[1](event, self.parent.profile) |
278 | 278 |
279 def deleteReceived(self, event): | 279 def deleteReceived(self, event): |
280 #TODO: manage delete event | 280 #TODO: manage delete event |
281 log.debug(_("Publish node deleted")) | 281 log.debug(_(u"Publish node deleted")) |
282 | 282 |
283 # def purgeReceived(self, event): | 283 # def purgeReceived(self, event): |
284 | 284 |
285 def subscriptions(self, service, nodeIdentifier, sender=None): | 285 def subscriptions(self, service, nodeIdentifier, sender=None): |
286 """Return the list of subscriptions to the given service and node. | 286 """Return the list of subscriptions to the given service and node. |