contextframework/cfwplugins/ApplicationStateSourcePlugIn/src/cfapplicationstatesettings.cpp
author fimarlaht2 <>
Mon, 18 Oct 2010 15:01:14 +0300
branchRCL_3
changeset 85 32f887d619a0
parent 63 c2c61fdca848
permissions -rw-r--r--
Bug 3556 - Not possible to restore factory settings

/*
* Copyright (c) 2007-2010 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:  Encapsulates information about application and its views.
*
*/


#include "cfapplicationstatesettings.h"

// ======== MEMBER FUNCTIONS ========

CCFApplicationStateSettings::CCFApplicationStateSettings()
    {
    }

void CCFApplicationStateSettings::ConstructL( const TUid& aUid,
    const TDesC& aName )
    {
    iApplicationInfo = CCFUidNamePair::NewL( aUid, aName );
    }

CCFApplicationStateSettings* CCFApplicationStateSettings::NewL(
    const TUid& aUid,
    const TDesC& aName )
    {
    CCFApplicationStateSettings* self
        = CCFApplicationStateSettings::NewLC( aUid, aName );
    CleanupStack::Pop( self );

    return self;
    }

CCFApplicationStateSettings* CCFApplicationStateSettings::NewLC(
    const TUid& aUid,
    const TDesC& aName )
    {
    CCFApplicationStateSettings* self
        = new( ELeave ) CCFApplicationStateSettings();
    CleanupStack::PushL( self );
    self->ConstructL( aUid, aName );

    return self;
    }

CCFApplicationStateSettings::~CCFApplicationStateSettings()
    {
    delete iApplicationInfo;
    iViewInfo.ResetAndDestroy();
    }


//-----------------------------------------------------------------------------
// CCFApplicationStateSettings::Uid
//-----------------------------------------------------------------------------
//
const TUid& CCFApplicationStateSettings::Uid() const
    {
    return iApplicationInfo->Uid();
    }

//-----------------------------------------------------------------------------
// CCFApplicationStateSettings::Name
//-----------------------------------------------------------------------------
//
const TDesC& CCFApplicationStateSettings::Name() const
    {
    if( !iApplicationInfo )
        {
        return KNullDesC;
        }
    else
        {
        return iApplicationInfo->Name();
        }
    }

//-----------------------------------------------------------------------------
// CCFApplicationStateSettings::AddViewSettingsL
//-----------------------------------------------------------------------------
//
void CCFApplicationStateSettings::AddViewSettingsL( 
    CCFUidNamePair* aViewSettings )
    {
    iViewInfo.AppendL( aViewSettings );
    }

//-----------------------------------------------------------------------------
// CCFApplicationStateSettings::AddViewSettingsL
//-----------------------------------------------------------------------------
//
TBool CCFApplicationStateSettings::GetViewName( const TUid& aUid, 
    TPtrC& aName ) const
    {
    TBool matchFound = EFalse;
    for ( TInt i = 0; i < iViewInfo.Count(); ++i )
        {
        if ( aUid == iViewInfo[ i ]->Uid() )
            {
            aName.Set( iViewInfo[ i ]->Name() );
            matchFound = ETrue;
            break;
            }
        }
    return matchFound;
    }