xdmprotocols/XcapProtocol/XcapAppUsage/XcapPresenceRulesUsage/src/XcapOmaPresRulesUsage.cpp
branchRCL_3
changeset 35 fbd2e7cec7ef
parent 0 c8caa15ef882
equal deleted inserted replaced
34:2669f8761a99 35: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:  CXcapOmaPresRulesUsage
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <XdmErrors.h>
       
    22 #include <XdmDocumentNode.h>
       
    23 #include "XcapOmaPresRulesUsage.h"
       
    24 
       
    25 // Used specification
       
    26 // OMA-TS-Presence_SIMPLE_XDM-V1_0-20060110-C, 10 January 2006
       
    27 // OMA-TS-Presence_SIMPLE_XDM-V1_0-20060418-C, 18 April 2006
       
    28 
       
    29 // ----------------------------------------------------
       
    30 // CXcapOmaPresRulesUsage::CXcapOmaPresRulesUsage
       
    31 // 
       
    32 // ----------------------------------------------------
       
    33 //
       
    34 CXcapOmaPresRulesUsage::CXcapOmaPresRulesUsage( const CXdmEngine& aXdmEngine ) :
       
    35 CXcapAppUsage( aXdmEngine ),
       
    36 iIetfPresRules( NULL ),
       
    37 iIetfCommonPolicy( NULL ),
       
    38 iOmaCommonPolicy( NULL )
       
    39     {
       
    40     }
       
    41 
       
    42 // ----------------------------------------------------
       
    43 // CXcapOmaPresRulesUsage::NewL
       
    44 // 
       
    45 // ----------------------------------------------------
       
    46 //
       
    47 CXcapOmaPresRulesUsage* CXcapOmaPresRulesUsage::NewL( const TXcapAppUsageParams& aParameters )
       
    48     {
       
    49     CXcapOmaPresRulesUsage* self = new ( ELeave ) CXcapOmaPresRulesUsage( aParameters.iXdmEngine );
       
    50     CleanupStack::PushL( self );	// << self
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop( self );      // >> self
       
    53     return self;
       
    54     }
       
    55 
       
    56 // ----------------------------------------------------
       
    57 // CXcapOmaPresRulesUsage::~CXcapOmaPresRulesUsage
       
    58 // 
       
    59 // ----------------------------------------------------
       
    60 //
       
    61 CXcapOmaPresRulesUsage::~CXcapOmaPresRulesUsage()
       
    62     {
       
    63     delete iIetfPresRules;
       
    64     delete iIetfCommonPolicy;
       
    65     delete iOmaCommonPolicy;
       
    66     }
       
    67         
       
    68 // ----------------------------------------------------
       
    69 // CXcapOmaPresRulesUsage::ConstructL
       
    70 // 
       
    71 // ----------------------------------------------------
       
    72 //
       
    73 void CXcapOmaPresRulesUsage::ConstructL()
       
    74     {
       
    75     iIetfPresRules = CXcapAppUsage::NewL( iXdmEngine, KXdmIetfPresRulesUsageUid );
       
    76     iIetfCommonPolicy = CXcapAppUsage::NewL( iXdmEngine, KXdmIetfCommonPolicyUsageUid );
       
    77     iOmaCommonPolicy = CXcapAppUsage::NewL( iXdmEngine, KXdmOmaCommonPolicyUsageUid );
       
    78     }
       
    79 
       
    80 // ----------------------------------------------------
       
    81 // CXcapOmaPresRulesUsage::AUID
       
    82 // 
       
    83 // ----------------------------------------------------
       
    84 //
       
    85 TPtrC8 CXcapOmaPresRulesUsage::AUID() const
       
    86     {
       
    87     return TPtrC8( KXdmOmaPresRulesUsageAUID );
       
    88     }
       
    89                 
       
    90 // ----------------------------------------------------
       
    91 // CXcapOmaPresRulesUsage::ContentType
       
    92 // 
       
    93 // ----------------------------------------------------
       
    94 //
       
    95 TPtrC8 CXcapOmaPresRulesUsage::ContentType() const
       
    96     {
       
    97     return TPtrC8( KXdmOmaPresRulesUsageContType );
       
    98     }
       
    99     
       
   100 // ----------------------------------------------------
       
   101 // CXcapOmaPresRulesUsage::DefaultNamespace
       
   102 // 
       
   103 // ----------------------------------------------------
       
   104 //
       
   105 TPtrC8 CXcapOmaPresRulesUsage::DefaultNamespace() const
       
   106     {
       
   107     //return TPtrC8( KXdmOmaPresRulesNamespace );
       
   108     // NOTE the default namespace is IetfCommonPolicy
       
   109     return TPtrC8( KXdmIetfCommonPolicyNamespace );
       
   110     }    
       
   111 
       
   112 // ----------------------------------------------------
       
   113 // CXcapOmaPresRulesUsage::ValidateL
       
   114 // 
       
   115 // ----------------------------------------------------
       
   116 //
       
   117 TBool CXcapOmaPresRulesUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
       
   118     {
       
   119     // This method is called by base class for each element
       
   120     // in document, here we have to declare every element, check element 
       
   121     // datatype, restrictions for values and also do all checking that concerns  
       
   122     // the structure of the element. If the datatype is some of
       
   123     // the common datatypes defined in xcapappusage.h, the node
       
   124     // can pe passed to the base class for value validation.
       
   125     // If the node belongs to this namespace, the return value
       
   126     // should be true, false otherwise.
       
   127 
       
   128     TBool found ( EFalse );   
       
   129     TDataType dataType ( EDataTypeUndefined );
       
   130     TPtrC element = aXdmNode.NodeName();
       
   131      
       
   132     // <provide-willigness>
       
   133     if ( Match( element, KXdmProvideWillingness ) )
       
   134         {
       
   135         dataType = EDataTypeBoolean;
       
   136         found = ETrue;
       
   137         }
       
   138     // <provide-network-availability>
       
   139     else if ( Match( element, KXdmProvideNetworkAvailability ) )
       
   140         {
       
   141         dataType = EDataTypeBoolean;
       
   142         found = ETrue;
       
   143         }
       
   144     // <provide-session-participation>
       
   145     else if ( Match( element, KXdmProvideSessionParticipation ) )
       
   146         {
       
   147         dataType = EDataTypeBoolean;
       
   148         found = ETrue;
       
   149         }
       
   150     // <provide-registration-state>
       
   151     else if ( Match( element, KXdmProvideRegistrationState ) )
       
   152         {
       
   153         dataType = EDataTypeBoolean;
       
   154         found = ETrue;
       
   155         }
       
   156     // <provide-barring-state>
       
   157     else if ( Match( element, KXdmProvideBarringState ) )
       
   158         {
       
   159         dataType = EDataTypeBoolean;
       
   160         found = ETrue;
       
   161         }
       
   162     // <provide-geopriv>
       
   163     else if ( Match( element, KXdmProvideGeopriv ) )
       
   164         {
       
   165         // value must be "false" or "full"
       
   166         // 0 (false), 1 (full)
       
   167         TPtrC8 data = aXdmNode.LeafNodeContent();
       
   168         if ( data.CompareF( KXdmFalse )
       
   169              && data.CompareF( KXdmFull ) )
       
   170             {
       
   171             LeaveWithErrorL( KXcapErrorEnumerationRule );
       
   172             }
       
   173         found = ETrue;
       
   174         }
       
   175     // <service-id>
       
   176     else if ( Match( element, KXdmServiceId ) )
       
   177         {
       
   178         dataType = EDataTypeString;
       
   179         found = ETrue;
       
   180         }
       
   181         
       
   182     // NOTE the default namespace is IetfCommonPolicy
       
   183     if ( found )
       
   184         {
       
   185         SetPrefixL( aXdmNode, KXdmOmaPresRulesNsPrefix );
       
   186         }
       
   187 
       
   188     // urn:ietf:params:xml:ns:pres-rules
       
   189     // urn:ietf:params:xml:ns:common-policy
       
   190     // urn:oma:xml:xdm:common-policy
       
   191     else
       
   192         {
       
   193         // urn:ietf:params:xml:ns:common-policy
       
   194         found = iIetfCommonPolicy->ValidateNodeL( aXdmNode );
       
   195         if ( found )
       
   196             {
       
   197             // this means that this belongs to urn:ietf:params:xml:ns:common-policy,
       
   198             // there may be the prefix already
       
   199             // NOTE the default namespace is IetfCommonPolicy
       
   200                 SetPrefixL( aXdmNode, KNullDesC8 );
       
   201                 }
       
   202         else
       
   203             {
       
   204             // urn:ietf:params:xml:ns:pres-rules
       
   205             found = iIetfPresRules->ValidateNodeL( aXdmNode );
       
   206             if ( found )
       
   207                 {
       
   208                 SetPrefixL( aXdmNode, KXdmIetfPresRulesNsPrefix );
       
   209                 }
       
   210             else
       
   211                 {
       
   212                 // urn:oma:xml:xdm:common-policy
       
   213                 found = iOmaCommonPolicy->ValidateNodeL( aXdmNode );
       
   214                 if ( found )
       
   215                     {
       
   216                     SetPrefixL( aXdmNode, KXdmOmaCommonPolicyNsPrefix );
       
   217                     }
       
   218                 }
       
   219             }
       
   220         }
       
   221         
       
   222     if ( dataType != EDataTypeUndefined )
       
   223         {
       
   224         // pass to the base class for data validation
       
   225         ValidateDataL( dataType, aXdmNode );
       
   226         }
       
   227     return found;
       
   228     }
       
   229 
       
   230 // ----------------------------------------------------
       
   231 // CXcapOmaPresRulesUsage::ValidateAttributeL
       
   232 // 
       
   233 // ----------------------------------------------------
       
   234 //
       
   235 void CXcapOmaPresRulesUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
       
   236     {
       
   237     // This method is called by base class for each attribute
       
   238     // in document, here we have to define data types
       
   239     // for attributes, and pass them to the base class
       
   240     // for the actual data checking.
       
   241     
       
   242     // there aren't any attributes in
       
   243     // oma presence rules usage schema
       
   244     // urn:ietf:params:xml:ns:pres-rules
       
   245     // urn:ietf:params:xml:ns:common-policy
       
   246     iIetfPresRules->ValidateAttributeL( aXdmNodeAttr );
       
   247     }   
       
   248                          
       
   249 // ----------------------------------------------------
       
   250 // CXcapOmaPresRulesUsage::AddNamespaceInformationL
       
   251 // 
       
   252 // ----------------------------------------------------
       
   253 //
       
   254 void CXcapOmaPresRulesUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
       
   255     {
       
   256     // NOTE the default namespace is IetfCommonPolicy
       
   257     aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KNullDesC8 );
       
   258     aXdmDocument.AppendNamespaceL( KXdmOmaCommonPolicyNamespace, KXdmOmaCommonPolicyNsPrefix );
       
   259     aXdmDocument.AppendNamespaceL( KXdmOmaPresRulesNamespace, KXdmOmaPresRulesNsPrefix );
       
   260     aXdmDocument.AppendNamespaceL( KXdmIetfPresRulesNamespace, KXdmIetfPresRulesNsPrefix );
       
   261 /*    aXdmDocument.AppendNamespaceL( KXdmOmaPresRulesNamespace, KNullDesC8 );
       
   262     aXdmDocument.AppendNamespaceL( KXdmIetfPresRulesNamespace, KXdmIetfPresRulesNsPrefix );
       
   263     aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KXdmIetfCommonPolicyNsPrefix );*/
       
   264     }
       
   265 
       
   266 // End of File
       
   267