sensorservices/sensorserver/src/server/sensrvshutdown.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2008 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:  This class implements the shutdown timer that is used by the 
       
    15 *                SensorServer to shutdown the server after the last client has
       
    16 *                disconnected.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "sensrvshutdown.h"
       
    24 #include "sensrvtrace.h"
       
    25 #include "sensrvproxymanager.h"
       
    26 
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CRadioServerShutdown::CRadioServerShutdown
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CSensrvShutdown::CSensrvShutdown( CSensrvProxyManager& aProxyManager )
       
    37 	:	CTimer(EPriorityStandard),
       
    38 	iProxyManager(aProxyManager)
       
    39     {
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CRadioServerShutdown::ConstructL
       
    44 // Symbian 2nd phase constructor can leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 void CSensrvShutdown::ConstructL()
       
    48     {
       
    49 	COMPONENT_TRACE( _L( "Sensor Server - CSensrvShutdown::ConstructL" ) );
       
    50 	CTimer::ConstructL();
       
    51 	CActiveScheduler::Add(this);
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CRadioServerShutdown::NewL
       
    56 // Two-phased constructor.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CSensrvShutdown* CSensrvShutdown::NewL( CSensrvProxyManager& aProxyManager )
       
    60     {
       
    61     CSensrvShutdown* self = new( ELeave ) CSensrvShutdown( aProxyManager );
       
    62     CleanupStack::PushL(self);
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop(self);
       
    65     return self;
       
    66     }
       
    67 
       
    68 // Destructor
       
    69 CSensrvShutdown::~CSensrvShutdown()
       
    70     {
       
    71     COMPONENT_TRACE( _L( "Sensor Server - CSensrvShutdown::CSensrvShutdown" ) );
       
    72 	if ( IsActive() )
       
    73 		{
       
    74 		Cancel();
       
    75 		}
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CRadioServerShutdown::Start
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CSensrvShutdown::Start()
       
    83     {
       
    84     COMPONENT_TRACE( _L( "Sensor Server - CSensrvShutdown::Start" ) );
       
    85 	if ( !IsActive() )
       
    86 		{
       
    87 		After(iProxyManager.TerminationPeriod());
       
    88 		}
       
    89 	COMPONENT_TRACE( _L( "Sensor Server - CSensrvShutdown::Start - return" ) );
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CRadioServerShutdown::DoCancel
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CSensrvShutdown::DoCancel()
       
    97     {
       
    98     CTimer::DoCancel();
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CRadioServerShutdown::RunL
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CSensrvShutdown::RunL()
       
   106     {
       
   107 	COMPONENT_TRACE( _L( "Sensor Server - CSensrvShutdown::RunL - Stop scheduler" ) );
       
   108     iProxyManager.ShutdownServer();
       
   109     }
       
   110 
       
   111 //  End of File