Update contrib.
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.
26 #ifndef __CAFMIMEHEADER_H__
27 #define __CAFMIMEHEADER_H__
31 #include <caf/caftypes.h>
35 #include <caf/caftypes.h>
40 namespace ContentAccess
42 class CMimeFieldAndData;
45 * Packages the MIME header information for easy use by a Content Access Agent.
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.
50 * Consider the following MIME header
53 * Content-type: application/vnd.oma.drm.content;
54 * Content-Length: 1234
55 * X-Oma-Drm-Separate-Delivery: 12
59 * The CCafMimeHeader is constructed as follows:
62 * // initialise the header with the content type
63 * _LIT8(KMyMime,"application/vnd.oma.drm.content");
64 * CCafMimeHeader *header = CCafMimeHeader::NewL(KMyMime());
66 * // Set the content length
67 * _LIT8(KMyLength,"1234");
68 * header->SetStandardMimeDataL(EContentLength, KMyLength());
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());
77 * To retreive the values from the CCafMimeHeader
80 * TPtrC8 contentType = header->StandardMimeData(EContentType); // application/vnd.oma.drm.content
81 * TPtrC8 contentLength = header->StandardMimeData(EContentLength); // 1234
83 * TInt numNonStandard = header->NonStandardMimeCount(); // 1
84 * TPtrC8 field = header->NonStandardMimeField(0); // X-Oma-Drm-Separate-Delivery
85 * TPtrC8 data = header->NonStandardMimeData(0); // 12
92 class CCafMimeHeader : public CBase
95 /** This creates the CCafMimeHeader object and calls SetFieldDataL(EContentType, aContent_Type);
97 * A CCafMimeHeader must have a valid EContentType field, so the only
98 * constructor available requires this as a parameter.
100 * @param aContent_Type The "Content-Type :" field from the MIME header.
102 IMPORT_C static CCafMimeHeader* NewL(const TDesC8& aContent_Type);
105 IMPORT_C virtual ~CCafMimeHeader();
107 /** Sets the MIME data associated with a standard MIME field.
109 * @param aIndex The TMimeFields MIME header field.
110 * @param aData The data corresponding to the MIME header.
112 IMPORT_C void SetStandardMimeDataL(const TMimeFields &aIndex, const TDesC8& aData);
114 /** Gets the data associated with the standard MIME field.
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.
119 IMPORT_C TPtrC8 StandardMimeData(const TMimeFields& aIndex) const;
121 /** Adds a new non-standard MIME header field.
123 * e.g., OMA requires a MIME header "X-Oma-Drm-Separate-Delivery".
125 * @param aFieldName The ....
126 * @param aData The data corresponding to the MIME header.
128 IMPORT_C void AddNonStandardMimeL(const TDesC8& aFieldName, const TDesC8& aData);
130 /** Retrieves the field name for a non-standard MIME header.
132 * @param aIndex The index of the non-standard MIME header.
133 * @return The non-standard MIME field.
135 IMPORT_C TPtrC8 NonStandardMimeField(TInt aIndex) const;
137 /** Retrieves the data for a non-standard MIME header.
139 * @param aIndex The index of the non-standard MIME header.
140 * @return The data associated with the non-standard MIME field.
142 IMPORT_C TPtrC8 NonStandardMimeData(TInt aIndex) const;
144 /** The number of non-standard MIME header fields.
146 * e.g., OMA requires a MIME header "X-Oma-Drm-Separate-Delivery".
148 * @return The number of non-standard MIME header fields.
150 IMPORT_C TInt NonStandardMimeCount() const;
152 /** Externalizes the CCafMimeHeader object.
154 * Allows the MIME header information to be passed between the client proxy
155 * and the CA agent server.
157 * @param aStream The stream to write the header information to.
159 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
161 /** Internalize the CCafMimeHeader object.
163 * Allows the MIME header information to be passed between the client proxy
164 * and the CA agent server.
166 * @param aStream The stream to read the header information from.
168 IMPORT_C void InternalizeL(RReadStream& aStream);
173 void ConstructL(const TDesC8& aContent_Type);
175 // Index used to map the fixed TMimeFields field value to the position in
176 // iStandardMimeHeaders used to store it
177 HBufC8* iStandardMimeHeader[EMimeMax];
179 /** Non-standard header fields, some agents (e.g., OMA) need access to
180 * other MIME headers.
182 RPointerArray <CMimeFieldAndData> iNonStandardMimeHeaders;
186 #endif // REMOVE_CAF1
188 #endif // __CAFMIMEHEADER_H__