satengine/SatServer/SatInternalClient/src/CSatCEventHandler.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  This is the handler for various events related to
       
    15 *                those SIM Application Toolkit proactive commands that
       
    16 *                simply indicate that an action occured at the server.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include    <e32svr.h>
       
    24 #include    <basched.h>
       
    25 #include    "RSatUiSession.h"
       
    26 #include    "MSatUiObserver.h"
       
    27 #include    "CSatCEventHandler.h"
       
    28 #include    "SatSOpcodes.h"
       
    29 #include    "SatSTypes.h"
       
    30 #include    "SatLog.h"
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CSatCEventHandler::CSatCEventHandler
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 //lint -e{1769, 1403} Can not be initialized.
       
    41 CSatCEventHandler::CSatCEventHandler(
       
    42     TInt aPriority,
       
    43     RSatUiSession* aSession ) :
       
    44     CActive( aPriority ),
       
    45     iSession( aSession ),
       
    46     iEventData(),
       
    47     iEventPckg( iEventData )
       
    48     {
       
    49     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::CSatCEventHandler calling" )
       
    50 
       
    51     // Add to active scheduler.
       
    52     CActiveScheduler::Add( this );
       
    53 
       
    54     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::CSatCEventHandler exiting" )
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CSatCEventHandler::NewL
       
    59 // Two-phased constructor.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CSatCEventHandler* CSatCEventHandler::NewL(
       
    63     RSatUiSession* aSat )
       
    64     {
       
    65     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::NewL calling" )
       
    66 
       
    67     // Perform construction.
       
    68     CSatCEventHandler* self =
       
    69         new ( ELeave ) CSatCEventHandler( EPriorityLow, aSat );
       
    70 
       
    71     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::NewL exiting" )
       
    72     return self;
       
    73     }
       
    74 
       
    75 // Destructor
       
    76 CSatCEventHandler::~CSatCEventHandler()
       
    77     {
       
    78     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::~CSatCEventHandler calling" )
       
    79 
       
    80     // Cancel any outstanding requests.
       
    81     Cancel();
       
    82     iSession = NULL;
       
    83 
       
    84     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::~CSatCEventHandler exiting" )
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CSatCEventHandler::Start
       
    89 // Starts the handler.
       
    90 // (other items were commented in a header).
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 void CSatCEventHandler::Start()
       
    94     {
       
    95     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::Start calling" )
       
    96 
       
    97     // Request notifications about various server-side events.
       
    98     TIpcArgs arguments( &iEventPckg );
       
    99     iSession->CreateRequest( ESatSProactiveEvent, arguments, iStatus );
       
   100 
       
   101     // Set this handler to active so that it can receive requests.
       
   102     SetActive();
       
   103 
       
   104     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::Start exiting" )
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CSatCEventHandler::RunL
       
   109 // Handles the command.
       
   110 // (other items were commented in a header).
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CSatCEventHandler::RunL()
       
   114     {
       
   115     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::RunL calling" )
       
   116 
       
   117     // Check the status of the asnychronous operation
       
   118     if ( KErrNone != iStatus.Int() )
       
   119         {
       
   120         LOG2(
       
   121             SIMPLE,
       
   122             "SATINTERNALCLIENT: CSatCEventHandler::RunL exiting, error: %d",
       
   123             iStatus.Int() )
       
   124 
       
   125         // Renew the request
       
   126         Start();
       
   127 
       
   128         return;
       
   129         }
       
   130 
       
   131     // Send event to UI
       
   132     iSession->SatUiObserver()->EventNotification( 
       
   133         iEventData.iEvent,
       
   134         iEventData.iStatus,
       
   135         iEventData.iError );
       
   136         
       
   137     if ( ESatSCloseSatUiAppEvent == iEventData.iEvent )
       
   138         {
       
   139         LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::RunL close ui" )
       
   140         // Close UI
       
   141         CBaActiveScheduler::Exit();
       
   142         }
       
   143 
       
   144 
       
   145     // Pass the Event response IPC package.
       
   146     TIpcArgs arguments( &iEventPckg );
       
   147 
       
   148     // Perform the IPC data transfer.
       
   149     iSession->CreateRequest( ESatSProactiveEventResponse, arguments );
       
   150 
       
   151     // Renew the service request.
       
   152     Start();
       
   153 
       
   154     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::RunL exiting" )
       
   155     }
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // CSatCEventHandler::DoCancel
       
   159 // Cancels the pending request.
       
   160 // (other items were commented in a header).
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 void CSatCEventHandler::DoCancel()
       
   164     {
       
   165     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::DoCancel calling" )
       
   166 
       
   167     // Complete the request with cancel code.
       
   168     TRequestStatus* requestStatus = &iStatus;
       
   169     User::RequestComplete( requestStatus, KErrCancel );
       
   170 
       
   171     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCEventHandler::DoCancel exiting" )
       
   172     }
       
   173 
       
   174 //  End of File