accessoryservices/remotecontrolfw/client/extapi1/src/absvolutils.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @publishedPartner
       
    19  @released
       
    20 */
       
    21 
       
    22 #include "absvolutils.h"
       
    23 
       
    24 TInt GetAbsMaxVol(const TDesC8& aData, TUint& aAbsVol, TUint& aMaxVol)
       
    25 	{
       
    26 	// Decompose aData to get the absolute volume. It should be in the format 
       
    27 	// '0xAAAAAAAA0xBBBBBBBB' where AAAAAAAA is the absolute volume, and 
       
    28 	// BBBBBBBB is the maximum volume. If it isn't in this format, return 
       
    29 	// error.
       
    30 	TInt err = KErrArgument;
       
    31 
       
    32 	// 20 is the size we need for the following formatting.
       
    33 	if ( aData.Length() >= 20 )
       
    34 		{
       
    35 		TLex8 lex(aData.Mid(2, 8));
       
    36 		err = lex.Val(aAbsVol, EHex);
       
    37 		if ( err == KErrNone )
       
    38 			{
       
    39 			TLex8 lex(aData.Mid(12, 8));
       
    40 			err = lex.Val(aMaxVol, EHex);
       
    41 			}
       
    42 		}
       
    43 
       
    44 	return err;
       
    45 	}