diff src/tools/memory.py @ 282:6a0c6d8e119d

added plugin xep-0115: entity capabilities
author Goffi <goffi@goffi.org>
date Thu, 03 Feb 2011 01:27:57 +0100
parents a00e87d48213
children 15a12bf2bb62
line wrap: on
line diff
--- a/src/tools/memory.py	Thu Feb 03 01:27:09 2011 +0100
+++ b/src/tools/memory.py	Thu Feb 03 01:27:57 2011 +0100
@@ -397,6 +397,7 @@
         self.params=Param(host)
         self.history={}  #used to store chat history (key: short jid)
         self.private={}  #used to store private value
+        self.server_features={} #used to store discovery's informations
         host.set_const('savefile_history', SAVEFILE_HISTORY)
         host.set_const('savefile_private', SAVEFILE_PRIVATE)
         self.load()
@@ -537,6 +538,23 @@
             return self.private[key]
         return None
 
+    def addServerFeature(self, feature, profile):
+        """Add a feature discovered from server
+        @param feature: string of the feature
+        @param profile: which profile is using this server ?"""
+        if not self.server_features.has_key(profile):
+            self.server_features[profile] = []
+        self.server_features[profile].append(feature)
+
+    def hasServerFeature(self, feature, profile_key='@DEFAULT@'):
+        """Tell if the server of the profile has the required feature"""
+        profile = self.getProfileName(profile_key)
+        if not profile:
+            error (_('Trying find server feature for a non-existant profile'))
+            return
+        assert(self.server_features.has_key(profile))
+        return feature in self.server_features[profile]
+
 
     def addContact(self, contact_jid, attributes, groups, profile_key='@DEFAULT@'):
         debug("Memory addContact: %s",contact_jid.userhost())