smsprotocols/smsstack/wapprot/Inc/wapthdr.inl
changeset 0 3553901f7fa8
child 14 7ef16719d8cb
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 // This file contains the inline methods of TWapTextMessage.
       
    15 // TWapTextMessage encodes and decodes 7-bit WAP text headers
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalAll
       
    22 */
       
    23 
       
    24 #include "wapmain.h"
       
    25 
       
    26 
       
    27 /**
       
    28  *  return the destination port of this WAP message
       
    29  *  
       
    30  *  @param aIs16Bit Pointer. If true on return, destination port is 16 bits
       
    31  *  @return the destination port
       
    32  */
       
    33 inline TInt TWapTextMessage::DestinationPort(TBool* aIs16Bit) const
       
    34     {
       
    35     __ASSERT_DEBUG(iIsWapTextMessage, Panic(KPanicTextHeaderNotTextHeader));
       
    36     if (aIs16Bit)
       
    37         *aIs16Bit = iIs16Bit;
       
    38     return iDestinationPort;
       
    39     }
       
    40 
       
    41 
       
    42 /**
       
    43  *  set the destination port of this WAP message
       
    44  *  
       
    45  *  @param aToPort Destination port
       
    46  *  @param aIs16Bit TRUE if the dest port is a 16-bit value
       
    47  */
       
    48 inline void TWapTextMessage::SetDestinationPort(const TInt aToPort, const TBool aIs16Bit)
       
    49     {
       
    50     iDestinationPort = aToPort;
       
    51     // Don't override a true value
       
    52     if (!iIs16Bit)
       
    53         iIs16Bit = aIs16Bit;
       
    54     }
       
    55 
       
    56 
       
    57 /**
       
    58  *  Return the source port of this WAP message
       
    59  *  if not present, value of destination port is returned
       
    60  *  
       
    61  *  @param aIs16Bit Pointer. If true on return, source port is 16 bits
       
    62  *  @return the source port
       
    63  */
       
    64 inline TInt TWapTextMessage::SourcePort(TBool* aIs16Bit) const
       
    65     {
       
    66     __ASSERT_DEBUG(iIsWapTextMessage, Panic(KPanicTextHeaderNotTextHeader));
       
    67     if (aIs16Bit)
       
    68         *aIs16Bit = iIs16Bit;
       
    69     if (iSourcePort == (-1)) // TODO what does -1 mean?
       
    70         return iDestinationPort;
       
    71     return iSourcePort;
       
    72     }
       
    73 
       
    74 
       
    75 /**
       
    76  *  Set the source port of this WAP message
       
    77  *  
       
    78  *  do not set the source port or set it to -1,
       
    79  *  if you choose the omit and assume that the wap datagram would
       
    80  *  fit in one segment
       
    81  *  
       
    82  *  @param aSourcePort Source port
       
    83  *  @param aIs16Bit TRUE if the dest port is a 16-bit value
       
    84  */
       
    85 inline void TWapTextMessage::SetSourcePort(const TInt aSourcePort, const TBool aIs16Bit)
       
    86     {
       
    87     iSourcePort = aSourcePort;
       
    88     // Don't override a true value
       
    89     if (!iIs16Bit)
       
    90         iIs16Bit = aIs16Bit;
       
    91     }
       
    92 
       
    93 
       
    94 /**
       
    95  *  Return the reference number for this WAP message
       
    96  *  
       
    97  *  @note 0 is a valid number
       
    98  */
       
    99 inline TInt TWapTextMessage::ReferenceNumber() const
       
   100     {
       
   101     __ASSERT_DEBUG(iIsWapTextMessage,Panic(KPanicTextHeaderNotTextHeader));
       
   102     return iReference;
       
   103     }
       
   104 
       
   105 
       
   106 /**
       
   107  *  Set the reference number for this WAP message
       
   108  *  
       
   109  *  @note 0 is a valid number
       
   110  */
       
   111 inline void TWapTextMessage::SetReferenceNumber(const TInt aReference)
       
   112     {
       
   113     iReference = aReference%256; // 8 bit ref number
       
   114     }
       
   115 
       
   116 
       
   117 /**
       
   118  *  Return the total number of segments for this WAP message
       
   119  *  1 is returned, if SAR is not present (but port info is)
       
   120  */
       
   121 inline TInt TWapTextMessage::TotalSegments() const
       
   122     {
       
   123     __ASSERT_DEBUG(iIsWapTextMessage,Panic(KPanicTextHeaderNotTextHeader));
       
   124     return iTotalSegments;
       
   125     }
       
   126 
       
   127 
       
   128 /**
       
   129  *  return the segment number for this WAP message
       
   130  *  
       
   131  *  Valid values start from 1.
       
   132  *  1 is returned,if SAR is not present (but port info is)
       
   133  */
       
   134 inline TInt TWapTextMessage::SegmentNumber() const
       
   135     {
       
   136     __ASSERT_DEBUG(iIsWapTextMessage,Panic(KPanicTextHeaderNotTextHeader));
       
   137     return iSegmentNumber;
       
   138     }
       
   139 
       
   140 
       
   141 /**
       
   142  *  from WAP spec: other header specified by text mode of WAP spec
       
   143  *  
       
   144  *  TODO no idea what is it used for ?
       
   145  *  Descriptor lenght is set 0, if not present
       
   146  *  '//' is included
       
   147  */
       
   148 inline void TWapTextMessage::OtherHeader(TDes8&      aOtherHeader) const
       
   149     {
       
   150     __ASSERT_DEBUG(iIsWapTextMessage,Panic(KPanicTextHeaderNotTextHeader));
       
   151     aOtherHeader.Append(iWAPMessage.Mid(iOtherHeader,iOtherHeaderLength));
       
   152     }
       
   153 
       
   154 
       
   155 /**
       
   156  *  Set the 'other header' field
       
   157  */
       
   158 inline void TWapTextMessage::SetOtherHeader(const TDesC8& aOtherHeader)
       
   159     {
       
   160     iRefOtherHeader.Set(aOtherHeader);
       
   161     }
       
   162 
       
   163 
       
   164 /**
       
   165  *  Gets the user data
       
   166  *  If the descriptor contains already data, the new data is appended.
       
   167  */
       
   168 inline void TWapTextMessage::UserData(TDes8& aWAPUserData) const
       
   169     {
       
   170     aWAPUserData.Append(iWAPMessage.Mid(iData,iDataLength));
       
   171     }
       
   172 
       
   173 
       
   174 /**
       
   175  *  Set the user data
       
   176  */
       
   177 inline void TWapTextMessage::SetUserData(const TDesC8& aWAPUserData)
       
   178     {
       
   179     iRefData.Set(aWAPUserData);
       
   180     }
       
   181 
       
   182 
       
   183 // EOF - WAPTHDR.INL