plugin XEP-0085: fixes the calls to memory.deleteEntityDatum and self.updateCache (was self.updateEntityData, has been renamed to avoid confusion with the memory method)
This commit is contained in:
parent
ed8821d54b
commit
d70f08d524
1 changed files with 7 additions and 7 deletions
|
|
@ -126,16 +126,16 @@ class XEP_0085(object):
|
|||
self.map[profile][to_jid]._onEvent('gone')
|
||||
del self.map[profile]
|
||||
|
||||
def updateEntityData(self, entity_jid, value, profile):
|
||||
def updateCache(self, entity_jid, value, profile):
|
||||
"""Update the entity data of the given profile for one or all contacts.
|
||||
|
||||
Reset the chat state(s) display if the notification has been disabled.
|
||||
|
||||
@param entity_jid: contact's JID, or C.ENTITY_ALL to update all contacts.
|
||||
@param value: True, False or DELETE_VALUE to delete the entity data
|
||||
@param profile: current profile
|
||||
"""
|
||||
if value == DELETE_VALUE:
|
||||
self.host.memory.delEntityData(entity_jid, ENTITY_KEY, profile)
|
||||
self.host.memory.delEntityDatum(entity_jid, ENTITY_KEY, profile)
|
||||
else:
|
||||
self.host.memory.updateEntityData(entity_jid, ENTITY_KEY, value, profile_key=profile)
|
||||
if not value or value == DELETE_VALUE:
|
||||
|
|
@ -151,7 +151,7 @@ class XEP_0085(object):
|
|||
@param type_: parameter type
|
||||
"""
|
||||
if (category, name) == (PARAM_KEY, PARAM_NAME):
|
||||
self.updateEntityData(C.ENTITY_ALL, True if bool("true") else DELETE_VALUE, profile_key=profile)
|
||||
self.updateCache(C.ENTITY_ALL, True if bool("true") else DELETE_VALUE, profile=profile)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
@ -173,11 +173,11 @@ class XEP_0085(object):
|
|||
try:
|
||||
domish.generateElementsNamed(message.elements(), name="active").next()
|
||||
# contact enabled Chat State Notifications
|
||||
self.updateEntityData(from_jid, True, profile_key=profile)
|
||||
self.updateCache(from_jid, True, profile=profile)
|
||||
except StopIteration:
|
||||
if message.getAttribute('type') == 'chat':
|
||||
# contact didn't enable Chat State Notifications
|
||||
self.updateEntityData(from_jid, False, profile_key=profile)
|
||||
self.updateCache(from_jid, False, profile=profile)
|
||||
return True
|
||||
except StopIteration:
|
||||
pass
|
||||
|
|
@ -260,7 +260,7 @@ class XEP_0085(object):
|
|||
except (exceptions.UnknownEntityError, KeyError):
|
||||
if forceEntityData:
|
||||
# enable it for the first time
|
||||
self.updateEntityData(to_jid, True, profile_key=profile)
|
||||
self.updateCache(to_jid, True, profile=profile)
|
||||
return True
|
||||
# wait for the first message before sending states
|
||||
return False
|
||||
|
|
|
|||
Loading…
Reference in a new issue