smartinstaller/adm/src/progressdialog.cpp
branchADM
changeset 48 364021cecc90
equal deleted inserted replaced
47:3f419852be07 48:364021cecc90
       
     1 /*
       
     2 * Copyright (c) 2009 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include "progressdialog.h"
       
    19 #include <aknglobalprogressdialog.h>
       
    20 CProgressDialog* CProgressDialog::NewL(MProgressDialogClient& aOwner)
       
    21 {
       
    22 	CProgressDialog* self = new(ELeave) CProgressDialog(aOwner);
       
    23 	CleanupStack::PushL(self);
       
    24 	self->ConstructL();
       
    25 	CleanupStack::Pop(self);
       
    26 	return self;
       
    27 }
       
    28 
       
    29 CProgressDialog::CProgressDialog(MProgressDialogClient& aOwner) :
       
    30 	CActive(EPriorityStandard), iOwner(aOwner)
       
    31 {
       
    32 }
       
    33 
       
    34 void CProgressDialog::ConstructL()
       
    35 {
       
    36 	iProgress = CAknGlobalProgressDialog::NewL();
       
    37 	CActiveScheduler::Add(this);
       
    38 }
       
    39 
       
    40 void CProgressDialog::StartL(const TDesC& aPrompt, TInt aFinal)
       
    41 {
       
    42 	if(!IsActive()) {
       
    43 		iProgress->ShowProgressDialogL(iStatus, aPrompt, 0, aFinal);
       
    44 		SetActive();
       
    45 	}
       
    46 	iCurrentValue = 0;
       
    47 	iFinalValue = aFinal;
       
    48 }
       
    49 
       
    50 void CProgressDialog::Update(TInt aProgress, TInt aFinal)
       
    51 {
       
    52 	iCurrentValue = aProgress;
       
    53 	iFinalValue = aFinal;
       
    54 	iProgress->UpdateProgressDialog(aProgress, iFinalValue);
       
    55 }
       
    56 
       
    57 void CProgressDialog::Add(TInt aProgress)
       
    58 {
       
    59 	iCurrentValue += aProgress;
       
    60 	iProgress->UpdateProgressDialog(iCurrentValue, iFinalValue);
       
    61 }
       
    62 
       
    63 void CProgressDialog::Stop()
       
    64 {
       
    65 	iProgress->ProcessFinished();
       
    66 }
       
    67 
       
    68 void CProgressDialog::RunL()
       
    69 {
       
    70 	if(iStatus.Int() == EAknSoftkeyCancel)
       
    71 		iOwner.ProgressDialogCancelled();
       
    72 }
       
    73 
       
    74 CProgressDialog::~CProgressDialog()
       
    75 {
       
    76 	Cancel();
       
    77 	delete iProgress;
       
    78 }
       
    79 
       
    80 void CProgressDialog::DoCancel()
       
    81 {
       
    82 	iProgress->CancelProgressDialog();
       
    83 }