comparison src/plugins/plugin_xep_0085.py @ 1565:d86685c0c019

plugin XEP-0085: renamed "__xxx" methods to "_xxx"
author Goffi <goffi@goffi.org>
date Fri, 06 Nov 2015 17:09:45 +0100
parents 075a63180eab
children d17772b0fe22
comparison
equal deleted inserted replaced
1564:001b62bed67c 1565:d86685c0c019
182 return True 182 return True
183 except StopIteration: 183 except StopIteration:
184 pass 184 pass
185 185
186 # send our next "composing" states to any MUC and to the contacts who enabled the feature 186 # send our next "composing" states to any MUC and to the contacts who enabled the feature
187 self.__chatStateInit(from_jid, message.getAttribute("type"), profile) 187 self._chatStateInit(from_jid, message.getAttribute("type"), profile)
188 188
189 state_list = [child.name for child in message.elements() if 189 state_list = [child.name for child in message.elements() if
190 message.getAttribute("type") in MESSAGE_TYPES 190 message.getAttribute("type") in MESSAGE_TYPES
191 and child.name in CHAT_STATES 191 and child.name in CHAT_STATES
192 and child.defaultUri == NS_CHAT_STATES] 192 and child.defaultUri == NS_CHAT_STATES]
212 domish.generateElementsNamed(message.elements(), name="body").next() 212 domish.generateElementsNamed(message.elements(), name="body").next()
213 message.addElement('active', NS_CHAT_STATES) 213 message.addElement('active', NS_CHAT_STATES)
214 # launch the chat state machine (init the timer) 214 # launch the chat state machine (init the timer)
215 if self._isMUC(to_jid, profile): 215 if self._isMUC(to_jid, profile):
216 to_jid = to_jid.userhostJID() 216 to_jid = to_jid.userhostJID()
217 self.__chatStateActive(to_jid, mess_data["type"], profile) 217 self._chatStateActive(to_jid, mess_data["type"], profile)
218 except StopIteration: 218 except StopIteration:
219 if "chat_state" in mess_data["extra"]: 219 if "chat_state" in mess_data["extra"]:
220 state = mess_data["extra"].pop("chat_state") 220 state = mess_data["extra"].pop("chat_state")
221 assert state in CHAT_STATES 221 assert state in CHAT_STATES
222 message.addElement(state, NS_CHAT_STATES) 222 message.addElement(state, NS_CHAT_STATES)
264 self.updateCache(to_jid, True, profile=profile) 264 self.updateCache(to_jid, True, profile=profile)
265 return True 265 return True
266 # wait for the first message before sending states 266 # wait for the first message before sending states
267 return False 267 return False
268 268
269 def __chatStateInit(self, to_jid, mess_type, profile): 269 def _chatStateInit(self, to_jid, mess_type, profile):
270 """ 270 """
271 Data initialization for the chat state machine. 271 Data initialization for the chat state machine.
272 272
273 @param to_jid (JID): full JID for one2one, bare JID for MUC 273 @param to_jid (JID): full JID for one2one, bare JID for MUC
274 @param mess_type (str): "one2one" or "groupchat" 274 @param mess_type (str): "one2one" or "groupchat"
280 if to_jid not in profile_map: 280 if to_jid not in profile_map:
281 machine = ChatStateMachine(self.host, to_jid, 281 machine = ChatStateMachine(self.host, to_jid,
282 mess_type, profile) 282 mess_type, profile)
283 self.map[profile][to_jid] = machine 283 self.map[profile][to_jid] = machine
284 284
285 def __chatStateActive(self, to_jid, mess_type, profile_key): 285 def _chatStateActive(self, to_jid, mess_type, profile_key):
286 """ 286 """
287 Launch the chat state machine on "active" state. 287 Launch the chat state machine on "active" state.
288 288
289 @param to_jid (JID): full JID for one2one, bare JID for MUC 289 @param to_jid (JID): full JID for one2one, bare JID for MUC
290 @param mess_type (str): "one2one" or "groupchat" 290 @param mess_type (str): "one2one" or "groupchat"
291 @param profile (str): %(doc_profile)s 291 @param profile (str): %(doc_profile)s
292 """ 292 """
293 profile = self.host.memory.getProfileName(profile_key) 293 profile = self.host.memory.getProfileName(profile_key)
294 if profile is None: 294 if profile is None:
295 raise exceptions.ProfileUnknownError 295 raise exceptions.ProfileUnknownError
296 self.__chatStateInit(to_jid, mess_type, profile) 296 self._chatStateInit(to_jid, mess_type, profile)
297 self.map[profile][to_jid]._onEvent("active") 297 self.map[profile][to_jid]._onEvent("active")
298 298
299 def chatStateComposing(self, to_jid_s, profile_key): 299 def chatStateComposing(self, to_jid_s, profile_key):
300 """Move to the "composing" state when required. 300 """Move to the "composing" state when required.
301 301