|
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 : TransactionHeaders.cpp |
|
15 // Part of : TransactionUser |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "uricontainer.h" |
|
22 #include "siptoheader.h" |
|
23 #include "sipfromheader.h" |
|
24 #include "sipcallidheader.h" |
|
25 #include "siprecordrouteheader.h" |
|
26 #include "sipcontactheader.h" |
|
27 |
|
28 #include "CTransactionHeaders.h" |
|
29 |
|
30 #ifdef CPPUNIT_TEST |
|
31 #include "TestCleanupStack.h" |
|
32 #endif |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CTransactionHeaders::NewL |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CTransactionHeaders* |
|
39 CTransactionHeaders::NewL(const CURIContainer* aRequestURI, |
|
40 const CSIPToHeader* aTo, |
|
41 const CSIPFromHeader* aFrom, |
|
42 const CSIPCallIDHeader* aCallID, |
|
43 TUint aCSeq, |
|
44 RPointerArray<CSIPRecordRouteHeader>& aRecordRoute, |
|
45 RPointerArray<CSIPContactHeader>& aContact) |
|
46 { |
|
47 CTransactionHeaders* self = new (ELeave) CTransactionHeaders(aCSeq); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(aRequestURI, aTo, aFrom, aCallID, aRecordRoute, aContact); |
|
50 CleanupStack::Pop(self); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CTransactionHeaders::CTransactionHeaders |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CTransactionHeaders::CTransactionHeaders(TUint aCSeq) : iCSeq(aCSeq) |
|
59 { |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CTransactionHeaders::ConstructL |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CTransactionHeaders::ConstructL(const CURIContainer* aRequestURI, |
|
67 const CSIPToHeader* aTo, |
|
68 const CSIPFromHeader* aFrom, |
|
69 const CSIPCallIDHeader* aCallID, |
|
70 RPointerArray<CSIPRecordRouteHeader>& aRecordRoute, |
|
71 RPointerArray<CSIPContactHeader>& aContact) |
|
72 { |
|
73 if (aRequestURI) |
|
74 { |
|
75 iRequestURI = CURIContainer::NewL(*aRequestURI); |
|
76 } |
|
77 |
|
78 if (aTo) |
|
79 { |
|
80 iTo = CSIPToHeader::NewL(*aTo); |
|
81 } |
|
82 |
|
83 if (aFrom) |
|
84 { |
|
85 iFrom = CSIPFromHeader::NewL(*aFrom); |
|
86 } |
|
87 |
|
88 if (aCallID) |
|
89 { |
|
90 iCallID = static_cast<CSIPCallIDHeader*>(aCallID->CloneL()); |
|
91 } |
|
92 |
|
93 if (aRecordRoute.Count() > 0) |
|
94 { |
|
95 iRecordRoute = new (ELeave) RPointerArray<CSIPRouteHeaderBase>( |
|
96 #ifdef CPPUNIT_TEST |
|
97 //For unit tests the granularity of arrays is set to 1 to cause |
|
98 //them to allocate memory every time an item is appended to array |
|
99 1 |
|
100 #endif |
|
101 ); |
|
102 |
|
103 for (TInt i = 0; i < aRecordRoute.Count(); i++) |
|
104 { |
|
105 CSIPRecordRouteHeader* rr = |
|
106 static_cast<CSIPRecordRouteHeader*>(aRecordRoute[i]->CloneL()); |
|
107 CleanupStack::PushL(rr); |
|
108 iRecordRoute->AppendL(rr); |
|
109 CleanupStack::Pop(rr); |
|
110 } |
|
111 } |
|
112 |
|
113 if (aContact.Count() > 0) |
|
114 { |
|
115 iContact = new (ELeave) RPointerArray<CSIPContactHeader>( |
|
116 #ifdef CPPUNIT_TEST |
|
117 1 |
|
118 #endif |
|
119 ); |
|
120 |
|
121 for (TInt i = 0; i < aContact.Count(); i++) |
|
122 { |
|
123 CSIPContactHeader* contact = |
|
124 static_cast<CSIPContactHeader*>(aContact[i]->CloneL()); |
|
125 CleanupStack::PushL(contact); |
|
126 iContact->AppendL(contact); |
|
127 CleanupStack::Pop(contact); |
|
128 } |
|
129 } |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CTransactionHeaders::~CTransactionHeaders |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 CTransactionHeaders::~CTransactionHeaders() |
|
137 { |
|
138 delete iRequestURI; |
|
139 delete iTo; |
|
140 delete iFrom; |
|
141 delete iCallID; |
|
142 |
|
143 if (iRecordRoute) |
|
144 { |
|
145 iRecordRoute->ResetAndDestroy(); |
|
146 } |
|
147 delete iRecordRoute; |
|
148 |
|
149 if (iContact) |
|
150 { |
|
151 iContact->ResetAndDestroy(); |
|
152 } |
|
153 delete iContact; |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CTransactionHeaders::RequestURI |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 CURIContainer* CTransactionHeaders::RequestURI() |
|
161 { |
|
162 CURIContainer* requestURI = iRequestURI; |
|
163 iRequestURI = NULL; |
|
164 return requestURI; |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CTransactionHeaders::ToHeader |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 CSIPToHeader* CTransactionHeaders::ToHeader() |
|
172 { |
|
173 CSIPToHeader* to = iTo; |
|
174 iTo = NULL; |
|
175 return to; |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CTransactionHeaders::FromHeader |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 CSIPFromHeader* CTransactionHeaders::FromHeader() |
|
183 { |
|
184 CSIPFromHeader* from = iFrom; |
|
185 iFrom = NULL; |
|
186 return from; |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // CTransactionHeaders::CallIDHeader |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 CSIPCallIDHeader* CTransactionHeaders::CallIDHeader() |
|
194 { |
|
195 CSIPCallIDHeader* callID = iCallID; |
|
196 iCallID = NULL; |
|
197 return callID; |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CTransactionHeaders::CSeqNumber |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 TUint CTransactionHeaders::CSeqNumber() const |
|
205 { |
|
206 return iCSeq; |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CTransactionHeaders::RecordRoute |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 RPointerArray<CSIPRouteHeaderBase>* CTransactionHeaders::RecordRoute() |
|
214 { |
|
215 RPointerArray<CSIPRouteHeaderBase>* recordRoute = iRecordRoute; |
|
216 iRecordRoute = NULL; |
|
217 return recordRoute; |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // CTransactionHeaders::Contact |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 RPointerArray<CSIPContactHeader>* CTransactionHeaders::Contact() |
|
225 { |
|
226 RPointerArray<CSIPContactHeader>* contact = iContact; |
|
227 iContact = NULL; |
|
228 return contact; |
|
229 } |