satengine/SatServer/Commands/SendSSCmd/src/CSendSsHandler.cpp
changeset 0 ff3b6d0fd310
child 7 a19c8664496d
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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:  Handles SendSS command
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include    <CPhoneGsmParserBase.h>
       
    20 #include    <CPhoneGsmParserResult.h>
       
    21 #include    <PhoneGsmParser.h>
       
    22 #include    <CPhoneGsmOptionContainerBase.h>
       
    23 
       
    24 #include    "MSatSystemState.h"
       
    25 #include    "MSatApi.h"
       
    26 #include    "MSatUtils.h"
       
    27 #include    "MSatUiSession.h"
       
    28 #include    "SatSOpcodes.h"
       
    29 #include    "MSatSUiClientHandler.h"
       
    30 #include    "CSendSsHandler.h"
       
    31 #include    "SatLog.h"
       
    32 #include    "csatsendssrequestcompletehandler.h"
       
    33 #include    "csatsendssadditionalinfohandler.h"
       
    34 #include    "csatsendsshandler.h"
       
    35 
       
    36 // CustomAPI returns KCustomApiSsGsmActive=0x01
       
    37 const TInt KSsGsmActiveSuccess = 0x01;
       
    38 // CustomAPI returns KCustomApiSsGsmRegistered=0x02
       
    39 const TInt KSsGsmRegistered = 0x02;
       
    40 // CustomAPI returns KCustomApiSsGsmProvisioned=0x04
       
    41 const TInt KSsGsmProvisioned = 0x04;
       
    42 // CustomAPI returns KCustomApiSsGsmQuiescent=0x08
       
    43 const TInt KSsGsmQuiescent = 0x08;
       
    44 // CustomAPI returns SsServiceFailedResp=0xFFFF
       
    45 const TInt KSsServiceFailed = 0xFFFF;
       
    46 // Error code for NetworkFailure = 0xFFFE
       
    47 const TInt KSsNetworkError = 0xFFFE;
       
    48 //interval wait for ussd send
       
    49 const TInt KCallbackInterval = 1000000;
       
    50 // Interval wait for additional info
       
    51 const TInt KSSRequestCallbackInterval = 5000000;
       
    52 // Ss OperationCode value.
       
    53 const TInt KSsOperationShowFDNLIst = 0x05;
       
    54 const TInt KSsOperationPasswordRegistration = 0x06;
       
    55 // Ss error
       
    56 const TInt KSsSimAtkCcRejected = 0x0D;
       
    57 const TInt KTwo = 2;
       
    58 
       
    59 // ======== MEMBER FUNCTIONS ========
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // Two-phased constructor.
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CSendSSHandler* CSendSSHandler::NewL( MSatUtils* aUtils )
       
    66     {
       
    67     LOG( SIMPLE, "SENDSS: CSendSSHandler::NewL calling" )
       
    68 
       
    69     CSendSSHandler* self = new( ELeave ) CSendSSHandler;
       
    70 
       
    71     CleanupStack::PushL( self );
       
    72     self->BaseConstructL( aUtils );
       
    73     self->ConstructL();
       
    74     CleanupStack::Pop( self );
       
    75 
       
    76     LOG( SIMPLE, "SENDSS: CSendSSHandler::NewL exiting" )
       
    77     return self;
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // Destructor.
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 CSendSSHandler::~CSendSSHandler()
       
    85     {
       
    86     LOG( SIMPLE, "SENDSS: CSendSSHandler::~CSendSSHandler calling" )
       
    87 
       
    88     Cancel();
       
    89     // Destroy all objects.
       
    90     delete iAdditionalInfoHandler;
       
    91     delete iRequestCompleteHandler;
       
    92     delete iPhoneGsmHandlerBase;
       
    93     delete iParser;
       
    94     delete iResult;
       
    95     delete iPhoneGsmOptionContainerBase;
       
    96     if ( iTimer )
       
    97         {
       
    98         iTimer->Cancel();
       
    99         delete iTimer;
       
   100         iTimer = NULL;
       
   101         }
       
   102 
       
   103     LOG( SIMPLE, "SENDSS: CSendSSHandler::~CSendSSHandler exiting" )
       
   104     }
       
   105     
       
   106 // -----------------------------------------------------------------------------
       
   107 // Processes the SS Request Complete.
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void CSendSSHandler::DispatchSsRequestComplete( TInt aErrCode )
       
   111     {
       
   112     LOG2( SIMPLE, "SENDSS: CSendSSHandler::DispatchSsRequestComplete \
       
   113     called aErrCode: %i", aErrCode )
       
   114 
       
   115     if ( ( KSsGsmActiveSuccess == aErrCode ) ||
       
   116          ( KSsGsmRegistered == aErrCode ) ||
       
   117          ( KSsGsmProvisioned == aErrCode ) ||
       
   118          ( KSsGsmQuiescent == aErrCode ) )
       
   119         {
       
   120         iSsResult = KErrNone;
       
   121         }
       
   122     else
       
   123         {
       
   124         iSsResult = aErrCode;
       
   125         }
       
   126 
       
   127     // Store result for later use
       
   128     iSsResult = aErrCode;
       
   129     iRequestCompleteArrived = ETrue;
       
   130 
       
   131     //is additional info received
       
   132     if ( iAdditionalInfoArrived )
       
   133         {
       
   134         LOG( SIMPLE, 
       
   135         "SENDSS: CSendSSHandler::DispatchSsRequestComplete \
       
   136         iAdditionalInfoArrived true" )
       
   137         HandleSendSsResult();
       
   138         }
       
   139     else    //if not 5 second timer to get additional info
       
   140         {
       
   141         if ( !iTimer )
       
   142             {
       
   143             LOG( SIMPLE, 
       
   144             "CSendSSHandler::DispatchSsRequestComplete iTimer false" )
       
   145             TRAPD( err, iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); );
       
   146             
       
   147             LOG2( NORMAL, "SENDSS: CSendSSHandler::DispatchSsRequestComplete \
       
   148             CPeriodic::NewL err: %d ", err )              
       
   149             if ( KErrNone == err )
       
   150                 {
       
   151                 iTimer->Start( KSSRequestCallbackInterval,
       
   152                     KCallbackInterval, TCallBack( SSRequestCallback, this ) );
       
   153                 }
       
   154             }
       
   155         }
       
   156 
       
   157     LOG( SIMPLE, "CSendSSHandler::DispatchSsRequestComplete exit" )
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // Processes the SS aditional info.
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 void CSendSSHandler::DispatchSsAdditionalInfo(
       
   165     const TDesC& aAdditionalInfo )
       
   166     {
       
   167     LOG( SIMPLE, "SENDSS: CSendSSHandler::DispatchSsAdditionalInfo called" )
       
   168 
       
   169     iAdditionalInfoArrived = ETrue;
       
   170     iAdditionalInfo.Copy( aAdditionalInfo );
       
   171     LOG2( SIMPLE, "SENDSS: CSendSSHandler::DispatchSsAdditionalInfo length of\
       
   172     aAdditionalInfo: %i", aAdditionalInfo.Length())
       
   173 
       
   174     if ( aAdditionalInfo.Length() > 0 )
       
   175         {
       
   176         // This is special case due tsy will not send request complete.
       
   177         if ( ( ( KSsOperationPasswordRegistration == aAdditionalInfo[0] ) ||
       
   178                ( KSsOperationShowFDNLIst == aAdditionalInfo[0] ) ) &&
       
   179              ( !iRequestCompleteArrived ) )
       
   180             {
       
   181             LOG( SIMPLE, 
       
   182             "SENDSS: CSendSSHandler::DispatchSsAdditionalInfo special case" )
       
   183             iSsResult = KErrNone;
       
   184             iRequestCompleteArrived = ETrue;
       
   185             }
       
   186         }
       
   187 
       
   188     //is requestcompletenotification reveived
       
   189     if ( iRequestCompleteArrived )
       
   190         {
       
   191         LOG( SIMPLE, 
       
   192         "SENDSS: CSendSSHandler::DispatchSsAdditionalInfo \
       
   193         iRequestCompleteArrived true" )
       
   194         HandleSendSsResult();
       
   195         }
       
   196     else    //if not 5 second timer to get requestcompletenote
       
   197         {
       
   198         if ( !iTimer )
       
   199             {
       
   200             LOG( SIMPLE, 
       
   201             "SENDSS: CSendSSHandler::DispatchSsAdditionalInfo iTimer false" )
       
   202             TRAPD( err, iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); );
       
   203             
       
   204             LOG2( NORMAL, "SENDSS: CSendSSHandler::DispatchSsAdditionalInfo \
       
   205             CPeriodic::NewL err: %d ", err )            
       
   206             if ( KErrNone == err )
       
   207                 {
       
   208                 iTimer->Start( KSSRequestCallbackInterval,
       
   209                     KCallbackInterval, TCallBack( SSRequestCallback, this ) );
       
   210                 }
       
   211             }
       
   212         }
       
   213 
       
   214     LOG( SIMPLE, "SENDSS: CSendSSHandler::DispatchSsAdditionalInfo exit" )
       
   215     }
       
   216 
       
   217 // -----------------------------------------------------------------------------
       
   218 // From class MSatCommand.
       
   219 // Response from the client.
       
   220 // -----------------------------------------------------------------------------
       
   221 //
       
   222 void CSendSSHandler::ClientResponse()
       
   223     {
       
   224     LOG( SIMPLE, "SENDSS: CSendSSHandler::ClientResponse calling" )
       
   225 
       
   226     if ( iQueryRsp.iAccepted && !iNotificationSent )
       
   227         {
       
   228         LOG( NORMAL, 
       
   229         "SENDSS: CSendSSHandler::ClientResponse Sending notification" )
       
   230         iNotificationSent = ETrue;
       
   231 
       
   232         // Register service request
       
   233         TRAP_IGNORE( iUtils->RegisterServiceRequestL(
       
   234             ESatSProactiveNotification,
       
   235             ESatSProactiveNotificationResponse,
       
   236             this ) )
       
   237 
       
   238         // Send notification
       
   239         iUtils->SatUiHandler().UiSession()->SendCommand(
       
   240             &iNotificationDataPckg,
       
   241             &iNotificationRspPckg,
       
   242             ESatSProactiveNotification );
       
   243         }
       
   244     else if ( iNotificationRsp.iAccepted && iNotificationSent )
       
   245         {
       
   246         LOG( NORMAL, 
       
   247         "SENDSS: CSendSSHandler::ClientResponse Notification response" )
       
   248         }
       
   249     else // User reject
       
   250         {
       
   251         iUserAccepted = EFalse;
       
   252         // Cannot return KPCmdNotAcceptedByUser (ETSI 11.14 v8.3.0 p65)
       
   253         iSendSsRsp.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   254         iSendSsRsp.iInfoType = RSat::KMeProblem;
       
   255         iSendSsRsp.iAdditionalInfo.SetLength( 1 );
       
   256         iSendSsRsp.iAdditionalInfo[0] = RSat::KScreenBusy;
       
   257 
       
   258         if ( iQueryRsp.iSessionTerminatedByUser )
       
   259             {
       
   260             LOG( NORMAL, "SENDSS: CSendSSHandler::ClientResponse \
       
   261             ESessionTerminatedByUser" )
       
   262             // Notify sim session end command that next sim session end
       
   263             // should close the ui session.
       
   264             iUtils->NotifyEvent( MSatUtils::ESessionTerminatedByUser );
       
   265             }
       
   266 
       
   267         SendTerminalResponse();
       
   268         }
       
   269 
       
   270     // Release Wait
       
   271     if ( iSendWait.IsStarted() )
       
   272         {
       
   273         LOG( NORMAL, "SENDSS: CSendSSHandler::ClientResponse stop iSendWait" )
       
   274         iSendWait.AsyncStop();
       
   275         }
       
   276 
       
   277     LOG( SIMPLE, "SENDSS: CSendSSHandler::ClientResponse exiting" )
       
   278     }
       
   279 
       
   280 // -----------------------------------------------------------------------------
       
   281 // From class CSatCommandHandler.
       
   282 // Waits for indication of user rejection
       
   283 // -----------------------------------------------------------------------------
       
   284 //
       
   285 void CSendSSHandler::Event( TInt aEvent )
       
   286     {
       
   287     LOG2( SIMPLE, "SENDSS: CSendSSHandler::Event calling, aEvent:%d", aEvent )
       
   288 
       
   289     switch ( aEvent )
       
   290         {
       
   291         case MSatUtils::ECancelledUsingEndKey:
       
   292             {
       
   293             // Notify sim session end command that next sim session end
       
   294             // should close the ui session.
       
   295             iUtils->NotifyEvent( MSatUtils::ESessionTerminatedByUser );
       
   296             // This event is handled as above, but notification must be done.
       
   297             }
       
   298             //lint -fallthrough intended here
       
   299 
       
   300         case MSatUtils::ECommandCancelled:
       
   301             {
       
   302             // Check is there a confirmation on screen
       
   303             if ( !iQueryOn || iNotificationSent )
       
   304                 {
       
   305                 LOG( SIMPLE, 
       
   306                 "SENDSS: CSendSSHandler::Event iNotificationSent true" )
       
   307                 // Cancel notification requests
       
   308                 iRequestCompleteHandler->Cancel();
       
   309                 iAdditionalInfoHandler->Cancel();
       
   310 
       
   311                 iSendSsRsp.iGeneralResult = RSat::KUssdTransactionTerminatedByUser;
       
   312                 iSendSsRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   313                 iSendSsRsp.iAdditionalInfo.Zero();
       
   314                 SendTerminalResponse();
       
   315                 }
       
   316             break;
       
   317             }
       
   318 
       
   319         default:
       
   320             {
       
   321             // Move event to base class
       
   322             CSatCommandHandler::Event( aEvent );
       
   323             }
       
   324         }
       
   325 
       
   326     LOG( SIMPLE, "SENDSS: CSendSSHandler::Event exiting" )
       
   327     }
       
   328 
       
   329 // -----------------------------------------------------------------------------
       
   330 // From class CActive.
       
   331 // Cancels the sat request.
       
   332 // -----------------------------------------------------------------------------
       
   333 //
       
   334 void CSendSSHandler::DoCancel()
       
   335     {
       
   336     LOG( SIMPLE, "SENDSS: CSendSSHandler::DoCancel calling" )
       
   337 
       
   338     iUtils->USatAPI().NotifySendSsCancel();
       
   339 
       
   340     LOG( SIMPLE, "SENDSS: CSendSSHandler::DoCancel exiting" )
       
   341     }
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // From class CSatCommandHandler.
       
   345 // Requests the command notification.
       
   346 // -----------------------------------------------------------------------------
       
   347 //
       
   348 void CSendSSHandler::IssueUSATRequest( TRequestStatus& aStatus )
       
   349     {
       
   350     LOG( SIMPLE, "SENDSS: CSendSSHandler::IssueUSATRequest calling" )
       
   351 
       
   352     // Clear the IPC package.
       
   353     new (&iSendSsData) RSat::TSendSsV1();
       
   354     iQueryOn = EFalse;
       
   355     iQueryRsp.iAccepted = EFalse; // default
       
   356     iNotificationRsp.iAccepted = EFalse;
       
   357     iSendSsRsp.iGeneralResult = RSat::KPSessionTerminatedByUser; // default
       
   358     iSendSsRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   359     iSendSsRsp.iAdditionalInfo.Zero();
       
   360 
       
   361     iUtils->USatAPI().NotifySendSs( aStatus, iSendSsPckg );
       
   362 
       
   363     // Unregister from events
       
   364     iUtils->UnregisterEvent( this, MSatUtils::ECommandCancelled );
       
   365     iUtils->UnregisterEvent( this, MSatUtils::ECancelledUsingEndKey );
       
   366 
       
   367     LOG( SIMPLE, "SENDSS: CSendSSHandler::IssueUSATRequest exiting" )
       
   368     }
       
   369 
       
   370 // -----------------------------------------------------------------------------
       
   371 // From class CSatCommandHandler.
       
   372 // Precheck before executing the command.
       
   373 // -----------------------------------------------------------------------------
       
   374 //
       
   375 TBool CSendSSHandler::CommandAllowed()
       
   376     {
       
   377     LOG( SIMPLE, "SENDSS: CSendSSHandler::CommandAllowed calling" )
       
   378 
       
   379     // Allow this command to send terminal response
       
   380     iTerminalRespSent = EFalse;
       
   381     RMobilePhone::TMobilePhoneRegistrationStatus registrationStatus(
       
   382         iUtils->SystemState().GetNetworkRegistrationStatus() );
       
   383 
       
   384     TBool commandAllowed( ETrue );
       
   385 
       
   386     // icon without alpha id
       
   387     if ( ( RSat::EAlphaIdProvided != iSendSsData.iAlphaId.iStatus ) &&
       
   388          ( RSat::ESelfExplanatory == iSendSsData.iIconId.iQualifier ||
       
   389            RSat::ENotSelfExplanatory == iSendSsData.iIconId.iQualifier ) )
       
   390         {
       
   391         iSendSsRsp.iGeneralResult = RSat::KCmdDataNotUnderstood;
       
   392         iSendSsRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   393         iSendSsRsp.iAdditionalInfo.Zero();
       
   394         commandAllowed = EFalse;
       
   395         LOG( SIMPLE,
       
   396             "SENDSS: CSendSSHandler::CommandAllowed icon without alpha id" )
       
   397         }
       
   398     else if ( ( RMobilePhone::ERegisteredOnHomeNetwork != registrationStatus ) &&
       
   399         ( RMobilePhone::ERegisteredRoaming != registrationStatus ) )
       
   400         {
       
   401         iSendSsRsp.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   402         iSendSsRsp.iInfoType = RSat::KMeProblem;
       
   403         iSendSsRsp.iAdditionalInfo.SetLength( 1 );
       
   404         iSendSsRsp.iAdditionalInfo[0] = RSat::KNoService;
       
   405         commandAllowed = EFalse;
       
   406         LOG( SIMPLE,
       
   407             "SENDSS: CSendSSHandler::CommandAllowed no service" )
       
   408         }
       
   409     // Set icon command flag whether icon data was received and set qualifier
       
   410     // to no icon id
       
   411     // To be removed when icons are allowed in this command
       
   412     else if ( ( RSat::ESelfExplanatory ==
       
   413         iSendSsData.iIconId.iQualifier ) ||
       
   414         ( RSat::ENotSelfExplanatory ==
       
   415         iSendSsData.iIconId.iQualifier ) )
       
   416         {
       
   417         LOG( SIMPLE,
       
   418             "SENDSS: CSendSSHandler::CommandAllowed ENoIconId" )
       
   419         iIconCommand = ETrue;
       
   420         iSendSsData.iIconId.iQualifier = RSat::ENoIconId;
       
   421         }
       
   422     else
       
   423         {
       
   424         LOG( SIMPLE,
       
   425             "SENDSS: CSendSSHandler::CommandAllowed others" )
       
   426         iIconCommand = EFalse;
       
   427         }
       
   428 
       
   429     if ( !commandAllowed )
       
   430         {
       
   431         SendTerminalResponse();
       
   432         LOG( SIMPLE, "SENDSS: CSendSSHandler::CommandAllowed not allowed" )
       
   433         }
       
   434 
       
   435     LOG( SIMPLE, "SENDSS: CSendSSHandler::CommandAllowed exiting" )
       
   436     return commandAllowed;
       
   437     }
       
   438 
       
   439 // -----------------------------------------------------------------------------
       
   440 // From class CSatCommandHandler.
       
   441 // Answers for need of UI session.
       
   442 // -----------------------------------------------------------------------------
       
   443 //
       
   444 TBool CSendSSHandler::NeedUiSession()
       
   445     {
       
   446     LOG( SIMPLE, "SENDSS: CSendSSHandler::NeedUiSession calling" )
       
   447 
       
   448     iNeedUiSession = !TransparentSsSending();
       
   449 
       
   450     // Notify Cover UI if it's supported
       
   451     if ( iNeedUiSession && iUtils->CoverUiSupported() )
       
   452         {
       
   453         TSatCommandData medEventData;
       
   454         medEventData.iPCmdNumber = RSat::ESendSs;
       
   455         medEventData.iAlphaId = iSendSsData.iAlphaId;
       
   456         if ( iUtils->SystemState().IsConfirmSatOperationsOn() )
       
   457             {
       
   458             LOG( SIMPLE, 
       
   459             "SENDSS: CSendSSHandler::NeedUiSession KSatLongDuration" )
       
   460             medEventData.iDuration.iNumOfUnits = KSatLongDuration;
       
   461             }
       
   462         else
       
   463             {
       
   464             LOG( SIMPLE, 
       
   465             "SENDSS: CSendSSHandler::NeedUiSession KSatDefaultDuration" )
       
   466             medEventData.iDuration.iNumOfUnits = KSatDefaultDuration;
       
   467             }
       
   468         medEventData.iDuration.iTimeUnit = RSat::ESeconds;
       
   469         medEventData.iIconID = iSendSsData.iIconId;
       
   470         TSatCommandPckg tPckg( medEventData );
       
   471         iUtils->RaiseSatEvent( tPckg );
       
   472         }
       
   473 
       
   474     LOG2( SIMPLE, "SENDSS: CSendSSHandler::NeedUiSession exiting,\
       
   475     iNeedUiSession: %d", iNeedUiSession )
       
   476     return iNeedUiSession;
       
   477     }
       
   478 
       
   479 // -----------------------------------------------------------------------------
       
   480 // From class CSatCommandHandler.
       
   481 // Called when USAT API notifies that command.
       
   482 // -----------------------------------------------------------------------------
       
   483 //
       
   484 void CSendSSHandler::HandleCommand()
       
   485     {
       
   486     LOG( SIMPLE, "SENDSS: CSendSSHandler::HandleCommand calling" )
       
   487 
       
   488     iUtils->NotifyEvent( MSatUtils::ESendSsExecuting );
       
   489 
       
   490     // This is true, by default
       
   491     iUserAccepted = ETrue;
       
   492 
       
   493     if ( iNeedUiSession )
       
   494         {
       
   495         LOG( SIMPLE, 
       
   496         "SENDSS: CSendSSHandler::HandleCommand iNeedUiSession true" )
       
   497         TRAP_IGNORE(
       
   498         // Register to listen user cancel events:
       
   499         // Cancel key event from dialog
       
   500         iUtils->RegisterL( this, MSatUtils::ECommandCancelled );
       
   501         // End key from dialog
       
   502         iUtils->RegisterL( this, MSatUtils::ECancelledUsingEndKey ) )
       
   503 
       
   504         // Build Qyery and Notify packages
       
   505         // Has to be casted to TInt before casting to TSatIconQualifier, because
       
   506         // GCC warns about the direct cast.
       
   507         const struct TSatIconId iconId = { iSendSsData.iIconId.iIdentifier,
       
   508             static_cast<TSatIconQualifier>(
       
   509                 static_cast<TInt>( iSendSsData.iIconId.iQualifier ) ) };
       
   510 
       
   511         if ( RSat::EAlphaIdNotPresent == iSendSsData.iAlphaId.iStatus )
       
   512             {
       
   513             LOG( SIMPLE, 
       
   514             "SENDSS: CSendSSHandler::HandleCommand EAlphaIdNotPresent" )
       
   515             iQueryData.iAlphaIdStatus = ESatAlphaIdNotProvided;
       
   516             iNotificationData.iAlphaIdStatus = ESatAlphaIdNotProvided;
       
   517             }
       
   518         else if ( RSat::EAlphaIdProvided == iSendSsData.iAlphaId.iStatus )
       
   519             {
       
   520             LOG( SIMPLE, 
       
   521             "SENDSS: CSendSSHandler::HandleCommand EAlphaIdProvided" )
       
   522             iQueryData.iAlphaIdStatus = ESatAlphaIdNotNull;
       
   523             iNotificationData.iAlphaIdStatus = ESatAlphaIdNotNull;
       
   524             }
       
   525         else
       
   526             {
       
   527             LOG( SIMPLE, 
       
   528             "SENDSS: CSendSSHandler::HandleCommand ESatAlphaIdNull" )
       
   529             iQueryData.iAlphaIdStatus = ESatAlphaIdNull;
       
   530             iNotificationData.iAlphaIdStatus = ESatAlphaIdNull;
       
   531             }
       
   532 
       
   533         iQueryData.iCommand = ESatSSendSsQuery;
       
   534         iQueryData.iQueryText = iSendSsData.iAlphaId.iAlphaId;
       
   535         iQueryData.iIconId = iconId;
       
   536 
       
   537         iNotificationSent = EFalse;
       
   538         iNotificationData.iCommand = ESatSSendSsNotify;
       
   539         iNotificationData.iText = iSendSsData.iAlphaId.iAlphaId;
       
   540         iNotificationData.iIconId = iconId;
       
   541 
       
   542         MSatUiSession* uiSession = iUtils->SatUiHandler().UiSession();
       
   543 
       
   544         // Send either query or notification
       
   545         if ( iQueryOn )
       
   546             {
       
   547             LOG( NORMAL, 
       
   548             "SENDSS: CSendSSHandler::HandleCommand Sending Query" )
       
   549             iNotificationSent = EFalse;
       
   550             // Register service request
       
   551             TRAP_IGNORE( iUtils->RegisterServiceRequestL(
       
   552                 ESatSProactiveQuery,
       
   553                 ESatSProactiveQueryResponse,
       
   554                 this ) )
       
   555 
       
   556             // Send query
       
   557             uiSession->SendCommand(
       
   558                 &iQueryPckg,
       
   559                 &iQueryRspPckg,
       
   560                 ESatSProactiveQuery );
       
   561             }
       
   562         else
       
   563             {
       
   564             LOG( NORMAL, 
       
   565             "SENDSS: CSendSSHandler::HandleCommand Sending notification" )
       
   566             iNotificationSent = ETrue;
       
   567 
       
   568             // Register service request
       
   569             TRAP_IGNORE( iUtils->RegisterServiceRequestL(
       
   570                 ESatSProactiveNotification,
       
   571                 ESatSProactiveNotificationResponse,
       
   572                 this ) )
       
   573 
       
   574             // Send notification
       
   575             uiSession->SendCommand(
       
   576                 &iNotificationDataPckg,
       
   577                 &iNotificationRspPckg,
       
   578                 ESatSProactiveNotification );
       
   579             }
       
   580 
       
   581         if ( !iSendWait.IsStarted() )
       
   582             {
       
   583             LOG( NORMAL, 
       
   584             "SENDSS: CSendSSHandler::HandleCommand start iSendWait" )
       
   585             // Start waiting response from the user
       
   586             iSendWait.Start();
       
   587             }
       
   588         }
       
   589 
       
   590     if ( iUserAccepted )
       
   591         {
       
   592         LOG( NORMAL, 
       
   593         "SENDSS: CSendSSHandler::HandleCommand iUserAccepted true" )
       
   594         // Ready to send Ss string
       
   595         TRAPD( err, SendSsStringL() )
       
   596         if ( KErrNone != err )
       
   597             {
       
   598             LOG2( NORMAL, " Ss sending failed: %i", err )
       
   599             iSendSsRsp.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   600             iSendSsRsp.iInfoType = RSat::KMeProblem;
       
   601             iSendSsRsp.iAdditionalInfo.SetLength( 1 );
       
   602             iSendSsRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem;
       
   603             SendTerminalResponse();
       
   604             }
       
   605         }
       
   606 
       
   607     LOG( SIMPLE, "SENDSS: CSendSSHandler::HandleCommand exiting" )
       
   608     }
       
   609     
       
   610 // -----------------------------------------------------------------------------
       
   611 // From class CSatCommandHandler.
       
   612 // Indicates the failure of launching ui client
       
   613 // -----------------------------------------------------------------------------
       
   614 //
       
   615 void CSendSSHandler::UiLaunchFailed()
       
   616     {
       
   617     LOG( SIMPLE, "SENDSS: CSendSSHandler::UiLaunchFailed calling" )
       
   618 
       
   619     iSendSsRsp.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   620     iSendSsRsp.iInfoType = RSat::KMeProblem;
       
   621     iSendSsRsp.iAdditionalInfo.SetLength( 1 );
       
   622     iSendSsRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem;
       
   623     SendTerminalResponse();
       
   624 
       
   625     LOG( SIMPLE, "SENDSS: CSendSSHandler::UiLaunchFailed exiting" )
       
   626     }
       
   627 
       
   628 // -----------------------------------------------------------------------------
       
   629 // C++ default constructor can NOT contain any code, that
       
   630 // might leave.
       
   631 // -----------------------------------------------------------------------------
       
   632 //
       
   633 //lint -e{1403, 1769} Can not be initialized.
       
   634 CSendSSHandler::CSendSSHandler() :
       
   635     CSatCommandHandler(),
       
   636     iSendSsData(),
       
   637     iSendSsPckg( iSendSsData ),
       
   638     iSendSsRsp(),
       
   639     iSendSsRspPckg( iSendSsRsp ),
       
   640     iQueryData(),
       
   641     iQueryPckg( iQueryData ),
       
   642     iQueryRsp(),
       
   643     iQueryRspPckg( iQueryRsp ),
       
   644     iNotificationData(),
       
   645     iNotificationDataPckg( iNotificationData ),
       
   646     iNotificationRsp(),
       
   647     iNotificationRspPckg( iNotificationRsp ),
       
   648     // To be removed when icons are allowed in this command
       
   649     iIconCommand( EFalse )
       
   650     {
       
   651     LOG( SIMPLE, "SENDSS: CSendSSHandler::CSendSSHandler calling - exiting" )
       
   652     }
       
   653 
       
   654 // -----------------------------------------------------------------------------
       
   655 // Symbian 2nd phase constructor can leave.
       
   656 // -----------------------------------------------------------------------------
       
   657 //
       
   658 void CSendSSHandler::ConstructL()
       
   659     {
       
   660     LOG( SIMPLE, "SENDSS: CSendSSHandler::ConstructL calling" )
       
   661 
       
   662     // Create additional info and request complete handlers
       
   663     iAdditionalInfoHandler = CSatSendSsAdditionalInfoHandler::NewL(
       
   664         *iUtils->CustomApi(), this );
       
   665     iRequestCompleteHandler = CSatSendSsRequestCompleteHandler::NewL(
       
   666         *iUtils->CustomApi(), this );
       
   667     iPhoneGsmHandlerBase = new ( ELeave ) CSatSendSsHandler();
       
   668 
       
   669     LOG( SIMPLE, "SENDSS: CSendSSHandler::ConstructL exiting" )
       
   670     }
       
   671     
       
   672 // -----------------------------------------------------------------------------
       
   673 // Handles the Ss string sending.
       
   674 // -----------------------------------------------------------------------------
       
   675 //
       
   676 void CSendSSHandler::SendSsStringL()
       
   677     {
       
   678     LOG( SIMPLE, "SENDSS: CSendSSHandler::SendSsString calling" )
       
   679 
       
   680     // Set default values
       
   681     iSsResult = KErrArgument;
       
   682     iRequestCompleteArrived = EFalse;
       
   683     iAdditionalInfoArrived = EFalse;
       
   684 
       
   685     //Parsing and interpreting
       
   686     TBuf<RSat::KStringMaxSize> sendMessage;
       
   687     sendMessage.Copy( iSendSsData.iSsString.iSsString );
       
   688 
       
   689     // CPhoneGsmOptionContainerBase cannot be deleted before SendSsString 
       
   690     // complete, so the object is designed as a member in order that it can be 
       
   691     // deleted asychronously.
       
   692     iParser = PhoneGsmParser::CreateParserL();
       
   693     iResult = PhoneGsmParser::CreateResultL();
       
   694     iPhoneGsmOptionContainerBase = PhoneGsmParser::CreateOptionContainerL();
       
   695 
       
   696     //Update options
       
   697     iPhoneGsmOptionContainerBase->SetOptionStatus( KPhoneOptionSend, ETrue );
       
   698 
       
   699     //Parsing and interpreting
       
   700 
       
   701     //Parse string
       
   702     if ( iParser->ParseL( sendMessage, *iResult, *iPhoneGsmOptionContainerBase ) )
       
   703         {
       
   704         if ( PhoneGsmParser::DetermineContentType( *iResult ) ==
       
   705             PhoneGsmParser::EContentSupplementaryService )
       
   706             {
       
   707 
       
   708             if ( !iRequestCompleteHandler->IsActive() )
       
   709                 {
       
   710                 LOG( SIMPLE, 
       
   711                 "SENDSS: CSendSSHandler::SendSsString start \
       
   712                 iRequestCompleteHandler" )
       
   713                 iRequestCompleteHandler->Start();
       
   714                 }
       
   715 
       
   716             if ( !iAdditionalInfoHandler->IsActive() )
       
   717                 {
       
   718                 LOG( SIMPLE, 
       
   719                 "SENDSS: CSendSSHandler::SendSsString start \
       
   720                 iAdditionalInfoHandler" )
       
   721                 iAdditionalInfoHandler->Start();
       
   722                 }
       
   723 
       
   724             // Make a Default Additional Info here, in case additional
       
   725             // info field won't be received
       
   726             // the field is a dummy
       
   727             iAdditionalInfo.SetLength( 1 );
       
   728             iAdditionalInfo[0] = 0x00;
       
   729 
       
   730             LOG( SIMPLE, 
       
   731             "SENDSS: CSendSSHandler::SendSsString Processing Ss" )
       
   732 
       
   733             // CPhoneGsmHandlerBase lives in all lifetime of 
       
   734             // CSendSSHandler. So, it designed as a member.
       
   735             iPhoneGsmHandlerBase->ProcessL( *iResult );
       
   736             }
       
   737         else
       
   738             {
       
   739             LOG( SIMPLE, 
       
   740             "SENDSS: CSendSSHandler::SendSsString KCmdDataNotUnderstood" )
       
   741             iSendSsRsp.iGeneralResult = RSat::KCmdDataNotUnderstood;
       
   742             iSendSsRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   743             iSendSsRsp.iAdditionalInfo.Zero();
       
   744 
       
   745             // Send terminal response
       
   746             SendTerminalResponse();
       
   747             }
       
   748         }
       
   749 
       
   750     LOG( SIMPLE, "SENDSS: CSendSSHandler::SendSsString exiting" )
       
   751     }
       
   752 
       
   753 // -----------------------------------------------------------------------------
       
   754 // Handles the result of Ss sending.
       
   755 // -----------------------------------------------------------------------------
       
   756 //
       
   757 void CSendSSHandler::HandleSendSsResult()
       
   758     {
       
   759     LOG( SIMPLE, "SENDSS: CSendSSHandler::HandleSendSsResult calling" )
       
   760     LOG2( SIMPLE, 
       
   761     "SENDSS: CSendSSHandler::HandleSendSsResult iSsResult: %i", iSsResult )
       
   762     // Remove progress bar from the screen
       
   763     if ( KSsServiceFailed == iSsResult || KSsNetworkError == iSsResult )
       
   764         {
       
   765         LOG( SIMPLE, 
       
   766         "SENDSS: CSendSSHandler::HandleSendSsResult Clearing Progress bar.." )
       
   767         iUtils->NotifyUiEvent( ESatSsEndEvent, ESatEventFailure, iSsResult );
       
   768         // Send Error notification, but only if Alpha ID was provided
       
   769 	    if ( ESatAlphaIdNotNull == iNotificationData.iAlphaIdStatus )
       
   770 	        {
       
   771 	        LOG( SIMPLE, 
       
   772 	        "SENDSS: CSendSSHandler::HandleSendSsResult Sending Ss note: \
       
   773 	        Not Done" )
       
   774 	        iUtils->NotifyUiEvent( ESatSsErrorEvent, ESatEventFailure, 
       
   775 	        	iSsResult );
       
   776 	        }
       
   777         }
       
   778     else if ( iNotificationSent )
       
   779         {
       
   780         // Remove the UI dialog
       
   781         LOG( SIMPLE, 
       
   782         "SENDSS: CSendSSHandler::HandleSendSsResult iNotificationSent true" )
       
   783         iUtils->NotifyUiEvent( ESatSsEndEvent, ESatEventCompleteOk, iSsResult );
       
   784         }
       
   785 
       
   786     switch ( iSsResult )
       
   787         {
       
   788         case KErrGeneral: // Command not processed
       
   789             {
       
   790             iSendSsRsp.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   791             iSendSsRsp.iInfoType = RSat::KMeProblem;
       
   792             iSendSsRsp.iAdditionalInfo.SetLength( 1 );
       
   793             iSendSsRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem;
       
   794             break;
       
   795             }
       
   796 
       
   797         case KErrArgument:
       
   798             {
       
   799             iSendSsRsp.iGeneralResult = RSat::KCmdDataNotUnderstood;
       
   800             iSendSsRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   801             iSendSsRsp.iAdditionalInfo.Zero();
       
   802             break;
       
   803             }
       
   804 
       
   805         case KSsServiceFailed:
       
   806             {
       
   807             //This is a special case, TSY sends error value in additional info
       
   808             //when SS is rejected by Call control 
       
   809             if ( KTwo <= iAdditionalInfo.Length() && 
       
   810                 KSsSimAtkCcRejected == iAdditionalInfo[1] )
       
   811                 {
       
   812                 LOG( SIMPLE, 
       
   813                 "SENDSS: CSendSSHandler::HandleSendSsResult \
       
   814                 KInteractionWithCCPermanentError" )
       
   815                 iSendSsRsp.iGeneralResult = 
       
   816                     RSat::KInteractionWithCCPermanentError;
       
   817                 iSendSsRsp.iAdditionalInfo.SetLength( 1 );
       
   818                 iSendSsRsp.iAdditionalInfo[0] = RSat::KActionNotAllowed;	
       
   819                 }
       
   820             else
       
   821                 {
       
   822                 LOG( SIMPLE, 
       
   823                 "SENDSS: CSendSSHandler::HandleSendSsResult KSsReturnError" )
       
   824                 iSendSsRsp.iGeneralResult = RSat::KSsReturnError;
       
   825                 iSendSsRsp.iAdditionalInfo.Copy( iAdditionalInfo );	
       
   826                 }
       
   827             iSendSsRsp.iInfoType = RSat::KMeProblem;
       
   828             break;
       
   829             }
       
   830 
       
   831         case KSsNetworkError:
       
   832             {
       
   833             iSendSsRsp.iGeneralResult = RSat::KNetworkUnableToProcessCmd;
       
   834             iSendSsRsp.iInfoType = RSat::KSatNetworkErrorInfo;
       
   835             iSendSsRsp.iAdditionalInfo.SetLength( 1 );
       
   836             if ( iAdditionalInfo.Length() > 1 )
       
   837                 {
       
   838                 LOG( SIMPLE, 
       
   839                 "SENDSS: CSendSSHandler::HandleSendSsResult \
       
   840                 iAdditionalInfo.Length() > 1" )
       
   841                 iSendSsRsp.iAdditionalInfo[0] = \
       
   842                     ( iAdditionalInfo[1] == RSat::KNoSpecificMeProblem ) \
       
   843                     ? iAdditionalInfo[1] : ( iAdditionalInfo[1] | 0x80 );
       
   844                 }
       
   845             else
       
   846                 {
       
   847                 iSendSsRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem;
       
   848                 }
       
   849             break;
       
   850             }
       
   851 
       
   852         default:
       
   853             {
       
   854             // Convert terminal rsp if icon used
       
   855             iSendSsRsp.iGeneralResult = RSat::KSuccess;
       
   856 
       
   857             // If command had icon data and was done succesfully,
       
   858             // report that icon was not shown.
       
   859             // To be removed and correct handling (i.e. ClientResponse to
       
   860             // notification is received) for general result
       
   861             // KSuccessRequestedIconNotDisplayed must be added when icons are
       
   862             // allowed in this command 
       
   863             if ( iIconCommand )
       
   864                 {
       
   865                 LOG( SIMPLE, 
       
   866                 "SENDSS: CSendSSHandler::HandleSendSsResult iIconCommand \
       
   867                 true" )
       
   868                 iSendSsRsp.iGeneralResult =
       
   869                             RSat::KSuccessRequestedIconNotDisplayed;
       
   870                 }
       
   871             
       
   872             if ( iAdditionalInfo.Length() )
       
   873                 {
       
   874                 LOG( SIMPLE, 
       
   875                 "SENDSS: CSendSSHandler::HandleSendSsResult \
       
   876                 iAdditionalInfo.Length >0" )
       
   877                 iSendSsRsp.iInfoType = RSat::KSendSsInfo;
       
   878                 iSendSsRsp.iAdditionalInfo.Copy( iAdditionalInfo );
       
   879                 }
       
   880             else
       
   881                 {
       
   882                 iSendSsRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   883                 iSendSsRsp.iAdditionalInfo.Zero();
       
   884                 }
       
   885 
       
   886             break;
       
   887             }
       
   888         }
       
   889 
       
   890     delete iResult;
       
   891     iResult = NULL;
       
   892 
       
   893     delete iParser;
       
   894     iParser = NULL;
       
   895 
       
   896     delete iPhoneGsmOptionContainerBase;
       
   897     iPhoneGsmOptionContainerBase = NULL;
       
   898 
       
   899     iRequestCompleteHandler->Cancel();
       
   900     iAdditionalInfoHandler->Cancel();
       
   901 
       
   902     // Send terminal response
       
   903     SendTerminalResponse();
       
   904 
       
   905     LOG( SIMPLE, "SENDSS: CSendSSHandler::HandleSendSsResult exiting" )
       
   906     }
       
   907     
       
   908 // -----------------------------------------------------------------------------
       
   909 // SS sending should be transparent if alpha identifier is provided but it's
       
   910 // length is 0. Also user query setting is not on.
       
   911 // -----------------------------------------------------------------------------
       
   912 //
       
   913 TBool CSendSSHandler::TransparentSsSending()
       
   914     {
       
   915     LOG( SIMPLE, "SENDSS: CSendSSHandler::TransparentSsSending calling" )
       
   916 
       
   917     TBool result( EFalse );
       
   918     const RSat::TAlphaId alphaId( iSendSsData.iAlphaId );
       
   919 
       
   920     // Store to member variable for later use
       
   921     iQueryOn = iUtils->SystemState().IsConfirmSatOperationsOn();
       
   922 
       
   923     if ( ( alphaId.iStatus == RSat::EAlphaIdProvided &&
       
   924            alphaId.iAlphaId.Length() == 0 ) ||
       
   925            alphaId.iStatus == RSat::EAlphaIdNull )
       
   926         {
       
   927         LOG( SIMPLE, 
       
   928         "SENDSS: CSendSSHandler::TransparentSsSending EAlphaIdNull" )
       
   929         if ( !iQueryOn )
       
   930             {
       
   931             LOG( SIMPLE, 
       
   932             "SENDSS: CSendSSHandler::TransparentSsSending iQueryOn false" )
       
   933             result = ETrue;
       
   934             }
       
   935         }
       
   936 
       
   937     LOG2( SIMPLE, "SENDSS: CSendSSHandler::TransparentSsSending exiting: %i",
       
   938         result )
       
   939     return result;
       
   940     }
       
   941 
       
   942 // -----------------------------------------------------------------------------
       
   943 // Sends terminal response, if not yet sent
       
   944 // -----------------------------------------------------------------------------
       
   945 //
       
   946 void CSendSSHandler::SendTerminalResponse()
       
   947     {
       
   948     LOG( SIMPLE, "SENDSS: CSendSSHandler::SendTerminalResponse calling" )
       
   949 
       
   950     if ( !iTerminalRespSent )
       
   951         {
       
   952         LOG( SIMPLE, 
       
   953         "SENDSS: CSendSSHandler::SendTerminalResponse iTerminalRespSent false" )
       
   954         iTerminalRespSent = ETrue;
       
   955         iSendSsRsp.SetPCmdNumber( iSendSsData.PCmdNumber() );
       
   956         TerminalRsp( RSat::ESendSs, iSendSsRspPckg );
       
   957         }
       
   958 
       
   959     // Delete timer in case it is still active
       
   960     if ( iTimer )
       
   961         {
       
   962         LOG( SIMPLE, 
       
   963         "SENDSS: CSendSSHandler::SendTerminalResponse iTimer true" )
       
   964         iTimer->Cancel();
       
   965         delete iTimer;
       
   966         iTimer = NULL;
       
   967         }
       
   968 
       
   969     LOG( SIMPLE, "SENDSS: CSendSSHandler::SendTerminalResponse exiting" )
       
   970     }
       
   971 
       
   972 // -----------------------------------------------------------------------------
       
   973 // Callback for SendSS additionalinfo waiting timer.
       
   974 // -----------------------------------------------------------------------------
       
   975 //
       
   976 TInt CSendSSHandler::SSRequestCallback( TAny* aPtr )
       
   977     {
       
   978     LOG( SIMPLE, "SENDSS: CSendSSHandler::SSRequestCallback calling" )
       
   979 
       
   980     CSendSSHandler* handler =
       
   981         static_cast<CSendSSHandler*>( aPtr );
       
   982 
       
   983     if ( handler )
       
   984         {
       
   985         LOG( SIMPLE, 
       
   986         "SENDSS: CSendSSHandler::SSRequestCallback handler true" )
       
   987         handler->HandleSendSsResult();
       
   988 
       
   989         if ( handler->iTimer )
       
   990             {
       
   991             LOG( SIMPLE, 
       
   992             "SENDSS: CSendSSHandler::SSRequestCallback cancel iTimer" )
       
   993             handler->iTimer->Cancel();
       
   994             delete handler->iTimer;
       
   995             handler->iTimer = NULL;
       
   996             }
       
   997         }
       
   998 
       
   999     LOG( SIMPLE, "SENDSS: CSendSSHandler::SSRequestCallback exiting" )
       
  1000     return ( KErrNone );
       
  1001     }
       
  1002