|
1 /* |
|
2 * Copyright (c) 2004-2006 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 class is a state machine of BTSap Server |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32property.h> |
|
23 #include "BTSapDomainPSKeys.h" |
|
24 |
|
25 #include "BTSapServerState.h" |
|
26 #include "BTSapSocketHandler.h" |
|
27 #include "BTSapRequestHandler.h" |
|
28 #include "BTSapSimCardStatusNotifier.h" |
|
29 #include "debug.h" |
|
30 |
|
31 _LIT(KPhoneTsy, "PhoneTsy") ; |
|
32 _LIT(KDefaultPhone, "DefaultPhone"); |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 |
|
36 // --------------------------------------------------------- |
|
37 // CBTSapStatusObserver::CBTSapStatusObserver() |
|
38 //---------------------------------------------------------- |
|
39 // |
|
40 CBTSapStatusObserver::CBTSapStatusObserver(): CActive(CActive::EPriorityStandard) |
|
41 { |
|
42 CActiveScheduler::Add( this ); |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // CBTSapStatusObserver::NewL() |
|
47 //---------------------------------------------------------- |
|
48 // |
|
49 CBTSapStatusObserver* CBTSapStatusObserver::NewL() |
|
50 { |
|
51 CBTSapStatusObserver* self = new(ELeave) CBTSapStatusObserver(); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 CleanupStack::Pop(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------- |
|
59 // CBTSapStatusObserver::ConstructL() |
|
60 //---------------------------------------------------------- |
|
61 // |
|
62 void CBTSapStatusObserver::ConstructL() |
|
63 { |
|
64 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapStatusObserver::ConstructL"))); |
|
65 |
|
66 User::LeaveIfError(iProperty.Attach( KPSUidBluetoothSapConnectionState, |
|
67 KBTSapConnectionState)); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------- |
|
71 // CBTSapStatusObserver::~CBTSapStatusObserver |
|
72 //---------------------------------------------------------- |
|
73 // |
|
74 CBTSapStatusObserver::~CBTSapStatusObserver() |
|
75 { |
|
76 Cancel(); |
|
77 iProperty.Close(); |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------- |
|
81 // CBTSapStatusObserver::StartObservingL() |
|
82 //---------------------------------------------------------- |
|
83 // |
|
84 void CBTSapStatusObserver::SubscribeSapStatusL(MSapStatusObserver* aObserver) |
|
85 { |
|
86 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapStatusObserver::SubscribeSapStatusL"))); |
|
87 |
|
88 ASSERT(aObserver); |
|
89 |
|
90 iObserver = aObserver; |
|
91 |
|
92 iProperty.Subscribe(iStatus); |
|
93 SetActive(); |
|
94 } |
|
95 |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // CBTSapStatusObserver::DoCancel() |
|
99 // --------------------------------------------------------- |
|
100 // |
|
101 void CBTSapStatusObserver::DoCancel() |
|
102 { |
|
103 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapStatusObserver::DoCancel"))); |
|
104 |
|
105 iProperty.Cancel(); |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------- |
|
109 // CBTSapStatusObserver::RunL() |
|
110 // --------------------------------------------------------- |
|
111 // |
|
112 void CBTSapStatusObserver::RunL() |
|
113 { |
|
114 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapStatusObserver::RunL"))); |
|
115 |
|
116 TInt btSapState; |
|
117 TInt err = iStatus.Int(); |
|
118 |
|
119 iProperty.Subscribe(iStatus); |
|
120 SetActive(); |
|
121 |
|
122 if (!err) |
|
123 { |
|
124 err = iProperty.Get(btSapState); |
|
125 if (!err) |
|
126 { |
|
127 iObserver->SapStatusChangedL(btSapState); |
|
128 } |
|
129 } |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------- |
|
133 // CBTSapServerState::CBTSapServerState() |
|
134 // --------------------------------------------------------- |
|
135 // |
|
136 CBTSapServerState::CBTSapServerState(CBTSapPlugin& aBTSapPlugin) |
|
137 : CActive(CActive::EPriorityStandard), |
|
138 iBTSapPlugin(aBTSapPlugin), |
|
139 iCurrentState(EStateInit), |
|
140 iStatesCreated(EFalse) |
|
141 { |
|
142 CActiveScheduler::Add(this); |
|
143 |
|
144 _LIT_SECURITY_POLICY_C2(sapConnectionStateReadAndWritePolicy, ECapabilityLocalServices, ECapabilityReadDeviceData); |
|
145 //_LIT_SECURITY_POLICY_S0(sapConnectionStateWritePolicy, 0x10005950); // BtEngServer SID |
|
146 |
|
147 RProperty::Define(KPSUidBluetoothSapConnectionState, KBTSapConnectionState, RProperty::EInt, |
|
148 sapConnectionStateReadAndWritePolicy, sapConnectionStateReadAndWritePolicy); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------- |
|
152 // CBTSapServerState::~CBTSapServerState() |
|
153 // --------------------------------------------------------- |
|
154 // |
|
155 CBTSapServerState::~CBTSapServerState() |
|
156 { |
|
157 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::~CBTSapServerState"))); |
|
158 // Make sure we've cancelled. |
|
159 Cancel(); |
|
160 |
|
161 if (IsSapConnected()) |
|
162 { |
|
163 iStateArray[iCurrentState]->NotifySapState(ESapNotConnected); |
|
164 } |
|
165 |
|
166 iStateArray.ResetAndDestroy(); |
|
167 |
|
168 delete iSocketHandler; |
|
169 delete iSimCardStatusNotifier; |
|
170 delete iRequestHandler; |
|
171 delete iStatusObserver; |
|
172 |
|
173 iSubscriptionModule.Close(); |
|
174 iPhone.Close(); |
|
175 iTelServer.UnloadPhoneModule(KPhoneTsy); |
|
176 iTelServer.Close(); |
|
177 |
|
178 RProperty::Delete(KPSUidBluetoothSapConnectionState, KBTSapConnectionState); |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------- |
|
182 // CBTSapServerState::NewL() |
|
183 // --------------------------------------------------------- |
|
184 // |
|
185 CBTSapServerState* CBTSapServerState::NewL(CBTSapPlugin& aBTSapPlugin) |
|
186 { |
|
187 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::NewL"))); |
|
188 |
|
189 CBTSapServerState* self = new (ELeave) CBTSapServerState(aBTSapPlugin); |
|
190 CleanupStack::PushL(self); |
|
191 self->ConstructL(); |
|
192 CleanupStack::Pop(); |
|
193 return self; |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------- |
|
197 // CBTSapServerState::ConstructL() |
|
198 // --------------------------------------------------------- |
|
199 // |
|
200 void CBTSapServerState::ConstructL() |
|
201 { |
|
202 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::ConstructL"))); |
|
203 |
|
204 OpenSubscriptionModuleL(); |
|
205 iRequestHandler = CBTSapRequestHandler::NewL(*this); |
|
206 iSocketHandler = CBTSapSocketHandler::NewL(*this, *iRequestHandler); |
|
207 iSimCardStatusNotifier = CBTSapSimCardStatusNotifier::NewL(*this); |
|
208 iStatusObserver = CBTSapStatusObserver::NewL(); |
|
209 |
|
210 TState* state = new (ELeave) TStateInit(*this); |
|
211 CleanupStack::PushL(state); |
|
212 User::LeaveIfError(iStateArray.Append(state)); |
|
213 CleanupStack::Pop(state); |
|
214 |
|
215 ChangeState(EStateInit); |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------- |
|
219 // CBTSapServerState::StartL() |
|
220 // --------------------------------------------------------- |
|
221 // |
|
222 void CBTSapServerState::StartL() |
|
223 { |
|
224 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::StartL"))); |
|
225 |
|
226 // the order matters |
|
227 TState* state = new (ELeave) TStateNotConnected(*this); |
|
228 CleanupStack::PushL(state); |
|
229 User::LeaveIfError(iStateArray.Append(state)); |
|
230 CleanupStack::Pop(state); |
|
231 |
|
232 // The SAP connection is accepted/rejected via a P&S key (KPSUidBluetoothSapConnectionState) |
|
233 // iStatusObserver monitors P&S key changes and calls AcceptSapConnection or |
|
234 // RejectSapConnection accordingly. |
|
235 iStatusObserver->SubscribeSapStatusL(this); |
|
236 |
|
237 ChangeState(EStateNotConnected); |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------- |
|
241 // CBTSapServerState::DoCancel() |
|
242 // --------------------------------------------------------- |
|
243 // |
|
244 void CBTSapServerState::DoCancel() |
|
245 { |
|
246 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::DoCancel"))); |
|
247 |
|
248 iStateArray[iCurrentState]->Cancel(); |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------- |
|
252 // CBTSapServerState::ChangeState |
|
253 // --------------------------------------------------------- |
|
254 void CBTSapServerState:: ChangeState(const TBTSapServerState aNextState) |
|
255 { |
|
256 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapServerState:: ChangeState: %d"), aNextState)); |
|
257 |
|
258 Cancel(); |
|
259 iCurrentState = aNextState; |
|
260 iStateArray[iCurrentState]->Enter(iStatus); |
|
261 SetActive(); |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------- |
|
265 // CBTSapServerState::RunL() |
|
266 // --------------------------------------------------------- |
|
267 // |
|
268 void CBTSapServerState::RunL() |
|
269 { |
|
270 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::RunL: %d >>"), iStatus.Int())); |
|
271 |
|
272 TBTSapServerState nextState = iStateArray[iCurrentState]->Complete(iStatus.Int()); |
|
273 |
|
274 // Enter new state |
|
275 ChangeState(nextState); |
|
276 |
|
277 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: RunL complete <<"))); |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------- |
|
281 // CBTSapServerState::CurrentState() |
|
282 // --------------------------------------------------------- |
|
283 TBTSapServerState CBTSapServerState:: CurrentState() |
|
284 { |
|
285 return iCurrentState; |
|
286 } |
|
287 |
|
288 // --------------------------------------------------------- |
|
289 // CBTSapServerState::AcceptSapConnection() |
|
290 // --------------------------------------------------------- |
|
291 // |
|
292 TInt CBTSapServerState::AcceptSapConnection() |
|
293 { |
|
294 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::AcceptSapConnection"))); |
|
295 |
|
296 return iStateArray[iCurrentState]->AcceptSapConnection(); |
|
297 } |
|
298 |
|
299 // --------------------------------------------------------- |
|
300 // CBTSapServerState::RejectSapConnection() |
|
301 // --------------------------------------------------------- |
|
302 // |
|
303 TInt CBTSapServerState:: RejectSapConnection(TBTSapRejectReason aReason) |
|
304 { |
|
305 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::RejectSapConnection"))); |
|
306 |
|
307 return iStateArray[iCurrentState]->RejectSapConnection(aReason); |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------- |
|
311 // CBTSapServerState::DisconnectSapConnection() |
|
312 // --------------------------------------------------------- |
|
313 // |
|
314 TInt CBTSapServerState::DisconnectSapConnection(TBTSapDisconnectType aType) |
|
315 { |
|
316 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::DisconnectSapConnection: %d"), aType)); |
|
317 TInt retVal = KErrNotReady; |
|
318 |
|
319 if (IsSapConnected()) |
|
320 { |
|
321 Cancel(); // Cancel current state |
|
322 retVal = iStateArray[iCurrentState]->DisconnectSapConnection(aType); |
|
323 ChangeState(aType == EDisconnectImmediate ? EStateNotConnected : EStateIdle); |
|
324 } |
|
325 |
|
326 return retVal; |
|
327 } |
|
328 |
|
329 // --------------------------------------------------------- |
|
330 // CBTSapServerState::IsSapConnected() |
|
331 // --------------------------------------------------------- |
|
332 // |
|
333 TBool CBTSapServerState::IsSapConnected() |
|
334 { |
|
335 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::IsSapConnected"))); |
|
336 TBool ret = EFalse; |
|
337 if (iSocketHandler) |
|
338 { |
|
339 ret = iSocketHandler->IsSapConnected(); |
|
340 } |
|
341 return ret; |
|
342 } |
|
343 |
|
344 // --------------------------------------------------------- |
|
345 // CBTSapServerState::GetRemoteBTAddress() |
|
346 // --------------------------------------------------------- |
|
347 // |
|
348 TInt CBTSapServerState::GetRemoteBTAddress(TBTDevAddr& aBTDevAddr) |
|
349 { |
|
350 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::GetRemoteBTAddress"))); |
|
351 |
|
352 return (iSocketHandler != NULL) ? iSocketHandler->GetRemoteBTAddress(aBTDevAddr) : KErrDisconnected; |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------- |
|
356 // CBTSapServerState::SimCardStatusChanged() |
|
357 // --------------------------------------------------------- |
|
358 // |
|
359 void CBTSapServerState::SimCardStatusChanged(TCardStatus aCardStatus) |
|
360 { |
|
361 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] SapSimCardStatusChanged: %d"), aCardStatus)); |
|
362 |
|
363 if (iCurrentState == EStateConnect || |
|
364 iCurrentState == EStatePowerOn || |
|
365 iCurrentState == EStateReset) |
|
366 { |
|
367 iStateArray[iCurrentState]->SimCardStatusChanged(aCardStatus); |
|
368 } |
|
369 else |
|
370 { |
|
371 // real indication |
|
372 Cancel(); |
|
373 iStateArray[iCurrentState]->SimCardStatusChanged(aCardStatus); |
|
374 ChangeState(EStateIdle); |
|
375 } |
|
376 } |
|
377 |
|
378 // --------------------------------------------------------- |
|
379 // CBTSapServerState::CreateStatesL() |
|
380 // --------------------------------------------------------- |
|
381 // |
|
382 TInt CBTSapServerState::CreateStatesL() |
|
383 { |
|
384 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::CreateStatesL"))); |
|
385 |
|
386 if (!iStatesCreated) |
|
387 { |
|
388 // Create SAP states. TStateInit and TStateNotConnected have already been created. |
|
389 TState* state = new (ELeave) TStateConnect(*this); |
|
390 CleanupStack::PushL(state); |
|
391 User::LeaveIfError(iStateArray.Append(state)); |
|
392 CleanupStack::Pop(state); |
|
393 |
|
394 state = new (ELeave) TStateDisconnect(*this); |
|
395 CleanupStack::PushL(state); |
|
396 User::LeaveIfError(iStateArray.Append(state)); |
|
397 CleanupStack::Pop(state); |
|
398 |
|
399 state = new (ELeave) TStateIdle(*this); |
|
400 CleanupStack::PushL(state); |
|
401 User::LeaveIfError(iStateArray.Append(state)); |
|
402 CleanupStack::Pop(state); |
|
403 |
|
404 state = new (ELeave) TStateAPDU(*this); |
|
405 CleanupStack::PushL(state); |
|
406 User::LeaveIfError(iStateArray.Append(state)); |
|
407 CleanupStack::Pop(state); |
|
408 |
|
409 state = new (ELeave) TStateATR(*this); |
|
410 CleanupStack::PushL(state); |
|
411 User::LeaveIfError(iStateArray.Append(state)); |
|
412 CleanupStack::Pop(state); |
|
413 |
|
414 state = new (ELeave) TStatePowerOff(*this); |
|
415 CleanupStack::PushL(state); |
|
416 User::LeaveIfError(iStateArray.Append(state)); |
|
417 CleanupStack::Pop(state); |
|
418 |
|
419 state = new (ELeave) TStatePowerOn(*this); |
|
420 CleanupStack::PushL(state); |
|
421 User::LeaveIfError(iStateArray.Append(state)); |
|
422 CleanupStack::Pop(state); |
|
423 |
|
424 state = new (ELeave) TStateReset(*this); |
|
425 CleanupStack::PushL(state); |
|
426 User::LeaveIfError(iStateArray.Append(state)); |
|
427 CleanupStack::Pop(state); |
|
428 |
|
429 state = new (ELeave) TStateCardReaderStatus(*this); |
|
430 CleanupStack::PushL(state); |
|
431 User::LeaveIfError(iStateArray.Append(state)); |
|
432 CleanupStack::Pop(state); |
|
433 } |
|
434 |
|
435 iStatesCreated = ETrue; |
|
436 return KErrNone; |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------- |
|
440 // CBTSapServerState::ReleaseStatesL() |
|
441 // --------------------------------------------------------- |
|
442 // |
|
443 TInt CBTSapServerState::ReleaseStatesL() |
|
444 { |
|
445 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::ReleaseStatesL"))); |
|
446 // Delete SAP states, all except TStateInit and TStateNotConnected. |
|
447 for(TInt i = iStateArray.Count() - 1; i >= 2; i--) |
|
448 { |
|
449 delete iStateArray[i]; |
|
450 iStateArray[i] = NULL; |
|
451 iStateArray.Remove(i); |
|
452 } |
|
453 |
|
454 iStatesCreated = EFalse; |
|
455 return KErrNone; |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------- |
|
459 // CBTSapServerState::DisconnectCompleteL() |
|
460 // --------------------------------------------------------- |
|
461 // |
|
462 TInt CBTSapServerState::DisconnectCompleteL(TInt aErr) |
|
463 { |
|
464 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::DisconnectCompleteL"))); |
|
465 iBTSapPlugin.OperationCompletedL(MSapAsyncObserver::EDisconnect, aErr); |
|
466 return KErrNone; |
|
467 } |
|
468 |
|
469 // --------------------------------------------------------- |
|
470 // CBTSapServerState::HandleStateChangeRequest() |
|
471 // --------------------------------------------------------- |
|
472 // |
|
473 TInt CBTSapServerState::HandleStateChangeRequest(TBTSapServerState& aNextState) |
|
474 { |
|
475 return iStateArray[iCurrentState]->ChangeState(aNextState); |
|
476 } |
|
477 |
|
478 // --------------------------------------------------------- |
|
479 // CBTSapServerState::SendErrorResponse() |
|
480 // --------------------------------------------------------- |
|
481 // |
|
482 void CBTSapServerState::SendErrorResponse() |
|
483 { |
|
484 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::SendErrorResponse"))); |
|
485 |
|
486 // set response: error_response |
|
487 iResponseMessage.SetMsgID(EErrorResponse); |
|
488 iSocketHandler->Send(iResponseMessage.Data()); |
|
489 } |
|
490 |
|
491 // --------------------------------------------------------- |
|
492 // CBTSapServerState::OpenSubscriptionModuleL() |
|
493 // --------------------------------------------------------- |
|
494 // |
|
495 void CBTSapServerState::OpenSubscriptionModuleL() |
|
496 { |
|
497 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::OpenSubscriptionModuleL"))); |
|
498 |
|
499 User::LeaveIfError(iTelServer.Connect()); |
|
500 User::LeaveIfError(iTelServer.LoadPhoneModule(KPhoneTsy)); // Load Custom API Extension |
|
501 User::LeaveIfError(iPhone.Open( iTelServer, KDefaultPhone)); |
|
502 User::LeaveIfError(iSubscriptionModule.Open(iPhone)); |
|
503 } |
|
504 |
|
505 // --------------------------------------------------------- |
|
506 // CBTSapServerState::BTSapSocketHandler() |
|
507 // --------------------------------------------------------- |
|
508 // |
|
509 CBTSapSocketHandler& CBTSapServerState::BTSapSocketHandler() |
|
510 { |
|
511 return *iSocketHandler; |
|
512 } |
|
513 |
|
514 // --------------------------------------------------------- |
|
515 // CBTSapServerState::BTSapSimCardStatusNotifier() |
|
516 // --------------------------------------------------------- |
|
517 // |
|
518 CBTSapSimCardStatusNotifier& CBTSapServerState::BTSapSimCardStatusNotifier() |
|
519 { |
|
520 return *iSimCardStatusNotifier; |
|
521 } |
|
522 |
|
523 // --------------------------------------------------------- |
|
524 // CBTSapServerState::SubscriptionModule() |
|
525 // --------------------------------------------------------- |
|
526 // |
|
527 RMmCustomAPI& CBTSapServerState::SubscriptionModule() |
|
528 { |
|
529 return iSubscriptionModule; |
|
530 } |
|
531 |
|
532 // --------------------------------------------------------- |
|
533 // CBTSapServerState::BTSapRequestMessage() |
|
534 // --------------------------------------------------------- |
|
535 // |
|
536 TBTSapMessage& CBTSapServerState::BTSapRequestMessage() |
|
537 { |
|
538 return iRequestMessage; |
|
539 } |
|
540 |
|
541 // --------------------------------------------------------- |
|
542 // CBTSapServerState::BTSapResponseMessage() |
|
543 // --------------------------------------------------------- |
|
544 // |
|
545 TBTSapMessage& CBTSapServerState::BTSapResponseMessage() |
|
546 { |
|
547 return iResponseMessage; |
|
548 } |
|
549 |
|
550 // --------------------------------------------------------- |
|
551 // CBTSapServerState::SapStatusChangedL() |
|
552 // --------------------------------------------------------- |
|
553 // |
|
554 void CBTSapServerState::SapStatusChangedL(TInt aStatus) |
|
555 { |
|
556 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::SapStatusChangedL"))); |
|
557 |
|
558 switch (aStatus) |
|
559 { |
|
560 case EBTSapNotConnected: |
|
561 case EBTSapConnecting: |
|
562 { |
|
563 // no actions |
|
564 break; |
|
565 } |
|
566 case EBTSapConnected: |
|
567 { |
|
568 // Inform observers |
|
569 iBTSapPlugin.ConnectComplete(); |
|
570 break; |
|
571 } |
|
572 case EBTSapAccepted: |
|
573 { |
|
574 AcceptSapConnection(); |
|
575 break; |
|
576 } |
|
577 case EBTSapRejected: |
|
578 { |
|
579 RejectSapConnection(ERejectGeneralError); |
|
580 break; |
|
581 } |
|
582 default: |
|
583 { |
|
584 // An error or invalid state |
|
585 RejectSapConnection(ERejectGeneralError); |
|
586 break; |
|
587 } |
|
588 } |
|
589 } |
|
590 |
|
591 |
|
592 // End of File |