multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdGetProperty.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2008 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:    Implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "MCEConstants.h"
       
    21 #include "TCmdGetProperty.h"
       
    22 #include "CTcMCEContext.h"
       
    23 #include "mcetesterpskeys.h"
       
    24 
       
    25 #include <e32property.h>
       
    26 
       
    27 
       
    28 void TCmdGetProperty::ExecuteL()
       
    29 	{
       
    30     // ---------- Setup --------------------------------------------------------
       
    31 
       
    32     //Getting Uids and value
       
    33     TInt uidValue = ExtractIntegerL( KParamPropertyUid, 0, EFalse );
       
    34     TInt key = ExtractIntegerL( KParamPropertyKey, 0, ETrue );
       
    35     TUid uidkey = KUidMceTesterPSKeys;
       
    36     if ( uidValue != 0 )
       
    37         {
       
    38         uidkey = TUid::Uid( uidValue );
       
    39         }
       
    40 
       
    41 
       
    42 	// ---------- Execution ----------------------------------------------------	
       
    43 
       
    44 	TBool intParameterUsed = ETrue;
       
    45     TInt intValue( 0 );
       
    46     HBufC8* descrValue( NULL );
       
    47 
       
    48     // Try to get as integer value
       
    49     TInt err = RProperty::Get( uidkey, key, intValue );
       
    50     if ( err == KErrArgument )
       
    51     	{
       
    52     	// Parameter was not integer, so it is text
       
    53     	intParameterUsed = EFalse;
       
    54     	descrValue = HBufC8::NewLC( KPropertyTextValueMaxLength );
       
    55 
       
    56 		TPtr8 ptr( descrValue->Des() );
       
    57 		User::LeaveIfError( RProperty::Get( uidkey, key, ptr ) );
       
    58     	}
       
    59     else
       
    60     	{
       
    61     	User::LeaveIfError( err );
       
    62     	}
       
    63 
       
    64 
       
    65 	// ---------- Response creation --------------------------------------------
       
    66 
       
    67 	if ( intParameterUsed )
       
    68 		{
       
    69 		AddIntegerResponseL( KResponsePropertyValue, intValue );	
       
    70 		}
       
    71 	else
       
    72 		{
       
    73 		AddTextResponseL( KResponsePropertyTextValue, *descrValue );
       
    74 		CleanupStack::PopAndDestroy( descrValue );
       
    75 		}
       
    76     }
       
    77 	
       
    78 TBool TCmdGetProperty::Match( const TTcIdentifier& aId )
       
    79 	{
       
    80 	return TTcMceCommandBase::Match( aId, _L8("GetProperty") );
       
    81 	}
       
    82 
       
    83 TTcCommandBase* TCmdGetProperty::CreateL( MTcTestContext& aContext )
       
    84 	{
       
    85 	return new( ELeave ) TCmdGetProperty( aContext );
       
    86 	}