android/sdremote/src/org/libreoffice/impressremote/communication/Client.java | 1 android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java | 1 android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java | 28 ++ sd/source/ui/inc/Server.hxx | 56 +++++ sd/source/ui/remotecontrol/Listener.cxx | 111 ++++++---- sd/source/ui/remotecontrol/Listener.hxx | 40 ++- sd/source/ui/remotecontrol/Receiver.cxx | 65 ++++- sd/source/ui/remotecontrol/Server.cxx | 52 ++++ sd/source/ui/remotecontrol/Server.hxx | 51 ---- sd/source/ui/remotecontrol/Transmitter.cxx | 8 sd/source/ui/slideshow/slideshow.cxx | 3 11 files changed, 289 insertions(+), 127 deletions(-)
New commits: commit e11572d3d61e0e9ad0d2f9b0553bdaed5a09bac4 Merge: fc5b5d4... 51bd28c... Author: Andrzej J. R. Hunt <[email protected]> Date: Tue Jul 17 23:28:17 2012 +0200 Merge again due to changes in repository. Conflicts: sd/source/ui/remotecontrol/Receiver.cxx Change-Id: If2549a32df3d3864f293013c1ac93cc79193d3af commit fc5b5d464e60c2698006eefbd315a351ce30da2a Author: Andrzej J. R. Hunt <[email protected]> Date: Tue Jul 17 23:22:39 2012 +0200 Merged changes. Change-Id: I436a3ac7af0fbad3f37c6799de9186142f0af430 diff --git a/sd/source/ui/remotecontrol/Transmitter.cxx b/sd/source/ui/remotecontrol/Transmitter.cxx index bc25355..24189a3 100644 --- a/sd/source/ui/remotecontrol/Transmitter.cxx +++ b/sd/source/ui/remotecontrol/Transmitter.cxx @@ -34,7 +34,7 @@ Transmitter::execute() osl::MutexGuard aQueueGuard( mQueueMutex ); while ( mHighPriority.size() ) { - OString aMessage = mHighPriority.front(); + OString aMessage( mHighPriority.front() ); mHighPriority.pop(); fprintf(stderr , " Writing HIGHP:\n%s<<END>>", aMessage.getStr() ); mStreamSocket.write( aMessage.getStr(), aMessage.getLength() ); @@ -42,7 +42,7 @@ Transmitter::execute() if( mLowPriority.size() ) { - OString aMessage = mLowPriority.front(); + OString aMessage( mLowPriority.front() ); mLowPriority.pop(); fprintf(stderr , " Writing LOWP:\n%s<<END>>", aMessage.getStr() ); mStreamSocket.write( aMessage.getStr(), aMessage.getLength() ); commit cf901534f1264ccbd0c4c55d2ef90ae128499e13 Author: Andrzej J. R. Hunt <[email protected]> Date: Tue Jul 17 23:03:31 2012 +0200 Fixed constructor issue in Listener, fixed usage of Transmitter. Change-Id: I875cb1fba51faadafd8f7f0e34ef6b56a818bb7a diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java index d4c1c4e..98f713b 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java @@ -56,6 +56,7 @@ public abstract class Client { String aTemp; // read until empty line while ((aTemp = aReader.readLine()).length() != 0) { + System.out.println("Read:" + aTemp); aList.add(aTemp); } mReceiver.parseCommand(aList); diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java index e26ef31..8418cab 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java @@ -25,6 +25,7 @@ public class Receiver { } public void parseCommand(ArrayList<String> aCommand) { + System.out.println("parsing " +aCommand.get(0)); if (mActivityMessenger == null) { return; } diff --git a/sd/source/ui/remotecontrol/Listener.cxx b/sd/source/ui/remotecontrol/Listener.cxx index 25f5107..a13752f 100644 --- a/sd/source/ui/remotecontrol/Listener.cxx +++ b/sd/source/ui/remotecontrol/Listener.cxx @@ -10,26 +10,39 @@ #include <comphelper/processfactory.hxx> #include <com/sun/star/presentation/XPresentationSupplier.hpp> #include <com/sun/star/presentation/XPresentation2.hpp> + +#include <rtl/strbuf.hxx> + #include "Listener.hxx" using namespace sd; using namespace ::com::sun::star::presentation; using namespace ::com::sun::star::frame; using rtl::OString; +using rtl::OStringBuffer; -Listener::Listener( sd::Transmitter& rTransmitter ) +Listener::Listener( sd::Transmitter *aTransmitter ) : ::cppu::WeakComponentImplHelper1< XSlideShowListener>( m_aMutex ) { + fprintf( stderr, "Creating Transmitter\n" ); + mTransmitter = aTransmitter; } -void Listener::init(css::uno::Reference< css::presentation::XSlideShowController > aController) +Listener::~Listener() { - aController->addSlideShowListener(static_cast<XSlideShowListener*>(this)); } - - +void Listener::init(css::uno::Reference< css::presentation::XSlideShowController >& aController) +{ + fprintf( stderr, "Initing Transmitter\n" ); + if (aController.is() ) + { +// mController = aController; + aController->addSlideShowListener(static_cast<XSlideShowListener*>(this));- + } + fprintf( stderr, "Initiated Transmitter\n" ); +} //----- XAnimationListener ---------------------------------------------------- void SAL_CALL Listener::beginEvent(const css::uno::Reference< @@ -46,10 +59,11 @@ void SAL_CALL Listener::endEvent( const css::uno::Reference< } void SAL_CALL Listener::repeat( const css::uno::Reference< - css::animations::XAnimationNode >& rNode, ::sal_Int32 Repeat ) + css::animations::XAnimationNode >& rNode, ::sal_Int32 aRepeat ) throw (css::uno::RuntimeException) { (void) rNode; + (void) aRepeat; } @@ -68,40 +82,16 @@ void SAL_CALL Listener::resumed (void) void SAL_CALL Listener::slideEnded (sal_Bool bReverse) throw (css::uno::RuntimeException) { + fprintf( stderr, "slideEnded\n" ); (void) bReverse; - fprintf( stderr, "slidenede\n" ); -// (void) bReverse; -// JsonBuilder *aBuilder = json_builder_new(); -// -// -// json_builder_begin_object( aBuilder ); -// json_builder_set_member_name( aBuilder, "slide_number"); -// json_builder_add_int_value( aBuilder, 2 ); -// // FIXME: get the slide number -// json_builder_end_object( aBuilder ); -// -// JsonGenerator *aGen = json_generator_new(); -// JsonNode *aRoot = json_builder_get_root( aBuilder ); -// json_generator_set_root( aGen, aRoot ); -// char *aCommand = json_generator_to_data( aGen, NULL); -// -// json_node_free( aRoot ); -// g_object_unref ( aGen ); -// g_object_unref ( aBuilder ); -// -// sal_Int32 aLen = strlen( aCommand ); -// -// OString aLengthString = OString::valueOf( aLen ); -// const char *aLengthChar = aLengthString.getStr(); -// -// sal_Int32 aLengthLength = aLengthString.getLength(); -// -// mStreamSocket.write( aLengthChar, aLengthLength ); -// mStreamSocket.write( "\n", 1 ); -// mStreamSocket.write( aCommand, aLen ); -// // Transmit here. -// -// g_free( aCommand ); + sal_Int32 aSlide = mController->getCurrentSlideIndex(); + + OStringBuffer aBuilder( "slide_updated\n" ); + aBuilder.append( OString::valueOf( aSlide ) ); + aBuilder.append( "\n\n" ); + + mTransmitter->addMessage( aBuilder.makeStringAndClear() , + Transmitter::Priority::HIGH ); } void SAL_CALL Listener::hyperLinkClicked (const rtl::OUString &) @@ -112,17 +102,19 @@ void SAL_CALL Listener::hyperLinkClicked (const rtl::OUString &) void SAL_CALL Listener::slideTransitionStarted (void) throw (css::uno::RuntimeException) { + fprintf( stderr, "slideTransitionStarted\n" ); } void SAL_CALL Listener::slideTransitionEnded (void) throw (css::uno::RuntimeException) { - fprintf( stderr, "slidetreatasdfanede\n" ); + fprintf( stderr, "slideTransitionEnded\n" ); } void SAL_CALL Listener::slideAnimationsEnded (void) throw (css::uno::RuntimeException) { + fprintf( stderr, "slideAnimationsEnded\n" ); } void SAL_CALL Listener::disposing (void) @@ -134,6 +126,7 @@ void SAL_CALL Listener::disposing ( const css::lang::EventObject& rEvent) throw (::com::sun::star::uno::RuntimeException) { + (void) rEvent; // FIXME: disconnect as appropriate } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/sd/source/ui/remotecontrol/Listener.hxx b/sd/source/ui/remotecontrol/Listener.hxx index e05c259..a70ede1 100644 --- a/sd/source/ui/remotecontrol/Listener.hxx +++ b/sd/source/ui/remotecontrol/Listener.hxx @@ -28,8 +28,9 @@ class Listener public ::cppu::WeakComponentImplHelper1< css::presentation::XSlideShowListener > { public: - Listener( sd::Transmitter& rTransmitter ); - void init( css::uno::Reference< css::presentation::XSlideShowController > aController); + Listener( sd::Transmitter *aTransmitter ); + ~Listener(); + void init( css::uno::Reference< css::presentation::XSlideShowController >& aController); // XAnimationListener virtual void SAL_CALL beginEvent(const css::uno::Reference< @@ -57,8 +58,9 @@ public: throw (com::sun::star::uno::RuntimeException); private: - css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController; osl::StreamSocket mStreamSocket; + sd::Transmitter *mTransmitter; + css::uno::Reference< css::presentation::XSlideShowController > mController; }; } #endif // _SD_IMPRESSREMOTE_LISTENER_HXX diff --git a/sd/source/ui/remotecontrol/Receiver.cxx b/sd/source/ui/remotecontrol/Receiver.cxx index 28f01be..153ffc5 100644 --- a/sd/source/ui/remotecontrol/Receiver.cxx +++ b/sd/source/ui/remotecontrol/Receiver.cxx @@ -42,9 +42,6 @@ Receiver::~Receiver() void Receiver::parseCommand( std::vector<OString> aCommand ) { - fprintf( stderr, "Parsing:\n"); - for (size_t i = 0; i < aCommand.size(); i++) - { uno::Reference<presentation::XSlideShowController> xSlideShowController; uno::Reference<presentation::XPresentation2> xPresentation; try { @@ -113,7 +110,7 @@ void Receiver::parseCommand( std::vector<OString> aCommand ) } } // FIXME: remove later, this is just to test functionality - //sendPreview( 0, xSlideShowController, mTransmitter ); + sendPreview( 0, xSlideShowController, mTransmitter ); } @@ -190,8 +187,6 @@ preparePreview(sal_uInt32 aSlideNumber, xFilter->filter( aProps ); - fprintf( stderr, "%s\n", rtl::OUStringToOString( aFileURL , RTL_TEXTENCODING_UTF8 ).getStr() ); - // FIXME: error handling. File aFile( aFileURL ); diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx index ad17ac4..748cbf9 100644 --- a/sd/source/ui/remotecontrol/Server.cxx +++ b/sd/source/ui/remotecontrol/Server.cxx @@ -10,6 +10,8 @@ #include <algorithm> #include <vector> +#include <comphelper/processfactory.hxx> + #include "sddll.hxx" #include "Server.hxx" #include "Receiver.hxx" @@ -32,13 +34,13 @@ Server::~Server() // Run as a thread void Server::listenThread() { - Transmitter aTransmitter( mStreamSocket ); - mTransmitter = &aTransmitter; - Receiver aReceiver( &aTransmitter ); +// Transmitter aTransmitter( mStreamSocket ); + mTransmitter = new Transmitter( mStreamSocket); + Receiver aReceiver( mTransmitter ); + mTransmitter->addMessage( "Hello world\n\n", Transmitter::Priority::HIGH ); - uno::Reference<presentation::XSlideShowController> xSlideShowController; - uno::Reference<presentation::XPresentation2> xPresentation; try { + fprintf( stderr, "Trying to add a Listener in listenThread\n" ); uno::Reference< lang::XMultiServiceFactory > xServiceManager( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); uno::Reference< frame::XFramesSupplier > xFramesSupplier( xServiceManager->createInstance( @@ -50,11 +52,13 @@ void Server::listenThread() if ( xPresentation->isRunning() ) { presentationStarted( xPresentation->getController() ); + fprintf( stderr, "Added the listener\n"); } + fprintf( stderr, "We aren't running\n" ); } catch ( com::sun::star::uno::RuntimeException &e ) { - //return; + fprintf( stderr, "Exeption on add\n" ); } @@ -95,6 +99,7 @@ void Server::listenThread() // TODO: deal with transmision errors gracefully. } + delete mTransmitter; mTransmitter = NULL; } @@ -127,8 +132,10 @@ void Server::presentationStarted( css::uno::Reference< { if ( mTransmitter ) { - Listener* aListener = new Listener( *mTransmitter ); + fprintf( stderr, "Adding Listener on start of presentation.\n" ); + Listener* aListener = new Listener( mTransmitter ); aListener->init( rController ); + fprintf( stderr, "Added the listener as desired.\n" ); } } diff --git a/sd/source/ui/remotecontrol/Transmitter.cxx b/sd/source/ui/remotecontrol/Transmitter.cxx index 276fc89..bc25355 100644 --- a/sd/source/ui/remotecontrol/Transmitter.cxx +++ b/sd/source/ui/remotecontrol/Transmitter.cxx @@ -26,6 +26,7 @@ Transmitter::Transmitter( StreamSocket &aSocket ) void Transmitter::execute() { + fprintf( stderr, "Waiting\n" ); while( mQueuesNotEmpty.wait() ) { while ( true ) @@ -35,6 +36,7 @@ Transmitter::execute() { OString aMessage = mHighPriority.front(); mHighPriority.pop(); + fprintf(stderr , " Writing HIGHP:\n%s<<END>>", aMessage.getStr() ); mStreamSocket.write( aMessage.getStr(), aMessage.getLength() ); } @@ -42,10 +44,10 @@ Transmitter::execute() { OString aMessage = mLowPriority.front(); mLowPriority.pop(); + fprintf(stderr , " Writing LOWP:\n%s<<END>>", aMessage.getStr() ); mStreamSocket.write( aMessage.getStr(), aMessage.getLength() ); } - //fprintf( stderr, "Lowsize:%i, Highsize:%i\n", mLowPriority.size(), mHighPriority.size() ); if ( (mLowPriority.size() == 0) && (mHighPriority.size() == 0) ) { mQueuesNotEmpty.reset(); commit ecd6199ce68458f28820b78b4443abfad0afd46e Author: Andrzej J. R. Hunt <[email protected]> Date: Tue Jul 17 17:48:07 2012 +0200 Added registration of the slideshow listener. Change-Id: I Icaf2fe03e5f5b8ee9de3138b8dd28d837c734e94 diff --git a/sd/source/ui/remotecontrol/Listener.cxx b/sd/source/ui/remotecontrol/Listener.cxx index 47cf1fa..25f5107 100644 --- a/sd/source/ui/remotecontrol/Listener.cxx +++ b/sd/source/ui/remotecontrol/Listener.cxx @@ -18,50 +18,14 @@ using namespace ::com::sun::star::frame; using rtl::OString; -Listener::Listener( css::uno::Reference< css::presentation::XSlideShowController > aController, sd::Transmitter& rTransmitter ) - : ::cppu::WeakComponentImplHelper2< XSlideShowListener, - XFrameActionListener >( m_aMutex ) +Listener::Listener( sd::Transmitter& rTransmitter ) + : ::cppu::WeakComponentImplHelper1< XSlideShowListener>( m_aMutex ) { - fprintf( stderr, "Hello from a listener...\n" ); - try - { - css::uno::Reference< css::lang::XMultiServiceFactory > xServiceManager( - ::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW ); - css::uno::Reference< css::frame::XFrame > xDesktop( xServiceManager->createInstance( - "com.sun.star.frame.Desktop" ) , css::uno::UNO_QUERY_THROW ); - xDesktop->addFrameActionListener( static_cast<XFrameActionListener*>(this)); - } - catch ( css::uno::RuntimeException &e ) - { - //return; - } - if( aController.is() ) - { -// css::uno::Reference< css::lang::XMultiServiceFactory > xServiceManager( -// ::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW ); -// css::uno::Reference< css::frame::XFramesSupplier > xFramesSupplier( -// xServiceManager->createInstance( "com.sun.star.frame.Desktop" ) , -// css::uno::UNO_QUERY_THROW ); -// css::uno::Reference< css::frame::XFrame > xFrame ( -// xFramesSupplier->getActiveFrame(), css::uno::UNO_QUERY_THROW ); -// css::uno::Reference<css::presentation::XPresentationSupplier> xPS ( -// xFrame->getController()->getModel(), css::uno::UNO_QUERY_THROW); -// css::uno::Reference<css::presentation::XPresentation2> xPresentation( -// xPS->getPresentation(), css::uno::UNO_QUERY_THROW); -// // Throws an exception if now slideshow running -// css::uno::Reference<css::presentation::XSlideShowController> xSlideShowController( -// xPresentation->getController(), css::uno::UNO_QUERY_THROW ); -// xSlideShowController->addSlideShowListener(static_cast<XSlideShowListener*>(this)); -// fprintf(stderr, "Registered the slideshowlistener\n" ); - fprintf(stderr, "Trying to add the slideshowlistener\n" ); - aController->addSlideShowListener(static_cast<XSlideShowListener*>(this)); - fprintf(stderr, "Registered the slideshowlistener\n" ); - } - else - { - fprintf(stderr, "rController isn't\n" ); - } +} +void Listener::init(css::uno::Reference< css::presentation::XSlideShowController > aController) +{ + aController->addSlideShowListener(static_cast<XSlideShowListener*>(this)); } @@ -161,12 +125,6 @@ void SAL_CALL Listener::slideAnimationsEnded (void) { } -void SAL_CALL Listener::frameAction (const css::frame::FrameActionEvent& rEvent) - throw (::com::sun::star::uno::RuntimeException) -{ - fprintf( stderr, "FrameAction\n" ); -} - void SAL_CALL Listener::disposing (void) { // FIXME: disconnect as appropriate diff --git a/sd/source/ui/remotecontrol/Listener.hxx b/sd/source/ui/remotecontrol/Listener.hxx index 56635dc..e05c259 100644 --- a/sd/source/ui/remotecontrol/Listener.hxx +++ b/sd/source/ui/remotecontrol/Listener.hxx @@ -14,7 +14,7 @@ #include <com/sun/star/presentation/XSlideShowListener.hpp> #include <com/sun/star/presentation/XSlideShowController.hpp> -#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/compbase1.hxx> #include <cppuhelper/basemutex.hxx> #include <osl/socket.hxx> @@ -25,11 +25,11 @@ namespace css = ::com::sun::star; namespace sd { class Listener : protected ::cppu::BaseMutex, - public ::cppu::WeakComponentImplHelper2< css::presentation::XSlideShowListener, css::frame::XFrameActionListener > + public ::cppu::WeakComponentImplHelper1< css::presentation::XSlideShowListener > { public: - Listener( css::uno::Reference< css::presentation::XSlideShowController > aController, sd::Transmitter& rTransmitter ); - + Listener( sd::Transmitter& rTransmitter ); + void init( css::uno::Reference< css::presentation::XSlideShowController > aController); // XAnimationListener virtual void SAL_CALL beginEvent(const css::uno::Reference< @@ -50,10 +50,6 @@ public: virtual void SAL_CALL hyperLinkClicked( const ::rtl::OUString& hyperLink ) throw (css::uno::RuntimeException); - // XFrameActionListener - virtual void SAL_CALL frameAction (const css::frame::FrameActionEvent& rEvent) - throw (css::uno::RuntimeException); - // XEventListener virtual void SAL_CALL disposing (void); virtual void SAL_CALL disposing ( diff --git a/sd/source/ui/remotecontrol/Receiver.cxx b/sd/source/ui/remotecontrol/Receiver.cxx index 52f6a1b..28f01be 100644 --- a/sd/source/ui/remotecontrol/Receiver.cxx +++ b/sd/source/ui/remotecontrol/Receiver.cxx @@ -8,6 +8,9 @@ */ #include "Receiver.hxx" #include <string.h> +#include <com/sun/star/presentation/XSlideShowController.hpp> +#include <com/sun/star/presentation/XPresentationSupplier.hpp> +#include <com/sun/star/presentation/XPresentation2.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XExporter.hpp> @@ -40,10 +43,8 @@ Receiver::~Receiver() void Receiver::parseCommand( std::vector<OString> aCommand ) { fprintf( stderr, "Parsing:\n"); - for (uint i = 0; i < aCommand.size(); i++) + for (size_t i = 0; i < aCommand.size(); i++) { - fprintf( stderr, "%s\n", aCommand[i].getStr() );} - fprintf( stderr, "End parse\n" ); uno::Reference<presentation::XSlideShowController> xSlideShowController; uno::Reference<presentation::XPresentation2> xPresentation; try { @@ -133,7 +134,7 @@ void sendPreview(sal_uInt32 aSlideNumber, aBuffer.append( "slide_preview\n" ); - rtl::OString aSlideNumberString( rtl::OString::valueOf( 2 ) ); // FIXME get number + rtl::OString aSlideNumberString( rtl::OString::valueOf( sal_Int32(2) ) ); // FIXME get number aBuffer.append( aSlideNumberString.getStr() ); aBuffer.append( "\n" ); diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx index 9ad7f69..ad17ac4 100644 --- a/sd/source/ui/remotecontrol/Server.cxx +++ b/sd/source/ui/remotecontrol/Server.cxx @@ -17,6 +17,7 @@ using namespace std; using namespace sd; +using namespace ::com::sun::star; using rtl::OString; Server::Server() @@ -35,6 +36,28 @@ void Server::listenThread() mTransmitter = &aTransmitter; Receiver aReceiver( &aTransmitter ); + uno::Reference<presentation::XSlideShowController> xSlideShowController; + uno::Reference<presentation::XPresentation2> xPresentation; + try { + uno::Reference< lang::XMultiServiceFactory > xServiceManager( + ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); + uno::Reference< frame::XFramesSupplier > xFramesSupplier( xServiceManager->createInstance( + "com.sun.star.frame.Desktop" ) , uno::UNO_QUERY_THROW ); + uno::Reference< frame::XFrame > xFrame ( xFramesSupplier->getActiveFrame(), uno::UNO_QUERY_THROW ); + uno::Reference<presentation::XPresentationSupplier> xPS ( xFrame->getController()->getModel(), uno::UNO_QUERY_THROW); + uno::Reference<presentation::XPresentation2> xPresentation( + xPS->getPresentation(), uno::UNO_QUERY_THROW); + if ( xPresentation->isRunning() ) + { + presentationStarted( xPresentation->getController() ); + } + } + catch ( com::sun::star::uno::RuntimeException &e ) + { + //return; + } + + // TODO: decryption while (true) { @@ -72,6 +95,7 @@ void Server::listenThread() // TODO: deal with transmision errors gracefully. } + mTransmitter = NULL; } @@ -101,10 +125,11 @@ void Server::execute() void Server::presentationStarted( css::uno::Reference< css::presentation::XSlideShowController > rController ) { - - fprintf( stderr, "Registering\n" ); - new Listener( rController, *mTransmitter ); - + if ( mTransmitter ) + { + Listener* aListener = new Listener( *mTransmitter ); + aListener->init( rController ); + } } commit 091fcbc61e1a8c98ca145b0968b5ac25b25f0626 Author: Andrzej J. R. Hunt <[email protected]> Date: Tue Jul 17 16:44:46 2012 +0200 Create listener when presentation is started. Change-Id: I830bb6e20046ebc80c740ca77bb97dddca1e4c02 diff --git a/sd/source/ui/inc/Server.hxx b/sd/source/ui/inc/Server.hxx new file mode 100644 index 0000000..952dcdd --- /dev/null +++ b/sd/source/ui/inc/Server.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef _SD_IMPRESSREMOTE_SERVER_HXX +#define _SD_IMPRESSREMOTE_SERVER_HXX + +// SERVER +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> + +#include <osl/socket.hxx> +#include <salhelper/thread.hxx> + +#include <com/sun/star/presentation/XSlideShowController.hpp> + +namespace css = ::com::sun::star; + +/** +* The port for use for the main communication between LibO and remote control app. +*/ +#define PORT 1599 + +#define CHARSET RTL_TEXTENCODING_UTF8 + +namespace sd +{ + + class Transmitter; + + class Server : public salhelper::Thread + { + public: + static void setup(); + static void presentationStarted( css::uno::Reference< + css::presentation::XSlideShowController > rController ); + private: + Server(); + ~Server(); + static Server *spServer; + osl::AcceptorSocket mSocket; + osl::StreamSocket mStreamSocket; + void listenThread(); + void execute(); + static Transmitter *mTransmitter; + }; +} + +#endif // _SD_IMPRESSREMOTE_SERVER_HXX +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/sd/source/ui/remotecontrol/Listener.cxx b/sd/source/ui/remotecontrol/Listener.cxx index 9679912..47cf1fa 100644 --- a/sd/source/ui/remotecontrol/Listener.cxx +++ b/sd/source/ui/remotecontrol/Listener.cxx @@ -7,35 +7,88 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <cstring> - +#include <comphelper/processfactory.hxx> +#include <com/sun/star/presentation/XPresentationSupplier.hpp> +#include <com/sun/star/presentation/XPresentation2.hpp> #include "Listener.hxx" using namespace sd; using namespace ::com::sun::star::presentation; +using namespace ::com::sun::star::frame; using rtl::OString; -Listener::Listener( const css::uno::Reference<XSlideShowController>& rxSlideShowController, - osl::StreamSocket aSocket ) - : ::cppu::WeakComponentImplHelper1< XSlideShowListener >( m_aMutex ), - mxSlideShowController(rxSlideShowController), - mStreamSocket( aSocket ) +Listener::Listener( css::uno::Reference< css::presentation::XSlideShowController > aController, sd::Transmitter& rTransmitter ) + : ::cppu::WeakComponentImplHelper2< XSlideShowListener, + XFrameActionListener >( m_aMutex ) { - if( mxSlideShowController.is() ) + fprintf( stderr, "Hello from a listener...\n" ); + try + { + css::uno::Reference< css::lang::XMultiServiceFactory > xServiceManager( + ::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW ); + css::uno::Reference< css::frame::XFrame > xDesktop( xServiceManager->createInstance( + "com.sun.star.frame.Desktop" ) , css::uno::UNO_QUERY_THROW ); + xDesktop->addFrameActionListener( static_cast<XFrameActionListener*>(this)); + } + catch ( css::uno::RuntimeException &e ) { - // Listen for events from the slide show controller. - mxSlideShowController->addSlideShowListener(static_cast<XSlideShowListener*>(this)); + //return; } + if( aController.is() ) + { +// css::uno::Reference< css::lang::XMultiServiceFactory > xServiceManager( +// ::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW ); +// css::uno::Reference< css::frame::XFramesSupplier > xFramesSupplier( +// xServiceManager->createInstance( "com.sun.star.frame.Desktop" ) , +// css::uno::UNO_QUERY_THROW ); +// css::uno::Reference< css::frame::XFrame > xFrame ( +// xFramesSupplier->getActiveFrame(), css::uno::UNO_QUERY_THROW ); +// css::uno::Reference<css::presentation::XPresentationSupplier> xPS ( +// xFrame->getController()->getModel(), css::uno::UNO_QUERY_THROW); +// css::uno::Reference<css::presentation::XPresentation2> xPresentation( +// xPS->getPresentation(), css::uno::UNO_QUERY_THROW); +// // Throws an exception if now slideshow running +// css::uno::Reference<css::presentation::XSlideShowController> xSlideShowController( +// xPresentation->getController(), css::uno::UNO_QUERY_THROW ); +// xSlideShowController->addSlideShowListener(static_cast<XSlideShowListener*>(this)); +// fprintf(stderr, "Registered the slideshowlistener\n" ); + fprintf(stderr, "Trying to add the slideshowlistener\n" ); + aController->addSlideShowListener(static_cast<XSlideShowListener*>(this)); + fprintf(stderr, "Registered the slideshowlistener\n" ); + } + else + { + fprintf(stderr, "rController isn't\n" ); + } } -Listener::~Listener() + + + +//----- XAnimationListener ---------------------------------------------------- +void SAL_CALL Listener::beginEvent(const css::uno::Reference< + css::animations::XAnimationNode >& rNode ) throw (css::uno::RuntimeException) { + (void) rNode; +} +void SAL_CALL Listener::endEvent( const css::uno::Reference< + css::animations::XAnimationNode >& rNode ) throw (css::uno::RuntimeException) +{ + (void) rNode; } +void SAL_CALL Listener::repeat( const css::uno::Reference< + css::animations::XAnimationNode >& rNode, ::sal_Int32 Repeat ) + throw (css::uno::RuntimeException) +{ + (void) rNode; +} + + //----- XSlideShowListener ---------------------------------------------------- void SAL_CALL Listener::paused (void) @@ -51,6 +104,8 @@ void SAL_CALL Listener::resumed (void) void SAL_CALL Listener::slideEnded (sal_Bool bReverse) throw (css::uno::RuntimeException) { + (void) bReverse; + fprintf( stderr, "slidenede\n" ); // (void) bReverse; // JsonBuilder *aBuilder = json_builder_new(); // @@ -98,10 +153,29 @@ void SAL_CALL Listener::slideTransitionStarted (void) void SAL_CALL Listener::slideTransitionEnded (void) throw (css::uno::RuntimeException) { + fprintf( stderr, "slidetreatasdfanede\n" ); } void SAL_CALL Listener::slideAnimationsEnded (void) throw (css::uno::RuntimeException) { } + +void SAL_CALL Listener::frameAction (const css::frame::FrameActionEvent& rEvent) + throw (::com::sun::star::uno::RuntimeException) +{ + fprintf( stderr, "FrameAction\n" ); +} + +void SAL_CALL Listener::disposing (void) +{ +// FIXME: disconnect as appropriate +} + +void SAL_CALL Listener::disposing ( + const css::lang::EventObject& rEvent) + throw (::com::sun::star::uno::RuntimeException) +{ +// FIXME: disconnect as appropriate +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/sd/source/ui/remotecontrol/Listener.hxx b/sd/source/ui/remotecontrol/Listener.hxx index 8c2ef1b..56635dc 100644 --- a/sd/source/ui/remotecontrol/Listener.hxx +++ b/sd/source/ui/remotecontrol/Listener.hxx @@ -10,33 +10,55 @@ #define _SD_IMPRESSREMOTE_LISTENER_HXX #include <sal/config.h> +#include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/presentation/XSlideShowListener.hpp> #include <com/sun/star/presentation/XSlideShowController.hpp> -#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/compbase2.hxx> #include <cppuhelper/basemutex.hxx> #include <osl/socket.hxx> +#include "Transmitter.hxx" + namespace css = ::com::sun::star; namespace sd { class Listener : protected ::cppu::BaseMutex, - public ::cppu::WeakComponentImplHelper1< css::presentation::XSlideShowListener > + public ::cppu::WeakComponentImplHelper2< css::presentation::XSlideShowListener, css::frame::XFrameActionListener > { public: - Listener( const css::uno::Reference<css::presentation::XSlideShowController>& rxSlideShowController, - osl::StreamSocket aSocket ); - ~Listener(); + Listener( css::uno::Reference< css::presentation::XSlideShowController > aController, sd::Transmitter& rTransmitter ); + + + // XAnimationListener + virtual void SAL_CALL beginEvent(const css::uno::Reference< + css::animations::XAnimationNode >& rNode ) throw (css::uno::RuntimeException); + virtual void SAL_CALL endEvent( const css::uno::Reference< + css::animations::XAnimationNode >& rNode ) throw (css::uno::RuntimeException); + virtual void SAL_CALL repeat( const css::uno::Reference< + css::animations::XAnimationNode >& rNode, ::sal_Int32 Repeat ) + throw (css::uno::RuntimeException); // XSlideShowListener - virtual void SAL_CALL paused( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL resumed( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL slideTransitionStarted( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL slideTransitionEnded( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL slideAnimationsEnded( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL slideEnded(sal_Bool bReverse) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL hyperLinkClicked( const ::rtl::OUString& hyperLink ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL paused( ) throw (css::uno::RuntimeException); + virtual void SAL_CALL resumed( ) throw (css::uno::RuntimeException); + virtual void SAL_CALL slideTransitionStarted( ) throw (css::uno::RuntimeException); + virtual void SAL_CALL slideTransitionEnded( ) throw (css::uno::RuntimeException); + virtual void SAL_CALL slideAnimationsEnded( ) throw (css::uno::RuntimeException); + virtual void SAL_CALL slideEnded(sal_Bool bReverse) throw (css::uno::RuntimeException); + virtual void SAL_CALL hyperLinkClicked( const ::rtl::OUString& hyperLink ) + throw (css::uno::RuntimeException); + + // XFrameActionListener + virtual void SAL_CALL frameAction (const css::frame::FrameActionEvent& rEvent) + throw (css::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing (void); + virtual void SAL_CALL disposing ( + const com::sun::star::lang::EventObject& rEvent) + throw (com::sun::star::uno::RuntimeException); private: css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController; diff --git a/sd/source/ui/remotecontrol/Receiver.cxx b/sd/source/ui/remotecontrol/Receiver.cxx index 6f8c8d5..52f6a1b 100644 --- a/sd/source/ui/remotecontrol/Receiver.cxx +++ b/sd/source/ui/remotecontrol/Receiver.cxx @@ -116,7 +116,6 @@ void Receiver::parseCommand( std::vector<OString> aCommand ) } - void sendPreview(sal_uInt32 aSlideNumber, uno::Reference<presentation::XSlideShowController> xSlideShowController, Transmitter *aTransmitter ) { diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx index f858a36..9ad7f69 100644 --- a/sd/source/ui/remotecontrol/Server.cxx +++ b/sd/source/ui/remotecontrol/Server.cxx @@ -13,6 +13,7 @@ #include "sddll.hxx" #include "Server.hxx" #include "Receiver.hxx" +#include "Listener.hxx" using namespace std; using namespace sd; @@ -31,7 +32,9 @@ Server::~Server() void Server::listenThread() { Transmitter aTransmitter( mStreamSocket ); + mTransmitter = &aTransmitter; Receiver aReceiver( &aTransmitter ); + // TODO: decryption while (true) { @@ -94,7 +97,20 @@ void Server::execute() } + +void Server::presentationStarted( css::uno::Reference< + css::presentation::XSlideShowController > rController ) +{ + + fprintf( stderr, "Registering\n" ); + new Listener( rController, *mTransmitter ); + +} + + + Server *sd::Server::spServer = NULL; +Transmitter *sd::Server::mTransmitter = NULL; void Server::setup() { diff --git a/sd/source/ui/remotecontrol/Server.hxx b/sd/source/ui/remotecontrol/Server.hxx deleted file mode 100644 index bc2de65..0000000 --- a/sd/source/ui/remotecontrol/Server.hxx +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -#ifndef _SD_IMPRESSREMOTE_SERVER_HXX -#define _SD_IMPRESSREMOTE_SERVER_HXX - -// SERVER -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> - -#include <osl/socket.hxx> -#include <salhelper/thread.hxx> - -#include <com/sun/star/presentation/XSlideShowListener.hpp> - -/** -* The port for use for the main communication between LibO and remote control app. -*/ -#define PORT 1599 - -#define CHARSET RTL_TEXTENCODING_UTF8 - -namespace sd -{ - - class Server : public salhelper::Thread - { - public: - static void setup(); - private: - Server(); - ~Server(); - static Server *spServer; - osl::AcceptorSocket mSocket; - osl::StreamSocket mStreamSocket; - void listenThread(); - void execute(); - }; -} - -#endif // _SD_IMPRESSREMOTE_SERVER_HXX -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx index ffd8cef..a48de21 100644 --- a/sd/source/ui/slideshow/slideshow.cxx +++ b/sd/source/ui/slideshow/slideshow.cxx @@ -58,6 +58,7 @@ #include "sdattr.hrc" #include "FactoryIds.hxx" #include "ViewShell.hxx" +#include "Server.hxx" #include "SlideShowRestarter.hxx" #include "DrawController.hxx" #include <boost/bind.hpp> @@ -267,6 +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() ); } // -------------------------------------------------------------------- @@ -910,6 +912,7 @@ void SAL_CALL SlideShow::startWithArguments( const Sequence< PropertyValue >& rA StartFullscreenPresentation(); else StartInPlacePresentation(); + } // -------------------------------------------------------------------- commit 975127d0d851b0d12231c2f87b20318dea0a8981 Author: Andrzej J. R. Hunt <[email protected]> Date: Sun Jul 15 16:37:26 2012 +0100 Added additional commands and parsing. Change-Id: Iae099aeb07d25435115514e1bf0c4efb31613d50 diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java index 40bb918..679b287 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java @@ -1,5 +1,7 @@ package org.libreoffice.impressremote.communication; +import android.graphics.Color; + /** * Interface to send commands to the server. * @@ -26,4 +28,30 @@ public class Transmitter { mClient.sendCommand("goto_slide\n" + slide + "\n\n"); } + /** + * Blank the screen to the default colour (set server-side), which is + * generally black. This is slightly faster than using + * <code> blankScreen( colour ) </code>. + */ + public void blankScreen() { + mClient.sendCommand("presentation_blank_screen\n\n"); + } + + /** + * Set the screen to a specific colour. Only use if a non default colour is + * needed. + * @param aColor + */ + public void blankScreen(Color aColor) { + // Fixme: check how to get colour in integer form. + mClient.sendCommand("presentation_blank_screen\n" + aColor + "\n\n"); + } + + public void startPresentation() { + mClient.sendCommand("presentation_start\n\n"); + } + + public void stopPresentation() { + mClient.sendCommand("presentation_stop\n\n"); + } } diff --git a/sd/source/ui/remotecontrol/Receiver.cxx b/sd/source/ui/remotecontrol/Receiver.cxx index 87eee7f..6f8c8d5 100644 --- a/sd/source/ui/remotecontrol/Receiver.cxx +++ b/sd/source/ui/remotecontrol/Receiver.cxx @@ -40,11 +40,12 @@ Receiver::~Receiver() void Receiver::parseCommand( std::vector<OString> aCommand ) { fprintf( stderr, "Parsing:\n"); - for (int i = 0; i < aCommand.size(); i++) + for (uint i = 0; i < aCommand.size(); i++) { fprintf( stderr, "%s\n", aCommand[i].getStr() );} fprintf( stderr, "End parse\n" ); uno::Reference<presentation::XSlideShowController> xSlideShowController; + uno::Reference<presentation::XPresentation2> xPresentation; try { uno::Reference< lang::XMultiServiceFactory > xServiceManager( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); @@ -52,31 +53,64 @@ void Receiver::parseCommand( std::vector<OString> aCommand ) "com.sun.star.frame.Desktop" ) , uno::UNO_QUERY_THROW ); uno::Reference< frame::XFrame > xFrame ( xFramesSupplier->getActiveFrame(), uno::UNO_QUERY_THROW ); uno::Reference<presentation::XPresentationSupplier> xPS ( xFrame->getController()->getModel(), uno::UNO_QUERY_THROW); - uno::Reference<presentation::XPresentation2> xPresentation(xPS->getPresentation(), uno::UNO_QUERY_THROW); + xPresentation = uno::Reference<presentation::XPresentation2>( + xPS->getPresentation(), uno::UNO_QUERY_THROW); // Throws an exception if now slideshow running xSlideShowController = uno::Reference<presentation::XSlideShowController>( xPresentation->getController(), uno::UNO_QUERY_THROW ); } catch ( com::sun::star::uno::RuntimeException &e ) { - return; + //return; } - if ( aCommand[0].compareTo( "transition_next" ) == 0 ) + if ( aCommand[0].equals( "transition_next" ) ) { - xSlideShowController->gotoNextEffect(); + if ( xSlideShowController.is() ) + xSlideShowController->gotoNextEffect(); } - else if ( aCommand[0].compareTo( "transition_previous" ) == 0 ) + else if ( aCommand[0].equals( "transition_previous" ) ) { - xSlideShowController->gotoPreviousEffect(); + if ( xSlideShowController.is() ) + xSlideShowController->gotoPreviousEffect(); } - else if ( aCommand[0].compareTo( "goto_slide" ) == 0 ) + else if ( aCommand[0].equals( "goto_slide" ) ) { // FIXME: if 0 returned, then not a valid number sal_Int32 aSlide = aCommand[1].toInt32(); - xSlideShowController->gotoSlideIndex( aSlide ); + if ( xSlideShowController.is() ) + xSlideShowController->gotoSlideIndex( aSlide ); + } + else if ( aCommand[0].equals( "presentation_start" ) ) + { + if ( xPresentation.is() ) + xPresentation->start(); + } + else if ( aCommand[0].equals( "presentation_stop" ) ) + { + if ( xPresentation.is() ) + xPresentation->end(); + } + else if ( aCommand[0].equals( "presentation_blank_screen" ) ) + { + sal_Int32 aColour = 0; // Default is black + if ( aCommand.size() > 1 ) + { +// aColour = FIXME: get the colour in some format from this string +// Determine the formatting first. + } + if ( xSlideShowController.is() ) + { + xSlideShowController->blankScreen( aColour ); + } + } + else if ( aCommand[0].equals( "presentation_resume" ) ) + { + if ( xSlideShowController.is() ) + { + xSlideShowController->resume(); + } } - // FIXME: remove later, this is just to test functionality //sendPreview( 0, xSlideShowController, mTransmitter ); diff --git a/sd/source/ui/remotecontrol/Server.hxx b/sd/source/ui/remotecontrol/Server.hxx index 2b3c706..bc2de65 100644 --- a/sd/source/ui/remotecontrol/Server.hxx +++ b/sd/source/ui/remotecontrol/Server.hxx @@ -20,8 +20,6 @@ #include <com/sun/star/presentation/XSlideShowListener.hpp> - - /** * The port for use for the main communication between LibO and remote control app. */ _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
