smsprotocols/smsstack/wapprot/Inc/wapthdr.h
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     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 // Contains the header file of the TWapTextMessage.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalAll
       
    21 */
       
    22 
       
    23 #if !defined (WAPTHDR_H__)
       
    24 #define WAPTHDR_H__
       
    25 
       
    26 #include <e32base.h>
       
    27 
       
    28 /**
       
    29  *  @internalComponent
       
    30  */
       
    31 const TInt KMaxSmsChars = 160;  //< maximum number of characters in one SMS PDU
       
    32 
       
    33 
       
    34 /**
       
    35  *  TWapTextMessage encodes and decodes 7-bit WAP text headers
       
    36  *  @internalComponent
       
    37  */
       
    38 class TWapTextMessage
       
    39 	{
       
    40 public:
       
    41 	TWapTextMessage(const TDesC8& aWAPMessage);
       
    42 	TBool Parse();
       
    43     void EncodeSegmentsL(CArrayPtr<HBufC8>& aSegmentArray);
       
    44 	inline TInt DestinationPort(TBool* aIs16Bit=NULL) const;
       
    45 	inline void SetDestinationPort(TInt aToPort, TBool aIs16Bit=EFalse);
       
    46 	inline TInt SourcePort(TBool* aIs16Bit=NULL) const;
       
    47 	inline void SetSourcePort(TInt aFromPort, TBool aIs16Bit=EFalse);
       
    48 	inline TInt ReferenceNumber() const;
       
    49 	inline void SetReferenceNumber(const TInt aReference);
       
    50 	inline TInt TotalSegments() const;
       
    51 	inline TInt SegmentNumber() const;
       
    52 	inline void OtherHeader(TDes8& aOtherHeader) const;
       
    53 	inline void SetOtherHeader(const TDesC8& aOtherHeader);
       
    54 	inline void UserData(TDes8& aWAPUserData) const;
       
    55 	inline void SetUserData(const TDesC8& aWAPUserData);
       
    56 	static TInt ParseNumber(const TDesC8& aInValue, TBool aBigEndian, TInt aRadix);
       
    57 
       
    58 private:
       
    59 	enum TElemIndexes
       
    60 	{
       
    61 		KIndexDestinationPort = 0,
       
    62 		KIndexSourcePort,
       
    63 		KIndexReferenceNumber,
       
    64 		KIndexTotalSegments,
       
    65 		KIndexSegmentNumber,
       
    66 		KIndexOtherHeader
       
    67 	};
       
    68 
       
    69 	enum
       
    70 	{
       
    71 		KElemIndexCount = 6,
       
    72 	};
       
    73 
       
    74 	// Made following public because of easy access
       
    75 	// for bith segmenting and reassembly
       
    76 	static const TInt KHeaderCount;
       
    77 
       
    78 	typedef TInt IndexValues[KElemIndexCount];
       
    79 
       
    80 	struct TIndexInfo
       
    81 		{
       
    82 		TInt           iLastIndex;
       
    83 		IndexValues    iIndexes;
       
    84 		};
       
    85 
       
    86 	static const TIndexInfo KElemIndexes[];
       
    87 
       
    88 	TBool ParseWapTextHeader(const TIndexInfo& IndexArray);
       
    89 	TInt CreateHeader(TDes8& aFixedHeader, TInt& aSegmentNumberIndex);
       
    90 	TInt CalculateTotalSegments(TInt aFixedLength);
       
    91 
       
    92 	// Incoming only
       
    93 	TBool      iIsWapTextMessage;
       
    94 	TPtrC8     iWAPMessage;
       
    95 
       
    96 	// header elements
       
    97 	TBool      iIs16Bit;
       
    98 	// constructor initialises the port values to (-1)
       
    99 	TInt       iDestinationPort;
       
   100 	TInt       iSourcePort;
       
   101 	TInt       iReference;
       
   102 	TInt       iTotalSegments;
       
   103 	TInt       iSegmentNumber;
       
   104 
       
   105 	// Incoming only: about other header and data
       
   106 	TInt       iOtherHeader;   // index
       
   107 	TInt       iOtherHeaderLength;
       
   108 	TInt       iData;          // index
       
   109 	TInt       iDataLength;
       
   110 
       
   111 	// Outgoing only
       
   112 	TPtrC8     iRefOtherHeader;
       
   113 	TPtrC8     iRefData;
       
   114 	};
       
   115 
       
   116 
       
   117 #include "wapthdr.inl"
       
   118 
       
   119 #endif // !defined WAPTHDR_H__