phoneapp/silenceactionplugin/src/silenceaction.cpp
changeset 37 ba76fc04e6c2
child 51 f39ed5e045e0
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2006-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:  A plug-in for silencing the rigning tones.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "silenceaction.h"
       
    20 #include "logger.h"
       
    21 
       
    22 // CONSTANTS
       
    23 
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CSilenceAction::NewL
       
    27 // -----------------------------------------------------------------------------
       
    28 // 
       
    29 CSilenceAction* CSilenceAction::NewL( MSilenceActionObserver& aObserver )
       
    30     {
       
    31     CSilenceAction* self = CSilenceAction::NewLC( aObserver );
       
    32     CleanupStack::Pop( self );
       
    33     return self;
       
    34     }
       
    35  
       
    36 // -----------------------------------------------------------------------------
       
    37 // CSilenceAction::NewLC
       
    38 // -----------------------------------------------------------------------------
       
    39 // 
       
    40 CSilenceAction* CSilenceAction::NewLC( MSilenceActionObserver& aObserver )
       
    41     {
       
    42     CSilenceAction* self = new( ELeave ) CSilenceAction( aObserver );
       
    43     CleanupStack::PushL( self );
       
    44     self->ConstructL( );
       
    45     return self;
       
    46     }
       
    47  
       
    48 // -----------------------------------------------------------------------------
       
    49 // CSilenceAction Destructor.
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CSilenceAction::~CSilenceAction()
       
    53     {
       
    54     Cancel();
       
    55         
       
    56     if ( iPhoneClient )
       
    57         {
       
    58         delete iPhoneClient; 
       
    59         }
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CSilenceAction constructor.
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CSilenceAction::CSilenceAction( MSilenceActionObserver& aObserver ):
       
    67     CActive( EPriorityStandard ),
       
    68     iObserver( aObserver )
       
    69     {
       
    70     CActiveScheduler::Add( this );
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CSilenceAction::ConstructL
       
    75 // Symbian 2nd phase constructor can leave.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void CSilenceAction::ConstructL( )
       
    79     {
       
    80     LOG_1( _L("->CSilenceAction::ConstructL: START") );     
       
    81 
       
    82     iPhoneClient = CPhCltCommandHandler::NewL();
       
    83 
       
    84     LOG_1( _L("<-CSilenceAction::ConstructL: END") );
       
    85     }
       
    86 
       
    87 //-----------------------------------------------------------------------------
       
    88 // CSilenceAction::ActionMuteRingingToneL
       
    89 //-----------------------------------------------------------------------------
       
    90 // 
       
    91 void CSilenceAction::ActionMuteRingingTone( )
       
    92     {
       
    93     LOG_1( _L("->CSilenceAction::ActionMuteRingingTone: START") );
       
    94     if ( !IsActive() ) 
       
    95         {
       
    96         iPhoneClient->MuteRingingTone(iStatus);
       
    97         SetActive();
       
    98         }
       
    99     LOG_1( _L("<-CSilenceAction::ActionMuteRingingTone: END") );
       
   100     }
       
   101 //-----------------------------------------------------------------------------
       
   102 // CSilenceAction::RunL
       
   103 //-----------------------------------------------------------------------------
       
   104 //
       
   105 void CSilenceAction::RunL()
       
   106     {
       
   107     iObserver.MuteActionCompleted();
       
   108     LOG_2( _L("CSilenceAction::RunL iStatus: %d"), iStatus.Int() );
       
   109     }
       
   110 
       
   111 //-----------------------------------------------------------------------------
       
   112 // CSilenceAction::DoCancel
       
   113 //-----------------------------------------------------------------------------
       
   114 //
       
   115 void CSilenceAction::DoCancel()
       
   116     {
       
   117     LOG_1( _L("->CSilenceAction::DoCancel: START") );
       
   118     iPhoneClient->CancelAsyncRequest( EPhCltCommandMuteRingingTone );
       
   119     LOG_1( _L("<-CSilenceAction::DoCancel: END") );
       
   120     }
       
   121         
       
   122 //-----------------------------------------------------------------------------
       
   123 // CSilenceAction::RunError
       
   124 //-----------------------------------------------------------------------------
       
   125 //
       
   126 TInt CSilenceAction::RunError( TInt aError )
       
   127     {
       
   128     LOG_2( _L("CSilenceAction::RunError aError: %d"), aError );
       
   129     return aError;
       
   130     }
       
   131 
       
   132 // End of File