photosgallery/slideshow/view/src/shwslideshowpausehandler.cpp
changeset 0 4e91876724a2
child 25 191387a8b767
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    The pause handling control for the slideshow
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 //  CLASS HEADER
       
    22 #include "shwslideshowpausehandler.h"
       
    23 
       
    24 //  EXTERNAL INCLUDES
       
    25 
       
    26 //  INTERNAL INCLUDES
       
    27 #include "shwslideshowengine.h"
       
    28 
       
    29 #include <glxlog.h>
       
    30 #include <glxtracer.h>
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // C++ Constructor. inlined to save a few bits of ROM
       
    34 // -----------------------------------------------------------------------------
       
    35 inline CShwSlideShowPauseHandler::CShwSlideShowPauseHandler(
       
    36         CShwSlideshowEngine& aEngine )
       
    37     : iEngine( aEngine ),
       
    38     iInCall( EFalse ),  // set to false just to clarify
       
    39     iUserPaused( EFalse ), // set to false to clarify
       
    40     iOnForeground( ETrue ) // we are on foreground by default
       
    41     {
       
    42     // No implementation required
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // NewL. Static construction
       
    47 // -----------------------------------------------------------------------------
       
    48 CShwSlideShowPauseHandler* CShwSlideShowPauseHandler::NewL(
       
    49         CShwSlideshowEngine& aEngine )
       
    50     {
       
    51     TRACER("CShwSlideShowPauseHandler::OfferKeyEventL");
       
    52     GLX_LOG_INFO( "CShwSlideShowPauseHandler::NewL" );
       
    53     CShwSlideShowPauseHandler* self = 
       
    54         new( ELeave ) CShwSlideShowPauseHandler( aEngine );
       
    55     return self;
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // Destructor.
       
    60 // -----------------------------------------------------------------------------
       
    61 CShwSlideShowPauseHandler::~CShwSlideShowPauseHandler()
       
    62     {
       
    63     // No implementation required
       
    64     }
       
    65 // -----------------------------------------------------------------------------
       
    66 // UserToggledControlsVisibiltyL.
       
    67 // -----------------------------------------------------------------------------
       
    68 void CShwSlideShowPauseHandler::ToggleUiControlsVisibiltyL()
       
    69     {
       
    70         iEngine.ToggleUiControlsVisibiltyL();
       
    71     }
       
    72 // -----------------------------------------------------------------------------
       
    73 // UserToggledPauseL.
       
    74 // -----------------------------------------------------------------------------
       
    75 void CShwSlideShowPauseHandler::UserToggledPauseL()
       
    76     {
       
    77     TRACER("CShwSlideShowPauseHandler::UserToggledPauseL");
       
    78     GLX_LOG_INFO( 
       
    79         "CShwSlideShowPauseHandler::UserToggledPauseL" );
       
    80     // get the engine state unless we are on background
       
    81     if( iOnForeground )
       
    82         {
       
    83         CShwSlideshowEngine::TShwState state = iEngine.State();
       
    84         if ( CShwSlideshowEngine::EShwStateRunning == state )
       
    85             {
       
    86             // user paused us
       
    87             iUserPaused = ETrue;
       
    88             // Calling PauseL on the engine results in the view receiving an
       
    89             // paused event from engine observer.
       
    90             iEngine.PauseL();
       
    91             }
       
    92         else if ( CShwSlideshowEngine::EShwStatePaused == state )
       
    93             {
       
    94             // user resumed us
       
    95             iUserPaused = EFalse;
       
    96             // if engine is paused, resume
       
    97             iEngine.ResumeL(); 
       
    98             }
       
    99         }
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // PhoneCallStartedL.
       
   104 // -----------------------------------------------------------------------------
       
   105 void CShwSlideShowPauseHandler::PhoneCallStartedL()
       
   106     {
       
   107     TRACER("CShwSlideShowPauseHandler::PhoneCallStartedL");
       
   108     GLX_LOG_INFO( 
       
   109         "CShwSlideShowPauseHandler::PhoneCallStartedL" );
       
   110     // set state to in call
       
   111     iInCall = ETrue;
       
   112     // get the engine state
       
   113     CShwSlideshowEngine::TShwState state = iEngine.State();
       
   114     // if engine is running
       
   115     if ( CShwSlideshowEngine::EShwStateRunning == state )
       
   116         {
       
   117         // Calling PauseL on the engine results in the view receiving an
       
   118         // paused event from engine observer.
       
   119         iEngine.PauseL();
       
   120         }
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // PhoneCallEndedL.
       
   125 // -----------------------------------------------------------------------------
       
   126 void CShwSlideShowPauseHandler::PhoneCallEndedL()
       
   127     {
       
   128     TRACER("CShwSlideShowPauseHandler::PhoneCallEndedL");
       
   129     GLX_LOG_INFO( 
       
   130         "CShwSlideShowPauseHandler::PhoneCallEndedL" );
       
   131     // set state to not in call
       
   132     iInCall = EFalse;
       
   133     // only resume when we are on foreground
       
   134     if( iOnForeground )
       
   135         {
       
   136         // get the engine state
       
   137         CShwSlideshowEngine::TShwState state = iEngine.State();
       
   138         // if not paused by user and engine is paused, resume
       
   139         if( ( !iUserPaused )&&
       
   140             ( CShwSlideshowEngine::EShwStatePaused == state ) )
       
   141             {
       
   142             iEngine.ResumeL(); 
       
   143             }
       
   144         }
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // SwitchToBackgroundL.
       
   149 // -----------------------------------------------------------------------------
       
   150 void CShwSlideShowPauseHandler::SwitchToBackgroundL()
       
   151     {
       
   152     TRACER("CShwSlideShowPauseHandler::SwitchToBackgroundL");
       
   153     GLX_LOG_INFO( 
       
   154         "CShwSlideShowPauseHandler::SwitchToBackgroundL" );
       
   155     // we are now not on foreground
       
   156     iOnForeground = EFalse;
       
   157     // get the engine state
       
   158     CShwSlideshowEngine::TShwState state = iEngine.State();
       
   159     // if engine is running
       
   160     if ( CShwSlideshowEngine::EShwStateRunning == state )
       
   161         {
       
   162         // Calling PauseL on the engine results in the view receiving an
       
   163         // paused event from engine observer.
       
   164         iEngine.PauseL();
       
   165         }
       
   166     }
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // SwitchToForegroundL.
       
   170 // -----------------------------------------------------------------------------
       
   171 void CShwSlideShowPauseHandler::SwitchToForegroundL()
       
   172     {
       
   173     TRACER("CShwSlideShowPauseHandler::SwitchToForegroundL");
       
   174     GLX_LOG_INFO( 
       
   175         "CShwSlideShowPauseHandler::SwitchToForegroundL" );
       
   176     // we are now on foreground
       
   177     iOnForeground = ETrue;
       
   178     // get the engine state
       
   179     CShwSlideshowEngine::TShwState state = iEngine.State();
       
   180     // if we are not paused by user, not in call and engine is paused, resume
       
   181     if( ( !iUserPaused )&&
       
   182         ( !iInCall )&&
       
   183         ( CShwSlideshowEngine::EShwStatePaused == state ) )
       
   184         {
       
   185         iEngine.ResumeL(); 
       
   186         }
       
   187     }
       
   188