os/security/contentmgmt/contentaccessfwfordrm/inc/metadata.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2004-2009 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 the License "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: 
    15 *
    16 */
    17 
    18 
    19 /**
    20  @file
    21  @publishedAll
    22  @released
    23 */
    24 
    25 
    26 #ifndef __CAF_METADATA_H__
    27 #define __CAF_METADATA_H__
    28 
    29 #include <e32base.h>
    30 #include <f32file.h>
    31 
    32 class RReadStream;
    33 class RWriteStream;
    34 
    35 namespace ContentAccess
    36 	{
    37 	/** Stores a field and data pair for use in a supplier import operation
    38 	
    39 	The field and data can be any values the application doing the import thinks 
    40 	the agent will find useful. Some information that could be included here are
    41 	headers, eg:
    42 
    43 	"Content Type", "application/vnd.oma.drm.dm"
    44 
    45 	The application can include anything it likes, if the agent doesn't understand
    46 	the header it can just ignore it, eg:
    47 
    48 	"Colour", "Yellow"
    49 
    50 
    51 	CMetaData can be used with 8-bit or unicode data and automatically performs
    52 	conversions between the two. 
    53 	
    54 	Applications should use the unicode functions whenever possible because it 
    55 	removes the risk of losing information during the unicode to 8 bit conversion.
    56 
    57 	*/
    58 	class CMetaData : public CBase
    59 		{
    60 	public:
    61 		/** Construct a new CMetaData with 8 bit data 
    62 		The 8-bit data will be stored in CMetaData as unicode 
    63 		
    64 		@param aField The name of the field
    65 		@param aData The data associated with the field
    66 		@return A CMetaData object populated with the given field and data		
    67 		*/
    68 		static CMetaData* NewL(const TDesC8& aField, const TDesC8& aData);
    69 		/** Construct a new CMetaData with unicode data 
    70 
    71 		@param aField The name of the field
    72 		@param aData The data associated with the field
    73 		@return A CMetaData object populated with the given field and data		
    74 
    75 		*/
    76 		static CMetaData* NewL(const TDesC16& aField, const TDesC16& aData);
    77 
    78 		/** Construct a new CMetaData from a data stream
    79 
    80 		@param aStream The stream to read the CMetaData object from
    81 		@return A CMetaData object read from the stream
    82 		
    83 		*/
    84 		static CMetaData* NewL(RReadStream& aStream);
    85 
    86 		/** destructor 
    87 		*/
    88 		virtual ~CMetaData();
    89 
    90 		/** The field name 
    91 		@return The field name
    92 		*/
    93 		IMPORT_C const TDesC& Field() const;
    94 		
    95 		/** The data value 
    96 		@return The data value
    97 		*/
    98 		IMPORT_C const TDesC& Data() const;
    99 
   100 		/** The field name 
   101 		@return The field name
   102 		*/
   103 		IMPORT_C const TDesC8& Field8() const;
   104 		
   105 		/** The data value 
   106 		@return The data value
   107 		*/
   108 		IMPORT_C const TDesC8& Data8() const;
   109 
   110 		/** Write the CMetaData to a data stream
   111 		
   112 		@param aStream The stream to write the CMetaData object to
   113 		*/
   114 		void ExternalizeL(RWriteStream& aStream) const;
   115 
   116 	private:
   117 		CMetaData(TBool aUnicode);
   118 		void ConstructL(const TDesC8& aField, const TDesC8& aData);
   119 		void ConstructL(const TDesC16& aField, const TDesC16& aData);
   120 
   121 		/** Read the CMetaData from a data stream
   122 		*/
   123 		void InternalizeL(RReadStream& aStream);
   124 
   125 	private:
   126 		HBufC* iField;
   127 		HBufC* iData;
   128 		HBufC8* iField8;
   129 		HBufC8* iData8;
   130 		TBool iUnicode;
   131 		};
   132 	}
   133 
   134 #endif