diff --git a/core/core.py b/core/core.py
index 869dccd68..13dc8107a 100644
--- a/core/core.py
+++ b/core/core.py
@@ -32,6 +32,7 @@ log = logging.getLogger('core.core')
log.setLevel(logging.DEBUG)
CONFPATH = "~/.gajim/config"
+LOGPATH = os.path.expanduser("~/.gajim/logs/")
class GajimCore:
"""Core"""
@@ -390,6 +391,29 @@ class GajimCore:
t='available';
p = common.jabber.Presence(to=ev[2][0], type=t)
con.send(p)
+ #('LOG_NB_LINE', account, jid)
+ elif ev[0] == 'LOG_NB_LINE':
+ fic = open(LOGPATH + ev[2], "r")
+ nb = 0
+ while (fic.readline()):
+ nb = nb+1
+ fic.close()
+ self.hub.sendPlugin('LOG_NB_LINE', ev[1], (ev[2], nb))
+ #('LOG_GET_RANGE', account, (jid, line_begin, line_end))
+ elif ev[0] == 'LOG_GET_RANGE':
+ fic = open(LOGPATH + ev[2][0], "r")
+ nb = 0
+ while (nb < ev[2][1] and fic.readline()):
+ nb = nb+1
+ while nb < ev[2][2]:
+ line = fic.readline()
+ nb = nb+1
+ if line:
+ lineSplited = string.split(line, ':')
+ if len(lineSplited) > 2:
+ self.hub.sendPlugin('LOG_LINE', ev[1], (ev[2][0], nb, \
+ lineSplited[0], lineSplited[1], lineSplited[2:]))
+ fic.close()
else:
log.debug("Unknown Command %s" % ev[0])
else:
@@ -423,6 +447,8 @@ def loadPlugins(gc):
gc.hub.register(mod, 'ACC_OK')
gc.hub.register(mod, 'CONFIG')
gc.hub.register(mod, 'VCARD')
+ gc.hub.register(mod, 'LOG_NB_LINE')
+ gc.hub.register(mod, 'LOG_LINE')
modObj.load()
# END loadPLugins
diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade
index cf7b31eab..d0b18db88 100644
--- a/plugins/gtkgui/gtkgui.glade
+++ b/plugins/gtkgui/gtkgui.glade
@@ -354,6 +354,7 @@
True
True
GTK_RELIEF_NORMAL
+
@@ -617,6 +618,7 @@
GTK_WINDOW_TOPLEVEL
GTK_WIN_POS_NONE
False
+ 200
True
False
@@ -6360,4 +6362,293 @@ when NOT onlie
+
+ True
+ Log
+ GTK_WINDOW_TOPLEVEL
+ GTK_WIN_POS_NONE
+ False
+ True
+ False
+
+
+
+
+ True
+ False
+ 0
+
+
+
+ 10
+ True
+ GTK_BUTTONBOX_DEFAULT_STYLE
+ 5
+
+
+
+ True
+ True
+ True
+ GTK_RELIEF_NORMAL
+
+
+
+
+ True
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+
+ True
+ False
+ 2
+
+
+
+ True
+ gtk-goto-first
+ 4
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ earliest
+ True
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ True
+ GTK_RELIEF_NORMAL
+
+
+
+
+ True
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+
+ True
+ False
+ 2
+
+
+
+ True
+ gtk-go-back
+ 4
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ Previous
+ True
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ True
+ gtk-go-forward
+ True
+ GTK_RELIEF_NORMAL
+
+
+
+
+
+
+ True
+ True
+ True
+ GTK_RELIEF_NORMAL
+
+
+
+
+ True
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+
+ True
+ False
+ 2
+
+
+
+ True
+ gtk-goto-last
+ 4
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ lastest
+ True
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ True
+ gtk-close
+ True
+ GTK_RELIEF_NORMAL
+
+
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ True
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
+ GTK_SHADOW_NONE
+ GTK_CORNER_TOP_LEFT
+
+
+
+ True
+ True
+ True
+ GTK_JUSTIFY_LEFT
+ GTK_WRAP_NONE
+ True
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+
+
+ 0
+ True
+ True
+
+
+
+
+
+
diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py
index 0dcf6a901..5213264d0 100644
--- a/plugins/gtkgui/gtkgui.py
+++ b/plugins/gtkgui/gtkgui.py
@@ -1016,6 +1016,11 @@ class message_Window:
deb, end = buffer.get_bounds()
buffer.delete(deb, end)
+ def on_history(self, widget):
+ """When history button is pressed : call log window"""
+ if not self.plugin.windows['logs'].has_key(self.user.jid):
+ self.plugin.windows['logs'][self.user.jid] = log_Window(self.plugin, self.user.jid)
+
def __init__(self, user, plugin, account):
self.user = user
self.plugin = plugin
@@ -1038,27 +1043,165 @@ class message_Window:
buffer.create_mark('end', end_iter, 0)
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
self.xml.signal_connect('on_clear_clicked', self.on_clear)
+ self.xml.signal_connect('on_history_clicked', self.on_history)
self.xml.signal_connect('on_msg_key_press_event', \
self.on_msg_key_press_event)
- self.tagIn = buffer.create_tag("incoming")
+ tagIn = buffer.create_tag("incoming")
color = self.plugin.config['inmsgcolor']
if not color:
color = 'red'
- self.tagIn.set_property("foreground", color)
- self.tagOut = buffer.create_tag("outgoing")
+ tagIn.set_property("foreground", color)
+ tagOut = buffer.create_tag("outgoing")
color = self.plugin.config['outmsgcolor']
if not color:
color = 'blue'
- self.tagOut.set_property("foreground", color)
- self.tagStatus = buffer.create_tag("status")
+ tagOut.set_property("foreground", color)
+ tagStatus = buffer.create_tag("status")
color = self.plugin.config['statusmsgcolor']
if not color:
color = 'green'
- self.tagStatus.set_property("foreground", color)
+ tagStatus.set_property("foreground", color)
#print queued messages
if plugin.queues[account].has_key(user.jid):
self.read_queue(plugin.queues[account][user.jid])
+class log_Window:
+ """Class for bowser agent window :
+ to know the agents on the selected server"""
+ def delete_event(self, widget):
+ """close window"""
+ del self.plugin.windows['logs'][self.jid]
+
+ def on_close(self, widget):
+ """When Close button is clicked"""
+ widget.get_toplevel().destroy()
+
+ def on_earliest(self, widget):
+ buffer = self.xml.get_widget('textview').get_buffer()
+ start, end = buffer.get_bounds()
+ buffer.delete(start, end)
+ self.xml.get_widget('earliest_button').set_sensitive(False)
+ self.xml.get_widget('previous_button').set_sensitive(False)
+ self.xml.get_widget('forward_button').set_sensitive(True)
+ self.xml.get_widget('lastest_button').set_sensitive(True)
+ end = 50
+ if end > self.nb_line:
+ end = nb_line
+ self.plugin.send('LOG_GET_RANGE', None, (self.jid, 0, end))
+ self.num_begin = self.nb_line
+
+ def on_previous(self, widget):
+ buffer = self.xml.get_widget('textview').get_buffer()
+ start, end = buffer.get_bounds()
+ buffer.delete(start, end)
+ self.xml.get_widget('earliest_button').set_sensitive(True)
+ self.xml.get_widget('previous_button').set_sensitive(True)
+ self.xml.get_widget('forward_button').set_sensitive(True)
+ self.xml.get_widget('lastest_button').set_sensitive(True)
+ begin = self.num_begin - 50
+ if begin < 0:
+ begin = 0
+ end = begin + 50
+ if end > self.nb_line:
+ end = self.nb_line
+ self.plugin.send('LOG_GET_RANGE', None, (self.jid, begin, end))
+ self.num_begin = self.nb_line
+
+ def on_forward(self, widget):
+ buffer = self.xml.get_widget('textview').get_buffer()
+ start, end = buffer.get_bounds()
+ buffer.delete(start, end)
+ self.xml.get_widget('earliest_button').set_sensitive(True)
+ self.xml.get_widget('previous_button').set_sensitive(True)
+ self.xml.get_widget('forward_button').set_sensitive(True)
+ self.xml.get_widget('lastest_button').set_sensitive(True)
+ begin = self.num_begin + 50
+ if begin > self.nb_line:
+ begin = self.nb_line
+ end = begin + 50
+ if end > self.nb_line:
+ end = self.nb_line
+ self.plugin.send('LOG_GET_RANGE', None, (self.jid, begin, end))
+ self.num_begin = self.nb_line
+
+ def on_latest(self, widget):
+ buffer = self.xml.get_widget('textview').get_buffer()
+ start, end = buffer.get_bounds()
+ buffer.delete(start, end)
+ self.xml.get_widget('earliest_button').set_sensitive(True)
+ self.xml.get_widget('previous_button').set_sensitive(True)
+ self.xml.get_widget('forward_button').set_sensitive(False)
+ self.xml.get_widget('lastest_button').set_sensitive(False)
+ begin = self.nb_line - 50
+ if begin < 0:
+ begin = 0
+ self.plugin.send('LOG_GET_RANGE', None, (self.jid, begin, self.nb_line))
+ self.num_begin = self.nb_line
+
+ def new_line(self, infos):
+ """write a new line"""
+ #infos = [num_line, date, type, data]
+ if infos[0] < self.num_begin:
+ self.num_begin = infos[0]
+ if infos[0] == 0:
+ self.xml.get_widget('earliest_button').set_sensitive(False)
+ self.xml.get_widget('previous_button').set_sensitive(False)
+ if infos[0] == self.nb_line:
+ self.xml.get_widget('forward_button').set_sensitive(False)
+ self.xml.get_widget('lastest_button').set_sensitive(False)
+ buffer = self.xml.get_widget('textview').get_buffer()
+ start_iter = buffer.get_start_iter()
+ end_iter = buffer.get_end_iter()
+ tim = time.strftime("[%x %X] ", time.localtime(float(infos[1])))
+ buffer.insert(start_iter, tim)
+ if infos[2] == 'recv':
+ msg = string.join(infos[3][0:], ':')
+ msg = string.replace(msg, '\\n', '\n')
+ buffer.insert_with_tags_by_name(start_iter, msg, 'incoming')
+ elif infos[2] == 'sent':
+ msg = string.join(infos[3][0:], ':')
+ msg = string.replace(msg, '\\n', '\n')
+ buffer.insert_with_tags_by_name(start_iter, msg, 'outgoing')
+ else:
+ msg = string.join(infos[3][1:], ':')
+ msg = string.replace(msg, '\\n', '\n')
+ buffer.insert_with_tags_by_name(start_iter, 'Status is now : ' + \
+ infos[3][0]+' : ' + msg, 'status')
+
+ def set_nb_line(self, nb_line):
+ self.nb_line = nb_line
+ self.num_begin = nb_line
+
+ def __init__(self, plugin, jid):
+ self.plugin = plugin
+ self.jid = jid
+ self.nb_line = 0
+ self.num_begin = 0
+ self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Log')
+ self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
+ self.xml.signal_connect('on_close_clicked', self.on_close)
+ self.xml.signal_connect('on_earliest_clicked', self.on_earliest)
+ self.xml.signal_connect('on_previous_clicked', self.on_previous)
+ self.xml.signal_connect('on_forward_clicked', self.on_forward)
+ self.xml.signal_connect('on_latest_clicked', self.on_latest)
+ buffer = self.xml.get_widget('textview').get_buffer()
+ tagIn = buffer.create_tag("incoming")
+ color = self.plugin.config['inmsgcolor']
+ if not color:
+ color = 'red'
+ tagIn.set_property("foreground", color)
+ tagOut = buffer.create_tag("outgoing")
+ color = self.plugin.config['outmsgcolor']
+ if not color:
+ color = 'blue'
+ tagOut.set_property("foreground", color)
+ tagStatus = buffer.create_tag("status")
+ color = self.plugin.config['statusmsgcolor']
+ if not color:
+ color = 'green'
+ tagStatus.set_property("foreground", color)
+ self.plugin.send('LOG_NB_LINE', None, jid)
+
class roster_Window:
"""Class for main gtk window"""
@@ -1928,6 +2071,20 @@ class plugin:
elif ev[0] == 'VCARD':
if self.windows[ev[1]]['infos'].has_key(ev[2]['jid']):
self.windows[ev[1]]['infos'][ev[2]['jid']].set_values(ev[2])
+ #('LOG_NB_LINE', account, (jid, nb_line))
+ elif ev[0] == 'LOG_NB_LINE':
+ if self.windows['logs'].has_key(ev[2][0]):
+ self.windows['logs'][ev[2][0]].set_nb_line(ev[2][1])
+ begin = 0
+ if ev[2][1] > 50:
+ begin = ev[2][1] - 50
+ self.send('LOG_GET_RANGE', None, (ev[2][0], begin, ev[2][1]))
+ #('LOG_LINE', account, (jid, num_line, date, type, data))
+ # if type = 'recv' or 'sent' data = [msg]
+ # else type = jid and data = [status, away_msg]
+ elif ev[0] == 'LOG_LINE':
+ if self.windows['logs'].has_key(ev[2][0]):
+ self.windows['logs'][ev[2][0]].new_line(ev[2][1:])
return 1
def read_sleepy(self):
@@ -1971,7 +2128,7 @@ class plugin:
self.config = self.wait('CONFIG')
self.send('ASK_CONFIG', None, ('GtkGui', 'accounts'))
self.accounts = self.wait('CONFIG')
- self.windows = {}
+ self.windows = {'logs':{}}
self.queues = {}
self.connected = {}
for a in self.accounts.keys():
diff --git a/plugins/logger/logger.py b/plugins/logger/logger.py
index 614db43bf..5842234b2 100644
--- a/plugins/logger/logger.py
+++ b/plugins/logger/logger.py
@@ -21,7 +21,6 @@ import os
import string
import time
import common.optparser
-CONFPATH = "~/.gajim/config"
LOGPATH = os.path.expanduser("~/.gajim/logs/")
class plugin:
@@ -36,8 +35,7 @@ class plugin:
lognotusr = self.config['lognotusr']
else:
lognotusr = 1
-# tim = time.strftime("%d%m%y%H%M%S")
- tim = "%d" % time.time()
+ tim = time.time()
ev = self.queueIN.get()
if ev[0] == 'QUIT':
@@ -48,6 +46,7 @@ class plugin:
jid = string.split(ev[2][0], '/')[0]
if not status:
status = ""
+ status = string.replace(status, '\n', '\\n')
if lognotsep == 1:
fic = open(LOGPATH + "notify.log", "a")
fic.write("%s:%s:%s:%s\n" % (tim, ev[2][0], \
@@ -59,14 +58,16 @@ class plugin:
ev[2][1], status))
fic.close()
elif ev[0] == 'MSG':
+ msg = string.replace(ev[2][1], '\n', '\\n')
jid = string.split(ev[2][0], '/')[0]
fic = open(LOGPATH + jid, "a")
- fic.write("%s:recv:%s\n" % (tim, ev[2][1]))
+ fic.write("%s:recv:%s\n" % (tim, msg))
fic.close()
elif ev[0] == 'MSGSENT':
+ msg = string.replace(ev[2][1], '\n', '\\n')
jid = string.split(ev[2][0], '/')[0]
fic = open(LOGPATH + jid, "a")
- fic.write("%s:sent:%s\n" % (tim, ev[2][1]))
+ fic.write("%s:sent:%s\n" % (tim, msg))
fic.close()
time.sleep(0.5)