/* AbiCollab- Code to enable the modification of remote documents. * Copyright (C) 2005 by Martin Sevior * * 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., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ #ifdef ABI_PLUGIN_BUILTIN #define abi_plugin_register abipgn_abicollab_register #define abi_plugin_unregister abipgn_abicollab_unregister #define abi_plugin_supports_version abipgn_abicollab_supports_version #endif #include "ut_assert.h" #include "ut_debugmsg.h" #include "xap_Module.h" #include "xap_App.h" #include "xap_Frame.h" #include "fv_View.h" #include "xav_View.h" #include "xav_Listener.h" #include "fl_BlockLayout.h" #include "pd_Document.h" #include "px_CR_SpanChange.h" #include "px_CR_FmtMarkChange.h" #include "px_CR_SpanChange.h" #include "px_CR_FmtMark.h" #include "px_CR_Span.h" #include "px_CR_Glob.h" #include "px_CR_StruxChange.h" #include "px_CR_ObjectChange.h" #include "px_CR_Strux.h" #include "px_CR_Object.h" #include "ut_assert.h" #include "ap_Menu_Id.h" #include "ev_Menu_Actions.h" #include "ev_Menu.h" #include "ev_Menu_Layouts.h" #include "ev_Menu_Labels.h" #include "ev_EditMethod.h" #include "xap_Menu_Layouts.h" #include "ie_exp.h" #include "ie_types.h" #include "ut_types.h" #include "ut_misc.h" #include "ut_units.h" #include "xap_Dialog_Id.h" #include "ap_Dialog_Id.h" #include "xap_Dlg_FileOpenSaveAs.h" #include "xap_DialogFactory.h" #include "xap_Dlg_MessageBox.h" #include "ap_Strings.h" #include "RecordPackets.h" #include "ut_sleep.h" #include #include #include #ifdef WIN32 #include #else #include #include #include #include "ut_files.h" #endif AbiCollabRecord::AbiCollabRecord(AbiCollabFactoryContainer* pFactory, PD_Document * pDoc, UT_UTF8String sID, bool bAsCommandLine, UT_UTF8String * pRecordPathName, UT_UTF8String * pReplayPathName ) : AbiCollab(pFactory, pDoc, sID, bAsCommandLine, NULL), m_bRecord( !(pRecordPathName == NULL)), m_bReplay( !(pReplayPathName == NULL)), m_sRecordPath(""), m_sReplayPath(""), m_outfile(NULL) { if (m_bRecord) { m_sRecordPath = *pRecordPathName; m_outfile = fopen(m_sRecordPath.utf8_str(),"wb"); if(m_outfile) fprintf(m_outfile,"\n"); } if (m_bReplay) { m_sReplayPath = *pReplayPathName; } } AbiCollabRecord::~AbiCollabRecord(void) { if (m_bRecord && m_outfile) { fprintf(m_outfile,"\n"); fclose(m_outfile); } } void AbiCollabRecord::push(const UT_UTF8String& packet) { if (m_bExportMasked) { getExport()->clearGLOB(); UT_DEBUGMSG(("Masked Call \n")); return; } if(m_outfile) fprintf(m_outfile,"%s\n",packet.utf8_str()); } void AbiCollabRecord::maskExport() { m_bExportMasked = true; // TODO: delete all strings in the list; this is a mem-leak m_pMaskedPackets.clear(); } const std::vector& AbiCollabRecord::unmaskExport() { if(getExport()) getExport()->clearGLOB(); return AbiCollab::unmaskExport(); } bool AbiCollabRecord::replayFile(void) { maskExport(); AbiCollab_Packet * pPacket = NULL; AbiCollab_Packet_Factory * pFactory = new AbiCollab_Packet_Factory(m_sReplayPath.utf8_str()); pPacket = pFactory->getNextPacket(); while(pPacket) { UT_DEBUGMSG(("Got Packet 5x \n",pPacket)); getImport()->import(*pPacket); DELETEP(pPacket); pPacket = pFactory->getNextPacket(); } DELETEP(pFactory); unmaskExport(); }