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

AbiCollab_Import.h

Go to the documentation of this file.
00001 /*
00002  * AbiCollab - Code to enable the modification of remote documents.
00003  * Copyright (C) 2005 by Martin Sevior
00004  * Copyright (C) 2006,2007 by Marc Maurer <uwog@uwog.net>
00005  * Copyright (C) 2007 by One Laptop Per Child
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 USA.
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; // maintained by the importer, used by the exporter
00084     std::vector<std::pair<BuddyPtr, UT_sint32> > m_revertSet; // only used by the session owner
00085     std::deque<UT_sint32>               m_iAlreadyRevertedRevs; // only used by non-session owners
00086 };
00087 
00088 #endif /* ABI_COLLAB_IMPORT_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1