|
1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Inline implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <s32mem.h> |
|
19 #include <mcallremotepartyinfo.h> |
|
20 |
|
21 namespace RemotePartyMediatorApi |
|
22 { |
|
23 enum TPanic |
|
24 { |
|
25 ENullPointer |
|
26 }; |
|
27 _LIT( KRemotePartyMediatorApi, "RPMA"); |
|
28 } |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // static constructor |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CCallRemotePartyInfo* CCallRemotePartyInfo::NewL() |
|
35 { |
|
36 CCallRemotePartyInfo* self = CCallRemotePartyInfo::NewLC(); |
|
37 CleanupStack::Pop( self ); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // static constructor |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CCallRemotePartyInfo* CCallRemotePartyInfo::NewLC() |
|
46 { |
|
47 CCallRemotePartyInfo* self = new( ELeave )CCallRemotePartyInfo(); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // Destructor |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CCallRemotePartyInfo::~CCallRemotePartyInfo() |
|
58 { |
|
59 delete iCompanyName; |
|
60 delete iMatchedName; |
|
61 delete iNameFromNetwork; |
|
62 delete iAddress; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // Extarnalizes remote party info to stream |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CCallRemotePartyInfo::ExternalizeL( RWriteStream& aStream ) const |
|
70 { |
|
71 WriteDescriptorToStreamL( aStream, *iCompanyName ); |
|
72 WriteDescriptorToStreamL( aStream, *iMatchedName ); |
|
73 WriteDescriptorToStreamL( aStream, *iNameFromNetwork ); |
|
74 WriteDescriptorToStreamL( aStream, *iAddress ); |
|
75 aStream.WriteInt32L( iCallIndex ); |
|
76 aStream.WriteInt32L( iRemoteIdentity ); |
|
77 aStream.WriteInt32L( iSATCall ); |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // Internalizes remote party info from stream |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CCallRemotePartyInfo::InternalizeL( RReadStream& aStream ) |
|
85 { |
|
86 HBufC* companyName = ReadDescriptorFromStreamLC( aStream ); |
|
87 HBufC* matchedName = ReadDescriptorFromStreamLC( aStream ); |
|
88 HBufC* nameFromNetwork = ReadDescriptorFromStreamLC( aStream ); |
|
89 HBufC* address = ReadDescriptorFromStreamLC( aStream ); |
|
90 const TInt callIndex = aStream.ReadInt32L(); |
|
91 const TInt remoteIdentity = aStream.ReadInt32L(); |
|
92 const TInt SATCall = aStream.ReadInt32L(); |
|
93 |
|
94 CleanupStack::Pop( 4, companyName ); |
|
95 |
|
96 |
|
97 delete iCompanyName; |
|
98 delete iMatchedName; |
|
99 delete iNameFromNetwork; |
|
100 delete iAddress; |
|
101 |
|
102 |
|
103 iCompanyName = companyName; |
|
104 iMatchedName = matchedName; |
|
105 iNameFromNetwork = nameFromNetwork; |
|
106 iAddress = address; |
|
107 iCallIndex = callIndex; |
|
108 iRemoteIdentity = static_cast < TRemoteIdentityStatus > ( remoteIdentity ); |
|
109 iSATCall = SATCall; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // Size of the descriptor required for the information to be externalized |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 TInt CCallRemotePartyInfo::Size() const |
|
117 { |
|
118 // each member descriptor also needs the length of the descriptor |
|
119 TInt size = sizeof(TInt) + iCompanyName->Size(); |
|
120 size += sizeof( TInt ) + iMatchedName->Size(); |
|
121 size += sizeof( TInt ) + iNameFromNetwork->Size(); |
|
122 size += sizeof( TInt ) + iAddress->Size(); |
|
123 size += sizeof( TInt ); // Call index |
|
124 size += sizeof( TInt ); // remote identity |
|
125 size += sizeof( TInt ); // SAT call |
|
126 return size; |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // Sets remote matched name |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void CCallRemotePartyInfo::SetMatchedNameL( const TDesC& aName ) |
|
134 { |
|
135 HBufC* name = aName.AllocL(); |
|
136 delete iMatchedName; |
|
137 iMatchedName = name; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // Sets remote name from network |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CCallRemotePartyInfo::SetNameFromNetworkL( const TDesC& aName ) |
|
145 { |
|
146 HBufC* name = aName.AllocL(); |
|
147 delete iNameFromNetwork; |
|
148 iNameFromNetwork = name; |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // Sets remote company name |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CCallRemotePartyInfo::SetCompanyNameL( const TDesC& aName ) |
|
156 { |
|
157 HBufC* name = aName.AllocL(); |
|
158 delete iCompanyName; |
|
159 iCompanyName = name; |
|
160 } |
|
161 |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // Sets remote address |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 void CCallRemotePartyInfo::SetAddressL( const TDesC& aAddress ) |
|
168 { |
|
169 HBufC* address = aAddress.AllocL(); |
|
170 delete iAddress; |
|
171 iAddress = address; |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // Sets call index |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CCallRemotePartyInfo::SetCallIndex( TInt aCallIndex ) |
|
179 { |
|
180 iCallIndex = aCallIndex; |
|
181 } |
|
182 |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // Sets remote identity |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 void CCallRemotePartyInfo::SetRemoteIdentity( TRemoteIdentityStatus aRemoteIdentity ) |
|
189 { |
|
190 iRemoteIdentity = aRemoteIdentity; |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // Sets SAT call flag |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 void CCallRemotePartyInfo::SetSATCall( TBool aSatCall ) |
|
198 { |
|
199 iSATCall = aSatCall; |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // From base class MCallRemotePartyInfo |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 const TDesC& CCallRemotePartyInfo::Address() const |
|
207 { |
|
208 return *iAddress; |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // From base class MCallRemotePartyInfo |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 const TDesC& CCallRemotePartyInfo::CompanyName() const |
|
216 { |
|
217 return *iCompanyName; |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // From base class MCallRemotePartyInfo |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 const TDesC& CCallRemotePartyInfo::MatchedName() const |
|
225 { |
|
226 return *iMatchedName; |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // From base class MCallRemotePartyInfo |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 const TDesC& CCallRemotePartyInfo::NameFromNetwork() const |
|
234 { |
|
235 return *iNameFromNetwork; |
|
236 } |
|
237 |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // From base class MCallRemotePartyInfo |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 TInt CCallRemotePartyInfo::CallIndex() const |
|
244 { |
|
245 return iCallIndex; |
|
246 } |
|
247 |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // From base class MCallRemotePartyInfo |
|
251 // --------------------------------------------------------------------------- |
|
252 // |
|
253 MCallRemotePartyInfo::TRemoteIdentityStatus CCallRemotePartyInfo::RemoteIdentity() const |
|
254 { |
|
255 return iRemoteIdentity; |
|
256 } |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 // From base class MCallRemotePartyInfo |
|
260 // --------------------------------------------------------------------------- |
|
261 // |
|
262 TBool CCallRemotePartyInfo::SATCall() const |
|
263 { |
|
264 return iSATCall; |
|
265 } |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // From base class MCallRemotePartyInfo |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 TBool CCallRemotePartyInfo::operator==(const MCallRemotePartyInfo& aRemoteInfo) const |
|
275 { |
|
276 |
|
277 if ( iMatchedName->Match( aRemoteInfo.MatchedName() ) == KErrNone && |
|
278 iNameFromNetwork->Match( aRemoteInfo.NameFromNetwork() ) == KErrNone && |
|
279 iCompanyName->Match( aRemoteInfo.CompanyName() ) == KErrNone && |
|
280 iAddress->Match( aRemoteInfo.Address() ) == KErrNone && |
|
281 iCallIndex == aRemoteInfo.CallIndex() && |
|
282 iRemoteIdentity == aRemoteInfo.RemoteIdentity() && |
|
283 iSATCall == aRemoteInfo.SATCall() ) |
|
284 { |
|
285 return ETrue; |
|
286 } |
|
287 |
|
288 return EFalse; |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // Reads descriptor from stream. |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 HBufC* CCallRemotePartyInfo::ReadDescriptorFromStreamLC( RReadStream& aStream ) |
|
296 { |
|
297 const TInt descLength = aStream.ReadInt32L(); |
|
298 HBufC* desc = HBufC::NewLC( descLength ); |
|
299 TPtr descPtr = desc->Des(); |
|
300 aStream.ReadL( descPtr, descLength ); |
|
301 return desc; |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // writes descriptor to stream. |
|
306 // --------------------------------------------------------------------------- |
|
307 // |
|
308 void CCallRemotePartyInfo::WriteDescriptorToStreamL( |
|
309 RWriteStream& aStream, |
|
310 const TDesC& aDesc ) |
|
311 { |
|
312 aStream.WriteInt32L( aDesc.Length() ); |
|
313 aStream.WriteL( aDesc ); |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------------------------- |
|
317 // c++ constructor |
|
318 // --------------------------------------------------------------------------- |
|
319 // |
|
320 CCallRemotePartyInfo::CCallRemotePartyInfo() : |
|
321 iCallIndex( -1 ), |
|
322 iRemoteIdentity( MCallRemotePartyInfo::ERemoteIdentityUnknown ) |
|
323 { |
|
324 } |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // 2nd phase constructor |
|
328 // --------------------------------------------------------------------------- |
|
329 // |
|
330 void CCallRemotePartyInfo::ConstructL() |
|
331 { |
|
332 iCompanyName = KNullDesC().AllocL(); |
|
333 iMatchedName = KNullDesC().AllocL(); |
|
334 iNameFromNetwork = KNullDesC().AllocL(); |
|
335 iAddress = KNullDesC().AllocL(); |
|
336 } |
|
337 // --------------------------------------------------------------------------- |
|
338 // static constructor |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 CCallRemotePartyInfos* CCallRemotePartyInfos::NewL() |
|
342 { |
|
343 CCallRemotePartyInfos* self = CCallRemotePartyInfos::NewLC(); |
|
344 CleanupStack::Pop( self ); |
|
345 return self; |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // static constructor |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 CCallRemotePartyInfos* CCallRemotePartyInfos::NewLC() |
|
353 { |
|
354 CCallRemotePartyInfos* self = new( ELeave )CCallRemotePartyInfos(); |
|
355 CleanupStack::PushL( self ); |
|
356 return self; |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------------------------- |
|
360 // Destructor |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 CCallRemotePartyInfos::~CCallRemotePartyInfos() |
|
364 { |
|
365 iInfos.ResetAndDestroy(); |
|
366 } |
|
367 |
|
368 // --------------------------------------------------------------------------- |
|
369 // Adds remote party information |
|
370 // --------------------------------------------------------------------------- |
|
371 // |
|
372 void CCallRemotePartyInfos::AddL( CCallRemotePartyInfo* aInfo ) |
|
373 { |
|
374 __ASSERT_ALWAYS( aInfo, |
|
375 User::Panic(RemotePartyMediatorApi::KRemotePartyMediatorApi, |
|
376 RemotePartyMediatorApi::ENullPointer ) ); |
|
377 iInfos.AppendL( aInfo ); |
|
378 } |
|
379 |
|
380 // --------------------------------------------------------------------------- |
|
381 // Remote party information access |
|
382 // --------------------------------------------------------------------------- |
|
383 // |
|
384 const RPointerArray<CCallRemotePartyInfo>& |
|
385 CCallRemotePartyInfos::RemotePartyInfos() const |
|
386 { |
|
387 return iInfos; |
|
388 } |
|
389 |
|
390 // --------------------------------------------------------------------------- |
|
391 // Packages remote party information to descriptor |
|
392 // --------------------------------------------------------------------------- |
|
393 // |
|
394 HBufC8* CCallRemotePartyInfos::ExternalizeL() const |
|
395 { |
|
396 // Calculate the size of the descriptor required |
|
397 TInt sizeRequired = sizeof(TInt); // Count of the infos |
|
398 TInt count = iInfos.Count(); |
|
399 for ( TInt i = 0; i < count; i++ ) |
|
400 { |
|
401 sizeRequired += iInfos[i]->Size(); |
|
402 } |
|
403 HBufC8* package = HBufC8::NewLC( sizeRequired ); |
|
404 TPtr8 packagePtr = package->Des(); |
|
405 RDesWriteStream stream( packagePtr ); |
|
406 stream.PushL(); |
|
407 stream.WriteInt32L( count ); |
|
408 for( TInt i = 0; i < count; i++ ) |
|
409 { |
|
410 iInfos[i]->ExternalizeL( stream ); |
|
411 } |
|
412 stream.CommitL(); |
|
413 stream.Pop(); |
|
414 stream.Close(); |
|
415 CleanupStack::Pop( package ); |
|
416 return package; |
|
417 } |
|
418 |
|
419 // --------------------------------------------------------------------------- |
|
420 // Unpacks remote party informations from descriptor. |
|
421 // --------------------------------------------------------------------------- |
|
422 // |
|
423 void CCallRemotePartyInfos::InternalizeL( const TDesC8& aData ) |
|
424 { |
|
425 iInfos.ResetAndDestroy(); |
|
426 |
|
427 RDesReadStream stream( aData ); |
|
428 stream.PushL(); |
|
429 const TInt numberOfInfos = stream.ReadInt32L(); |
|
430 for ( TInt i = 0; i < numberOfInfos; i++ ) |
|
431 { |
|
432 CCallRemotePartyInfo* info = CCallRemotePartyInfo::NewLC(); |
|
433 info->InternalizeL( stream ); |
|
434 iInfos.AppendL( info ); |
|
435 CleanupStack::Pop( info ); |
|
436 } |
|
437 |
|
438 stream.Pop(); |
|
439 stream.Close(); |
|
440 } |
|
441 |
|
442 // --------------------------------------------------------------------------- |
|
443 // c++ constructor |
|
444 // --------------------------------------------------------------------------- |
|
445 // |
|
446 CCallRemotePartyInfos::CCallRemotePartyInfos() |
|
447 { |
|
448 |
|
449 } |
|
450 |
|
451 |
|
452 |
|
453 |