brandingserver/bsclient/cbsfactory.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 15:31:29 +0300
branchRCL_3
changeset 21 cfd5c2994f10
parent 0 e6b17d312c8b
child 22 113b91e0a2ad
permissions -rw-r--r--
Revision: 201033 Kit: 201035

/*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "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:   Factory for creating branding
*
*/


// INCLUDE FILES
#include    "cbsfactory.h"
#include	"cbsaccess.h"
#include	"cbsupdater.h"
#include	"mbsaccess.h"
#include	"mbsupdater.h"
#include	"cbsclient.h"
#include    "DebugTrace.h"

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

// -----------------------------------------------------------------------------
// BrandingFactory::NewL
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
EXPORT_C CBSFactory* CBSFactory::NewL( const TDesC8& aDefaultBrandId,
							  const TDesC8& aApplicationId )
	{
    TRACE( T_LIT("CBSFactory::NewL begin") );
    CBSFactory* self = new ( ELeave ) CBSFactory() ;
    CleanupStack::PushL( self );
    self->ConstructL( aDefaultBrandId, aApplicationId );
    CleanupStack::Pop( self );  //self
    TRACE( T_LIT("CBSFactory::NewL end") );
    return self;
	}


// C++ default constructor can NOT contain any code, that
// might leave.
//
CBSFactory::CBSFactory()
	{
	}

// destructor
CBSFactory::~CBSFactory()
	{
	delete iDefaultBrand;
	delete iApplicationId;
	if( iServerKeepAlive )
		{
		iServerKeepAlive->Close();	
		}
	delete iServerKeepAlive;
	}

// Symbian OS default constructor can leave.
void CBSFactory::ConstructL( const TDesC8& aDefaultBrandId,
							 const TDesC8& aApplicationId )
	{
	iDefaultBrand = aDefaultBrandId.AllocL();
	iApplicationId = aApplicationId.AllocL();
	iServerKeepAlive = new(ELeave) RBSClient(); // CSI: 74 # this needs to be like this
	User::LeaveIfError( iServerKeepAlive->Connect() );
	}


// -----------------------------------------------------------------------------
// CBSFactory::CreateAccessL()
// -----------------------------------------------------------------------------
//
EXPORT_C MBSAccess* CBSFactory::CreateAccessL( const TDesC8& aBrandId,
    					  						  TLanguage aLanguageId,
    					  						  TBool aCacheData, /* = EFalse */
    					  						  TInt aReserved /*= 0*/ )
    {
    TRACE( T_LIT("CBSFactory::CreateAccessL begin") );
    CBSAccess* access = CBSAccess::NewL( aBrandId, *iApplicationId, *iDefaultBrand,
    									 aLanguageId, aCacheData, aReserved );
    TRACE( T_LIT("CBSFactory::CreateAccessL end") );
    return access;
    }

// -----------------------------------------------------------------------------
// CBSFactory::CreateAccessL()
// -----------------------------------------------------------------------------
//
EXPORT_C MBSAccess* CBSFactory::CreateAccessLC( const TDesC8& aBrandId,
    					  						  TLanguage aLanguageId,
    					  						  TBool aCacheData, /* = EFalse */
    					  						  TInt aReserved /*= 0 */)
    {
    CBSAccess* access = CBSAccess::NewL( aBrandId, *iApplicationId, *iDefaultBrand,
    									 aLanguageId, aCacheData, aReserved );
	CleanupClosePushL( *access );
    return access;
    }

// -----------------------------------------------------------------------------
// CBSFactory::CreateUpdaterL()
// -----------------------------------------------------------------------------
//
EXPORT_C MBSUpdater* CBSFactory::CreateUpdaterL()
    {
    CBSUpdater* updater = CBSUpdater::NewL( *iApplicationId );
    return updater;
    }

// -----------------------------------------------------------------------------
// CBSFactory::CreateUpdaterLC()
// -----------------------------------------------------------------------------
//
EXPORT_C MBSUpdater* CBSFactory::CreateUpdaterLC()
    {
    CBSUpdater* updater = CBSUpdater::NewL( *iApplicationId );
    CleanupClosePushL( *updater );
    return updater;
    }

//  End of File