supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasupldialogtimer.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:24:21 +0100
branchRCL_3
changeset 21 6b6920c56e2f
parent 0 667063e416a2
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035

/*
* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:   General purpose class for timeout notification.
*
*/



#include "epos_comasupldialogtimer.h"
#include "epos_momasupldialogtimeoutnotifier.h"

#if defined(_DEBUG)
	_LIT( KPanicMsg, "COMASuplDialogTimer");
#endif	
    
// COMASuplDialogTimer::NewL
// Creates instance of COMASuplDialogTimer

COMASuplDialogTimer* COMASuplDialogTimer::NewL(MOMASuplDialogTimeOutNotifier& aTimeOutNotify)
    {
    COMASuplDialogTimer* self = COMASuplDialogTimer::NewLC(aTimeOutNotify);
    CleanupStack::Pop(self);
    return self;
    }

// COMASuplTimeoutTimer::NewLC
// Creates instance of COMASuplTimeoutTimer & pushes into cleanup stack    
COMASuplDialogTimer* COMASuplDialogTimer::NewLC(MOMASuplDialogTimeOutNotifier& aTimeOutNotify)
    {
    COMASuplDialogTimer* self = new (ELeave) COMASuplDialogTimer(aTimeOutNotify);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

// COMASuplDialogTimer::COMASuplDialogTimer
// Constructor
COMASuplDialogTimer::COMASuplDialogTimer(MOMASuplDialogTimeOutNotifier& aTimeOutNotify)
: CTimer(CActive::EPriorityStandard), iNotify(aTimeOutNotify),iTimerExpired(EFalse)
    {
    }

// COMASuplDialogTimer::~COMASuplDialogTimer()
// Destuctor
COMASuplDialogTimer::~COMASuplDialogTimer()
    {
    }

// COMASuplDialogTimer::ConstructL()
// 2nd phase constuction
void COMASuplDialogTimer::ConstructL()
    {
    CTimer::ConstructL();
    CActiveScheduler::Add(this);
    }

// COMASuplDialogTimer::StartTimer()
// Starts timer
void COMASuplDialogTimer::StartTimer( const TInt aTimeOut)
    {
	    if (!IsActive())
	    	{
	    		iTimerExpired = EFalse;
	    		After(aTimeOut);
	    	}
    }

// COMASuplDialogTimer::StopTimer()
// Stops timer
void COMASuplDialogTimer::StopTimer()
    {
    		iTimerExpired = EFalse;
			Cancel();
    }

// COMASuplDialogTimer::RunL()
// Gets called when time out occurs
void COMASuplDialogTimer::RunL()
    {
    // Timer request has completed, so notify the timer's owner
    if (iStatus == KErrNone)
        {
        	iTimerExpired = ETrue;
        	iNotify.DialogTimerExpiredL();
        }
    else
        {
        #if defined(_DEBUG)
        	User::Panic(KPanicMsg, ESuplDialogTimeoutTimerFailed);
        #endif	
        }
    }

TBool COMASuplDialogTimer::IsTimerExpired()
	{
		return iTimerExpired;
	}
TBool COMASuplDialogTimer::IsTimerStarted()
	{
		if(IsActive())
			{
				return ETrue;
			}
		else
			{
				return EFalse;
			}	
	}