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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 #ifndef __OBEXHEADERS_H
25 #define __OBEXHEADERS_H
27 #include <obextypes.h>
30 Encapsulates an Obex header.
32 This class provides the ability to hold a header of any of the Obex
33 supported types as a native Symbian OS type.
35 A header may also have one or more attributes set. These are used by
36 the object which owns the header collection so that it can keep track
37 of which headers should be sent (!(ESuppressed || EDeleted)), which have
38 been sent (ESent), and whether the header should be deleted (EDeleted).
39 Deletion is a special case---any operation on the Object which causes
40 a scan of the headers will trigger deletion of any marked headers.
41 This is required as they are owned by the Object, but can be accessed
42 seperately (including through the creator keeping a pointer to the
49 NONSHARABLE_CLASS(CObexHeader) : public CBase
52 // Requires friendship with CObexBaseObject to support some aspects of the
53 // legacy API (specifically the HTTP accessor method).
54 friend class CObexBaseObject;
71 IMPORT_C static CObexHeader* NewL();
72 virtual ~CObexHeader();
73 IMPORT_C CObexHeader* CopyL() const;
75 //Sets this object to use the same underlying header as the parameter.
76 IMPORT_C void Set(CObexHeader* aHeader);
77 //Resets the contents of this header, discarding the underlying data.
78 IMPORT_C void Reset();
80 //Resets and destroys all header attributes.
81 IMPORT_C void ResetContents();
83 IMPORT_C void SetAttributes(TUint16 aAttr);
84 IMPORT_C TUint16 Attributes() const;
86 IMPORT_C THeaderType Type() const;
88 IMPORT_C TUint8 HI() const;
89 IMPORT_C TUint8 AsByte() const;
90 IMPORT_C TUint32 AsFourByte() const;
91 IMPORT_C const TDesC8& AsByteSeq() const;
92 IMPORT_C const TDesC16& AsUnicode() const;
94 IMPORT_C void SetByte(const TUint8 aHI, const TUint8 aByte);
95 IMPORT_C void SetFourByte(const TUint8 aHI, const TUint32 aFourByte);
96 IMPORT_C void SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq);
97 IMPORT_C void SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode);
99 IMPORT_C TInt EncodedSize() const;
103 CObexHeader(CObexUnderlyingHeader* aHeader);
107 CObexUnderlyingHeader* iHeader;
111 Used to allow the iterator to decide whether to present a header to
112 the user, by passing in a possible header HI value. Headers present
113 in the object will be presented to the Interested() function in the
114 object in which they are held (if received from a remote device
115 this will be the order in which they were received, otherwise this will
116 be the order in which they were set).
117 The function can implement any desired behaviour, including relying on
118 the order in which the headers are presented.
120 In case any state is held, the object also provides a Reset() function.
121 Reset() provides a default empty implementation.
123 Note: there is no destructor.
128 class MObexHeaderCheck
132 Called to discover is the user is interested in the contents of
135 @param aHI The identifier of the header, including type bits.
136 @return ETrue if the user is interested in the contents of this
141 IMPORT_C virtual TBool Interested(TUint8 aHI) =0;
144 Called in response to First() being called on the iterator object.
145 The default implementation does nothing---some implementations may
146 wish to reset state variables.
151 IMPORT_C virtual void Reset();
154 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
155 @param aInterface UID of the interface to return
156 @param aObject the container for another interface as specified by aInterface
159 IMPORT_C virtual void MOHC_ExtensionInterfaceL(TUid aInterface, void*& aObject);
163 A collection of headers. Includes code to filter based on the header HI
164 value, iterate through the set of interesting headers, and extract headers
165 with specific HI values.
170 NONSHARABLE_CLASS(CObexHeaderSet) : public CBase
173 IMPORT_C static CObexHeaderSet* NewL();
174 IMPORT_C CObexHeaderSet* CopyL();
175 IMPORT_C CObexHeaderSet* CopyL(MObexHeaderCheck& aHeaderCheck);
178 IMPORT_C TInt AddHeader(CObexHeader* aHeader);
179 IMPORT_C void DeleteCurrentHeader();
181 IMPORT_C void SetMask(MObexHeaderCheck* aMask);
182 IMPORT_C void DeleteMasked();
184 IMPORT_C void First() const;
185 IMPORT_C TInt This(CObexHeader* aHeader) const;
186 IMPORT_C TInt Next() const;
187 IMPORT_C TInt Next(TInt aSkip) const;
188 IMPORT_C TInt Count() const;
190 IMPORT_C TInt Find(TUint8 aHI, CObexHeader& aHeader) const;
196 RPointerArray<CObexHeader> iHeaders;
197 mutable MObexHeaderCheck* iMask;
205 NONSHARABLE_CLASS(TObexMatchHeader) : public MObexHeaderCheck
208 virtual EXPORT_C TBool Interested(TUint8 aHI);
209 IMPORT_C void SetHeader(TUint8 aHI);
215 // This data padding has been added to help prevent future binary compatibility breaks
216 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
225 NONSHARABLE_CLASS(TObexMatchHeaderType) : public MObexHeaderCheck
228 virtual EXPORT_C TBool Interested(TUint8 aHI);
229 IMPORT_C void SetType(CObexHeader::THeaderType aType);
235 // This data padding has been added to help prevent future binary compatibility breaks
236 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
241 #endif // __OBEXHEADERS_H