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
00022
00023 #ifndef ABI_COLLAB_IMPORT_H
00024 #define ABI_COLLAB_IMPORT_H
00025
00026 #include <map>
00027 #include <vector>
00028 #include <string>
00029 #include <deque>
00030
00031 #include "ut_types.h"
00032 #include "pt_Types.h"
00033 #include "px_ChangeRecord.h"
00034 #include "ut_stack.h"
00035 #include "xav_Listener.h"
00036 #include "pl_Listener.h"
00037 #include "ut_string_class.h"
00038 #include <packet/xp/AbiCollab_Packet.h>
00039 #include <account/xp/Buddy.h>
00040
00041 class FL_DocLayout;
00042 class PD_Document;
00043 class UT_Stack;
00044 class ABI_xmpp;
00045 class ChangeAdjust;
00046
00047 class ABI_Collab_Import
00048 {
00049 friend class FakeAccountHandler;
00050
00051 public:
00052 ABI_Collab_Import(AbiCollab* pAbiCollab, PD_Document* doc);
00053 ~ABI_Collab_Import();
00054
00055 bool import(const SessionPacket& sPacket, BuddyPtr collaborator);
00056 std::map<BuddyPtr, UT_sint32>& getRemoteRevisions()
00057 { return m_remoteRevs; }
00058 PT_DocPosition getEndOfDoc();
00059 void masterInit();
00060 void slaveInit(BuddyPtr pBuddy, UT_sint32 iRev);
00061
00062 private:
00063 bool _isOverlapping(UT_sint32 pos1, UT_sint32 length1, UT_sint32 pos2, UT_sint32 length2);
00064 void _calculateCollisionSeqence(UT_sint32 iIncomingRemoteRev,
00065 const std::string& sIncomingDocUUID,
00066 UT_sint32& iStart,
00067 UT_sint32& iEnd);
00068 UT_sint32 _getIncomingAdjustmentForState(
00069 const UT_GenericVector<ChangeAdjust *>* pExpAdjusts,
00070 UT_sint32 iStart, UT_sint32 iEnd, UT_sint32 iIncomingPos,
00071 UT_sint32 iIncomingLength, const std::string& sIncomingUUID,
00072 std::deque<int>& impAdjs);
00073 bool _checkForCollision(const AbstractChangeRecordSessionPacket& acrsp, UT_sint32& iRev,
00074 UT_sint32& iImportAdjustment);
00075 bool _handleCollision(UT_sint32 iIncommingRev, UT_sint32 iLocalRev, BuddyPtr pCollaborator);
00076 bool _shouldIgnore(BuddyPtr pCollaborator);
00077 void _disableUpdates(UT_GenericVector<AV_View *>& vecViews, bool bIsGlob);
00078 void _enableUpdates(UT_GenericVector<AV_View *> vecViews, bool bIsGlob);
00079 bool _import(const SessionPacket& packet, UT_sint32 iImportAdjustment, BuddyPtr pCollaborator, bool inGlob = false);
00080
00081 PD_Document* m_pDoc;
00082 AbiCollab * m_pAbiCollab;
00083 std::map<BuddyPtr, UT_sint32> m_remoteRevs;
00084 std::vector<std::pair<BuddyPtr, UT_sint32> > m_revertSet;
00085 std::deque<UT_sint32> m_iAlreadyRevertedRevs;
00086 };
00087
00088 #endif