psmservices/psmserver/src/server/psmsrvshutdown.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2007 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:  PSM Server shutdown
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "psmsrvshutdown.h"
       
    20 #include "psmsrvserver.h"
       
    21 #include "psmsrvsession.h"
       
    22 #include "psmtrace.h"
       
    23 
       
    24 const TTimeIntervalMicroSeconds32 KShutDownTime = 60000000; // One minute 
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CPsmSrvShutdown::CPsmSrvShutdown
       
    28 // C++ default constructor can NOT contain any code, that
       
    29 // might leave.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CPsmSrvShutdown::CPsmSrvShutdown( CPsmSrvServer& aServer ) : 
       
    33     CActive( EPriorityNormal ),
       
    34     iServer( aServer )
       
    35     {
       
    36     CActiveScheduler::Add( this );
       
    37     iTimer.CreateLocal();
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // Destructor
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CPsmSrvShutdown::~CPsmSrvShutdown()
       
    45     {
       
    46     COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::~CPsmSrvShutdown()" ) ) );
       
    47     Cancel();
       
    48     COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::~CPsmSrvShutdown - return") ) );
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CPsmSrvShutdown::ServiceL
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 void CPsmSrvShutdown::RunL()
       
    56     {
       
    57     COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::RunL()" ) ) );
       
    58 
       
    59     // Note. This class does not implement CActive::RunError so this function cannot leave
       
    60 
       
    61     if ( KErrNone == iServer.ShutdownServer() )
       
    62         {
       
    63         iTimer.Close();
       
    64         }
       
    65 
       
    66     COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::RunL - return" ) ) );
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CPsmSrvShutdown::DoCancel
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void CPsmSrvShutdown::DoCancel()
       
    74     {
       
    75     COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::DoCancel()" ) ) );
       
    76 
       
    77     iTimer.Cancel();
       
    78 
       
    79     COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::DoCancel - return" ) ) );
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CPsmSrvShutdown::Start
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void CPsmSrvShutdown::Start()
       
    87     {
       
    88     COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::Start()" ) ) );
       
    89 
       
    90     iTimer.After( iStatus, KShutDownTime );
       
    91     SetActive();
       
    92 
       
    93     COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::Start - return" ) ) );
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CPsmSrvShutdown::Restart
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 void CPsmSrvShutdown::Restart()
       
   101     {
       
   102     COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::Restart()" ) ) );
       
   103 
       
   104     if ( IsActive() )
       
   105         {
       
   106         Cancel();
       
   107         }
       
   108 
       
   109     iTimer.After( iStatus, KShutDownTime );
       
   110     SetActive();
       
   111 
       
   112     COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::Restart - return" ) ) );
       
   113     }
       
   114 
       
   115 // End of file