satengine/SatServer/Commands/SendDataCmd/src/CSendDataHandler.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     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 SendData command
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include    <e32std.h>
       
    20 #include    <etelmmerr.h>
       
    21 #include    "MSatApi.h"
       
    22 #include    "MSatUtils.h"
       
    23 #include    "MSatSystemState.h"
       
    24 #include    "MSatBIPUtils.h"
       
    25 #include    "MSatBIPDataChannel.h"
       
    26 #include    "MSatApnHandler.h"
       
    27 #include    "MSatUiSession.h"
       
    28 #include    "SatSOpcodes.h"
       
    29 #include    "MSatSUiClientHandler.h"
       
    30 #include    "CSendDataHandler.h"
       
    31 #include    "SatLog.h"
       
    32 
       
    33 // ======== MEMBER FUNCTIONS ========
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // Two-phased constructor.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CSendDataHandler* CSendDataHandler::NewL( MSatUtils* aUtils )
       
    40     {
       
    41     LOG( SIMPLE, "SendData: CSendDataHandler::NewL calling" )
       
    42 
       
    43     CSendDataHandler* self = new( ELeave ) CSendDataHandler;
       
    44 
       
    45     CleanupStack::PushL( self );
       
    46     self->BaseConstructL( aUtils );
       
    47     self->ConstructL();
       
    48     CleanupStack::Pop( self );
       
    49 
       
    50     LOG( SIMPLE, "SendData: CSendDataHandler::NewL exiting" )
       
    51     return self;
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // Destructor.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CSendDataHandler::~CSendDataHandler()
       
    59     {
       
    60     LOG( SIMPLE, "SendData: CSendDataHandler::~CSendDataHandler calling" )
       
    61 
       
    62     Cancel();
       
    63 
       
    64     iDataChannel = NULL;
       
    65 
       
    66     LOG( SIMPLE, "SendData: CSendDataHandler::~CSendDataHandler exiting" )
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // From class MSatCommand.
       
    71 // Response from the client.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 void CSendDataHandler::ClientResponse()
       
    75     {
       
    76     LOG( SIMPLE, "SendData: CSendDataHandler::ClientResponse calling-exiting" )
       
    77     // Don't send terminal response, already sent in HandleCommand
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // From class MSatSendDataObserver.
       
    82 // Notification of data has been sent.
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CSendDataHandler::DataSentNotification(
       
    86     const TInt aError, const TInt aLength )
       
    87     {
       
    88     LOG( SIMPLE, "SendData: CSendDataHandler::DataSentNotification calling" )
       
    89 
       
    90     if ( MSatBIPUtils::ESatBIPSuccess != aError )
       
    91         {
       
    92         LOG( SIMPLE, "SendData: CSendDataHandler::DataSentNotification Error" )
       
    93         iSendDataRspData.iGeneralResult = RSat::KBearerIndepProtocolError;
       
    94         }
       
    95     else
       
    96         {
       
    97         iSendDataRspData.iGeneralResult = RSat::KSuccess;
       
    98         iFreeBuffSize = aLength;
       
    99         }
       
   100 
       
   101     SendTerminalResponse( aError );
       
   102 
       
   103     LOG( SIMPLE, "SendData: CSendDataHandler::DataSentNotification exiting" )
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // From class MSatSendDataObserver.
       
   108 // Notfication from the connection.
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CSendDataHandler::ConnectionNotification( TInt aError )
       
   112     {
       
   113     LOG2( SIMPLE, "SENDDATA: CSendDataHandler::ConnectionNotification\
       
   114          calling with code %i", aError )
       
   115 
       
   116     if ( KErrNone == aError )
       
   117         {
       
   118         // Connection established, send data
       
   119         SendData();
       
   120         }
       
   121     else
       
   122         {
       
   123 
       
   124         // Get connection info and remove APN from CommDB, if created during
       
   125         // OpenChannel command
       
   126         TUint32 apnId( iDataChannel->ConnInfo().iCreatedApnId );
       
   127         LOG2( SIMPLE, "SENDDATA: CSendDataHandler::ConnectionNotification \
       
   128         apnId: %i", apnId )
       
   129         if ( apnId > 0 )
       
   130             {
       
   131             TRAP_IGNORE( iUtils->BipUtils().ApnHandler().DeleteApnL( apnId ) )
       
   132             }
       
   133 
       
   134         // Connection failed
       
   135         iSendDataRspData.iGeneralResult = RSat::KBearerIndepProtocolError;
       
   136         SendTerminalResponse( MSatBIPUtils::ESatBIPChannelClosed );
       
   137         }
       
   138 
       
   139     LOG( SIMPLE, "SENDDATA: CSendDataHandler::ConnectionNotification exiting" )
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // From class CSatCommandHandler.
       
   144 // Waits for indication of user wanting to close the BIP session.
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void CSendDataHandler::Event( TInt aEvent )
       
   148     {
       
   149     LOG2( SIMPLE, "CSendDataHandler::Event calling, aEvent:%d", aEvent )
       
   150 
       
   151     switch ( aEvent )
       
   152         {
       
   153         case MSatUtils::ECommandCancelled:
       
   154         case MSatUtils::ECancelledUsingEndKey:
       
   155             {
       
   156             // Check Channel activation status
       
   157             if ( iUtils->BipUtils().IsContextActive() )
       
   158                 {
       
   159                 LOG( SIMPLE, "CSendDataHandler::Event IsContextActive" )
       
   160                 // Next command is rejected
       
   161                 iUserCancelled = ETrue;
       
   162                 SendTerminalResponse(); // If command is executing, send.
       
   163                 }
       
   164             break;
       
   165             }
       
   166         case MSatUtils::EOpenChannelExecuting:
       
   167             {
       
   168             // New channel, reset user cancel flag.
       
   169             iUserCancelled = EFalse;
       
   170             break;
       
   171             }
       
   172         default:
       
   173             {
       
   174             // Move event to base class
       
   175             CSatCommandHandler::Event( aEvent );
       
   176             }
       
   177         }
       
   178 
       
   179     LOG( SIMPLE, "CSendDataHandler::Event exiting" )
       
   180     }
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // From class CActive.
       
   184 // Cancels the sat request.
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 void CSendDataHandler::DoCancel()
       
   188     {
       
   189     LOG( SIMPLE, "SendData: CSendDataHandler::DoCancel calling" )
       
   190 
       
   191     iUtils->USatAPI().NotifySendDataCancel();
       
   192 
       
   193     LOG( SIMPLE, "SendData: CSendDataHandler::DoCancel exiting" )
       
   194     }
       
   195 
       
   196 // -----------------------------------------------------------------------------
       
   197 // From class CSatCommandHandler.
       
   198 // Requests the command notification.
       
   199 // -----------------------------------------------------------------------------
       
   200 //
       
   201 void CSendDataHandler::IssueUSATRequest( TRequestStatus& aStatus )
       
   202     {
       
   203     LOG( SIMPLE, "SendData: CSendDataHandler::IssueUSATRequest calling" )
       
   204 
       
   205     // Empty previously recevied data.
       
   206     new (&iSendDataData) RSat::TSendDataV2();
       
   207 
       
   208     iUtils->USatAPI().NotifySendData( aStatus, iSendDataPckg );
       
   209     iUtils->NotifyEvent( MSatUtils::EBipCommandDoneExecuting );
       
   210 
       
   211     LOG( SIMPLE, "SendData: CSendDataHandler::IssueUSATRequest exiting" )
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // From class CSatCommandHandler.
       
   216 // Precheck before executing the command.
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 TBool CSendDataHandler::CommandAllowed()
       
   220     {
       
   221     LOG( SIMPLE, "SendData: CSendDataHandler::CommandAllowed calling" )
       
   222 
       
   223     TBool commandAllowed( ETrue );
       
   224 
       
   225     if ( iUserCancelled )
       
   226         {
       
   227         LOG( SIMPLE, "SendData: CSendDataHandler::CommandAllowed \
       
   228         UserCancelled" )
       
   229         SendTerminalResponse();
       
   230 
       
   231         commandAllowed = EFalse;
       
   232         }
       
   233     else
       
   234         {
       
   235         // Proceed with the command
       
   236         const TInt channelId( iSendDataData.iDestination );
       
   237 
       
   238         if ( ( RSat::KChannel1 > channelId || RSat::KChannel7 < channelId ) ||
       
   239             // If icon data without alpha id
       
   240             ( ( RSat::EAlphaIdProvided !=
       
   241                 iSendDataData.iAlphaId.iStatus ) &&
       
   242             ( ( RSat::ESelfExplanatory ==
       
   243                 iSendDataData.iIconId.iQualifier ) ||
       
   244             ( RSat::ENotSelfExplanatory ==
       
   245                 iSendDataData.iIconId.iQualifier ) ) ) )
       
   246             {
       
   247             LOG( NORMAL, "SendData: CSendDataHandler::CommandAllowed Unknown \
       
   248                 channel identifier or icon without alpha id - Not allowed" )
       
   249             // Create the response IPC package
       
   250             iSendDataRspData.iGeneralResult = RSat::KCmdDataNotUnderstood;
       
   251             iSendDataRspData.iInfoType = RSat::KNoAdditionalInfo;
       
   252             iSendDataRspData.iAdditionalInfo.Zero();
       
   253             commandAllowed = EFalse;
       
   254             }
       
   255         else
       
   256             {
       
   257             RMobilePhone::TMobilePhoneRegistrationStatus registrationStatus(
       
   258                 iUtils->SystemState().GetNetworkRegistrationStatus() );
       
   259 
       
   260             if ( ( RMobilePhone::ERegisteredOnHomeNetwork !=
       
   261                     registrationStatus ) &&
       
   262                  ( RMobilePhone::ERegisteredRoaming != registrationStatus ) )
       
   263                 {
       
   264 
       
   265                 iSendDataRspData.iInfoType = RSat::KMeProblem;
       
   266                 iSendDataRspData.iAdditionalInfo.SetLength( 1 );
       
   267                 iSendDataRspData.iAdditionalInfo[0] = RSat::KNoService;
       
   268                 iSendDataRspData.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   269                 commandAllowed = EFalse;
       
   270                 LOG( NORMAL,
       
   271                     "SendData: CSendDataHandler::CommandAllowed Not allowed" )
       
   272                 }
       
   273             // Set icon command flag whether icon data was received and set qualifier
       
   274             // to no icon id
       
   275             // To be removed when icons are allowed in this command
       
   276             else if ( ( RSat::ESelfExplanatory ==
       
   277                 iSendDataData.iIconId.iQualifier ) ||
       
   278                 ( RSat::ENotSelfExplanatory ==
       
   279                 iSendDataData.iIconId.iQualifier ) )
       
   280                 {
       
   281                 LOG( NORMAL,
       
   282                     "SendData: CSendDataHandler::CommandAllowed ENoIconId" )
       
   283                 iIconCommand = ETrue;
       
   284                 iSendDataData.iIconId.iQualifier = RSat::ENoIconId;
       
   285                 }
       
   286             else
       
   287                 {
       
   288                 LOG( NORMAL,
       
   289                     "SendData: CSendDataHandler::CommandAllowed others" )
       
   290                 iIconCommand = EFalse;
       
   291                 }
       
   292             }
       
   293 
       
   294         if ( !commandAllowed )
       
   295             {
       
   296             LOG( NORMAL,
       
   297             "SendData: CSendDataHandler::CommandAllowed command not allowed" )
       
   298             iSendDataRspData.SetPCmdNumber( iSendDataData.PCmdNumber() );
       
   299             TerminalRsp( RSat::ESendData, iSendDataRspPckg );
       
   300             }
       
   301         }
       
   302 
       
   303     LOG2( SIMPLE, 
       
   304     "SendData: CSendDataHandler::CommandAllowed exiting, commandAllowed: %d", 
       
   305     commandAllowed )
       
   306     return commandAllowed;
       
   307     }
       
   308 
       
   309 // -----------------------------------------------------------------------------
       
   310 // From class CSatCommandHandler.
       
   311 // Need for ui session.
       
   312 // -----------------------------------------------------------------------------
       
   313 //
       
   314 TBool CSendDataHandler::NeedUiSession()
       
   315     {
       
   316     LOG( SIMPLE, "SendData: CSendDataHandler::NeedUiSession calling" )
       
   317 
       
   318     // UI is NOT needed in case where AlphaID is provided and it is a NULL
       
   319     // If information indication to the user is needed and data is not
       
   320     // stored in Tx Buffer, show it now.
       
   321     iNeedUiSession = ( !( RSat::EAlphaIdNull ==
       
   322                           iSendDataData.iAlphaId.iStatus ) &&
       
   323                        !( RSat::EAlphaIdNotPresent ==
       
   324                           iSendDataData.iAlphaId.iStatus ) &&
       
   325                        !( RSat::EStoreDataInTxBuffer ==
       
   326                           iSendDataData.iMode ) );
       
   327     // Send notification to Mediator client if Cover UI is supported
       
   328     if ( iNeedUiSession && iUtils->CoverUiSupported() )
       
   329         {
       
   330         LOG( SIMPLE, 
       
   331             "SendData: CSendDataHandler::NeedUiSession CoverUiSupported" )
       
   332         TSatCommandData medEventData;
       
   333         medEventData.iPCmdNumber = RSat::ESendData;
       
   334         medEventData.iAlphaId = iSendDataData.iAlphaId;
       
   335         medEventData.iDuration.iNumOfUnits = KSatDefaultDuration;
       
   336         medEventData.iIconID = iSendDataData.iIconId;
       
   337         TSatCommandPckg tPckg( medEventData );
       
   338         iUtils->RaiseSatEvent( tPckg );
       
   339         }
       
   340 
       
   341     LOG2( SIMPLE, 
       
   342     "SendData: CSendDataHandler::NeedUiSession exiting,iNeedUiSession: %d",
       
   343     iNeedUiSession )
       
   344     return iNeedUiSession;
       
   345     }
       
   346 
       
   347 // -----------------------------------------------------------------------------
       
   348 // From class CSatCommandHandler.
       
   349 // Called when USAT API notifies that command.
       
   350 // -----------------------------------------------------------------------------
       
   351 //
       
   352 void CSendDataHandler::HandleCommand()
       
   353     {
       
   354     LOG( SIMPLE, "SendData: CSendDataHandler::HandleCommand calling" )
       
   355 
       
   356     // Notify other's about this command executiuon
       
   357     iUtils->NotifyEvent( MSatUtils::ESendDataExecuting );
       
   358     iUtils->NotifyEvent( MSatUtils::EBipCommandExecuting );
       
   359     TInt uiError( KErrNone );
       
   360 
       
   361     if ( iNeedUiSession )
       
   362         {
       
   363         LOG( NORMAL, "SendData: CSendDataHandler::HandleCommand \
       
   364             Sending UI Notification" )
       
   365 
       
   366         uiError = SendUiNotification();
       
   367         }
       
   368     LOG2( NORMAL, "SendData: CSendDataHandler::HandleCommand \
       
   369           uiError: %i", uiError )
       
   370     if ( KErrNone == uiError )
       
   371         {
       
   372         iFreeBuffSize = 0;
       
   373         TInt err( MSatBIPUtils::ESatBIPSuccess );
       
   374 
       
   375         // Get Data Channel
       
   376         iDataChannel = iUtils->BipUtils().DataChannel(
       
   377             iSendDataData.iDestination, err );
       
   378 
       
   379         // Check the SendData mode. If Store, no need for active channel
       
   380         if ( ( iDataChannel ) &&
       
   381              ( RSat::EStoreDataInTxBuffer == iSendDataData.iMode ) )
       
   382             {
       
   383             LOG( NORMAL, "SendData: CSendDataHandler::HandleCommand \
       
   384                  send data" )
       
   385             SendData();
       
   386             }
       
   387         //Check if ch was found and if not active, try to activate
       
   388         else if ( ( iDataChannel ) &&
       
   389                   ( MSatBIPUtils::ESatBIPChannelClosed == err ) )
       
   390             {
       
   391             LOG( NORMAL, "SendData: CSendDataHandler::HandleCommand \
       
   392                 Inactive channel found, try to activate" )
       
   393             TRAP( err, iDataChannel->ActivateConnectionL( this ) );
       
   394 
       
   395             if ( err != KErrNone )
       
   396                 {
       
   397                 LOG2( NORMAL, "SendData: CSendDataHandler::HandleCommand \
       
   398                  Channel activation Failed Error %i", err )
       
   399 
       
   400                 // Get connection info and remove APN from CommDB, if created
       
   401                 // during OpenChannel command
       
   402                 TUint32 apnId( iDataChannel->ConnInfo().iCreatedApnId );
       
   403                 
       
   404                 LOG2( NORMAL, "SendData: CSendDataHandler::HandleCommand \
       
   405                 apnId: %i", apnId )
       
   406                 if ( apnId > 0 )
       
   407                     {
       
   408                     TRAP_IGNORE(
       
   409                         iUtils->BipUtils().ApnHandler().DeleteApnL( apnId ) )
       
   410                     }
       
   411                     
       
   412                 if ( ( KErrMMEtelActivationBlockedByCallControlNoText == err ) ||
       
   413                      ( KErrMMEtelActivationBlockedByCallControlWithText == err ) )
       
   414                     {
       
   415                     err = RSat::KActionNotAllowed;
       
   416                     iSendDataRspData.iGeneralResult = 
       
   417                         RSat::KInteractionWithCCPermanentError;
       
   418                     LOG( DETAILED, "  CC on GPRS not allowed" )
       
   419                     }
       
   420                     
       
   421                 else
       
   422                     {
       
   423                     err = MSatBIPUtils::ESatBIPChannelClosed;
       
   424                     iSendDataRspData.iGeneralResult =
       
   425                         RSat::KBearerIndepProtocolError;
       
   426                     }
       
   427                     
       
   428                 SendTerminalResponse( err );
       
   429                 }
       
   430             }
       
   431         // SendImmediate, Only if Active channel exists
       
   432         else if ( MSatBIPUtils::ESatBIPSuccess == err )
       
   433             {
       
   434             LOG( NORMAL, "SendData: CSendDataHandler::HandleCommand \
       
   435                  SendImmediate" )
       
   436             SendData();
       
   437             }
       
   438         // Active channel doesn't exist
       
   439         else
       
   440             {
       
   441             LOG2( NORMAL, "SendData: CSendData::HandleCommand \
       
   442                     Error %i", err )
       
   443             iSendDataRspData.iGeneralResult = RSat::KBearerIndepProtocolError;
       
   444             SendTerminalResponse( err );
       
   445             }
       
   446         }
       
   447 
       
   448     LOG( SIMPLE, "SendData: CSendDataHandler::HandleCommand exiting" )
       
   449     }
       
   450 
       
   451 // -----------------------------------------------------------------------------
       
   452 // From class CSatCommandHandler.
       
   453 // Indicates the failure of launching ui client.
       
   454 // -----------------------------------------------------------------------------
       
   455 //
       
   456 void CSendDataHandler::UiLaunchFailed()
       
   457     {
       
   458     LOG( SIMPLE, "SendData: CSendDataHandler::UiLaunchFailed calling" )
       
   459 
       
   460     iSendDataRspData.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   461     iSendDataRspData.iInfoType = RSat::KMeProblem;
       
   462     iSendDataRspData.iAdditionalInfo.SetLength( 1 );
       
   463     iSendDataRspData.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem;
       
   464     iSendDataRspData.SetPCmdNumber( iSendDataData.PCmdNumber() );
       
   465     TerminalRsp( RSat::ESendData, iSendDataRspPckg );
       
   466 
       
   467     LOG( SIMPLE, "SendData: CSendDataHandler::UiLaunchFailed exiting" )
       
   468     }
       
   469 
       
   470 // -----------------------------------------------------------------------------
       
   471 // C++ default constructor can NOT contain any code, that
       
   472 // might leave.
       
   473 // -----------------------------------------------------------------------------
       
   474 //
       
   475 //lint -e{1403, 1769} Can not be initialized.
       
   476 CSendDataHandler::CSendDataHandler() :
       
   477     CSatCommandHandler(),
       
   478     iSendDataData(),
       
   479     iSendDataPckg( iSendDataData ),
       
   480     iSendDataRspData(),
       
   481     iSendDataRspPckg( iSendDataRspData ),
       
   482     iSendDataUiData(),
       
   483     iSendDataUiPckg( iSendDataUiData ),
       
   484     iSendDataUiRsp(),
       
   485     iSendDataUiRspPckg( iSendDataUiRsp ),
       
   486     // To be removed when icons are allowed in this command
       
   487     iIconCommand( EFalse )
       
   488     {
       
   489     LOG( SIMPLE,
       
   490         "SendData: CSendDataHandler::CSendDataHandler calling - exiting" )
       
   491     }
       
   492 
       
   493 // -----------------------------------------------------------------------------
       
   494 // Symbian 2nd phase constructor can leave.
       
   495 // -----------------------------------------------------------------------------
       
   496 //
       
   497 void CSendDataHandler::ConstructL()
       
   498     {
       
   499     LOG( SIMPLE, "SendData: CSendDataHandler::ConstructL calling" )
       
   500 
       
   501      // Register to ui service request
       
   502      iUtils->RegisterServiceRequestL( ESatSProactiveNotification,
       
   503         ESatSProactiveNotificationResponse, this );
       
   504 
       
   505     // Register to ui service request
       
   506     // Cancel key event from dialog
       
   507     iUtils->RegisterL( this, MSatUtils::ECommandCancelled );
       
   508 
       
   509     // End key from dialog
       
   510     iUtils->RegisterL( this, MSatUtils::ECancelledUsingEndKey );
       
   511 
       
   512     // Open channel execution
       
   513     iUtils->RegisterL( this, MSatUtils::EOpenChannelExecuting );
       
   514 
       
   515     LOG( SIMPLE, "SendData: CSendDataHandler::ConstructL exiting" )
       
   516     }
       
   517 
       
   518 // -----------------------------------------------------------------------------
       
   519 // Sends data
       
   520 // -----------------------------------------------------------------------------
       
   521 //
       
   522 void CSendDataHandler::SendData()
       
   523     {
       
   524     LOG( SIMPLE, "SendData: CSendDataHandler::SendData calling" )
       
   525 
       
   526     // Indicates the send mode.
       
   527     TBool sendImmediately( RSat::ESendDataImmediately == iSendDataData.iMode );
       
   528     TInt err( MSatBIPUtils::ESatBIPSuccess );
       
   529 
       
   530     TRAPD( error, err = iDataChannel->SendDataL(
       
   531         iSendDataData.iChannelData,
       
   532         sendImmediately,
       
   533         iFreeBuffSize,
       
   534         this ) );
       
   535     LOG2( NORMAL, "SendData: CSendDataHandler::SendData error: %i", error )
       
   536 
       
   537     // Check were the send data success.
       
   538     if ( ( error != KErrNone ) || ( err != MSatBIPUtils::ESatBIPSuccess ) )
       
   539         {
       
   540         LOG2( NORMAL, "SendData: CSendDataHandler::SendData Error %i", err )
       
   541 
       
   542         if ( MSatBIPUtils::ESatBIPServiceError == err )
       
   543             {
       
   544             // Connection suspended
       
   545             iSendDataRspData.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   546             err = RSat::KNoSpecificMeProblem;
       
   547             }
       
   548         else
       
   549             {
       
   550             iSendDataRspData.iGeneralResult = RSat::KBearerIndepProtocolError;
       
   551             }
       
   552 
       
   553         SendTerminalResponse( err );
       
   554         }
       
   555     else if ( !sendImmediately )
       
   556         {
       
   557         // If data is stored, send terminal response, otherwise wait for
       
   558         // notification of data sent.
       
   559         LOG( NORMAL, "SendData: CSendDataHandler::SendData Succeed" )
       
   560         iSendDataRspData.iGeneralResult = RSat::KSuccess;
       
   561         SendTerminalResponse();
       
   562         }
       
   563     else
       
   564         {
       
   565         LOG( NORMAL,
       
   566             "SendData: CSendDataHandler::SendData Waiting send to complete" )
       
   567         }
       
   568 
       
   569     LOG( SIMPLE, "SendData: CSendDataHandler::SendData exiting" )
       
   570     }
       
   571 
       
   572 // -----------------------------------------------------------------------------
       
   573 // Completes Terminal response and sends it
       
   574 // -----------------------------------------------------------------------------
       
   575 //
       
   576 void CSendDataHandler::SendTerminalResponse( const TInt aError )
       
   577     {
       
   578     LOG( SIMPLE, "SendData: CSendDataHandler::SendTerminalResponse calling" )
       
   579 
       
   580     if ( iUserCancelled )
       
   581         {
       
   582         LOG( NORMAL, "SENDDATA: CSendDataHandler::SendTerminalResponse \
       
   583             User cancelled the action" )
       
   584         iSendDataRspData.iGeneralResult = RSat::KPSessionTerminatedByUser;
       
   585         iSendDataRspData.iInfoType = RSat::KNoAdditionalInfo;
       
   586         iSendDataRspData.iAdditionalInfo.Zero();
       
   587         }
       
   588     else if ( RSat::KSuccess == iSendDataRspData.iGeneralResult )
       
   589         {
       
   590         LOG( NORMAL, "SENDDATA: CSendDataHandler::SendTerminalResponse \
       
   591             KSuccess" )
       
   592         iSendDataRspData.iInfoType = RSat::KNoAdditionalInfo;
       
   593         iSendDataRspData.iAdditionalInfo.Zero();
       
   594         if ( iFreeBuffSize > KSatBIPMoreThanMaxSize )
       
   595             {
       
   596             LOG( NORMAL, "SENDDATA: CSendDataHandler::SendTerminalResponse \
       
   597             iFreeBuffSize > KSatBIPMoreThanMaxSize" )
       
   598             iSendDataRspData.iChannelDataLength = KSatBIPMoreThanMaxSize;
       
   599             }
       
   600         else
       
   601             {
       
   602             iSendDataRspData.iChannelDataLength =
       
   603                 static_cast<TUint8> ( iFreeBuffSize );
       
   604             }
       
   605         // If command had icon data and was done succesfully,
       
   606         // report that icon was not shown.
       
   607         // To be removed and correct handling (i.e. ClientResponse to
       
   608         // notification is received) for general result
       
   609         // KSuccessRequestedIconNotDisplayed must be added when icons
       
   610         // are allowed in this command 
       
   611         if ( iIconCommand )
       
   612             {
       
   613             LOG( NORMAL, "SENDDATA: CSendDataHandler::SendTerminalResponse \
       
   614             iIconCommand true" )
       
   615             iSendDataRspData.iGeneralResult =
       
   616                 RSat::KSuccessRequestedIconNotDisplayed;
       
   617             }
       
   618         }
       
   619     else
       
   620         {
       
   621         iSendDataRspData.iInfoType = RSat::KMeProblem;
       
   622         iSendDataRspData.iAdditionalInfo.SetLength( 1 );
       
   623         // Error code from MSatBIPUtils is the same as defined in etelsat.h,
       
   624         // so we can put that error code straigth to additional info
       
   625         iSendDataRspData.iAdditionalInfo[0] = static_cast<TUint8> ( aError );
       
   626         iSendDataRspData.iChannelDataLength = 0;
       
   627         }
       
   628 
       
   629     if ( IsCommandExecuting() )
       
   630         {
       
   631         LOG( NORMAL, "SENDDATA: CSendDataHandler::SendTerminalResponse \
       
   632             IsCommandExecuting true" )
       
   633         iSendDataRspData.SetPCmdNumber( iSendDataData.PCmdNumber() );
       
   634 
       
   635         // Send terminal response
       
   636         iUtils->NotifyEvent( MSatUtils::EDelaySimSessionEnd );
       
   637         iUtils->USatAPI().TerminalRsp( RSat::ESendData, iSendDataRspPckg );
       
   638         Start();
       
   639         }
       
   640 
       
   641     LOG( SIMPLE, "SendData: CSendDataHandler::::SendTerminalResponse exiting" )
       
   642     }
       
   643     
       
   644 // -----------------------------------------------------------------------------
       
   645 // Sends notification to UI
       
   646 // -----------------------------------------------------------------------------
       
   647 //
       
   648 TInt CSendDataHandler::SendUiNotification()
       
   649     {
       
   650     LOG( NORMAL, "SendData: CSendDataHandler::SendUiNotification calling" )
       
   651 
       
   652     // Register to ui service request
       
   653     TRAPD( uiError, iUtils->RegisterServiceRequestL(
       
   654         ESatSProactiveNotification,
       
   655         ESatSProactiveNotificationResponse, this ) );
       
   656     LOG2( NORMAL, "CSendDataHandler::SendUiNotification uiError %i", uiError )
       
   657     // Check UI error
       
   658     if ( KErrNone == uiError )
       
   659         {
       
   660         // Create IPC data to UI
       
   661         iSendDataUiData.iCommand = ESatSSendDataNotify;
       
   662 
       
   663         iSendDataUiData.iText = iSendDataData.iAlphaId.iAlphaId;
       
   664         iSendDataUiData.iIconId.iIdentifier =
       
   665             iSendDataData.iIconId.iIdentifier;
       
   666         LOG2( NORMAL, "CSendDataHandler::SendUiNotification \
       
   667               iSendDataData.iIconId.iQualifier: %i",
       
   668               iSendDataData.iIconId.iQualifier )
       
   669         // Define icon qualifier
       
   670         if ( RSat::ENotSelfExplanatory == iSendDataData.iIconId.iQualifier )
       
   671             {
       
   672             iSendDataUiData.iIconId.iIconQualifier = ESatNotSelfExplanatory;
       
   673             }
       
   674         else if ( RSat::ESelfExplanatory == iSendDataData.iIconId.iQualifier )
       
   675             {
       
   676             iSendDataUiData.iIconId.iIconQualifier = ESatSelfExplanatory;
       
   677             }
       
   678         else // Icon qualifier not present
       
   679             {
       
   680             iSendDataUiData.iIconId.iIconQualifier = ESatENoIconId;
       
   681             }
       
   682         LOG2( NORMAL, "CSendDataHandler::SendUiNotification \
       
   683               iSendDataData.iAlphaId.iStatus: %i",
       
   684               iSendDataData.iAlphaId.iStatus )
       
   685         // Define AlphaID status
       
   686         switch ( iSendDataData.iAlphaId.iStatus )
       
   687             {
       
   688             case RSat::EAlphaIdNotPresent:
       
   689                 {
       
   690                 iSendDataUiData.iAlphaIdStatus = ESatAlphaIdNotProvided;
       
   691                 break;
       
   692                 }
       
   693 
       
   694             case RSat::EAlphaIdProvided:
       
   695                 {
       
   696                 iSendDataUiData.iAlphaIdStatus = ESatAlphaIdNotNull;
       
   697                 break;
       
   698                 }
       
   699 
       
   700             default:
       
   701                 {
       
   702                 iSendDataUiData.iAlphaIdStatus = ESatAlphaIdNull;
       
   703                 break;
       
   704                 }
       
   705             }
       
   706 
       
   707         // Send notification to UI
       
   708         MSatUiSession* session = iUtils->SatUiHandler().UiSession();
       
   709         session->SendCommand( &iSendDataUiPckg,
       
   710                               &iSendDataUiRspPckg,
       
   711                               ESatSProactiveNotification );
       
   712         }
       
   713     else
       
   714         {
       
   715         // Send error terminal response
       
   716         iSendDataRspData.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   717         SendTerminalResponse( RSat::KNoSpecificMeProblem );
       
   718         }
       
   719 
       
   720     LOG( NORMAL, "SendData: CSendDataHandler::SendUiNotification exiting" )
       
   721     return uiError;
       
   722     }
       
   723