convergedconnectionhandler/cchserver/src/cchserverbase.cpp
changeset 0 a4daefaec16c
child 14 be41ab7b952f
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2006-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:  CCCHServerBase implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cchlogger.h"
       
    21 #include "cchserverbase.h"
       
    22 #include "cchsession.h"
       
    23 #include "cchrequeststorage.h"
       
    24 #include "cchconnmonhandler.h"
       
    25 #include "cchspshandler.h"
       
    26 #include "cchservicehandler.h"
       
    27 #include "cchpluginhandler.h"
       
    28 #include "cchfeaturemanager.h"
       
    29 #include "cchwakeupeventnotifier.h"
       
    30 #include "cchstartupcounter.h"
       
    31 #include "cchactivescheduler.h"
       
    32 
       
    33 #include <ecom/ecom.h>
       
    34 
       
    35 // EXTERNAL DATA STRUCTURES
       
    36 // None
       
    37 
       
    38 // EXTERNAL FUNCTION PROTOTYPES
       
    39 // None
       
    40 
       
    41 // CONSTANTS
       
    42 // None
       
    43 
       
    44 // MACROS
       
    45 // None
       
    46 
       
    47 // LOCAL CONSTANTS AND MACROS
       
    48 // None
       
    49 
       
    50 // MODULE DATA STRUCTURES
       
    51 // None
       
    52 
       
    53 // LOCAL FUNCTION PROTOTYPES
       
    54 GLDEF_C TInt E32Main();
       
    55 #ifdef _DEBUG
       
    56 GLDEF_C void MemUsage();
       
    57 #endif
       
    58 // FORWARD DECLARATIONS
       
    59 // None
       
    60 
       
    61 // ============================= LOCAL FUNCTIONS =============================
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // InitServerL Creates CCHServer.
       
    65 // Returns: None.
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 static void InitServerL()
       
    69     {
       
    70     CCHLOGSTRING("CCCHServerBase::InitServerL");
       
    71     
       
    72     // This is only for startup situation, because starter does not use 
       
    73     // connect metod, which in normal situation reserves the mutex 
       
    74     RMutex serverStartMutex;
       
    75     CleanupClosePushL( serverStartMutex );    
       
    76     TInt createError( serverStartMutex.CreateGlobal( KCCHServerStartMutex ) );
       
    77     if ( KErrNone != createError )
       
    78         {
       
    79         User::LeaveIfError( serverStartMutex.OpenGlobal( KCCHServerStartMutex ) );
       
    80         }
       
    81 
       
    82     serverStartMutex.Wait();
       
    83     CCHLOGSTRING( "CCCHServerBase::InitServerL: mutex available" );
       
    84     
       
    85     TFullName name;
       
    86     TFindServer findServer( KCCHServerName );
       
    87     // Check that the server does not exists.
       
    88     if( findServer.Next( name ) == KErrNotFound )
       
    89         {
       
    90         User::LeaveIfError( User::RenameThread( KCCHServerName ) );
       
    91     
       
    92         // create and install the active scheduler we need
       
    93         CCchActiveScheduler* scheduler = new (ELeave) CCchActiveScheduler;
       
    94         CleanupStack::PushL( scheduler );
       
    95         CActiveScheduler::Install( scheduler ); 
       
    96     
       
    97         // create the server (leave it on the cleanup stack)
       
    98         CCCHServerBase* server = NULL;
       
    99         TRAPD( err, server = CCCHServerBase::NewL() );
       
   100     
       
   101         if ( KErrNone != err )
       
   102             {
       
   103             CCHLOGSTRING2
       
   104                 ("InitServerL: Server creation failed, error = %d", err );
       
   105                 
       
   106             server->PanicServer( ECCHErrCreateServer );
       
   107             }
       
   108         
       
   109         // Scheduler needs server, because server might needs to be restarted 
       
   110         scheduler->SetServer( server );
       
   111         // Initialisation complete, now signal the client
       
   112         RProcess::Rendezvous( KErrNone );
       
   113         
       
   114         // Release and close mutex
       
   115         CCHLOGSTRING( "CCCHServerBase::InitServerL: Release the mutex" );
       
   116         serverStartMutex.Signal();
       
   117         serverStartMutex.Close();
       
   118         
       
   119         // Ready to run
       
   120         CCHLOGSTRING( "CCCHServerBase::InitServerL: Server Running..." );
       
   121         CActiveScheduler::Start();
       
   122     
       
   123         // Cleanup the mutex, scheduler and server
       
   124         delete server;
       
   125         server = NULL;
       
   126     
       
   127         CleanupStack::PopAndDestroy( scheduler );
       
   128         }
       
   129     else
       
   130         {
       
   131         CCHLOGSTRING( "CCCHServerBase::InitServerL: cch server already exists" );
       
   132         RProcess::Rendezvous( KErrAlreadyExists );
       
   133         // Release and close mutex
       
   134         CCHLOGSTRING( "CCCHServerBase::InitServerL: Release the mutex" );
       
   135         serverStartMutex.Signal();
       
   136         serverStartMutex.Close();
       
   137         }
       
   138     CleanupStack::PopAndDestroy( &serverStartMutex );
       
   139     }
       
   140 
       
   141 // ============================ MEMBER FUNCTIONS =============================
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CCCHServerBase::CCCHServerBase
       
   145 // C++ default constructor can NOT contain any code, that might leave.
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 CCCHServerBase::CCCHServerBase() :
       
   149     CPolicyServer( EPriorityHigh, KCCHPolicy ),
       
   150     iSessionCounter( 0 )
       
   151     {
       
   152     CCHLOGSTRING( "CCCHServerBase::CCCHServerBase" );
       
   153     iVoIPEmergencyNoteShown = EFalse;
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // CCCHServerBase::ConstructL
       
   158 // Symbian 2nd phase constructor can leave.
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 void CCCHServerBase::ConstructL()
       
   162     {
       
   163     CCHLOGSTRING( "CCCHServerBase::ConstructL" );
       
   164     iWakeUpEventNotifier = CCchWakeUpEventNotifier::NewL( *this );
       
   165     
       
   166     InitServerObjectsL();
       
   167     //Start server
       
   168     StartL( KCCHServerName );
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // CCCHServerBase::NewL
       
   173 // Two-phased constructor.
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 CCCHServerBase* CCCHServerBase::NewL()
       
   177     {
       
   178     CCCHServerBase* self = CCCHServerBase::NewLC();
       
   179     CleanupStack::Pop( self );
       
   180     return self;
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CCCHServerBase::NewLC
       
   185 // Two-phased constructor.
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 CCCHServerBase* CCCHServerBase::NewLC()
       
   189     {
       
   190     CCCHServerBase* self = new (ELeave)CCCHServerBase();
       
   191     CleanupStack::PushL( self );
       
   192     self->ConstructL();
       
   193     return self;
       
   194     }
       
   195 
       
   196 // Destructor
       
   197 CCCHServerBase::~CCCHServerBase()
       
   198     { 
       
   199     delete iStartupCounter;
       
   200     delete iWakeUpEventNotifier;
       
   201     
       
   202     ReleaseAllResources();
       
   203     REComSession::FinalClose();
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // CCCHServerBase::NewSessionL
       
   208 // This is called by RSessionBase (base class for client interface).
       
   209 // Two-phased constructor.
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 CSession2* CCCHServerBase::NewSessionL( const TVersion& aVersion,
       
   213     const RMessage2& /* aMessage */ ) const
       
   214     {
       
   215     CCHLOGSTRING( "CCCHServerBase::NewSessionL" );
       
   216 
       
   217     TVersion version( KCCHServMajorVersionNumber,
       
   218                       KCCHServMinorVersionNumber,
       
   219                       KCCHServBuildVersionNumber );
       
   220 
       
   221     if ( !User::QueryVersionSupported( version , aVersion ) )
       
   222         {
       
   223         User::Leave( KErrNotSupported );
       
   224         }
       
   225     CCCHSession* session = 
       
   226         CCCHSession::NewL( const_cast<CCCHServerBase&>( *this ) );
       
   227     return session;
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------------------------
       
   231 // CCCHServerBase::ShutdownServerL
       
   232 // (other items were commented in a header).
       
   233 // ---------------------------------------------------------------------------
       
   234 //
       
   235 void CCCHServerBase::ShutDownServerL()
       
   236     {
       
   237     CCHLOGSTRING( "CCCHServerBase::ShutDownServerL - IN" );
       
   238          
       
   239     if ( !iSessionCounter && IsServerShutdownAllowedL() )
       
   240         {
       
   241         CCHLOGSTRING( "CCCHServerBase::ShutDownServerL - Allowed" );
       
   242         // if session counter is zero -> close server
       
   243         // MSI: Shouldn't we continue in minimal mode?
       
   244         // CActiveScheduler::Current()->Stop();
       
   245         TRAP_IGNORE( StartMinimalServerL() );
       
   246         }
       
   247     CCHLOGSTRING( "CCCHServerBase::ShutDownServerL - OUT" );
       
   248     }
       
   249 
       
   250 // ---------------------------------------------------------------------------
       
   251 // CCCHServerBase::InitServerL
       
   252 // (other items were commented in a header).
       
   253 // ---------------------------------------------------------------------------
       
   254 //
       
   255 void CCCHServerBase::InitServerObjectsL()
       
   256     {
       
   257     CCHLOGSTRING( "CCCHServerBase::InitServerObjectsL: IN" );
       
   258 
       
   259     ServiceHandler().InitServiceHandlerL();
       
   260 
       
   261     if ( iServiceHandler->IsStartupFlagSet() )
       
   262         {
       
   263         // Start monitoring startup flag registration, this may set startup 
       
   264         // flag to OFF if crashes happens more than KCCHMaxStartupCount during 
       
   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         }
       
   276     else
       
   277         {
       
   278         // 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
       
   280         ResetStartupCounterL();
       
   281         StartMinimalServerL();
       
   282         }
       
   283     CCHLOGSTRING( "CCCHServerBase::InitServerObjectsL: OUT" );
       
   284     }
       
   285     
       
   286 // ---------------------------------------------------------------------------
       
   287 // CCCHServerBase::StartMinimalServerL
       
   288 // Start server in settings monitoring mode
       
   289 // ---------------------------------------------------------------------------
       
   290 //
       
   291 void CCCHServerBase::StartMinimalServerL()
       
   292     {
       
   293     CCHLOGSTRING( "CCCHServerBase::StartMinimalServerL IN" );
       
   294 
       
   295     iWakeUpEventNotifier->StartL();
       
   296     ReleaseAllResources();
       
   297     CCHLOGSTRING( "CCCHServerBase::StartMinimalServerL OUT" );
       
   298     }
       
   299 
       
   300 // ---------------------------------------------------------------------------
       
   301 // CCCHServerBase::ReleaseAllResources
       
   302 // Start server in settings monitoring mode
       
   303 // ---------------------------------------------------------------------------
       
   304 //
       
   305 void CCCHServerBase::ReleaseAllResources()
       
   306     {
       
   307     CCHLOGSTRING( "CCCHServerBase::ReleaseAllResources" );
       
   308 
       
   309     delete iServiceHandler;
       
   310     iServiceHandler = NULL;
       
   311     delete iSPSHandler;
       
   312     iSPSHandler = NULL;
       
   313     delete iConnMonHandler;
       
   314     iConnMonHandler = NULL;
       
   315     delete iRequestStorage;
       
   316     iRequestStorage = NULL;
       
   317     delete iPluginHandler;
       
   318     iPluginHandler = NULL;
       
   319     delete iFeatureManager;
       
   320     iFeatureManager = NULL;
       
   321     delete iObjectConIx;
       
   322     iObjectConIx = NULL;
       
   323     }
       
   324 
       
   325 
       
   326 // ---------------------------------------------------------------------------
       
   327 // CCCHServerBase::NotifySessionCreatedL
       
   328 // Increase session counter
       
   329 // (other items were commented in a header).
       
   330 // ---------------------------------------------------------------------------
       
   331 //
       
   332 void CCCHServerBase::NotifySessionCreatedL()
       
   333     {
       
   334     CCHLOGSTRING( "CCCHServerBase::NotifySessionCreatedL" );
       
   335     
       
   336     iWakeUpEventNotifier->Stop();
       
   337     
       
   338     if ( iSessionCounter == 0 && IsServerShutdownAllowedL() )
       
   339     	{
       
   340         ServiceHandler().InitServiceHandlerL();
       
   341     	}
       
   342     iSessionCounter++;
       
   343     }
       
   344 
       
   345 // ---------------------------------------------------------------------------
       
   346 // CCCHServerBase::NotifySessionClosed
       
   347 // Decrease session counter
       
   348 // (other items were commented in a header).
       
   349 // ---------------------------------------------------------------------------
       
   350 //
       
   351 void CCCHServerBase::NotifySessionClosed()
       
   352     {
       
   353     CCHLOGSTRING( "CCCHServerBase::NotifySessionClosed" );
       
   354     if ( 0 < iSessionCounter )
       
   355         {
       
   356         iSessionCounter--;
       
   357         }
       
   358     if ( 0 >= iSessionCounter )
       
   359         {
       
   360         iSessionCounter = 0;        
       
   361         TRAP_IGNORE( ShutDownServerL() );
       
   362         }
       
   363     }
       
   364 
       
   365 // ---------------------------------------------------------------------------
       
   366 // CCCHServerBase::PanicClient
       
   367 // Panic client with given error code.
       
   368 // (other items were commented in a header).
       
   369 // ---------------------------------------------------------------------------
       
   370 //
       
   371 void CCCHServerBase::PanicClient(
       
   372     const RMessage2& aMessage,
       
   373     TInt aPanic )
       
   374     {
       
   375     CCHLOGSTRING2("CCCHServerBase::PanicClient: Panic = %d", aPanic );
       
   376     _LIT( KTxtServer, "CCH Server Client" );
       
   377     aMessage.Panic( KTxtServer, aPanic );
       
   378     CCHLOGSTRING("CCCHServerBase::PanicClient exiting" );
       
   379     }
       
   380 
       
   381 // ---------------------------------------------------------------------------
       
   382 // PanicServer implements server panic handler.
       
   383 // Panic server with given error code.
       
   384 // Returns: None.
       
   385 // ---------------------------------------------------------------------------
       
   386 //
       
   387 void CCCHServerBase::PanicServer(
       
   388     TInt aPanic )
       
   389     {
       
   390     CCHLOGSTRING2("CCCHServerBase::PanicServer: Panic = %d", aPanic );
       
   391     _LIT( KTxtServerPanic, "CCH Server" );
       
   392     User::Panic( KTxtServerPanic, aPanic );
       
   393     CCHLOGSTRING("CCCHServerBase::PanicServer exit" );
       
   394     }
       
   395 
       
   396 // ---------------------------------------------------------------------------
       
   397 // CCCHServerBase::ConstructObject
       
   398 // Create requested object and/or return reference to it.
       
   399 // ---------------------------------------------------------------------------
       
   400 //
       
   401 template <class T>T& CCCHServerBase::ConstructObject( 
       
   402     CCCHServerBase* aThis,
       
   403     T*& aObject )
       
   404     {
       
   405     TInt error = KErrNone;
       
   406     if ( !aObject )
       
   407         {
       
   408         TRAP( error, aObject = T::NewL( *aThis ) );
       
   409         }
       
   410     
       
   411     if ( KErrNone != error )
       
   412         {
       
   413         // Failed to create object, have to Panic!
       
   414         PanicServer( ECCHErrCreateServer );
       
   415         }
       
   416     return *aObject;
       
   417     }
       
   418 
       
   419 // ---------------------------------------------------------------------------
       
   420 // CCCHServerBase::ConstructObject
       
   421 // Create requested object and/or return reference to it.
       
   422 // ---------------------------------------------------------------------------
       
   423 //
       
   424 template <class T>T& CCCHServerBase::ConstructObject( 
       
   425     T*& aObject )
       
   426     {
       
   427     TInt error = KErrNone;
       
   428     if ( !aObject )
       
   429         {
       
   430         TRAP( error, aObject = T::NewL() );
       
   431         }
       
   432     
       
   433     if ( KErrNone != error )
       
   434         {
       
   435         // Failed to create object, have to Panic!
       
   436         PanicServer( ECCHErrCreateServer );
       
   437         }
       
   438     return *aObject;
       
   439     }
       
   440 
       
   441 TBool CCCHServerBase::VoIPEmergencyNoteShown()
       
   442 	{
       
   443 	return iVoIPEmergencyNoteShown;
       
   444 	}
       
   445 
       
   446 void CCCHServerBase::SetVoIPEmergencyNoteShown( TBool aShown )
       
   447 	{
       
   448 	iVoIPEmergencyNoteShown = aShown;
       
   449 	}
       
   450 
       
   451 // ---------------------------------------------------------------------------
       
   452 // CCCHServerBase::ObjectContainerIx
       
   453 // Return object container index.
       
   454 // (other items were commented in a header).
       
   455 // ---------------------------------------------------------------------------
       
   456 //
       
   457 CObjectConIx& CCCHServerBase::ObjectContainerIx()
       
   458     {
       
   459     return ConstructObject<CObjectConIx>( iObjectConIx );
       
   460     }
       
   461 
       
   462 // ---------------------------------------------------------------------------
       
   463 // CCCHServerBase::RequestStorage
       
   464 // Return instance of request storage.
       
   465 // (other items were commented in a header).
       
   466 // ---------------------------------------------------------------------------
       
   467 //
       
   468 CCCHRequestStorage& CCCHServerBase::RequestStorage()
       
   469     {
       
   470     return ConstructObject<CCCHRequestStorage>( this, iRequestStorage );
       
   471     }
       
   472 
       
   473 // ---------------------------------------------------------------------------
       
   474 // CCCHServerBase::ConnMonHandler
       
   475 // Return instance of ConnMonHandler.
       
   476 // (other items were commented in a header).
       
   477 // ---------------------------------------------------------------------------
       
   478 //
       
   479 CCCHConnMonHandler& CCCHServerBase::ConnMonHandler()
       
   480     {
       
   481     return ConstructObject<CCCHConnMonHandler>( this, iConnMonHandler );
       
   482     }
       
   483     
       
   484 // -----------------------------------------------------------------------------
       
   485 // CCCHServerBase::PluginHandler
       
   486 // Return instance of plug-in handler.
       
   487 // (other items were commented in a header).
       
   488 // -----------------------------------------------------------------------------
       
   489 //
       
   490 CCCHPluginHandler& CCCHServerBase::PluginHandler()
       
   491     {
       
   492     return ConstructObject<CCCHPluginHandler>( this, iPluginHandler );
       
   493     }
       
   494 
       
   495 // ---------------------------------------------------------------------------
       
   496 // CCCHServerBase::SPSHandler
       
   497 // Return instance of SPSHandler.
       
   498 // (other items were commented in a header).
       
   499 // ---------------------------------------------------------------------------
       
   500 //
       
   501 CCCHSPSHandler& CCCHServerBase::SPSHandler()
       
   502     {
       
   503     return ConstructObject<CCCHSPSHandler>( this, iSPSHandler );
       
   504     }
       
   505     
       
   506 // ---------------------------------------------------------------------------
       
   507 // CCCHServerBase::ServiceHandler
       
   508 // Return instance of ServiceHandler.
       
   509 // (other items were commented in a header).
       
   510 // ---------------------------------------------------------------------------
       
   511 //
       
   512 CCCHServiceHandler& CCCHServerBase::ServiceHandler()
       
   513     {
       
   514     return ConstructObject<CCCHServiceHandler>( this, iServiceHandler );
       
   515     }
       
   516 
       
   517 // ---------------------------------------------------------------------------
       
   518 // CCCHServerBase::FeatureManager
       
   519 // Return instance of FeatureManager.
       
   520 // (other items were commented in a header).
       
   521 // ---------------------------------------------------------------------------
       
   522 //
       
   523 CCchFeatureManager& CCCHServerBase::FeatureManager()
       
   524     {
       
   525     return ConstructObject<CCchFeatureManager>( iFeatureManager );
       
   526     }
       
   527         
       
   528 // ---------------------------------------------------------------------------
       
   529 // CCCHServerBase::WakeUp
       
   530 // Creates all required objects needed by full server mode.
       
   531 // ---------------------------------------------------------------------------
       
   532 //
       
   533 void CCCHServerBase::WakeUp()
       
   534     {
       
   535     CCHLOGSTRING( "CCCHServerBase::WakeUp IN" );
       
   536     if ( iSessionCounter == 0 && !iServerObjectsInit )
       
   537     	{
       
   538 	    TRAPD( err, InitServerObjectsL() );
       
   539 	    if ( KErrNone != err )
       
   540 	    	{
       
   541 	        // Failed to create required objects, have to Panic!
       
   542 	        PanicServer( ECCHErrCreateServer );
       
   543 	    	}
       
   544     	}
       
   545     CCHLOGSTRING( "CCCHServerBase::WakeUp OUT" );
       
   546     }
       
   547 
       
   548 // ---------------------------------------------------------------------------
       
   549 // CCCHServerBase::CreateStartupCounterL
       
   550 // 
       
   551 // (other items were commented in a header).
       
   552 // ---------------------------------------------------------------------------
       
   553 //
       
   554 void CCCHServerBase::CreateStartupCounterL()
       
   555     {
       
   556     if ( !iStartupCounter )
       
   557         {
       
   558         iStartupCounter = CCchStartupCounter::NewL( *this );
       
   559         }
       
   560     iStartupCounter->StartupOccuredL();
       
   561     }
       
   562 
       
   563 // ---------------------------------------------------------------------------
       
   564 // CCCHServerBase::ResetStartupCounterL
       
   565 // 
       
   566 // (other items were commented in a header).
       
   567 // ---------------------------------------------------------------------------
       
   568 //
       
   569 void CCCHServerBase::ResetStartupCounterL()
       
   570     {
       
   571     if ( !iStartupCounter )
       
   572         {
       
   573         iStartupCounter = CCchStartupCounter::NewL( *this );
       
   574         }
       
   575     iStartupCounter->ResetStartupCounter();
       
   576     delete iStartupCounter;
       
   577     iStartupCounter = NULL;
       
   578     }
       
   579 
       
   580 // ---------------------------------------------------------------------------
       
   581 // CCCHServerBase::Restart
       
   582 // 
       
   583 // (other items were commented in a header).
       
   584 // ---------------------------------------------------------------------------
       
   585 //
       
   586 void CCCHServerBase::Restart()
       
   587     {
       
   588     CCHLOGSTRING( "CCCHServerBase::Restart IN" );
       
   589     
       
   590     // Send notify to our client
       
   591     TRAP_IGNORE( iServiceHandler->HandleRestartL() );
       
   592     
       
   593     // Do we have to make reregistration
       
   594     if ( iServiceHandler->IsStartupFlagSet() )
       
   595         {
       
   596         delete iServiceHandler;
       
   597         iServiceHandler = NULL;
       
   598         delete iPluginHandler;
       
   599         iPluginHandler = NULL;
       
   600         TRAP_IGNORE( InitServerObjectsL() );
       
   601         }
       
   602     
       
   603     CCHLOGSTRING( "CCCHServerBase::Restart OUT" );
       
   604     }
       
   605 
       
   606 // ---------------------------------------------------------------------------
       
   607 // CCCHServerBase::IsServerShutdownAllowedL
       
   608 // (other items were commented in a header).
       
   609 // ---------------------------------------------------------------------------
       
   610 //
       
   611 TBool CCCHServerBase::IsServerShutdownAllowedL()
       
   612     {
       
   613     CCHLOGSTRING( "CCCHServerBase::IsServerShutdownAllowedL" );
       
   614     
       
   615     TBool shutDownAllowed( ETrue );
       
   616     
       
   617     if ( iSPSHandler && iServiceHandler )  
       
   618         {
       
   619         // Get service IDs
       
   620         RArray<TUint> serviceIds;
       
   621         CleanupClosePushL( serviceIds );
       
   622         
       
   623         iSPSHandler->GetServiceIdsL( serviceIds );
       
   624         
       
   625         TCCHSubserviceState state( ECCHUninitialized );
       
   626   
       
   627         for ( TInt i( 0 ); i < serviceIds.Count(); i++ )
       
   628             {
       
   629             state = iServiceHandler->ServiceState( serviceIds[i] );
       
   630 
       
   631             if ( ECCHDisabled != state && ECCHUninitialized != state )
       
   632                 {
       
   633                 shutDownAllowed = EFalse;
       
   634                 }
       
   635             }
       
   636     
       
   637         CleanupStack::PopAndDestroy( &serviceIds ); 
       
   638         }
       
   639 
       
   640     CCHLOGSTRING2("CCCHServerBase::IsServerShutdownAllowedL: shutDownAllowed = %d", shutDownAllowed );
       
   641     return shutDownAllowed;
       
   642     }
       
   643 
       
   644 // ========================== OTHER EXPORTED FUNCTIONS =======================
       
   645 
       
   646 // ---------------------------------------------------------------------------
       
   647 // E32Main implements the executable entry function.
       
   648 // Note that because the target type of the CCHServer module
       
   649 // is EXEDLL, the entry point has different signature depending
       
   650 // on the build platform.
       
   651 // Creates a cleanup stack and runs the server.
       
   652 // Returns: Zero
       
   653 // ---------------------------------------------------------------------------
       
   654 //
       
   655 GLDEF_C TInt E32Main()
       
   656     {
       
   657     TInt error( KErrNoMemory );
       
   658     __UHEAP_MARK;
       
   659     CCHLOGSTRING( "CCCHServerBase E32Main" );
       
   660     CTrapCleanup* cleanup = CTrapCleanup::New();
       
   661 
       
   662     
       
   663     if ( cleanup )
       
   664         {
       
   665         TRAP( error, InitServerL() );
       
   666         delete cleanup;
       
   667         }
       
   668 
       
   669     __UHEAP_MARKEND;
       
   670 
       
   671     return error;
       
   672     }
       
   673 
       
   674 //  End of File