epoc32/include/caf/cafmimeheader.h
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/caf/cafmimeheader.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,190 @@
     1.4 +/*
     1.5 +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +
    1.24 +/**
    1.25 + @file
    1.26 + @publishedPartner
    1.27 + @deprecated
    1.28 +*/
    1.29 +
    1.30 +
    1.31 +#ifndef __CAFMIMEHEADER_H__
    1.32 +#define __CAFMIMEHEADER_H__
    1.33 +
    1.34 +#ifndef REMOVE_CAF1
    1.35 +
    1.36 +#include <caf/caftypes.h>
    1.37 +
    1.38 +#include <e32std.h>
    1.39 +#include <e32base.h>
    1.40 +#include <caf/caftypes.h>
    1.41 +
    1.42 +class RWriteStream;
    1.43 +class RReadStream;
    1.44 +
    1.45 +namespace ContentAccess
    1.46 +	{
    1.47 +	class CMimeFieldAndData;
    1.48 +	
    1.49 +	/**
    1.50 +	* Packages the MIME header information for easy use by a Content Access Agent.
    1.51 +	*
    1.52 +	* The "Content-Type" MIME header must be correct; other fields are optional from
    1.53 +	* CAF's perspective, but may be mandatory for some agents.
    1.54 +	*
    1.55 +	* Consider the following MIME header
    1.56 +	*
    1.57 +	* @code
    1.58 +	* Content-type: application/vnd.oma.drm.content;
    1.59 +	* Content-Length: 1234
    1.60 +	* X-Oma-Drm-Separate-Delivery: 12
    1.61 +	*
    1.62 +	* @endcode
    1.63 +	*
    1.64 +	* The CCafMimeHeader is constructed as follows:
    1.65 +	*
    1.66 +	* @code
    1.67 +	* // initialise the header with the content type
    1.68 +	* _LIT8(KMyMime,"application/vnd.oma.drm.content");
    1.69 +	* CCafMimeHeader *header = CCafMimeHeader::NewL(KMyMime());
    1.70 +	* 
    1.71 +	* // Set the content length
    1.72 +	* _LIT8(KMyLength,"1234");
    1.73 +	* header->SetStandardMimeDataL(EContentLength, KMyLength());
    1.74 +	* 
    1.75 +	* // Set the non-standard header X-Oma-Drm-Separate-Delivery
    1.76 +	* _LIT8(KMyField,"X-Oma-Drm-Separate-Delivery");
    1.77 +	* _LIT8(KMyData,"12");
    1.78 +	* header->AddNonStandardMimeL(KMyField(), KMyData());
    1.79 +	*
    1.80 +	* @endcode
    1.81 +	*
    1.82 +	* To retreive the values from the CCafMimeHeader
    1.83 +	* 
    1.84 +	* @code
    1.85 +	* TPtrC8 contentType = header->StandardMimeData(EContentType);     // application/vnd.oma.drm.content
    1.86 +	* TPtrC8 contentLength = header->StandardMimeData(EContentLength); // 1234
    1.87 +	*
    1.88 +	* TInt numNonStandard = header->NonStandardMimeCount();            // 1
    1.89 +	* TPtrC8 field = header->NonStandardMimeField(0);                  // X-Oma-Drm-Separate-Delivery
    1.90 +	* TPtrC8 data = header->NonStandardMimeData(0);                    // 12
    1.91 +	*
    1.92 +	* @endcode
    1.93 +	*
    1.94 +	* @publishedPartner
    1.95 +	* @deprecated 
    1.96 +	*/
    1.97 +	class CCafMimeHeader : public CBase
    1.98 +		{
    1.99 +	public:
   1.100 +		/** This creates the CCafMimeHeader object and calls SetFieldDataL(EContentType, aContent_Type);
   1.101 +		*
   1.102 +		* A CCafMimeHeader must have a valid EContentType field, so the only 
   1.103 +		* constructor available requires this as a parameter. 
   1.104 +		*
   1.105 +		* @param aContent_Type	The "Content-Type :" field from the MIME header.
   1.106 +		*/
   1.107 +		IMPORT_C static CCafMimeHeader* NewL(const TDesC8& aContent_Type);
   1.108 +		
   1.109 +		/** Destructor */
   1.110 +		IMPORT_C virtual ~CCafMimeHeader();
   1.111 +
   1.112 +		/** Sets the MIME data associated with a standard MIME field.
   1.113 +		*
   1.114 +		* @param aIndex	The TMimeFields MIME header field.
   1.115 +		* @param aData	The data corresponding to the MIME header.
   1.116 +		*/
   1.117 +		IMPORT_C void SetStandardMimeDataL(const TMimeFields &aIndex, const TDesC8& aData);
   1.118 +
   1.119 +		/** Gets the data associated with the standard MIME field.
   1.120 +		* 
   1.121 +		* @param aIndex	The TMimeFields MIME header to retrieve corresponding to the MIME data.
   1.122 +		* @return		The MIME data associated with the field corresponding to aIndex.
   1.123 +		*/
   1.124 +		IMPORT_C TPtrC8 StandardMimeData(const TMimeFields& aIndex) const;
   1.125 +		
   1.126 +		/** Adds a new non-standard MIME header field.
   1.127 +		* 
   1.128 +		* e.g., OMA requires a MIME header "X-Oma-Drm-Separate-Delivery".
   1.129 +		*
   1.130 +		* @param aFieldName The ....
   1.131 +		* @param aData		The data corresponding to the MIME header.
   1.132 +		*/
   1.133 +		IMPORT_C void AddNonStandardMimeL(const TDesC8& aFieldName, const TDesC8& aData);
   1.134 +
   1.135 +		/** Retrieves the field name for a non-standard MIME header. 
   1.136 +		*
   1.137 +		* @param aIndex	The index of the non-standard MIME header.
   1.138 +		* @return		The non-standard MIME field.
   1.139 +		*/
   1.140 +		IMPORT_C TPtrC8 NonStandardMimeField(TInt aIndex) const;
   1.141 +
   1.142 +		/** Retrieves the data for a non-standard MIME header. 
   1.143 +		*
   1.144 +		* @param aIndex	The index of the non-standard MIME header.
   1.145 +		* @return		The data associated with the non-standard MIME field. 
   1.146 +		*/
   1.147 +		IMPORT_C TPtrC8 NonStandardMimeData(TInt aIndex) const;
   1.148 +
   1.149 +		/** The number of non-standard MIME header fields.
   1.150 +		* 
   1.151 +		* e.g., OMA requires a MIME header "X-Oma-Drm-Separate-Delivery".
   1.152 +		*
   1.153 +		* @return	The number of non-standard MIME header fields.
   1.154 +		*/
   1.155 +		IMPORT_C TInt NonStandardMimeCount() const;
   1.156 +
   1.157 +		/** Externalizes the CCafMimeHeader object.
   1.158 +		* 
   1.159 +		* Allows the MIME header information to be passed between the client proxy 
   1.160 +		* and the CA agent server.
   1.161 +		*
   1.162 +		* @param aStream	The stream to write the header information to.
   1.163 +		*/
   1.164 +		IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   1.165 +
   1.166 +		/** Internalize the CCafMimeHeader object.
   1.167 +		* 
   1.168 +		* Allows the MIME header information to be passed between the client proxy 
   1.169 +		* and the CA agent server.
   1.170 +		*
   1.171 +		* @param aStream	The stream to read the header information from.
   1.172 +		*/
   1.173 +		IMPORT_C void InternalizeL(RReadStream& aStream);
   1.174 +
   1.175 +	private:
   1.176 +		CCafMimeHeader();
   1.177 +
   1.178 +		void ConstructL(const TDesC8& aContent_Type);
   1.179 +	
   1.180 +		// Index used to map the fixed TMimeFields field value to the position in
   1.181 +		// iStandardMimeHeaders used to store it
   1.182 +		HBufC8* iStandardMimeHeader[EMimeMax];
   1.183 +
   1.184 +		/** Non-standard header fields, some agents (e.g., OMA) need access to 
   1.185 +		* other MIME headers.	
   1.186 +		*/
   1.187 +		RPointerArray <CMimeFieldAndData> iNonStandardMimeHeaders;  
   1.188 +		
   1.189 +		};
   1.190 +	}
   1.191 +#endif // REMOVE_CAF1
   1.192 +
   1.193 +#endif // __CAFMIMEHEADER_H__