Commit 2879d3c6 authored by mathieui's avatar mathieui

Mostly line-wrap at 80 chars and add docstrings

- also fix some erroneous comment(s)
- remove self.background which wasn’t set to something other than false
- fix the chatroom address (and the doc) in the first help message
parent 28d92899
...@@ -62,6 +62,7 @@ class Core(object): ...@@ -62,6 +62,7 @@ class Core(object):
# of being displayed on the screen and exiting the program. # of being displayed on the screen and exiting the program.
sys.excepthook = self.on_exception sys.excepthook = self.on_exception
self.connection_time = time.time() self.connection_time = time.time()
self.stdscr = None
status = config.get('status', None) status = config.get('status', None)
status = possible_show.get(status, None) status = possible_show.get(status, None)
self.status = Status(show=status, self.status = Status(show=status,
...@@ -83,9 +84,10 @@ class Core(object): ...@@ -83,9 +84,10 @@ class Core(object):
self.information_win_size = config.get('info_win_height', 2, 'var') self.information_win_size = config.get('info_win_height', 2, 'var')
self.information_win = windows.TextWin(300) self.information_win = windows.TextWin(300)
self.information_buffer.add_window(self.information_win) self.information_buffer.add_window(self.information_win)
self.left_tab_win = None
self.tab_win = windows.GlobalInfoBar() self.tab_win = windows.GlobalInfoBar()
# Number of xml tabs opened, used to avoid useless memory consumption # Whether the XML tab is opened
self.xml_tab = False self.xml_tab = False
self.xml_buffer = TextBuffer() self.xml_buffer = TextBuffer()
...@@ -93,7 +95,11 @@ class Core(object): ...@@ -93,7 +95,11 @@ class Core(object):
self._current_tab_nb = 0 self._current_tab_nb = 0
self.previous_tab_nb = 0 self.previous_tab_nb = 0
self.own_nick = config.get('default_nick', '') or self.xmpp.boundjid.user or os.environ.get('USER') or 'poezio' own_nick = config.get('default_nick', '')
own_nick = own_nick or self.xmpp.boundjid.user
own_nick = own_nick or os.environ.get('USER')
own_nick = own_nick or 'poezio'
self.own_nick = own_nick
self.plugins_autoloaded = False self.plugins_autoloaded = False
self.plugin_manager = PluginManager(self) self.plugin_manager = PluginManager(self)
...@@ -185,44 +191,68 @@ class Core(object): ...@@ -185,44 +191,68 @@ class Core(object):
self.xmpp.add_event_handler('failed_auth', self.on_failed_auth) self.xmpp.add_event_handler('failed_auth', self.on_failed_auth)
self.xmpp.add_event_handler('no_auth', self.on_no_auth) self.xmpp.add_event_handler('no_auth', self.on_no_auth)
self.xmpp.add_event_handler("session_start", self.on_session_start) self.xmpp.add_event_handler("session_start", self.on_session_start)
self.xmpp.add_event_handler("session_start", self.on_session_start_features) self.xmpp.add_event_handler("session_start",
self.xmpp.add_event_handler("groupchat_presence", self.on_groupchat_presence) self.on_session_start_features)
self.xmpp.add_event_handler("groupchat_message", self.on_groupchat_message) self.xmpp.add_event_handler("groupchat_presence",
self.xmpp.add_event_handler("groupchat_invite", self.on_groupchat_invitation) self.on_groupchat_presence)
self.xmpp.add_event_handler("groupchat_direct_invite", self.on_groupchat_direct_invitation) self.xmpp.add_event_handler("groupchat_message",
self.xmpp.add_event_handler("groupchat_decline", self.on_groupchat_decline) self.on_groupchat_message)
self.xmpp.add_event_handler("groupchat_config_status", self.on_status_codes) self.xmpp.add_event_handler("groupchat_invite",
self.xmpp.add_event_handler("groupchat_subject", self.on_groupchat_subject) self.on_groupchat_invitation)
self.xmpp.add_event_handler("groupchat_direct_invite",
self.on_groupchat_direct_invitation)
self.xmpp.add_event_handler("groupchat_decline",
self.on_groupchat_decline)
self.xmpp.add_event_handler("groupchat_config_status",
self.on_status_codes)
self.xmpp.add_event_handler("groupchat_subject",
self.on_groupchat_subject)
self.xmpp.add_event_handler("message", self.on_message) self.xmpp.add_event_handler("message", self.on_message)
self.xmpp.add_event_handler("got_online", self.on_got_online) self.xmpp.add_event_handler("got_online", self.on_got_online)
self.xmpp.add_event_handler("got_offline", self.on_got_offline) self.xmpp.add_event_handler("got_offline", self.on_got_offline)
self.xmpp.add_event_handler("roster_update", self.on_roster_update) self.xmpp.add_event_handler("roster_update", self.on_roster_update)
self.xmpp.add_event_handler("changed_status", self.on_presence) self.xmpp.add_event_handler("changed_status", self.on_presence)
self.xmpp.add_event_handler("presence_error", self.on_presence_error) self.xmpp.add_event_handler("presence_error", self.on_presence_error)
self.xmpp.add_event_handler("roster_subscription_request", self.on_subscription_request) self.xmpp.add_event_handler("roster_subscription_request",
self.xmpp.add_event_handler("roster_subscription_authorized", self.on_subscription_authorized) self.on_subscription_request)
self.xmpp.add_event_handler("roster_subscription_remove", self.on_subscription_remove) self.xmpp.add_event_handler("roster_subscription_authorized",
self.xmpp.add_event_handler("roster_subscription_removed", self.on_subscription_removed) self.on_subscription_authorized)
self.xmpp.add_event_handler("roster_subscription_remove",
self.on_subscription_remove)
self.xmpp.add_event_handler("roster_subscription_removed",
self.on_subscription_removed)
self.xmpp.add_event_handler("message_xform", self.on_data_form) self.xmpp.add_event_handler("message_xform", self.on_data_form)
self.xmpp.add_event_handler("chatstate_active", self.on_chatstate_active) self.xmpp.add_event_handler("chatstate_active",
self.xmpp.add_event_handler("chatstate_composing", self.on_chatstate_composing) self.on_chatstate_active)
self.xmpp.add_event_handler("chatstate_paused", self.on_chatstate_paused) self.xmpp.add_event_handler("chatstate_composing",
self.xmpp.add_event_handler("chatstate_gone", self.on_chatstate_gone) self.on_chatstate_composing)
self.xmpp.add_event_handler("chatstate_inactive", self.on_chatstate_inactive) self.xmpp.add_event_handler("chatstate_paused",
self.on_chatstate_paused)
self.xmpp.add_event_handler("chatstate_gone",
self.on_chatstate_gone)
self.xmpp.add_event_handler("chatstate_inactive",
self.on_chatstate_inactive)
self.xmpp.add_event_handler("attention", self.on_attention) self.xmpp.add_event_handler("attention", self.on_attention)
self.xmpp.add_event_handler("ssl_cert", self.validate_ssl) self.xmpp.add_event_handler("ssl_cert", self.validate_ssl)
self.all_stanzas = Callback('custom matcher', connection.MatchAll(None), self.incoming_stanza) self.all_stanzas = Callback('custom matcher',
connection.MatchAll(None),
self.incoming_stanza)
self.xmpp.register_handler(self.all_stanzas) self.xmpp.register_handler(self.all_stanzas)
if config.get('enable_user_tune', True): if config.get('enable_user_tune', True):
self.xmpp.add_event_handler("user_tune_publish", self.on_tune_event) self.xmpp.add_event_handler("user_tune_publish",
self.on_tune_event)
if config.get('enable_user_nick', True): if config.get('enable_user_nick', True):
self.xmpp.add_event_handler("user_nick_publish", self.on_nick_received) self.xmpp.add_event_handler("user_nick_publish",
self.on_nick_received)
if config.get('enable_user_mood', True): if config.get('enable_user_mood', True):
self.xmpp.add_event_handler("user_mood_publish", self.on_mood_event) self.xmpp.add_event_handler("user_mood_publish",
self.on_mood_event)
if config.get('enable_user_activity', True): if config.get('enable_user_activity', True):
self.xmpp.add_event_handler("user_activity_publish", self.on_activity_event) self.xmpp.add_event_handler("user_activity_publish",
self.on_activity_event)
if config.get('enable_user_gaming', True): if config.get('enable_user_gaming', True):
self.xmpp.add_event_handler("user_gaming_publish", self.on_gaming_event) self.xmpp.add_event_handler("user_gaming_publish",
self.on_gaming_event)
self.initial_joins = [] self.initial_joins = []
...@@ -238,20 +268,28 @@ class Core(object): ...@@ -238,20 +268,28 @@ class Core(object):
# callbacks are triggered. # callbacks are triggered.
# Use Core.add_configuration_handler("option", callback) to add a # Use Core.add_configuration_handler("option", callback) to add a
# handler # handler
# Note that the callback will be called when it’s changed in the global section, OR # Note that the callback will be called when it’s changed in the
# in a special section. # global section, OR in a special section.
# As a special case, handlers can be associated with the empty # As a special case, handlers can be associated with the empty
# string option (""), they will be called for every option change # string option (""), they will be called for every option change
# The callback takes two argument: the config option, and the new # The callback takes two argument: the config option, and the new
# value # value
self.configuration_change_handlers = {"": []} self.configuration_change_handlers = {"": []}
self.add_configuration_handler("create_gaps", self.on_gaps_config_change) self.add_configuration_handler("create_gaps",
self.add_configuration_handler("plugins_dir", self.on_plugins_dir_config_change) self.on_gaps_config_change)
self.add_configuration_handler("plugins_conf_dir", self.on_plugins_conf_dir_config_change) self.add_configuration_handler("plugins_dir",
self.add_configuration_handler("connection_timeout_delay", self.xmpp.set_keepalive_values) self.on_plugins_dir_config_change)
self.add_configuration_handler("connection_check_interval", self.xmpp.set_keepalive_values) self.add_configuration_handler("plugins_conf_dir",
self.add_configuration_handler("themes_dir", theming.update_themes_dir) self.on_plugins_conf_dir_config_change)
self.add_configuration_handler("theme", self.on_theme_config_change) self.add_configuration_handler("connection_timeout_delay",
self.xmpp.set_keepalive_values)
self.add_configuration_handler("connection_check_interval",
self.xmpp.set_keepalive_values)
self.add_configuration_handler("themes_dir",
theming.update_themes_dir)
self.add_configuration_handler("theme",
self.on_theme_config_change)
self.add_configuration_handler("", self.on_any_config_change) self.add_configuration_handler("", self.on_any_config_change)
def on_any_config_change(self, option, value): def on_any_config_change(self, option, value):
...@@ -291,7 +329,7 @@ class Core(object): ...@@ -291,7 +329,7 @@ class Core(object):
Remove all gaptabs if switching from gaps to nogaps. Remove all gaptabs if switching from gaps to nogaps.
""" """
if value.lower() == "false": if value.lower() == "false":
self.tabs = list(filter(lambda x: bool(x), self.tabs)) self.tabs = list(tab for tab in self.tabs if tab)
def on_plugins_dir_config_change(self, option, value): def on_plugins_dir_config_change(self, option, value):
""" """
...@@ -398,10 +436,11 @@ class Core(object): ...@@ -398,10 +436,11 @@ class Core(object):
if firstrun: if firstrun:
self.information(_( self.information(_(
'It seems that it is the first time you start poezio.\n' 'It seems that it is the first time you start poezio.\n'
'The online help is here http://poezio.eu/doc/en/\n' 'The online help is here http://doc.poez.io/\n'
'No room is joined by default, but you can join poezio’s chatroom ' 'No room is joined by default, but you can join poezio’s'
'(with /join poezio@muc.poezio.eu), where you can ask for help or tell us how great it is.' 'chatroom (with /join poezio@muc.poez.io), where you can'
), 'Help') ' ask for help or tell us how great it is.'),
_('Help'))
self.refresh_window() self.refresh_window()
def on_exception(self, typ, value, trace): def on_exception(self, typ, value, trace):
...@@ -420,6 +459,7 @@ class Core(object): ...@@ -420,6 +459,7 @@ class Core(object):
main loop waiting for the user to press a key main loop waiting for the user to press a key
""" """
def replace_line_breaks(key): def replace_line_breaks(key):
"replace ^J with \n"
if key == '^J': if key == '^J':
return '\n' return '\n'
return key return key
...@@ -490,7 +530,7 @@ class Core(object): ...@@ -490,7 +530,7 @@ class Core(object):
if func: if func:
func() func()
else: else:
res = self.do_command(replace_line_breaks(char), False) self.do_command(replace_line_breaks(char), False)
else: else:
self.do_command(''.join(char_list), True) self.do_command(''.join(char_list), True)
self.doupdate() self.doupdate()
...@@ -499,9 +539,14 @@ class Core(object): ...@@ -499,9 +539,14 @@ class Core(object):
""" """
Save config in the file just before exit Save config in the file just before exit
""" """
if not roster.save_to_config_file() or \ ok = roster.save_to_config_file()
not config.silent_set('info_win_height', self.information_win_size, 'var'): ok = ok and config.silent_set('info_win_height',
self.information(_('Unable to write in the config file'), 'Error') self.information_win_size,
'var')
if not ok:
self.information(_('Unable to save runtime preferences'
' in the config file'),
_('Error'))
def on_roster_enter_key(self, roster_row): def on_roster_enter_key(self, roster_row):
""" """
...@@ -513,7 +558,9 @@ class Core(object): ...@@ -513,7 +558,9 @@ class Core(object):
else: else:
self.focus_tab_named(roster_row.bare_jid) self.focus_tab_named(roster_row.bare_jid)
if isinstance(roster_row, Resource): if isinstance(roster_row, Resource):
if not self.get_conversation_by_jid(roster_row.jid, False, fallback_barejid=False): if not self.get_conversation_by_jid(roster_row.jid,
False,
fallback_barejid=False):
self.open_conversation_window(roster_row.jid) self.open_conversation_window(roster_row.jid)
else: else:
self.focus_tab_named(roster_row.jid) self.focus_tab_named(roster_row.jid)
...@@ -555,7 +602,8 @@ class Core(object): ...@@ -555,7 +602,8 @@ class Core(object):
func(arg) func(arg)
return return
else: else:
self.information(_("Unknown command (%s)") % (command), _('Error')) self.information(_("Unknown command (%s)") % (command),
_('Error'))
def exec_command(self, command): def exec_command(self, command):
""" """
...@@ -587,35 +635,48 @@ class Core(object): ...@@ -587,35 +635,48 @@ class Core(object):
""" """
if config.get('exec_remote', False): if config.get('exec_remote', False):
# We just write the command in the fifo # We just write the command in the fifo
fifo_path = config.get('remote_fifo_path', './')
if not self.remote_fifo: if not self.remote_fifo:
try: try:
self.remote_fifo = Fifo(os.path.join(config.get('remote_fifo_path', './'), 'poezio.fifo'), 'w') self.remote_fifo = Fifo(os.path.join(fifo_path,
except (OSError, IOError) as e: 'poezio.fifo'),
'w')
except (OSError, IOError) as exc:
log.error('Could not open the fifo for writing (%s)', log.error('Could not open the fifo for writing (%s)',
os.path.join(config.get('remote_fifo_path', './'), 'poezio.fifo'), os.path.join(fifo_path, './', 'poezio.fifo'),
exc_info=True) exc_info=True)
self.information('Could not open fifo file for writing: %s' % (e,), 'Error') self.information('Could not open the fifo '
'file for writing: %s' % exc,
'Error')
return return
command_str = ' '.join([pipes.quote(arg.replace('\n', ' ')) for arg in command]) + '\n'
args = (pipes.quote(arg.replace('\n', ' ')) for arg in command)
command_str = ' '.join(args) + '\n'
try: try:
self.remote_fifo.write(command_str) self.remote_fifo.write(command_str)
except (IOError) as e: except (IOError) as exc:
log.error('Could not write in the fifo (%s): %s', log.error('Could not write in the fifo (%s): %s',
os.path.join(config.get('remote_fifo_path', './'), 'poezio.fifo'), os.path.join(fifo_path, './', 'poezio.fifo'),
repr(command), repr(command),
exc_info=True) exc_info=True)
self.information('Could not execute %s: %s' % (command, e,), 'Error') self.information('Could not execute %s: %s' % (command, exc),
'Error')
self.remote_fifo = None self.remote_fifo = None
else: else:
e = Executor(command) executor = Executor(command)
try: try:
e.start() executor.start()
except ValueError as e: except ValueError as exc:
log.error('Could not execute command (%s)', repr(command), exc_info=True) log.error('Could not execute command (%s)',
self.information('%s' % (e,), 'Error') repr(command),
exc_info=True)
self.information('%s' % exc, 'Error')
def do_command(self, key, raw): def do_command(self, key, raw):
"""
Execute the action associated with a key
"""
if not key: if not key:
return return
return self.current_tab().on_input(key, raw) return self.current_tab().on_input(key, raw)
...@@ -670,9 +731,12 @@ class Core(object): ...@@ -670,9 +731,12 @@ class Core(object):
""" """
self.status = Status(show=pres, message=msg) self.status = Status(show=pres, message=msg)
if config.get('save_status', True): if config.get('save_status', True):
if not config.silent_set('status', pres if pres else '') or \ ok = config.silent_set('status', pres if pres else '')
not config.silent_set('status_message', msg.replace('\n', '|') if msg else ''): msg = msg.replace('\n', '|') if msg else ''
self.information(_('Unable to write in the config file'), 'Error') ok = ok and config.silent_set('status_message', msg)
if not ok:
self.information(_('Unable to save the status in '
'the config file'), 'Error')
def get_bookmark_nickname(self, room_name): def get_bookmark_nickname(self, room_name):
""" """
...@@ -698,7 +762,8 @@ class Core(object): ...@@ -698,7 +762,8 @@ class Core(object):
def send_message(self, msg): def send_message(self, msg):
""" """
Function to use in plugins to send a message in the current conversation. Function to use in plugins to send a message in the current
conversation.
Returns False if the current tab is not a conversation tab Returns False if the current tab is not a conversation tab
""" """
if not isinstance(self.current_tab(), tabs.ChatTab): if not isinstance(self.current_tab(), tabs.ChatTab):
...@@ -749,9 +814,11 @@ class Core(object): ...@@ -749,9 +814,11 @@ class Core(object):
else: else:
body = condition or _('Unknown error') body = condition or _('Unknown error')
if code: if code:
message = _('%(from)s: %(code)s - %(msg)s: %(body)s') % {'from':sender, 'msg':msg, 'body':body, 'code':code} message = _('%(from)s: %(code)s - %(msg)s: %(body)s') % {
'from': sender, 'msg': msg, 'body': body, 'code': code}
else: else:
message = _('%(from)s: %(msg)s: %(body)s') % {'from':sender, 'msg':msg, 'body':body} message = _('%(from)s: %(msg)s: %(body)s') % {
'from': sender, 'msg': msg, 'body': body}
return message return message
...@@ -780,20 +847,25 @@ class Core(object): ...@@ -780,20 +847,25 @@ class Core(object):
tabs with the same barejid, instead of searching only by fulljid. tabs with the same barejid, instead of searching only by fulljid.
""" """
jid = safeJID(jid) jid = safeJID(jid)
# We first check if we have a static conversation opened with this precise resource # We first check if we have a static conversation opened
conversation = self.get_tab_by_name(jid.full, tabs.StaticConversationTab) # with this precise resource
conversation = self.get_tab_by_name(jid.full,
tabs.StaticConversationTab)
if jid.bare == jid.full and not conversation: if jid.bare == jid.full and not conversation:
conversation = self.get_tab_by_name(jid.full, tabs.DynamicConversationTab) conversation = self.get_tab_by_name(jid.full,
tabs.DynamicConversationTab)
if not conversation and fallback_barejid: if not conversation and fallback_barejid:
# If not, we search for a conversation with the bare jid # If not, we search for a conversation with the bare jid
conversation = self.get_tab_by_name(jid.bare, tabs.DynamicConversationTab) conversation = self.get_tab_by_name(jid.bare,
tabs.DynamicConversationTab)
if not conversation: if not conversation:
if create: if create:
# We create a dynamic conversation with the bare Jid if # We create a dynamic conversation with the bare Jid if
# nothing was found (and we lock it to the resource # nothing was found (and we lock it to the resource
# later) # later)
conversation = self.open_conversation_window(jid.bare, False) conversation = self.open_conversation_window(jid.bare,
False)
else: else:
conversation = None conversation = None
return conversation return conversation
...@@ -851,7 +923,8 @@ class Core(object): ...@@ -851,7 +923,8 @@ class Core(object):
target = None if new_pos >= len(self.tabs) else self.tabs[new_pos] target = None if new_pos >= len(self.tabs) else self.tabs[new_pos]
if not target: if not target:
if new_pos < len(self.tabs): if new_pos < len(self.tabs):
self.tabs[new_pos], self.tabs[old_pos] = self.tabs[old_pos], tabs.GapTab() old_tab = self.tabs[old_pos]
self.tabs[new_pos], self.tabs[old_pos] = old_tab, tabs.GapTab()
else: else:
self.tabs.append(self.tabs[old_pos]) self.tabs.append(self.tabs[old_pos])
self.tabs[old_pos] = tabs.GapTab() self.tabs[old_pos] = tabs.GapTab()
...@@ -941,9 +1014,11 @@ class Core(object): ...@@ -941,9 +1014,11 @@ class Core(object):
self.command_win('%s%s' % (nb1, nb2)) self.command_win('%s%s' % (nb1, nb2))
def go_to_roster(self): def go_to_roster(self):
"Select the roster as the current tab"
self.command_win('0') self.command_win('0')
def go_to_previous_tab(self): def go_to_previous_tab(self):
"Go to the previous tab"
self.command_win('%s' % (self.previous_tab_nb,)) self.command_win('%s' % (self.previous_tab_nb,))
def go_to_important_room(self): def go_to_important_room(self):
...@@ -963,12 +1038,15 @@ class Core(object): ...@@ -963,12 +1038,15 @@ class Core(object):
else: else:
tab_refs[tab.state].append(tab) tab_refs[tab.state].append(tab)
# sort the state by priority and remove those with negative priority # sort the state by priority and remove those with negative priority
states = sorted(tab_refs.keys(), key=(lambda x: priority.get(x, 0)), reverse=True) states = sorted(tab_refs.keys(),
key=(lambda x: priority.get(x, 0)),
reverse=True)
states = [state for state in states if priority.get(state, -1) >= 0] states = [state for state in states if priority.get(state, -1) >= 0]
for state in states: for state in states:
for tab in tab_refs[state]: for tab in tab_refs[state]:
if tab.nb < self.current_tab_nb and tab_refs[state][-1].nb > self.current_tab_nb: if (tab.nb < self.current_tab_nb and
tab_refs[state][-1].nb > self.current_tab_nb):
continue continue
self.command_win('%s' % tab.nb) self.command_win('%s' % tab.nb)
return return
...@@ -985,10 +1063,15 @@ class Core(object): ...@@ -985,10 +1063,15 @@ class Core(object):
@property @property
def current_tab_nb(self): def current_tab_nb(self):
"""Wrapper for the current tab number"""
return self._current_tab_nb return self._current_tab_nb
@current_tab_nb.setter @current_tab_nb.setter
def current_tab_nb(self, value): def current_tab_nb(self, value):
"""
Prevents the tab number from going over the total number of opened
tabs, or under 0
"""
if value >= len(self.tabs): if value >= len(self.tabs):
self._current_tab_nb = 0 self._current_tab_nb = 0
elif value < 0: elif value < 0:
...@@ -1057,18 +1140,22 @@ class Core(object): ...@@ -1057,18 +1140,22 @@ class Core(object):
self.add_tab(form_tab, True) self.add_tab(form_tab, True)
### Modifying actions ### ### Modifying actions ###
def rename_private_tabs(self, room_name, old_nick, new_nick): def rename_private_tabs(self, room_name, old_nick, new_nick):
""" """
Call this method when someone changes his/her nick in a MUC, this updates Call this method when someone changes his/her nick in a MUC,
the name of all the opened private conversations with him/her this updates the name of all the opened private conversations
with him/her
""" """
tab = self.get_tab_by_name('%s/%s' % (room_name, old_nick), tabs.PrivateTab) tab = self.get_tab_by_name('%s/%s' % (room_name, old_nick),
tabs.PrivateTab)
if tab: if tab:
tab.rename_user(old_nick, new_nick) tab.rename_user(old_nick, new_nick)
def on_user_left_private_conversation(self, room_name, nick, status_message): def on_user_left_private_conversation(self, room_name, nick, status_message):
""" """
The user left the MUC: add a message in the associated private conversation The user left the MUC: add a message in the associated
private conversation
""" """
tab = self.get_tab_by_name('%s/%s' % (room_name, nick), tabs.PrivateTab) tab = self.get_tab_by_name('%s/%s' % (room_name, nick), tabs.PrivateTab)
if tab: if tab:
...@@ -1076,24 +1163,29 @@ class Core(object): ...@@ -1076,24 +1163,29 @@ class Core(object):
def on_user_rejoined_private_conversation(self, room_name, nick): def on_user_rejoined_private_conversation(self, room_name, nick):
""" """
The user joined a MUC: add a message in the associated private conversation The user joined a MUC: add a message in the associated
private conversation
""" """
tab = self.get_tab_by_name('%s/%s' % (room_name, nick), tabs.PrivateTab) tab = self.get_tab_by_name('%s/%s' % (room_name, nick), tabs.PrivateTab)
if tab: if tab:
tab.user_rejoined(nick) tab.user_rejoined(nick)
def disable_private_tabs(self, room_name, reason='\x195}You left the chatroom\x193}'): def disable_private_tabs(self, room_name, reason=None):
""" """
Disable private tabs when leaving a room Disable private tabs when leaving a room
""" """
if reason is None:
reason = _('\x195}You left the chatroom\x193}')
for tab in self.get_tabs(tabs.PrivateTab): for tab in self.get_tabs(tabs.PrivateTab):
if tab.get_name().startswith(room_name): if tab.get_name().startswith(room_name):
tab.deactivate(reason=reason) tab.deactivate(reason=reason)