Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ABICOLLAB_DISK_RECORDER_H
00022 #define ABICOLLAB_DISK_RECORDER_H
00023
00024 #include <vector>
00025
00026 #include <string>
00027 #include <time.h>
00028
00029 #include "xap_App.h"
00030 #include "ut_assert.h"
00031 #include "ut_go_file.h"
00032
00033 #include <session/xp/AbiCollab.h>
00034
00035 class RecordedPacket
00036 {
00037 public:
00038 RecordedPacket(bool bIncoming,bool bHasBuddy, const UT_UTF8String& buddyName, UT_uint64 timestamp, Packet* pPacket)
00039 : m_bIncoming(bIncoming),
00040 m_bHasBuddy(bHasBuddy),
00041 m_buddyName(buddyName),
00042 m_timestamp(timestamp),
00043 m_pPacket(pPacket),
00044 m_bDeleteAtDestroy(false)
00045 {}
00046
00047 ~RecordedPacket()
00048 {
00049 DELETEP(m_pPacket);
00050 }
00051
00052 bool m_bIncoming;
00053 bool m_bHasBuddy;
00054 UT_UTF8String m_buddyName;
00055 UT_uint64 m_timestamp;
00056 Packet* m_pPacket;
00057
00058 bool m_bDeleteAtDestroy;
00059 };
00060
00061 class DiskSessionRecorder : public SessionRecorderInterface
00062 {
00063 public:
00064 DiskSessionRecorder(AbiCollab* pSession);
00065 ~DiskSessionRecorder();
00066
00067 static const char* getTargetDirectory()
00068 { return XAP_App::getApp()->getUserPrivateDirectory(); }
00069
00070 static const char* getPrefix()
00071 { return "Session-"; }
00072
00073 static bool getPackets(const std::string& filename, bool& bLocallyControlled, std::vector<RecordedPacket*>& packets);
00074
00075 static bool dumpSession(const std::string& filename);
00076
00077 void storeOutgoing(const Packet* pPacket)
00078 { store(false, pPacket, BuddyPtr()); }
00079
00080 void storeOutgoing(const Packet* pPacket, BuddyPtr toBuddy)
00081 { store(false, pPacket, toBuddy); }
00082
00083 void storeIncoming(const Packet* pPacket, BuddyPtr fromBuddy)
00084 { store(true, pPacket, fromBuddy); }
00085
00086 static const char* getHeader()
00087 { return "DSR!"; }
00088
00089 protected:
00090 GsfOutput* m_GsfStream;
00091 GError* m_Error;
00092 const char* m_URI;
00093
00094 void destroy();
00095 void store(bool incoming, const Packet* pPacket, BuddyPtr pBuddy);
00096 void write(const void* data, int count);
00097 };
00098
00099 #endif