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