1 /* |
1 /* |
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
27 #include "cchpluginhandler.h" |
27 #include "cchpluginhandler.h" |
28 #include "cchfeaturemanager.h" |
28 #include "cchfeaturemanager.h" |
29 #include "cchwakeupeventnotifier.h" |
29 #include "cchwakeupeventnotifier.h" |
30 #include "cchstartupcounter.h" |
30 #include "cchstartupcounter.h" |
31 #include "cchactivescheduler.h" |
31 #include "cchactivescheduler.h" |
|
32 #include "cchconnmonhandlernotifier.h" |
32 |
33 |
33 #include <ecom/ecom.h> |
34 #include <ecom/ecom.h> |
|
35 #include <rconnmon.h> |
34 |
36 |
35 // EXTERNAL DATA STRUCTURES |
37 // EXTERNAL DATA STRUCTURES |
36 // None |
38 // None |
37 |
39 |
38 // EXTERNAL FUNCTION PROTOTYPES |
40 // EXTERNAL FUNCTION PROTOTYPES |
258 |
260 |
259 ServiceHandler().InitServiceHandlerL(); |
261 ServiceHandler().InitServiceHandlerL(); |
260 |
262 |
261 if ( iServiceHandler->IsStartupFlagSet() ) |
263 if ( iServiceHandler->IsStartupFlagSet() ) |
262 { |
264 { |
263 // Start monitoring startup flag registration, this may set startup |
265 // is snap ready to proceed startup |
264 // flag to OFF if crashes happens more than KCCHMaxStartupCount during |
266 ConnMonHandler().ScanNetworks( ETrue, this ); |
265 // startup flag registration |
|
266 TRAP_IGNORE( CreateStartupCounterL() ); |
|
267 // If CCH cannot load the Plug-ins, CCH can still |
|
268 // try to load them later |
|
269 TRAP_IGNORE( iServiceHandler->LoadPluginsL() ); |
|
270 RequestStorage().ScanNetworks(); |
|
271 // initialization is now done. update states and send notification to |
|
272 // all clients |
|
273 iServerObjectsInit = ETrue; |
|
274 iServiceHandler->UpdateL(); |
|
275 } |
267 } |
276 else |
268 else |
277 { |
269 { |
278 // Startup flag is not ON, we have to be sure that startup counter |
270 // Startup flag is not ON, we have to be sure that startup counter |
279 // is truly zero for the next time when startup flag is ON |
271 // is truly zero for the next time when startup flag is ON |
280 ResetStartupCounterL(); |
272 ResetStartupCounterL(); |
281 StartMinimalServerL(); |
273 StartMinimalServerL(); |
282 } |
274 } |
283 CCHLOGSTRING( "CCCHServerBase::InitServerObjectsL: OUT" ); |
275 CCHLOGSTRING( "CCCHServerBase::InitServerObjectsL: OUT" ); |
284 } |
276 } |
285 |
277 |
|
278 // --------------------------------------------------------------------------- |
|
279 // CCCHServerBase::ServiceStartupL |
|
280 // (other items were commented in a header). |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 void CCCHServerBase::ServiceStartupL() |
|
284 { |
|
285 CCHLOGSTRING( "CCCHServerBase::ServiceStartupL: IN" ); |
|
286 // Start monitoring startup flag registration, this may set startup |
|
287 // flag to OFF if crashes happens more than KCCHMaxStartupCount during |
|
288 // startup flag registration |
|
289 TRAP_IGNORE( CreateStartupCounterL() ); |
|
290 // If CCH cannot load the Plug-ins, CCH can still |
|
291 // try to load them later |
|
292 TRAP_IGNORE( iServiceHandler->LoadPluginsL() ); |
|
293 RequestStorage().ScanNetworks(); |
|
294 // initialization is now done. update states and send notification to |
|
295 // all clients |
|
296 iServerObjectsInit = ETrue; |
|
297 iServiceHandler->UpdateL(); |
|
298 CCHLOGSTRING( "CCCHServerBase::ServiceStartupL: OUT" ); |
|
299 } |
|
300 |
286 // --------------------------------------------------------------------------- |
301 // --------------------------------------------------------------------------- |
287 // CCCHServerBase::StartMinimalServerL |
302 // CCCHServerBase::StartMinimalServerL |
288 // Start server in settings monitoring mode |
303 // Start server in settings monitoring mode |
289 // --------------------------------------------------------------------------- |
304 // --------------------------------------------------------------------------- |
290 // |
305 // |
639 |
654 |
640 CCHLOGSTRING2("CCCHServerBase::IsServerShutdownAllowedL: shutDownAllowed = %d", shutDownAllowed ); |
655 CCHLOGSTRING2("CCCHServerBase::IsServerShutdownAllowedL: shutDownAllowed = %d", shutDownAllowed ); |
641 return shutDownAllowed; |
656 return shutDownAllowed; |
642 } |
657 } |
643 |
658 |
|
659 // --------------------------------------------------------------------------- |
|
660 // From MCCHConnMonHandlerNotifier |
|
661 // CCCHServerBase::NetworkScanningCompletedL |
|
662 // --------------------------------------------------------------------------- |
|
663 // |
|
664 void CCCHServerBase::NetworkScanningCompletedL( |
|
665 const TConnMonSNAPInfo& aSNAPs, TInt aError ) |
|
666 { |
|
667 CCHLOGSTRING2( "CCCHServerBase::NetworkScanningCompletedL error = %d", aError ); |
|
668 |
|
669 if ( KErrNone == aError && aSNAPs.iCount ) |
|
670 { |
|
671 ServiceStartupL(); |
|
672 } |
|
673 else if ( KErrNone == aError || KErrNotReady == aError ) |
|
674 { |
|
675 // No SNAPs available. Start listen to availability change |
|
676 ConnMonHandler().SetSNAPsAvailabilityChangeListener( this ); |
|
677 } |
|
678 else |
|
679 { |
|
680 // exceptional error occured |
|
681 ResetStartupCounterL(); |
|
682 StartMinimalServerL(); |
|
683 } |
|
684 } |
|
685 |
|
686 // --------------------------------------------------------------------------- |
|
687 // From MCCHConnMonHandlerNotifier |
|
688 // CCCHServerBase::SNAPsAvailabilityChanged |
|
689 // --------------------------------------------------------------------------- |
|
690 // |
|
691 void CCCHServerBase::SNAPsAvailabilityChanged( TInt aError ) |
|
692 { |
|
693 CCHLOGSTRING2( "CCCHServerBase::SNAPsAvailabilityChanged error = %d", aError ); |
|
694 |
|
695 // Stop event receiving |
|
696 ConnMonHandler().SetSNAPsAvailabilityChangeListener( NULL ); |
|
697 |
|
698 if ( KErrNone == aError || KErrTimedOut == aError ) |
|
699 { |
|
700 ServiceStartupL(); |
|
701 } |
|
702 else |
|
703 { |
|
704 // exceptional error occured |
|
705 ResetStartupCounterL(); |
|
706 StartMinimalServerL(); |
|
707 } |
|
708 } |
|
709 |
644 // ========================== OTHER EXPORTED FUNCTIONS ======================= |
710 // ========================== OTHER EXPORTED FUNCTIONS ======================= |
645 |
711 |
646 // --------------------------------------------------------------------------- |
712 // --------------------------------------------------------------------------- |
647 // E32Main implements the executable entry function. |
713 // E32Main implements the executable entry function. |
648 // Note that because the target type of the CCHServer module |
714 // Note that because the target type of the CCHServer module |