summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorAndrzej J. R. Hunt <andrzej@ahunt.org>2012-07-19 15:36:24 +0200
committerMichael Meeks <michael.meeks@suse.com>2012-08-06 10:22:58 +0100
commit405416e0b3e7d68963fc8c24512299c2cb117fca (patch)
tree0a3a096aa1928237b595d1180b57c4df76d169cb /sd
parent4967e88b9adf73f538a379f0a215b0e0b6c2a968 (diff)
Fixed Listener registration and destruction for all cases.
Change-Id: I I I8be3c67889969d714514ca073c48ab26248a30e1
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/remotecontrol/Listener.cxx14
-rw-r--r--sd/source/ui/remotecontrol/Server.cxx62
-rw-r--r--sd/source/ui/slideshow/slideshow.cxx4
3 files changed, 37 insertions, 43 deletions
diff --git a/sd/source/ui/remotecontrol/Listener.cxx b/sd/source/ui/remotecontrol/Listener.cxx
index ed6532c478e7..e51bb57572b9 100644
--- a/sd/source/ui/remotecontrol/Listener.cxx
+++ b/sd/source/ui/remotecontrol/Listener.cxx
@@ -36,12 +36,16 @@ Listener::~Listener()
void Listener::init( const css::uno::Reference< css::presentation::XSlideShowController >& aController)
{
- if (aController.is() )
+ if ( aController.is() )
{
mController = css::uno::Reference< css::presentation::XSlideShowController >( aController );
aController->addSlideShowListener( this );
fprintf( stderr, "Registered listener.\n" );
}
+ else
+ {
+ fprintf( stderr, "Couldn't register listener -- aController isn't\n" );
+ }
}
//----- XAnimationListener ----------------------------------------------------
@@ -93,6 +97,7 @@ void SAL_CALL Listener::hyperLinkClicked (const rtl::OUString &)
void SAL_CALL Listener::slideTransitionStarted (void)
throw (css::uno::RuntimeException)
{
+ fprintf( stderr, "slideTransitionStarted\n" );
sal_Int32 aSlide = mController->getCurrentSlideIndex();
OStringBuffer aBuilder( "slide_updated\n" );
@@ -118,25 +123,20 @@ void SAL_CALL Listener::slideAnimationsEnded (void)
void SAL_CALL Listener::disposing (void)
{
- fprintf( stderr, "In disposing\n" );
pTransmitter = NULL;
- fprintf( stderr, "Nulled transmitter\n" );
if ( mController.is() )
{
- fprintf( stderr, "mController was\n" );
mController->removeSlideShowListener( this );
mController = NULL;
}
mServer->informListenerDestroyed();
- fprintf( stderr, "finished disposing\n" );
}
void SAL_CALL Listener::disposing (
const css::lang::EventObject& rEvent)
throw (::com::sun::star::uno::RuntimeException)
{
- fprintf( stderr, "disposing\n");
(void) rEvent;
- dispose();
+ dispose();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
index 919d47152435..361954df0a01 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -35,12 +35,9 @@ Server::~Server()
// Run as a thread
void Server::listenThread()
{
- fprintf( stderr, "Server:: address of Transmitter before:%p\n", pTransmitter );
pTransmitter = new Transmitter( mStreamSocket );
pTransmitter->launch();
Receiver aReceiver( pTransmitter );
- fprintf( stderr, "Server:: address of Transmitter:%p\n", pTransmitter );
-// aTransmitter.addMessage( "Hello world\n\n", Transmitter::Priority::HIGH );
try {
fprintf( stderr, "Trying to add a Listener in listenThread\n" );
uno::Reference< lang::XMultiServiceFactory > xServiceManager(
@@ -60,50 +57,46 @@ void Server::listenThread()
}
catch ( com::sun::star::uno::RuntimeException &e )
{
- fprintf( stderr, "Exception on add\n" );
}
// TODO: decryption
- while (true)
+
+ sal_uInt64 aRet, aRead;
+ vector<char> aBuffer;
+ vector<OString> aCommand;
+ aRead = 0;
+ while ( true )
{
- sal_uInt64 aRet, aRead;
- vector<char> aBuffer;
- vector<OString> aCommand;
- aRead = 0;
- while ( true )
+ aBuffer.resize( aRead + 100 );
+ aRet = mStreamSocket.recv( &aBuffer[aRead], 100 );
+ if ( aRet == 0 )
{
- aBuffer.resize( aRead + 100 );
- aRet = mStreamSocket.recv( &aBuffer[aRead], 100 );
- if ( aRet == 0 )
- {
- break; // I.e. transmission finished.
- }
- aRead += aRet;
- vector<char>::iterator aIt;
- while ( (aIt = find( aBuffer.begin(), aBuffer.end(), '\n' ))
- != aBuffer.end() )
- {
- sal_uInt64 aLocation = aIt - aBuffer.begin();
-
- aCommand.push_back( OString( &(*aBuffer.begin()), aLocation ) );
+ break; // I.e. transmission finished.
+ }
+ aRead += aRet;
+ vector<char>::iterator aIt;
+ while ( (aIt = find( aBuffer.begin(), aBuffer.end(), '\n' ))
+ != aBuffer.end() )
+ {
+ sal_uInt64 aLocation = aIt - aBuffer.begin();
- if ( aIt == aBuffer.begin() )
- {
- aReceiver.parseCommand( aCommand );
- aCommand.clear();
- }
- aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the newline
- aRead -= (aLocation + 1);
+ aCommand.push_back( OString( &(*aBuffer.begin()), aLocation ) );
+ if ( aIt == aBuffer.begin() )
+ {
+ aReceiver.parseCommand( aCommand );
+ aCommand.clear();
}
+ aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the newline
+ aRead -= (aLocation + 1);
}
-
- // TODO: deal with transmision errors gracefully.
}
- mListener->dispose();
+ // TODO: deal with transmision errors gracefully.
+ mListener->disposing();
mListener = NULL;
delete pTransmitter;
pTransmitter = NULL;
+ fprintf( stderr, "Finished listening\n" );
}
@@ -141,7 +134,6 @@ void Server::presentationStarted( const css::uno::Reference<
{
mListener = rtl::Reference<Listener>( new Listener( spServer, pTransmitter ) );
mListener->init( rController );
-
}
}
diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx
index 32bbfe042623..9551137519f7 100644
--- a/sd/source/ui/slideshow/slideshow.cxx
+++ b/sd/source/ui/slideshow/slideshow.cxx
@@ -268,7 +268,7 @@ void SlideShow::CreateController( ViewShell* pViewSh, ::sd::View* pView, ::Wind
// multiple slide show instances for one document.
mxController = xController;
mbIsInStartup = false;
- Server::presentationStarted( getController() );
+
}
// --------------------------------------------------------------------
@@ -1073,6 +1073,8 @@ void SlideShow::activate( ViewShellBase& rBase )
if( mxController.is() )
mxController->activate();
+
+ Server::presentationStarted( mxController.get() );
}
// ---------------------------------------------------------