williamr@2: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: /** williamr@2: @file williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: williamr@2: #ifndef __OBEXHEADERS_H williamr@2: #define __OBEXHEADERS_H williamr@2: williamr@2: #include williamr@2: williamr@2: /** williamr@2: Encapsulates an Obex header. williamr@2: williamr@2: This class provides the ability to hold a header of any of the Obex williamr@2: supported types as a native Symbian OS type. williamr@2: williamr@2: A header may also have one or more attributes set. These are used by williamr@2: the object which owns the header collection so that it can keep track williamr@2: of which headers should be sent (!(ESuppressed || EDeleted)), which have williamr@2: been sent (ESent), and whether the header should be deleted (EDeleted). williamr@2: Deletion is a special case---any operation on the Object which causes williamr@2: a scan of the headers will trigger deletion of any marked headers. williamr@2: This is required as they are owned by the Object, but can be accessed williamr@2: seperately (including through the creator keeping a pointer to the williamr@2: header). williamr@2: williamr@2: @see CObexBaseObject williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: NONSHARABLE_CLASS(CObexHeader) : public CBase williamr@2: { williamr@2: public: williamr@2: // Requires friendship with CObexBaseObject to support some aspects of the williamr@2: // legacy API (specifically the HTTP accessor method). williamr@2: friend class CObexBaseObject; williamr@2: williamr@2: enum THeaderType williamr@2: { williamr@2: EUnicode = 0x00, williamr@2: EByteSeq = 0x01, williamr@2: EByte = 0x02, williamr@2: EFourByte = 0x03 williamr@2: }; williamr@2: williamr@2: enum THeaderAttr williamr@2: { williamr@2: ESuppressed = 0x01, williamr@2: ESent = 0x02, williamr@2: EDeleted = 0x04, williamr@2: }; williamr@2: williamr@2: IMPORT_C static CObexHeader* NewL(); williamr@2: virtual ~CObexHeader(); williamr@2: IMPORT_C CObexHeader* CopyL() const; williamr@2: williamr@2: //Sets this object to use the same underlying header as the parameter. williamr@2: IMPORT_C void Set(CObexHeader* aHeader); williamr@2: //Resets the contents of this header, discarding the underlying data. williamr@2: IMPORT_C void Reset(); williamr@2: williamr@2: //Resets and destroys all header attributes. williamr@2: IMPORT_C void ResetContents(); williamr@2: williamr@2: IMPORT_C void SetAttributes(TUint16 aAttr); williamr@2: IMPORT_C TUint16 Attributes() const; williamr@2: williamr@2: IMPORT_C THeaderType Type() const; williamr@2: williamr@2: IMPORT_C TUint8 HI() const; williamr@2: IMPORT_C TUint8 AsByte() const; williamr@2: IMPORT_C TUint32 AsFourByte() const; williamr@2: IMPORT_C const TDesC8& AsByteSeq() const; williamr@2: IMPORT_C const TDesC16& AsUnicode() const; williamr@2: williamr@2: IMPORT_C void SetByte(const TUint8 aHI, const TUint8 aByte); williamr@2: IMPORT_C void SetFourByte(const TUint8 aHI, const TUint32 aFourByte); williamr@2: IMPORT_C void SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq); williamr@2: IMPORT_C void SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode); williamr@2: williamr@2: IMPORT_C TInt EncodedSize() const; williamr@2: williamr@2: private: williamr@2: CObexHeader(); williamr@2: CObexHeader(CObexUnderlyingHeader* aHeader); williamr@2: void ConstructL(); williamr@2: williamr@2: private: williamr@2: CObexUnderlyingHeader* iHeader; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Used to allow the iterator to decide whether to present a header to williamr@2: the user, by passing in a possible header HI value. Headers present williamr@2: in the object will be presented to the Interested() function in the williamr@2: object in which they are held (if received from a remote device williamr@2: this will be the order in which they were received, otherwise this will williamr@2: be the order in which they were set). williamr@2: The function can implement any desired behaviour, including relying on williamr@2: the order in which the headers are presented. williamr@2: williamr@2: In case any state is held, the object also provides a Reset() function. williamr@2: Reset() provides a default empty implementation. williamr@2: williamr@2: Note: there is no destructor. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class MObexHeaderCheck williamr@2: { williamr@2: public: williamr@2: /** williamr@2: Called to discover is the user is interested in the contents of williamr@2: this header. williamr@2: williamr@2: @param aHI The identifier of the header, including type bits. williamr@2: @return ETrue if the user is interested in the contents of this williamr@2: header. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: IMPORT_C virtual TBool Interested(TUint8 aHI) =0; williamr@2: williamr@2: /** williamr@2: Called in response to First() being called on the iterator object. williamr@2: The default implementation does nothing---some implementations may williamr@2: wish to reset state variables. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: IMPORT_C virtual void Reset(); williamr@2: williamr@2: /** williamr@2: Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is. williamr@2: @param aInterface UID of the interface to return williamr@2: @param aObject the container for another interface as specified by aInterface williamr@4: @publishedAll williamr@2: */ williamr@2: IMPORT_C virtual void MOHC_ExtensionInterfaceL(TUid aInterface, void*& aObject); williamr@2: }; williamr@2: williamr@2: /** williamr@2: A collection of headers. Includes code to filter based on the header HI williamr@2: value, iterate through the set of interesting headers, and extract headers williamr@2: with specific HI values. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: NONSHARABLE_CLASS(CObexHeaderSet) : public CBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CObexHeaderSet* NewL(); williamr@2: IMPORT_C CObexHeaderSet* CopyL(); williamr@2: IMPORT_C CObexHeaderSet* CopyL(MObexHeaderCheck& aHeaderCheck); williamr@2: ~CObexHeaderSet(); williamr@2: williamr@2: IMPORT_C TInt AddHeader(CObexHeader* aHeader); williamr@2: IMPORT_C void DeleteCurrentHeader(); williamr@2: williamr@2: IMPORT_C void SetMask(MObexHeaderCheck* aMask); williamr@2: IMPORT_C void DeleteMasked(); williamr@2: williamr@2: IMPORT_C void First() const; williamr@2: IMPORT_C TInt This(CObexHeader* aHeader) const; williamr@2: IMPORT_C TInt Next() const; williamr@2: IMPORT_C TInt Next(TInt aSkip) const; williamr@2: IMPORT_C TInt Count() const; williamr@2: williamr@2: IMPORT_C TInt Find(TUint8 aHI, CObexHeader& aHeader) const; williamr@2: williamr@2: private: williamr@2: CObexHeaderSet(); williamr@2: williamr@2: private: williamr@2: RPointerArray iHeaders; williamr@2: mutable MObexHeaderCheck* iMask; williamr@2: mutable TInt iPos; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: NONSHARABLE_CLASS(TObexMatchHeader) : public MObexHeaderCheck williamr@2: { williamr@2: public: williamr@2: virtual EXPORT_C TBool Interested(TUint8 aHI); williamr@2: IMPORT_C void SetHeader(TUint8 aHI); williamr@2: williamr@2: private: williamr@2: TUint8 iHI; williamr@2: williamr@2: private: williamr@2: // This data padding has been added to help prevent future binary compatibility breaks williamr@2: // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used williamr@2: TUint32 iPadding1; williamr@2: TUint32 iPadding2; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: NONSHARABLE_CLASS(TObexMatchHeaderType) : public MObexHeaderCheck williamr@2: { williamr@2: public: williamr@2: virtual EXPORT_C TBool Interested(TUint8 aHI); williamr@2: IMPORT_C void SetType(CObexHeader::THeaderType aType); williamr@2: williamr@2: private: williamr@2: TInt iType; williamr@2: williamr@2: private: williamr@2: // This data padding has been added to help prevent future binary compatibility breaks williamr@2: // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used williamr@2: TUint32 iPadding1; williamr@2: TUint32 iPadding2; williamr@2: }; williamr@2: williamr@2: #endif // __OBEXHEADERS_H