realtimenetprots/sipfw/SIP/Codec/src/CSIPSubscriptionStateHeader.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2004-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 // Name          : CSIPSubscriptionStateHeader.cpp
       
    15 // Part of       : SIP Codec
       
    16 // Version       : SIP/4.0 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include "sipsubscriptionstateheader.h"
       
    22 #include "CSIPSubscriptionStateHeaderParams.h"
       
    23 #include "CSIPTokenizer.h"
       
    24 #include "sipcodecerr.h"
       
    25 #include "SIPSyntaxCheck.h"
       
    26 #include "sipstrings.h"
       
    27 #include "sipstrconsts.h"
       
    28 #include "sipcodecutils.h"
       
    29 #include "_sipcodecdefs.h"
       
    30 
       
    31 
       
    32 // ----------------------------------------------------------------------------
       
    33 // CSIPSubscriptionStateHeader::DecodeL
       
    34 // ----------------------------------------------------------------------------
       
    35 //
       
    36 EXPORT_C CSIPSubscriptionStateHeader* 
       
    37 CSIPSubscriptionStateHeader::DecodeL (const TDesC8& aValue)
       
    38 	{
       
    39 	CSIPSubscriptionStateHeader* header = 
       
    40 	    new(ELeave)CSIPSubscriptionStateHeader;
       
    41     CleanupStack::PushL(header);
       
    42     header->ConstructL();
       
    43 	header->ParseL(aValue);
       
    44 	CleanupStack::Pop(header);
       
    45 	return header;	
       
    46     }
       
    47 
       
    48 // ----------------------------------------------------------------------------
       
    49 // CSIPSubscriptionStateHeader::NewL
       
    50 // ----------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C CSIPSubscriptionStateHeader* CSIPSubscriptionStateHeader::NewL(
       
    53     const TDesC8& aSubStateValue)
       
    54 	{
       
    55 	CSIPSubscriptionStateHeader* self = 
       
    56 		CSIPSubscriptionStateHeader::NewLC(aSubStateValue);
       
    57 	CleanupStack::Pop(self);
       
    58 	return self;
       
    59 	}
       
    60 
       
    61 // ----------------------------------------------------------------------------
       
    62 // CSIPSubscriptionStateHeader::NewLC
       
    63 // ----------------------------------------------------------------------------
       
    64 //
       
    65 EXPORT_C CSIPSubscriptionStateHeader* CSIPSubscriptionStateHeader::NewLC(
       
    66     const TDesC8& aSubStateValue)
       
    67 	{
       
    68 	CSIPSubscriptionStateHeader* self = 
       
    69         new(ELeave) CSIPSubscriptionStateHeader();
       
    70 	CleanupStack::PushL(self);
       
    71 	self->ConstructL(aSubStateValue);
       
    72 	return self;
       
    73 	}
       
    74 
       
    75 // ----------------------------------------------------------------------------
       
    76 // CSIPSubscriptionStateHeader::CSIPSubscriptionStateHeader
       
    77 // ----------------------------------------------------------------------------
       
    78 //
       
    79 CSIPSubscriptionStateHeader::CSIPSubscriptionStateHeader()
       
    80 :   CSIPParameterHeaderBase( ';' )
       
    81 	{
       
    82 	}
       
    83 
       
    84 // ----------------------------------------------------------------------------
       
    85 // CSIPSubscriptionStateHeader::ConstructL
       
    86 // ----------------------------------------------------------------------------
       
    87 //
       
    88 void CSIPSubscriptionStateHeader::ConstructL()
       
    89 	{
       
    90 	iParams = new(ELeave)CSIPSubscriptionStateHeaderParams;
       
    91 	}
       
    92 
       
    93 // ----------------------------------------------------------------------------
       
    94 // CSIPSubscriptionStateHeader::ConstructL
       
    95 // ----------------------------------------------------------------------------
       
    96 //
       
    97 void CSIPSubscriptionStateHeader::ConstructL (const TDesC8& aSubStateValue)
       
    98 	{
       
    99 	ConstructL ();
       
   100 	SetSubStateValueL (aSubStateValue);
       
   101 	}
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CSIPSubscriptionStateHeader::ConstructL
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CSIPSubscriptionStateHeader::ConstructL (const CSIPSubscriptionStateHeader&
       
   108 										aSubscriptionStateHeader)
       
   109 	{
       
   110     SetSubStateValueL(aSubscriptionStateHeader.SubStateValue());
       
   111     iParams = CSIPSubscriptionStateHeaderParams::NewL(
       
   112         *(aSubscriptionStateHeader.iParams));
       
   113 	}
       
   114 
       
   115 // ----------------------------------------------------------------------------
       
   116 // CSIPSubscriptionStateHeader::~CSIPSubscriptionStateHeader
       
   117 // ----------------------------------------------------------------------------
       
   118 //
       
   119 EXPORT_C CSIPSubscriptionStateHeader::~CSIPSubscriptionStateHeader()
       
   120 	{
       
   121 	delete iParams;
       
   122 	delete iSubStateValue;
       
   123 	}
       
   124 
       
   125 // ----------------------------------------------------------------------------
       
   126 // CSIPSubscriptionStateHeader::CloneL
       
   127 // From CSIPHeaderBase:
       
   128 // ----------------------------------------------------------------------------
       
   129 //
       
   130 EXPORT_C CSIPHeaderBase* CSIPSubscriptionStateHeader::CloneL () const
       
   131 	{
       
   132 	CSIPSubscriptionStateHeader* clone = 
       
   133         new(ELeave)CSIPSubscriptionStateHeader;
       
   134 	CleanupStack::PushL(clone);
       
   135 	clone->ConstructL(*this);
       
   136 	CleanupStack::Pop(clone);
       
   137 	return clone;
       
   138 	}
       
   139 
       
   140 // ----------------------------------------------------------------------------
       
   141 // CSIPSubscriptionStateHeader::Name
       
   142 // From CSIPHeaderBase:
       
   143 // ----------------------------------------------------------------------------
       
   144 //
       
   145 EXPORT_C RStringF CSIPSubscriptionStateHeader::Name() const
       
   146     {
       
   147     return SIPStrings::StringF(SipStrConsts::ESubscriptionStateHeader);
       
   148     }
       
   149 
       
   150 // ----------------------------------------------------------------------------
       
   151 // CSIPSubscriptionStateHeader::SetSubStateValueL
       
   152 // ----------------------------------------------------------------------------
       
   153 //
       
   154 EXPORT_C void 
       
   155 CSIPSubscriptionStateHeader::SetSubStateValueL (const TDesC8& aSubStateValue)
       
   156 	{
       
   157     SIPCodecUtils::CheckAndSetValueL(iSubStateValue,
       
   158                                      aSubStateValue,
       
   159                                      KErrSipCodecSubscriptionStateHeader);
       
   160 	}
       
   161 
       
   162 // ----------------------------------------------------------------------------
       
   163 // CSIPSubscriptionStateHeader::SubStateValue
       
   164 // ----------------------------------------------------------------------------
       
   165 //
       
   166 EXPORT_C const TDesC8& CSIPSubscriptionStateHeader::SubStateValue() const
       
   167 	{
       
   168     return *iSubStateValue;
       
   169 	}
       
   170 
       
   171 // ----------------------------------------------------------------------------
       
   172 // CSIPSubscriptionStateHeader::ExpiresParameter
       
   173 // ----------------------------------------------------------------------------
       
   174 //
       
   175 EXPORT_C TInt CSIPSubscriptionStateHeader::ExpiresParameter () const
       
   176 	{
       
   177 	return iParams->IntParamValue(SIPStrings::StringF(SipStrConsts::EExpires));
       
   178 	}
       
   179 
       
   180 // ----------------------------------------------------------------------------
       
   181 // CSIPSubscriptionStateHeader::SetExpiresParameterL
       
   182 // ----------------------------------------------------------------------------
       
   183 //
       
   184 EXPORT_C void 
       
   185 CSIPSubscriptionStateHeader::SetExpiresParameterL (TInt aExpiresParam)
       
   186 	{
       
   187 	iParams->SetParamL (
       
   188         SIPStrings::StringF(SipStrConsts::EExpires), 
       
   189         aExpiresParam);
       
   190 	}
       
   191 
       
   192 // ----------------------------------------------------------------------------
       
   193 // CSIPSubscriptionStateHeader::RetryAfterParameter
       
   194 // ----------------------------------------------------------------------------
       
   195 //
       
   196 EXPORT_C TInt CSIPSubscriptionStateHeader::RetryAfterParameter () const
       
   197 	{
       
   198 	return iParams->IntParamValue(
       
   199         SIPStrings::StringF(SipStrConsts::ERetryAfter));
       
   200 	}
       
   201 
       
   202 // ----------------------------------------------------------------------------
       
   203 // CSIPSubscriptionStateHeader::SetRetryAfterParameterL
       
   204 // ----------------------------------------------------------------------------
       
   205 //
       
   206 EXPORT_C void CSIPSubscriptionStateHeader::SetRetryAfterParameterL(
       
   207     TInt aRetryAfterParam)
       
   208 	{
       
   209 	iParams->SetParamL (
       
   210         SIPStrings::StringF(SipStrConsts::ERetryAfter), 
       
   211         aRetryAfterParam);
       
   212 	}
       
   213 
       
   214 // ----------------------------------------------------------------------------
       
   215 // CSIPSubscriptionStateHeader::InternalizeValueL
       
   216 // ----------------------------------------------------------------------------
       
   217 //
       
   218 EXPORT_C CSIPHeaderBase* CSIPSubscriptionStateHeader::InternalizeValueL(
       
   219     RReadStream& aReadStream)
       
   220 	{
       
   221 	CSIPSubscriptionStateHeader* self = new(ELeave)CSIPSubscriptionStateHeader;
       
   222 	CleanupStack::PushL(self);
       
   223 	self->DoInternalizeValueL(aReadStream);
       
   224 	CleanupStack::Pop(self);
       
   225 	return self;
       
   226 	}
       
   227 
       
   228 // ----------------------------------------------------------------------------
       
   229 // CSIPSubscriptionStateHeader::DoInternalizeValueL
       
   230 // ----------------------------------------------------------------------------
       
   231 //
       
   232 void CSIPSubscriptionStateHeader::DoInternalizeValueL(RReadStream& aReadStream)
       
   233 	{
       
   234     iSubStateValue = SIPCodecUtils::ReadDescFromStreamL(aReadStream);
       
   235 	iParams = CSIPSubscriptionStateHeaderParams::InternalizeL (aReadStream);
       
   236 	}	
       
   237 
       
   238 // ----------------------------------------------------------------------------
       
   239 // CSIPSubscriptionStateHeader::ExternalizeValueL
       
   240 // From CSIPHeaderBase:
       
   241 // ----------------------------------------------------------------------------
       
   242 //
       
   243 void CSIPSubscriptionStateHeader::ExternalizeValueL(
       
   244     RWriteStream& aWriteStream) const
       
   245 	{
       
   246 	aWriteStream.WriteUint32L (iSubStateValue->Length());
       
   247 	if (iSubStateValue->Length() > 0)
       
   248 		{
       
   249 		aWriteStream.WriteL (SubStateValue());
       
   250 		}
       
   251 	iParams->ExternalizeL (aWriteStream);
       
   252 	}
       
   253 
       
   254 // ----------------------------------------------------------------------------
       
   255 // CSIPSubscriptionStateHeader::PreferredPlaceInMessage
       
   256 // From CSIPHeaderBase:
       
   257 // ----------------------------------------------------------------------------
       
   258 //
       
   259 CSIPHeaderBase::TPreferredPlace
       
   260 CSIPSubscriptionStateHeader::PreferredPlaceInMessage () const
       
   261 	{
       
   262 	return CSIPHeaderBase::EBottom;
       
   263 	}
       
   264 
       
   265 // ----------------------------------------------------------------------------
       
   266 // CSIPSubscriptionStateHeader::BaseDecodeL
       
   267 // ----------------------------------------------------------------------------
       
   268 //
       
   269 RPointerArray<CSIPHeaderBase> 
       
   270 CSIPSubscriptionStateHeader::BaseDecodeL(const TDesC8& aValue)
       
   271     {
       
   272 	CSIPSubscriptionStateHeader* header = DecodeL(aValue);
       
   273     CleanupStack::PushL(header);
       
   274 	RPointerArray<CSIPHeaderBase> headerArray;
       
   275 	User::LeaveIfError (headerArray.Append(header));
       
   276 	CleanupStack::Pop(header);
       
   277 	return headerArray;
       
   278     }
       
   279 
       
   280 // ----------------------------------------------------------------------------
       
   281 // CSIPSubscriptionStateHeaderr::ToTextMandatoryPartLC
       
   282 // From CSIPParameterHeaderBase:
       
   283 // ----------------------------------------------------------------------------
       
   284 //
       
   285 HBufC8* CSIPSubscriptionStateHeader::ToTextMandatoryPartLC () const
       
   286 	{
       
   287 	return iSubStateValue->AllocLC();
       
   288 	}
       
   289 	
       
   290 // ----------------------------------------------------------------------------
       
   291 // CSIPSubscriptionStateHeader::ParseMandatoryPartL
       
   292 // From CSIPParameterHeaderBase:
       
   293 // ----------------------------------------------------------------------------
       
   294 //
       
   295 void 
       
   296 CSIPSubscriptionStateHeader::ParseMandatoryPartL (const TDesC8& aMandatoryPart)
       
   297 	{
       
   298 	SetSubStateValueL(aMandatoryPart);
       
   299 	}
       
   300 
       
   301 // ----------------------------------------------------------------------------
       
   302 // CSIPSubscriptionStateHeader::Params
       
   303 // From CSIPParameterHeaderBase:
       
   304 // ----------------------------------------------------------------------------
       
   305 //
       
   306 const CSIPParamContainerBase& CSIPSubscriptionStateHeader::Params () const
       
   307     {
       
   308     return *iParams; 
       
   309     }
       
   310 
       
   311 // ----------------------------------------------------------------------------
       
   312 // CSIPSubscriptionStateHeader::Params
       
   313 // From CSIPParameterHeaderBase:
       
   314 // ----------------------------------------------------------------------------
       
   315 //
       
   316 CSIPParamContainerBase& CSIPSubscriptionStateHeader::Params ()
       
   317     {
       
   318     return *iParams; 
       
   319     }