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