equal
deleted
inserted
replaced
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
66 * Second-phase constructor. Creates all the state objects it owns. |
66 * Second-phase constructor. Creates all the state objects it owns. |
67 */ |
67 */ |
68 { |
68 { |
69 _LOG_L1C1(_L8("CBcaIoController::ConstructL")); |
69 _LOG_L1C1(_L8("CBcaIoController::ConstructL")); |
70 BaseConstructL(); |
70 BaseConstructL(); |
71 iSender = CSender::NewL(*this, iTheLogger, iMaxPacketSise); |
71 iSender = CSender::NewL(*this, iTheLogger, iMaxTxPacketSize); |
72 iReceiver = CReceiver::NewL(*this, iTheLogger, iMaxPacketSise); |
72 iReceiver = CReceiver::NewL(*this, iTheLogger, iMaxRxPacketSize); |
73 iLoader = new (ELeave) CBcaControl(*this, iTheLogger); |
73 iLoader = new (ELeave) CBcaControl(*this, iTheLogger); |
74 } |
74 } |
75 |
75 |
76 |
76 |
77 CBcaIoController::~CBcaIoController() |
77 CBcaIoController::~CBcaIoController() |
90 * @param aBcaStack Text composed of bca stack and next bca names |
90 * @param aBcaStack Text composed of bca stack and next bca names |
91 */ |
91 */ |
92 void CBcaIoController::SetBcaStackAndName(const TDesC& aBcaStack, const TDesC& aBcaName) |
92 void CBcaIoController::SetBcaStackAndName(const TDesC& aBcaStack, const TDesC& aBcaName) |
93 { |
93 { |
94 iBcaName.Set(aBcaName); |
94 iBcaName.Set(aBcaName); |
95 iBcaName.Set(aBcaStack); |
95 iBcaStack.Set(aBcaStack); |
96 } |
96 } |
97 |
97 |
98 |
98 |
99 void CBcaIoController::StartL() |
99 void CBcaIoController::StartL() |
100 /** |
100 /** |
124 } |
124 } |
125 |
125 |
126 // Update module state |
126 // Update module state |
127 SendState(EShuttingDown); |
127 SendState(EShuttingDown); |
128 |
128 |
129 //It does nothing here. |
129 iLoader->ShutdownBca(aError); |
130 iLoader->Cancel(); |
130 } |
131 MBca* bca = iLoader->Bca(); |
|
132 if(bca) |
|
133 { |
|
134 if(aError == KErrConnectionTerminated ) |
|
135 { |
|
136 _LOG_L1C1(_L8("This is an emergency shutdown, it kills the NIF immediately.")); |
|
137 // It is a emergency shutdown, it kills the NIF immediately. |
|
138 bca->Close(); |
|
139 GetObserver().ShutDown(MControllerObserver::EBcaController, aError); |
|
140 } |
|
141 |
|
142 else |
|
143 { |
|
144 _LOG_L1C1(_L8("This is a graceful termination which takes a while.")); |
|
145 //It is a graceful termination which takes a while. |
|
146 iLoader->ShutdownBca(aError); |
|
147 } |
|
148 } |
|
149 else //nothing to shutdown, just notify linklayer down. |
|
150 { |
|
151 _LOG_L1C1(_L8("Bca is not initialized, bring the linklayer down")); |
|
152 GetObserver().ShutDown(MControllerObserver::EBcaController, aError); |
|
153 } |
|
154 |
|
155 } |
|
156 |
131 |
157 void CBcaIoController::InitialiseBcaL() |
132 void CBcaIoController::InitialiseBcaL() |
158 /** |
133 /** |
159 * Load & Initialise Bca. |
134 * Load & Initialise Bca. |
160 */ |
135 */ |
233 */ |
208 */ |
234 { |
209 { |
235 Cancel(); |
210 Cancel(); |
236 if(iMBca) |
211 if(iMBca) |
237 { |
212 { |
|
213 //If the Bca is still open, close it |
|
214 if(EBcaOpened == iState) |
|
215 { |
|
216 iMBca->Close(); |
|
217 } |
|
218 //delete the BCA instance |
238 iMBca->Release(); |
219 iMBca->Release(); |
239 } |
220 } |
240 |
|
241 // Library will be Closed when iBcaDll is destroyed. |
221 // Library will be Closed when iBcaDll is destroyed. |
242 } |
222 } |
243 |
223 |
244 void CBcaControl::RunL() |
224 void CBcaControl::RunL() |
245 /** |
225 /** |
325 _LOG_L2C2(_L8("ERROR in BCA Open = %d"), iStatus.Int()); |
305 _LOG_L2C2(_L8("ERROR in BCA Open = %d"), iStatus.Int()); |
326 iObserver.Stop(iStatus.Int()); |
306 iObserver.Stop(iStatus.Int()); |
327 } |
307 } |
328 else |
308 else |
329 { |
309 { |
|
310 iState = EBcaOpened; |
|
311 //Activate the receiver Active Object |
330 iObserver.Receiver().StartListening(); |
312 iObserver.Receiver().StartListening(); |
331 _LOG_L1C1(_L8("CBcaIoController Is Initialised")); |
313 _LOG_L1C1(_L8("CBcaIoController Is Initialised")); |
332 TRAPD(err, iObserver.GetObserver().InitialiseL(MRawIPObserverBase::EBcaController,KErrNone)); |
314 TRAPD(err, iObserver.GetObserver().InitialiseL(MRawIPObserverBase::EBcaController,KErrNone)); |
333 if(err != KErrNone) |
315 if(err != KErrNone) |
334 { |
316 { |
341 |
323 |
342 //in this state, BCA is Shutdown, shutdown the NIF. |
324 //in this state, BCA is Shutdown, shutdown the NIF. |
343 case EClosing: |
325 case EClosing: |
344 { |
326 { |
345 // linklayer shutdown |
327 // linklayer shutdown |
|
328 iState = EIdling; |
346 iObserver.GetObserver().ShutDown(MControllerObserver::EBcaController, iError); |
329 iObserver.GetObserver().ShutDown(MControllerObserver::EBcaController, iError); |
347 break; |
330 break; |
348 } |
331 } |
349 // Wrong state. |
332 // Wrong state. |
350 default: |
333 default: |
366 _LOG_L2C2(_L8("iState value is %d"), iState); |
349 _LOG_L2C2(_L8("iState value is %d"), iState); |
367 switch (iState) |
350 switch (iState) |
368 { |
351 { |
369 case EIdling: |
352 case EIdling: |
370 case EIAPSet: |
353 case EIAPSet: |
|
354 case EBcaStackSet: |
371 if(iMBca) |
355 if(iMBca) |
372 { |
356 { |
373 iMBca->CancelIoctl(); |
357 iMBca->CancelIoctl(); |
374 } |
358 } |
375 iState = EIdling; |
359 iState = EIdling; |
376 break; |
360 break; |
377 case EBcaStackSet: |
|
378 case EClosing: |
361 case EClosing: |
379 if(iMBca) |
362 iState = EIdling; |
380 { |
363 break; |
381 iMBca->Close(); |
|
382 } |
|
383 iState = EIdling; |
|
384 break; |
|
385 default: |
364 default: |
386 _LOG_L2C1(_L8("ERROR CBcaControl::DoCancel(): Unknown state")); |
365 _LOG_L2C1(_L8("ERROR CBcaControl::DoCancel(): Unknown state")); |
387 _BTT_PANIC(KNifName, KBcaUnkownState); |
366 _BTT_PANIC(KNifName, KBcaUnkownState); |
388 break; |
367 break; |
389 } |
368 } |
394 * This method loads the C32BCA library and uses Ioctl to set the Bca iIapId. |
373 * This method loads the C32BCA library and uses Ioctl to set the Bca iIapId. |
395 */ |
374 */ |
396 { |
375 { |
397 _LOG_L1C1(_L8("CBcaControl::StartLoad")); |
376 _LOG_L1C1(_L8("CBcaControl::StartLoad")); |
398 |
377 |
|
378 //iMBca should not be initialized at this point |
|
379 __ASSERT_DEBUG(!iMBca,Panic(KBcaAlreadyExists)); |
|
380 |
|
381 //We don't expect iMBca here, but if it occurs, we delete previous BCA Instance |
|
382 if(iMBca) |
|
383 { |
|
384 //If the state is still "open", close it first |
|
385 if(EBcaOpened == iState) |
|
386 { |
|
387 iMBca->Close(); |
|
388 } |
|
389 iMBca->Release(); |
|
390 } |
|
391 |
399 // Loads Bca Dll and creates a Bca instance; |
392 // Loads Bca Dll and creates a Bca instance; |
400 User::LeaveIfError(iBcaDll.iObj.Load(iObserver.BcaName())); |
393 User::LeaveIfError(iBcaDll.iObj.Load(iObserver.BcaName())); |
401 |
394 |
402 TNewBcaFactoryL newBcaFactoryProcL = (TNewBcaFactoryL)iBcaDll.iObj.Lookup(1); |
395 TNewBcaFactoryL newBcaFactoryProcL = (TNewBcaFactoryL)iBcaDll.iObj.Lookup(1); |
403 if (NULL == newBcaFactoryProcL) |
396 if (NULL == newBcaFactoryProcL) |
435 * @param aError the error code to shutdown the NIF. |
428 * @param aError the error code to shutdown the NIF. |
436 */ |
429 */ |
437 { |
430 { |
438 __ASSERT_DEBUG(iMBca,Panic(KBcaNotExist)); |
431 __ASSERT_DEBUG(iMBca,Panic(KBcaNotExist)); |
439 Cancel(); |
432 Cancel(); |
440 iError = aError; |
433 |
441 iState = EClosing; |
434 //We should only call shutdown or close if we have successfully opened a BCA Channel |
442 if(iMBca) |
435 if((iMBca) && (EBcaOpened == iState)) |
443 { |
436 { |
444 iMBca->Shutdown(iStatus); |
437 if(aError == KErrConnectionTerminated ) |
445 SetActive(); |
438 { |
|
439 _LOG_L1C1(_L8("This is an emergency shutdown, it kills the NIF immediately.")); |
|
440 // It is a emergency shutdown, it kills the NIF immediately. |
|
441 iMBca->Close(); |
|
442 iState = EIdling; |
|
443 iObserver.GetObserver().ShutDown(MControllerObserver::EBcaController, aError); |
|
444 } |
|
445 else |
|
446 { |
|
447 _LOG_L1C1(_L8("This is a graceful termination which takes a while.")); |
|
448 //It is a graceful termination which takes a while. |
|
449 iError = aError; |
|
450 iState = EClosing; |
|
451 iMBca->Shutdown(iStatus); |
|
452 SetActive(); |
|
453 } |
446 } |
454 } |
|
455 else //nothing to shutdown, just notify linklayer down. |
|
456 { |
|
457 _LOG_L1C1(_L8("Bca is not initialized or opened, bring the linklayer down")); |
|
458 iState = EIdling; |
|
459 iObserver.GetObserver().ShutDown(MControllerObserver::EBcaController, aError); |
|
460 } |
|
461 |
447 } |
462 } |
448 |
463 |
449 /** Panic function for RawIpNif |
464 /** Panic function for RawIpNif |
450 |
465 |
451 * @param aPanic panic code */ |
466 * @param aPanic panic code */ |