satengine/SatServer/EventMonitors/src/CSatEventMonitorHandler.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:  Base class for event monitors
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CSatEventMonitorHandler.h"
       
    21 #include    "MSatEventMonitorUtils.h"
       
    22 #include    "SatLog.h"
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 // -----------------------------------------------------------------------------
       
    26 // CSatEventMonitorHandler::CSatEventMonitorHandler
       
    27 // C++ default constructor can NOT contain any code, that
       
    28 // might leave.
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CSatEventMonitorHandler::CSatEventMonitorHandler(
       
    32     MSatEventMonitorUtils& aUtils ) :
       
    33     iEventUtils( aUtils )
       
    34     {
       
    35     LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
    36         CSatEventMonitorHandler calling-exiting" )
       
    37     }
       
    38 
       
    39 // Destructor
       
    40 CSatEventMonitorHandler::~CSatEventMonitorHandler()
       
    41     {
       
    42     LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
    43         ~CSatEventMonitorHandler calling-exiting" )
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CSatEventMonitorHandler::BaseConstructL
       
    48 // Constructor of this class.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CSatEventMonitorHandler::BaseConstructL( MSatEventMonitor::TEvent aEvent )
       
    52     {
       
    53     LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
    54         BaseConstructL calling" )
       
    55 
       
    56     iIsSimRemovalMonitor = EFalse;
       
    57     iSimRemovalMonitorActive = EFalse;
       
    58 
       
    59     // Resolve correct event
       
    60     switch ( aEvent )
       
    61         {
       
    62         case MSatEventMonitor::EUserActivity:
       
    63             {
       
    64             LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
    65                 BaseConstructL User activity" )
       
    66             iEvent = RSat::KUserActivity;
       
    67             break;
       
    68             }
       
    69 
       
    70         case MSatEventMonitor::EIdleScreenAvailable:
       
    71             {
       
    72             LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
    73                 BaseConstructL Idle Screen available" )
       
    74             iEvent = RSat::KIdleScreenAvailable;
       
    75             break;
       
    76             }
       
    77 
       
    78         case MSatEventMonitor::ELanguageSelection:
       
    79             {
       
    80             LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
    81                 BaseConstructL Language selection" )
       
    82             iEvent = RSat::KLanguageSelection;
       
    83             break;
       
    84             }
       
    85 
       
    86         case MSatEventMonitor::ESimRemoved:
       
    87             {
       
    88             LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
    89                 BaseConstructL SIM removal" )
       
    90             // There is no event for sim removal event.
       
    91             // The observer of events should cancel all monitors
       
    92             // if sim is removed.
       
    93             iIsSimRemovalMonitor = ETrue;
       
    94             break;
       
    95             }
       
    96 
       
    97         case MSatEventMonitor::EBrowserTerminated:
       
    98             {
       
    99             LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   100                 BaseConstructL Browser termination" )
       
   101             iEvent = RSat::KBrowserTermination;
       
   102             break;
       
   103             }
       
   104 
       
   105         case MSatEventMonitor::EDataAvailable:
       
   106             {
       
   107             LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   108                 BaseConstructL Data available" )
       
   109             iEvent = RSat::KDataAvailable;
       
   110             break;
       
   111             }
       
   112 
       
   113         case MSatEventMonitor::EChannelStatus:
       
   114             {
       
   115             LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   116                 BaseConstructL Channel status" )
       
   117             iEvent = RSat::KChannelStatus;
       
   118             break;
       
   119             }
       
   120 
       
   121         default:
       
   122             {
       
   123             LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   124                 BaseConstructL No implementation" )
       
   125             }
       
   126         }
       
   127 
       
   128     LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   129         BaseConstructL exiting" )
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CSatEventMonitorHandler::CancelMonitor
       
   134 // (other items were commented in a header).
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 EXPORT_C void CSatEventMonitorHandler::CancelMonitor()
       
   138     {
       
   139     LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   140         CancelMonitor calling" )
       
   141 
       
   142     DoCancelMonitor();
       
   143 
       
   144     LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   145         CancelMonitor exiting" )
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CSatEventMonitorHandler::UpdateMonitor
       
   150 // (other items were commented in a header).
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 EXPORT_C TInt CSatEventMonitorHandler::UpdateMonitor(
       
   154     TUint aEvents )
       
   155     {
       
   156     LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   157         UpdateMonitor calling" )
       
   158 
       
   159     TInt errCode = KErrNone;
       
   160 
       
   161     LOG2( DETAILED, "SATEVENTMONITORS: CSatEventMonitorHandler::aEvents = %d",
       
   162         aEvents )
       
   163     LOG2( DETAILED, "SATEVENTMONITORS: CSatEventMonitorHandler::iEvent = %d",
       
   164         iEvent )
       
   165 
       
   166     // There is no specific event ID for SIM removal monitor,
       
   167     // so we have to check this different than others
       
   168     if ( iIsSimRemovalMonitor )
       
   169         {
       
   170         LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   171             IsSimRemovalMonitor" )
       
   172 
       
   173         // If events list is not empty, start
       
   174         // SIM removal monitor. Otherwise cancel it.
       
   175         if ( aEvents != 0 )
       
   176             {
       
   177             LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   178                 IsSimRemovalMonitor - Events list is not empty" )
       
   179             // Start SIM removal monitor only if it is not already active
       
   180             if ( !iSimRemovalMonitorActive )
       
   181                 {
       
   182                 LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   183                     IsSimRemovalMonitor - Start SIM removal monitor" )
       
   184                 errCode = StartMonitor();
       
   185                 iSimRemovalMonitorActive = ETrue;
       
   186                 }
       
   187             }
       
   188         else
       
   189             {
       
   190             LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   191                 IsSimRemovalMonitor - Cancel monitor" )
       
   192             CancelMonitor();
       
   193             iSimRemovalMonitorActive = EFalse;
       
   194             }
       
   195         }
       
   196 
       
   197     // Check is derived monitor in list
       
   198     else if ( aEvents & iEvent )
       
   199         {
       
   200         LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   201             UpdateMonitor Starting monitor" )
       
   202         // Monitor found, start monitor
       
   203         errCode = StartMonitor();
       
   204         }
       
   205     else
       
   206         {
       
   207         LOG( NORMAL, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   208             UpdateMonitor Cancelling monitor" )
       
   209         // Monitor not in list, cancel monitor
       
   210         CancelMonitor();
       
   211         }
       
   212 
       
   213     LOG2( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   214         UpdateMonitor exiting with value: %d", errCode )
       
   215     return errCode;
       
   216     }
       
   217 
       
   218 // -----------------------------------------------------------------------------
       
   219 // CSatEventMonitorHandler::IsMonitoringEvent
       
   220 // (other items were commented in a header).
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 EXPORT_C TBool CSatEventMonitorHandler::IsMonitoringEvent( const TInt aEvent )
       
   224     {
       
   225     LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   226         IsMonitoringEvent calling-exiting" )
       
   227     return ( aEvent == iEvent );
       
   228     }
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CSatEventMonitorHandler::EventOccured
       
   232 // (other items were commented in a header).
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 void CSatEventMonitorHandler::EventOccured( TInt aIntArg, TInt aSecArg )
       
   236     {
       
   237     LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   238         EventOccured calling" )
       
   239 
       
   240     // Check is this SimRemoval monitor.
       
   241     if ( iIsSimRemovalMonitor )
       
   242         {
       
   243         LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   244         EventOccured iIsSimRemovalMonitor true" )
       
   245         // Yes, Inform observer that SIM is removed
       
   246         iEventUtils.SimRemoved();
       
   247         }
       
   248     else
       
   249         {
       
   250         // No, Inform normal event occurrence
       
   251         iEventUtils.EventDownload( iEvent, aIntArg, aSecArg );
       
   252         }
       
   253 
       
   254     LOG( SIMPLE, "SATEVENTMONITORS: CSatEventMonitorHandler::\
       
   255         EventOccured exiting" )
       
   256     }
       
   257 
       
   258 //  End of File