/*
* Copyright (c) 2002 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: 
*
*/

// AknProgressTimer.cpp: implementation of the CAknProgressTimer class.
//
//////////////////////////////////////////////////////////////////////
#include <coemain.h>
#include "aknnotecontrol.h"
#include "aknprogresstimer.h"
#include "akntrace.h"


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CAknProgressTimer::CAknProgressTimer() : CTimer(EActivePriorityClockTimer)
  {

  }


CAknProgressTimer::~CAknProgressTimer()
  {
  Cancel();
  }

void CAknProgressTimer::AdjustRunningState()
  {
  (iModel->iRunning) ? Queue() : Cancel();
  }

void CAknProgressTimer::ConstructL(TTimerModel *aModel,CAknNoteControl *aContainer,TCallBack aCallBack)
  {
  _AKNTRACE_FUNC_ENTER;
  iCallBack = aCallBack;
  CTimer::ConstructL();
  CActiveScheduler::Add(this);
  iModel = aModel;
  iContainer = aContainer;
  iContainer->SetFinalProgressValue(iModel->iFinalValue);
  if (iModel->iRunning)
    Queue();
  _AKNTRACE_FUNC_EXIT;
  }

void CAknProgressTimer::Queue()
  {
  After(10000 * iModel->iHundreths);
  }

void CAknProgressTimer::RunL()
  {
  _AKNTRACE_FUNC_ENTER;
  if (iContainer->IncrementBarsAndDraw(iModel->iIncrement))
    Queue();
  else
    iCallBack.CallBack();
  _AKNTRACE_FUNC_EXIT;
  }

// End of File
