psmservices/psmserver/src/server/psmsrvshutdown.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:34:26 +0100
branchRCL_3
changeset 61 8cb079868133
parent 0 4e1aa6a622a0
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035

/*
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  PSM Server shutdown
*
*/


#include "psmsrvshutdown.h"
#include "psmsrvserver.h"
#include "psmsrvsession.h"
#include "psmtrace.h"

const TTimeIntervalMicroSeconds32 KShutDownTime = 60000000; // One minute 

// -----------------------------------------------------------------------------
// CPsmSrvShutdown::CPsmSrvShutdown
// C++ default constructor can NOT contain any code, that
// might leave.
// -----------------------------------------------------------------------------
//
CPsmSrvShutdown::CPsmSrvShutdown( CPsmSrvServer& aServer ) : 
    CActive( EPriorityNormal ),
    iServer( aServer )
    {
    CActiveScheduler::Add( this );
    iTimer.CreateLocal();
    }

// -----------------------------------------------------------------------------
// Destructor
// -----------------------------------------------------------------------------
//
CPsmSrvShutdown::~CPsmSrvShutdown()
    {
    COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::~CPsmSrvShutdown()" ) ) );
    Cancel();
    COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::~CPsmSrvShutdown - return") ) );
    }

// -----------------------------------------------------------------------------
// CPsmSrvShutdown::ServiceL
// -----------------------------------------------------------------------------
//
void CPsmSrvShutdown::RunL()
    {
    COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::RunL()" ) ) );

    // Note. This class does not implement CActive::RunError so this function cannot leave

    if ( KErrNone == iServer.ShutdownServer() )
        {
        iTimer.Close();
        }

    COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::RunL - return" ) ) );
    }

// -----------------------------------------------------------------------------
// CPsmSrvShutdown::DoCancel
// -----------------------------------------------------------------------------
//
void CPsmSrvShutdown::DoCancel()
    {
    COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::DoCancel()" ) ) );

    iTimer.Cancel();

    COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::DoCancel - return" ) ) );
    }

// -----------------------------------------------------------------------------
// CPsmSrvShutdown::Start
// -----------------------------------------------------------------------------
//
void CPsmSrvShutdown::Start()
    {
    COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::Start()" ) ) );

    iTimer.After( iStatus, KShutDownTime );
    SetActive();

    COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::Start - return" ) ) );
    }

// -----------------------------------------------------------------------------
// CPsmSrvShutdown::Restart
// -----------------------------------------------------------------------------
//
void CPsmSrvShutdown::Restart()
    {
    COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::Restart()" ) ) );

    if ( IsActive() )
        {
        Cancel();
        }

    iTimer.After( iStatus, KShutDownTime );
    SetActive();

    COMPONENT_TRACE( ( _L( "PSM Server - CPsmSrvShutdown::Restart - return" ) ) );
    }

// End of file