|
1 |
|
2 // Copyright (c) 2001-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: |
|
15 // This file contains the implementation for the functionality common to all |
|
16 // the specific line classes, such as CSimVoiceLine and CSimDataline. |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 */ |
|
23 |
|
24 #include <testconfigfileparser.h> |
|
25 #include "CSimLine.h" |
|
26 #include "CSimPhone.h" |
|
27 #include "CSimCall.h" |
|
28 #include "Simlog.h" |
|
29 #include "CSimPubSub.h" |
|
30 |
|
31 void CSimLine::CloseLine(TAny* aObj) |
|
32 /** |
|
33 * Utility func for cleanup stack |
|
34 * |
|
35 * @param aObj a pointer to the CObject to close |
|
36 */ |
|
37 { |
|
38 ((CObject*)aObj)->Close(); |
|
39 } |
|
40 |
|
41 CSimLine::CSimLine(CSimPhone* aPhone) |
|
42 :iPhone(aPhone), iState(RMobileCall::EStatusIdle), |
|
43 iHookState(ConvertStateToHook(iState)) |
|
44 { |
|
45 iNameOfLastCallAdded.Zero(); |
|
46 iNotifyStatusChange.iNotifyPending = EFalse; |
|
47 iNotifyMobileStatusChange.iNotifyPending = EFalse; |
|
48 } |
|
49 |
|
50 void CSimLine::ConstructL(const TName& aName) |
|
51 /** |
|
52 * Second phase of two phase constructor. |
|
53 * Creates the System Agent object for incoming call notification and other notifications. |
|
54 * |
|
55 * @param aName name of the Line to be created. |
|
56 */ |
|
57 { |
|
58 LOGLINE2(">>CSimLine::ConstructL [aLineName=%S]", &aName); |
|
59 iLineName = aName; |
|
60 iSimPubSubIC = CSimPubSub::NewL(this,iICProperty); |
|
61 iSimPubSubIC->Start(); |
|
62 |
|
63 iSimPubSubRH = CSimPubSub::NewL(this,iRHProperty); |
|
64 iSimPubSubRH->Start(); |
|
65 |
|
66 iNotifyIncomingCallPause=this->CfgFile()->ItemValue(KNotifyIncomingCallPauseDuration,KDefaultNotifyIncomingCallPauseDuration); |
|
67 |
|
68 iTimer = CSimTimer::NewL(iPhone); |
|
69 LOGLINE1("<<CSimLine::ConstructL"); |
|
70 } |
|
71 |
|
72 CSimLine::~CSimLine() |
|
73 /** |
|
74 * Standard destructor. |
|
75 */ |
|
76 { |
|
77 delete iSimPubSubIC; |
|
78 delete iSimPubSubRH; |
|
79 iTimer->Cancel(); |
|
80 delete iTimer; |
|
81 } |
|
82 |
|
83 |
|
84 void CSimLine::UpdatePhoneNotifiers(CSimCall* aCall,TUint /*aStatus*/) |
|
85 { |
|
86 TInt count= iCalls->Count(); |
|
87 TInt i=0; |
|
88 while(i<count) |
|
89 { |
|
90 if(iCalls->At(i) != aCall && (iCalls->At(i)->iState == RMobileCall::EStatusHold || iCalls->At(i)->iState == RMobileCall::EStatusConnected)) |
|
91 iCalls->At(i)->UpdateNotifiers(); |
|
92 i++; |
|
93 } |
|
94 } |
|
95 |
|
96 CTelObject::TReqMode CSimLine::ReqModeL(const TInt aIpc) |
|
97 /** |
|
98 * This function returns the Request Mode for the request with the passed IPC value. |
|
99 * The ETel Server provides a function for returning the standard request modes for |
|
100 * the Core API requests. |
|
101 * Multimode API requests mode are handled here. |
|
102 * |
|
103 * @param aIpc the IPc number representing the client request |
|
104 * @return CTelObject::TReqMode the request mode to be used for this IPc number |
|
105 * @leave Leaves if the IPc number is not found |
|
106 */ |
|
107 { |
|
108 // ReqModeL is called from the server's CTelObject::ReqAnalyserL |
|
109 // in order to check the type of request it has |
|
110 |
|
111 CTelObject::TReqMode reqMode=0; |
|
112 switch (aIpc) |
|
113 { |
|
114 // |
|
115 // No Flow Control NOR Multiple Completion |
|
116 // |
|
117 case EMobileLineGetMobileLineStatus: |
|
118 break; |
|
119 |
|
120 // |
|
121 // Multiple Completion Services with Immediate Server Repost |
|
122 // (Usually Notifications) |
|
123 // |
|
124 case EMobileLineNotifyMobileLineStatusChange: |
|
125 reqMode=KReqModeMultipleCompletionEnabled | KReqModeRePostImmediately; |
|
126 break; |
|
127 // |
|
128 // Must be a core API request so get request mode from Etel |
|
129 // |
|
130 default: |
|
131 reqMode=CLineBase::ReqModeL(aIpc); |
|
132 break; |
|
133 } |
|
134 |
|
135 return reqMode; |
|
136 } |
|
137 |
|
138 |
|
139 TInt CSimLine::NumberOfSlotsL(const TInt aIpc) |
|
140 /** |
|
141 * NumberOfSlotsL is called by the server when it is registering a new notification |
|
142 * It enables the TSY to tell the server how many buffer slots to allocate for |
|
143 * "repost immediately" notifications that may trigger before clients collect them |
|
144 * |
|
145 * @param aIpc the IPc number representing the client request |
|
146 * @return TInt the number of slots required |
|
147 * @leave Leaves if the IPc number is not found |
|
148 */ |
|
149 { |
|
150 switch (aIpc) |
|
151 { |
|
152 case EMobileLineNotifyMobileLineStatusChange: |
|
153 LOGLINE1("CLineMobile: Registered with the default number of slots"); |
|
154 return KDefaultNumberOfSlots; |
|
155 |
|
156 default: |
|
157 LOGLINE1("CSimLine::NumberOfSlotsL: No match for IPC, defering to base function"); |
|
158 break; |
|
159 } |
|
160 return CLineBase::NumberOfSlotsL(aIpc); |
|
161 } |
|
162 |
|
163 |
|
164 TInt CSimLine::RegisterNotification(const TInt /*aIpc*/) |
|
165 /** |
|
166 * The ETel Server calls this function when the first client makes a notification request. |
|
167 * If supported by the underlying protocol controlling the signalling stack, |
|
168 * this can be used to start requesting updates for the relevant service. |
|
169 */ |
|
170 { |
|
171 return KErrNone; |
|
172 } |
|
173 |
|
174 TInt CSimLine::DeregisterNotification(const TInt /*aIpc*/) |
|
175 /** |
|
176 * The ETel Server calls this function when the last client that had previously |
|
177 * made a notification request closes its ETel Server handle. If supported by |
|
178 * the underlying protocol controlling the signalling stack, this can be used |
|
179 * to stop requesting updates for the relevant service. |
|
180 */ |
|
181 { |
|
182 return KErrNone; |
|
183 } |
|
184 |
|
185 void CSimLine::Init() |
|
186 /** |
|
187 * This function can be used to perform any necessary synchronous initialisation. |
|
188 */ |
|
189 {} |
|
190 |
|
191 TInt CSimLine::NotifyIncomingCall(const TTsyReqHandle aTsyReqHandle, TName* aName) |
|
192 /** |
|
193 * Register a client's interest in an incoming call notification. |
|
194 * Core ETel API Request. |
|
195 * |
|
196 * @param aTsyReqHandle Tsy Request handle for the client request |
|
197 * @param aName pointer to the name of the call |
|
198 * @return KErrNone |
|
199 */ |
|
200 { |
|
201 LOGLINE1(">>CSimLine::NotifyIncomingCall"); |
|
202 iNotifyIncomingCall.iNotifyPending=ETrue; |
|
203 iNotifyIncomingCall.iNotifyHandle=aTsyReqHandle; |
|
204 iNotifyIncomingCall.iNotifyData=(TAny*)aName; |
|
205 LOGLINE1("<<CSimLine::NotifyIncomingCall"); |
|
206 return KErrNone; |
|
207 } |
|
208 |
|
209 TInt CSimLine::NotifyIncomingCallCancel(const TTsyReqHandle /*aTsyReqHandle*/) |
|
210 /** |
|
211 * Cancels a client's interest in an incoming call. |
|
212 * Core ETel API Request. |
|
213 * |
|
214 * @param aTsyReqHandle Tsy Request handle for the client cancel request |
|
215 * @return KErrNone |
|
216 */ |
|
217 { |
|
218 LOGLINE1(">>CSimLine::NotifyIncomingCallCancel"); |
|
219 if(iNotifyIncomingCall.iNotifyPending) |
|
220 { |
|
221 iTimer->Cancel(); |
|
222 iNotifyIncomingCall.iNotifyPending=EFalse; |
|
223 ReqCompleted(iNotifyIncomingCall.iNotifyHandle, KErrCancel); |
|
224 } |
|
225 LOGLINE1("<<CSimLine::NotifyIncomingCallCancel"); |
|
226 return KErrNone; |
|
227 } |
|
228 |
|
229 TInt CSimLine::NotifyHookChange(const TTsyReqHandle aTsyReqHandle, RCall::THookStatus* aHookStatus) |
|
230 /** |
|
231 * Record a client's interst in being notified when the line hook changes state. |
|
232 * Core ETel API Request. |
|
233 * |
|
234 * @param aTsyReqHandle Tsy Request handle for the client request |
|
235 * @param aHookStatus pointer to the line hook |
|
236 * @return KErrNone |
|
237 */ |
|
238 { |
|
239 LOGLINE1(">>CSimLine::NotifyHookChange"); |
|
240 iNotifyHookChange.iNotifyPending=ETrue; |
|
241 iNotifyHookChange.iNotifyHandle=aTsyReqHandle; |
|
242 iNotifyHookChange.iNotifyData=(TAny*)aHookStatus; |
|
243 LOGLINE1("<<CSimLine::NotifyHookChange"); |
|
244 return KErrNone; |
|
245 } |
|
246 |
|
247 TInt CSimLine::NotifyHookChangeCancel(const TTsyReqHandle /*aTsyReqHandle*/) |
|
248 /** |
|
249 * Cancel a client's interest in being notified when the line hook changes state. |
|
250 * Core ETel API Request. |
|
251 * |
|
252 * @param aTsyReqHandle Tsy Request handle for the client cancel request |
|
253 * @return KErrNone |
|
254 */ |
|
255 { |
|
256 LOGLINE1(">>CSimLine::NotifyHookChangeCancel"); |
|
257 if(iNotifyHookChange.iNotifyPending) |
|
258 { |
|
259 iNotifyHookChange.iNotifyPending=EFalse; |
|
260 ReqCompleted(iNotifyHookChange.iNotifyHandle,KErrCancel); |
|
261 } |
|
262 LOGLINE1("<<CSimLine::NotifyHookChangeCancel"); |
|
263 return KErrNone; |
|
264 } |
|
265 |
|
266 |
|
267 TInt CSimLine::NotifyMobileLineStatusChange(const TTsyReqHandle aTsyReqHandle, RMobileCall::TMobileCallStatus* aStatus) |
|
268 /** |
|
269 * Record a client's interst in being notified when the line changes state. (Multimode) |
|
270 * MM ETel API Request. |
|
271 * |
|
272 * @param aTsyReqHandle Tsy Request handle for the client request |
|
273 * @param aStatus pointer to the line status |
|
274 * @return KErrNone |
|
275 */ |
|
276 { |
|
277 LOGLINE1(">>CSimLine::NotifyMobileLineStatusChange"); |
|
278 iNotifyMobileStatusChange.iNotifyPending=ETrue; |
|
279 iNotifyMobileStatusChange.iNotifyHandle=aTsyReqHandle; |
|
280 iNotifyMobileStatusChange.iNotifyData=aStatus; |
|
281 LOGLINE1("<<CSimLine::NotifyMobileLineStatusChange"); |
|
282 return KErrNone; |
|
283 } |
|
284 |
|
285 TInt CSimLine::NotifyMobileLineStatusChangeCancel(const TTsyReqHandle /*aTsyReqHandle*/) |
|
286 /** |
|
287 * Cancel a client's interest in being notified when the line changes state.(Multimode Request) |
|
288 * MM ETel API Request. |
|
289 * |
|
290 * @param aTsyReqHandle Tsy Request handle for the client cancel request |
|
291 * @return KErrNone |
|
292 */ |
|
293 { |
|
294 LOGLINE1(">>CSimLine::NotifyMobileLineStatusChangeCancel"); |
|
295 if(iNotifyMobileStatusChange.iNotifyPending) |
|
296 { |
|
297 iNotifyMobileStatusChange.iNotifyPending=EFalse; |
|
298 ReqCompleted(iNotifyMobileStatusChange.iNotifyHandle,KErrCancel); |
|
299 } |
|
300 LOGLINE1("<<CSimLine::NotifyMobileLineStatusChangeCancel"); |
|
301 return KErrNone; |
|
302 } |
|
303 |
|
304 TInt CSimLine::NotifyStatusChange(const TTsyReqHandle aTsyReqHandle, RCall::TStatus* aStatus) |
|
305 /** |
|
306 * Record a client's interst in being notified when the line changes state. (Core) |
|
307 * Core ETel API Request. |
|
308 * |
|
309 * @param aTsyReqHandle Tsy Request handle for the client request |
|
310 * @param aStatus pointer to the line status |
|
311 * @return KErrNone |
|
312 */ |
|
313 { |
|
314 LOGLINE1(">>CSimLine::NotifyStatusChange"); |
|
315 iNotifyStatusChange.iNotifyPending=ETrue; |
|
316 iNotifyStatusChange.iNotifyHandle=aTsyReqHandle; |
|
317 iNotifyStatusChange.iNotifyData=aStatus; |
|
318 LOGLINE1("<<CSimLine::NotifyStatusChange"); |
|
319 return KErrNone; |
|
320 } |
|
321 |
|
322 TInt CSimLine::NotifyStatusChangeCancel(const TTsyReqHandle /*aTsyReqHandle*/) |
|
323 /** |
|
324 * Cancel a client's interest in being notified when the line changes state.(Multimode Request) |
|
325 * Core ETel API Request. |
|
326 * |
|
327 * @param aTsyReqHandle Tsy Request handle for the client cancel request |
|
328 * @return KErrNone |
|
329 */ |
|
330 { |
|
331 LOGLINE1(">>CSimLine::NotifyStatusChangeCancel"); |
|
332 if(iNotifyStatusChange.iNotifyPending) |
|
333 { |
|
334 iNotifyStatusChange.iNotifyPending=EFalse; |
|
335 ReqCompleted(iNotifyStatusChange.iNotifyHandle,KErrCancel); |
|
336 } |
|
337 LOGLINE1("<<CSimLine::NotifyStatusChangeCancel"); |
|
338 return KErrNone; |
|
339 } |
|
340 |
|
341 TInt CSimLine::NotifyCallAdded(const TTsyReqHandle aTsyReqHandle,TName* aName) |
|
342 /** |
|
343 * Record a client's interest in being notified when a new call is added. |
|
344 * Core ETel API Request. |
|
345 * |
|
346 * @param aTsyReqHandle Tsy Request handle for the client request |
|
347 * @param aName pointer to the name of the call |
|
348 * @return KErrNone |
|
349 */ |
|
350 { |
|
351 LOGLINE1(">>CSimLine::NotifyCallAdded"); |
|
352 iNotifyCallAdded.iNotifyPending=ETrue; |
|
353 iNotifyCallAdded.iNotifyHandle=aTsyReqHandle; |
|
354 iNotifyCallAdded.iNotifyData=(TAny*)aName; |
|
355 LOGLINE1("<<CSimLine::NotifyCallAdded"); |
|
356 return KErrNone; |
|
357 } |
|
358 |
|
359 TInt CSimLine::NotifyCallAddedCancel(const TTsyReqHandle /*aTsyReqHandle*/) |
|
360 /** |
|
361 * Cancel a client's interest in being notified when a new call is added. |
|
362 * Core ETel API Request. |
|
363 * |
|
364 * @param aTsyReqHandle Tsy Request handle for the client cancel request |
|
365 * @return KErrNone |
|
366 */ |
|
367 { |
|
368 LOGLINE1(">>CSimLine::NotifyCallAddedCancel"); |
|
369 if(iNotifyCallAdded.iNotifyPending) |
|
370 { |
|
371 iNotifyCallAdded.iNotifyPending=EFalse; |
|
372 ReqCompleted(iNotifyCallAdded.iNotifyHandle,KErrCancel); |
|
373 } |
|
374 LOGLINE1("<<CSimLine::NotifyCallAddedCancel"); |
|
375 return KErrNone; |
|
376 } |
|
377 |
|
378 |
|
379 void CSimLine::HandleNewCallAddedNotification(const TDesC& aNewName) |
|
380 /** |
|
381 * Process a potential "New Call Added Notification" completion. |
|
382 */ |
|
383 { |
|
384 LOGLINE1(">>CSimLine::HandleNewCallAddedNotification"); |
|
385 iNameOfLastCallAdded.Copy(aNewName); |
|
386 if(iNotifyCallAdded.iNotifyPending) |
|
387 { |
|
388 iNotifyCallAdded.iNotifyPending=EFalse; |
|
389 ((TName*)iNotifyCallAdded.iNotifyData)->Copy(aNewName); |
|
390 ReqCompleted(iNotifyCallAdded.iNotifyHandle,KErrNone); |
|
391 } |
|
392 LOGLINE1("<<CSimLine::HandleNewCallAddedNotification"); |
|
393 } |
|
394 |
|
395 TInt CSimLine::GetCaps(const TTsyReqHandle aTsyReqHandle, RLine::TCaps* aCaps) |
|
396 /** |
|
397 * Retrieve the current line capabilities. |
|
398 * Core ETel API Request. |
|
399 * |
|
400 * @param aTsyReqHandle TSY request handle associated with this request. |
|
401 * @param aCaps Point to capability structure that will be populated with the caps. |
|
402 * @return TInt Standard return value. |
|
403 */ |
|
404 { |
|
405 aCaps->iFlags=iCaps; |
|
406 ReqCompleted(aTsyReqHandle,KErrNone); |
|
407 return KErrNone; |
|
408 } |
|
409 |
|
410 TInt CSimLine::NotifyCapsChange(const TTsyReqHandle aTsyReqHandle, RLine::TCaps* aCaps) |
|
411 /** |
|
412 * Register a client's interest in being notified when the line caps change. |
|
413 * Core ETel API Request. |
|
414 * |
|
415 * @param aTsyReqHandle The TSY handle associated with this request. |
|
416 * @param aCaps The capability structure that will be populated with the new capability |
|
417 * information. |
|
418 * @return TInt Standard error code. |
|
419 */ |
|
420 { |
|
421 __ASSERT_ALWAYS(!iNotifyCapsChange.iNotifyPending,SimPanic(ENotificationReqAlreadyOutstanding)); |
|
422 iNotifyCapsChange.iNotifyPending=ETrue; |
|
423 iNotifyCapsChange.iNotifyHandle=aTsyReqHandle; |
|
424 iNotifyCapsChange.iNotifyData=aCaps; |
|
425 return KErrNone; |
|
426 } |
|
427 |
|
428 TInt CSimLine::NotifyCapsChangeCancel(const TTsyReqHandle /*aTsyReqHandle*/) |
|
429 /** |
|
430 * Cancel a client's interest in being notified when the call capabilities change. |
|
431 * Core ETel API Request. |
|
432 */ |
|
433 { |
|
434 if(iNotifyCapsChange.iNotifyPending) |
|
435 { |
|
436 iNotifyCapsChange.iNotifyPending=EFalse; |
|
437 ReqCompleted(iNotifyCapsChange.iNotifyHandle,KErrCancel); |
|
438 } |
|
439 return KErrNone; |
|
440 } |
|
441 |
|
442 TInt CSimLine::GetInfo(const TTsyReqHandle aTsyReqHandle, RMobileLine::TLineInfo* aLineInfo) |
|
443 /** |
|
444 * Retrieve the Line Information |
|
445 * Core ETel API Request. |
|
446 * |
|
447 * @param aTsyReqHandle |
|
448 * @param aLineInfo pointer to the line information to be returned to client |
|
449 * @return KErrNone |
|
450 */ |
|
451 { |
|
452 LOGLINE1(">>CSimLine::GetInfo"); |
|
453 aLineInfo->iHookStatus=iHookState; |
|
454 aLineInfo->iStatus=(RCall::TStatus)iState; |
|
455 aLineInfo->iNameOfLastCallAdded.Copy(iNameOfLastCallAdded); |
|
456 if(iAnswerNextIncomingCall) |
|
457 aLineInfo->iNameOfCallForAnswering.Copy(iAnswerNextIncomingCall->iName); |
|
458 else |
|
459 aLineInfo->iNameOfCallForAnswering.Zero(); |
|
460 |
|
461 ReqCompleted(aTsyReqHandle,KErrNone); |
|
462 LOGLINE1("<<CSimLine::GetInfo"); |
|
463 return KErrNone; |
|
464 } |
|
465 |
|
466 |
|
467 RCall::TStatus CSimLine::GetCoreLineStatus() |
|
468 /** |
|
469 * Converts Multimode call status (RMobileCall::TMobileCallStatus) to |
|
470 * Core call Status (RCall::TStatus) |
|
471 * |
|
472 * @return RCall::TStatus The core call status |
|
473 */ |
|
474 { |
|
475 // All status enums with values of Disconnecting and below are identical in |
|
476 // ETelMM and Core, so the mapping function is simple. |
|
477 RCall::TStatus coreStatus; |
|
478 if (iState <= RMobileCall::EStatusDisconnecting) |
|
479 coreStatus = (RCall::TStatus)iState; |
|
480 else |
|
481 switch (iState) |
|
482 { |
|
483 case RMobileCall::EStatusReconnectPending: |
|
484 case RMobileCall::EStatusHold: |
|
485 coreStatus = RCall::EStatusConnected; |
|
486 break; |
|
487 case RMobileCall::EStatusWaitingAlternatingCallSwitch: |
|
488 coreStatus = RCall::EStatusIdle; |
|
489 break; |
|
490 default: |
|
491 coreStatus = RCall::EStatusUnknown; |
|
492 break; |
|
493 } |
|
494 return coreStatus; |
|
495 } |
|
496 |
|
497 TInt CSimLine::GetStatus(const TTsyReqHandle aTsyReqHandle,RCall::TStatus* aLineStatus) |
|
498 /** |
|
499 * Return the current line state. (Core API request) |
|
500 * Core ETel API Request. |
|
501 * |
|
502 * @param aTsyReqHandle |
|
503 * @param aLineStatus pointer to the line status |
|
504 * @return KErrNone |
|
505 */ |
|
506 { |
|
507 LOGLINE1(">>CSimLine::GetStatus"); |
|
508 *aLineStatus=GetCoreLineStatus(); |
|
509 ReqCompleted(aTsyReqHandle,KErrNone); |
|
510 LOGLINE1("<<CSimLine::GetStatus"); |
|
511 return KErrNone; |
|
512 } |
|
513 |
|
514 TInt CSimLine::GetMobileLineStatus(const TTsyReqHandle aTsyReqHandle,RMobileCall::TMobileCallStatus* aLineStatus) |
|
515 /** |
|
516 * Return the current line state. (MultiMode API request) |
|
517 * MM ETel API Request. |
|
518 * |
|
519 * @param aTsyReqHandle |
|
520 * @param aLineStatus pointer to the line status |
|
521 * @return KErrNone |
|
522 */ |
|
523 { |
|
524 LOGLINE1(">>CSimLine::GetMobileLineStatus"); |
|
525 *aLineStatus=iState; |
|
526 ReqCompleted(aTsyReqHandle,KErrNone); |
|
527 LOGLINE1("<<CSimLine::GetMobileLineStatus"); |
|
528 return KErrNone; |
|
529 } |
|
530 |
|
531 TInt CSimLine::GetHookStatus(const TTsyReqHandle aTsyReqHandle,RCall::THookStatus* aHookStatus) |
|
532 /** |
|
533 * Return the current Hook state. |
|
534 * Core ETel API Request. |
|
535 * |
|
536 * @param aTsyReqHandle |
|
537 * @param aHookStatus pointer to the hook status |
|
538 * @return KErrNone |
|
539 */ |
|
540 { |
|
541 LOGLINE1(">>CSimLine::GetHookStatus"); |
|
542 *aHookStatus=iHookState; |
|
543 ReqCompleted(aTsyReqHandle,KErrNone); |
|
544 LOGLINE1("<<CSimLine::GetHookStatus"); |
|
545 return KErrNone; |
|
546 } |
|
547 |
|
548 const CTestConfigSection* CSimLine::CfgFile() |
|
549 /** |
|
550 * Returns a pointer to the config file section |
|
551 * |
|
552 * @return CTestConfig a pointer to the configuration file data section |
|
553 */ |
|
554 { |
|
555 LOGLINE1(">>CSimLine::CfgFile"); |
|
556 return iPhone->CfgFile(); |
|
557 } |
|
558 |
|
559 TInt CSimLine::ChangeStateL(RMobileCall::TMobileCallStatus aNewState,TBool aSwap,CSimCall* aOriginatingCall) |
|
560 /** |
|
561 * Validate and change the Line State |
|
562 * |
|
563 * @param aNewState the new state to change to |
|
564 * @param aSwap indicates whether change comes from swap operation on the call |
|
565 * @param aOriginatingCall original call that change comes from |
|
566 * @return Error indication if change of state is successful or not |
|
567 */ |
|
568 { |
|
569 __ASSERT_ALWAYS(aNewState!=RMobileCall::EStatusUnknown,SimPanic(ECallStatusUnknownIllegal)); |
|
570 __ASSERT_ALWAYS(iState!=RMobileCall::EStatusUnknown,SimPanic(ECallStatusUnknownIllegal)); |
|
571 CSimCall* swappedCall=NULL; |
|
572 TInt i=0; |
|
573 TInt count=iCalls->Count(); |
|
574 for(i=0;i<count;i++) |
|
575 { |
|
576 LOGLINE3(">>CSimLine::ChangeState0 0x%08x %d",iCalls->At(i),iCalls->At(i)->iState); |
|
577 } |
|
578 |
|
579 TInt ret=KErrGeneral; |
|
580 const TStateChangeValidity* stateChangePnt=KLineStateChangeValidity; |
|
581 while(stateChangePnt->iOldState!=KStateTableTerminator) |
|
582 { |
|
583 if((stateChangePnt->iOldState==iState) && |
|
584 ((stateChangePnt->iNewState==aNewState) || aNewState==RMobileCall::EStatusIdle)) |
|
585 { |
|
586 ret=stateChangePnt->iError; |
|
587 break; |
|
588 } |
|
589 stateChangePnt++; |
|
590 } |
|
591 |
|
592 //coverity[cannot_single] |
|
593 if(ret!=KErrNone && !(aSwap && iState==RMobileCall::EStatusConnected && aNewState==RMobileCall::EStatusConnected)) |
|
594 return ret; |
|
595 |
|
596 LOGLINE2(">>CSimLine::ChangeState 0x%08x",aOriginatingCall); |
|
597 if(aNewState==RMobileCall::EStatusIdle) |
|
598 { |
|
599 if(iState==RMobileCall::EStatusIdle) |
|
600 return KErrAlreadyExists; |
|
601 else if(iState==RMobileCall::EStatusDisconnecting || iState==RMobileCall::EStatusDialling) |
|
602 { |
|
603 TInt i=0; |
|
604 TInt count=iCalls->Count(); |
|
605 for(i=0;i<count;i++) |
|
606 { |
|
607 LOGLINE3(">>CSimLine::ChangeState1 0x%08x %d",iCalls->At(i),iCalls->At(i)->iState); |
|
608 |
|
609 if(aOriginatingCall!=iCalls->At(i) && iCalls->At(i)->iState != RMobileCall::EStatusIdle) |
|
610 { |
|
611 aNewState=iCalls->At(i)->iState; |
|
612 break; |
|
613 } |
|
614 } |
|
615 } |
|
616 } |
|
617 else if(aNewState==RMobileCall::EStatusHold) |
|
618 { |
|
619 if((iState == RMobileCall::EStatusRinging) && |
|
620 (aNewState == RMobileCall::EStatusHold)) |
|
621 { |
|
622 if(aOriginatingCall->iState != RMobileCall::EStatusConnected) |
|
623 return KErrGeneral; |
|
624 aNewState=RMobileCall::EStatusRinging; |
|
625 } |
|
626 TInt i=0; |
|
627 TInt count=iCalls->Count(); |
|
628 for(i=0;i<count;i++) |
|
629 { |
|
630 LOGLINE3(">>CSimLine::ChangeState1 0x%08x %d",iCalls->At(i),iCalls->At(i)->iState); |
|
631 if(iCalls->At(i) != aOriginatingCall && iCalls->At(i)->iState == RMobileCall::EStatusHold) |
|
632 { |
|
633 if(aSwap) |
|
634 { |
|
635 swappedCall=iCalls->At(i); |
|
636 swappedCall->iState=RMobileCall::EStatusConnected; |
|
637 aNewState=RMobileCall::EStatusConnected; |
|
638 } |
|
639 else |
|
640 return KErrAlreadyExists; |
|
641 } |
|
642 } |
|
643 } |
|
644 else if(aNewState==RMobileCall::EStatusConnected) |
|
645 { |
|
646 TInt i=0; |
|
647 TInt count=iCalls->Count(); |
|
648 for(i=0;i<count;i++) |
|
649 { |
|
650 LOGLINE3(">>CSimLine::ChangeState1 0x%08x %d",iCalls->At(i),iCalls->At(i)->iState); |
|
651 if(iCalls->At(i) != aOriginatingCall) |
|
652 { |
|
653 if(iCalls->At(i)->iState == RMobileCall::EStatusConnected) |
|
654 { |
|
655 //coverity[dead_error_condition] |
|
656 if(aSwap) |
|
657 { |
|
658 swappedCall=iCalls->At(i); |
|
659 swappedCall->iState=RMobileCall::EStatusHold; |
|
660 aNewState=RMobileCall::EStatusConnected; |
|
661 break; |
|
662 } |
|
663 else |
|
664 //coverity[dead_error_line] |
|
665 return KErrAlreadyExists; |
|
666 } |
|
667 } |
|
668 } |
|
669 } |
|
670 |
|
671 // Actually change the state. |
|
672 LOGLINE3(">>CSimLine::ChangeState [oldState=%d] [newState=%d]", iState, aNewState); |
|
673 |
|
674 if(iState != aNewState) |
|
675 { |
|
676 iState=aNewState; |
|
677 |
|
678 // Check for a pending line state notification (core) |
|
679 if(iNotifyStatusChange.iNotifyPending) |
|
680 { |
|
681 iNotifyStatusChange.iNotifyPending=EFalse; |
|
682 *(RCall::TStatus*)iNotifyStatusChange.iNotifyData=GetCoreLineStatus(); |
|
683 ReqCompleted(iNotifyStatusChange.iNotifyHandle,KErrNone); |
|
684 } |
|
685 |
|
686 // Check for a pending line state notification (multimode) |
|
687 if(iNotifyMobileStatusChange.iNotifyPending) |
|
688 { |
|
689 iNotifyMobileStatusChange.iNotifyPending=EFalse; |
|
690 *(RMobileCall::TMobileCallStatus*)iNotifyMobileStatusChange.iNotifyData=iState; |
|
691 ReqCompleted(iNotifyMobileStatusChange.iNotifyHandle,KErrNone); |
|
692 } |
|
693 |
|
694 // Check for a pending hook state notification. |
|
695 if(iHookState!=ConvertStateToHook(iState)) |
|
696 { |
|
697 iHookState=ConvertStateToHook(iState); |
|
698 if(iNotifyHookChange.iNotifyPending) |
|
699 { |
|
700 iNotifyHookChange.iNotifyPending=EFalse; |
|
701 *(RCall::THookStatus*)iNotifyHookChange.iNotifyData=iHookState; |
|
702 ReqCompleted(iNotifyHookChange.iNotifyHandle,KErrNone); |
|
703 } |
|
704 } |
|
705 } |
|
706 // Check for a possible change in capabilities. |
|
707 TUint caps=Caps(); |
|
708 if(iCaps!=caps) |
|
709 { |
|
710 iCaps=caps; |
|
711 if(iNotifyCapsChange.iNotifyPending) |
|
712 { |
|
713 iNotifyCapsChange.iNotifyPending=EFalse; |
|
714 ((RLine::TCaps*)iNotifyCapsChange.iNotifyData)->iFlags=iCaps; |
|
715 ReqCompleted(iNotifyCapsChange.iNotifyHandle,KErrNone); |
|
716 } |
|
717 } |
|
718 |
|
719 if(aSwap && swappedCall) |
|
720 swappedCall->UpdateNotifiers(); |
|
721 // Request that the phone change its state, to ensure its in step. |
|
722 if((ret = iPhone->ValidateChangeState(this,aNewState)) != KErrNone) |
|
723 return ret; |
|
724 |
|
725 for(i=0;i<iCalls->Count();i++) |
|
726 { |
|
727 LOGLINE3(">>CSimLine::ChangeState5 0x%08x %d",iCalls->At(i),iCalls->At(i)->iState); |
|
728 } |
|
729 |
|
730 LOGLINE1("<<CSimLine::ChangeState"); |
|
731 return KErrNone; |
|
732 } |
|
733 |
|
734 void CSimLine::SimPSEvent(const CSimPubSub::TPubSubProperty aProperty, TInt /*aStatus*/) |
|
735 /** |
|
736 Handles the P&S notifications for the Line class |
|
737 |
|
738 @param aProperty The property key representing the notification. |
|
739 */ |
|
740 { |
|
741 LOGLINE1(">>CSimLine::SimPSEvent"); |
|
742 if(aProperty==iICProperty) // check for this here still, start the timer for amount specified in config file. |
|
743 ProcessIncomingCallEvent(); |
|
744 if(aProperty==iRHProperty) |
|
745 ProcessRemoteHangupEvent(); |
|
746 LOGLINE1("<<CSimLine::SimPSEvent"); |
|
747 } |
|
748 |
|
749 TInt CSimLine::SetAutoAnswerCallObject(CSimCall* aCallObject) |
|
750 /** |
|
751 * Attempt to set the call object that will be used to answer the next incoming |
|
752 * call. If there is already an AnswerIncomingCall registered, then |
|
753 * return with the relevant error. |
|
754 * |
|
755 * @param aCallObject pointer to the call object |
|
756 * @return KErrNone if successful |
|
757 */ |
|
758 { |
|
759 LOGLINE1(">>CSimLine::SetAnswerCallObject"); |
|
760 if(iAnswerIncomingCallReqPending) // Is there a request already outstanding? |
|
761 return KErrEtelAnswerAlreadyOutstanding; |
|
762 |
|
763 iAnswerIncomingCallReqPending=ETrue; |
|
764 if (iAnswerNextIncomingCall!=aCallObject) |
|
765 { |
|
766 if (iSpareCall != iAnswerNextIncomingCall) |
|
767 { |
|
768 iAnswerNextIncomingCall->Close(); |
|
769 } |
|
770 iAnswerNextIncomingCall=aCallObject; // Set the "answer next call" object |
|
771 iAnswerNextIncomingCall->Open(); |
|
772 } |
|
773 LOGLINE1("<<CSimLine::SetAnswerCallObject"); |
|
774 return KErrNone; |
|
775 } |
|
776 |
|
777 void CSimLine::ResetAutoAnswerCallObject(CSimCall* aCallObject) |
|
778 /** |
|
779 * This function is used to reset, or effectively cancel, the call object that |
|
780 * was to be used to automatically answer the next incoming call. |
|
781 * |
|
782 * @param aCallObject pointer to the call object |
|
783 */ |
|
784 { |
|
785 LOGLINE1(">>CSimLine::ResetAnswerCallObject"); |
|
786 __ASSERT_ALWAYS(iAnswerNextIncomingCall==aCallObject,SimPanic(EIllegalAnswerNextIncomingCallInconsistancy)); |
|
787 iAnswerNextIncomingCall->Close(); |
|
788 iAnswerNextIncomingCall=iSpareCall; |
|
789 iAnswerIncomingCallReqPending=EFalse; |
|
790 } |
|
791 |
|
792 void CSimLine::ProcessIncomingCallEvent() |
|
793 /** |
|
794 * Process an incoming call event. |
|
795 */ |
|
796 { |
|
797 LOGLINE1(">>CSimLine::ProcessIncomingCallEvent "); |
|
798 |
|
799 if (iSpareCall == iAnswerNextIncomingCall) |
|
800 { |
|
801 TName callName; |
|
802 TRAPD(err,iAnswerNextIncomingCall=CreateNewCallL(callName,ECallTypeNormalCall)); |
|
803 if (err!=KErrNone) |
|
804 { |
|
805 SimPanic(EOjectNotConstructed); |
|
806 } |
|
807 } |
|
808 |
|
809 // Delay sending the notification of an incoming call if |
|
810 // one has been set. |
|
811 iTimer->Start(iNotifyIncomingCallPause, this); |
|
812 |
|
813 __ASSERT_ALWAYS(iAnswerNextIncomingCall->ActionEvent(CSimCall::ECallEventIncomingCall,KErrNone) == KErrNone, SimPanic(EGeneral)); |
|
814 LOGLINE1("<<CSimLine::ProcessIncomingCallEvent"); |
|
815 } |
|
816 |
|
817 TInt CSimLine::SetRemoteHangupCallObject(CSimCall* aCallObject) |
|
818 /** |
|
819 * Attempt to set the call object that will be hung up remotely |
|
820 * If there is already a RemoteHangup registered, then |
|
821 * return with the relevant error. |
|
822 * |
|
823 * @param aCallObject pointer to the call object |
|
824 * @return KErrNone if successful |
|
825 */ |
|
826 { |
|
827 LOGLINE1(">>CSimLine::SetRemoteHangupCallObject"); |
|
828 if(iRemoteHangupCallReqPending) // Is there a request already outstanding? |
|
829 return KErrEtelInitialisationFailure; |
|
830 |
|
831 iRemoteHangupCallReqPending=ETrue; |
|
832 if (iRemoteHangupCall!=aCallObject) |
|
833 { |
|
834 iRemoteHangupCall=aCallObject; // Set the "remote hang up" object |
|
835 } |
|
836 LOGLINE1("<<CSimLine::SetRemoteHangupCallObject"); |
|
837 return KErrNone; |
|
838 } |
|
839 |
|
840 void CSimLine::ResetRemoteHangupCallObject(CSimCall* aCallObject) |
|
841 /** |
|
842 * This function is used to reset, or effectively cancel, the call object that |
|
843 * was to be remotely hung up. |
|
844 * |
|
845 * @param aCallObject pointer to the call object |
|
846 */ |
|
847 { |
|
848 LOGLINE1(">>CSimLine::ResetRemoteHangupCallObject"); |
|
849 __ASSERT_ALWAYS(iRemoteHangupCall==aCallObject,SimPanic(EIllegalAnswerRemoteHangupCallInconsistency)); |
|
850 iRemoteHangupCallReqPending=EFalse; |
|
851 } |
|
852 |
|
853 void CSimLine::ProcessRemoteHangupEvent() |
|
854 /** |
|
855 * Process a remote hangup event. |
|
856 */ |
|
857 { |
|
858 LOGLINE1(">>CSimLine::ProcessRemoteHangupEvent"); |
|
859 |
|
860 if (iRemoteHangupCall == NULL) |
|
861 { |
|
862 TInt err = FindActiveCall(iRemoteHangupCall); |
|
863 if(err == KErrNone) |
|
864 { |
|
865 err = iRemoteHangupCall->ActionEvent(CSimCall::ECallEventRemoteHangup,KErrNone); |
|
866 if(err != KErrNone) |
|
867 { |
|
868 LOGLINE2("ERROR: CSimLine::ProcessRemoteHangupEvent returned: %d", err); |
|
869 } |
|
870 } |
|
871 else |
|
872 { |
|
873 LOGLINE1("No outstanding call to hang up remotely"); |
|
874 } |
|
875 } |
|
876 LOGLINE1("<<CSimLine::ProcessRemoteHangupEvent"); |
|
877 } |
|
878 |
|
879 void CSimLine::CallDestructor(CSimCall* aCall) |
|
880 /** |
|
881 * This function is called from a call's destructor. |
|
882 * It must delete the call from its list. If the call cannot be found, an unacceptable |
|
883 * inconsistancy must have developed, and the TSY will panic. |
|
884 */ |
|
885 { |
|
886 for(TInt i=0;i<iCalls->Count();i++) |
|
887 { |
|
888 if(iCalls->At(i)==aCall) |
|
889 { |
|
890 iCalls->Delete(i); |
|
891 return; |
|
892 } |
|
893 } |
|
894 SimPanic(EIllegalCallNotRegisteredWithLine); |
|
895 } |
|
896 |
|
897 TBool CSimLine::IsAnswerCallObjectSpare() |
|
898 /** |
|
899 * Is the "answer" call object actually the spare object. |
|
900 */ |
|
901 { |
|
902 return (iSpareCall==iAnswerNextIncomingCall); |
|
903 } |
|
904 |
|
905 /** |
|
906 Called when iTimer has delayed the sending of the notification of the incoming call. |
|
907 */ |
|
908 void CSimLine::TimerCallBack(TInt /*aId*/) |
|
909 { |
|
910 ProcessNotifyIncomingCallEvent(); |
|
911 } |
|
912 |
|
913 /** |
|
914 Send notification of an incoming call. |
|
915 */ |
|
916 void CSimLine::ProcessNotifyIncomingCallEvent() |
|
917 { |
|
918 LOGLINE1(">>CSimLine::ProcessNotifyIncomingCallEvent"); |
|
919 if(iNotifyIncomingCall.iNotifyPending) |
|
920 { |
|
921 iNotifyIncomingCall.iNotifyPending=EFalse; |
|
922 ((TName*)iNotifyIncomingCall.iNotifyData)->Copy(iAnswerNextIncomingCall->iName); |
|
923 ReqCompleted(iNotifyIncomingCall.iNotifyHandle,KErrNone); |
|
924 } |
|
925 LOGLINE1("<<CSimLine::ProcessNotifyIncomingCallEvent"); |
|
926 } |
|
927 |