summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core.py14
-rw-r--r--src/logger.py10
-rw-r--r--src/tabs.py5
3 files changed, 24 insertions, 5 deletions
diff --git a/src/core.py b/src/core.py
index 3f24fb1b..22398ac4 100644
--- a/src/core.py
+++ b/src/core.py
@@ -215,6 +215,7 @@ class Core(object):
def grow_information_win(self, nb=1):
if self.information_win_size == 14:
+ self.refresh_window()
return
self.information_win_size += nb
if self.information_win_size > 14:
@@ -335,6 +336,7 @@ class Core(object):
def on_got_offline(self, presence):
jid = presence['from']
contact = roster.get_contact_by_jid(jid.bare)
+ logger.log_roster_change(jid.bare, 'got offline')
if not contact:
return
log.debug('on_got_offline: %s' % presence)
@@ -356,6 +358,7 @@ class Core(object):
if not contact:
# Todo, handle presence comming from contacts not in roster
return
+ logger.log_roster_change(jid.bare, 'got online')
resource = contact.get_resource_by_fulljid(jid.full)
assert not resource
resource = Resource(jid.full)
@@ -483,11 +486,12 @@ class Core(object):
# Differentiate both type of messages, and call the appropriate handler.
jid_from = message['from']
for tab in self.tabs:
- if tab.get_name() == jid_from.bare and isinstance(tab, tabs.MucTab):
+ if tab.get_name() == jid_from and isinstance(tab, tabs.PrivateTab):
if message['type'] == 'error':
- return self.room_error(message, tab.get_room().name)
+ return self.room_error(message, jid_from)
else:
return self.on_groupchat_private_message(message)
+
return self.on_normal_message(message)
def on_groupchat_private_message(self, message):
@@ -1388,13 +1392,17 @@ class Core(object):
def information(self, msg, typ=''):
"""
- Displays an informational message in the "Info" room window
+ Displays an informational message in the "Info" buffer
"""
nb_lines = self.information_buffer.add_message(msg, nickname=typ)
if typ != '' and typ.lower() in config.get('information_buffer_popup_on',
'error roster warning help info').split():
popup_time = config.get('popup_time', 4) + (nb_lines - 1) * 2
self.pop_information_win_up(nb_lines, popup_time)
+ else:
+ if self.information_win_size != 0:
+ self.information_win.refresh(self.information_buffer)
+ self.current_tab().input.refresh()
def disconnect(self, msg=None, reconnect=False):
"""
diff --git a/src/logger.py b/src/logger.py
index ad615f9b..d87eaa6b 100644
--- a/src/logger.py
+++ b/src/logger.py
@@ -34,6 +34,7 @@ class Logger(object):
"""
def __init__(self):
self.logfile = config.get('logfile', 'logs')
+ self.roster_logfile = None
# a dict of 'groupchatname': file-object (opened)
self.fds = dict()
@@ -81,4 +82,13 @@ class Logger(object):
else:
fd.flush() # TODO do something better here?
+ def log_roster_change(self, jid, message):
+ if not self.roster_logfile:
+ try:
+ self.roster_logfile = open(os.path.join(DATA_HOME, 'logs', 'roster.log'), 'a')
+ except IOError:
+ return
+ self.roster_logfile.write('%s %s %s\n' % (datetime.now().strftime('%d-%m-%y [%H:%M:%S]'), jid, message))
+ self.roster_logfile.flush()
+
logger = Logger()
diff --git a/src/tabs.py b/src/tabs.py
index f69ef919..c396c270 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -1049,7 +1049,8 @@ class PrivateTab(ChatTab):
empty_before = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
self.input.do_command(key)
empty_after = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
- self.send_composing_chat_state(empty_before, empty_after)
+ if self.core.get_tab_by_name(JID(self.get_room().name).bare, MucTab).get_room().joined:
+ self.send_composing_chat_state(empty_before, empty_after)
return False
def on_lose_focus(self):
@@ -1062,7 +1063,7 @@ class PrivateTab(ChatTab):
def on_gain_focus(self):
self._room.set_color_state(theme.COLOR_TAB_CURRENT)
curses.curs_set(1)
- if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text():
+ if self.get_room().joined and config.get('send_chat_states', 'true') == 'true' and not self.input.get_text():
self.send_chat_state('active')
def on_scroll_up(self):