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