photosgallery/slideshow/engine/controlsrc/shwtimercontrol.cpp
changeset 0 4e91876724a2
child 16 0bc0ea26031e
child 18 bcb43dc84c44
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 timer control for the slideshow
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "shwtimercontrol.h"
       
    22 #include "shwevent.h"
       
    23 #include "shwcallback.h"
       
    24 #include "shwtimer.h"
       
    25 
       
    26 #include <glxlog.h>
       
    27 #include <glxtracer.h>
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // C++ Constructor. Save a few bits of rom with inlining
       
    31 // -----------------------------------------------------------------------------
       
    32 inline CShwTimerControl::CShwTimerControl()
       
    33 	{
       
    34 	// No implementation required
       
    35 	}
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // NewL. Static construction
       
    39 // -----------------------------------------------------------------------------
       
    40 CShwTimerControl* CShwTimerControl::NewL()
       
    41 	{
       
    42 	TRACER("CShwTimerControl::NewL");
       
    43 	GLX_LOG_INFO( "CShwTimerControl::NewL" );
       
    44 	CShwTimerControl* self = new( ELeave ) CShwTimerControl;
       
    45 	CleanupStack::PushL( self );
       
    46 	self->ConstructL();
       
    47 	CleanupStack::Pop( self );
       
    48 	return self;
       
    49 	}
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // Destructor.
       
    53 // -----------------------------------------------------------------------------
       
    54 CShwTimerControl::~CShwTimerControl()
       
    55 	{
       
    56 	TRACER("CShwTimerControl::~CShwTimerControl");
       
    57     GLX_LOG_INFO( "CShwTimerControl::~CShwTimerControl" );
       
    58 	// just delete, it cancels the timer
       
    59 	delete iTimer;
       
    60 	}
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // ConstructL.
       
    64 // -----------------------------------------------------------------------------
       
    65 void CShwTimerControl::ConstructL()
       
    66 	{
       
    67 	TRACER("CShwTimerControl::ConstructL");
       
    68 	// create the timer
       
    69 	iTimer = CShwTimer::NewL( CActive::EPriorityStandard ); // neutral priority
       
    70 	}
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // SendTimerBeatL.
       
    74 // -----------------------------------------------------------------------------
       
    75 TInt CShwTimerControl::SendTimerBeatL()
       
    76 	{
       
    77 	TRACER("CShwTimerControl::SendTimerBeatL");
       
    78     GLX_LOG_INFO( "CShwTimerControl::SendTimerBeatL" );
       
    79 	// cancel the timer
       
    80 	iTimer->Cancel();
       
    81 	// send the timerbeat
       
    82 	TShwEventTimerBeat timerbeat;
       
    83 	SendEventL( &timerbeat );
       
    84 	// return KErrNone, return value is ignored by CPeriodic
       
    85 	return KErrNone;
       
    86 	}
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // NotifyL.
       
    90 // -----------------------------------------------------------------------------
       
    91 void CShwTimerControl::NotifyL( MShwEvent* aEvent )
       
    92 	{
       
    93 	TRACER("CShwTimerControl::NotifyL");
       
    94     GLX_LOG_INFO( "CShwTimerControl::NotifyL" );
       
    95 	TShwEventStartView* eventStartView = 
       
    96 		dynamic_cast<TShwEventStartView*>( aEvent );
       
    97     // was it start view
       
    98 	if( eventStartView )
       
    99 		{
       
   100 		// event is start view
       
   101 		TInt interval = eventStartView->Parameter();
       
   102 		// get the relevant delay and interval values
       
   103 	    GLX_LOG_INFO1( 
       
   104 	        "CShwTimerControl::NotifyL - TShwEventStartView %d", interval );
       
   105 
       
   106 		// Start the timer with the appropriate values for the event
       
   107 		iTimer->Start( interval, interval,
       
   108 			TShwCallBack< CShwTimerControl, SendTimerBeatL >( this ) );		
       
   109 		}
       
   110     // was it start pause
       
   111 	else if ( dynamic_cast<TShwEventPause*>( aEvent ) )
       
   112 		{
       
   113 		GLX_LOG_INFO( "CShwTimerControl::NotifyL - TShwEventPause" );
       
   114 		// pause the timer
       
   115 		iTimer->Pause();
       
   116 		}
       
   117     // was it start resume
       
   118 	else if( dynamic_cast<TShwEventResume*>( aEvent ) )
       
   119 		{
       
   120 		// event is resume
       
   121 	    GLX_LOG_INFO( "CShwTimerControl::NotifyL - TShwEventResume" );
       
   122 		// resume the timer
       
   123 		iTimer->Resume();
       
   124 		}
       
   125 	// was it next or previous image?
       
   126 	else if ( dynamic_cast< TShwEventNextImage* >( aEvent ) || 
       
   127 			  dynamic_cast< TShwEventPreviousImage* >( aEvent ) )
       
   128 	    {
       
   129 	    GLX_LOG_INFO( "CShwTimerControl::NotifyL - TShwEventNext/PreviousImage" );
       
   130         // cancel the timer as we have moved to another image
       
   131         iTimer->Cancel();
       
   132 	    }
       
   133 	else if ( dynamic_cast< TShwEventToggleControlUi* >( aEvent ))
       
   134         {
       
   135         GLX_LOG_INFO( "CShwTimerControl::NotifyL - TShwEventToggleControlUi" );
       
   136         // Have to impliment if need comes
       
   137         }
       
   138 	}