idlehomescreen/xmluicontroller/src/aipolicyelement.cpp
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Policy element
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "aipolicyelement.h"
       
    20 #include "aixmluiconstants.h"
       
    21 #include "xmluicontrollerpanic.h"
       
    22 
       
    23 using namespace AiXmlUiController;
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 TAiPolicyElement::TAiPolicyElement()
       
    28     : iTarget( NULL ),
       
    29       iPolicy( KNullDesC8 ),
       
    30       iSeparator( KErrNotFound )
       
    31     {
       
    32     }
       
    33 
       
    34 TAiPolicyElement::TAiPolicyElement( CXnNodeAppIf& aTarget, const TDesC8& aPolicy )
       
    35     : iTarget( &aTarget ),
       
    36       iPolicy( aPolicy )
       
    37     {
       
    38     iSeparator = iPolicy.Find( AiUiDef::xml::css::KSeparator );
       
    39     }
       
    40 
       
    41 CXnNodeAppIf& TAiPolicyElement::Target() const
       
    42     {
       
    43     if ( !iTarget )
       
    44         {
       
    45         AiXmlUiController::Panic( ETargetNodeNull );
       
    46         }
       
    47         
       
    48     return *iTarget;
       
    49     }
       
    50 
       
    51 TPtrC8 TAiPolicyElement::Name() const
       
    52     {
       
    53     if ( iSeparator < 0 )
       
    54         {
       
    55         return TPtrC8( KNullDesC8 );
       
    56         }
       
    57         
       
    58     return TLex8( iPolicy.Left( iSeparator ) ).NextToken();
       
    59     }
       
    60 
       
    61 TPtrC8 TAiPolicyElement::Policy() const
       
    62     {
       
    63     return iPolicy;
       
    64     }
       
    65 
       
    66 TPtrC8 TAiPolicyElement::Value() const
       
    67     {
       
    68     if ( iSeparator < 0 )
       
    69         {
       
    70         return TPtrC8( KNullDesC8 );
       
    71         }
       
    72         
       
    73     TPtrC8 value( TLex8( iPolicy.Mid( iSeparator + 1 ) ).NextToken() );
       
    74     
       
    75     TInt terminatorPos = value.Find( AiUiDef::xml::css::KValueTerminator );
       
    76     
       
    77     if ( terminatorPos > KErrNotFound )
       
    78         {
       
    79         return value.Left( terminatorPos );
       
    80         }
       
    81     else
       
    82         {
       
    83         return value;
       
    84         }
       
    85     }