williamr@2
|
1 |
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@4
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
//
|
williamr@2
|
15 |
|
williamr@2
|
16 |
/**
|
williamr@2
|
17 |
@file
|
williamr@2
|
18 |
@publishedAll
|
williamr@2
|
19 |
@released
|
williamr@2
|
20 |
*/
|
williamr@2
|
21 |
|
williamr@2
|
22 |
#ifndef __OBEXHEADERS_H
|
williamr@2
|
23 |
#define __OBEXHEADERS_H
|
williamr@2
|
24 |
|
williamr@2
|
25 |
#include <obextypes.h>
|
williamr@2
|
26 |
|
williamr@2
|
27 |
/**
|
williamr@2
|
28 |
Encapsulates an Obex header.
|
williamr@2
|
29 |
|
williamr@2
|
30 |
This class provides the ability to hold a header of any of the Obex
|
williamr@2
|
31 |
supported types as a native Symbian OS type.
|
williamr@2
|
32 |
|
williamr@2
|
33 |
A header may also have one or more attributes set. These are used by
|
williamr@2
|
34 |
the object which owns the header collection so that it can keep track
|
williamr@2
|
35 |
of which headers should be sent (!(ESuppressed || EDeleted)), which have
|
williamr@2
|
36 |
been sent (ESent), and whether the header should be deleted (EDeleted).
|
williamr@2
|
37 |
Deletion is a special case---any operation on the Object which causes
|
williamr@2
|
38 |
a scan of the headers will trigger deletion of any marked headers.
|
williamr@2
|
39 |
This is required as they are owned by the Object, but can be accessed
|
williamr@2
|
40 |
seperately (including through the creator keeping a pointer to the
|
williamr@2
|
41 |
header).
|
williamr@2
|
42 |
|
williamr@2
|
43 |
@see CObexBaseObject
|
williamr@2
|
44 |
@publishedAll
|
williamr@2
|
45 |
@released
|
williamr@2
|
46 |
*/
|
williamr@2
|
47 |
NONSHARABLE_CLASS(CObexHeader) : public CBase
|
williamr@2
|
48 |
{
|
williamr@2
|
49 |
public:
|
williamr@2
|
50 |
// Requires friendship with CObexBaseObject to support some aspects of the
|
williamr@2
|
51 |
// legacy API (specifically the HTTP accessor method).
|
williamr@2
|
52 |
friend class CObexBaseObject;
|
williamr@2
|
53 |
|
williamr@2
|
54 |
enum THeaderType
|
williamr@2
|
55 |
{
|
williamr@2
|
56 |
EUnicode = 0x00,
|
williamr@2
|
57 |
EByteSeq = 0x01,
|
williamr@2
|
58 |
EByte = 0x02,
|
williamr@2
|
59 |
EFourByte = 0x03
|
williamr@2
|
60 |
};
|
williamr@2
|
61 |
|
williamr@2
|
62 |
enum THeaderAttr
|
williamr@2
|
63 |
{
|
williamr@2
|
64 |
ESuppressed = 0x01,
|
williamr@2
|
65 |
ESent = 0x02,
|
williamr@2
|
66 |
EDeleted = 0x04,
|
williamr@2
|
67 |
};
|
williamr@2
|
68 |
|
williamr@2
|
69 |
IMPORT_C static CObexHeader* NewL();
|
williamr@2
|
70 |
virtual ~CObexHeader();
|
williamr@2
|
71 |
IMPORT_C CObexHeader* CopyL() const;
|
williamr@2
|
72 |
|
williamr@2
|
73 |
//Sets this object to use the same underlying header as the parameter.
|
williamr@2
|
74 |
IMPORT_C void Set(CObexHeader* aHeader);
|
williamr@2
|
75 |
//Resets the contents of this header, discarding the underlying data.
|
williamr@2
|
76 |
IMPORT_C void Reset();
|
williamr@2
|
77 |
|
williamr@2
|
78 |
//Resets and destroys all header attributes.
|
williamr@2
|
79 |
IMPORT_C void ResetContents();
|
williamr@2
|
80 |
|
williamr@2
|
81 |
IMPORT_C void SetAttributes(TUint16 aAttr);
|
williamr@2
|
82 |
IMPORT_C TUint16 Attributes() const;
|
williamr@2
|
83 |
|
williamr@2
|
84 |
IMPORT_C THeaderType Type() const;
|
williamr@2
|
85 |
|
williamr@2
|
86 |
IMPORT_C TUint8 HI() const;
|
williamr@2
|
87 |
IMPORT_C TUint8 AsByte() const;
|
williamr@2
|
88 |
IMPORT_C TUint32 AsFourByte() const;
|
williamr@2
|
89 |
IMPORT_C const TDesC8& AsByteSeq() const;
|
williamr@2
|
90 |
IMPORT_C const TDesC16& AsUnicode() const;
|
williamr@2
|
91 |
|
williamr@2
|
92 |
IMPORT_C void SetByte(const TUint8 aHI, const TUint8 aByte);
|
williamr@2
|
93 |
IMPORT_C void SetFourByte(const TUint8 aHI, const TUint32 aFourByte);
|
williamr@2
|
94 |
IMPORT_C void SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq);
|
williamr@2
|
95 |
IMPORT_C void SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode);
|
williamr@2
|
96 |
|
williamr@2
|
97 |
IMPORT_C TInt EncodedSize() const;
|
williamr@2
|
98 |
|
williamr@2
|
99 |
private:
|
williamr@2
|
100 |
CObexHeader();
|
williamr@2
|
101 |
CObexHeader(CObexUnderlyingHeader* aHeader);
|
williamr@2
|
102 |
void ConstructL();
|
williamr@2
|
103 |
|
williamr@2
|
104 |
private:
|
williamr@2
|
105 |
CObexUnderlyingHeader* iHeader;
|
williamr@2
|
106 |
};
|
williamr@2
|
107 |
|
williamr@2
|
108 |
/**
|
williamr@2
|
109 |
Used to allow the iterator to decide whether to present a header to
|
williamr@2
|
110 |
the user, by passing in a possible header HI value. Headers present
|
williamr@2
|
111 |
in the object will be presented to the Interested() function in the
|
williamr@2
|
112 |
object in which they are held (if received from a remote device
|
williamr@2
|
113 |
this will be the order in which they were received, otherwise this will
|
williamr@2
|
114 |
be the order in which they were set).
|
williamr@2
|
115 |
The function can implement any desired behaviour, including relying on
|
williamr@2
|
116 |
the order in which the headers are presented.
|
williamr@2
|
117 |
|
williamr@2
|
118 |
In case any state is held, the object also provides a Reset() function.
|
williamr@2
|
119 |
Reset() provides a default empty implementation.
|
williamr@2
|
120 |
|
williamr@2
|
121 |
Note: there is no destructor.
|
williamr@2
|
122 |
|
williamr@2
|
123 |
@publishedAll
|
williamr@2
|
124 |
@released
|
williamr@2
|
125 |
*/
|
williamr@2
|
126 |
class MObexHeaderCheck
|
williamr@2
|
127 |
{
|
williamr@2
|
128 |
public:
|
williamr@2
|
129 |
/**
|
williamr@2
|
130 |
Called to discover is the user is interested in the contents of
|
williamr@2
|
131 |
this header.
|
williamr@2
|
132 |
|
williamr@2
|
133 |
@param aHI The identifier of the header, including type bits.
|
williamr@2
|
134 |
@return ETrue if the user is interested in the contents of this
|
williamr@2
|
135 |
header.
|
williamr@2
|
136 |
@publishedAll
|
williamr@2
|
137 |
@released
|
williamr@2
|
138 |
*/
|
williamr@2
|
139 |
IMPORT_C virtual TBool Interested(TUint8 aHI) =0;
|
williamr@2
|
140 |
|
williamr@2
|
141 |
/**
|
williamr@2
|
142 |
Called in response to First() being called on the iterator object.
|
williamr@2
|
143 |
The default implementation does nothing---some implementations may
|
williamr@2
|
144 |
wish to reset state variables.
|
williamr@2
|
145 |
|
williamr@2
|
146 |
@publishedAll
|
williamr@2
|
147 |
@released
|
williamr@2
|
148 |
*/
|
williamr@2
|
149 |
IMPORT_C virtual void Reset();
|
williamr@2
|
150 |
|
williamr@2
|
151 |
/**
|
williamr@2
|
152 |
Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
|
williamr@2
|
153 |
@param aInterface UID of the interface to return
|
williamr@2
|
154 |
@param aObject the container for another interface as specified by aInterface
|
williamr@4
|
155 |
@publishedAll
|
williamr@2
|
156 |
*/
|
williamr@2
|
157 |
IMPORT_C virtual void MOHC_ExtensionInterfaceL(TUid aInterface, void*& aObject);
|
williamr@2
|
158 |
};
|
williamr@2
|
159 |
|
williamr@2
|
160 |
/**
|
williamr@2
|
161 |
A collection of headers. Includes code to filter based on the header HI
|
williamr@2
|
162 |
value, iterate through the set of interesting headers, and extract headers
|
williamr@2
|
163 |
with specific HI values.
|
williamr@2
|
164 |
|
williamr@2
|
165 |
@publishedAll
|
williamr@2
|
166 |
@released
|
williamr@2
|
167 |
*/
|
williamr@2
|
168 |
NONSHARABLE_CLASS(CObexHeaderSet) : public CBase
|
williamr@2
|
169 |
{
|
williamr@2
|
170 |
public:
|
williamr@2
|
171 |
IMPORT_C static CObexHeaderSet* NewL();
|
williamr@2
|
172 |
IMPORT_C CObexHeaderSet* CopyL();
|
williamr@2
|
173 |
IMPORT_C CObexHeaderSet* CopyL(MObexHeaderCheck& aHeaderCheck);
|
williamr@2
|
174 |
~CObexHeaderSet();
|
williamr@2
|
175 |
|
williamr@2
|
176 |
IMPORT_C TInt AddHeader(CObexHeader* aHeader);
|
williamr@2
|
177 |
IMPORT_C void DeleteCurrentHeader();
|
williamr@2
|
178 |
|
williamr@2
|
179 |
IMPORT_C void SetMask(MObexHeaderCheck* aMask);
|
williamr@2
|
180 |
IMPORT_C void DeleteMasked();
|
williamr@2
|
181 |
|
williamr@2
|
182 |
IMPORT_C void First() const;
|
williamr@2
|
183 |
IMPORT_C TInt This(CObexHeader* aHeader) const;
|
williamr@2
|
184 |
IMPORT_C TInt Next() const;
|
williamr@2
|
185 |
IMPORT_C TInt Next(TInt aSkip) const;
|
williamr@2
|
186 |
IMPORT_C TInt Count() const;
|
williamr@2
|
187 |
|
williamr@2
|
188 |
IMPORT_C TInt Find(TUint8 aHI, CObexHeader& aHeader) const;
|
williamr@2
|
189 |
|
williamr@2
|
190 |
private:
|
williamr@2
|
191 |
CObexHeaderSet();
|
williamr@2
|
192 |
|
williamr@2
|
193 |
private:
|
williamr@2
|
194 |
RPointerArray<CObexHeader> iHeaders;
|
williamr@2
|
195 |
mutable MObexHeaderCheck* iMask;
|
williamr@2
|
196 |
mutable TInt iPos;
|
williamr@2
|
197 |
};
|
williamr@2
|
198 |
|
williamr@2
|
199 |
/**
|
williamr@2
|
200 |
@publishedAll
|
williamr@2
|
201 |
@released
|
williamr@2
|
202 |
*/
|
williamr@2
|
203 |
NONSHARABLE_CLASS(TObexMatchHeader) : public MObexHeaderCheck
|
williamr@2
|
204 |
{
|
williamr@2
|
205 |
public:
|
williamr@2
|
206 |
virtual EXPORT_C TBool Interested(TUint8 aHI);
|
williamr@2
|
207 |
IMPORT_C void SetHeader(TUint8 aHI);
|
williamr@2
|
208 |
|
williamr@2
|
209 |
private:
|
williamr@2
|
210 |
TUint8 iHI;
|
williamr@2
|
211 |
|
williamr@2
|
212 |
private:
|
williamr@2
|
213 |
// This data padding has been added to help prevent future binary compatibility breaks
|
williamr@2
|
214 |
// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
|
williamr@2
|
215 |
TUint32 iPadding1;
|
williamr@2
|
216 |
TUint32 iPadding2;
|
williamr@2
|
217 |
};
|
williamr@2
|
218 |
|
williamr@2
|
219 |
/**
|
williamr@2
|
220 |
@publishedAll
|
williamr@2
|
221 |
@released
|
williamr@2
|
222 |
*/
|
williamr@2
|
223 |
NONSHARABLE_CLASS(TObexMatchHeaderType) : public MObexHeaderCheck
|
williamr@2
|
224 |
{
|
williamr@2
|
225 |
public:
|
williamr@2
|
226 |
virtual EXPORT_C TBool Interested(TUint8 aHI);
|
williamr@2
|
227 |
IMPORT_C void SetType(CObexHeader::THeaderType aType);
|
williamr@2
|
228 |
|
williamr@2
|
229 |
private:
|
williamr@2
|
230 |
TInt iType;
|
williamr@2
|
231 |
|
williamr@2
|
232 |
private:
|
williamr@2
|
233 |
// This data padding has been added to help prevent future binary compatibility breaks
|
williamr@2
|
234 |
// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
|
williamr@2
|
235 |
TUint32 iPadding1;
|
williamr@2
|
236 |
TUint32 iPadding2;
|
williamr@2
|
237 |
};
|
williamr@2
|
238 |
|
williamr@2
|
239 |
#endif // __OBEXHEADERS_H
|