sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: sl@0: sl@0: #ifndef __CAF_METADATA_H__ sl@0: #define __CAF_METADATA_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: class RReadStream; sl@0: class RWriteStream; sl@0: sl@0: namespace ContentAccess sl@0: { sl@0: /** Stores a field and data pair for use in a supplier import operation sl@0: sl@0: The field and data can be any values the application doing the import thinks sl@0: the agent will find useful. Some information that could be included here are sl@0: headers, eg: sl@0: sl@0: "Content Type", "application/vnd.oma.drm.dm" sl@0: sl@0: The application can include anything it likes, if the agent doesn't understand sl@0: the header it can just ignore it, eg: sl@0: sl@0: "Colour", "Yellow" sl@0: sl@0: sl@0: CMetaData can be used with 8-bit or unicode data and automatically performs sl@0: conversions between the two. sl@0: sl@0: Applications should use the unicode functions whenever possible because it sl@0: removes the risk of losing information during the unicode to 8 bit conversion. sl@0: sl@0: */ sl@0: class CMetaData : public CBase sl@0: { sl@0: public: sl@0: /** Construct a new CMetaData with 8 bit data sl@0: The 8-bit data will be stored in CMetaData as unicode sl@0: sl@0: @param aField The name of the field sl@0: @param aData The data associated with the field sl@0: @return A CMetaData object populated with the given field and data sl@0: */ sl@0: static CMetaData* NewL(const TDesC8& aField, const TDesC8& aData); sl@0: /** Construct a new CMetaData with unicode data sl@0: sl@0: @param aField The name of the field sl@0: @param aData The data associated with the field sl@0: @return A CMetaData object populated with the given field and data sl@0: sl@0: */ sl@0: static CMetaData* NewL(const TDesC16& aField, const TDesC16& aData); sl@0: sl@0: /** Construct a new CMetaData from a data stream sl@0: sl@0: @param aStream The stream to read the CMetaData object from sl@0: @return A CMetaData object read from the stream sl@0: sl@0: */ sl@0: static CMetaData* NewL(RReadStream& aStream); sl@0: sl@0: /** destructor sl@0: */ sl@0: virtual ~CMetaData(); sl@0: sl@0: /** The field name sl@0: @return The field name sl@0: */ sl@0: IMPORT_C const TDesC& Field() const; sl@0: sl@0: /** The data value sl@0: @return The data value sl@0: */ sl@0: IMPORT_C const TDesC& Data() const; sl@0: sl@0: /** The field name sl@0: @return The field name sl@0: */ sl@0: IMPORT_C const TDesC8& Field8() const; sl@0: sl@0: /** The data value sl@0: @return The data value sl@0: */ sl@0: IMPORT_C const TDesC8& Data8() const; sl@0: sl@0: /** Write the CMetaData to a data stream sl@0: sl@0: @param aStream The stream to write the CMetaData object to sl@0: */ sl@0: void ExternalizeL(RWriteStream& aStream) const; sl@0: sl@0: private: sl@0: CMetaData(TBool aUnicode); sl@0: void ConstructL(const TDesC8& aField, const TDesC8& aData); sl@0: void ConstructL(const TDesC16& aField, const TDesC16& aData); sl@0: sl@0: /** Read the CMetaData from a data stream sl@0: */ sl@0: void InternalizeL(RReadStream& aStream); sl@0: sl@0: private: sl@0: HBufC* iField; sl@0: HBufC* iData; sl@0: HBufC8* iField8; sl@0: HBufC8* iData8; sl@0: TBool iUnicode; sl@0: }; sl@0: } sl@0: sl@0: #endif