satengine/SatServer/SatInternalClient/src/CSatCQueryHandler.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 query requests related to
       
    15 *                those SIM Application Toolkit proactive commands that require
       
    16 *                user permissions to complete their actions.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include    <e32base.h>
       
    24 #include    <e32svr.h>
       
    25 #include    "RSatUiSession.h"
       
    26 #include    "MSatUiObserver.h"
       
    27 #include    "SatSOpcodes.h"
       
    28 #include    "CSatCQueryHandler.h"
       
    29 #include    "SatLog.h"
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // This will contain the Window Group Id of SAT UI
       
    34 const TInt KSatUiWgId = -1;
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS ===============================
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CSatCQueryHandler::CSatCQueryHandler
       
    40 // C++ default constructor can NOT contain any code, that
       
    41 // might leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 //lint -e{1403, 1769} Can not be initialized, harmless.
       
    45 CSatCQueryHandler::CSatCQueryHandler(
       
    46     TInt aPriority,
       
    47     RSatUiSession* aSession ) :
       
    48     CActive( aPriority ),
       
    49     iSession( aSession ),
       
    50     iQueryData(),
       
    51     iQueryPckg( iQueryData ),
       
    52     iQueryRsp(),
       
    53     iQueryRspPckg( iQueryRsp )
       
    54     {
       
    55     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCQueryHandler::CSatCQueryHandler calling" )
       
    56 
       
    57     // Add to active scheduler.
       
    58     CActiveScheduler::Add( this );
       
    59 
       
    60     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCQueryHandler::CSatCQueryHandler exiting" )
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CSatCQueryHandler::NewL
       
    65 // Two-phased constructor.
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CSatCQueryHandler* CSatCQueryHandler::NewL(
       
    69     RSatUiSession* aSat )
       
    70     {
       
    71     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCQueryHandler::NewL calling" )
       
    72 
       
    73     // Perform construction.
       
    74     CSatCQueryHandler* self =
       
    75         new ( ELeave ) CSatCQueryHandler( EPriorityLow, aSat );
       
    76 
       
    77     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCQueryHandler::NewL exiting" )
       
    78     return self;
       
    79     }
       
    80 
       
    81 // Destructor
       
    82 CSatCQueryHandler::~CSatCQueryHandler()
       
    83     {
       
    84     LOG( SIMPLE,
       
    85         "SATINTERNALCLIENT: CSatCQueryHandler::~CSatCQueryHandler calling" )
       
    86 
       
    87     // Cancel any outstanding requests.
       
    88     Cancel();
       
    89     iSession = NULL;
       
    90 
       
    91     LOG( SIMPLE,
       
    92         "SATINTERNALCLIENT: CSatCQueryHandler::~CSatCQueryHandler exiting" )
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CSatCQueryHandler::Start
       
    97 // Starts the handler.
       
    98 // (other items were commented in a header).
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 void CSatCQueryHandler::Start()
       
   102     {
       
   103     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCQueryHandler::Start calling" )
       
   104 
       
   105     // Empty the IPC data
       
   106     TSatQueryV1 temp;
       
   107     iQueryData = temp;
       
   108     TSatQueryRspV1 temp2;
       
   109     temp2.iAccepted = EFalse;
       
   110     temp2.iCommand = ESatSSendSmQuery;
       
   111     iQueryRsp = temp2;
       
   112 
       
   113     // Request queries notification.
       
   114     TIpcArgs arguments( &iQueryPckg );
       
   115 
       
   116     // Pass the Query IPC package.
       
   117     iSession->CreateRequest( ESatSProactiveQuery, arguments, iStatus );
       
   118 
       
   119     // Set this handler to active so that it can receive requests.
       
   120     SetActive();
       
   121 
       
   122     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCQueryHandler::Start exiting" )
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CSatCQueryHandler::RunL
       
   127 // Handles the command.
       
   128 // (other items were commented in a header).
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 void CSatCQueryHandler::RunL()
       
   132     {
       
   133     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCQueryHandler::RunL calling" )
       
   134 
       
   135     // Check the status of the asnychronous operation
       
   136     if ( KErrNone != iStatus.Int() )
       
   137         {
       
   138         LOG2(
       
   139             SIMPLE,
       
   140             "SATINTERNALCLIENT: CSatCQueryHandler::RunL error: %d",
       
   141             iStatus.Int() )
       
   142 
       
   143         // Renew the request
       
   144         Start();
       
   145         }
       
   146 
       
   147     else
       
   148         {
       
   149         // This will contain the result of the user query.
       
   150         TBool userQuery( EFalse );
       
   151 
       
   152         // This will contain EFalse if requested icon is not displayed.
       
   153         // And if icon is displayed, it contains ETrue.
       
   154         TBool requestedIconDisplayed( EFalse );
       
   155 
       
   156         // This will contain the result that has the user pressed end key.
       
   157         TBool terminatedByUser( EFalse );
       
   158 
       
   159         // Use general configm function
       
   160         iSession->SatUiObserver()->ConfirmCommand(
       
   161             iQueryData.iCommand,
       
   162             iQueryData.iAlphaIdStatus,
       
   163             iQueryData.iQueryText,
       
   164             iQueryData.iSimApplicationName,
       
   165             userQuery,
       
   166             iQueryData.iIconId,
       
   167             requestedIconDisplayed,
       
   168             terminatedByUser );
       
   169 
       
   170         // Return the result of the query to the server.
       
   171         iQueryRsp.iAccepted = userQuery;
       
   172         iQueryRsp.iCommand = iQueryData.iCommand;
       
   173         iQueryRsp.iWgId = KSatUiWgId;
       
   174         iQueryRsp.iRequestedIconDisplayed = requestedIconDisplayed;
       
   175         iQueryRsp.iSessionTerminatedByUser = terminatedByUser;
       
   176 
       
   177         // Pass the Query response IPC package.
       
   178         TIpcArgs arguments( &iQueryRspPckg );
       
   179 
       
   180         // Perform the IPC data transfer.
       
   181         iSession->CreateRequest( ESatSProactiveQueryResponse, arguments );
       
   182 
       
   183         Start();
       
   184         }
       
   185 
       
   186     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCQueryHandler::RunL exiting" )
       
   187     }
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // CSatCQueryHandler::DoCancel
       
   191 // Cancels the pending request.
       
   192 // (other items were commented in a header).
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 void CSatCQueryHandler::DoCancel()
       
   196     {
       
   197     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCQueryHandler::DoCancel calling" )
       
   198 
       
   199     // Complete the request with cancel code.
       
   200     TRequestStatus* requestStatus = &iStatus;
       
   201     User::RequestComplete( requestStatus, KErrCancel );
       
   202 
       
   203     LOG( SIMPLE, "SATINTERNALCLIENT: CSatCQueryHandler::DoCancel exiting" )
       
   204     }
       
   205 
       
   206 //  End of File