iaupdate/IAD/engine/controller/src/iaupdateenginexmlsubparser.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 
       
    24 #include "iaupdateenginexmlsubparser.h"
       
    25 #include "iaupdateengineconfigdata.h"
       
    26 #include "iaupdateengineconfigconsts.h"
       
    27 
       
    28 
       
    29 CIAUpdateEngineXmlSubParser* CIAUpdateEngineXmlSubParser::NewL( 
       
    30                                          CIAUpdateEngineConfigData& aConfigData )
       
    31     {
       
    32     CIAUpdateEngineXmlSubParser* self =
       
    33         CIAUpdateEngineXmlSubParser::NewLC( aConfigData );
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37 
       
    38 
       
    39 CIAUpdateEngineXmlSubParser* CIAUpdateEngineXmlSubParser::NewLC( 
       
    40                                          CIAUpdateEngineConfigData& aConfigData )
       
    41     {
       
    42     CIAUpdateEngineXmlSubParser* self =
       
    43         new( ELeave ) CIAUpdateEngineXmlSubParser( aConfigData );
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL();
       
    46     return self;    
       
    47     }
       
    48 
       
    49 
       
    50 CIAUpdateEngineXmlSubParser::CIAUpdateEngineXmlSubParser( 
       
    51                                          CIAUpdateEngineConfigData& aConfigData )
       
    52 : CIAUpdateXmlSubParser(),
       
    53   iConfigData( aConfigData )
       
    54     {
       
    55     
       
    56     }
       
    57     
       
    58     
       
    59 void CIAUpdateEngineXmlSubParser::ConstructL()
       
    60     {
       
    61     CIAUpdateXmlSubParser::ConstructL( IAUpdateEngineConfigConsts::KIAElementLocalName );
       
    62     }
       
    63 
       
    64 
       
    65 CIAUpdateEngineXmlSubParser::~CIAUpdateEngineXmlSubParser()
       
    66     {
       
    67     }
       
    68 
       
    69 
       
    70 const CIAUpdateEngineConfigData& CIAUpdateEngineXmlSubParser::ConfigData() const
       
    71     {
       
    72     return iConfigData;
       
    73     }
       
    74 
       
    75 
       
    76 void CIAUpdateEngineXmlSubParser::OnStartElementL( const Xml::RTagInfo& aElement, 
       
    77                                                    const Xml::RAttributeArray& aAttributes, 
       
    78                                                    TInt aErrorCode )
       
    79     {
       
    80     CIAUpdateXmlSubParser::OnStartElementL( aElement, aAttributes, aErrorCode );
       
    81     
       
    82     if ( aErrorCode == KErrNone )
       
    83         {
       
    84         const TDesC8& element = aElement.LocalName().DesC();
       
    85 
       
    86         // KIAUpdateEngineConfig starts the whole configuration info.
       
    87         // But, we are not so picky here. So, just let it go through
       
    88         // and forget checkings. Also, if unknown element is given here,
       
    89         // just ignore it.
       
    90 
       
    91         if ( element == IAUpdateEngineConfigConsts::KIAStorage )
       
    92             {
       
    93             HandleStorageAttributesL( aAttributes );            
       
    94             }
       
    95         else if ( element == IAUpdateEngineConfigConsts::KIAMasterServer )
       
    96             {
       
    97             HandleMasterServerAttributesL( aAttributes );
       
    98             }
       
    99         else if ( element == IAUpdateEngineConfigConsts::KIAProvisioning )
       
   100             {
       
   101             HandleProvisioningAttributesL( aAttributes );
       
   102             }
       
   103         else if ( element == IAUpdateEngineConfigConsts::KIAClientRole )
       
   104             {
       
   105             HandleClientRoleAttributesL( aAttributes );
       
   106             }
       
   107         }
       
   108     }
       
   109 
       
   110 
       
   111 void CIAUpdateEngineXmlSubParser::HandleStorageAttributesL( 
       
   112                                 const Xml::RAttributeArray& aAttributes )
       
   113     {
       
   114     for ( TInt i = 0; i < aAttributes.Count(); ++ i )
       
   115         {
       
   116         const TDesC8& attributeName =
       
   117             aAttributes[ i ].Attribute().LocalName().DesC();
       
   118         
       
   119         const TDesC8& attributeValue =
       
   120             aAttributes[ i ].Value().DesC();
       
   121 
       
   122         HBufC* value( HBufC::NewLC( attributeValue.Length() ) );
       
   123         value->Des().Copy( attributeValue );
       
   124 
       
   125         if ( attributeName == IAUpdateEngineConfigConsts::KIAMaxSize )
       
   126             {
       
   127             iConfigData.SetStorageMaxSizeL( *value );
       
   128             }
       
   129 
       
   130         CleanupStack::PopAndDestroy( value );                    
       
   131         }    
       
   132     }
       
   133     
       
   134     
       
   135 void CIAUpdateEngineXmlSubParser::HandleMasterServerAttributesL( 
       
   136                                 const Xml::RAttributeArray& aAttributes )
       
   137     {
       
   138     for ( TInt i = 0; i < aAttributes.Count(); ++ i )
       
   139         {
       
   140         const TDesC8& attributeName =
       
   141             aAttributes[ i ].Attribute().LocalName().DesC();
       
   142         
       
   143         const TDesC8& attributeValue =
       
   144             aAttributes[ i ].Value().DesC();
       
   145 
       
   146         HBufC* value( HBufC::NewLC( attributeValue.Length() ) );
       
   147         value->Des().Copy( attributeValue );
       
   148 
       
   149         if ( attributeName == IAUpdateEngineConfigConsts::KIAUri )
       
   150             {
       
   151             iConfigData.SetMasterServerUriL( *value );
       
   152             }
       
   153 
       
   154         CleanupStack::PopAndDestroy( value );                    
       
   155         }    
       
   156     }
       
   157 
       
   158     
       
   159 void CIAUpdateEngineXmlSubParser::HandleProvisioningAttributesL( 
       
   160                                 const Xml::RAttributeArray& aAttributes )
       
   161     {
       
   162     for ( TInt i = 0; i < aAttributes.Count(); ++ i )
       
   163         {
       
   164         const TDesC8& attributeName =
       
   165             aAttributes[ i ].Attribute().LocalName().DesC();
       
   166         
       
   167         const TDesC8& attributeValue =
       
   168             aAttributes[ i ].Value().DesC();
       
   169 
       
   170         HBufC* value( HBufC::NewLC( attributeValue.Length() ) );
       
   171         value->Des().Copy( attributeValue );
       
   172 
       
   173         if ( attributeName == IAUpdateEngineConfigConsts::KIAValue )
       
   174             {
       
   175             iConfigData.SetProvisioningL( *value );
       
   176             }
       
   177 
       
   178         CleanupStack::PopAndDestroy( value );                    
       
   179         }    
       
   180     }
       
   181     
       
   182 
       
   183 void CIAUpdateEngineXmlSubParser::HandleClientRoleAttributesL( 
       
   184                                 const Xml::RAttributeArray& aAttributes )
       
   185     {
       
   186     for ( TInt i = 0; i < aAttributes.Count(); ++ i )
       
   187         {
       
   188         const TDesC8& attributeName =
       
   189             aAttributes[ i ].Attribute().LocalName().DesC();
       
   190         
       
   191         const TDesC8& attributeValue =
       
   192             aAttributes[ i ].Value().DesC();
       
   193 
       
   194         HBufC* value( HBufC::NewLC( attributeValue.Length() ) );
       
   195         value->Des().Copy( attributeValue );
       
   196 
       
   197         if ( attributeName == IAUpdateEngineConfigConsts::KIAValue )
       
   198             {
       
   199             iConfigData.SetClientRoleL( *value );
       
   200             }
       
   201 
       
   202         CleanupStack::PopAndDestroy( value );                    
       
   203         }    
       
   204     }