iaupdate/IAD/engine/controller/src/iaupdatenodeuidxmlparser.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 "iaupdatenodeuidxmlparser.h"
       
    25 #include "iaupdatenodedependencyimpl.h"
       
    26 #include "iaupdateutils.h"
       
    27 #include "iaupdateprotocolconsts.h"
       
    28 
       
    29 
       
    30 CIAUpdateNodeUidXmlParser* CIAUpdateNodeUidXmlParser::NewL( 
       
    31                                      CIAUpdateNodeDependency*& aDependency )
       
    32     {
       
    33     CIAUpdateNodeUidXmlParser* self =
       
    34         CIAUpdateNodeUidXmlParser::NewLC( aDependency );
       
    35     CleanupStack::Pop( self );
       
    36     return self;
       
    37     }
       
    38 
       
    39 
       
    40 CIAUpdateNodeUidXmlParser* CIAUpdateNodeUidXmlParser::NewLC( 
       
    41                                     CIAUpdateNodeDependency*& aDependency )
       
    42     {
       
    43     CIAUpdateNodeUidXmlParser* self =
       
    44         new( ELeave ) CIAUpdateNodeUidXmlParser( aDependency );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     return self;    
       
    48     }
       
    49 
       
    50 
       
    51 CIAUpdateNodeUidXmlParser::CIAUpdateNodeUidXmlParser( 
       
    52                                     CIAUpdateNodeDependency*& aDependency )
       
    53 : CIAUpdateXmlSubParser(),
       
    54   iDependency( aDependency )
       
    55     {
       
    56     
       
    57     }
       
    58     
       
    59     
       
    60 void CIAUpdateNodeUidXmlParser::ConstructL()
       
    61     {
       
    62     CIAUpdateXmlSubParser::ConstructL( IAUpdateProtocolConsts::KNodeUid() );    
       
    63     }
       
    64 
       
    65 
       
    66 CIAUpdateNodeUidXmlParser::~CIAUpdateNodeUidXmlParser()
       
    67     {
       
    68     }
       
    69 
       
    70 
       
    71 void CIAUpdateNodeUidXmlParser::OnContentL( const TDesC8& aBytes, 
       
    72                                             TInt aErrorCode )
       
    73     {
       
    74     // If the parent class wants to do something with the information.
       
    75     CIAUpdateXmlSubParser::OnContentL( aBytes, aErrorCode );
       
    76 
       
    77     if ( AcceptData() )
       
    78         {
       
    79         // Because there is no current subparser set, this means
       
    80         // that this parser is the leaf parser at the moment.
       
    81 
       
    82         // We have gotten content for this element.
       
    83         // Now, set the node information to the dependency object.
       
    84         HBufC* tmp( HBufC::NewLC( aBytes.Length() * 2 ) );
       
    85         TPtr ptr( tmp->Des() );
       
    86         ptr.Copy( aBytes );
       
    87         // Get the UID value for the dependency
       
    88         TUid uid( TUid::Uid( IAUpdateUtils::DesHexToIntL( ptr ) ) );
       
    89         DependencyL().SetUid( uid );
       
    90         CleanupStack::PopAndDestroy( tmp );
       
    91         }
       
    92     }
       
    93 
       
    94 
       
    95 CIAUpdateNodeDependency& CIAUpdateNodeUidXmlParser::DependencyL()
       
    96     {
       
    97     if ( !iDependency )
       
    98         {
       
    99         User::Leave( KErrNotFound );
       
   100         }
       
   101         
       
   102     return *iDependency;
       
   103     }
       
   104