|
1 /* |
|
2 * Copyright (c) 2007-2008 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: This file contains the implementation of CPECallArrayOwner class |
|
15 * member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <talogger.h> |
|
22 #include <pepanic.pan> |
|
23 #include <ccce.h> |
|
24 |
|
25 #include "cpecallarrayowner.h" |
|
26 #include "cpesinglecall.h" |
|
27 #include "cpevideocallhandling.h" |
|
28 |
|
29 // EXTERNAL DATA STRUCTURES |
|
30 // None. |
|
31 |
|
32 // EXTERNAL FUNCTION PROTOTYPES |
|
33 // None. |
|
34 |
|
35 // CONSTANTS |
|
36 // None. |
|
37 |
|
38 // MACROS |
|
39 // None. |
|
40 |
|
41 // LOCAL CONSTANTS AND MACROS |
|
42 // None. |
|
43 |
|
44 // MODULE DATA STRUCTURES |
|
45 // None. |
|
46 |
|
47 // LOCAL FUNCTION PROTOTYPES |
|
48 // None. |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 // None. |
|
52 |
|
53 // ==================== LOCAL FUNCTIONS ==================== |
|
54 // None. |
|
55 |
|
56 // ================= MEMBER FUNCTIONS ======================= |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CPECallArrayOwner::CPECallArrayOwner |
|
60 // C++ default constructor can NOT contain any code, that |
|
61 // might leave. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CPECallArrayOwner::CPECallArrayOwner() |
|
65 { |
|
66 } |
|
67 |
|
68 // Destructor |
|
69 CPECallArrayOwner::~CPECallArrayOwner() |
|
70 { |
|
71 TEFLOGSTRING( KTAOBJECT, |
|
72 "CALL CPECallArrayOwner::~CPECallArrayOwner: Start." ); |
|
73 |
|
74 if ( iCallArray ) |
|
75 { |
|
76 iCallArray->ResetAndDestroy(); |
|
77 iCallArray->Close(); |
|
78 delete iCallArray; |
|
79 iCallArray = NULL; |
|
80 } |
|
81 |
|
82 TEFLOGSTRING( KTAOBJECT, |
|
83 "CALL: CPECallArrayOwner::~CPECallArrayOwner: Complete." ); |
|
84 } |
|
85 |
|
86 CPECallArrayOwner* CPECallArrayOwner::NewL( |
|
87 CCCE& iConvergedCallEngine, |
|
88 MPEMessageSender& aOwner ) |
|
89 { |
|
90 TEFLOGSTRING( KTAOBJECT, |
|
91 "CALL CPECallArrayOwner::NewL: start." ); |
|
92 |
|
93 CPECallArrayOwner* self = new ( ELeave ) CPECallArrayOwner(); |
|
94 CleanupStack::PushL( self ); |
|
95 self->ConstructL( iConvergedCallEngine, aOwner ); |
|
96 CleanupStack::Pop( self ); |
|
97 |
|
98 TEFLOGSTRING( KTAOBJECT, |
|
99 "CALL CPECallArrayOwner::NewL: complete." ); |
|
100 |
|
101 return self; |
|
102 } |
|
103 |
|
104 void CPECallArrayOwner::ConstructL( |
|
105 CCCE& iConvergedCallEngine, |
|
106 MPEMessageSender& aOwner ) |
|
107 |
|
108 { |
|
109 TEFLOGSTRING( KTAOBJECT, |
|
110 "CALL CPECallArrayOwner::ConstructL: start." ); |
|
111 |
|
112 iCallArray = new ( ELeave ) RPointerArray< CPESingleCall >; |
|
113 |
|
114 // Open emergency call, this done here so that phone app doesn't allocate memory |
|
115 // when emeregency call is really created. |
|
116 CPESingleCall* call = CreateEmergencyCallL( aOwner ); |
|
117 call->SetCall( iConvergedCallEngine.InitializeEmergencyCall( *call ) ); |
|
118 |
|
119 TEFLOGSTRING( KTAOBJECT, |
|
120 "CALL CPECallArrayOwner::ConstructL: complete." ); |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CPECallArrayOwner::CreateCallL |
|
125 // |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 CPESingleCall* CPECallArrayOwner::CreateCallL( MPEMessageSender& aOwner ) |
|
129 { |
|
130 TEFLOGSTRING( KTAMESINT, "CALL CPECallArrayOwner::CreateCallL"); |
|
131 CPESingleCall* call( NULL ); |
|
132 |
|
133 if( iCallArray->Count() < ( KPEMaximumNumberOfVoiceCalls ) ) |
|
134 { |
|
135 // Find free call id |
|
136 for( TInt callId = 0; callId < KPEMaximumNumberOfVoiceCalls; callId++ ) |
|
137 { |
|
138 if( !GetCallObject( callId ) ) |
|
139 { |
|
140 call = CPESingleCall::NewL( aOwner ); |
|
141 call->SetCallId( callId ); |
|
142 iCallArray->Append( call ); |
|
143 break; |
|
144 } |
|
145 } |
|
146 } |
|
147 else |
|
148 { |
|
149 TEFLOGSTRING( KTAMESINT, "CALL CPECallArrayOwner::CreateCallL Leave( ECCPRequestFailure )"); |
|
150 User::Leave( ECCPRequestFailure ); |
|
151 } |
|
152 return call; |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CPECallArrayOwner::CallByCallId |
|
157 // |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 CPESingleCall* CPECallArrayOwner::GetCallObject( |
|
161 const TInt aCallId ) const |
|
162 { |
|
163 TEFLOGSTRING( KTAMESINT, "CALL CPECallArrayOwner::GetCallObject"); |
|
164 CPESingleCall* call( NULL ); |
|
165 TInt callIndex; |
|
166 |
|
167 __ASSERT_DEBUG( |
|
168 aCallId <= ( KPEMaximumNumberOfVoiceCalls + KPEMaximumNumberOfDataCalls ), |
|
169 Panic( EPEPanicIndexOutOfRange) ); |
|
170 |
|
171 for( callIndex = 0; callIndex < iCallArray->Count(); callIndex++ ) |
|
172 { |
|
173 if( aCallId == (*iCallArray)[callIndex]->GetCallId() ) |
|
174 { |
|
175 call = (*iCallArray)[callIndex]; |
|
176 TEFLOGSTRING2( KTAMESINT, "CALL CPECallArrayOwner::GetCallObject %d", callIndex); |
|
177 break; |
|
178 } |
|
179 } |
|
180 return call; |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CPECallArrayOwner::GetCallObjectByIndex |
|
185 // |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 CPESingleCall* CPECallArrayOwner::GetCallObjectByIndex( |
|
189 const TInt aIndex ) const |
|
190 { |
|
191 TEFLOGSTRING( KTAMESINT, "CALL CPECallArrayOwner::GetCallObjectByIndex"); |
|
192 |
|
193 __ASSERT_DEBUG( |
|
194 aIndex < ( KPEMaximumNumberOfVoiceCalls ), |
|
195 Panic( EPEPanicIndexOutOfRange) ); |
|
196 |
|
197 return aIndex < Count() ? (*iCallArray)[aIndex] : NULL; |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CPECallArrayOwner::DeleteCallObject |
|
202 // |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 TInt CPECallArrayOwner::DeleteCallObject( |
|
206 const TInt aCallId ) |
|
207 { |
|
208 TEFLOGSTRING2( KTAMESINT, "CALL CPECallArrayOwner::DeleteCallObject, call id: %d", aCallId ); |
|
209 CPESingleCall* call( NULL ); |
|
210 TInt callIndex; |
|
211 TInt errorCode( KErrNotFound ); |
|
212 |
|
213 __ASSERT_DEBUG( |
|
214 aCallId <= ( KPEMaximumNumberOfVoiceCalls + KPEMaximumNumberOfDataCalls ), |
|
215 Panic( EPEPanicIndexOutOfRange) ); |
|
216 |
|
217 if( aCallId != KPEEmergencyCallId ) |
|
218 { |
|
219 // Normal Voice Calls |
|
220 for( callIndex = 0; callIndex < iCallArray->Count(); callIndex++ ) |
|
221 { |
|
222 if( aCallId == (*iCallArray)[callIndex]->GetCallId() ) |
|
223 { |
|
224 call = (*iCallArray)[callIndex]; |
|
225 delete call; |
|
226 iCallArray->Remove(callIndex); |
|
227 iCallArray->Compress(); |
|
228 errorCode = KErrNone; |
|
229 break; |
|
230 } |
|
231 } |
|
232 } |
|
233 return errorCode; |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CPECallArrayOwner::Count() |
|
238 // |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 TInt CPECallArrayOwner::Count() const |
|
242 { |
|
243 TEFLOGSTRING2( KTAMESINT, "CALL CPECallArrayOwner::Count %d", iCallArray->Count() ); |
|
244 return iCallArray->Count(); |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CPECallArrayOwner::ActiveCallCount() |
|
249 // |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 EXPORT_C TInt CPECallArrayOwner::ActiveCallCount() const |
|
253 { |
|
254 TInt numberOfCalls = 0; |
|
255 |
|
256 // Count ongoing voice calls |
|
257 numberOfCalls = iCallArray->Count(); |
|
258 |
|
259 for( TInt callIndex = 0; |
|
260 callIndex < iCallArray->Count(); |
|
261 callIndex++ ) |
|
262 { |
|
263 if( EPEStateIdle == (*iCallArray)[callIndex]->GetCallState() ) |
|
264 { |
|
265 numberOfCalls--; |
|
266 } |
|
267 } |
|
268 TEFLOGSTRING2( KTAMESINT, "CALL CPECallArrayOwner::ActiveCallCount %d", numberOfCalls ); |
|
269 |
|
270 return numberOfCalls; |
|
271 } |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CPECallArrayOwner::CreateEmercencyCallL |
|
275 // Method |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 CPESingleCall* CPECallArrayOwner::CreateEmergencyCallL( MPEMessageSender& aOwner ) |
|
279 { |
|
280 TEFLOGSTRING( KTAMESINT, "CALL CPECallArrayOwner::CreateEmercencyCallL"); |
|
281 CPESingleCall* call = GetCallObject( KPEEmergencyCallId ); |
|
282 |
|
283 if( !call ) |
|
284 { |
|
285 call = CPESingleCall::NewL( aOwner ); |
|
286 call->SetCallId( KPEEmergencyCallId ); |
|
287 iCallArray->Append( call ); |
|
288 } |
|
289 else |
|
290 { |
|
291 TEFLOGSTRING( KTAMESINT, "CALL CPECallArrayOwner::CreateEmercencyCallL: Already exist"); |
|
292 User::Leave( KErrAlreadyExists ); |
|
293 } |
|
294 |
|
295 return call; |
|
296 } |
|
297 |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // CPECallArrayOwner::CreateDataCallL |
|
301 // |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 CPESingleCall* CPECallArrayOwner::CreateDataCallL( MPEMessageSender& aOwner ) |
|
305 { |
|
306 TEFLOGSTRING( KTAMESINT, "CALL CPECallArrayOwner::CreateDataCallL"); |
|
307 CPESingleCall* call( NULL ); |
|
308 |
|
309 if( iCallArray->Count() < ( KPEMaximumNumberOfVoiceCalls ) ) |
|
310 { |
|
311 // find free call id |
|
312 for( TInt callId = KPEDataCallIdBase; |
|
313 callId < KPEDataCallIdBase + KPEMaximumNumberOfDataCalls; callId++ ) |
|
314 { |
|
315 if( !GetCallObject( callId ) ) |
|
316 { |
|
317 call = CPESingleCall::NewL( aOwner ); |
|
318 call->SetCallId( callId ); |
|
319 iCallArray->Append( call ); |
|
320 break; |
|
321 } |
|
322 } |
|
323 if( !call ) |
|
324 { |
|
325 // Leave if all datacallids are reserved |
|
326 TEFLOGSTRING( KTAMESINT, "CALL CPECallArrayOwner::CreateCallL all datacallids are reserved Leave( ECCPRequestFailure )"); |
|
327 User::Leave( ECCPRequestFailure ); |
|
328 } |
|
329 } |
|
330 else |
|
331 { |
|
332 TEFLOGSTRING( KTAMESINT, "CALL CPECallArrayOwner::CreateCallL Leave( ECCPRequestFailure )"); |
|
333 User::Leave( ECCPRequestFailure ); |
|
334 } |
|
335 return call; |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------------- |
|
339 // CPECallArrayOwner::CallPointerByState |
|
340 // returns CPESingleCall voice call object by State, NULL if not found |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 CPESingleCall* CPECallArrayOwner::CallPointerByState( |
|
344 TPEState aState ) const |
|
345 { |
|
346 CPESingleCall* returnValue = NULL; |
|
347 |
|
348 TEFLOGSTRING2( |
|
349 KTAREQEND, |
|
350 "CALL CPECallHandling::CallPointerByState: asked aState: %d", |
|
351 aState ); |
|
352 |
|
353 for( TInt callIndex = 0; |
|
354 callIndex < iCallArray->Count(); |
|
355 callIndex++ ) |
|
356 { |
|
357 if( aState == (*iCallArray)[callIndex]->GetCallState() ) |
|
358 { |
|
359 TEFLOGSTRING2( |
|
360 KTAREQEND, |
|
361 "CALL CPECallHandling::CallPointerByState: callIndex: %d", |
|
362 callIndex ); |
|
363 returnValue = (*iCallArray)[callIndex]; |
|
364 break; |
|
365 } |
|
366 } |
|
367 |
|
368 return returnValue; |
|
369 } |
|
370 |
|
371 // ----------------------------------------------------------------------------- |
|
372 // CPECallArrayOwner::IsCallByState |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 EXPORT_C TBool CPECallArrayOwner::IsCallByState( |
|
376 const TPEState aState ) const |
|
377 { |
|
378 TEFLOGSTRING2( |
|
379 KTAREQEND, |
|
380 "CALL CPECallHandling::CallByState: asked aState: %d", |
|
381 aState ); |
|
382 |
|
383 return CallByState( aState ) ? ETrue : EFalse; |
|
384 } |
|
385 |
|
386 // ----------------------------------------------------------------------------- |
|
387 // CPECallArrayOwner::IsCallByCallId |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 EXPORT_C TBool CPECallArrayOwner::IsCallByCallId( |
|
391 const TInt aCallId ) const |
|
392 { |
|
393 TEFLOGSTRING2( |
|
394 KTAREQEND, |
|
395 "CALL CPECallHandling::CallByCallId: asked aCallId: %d", |
|
396 aCallId ); |
|
397 |
|
398 return GetCallObject( aCallId ) ? ETrue : EFalse; |
|
399 } |
|
400 |
|
401 // ----------------------------------------------------------------------------- |
|
402 // CPECallArrayOwner::CallByState |
|
403 // ----------------------------------------------------------------------------- |
|
404 // |
|
405 EXPORT_C MPECall* CPECallArrayOwner::CallByState( |
|
406 const TPEState aState ) const |
|
407 { |
|
408 TEFLOGSTRING2( |
|
409 KTAREQEND, |
|
410 "CALL CPECallHandling::CallByState: asked aState: %d", |
|
411 aState ); |
|
412 |
|
413 return CallPointerByState( aState ); |
|
414 } |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // CPECallArrayOwner::CallByCallId |
|
418 // ----------------------------------------------------------------------------- |
|
419 // |
|
420 EXPORT_C MPECall* CPECallArrayOwner::CallByCallId( |
|
421 const TInt aCallId ) const |
|
422 { |
|
423 TEFLOGSTRING2( |
|
424 KTAREQEND, |
|
425 "CALL CPECallHandling::CallByCallId: asked aCallId: %d", |
|
426 aCallId ); |
|
427 |
|
428 return GetCallObject( aCallId ); |
|
429 } |
|
430 |
|
431 // ----------------------------------------------------------------------------- |
|
432 // CPECallArrayOwner::CallByName |
|
433 // ----------------------------------------------------------------------------- |
|
434 // |
|
435 EXPORT_C MPECall* CPECallArrayOwner::CallByName( |
|
436 const TName& aName ) const |
|
437 { |
|
438 TEFLOGSTRING2( |
|
439 KTAREQEND, |
|
440 "CALL CPECallHandling::CallByName: aName: %S", |
|
441 &aName ); |
|
442 return CallPointerByName( aName ); |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CPECallArrayOwner::CallPointerByName |
|
447 // ----------------------------------------------------------------------------- |
|
448 // |
|
449 CPESingleCall* CPECallArrayOwner::CallPointerByName( |
|
450 const TName& aName ) const |
|
451 { |
|
452 CPESingleCall* call( NULL ); |
|
453 for ( TInt index=0; index < Count(); index++ ) |
|
454 { |
|
455 CPESingleCall* callData = GetCallObjectByIndex( index ); |
|
456 if( callData ) |
|
457 { |
|
458 RMobileCall::TMobileCallInfoV3 callInfo; |
|
459 callData->GetCallInfo( callInfo ); |
|
460 if( callInfo.iCallName == aName ) |
|
461 { |
|
462 call = callData; |
|
463 break; |
|
464 } |
|
465 } |
|
466 } |
|
467 TEFLOGSTRING2( |
|
468 KTAREQEND, |
|
469 "CALL CPECallHandling::CallPointerByName: call: %d", |
|
470 call ); |
|
471 return call; |
|
472 } |
|
473 |
|
474 // ================= OTHER EXPORTED FUNCTIONS ============================== |
|
475 |
|
476 // End of File |