• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

DiskSessionRecorder.h

Go to the documentation of this file.
00001 /*
00002  * AbiCollab - Code to enable the modification of remote documents.
00003  * Copyright (C) 2007 One Laptop Per Child
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018  * 02110-1301 USA.
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 /* ABICOLLAB_DISK_RECORDER_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1