diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-03-19 03:30:51 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-03-19 03:30:51 +0000 |
commit | a923d32ee47fab1aa5de01a1c41a8082c108a649 (patch) | |
tree | 0f3248fb54f48a149bc71b43dbd7088da98f32b6 /src/gui.py | |
parent | d25f061a8bfc71317f045c6b78d98777cd871098 (diff) | |
download | poezio-a923d32ee47fab1aa5de01a1c41a8082c108a649.tar.gz poezio-a923d32ee47fab1aa5de01a1c41a8082c108a649.tar.bz2 poezio-a923d32ee47fab1aa5de01a1c41a8082c108a649.tar.xz poezio-a923d32ee47fab1aa5de01a1c41a8082c108a649.zip |
fixed #1230 Do not put the 'there is a message' color when the message is from the MUC history
Diffstat (limited to 'src/gui.py')
-rw-r--r-- | src/gui.py | 41 |
1 files changed, 19 insertions, 22 deletions
@@ -20,6 +20,7 @@ from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset, gettext as _) + bindtextdomain('poezio') textdomain('poezio') bind_textdomain_codeset('poezio', 'utf-8') @@ -29,7 +30,13 @@ locale.setlocale(locale.LC_ALL, '') import sys import curses +import xmpp from datetime import datetime +from time import (altzone, daylight, gmtime, localtime, mktime, strftime, + time as time_time, timezone, tzname) +from calendar import timegm + +import common from handler import Handler from logging import logger @@ -98,7 +105,6 @@ class Gui(object): self.handler.connect('join-room', self.join_room) self.handler.connect('room-presence', self.room_presence) self.handler.connect('room-message', self.room_message) - self.handler.connect('room-delayed-message', self.room_delayed_message) def main_loop(self, stdscr): while 1: @@ -211,16 +217,17 @@ class Gui(object): self.rooms.insert(0, self.rooms.pop()) self.window.refresh(self.rooms) - def room_delayed_message(self, stanza): - self.room_message(stanza) - def room_message(self, stanza, date=None): + delay_tag = stanza.getTag('delay', namespace='urn:xmpp:delay') + if delay_tag and not date: + delayed = True + date = common.datetime_tuple(delay_tag.getAttr('stamp')) + else: + delayed = False if len(sys.argv) > 1: self.information(str(stanza).encode('utf-8')) if stanza.getType() != 'groupchat': return # ignore all messages not comming from a MUC - if not date: - date = datetime.now() nick_from = stanza.getFrom().getResource() room_from = stanza.getFrom().getStripped() room = self.get_room_by_name(room_from) @@ -241,7 +248,7 @@ class Gui(object): if body.startswith('/me '): self.add_info(room, nick_from + ' ' + body[4:], date) else: - self.add_message(room, nick_from, body, date) + self.add_message(room, nick_from, body, date, delayed) self.window.input.refresh() curses.doupdate() @@ -332,14 +339,14 @@ class Gui(object): self.window.input.refresh() curses.doupdate() - def add_message(self, room, nick_from, body, date=None): + def add_message(self, room, nick_from, body, date=None, delayed=False): if not date: date = datetime.now() color = room.add_message(nick_from, body, date) self.window.text_win.add_line(room, (date, nick_from.encode('utf-8'), body.encode('utf-8'), color)) if room == self.current_room(): self.window.text_win.refresh(room.name) - else: + elif not delayed: self.window.info_win.refresh(self.rooms, self.current_room()) def execute(self): @@ -374,10 +381,7 @@ class Gui(object): msg = self.commands[args[0]][1] else: msg = _('Unknown command: %s') % args[0] - room.add_info(msg) - self.window.text_win.add_line(room, (datetime.now(), msg)) - self.window.text_win.refresh(room.name) - self.window.input.refresh() + self.add_info(room, msg) def command_win(self, args): if len(args) != 1: @@ -400,7 +404,6 @@ class Gui(object): return self.window.refresh(self.rooms) - def command_kick(self, args): if len(args) < 1: self.command_help(['kick']) @@ -486,10 +489,7 @@ class Gui(object): config.set_and_save(option, value) msg = "%s=%s" % (option, value) room = self.current_room() - room.add_info(msg) - self.window.text_win.add_line(room, (datetime.now(), msg)) - self.window.text_win.refresh(room.name) - self.window.input.refresh() + self.add_info(room, msg) def command_show(self, args): possible_show = {'avail':'None', @@ -555,10 +555,7 @@ class Gui(object): def information(self, msg): room = self.get_room_by_name("Info") info = room.add_info(msg) - if self.current_room() == room: - self.window.text_win.add_line(room, (datetime.now(), info)) - self.window.text_win.refresh(room.name) - curses.doupdate() + self.add_info(room, msg) def command_quit(self, args): self.reset_curses() |