obex/obexprotocol/obex/inc/obexunderlyingheader.h
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     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  @internalComponent
       
    19 */
       
    20 
       
    21 #ifndef __OBEXUNDERLYINGHEADER_H
       
    22 #define __OBEXUNDERLYINGHEADER_H
       
    23 
       
    24 #include <obextypes.h>
       
    25 #include <obexheaders.h>
       
    26 
       
    27 /**
       
    28 Implements reference counting.
       
    29 
       
    30 @internalComponent
       
    31 */
       
    32 NONSHARABLE_CLASS(CRefCounted) : public CBase
       
    33 	{
       
    34 public:
       
    35 	CRefCounted();
       
    36 	virtual ~CRefCounted();
       
    37 	void Open() const;
       
    38 	void Close() const;
       
    39 
       
    40 private:
       
    41 	mutable TInt iCount;
       
    42 	};
       
    43 	
       
    44 /**
       
    45 Encapsulates an Obex header.
       
    46 
       
    47 This class provides the ability to hold a header of any of the Obex
       
    48 supported types as a native Symbian OS type.
       
    49 
       
    50 A header may also have one or more attributes set.  These are used by
       
    51 the object which owns the header collection so that it can keep track
       
    52 of which headers should be sent (!(ESuppressed || EDeleted)), which have
       
    53 been sent (ESent), and whether the header should be deleted (EDeleted).
       
    54 
       
    55 This is a reference counted object and should not be used directly.
       
    56 Instead the CObexHeader object provides a facade which not only allows
       
    57 the CRefCounted nature of this class to be concealed, but also
       
    58 allows header objects to be deleted normally, which decrements the
       
    59 count.  Ultimately the count will reach zero, at which point this header
       
    60 object will be destroyed.
       
    61 
       
    62 @see CObexBaseObject 
       
    63 @see CObexHeader
       
    64 @internalComponent
       
    65 */
       
    66 NONSHARABLE_CLASS(CObexUnderlyingHeader) : public CRefCounted
       
    67 	{
       
    68 public:
       
    69 	static CObexUnderlyingHeader* NewL();
       
    70 	virtual ~CObexUnderlyingHeader();
       
    71 	
       
    72 	void ResetContents();
       
    73 	void SetAttributes(TUint16 aAttr);
       
    74 	TUint16 Attributes() const;
       
    75 	
       
    76 	CObexHeader::THeaderType Type() const;
       
    77 	
       
    78 	TUint8   HI() const;
       
    79 	TUint8   AsByte() const;
       
    80 	TUint32  AsFourByte() const;
       
    81 	const TDesC8&  AsByteSeq() const;
       
    82 	const TDesC16& AsUnicode() const;
       
    83 
       
    84 	void SetByte(const TUint8 aHI, const TUint8 aByte);
       
    85 	void SetFourByte(const TUint8 aHI, const TUint32 aFourByte);
       
    86 	void SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq);
       
    87 	void SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode);
       
    88 	
       
    89 	TInt EncodedSize() const;
       
    90 	
       
    91 private:
       
    92 	CObexUnderlyingHeader();
       
    93 
       
    94 private:
       
    95 	TUint16 iAttributes;
       
    96 	TUint8 iHI;
       
    97 
       
    98 	union
       
    99 		{
       
   100 		TUint8   iByte;
       
   101 		TUint32  iFourByte;
       
   102 		HBufC8*  iByteSeq;
       
   103 		HBufC16* iUnicode;
       
   104 		} iHV;
       
   105 	};
       
   106 
       
   107 #endif // __OBEXUNDERLYINGHEADER_H