2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
28 #ifndef __CAFMIMEHEADER_H__
29 #define __CAFMIMEHEADER_H__
33 #include <caf/caftypes.h>
37 #include <caf/caftypes.h>
42 namespace ContentAccess
44 class CMimeFieldAndData;
47 * Packages the MIME header information for easy use by a Content Access Agent.
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.
52 * Consider the following MIME header
55 * Content-type: application/vnd.oma.drm.content;
56 * Content-Length: 1234
57 * X-Oma-Drm-Separate-Delivery: 12
61 * The CCafMimeHeader is constructed as follows:
64 * // initialise the header with the content type
65 * _LIT8(KMyMime,"application/vnd.oma.drm.content");
66 * CCafMimeHeader *header = CCafMimeHeader::NewL(KMyMime());
68 * // Set the content length
69 * _LIT8(KMyLength,"1234");
70 * header->SetStandardMimeDataL(EContentLength, KMyLength());
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());
79 * To retreive the values from the CCafMimeHeader
82 * TPtrC8 contentType = header->StandardMimeData(EContentType); // application/vnd.oma.drm.content
83 * TPtrC8 contentLength = header->StandardMimeData(EContentLength); // 1234
85 * TInt numNonStandard = header->NonStandardMimeCount(); // 1
86 * TPtrC8 field = header->NonStandardMimeField(0); // X-Oma-Drm-Separate-Delivery
87 * TPtrC8 data = header->NonStandardMimeData(0); // 12
94 class CCafMimeHeader : public CBase
97 /** This creates the CCafMimeHeader object and calls SetFieldDataL(EContentType, aContent_Type);
99 * A CCafMimeHeader must have a valid EContentType field, so the only
100 * constructor available requires this as a parameter.
102 * @param aContent_Type The "Content-Type :" field from the MIME header.
104 IMPORT_C static CCafMimeHeader* NewL(const TDesC8& aContent_Type);
107 IMPORT_C virtual ~CCafMimeHeader();
109 /** Sets the MIME data associated with a standard MIME field.
111 * @param aIndex The TMimeFields MIME header field.
112 * @param aData The data corresponding to the MIME header.
114 IMPORT_C void SetStandardMimeDataL(const TMimeFields &aIndex, const TDesC8& aData);
116 /** Gets the data associated with the standard MIME field.
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.
121 IMPORT_C TPtrC8 StandardMimeData(const TMimeFields& aIndex) const;
123 /** Adds a new non-standard MIME header field.
125 * e.g., OMA requires a MIME header "X-Oma-Drm-Separate-Delivery".
127 * @param aFieldName The ....
128 * @param aData The data corresponding to the MIME header.
130 IMPORT_C void AddNonStandardMimeL(const TDesC8& aFieldName, const TDesC8& aData);
132 /** Retrieves the field name for a non-standard MIME header.
134 * @param aIndex The index of the non-standard MIME header.
135 * @return The non-standard MIME field.
137 IMPORT_C TPtrC8 NonStandardMimeField(TInt aIndex) const;
139 /** Retrieves the data for a non-standard MIME header.
141 * @param aIndex The index of the non-standard MIME header.
142 * @return The data associated with the non-standard MIME field.
144 IMPORT_C TPtrC8 NonStandardMimeData(TInt aIndex) const;
146 /** The number of non-standard MIME header fields.
148 * e.g., OMA requires a MIME header "X-Oma-Drm-Separate-Delivery".
150 * @return The number of non-standard MIME header fields.
152 IMPORT_C TInt NonStandardMimeCount() const;
154 /** Externalizes the CCafMimeHeader object.
156 * Allows the MIME header information to be passed between the client proxy
157 * and the CA agent server.
159 * @param aStream The stream to write the header information to.
161 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
163 /** Internalize the CCafMimeHeader object.
165 * Allows the MIME header information to be passed between the client proxy
166 * and the CA agent server.
168 * @param aStream The stream to read the header information from.
170 IMPORT_C void InternalizeL(RReadStream& aStream);
175 void ConstructL(const TDesC8& aContent_Type);
177 // Index used to map the fixed TMimeFields field value to the position in
178 // iStandardMimeHeaders used to store it
179 HBufC8* iStandardMimeHeader[EMimeMax];
181 /** Non-standard header fields, some agents (e.g., OMA) need access to
182 * other MIME headers.
184 RPointerArray <CMimeFieldAndData> iNonStandardMimeHeaders;
188 #endif // REMOVE_CAF1
190 #endif // __CAFMIMEHEADER_H__