voiceui/pbkinfoviewimpl/src/pbkinfoviewutil.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:29:17 +0100
branchRCL_3
changeset 19 e36f3802f733
parent 0 bf1d17376201
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035

/*
* Copyright (c) 2002-2005 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:  Utility functions for PbkInfoView.
*
*/


// INCLUDES
#include <eikenv.h>
#include <bautils.h>
#include <avkon.rsg>

#include "pbkinfoviewutil.h"

// -------------------------------------------------------------------------------
// TPbkInfoViewUtil::Panic
//
// -------------------------------------------------------------------------------
//
void TPbkInfoViewUtil::Panic( TInt aReason )
    {
	_LIT( KPanicCategory,"Info view" );

	User::Panic( KPanicCategory, aReason ); 
    }

// -------------------------------------------------------------------------------
// TPbkInfoViewUtil::StrCopy
//
// String copy with length check.
// @param TDes8& aTarget Copied text will be put to this variable.
// @param TDesC& aSource Includes the text to be copied.
// -------------------------------------------------------------------------------
//
void TPbkInfoViewUtil::StrCopy( TDes8& aTarget, const TDesC& aSource )
    {
	TInt len = aTarget.MaxLength();
    if( len < aSource.Length() ) 
	    {
		aTarget.Copy( aSource.Left( len ) );
		return;
	    }
	aTarget.Copy( aSource );
    }

// -------------------------------------------------------------------------------
// TPbkInfoViewUtil::StrCopy
//
// String copy with length check.
// @param TDes& aTarget Copied text will be put to this variable.
// @param TDesC8& aSource Includes the text to be copied.
// -------------------------------------------------------------------------------
//
void TPbkInfoViewUtil::StrCopy( TDes& aTarget, const TDesC8& aSource )
    {
	TInt len = aTarget.MaxLength();
    if( len < aSource.Length() ) 
	    {
		aTarget.Copy( aSource.Left( len ) );
		return;
	    }
	aTarget.Copy( aSource );
    }

// -------------------------------------------------------------------------------
// TPbkInfoViewUtil::StrCopy
//
// String copy with length check.
// @param TDes& aTarget Copied text will be put to this variable.
// @param TDesC& aSource Includes the text to be copied.
// -------------------------------------------------------------------------------
//
void TPbkInfoViewUtil::StrCopy( TDes& aTarget, const TDesC& aSource )
    {
	TInt len = aTarget.MaxLength();
    if( len < aSource.Length() ) 
	    {
		aTarget.Copy( aSource.Left(len) );
		return;
	    }
	aTarget.Copy( aSource );
    }

// -----------------------------------------------------------------------------
// TPbkInfoViewUtil::AddResFileL
// Adds resource file to control environment.
// @param aFile File location.
// @return TInt Error code.
// -----------------------------------------------------------------------------
//
TInt TPbkInfoViewUtil::AddResFileL( const TDesC& aFile )
	{
	CEikonEnv* env = CEikonEnv::Static();

	TFileName fileName( aFile );

	BaflUtils::NearestLanguageFile( env->FsSession(), fileName );

    return env->AddResourceFileL( fileName );
	}

// End of file