obex/obexprotocol/obextransport/public/obexpacket.h
changeset 57 f6055a57ae18
parent 0 d0791faffa3f
equal deleted inserted replaced
54:4dc88a4ac6f4 57:f6055a57ae18
       
     1 // Copyright (c) 1997-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  @internalTechnology
       
    19 */
       
    20 
       
    21 #ifndef __OBEXPACKET_H__
       
    22 #define __OBEXPACKET_H__
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <obex/internal/obexinternalconstants.h>
       
    26 #include <obex/internal/obextransportconstants.h>
       
    27 #include <obextypes.h>
       
    28 
       
    29 class TObexData;
       
    30 
       
    31 /**	
       
    32 Packets, which are the basic unit transfered between CObex and the transport
       
    33 @internalTechnology
       
    34 */ 
       
    35 NONSHARABLE_CLASS(CObexPacket) : public CBase
       
    36 	{
       
    37 friend class CObexActiveRW;
       
    38 
       
    39 public:
       
    40 	IMPORT_C ~CObexPacket ();
       
    41 	IMPORT_C static CObexPacket* NewL (TUint16 aBufferSize, TUint16 aDataLimit);
       
    42 													  
       
    43 	// Functions to set packet data
       
    44 	IMPORT_C void Init (TObexOpcode aOpcode);
       
    45 	
       
    46 	IMPORT_C TObexOpcode Opcode () const;
       
    47 	IMPORT_C void SetOpcode (TObexOpcode aOpcode);
       
    48 
       
    49 	IMPORT_C TBool IsFinal () const;
       
    50 	IMPORT_C void SetFinal (TBool aFinal = ETrue);
       
    51 	
       
    52 	// Get/Set the current packet size
       
    53 	// These refer size encoded in the OBEX packet itself (not the buffer used to contain the packet)
       
    54     	IMPORT_C TUint16 PacketSize () const;
       
    55 	IMPORT_C void SetPacketSize (TUint16 aSize);
       
    56 
       
    57 	// Get/Set the buffer size/data limit
       
    58 	IMPORT_C TUint16 SetLegalDataLimit (TUint16 aSize);
       
    59 	IMPORT_C TUint16 DataLimit () const; 
       
    60 	IMPORT_C TUint16 BufferSize () const;
       
    61 
       
    62 	// Setters & Getters, payload
       
    63 	IMPORT_C TBool InsertData (const TObexData& aHeader);
       
    64 	IMPORT_C TBool ExtractData (TObexData& aHeader);
       
    65 	IMPORT_C TUint16 RemainingInsertSpace () const;
       
    66 	IMPORT_C TUint16 RemainingExtractSpace () const;
       
    67 	IMPORT_C void AddPacketProcessEvents(TObexPacketProcessEvents aEvents);
       
    68 	IMPORT_C void RemovePacketProcessEvents(TObexPacketProcessEvents aEvents);
       
    69 	IMPORT_C TObexPacketProcessEvents PacketProcessNotificationEvents() const;
       
    70 	IMPORT_C void Dump() const;
       
    71 
       
    72 private:
       
    73 	CObexPacket (TUint16 aBufferSize, TUint16 aDataLimit);
       
    74 	void ConstructL ();
       
    75 
       
    76 	inline const TUint8* Payload () const {return (&iBuffer[KObexPacketHeaderSize]);};
       
    77 	inline TUint8* Payload () {return (&iBuffer[KObexPacketHeaderSize]);};
       
    78 	inline TUint16 PayloadSize () const {return (STATIC_CAST(TUint16, PacketSize () - KObexPacketHeaderSize));};
       
    79 
       
    80 
       
    81 // Data
       
    82 private:
       
    83 	TUint16 iBufferSize;	// how big the buffer actually is
       
    84 	TUint16 iDataLimit;		// how large the data can be (usually set per conenction)
       
    85 	TUint8* iInsertPoint;
       
    86 	TUint8* iExtractPoint;
       
    87 	TUint8* iBuffer;
       
    88 	TObexPacketProcessEvents iNotificationEvents;
       
    89 	};	// CObexPacket
       
    90 	
       
    91 #endif // __OBEXPACKET_H__