epoc32/include/mw/obexheaders.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/mw/obexheaders.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,241 @@
     1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// 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
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @publishedAll
    1.24 + @released
    1.25 +*/
    1.26 +
    1.27 +#ifndef __OBEXHEADERS_H
    1.28 +#define __OBEXHEADERS_H
    1.29 +
    1.30 +#include <obextypes.h>
    1.31 +
    1.32 +/**
    1.33 +Encapsulates an Obex header.
    1.34 +
    1.35 +This class provides the ability to hold a header of any of the Obex
    1.36 +supported types as a native Symbian OS type.
    1.37 +
    1.38 +A header may also have one or more attributes set.  These are used by
    1.39 +the object which owns the header collection so that it can keep track
    1.40 +of which headers should be sent (!(ESuppressed || EDeleted)), which have
    1.41 +been sent (ESent), and whether the header should be deleted (EDeleted).
    1.42 +Deletion is a special case---any operation on the Object which causes
    1.43 +a scan of the headers will trigger deletion of any marked headers.
    1.44 +This is required as they are owned by the Object, but can be accessed
    1.45 +seperately (including through the creator keeping a pointer to the
    1.46 +header).
    1.47 +
    1.48 +@see CObexBaseObject
    1.49 +@publishedAll
    1.50 +@released
    1.51 +*/
    1.52 +NONSHARABLE_CLASS(CObexHeader) : public CBase
    1.53 +	{
    1.54 +public:
    1.55 +	// Requires friendship with CObexBaseObject to support some aspects of the
    1.56 +	// legacy API (specifically the HTTP accessor method).
    1.57 +	friend class CObexBaseObject;
    1.58 +
    1.59 +	enum THeaderType
    1.60 +		{
    1.61 +		EUnicode  = 0x00,
    1.62 +		EByteSeq  = 0x01,
    1.63 +		EByte     = 0x02,
    1.64 +		EFourByte = 0x03
    1.65 +		};
    1.66 +	
    1.67 +	enum THeaderAttr
    1.68 +		{
    1.69 +		ESuppressed = 0x01,
    1.70 +		ESent       = 0x02,
    1.71 +		EDeleted    = 0x04,
    1.72 +		};
    1.73 +		
    1.74 +	IMPORT_C static CObexHeader* NewL();
    1.75 +	virtual ~CObexHeader();
    1.76 +	IMPORT_C CObexHeader* CopyL() const;
    1.77 +	
    1.78 +	//Sets this object to use the same underlying header as the parameter.
    1.79 +	IMPORT_C void Set(CObexHeader* aHeader);
    1.80 +	//Resets the contents of this header, discarding the underlying data.
    1.81 +	IMPORT_C void Reset();
    1.82 +	
    1.83 +	//Resets and destroys all header attributes.
    1.84 +	IMPORT_C void ResetContents();
    1.85 +	
    1.86 +	IMPORT_C void SetAttributes(TUint16 aAttr);
    1.87 +	IMPORT_C TUint16 Attributes() const;
    1.88 +	
    1.89 +	IMPORT_C THeaderType Type() const;
    1.90 +	
    1.91 +	IMPORT_C TUint8   HI() const;
    1.92 +	IMPORT_C TUint8   AsByte() const;
    1.93 +	IMPORT_C TUint32  AsFourByte() const;
    1.94 +	IMPORT_C const TDesC8&  AsByteSeq() const;
    1.95 +	IMPORT_C const TDesC16& AsUnicode() const;
    1.96 +
    1.97 +	IMPORT_C void SetByte(const TUint8 aHI, const TUint8 aByte);
    1.98 +	IMPORT_C void SetFourByte(const TUint8 aHI, const TUint32 aFourByte);
    1.99 +	IMPORT_C void SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq);
   1.100 +	IMPORT_C void SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode);
   1.101 +
   1.102 +	IMPORT_C TInt EncodedSize() const;
   1.103 +	
   1.104 +private:
   1.105 +	CObexHeader();
   1.106 +	CObexHeader(CObexUnderlyingHeader* aHeader);
   1.107 +	void ConstructL();
   1.108 +	
   1.109 +private:
   1.110 +	CObexUnderlyingHeader* iHeader;
   1.111 +	};
   1.112 +
   1.113 +/**
   1.114 +Used to allow the iterator to decide whether to present a header to
   1.115 +the user, by passing in a possible header HI value.  Headers present
   1.116 +in the object will be presented to the Interested() function in the 
   1.117 +object in which they are held (if received from a remote device
   1.118 +this will be the order in which they were received, otherwise this will
   1.119 +be the order in which they were set).
   1.120 +The function can implement any desired behaviour, including relying on
   1.121 +the order in which the headers are presented.
   1.122 +
   1.123 +In case any state is held, the object also provides a Reset() function.
   1.124 +Reset() provides a default empty implementation.
   1.125 +
   1.126 +Note: there is no destructor. 
   1.127 + 
   1.128 +@publishedAll
   1.129 +@released
   1.130 +*/
   1.131 +class MObexHeaderCheck 
   1.132 +	{
   1.133 +public:
   1.134 +	/**
   1.135 +	Called to discover is the user is interested in the contents of
   1.136 +	this header.
   1.137 +	
   1.138 +	@param aHI The identifier of the header, including type bits.
   1.139 +	@return ETrue if the user is interested in the contents of this
   1.140 +	header.
   1.141 +	@publishedAll
   1.142 +	@released
   1.143 +	*/
   1.144 +	IMPORT_C virtual TBool Interested(TUint8 aHI) =0;
   1.145 +	
   1.146 +	/**
   1.147 +	Called in response to First() being called on the iterator object.
   1.148 +	The default implementation does nothing---some implementations may
   1.149 +	wish to reset state variables.
   1.150 +	
   1.151 +	@publishedAll
   1.152 +	@released
   1.153 +	*/
   1.154 +	IMPORT_C virtual void Reset();
   1.155 +	
   1.156 +	/**
   1.157 + 	Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
   1.158 +	@param aInterface UID of the interface to return
   1.159 +	@param aObject the container for another interface as specified by aInterface
   1.160 +	@internalComponent
   1.161 +	*/
   1.162 +	IMPORT_C virtual void MOHC_ExtensionInterfaceL(TUid aInterface, void*& aObject);
   1.163 +	};
   1.164 +
   1.165 +/**
   1.166 +A collection of headers.  Includes code to filter based on the header HI
   1.167 +value, iterate through the set of interesting headers, and extract headers
   1.168 +with specific HI values.
   1.169 + 
   1.170 +@publishedAll
   1.171 +@released
   1.172 +*/
   1.173 +NONSHARABLE_CLASS(CObexHeaderSet) : public CBase
   1.174 +	{
   1.175 +public:
   1.176 +	IMPORT_C static CObexHeaderSet* NewL();
   1.177 +	IMPORT_C CObexHeaderSet* CopyL();
   1.178 +	IMPORT_C CObexHeaderSet* CopyL(MObexHeaderCheck& aHeaderCheck);
   1.179 +	~CObexHeaderSet();
   1.180 +
   1.181 +	IMPORT_C TInt AddHeader(CObexHeader* aHeader);
   1.182 +	IMPORT_C void DeleteCurrentHeader();
   1.183 +
   1.184 +	IMPORT_C void SetMask(MObexHeaderCheck* aMask);
   1.185 +	IMPORT_C void DeleteMasked();
   1.186 +	
   1.187 +	IMPORT_C void First() const;
   1.188 +	IMPORT_C TInt This(CObexHeader* aHeader) const;
   1.189 +	IMPORT_C TInt Next() const;
   1.190 +	IMPORT_C TInt Next(TInt aSkip) const;
   1.191 +	IMPORT_C TInt Count() const;
   1.192 +	
   1.193 +	IMPORT_C TInt Find(TUint8 aHI, CObexHeader& aHeader) const;
   1.194 +	
   1.195 +private:
   1.196 +	CObexHeaderSet();
   1.197 +
   1.198 +private:
   1.199 +	RPointerArray<CObexHeader> iHeaders;
   1.200 +	mutable MObexHeaderCheck* iMask;
   1.201 +	mutable TInt iPos;
   1.202 +	};
   1.203 +
   1.204 +/** 
   1.205 +@publishedAll
   1.206 +@released
   1.207 +*/
   1.208 +NONSHARABLE_CLASS(TObexMatchHeader) : public MObexHeaderCheck
   1.209 +	{
   1.210 +public:
   1.211 +	virtual EXPORT_C TBool Interested(TUint8 aHI);
   1.212 +	IMPORT_C void SetHeader(TUint8 aHI);
   1.213 +
   1.214 +private:
   1.215 +	TUint8 iHI;
   1.216 +	
   1.217 +private:
   1.218 +	// This data padding has been added to help prevent future binary compatibility breaks	
   1.219 +	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
   1.220 +	TUint32     iPadding1; 
   1.221 +	TUint32     iPadding2; 	
   1.222 +	};
   1.223 +
   1.224 +/** 
   1.225 +@publishedAll
   1.226 +@released
   1.227 +*/
   1.228 +NONSHARABLE_CLASS(TObexMatchHeaderType) : public MObexHeaderCheck
   1.229 +{
   1.230 +public:
   1.231 +	virtual EXPORT_C TBool Interested(TUint8 aHI);
   1.232 +	IMPORT_C void SetType(CObexHeader::THeaderType aType);
   1.233 +
   1.234 +private:
   1.235 +	TInt iType;
   1.236 +
   1.237 +private:
   1.238 +	// This data padding has been added to help prevent future binary compatibility breaks	
   1.239 +	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
   1.240 +	TUint32     iPadding1; 
   1.241 +	TUint32     iPadding2; 	
   1.242 +	};
   1.243 +
   1.244 +#endif // __OBEXHEADERS_H