comparison src/plugins/plugin_xep_0085.py @ 1337:f29beedb33b0 frontends_multi_profiles

merged souliane changes
author Goffi <goffi@goffi.org>
date Mon, 23 Feb 2015 18:08:22 +0100
parents 2c6c93438f74 22fce2e51c70
children 8aa32bcc3a9c
comparison
equal deleted inserted replaced
1336:2ecc07a8f91b 1337:f29beedb33b0
124 # before the chat state, so it will be ignored... find a way to 124 # before the chat state, so it will be ignored... find a way to
125 # actually defer the disconnection 125 # actually defer the disconnection
126 self.map[profile][to_jid]._onEvent('gone') 126 self.map[profile][to_jid]._onEvent('gone')
127 del self.map[profile] 127 del self.map[profile]
128 128
129 def updateEntityData(self, entity_jid, value, profile): 129 def updateCache(self, entity_jid, value, profile):
130 """Update the entity data of the given profile for one or all contacts. 130 """Update the entity data of the given profile for one or all contacts.
131
132 Reset the chat state(s) display if the notification has been disabled. 131 Reset the chat state(s) display if the notification has been disabled.
132
133 @param entity_jid: contact's JID, or C.ENTITY_ALL to update all contacts. 133 @param entity_jid: contact's JID, or C.ENTITY_ALL to update all contacts.
134 @param value: True, False or DELETE_VALUE to delete the entity data 134 @param value: True, False or DELETE_VALUE to delete the entity data
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.delEntityDatum(entity_jid, ENTITY_KEY, profile)
139 else: 139 else:
140 self.host.memory.updateEntityData(entity_jid, ENTITY_KEY, value, profile_key=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)
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=profile) 154 self.updateCache(C.ENTITY_ALL, True if bool("true") else DELETE_VALUE, profile=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=profile) 176 self.updateCache(from_jid, True, profile=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=profile) 180 self.updateCache(from_jid, False, profile=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=profile) 263 self.updateCache(to_jid, True, profile=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):