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