diff 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
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0060.py	Fri Aug 21 17:08:26 2015 +0200
+++ b/src/plugins/plugin_xep_0060.py	Fri Aug 21 17:09:43 2015 +0200
@@ -21,6 +21,7 @@
 from sat.core.constants import Const as C
 from sat.core.log import getLogger
 log = getLogger(__name__)
+from sat.core import exceptions
 
 from sat.tools import sat_defer
 
@@ -102,6 +103,20 @@
         else:
             client.pubsub_service = None
 
+    def getFeatures(self, profile):
+        try:
+            client = self.host.getClient(profile)
+        except exceptions.ProfileNotSetError:
+            return {}
+        try:
+            return {'service': client.pubsub_service.full() if client.pubsub_service is not None else  ''}
+        except AttributeError:
+            if self.host.isConnected(profile):
+                log.debug("Profile is not connected, service is not checked yet")
+            else:
+                log.error("Service should be available !")
+            return {}
+
     def parseExtra(self, extra):
         """Parse extra dictionnary