obex/obexprotocol/obex/public/obexheaders.h
changeset 54 4dc88a4ac6f4
parent 52 866b4af7ffbe
child 57 f6055a57ae18
equal deleted inserted replaced
52:866b4af7ffbe 54:4dc88a4ac6f4
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @publishedAll
       
    19  @released
       
    20 */
       
    21 
       
    22 #ifndef __OBEXHEADERS_H
       
    23 #define __OBEXHEADERS_H
       
    24 
       
    25 #include <obextypes.h>
       
    26 
       
    27 /**
       
    28 Encapsulates an Obex header.
       
    29 
       
    30 This class provides the ability to hold a header of any of the Obex
       
    31 supported types as a native Symbian OS type.
       
    32 
       
    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
       
    41 header).
       
    42 
       
    43 @see CObexBaseObject
       
    44 @publishedAll
       
    45 @released
       
    46 */
       
    47 NONSHARABLE_CLASS(CObexHeader) : public CBase
       
    48 	{
       
    49 public:
       
    50 	// Requires friendship with CObexBaseObject to support some aspects of the
       
    51 	// legacy API (specifically the HTTP accessor method).
       
    52 	friend class CObexBaseObject;
       
    53 
       
    54 	enum THeaderType
       
    55 		{
       
    56 		EUnicode  = 0x00,
       
    57 		EByteSeq  = 0x01,
       
    58 		EByte     = 0x02,
       
    59 		EFourByte = 0x03
       
    60 		};
       
    61 	
       
    62 	enum THeaderAttr
       
    63 		{
       
    64 		ESuppressed = 0x01,
       
    65 		ESent       = 0x02,
       
    66 		EDeleted    = 0x04,
       
    67 		};
       
    68 		
       
    69 	IMPORT_C static CObexHeader* NewL();
       
    70 	virtual ~CObexHeader();
       
    71 	IMPORT_C CObexHeader* CopyL() const;
       
    72 	
       
    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();
       
    77 	
       
    78 	//Resets and destroys all header attributes.
       
    79 	IMPORT_C void ResetContents();
       
    80 	
       
    81 	IMPORT_C void SetAttributes(TUint16 aAttr);
       
    82 	IMPORT_C TUint16 Attributes() const;
       
    83 	
       
    84 	IMPORT_C THeaderType Type() const;
       
    85 	
       
    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;
       
    91 
       
    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);
       
    96 
       
    97 	IMPORT_C TInt EncodedSize() const;
       
    98 	
       
    99 private:
       
   100 	CObexHeader();
       
   101 	CObexHeader(CObexUnderlyingHeader* aHeader);
       
   102 	void ConstructL();
       
   103 	
       
   104 private:
       
   105 	CObexUnderlyingHeader* iHeader;
       
   106 	};
       
   107 
       
   108 /**
       
   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.
       
   117 
       
   118 In case any state is held, the object also provides a Reset() function.
       
   119 Reset() provides a default empty implementation.
       
   120 
       
   121 Note: there is no destructor. 
       
   122  
       
   123 @publishedAll
       
   124 @released
       
   125 */
       
   126 class MObexHeaderCheck 
       
   127 	{
       
   128 public:
       
   129 	/**
       
   130 	Called to discover is the user is interested in the contents of
       
   131 	this header.
       
   132 	
       
   133 	@param aHI The identifier of the header, including type bits.
       
   134 	@return ETrue if the user is interested in the contents of this
       
   135 	header.
       
   136 	@publishedAll
       
   137 	@released
       
   138 	*/
       
   139 	IMPORT_C virtual TBool Interested(TUint8 aHI) =0;
       
   140 	
       
   141 	/**
       
   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.
       
   145 	
       
   146 	@publishedAll
       
   147 	@released
       
   148 	*/
       
   149 	IMPORT_C virtual void Reset();
       
   150 	
       
   151 	/**
       
   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
       
   155 	@publishedAll
       
   156 	*/
       
   157 	IMPORT_C virtual void MOHC_ExtensionInterfaceL(TUid aInterface, void*& aObject);
       
   158 	};
       
   159 
       
   160 /**
       
   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.
       
   164  
       
   165 @publishedAll
       
   166 @released
       
   167 */
       
   168 NONSHARABLE_CLASS(CObexHeaderSet) : public CBase
       
   169 	{
       
   170 public:
       
   171 	IMPORT_C static CObexHeaderSet* NewL();
       
   172 	IMPORT_C CObexHeaderSet* CopyL();
       
   173 	IMPORT_C CObexHeaderSet* CopyL(MObexHeaderCheck& aHeaderCheck);
       
   174 	~CObexHeaderSet();
       
   175 
       
   176 	IMPORT_C TInt AddHeader(CObexHeader* aHeader);
       
   177 	IMPORT_C void DeleteCurrentHeader();
       
   178 
       
   179 	IMPORT_C void SetMask(MObexHeaderCheck* aMask);
       
   180 	IMPORT_C void DeleteMasked();
       
   181 	
       
   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;
       
   187 	
       
   188 	IMPORT_C TInt Find(TUint8 aHI, CObexHeader& aHeader) const;
       
   189 	
       
   190 private:
       
   191 	CObexHeaderSet();
       
   192 
       
   193 private:
       
   194 	RPointerArray<CObexHeader> iHeaders;
       
   195 	mutable MObexHeaderCheck* iMask;
       
   196 	mutable TInt iPos;
       
   197 	};
       
   198 
       
   199 /** 
       
   200 @publishedAll
       
   201 @released
       
   202 */
       
   203 NONSHARABLE_CLASS(TObexMatchHeader) : public MObexHeaderCheck
       
   204 	{
       
   205 public:
       
   206 	virtual EXPORT_C TBool Interested(TUint8 aHI);
       
   207 	IMPORT_C void SetHeader(TUint8 aHI);
       
   208 
       
   209 private:
       
   210 	TUint8 iHI;
       
   211 	
       
   212 private:
       
   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
       
   215 	TUint32     iPadding1; 
       
   216 	TUint32     iPadding2; 	
       
   217 	};
       
   218 
       
   219 /** 
       
   220 @publishedAll
       
   221 @released
       
   222 */
       
   223 NONSHARABLE_CLASS(TObexMatchHeaderType) : public MObexHeaderCheck
       
   224 {
       
   225 public:
       
   226 	virtual EXPORT_C TBool Interested(TUint8 aHI);
       
   227 	IMPORT_C void SetType(CObexHeader::THeaderType aType);
       
   228 
       
   229 private:
       
   230 	TInt iType;
       
   231 
       
   232 private:
       
   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
       
   235 	TUint32     iPadding1; 
       
   236 	TUint32     iPadding2; 	
       
   237 	};
       
   238 
       
   239 #endif // __OBEXHEADERS_H