sl@0: /* sl@0: * Copyright (c) 2003-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: @publishedPartner sl@0: @deprecated sl@0: */ sl@0: sl@0: sl@0: #ifndef __CAFMIMEHEADER_H__ sl@0: #define __CAFMIMEHEADER_H__ sl@0: sl@0: #ifndef REMOVE_CAF1 sl@0: sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: class RWriteStream; sl@0: class RReadStream; sl@0: sl@0: namespace ContentAccess sl@0: { sl@0: class CMimeFieldAndData; sl@0: sl@0: /** sl@0: * Packages the MIME header information for easy use by a Content Access Agent. sl@0: * sl@0: * The "Content-Type" MIME header must be correct; other fields are optional from sl@0: * CAF's perspective, but may be mandatory for some agents. sl@0: * sl@0: * Consider the following MIME header sl@0: * sl@0: * @code sl@0: * Content-type: application/vnd.oma.drm.content; sl@0: * Content-Length: 1234 sl@0: * X-Oma-Drm-Separate-Delivery: 12 sl@0: * sl@0: * @endcode sl@0: * sl@0: * The CCafMimeHeader is constructed as follows: sl@0: * sl@0: * @code sl@0: * // initialise the header with the content type sl@0: * _LIT8(KMyMime,"application/vnd.oma.drm.content"); sl@0: * CCafMimeHeader *header = CCafMimeHeader::NewL(KMyMime()); sl@0: * sl@0: * // Set the content length sl@0: * _LIT8(KMyLength,"1234"); sl@0: * header->SetStandardMimeDataL(EContentLength, KMyLength()); sl@0: * sl@0: * // Set the non-standard header X-Oma-Drm-Separate-Delivery sl@0: * _LIT8(KMyField,"X-Oma-Drm-Separate-Delivery"); sl@0: * _LIT8(KMyData,"12"); sl@0: * header->AddNonStandardMimeL(KMyField(), KMyData()); sl@0: * sl@0: * @endcode sl@0: * sl@0: * To retreive the values from the CCafMimeHeader sl@0: * sl@0: * @code sl@0: * TPtrC8 contentType = header->StandardMimeData(EContentType); // application/vnd.oma.drm.content sl@0: * TPtrC8 contentLength = header->StandardMimeData(EContentLength); // 1234 sl@0: * sl@0: * TInt numNonStandard = header->NonStandardMimeCount(); // 1 sl@0: * TPtrC8 field = header->NonStandardMimeField(0); // X-Oma-Drm-Separate-Delivery sl@0: * TPtrC8 data = header->NonStandardMimeData(0); // 12 sl@0: * sl@0: * @endcode sl@0: * sl@0: * @publishedPartner sl@0: * @deprecated sl@0: */ sl@0: class CCafMimeHeader : public CBase sl@0: { sl@0: public: sl@0: /** This creates the CCafMimeHeader object and calls SetFieldDataL(EContentType, aContent_Type); sl@0: * sl@0: * A CCafMimeHeader must have a valid EContentType field, so the only sl@0: * constructor available requires this as a parameter. sl@0: * sl@0: * @param aContent_Type The "Content-Type :" field from the MIME header. sl@0: */ sl@0: IMPORT_C static CCafMimeHeader* NewL(const TDesC8& aContent_Type); sl@0: sl@0: /** Destructor */ sl@0: IMPORT_C virtual ~CCafMimeHeader(); sl@0: sl@0: /** Sets the MIME data associated with a standard MIME field. sl@0: * sl@0: * @param aIndex The TMimeFields MIME header field. sl@0: * @param aData The data corresponding to the MIME header. sl@0: */ sl@0: IMPORT_C void SetStandardMimeDataL(const TMimeFields &aIndex, const TDesC8& aData); sl@0: sl@0: /** Gets the data associated with the standard MIME field. sl@0: * sl@0: * @param aIndex The TMimeFields MIME header to retrieve corresponding to the MIME data. sl@0: * @return The MIME data associated with the field corresponding to aIndex. sl@0: */ sl@0: IMPORT_C TPtrC8 StandardMimeData(const TMimeFields& aIndex) const; sl@0: sl@0: /** Adds a new non-standard MIME header field. sl@0: * sl@0: * e.g., OMA requires a MIME header "X-Oma-Drm-Separate-Delivery". sl@0: * sl@0: * @param aFieldName The .... sl@0: * @param aData The data corresponding to the MIME header. sl@0: */ sl@0: IMPORT_C void AddNonStandardMimeL(const TDesC8& aFieldName, const TDesC8& aData); sl@0: sl@0: /** Retrieves the field name for a non-standard MIME header. sl@0: * sl@0: * @param aIndex The index of the non-standard MIME header. sl@0: * @return The non-standard MIME field. sl@0: */ sl@0: IMPORT_C TPtrC8 NonStandardMimeField(TInt aIndex) const; sl@0: sl@0: /** Retrieves the data for a non-standard MIME header. sl@0: * sl@0: * @param aIndex The index of the non-standard MIME header. sl@0: * @return The data associated with the non-standard MIME field. sl@0: */ sl@0: IMPORT_C TPtrC8 NonStandardMimeData(TInt aIndex) const; sl@0: sl@0: /** The number of non-standard MIME header fields. sl@0: * sl@0: * e.g., OMA requires a MIME header "X-Oma-Drm-Separate-Delivery". sl@0: * sl@0: * @return The number of non-standard MIME header fields. sl@0: */ sl@0: IMPORT_C TInt NonStandardMimeCount() const; sl@0: sl@0: /** Externalizes the CCafMimeHeader object. sl@0: * sl@0: * Allows the MIME header information to be passed between the client proxy sl@0: * and the CA agent server. sl@0: * sl@0: * @param aStream The stream to write the header information to. sl@0: */ sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: sl@0: /** Internalize the CCafMimeHeader object. sl@0: * sl@0: * Allows the MIME header information to be passed between the client proxy sl@0: * and the CA agent server. sl@0: * sl@0: * @param aStream The stream to read the header information from. sl@0: */ sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: sl@0: private: sl@0: CCafMimeHeader(); sl@0: sl@0: void ConstructL(const TDesC8& aContent_Type); sl@0: sl@0: // Index used to map the fixed TMimeFields field value to the position in sl@0: // iStandardMimeHeaders used to store it sl@0: HBufC8* iStandardMimeHeader[EMimeMax]; sl@0: sl@0: /** Non-standard header fields, some agents (e.g., OMA) need access to sl@0: * other MIME headers. sl@0: */ sl@0: RPointerArray iNonStandardMimeHeaders; sl@0: sl@0: }; sl@0: } sl@0: #endif // REMOVE_CAF1 sl@0: sl@0: #endif // __CAFMIMEHEADER_H__