xdmprotocols/XcapProtocol/XcapAppUsage/XcapC4/src/XcapC4.cpp
changeset 0 c8caa15ef882
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     1 /*
       
     2 * Copyright (c) 2008 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:  CXcapC4
       
    15 *
       
    16 */
       
    17 
       
    18 #include <XdmErrors.h>
       
    19 #include <XdmDocumentNode.h>
       
    20 #include <XdmNodeAttribute.h>
       
    21 #include <centralrepository.h>
       
    22 #ifdef _DEBUG
       
    23 #include <flogger.h>
       
    24 #endif
       
    25 
       
    26 #include "XcapC4.h"
       
    27 //#include "pasvariation.hrh"
       
    28 
       
    29 
       
    30 // Used specification
       
    31 // Presence Content XDM Specification, draft 1.0
       
    32 
       
    33 // ----------------------------------------------------
       
    34 // CXcapC4::CXcapC4
       
    35 // 
       
    36 // ----------------------------------------------------
       
    37 //
       
    38 CXcapC4::CXcapC4( const CXdmEngine& aXdmEngine ) :
       
    39 	CXcapAppUsage( aXdmEngine )
       
    40     {
       
    41 #ifdef _DEBUG 
       
    42     WriteToLog( _L8( "CXcapC4 initialized!" ) );
       
    43 #endif
       
    44     }
       
    45 
       
    46 // ----------------------------------------------------
       
    47 // CXcapC4::NewL
       
    48 // 
       
    49 // ----------------------------------------------------
       
    50 //
       
    51 CXcapC4* CXcapC4::NewL( const TXcapAppUsageParams& aParameters )
       
    52     {
       
    53     CXcapC4* self = new ( ELeave ) CXcapC4( aParameters.iXdmEngine );
       
    54     CleanupStack::PushL( self );	// << self
       
    55     self->ConstructL();
       
    56     CleanupStack::Pop( self );      // >> self
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ----------------------------------------------------
       
    61 // CXcapC4::~CXcapC4
       
    62 // 
       
    63 // ----------------------------------------------------
       
    64 //
       
    65 CXcapC4::~CXcapC4()
       
    66     {
       
    67     }
       
    68         
       
    69 // ----------------------------------------------------
       
    70 // CXcapC4::ConstructL
       
    71 // 
       
    72 // ----------------------------------------------------
       
    73 //
       
    74 void CXcapC4::ConstructL()
       
    75     {
       
    76     CRepository* cenRepRCSGlobal;
       
    77     cenRepRCSGlobal = CRepository::NewL( TUid::Uid( KC4SettingsCenRepUID ) );
       
    78 	CleanupStack::PushL( cenRepRCSGlobal );
       
    79 
       
    80     // 0x06 is the index in central repository for content type setting
       
    81     User::LeaveIfError( cenRepRCSGlobal->Get( 0x06, iRCSGlobalOldContentType ) );
       
    82     CleanupStack::PopAndDestroy( ); // cenRepRCSGlobal
       
    83     }
       
    84 
       
    85 // ----------------------------------------------------
       
    86 // CXcapC4::AUID
       
    87 // 
       
    88 // ----------------------------------------------------
       
    89 //
       
    90 TPtrC8 CXcapC4::AUID() const
       
    91     {
       
    92     return TPtrC8( KXdmPresContentAUID );
       
    93     }
       
    94                 
       
    95 // ----------------------------------------------------
       
    96 // CXcapC4::ContentType
       
    97 // 
       
    98 // ----------------------------------------------------
       
    99 //
       
   100 TPtrC8 CXcapC4::ContentType() const
       
   101     {
       
   102     if ( iRCSGlobalOldContentType )
       
   103     	{
       
   104 	return TPtrC8( KXdmPresContentContTypeOld );
       
   105     	}
       
   106     else
       
   107     	{
       
   108 	return TPtrC8( KXdmPresContentContType );
       
   109     	}
       
   110     }
       
   111 
       
   112 // ----------------------------------------------------
       
   113 // CXcapC4::DefaultNamespace
       
   114 // 
       
   115 // ----------------------------------------------------
       
   116 //
       
   117 TPtrC8 CXcapC4::DefaultNamespace() const
       
   118     {
       
   119     return TPtrC8( KXdmPresContentNamespace );
       
   120     }   
       
   121     
       
   122 // ----------------------------------------------------
       
   123 // CXcapC4::ValidateL
       
   124 // 
       
   125 // ----------------------------------------------------
       
   126 //
       
   127 TBool CXcapC4::ValidateNodeL( CXdmDocumentNode& aXdmNode )
       
   128     {
       
   129 #ifdef _DEBUG 
       
   130     WriteToLog( _L8( "CXcapC4::ValidateNodeL" ) );
       
   131 #endif
       
   132     // This method is called by base class for each element
       
   133     // in document, here we have to declare every element, check element 
       
   134     // datatype, restrictions for values and also do all checking that concerns  
       
   135     // the structure of the element. If the datatype is some of
       
   136     // the common datatypes defined in xcapappusage.h, the node
       
   137     // can pe passed to the base class for value validation.
       
   138     // If the node belongs to this namespace, the return value
       
   139     // should be true, false otherwise.
       
   140      
       
   141     TBool found ( EFalse );   
       
   142     TPtrC element = aXdmNode.NodeName();
       
   143 
       
   144 	// mime-type
       
   145 	if ( Match( element, KXdmMimeType ) )
       
   146 		{
       
   147 		found = ETrue;
       
   148 		}
       
   149 	else if ( Match( element, KXdmEncoding ) )
       
   150 		{
       
   151 		found = ETrue;
       
   152 		}
       
   153 	else if ( Match( element, KXdmDescription ) )
       
   154 		{
       
   155 		found = ETrue;
       
   156 		}
       
   157 	else if ( Match( element, KXdmData ) )
       
   158 		{
       
   159 		found = ETrue;
       
   160 		}
       
   161 
       
   162 #ifdef _DEBUG 
       
   163     WriteToLog( _L8( "CXcapC4::ValidateNodeL - found: %d" ), found );
       
   164 #endif
       
   165     return found;
       
   166     }
       
   167 
       
   168 // ----------------------------------------------------
       
   169 // CXcapC4::ValidateAttributeL
       
   170 // 
       
   171 // ----------------------------------------------------
       
   172 //
       
   173 void CXcapC4::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 should not be any attributes in pres-content document
       
   181 #ifdef _DEBUG 
       
   182     WriteToLog( _L8( "CXcapC4::ValidateAttributeL" ) );
       
   183 #endif
       
   184 //	User::Leave( KErrNotSupported );
       
   185     }   
       
   186                          
       
   187 // ----------------------------------------------------
       
   188 // CXcapC4::AddNamespaceInformationL
       
   189 // 
       
   190 // ----------------------------------------------------
       
   191 //
       
   192 void CXcapC4::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
       
   193     {
       
   194 #ifdef _DEBUG 
       
   195     WriteToLog( _L8( "CXcapC4::AddNamespaceInformationL" ) );
       
   196 #endif
       
   197     aXdmDocument.AppendNamespaceL( KXdmPresContentNamespace, KNullDesC8 );
       
   198     }
       
   199 
       
   200 // End of File
       
   201