xdmprotocols/XcapProtocol/XcapAppUsage/XCapPocUserAccessUsage/src/XcapPocUserAccessUsage.cpp
branchGCC_SURGE
changeset 28 d9861ae9169c
parent 23 77cb48a03620
parent 26 04ca1926b01c
equal deleted inserted replaced
23:77cb48a03620 28:d9861ae9169c
     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:  CXcapPocUserAccessUsage
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <XdmErrors.h>
       
    22 #include <XdmDocumentNode.h>
       
    23 #include <XdmNodeAttribute.h>
       
    24 #include "XcapPocUserAccessUsage.h"
       
    25 
       
    26 // Used specification
       
    27 // OMA-TS-PoC_XDM-V1_0-20050317-C, 17 March 2005
       
    28 // OMA-TS-PoC_XDM-V1_0-20060127-C, 27 January 2006
       
    29 
       
    30 // ----------------------------------------------------
       
    31 // CXcapPocUserAccessUsage::CXcapPocUserAccessUsage
       
    32 // 
       
    33 // ----------------------------------------------------
       
    34 //
       
    35 CXcapPocUserAccessUsage::CXcapPocUserAccessUsage( const CXdmEngine& aXdmEngine ) :
       
    36 CXcapAppUsage( aXdmEngine ),
       
    37 iIetfCommonPolicies( NULL ),
       
    38 iOmaCommonPolicies( NULL )
       
    39     {
       
    40     }
       
    41 
       
    42 // ----------------------------------------------------
       
    43 // CXcapPocUserAccessUsage::NewL
       
    44 // 
       
    45 // ----------------------------------------------------
       
    46 //
       
    47 CXcapPocUserAccessUsage* CXcapPocUserAccessUsage::NewL( const TXcapAppUsageParams& aParameters )
       
    48     {
       
    49     CXcapPocUserAccessUsage* self = new ( ELeave ) CXcapPocUserAccessUsage( aParameters.iXdmEngine );
       
    50     CleanupStack::PushL( self );	// << self
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop( self );      // >> self
       
    53     return self;
       
    54     }
       
    55 
       
    56 // ----------------------------------------------------
       
    57 // CXcapPocUserAccessUsage::~CXcapPocUserAccessUsage
       
    58 // 
       
    59 // ----------------------------------------------------
       
    60 //
       
    61 CXcapPocUserAccessUsage::~CXcapPocUserAccessUsage()
       
    62     {
       
    63     delete iIetfCommonPolicies;
       
    64     delete iOmaCommonPolicies;
       
    65     }
       
    66         
       
    67 // ----------------------------------------------------
       
    68 // CXcapPocUserAccessUsage::ConstructL
       
    69 // 
       
    70 // ----------------------------------------------------
       
    71 //
       
    72 void CXcapPocUserAccessUsage::ConstructL()
       
    73     {
       
    74     iIetfCommonPolicies = CXcapAppUsage::NewL( iXdmEngine, EXdmIetfCommonPolicy );
       
    75     iOmaCommonPolicies = CXcapAppUsage::NewL( iXdmEngine, EXdmOmaCommonPolicy );
       
    76     }
       
    77 
       
    78 // ----------------------------------------------------
       
    79 // CXcapPocUserAccessUsage::AUID
       
    80 // 
       
    81 // ----------------------------------------------------
       
    82 //
       
    83 TPtrC8 CXcapPocUserAccessUsage::AUID() const
       
    84     {
       
    85     return TPtrC8( KXdmPocUserAccessUsageAUID );
       
    86     }
       
    87 
       
    88 // ----------------------------------------------------
       
    89 // CXcapPocUserAccessUsage::ContentType
       
    90 // 
       
    91 // ----------------------------------------------------
       
    92 //
       
    93 TPtrC8 CXcapPocUserAccessUsage::ContentType() const
       
    94     {
       
    95     return TPtrC8( KXdmPocUserAccessUsageContType );
       
    96     }
       
    97 
       
    98 // ----------------------------------------------------
       
    99 // CXcapPocUserAccessUsage::DefaultNamespace
       
   100 // 
       
   101 // ----------------------------------------------------
       
   102 //
       
   103 TPtrC8 CXcapPocUserAccessUsage::DefaultNamespace() const
       
   104     {
       
   105 //    return TPtrC8( KXdmPocUserAccessNamespace );
       
   106     // NOTE the default namespace is IetfCommonPolicy
       
   107     return TPtrC8( KXdmIetfCommonPolicyNamespace );
       
   108     }   
       
   109     
       
   110 // ----------------------------------------------------
       
   111 // CXcapPocUserAccessUsage::ValidateNodeL
       
   112 // 
       
   113 // ----------------------------------------------------
       
   114 //
       
   115 TBool CXcapPocUserAccessUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
       
   116     {    
       
   117     // This method is called by base class for each element
       
   118     // in document, here we have to declare every element, check element 
       
   119     // datatype, restrictions for values and also do all checking that concerns  
       
   120     // the structure of the element. If the datatype is some of
       
   121     // the common datatypes defined in xcapappusage.h, the node
       
   122     // can pe passed to the base class for value validation.
       
   123     // If the node belongs to this namespace, the return value
       
   124     // should be true, false otherwise.
       
   125 
       
   126     TBool found ( EFalse );
       
   127     TPtrC element = aXdmNode.NodeName();
       
   128     
       
   129     // there is restriction for the value 
       
   130     // of <allow-invite>
       
   131     // check that value is either "reject", "accept" or "pass"
       
   132     // 0 (reject), 1 (pass), 2 (accept)
       
   133     if ( Match( element, KXdmAllowInvite ) )
       
   134         {
       
   135         TPtrC8 data = aXdmNode.LeafNodeContent();
       
   136         if ( data.CompareF( KXdmReject )
       
   137              && data.CompareF( KXdmAccept )
       
   138              && data.CompareF( KXdmPass ) )
       
   139             {
       
   140             LeaveWithErrorL( KXcapErrorEnumerationRule );
       
   141             }
       
   142         found = ETrue;
       
   143         // NOTE the default namespace is IetfCommonPolicy
       
   144         SetPrefixL( aXdmNode, KXdmPocUserAccessNsPrefix ); 
       
   145         }
       
   146     // urn:ietf:params:xml:ns:common-policy
       
   147     if ( !found )
       
   148         {
       
   149         found = iIetfCommonPolicies->ValidateNodeL( aXdmNode );
       
   150         // NOTE the default namespace is IetfCommonPolicy
       
   151         /*if ( found )
       
   152             {
       
   153             SetPrefixL( aXdmNode, KXdmIetfCommonPolicyNsPrefix );  
       
   154             }*/
       
   155         }
       
   156     // urn:oma:params:xml:ns:common-policy
       
   157     if ( !found )
       
   158         {
       
   159         found = iOmaCommonPolicies->ValidateNodeL( aXdmNode );
       
   160                 if ( found )
       
   161             {
       
   162             SetPrefixL( aXdmNode, KXdmOmaCommonPolicyNsPrefix );   
       
   163             }
       
   164         }
       
   165     return found;
       
   166     }
       
   167         
       
   168 // ----------------------------------------------------
       
   169 // CXcapPocUserAccessUsage::ValidateAttributeL
       
   170 // 
       
   171 // ----------------------------------------------------
       
   172 //
       
   173 void CXcapPocUserAccessUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr)
       
   174     {
       
   175     // This method is called by base class for each attribute
       
   176     // in document, here we have to define data types
       
   177     // for attributes, and pass them to the base class
       
   178     // for the actual data checking.
       
   179     
       
   180     // there aren't any attributes, all attributes are
       
   181     // either from urn:ietf:params:xml:ns:common-policy
       
   182     // or from urn:oma:params:xml:ns:common-policy
       
   183     
       
   184     // add parent element namespace checking when available,
       
   185     // now we don't know the attribute's namespace
       
   186     iIetfCommonPolicies->ValidateAttributeL( aXdmNodeAttr );
       
   187     iOmaCommonPolicies->ValidateAttributeL( aXdmNodeAttr ); 
       
   188     }
       
   189         
       
   190 
       
   191  // ----------------------------------------------------
       
   192 // CXcapPocUserAccessUsage::AddNamespaceInformationL
       
   193 // 
       
   194 // ----------------------------------------------------
       
   195 //
       
   196 void CXcapPocUserAccessUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
       
   197     {
       
   198     aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KNullDesC8 );
       
   199     aXdmDocument.AppendNamespaceL( KXdmPocUserAccessNamespace, KXdmPocUserAccessNsPrefix );
       
   200     aXdmDocument.AppendNamespaceL( KXdmOmaCommonPolicyNamespace, KXdmOmaCommonPolicyNsPrefix );
       
   201 /*    aXdmDocument.AppendNamespaceL( KXdmPocUserAccessNamespace, KNullDesC8 );
       
   202     aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KXdmIetfCommonPolicyNsPrefix );
       
   203     aXdmDocument.AppendNamespaceL( KXdmOmaCommonPolicyNamespace, KXdmOmaCommonPolicyNsPrefix );*/
       
   204     }                           
       
   205                            
       
   206                            
       
   207 // End of File
       
   208