From 37c67a137882cc1a9e113552dcab42a7d6337358 Mon Sep 17 00:00:00 2001 From: Matúš Kukan Date: Fri, 20 Jul 2012 00:12:19 +0200 Subject: tubes: send a file for collaboration when buddy session starts Channels for file and for tube are independent in telepathy, so let sender create UUID and pass it to receiver, who then can bind the document to the channel. UUID for tube channel goes through telepathy. UUID for file channel is encoded in the filename for now. Tubes specific CreateDocFunc is re-introduced, so we could set current UUID after file is received and when the document is being constructed, get channel from TeleManager with this UUID. This is not immune to constructing other documents in the middle of binding proccess. Change-Id: I57c7e57a5d7d3ccd7d94677a8cf2719c78baa2fd --- sc/source/ui/collab/contacts.cxx | 9 ++++----- sc/source/ui/collab/sendfunc.cxx | 28 +++++++++++++++++++--------- sc/source/ui/collab/sendfunc.hxx | 3 ++- sc/source/ui/docshell/docsh.cxx | 2 ++ 4 files changed, 27 insertions(+), 15 deletions(-) (limited to 'sc/source/ui') diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx index d81ff9a65b58..c2cc8b6488ef 100644 --- a/sc/source/ui/collab/contacts.cxx +++ b/sc/source/ui/collab/contacts.cxx @@ -98,11 +98,6 @@ class TubeContacts : public ModelessDialog // Receiving file is not related to any document. mpManager->sigFileReceived.connect( boost::bind( &ScDocFuncRecv::fileReceived, mpSender->GetReceiver(), _1 ) ); - - // TODO: It's still not clear to me who should take care of this signal - // and what exactly it is supposed to happen. - mpManager->sigConferenceCreated.connect( boost::bind( - &ScDocFuncSend::SetCollaboration, mpSender, _1 ) ); } } @@ -124,7 +119,11 @@ class TubeContacts : public ModelessDialog fprintf( stderr, "could not start session with %s\n", tp_contact_get_identifier( pContact ) ); else + { mpSender->SetCollaboration( pConference ); + mpSender->SendFile( OStringToOUString( + pConference->getUuid(), RTL_TEXTENCODING_UTF8 ) ); + } } } diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx index d22e4ba3b143..4b3d1c92f769 100644 --- a/sc/source/ui/collab/sendfunc.cxx +++ b/sc/source/ui/collab/sendfunc.cxx @@ -39,6 +39,7 @@ #include #include #include +#include // new file send/recv fun ... #include @@ -232,12 +233,13 @@ void ScDocFuncSend::SendMessage( ScChangeOpWriter &rOp ) mpDirect->RecvMessage( rOp.toString() ); } -void ScDocFuncSend::SendFile( const rtl::OUString &rURL ) +void ScDocFuncSend::SendFile( const rtl::OUString &sUuid ) { - (void)rURL; - String aTmpPath = utl::TempFile::CreateTempName(); - aTmpPath.Append( rtl::OUString( ".ods" ) ); + aTmpPath.Append( OUString("_") ); + aTmpPath.Append( sUuid ); + aTmpPath.Append( OUString("_") ); + aTmpPath.Append( OUString(".ods") ); rtl::OUString aFileURL; ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aTmpPath, aFileURL ); @@ -416,22 +418,30 @@ sal_Bool ScDocFuncSend::MergeCells( const ScCellMergeOption& rOption, sal_Bool b return ScDocFunc::MergeCells( rOption, bContents, bRecord, bApi ); } -#ifdef INTERCEPT -SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc() +ScDocFunc *ScDocShell::CreateDocFunc() { if (getenv ("INTERCEPT")) { - boost::shared_ptr pDirect( new ScDocFuncDirect( *this ) ); + ScDocFuncDirect* pDirect = new ScDocFuncDirect( *this ); boost::shared_ptr pReceiver( new ScDocFuncRecv( pDirect ) ); static boost::shared_ptr aDemoBus( new ScDocFuncDemo() ); aDemoBus->add_client( pReceiver ); // a lifecycle horror no doubt. - return new ScDocFuncSend( *this, boost::shared_ptr( aDemoBus.get() ) ); + return new ScDocFuncSend( *this, aDemoBus.get() ); + } + else if (TeleManager::hasWaitingConference()) + { + ScDocFuncDirect *pDirect = new ScDocFuncDirect( *this ); + ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect ); + ScDocFuncSend *pSender = new ScDocFuncSend( *this, pReceiver ); + TeleManager *pManager = TeleManager::get(); + pSender->SetCollaboration( pManager->getConference() ); + pManager->unref(); + 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 981363358065..f9c2bcfaa239 100644 --- a/sc/source/ui/collab/sendfunc.hxx +++ b/sc/source/ui/collab/sendfunc.hxx @@ -229,7 +229,6 @@ class ScDocFuncSend : public ScDocFunc TeleConference *mpConference; void SendMessage( ScChangeOpWriter &rOp ); - void SendFile( const rtl::OUString &rURL ); public: // FIXME: really ScDocFunc should be an abstract base, so @@ -240,6 +239,8 @@ public: void SetCollaboration( TeleConference* pConference ); TeleConference* GetConference(); ScDocFuncRecv* GetReceiver(); + // TODO: I think this could be moved to TeleManager later. + void SendFile( const rtl::OUString &rURL ); 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 cfdd45590a46..2c3d5ac0c445 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -2500,10 +2500,12 @@ 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(), -- cgit