iaupdate/IAD/engine/controller/src/iaupdatenodeembeddedxmlparser.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2009 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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <xml/documentparameters.h>
       
    21 #include <xml/taginfo.h>
       
    22 #include <xml/attribute.h>
       
    23 #include <ncdutils.h>
       
    24 
       
    25 #include "iaupdatenodeembeddedxmlparser.h"
       
    26 #include "iaupdatenodedependencyimpl.h"
       
    27 #include "iaupdateprotocolconsts.h"
       
    28 
       
    29 
       
    30 CIAUpdateNodeEmbeddedXmlParser* CIAUpdateNodeEmbeddedXmlParser::NewL( 
       
    31                                       CIAUpdateNodeDependency*& aDependency )
       
    32     {
       
    33     CIAUpdateNodeEmbeddedXmlParser* self =
       
    34         CIAUpdateNodeEmbeddedXmlParser::NewLC( aDependency );
       
    35     CleanupStack::Pop( self );
       
    36     return self;
       
    37     }
       
    38 
       
    39 
       
    40 CIAUpdateNodeEmbeddedXmlParser* CIAUpdateNodeEmbeddedXmlParser::NewLC( 
       
    41                                       CIAUpdateNodeDependency*& aDependency )
       
    42     {
       
    43     CIAUpdateNodeEmbeddedXmlParser* self =
       
    44         new( ELeave ) CIAUpdateNodeEmbeddedXmlParser( aDependency );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     return self;    
       
    48     }
       
    49 
       
    50 
       
    51 CIAUpdateNodeEmbeddedXmlParser::CIAUpdateNodeEmbeddedXmlParser( 
       
    52                                       CIAUpdateNodeDependency*& aDependency )
       
    53 : CIAUpdateXmlSubParser(),
       
    54   iDependency( aDependency )
       
    55     {
       
    56     
       
    57     }
       
    58     
       
    59     
       
    60 void CIAUpdateNodeEmbeddedXmlParser::ConstructL()
       
    61     {
       
    62     CIAUpdateXmlSubParser::ConstructL( IAUpdateProtocolConsts::KNodeEmbedded() );    
       
    63     }
       
    64 
       
    65 
       
    66 CIAUpdateNodeEmbeddedXmlParser::~CIAUpdateNodeEmbeddedXmlParser()
       
    67     {
       
    68     }
       
    69 
       
    70 
       
    71 void CIAUpdateNodeEmbeddedXmlParser::OnContentL( const TDesC8& aBytes, 
       
    72                                                  TInt aErrorCode )
       
    73     {
       
    74     // If the parent wants to do something with the information.
       
    75     CIAUpdateXmlSubParser::OnContentL( aBytes, aErrorCode );
       
    76 
       
    77     // Check if this is the leaf parser and no other sub parser should 
       
    78     // handle this.
       
    79     if ( AcceptData() )
       
    80         {
       
    81         // We have gotten content for this element.
       
    82         // Now, set the node information to the dependency object.
       
    83         _LIT8( KTrue, "true" );
       
    84         _LIT8( KFalse, "false" );
       
    85         _LIT8( KOneTrue, "1" );
       
    86         _LIT8( KZeroFalse, "0" );
       
    87 
       
    88         TBool embedded( EFalse );    
       
    89         if ( aBytes.CompareF( KTrue() ) == 0 
       
    90              || aBytes.CompareF( KOneTrue() ) == 0 )
       
    91             {
       
    92             embedded = ETrue;
       
    93             }
       
    94         else if ( aBytes.CompareF( KFalse() ) == 0 
       
    95                   || aBytes.CompareF( KZeroFalse() ) == 0 )
       
    96             {
       
    97             embedded = EFalse;
       
    98             }
       
    99         else
       
   100             {
       
   101             // The content is corrupted.
       
   102             User::Leave( KErrArgument );
       
   103             }
       
   104             
       
   105         DependencyL().SetEmbedded( embedded );
       
   106         }
       
   107     }
       
   108 
       
   109 
       
   110 CIAUpdateNodeDependency& CIAUpdateNodeEmbeddedXmlParser::DependencyL()
       
   111     {
       
   112     if ( !iDependency )
       
   113         {
       
   114         User::Leave( KErrNotFound );
       
   115         }
       
   116         
       
   117     return *iDependency;
       
   118     }
       
   119