LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/remotecontrol - Communicator.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 53 0.0 %
Date: 2012-12-17 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : #include <algorithm>
      10             : #include <vector>
      11             : 
      12             : #include <comphelper/processfactory.hxx>
      13             : 
      14             : #include "Communicator.hxx"
      15             : #include "Listener.hxx"
      16             : #include "Receiver.hxx"
      17             : #include "RemoteServer.hxx"
      18             : 
      19             : using namespace sd;
      20             : using namespace std;
      21             : using namespace com::sun::star;
      22             : using namespace osl;
      23             : 
      24           0 : Communicator::Communicator( BufferedStreamSocket *pSocket ):
      25             :     Thread( "CommunicatorThread" ),
      26             :     mpSocket( pSocket ),
      27             :     pTransmitter( 0 ),
      28           0 :     mListener( 0 )
      29             : {
      30           0 : }
      31             : 
      32           0 : Communicator::~Communicator()
      33             : {
      34           0 : }
      35             : 
      36             : // Run as a thread
      37           0 : void Communicator::execute()
      38             : {
      39           0 :     pTransmitter = new Transmitter( mpSocket );
      40           0 :     pTransmitter->create();
      41             : 
      42             :     pTransmitter->addMessage( "LO_SERVER_SERVER_PAIRED\n\n",
      43           0 :                               Transmitter::PRIORITY_HIGH );
      44           0 :     Receiver aReceiver( pTransmitter );
      45             :     try {
      46             :         uno::Reference< lang::XMultiServiceFactory > xServiceManager(
      47           0 :             ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
      48           0 :         uno::Reference< frame::XFramesSupplier > xFramesSupplier( xServiceManager->createInstance(
      49           0 :         "com.sun.star.frame.Desktop" ) , uno::UNO_QUERY_THROW );
      50           0 :         uno::Reference< frame::XFrame > xFrame ( xFramesSupplier->getActiveFrame(), uno::UNO_QUERY_THROW );
      51           0 :         uno::Reference<presentation::XPresentationSupplier> xPS ( xFrame->getController()->getModel(), uno::UNO_QUERY_THROW);
      52             :         uno::Reference<presentation::XPresentation2> xPresentation(
      53           0 :             xPS->getPresentation(), uno::UNO_QUERY_THROW);
      54           0 :         if ( xPresentation->isRunning() )
      55             :         {
      56           0 :             presentationStarted( xPresentation->getController() );
      57             :         }
      58             :         else
      59             :         {
      60             :             pTransmitter->addMessage( "slideshow_finished\n\n",
      61           0 :                                       Transmitter::PRIORITY_HIGH );
      62           0 :         }
      63             :     }
      64           0 :     catch (uno::RuntimeException &)
      65             :     {
      66             :     }
      67             : 
      68             :     sal_uInt64 aRet;
      69           0 :     vector<OString> aCommand;
      70           0 :     while ( true )
      71             :     {
      72           0 :         OString aLine;
      73           0 :         aRet = mpSocket->readLine( aLine );
      74           0 :         if ( aRet == 0 )
      75             :         {
      76             :             break; // I.e. transmission finished.
      77             :         }
      78           0 :         if ( aLine.getLength() )
      79             :         {
      80           0 :             aCommand.push_back( aLine );
      81             :         }
      82             :         else
      83             :         {
      84           0 :             aReceiver.parseCommand( aCommand );
      85           0 :             aCommand.clear();
      86             :         }
      87           0 :     }
      88           0 :     disposeListener();
      89             : 
      90           0 :     pTransmitter->notifyFinished();
      91           0 :     pTransmitter->join();
      92           0 :     pTransmitter = NULL;
      93             : 
      94           0 :     delete mpSocket;
      95             : 
      96           0 :     RemoteServer::removeCommunicator( this );
      97           0 : }
      98             : 
      99           0 : void Communicator::informListenerDestroyed()
     100             : {
     101           0 :     if ( pTransmitter )
     102             :         pTransmitter->addMessage( "slideshow_finished\n\n",
     103           0 :                                   Transmitter::PRIORITY_HIGH );
     104           0 :     mListener.clear();
     105           0 : }
     106             : 
     107           0 : void Communicator::presentationStarted( const css::uno::Reference<
     108             :      css::presentation::XSlideShowController > &rController )
     109             : {
     110           0 :     if ( pTransmitter )
     111             :     {
     112           0 :         mListener = rtl::Reference<Listener>( new Listener( this, pTransmitter ) );
     113           0 :         mListener->init( rController );
     114             :     }
     115           0 : }
     116             : 
     117           0 : void Communicator::disposeListener()
     118             : {
     119           0 :     if ( mListener.is() )
     120             :     {
     121           0 :         mListener->disposing();
     122           0 :         mListener = NULL;
     123             :     }
     124           0 : }
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10