satengine/SatServer/EventMonitors/src/CSatSimRemovalMonitor.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-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:  Monitor for SIM removal
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "TSatSystemStateFactory.h"
       
    21 #include    "MSatSystemStateChangeNotifier.h"
       
    22 #include    "CSatSimRemovalMonitor.h"
       
    23 #include    "SatLog.h"
       
    24 
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 // -----------------------------------------------------------------------------
       
    28 // CSatSimRemovalMonitor::CSatSimRemovalMonitor
       
    29 // C++ default constructor can NOT contain any code, that
       
    30 // might leave.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CSatSimRemovalMonitor::CSatSimRemovalMonitor(
       
    34     MSatEventMonitorUtils& aUtils ) :
       
    35     CSatEventMonitorHandler( aUtils )
       
    36     {
       
    37     LOG( SIMPLE, "SATEVENTMONITORS: CSatSimRemovalMonitor::\
       
    38         CSatSimRemovalMonitor calling-exiting" )
       
    39     }
       
    40 
       
    41 // Destructor
       
    42 CSatSimRemovalMonitor::~CSatSimRemovalMonitor()
       
    43     {
       
    44     LOG( SIMPLE, "SATEVENTMONITORS: CSatSimRemovalMonitor::\
       
    45         ~CSatSimRemovalMonitor calling" )
       
    46 
       
    47     delete iPSNotifier;
       
    48 
       
    49     LOG( SIMPLE, "SATEVENTMONITORS: CSatSimRemovalMonitor::\
       
    50         ~CSatSimRemovalMonitor exiting" )
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CSatSimRemovalMonitor::NewL
       
    55 // Two-phased constructor.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CSatSimRemovalMonitor* CSatSimRemovalMonitor::NewL(
       
    59     MSatEventMonitorUtils& aUtils )
       
    60     {
       
    61     LOG( SIMPLE, "SATEVENTMONITORS: CSatSimRemovalMonitor::NewL calling" )
       
    62 
       
    63     CSatSimRemovalMonitor* self = new( ELeave ) CSatSimRemovalMonitor( aUtils );
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop( self );
       
    67 
       
    68     LOG( SIMPLE, "SATEVENTMONITORS: CSatSimRemovalMonitor::NewL exiting" )
       
    69     return self;
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CSatSimRemovalMonitor::ConstructL
       
    74 // Symbian 2nd phase constructor can leave.
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 void CSatSimRemovalMonitor::ConstructL()
       
    78     {
       
    79     LOG( SIMPLE, "SATEVENTMONITORS: CSatSimRemovalMonitor::ConstructL calling" )
       
    80 
       
    81     // Create base class and give this monitors event as a parameter
       
    82     BaseConstructL( MSatEventMonitor::ESimRemoved );
       
    83 
       
    84     iPSNotifier =
       
    85         TSatSystemStateFactory::CreateSimStatusChangeNotifierL( *this );
       
    86 
       
    87     LOG( SIMPLE, "SATEVENTMONITORS: CSatSimRemovalMonitor::ConstructL exiting" )
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CSatSimRemovalMonitor::DoCancelMonitor
       
    92 // Cancels monitor.
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CSatSimRemovalMonitor::DoCancelMonitor()
       
    96     {
       
    97     LOG( SIMPLE,
       
    98         "SATEVENTMONITORS: CSatSimRemovalMonitor::DoCancelMonitor calling" )
       
    99 
       
   100     iPSNotifier->CancelNotify();
       
   101 
       
   102     LOG( SIMPLE,
       
   103         "SATEVENTMONITORS: CSatSimRemovalMonitor::DoCancelMonitor exiting" )
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CSatSimRemovalMonitor::StartMonitor
       
   108 // Starts monitor.
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 TInt CSatSimRemovalMonitor::StartMonitor()
       
   112     {
       
   113     LOG( SIMPLE,
       
   114         "SATEVENTMONITORS: CSatSimRemovalMonitor::StartMonitor calling" )
       
   115 
       
   116     // Cancel first. It might be activated already
       
   117     DoCancelMonitor();
       
   118 
       
   119     // Now start it again.
       
   120     TRAPD( err, iPSNotifier->NotifyChangeL() );
       
   121 
       
   122     LOG2( SIMPLE, "SATEVENTMONITORS: CSatSimRemovalMonitor::StartMonitor \
       
   123         exiting with value: %d", err )
       
   124     return err;
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CSatSimRemovalMonitor::StateChanged
       
   129 // Called when SIM is removed.
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 void CSatSimRemovalMonitor::StateChanged()
       
   133     {
       
   134     LOG( SIMPLE,
       
   135         "SATEVENTMONITORS: CSatSimRemovalMonitor::StateChanged calling" )
       
   136 
       
   137     // Inform SAT Engine that SIM status state has changed.
       
   138     EventOccured();
       
   139 
       
   140     LOG( SIMPLE,
       
   141         "SATEVENTMONITORS: CSatSimRemovalMonitor::StateChanged exiting" )
       
   142     }
       
   143 
       
   144 // End of file