comparison src/plugins/plugin_xep_0060.py @ 1483:0f0889028eea

plugin XEP-0060: implemented getFeatures, data has a "service" key if service is found for this profile
author Goffi <goffi@goffi.org>
date Fri, 21 Aug 2015 17:09:43 +0200
parents 4c4f88d7b156
children fcfec24c87f3
comparison
equal deleted inserted replaced
1482:80cd55dd5b04 1483:0f0889028eea
19 19
20 from sat.core.i18n import _ 20 from sat.core.i18n import _
21 from sat.core.constants import Const as C 21 from sat.core.constants import Const as C
22 from sat.core.log import getLogger 22 from sat.core.log import getLogger
23 log = getLogger(__name__) 23 log = getLogger(__name__)
24 from sat.core import exceptions
24 25
25 from sat.tools import sat_defer 26 from sat.tools import sat_defer
26 27
27 from twisted.words.protocols.jabber import jid 28 from twisted.words.protocols.jabber import jid
28 from twisted.internet import defer 29 from twisted.internet import defer
99 if pubsub_services: 100 if pubsub_services:
100 # we use one of the found services as our default pubsub service 101 # we use one of the found services as our default pubsub service
101 client.pubsub_service = pubsub_services.pop() 102 client.pubsub_service = pubsub_services.pop()
102 else: 103 else:
103 client.pubsub_service = None 104 client.pubsub_service = None
105
106 def getFeatures(self, profile):
107 try:
108 client = self.host.getClient(profile)
109 except exceptions.ProfileNotSetError:
110 return {}
111 try:
112 return {'service': client.pubsub_service.full() if client.pubsub_service is not None else ''}
113 except AttributeError:
114 if self.host.isConnected(profile):
115 log.debug("Profile is not connected, service is not checked yet")
116 else:
117 log.error("Service should be available !")
118 return {}
104 119
105 def parseExtra(self, extra): 120 def parseExtra(self, extra):
106 """Parse extra dictionnary 121 """Parse extra dictionnary
107 122
108 used bridge's extra dictionnaries 123 used bridge's extra dictionnaries