Fixes #2333
This commit is contained in:
parent
ae6fa61b84
commit
ce1c6e4ec6
2 changed files with 35 additions and 5 deletions
20
src/core.py
20
src/core.py
|
@ -1219,11 +1219,14 @@ class Core(object):
|
|||
if not tab:
|
||||
return None
|
||||
new_tab = tabs.PrivateTab(complete_jid, tab.own_nick)
|
||||
if hasattr(tab, 'directed_presence'):
|
||||
new_tab.directed_presence = tab.directed_presence
|
||||
if not focus:
|
||||
new_tab.state = "private"
|
||||
# insert it in the tabs
|
||||
self.add_tab(new_tab, focus)
|
||||
self.refresh_window()
|
||||
tab.privates.append(new_tab)
|
||||
return new_tab
|
||||
|
||||
def on_groupchat_subject(self, message):
|
||||
|
@ -1352,6 +1355,8 @@ class Core(object):
|
|||
for tab in self.tabs:
|
||||
if isinstance(tab, tabs.MucTab) and tab.joined:
|
||||
muc.change_show(self.xmpp, tab.name, tab.own_nick, show, msg)
|
||||
if hasattr(tab, 'directed_presence'):
|
||||
del tab.directed_presence
|
||||
self.set_status(show, msg)
|
||||
if isinstance(current, tabs.MucTab) and current.joined and show not in ('away', 'xa'):
|
||||
current.send_chat_state('active')
|
||||
|
@ -1395,6 +1400,21 @@ class Core(object):
|
|||
import traceback
|
||||
self.information(_('Could not send directed presence'), 'Error')
|
||||
log.debug(_("Could not send directed presence:\n") + traceback.format_exc())
|
||||
tab = self.get_tab_by_name(jid)
|
||||
if tab:
|
||||
if type in ('xa', 'away'):
|
||||
tab.directed_presence = False
|
||||
chatstate = 'inactive'
|
||||
else:
|
||||
tab.directed_presence = True
|
||||
chatstate = 'active'
|
||||
if tab == self.current_tab():
|
||||
tab.send_chat_state(chatstate, True)
|
||||
if isinstance(tab, tabs.MucTab):
|
||||
for private in tab.privates:
|
||||
private.directed_presence = tab.directed_presence
|
||||
if self.current_tab() in tab.privates:
|
||||
self.current_tab().send_chat_state(chatstate, True)
|
||||
|
||||
def completion_status(self, the_input):
|
||||
"""
|
||||
|
|
20
src/tabs.py
20
src/tabs.py
|
@ -461,7 +461,7 @@ class ChatTab(Tab):
|
|||
Send an empty chatstate message
|
||||
"""
|
||||
if not isinstance(self, MucTab) or self.joined:
|
||||
if state in ('active', 'inactive', 'gone') and self.core.status.show in ('xa', 'away') and not always_send:
|
||||
if state in ('active', 'inactive', 'gone') and self.inactive and not always_send:
|
||||
return
|
||||
msg = self.core.xmpp.make_message(self.get_name())
|
||||
msg['type'] = self.message_type
|
||||
|
@ -476,7 +476,7 @@ class ChatTab(Tab):
|
|||
"""
|
||||
name = self.general_jid
|
||||
if config.get_by_tabname('send_chat_states', 'true', name, True) == 'true' and self.remote_wants_chatstates:
|
||||
needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
|
||||
needed = 'inactive' if self.inactive else 'active'
|
||||
self.cancel_paused_delay()
|
||||
if not empty_after:
|
||||
if self.chat_state != "composing":
|
||||
|
@ -517,6 +517,12 @@ class ChatTab(Tab):
|
|||
del event
|
||||
self.timed_event_paused = None
|
||||
|
||||
@property
|
||||
def inactive(self):
|
||||
"""Whether we should send inactive or active as a chatstate"""
|
||||
return self.core.status.show in ('xa', 'away') or\
|
||||
(hasattr(self, 'directed_presence') and not self.directed_presence)
|
||||
|
||||
def move_separator(self):
|
||||
self.text_win.remove_line_separator()
|
||||
self.text_win.add_line_separator()
|
||||
|
@ -562,6 +568,7 @@ class MucTab(ChatTab):
|
|||
self.own_nick = nick
|
||||
self.name = jid
|
||||
self.users = []
|
||||
self.privates = [] # private conversations
|
||||
self.topic = ''
|
||||
self.remote_wants_chatstates = True
|
||||
# We send active, composing and paused states to the MUC because
|
||||
|
@ -950,7 +957,7 @@ class MucTab(ChatTab):
|
|||
self.core.information('Could not set affiliation', 'Error')
|
||||
|
||||
def command_say(self, line):
|
||||
needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
|
||||
needed = 'inactive' if self.inactive else 'active'
|
||||
msg = self.core.xmpp.make_message(self.get_name())
|
||||
msg['type'] = 'groupchat'
|
||||
msg['body'] = line
|
||||
|
@ -1460,6 +1467,9 @@ class PrivateTab(ChatTab):
|
|||
def general_jid(self):
|
||||
return self.get_name()
|
||||
|
||||
def on_close(self):
|
||||
self.parent_muc.privates.remove(self)
|
||||
|
||||
def completion(self):
|
||||
self.complete_commands(self.input)
|
||||
|
||||
|
@ -1479,7 +1489,7 @@ class PrivateTab(ChatTab):
|
|||
msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body'])
|
||||
msg['body'] = xhtml.clean_text(msg['body'])
|
||||
if config.get_by_tabname('send_chat_states', 'true', self.general_jid, True) == 'true' and self.remote_wants_chatstates is not False:
|
||||
needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
|
||||
needed = 'inactive' if self.inactive else 'active'
|
||||
msg['chat_state'] = needed
|
||||
if attention and self.remote_supports_attention:
|
||||
msg['attention'] = True
|
||||
|
@ -2241,7 +2251,7 @@ class ConversationTab(ChatTab):
|
|||
msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body'])
|
||||
msg['body'] = xhtml.clean_text(msg['body'])
|
||||
if config.get_by_tabname('send_chat_states', 'true', self.general_jid, True) == 'true' and self.remote_wants_chatstates is not False:
|
||||
needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
|
||||
needed = 'inactive' if self.inactive else 'active'
|
||||
msg['chat_state'] = needed
|
||||
if attention and self.remote_supports_attention:
|
||||
msg['attention'] = True
|
||||
|
|
Loading…
Reference in a new issue