summaryrefslogtreecommitdiff
path: root/src/tabs.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/tabs.py')
-rw-r--r--src/tabs.py53
1 files changed, 43 insertions, 10 deletions
diff --git a/src/tabs.py b/src/tabs.py
index 88d8ad7f..1b0406f2 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -799,7 +799,8 @@ class MucTab(ChatTab):
room.users.append(new_user)
if from_nick == room.own_nick:
room.joined = True
- self.send_chat_state('active')
+ if self.core.current_tab() == self and self.core.status.show not in ('xa', 'away'):
+ self.send_chat_state('active')
new_user.color = get_theme().COLOR_OWN_NICK
room.add_message(_("\x195}Your nickname is \x193}%s") % (from_nick))
if '170' in status_codes:
@@ -999,10 +1000,12 @@ class PrivateTab(ChatTab):
# keys
self.key_func['^I'] = self.completion
# commands
- #self.commands['info'] = (self.command_info, _('Usage: /info\nInfo: Display some information about the user in the MUC: '), None)
+ self.commands['info'] = (self.command_info, _('Usage: /info\nInfo: Display some information about the user in the MUC: '), None)
self.commands['unquery'] = (self.command_unquery, _("Usage: /unquery\nUnquery: close the tab"), None)
self.commands['part'] = (self.command_unquery, _("Usage: /part\nPart: close the tab"), None)
+ self.commands['version'] = (self.command_version, _('Usage: /version\nVersion: get the software version of the current interlocutor (usually its XMPP client and Operating System)'), None)
self.resize()
+ self.parent_muc = self.core.get_tab_by_name(JID(room.name).bare, MucTab)
self.on = True
def completion(self):
@@ -1019,7 +1022,8 @@ class PrivateTab(ChatTab):
msg['body'] = xhtml.clean_text(line)
msg['xhtml_im'] = xhtml.poezio_colors_to_html(line)
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
- msg['chat_state'] = 'active'
+ needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
+ msg['chat_state'] = needed
msg.send()
self.core.add_message_to_text_buffer(self.get_room(), line, None, self.core.own_nick or self.get_room().own_nick)
logger.log_message(JID(self.get_name()).bare, self.core.own_nick, line)
@@ -1033,6 +1037,31 @@ class PrivateTab(ChatTab):
"""
self.core.close_tab()
+ def command_version(self, arg):
+ """
+ /version
+ """
+ def callback(res):
+ if not res:
+ return self.core.information('Could not get the software version from %s' % (jid,), 'Warning')
+ version = '%s is running %s version %s on %s' % (jid,
+ res.get('name') or _('an unknown software'),
+ res.get('version') or _('unknown'),
+ res.get('os') or _('on an unknown platform'))
+ self.core.information(version, 'Info')
+ jid = self.get_room().name
+ self.core.xmpp.plugin['xep_0092'].get_version(jid, callback=callback)
+
+ def command_info(self, arg):
+ """
+ /info
+ """
+ if arg:
+ self.parent_muc.command_info(arg)
+ else:
+ user = JID(self.get_room().name).resource
+ self.parent_muc.command_info(user)
+
def resize(self):
if self.core.information_win_size >= self.height-3 or not self.visible:
return
@@ -1124,22 +1153,25 @@ class PrivateTab(ChatTab):
"""
The user left the associated MUC
"""
+ self.deactivate()
if not status_message:
self.get_room().add_message(_('\x191}%(spec)s \x193}%(nick)s\x195} has left the room') % {'nick':from_nick.replace('"', '\\"'), 'spec':get_theme().CHAR_QUIT.replace('"', '\\"')})
else:
self.get_room().add_message(_('\x191}%(spec)s \x193}%(nick)s\x195} has left the room (%(status)s)"') % {'nick':from_nick.replace('"', '\\"'), 'spec':get_theme().CHAR_QUIT, 'status': status_message.replace('"', '\\"')})
- self.deactivate()
- self.refresh()
- self.core.doupdate()
+ if self.core.current_tab() is self:
+ self.refresh()
+ self.core.doupdate()
def user_rejoined(self, nick):
"""
The user (or at least someone with the same nick) came back in the MUC
"""
- self.get_room().add_message('\x194}%(spec)s \x193}%(nick)s\x195} joined the room' % {'nick':nick, 'spec':get_theme().CHAR_JOIN})
self.activate()
- self.refresh()
- self.core.doupdate()
+ self.get_room().add_message('\x194}%(spec)s \x193}%(nick)s\x195} joined the room' % {'nick':nick, 'spec':get_theme().CHAR_JOIN})
+ if self.core.current_tab() is self:
+ self.refresh()
+ self.core.doupdate()
+
def activate(self):
self.on = True
@@ -1527,7 +1559,8 @@ class ConversationTab(ChatTab):
msg['body'] = xhtml.clean_text(line)
msg['xhtml_im'] = xhtml.poezio_colors_to_html(line)
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
- msg['chat_state'] = 'active'
+ needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
+ msg['chat_state'] = needed
msg.send()
self.core.add_message_to_text_buffer(self.get_room(), line, None, self.core.own_nick)
logger.log_message(JID(self.get_name()).bare, self.core.own_nick, line)