smartinstaller/common/globalwaitnote.cpp
branchADM
changeset 48 364021cecc90
equal deleted inserted replaced
47:3f419852be07 48:364021cecc90
       
     1 /*
       
     2 * Copyright (c) 2010 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 *     CGlobalWaitNoteObserver Definition.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 #include <aknglobalnote.h>
       
    21 #include <stringloader.h>
       
    22 #include <avkon.hrh>
       
    23 #include <avkon.rsg>
       
    24 
       
    25 #include "globalwaitnote.h"
       
    26 
       
    27 CGlobalWaitNote* CGlobalWaitNote::NewLC(MGlobalWaitNoteClient& aOwner, TBool aCancellable)
       
    28 	{
       
    29 	CGlobalWaitNote* self = new(ELeave) CGlobalWaitNote(aOwner, aCancellable);
       
    30 	CleanupStack::PushL(self);
       
    31 	self->ConstructL();
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 CGlobalWaitNote* CGlobalWaitNote::NewL(MGlobalWaitNoteClient& aOwner, TBool aCancellable)
       
    36 	{
       
    37 	CGlobalWaitNote* self = NewLC(aOwner, aCancellable);
       
    38 	CleanupStack::Pop(self);
       
    39 	return self;
       
    40 	}
       
    41 
       
    42 CGlobalWaitNote::CGlobalWaitNote(MGlobalWaitNoteClient& aOwner, TBool aCancellable) :
       
    43 	CActive(EPriorityStandard),
       
    44 	iOwner(aOwner),
       
    45 	iCancellable(aCancellable)
       
    46 	{
       
    47 	CActiveScheduler::Add(this);
       
    48 	}
       
    49 
       
    50 void CGlobalWaitNote::ConstructL()
       
    51 	{
       
    52 	iWaitNote = CAknGlobalNote::NewL();
       
    53 	}
       
    54 
       
    55 CGlobalWaitNote::~CGlobalWaitNote()
       
    56 	{
       
    57 	if ( IsActive() )
       
    58 		{
       
    59 		Cancel();
       
    60 		}
       
    61 	delete iWaitNote;
       
    62 	iWaitNote = NULL;
       
    63 	}
       
    64 
       
    65 void CGlobalWaitNote::ShowNoteL(const TDesC& aText)
       
    66 	{
       
    67 	if ( !IsActive() )
       
    68 		{
       
    69 		if ( !iCancellable )
       
    70 			{
       
    71 			iWaitNote->SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY );
       
    72 			}
       
    73 		iWaitNoteId = iWaitNote->ShowNoteL(
       
    74 			iStatus,
       
    75 			EAknGlobalWaitNote,
       
    76 			aText );
       
    77 		SetActive();
       
    78 		}
       
    79 	}
       
    80 
       
    81 void CGlobalWaitNote::CancelNoteL()
       
    82 	{
       
    83 	if ( iWaitNote /* && iWaitNoteId >= 0*/ )
       
    84 		{
       
    85 		iWaitNote->CancelNoteL( iWaitNoteId );
       
    86 		delete iWaitNote;
       
    87 		iWaitNote = NULL;
       
    88 		}
       
    89 	}
       
    90 
       
    91 void CGlobalWaitNote::RunL()
       
    92 	{
       
    93 	// Always cancel i.e. remove the note
       
    94 	CancelNoteL();
       
    95 	if ( iCancellable && iStatus.Int() == EAknSoftkeyCancel )
       
    96 		{
       
    97 		iOwner.WaitNoteCancelled();
       
    98 		}
       
    99 	}
       
   100 
       
   101 void CGlobalWaitNote::DoCancel()
       
   102 	{
       
   103 	}