diff options
author | Matúš Kukan <matus.kukan@gmail.com> | 2012-07-13 20:42:16 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2012-07-17 16:40:24 +0200 |
commit | 36170cd0dbc3409270cf3cf998805a790ee6228f (patch) | |
tree | 021542766cdb6f2ba7462732b52669a1ef653fc4 | |
parent | eafd7161ed544cebb450a334d8c13d15170e987b (diff) |
tubes: start collaboration from the File->Collaborate menu as the only way
This also kills LIBO_TUBES variable.
Listen button is used for registering client handlers (was LIBO_TUBES=slave).
It may not be possible (if the name is already in use by another process).
Change-Id: I04e0eb8721fa8e74c6cff585c79124b18046aad4
-rw-r--r-- | sc/source/ui/collab/contacts.cxx | 61 | ||||
-rw-r--r-- | sc/source/ui/collab/sendfunc.cxx | 55 | ||||
-rw-r--r-- | sc/source/ui/collab/sendfunc.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 2 |
4 files changed, 39 insertions, 81 deletions
diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx index 2fc8e1af193c..67002c2053a6 100644 --- a/sc/source/ui/collab/contacts.cxx +++ b/sc/source/ui/collab/contacts.cxx @@ -66,27 +66,9 @@ class TubeContacts : public ModelessDialog void Listen() { - ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current()); - ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL; - ScDocFuncSend *pSender = dynamic_cast<ScDocFuncSend*> (pDocFunc); - if (!pSender) - { - ScDocFuncDirect *pDirect = dynamic_cast<ScDocFuncDirect*> (pDocFunc); - ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect ); - pSender = new ScDocFuncSend( *pScDocShell, pReceiver ); - pScDocShell->SetDocFunc( pSender ); - } - // This is a hack to work around: - // `error registering client handler: Name - // 'org.freedesktop.Telepathy.Client.LibreOffice' already in use by another process` - // This happens when there is already slave instance running, - // so we try to init TeleManager as master. - bool bIsMaster = false; - if (!pSender->InitTeleManager( bIsMaster )) + if (!mpManager->registerClients()) { - fprintf( stderr, "Trying to initialize TeleManager as master..\n" ); - bIsMaster = true; - pSender->InitTeleManager( bIsMaster ); + fprintf( stderr, "Could not register client handlers.\n" ); } } @@ -127,11 +109,39 @@ public: maBtnConnect( this, ScResId( BTN_CONNECT ) ), maBtnListen( this, ScResId( BTN_LISTEN ) ), maListContainer( this, ScResId( CTL_LIST ) ), - maList( maListContainer ) + maList( maListContainer ), + mpManager( TeleManager::get() ) { - // FIXME: Who should really own TeleManager and where it can be destroyed ? - mpManager = TeleManager::get(); + ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current()); + ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL; + ScDocFuncSend *pSender = dynamic_cast<ScDocFuncSend*> (pDocFunc); + if (!pSender) + { + // This means pDocFunc has to be ScDocFuncDirect* and we are not collaborating yet. + ScDocFuncDirect *pDirect = dynamic_cast<ScDocFuncDirect*> (pDocFunc); + ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect ); + pSender = new ScDocFuncSend( *pScDocShell, pReceiver ); + pScDocShell->SetDocFunc( pSender ); + + // FIXME: Who should really own TeleManager and where it can be destroyed ? + // Take reference, so TeleManager does not get destroyed after closing dialog: + mpManager = TeleManager::get(); + + mpManager->sigPacketReceived.connect( boost::bind( + &ScDocFuncRecv::packetReceived, pReceiver, _1, _2 )); + mpManager->sigFileReceived.connect( boost::bind( + &ScDocFuncRecv::fileReceived, pReceiver, _1 )); + if (mpManager->createAccountManager()) + { + mpManager->prepareAccountManager(); + } + else + { + fprintf( stderr, "Could not create AccountManager.\n" ); + mpManager->unref(); + } + } maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) ); maBtnListen.SetClickHdl( LINK( this, TubeContacts, BtnListenHdl ) ); @@ -149,7 +159,10 @@ public: maList.InsertHeaderEntry( sHeader, HEADERBAR_APPEND, HIB_LEFT ); Show(); } - virtual ~TubeContacts() {} + virtual ~TubeContacts() + { + mpManager->unref(); + } static rtl::OUString fromUTF8( const char *pStr ) { diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx index 29898150dad8..1a1021359473 100644 --- a/sc/source/ui/collab/sendfunc.cxx +++ b/sc/source/ui/collab/sendfunc.cxx @@ -56,22 +56,6 @@ namespace css = ::com::sun::star; -namespace { - -bool isCollabMode( bool& rbMaster ) -{ - const char* pEnv = getenv ("LIBO_TUBES"); - if (pEnv) - { - rbMaster = !strcmp( pEnv, "master"); - return true; - } - rbMaster = false; - return false; -} - -} - // FIXME: really ScDocFunc should be an abstract base ScDocFuncRecv::ScDocFuncRecv( ScDocFuncDirect *pChain ) : mpChain( pChain ) @@ -294,30 +278,6 @@ ScDocFuncSend::~ScDocFuncSend() delete mpDirect; } -bool ScDocFuncSend::InitTeleManager( bool bIsMaster ) -{ - if (mpManager) - { - fprintf( stderr, "TeleManager is already connected.\n" ); - return true; - } - TeleManager *pManager = TeleManager::get(); - pManager->sigPacketReceived.connect( boost::bind( - &ScDocFuncRecv::packetReceived, mpDirect, _1, _2 )); - pManager->sigFileReceived.connect( boost::bind( - &ScDocFuncRecv::fileReceived, mpDirect, _1 )); - - if (pManager->createAccountManager()) - { - pManager->prepareAccountManager(); - mpManager = pManager; - return true; - } - fprintf( stderr, "Could not connect.\n" ); - pManager->unref(); - return false; -} - void ScDocFuncSend::EnterListAction( sal_uInt16 nNameResId ) { // Want to group these operations for the other side ... @@ -431,13 +391,9 @@ sal_Bool ScDocFuncSend::MergeCells( const ScCellMergeOption& rOption, sal_Bool b return ScDocFunc::MergeCells( rOption, bContents, bRecord, bApi ); } +#ifdef INTERCEPT SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc() { - // With ScDocFuncDirect shared_ptr it should even be possible during - // runtime to replace a ScDocFuncDirect instance with a ScDocFuncSend - // chained instance (holding the same ScDocFuncDirect instance) and vice - // versa. - bool bIsMaster = false; if (getenv ("INTERCEPT")) { boost::shared_ptr<ScDocFuncDirect> pDirect( new ScDocFuncDirect( *this ) ); @@ -448,16 +404,9 @@ SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc() return new ScDocFuncSend( *this, boost::shared_ptr<ScDocFuncRecv>( aDemoBus.get() ) ); } - else if (isCollabMode( bIsMaster )) - { - ScDocFuncDirect *pDirect = new ScDocFuncDirect( *this ); - ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect ); - ScDocFuncSend *pSender = new ScDocFuncSend( *this, pReceiver ); - pSender->InitTeleManager( bIsMaster ); - return pSender; - } else return new ScDocFuncDirect( *this ); } +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx index 1798743c7c57..bae2ad373ad0 100644 --- a/sc/source/ui/collab/sendfunc.hxx +++ b/sc/source/ui/collab/sendfunc.hxx @@ -237,8 +237,6 @@ public: ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect ); virtual ~ScDocFuncSend(); - bool InitTeleManager( bool bIsMaster ); - virtual void EnterListAction( sal_uInt16 nNameResId ); virtual void EndListAction(); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 2c3d5ac0c445..cfdd45590a46 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -2500,12 +2500,10 @@ sal_Bool ScDocShell::HasAutomaticTableName( const String& rFilter ) || rFilter.EqualsAscii( pFilterRtf ); } -#ifndef ENABLE_TELEPATHY ScDocFunc *ScDocShell::CreateDocFunc() { return new ScDocFuncDirect( *this ); } -#endif ScDocShell::ScDocShell( const ScDocShell& rShell ) : SvRefBase(), |