/* * AbiCollab - Code to enable the modification of remote documents. * Copyright (C) 2005 by Martin Sevior * Copyright (C) 2006,2007 by Marc Maurer * Copyright (C) 2007 by One Laptop Per Child * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. */ #ifndef ABI_COLLAB_IMPORT_H #define ABI_COLLAB_IMPORT_H #include #include #include #include #include "ut_types.h" #include "pt_Types.h" #include "px_ChangeRecord.h" #include "ut_stack.h" #include "xav_Listener.h" #include "pl_Listener.h" #include "ut_string_class.h" #include #include class FL_DocLayout; class PD_Document; class UT_Stack; class ABI_xmpp; class ChangeAdjust; class ABI_Collab_Import { friend class FakeAccountHandler; public: ABI_Collab_Import(AbiCollab* pAbiCollab, PD_Document* doc); ~ABI_Collab_Import(); bool import(const SessionPacket& sPacket, BuddyPtr collaborator); std::map& getRemoteRevisions() { return m_remoteRevs; } PT_DocPosition getEndOfDoc(); void masterInit(); void slaveInit(BuddyPtr pBuddy, UT_sint32 iRev); private: bool _isOverlapping(UT_sint32 pos1, UT_sint32 length1, UT_sint32 pos2, UT_sint32 length2); void _calculateCollisionSeqence(UT_sint32 iIncomingRemoteRev, const std::string& sIncomingDocUUID, UT_sint32& iStart, UT_sint32& iEnd); UT_sint32 _getIncomingAdjustmentForState( const UT_GenericVector* pExpAdjusts, UT_sint32 iStart, UT_sint32 iEnd, UT_sint32 iIncomingPos, UT_sint32 iIncomingLength, const std::string& sIncomingUUID, std::deque& impAdjs); bool _checkForCollision(const AbstractChangeRecordSessionPacket& acrsp, UT_sint32& iRev, UT_sint32& iImportAdjustment); bool _handleCollision(UT_sint32 iIncommingRev, UT_sint32 iLocalRev, BuddyPtr pCollaborator); bool _shouldIgnore(BuddyPtr pCollaborator); void _disableUpdates(UT_GenericVector& vecViews, bool bIsGlob); void _enableUpdates(UT_GenericVector vecViews, bool bIsGlob); bool _import(const SessionPacket& packet, UT_sint32 iImportAdjustment, BuddyPtr pCollaborator, bool inGlob = false); PD_Document* m_pDoc; AbiCollab * m_pAbiCollab; std::map m_remoteRevs; // maintained by the importer, used by the exporter std::vector > m_revertSet; // only used by the session owner std::deque m_iAlreadyRevertedRevs; // only used by non-session owners }; #endif /* ABI_COLLAB_IMPORT_H */