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