gajim-plural/src/tabbed_chat_window.py

614 lines
21 KiB
Python
Raw Normal View History

## tabbed_chat_window.py
2005-03-11 18:57:35 +01:00
##
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <kourem@gmail.com>
##
## Copyright (C) 2003-2005 Gajim Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 2 only.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
import gtk
import gtk.glade
import pango
import gobject
import time
import urllib
import base64
2005-03-11 18:57:35 +01:00
import dialogs
import chat
2005-03-11 18:57:35 +01:00
from common import gajim
from common import helpers
2005-03-11 18:57:35 +01:00
from common import i18n
_ = i18n._
APP = i18n.APP
gtk.glade.bindtextdomain(APP, i18n.DIR)
gtk.glade.textdomain(APP)
GTKGUI_GLADE = 'gtkgui.glade'
2005-03-11 18:57:35 +01:00
class TabbedChatWindow(chat.Chat):
2005-03-11 18:57:35 +01:00
"""Class for tabbed chat window"""
def __init__(self, user, plugin, account):
chat.Chat.__init__(self, plugin, account, 'tabbed_chat_window')
2005-03-11 18:57:35 +01:00
self.users = {}
self.chatstates = {}
2005-07-19 23:40:08 +02:00
# keep check for possible paused timeouts per jid
self.possible_paused_timeout_id = {}
# keep check for possible inactive timeouts per jid
self.possible_inactive_timeout_id = {}
2005-03-11 18:57:35 +01:00
self.new_user(user)
self.show_title()
self.xml.signal_connect('on_tabbed_chat_window_destroy',
2005-03-11 18:57:35 +01:00
self.on_tabbed_chat_window_destroy)
self.xml.signal_connect('on_tabbed_chat_window_delete_event',
2005-03-11 18:57:35 +01:00
self.on_tabbed_chat_window_delete_event)
self.xml.signal_connect('on_tabbed_chat_window_focus_in_event',
2005-03-11 18:57:35 +01:00
self.on_tabbed_chat_window_focus_in_event)
self.xml.signal_connect('on_tabbed_chat_window_focus_out_event',
self.on_tabbed_chat_window_focus_out_event)
self.xml.signal_connect('on_tabbed_chat_window_button_press_event',
self.on_chat_window_button_press_event)
self.xml.signal_connect('on_chat_notebook_key_press_event',
self.on_chat_notebook_key_press_event)
self.xml.signal_connect('on_chat_notebook_switch_page',
2005-03-11 18:57:35 +01:00
self.on_chat_notebook_switch_page)
if gajim.config.get('saveposition'):
# get window position and size from config
self.window.move(gajim.config.get('chat-x-position'),
gajim.config.get('chat-y-position'))
self.window.resize(gajim.config.get('chat-width'),
gajim.config.get('chat-height'))
self.window.show_all()
def save_var(self, jid):
'''return the specific variable of a jid, like gpg_enabled
the return value have to be compatible with wthe one given to load_var'''
gpg_enabled = self.xmls[jid].get_widget('gpg_togglebutton').get_active()
return {'gpg_enabled': gpg_enabled}
def load_var(self, jid, var):
if not self.xmls.has_key(jid):
return
2005-05-04 18:22:07 +02:00
self.xmls[jid].get_widget('gpg_togglebutton').set_active(
var['gpg_enabled'])
2005-03-11 18:57:35 +01:00
def draw_widgets(self, contact):
2005-03-11 18:57:35 +01:00
"""draw the widgets in a tab (status_image, contact_button ...)
according to the the information in the contact variable"""
jid = contact.jid
self.set_state_image(jid)
2005-03-11 18:57:35 +01:00
contact_button = self.xmls[jid].get_widget('contact_button')
contact_button.set_use_underline(False)
2005-07-05 23:40:40 +02:00
tb = self.xmls[jid].get_widget('gpg_togglebutton')
2005-07-06 15:31:55 +02:00
if contact.keyID: # we can do gpg
2005-07-05 23:40:40 +02:00
tb.set_sensitive(True)
tt = _('OpenPGP Encryption')
else:
tb.set_sensitive(False)
2005-07-19 01:21:22 +02:00
tt = _('%s has not broadcasted an OpenPGP key nor you have assigned one') % contact.name
2005-07-05 23:40:40 +02:00
tip = gtk.Tooltips()
tip.set_tip(self.xmls[jid].get_widget('gpg_eventbox'), tt)
2005-03-11 18:57:35 +01:00
# add the fat line at the top
self.draw_name_banner(contact.name, jid)
def draw_name_banner(self, name, jid):
'''Draw the fat line at the top of the window that
houses the status icon, name, jid, and avatar'''
# this is the text for the big brown bar
# some chars need to be escaped.. this fixes '&'
name = name.replace('&', '&amp;')
#FIXME: uncomment me when we support sending messages to specific resource
# composing full jid
#fulljid = jid
#if self.users[jid].resource:
# fulljid += '/' + self.users[jid].resource
#label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \
# % (name, fulljid)
label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \
% (name, jid)
# setup the label that holds name and jid
banner_name_label = self.xmls[jid].get_widget('banner_name_label')
banner_name_label.set_markup(label_text)
2005-06-14 00:11:09 +02:00
self.paint_banner(jid)
def set_avatar(self, vcard):
if not vcard.has_key('PHOTO'):
return
2005-06-10 15:46:41 +02:00
if type(vcard['PHOTO']) != type({}):
return
img_decoded = None
if vcard['PHOTO'].has_key('BINVAL'):
try:
img_decoded = base64.decodestring(vcard['PHOTO']['BINVAL'])
except:
pass
elif vcard[i].has_key('EXTVAL'):
url = vcard[i]['EXTVAL']
try:
fd = urllib.urlopen(url)
img_decoded = fd.read()
except:
pass
if img_decoded:
pixbufloader = gtk.gdk.PixbufLoader()
pixbufloader.write(img_decoded)
pixbuf = pixbufloader.get_pixbuf()
pixbufloader.close()
scaled_buf = pixbuf.scale_simple(52, 52, gtk.gdk.INTERP_HYPER)
image = self.xmls[vcard['jid']].get_widget('avatar_image')
image.set_from_pixbuf(scaled_buf)
image.show_all()
2005-05-04 18:22:07 +02:00
def set_state_image(self, jid):
prio = 0
if gajim.contacts[self.account].has_key(jid):
list_users = gajim.contacts[self.account][jid]
else:
list_users = [self.users[jid]]
user = list_users[0]
show = user.show
jid = user.jid
2005-05-27 17:47:15 +02:00
keyID = user.keyID
for u in list_users:
if u.priority > prio:
prio = u.priority
show = u.show
keyID = u.keyID
child = self.childs[jid]
status_image = self.notebook.get_tab_label(child).get_children()[0]
state_images = self.plugin.roster.get_appropriate_state_images(jid)
image = state_images[show]
banner_status_image = self.xmls[jid].get_widget('banner_status_image')
if keyID:
self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(True)
else:
self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(False)
2005-03-11 18:57:35 +01:00
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
banner_status_image.set_from_animation(image.get_animation())
status_image.set_from_animation(image.get_animation())
2005-03-11 18:57:35 +01:00
elif image.get_storage_type() == gtk.IMAGE_PIXBUF:
# make a copy because one will be scaled, one not (tab icon)
pix = image.get_pixbuf()
scaled_pix = pix.scale_simple(32, 32, gtk.gdk.INTERP_BILINEAR)
banner_status_image.set_from_pixbuf(scaled_pix)
status_image.set_from_pixbuf(pix)
2005-03-11 18:57:35 +01:00
def on_tabbed_chat_window_delete_event(self, widget, event):
"""close window"""
for jid in self.users:
if time.time() - gajim.last_message_time[self.account][jid] < 2:
# 2 seconds
dialog = dialogs.ConfirmationDialog(
_('You just received a new message from "%s"' % jid),
2005-06-07 03:10:24 +02:00
_('If you close the window, this message will be lost.'))
if dialog.get_response() != gtk.RESPONSE_OK:
2005-03-11 18:57:35 +01:00
return True #stop the propagation of the event
if gajim.config.get('saveposition'):
# save the window size and position
x, y = self.window.get_position()
gajim.config.set('chat-x-position', x)
gajim.config.set('chat-y-position', y)
width, height = self.window.get_size()
gajim.config.set('chat-width', width)
gajim.config.set('chat-height', height)
2005-03-11 18:57:35 +01:00
def on_tabbed_chat_window_destroy(self, widget):
2005-07-19 17:39:24 +02:00
#clean self.plugin.windows[self.account]['chats']
chat.Chat.on_window_destroy(self, widget, 'chats')
def on_tabbed_chat_window_focus_in_event(self, widget, event):
chat.Chat.on_chat_window_focus_in_event(self, widget, event)
# on focus in, send 'active' chatstate
self.send_chatstate('active')
def on_tabbed_chat_window_focus_out_event(self, widget, event):
gobject.timeout_add(500, self.check_window_state, widget)
def check_window_state(self, widget):
''' we want: "minimized" or "focus-out"
not "focus-out, minimized" or "focus-out" '''
new_state = widget.window.get_state()
if new_state & gtk.gdk.WINDOW_STATE_ICONIFIED:
print 'iconify'
self.send_chatstate('inactive')
else:
print 'just focus-out'
self.send_chatstate('paused')
def on_chat_notebook_key_press_event(self, widget, event):
chat.Chat.on_chat_notebook_key_press_event(self, widget, event)
2005-03-11 18:57:35 +01:00
def on_send_button_clicked(self, widget):
"""When send button is pressed: send the current message"""
jid = self.get_active_jid()
message_textview = self.xmls[jid].get_widget('message_textview')
message_buffer = message_textview.get_buffer()
start_iter = message_buffer.get_start_iter()
end_iter = message_buffer.get_end_iter()
message = message_buffer.get_text(start_iter, end_iter, 0)
# send the message
self.send_message(message)
message_buffer.set_text('')
2005-03-11 18:57:35 +01:00
def remove_tab(self, jid):
if time.time() - gajim.last_message_time[self.account][jid] < 2:
dialog = dialogs.ConfirmationDialog(
_('You just received a new message from "%s"' % jid),
2005-06-07 03:10:24 +02:00
_('If you close this tab, the message will be lost.'))
if dialog.get_response() != gtk.RESPONSE_OK:
2005-03-11 18:57:35 +01:00
return
# chatstates - window is destroyed, send gone
self.send_chatstate('gone')
chat.Chat.remove_tab(self, jid, 'chats')
if len(self.xmls) > 0:
2005-03-11 18:57:35 +01:00
del self.users[jid]
def new_user(self, contact):
2005-06-03 23:52:36 +02:00
'''when new tab is created'''
self.names[contact.jid] = contact.name
self.xmls[contact.jid] = gtk.glade.XML(GTKGUI_GLADE, 'chats_vbox', APP)
self.childs[contact.jid] = self.xmls[contact.jid].get_widget('chats_vbox')
self.users[contact.jid] = contact
if contact.jid in gajim.encrypted_chats[self.account]:
self.xmls[contact.jid].get_widget('gpg_togglebutton').set_active(True)
2005-03-11 18:57:35 +01:00
xm = gtk.glade.XML(GTKGUI_GLADE, 'tabbed_chat_popup_menu', APP)
xm.signal_autoconnect(self)
self.tabbed_chat_popup_menu = xm.get_widget('tabbed_chat_popup_menu')
chat.Chat.new_tab(self, contact.jid)
self.redraw_tab(contact.jid)
self.draw_widgets(contact)
2005-06-03 23:52:36 +02:00
uf_show = helpers.get_uf_show(contact.show)
s = _('%s is %s') % (contact.name, uf_show)
if contact.status:
s += ' (' + contact.status + ')'
self.print_conversation(s, contact.jid, 'status')
2005-03-11 18:57:35 +01:00
#restore previous conversation
self.restore_conversation(contact.jid)
2005-03-11 18:57:35 +01:00
#print queued messages
if gajim.awaiting_messages[self.account].has_key(contact.jid):
self.read_queue(contact.jid)
2005-03-11 18:57:35 +01:00
gajim.connections[self.account].request_vcard(contact.jid)
self.childs[contact.jid].show_all()
# chatstates
2005-07-19 23:03:48 +02:00
self.kbd_activity_in_last_5_secs = False
self.mouse_over_in_last_5_secs = False
self.chatstates[contact.jid] = None # our current chatstate with contact
2005-07-19 23:40:08 +02:00
self.possible_paused_timeout_id[contact.jid] =\
gobject.timeout_add(5000, self.check_for_possible_paused_chatstate,
contact)
self.possible_inactive_timeout_id[contact.jid] =\
gobject.timeout_add(30000, self.check_for_possible_inactive_chatstate,
contact)
def check_for_possible_paused_chatstate(self, contact):
''' did we move mouse of that window or kbd activity in that window
if yes we go active if not already
if no we go paused if not already '''
current_state = self.chatstates[contact.jid]
2005-07-19 23:52:01 +02:00
if current_state == False: # he doesn't support chatstates
2005-07-19 23:40:08 +02:00
return False # stop looping
print 'mouse', self.mouse_over_in_last_5_secs
print 'kbd', self.kbd_activity_in_last_5_secs
2005-07-19 23:03:48 +02:00
if self.mouse_over_in_last_5_secs:
self.send_chatstate('active')
elif self.kbd_activity_in_last_5_secs:
2005-07-19 23:03:48 +02:00
self.send_chatstate('composing')
else:
2005-07-19 23:03:48 +02:00
self.send_chatstate('paused')
# assume no activity and let the motion-notify or key_press make them True
self.mouse_over_in_last_5_secs = False
self.kbd_activity_in_last_5_secs = False
2005-07-19 23:40:08 +02:00
return True # loop forever
def check_for_possible_inactive_chatstate(self, contact):
''' did we move mouse of that window or kbd activity in that window
if yes we go active if not already
if no we go inactive if not already '''
current_state = self.chatstates[contact.jid]
2005-07-19 23:52:01 +02:00
if current_state == False: # he doesn't support chatstates
2005-07-19 23:40:08 +02:00
return False # stop looping
2005-07-19 23:03:48 +02:00
if self.mouse_over_in_last_5_secs:
self.send_chatstate('active')
elif self.kbd_activity_in_last_5_secs:
self.send_chatstate('composing')
else:
2005-07-19 23:03:48 +02:00
self.send_chatstate('inactive')
# assume no activity and let the motion-notify or key_press make them True
self.mouse_over_in_last_5_secs = False
self.kbd_activity_in_last_5_secs = False
2005-07-19 23:40:08 +02:00
return True # loop forever
2005-03-11 18:57:35 +01:00
def on_message_textview_key_press_event(self, widget, event):
2005-04-12 17:30:09 +02:00
"""When a key is pressed:
if enter is pressed without the shift key, message (if not empty) is sent
2005-03-11 18:57:35 +01:00
and printed in the conversation"""
2005-07-19 23:03:48 +02:00
self.kbd_activity_in_last_5_secs = True
jid = self.get_active_jid()
conversation_textview = self.xmls[jid].get_widget('conversation_textview')
message_buffer = widget.get_buffer()
start_iter, end_iter = message_buffer.get_bounds()
message = message_buffer.get_text(start_iter, end_iter, False)
if event.keyval == gtk.keysyms.ISO_Left_Tab: # SHIFT + TAB
if event.state & gtk.gdk.CONTROL_MASK: # CTRL + SHIFT + TAB
2005-04-12 17:30:09 +02:00
self.notebook.emit('key_press_event', event)
if event.keyval == gtk.keysyms.Tab:
if event.state & gtk.gdk.CONTROL_MASK: # CTRL + TAB
2005-04-12 17:30:09 +02:00
self.notebook.emit('key_press_event', event)
elif event.keyval == gtk.keysyms.Page_Down: # PAGE DOWN
if event.state & gtk.gdk.CONTROL_MASK: # CTRL + PAGE DOWN
self.notebook.emit('key_press_event', event)
elif event.state & gtk.gdk.SHIFT_MASK: # SHIFT + PAGE DOWN
conversation_textview.emit('key_press_event', event)
elif event.keyval == gtk.keysyms.Page_Up: # PAGE UP
if event.state & gtk.gdk.CONTROL_MASK: # CTRL + PAGE UP
self.notebook.emit('key_press_event', event)
elif event.state & gtk.gdk.SHIFT_MASK: # SHIFT + PAGE UP
conversation_textview.emit('key_press_event', event)
2005-03-18 02:28:59 +01:00
elif event.keyval == gtk.keysyms.Return or \
event.keyval == gtk.keysyms.KP_Enter: # ENTER
if gajim.config.get('send_on_ctrl_enter'):
if not (event.state & gtk.gdk.CONTROL_MASK):
return False
elif (event.state & gtk.gdk.SHIFT_MASK):
return False
if gajim.connections[self.account].connected < 2: #we are not connected
dialogs.ErrorDialog(_("A connection is not available"),
2005-06-28 12:20:59 +02:00
_("Your message can't be sent until you are connected.")).get_response()
2005-03-16 18:08:38 +01:00
return True
# send the message
self.send_message(message)
message_buffer.set_text('')
2005-03-16 18:08:38 +01:00
return True
elif event.keyval == gtk.keysyms.Up:
if event.state & gtk.gdk.CONTROL_MASK: #Ctrl+UP
self.sent_messages_scroll(jid, 'up', widget.get_buffer())
return True # override the default gtk+ thing for ctrl+up
elif event.keyval == gtk.keysyms.Down:
if event.state & gtk.gdk.CONTROL_MASK: #Ctrl+Down
self.sent_messages_scroll(jid, 'down', widget.get_buffer())
return True # override the default gtk+ thing for ctrl+down
else:
# chatstates
# if composing, send chatstate
self.send_chatstate('composing')
def send_chatstate(self, state):
2005-07-19 23:03:48 +02:00
''' sends our chatstate to the current tab only if new chatstate
is different for the previous one'''
# please read jep-85 to get an idea of this
# we keep track of jep85 support by the peer by three extra states:
# None, False and 'ask'
# None if no info about peer
# False if peer does not support jep85
# 'ask' if we sent 'active' chatstate and are waiting for reply
jid = self.get_active_jid()
if self.chatstates[jid] == False:
return
# if current state equals last state, return
if self.chatstates[jid] == state:
return
if self.chatstates[jid] is None:
# state = 'ask'
# send and return
return
if self.chatstates[jid] == 'ask':
return
# if last state was composing, don't send active
if self.chatstates[jid] == 'composing' and state == 'active':
return
2005-03-11 18:57:35 +01:00
self.chatstates[jid] = state
gajim.connections[self.account].send_message(jid, None, None,
chatstate = state)
def send_message(self, message):
"""Send the message given to the active tab"""
2005-06-21 22:04:23 +02:00
if not message:
return
jid = self.get_active_jid()
conversation_textview = self.xmls[jid].get_widget('conversation_textview')
message_textview = self.xmls[jid].get_widget('message_textview')
message_buffer = message_textview.get_buffer()
if message != '' or message != '\n':
self.save_sent_message(jid, message)
if message == '/clear':
self.on_clear(None, conversation_textview) # clear conversation
self.on_clear(None, message_textview) # clear message textview too
return True
elif message == '/compact':
self.set_compact_view(not self.compact_view_current_state)
self.on_clear(None, message_textview)
return True
keyID = ''
encrypted = False
if self.xmls[jid].get_widget('gpg_togglebutton').get_active():
keyID = self.users[jid].keyID
encrypted = True
# chatstates - if no info about peer, discover
if self.chatstates[jid] is None:
gajim.connections[self.account].send_message(jid, message, keyID,
chatstate = 'active')
self.chatstates[jid] = 'ask'
# if peer supports jep85, send 'active'
elif self.chatstates[jid] != False:
2005-07-19 23:03:48 +02:00
#send active chatstate on every message (as JEP says)
gajim.connections[self.account].send_message(jid, message, keyID,
chatstate = 'active')
else: # just send the message
gajim.connections[self.account].send_message(jid, message, keyID)
message_buffer.set_text('')
self.print_conversation(message, jid, jid, encrypted = encrypted)
2005-03-11 18:57:35 +01:00
def on_contact_button_clicked(self, widget):
jid = self.get_active_jid()
contact = self.users[jid]
self.plugin.roster.on_info(widget, contact, self.account)
2005-03-11 18:57:35 +01:00
def read_queue(self, jid):
"""read queue and print messages containted in it"""
l = gajim.awaiting_messages[self.account][jid]
2005-03-11 18:57:35 +01:00
user = self.users[jid]
2005-06-08 12:02:50 +02:00
for event in l:
self.print_conversation(event[0], jid, tim = event[1],
encrypted = event[2])
2005-03-11 18:57:35 +01:00
self.plugin.roster.nb_unread -= 1
self.plugin.roster.show_title()
del gajim.awaiting_messages[self.account][jid]
self.plugin.roster.draw_contact(jid, self.account)
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account)
showOffline = gajim.config.get('showoffline')
2005-03-11 18:57:35 +01:00
if (user.show == 'offline' or user.show == 'error') and \
not showOffline:
if len(gajim.contacts[self.account][jid]) == 1:
2005-04-12 17:30:09 +02:00
self.plugin.roster.really_remove_user(user, self.account)
2005-03-11 18:57:35 +01:00
def print_conversation(self, text, jid, contact = '', tim = None,
encrypted = False, subject = None):
"""Print a line in the conversation:
if contact is set to status: it's a status message
if contact is set to another value: it's an outgoing message
if contact is not set: it's an incomming message"""
2005-03-11 18:57:35 +01:00
user = self.users[jid]
if contact == 'status':
kind = 'status'
name = ''
2005-03-11 18:57:35 +01:00
else:
ec = gajim.encrypted_chats[self.account]
if encrypted and jid not in ec:
msg = _('Encryption enabled')
chat.Chat.print_conversation_line(self, msg, jid,
'status', '', tim)
ec.append(jid)
if not encrypted and jid in ec:
msg = _('Encryption disabled')
chat.Chat.print_conversation_line(self, msg, jid,
'status', '', tim)
ec.remove(jid)
self.xmls[jid].get_widget('gpg_togglebutton').set_active(encrypted)
2005-03-11 18:57:35 +01:00
if contact:
kind = 'outgoing'
name = gajim.nicks[self.account]
2005-03-11 18:57:35 +01:00
else:
kind = 'incoming'
2005-03-11 18:57:35 +01:00
name = user.name
chat.Chat.print_conversation_line(self, text, jid, kind, name, tim,
subject = subject)
2005-05-30 23:12:34 +02:00
def restore_conversation(self, jid):
2005-05-31 19:53:28 +02:00
# don't restore lines if it's a transport
2005-06-07 03:10:24 +02:00
is_transport = jid.startswith('aim') or jid.startswith('gadugadu') or\
jid.startswith('irc') or jid.startswith('icq') or\
jid.startswith('msn') or jid.startswith('sms') or\
jid.startswith('yahoo')
2005-05-30 23:16:59 +02:00
2005-05-30 23:12:34 +02:00
if is_transport:
return
2005-05-30 23:12:34 +02:00
#How many lines to restore and when to time them out
restore = gajim.config.get('restore_lines')
time_out = gajim.config.get('restore_timeout')
2005-05-30 23:12:34 +02:00
pos = 0 #position, while reading from history
size = 0 #how many lines we alreay retreived
lines = [] #we'll need to reverse the lines from history
count = gajim.logger.get_nb_line(jid)
if gajim.awaiting_messages[self.account].has_key(jid):
pos = len(gajim.awaiting_messages[self.account][jid])
else:
pos = 0
now = time.time()
2005-05-30 23:12:34 +02:00
while size <= restore:
if pos == count or size > restore - 1:
#don't try to read beyond history, not read more than required
break
nb, line = gajim.logger.read(jid, count - 1 - pos, count - pos)
pos = pos + 1
if (now - float(line[0][0]))/60 >= time_out:
#stop looking for messages if we found something too old
break
2005-05-30 23:12:34 +02:00
if line[0][1] != 'sent' and line[0][1] != 'recv':
# we don't want to display status lines, do we?
continue
lines.append(line[0])
size = size + 1
lines.reverse()
2005-05-30 23:12:34 +02:00
for msg in lines:
if msg[1] == 'sent':
kind = 'outgoing'
name = gajim.nicks[self.account]
2005-05-30 23:12:34 +02:00
elif msg[1] == 'recv':
kind = 'incoming'
2005-05-31 15:07:35 +02:00
name = self.users[jid].name
2005-05-30 23:12:34 +02:00
tim = time.localtime(float(msg[0]))
text = ':'.join(msg[2:])[:-1] #remove the latest \n
self.print_conversation_line(text, jid, kind, name, tim,
['small'], ['small', 'grey'], ['small', 'grey'], False)
if len(lines):
self.print_empty_line(jid)