phoneapp/silenceactionplugin/src/silenceaction.cpp
author William Roberts <williamr@symbian.org>
Thu, 22 Jul 2010 16:33:21 +0100
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 21 92ab7f8d0eab
parent 37 ba76fc04e6c2
permissions -rw-r--r--
Catchup to latest Symbian^4

/*
* Copyright (c) 2006-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:  A plug-in for silencing the rigning tones.
*
*/


#include "silenceaction.h"
#include "logger.h"

// CONSTANTS


// -----------------------------------------------------------------------------
// CSilenceAction::NewL
// -----------------------------------------------------------------------------
// 
CSilenceAction* CSilenceAction::NewL( MSilenceActionObserver& aObserver )
    {
    CSilenceAction* self = CSilenceAction::NewLC( aObserver );
    CleanupStack::Pop( self );
    return self;
    }
 
// -----------------------------------------------------------------------------
// CSilenceAction::NewLC
// -----------------------------------------------------------------------------
// 
CSilenceAction* CSilenceAction::NewLC( MSilenceActionObserver& aObserver )
    {
    CSilenceAction* self = new( ELeave ) CSilenceAction( aObserver );
    CleanupStack::PushL( self );
    self->ConstructL( );
    return self;
    }
 
// -----------------------------------------------------------------------------
// CSilenceAction Destructor.
// -----------------------------------------------------------------------------
//
CSilenceAction::~CSilenceAction()
    {
    Cancel();
        
    if ( iPhoneClient )
        {
        delete iPhoneClient; 
        }
    }

// -----------------------------------------------------------------------------
// CSilenceAction constructor.
// -----------------------------------------------------------------------------
//
CSilenceAction::CSilenceAction( MSilenceActionObserver& aObserver ):
    CActive( EPriorityStandard ),
    iObserver( aObserver )
    {
    CActiveScheduler::Add( this );
    }

// -----------------------------------------------------------------------------
// CSilenceAction::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CSilenceAction::ConstructL( )
    {
    LOG_1( _L("->CSilenceAction::ConstructL: START") );     

    iPhoneClient = CPhCltCommandHandler::NewL();

    LOG_1( _L("<-CSilenceAction::ConstructL: END") );
    }

//-----------------------------------------------------------------------------
// CSilenceAction::ActionMuteRingingToneL
//-----------------------------------------------------------------------------
// 
void CSilenceAction::ActionMuteRingingTone( )
    {
    LOG_1( _L("->CSilenceAction::ActionMuteRingingTone: START") );
    if ( !IsActive() ) 
        {
        iPhoneClient->MuteRingingTone(iStatus);
        SetActive();
        }
    LOG_1( _L("<-CSilenceAction::ActionMuteRingingTone: END") );
    }
//-----------------------------------------------------------------------------
// CSilenceAction::RunL
//-----------------------------------------------------------------------------
//
void CSilenceAction::RunL()
    {
    iObserver.MuteActionCompleted();
    LOG_2( _L("CSilenceAction::RunL iStatus: %d"), iStatus.Int() );
    }

//-----------------------------------------------------------------------------
// CSilenceAction::DoCancel
//-----------------------------------------------------------------------------
//
void CSilenceAction::DoCancel()
    {
    LOG_1( _L("->CSilenceAction::DoCancel: START") );
    iPhoneClient->CancelAsyncRequest( EPhCltCommandMuteRingingTone );
    LOG_1( _L("<-CSilenceAction::DoCancel: END") );
    }
        
//-----------------------------------------------------------------------------
// CSilenceAction::RunError
//-----------------------------------------------------------------------------
//
TInt CSilenceAction::RunError( TInt aError )
    {
    LOG_2( _L("CSilenceAction::RunError aError: %d"), aError );
    return aError;
    }

// End of File