summaryrefslogtreecommitdiff
path: root/poezio/core/handlers.py
diff options
context:
space:
mode:
Diffstat (limited to 'poezio/core/handlers.py')
-rw-r--r--poezio/core/handlers.py81
1 files changed, 31 insertions, 50 deletions
diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py
index 0e655d68..94d05ee2 100644
--- a/poezio/core/handlers.py
+++ b/poezio/core/handlers.py
@@ -97,6 +97,11 @@ class HandlerCore:
self.core.xmpp.plugin['xep_0030'].get_info(
jid=self.core.xmpp.boundjid.domain, callback=callback)
+ def find_identities(self, _):
+ asyncio.ensure_future(
+ self.core.xmpp['xep_0030'].get_info_from_domain(),
+ )
+
def on_carbon_received(self, message):
"""
Carbon <received/> received
@@ -1063,7 +1068,8 @@ class HandlerCore:
'{http://jabber.org/protocol/muc#user}x') is not None:
return
jid = presence['from']
- if not logger.log_roster_change(jid.bare, 'got offline'):
+ status = presence['status']
+ if not logger.log_roster_change(jid.bare, 'got offline{}'.format(' ({})'.format(status) if status else '')):
self.core.information('Unable to write in the log file', 'Error')
# If a resource got offline, display the message in the conversation with this
# precise resource.
@@ -1073,12 +1079,15 @@ class HandlerCore:
roster.connected -= 1
if contact.name:
name = contact.name
+ offline_msg = '%s is \x191}offline' % name
+ if status:
+ offline_msg += ' (\x19o%s\x191})' % status
if jid.resource:
self.core.add_information_message_to_conversation_tab(
- jid.full, '\x195}%s is \x191}offline' % name)
+ jid.full, '\x195}' + offline_msg)
self.core.add_information_message_to_conversation_tab(
- jid.bare, '\x195}%s is \x191}offline' % name)
- self.core.information('\x193}%s \x195}is \x191}offline' % name,
+ jid.bare, '\x195}' + offline_msg)
+ self.core.information('\x193}' + offline_msg,
'Roster')
roster.modified()
if isinstance(self.core.tabs.current_tab, tabs.RosterInfoTab):
@@ -1261,71 +1270,40 @@ class HandlerCore:
semi_anon = '173' in status_codes
full_anon = '174' in status_codes
modif = False
+ info_col = {'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}
if show_unavailable or hide_unavailable or non_priv or logging_off\
or non_anon or semi_anon or full_anon:
tab.add_message(
- '\x19%(info_col)s}Info: A configuration change not privacy-related occurred.'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: A configuration change not privacy-related occurred.' % info_col,
typ=2)
modif = True
if show_unavailable:
tab.add_message(
- '\x19%(info_col)s}Info: The unavailable members are now shown.'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: The unavailable members are now shown.' % info_col,
typ=2)
elif hide_unavailable:
tab.add_message(
- '\x19%(info_col)s}Info: The unavailable members are now hidden.'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: The unavailable members are now hidden.' % info_col,
typ=2)
if non_anon:
tab.add_message(
- '\x191}Warning:\x19%(info_col)s} The room is now not anonymous. (public JID)'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x191}Warning:\x19%(info_col)s} The room is now not anonymous. (public JID)' % info_col,
typ=2)
elif semi_anon:
tab.add_message(
- '\x19%(info_col)s}Info: The room is now semi-anonymous. (moderators-only JID)'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: The room is now semi-anonymous. (moderators-only JID)' % info_col,
typ=2)
elif full_anon:
tab.add_message(
- '\x19%(info_col)s}Info: The room is now fully anonymous.' %
- {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: The room is now fully anonymous.' % info_col,
typ=2)
if logging_on:
tab.add_message(
- '\x191}Warning: \x19%(info_col)s}This room is publicly logged'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x191}Warning: \x19%(info_col)s}This room is publicly logged' % info_col,
typ=2)
elif logging_off:
tab.add_message(
- '\x19%(info_col)s}Info: This room is not logged anymore.' %
- {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: This room is not logged anymore.' % info_col,
typ=2)
if modif:
self.core.refresh_window()
@@ -1343,9 +1321,10 @@ class HandlerCore:
if subject != tab.topic:
# Do not display the message if the subject did not change or if we
# receive an empty topic when joining the room.
+ theme = get_theme()
fmt = {
- 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT),
- 'text_col': dump_tuple(get_theme().COLOR_NORMAL_TEXT),
+ 'info_col': dump_tuple(theme.COLOR_INFORMATION_TEXT),
+ 'text_col': dump_tuple(theme.COLOR_NORMAL_TEXT),
'subject': subject,
'user': '',
}
@@ -1439,17 +1418,18 @@ class HandlerCore:
xhtml_text, force=True).rstrip('\x19o').strip()
else:
poezio_colored = str(stanza)
+ char = get_theme().CHAR_XML_OUT
self.core.add_message_to_text_buffer(
self.core.xml_buffer,
poezio_colored,
- nickname=get_theme().CHAR_XML_OUT)
+ nickname=char)
try:
if self.core.xml_tab.match_stanza(
ElementBase(ET.fromstring(stanza))):
self.core.add_message_to_text_buffer(
self.core.xml_tab.filtered_buffer,
poezio_colored,
- nickname=get_theme().CHAR_XML_OUT)
+ nickname=char)
except:
log.debug('', exc_info=True)
@@ -1468,16 +1448,17 @@ class HandlerCore:
xhtml_text, force=True).rstrip('\x19o').strip()
else:
poezio_colored = str(stanza)
+ char = get_theme().CHAR_XML_IN
self.core.add_message_to_text_buffer(
self.core.xml_buffer,
poezio_colored,
- nickname=get_theme().CHAR_XML_IN)
+ nickname=char)
try:
if self.core.xml_tab.match_stanza(stanza):
self.core.add_message_to_text_buffer(
self.core.xml_tab.filtered_buffer,
poezio_colored,
- nickname=get_theme().CHAR_XML_IN)
+ nickname=char)
except:
log.debug('', exc_info=True)
if isinstance(self.core.tabs.current_tab, tabs.XMLTab):