realtimenetprots/sipfw/SIP/Codec/src/CSIPFromToHeaderParams.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     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 // Name          : CSIPFromToHeaderParams.cpp
       
    15 // Part of       : SIP Codec
       
    16 // Version       : SIP/4.0 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #include "CSIPFromToHeaderParams.h"
       
    23 #include "sipcodecerr.h"
       
    24 #include "SIPSyntaxCheck.h"
       
    25 #include "sipstrings.h"
       
    26 #include "sipstrconsts.h"
       
    27 
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CSIPFromToHeaderParams::NewL
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CSIPFromToHeaderParams* CSIPFromToHeaderParams::NewL(
       
    34     const CSIPFromToHeaderParams& aParams)
       
    35 	{
       
    36 	CSIPFromToHeaderParams* self = CSIPFromToHeaderParams::NewLC (aParams);
       
    37 	CleanupStack::Pop(self);
       
    38 	return self;
       
    39 	}
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CSIPFromToHeaderParams::NewLC
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CSIPFromToHeaderParams* CSIPFromToHeaderParams::NewLC(
       
    46     const CSIPFromToHeaderParams& aParams)
       
    47 	{
       
    48 	CSIPFromToHeaderParams* self = new(ELeave)CSIPFromToHeaderParams;
       
    49 	CleanupStack::PushL(self);
       
    50 	self->ConstructL(aParams);
       
    51 	return self;
       
    52 	}	
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CSIPFromToHeaderParams::CSIPFromToHeaderParams
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CSIPFromToHeaderParams::CSIPFromToHeaderParams ()
       
    59  : CSIPParamContainerBase(';')
       
    60 	{
       
    61 	}
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CSIPFromToHeaderParams::~CSIPFromToHeaderParams
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CSIPFromToHeaderParams::~CSIPFromToHeaderParams ()
       
    68 	{
       
    69 	}
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CSIPFromToHeaderParams::operator==
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 TBool CSIPFromToHeaderParams::operator==(
       
    76     const CSIPFromToHeaderParams& aParams) const
       
    77 	{
       
    78 	// If a From/To-header has a "tag" parameter the other one
       
    79 	// has to have it too and their values must match. 
       
    80 	// The extension parameters must match only if they are present in both.
       
    81 	for (TInt i=0; i < iParams.Count(); i++)
       
    82 		{
       
    83 		RStringF name = iParams[i]->Name();
       
    84 		TInt index = aParams.FindParamIndex(name);
       
    85 		if (index >= 0)
       
    86 			{
       
    87 			if (!(*(aParams.iParams[index]) == *(iParams[i])))
       
    88 				{
       
    89 				return EFalse;
       
    90 				}
       
    91 			}
       
    92 		else
       
    93 			{
       
    94 			if (name == SIPStrings::StringF(SipStrConsts::ETag))
       
    95 				{
       
    96 				return EFalse;
       
    97 				}
       
    98 			}
       
    99 		}
       
   100 	for (TInt j=0; j < aParams.iParams.Count(); j++)
       
   101 		{
       
   102 		RStringF name = aParams.iParams[j]->Name();
       
   103 		TInt index = FindParamIndex(name);
       
   104 		if (index >= 0)
       
   105 			{
       
   106 			if (!(*(iParams[index]) == *(aParams.iParams[j])))
       
   107 				{
       
   108 				return EFalse;
       
   109 				}
       
   110 			}
       
   111 		else
       
   112 			{
       
   113 			if (name == SIPStrings::StringF(SipStrConsts::ETag))
       
   114 				{
       
   115 				return EFalse;
       
   116 				}
       
   117 			}
       
   118 		}
       
   119 	return ETrue;
       
   120 	}
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CSIPFromToHeaderParams::InternalizeL
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 CSIPFromToHeaderParams* CSIPFromToHeaderParams::InternalizeL(
       
   127     RReadStream& aReadStream)
       
   128 	{
       
   129 	CSIPFromToHeaderParams* self = new(ELeave)CSIPFromToHeaderParams;
       
   130 	CleanupStack::PushL(self);
       
   131 	self->DoInternalizeL(aReadStream);
       
   132 	CleanupStack::Pop(self);
       
   133 	return self;
       
   134 	}
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CSIPFromToHeaderParams::CheckParamL
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void CSIPFromToHeaderParams::CheckParamL(CSIPParam& aParam) const
       
   141 	{
       
   142 	// tag
       
   143 	if (aParam.Name() == SIPStrings::StringF(SipStrConsts::ETag))
       
   144 		{
       
   145 		if (!SIPSyntaxCheck::Token(aParam.Value().DesC()))
       
   146 			{
       
   147 			User::Leave(KErrSipCodecFromOrToParams);
       
   148 			}
       
   149 		return;
       
   150 		}
       
   151     // generic-param
       
   152     CheckGenericParamL(aParam, KErrSipCodecFromOrToParams);
       
   153 	}