core (memory): updateEntityData now accept a "silent" argument to avoid sending signal to frontends when updating an attribute with "signalOnUpdate" flag.

This commit is contained in:
Goffi 2015-02-09 21:39:51 +01:00
commit cdfb2c4dc6
8 changed files with 17 additions and 20 deletions

View file

@ -696,7 +696,7 @@ class SatMUCClient (muc.MUCClient):
self.userLeftRoom(room, user)
def userJoinedRoom(self, room, user):
self.host.memory.updateEntityData(room.roomJID, "type", "chatroom", self.parent.profile)
self.host.memory.updateEntityData(room.roomJID, "type", "chatroom", profile_key=self.parent.profile)
if user.nick in self.__changing_nicks:
self.__changing_nicks.remove(user.nick)
else:

View file

@ -105,7 +105,7 @@ class XEP_0054(object):
# hashs in memory. Hashed should be shared between profiles
for jid_s, avatar_hash in self.avatars_cache.iteritems():
jid_ = jid.JID(jid_s)
self.host.memory.updateEntityData(jid_, "avatar", avatar_hash, profile)
self.host.memory.updateEntityData(jid_, "avatar", avatar_hash, silent=True, profile_key=profile)
@defer.inlineCallbacks
def profileConnected(self, profile):
@ -122,7 +122,7 @@ class XEP_0054(object):
@param profile: profile which received the update
"""
assert not jid_.resource # VCard are retrieved with bare jid
self.host.memory.updateEntityData(jid_, name, value, profile)
self.host.memory.updateEntityData(jid_, name, value, profile_key=profile)
if name == "avatar":
self.avatars_cache[jid_.userhost()] = value

View file

@ -137,7 +137,7 @@ class XEP_0085(object):
if value == DELETE_VALUE:
self.host.memory.delEntityData(entity_jid, ENTITY_KEY, profile)
else:
self.host.memory.updateEntityData(entity_jid, ENTITY_KEY, value, profile)
self.host.memory.updateEntityData(entity_jid, ENTITY_KEY, value, profile_key=profile)
if not value or value == DELETE_VALUE:
# reinit chat state UI for this or these contact(s)
self.host.bridge.chatStateReceived(entity_jid.full(), "", profile)
@ -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)
self.updateEntityData(C.ENTITY_ALL, True if bool("true") else DELETE_VALUE, profile_key=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)
self.updateEntityData(from_jid, True, profile_key=profile)
except StopIteration:
if message.getAttribute('type') == 'chat':
# contact didn't enable Chat State Notifications
self.updateEntityData(from_jid, False, profile)
self.updateEntityData(from_jid, False, profile_key=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)
self.updateEntityData(to_jid, True, profile_key=profile)
return True
# wait for the first message before sending states
return False

View file

@ -107,7 +107,7 @@ class XEP_0115(object):
client.caps_sent = False
if cap_hash not in self.host.memory.disco.hashes:
self.host.memory.disco.hashes[cap_hash] = disco_infos
self.host.memory.updateEntityData(client.jid, C.ENTITY_CAP_HASH, cap_hash, profile)
self.host.memory.updateEntityData(client.jid, C.ENTITY_CAP_HASH, cap_hash, profile_key=profile)
class XEP_0115_handler(XMPPHandler):
@ -146,7 +146,7 @@ class XEP_0115_handler(XMPPHandler):
if c_ver in self.host.memory.disco.hashes:
# we already know the hash, we update the jid entity
log.debug ("hash [%(hash)s] already in cache, updating entity [%(jid)s]" % {'hash': c_ver, 'jid': from_jid.full()})
self.host.memory.updateEntityData(from_jid, C.ENTITY_CAP_HASH, c_ver, self.profile)
self.host.memory.updateEntityData(from_jid, C.ENTITY_CAP_HASH, c_ver, profile_key=self.profile)
return
if c_hash != 'sha-1': # unknown hash method