obex/obexprotocol/obextransport/public/obexinternalheader.h
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2005-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 __OBEXINTERNALHEADER_H__
       
    22 #define __OBEXINTERNALHEADER_H__
       
    23 
       
    24 #include <e32def.h>
       
    25 #include <e32cmn.h>
       
    26 #include <obex/internal/obexdata.h>
       
    27 
       
    28 // ########## Constant Data ##########
       
    29 
       
    30 const TUint8  KObexHeaderHILongSize		= 3;		// Unicode or Byte sequence
       
    31 const TUint8  KObexHeaderHIShortSize	= 1;		// Byte of 4 byte headers
       
    32 
       
    33 /**
       
    34 Two parts to headers: header IDs (HI) and header values (HV).
       
    35 There are some strange things going on in this class, due it sourcing data 
       
    36 (HV) from either obex or epoc, and having to then either stream it obex or 
       
    37 return it to epoc. Might be tidier having a finer class hierarcy, but the 
       
    38 implemented method does allow for complete generality.
       
    39 
       
    40 Partly due to this strangeness, this is only used internally.  There is also
       
    41 a CObexHeader class which is used for the external representation of a data
       
    42 header.
       
    43 @internalTechnology
       
    44 @see CObexHeader
       
    45 */
       
    46 NONSHARABLE_CLASS(TObexInternalHeader) : public TObexData
       
    47 
       
    48 	{
       
    49 public:
       
    50 	// Header specific types
       
    51 	typedef TUint8 THeaderID;
       
    52 	IMPORT_C enum THeaderType 
       
    53 		{ 
       
    54 		EUnicode = 0x00,
       
    55 		EByteSeq = 0x40,
       
    56 		E1Byte   = 0x80,
       
    57 		E4Byte   = 0xC0
       
    58 		};
       
    59 	
       
    60 	IMPORT_C enum TWellKnownHI
       
    61 		{
       
    62 		ECount				= 0x00 | E4Byte,
       
    63 		EName				= 0x01 | EUnicode,
       
    64 		EType				= 0x02 | EByteSeq,
       
    65 		ELength				= 0x03 | E4Byte,
       
    66 		ETime				= 0x04 | EByteSeq,
       
    67 		EDescription		= 0x05 | EUnicode,
       
    68 		ETarget				= 0x06 | EByteSeq,
       
    69 		EHttp				= 0x07 | EByteSeq,
       
    70 		EBody				= 0x08 | EByteSeq,
       
    71 		EEndOfBody			= 0x09 | EByteSeq,
       
    72 		EWho				= 0x0A | EByteSeq,
       
    73 		EConnectionID		= 0x0B | E4Byte,
       
    74 		EAppParam			= 0x0C | EByteSeq,
       
    75 		EAuthChallenge		= 0x0D | EByteSeq,
       
    76 		EAuthResponse		= 0x0E | EByteSeq,
       
    77 		ECreatorID			= 0x0F | E4Byte,
       
    78 		EWanUUID			= 0x10 | EByteSeq,
       
    79 		EObjectClass  		= 0x11 | EByteSeq
       
    80 		};
       
    81 	
       
    82 	IMPORT_C  enum THVRepresentation 
       
    83 		{ 
       
    84 		EHVObexDefault,
       
    85 		EHVMachineText,
       
    86 		EHVInt,
       
    87 		EHVDefered
       
    88 		};
       
    89 
       
    90 	IMPORT_C TObexInternalHeader ();
       
    91 
       
    92 	// Setters
       
    93 	IMPORT_C void SetHI (THeaderID aHID);
       
    94 	IMPORT_C void Set (THeaderID aHID, TInt aValue);
       
    95 	IMPORT_C void Set (THeaderID aHID, TUint8* aHV, TInt aHVSize);
       
    96 	IMPORT_C void Set (THeaderID aHID, const TDesC& aString);
       
    97 	IMPORT_C void SetDeferred (THeaderID aHID, TPtr8* aDataInserter, TInt aMinSize, TInt aMaxSize = 0);
       
    98 
       
    99     // Getters
       
   100 	IMPORT_C THeaderID HI () const;
       
   101 	IMPORT_C THeaderType HIType () const;
       
   102 	IMPORT_C TInt HVInt () const;
       
   103 	IMPORT_C TUint8* HVByteSeq () const;
       
   104 	IMPORT_C TInt GetHVText (TDes& aString) const;
       
   105 
       
   106 	IMPORT_C TUint16 HISize () const;
       
   107 	IMPORT_C TUint16 HVSize () const;
       
   108 	
       
   109 protected:
       
   110 	// Implementation of TObexData functions
       
   111 	TUint16 DoTotalSize () const;	// Total size of header
       
   112 	virtual TUint16 ParseIn (TUint8* aSource, const TUint16 aMaxSize);
       
   113 	virtual TUint16 WriteOut (TUint8* aDest, const TUint16 aMaxSize) const;
       
   114 
       
   115 private:
       
   116 	THeaderID	iHI;
       
   117 	union
       
   118 		{
       
   119 		TUint8*	iObex;
       
   120 		TText*	iMachine;
       
   121 		TInt	iInt;
       
   122 		TPtr8*  iDefered;
       
   123 		} iHV;
       
   124 	THVRepresentation		iHVRep;
       
   125 	TUint16		iHVSize;
       
   126 	TUint16		iHVMaxSize;		// Used for defered data entry
       
   127 	};	// TObexInternalHeader
       
   128 
       
   129 #endif // __OBEXINTERNALHEADER_H__