Do not send chat states if send_chat_states = false in config

This commit is contained in:
Florent Le Coz 2011-02-24 20:41:52 +01:00
parent 3f41cc8967
commit 3084a9cff7
2 changed files with 28 additions and 12 deletions

View file

@ -126,6 +126,14 @@ themes_dir =
# theme will be used instead
theme = poezio
# if true, chat states will be sent to the people you are talking to.
# Chat states are, for example, messages informing that you are composing
# a message or that you closed the tab, etc
# Set to false if you don't want people to know these information
# Note that you wont receive the chat states of your contacts
# if you don't send yours.
send_chat_states = true
# if true, information about the software (name and version)
# will be sent if requested by anyone
# Set to false if you don't want people to know these information

View file

@ -260,6 +260,24 @@ class ChatTab(Tab):
txt = txt[1:]
self.command_say(txt)
def send_composing_chat_state(self, empty_before, empty_after):
"""
Send the "active" or "composing" chatstate, depending
on the the current status of the input
"""
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates:
if not empty_before and empty_after:
msg = self.core.xmpp.make_message(self.get_name())
msg['type'] = 'chat'
msg['chat_state'] = 'active'
msg.send()
elif empty_before and not empty_after:
msg = self.core.xmpp.make_message(self.get_name())
msg['type'] = 'chat'
msg['chat_state'] = 'composing'
log.debug('MSG:%s\n' % msg)
msg.send()
def command_say(self, line):
raise NotImplementedError
@ -1114,7 +1132,7 @@ class ConversationTab(ChatTab, TabWithInfoWin):
msg = self.core.xmpp.make_message(self.get_name())
msg['type'] = 'chat'
msg['body'] = line
if self.remote_wants_chatstates is not False:
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
msg['chat_state'] = 'active'
msg.send()
self.core.add_message_to_text_buffer(self.get_room(), line, None, self.core.own_nick)
@ -1168,17 +1186,7 @@ class ConversationTab(ChatTab, TabWithInfoWin):
empty_before = self.input.get_text() == '' or self.input.get_text().startswith('/')
self.input.do_command(key)
empty_after = self.input.get_text() == '' or self.input.get_text().startswith('/')
if not empty_before and empty_after:
msg = self.core.xmpp.make_message(self.get_name())
msg['type'] = 'chat'
msg['chat_state'] = 'active'
msg.send()
elif empty_before and not empty_after:
msg = self.core.xmpp.make_message(self.get_name())
msg['type'] = 'chat'
msg['chat_state'] = 'composing'
log.debug('MSG:%s\n' % msg)
msg.send()
self.send_composing_chat_state(empty_before, empty_after)
return False
def on_lose_focus(self):