xdmprotocols/XcapProtocol/XcapAppUsage/XcapSharedXDMUsage/src/XcapSharedXDMUsage.cpp
branchRCL_3
changeset 18 fbd2e7cec7ef
parent 0 c8caa15ef882
equal deleted inserted replaced
17:2669f8761a99 18:fbd2e7cec7ef
       
     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:   CXcapSharedXDMUsage
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <XdmDocumentNode.h>
       
    22 #include <XdmNodeAttribute.h>
       
    23 #include "XcapSharedXDMUsage.h"
       
    24 
       
    25 // Used spesifications
       
    26 // OMA-TS-XDM_Core-V1_0-20051103-C, 03 November 2005
       
    27 // OMA-TS-XDM_Shared-V1_0-20051006-C, 12 June 2006
       
    28 
       
    29 // ----------------------------------------------------
       
    30 // CXcapSharedXDMUsage::CXcapSharedXDMUsage
       
    31 // 
       
    32 // ----------------------------------------------------
       
    33 //
       
    34 CXcapSharedXDMUsage::CXcapSharedXDMUsage( 
       
    35 const CXdmEngine& aXdmEngine ) : CXcapAppUsage( aXdmEngine ),
       
    36 iResListUsage( NULL )
       
    37     {
       
    38     }
       
    39 
       
    40 // ----------------------------------------------------
       
    41 // CXcapSharedXDMUsage::NewL
       
    42 // 
       
    43 // ----------------------------------------------------
       
    44 //
       
    45 CXcapSharedXDMUsage* CXcapSharedXDMUsage::NewL( const TXcapAppUsageParams& aParameters )
       
    46     {
       
    47     CXcapSharedXDMUsage* self = new ( ELeave ) CXcapSharedXDMUsage( aParameters.iXdmEngine );
       
    48     CleanupStack::PushL( self );	// << self
       
    49     self->ConstructL();
       
    50     CleanupStack::Pop( self );      // >> self
       
    51     return self;
       
    52     }
       
    53 
       
    54 // ----------------------------------------------------
       
    55 // CXcapSharedXDMUsage::~CXcapSharedXDMUsage
       
    56 // 
       
    57 // ----------------------------------------------------
       
    58 //
       
    59 CXcapSharedXDMUsage::~CXcapSharedXDMUsage()
       
    60     {
       
    61 	delete iResListUsage;
       
    62     }
       
    63         
       
    64 // ----------------------------------------------------
       
    65 // CXcapSharedXDMUsage::ConstructL
       
    66 // 
       
    67 // ----------------------------------------------------
       
    68 //
       
    69 void CXcapSharedXDMUsage::ConstructL()
       
    70     {
       
    71     iResListUsage = CXcapAppUsage::NewL( iXdmEngine, KXdmResourceListsUsageUid );
       
    72     }
       
    73 
       
    74 // ----------------------------------------------------
       
    75 // CXcapSharedXDMUsage::AUID
       
    76 // 
       
    77 // ----------------------------------------------------
       
    78 //
       
    79 TPtrC8 CXcapSharedXDMUsage::AUID() const
       
    80     {
       
    81     return TPtrC8( KXdmSharedXDMUsageAUID );
       
    82     }
       
    83                 
       
    84 // ----------------------------------------------------
       
    85 // CXcapSharedXDMUsage::ContentType
       
    86 // 
       
    87 // ----------------------------------------------------
       
    88 //
       
    89 TPtrC8 CXcapSharedXDMUsage::ContentType() const
       
    90     {
       
    91     return TPtrC8( KXdmSharedXDMUsageContType );
       
    92     }
       
    93 
       
    94 // ----------------------------------------------------
       
    95 // CXcapSharedXDMUsage::DefaultNamespace
       
    96 // 
       
    97 // ----------------------------------------------------
       
    98 //
       
    99 TPtrC8 CXcapSharedXDMUsage::DefaultNamespace() const
       
   100     {
       
   101     // we use urn:ietf:params:xml:ns:resource-lists 
       
   102     // as a default namespace
       
   103     return TPtrC8( KXdmResourceListsNamespace );
       
   104     }   
       
   105     
       
   106 // ----------------------------------------------------
       
   107 // CXcapSharedXDMUsage::ValidateNodeL
       
   108 // 
       
   109 // ----------------------------------------------------
       
   110 //
       
   111 TBool CXcapSharedXDMUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
       
   112     {
       
   113     // This method is called by base class for each element
       
   114     // in document, here we have to declare every element, check element 
       
   115     // datatype, restrictions for values and also do all checking that concerns  
       
   116     // the structure of the element. If the datatype is some of
       
   117     // the common datatypes defined in xcapappusage.h, the node
       
   118     // can pe passed to the base class for value validation.
       
   119     // If the node belongs to this namespace, the return value
       
   120     // should be true, false otherwise.
       
   121 
       
   122     TBool found ( EFalse );    
       
   123     TPtrC element = aXdmNode.NodeName();
       
   124   
       
   125     // <uriusages>
       
   126     if ( Match( element, KXdmUriUsages ) )    
       
   127         {
       
   128         SetPrefixL( aXdmNode, KXdmSharedXDMUriUsageNsPrefix );
       
   129         found = ETrue;
       
   130         }
       
   131     // <uriusage>
       
   132     else if ( Match( element, KXdmUriUsage ) )    
       
   133         {
       
   134         SetPrefixL( aXdmNode, KXdmSharedXDMUriUsageNsPrefix );
       
   135         found = ETrue;
       
   136         }
       
   137     // the rest are from urn:ietf:params:xml:ns:resource-lists
       
   138     else
       
   139         {
       
   140         // do not append the namespace prefix here,
       
   141         // since the used default namespace is
       
   142         // urn:ietf:params:xml:ns:resource-lists
       
   143         found = iResListUsage->ValidateNodeL( aXdmNode );
       
   144         }
       
   145     return found;
       
   146     }
       
   147 
       
   148 // ----------------------------------------------------
       
   149 // CXcapSharedXDMUsage::ValidateAttributeL
       
   150 // 
       
   151 // ----------------------------------------------------
       
   152 //
       
   153 void CXcapSharedXDMUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
       
   154     {
       
   155     // This method is called by base class for each attribute
       
   156     // in document, here we have to define data types
       
   157     // for attributes, and pass them to the base class
       
   158     // for the actual data checking.
       
   159 
       
   160     // this usage doesn't have any attributes,
       
   161     // all attributes are from urn:ietf:params:xml:ns:resource-lists
       
   162     iResListUsage->ValidateAttributeL( aXdmNodeAttr );
       
   163    
       
   164     }   
       
   165                          
       
   166 // ----------------------------------------------------
       
   167 // CXcapSharedXDMUsage::AddNamespaceInformationL
       
   168 // 
       
   169 // ----------------------------------------------------
       
   170 //
       
   171 void CXcapSharedXDMUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
       
   172     {
       
   173     // we use urn:ietf:params:xml:ns:resource-lists 
       
   174     // as a default namespace
       
   175     aXdmDocument.AppendNamespaceL( KXdmResourceListsNamespace, KNullDesC8 );
       
   176     aXdmDocument.AppendNamespaceL( KXdmSharedXDMUriUsageNamespace, KXdmSharedXDMUriUsageNsPrefix );
       
   177     }
       
   178 
       
   179 // End of File
       
   180