we now have history for gc too
This commit is contained in:
parent
1a5667ff1e
commit
f1d1a0a07e
10
src/chat.py
10
src/chat.py
|
@ -23,6 +23,7 @@ import pango
|
|||
import gobject
|
||||
import time
|
||||
import dialogs
|
||||
import history_window
|
||||
|
||||
try:
|
||||
import gtkspell
|
||||
|
@ -160,6 +161,15 @@ class Chat:
|
|||
"""When close button is pressed: close a tab"""
|
||||
self.remove_tab(jid)
|
||||
|
||||
def on_history_button_clicked(self, widget):
|
||||
"""When history button is pressed: call history window"""
|
||||
jid = self.get_active_jid()
|
||||
if self.plugin.windows['logs'].has_key(jid):
|
||||
self.plugin.windows['logs'][jid].window.present()
|
||||
else:
|
||||
self.plugin.windows['logs'][jid] = history_window.\
|
||||
HistoryWindow(self.plugin, jid, self.account)
|
||||
|
||||
def on_chat_window_focus_in_event(self, widget, event):
|
||||
"""When window gets focus"""
|
||||
jid = self.get_active_jid()
|
||||
|
|
|
@ -307,7 +307,7 @@ class Connection:
|
|||
errcode))
|
||||
if not ptype or ptype == 'unavailable':
|
||||
jid = prs.getFrom()
|
||||
gajim.logger.write('status', status, jid.getStripped().encode('utf8'), show)
|
||||
gajim.logger.write('status', status, str(jid).encode('utf8'), show)
|
||||
account = prs.getFrom().getStripped().encode('utf8')
|
||||
resource = prs.getFrom().getResource().encode('utf8')
|
||||
self.dispatch('NOTIFY', ( account, show, status,
|
||||
|
|
|
@ -74,6 +74,9 @@ class Logger:
|
|||
if common.gajim.config.get('log_notif_in_user_file'):
|
||||
path_to_file = os.path.join(LOGPATH, ji)
|
||||
if os.path.isdir(path_to_file):
|
||||
jid = 'gcstatus'
|
||||
msg = show + ':' + msg
|
||||
show = nick
|
||||
files.append(ji + '/' + ji)
|
||||
if os.path.isfile(jid):
|
||||
files.append(jid)
|
||||
|
@ -118,12 +121,20 @@ class Logger:
|
|||
fic.write('\n')
|
||||
fic.close()
|
||||
|
||||
def get_nb_line(self, jid):
|
||||
def __get_path_to_file(self, fjid):
|
||||
jid = fjid.split('/')[0]
|
||||
path_to_file = os.path.join(LOGPATH, jid)
|
||||
if os.path.isdir(path_to_file):
|
||||
if fjid == jid: # we want to read the gc history
|
||||
path_to_file = os.path.join(LOGPATH, jid + '/' + jid)
|
||||
else: #we want to read pm history
|
||||
path_to_file = os.path.join(LOGPATH, fjid)
|
||||
return path_to_file
|
||||
|
||||
def get_nb_line(self, fjid):
|
||||
'''return total number of lines in a log file
|
||||
return 0 if log file does not exist'''
|
||||
path_to_file = os.path.join(LOGPATH, jid.split('/')[0])
|
||||
if os.path.isdir(path_to_file):
|
||||
path_to_file = os.path.join(LOGPATH, jid)
|
||||
path_to_file = self.__get_path_to_file(fjid)
|
||||
if not os.path.exists(path_to_file):
|
||||
return 0
|
||||
fic = open(path_to_file, 'r')
|
||||
|
@ -133,12 +144,10 @@ class Logger:
|
|||
fic.close()
|
||||
return nb
|
||||
|
||||
def read(self, jid, begin_line, end_line):
|
||||
def read(self, fjid, begin_line, end_line):
|
||||
'''return number of lines read and the text in the lines
|
||||
return 0 and empty respectively if log file does not exist'''
|
||||
path_to_file = os.path.join(LOGPATH, jid.split('/')[0])
|
||||
if os.path.isdir(path_to_file):
|
||||
path_to_file = os.path.join(LOGPATH, jid)
|
||||
path_to_file = self.__get_path_to_file(fjid)
|
||||
if not os.path.exists(path_to_file):
|
||||
return 0, []
|
||||
fic = open(path_to_file, 'r')
|
||||
|
|
|
@ -125,7 +125,17 @@ class HistoryWindow:
|
|||
end_iter = buffer.get_end_iter()
|
||||
tim = time.strftime('[%x %X] ', time.localtime(float(date)))
|
||||
buffer.insert(start_iter, tim)
|
||||
if type == 'recv':
|
||||
if type == 'gc':
|
||||
msg = ':'.join(data[1:])
|
||||
buffer.insert_with_tags_by_name(start_iter, msg,
|
||||
'incoming')
|
||||
elif type == 'gcstatus':
|
||||
nick = data[0]
|
||||
show = data[1]
|
||||
msg = ':'.join(data[2:])
|
||||
buffer.insert_with_tags_by_name(start_iter,
|
||||
_('%s is now %s: %s') % (nick, show, msg), 'status')
|
||||
elif type == 'recv':
|
||||
msg = ':'.join(data[0:])
|
||||
buffer.insert_with_tags_by_name(start_iter, msg,
|
||||
'incoming')
|
||||
|
|
|
@ -26,7 +26,6 @@ import urllib
|
|||
import base64
|
||||
|
||||
import dialogs
|
||||
import history_window
|
||||
import chat
|
||||
|
||||
from common import gajim
|
||||
|
@ -208,15 +207,6 @@ class TabbedChatWindow(chat.Chat):
|
|||
def on_chat_notebook_key_press_event(self, widget, event):
|
||||
chat.Chat.on_chat_notebook_key_press_event(self, widget, event)
|
||||
|
||||
def on_history_button_clicked(self, widget):
|
||||
"""When history button is pressed: call history window"""
|
||||
jid = self.get_active_jid()
|
||||
if self.plugin.windows['logs'].has_key(jid):
|
||||
self.plugin.windows['logs'][jid].window.present()
|
||||
else:
|
||||
self.plugin.windows['logs'][jid] = history_window.\
|
||||
HistoryWindow(self.plugin, jid, self.account)
|
||||
|
||||
def on_send_button_clicked(self, widget):
|
||||
"""When send button is pressed: send the current message"""
|
||||
jid = self.get_active_jid()
|
||||
|
|
Loading…
Reference in New Issue