summaryrefslogtreecommitdiff
path: root/src/core.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-05-16 01:59:32 +0200
committermathieui <mathieui@mathieui.net>2012-05-16 01:59:32 +0200
commit58a41fe0652021481ebfa96fb3d238cddd93ca95 (patch)
treebc5b5fb0ecc9f6c0fc44e99ff945cc827aa99d95 /src/core.py
parente86ecb3a529f30123df376ca44da932288b24831 (diff)
downloadpoezio-58a41fe0652021481ebfa96fb3d238cddd93ca95.tar.gz
poezio-58a41fe0652021481ebfa96fb3d238cddd93ca95.tar.bz2
poezio-58a41fe0652021481ebfa96fb3d238cddd93ca95.tar.xz
poezio-58a41fe0652021481ebfa96fb3d238cddd93ca95.zip
Add status code handling - Fixes #2338
Get status codes in presence and message stanzas, and show information related to them. If the change hinders privacy (logs added, or public JIDs), then a red “Warning” message is shown instead of the classic “Info”.
Diffstat (limited to 'src/core.py')
-rw-r--r--src/core.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/core.py b/src/core.py
index 140a3bb9..c2624584 100644
--- a/src/core.py
+++ b/src/core.py
@@ -246,6 +246,7 @@ class Core(object):
self.xmpp.add_event_handler("groupchat_message", self.on_groupchat_message)
self.xmpp.add_event_handler("groupchat_invite", self.on_groupchat_invite)
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("got_online" , self.on_got_online)
@@ -1412,6 +1413,48 @@ class Core(object):
if config.get_by_tabname('disable_beep', 'false', room_from, False).lower() != 'true':
curses.beep()
+ def on_status_codes(self, message):
+ """
+ Handle groupchat messages with status codes.
+ Those are received when a room configuration change occurs.
+ """
+ room_from = message['from']
+ tab = self.get_tab_by_name(room_from, tabs.MucTab)
+ status_codes = set([s.attrib['code'] for s in message.findall('{%s}x/{%s}status' % (tabs.NS_MUC_USER, tabs.NS_MUC_USER))])
+ if '101' in status_codes:
+ self.information('Your affiliation in the room %s changed' % room_from, 'Info')
+ elif tab and status_codes:
+ show_unavailable = '102' in status_codes
+ hide_unavailable = '103' in status_codes
+ non_priv = '104' in status_codes
+ logging_on = '170' in status_codes
+ logging_off= '171' in status_codes
+ non_anon = '172' in status_codes
+ semi_anon = '173' in status_codes
+ full_anon = '174' in status_codes
+ modif = False
+ 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 occured.' % {'info_col': get_theme().COLOR_INFORMATION_TEXT[0]})
+ modif = True
+ if show_unavailable:
+ tab.add_message('\x19%(info_col)s}Info: The unavailable members are now shown.' % {'info_col': get_theme().COLOR_INFORMATION_TEXT[0]})
+ elif hide_unavailable:
+ tab.add_message('\x19%(info_col)s}Info: The unavailable members are now hidden.' % {'info_col': get_theme().COLOR_INFORMATION_TEXT[0]})
+ if non_anon:
+ tab.add_message('\x191}Warning:\x19%(info_col)s} The room is now not anonymous. (public JID)' % {'info_col': get_theme().COLOR_INFORMATION_TEXT[0]})
+ elif semi_anon:
+ tab.add_message('\x19%(info_col)s}Info: The room is now semi-anonymous. (moderators-only JID)' % {'info_col': get_theme().COLOR_INFORMATION_TEXT[0]})
+ elif full_anon:
+ tab.add_message('\x19%(info_col)s}Info: The room is now fully anonymous.' % {'info_col': get_theme().COLOR_INFORMATION_TEXT[0]})
+ if logging_on:
+ tab.add_message('\x191}Warning: \x19%(info_col)s}This room is publicly logged' % {'info_col': get_theme().COLOR_INFORMATION_TEXT[0]})
+ elif logging_off:
+ tab.add_message('\x19%(info_col)s}Info: This room is not logged anymore.' % {'info_col': get_theme().COLOR_INFORMATION_TEXT[0]})
+ if modif:
+ self.refresh_window()
+
+
def add_message_to_text_buffer(self, buff, txt, time=None, nickname=None, history=None):
"""
Add the message to the room if possible, else, add it to the Info window