1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #ifndef __OBEXHEADERS_H
23 #define __OBEXHEADERS_H
25 #include <obextypes.h>
28 Encapsulates an Obex header.
30 This class provides the ability to hold a header of any of the Obex
31 supported types as a native Symbian OS type.
33 A header may also have one or more attributes set. These are used by
34 the object which owns the header collection so that it can keep track
35 of which headers should be sent (!(ESuppressed || EDeleted)), which have
36 been sent (ESent), and whether the header should be deleted (EDeleted).
37 Deletion is a special case---any operation on the Object which causes
38 a scan of the headers will trigger deletion of any marked headers.
39 This is required as they are owned by the Object, but can be accessed
40 seperately (including through the creator keeping a pointer to the
47 NONSHARABLE_CLASS(CObexHeader) : public CBase
50 // Requires friendship with CObexBaseObject to support some aspects of the
51 // legacy API (specifically the HTTP accessor method).
52 friend class CObexBaseObject;
69 IMPORT_C static CObexHeader* NewL();
70 virtual ~CObexHeader();
71 IMPORT_C CObexHeader* CopyL() const;
73 //Sets this object to use the same underlying header as the parameter.
74 IMPORT_C void Set(CObexHeader* aHeader);
75 //Resets the contents of this header, discarding the underlying data.
76 IMPORT_C void Reset();
78 //Resets and destroys all header attributes.
79 IMPORT_C void ResetContents();
81 IMPORT_C void SetAttributes(TUint16 aAttr);
82 IMPORT_C TUint16 Attributes() const;
84 IMPORT_C THeaderType Type() const;
86 IMPORT_C TUint8 HI() const;
87 IMPORT_C TUint8 AsByte() const;
88 IMPORT_C TUint32 AsFourByte() const;
89 IMPORT_C const TDesC8& AsByteSeq() const;
90 IMPORT_C const TDesC16& AsUnicode() const;
92 IMPORT_C void SetByte(const TUint8 aHI, const TUint8 aByte);
93 IMPORT_C void SetFourByte(const TUint8 aHI, const TUint32 aFourByte);
94 IMPORT_C void SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq);
95 IMPORT_C void SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode);
97 IMPORT_C TInt EncodedSize() const;
101 CObexHeader(CObexUnderlyingHeader* aHeader);
105 CObexUnderlyingHeader* iHeader;
109 Used to allow the iterator to decide whether to present a header to
110 the user, by passing in a possible header HI value. Headers present
111 in the object will be presented to the Interested() function in the
112 object in which they are held (if received from a remote device
113 this will be the order in which they were received, otherwise this will
114 be the order in which they were set).
115 The function can implement any desired behaviour, including relying on
116 the order in which the headers are presented.
118 In case any state is held, the object also provides a Reset() function.
119 Reset() provides a default empty implementation.
121 Note: there is no destructor.
126 class MObexHeaderCheck
130 Called to discover is the user is interested in the contents of
133 @param aHI The identifier of the header, including type bits.
134 @return ETrue if the user is interested in the contents of this
139 IMPORT_C virtual TBool Interested(TUint8 aHI) =0;
142 Called in response to First() being called on the iterator object.
143 The default implementation does nothing---some implementations may
144 wish to reset state variables.
149 IMPORT_C virtual void Reset();
152 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
153 @param aInterface UID of the interface to return
154 @param aObject the container for another interface as specified by aInterface
157 IMPORT_C virtual void MOHC_ExtensionInterfaceL(TUid aInterface, void*& aObject);
161 A collection of headers. Includes code to filter based on the header HI
162 value, iterate through the set of interesting headers, and extract headers
163 with specific HI values.
168 NONSHARABLE_CLASS(CObexHeaderSet) : public CBase
171 IMPORT_C static CObexHeaderSet* NewL();
172 IMPORT_C CObexHeaderSet* CopyL();
173 IMPORT_C CObexHeaderSet* CopyL(MObexHeaderCheck& aHeaderCheck);
176 IMPORT_C TInt AddHeader(CObexHeader* aHeader);
177 IMPORT_C void DeleteCurrentHeader();
179 IMPORT_C void SetMask(MObexHeaderCheck* aMask);
180 IMPORT_C void DeleteMasked();
182 IMPORT_C void First() const;
183 IMPORT_C TInt This(CObexHeader* aHeader) const;
184 IMPORT_C TInt Next() const;
185 IMPORT_C TInt Next(TInt aSkip) const;
186 IMPORT_C TInt Count() const;
188 IMPORT_C TInt Find(TUint8 aHI, CObexHeader& aHeader) const;
194 RPointerArray<CObexHeader> iHeaders;
195 mutable MObexHeaderCheck* iMask;
203 NONSHARABLE_CLASS(TObexMatchHeader) : public MObexHeaderCheck
206 virtual EXPORT_C TBool Interested(TUint8 aHI);
207 IMPORT_C void SetHeader(TUint8 aHI);
213 // This data padding has been added to help prevent future binary compatibility breaks
214 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
223 NONSHARABLE_CLASS(TObexMatchHeaderType) : public MObexHeaderCheck
226 virtual EXPORT_C TBool Interested(TUint8 aHI);
227 IMPORT_C void SetType(CObexHeader::THeaderType aType);
233 // This data padding has been added to help prevent future binary compatibility breaks
234 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
239 #endif // __OBEXHEADERS_H