cmmanager/cmmgr/cmmserver/src/cmmserver.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
child 62 bb1f80fb7db2
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
     1 /*
       
     2 * Copyright (c) 2009-2010 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 * Connection method manager server.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <cmconnectionmethoddef.h>
       
    21 #include <cmpluginpacketdatadef.h>
       
    22 #include <cmpluginwlandef.h>
       
    23 
       
    24 #include "cmmserver.h"
       
    25 #include "cmmsession.h"
       
    26 
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "cmmserverTraces.h"
       
    30 #endif
       
    31 
       
    32 
       
    33 const TUint CCmmServer::iCmmRangeCount = 12;
       
    34 
       
    35 const TInt CCmmServer::iCmmRanges[iCmmRangeCount] =
       
    36     {
       
    37     0,      //  1.   0-11
       
    38     12,     //  2.  12-15
       
    39     16,     //  3.  16-22
       
    40     23,     //  4.  23-99
       
    41     100,    //  5. 100-113
       
    42     114,    //  6. 114-128
       
    43     129,    //  7. 129-199
       
    44     200,    //  8. 200-205
       
    45     206,    //  9. 206-210
       
    46     211,    // 10. 211-214
       
    47     215,    // 11. 215-220
       
    48     221     // 12. 221-KMaxInt
       
    49     };
       
    50 
       
    51 const TUint8 CCmmServer::iCmmElementIndex[iCmmRangeCount] =
       
    52     {
       
    53     CPolicyServer::EAlwaysPass,     // 0-11
       
    54     CPolicyServer::ECustomCheck,    // 12-15
       
    55     CPolicyServer::ECustomCheck,    // 16-22
       
    56     CPolicyServer::ENotSupported,   // 23-99
       
    57     CPolicyServer::EAlwaysPass,     // 100-113
       
    58     CPolicyServer::ECustomCheck,    // 114-128
       
    59     CPolicyServer::ENotSupported,   // 129-199
       
    60     CPolicyServer::EAlwaysPass,     // 200-205
       
    61     CPolicyServer::ECustomCheck,    // 206-210
       
    62     CPolicyServer::ECustomCheck,    // 211-214
       
    63     CPolicyServer::ECustomCheck,    // 215-220
       
    64     CPolicyServer::ENotSupported    // 221->
       
    65     };
       
    66 
       
    67 const CPolicyServer::TPolicyElement CCmmServer::iCmmElements[] =
       
    68     {
       
    69     {_INIT_SECURITY_POLICY_C1(ECapabilityReadDeviceData), CPolicyServer::EFailClient},
       
    70     {_INIT_SECURITY_POLICY_C1(ECapabilityWriteDeviceData), CPolicyServer::EFailClient},
       
    71     {_INIT_SECURITY_POLICY_C2(ECapabilityReadDeviceData, ECapabilityWriteDeviceData), 
       
    72             CPolicyServer::EFailClient},
       
    73     {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl), CPolicyServer::EFailClient},
       
    74     };
       
    75 
       
    76 const CPolicyServer::TPolicy CCmmServer::iCmmPolicy =
       
    77     {
       
    78     CPolicyServer::EAlwaysPass, // Specifies all connect attempts should pass
       
    79     iCmmRangeCount,     // Count of ranges
       
    80     iCmmRanges,         // 0-11, 12-15, 16...
       
    81     iCmmElementIndex,   // What to do for each range
       
    82     iCmmElements        // The list of policy elements
       
    83     };
       
    84 
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CCmmServer::CustomSecurityCheckL
       
    88 // Implements custom security checking for IPCs marked with
       
    89 // TSpecialCase::ECustomCheck.
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 CPolicyServer::TCustomResult CCmmServer::CustomSecurityCheckL(
       
    93         const RMessage2& aMessage,
       
    94         TInt& /*aAction*/,
       
    95         TSecurityInfo& /*aMissing*/ )
       
    96     {
       
    97     switch ( aMessage.Function() )
       
    98         {
       
    99         // ***********  2nd range: 12-15 *************
       
   100         case ECmmGetConnMethodInfoInt:
       
   101         case ECmmGetConnMethodInfoBool:
       
   102         case ECmmGetConnMethodInfoString:
       
   103         case ECmmGetConnMethodInfoString8:
       
   104         // ***********  10th range: 211-214 *************
       
   105         case ECMGetIntAttribute:
       
   106         case ECMGetBoolAttribute:
       
   107         case ECMGetStringAttribute:
       
   108         case ECMGetString8Attribute:
       
   109             {
       
   110             switch ( aMessage.Int0() )
       
   111                 {
       
   112                 // Private userdata has to be checked.
       
   113                 // WPA:
       
   114                 case CMManager::EWlanEnableWpaPsk:
       
   115                 case CMManager::EWlanWpaPreSharedKey:
       
   116                 // WEP:
       
   117                 case CMManager::EWlanWepKey1InHex:
       
   118                 case CMManager::EWlanWepKey2InHex:
       
   119                 case CMManager::EWlanWepKey3InHex:
       
   120                 case CMManager::EWlanWepKey4InHex:
       
   121                 case CMManager::EWlanWepKey1InAscii:
       
   122                 case CMManager::EWlanWepKey2InAscii:
       
   123                 case CMManager::EWlanWepKey3InAscii:
       
   124                 case CMManager::EWlanWepKey4InAscii:
       
   125                 case CMManager::EWlanWepKeyIndex:
       
   126                 // WAPI:
       
   127                 case CMManager::EWlanWapiPsk:
       
   128                 case CMManager::EWlanWapiPskFormat:
       
   129                 // 802.1x:
       
   130                 case CMManager::EWlan802_1xAllowUnencrypted:
       
   131                 // Authentication:
       
   132                 case CMManager::ECmIFAuthName:
       
   133                 case CMManager::EPacketDataIFAuthName:
       
   134                 case CMManager::ECmIFAuthPass:
       
   135                 case CMManager::EPacketDataIFAuthPass:
       
   136                     {
       
   137                     // ECapabilityReadDeviceData
       
   138                     return ( iCmmElements[0].iPolicy.CheckPolicy( aMessage ) ) ?
       
   139                         EPass : EFail;
       
   140                     }
       
   141                 default:
       
   142                     // By default reading does not need any capabilities.
       
   143                     return EPass;
       
   144                 }
       
   145             }
       
   146         // ***********  3rd range: 16-22 *************
       
   147         case ECmmUpdateBearerPriorityArray:
       
   148         case ECmmWriteDefaultConnection:
       
   149         case ECmmWriteGeneralConnectionSettings:
       
   150         // At this phase all capabilities are not checked because of
       
   151         // it's too heavy operation...
       
   152         // At Session phase the protection of the destination and/or
       
   153         // connection method is checked. If protected, 
       
   154         // ECapabilityNetworkControl is checked.
       
   155         case ECmmCopyConnMethod:
       
   156         case ECmmMoveConnMethod:
       
   157         case ECmmRemoveConnMethod:
       
   158         case ECmmRemoveAllReferences:
       
   159             {
       
   160             // ECapabilityWriteDeviceData is needed for writing
       
   161             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
       
   162                 EPass : EFail;
       
   163             }
       
   164         // ***********  6th range: 114-128 *************
       
   165         case EDestCreateDestinationWithName:
       
   166         case EDestCreateDestinationWithNameAndId:
       
   167         case EDestIsConnected:
       
   168         case EDestAddConnMethod:
       
   169         case EDestAddEmbeddedDestination:
       
   170         case EDestDeleteConnMethod:
       
   171         case EDestRemoveConnMethod:
       
   172         case EDestModifyPriority:
       
   173         case EDestSetName:
       
   174         case EDestSetMetadata:
       
   175         case EDestSetProtection:
       
   176         case EDestSetHidden:
       
   177         case EDestUpdate:
       
   178         case EDestDelete:
       
   179         case EDestSetIcon:
       
   180             {
       
   181             // ECapabilityWriteDeviceData is needed for writing
       
   182             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
       
   183                 EPass : EFail;
       
   184             }
       
   185         // ***********  9th range: 206-210 *************
       
   186 
       
   187         // ECapabilityWriteDeviceData is needed for writing
       
   188         case ECMCreateConnMethod:
       
   189         case ECMCreateConnMethodWithId:
       
   190         
       
   191         // At this phase all capabilities are not checked because of
       
   192         // it's too heavy operation...
       
   193         // At Session phase the protection of the destination and/or
       
   194         // connection method is checked. If protected, 
       
   195         // ECapabilityNetworkControl is checked.
       
   196         case ECMCreateConnMethodToDest:
       
   197         case ECMCreateConnMethodToDestWithId:
       
   198         case ECMCreateCopyOfExisting:
       
   199             {
       
   200             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
       
   201                 EPass : EFail;
       
   202             }
       
   203         // ***********  11th range: 215-220 *************
       
   204         // Protection of the CM is checked later(protected needs ECapabilityNetworkControl)
       
   205         case ECMSetIntAttribute:
       
   206         case ECMSetBoolAttribute:
       
   207         case ECMSetStringAttribute:
       
   208         case ECMSetString8Attribute:
       
   209             {
       
   210             switch ( aMessage.Int0() )
       
   211                 {
       
   212                 // WPA:
       
   213                 case CMManager::EWlanEnableWpaPsk:
       
   214                 case CMManager::EWlanWpaPreSharedKey:
       
   215                 // WEP:
       
   216                 case CMManager::EWlanWepKey1InHex:
       
   217                 case CMManager::EWlanWepKey2InHex:
       
   218                 case CMManager::EWlanWepKey3InHex:
       
   219                 case CMManager::EWlanWepKey4InHex:
       
   220                 case CMManager::EWlanWepKey1InAscii:
       
   221                 case CMManager::EWlanWepKey2InAscii:
       
   222                 case CMManager::EWlanWepKey3InAscii:
       
   223                 case CMManager::EWlanWepKey4InAscii:
       
   224                 case CMManager::EWlanWepKeyIndex:
       
   225                 // WAPI:
       
   226                 case CMManager::EWlanWapiPsk:
       
   227                 case CMManager::EWlanWapiPskFormat:
       
   228                 // 802.1x:
       
   229                 case CMManager::EWlan802_1xAllowUnencrypted:
       
   230                 // Authentication:
       
   231                 case CMManager::ECmIFAuthName:
       
   232                 case CMManager::EPacketDataIFAuthName:
       
   233                 case CMManager::ECmIFAuthPass:
       
   234                 case CMManager::EPacketDataIFAuthPass:
       
   235                     {
       
   236                     // ECapabilityReadDeviceData
       
   237                     return ( iCmmElements[2].iPolicy.CheckPolicy( aMessage ) ) ?
       
   238                         EPass : EFail;
       
   239                     }
       
   240                 default:
       
   241                     {
       
   242                     // ECapabilityWriteDeviceData
       
   243                     return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
       
   244                         EPass : EFail;
       
   245                     }
       
   246                 }
       
   247             }
       
   248         case ECMDelete:
       
   249         case ECMUpdate:
       
   250             {
       
   251             // ECapabilityWriteDeviceData (if protected, ECapabilityNetworkControl
       
   252             // is checked later).
       
   253             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
       
   254                 EPass : EFail;
       
   255             }
       
   256         default:
       
   257             return EPass;
       
   258         }
       
   259     }
       
   260 
       
   261 /**
       
   262  * This is for checking client's capabilities at later phase after
       
   263  * protections of destination/connection method have been checked
       
   264  * first.
       
   265  */
       
   266 CPolicyServer::TCustomResult CCmmServer::CapabilityCheckWithProtection( 
       
   267         const RMessage2& aMessage )
       
   268     {
       
   269     switch ( aMessage.Function() )
       
   270         {
       
   271         case ECmmCopyConnMethod:
       
   272         case ECmmMoveConnMethod:
       
   273         case ECmmRemoveConnMethod:
       
   274         case ECmmRemoveAllReferences:
       
   275         case EDestAddConnMethod:
       
   276         case EDestDeleteConnMethod:
       
   277         case EDestAddEmbeddedDestination:
       
   278         case EDestRemoveConnMethod:
       
   279         case EDestModifyPriority:
       
   280         case EDestSetName:
       
   281         case EDestSetMetadata:
       
   282         case EDestSetProtection:
       
   283         case EDestSetHidden:
       
   284         case EDestUpdate:
       
   285         case EDestDelete:
       
   286         case EDestSetIcon:
       
   287         case ECMCreateConnMethodToDest:
       
   288         case ECMCreateConnMethodToDestWithId:
       
   289         case ECMUpdate:
       
   290         case ECMDelete:
       
   291         case ECMSetIntAttribute:
       
   292         case ECMSetBoolAttribute:
       
   293         case ECMSetStringAttribute:
       
   294         case ECMSetString8Attribute:
       
   295             {
       
   296             // ECapabilityNetworkControl
       
   297             return ( iCmmElements[3].iPolicy.CheckPolicy( aMessage ) ) ? EPass : EFail;
       
   298             }
       
   299         default:
       
   300             // Execution should never come here.
       
   301             return EFail;
       
   302         }
       
   303     }
       
   304 
       
   305 CCmmServer::CCmmServer( TInt aPriority ) : CPolicyServer( aPriority, iCmmPolicy )
       
   306     {
       
   307     OstTraceFunctionEntry0( CCMMSERVER_CCMMSERVER_ENTRY );
       
   308 
       
   309     iSessionCount = 0;
       
   310     iCmManager = NULL;
       
   311     iContainerIndex = NULL;
       
   312     iShutdown = NULL;
       
   313 
       
   314     OstTraceFunctionExit0( CCMMSERVER_CCMMSERVER_EXIT );
       
   315     }
       
   316 
       
   317 CCmmServer::~CCmmServer()
       
   318     {
       
   319     OstTraceFunctionEntry0( DUP1_CCMMSERVER_CCMMSERVER_ENTRY );
       
   320 
       
   321     delete iCmManager;
       
   322     delete iContainerIndex;
       
   323     delete iShutdown;
       
   324 
       
   325     OstTraceFunctionExit0( DUP1_CCMMSERVER_CCMMSERVER_EXIT );
       
   326     }
       
   327 
       
   328 CCmmServer* CCmmServer::NewL()
       
   329     {
       
   330     OstTraceFunctionEntry0( CCMMSERVER_NEWL_ENTRY );
       
   331 
       
   332     CCmmServer* server = CCmmServer::NewLC();
       
   333     CleanupStack::Pop( server );
       
   334 
       
   335     OstTraceFunctionExit0( CCMMSERVER_NEWL_EXIT );
       
   336     return server;
       
   337     }
       
   338 
       
   339 CCmmServer* CCmmServer::NewLC()
       
   340     {
       
   341     OstTraceFunctionEntry0( CCMMSERVER_NEWLC_ENTRY );
       
   342 
       
   343     CCmmServer* server = new( ELeave ) CCmmServer( EPriorityNormal );
       
   344     CleanupStack::PushL( server );
       
   345     server->ConstructL();
       
   346 
       
   347     OstTraceFunctionExit0( CCMMSERVER_NEWLC_EXIT );
       
   348     return server;
       
   349     }
       
   350 
       
   351 void CCmmServer::ConstructL()
       
   352     {
       
   353     OstTraceFunctionEntry0( CCMMSERVER_CONSTRUCTL_ENTRY );
       
   354 
       
   355     StartL( KCmmServer );
       
   356 
       
   357     iCmManager = CCmManagerImpl::NewL();
       
   358 
       
   359     // Create the object container index.
       
   360     iContainerIndex = CObjectConIx::NewL();
       
   361 
       
   362     // Construct shutdown timer.
       
   363     iShutdown = new( ELeave ) CCmmDelayedShutdown( this );
       
   364     iShutdown->ConstructL();
       
   365 
       
   366     OstTraceFunctionExit0( CCMMSERVER_CONSTRUCTL_EXIT );
       
   367     }
       
   368 
       
   369 // -----------------------------------------------------------------------------
       
   370 // Create a new session.
       
   371 // -----------------------------------------------------------------------------
       
   372 //
       
   373 CSession2* CCmmServer::NewSessionL(
       
   374         const TVersion& /*aVersion*/,
       
   375         const RMessage2& /*aMessage*/ ) const
       
   376     {
       
   377     OstTraceFunctionEntry0( CCMMSERVER_NEWSESSIONL_ENTRY );
       
   378 
       
   379     CSession2* session = CCmmSession::NewL(
       
   380             *const_cast<CCmmServer*>( this ),
       
   381             iCmManager->Cache() );
       
   382 
       
   383     OstTraceFunctionExit0( CCMMSERVER_NEWSESSIONL_EXIT );
       
   384     return session;
       
   385     }
       
   386 
       
   387 // -----------------------------------------------------------------------------
       
   388 // Increments the session counter. Cancels the shutdown timer if active.
       
   389 // -----------------------------------------------------------------------------
       
   390 //
       
   391 void CCmmServer::IncrementSessions()
       
   392     {
       
   393     OstTraceFunctionEntry0( CCMMSERVER_INCREMENTSESSIONS_ENTRY );
       
   394 
       
   395     iSessionCount++;
       
   396     iShutdown->Cancel();
       
   397 
       
   398     OstTraceFunctionExit0( CCMMSERVER_INCREMENTSESSIONS_EXIT );
       
   399     }
       
   400 
       
   401 // -----------------------------------------------------------------------------
       
   402 // Decrements the session counter. Starts the shutdown counter when last
       
   403 // session closes.
       
   404 // -----------------------------------------------------------------------------
       
   405 //
       
   406 void CCmmServer::DecrementSessions()
       
   407     {
       
   408     OstTraceFunctionEntry0( CCMMSERVER_DECREMENTSESSIONS_ENTRY );
       
   409 
       
   410     iSessionCount--;
       
   411 
       
   412     // Terminate the server when there are no clients left.
       
   413     if ( iSessionCount <= 0 )
       
   414         {
       
   415         if ( !iShutdown->IsActive() )
       
   416             {
       
   417             iShutdown->Start();
       
   418             }
       
   419         }
       
   420 
       
   421     OstTraceFunctionExit0( CCMMSERVER_DECREMENTSESSIONS_EXIT );
       
   422     }
       
   423 
       
   424 // -----------------------------------------------------------------------------
       
   425 // CCmmServer::NewContainerL
       
   426 // -----------------------------------------------------------------------------
       
   427 //
       
   428 CObjectCon* CCmmServer::NewContainerL()
       
   429     {
       
   430     OstTraceFunctionEntry0( CCMMSERVER_NEWCONTAINERL_ENTRY );
       
   431 
       
   432     CObjectCon* container = iContainerIndex->CreateL();
       
   433 
       
   434     OstTraceFunctionExit0( CCMMSERVER_NEWCONTAINERL_EXIT );
       
   435     return container;
       
   436     }
       
   437 
       
   438 // -----------------------------------------------------------------------------
       
   439 // CCmmServer::RemoveContainer
       
   440 // -----------------------------------------------------------------------------
       
   441 //
       
   442 void CCmmServer::RemoveContainer( CObjectCon* aContainer )
       
   443     {
       
   444     OstTraceFunctionEntry0( CCMMSERVER_REMOVECONTAINER_ENTRY );
       
   445 
       
   446     iContainerIndex->Remove( aContainer );
       
   447 
       
   448     OstTraceFunctionExit0( CCMMSERVER_REMOVECONTAINER_EXIT );
       
   449     }
       
   450 
       
   451 // -----------------------------------------------------------------------------
       
   452 // CCmmServer::RunError
       
   453 // -----------------------------------------------------------------------------
       
   454 //
       
   455 TInt CCmmServer::RunError( TInt aError )
       
   456     {
       
   457     OstTraceFunctionEntry0( CCMMSERVER_RUNERROR_ENTRY );
       
   458 
       
   459     Message().Complete( aError );
       
   460 
       
   461     // The leave will result in an early return from CServer::RunL(),
       
   462     // skipping the call to request another message. So we issue the
       
   463     // request here in order to keep the server running.
       
   464     ReStart();
       
   465 
       
   466     OstTraceFunctionExit0( CCMMSERVER_RUNERROR_EXIT );
       
   467     return KErrNone;
       
   468     }
       
   469 
       
   470 // -----------------------------------------------------------------------------
       
   471 // CCmmServer::CmManager
       
   472 // -----------------------------------------------------------------------------
       
   473 //
       
   474 CCmManagerImpl* CCmmServer::CmManager()
       
   475     {
       
   476     OstTraceFunctionEntry0( CCMMSERVER_CMMANAGER_ENTRY );
       
   477 
       
   478     OstTraceFunctionExit0( CCMMSERVER_CMMANAGER_EXIT );
       
   479 
       
   480     return iCmManager;
       
   481     }
       
   482 
       
   483 // -----------------------------------------------------------------------------
       
   484 // Check for restrictions for adding an embedded destination from destination
       
   485 // instances of all clients.
       
   486 // - aDestinationId is the ID of the destination where a destination is beeing
       
   487 //   embedded.
       
   488 // - aEmbeddedDestinationId is the ID of the destination that is beeing
       
   489 //   embedded.
       
   490 // -----------------------------------------------------------------------------
       
   491 //
       
   492 TBool CCmmServer::EmbeddedDestinationConflictsFromAllSessions(
       
   493         const TUint32 aDestinationId,
       
   494         const TUint32 aEmbeddedDestinationId )
       
   495     {
       
   496     OstTraceFunctionEntry0( CCMMSERVER_EMBEDDEDDESTINATIONCONFLICTSFROMALLSESSIONS_ENTRY );
       
   497 
       
   498     TBool result( EFalse );
       
   499     CSession2* session( NULL );
       
   500 
       
   501     // Iterate through all sessions.
       
   502     iSessionIter.SetToFirst();
       
   503     for ( session = iSessionIter++; session; session = iSessionIter++ )
       
   504         {
       
   505         CCmmSession* cmmSession = static_cast<CCmmSession*>( session );
       
   506         if ( cmmSession->EmbeddedDestinationConflicts( aDestinationId, aEmbeddedDestinationId ) )
       
   507             {
       
   508             result = ETrue;
       
   509             break;
       
   510             }
       
   511         }
       
   512     OstTraceFunctionExit0( CCMMSERVER_EMBEDDEDDESTINATIONCONFLICTSFROMALLSESSIONS_EXIT );
       
   513 
       
   514     return result;
       
   515     }
       
   516 
       
   517 // ---------------------------------------------------------------------------
       
   518 // Notify each session about a destination/connection method that has been
       
   519 // updated to, or deleted from, database.
       
   520 // ---------------------------------------------------------------------------
       
   521 //
       
   522 void CCmmServer::RefreshHandlesForAllSessions( const TUint32 aId )
       
   523     {
       
   524     OstTraceFunctionEntry0( CCMMSERVER_REFRESHHANDLESFORALLSESSIONS_ENTRY );
       
   525 
       
   526     CSession2* session( NULL );
       
   527 
       
   528     // Iterate through all sessions.
       
   529     iSessionIter.SetToFirst();
       
   530     for ( session = iSessionIter++; session; session = iSessionIter++ )
       
   531         {
       
   532         CCmmSession* cmmSession = static_cast<CCmmSession*>( session );
       
   533         cmmSession->RefreshHandles( aId );
       
   534         }
       
   535     OstTraceFunctionExit0( CCMMSERVER_REFRESHHANDLESFORALLSESSIONS_EXIT );
       
   536     }
       
   537 
       
   538 // ============================ MEMBER FUNCTIONS ===============================
       
   539 
       
   540 // -----------------------------------------------------------------------------
       
   541 // CCmmDelayedShutdown::CCmmDelayedShutdown
       
   542 // -----------------------------------------------------------------------------
       
   543 //
       
   544 CCmmDelayedShutdown::CCmmDelayedShutdown( CCmmServer* aServer )
       
   545         :
       
   546         CActive( 0 ),
       
   547         iServer( aServer )
       
   548     {
       
   549     }
       
   550 
       
   551 // -----------------------------------------------------------------------------
       
   552 // CCmmDelayedShutdown::ConstructL
       
   553 // -----------------------------------------------------------------------------
       
   554 //
       
   555 void CCmmDelayedShutdown::ConstructL()
       
   556     {
       
   557     OstTraceFunctionEntry0( CCMMDELAYEDSHUTDOWN_CONSTRUCTL_ENTRY );
       
   558 
       
   559     CActiveScheduler::Add( this );
       
   560     User::LeaveIfError( iTimer.CreateLocal() );
       
   561 
       
   562     OstTraceFunctionExit0( CCMMDELAYEDSHUTDOWN_CONSTRUCTL_EXIT );
       
   563     }
       
   564 
       
   565 // Destructor
       
   566 CCmmDelayedShutdown::~CCmmDelayedShutdown()
       
   567     {
       
   568     OstTraceFunctionEntry0( CCMMDELAYEDSHUTDOWN_CCMMDELAYEDSHUTDOWN_ENTRY );
       
   569 
       
   570     Cancel();
       
   571     iTimer.Close();
       
   572     iServer = NULL;
       
   573 
       
   574     OstTraceFunctionExit0( CCMMDELAYEDSHUTDOWN_CCMMDELAYEDSHUTDOWN_EXIT );
       
   575     }
       
   576 
       
   577 // -----------------------------------------------------------------------------
       
   578 // CCmmMonDelayedShutdown::Start
       
   579 // -----------------------------------------------------------------------------
       
   580 //
       
   581 void CCmmDelayedShutdown::Start()
       
   582     {
       
   583     OstTraceFunctionEntry0( CCMMDELAYEDSHUTDOWN_START_ENTRY );
       
   584 
       
   585     if ( IsActive() )
       
   586         {
       
   587         OstTraceFunctionExit0( CCMMDELAYEDSHUTDOWN_START_EXIT );
       
   588 
       
   589         return;
       
   590         }
       
   591 
       
   592     iTimer.After( iStatus, KCmmShutdownDelay );
       
   593     SetActive();
       
   594 
       
   595     OstTraceFunctionExit0( DUP1_CCMMDELAYEDSHUTDOWN_START_EXIT );
       
   596     }
       
   597 
       
   598 // -----------------------------------------------------------------------------
       
   599 // CCmmMonDelayedShutdown::DoCancel
       
   600 // -----------------------------------------------------------------------------
       
   601 //
       
   602 void CCmmDelayedShutdown::DoCancel()
       
   603     {
       
   604     OstTraceFunctionEntry0( CCMMDELAYEDSHUTDOWN_DOCANCEL_ENTRY );
       
   605 
       
   606     iTimer.Cancel();
       
   607 
       
   608     OstTraceFunctionExit0( CCMMDELAYEDSHUTDOWN_DOCANCEL_EXIT );
       
   609     }
       
   610 
       
   611 // -----------------------------------------------------------------------------
       
   612 // CCmmMonDelayedShutdown::RunL
       
   613 // -----------------------------------------------------------------------------
       
   614 //
       
   615 void CCmmDelayedShutdown::RunL()
       
   616     {
       
   617     OstTraceFunctionEntry0( CCMMDELAYEDSHUTDOWN_RUNL_ENTRY );
       
   618 
       
   619     CActiveScheduler::Stop();
       
   620 
       
   621     OstTraceFunctionExit0( CCMMDELAYEDSHUTDOWN_RUNL_EXIT );
       
   622     }
       
   623 
       
   624 // End of file