satengine/SatServer/Commands/DisplayTextCmd/src/CClearScreenHandler.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:  ClearScreen handler is responsible for clearing screen when
       
    15 *                DisplayText has sent immediate response and it is still active
       
    16 *                when any other command starts to execute.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include    "MSatUtils.h"
       
    24 #include    "SatSTypes.h"
       
    25 #include    "CClearScreenHandler.h"
       
    26 #include    "SatLog.h"
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CClearScreenHandler::CClearScreenHandler
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CClearScreenHandler::CClearScreenHandler( MSatUtils& aUtils ) :
       
    37     iUtils( aUtils )
       
    38     {
       
    39     LOG( SIMPLE, "DISPLAYTEXT: \
       
    40         CClearScreenHandler::CClearScreenHandler calling - exiting" )
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CClearScreenHandler::ConstructL
       
    45 // Symbian 2nd phase constructor can leave.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 void CClearScreenHandler::ConstructL()
       
    49     {
       
    50     LOG( SIMPLE, "DISPLAYTEXT: CClearScreenHandler::ConstructL calling" )
       
    51 
       
    52     // Set immediate response to false.
       
    53     iImmediateResponse = EFalse;
       
    54 
       
    55     // List all events we should listen.
       
    56     iUtils.RegisterL( this, MSatUtils::ESetUpMenuExecuting );
       
    57     iUtils.RegisterL( this, MSatUtils::ESelectItemExecuting );
       
    58     iUtils.RegisterL( this, MSatUtils::ESetUpCallExecuting );
       
    59     iUtils.RegisterL( this, MSatUtils::EDisplayTextExecuting );
       
    60     iUtils.RegisterL( this, MSatUtils::ELaunchBrowserExecuting );
       
    61     iUtils.RegisterL( this, MSatUtils::EGetInputExecuting );
       
    62     iUtils.RegisterL( this, MSatUtils::EGetInkeyExecuting );
       
    63     iUtils.RegisterL( this, MSatUtils::ESendDtmfExecuting );
       
    64     iUtils.RegisterL( this, MSatUtils::ESendSsExecuting );
       
    65     iUtils.RegisterL( this, MSatUtils::ESendUssdExecuting );
       
    66     iUtils.RegisterL( this, MSatUtils::EPlayToneExecuting );
       
    67     iUtils.RegisterL( this, MSatUtils::ERefreshExecuting );
       
    68     iUtils.RegisterL( this, MSatUtils::ECallControlExecuting );
       
    69     iUtils.RegisterL( this, MSatUtils::ESendSmExecuting );
       
    70     iUtils.RegisterL( this, MSatUtils::EMoSmControlExecuting );
       
    71 
       
    72     LOG( SIMPLE, "DISPLAYTEXT: CClearScreenHandler::ConstructL exiting" )
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CClearScreenHandler::NewL
       
    77 // Two-phased constructor.
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 CClearScreenHandler* CClearScreenHandler::NewL( MSatUtils& aUtils )
       
    81     {
       
    82     LOG( SIMPLE, "DISPLAYTEXT: CClearScreenHandler::NewL calling" )
       
    83 
       
    84     CClearScreenHandler* self =
       
    85         new ( ELeave ) CClearScreenHandler( aUtils );
       
    86 
       
    87     CleanupStack::PushL( self );
       
    88     self->ConstructL();
       
    89     CleanupStack::Pop( self );
       
    90 
       
    91     LOG( SIMPLE, "DISPLAYTEXT: CClearScreenHandler::NewL exiting" )
       
    92     return self;
       
    93     }
       
    94 
       
    95 
       
    96 // Destructor
       
    97 CClearScreenHandler::~CClearScreenHandler()
       
    98     {
       
    99     LOG( SIMPLE,
       
   100         "DISPLAYTEXT: CClearScreenHandler::~CClearScreenHandler calling" )
       
   101 
       
   102     // Unregister this as an event observer
       
   103     iUtils.UnregisterEventObserver( this );
       
   104 
       
   105     LOG( SIMPLE,
       
   106         "DISPLAYTEXT: CClearScreenHandler::~CClearScreenHandler exiting" )
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CClearScreenHandler::UpdateImmediateState
       
   111 // Updates immediate response state.
       
   112 // (other items were commented in a header).
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CClearScreenHandler::UpdateImmediateState( TBool aState )
       
   116     {
       
   117     LOG( SIMPLE,
       
   118         "DISPLAYTEXT: CClearScreenHandler::UpdateImmediateState calling" )
       
   119 
       
   120     iImmediateResponse = aState;
       
   121 
       
   122     LOG( SIMPLE,
       
   123         "DISPLAYTEXT: CClearScreenHandler::UpdateImmediateState exiting" )
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CClearScreenHandler::Event
       
   128 // Notification of an event.
       
   129 // (other items were commented in a header).
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 void CClearScreenHandler::Event( TInt aEvent )
       
   133     {
       
   134     LOG2( SIMPLE, "DISPLAYTEXT: CClearScreenHandler::Event calling, \
       
   135           aEvent: %d", aEvent )
       
   136     LOG2( SIMPLE, "DISPLAYTEXT: CClearScreenHandler::Event, \
       
   137           iImmediateResponse: %d", iImmediateResponse )
       
   138     // We don't have to do anything if immediate response is not active.
       
   139     if ( iImmediateResponse )
       
   140         {
       
   141         switch ( aEvent )
       
   142             {
       
   143             case MSatUtils::ESetUpMenuExecuting:
       
   144             case MSatUtils::ESelectItemExecuting:
       
   145             case MSatUtils::ESetUpCallExecuting:
       
   146             case MSatUtils::EDisplayTextExecuting:
       
   147             case MSatUtils::ELaunchBrowserExecuting:
       
   148             case MSatUtils::EGetInputExecuting:
       
   149             case MSatUtils::EGetInkeyExecuting:
       
   150             case MSatUtils::ESendDtmfExecuting:
       
   151             case MSatUtils::ESendSsExecuting:
       
   152             case MSatUtils::ESendUssdExecuting:
       
   153             case MSatUtils::EPlayToneExecuting:
       
   154             case MSatUtils::ERefreshExecuting:
       
   155             case MSatUtils::ECallControlExecuting:
       
   156             case MSatUtils::ESendSmExecuting:
       
   157             case MSatUtils::EMoSmControlExecuting:
       
   158                 {
       
   159                 ClearScreen();
       
   160                 break;
       
   161                 }
       
   162 
       
   163             default:
       
   164                 {
       
   165                 // Do nothing.
       
   166                 break;
       
   167                 }
       
   168             }
       
   169         }
       
   170 
       
   171     LOG( SIMPLE, "DISPLAYTEXT: CClearScreenHandler::Event exiting" )
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CClearScreenHandler::ClearScreen
       
   176 // (other items were commented in a header).
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 void CClearScreenHandler::ClearScreen()
       
   180     {
       
   181     LOG( SIMPLE, "DISPLAYTEXT: CClearScreenHandler::ClearScreen calling" )
       
   182     LOG2( SIMPLE, "DISPLAYTEXT: CClearScreenHandler::ClearScreen, \
       
   183           iImmediateResponse: %d", iImmediateResponse )
       
   184     // Clear the screen if immediate response is active.
       
   185     //lint -e{961} Else block meaningless
       
   186     if ( iImmediateResponse )
       
   187         {
       
   188         iUtils.NotifyUiEvent(
       
   189             ESatSClearScreenEvent, ESatEventNone, KErrNone );
       
   190         iImmediateResponse = EFalse;
       
   191 
       
   192         iUtils.NotifyEvent( MSatUtils::ESustainedTextRemoved );
       
   193         }
       
   194 
       
   195     LOG( SIMPLE, "DISPLAYTEXT: CClearScreenHandler::ClearScreen exiting" )
       
   196     }
       
   197 
       
   198 //  End of File