comparison src/plugins/plugin_xep_0060.py @ 1290:faa1129559b8 frontends_multi_profiles

core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit): /!\ not finished, everything is still instable ! - bridge: DBus bridge has been modified to allow blocking call to be called in the same way as asynchronous calls - bridge: calls with a callback and no errback are now possible, default errback log the error - constants: removed hack to manage presence without OrderedDict, as an OrderedDict like class has been implemented in Libervia - core: getLastResource has been removed and replaced by getMainResource (there is a global better management of resources) - various style improvments: use of constants when possible, fixed variable overlaps, import of module instead of direct class import - frontends: printInfo and printMessage methods in (Quick)Chat are more generic (use of extra instead of timestamp) - frontends: bridge creation and option parsing (command line arguments) are now specified by the frontend in QuickApp __init__ - frontends: ProfileManager manage a more complete plug sequence (some stuff formerly manage in contact_list have moved to ProfileManager) - quick_frontend (quick_widgets): QuickWidgetsManager is now iterable (all widgets are then returned), or can return an iterator on a specific class (return all widgets of this class) with getWidgets - frontends: tools.jid can now be used in Pyjamas, with some care - frontends (XMLUI): profile is now managed - core (memory): big improvment on entities cache management (and specially resource management) - core (params/exceptions): added PermissionError - various fixes and improvments, check diff for more details
author Goffi <goffi@goffi.org>
date Sat, 24 Jan 2015 01:00:29 +0100
parents 93bce9e4c9c8
children f71a0fc26886
comparison
equal deleted inserted replaced
1289:653f2e2eea31 1290:faa1129559b8
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
174 profile, client = self.__getClientNProfile(profile_key, 'get items') 174 profile, client = self.__getClientNProfile(profile_key, 'get items')
175 found_nodes = yield self.listNodes(service, profile=profile) 175 found_nodes = yield self.listNodes(service, profile=profile)
176 d_dict = {} 176 d_dict = {}
177 for publisher, node in data.items(): 177 for publisher, node in data.items():
178 if node not in found_nodes: 178 if node not in found_nodes:
179 log.debug("Skip the items retrieval for [{node}]: node doesn't exist".format(node=node)) 179 log.debug(u"Skip the items retrieval for [{node}]: node doesn't exist".format(node=node))
180 continue # avoid pubsub "item-not-found" error 180 continue # avoid pubsub "item-not-found" error
181 d_dict[publisher] = client.items(service, node, max_items, item_ids, sub_id, client.parent.jid) 181 d_dict[publisher] = client.items(service, node, max_items, item_ids, sub_id, client.parent.jid)
182 defer.returnValue(d_dict) 182 defer.returnValue(d_dict)
183 183
184 def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None, profile_key=C.PROF_KEY_NONE): 184 def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None, profile_key=C.PROF_KEY_NONE):
220 found_nodes = yield self.listNodes(service, profile=profile) 220 found_nodes = yield self.listNodes(service, profile=profile)
221 subscribed_nodes = yield self.listSubscribedNodes(service, profile=profile) 221 subscribed_nodes = yield self.listSubscribedNodes(service, profile=profile)
222 d_list = [] 222 d_list = []
223 for nodeIdentifier in (set(nodeIdentifiers) - set(subscribed_nodes)): 223 for nodeIdentifier in (set(nodeIdentifiers) - set(subscribed_nodes)):
224 if nodeIdentifier not in found_nodes: 224 if nodeIdentifier not in found_nodes:
225 log.debug("Skip the subscription to [{node}]: node doesn't exist".format(node=nodeIdentifier)) 225 log.debug(u"Skip the subscription to [{node}]: node doesn't exist".format(node=nodeIdentifier))
226 continue # avoid sat-pubsub "SubscriptionExists" error 226 continue # avoid sat-pubsub "SubscriptionExists" error
227 d_list.append(client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options)) 227 d_list.append(client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options))
228 defer.returnValue(d_list) 228 defer.returnValue(d_list)
229 229
230 def subscriptions(self, service, nodeIdentifier='', profile_key=C.PROF_KEY_NONE): 230 def subscriptions(self, service, nodeIdentifier='', profile_key=C.PROF_KEY_NONE):
316 if event.nodeIdentifier == node[0]: 316 if event.nodeIdentifier == node[0]:
317 node[1](event, self.parent.profile) 317 node[1](event, self.parent.profile)
318 318
319 def deleteReceived(self, event): 319 def deleteReceived(self, event):
320 #TODO: manage delete event 320 #TODO: manage delete event
321 log.debug(_("Publish node deleted")) 321 log.debug(_(u"Publish node deleted"))
322 322
323 # def purgeReceived(self, event): 323 # def purgeReceived(self, event):
324 324
325 @defer.inlineCallbacks 325 @defer.inlineCallbacks
326 def subscriptions(self, service, nodeIdentifier, sender=None): 326 def subscriptions(self, service, nodeIdentifier, sender=None):