|
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 : CSIPContactHeaderParams.cpp |
|
15 // Part of : SIP Codec |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include "CSIPContactHeaderParams.h" |
|
23 #include "sipcodecerr.h" |
|
24 #include "SIPSyntaxCheck.h" |
|
25 #include "sipstrings.h" |
|
26 #include "sipstrconsts.h" |
|
27 |
|
28 // ---------------------------------------------------------------------------- |
|
29 // CSIPContactHeaderParams::NewL |
|
30 // ---------------------------------------------------------------------------- |
|
31 // |
|
32 CSIPContactHeaderParams* CSIPContactHeaderParams::NewL( |
|
33 const CSIPContactHeaderParams& aParams) |
|
34 { |
|
35 CSIPContactHeaderParams* self = CSIPContactHeaderParams::NewLC(aParams); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ---------------------------------------------------------------------------- |
|
41 // CSIPContactHeaderParams::NewLC |
|
42 // ---------------------------------------------------------------------------- |
|
43 // |
|
44 CSIPContactHeaderParams* CSIPContactHeaderParams::NewLC( |
|
45 const CSIPContactHeaderParams& aParams) |
|
46 { |
|
47 CSIPContactHeaderParams* self = new(ELeave)CSIPContactHeaderParams; |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(aParams); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // ---------------------------------------------------------------------------- |
|
54 // CSIPContactHeaderParams::CSIPContactHeaderParams |
|
55 // ---------------------------------------------------------------------------- |
|
56 // |
|
57 CSIPContactHeaderParams::CSIPContactHeaderParams () |
|
58 : CSIPParamContainerBase(';') |
|
59 { |
|
60 } |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // CSIPContactHeaderParams::~CSIPContactHeaderParams |
|
64 // ---------------------------------------------------------------------------- |
|
65 // |
|
66 CSIPContactHeaderParams::~CSIPContactHeaderParams () |
|
67 { |
|
68 } |
|
69 |
|
70 // ---------------------------------------------------------------------------- |
|
71 // CSIPContactHeaderParams::operator== |
|
72 // ---------------------------------------------------------------------------- |
|
73 // |
|
74 TBool |
|
75 CSIPContactHeaderParams::operator==( |
|
76 const CSIPContactHeaderParams& aParams) const |
|
77 { |
|
78 // If a Contact-header has a "q" or "expires" 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 TInt index = aParams.FindParamIndex(iParams[i]->Name()); |
|
84 if (index >= 0) |
|
85 { |
|
86 if (!(*(aParams.iParams[index]) == *(iParams[i]))) |
|
87 { |
|
88 return EFalse; |
|
89 } |
|
90 } |
|
91 else |
|
92 { |
|
93 RStringF name = iParams[i]->Name(); |
|
94 if (name == SIPStrings::StringF(SipStrConsts::EQ) || |
|
95 name == SIPStrings::StringF(SipStrConsts::EExpires)) |
|
96 { |
|
97 return EFalse; |
|
98 } |
|
99 } |
|
100 } |
|
101 for (TInt j=0; j < aParams.iParams.Count(); j++) |
|
102 { |
|
103 TInt index = FindParamIndex(aParams.iParams[j]->Name()); |
|
104 if (index >= 0) |
|
105 { |
|
106 if (!(*(iParams[index]) == *(aParams.iParams[j]))) |
|
107 { |
|
108 return EFalse; |
|
109 } |
|
110 } |
|
111 else |
|
112 { |
|
113 RStringF name = aParams.iParams[j]->Name(); |
|
114 if (name == SIPStrings::StringF(SipStrConsts::EQ) || |
|
115 name == SIPStrings::StringF(SipStrConsts::EExpires)) |
|
116 { |
|
117 return EFalse; |
|
118 } |
|
119 } |
|
120 } |
|
121 return ETrue; |
|
122 } |
|
123 |
|
124 // ---------------------------------------------------------------------------- |
|
125 // CSIPContactHeaderParams::InternalizeL |
|
126 // ---------------------------------------------------------------------------- |
|
127 // |
|
128 CSIPContactHeaderParams* CSIPContactHeaderParams::InternalizeL( |
|
129 RReadStream& aReadStream) |
|
130 { |
|
131 CSIPContactHeaderParams* self = new(ELeave)CSIPContactHeaderParams; |
|
132 CleanupStack::PushL(self); |
|
133 self->DoInternalizeL(aReadStream); |
|
134 CleanupStack::Pop(self); |
|
135 return self; |
|
136 } |
|
137 |
|
138 // ---------------------------------------------------------------------------- |
|
139 // CSIPContactHeaderParams::CheckParamL |
|
140 // ---------------------------------------------------------------------------- |
|
141 // |
|
142 void CSIPContactHeaderParams::CheckParamL (CSIPParam& aParam) const |
|
143 { |
|
144 RStringF name = aParam.Name(); |
|
145 TPtrC8 value = aParam.Value().DesC(); |
|
146 // expires |
|
147 if (name == SIPStrings::StringF(SipStrConsts::EExpires)) |
|
148 { |
|
149 if (!SIPSyntaxCheck::UInt(value)) |
|
150 { |
|
151 User::Leave(KErrSipCodecContactParams); |
|
152 } |
|
153 return; |
|
154 } |
|
155 // q |
|
156 if (name == SIPStrings::StringF(SipStrConsts::EQ)) |
|
157 { |
|
158 if (!SIPSyntaxCheck::QValue(value)) |
|
159 { |
|
160 User::Leave(KErrSipCodecContactParams); |
|
161 } |
|
162 return; |
|
163 } |
|
164 // generic-param |
|
165 CheckGenericParamL(aParam, KErrSipCodecContactParams); |
|
166 } |