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 51 0.0 %
Date: 2012-12-27 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 <com/sun/star/frame/Desktop.hpp>
      13             : #include <comphelper/processfactory.hxx>
      14             : 
      15             : #include "Communicator.hxx"
      16             : #include "Listener.hxx"
      17             : #include "Receiver.hxx"
      18             : #include "RemoteServer.hxx"
      19             : 
      20             : using namespace sd;
      21             : using namespace std;
      22             : using namespace com::sun::star;
      23             : using namespace osl;
      24             : 
      25           0 : Communicator::Communicator( BufferedStreamSocket *pSocket ):
      26             :     Thread( "CommunicatorThread" ),
      27             :     mpSocket( pSocket ),
      28             :     pTransmitter( 0 ),
      29           0 :     mListener( 0 )
      30             : {
      31           0 : }
      32             : 
      33           0 : Communicator::~Communicator()
      34             : {
      35           0 : }
      36             : 
      37             : // Run as a thread
      38           0 : void Communicator::execute()
      39             : {
      40           0 :     pTransmitter = new Transmitter( mpSocket );
      41           0 :     pTransmitter->create();
      42             : 
      43             :     pTransmitter->addMessage( "LO_SERVER_SERVER_PAIRED\n\n",
      44           0 :                               Transmitter::PRIORITY_HIGH );
      45           0 :     Receiver aReceiver( pTransmitter );
      46             :     try {
      47           0 :         uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create( ::comphelper::getProcessComponentContext() );
      48           0 :         uno::Reference< frame::XFrame > xFrame ( xFramesSupplier->getActiveFrame(), uno::UNO_QUERY_THROW );
      49           0 :         uno::Reference<presentation::XPresentationSupplier> xPS ( xFrame->getController()->getModel(), uno::UNO_QUERY_THROW);
      50             :         uno::Reference<presentation::XPresentation2> xPresentation(
      51           0 :             xPS->getPresentation(), uno::UNO_QUERY_THROW);
      52           0 :         if ( xPresentation->isRunning() )
      53             :         {
      54           0 :             presentationStarted( xPresentation->getController() );
      55             :         }
      56             :         else
      57             :         {
      58             :             pTransmitter->addMessage( "slideshow_finished\n\n",
      59           0 :                                       Transmitter::PRIORITY_HIGH );
      60           0 :         }
      61             :     }
      62           0 :     catch (uno::RuntimeException &)
      63             :     {
      64             :     }
      65             : 
      66             :     sal_uInt64 aRet;
      67           0 :     vector<OString> aCommand;
      68           0 :     while ( true )
      69             :     {
      70           0 :         OString aLine;
      71           0 :         aRet = mpSocket->readLine( aLine );
      72           0 :         if ( aRet == 0 )
      73             :         {
      74             :             break; // I.e. transmission finished.
      75             :         }
      76           0 :         if ( aLine.getLength() )
      77             :         {
      78           0 :             aCommand.push_back( aLine );
      79             :         }
      80             :         else
      81             :         {
      82           0 :             aReceiver.parseCommand( aCommand );
      83           0 :             aCommand.clear();
      84             :         }
      85           0 :     }
      86           0 :     disposeListener();
      87             : 
      88           0 :     pTransmitter->notifyFinished();
      89           0 :     pTransmitter->join();
      90           0 :     pTransmitter = NULL;
      91             : 
      92           0 :     delete mpSocket;
      93             : 
      94           0 :     RemoteServer::removeCommunicator( this );
      95           0 : }
      96             : 
      97           0 : void Communicator::informListenerDestroyed()
      98             : {
      99           0 :     if ( pTransmitter )
     100             :         pTransmitter->addMessage( "slideshow_finished\n\n",
     101           0 :                                   Transmitter::PRIORITY_HIGH );
     102           0 :     mListener.clear();
     103           0 : }
     104             : 
     105           0 : void Communicator::presentationStarted( const css::uno::Reference<
     106             :      css::presentation::XSlideShowController > &rController )
     107             : {
     108           0 :     if ( pTransmitter )
     109             :     {
     110           0 :         mListener = rtl::Reference<Listener>( new Listener( this, pTransmitter ) );
     111           0 :         mListener->init( rController );
     112             :     }
     113           0 : }
     114             : 
     115           0 : void Communicator::disposeListener()
     116             : {
     117           0 :     if ( mListener.is() )
     118             :     {
     119           0 :         mListener->disposing();
     120           0 :         mListener = NULL;
     121             :     }
     122           0 : }
     123             : 
     124             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10