comparison src/plugins/plugin_xep_0085.py @ 1315:be3a301540c0 frontends_multi_profiles

core (memory): updateEntityData now accept a "silent" argument to avoid sending signal to frontends when updating an attribute with "signalOnUpdate" flag.
author Goffi <goffi@goffi.org>
date Mon, 09 Feb 2015 21:39:51 +0100
parents faa1129559b8
children 22fce2e51c70 2c6c93438f74
comparison
equal deleted inserted replaced
1314:bb9c32249778 1315:be3a301540c0
135 @param profile: current profile 135 @param profile: current profile
136 """ 136 """
137 if value == DELETE_VALUE: 137 if value == DELETE_VALUE:
138 self.host.memory.delEntityData(entity_jid, ENTITY_KEY, profile) 138 self.host.memory.delEntityData(entity_jid, ENTITY_KEY, profile)
139 else: 139 else:
140 self.host.memory.updateEntityData(entity_jid, ENTITY_KEY, value, profile) 140 self.host.memory.updateEntityData(entity_jid, ENTITY_KEY, value, profile_key=profile)
141 if not value or value == DELETE_VALUE: 141 if not value or value == DELETE_VALUE:
142 # reinit chat state UI for this or these contact(s) 142 # reinit chat state UI for this or these contact(s)
143 self.host.bridge.chatStateReceived(entity_jid.full(), "", profile) 143 self.host.bridge.chatStateReceived(entity_jid.full(), "", profile)
144 144
145 def paramUpdateTrigger(self, name, value, category, type_, profile): 145 def paramUpdateTrigger(self, name, value, category, type_, profile):
149 @param value: "true" to activate the notifications, or any other value to delete it 149 @param value: "true" to activate the notifications, or any other value to delete it
150 @param category: parameter category 150 @param category: parameter category
151 @param type_: parameter type 151 @param type_: parameter type
152 """ 152 """
153 if (category, name) == (PARAM_KEY, PARAM_NAME): 153 if (category, name) == (PARAM_KEY, PARAM_NAME):
154 self.updateEntityData(C.ENTITY_ALL, True if bool("true") else DELETE_VALUE, profile) 154 self.updateEntityData(C.ENTITY_ALL, True if bool("true") else DELETE_VALUE, profile_key=profile)
155 return False 155 return False
156 return True 156 return True
157 157
158 def messageReceivedTrigger(self, message, post_treat, profile): 158 def messageReceivedTrigger(self, message, post_treat, profile):
159 """ 159 """
171 try: 171 try:
172 domish.generateElementsNamed(message.elements(), name="body").next() 172 domish.generateElementsNamed(message.elements(), name="body").next()
173 try: 173 try:
174 domish.generateElementsNamed(message.elements(), name="active").next() 174 domish.generateElementsNamed(message.elements(), name="active").next()
175 # contact enabled Chat State Notifications 175 # contact enabled Chat State Notifications
176 self.updateEntityData(from_jid, True, profile) 176 self.updateEntityData(from_jid, True, profile_key=profile)
177 except StopIteration: 177 except StopIteration:
178 if message.getAttribute('type') == 'chat': 178 if message.getAttribute('type') == 'chat':
179 # contact didn't enable Chat State Notifications 179 # contact didn't enable Chat State Notifications
180 self.updateEntityData(from_jid, False, profile) 180 self.updateEntityData(from_jid, False, profile_key=profile)
181 return True 181 return True
182 except StopIteration: 182 except StopIteration:
183 pass 183 pass
184 184
185 # send our next "composing" states to any MUC and to the contacts who enabled the feature 185 # send our next "composing" states to any MUC and to the contacts who enabled the feature
258 try: 258 try:
259 return self.host.memory.getEntityDatum(to_jid, ENTITY_KEY, profile) 259 return self.host.memory.getEntityDatum(to_jid, ENTITY_KEY, profile)
260 except (exceptions.UnknownEntityError, KeyError): 260 except (exceptions.UnknownEntityError, KeyError):
261 if forceEntityData: 261 if forceEntityData:
262 # enable it for the first time 262 # enable it for the first time
263 self.updateEntityData(to_jid, True, profile) 263 self.updateEntityData(to_jid, True, profile_key=profile)
264 return True 264 return True
265 # wait for the first message before sending states 265 # wait for the first message before sending states
266 return False 266 return False
267 267
268 def __chatStateInit(self, to_jid, mess_type, profile): 268 def __chatStateInit(self, to_jid, mess_type, profile):