Correctly fake NullClientCaps: Assume we support everything instead of the blacklisted features.
This commit is contained in:
		
							parent
							
								
									da0749b5d9
								
							
						
					
					
						commit
						85a35a21ac
					
				
					 1 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
					@ -47,6 +47,7 @@ FEATURE_BLACKLIST = [NS_CHATSTATES, NS_XHTML_IM, NS_RECEIPTS, NS_ESESSION,
 | 
				
			||||||
NEW = 0
 | 
					NEW = 0
 | 
				
			||||||
QUERIED = 1
 | 
					QUERIED = 1
 | 
				
			||||||
CACHED = 2 # got the answer
 | 
					CACHED = 2 # got the answer
 | 
				
			||||||
 | 
					FAKED = 3 # allow NullClientCaps to behave as it has a cached item
 | 
				
			||||||
 | 
					
 | 
				
			||||||
################################################################################
 | 
					################################################################################
 | 
				
			||||||
### Public API of this module
 | 
					### Public API of this module
 | 
				
			||||||
| 
						 | 
					@ -67,7 +68,7 @@ def client_supports(client_caps, requested_feature):
 | 
				
			||||||
	supported_features = cache_item.features
 | 
						supported_features = cache_item.features
 | 
				
			||||||
	if requested_feature in supported_features:
 | 
						if requested_feature in supported_features:
 | 
				
			||||||
		return True
 | 
							return True
 | 
				
			||||||
	elif supported_features == [] and cache_item.status in (NEW, QUERIED):
 | 
						elif not supported_features and cache_item.status in (NEW, QUERIED, FAKED):
 | 
				
			||||||
		# assume feature is supported, if we don't know yet, what the client
 | 
							# assume feature is supported, if we don't know yet, what the client
 | 
				
			||||||
		# is capable of
 | 
							# is capable of
 | 
				
			||||||
		return requested_feature not in FEATURE_BLACKLIST
 | 
							return requested_feature not in FEATURE_BLACKLIST
 | 
				
			||||||
| 
						 | 
					@ -262,7 +263,7 @@ class NullClientCaps(AbstractClientCaps):
 | 
				
			||||||
		# lookup something which does not exist to get a new CacheItem created
 | 
							# lookup something which does not exist to get a new CacheItem created
 | 
				
			||||||
		cache_item = caps_cache[('dummy', '')]
 | 
							cache_item = caps_cache[('dummy', '')]
 | 
				
			||||||
		# Mark the item as cached so that protocol/caps.py does not update it
 | 
							# Mark the item as cached so that protocol/caps.py does not update it
 | 
				
			||||||
		cache_item.status = CACHED
 | 
							cache_item.status = FAKED
 | 
				
			||||||
		return cache_item
 | 
							return cache_item
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def _discover(self, connection, jid):
 | 
						def _discover(self, connection, jid):
 | 
				
			||||||
| 
						 | 
					@ -354,7 +355,7 @@ class CapsCache(object):
 | 
				
			||||||
				Returns True if identities and features for this cache item
 | 
									Returns True if identities and features for this cache item
 | 
				
			||||||
				are known.
 | 
									are known.
 | 
				
			||||||
				""" 
 | 
									""" 
 | 
				
			||||||
				return self.status == CACHED
 | 
									return self.status in (CACHED, FAKED)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		self.__CacheItem = CacheItem
 | 
							self.__CacheItem = CacheItem
 | 
				
			||||||
		self.logger = logger
 | 
							self.logger = logger
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue