voiceui/pbkinfoviewimpl/src/pbkinfoviewutil.cpp
branchRCL_3
changeset 19 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Utility functions for PbkInfoView.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <eikenv.h>
       
    21 #include <bautils.h>
       
    22 #include <avkon.rsg>
       
    23 
       
    24 #include "pbkinfoviewutil.h"
       
    25 
       
    26 // -------------------------------------------------------------------------------
       
    27 // TPbkInfoViewUtil::Panic
       
    28 //
       
    29 // -------------------------------------------------------------------------------
       
    30 //
       
    31 void TPbkInfoViewUtil::Panic( TInt aReason )
       
    32     {
       
    33 	_LIT( KPanicCategory,"Info view" );
       
    34 
       
    35 	User::Panic( KPanicCategory, aReason ); 
       
    36     }
       
    37 
       
    38 // -------------------------------------------------------------------------------
       
    39 // TPbkInfoViewUtil::StrCopy
       
    40 //
       
    41 // String copy with length check.
       
    42 // @param TDes8& aTarget Copied text will be put to this variable.
       
    43 // @param TDesC& aSource Includes the text to be copied.
       
    44 // -------------------------------------------------------------------------------
       
    45 //
       
    46 void TPbkInfoViewUtil::StrCopy( TDes8& aTarget, const TDesC& aSource )
       
    47     {
       
    48 	TInt len = aTarget.MaxLength();
       
    49     if( len < aSource.Length() ) 
       
    50 	    {
       
    51 		aTarget.Copy( aSource.Left( len ) );
       
    52 		return;
       
    53 	    }
       
    54 	aTarget.Copy( aSource );
       
    55     }
       
    56 
       
    57 // -------------------------------------------------------------------------------
       
    58 // TPbkInfoViewUtil::StrCopy
       
    59 //
       
    60 // String copy with length check.
       
    61 // @param TDes& aTarget Copied text will be put to this variable.
       
    62 // @param TDesC8& aSource Includes the text to be copied.
       
    63 // -------------------------------------------------------------------------------
       
    64 //
       
    65 void TPbkInfoViewUtil::StrCopy( TDes& aTarget, const TDesC8& aSource )
       
    66     {
       
    67 	TInt len = aTarget.MaxLength();
       
    68     if( len < aSource.Length() ) 
       
    69 	    {
       
    70 		aTarget.Copy( aSource.Left( len ) );
       
    71 		return;
       
    72 	    }
       
    73 	aTarget.Copy( aSource );
       
    74     }
       
    75 
       
    76 // -------------------------------------------------------------------------------
       
    77 // TPbkInfoViewUtil::StrCopy
       
    78 //
       
    79 // String copy with length check.
       
    80 // @param TDes& aTarget Copied text will be put to this variable.
       
    81 // @param TDesC& aSource Includes the text to be copied.
       
    82 // -------------------------------------------------------------------------------
       
    83 //
       
    84 void TPbkInfoViewUtil::StrCopy( TDes& aTarget, const TDesC& aSource )
       
    85     {
       
    86 	TInt len = aTarget.MaxLength();
       
    87     if( len < aSource.Length() ) 
       
    88 	    {
       
    89 		aTarget.Copy( aSource.Left(len) );
       
    90 		return;
       
    91 	    }
       
    92 	aTarget.Copy( aSource );
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // TPbkInfoViewUtil::AddResFileL
       
    97 // Adds resource file to control environment.
       
    98 // @param aFile File location.
       
    99 // @return TInt Error code.
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 TInt TPbkInfoViewUtil::AddResFileL( const TDesC& aFile )
       
   103 	{
       
   104 	CEikonEnv* env = CEikonEnv::Static();
       
   105 
       
   106 	TFileName fileName( aFile );
       
   107 
       
   108 	BaflUtils::NearestLanguageFile( env->FsSession(), fileName );
       
   109 
       
   110     return env->AddResourceFileL( fileName );
       
   111 	}
       
   112 
       
   113 // End of file