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