satengine/SatServer/EventMonitors/src/CSatLanguageSelectionMonitor.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    "MSatEventMonitorUtils.h"
       
    23 #include    "CSatLanguageSelectionMonitor.h"
       
    24 #include    "SatLog.h"
       
    25 
       
    26 // CONSTANTS
       
    27 const TInt KSecond( 1000 );
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ===============================
       
    30 // -----------------------------------------------------------------------------
       
    31 // CSatLanguageSelectionMonitor::CSatLanguageSelectionMonitor
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CSatLanguageSelectionMonitor::CSatLanguageSelectionMonitor(
       
    37     MSatEventMonitorUtils& aUtils ) :
       
    38     CSatEventMonitorHandler( aUtils )
       
    39     {
       
    40     LOG( SIMPLE, "SATEVENTMONITORS: CSatLanguageSelectionMonitor::\
       
    41         CSatLanguageSelectionMonitor calling-exiting" )
       
    42     }
       
    43 
       
    44 // Destructor
       
    45 CSatLanguageSelectionMonitor::~CSatLanguageSelectionMonitor()
       
    46     {
       
    47     LOG( SIMPLE, "SATEVENTMONITORS: CSatLanguageSelectionMonitor::\
       
    48         ~CSatLanguageSelectionMonitor calling" )
       
    49 
       
    50     delete iPSNotifier;
       
    51 
       
    52     LOG( SIMPLE, "SATEVENTMONITORS: CSatLanguageSelectionMonitor::\
       
    53         ~CSatLanguageSelectionMonitor exiting" )
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CSatLanguageSelectionMonitor::NewL
       
    58 // Two-phased constructor.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CSatLanguageSelectionMonitor* CSatLanguageSelectionMonitor::NewL(
       
    62     MSatEventMonitorUtils& aUtils )
       
    63     {
       
    64     LOG( SIMPLE,
       
    65         "SATEVENTMONITORS: CSatLanguageSelectionMonitor::NewL calling" )
       
    66 
       
    67     CSatLanguageSelectionMonitor* self =
       
    68         new( ELeave ) CSatLanguageSelectionMonitor( aUtils );
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL();
       
    71     CleanupStack::Pop( self );
       
    72 
       
    73     LOG( SIMPLE,
       
    74         "SATEVENTMONITORS: CSatLanguageSelectionMonitor::NewL exiting" )
       
    75     return self;
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CSatLanguageSelectionMonitor::ConstructL
       
    80 // Symbian 2nd phase constructor can leave.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 void CSatLanguageSelectionMonitor::ConstructL()
       
    84     {
       
    85     LOG( SIMPLE,
       
    86         "SATEVENTMONITORS: CSatLanguageSelectionMonitor::ConstructL calling" )
       
    87 
       
    88     // Create base class and give this monitors event as a parameter
       
    89     BaseConstructL( MSatEventMonitor::ELanguageSelection );
       
    90     iPSNotifier =
       
    91         TSatSystemStateFactory::CreateLanguageSelectionChangeNotifierL( *this );
       
    92 
       
    93     LOG( SIMPLE,
       
    94         "SATEVENTMONITORS: CSatLanguageSelectionMonitor::ConstructL exiting" )
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CSatLanguageSelectionMonitor::DoCancelMonitor
       
    99 // Cancels monitor.
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void CSatLanguageSelectionMonitor::DoCancelMonitor()
       
   103     {
       
   104     LOG( SIMPLE, "SATEVENTMONITORS: CSatLanguageSelectionMonitor::\
       
   105         DoCancelMonitor calling" )
       
   106 
       
   107     iPSNotifier->CancelNotify();
       
   108     iEventUtils.WriteLanguageSelectionTime( KErrNone );
       
   109 
       
   110     LOG( SIMPLE, "SATEVENTMONITORS: CSatLanguageSelectionMonitor::\
       
   111         DoCancelMonitor exiting" )
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CSatLanguageSelectionMonitor::StartMonitor
       
   116 // Starts monitor.
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 TInt CSatLanguageSelectionMonitor::StartMonitor()
       
   120     {
       
   121     LOG( SIMPLE,
       
   122         "SATEVENTMONITORS: CSatLanguageSelectionMonitor::StartMonitor calling" )
       
   123 
       
   124     // Cancel first, it might be activated already
       
   125     DoCancelMonitor();
       
   126 
       
   127     // Now start
       
   128     TRAPD( err, iPSNotifier->NotifyChangeL() );
       
   129     iEventUtils.WriteLanguageSelectionTime( KSecond );
       
   130 
       
   131     LOG( SIMPLE,
       
   132         "SATEVENTMONITORS: CSatLanguageSelectionMonitor::StartMonitor exiting" )
       
   133     return err;
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CSatLanguageSelectionMonitor::StateChanged
       
   138 // Called when SIM is removed.
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 void CSatLanguageSelectionMonitor::StateChanged( const TInt aValue )
       
   142     {
       
   143     LOG( SIMPLE,
       
   144         "SATEVENTMONITORS: CSatLanguageSelectionMonitor::StateChanged calling" )
       
   145 
       
   146     // Inform SAT Engine that language is been changed.
       
   147     EventOccured( aValue );
       
   148 
       
   149     LOG( SIMPLE,
       
   150         "SATEVENTMONITORS: CSatLanguageSelectionMonitor::StateChanged exiting" )
       
   151     }
       
   152 
       
   153 // End of file