diff options
Diffstat (limited to 'sc/source/ui/collab')
-rw-r--r-- | sc/source/ui/collab/contacts.cxx | 38 | ||||
-rw-r--r-- | sc/source/ui/collab/sendfunc.cxx | 25 | ||||
-rw-r--r-- | sc/source/ui/collab/sendfunc.hxx | 7 |
3 files changed, 51 insertions, 19 deletions
diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx index 67002c2053a6..ac16c3947b5e 100644 --- a/sc/source/ui/collab/contacts.cxx +++ b/sc/source/ui/collab/contacts.cxx @@ -51,6 +51,7 @@ class TubeContacts : public ModelessDialog SvxSimpleTableContainer maListContainer; SvxSimpleTable maList; TeleManager* mpManager; + ScDocFuncSend* mpSender; DECL_LINK( BtnConnectHdl, void * ); DECL_LINK( BtnListenHdl, void * ); @@ -70,6 +71,19 @@ class TubeContacts : public ModelessDialog { fprintf( stderr, "Could not register client handlers.\n" ); } + else + { + // FIXME: These signals should not be bind to a document specific code. + + // 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 ) ); + } } void StartBuddySession() @@ -82,9 +96,12 @@ class TubeContacts : public ModelessDialog TpAccount* pAccount = pAC->mpAccount; TpContact* pContact = pAC->mpContact; fprintf( stderr, "picked %s\n", tp_contact_get_identifier( pContact ) ); - if (!mpManager->startBuddySession( pAccount, pContact )) + TeleConference* pConference = mpManager->startBuddySession( pAccount, pContact ); + if (!pConference) fprintf( stderr, "could not start session with %s\n", tp_contact_get_identifier( pContact ) ); + else + mpSender->SetCollaboration( pConference ); } } @@ -97,8 +114,12 @@ class TubeContacts : public ModelessDialog { TpAccount* pAccount = pAC->mpAccount; fprintf( stderr, "picked %s\n", tp_account_get_display_name( pAccount ) ); - if (!mpManager->startGroupSession( pAccount, rtl::OUString("liboroom"), rtl::OUString("conference.jabber.org") )) + TeleConference* pConference = mpManager->startGroupSession( pAccount, + rtl::OUString("liboroom"), rtl::OUString("conference.jabber.org") ); + if (!pConference) fprintf( stderr, "could not start group session\n" ); + else + mpSender->SetCollaboration( pConference ); } } @@ -114,24 +135,19 @@ public: { ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current()); ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL; - ScDocFuncSend *pSender = dynamic_cast<ScDocFuncSend*> (pDocFunc); - if (!pSender) + mpSender = dynamic_cast<ScDocFuncSend*> (pDocFunc); + if (!mpSender) { // 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 ); + mpSender = new ScDocFuncSend( *pScDocShell, pReceiver ); + pScDocShell->SetDocFunc( mpSender ); // 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(); diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx index 1a1021359473..e5e6c54beb09 100644 --- a/sc/source/ui/collab/sendfunc.cxx +++ b/sc/source/ui/collab/sendfunc.cxx @@ -105,7 +105,7 @@ void ScDocFuncRecv::RecvMessage( const rtl::OString &rString ) } } -void ScDocFuncRecv::packetReceived( TeleConference*, TelePacket &rPacket ) +void ScDocFuncRecv::packetReceived( TelePacket &rPacket ) { rtl::OString aString( rPacket.getData(), rPacket.getSize() ); RecvMessage( aString ); @@ -220,10 +220,10 @@ extern "C" void ScDocFuncSend::SendMessage( ScChangeOpWriter &rOp ) { fprintf( stderr, "Op: '%s'\n", rOp.toString().getStr() ); - if (mpManager) + if (mpConference) { TelePacket aPacket( "sender", rOp.toString().getStr(), rOp.toString().getLength() ); - mpManager->sendPacket( aPacket ); + mpConference->sendPacket( aPacket ); } else // local demo mode mpDirect->RecvMessage( rOp.toString() ); @@ -254,8 +254,8 @@ void ScDocFuncSend::SendFile( const rtl::OUString &rURL ) fprintf( stderr, "Temp file is '%s'\n", rtl::OUStringToOString( aFileURL, RTL_TEXTENCODING_UTF8 ).getStr() ); - if (mpManager) - mpManager->sendFile( aFileURL, file_sent_cb, NULL ); + if (mpConference) + mpConference->sendFile( aFileURL, file_sent_cb, NULL ); else mpDirect->fileReceived( aFileURL ); @@ -267,7 +267,7 @@ void ScDocFuncSend::SendFile( const rtl::OUString &rURL ) ScDocFuncSend::ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect ) : ScDocFunc( rDocSh ), mpDirect( pDirect ), - mpManager( NULL ) + mpConference( NULL ) { fprintf( stderr, "Sender created !\n" ); } @@ -275,9 +275,22 @@ ScDocFuncSend::ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect ) ScDocFuncSend::~ScDocFuncSend() { fprintf( stderr, "Sender destroyed !\n" ); + mpConference->close(); delete mpDirect; } +void ScDocFuncSend::SetCollaboration( TeleConference* pConference ) +{ + mpConference = pConference; + mpConference->sigPacketReceived.connect( boost::bind( + &ScDocFuncRecv::packetReceived, mpDirect, _1 ) ); +} + +ScDocFuncRecv* ScDocFuncSend::GetReceiver() +{ + return mpDirect; +} + void ScDocFuncSend::EnterListAction( sal_uInt16 nNameResId ) { // Want to group these operations for the other side ... diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx index bae2ad373ad0..1bcbe237c246 100644 --- a/sc/source/ui/collab/sendfunc.hxx +++ b/sc/source/ui/collab/sendfunc.hxx @@ -217,7 +217,7 @@ public: ScDocFuncRecv( ScDocFuncDirect *pChain ); virtual ~ScDocFuncRecv(); - void packetReceived( TeleConference*, TelePacket &rPacket ); + void packetReceived( TelePacket &rPacket ); virtual void fileReceived( const rtl::OUString &rStr ); virtual void RecvMessage( const rtl::OString &rString ); @@ -226,7 +226,7 @@ public: class ScDocFuncSend : public ScDocFunc { ScDocFuncRecv *mpDirect; - TeleManager *mpManager; + TeleConference *mpConference; void SendMessage( ScChangeOpWriter &rOp ); void SendFile( const rtl::OUString &rURL ); @@ -237,6 +237,9 @@ public: ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect ); virtual ~ScDocFuncSend(); + void SetCollaboration( TeleConference* pConference ); + ScDocFuncRecv* GetReceiver(); + virtual void EnterListAction( sal_uInt16 nNameResId ); virtual void EndListAction(); |