From c981ac6b000a7311f11ddec947b3510aa9912471 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sat, 16 Apr 2005 09:36:18 +0000 Subject: [PATCH] messages and presences are now logged --- src/common/connection.py | 18 ++++++++++-------- src/common/logger.py | 5 ++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 89526a1fa..2254be8da 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -163,7 +163,9 @@ class connection: self.dispatch('GC_SUBJECT', (str(msg.getFrom()), subject)) else: self.dispatch('GC_MSG', (str(msg.getFrom()), msgtxt, tim)) + gajim.logger.write('gc', msgtxt, str(msg.getFrom()), tim = tim) else: + gajim.logger.write('incoming', msgtxt, str(msg.getFrom()), tim = tim) self.dispatch('MSG', (str(msg.getFrom()), msgtxt, tim)) # END messageCB @@ -193,15 +195,8 @@ class connection: show = prs.getShow() if not show: show = 'online' - self.dispatch('NOTIFY', (prs.getFrom().getStripped(), show, status, \ - prs.getFrom().getResource(), prio, keyID, prs.getRole(), \ - prs.getAffiliation(), prs.getJid(), prs.getReason(), \ - prs.getActor(), prs.getStatusCode())) elif ptype == 'unavailable': - self.dispatch('NOTIFY', (prs.getFrom().getStripped(), 'offline', \ - status, prs.getFrom().getResource(), prio, keyID, prs.getRole(), \ - prs.getAffiliation(), prs.getJid(), prs.getReason(), \ - prs.getActor(), prs.getStatusCode())) + show = 'offline' elif ptype == 'subscribe': gajim.log.debug('subscribe request from %s' % who) if gajim.config.get('alwaysauth') or who.find("@") <= 0: @@ -258,6 +253,12 @@ class connection: self.dispatch('NOTIFY', (prs.getFrom().getStripped(), 'error', \ errmsg, prs.getFrom().getResource(), prio, keyID, None, None, \ None, None, None, None)) + if ptype == 'available' or ptype == 'unavailable': + gajim.logger.write('status', status, prs.getFrom().getStripped(), show) + self.dispatch('NOTIFY', (prs.getFrom().getStripped(), show, status, \ + prs.getFrom().getResource(), prio, keyID, prs.getRole(), \ + prs.getAffiliation(), prs.getJid(), prs.getReason(), \ + prs.getActor(), prs.getStatusCode())) # END presenceCB def _disconnectedCB(self, con): @@ -518,6 +519,7 @@ class connection: if msgenc: msg_iq.setX(common.jabber.NS_XENCRYPTED).insertData(msgenc) self.connection.send(msg_iq) + gajim.logger.write('outgoing', msg, jid) self.dispatch('MSGSENT', (jid, msg, keyID)) def request_subscription(self, jid, msg): diff --git a/src/common/logger.py b/src/common/logger.py index 9d29269b2..d92f122f0 100644 --- a/src/common/logger.py +++ b/src/common/logger.py @@ -75,7 +75,10 @@ class Logger: show = nick for f in files: fic = open(LOGPATH + f, 'a') - fic.write('%s:%s:%s:%s\n' % (tim, jid, show, msg)) + fic.write('%s:%s:%s' % (tim, jid, show)) + if msg: + fic.write(':' + msg) + fic.write('\n') fic.close() def get_nb_line(self, jid):