00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "sessionlogger_p.h"
00022
00023 #include <KDE/KGlobal>
00024
00025 namespace KIMAP
00026 {
00027 class SessionLoggerPrivate
00028 {
00029 public:
00030 SessionLogger instance;
00031 };
00032 }
00033
00034 using namespace KIMAP;
00035
00036 K_GLOBAL_STATIC(SessionLoggerPrivate, globalLogger)
00037
00038 SessionLogger::SessionLogger()
00039 : m_file( qgetenv( "KIMAP_LOGFILE" ) )
00040 {
00041 m_file.open( QFile::WriteOnly );
00042 }
00043
00044 SessionLogger::~SessionLogger()
00045 {
00046 m_file.close();
00047 }
00048
00049 SessionLogger *SessionLogger::self()
00050 {
00051 return &globalLogger->instance;
00052 }
00053
00054 void SessionLogger::dataSent( const QByteArray &data )
00055 {
00056 m_file.write( "C: "+data.trimmed()+'\n' );
00057 m_file.flush();
00058 }
00059
00060 void SessionLogger::dataReceived( const QByteArray &data )
00061 {
00062 m_file.write( "S: "+data.trimmed()+'\n' );
00063 m_file.flush();
00064 }
00065
00066 void SessionLogger::disconnectionOccured()
00067 {
00068 m_file.write( "X\n" );
00069 }
00070
00071
00072