xdmprotocols/LocalProtocol/src/LocalDocumentNode.cpp
changeset 0 c8caa15ef882
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     1 /*
       
     2 * Copyright (c) 2005 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: CLocalDocumentNode
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "XdmDocument.h"
       
    23 #include "LocalProtocol.h"
       
    24 #include "LocalDocumentNode.h"
       
    25 #include "LocalNodeAttribute.h"
       
    26 
       
    27 
       
    28 // ----------------------------------------------------------
       
    29 // CLocalDocumentNode::CLocalDocumentNode
       
    30 // 
       
    31 // ----------------------------------------------------------
       
    32 //
       
    33 CLocalDocumentNode::CLocalDocumentNode( CXdmEngine& aXdmEngine,
       
    34                                         CLocalProtocol& aLocalProtocol ) :
       
    35                                         CXdmDocumentNode( aXdmEngine, ( MXdmNodeFactory& )*this ),
       
    36                                         iLocalProtocol( aLocalProtocol )            
       
    37     {
       
    38     }
       
    39 
       
    40 
       
    41 // ----------------------------------------------------------
       
    42 // CLocalDocumentNode::CLocalDocumentNode
       
    43 // 
       
    44 // ----------------------------------------------------------
       
    45 //
       
    46 CLocalDocumentNode::CLocalDocumentNode( CXdmEngine& aXdmEngine,
       
    47                                         CXdmDocumentNode* aParentNode,
       
    48                                         CLocalProtocol& aLocalProtocol ) :
       
    49                                         CXdmDocumentNode( aXdmEngine,
       
    50                                       ( MXdmNodeFactory& )*this, aParentNode ),
       
    51                                         iLocalProtocol( aLocalProtocol )
       
    52                                                 
       
    53     {   
       
    54     }
       
    55 
       
    56 // ----------------------------------------------------------
       
    57 // CLocalDocumentNode::CLocalDocumentNode
       
    58 // 
       
    59 // ----------------------------------------------------------
       
    60 //
       
    61 CLocalDocumentNode::CLocalDocumentNode( const TBool aLeafNode,
       
    62                                         CXdmEngine& aXdmEngine,
       
    63                                         CXdmDocumentNode* aParentNode,
       
    64                                         CLocalProtocol& aLocalProtocol ) :
       
    65                                         CXdmDocumentNode( aLeafNode, aXdmEngine,
       
    66                                       ( MXdmNodeFactory& )*this, aParentNode ),
       
    67                                         iLocalProtocol( aLocalProtocol )
       
    68     {
       
    69     
       
    70     }
       
    71 
       
    72 // ----------------------------------------------------------
       
    73 // CLocalDocumentNode::NewL
       
    74 // 
       
    75 // ----------------------------------------------------------
       
    76 //
       
    77 CLocalDocumentNode* CLocalDocumentNode::NewL( CXdmEngine& aXdmEngine,
       
    78                                               CLocalProtocol& aLocalProtocol )
       
    79     {
       
    80     return new ( ELeave ) CLocalDocumentNode( aXdmEngine, aLocalProtocol );
       
    81     }
       
    82 
       
    83 // ----------------------------------------------------------
       
    84 // CLocalDocumentNode::NewL
       
    85 // 
       
    86 // ----------------------------------------------------------
       
    87 //
       
    88 CLocalDocumentNode* CLocalDocumentNode::NewL( CXdmEngine& aXdmEngine,
       
    89                                               const TDesC& aNodeName,
       
    90                                               CLocalProtocol& aLocalProtocol )
       
    91     {
       
    92     CLocalDocumentNode* self = new ( ELeave ) CLocalDocumentNode( aXdmEngine, aLocalProtocol );
       
    93     CleanupStack::PushL( self );
       
    94     self->BaseConstructL( aNodeName );
       
    95     CleanupStack::Pop();
       
    96     return self;
       
    97     }
       
    98 
       
    99 // ----------------------------------------------------------
       
   100 // CLocalDocumentNode::NewL
       
   101 // 
       
   102 // ----------------------------------------------------------
       
   103 //
       
   104 CLocalDocumentNode* CLocalDocumentNode::NewL( CXdmEngine& aXdmEngine,
       
   105                                               CLocalProtocol& aLocalProtocol,
       
   106                                               const CXdmDocumentNode& aAnotherNode,
       
   107                                               const CXdmDocumentNode& aParentNode )
       
   108     {
       
   109     CLocalDocumentNode* self = new ( ELeave ) CLocalDocumentNode( aXdmEngine, aLocalProtocol );
       
   110     CleanupStack::PushL( self );
       
   111     self->BaseConstructL( aAnotherNode.NodeName() );
       
   112     self->CopyConstructL( aAnotherNode, aParentNode );
       
   113     CleanupStack::Pop();
       
   114     return self;
       
   115     }
       
   116     
       
   117 // ----------------------------------------------------------
       
   118 // CLocalDocumentNode::NewL
       
   119 // 
       
   120 // ----------------------------------------------------------
       
   121 //
       
   122 CLocalDocumentNode* CLocalDocumentNode::NewL( CXdmEngine& aXdmEngine,
       
   123                                               const TDesC& aNodeName,
       
   124                                               CXdmDocumentNode* aParentNode,
       
   125                                               CLocalProtocol& aLocalProtocol )
       
   126     {
       
   127     CLocalDocumentNode* self = new ( ELeave ) CLocalDocumentNode( aXdmEngine, aParentNode,
       
   128                                                                   aLocalProtocol );
       
   129     CleanupStack::PushL( self );
       
   130     self->BaseConstructL( aNodeName );
       
   131     CleanupStack::Pop();
       
   132     return self;
       
   133     }
       
   134 
       
   135 // ----------------------------------------------------------
       
   136 // CLocalDocumentNode::NewL
       
   137 // 
       
   138 // ----------------------------------------------------------
       
   139 //
       
   140 CLocalDocumentNode* CLocalDocumentNode::NewL( const TBool aLeafNode,
       
   141                                               CXdmEngine& aXdmEngine,
       
   142                                               const TDesC& aNodeName,
       
   143                                               CXdmDocumentNode* aParentNode,
       
   144                                               CLocalProtocol& aLocalProtocol )
       
   145     {
       
   146     CLocalDocumentNode* self = new ( ELeave ) CLocalDocumentNode( aLeafNode, aXdmEngine,
       
   147                                                                   aParentNode, aLocalProtocol );
       
   148     CleanupStack::PushL( self );
       
   149     self->BaseConstructL( aNodeName );
       
   150     CleanupStack::Pop();
       
   151     return self;
       
   152     }
       
   153 
       
   154 // ----------------------------------------------------------
       
   155 // CXdmDocumentNode::NewL
       
   156 // 
       
   157 // ----------------------------------------------------------
       
   158 //
       
   159 CLocalDocumentNode* CLocalDocumentNode::NewL( const TBool aLeafNode,
       
   160                                               CXdmEngine& aXdmEngine,
       
   161                                               CXdmDocumentNode* aParentNode,
       
   162                                               CLocalProtocol& aLocalProtocol )
       
   163     {
       
   164     return new ( ELeave ) CLocalDocumentNode( aLeafNode, aXdmEngine,
       
   165                                               aParentNode, aLocalProtocol );
       
   166     }
       
   167 
       
   168 // ----------------------------------------------------------
       
   169 // CLocalDocumentNode::CopyConstructL
       
   170 // 
       
   171 // ----------------------------------------------------------
       
   172 //
       
   173 void CLocalDocumentNode::CopyConstructL(  const CXdmDocumentNode& aAnotherNode,
       
   174                                           const CXdmDocumentNode& aParentNode  )
       
   175     {
       
   176     CXdmDocumentNode::CopyConstructL( aAnotherNode, aParentNode );
       
   177     //TODO: Write the protocol specific copy operations
       
   178     }
       
   179     
       
   180 // ----------------------------------------------------
       
   181 // CLocalDocumentNode::~CLocalDocumentNode
       
   182 // 
       
   183 // ----------------------------------------------------
       
   184 //
       
   185 EXPORT_C CLocalDocumentNode::~CLocalDocumentNode()
       
   186     {
       
   187     #ifdef _DEBUG
       
   188         iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::~CLocalDocumentNode(): %x" ), this );
       
   189     #endif
       
   190     delete iPrefix;
       
   191     delete iNextNode;
       
   192     }
       
   193 
       
   194 // ----------------------------------------------------
       
   195 // CLocalDocumentNode::RemoveLocalL
       
   196 // 
       
   197 // ----------------------------------------------------
       
   198 //
       
   199 EXPORT_C void CLocalDocumentNode::RemoveLocalL( CXdmDocumentNode* aChileNode )
       
   200     {
       
   201     RemoveChileNodeL( aChileNode );
       
   202     }
       
   203   
       
   204 // ----------------------------------------------------
       
   205 // CLocalDocumentNode::AppendLocalL
       
   206 // 
       
   207 // ----------------------------------------------------
       
   208 //      
       
   209 EXPORT_C void CLocalDocumentNode::AppendLocalL( CXdmDocumentNode* aChileNode )
       
   210     {
       
   211     if( aChileNode->Match( *this ) )
       
   212         {
       
   213         const TInt count = aChileNode->NodeCount();
       
   214         for( TInt i = 0;i < count;i++ )
       
   215             AppendChileNodeL( aChileNode->ChileNode( i ) );
       
   216         }
       
   217     else AppendChileNodeL( aChileNode );
       
   218     }
       
   219 
       
   220 // ----------------------------------------------------
       
   221 // CLocalDocumentNode::ReplaceLocalL
       
   222 // 
       
   223 // ----------------------------------------------------
       
   224 //      
       
   225 EXPORT_C void CLocalDocumentNode::ReplaceLocalL( CXdmDocumentNode* aNewNode,
       
   226                                                  CXdmDocumentNode* aTargetNode )
       
   227     {
       
   228     ReplaceChileNodeL( aNewNode, aTargetNode );                                            
       
   229     }
       
   230                                             
       
   231 // ----------------------------------------------------
       
   232 // CLocalDocumentNode::CreateChileNodeL
       
   233 // 
       
   234 // ----------------------------------------------------
       
   235 //
       
   236 CXdmDocumentNode* CLocalDocumentNode::ChileNodeL()
       
   237     {
       
   238     #ifdef _DEBUG
       
   239         iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::CreateChileNodeL()" ) );
       
   240     #endif
       
   241     return CLocalDocumentNode::NewL( EFalse, iXdmEngine, this, iLocalProtocol );
       
   242     }
       
   243     
       
   244 // ----------------------------------------------------
       
   245 // CLocalDocumentNode::CreateChileNodeL
       
   246 // 
       
   247 // ----------------------------------------------------
       
   248 //
       
   249 CXdmDocumentNode* CLocalDocumentNode::ChileNodeL( const TDesC& aChildName )
       
   250     {
       
   251     #ifdef _DEBUG
       
   252         iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::CreateChileNodeL() - Name: %S" ), &aChildName );
       
   253     #endif
       
   254     return CLocalDocumentNode::NewL( EFalse, iXdmEngine, aChildName, this, iLocalProtocol );
       
   255     }
       
   256 
       
   257 // ----------------------------------------------------
       
   258 // CLocalDocumentNode::CreateChileNodeL
       
   259 // 
       
   260 // ----------------------------------------------------
       
   261 //
       
   262 CXdmDocumentNode* CLocalDocumentNode::ChileNodeL( const CXdmDocumentNode* aAnotherNode )
       
   263     {
       
   264     #ifdef _DEBUG
       
   265         iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::ChileNodeL() - Object: %x" ), aAnotherNode );
       
   266     #endif
       
   267     return CLocalDocumentNode::NewL( iXdmEngine, iLocalProtocol, *aAnotherNode, *this );
       
   268     }
       
   269 
       
   270 // ----------------------------------------------------
       
   271 // CLocalDocumentNode::CreateAttributeL
       
   272 // 
       
   273 // ----------------------------------------------------
       
   274 //
       
   275 CXdmNodeAttribute* CLocalDocumentNode::AttributeL()
       
   276     {
       
   277     #ifdef _DEBUG
       
   278         iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::CreateAttributeL()" ) );
       
   279     #endif
       
   280     return CLocalNodeAttribute::NewL( iXdmEngine, this, iLocalProtocol );
       
   281     }
       
   282     
       
   283 // ----------------------------------------------------
       
   284 // CLocalDocumentNode::CreateAttributeL
       
   285 // 
       
   286 // ----------------------------------------------------
       
   287 //
       
   288 CXdmNodeAttribute* CLocalDocumentNode::AttributeL( const TDesC& aAttributeName )
       
   289     {
       
   290     #ifdef _DEBUG
       
   291         iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::CreateAttributeL() - Name: %S" ), &aAttributeName );
       
   292     #endif
       
   293     return CLocalNodeAttribute::NewL( iXdmEngine, aAttributeName, this, iLocalProtocol );
       
   294     }
       
   295 
       
   296 // ----------------------------------------------------------
       
   297 // CLocalDocumentNode::SetParentNode
       
   298 // 
       
   299 // ----------------------------------------------------------
       
   300 //
       
   301 void CLocalDocumentNode::SetParentNode( CLocalDocumentNode*& aParentNode )
       
   302     {
       
   303     iParentNode = aParentNode;
       
   304     }
       
   305 
       
   306 // ----------------------------------------------------------
       
   307 // CLocalDocumentNode::NamespacePrefix
       
   308 // 
       
   309 // ----------------------------------------------------------
       
   310 //
       
   311 TPtrC8 CLocalDocumentNode::Prefix() const
       
   312     {
       
   313     return iPrefix != NULL ? iPrefix->Des() : TPtrC8();
       
   314     }
       
   315         
       
   316 // ----------------------------------------------------------
       
   317 // CLocalDocumentNode::SetNamespacePrefixL
       
   318 // 
       
   319 // ----------------------------------------------------------
       
   320 //
       
   321 void CLocalDocumentNode::SetPrefixL( const TDesC8& aPrefix )
       
   322     {
       
   323     delete iPrefix;
       
   324     iPrefix = NULL;
       
   325     iPrefix = HBufC8::NewL( aPrefix.Length() );
       
   326     iPrefix->Des().Copy( aPrefix );
       
   327     }
       
   328                        
       
   329 
       
   330 
       
   331