tools: renamed tools.jid.JID attribute "short" to "bare"

This commit is contained in:
souliane 2013-10-29 16:26:55 +01:00
commit 36cea6fc91

View file

@ -30,7 +30,7 @@ class QuickContactManagement(object):
self.__contactlist = {}
def __contains__(self, entity):
return entity.short in self.__contactlist
return entity.bare in self.__contactlist
def clear(self):
"""Clear all the contact list"""
@ -38,13 +38,13 @@ class QuickContactManagement(object):
def add(self, entity):
"""Add contact to the list, update resources"""
if not self.__contactlist.has_key(entity.short):
self.__contactlist[entity.short] = {'resources':[]}
if not self.__contactlist.has_key(entity.bare):
self.__contactlist[entity.bare] = {'resources':[]}
if not entity.resource:
return
if entity.resource in self.__contactlist[entity.short]['resources']:
self.__contactlist[entity.short]['resources'].remove(entity.resource)
self.__contactlist[entity.short]['resources'].append(entity.resource)
if entity.resource in self.__contactlist[entity.bare]['resources']:
self.__contactlist[entity.bare]['resources'].remove(entity.resource)
self.__contactlist[entity.bare]['resources'].append(entity.resource)
def getContFromGroup(self, group):
"""Return all contacts which are in given group"""
@ -60,28 +60,28 @@ class QuickContactManagement(object):
@param entity: jid of the contact
@param name: name of the attribute
@return: asked attribute"""
if self.__contactlist.has_key(entity.short):
if self.__contactlist.has_key(entity.bare):
if name == 'status': #FIXME: for the moment, we only use the first status
if self.__contactlist[entity.short]['statuses']:
return self.__contactlist[entity.short]['statuses'].values()[0]
if self.__contactlist[entity.short].has_key(name):
return self.__contactlist[entity.short][name]
if self.__contactlist[entity.bare]['statuses']:
return self.__contactlist[entity.bare]['statuses'].values()[0]
if self.__contactlist[entity.bare].has_key(name):
return self.__contactlist[entity.bare][name]
else:
debug(_('Trying to get attribute for an unknown contact'))
return None
def isConnected(self, entity):
"""Tell if the contact is online"""
return self.__contactlist.has_key(entity.short)
return self.__contactlist.has_key(entity.bare)
def remove(self, entity):
"""remove resource. If no more resource is online or is no resource is specified, contact is deleted"""
try:
if entity.resource:
self.__contactlist[entity.short]['resources'].remove(entity.resource)
if not entity.resource or not self.__contactlist[entity.short]['resources']:
self.__contactlist[entity.bare]['resources'].remove(entity.resource)
if not entity.resource or not self.__contactlist[entity.bare]['resources']:
#no more resource available: the contact seems really disconnected
del self.__contactlist[entity.short]
del self.__contactlist[entity.bare]
except KeyError:
error(_('INTERNAL ERROR: Key error'))
raise
@ -92,11 +92,11 @@ class QuickContactManagement(object):
@param key: name of the attribute
@param value: value of the attribute
"""
if self.__contactlist.has_key(entity.short):
self.__contactlist[entity.short][key] = value
if self.__contactlist.has_key(entity.bare):
self.__contactlist[entity.bare][key] = value
else:
debug (_('Trying to update an unknown contact: %s'), entity.short)
debug (_('Trying to update an unknown contact: %s'), entity.bare)
def get_full(self, entity):
return entity.short+'/'+self.__contactlist[entity.short]['resources'][-1]
return entity.bare+'/'+self.__contactlist[entity.bare]['resources'][-1]