os/security/contentmgmt/contentaccessfwfordrm/inc/cafmimeheader.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2003-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  @publishedPartner
    22  @deprecated
    23 */
    24 
    25 
    26 #ifndef __CAFMIMEHEADER_H__
    27 #define __CAFMIMEHEADER_H__
    28 
    29 #ifndef REMOVE_CAF1
    30 
    31 #include <caf/caftypes.h>
    32 
    33 #include <e32std.h>
    34 #include <e32base.h>
    35 #include <caf/caftypes.h>
    36 
    37 class RWriteStream;
    38 class RReadStream;
    39 
    40 namespace ContentAccess
    41 	{
    42 	class CMimeFieldAndData;
    43 	
    44 	/**
    45 	* Packages the MIME header information for easy use by a Content Access Agent.
    46 	*
    47 	* The "Content-Type" MIME header must be correct; other fields are optional from
    48 	* CAF's perspective, but may be mandatory for some agents.
    49 	*
    50 	* Consider the following MIME header
    51 	*
    52 	* @code
    53 	* Content-type: application/vnd.oma.drm.content;
    54 	* Content-Length: 1234
    55 	* X-Oma-Drm-Separate-Delivery: 12
    56 	*
    57 	* @endcode
    58 	*
    59 	* The CCafMimeHeader is constructed as follows:
    60 	*
    61 	* @code
    62 	* // initialise the header with the content type
    63 	* _LIT8(KMyMime,"application/vnd.oma.drm.content");
    64 	* CCafMimeHeader *header = CCafMimeHeader::NewL(KMyMime());
    65 	* 
    66 	* // Set the content length
    67 	* _LIT8(KMyLength,"1234");
    68 	* header->SetStandardMimeDataL(EContentLength, KMyLength());
    69 	* 
    70 	* // Set the non-standard header X-Oma-Drm-Separate-Delivery
    71 	* _LIT8(KMyField,"X-Oma-Drm-Separate-Delivery");
    72 	* _LIT8(KMyData,"12");
    73 	* header->AddNonStandardMimeL(KMyField(), KMyData());
    74 	*
    75 	* @endcode
    76 	*
    77 	* To retreive the values from the CCafMimeHeader
    78 	* 
    79 	* @code
    80 	* TPtrC8 contentType = header->StandardMimeData(EContentType);     // application/vnd.oma.drm.content
    81 	* TPtrC8 contentLength = header->StandardMimeData(EContentLength); // 1234
    82 	*
    83 	* TInt numNonStandard = header->NonStandardMimeCount();            // 1
    84 	* TPtrC8 field = header->NonStandardMimeField(0);                  // X-Oma-Drm-Separate-Delivery
    85 	* TPtrC8 data = header->NonStandardMimeData(0);                    // 12
    86 	*
    87 	* @endcode
    88 	*
    89 	* @publishedPartner
    90 	* @deprecated 
    91 	*/
    92 	class CCafMimeHeader : public CBase
    93 		{
    94 	public:
    95 		/** This creates the CCafMimeHeader object and calls SetFieldDataL(EContentType, aContent_Type);
    96 		*
    97 		* A CCafMimeHeader must have a valid EContentType field, so the only 
    98 		* constructor available requires this as a parameter. 
    99 		*
   100 		* @param aContent_Type	The "Content-Type :" field from the MIME header.
   101 		*/
   102 		IMPORT_C static CCafMimeHeader* NewL(const TDesC8& aContent_Type);
   103 		
   104 		/** Destructor */
   105 		IMPORT_C virtual ~CCafMimeHeader();
   106 
   107 		/** Sets the MIME data associated with a standard MIME field.
   108 		*
   109 		* @param aIndex	The TMimeFields MIME header field.
   110 		* @param aData	The data corresponding to the MIME header.
   111 		*/
   112 		IMPORT_C void SetStandardMimeDataL(const TMimeFields &aIndex, const TDesC8& aData);
   113 
   114 		/** Gets the data associated with the standard MIME field.
   115 		* 
   116 		* @param aIndex	The TMimeFields MIME header to retrieve corresponding to the MIME data.
   117 		* @return		The MIME data associated with the field corresponding to aIndex.
   118 		*/
   119 		IMPORT_C TPtrC8 StandardMimeData(const TMimeFields& aIndex) const;
   120 		
   121 		/** Adds a new non-standard MIME header field.
   122 		* 
   123 		* e.g., OMA requires a MIME header "X-Oma-Drm-Separate-Delivery".
   124 		*
   125 		* @param aFieldName The ....
   126 		* @param aData		The data corresponding to the MIME header.
   127 		*/
   128 		IMPORT_C void AddNonStandardMimeL(const TDesC8& aFieldName, const TDesC8& aData);
   129 
   130 		/** Retrieves the field name for a non-standard MIME header. 
   131 		*
   132 		* @param aIndex	The index of the non-standard MIME header.
   133 		* @return		The non-standard MIME field.
   134 		*/
   135 		IMPORT_C TPtrC8 NonStandardMimeField(TInt aIndex) const;
   136 
   137 		/** Retrieves the data for a non-standard MIME header. 
   138 		*
   139 		* @param aIndex	The index of the non-standard MIME header.
   140 		* @return		The data associated with the non-standard MIME field. 
   141 		*/
   142 		IMPORT_C TPtrC8 NonStandardMimeData(TInt aIndex) const;
   143 
   144 		/** The number of non-standard MIME header fields.
   145 		* 
   146 		* e.g., OMA requires a MIME header "X-Oma-Drm-Separate-Delivery".
   147 		*
   148 		* @return	The number of non-standard MIME header fields.
   149 		*/
   150 		IMPORT_C TInt NonStandardMimeCount() const;
   151 
   152 		/** Externalizes the CCafMimeHeader object.
   153 		* 
   154 		* Allows the MIME header information to be passed between the client proxy 
   155 		* and the CA agent server.
   156 		*
   157 		* @param aStream	The stream to write the header information to.
   158 		*/
   159 		IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   160 
   161 		/** Internalize the CCafMimeHeader object.
   162 		* 
   163 		* Allows the MIME header information to be passed between the client proxy 
   164 		* and the CA agent server.
   165 		*
   166 		* @param aStream	The stream to read the header information from.
   167 		*/
   168 		IMPORT_C void InternalizeL(RReadStream& aStream);
   169 
   170 	private:
   171 		CCafMimeHeader();
   172 
   173 		void ConstructL(const TDesC8& aContent_Type);
   174 	
   175 		// Index used to map the fixed TMimeFields field value to the position in
   176 		// iStandardMimeHeaders used to store it
   177 		HBufC8* iStandardMimeHeader[EMimeMax];
   178 
   179 		/** Non-standard header fields, some agents (e.g., OMA) need access to 
   180 		* other MIME headers.	
   181 		*/
   182 		RPointerArray <CMimeFieldAndData> iNonStandardMimeHeaders;  
   183 		
   184 		};
   185 	}
   186 #endif // REMOVE_CAF1
   187 
   188 #endif // __CAFMIMEHEADER_H__