telephonyserverplugins/simatktsy/src/CSatNotifySetUpCall.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
child 42 3adadc800673
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name        : CSatNotifySetUpCall.cpp
       
    15 // Part of     : Common SIM ATK TSY / commonsimatktsy
       
    16 // Set Up call notification functionality of Sat Tsy
       
    17 // Version     : 1.0
       
    18 //
       
    19 
       
    20 
       
    21 
       
    22 //INCLUDES
       
    23 #include <satcs.h>                  // Etel SAT IPC definitions
       
    24 #include "CSatTsy.h"                // Tsy class header
       
    25 #include "CSatNotifySetUpCall.h"    // Tsy class header
       
    26 #include "CSatNotificationsTsy.h"   // Class header
       
    27 #include "CBerTlv.h"                // Ber Tlv data handling
       
    28 #include "TTlv.h"					// TTlv class
       
    29 #include "CSatDataPackage.h"        // Parameter packing 
       
    30 #include "TfLogger.h"               // For TFLOGSTRING
       
    31 #include "TSatUtility.h"            // Utilities
       
    32 #include "CSatTsyReqHandleStore.h"  // Request handle class
       
    33 #include "cmmmessagemanagerbase.h"  // Message manager class for forwarding req.
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CSatNotifySetupCall::CSatNotifySetupCall
       
    37 // Constructor
       
    38 // -----------------------------------------------------------------------------
       
    39 //  
       
    40 CSatNotifySetUpCall* CSatNotifySetUpCall::NewL
       
    41         ( 
       
    42         CSatNotificationsTsy* aNotificationsTsy 
       
    43         )
       
    44     {
       
    45     TFLOGSTRING("CSAT: CSatNotifySetupCall::NewL"); 
       
    46     CSatNotifySetUpCall* const satNotifySetUpCall = 
       
    47         new ( ELeave ) CSatNotifySetUpCall( aNotificationsTsy );
       
    48     CleanupStack::PushL( satNotifySetUpCall );
       
    49     satNotifySetUpCall->ConstructL();
       
    50     CleanupStack::Pop( satNotifySetUpCall );
       
    51     TFLOGSTRING("CSAT: CSatNotifySetupCall::NewL, end of method"); 
       
    52     return satNotifySetUpCall;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CSatNotifySetupCall::~CSatNotifySetupCall
       
    57 // Destructor
       
    58 // -----------------------------------------------------------------------------
       
    59 //  
       
    60 CSatNotifySetUpCall::~CSatNotifySetUpCall
       
    61         (
       
    62         // None
       
    63         )
       
    64     {
       
    65     TFLOGSTRING("CSAT: CSatNotifySetupCall::~CSatNotifySetUpCall"); 
       
    66     }
       
    67         
       
    68 // -----------------------------------------------------------------------------
       
    69 // CSatNotifySetupCall::CSatNotifySetupCall
       
    70 // Constructor
       
    71 // -----------------------------------------------------------------------------
       
    72 //  
       
    73 CSatNotifySetUpCall::CSatNotifySetUpCall
       
    74         ( 
       
    75         CSatNotificationsTsy* aNotificationsTsy 
       
    76         ) : iNotificationsTsy ( aNotificationsTsy ), iCCResult( 0 )
       
    77     {
       
    78     // None
       
    79     }
       
    80     
       
    81 // -----------------------------------------------------------------------------
       
    82 // CSatNotifySetupCall::CSatNotifySetupCall
       
    83 // Constructor
       
    84 // -----------------------------------------------------------------------------
       
    85 //  
       
    86 void CSatNotifySetUpCall::ConstructL
       
    87         ( 
       
    88         // None
       
    89         )
       
    90     {
       
    91     TFLOGSTRING("CSAT: CSatNotifySetupCall::ConstructL"); 
       
    92     iCallConnectedEvent.Zero();
       
    93     }
       
    94     
       
    95 // -----------------------------------------------------------------------------
       
    96 // CSatNotifySetupCall::Notify
       
    97 // Save the request handle type for notification requested by ETel server
       
    98 // -----------------------------------------------------------------------------
       
    99 // 
       
   100 TInt CSatNotifySetUpCall::Notify
       
   101         ( 
       
   102         const TTsyReqHandle aTsyReqHandle,
       
   103         const TDataPackage& aPackage   
       
   104         )
       
   105     {
       
   106     TFLOGSTRING("CSAT: CSatNotifySetupCall::Notify"); 
       
   107     // Save data pointer to client side for completion
       
   108     iSetUpCallV1Pckg = reinterpret_cast<RSat::TSetUpCallV1Pckg*>( 
       
   109         aPackage.Des1n() );
       
   110     // Save the request handle
       
   111     iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, 
       
   112 		CSatTsy::ESatNotifySetUpCallPCmdReqType );   
       
   113     TFLOGSTRING2("CSAT: CSatNotifySetUpCall::Notify\t Handle:%d",
       
   114            aTsyReqHandle);
       
   115     // Check if requested notification is already pending
       
   116     iNotificationsTsy->NotifySatReadyForNotification( KSetUpCall );   
       
   117 
       
   118     return KErrNone;
       
   119     }
       
   120 
       
   121 
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CSatNotifySetupCall::CancelNotification
       
   125 // This method cancels an outstanding asynchronous 
       
   126 // NotifySetUpCall request.
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 TInt CSatNotifySetUpCall::CancelNotification
       
   130         (
       
   131         const TTsyReqHandle aTsyReqHandle
       
   132         )
       
   133     {
       
   134     TFLOGSTRING("CSAT: CSatNotifySetUpCall::CancelNotification");   
       
   135     // Reset the request handle 
       
   136     iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( 
       
   137         CSatTsy::ESatNotifySetUpCallPCmdReqType );
       
   138     // Reset the data pointer
       
   139     iSetUpCallV1Pckg = NULL;    
       
   140     // Complete the request with KErrCancel
       
   141     iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
       
   142 
       
   143     return KErrNone;      
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CSatNotifySetupCall::CompleteNotifyL
       
   148 // This method completes an outstanding asynchronous 
       
   149 // SetUpCall request. 
       
   150 // -----------------------------------------------------------------------------
       
   151 // 
       
   152 TInt CSatNotifySetUpCall::CompleteNotifyL
       
   153         ( 
       
   154         CSatDataPackage* aDataPackage,
       
   155         TInt aErrorCode  
       
   156         ) 
       
   157     {
       
   158     TFLOGSTRING("CSAT: CSatNotifySetupCall::CompleteNotifyL");
       
   159     TInt returnValue( KErrNone );
       
   160     TInt ret( KErrNone );
       
   161     iCCResult = 0;
       
   162     // Unpack parameters
       
   163     TPtrC8* data;
       
   164     aDataPackage->UnPackData( &data );
       
   165 	TBuf<1> additionalInfo;
       
   166     // Reset req handle. Returns the deleted req handle
       
   167     TTsyReqHandle reqHandle = 
       
   168         iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( 
       
   169         CSatTsy::ESatNotifySetUpCallPCmdReqType );
       
   170     
       
   171     // Get ber tlv 
       
   172     CBerTlv berTlv;
       
   173     berTlv.SetData( *data );
       
   174     // Get command details tlv
       
   175     CTlv commandDetails;
       
   176     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
   177     
       
   178     // Store command details tlv
       
   179     iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( 
       
   180     	commandDetails.Data() );
       
   181     
       
   182     TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
   183                 
       
   184     TFLOGSTRING2("CSAT: CSatNotifySetUpCall::CompleteNotifyL\t Handle:%d",
       
   185            reqHandle);
       
   186     // In case the request was ongoing, continue..
       
   187     if ( CSatTsy::ESatReqHandleUnknown  != reqHandle )
       
   188         {
       
   189         // Complete right away if error has occured, otherwise continue..
       
   190         if ( KErrNone == aErrorCode )
       
   191             {
       
   192             // Fill the Set Up Call structure
       
   193             RSat::TSetUpCallV1& setUpCallV1 = ( *iSetUpCallV1Pckg )();
       
   194 
       
   195             // Transaction ID
       
   196             setUpCallV1.SetPCmdNumber( pCmdNumber );
       
   197             
       
   198             TFLOGSTRING2("CSAT: CSatNotifySetupCall::CompleteNotifyL \
       
   199             	CommandQualifier %d", iNotificationsTsy->iTerminalRespData.
       
   200             	iCommandDetails[ KCommandQualifier ]);
       
   201 
       
   202             switch ( iNotificationsTsy->iTerminalRespData.
       
   203             		iCommandDetails[ KCommandQualifier ] )
       
   204                 {
       
   205                 case KOnlyIfNotBusy:
       
   206                     {
       
   207                     // Set up call, if not busy on another call
       
   208                     setUpCallV1.iType = RSat::EOnlyIfNotBusy;
       
   209                     break;
       
   210                     }
       
   211                 case KOnlyIfNotBusyWithRedial:
       
   212                     {
       
   213                     // Set up call, if not busy on another call, with redial
       
   214                     setUpCallV1.iType = RSat::EOnlyIfNotBusyWithRedial;
       
   215                     break;
       
   216                     }
       
   217                 case KHoldOtherCalls:
       
   218                     {
       
   219                     // Set up call, put other calls (if any) on hold
       
   220                     setUpCallV1.iType = RSat::EHoldOtherCalls;
       
   221                     break;
       
   222                     }
       
   223                 case KHoldOtherCallsWithRedial:
       
   224                     {
       
   225                     // Set up call, put other calls (if any) on hold, with 
       
   226                     // redial
       
   227                     setUpCallV1.iType = RSat::EHoldOtherCallsWithRedial;
       
   228                     break;
       
   229                     }
       
   230                 case KDisconnectOtherCalls:
       
   231                     {
       
   232                     // Set up call, disconnect other calls (if any)
       
   233                     setUpCallV1.iType = RSat::EDisconnectOtherCalls;
       
   234                     break;
       
   235                     }
       
   236                 case KDisconnectOtherCallsWithRedial:
       
   237                     {
       
   238                     // Set up call, disconn. other calls (if any), with redial
       
   239                     setUpCallV1.iType = RSat::EDisconnectOtherCallsWithRedial;
       
   240                     break;
       
   241                     }
       
   242                 default:
       
   243                     {
       
   244                     TFLOGSTRING("CSAT: CSatNotifySetupCall::CompleteNotifyL,\
       
   245                         Call type not set");
       
   246                     // Call type not set
       
   247                     setUpCallV1.iType = RSat::ESetUpCallTypeNotSet;
       
   248                     break;
       
   249                     }
       
   250                 }    
       
   251 
       
   252             TPtrC8 sourceString; // Used with conversions
       
   253 
       
   254             // Alpha id string (optional)
       
   255             setUpCallV1.iAlphaIdConfirmationPhase.iAlphaId.Zero();
       
   256 
       
   257              // Call setup phase alphaid (optional)
       
   258             setUpCallV1.iAlphaIdCallSetUpPhase.iAlphaId.Zero();
       
   259 
       
   260             CTlv alphaIdentifier;
       
   261             // Check alpha identifiers (for user confirmation phase and call set 
       
   262             // up phase )
       
   263             returnValue = berTlv.TlvByTagValue( &alphaIdentifier, 
       
   264                                                 KTlvAlphaIdentifierTag );
       
   265             // If alpha id string exist
       
   266             if ( KErrNone == returnValue ) 
       
   267                 {
       
   268                 // First alpha identifier is for user confirmation phase
       
   269                 if ( alphaIdentifier.GetLength() )
       
   270                     {
       
   271                     // Set status
       
   272                     setUpCallV1.iAlphaIdConfirmationPhase.iStatus =
       
   273                         RSat::EAlphaIdProvided;
       
   274 
       
   275                      // Get alpha id string
       
   276                     sourceString.Set( alphaIdentifier.GetData( 
       
   277                         ETLV_AlphaIdentifier ) );
       
   278                     TFLOGSTRING2("CSAT: CSatNotifySetupCall::CompleteNotifyL User \
       
   279                         confirmation phase: sourceString %s", 
       
   280                         &sourceString );               
       
   281                     // Convert and set the alpha id
       
   282                     TSatUtility::SetAlphaId( sourceString ,
       
   283                         setUpCallV1.iAlphaIdConfirmationPhase.iAlphaId ); 
       
   284                 
       
   285                     }
       
   286                 // Alpha id found for user confirmation phase, but length 
       
   287                 // is zero
       
   288                 else
       
   289                     {
       
   290                     TFLOGSTRING("CSAT: CSatNotifySetupCall::CompleteNotifyL \
       
   291                         User confirmation phase: Alpha Id missing");
       
   292                     setUpCallV1.iAlphaIdConfirmationPhase.iStatus = 
       
   293                         RSat::EAlphaIdNull;
       
   294                     }
       
   295                 }
       
   296             // No alpha id for user confirmation phase
       
   297             else
       
   298                 {
       
   299                 TFLOGSTRING("CSAT: CSatNotifySetupCall::CompleteNotifyL,\
       
   300                     User confirmation phase: Alpha ID not present");
       
   301                 setUpCallV1.iAlphaIdConfirmationPhase.iStatus = 
       
   302                     RSat::EAlphaIdNotPresent;
       
   303                 }  
       
   304 
       
   305             // Get alpha identifier for call set up phase
       
   306             returnValue = berTlv.TlvByTagValue( &alphaIdentifier, 
       
   307                                                 KTlvAlphaIdentifierTag, 1 );
       
   308             // If alpha id string exist
       
   309             if ( KErrNone == returnValue )
       
   310                 {
       
   311                 // Second alpha identifier is for call set up phase 
       
   312                 if ( alphaIdentifier.GetLength() )
       
   313                     {
       
   314                     // Set status
       
   315                     setUpCallV1.iAlphaIdCallSetUpPhase.iStatus = 
       
   316                         RSat::EAlphaIdProvided;
       
   317                      // Get alpha id string
       
   318                     sourceString.Set( alphaIdentifier.GetData( 
       
   319                         ETLV_AlphaIdentifier ) );
       
   320                     TFLOGSTRING2("CSAT: CSatNotifySetupCall::CompleteNotifyL \
       
   321                         Call Set Up phase: sourceString %s",
       
   322                         &sourceString );
       
   323                     // Convert and set the alpha id
       
   324                     TSatUtility::SetAlphaId( sourceString,
       
   325                         setUpCallV1.iAlphaIdCallSetUpPhase.iAlphaId ); 
       
   326 
       
   327                     }
       
   328                 // Alpha id found for set up call phase,  but length is zero
       
   329                 else
       
   330                     {
       
   331                     TFLOGSTRING("CSAT: CSatNotifySetupCall::CompleteNotifyL \
       
   332                         Call Set Up phase: Alpha Id is NULL"); 
       
   333                     setUpCallV1.iAlphaIdCallSetUpPhase.iStatus = 
       
   334                         RSat::EAlphaIdNull;
       
   335                     }
       
   336                 }
       
   337    
       
   338             // No alpha id set up call phase
       
   339             else
       
   340                 {
       
   341                 TFLOGSTRING("CSAT: CSatNotifySetupCall::CompleteNotifyL,\
       
   342                     Alpha ID not present");
       
   343                 setUpCallV1.iAlphaIdCallSetUpPhase.iStatus = 
       
   344                     RSat::EAlphaIdNotPresent;
       
   345                 }  
       
   346 
       
   347             // First icon for user confirmation phase
       
   348             TSatUtility::FillIconStructure( 
       
   349                 berTlv, setUpCallV1.iIconIdConfirmationPhase, 0 );
       
   350 
       
   351             // Second icon for set up call phase
       
   352             TSatUtility::FillIconStructure( 
       
   353                 berTlv, setUpCallV1.iIconIdCallSetUpPhase, 1 );
       
   354 
       
   355             // Expecting address
       
   356             CTlv addressTlv;
       
   357             returnValue = berTlv.TlvByTagValue( &addressTlv, 
       
   358                                                 KTlvAddressTag );
       
   359             if ( KErrNone == returnValue && addressTlv.GetLength() )
       
   360                 {
       
   361                 // Initialize ton and npi
       
   362                 RSat::TTypeOfNumber ton( RSat::EUnknownNumber );
       
   363                 RSat::TNumberingPlan npi( RSat::EUnknownNumberingPlan );
       
   364 
       
   365                 // Call utility function that maps received TON and NPI to 
       
   366                 // RSat values
       
   367                 TSatUtility::TonAndNpi( 
       
   368                     addressTlv.GetShortInfo( ETLV_TonAndNpi ) , &ton, &npi );
       
   369             
       
   370                 // Set TON and NPI
       
   371                 setUpCallV1.iAddress.iTypeOfNumber = ton;
       
   372                 setUpCallV1.iAddress.iNumberPlan = npi;
       
   373             
       
   374                 // Address
       
   375                 setUpCallV1.iAddress.iTelNumber.Zero();
       
   376                 // Length is number of BCD characters, 
       
   377                 // multiply by two to get real length and - 2 for ton&npi
       
   378                 TUint8 dialNumberLength( (TUint8) ( ( 
       
   379                     addressTlv.GetLength() * 2 ) - 2 ) );
       
   380             
       
   381                 if ( dialNumberLength )
       
   382                     {   
       
   383                     // Semi-octet presentation used
       
   384                     sourceString.Set( addressTlv.GetData( 
       
   385                         ETLV_DiallingNumberString ) );
       
   386 
       
   387                     TBuf8<RSat::KMaxMobileTelNumberSize> tempNumber;
       
   388                     // Convert BCD string to ASCII        
       
   389                     TSatUtility::BCDToAscii( sourceString, tempNumber );
       
   390             
       
   391                     sourceString.Set( tempNumber );
       
   392 
       
   393                     // Add '+' character to the preceding of international number
       
   394                     if ( ( RSat::EInternationalNumber == 
       
   395                     	setUpCallV1.iAddress.iTypeOfNumber )
       
   396                             && (KPlusMarkCharacterCode != sourceString[0] )
       
   397                             && ( RSat::KMaxMobileTelNumberSize > dialNumberLength ) )
       
   398                         {
       
   399                         _LIT8( KPlusMark, "+");
       
   400                         tempNumber.Insert( 0, KPlusMark );
       
   401                         sourceString.Set( tempNumber );
       
   402                         }
       
   403 
       
   404                     // The command may also include DTMF digits, which the ME shall
       
   405                     // send to the network after the call has connected. 
       
   406                     // Remove wild and expansion digits.
       
   407                     TSatUtility::RemoveWildAndExpansionDigit( sourceString, 
       
   408                         tempNumber );
       
   409                     // Set actual number
       
   410                     setUpCallV1.iAddress.iTelNumber.Copy( tempNumber );
       
   411 
       
   412                     TFLOGSTRING2("CSAT: CSatNotifySetUpCall::CompleteNotifyL, \
       
   413                     	TelNumber: %S", &setUpCallV1.iAddress.iTelNumber );
       
   414                     	
       
   415                     iNotificationsTsy->iSatTsy->StoreProactiveAddress( 
       
   416                         &tempNumber );
       
   417                     }
       
   418                 }
       
   419             else
       
   420                 {
       
   421                 TFLOGSTRING("CSAT: CSatNotifySetupCall::CompleteNotifyL,\
       
   422                     Request not ongoing");
       
   423                 additionalInfo.Zero();
       
   424                 additionalInfo.Append( KNoCause );
       
   425                 // Request not on, returning response immediately
       
   426                 CreateTerminalRespL( pCmdNumber, RSat::KCmdDataNotUnderstood,
       
   427                     additionalInfo ); 
       
   428                 ret = KErrCorrupt;
       
   429                 }
       
   430 
       
   431             // Bearer capability
       
   432             setUpCallV1.iCapabilityConfigParams.Zero();
       
   433             CTlv capabilityConfig;
       
   434             returnValue = berTlv.TlvByTagValue( &capabilityConfig, 
       
   435                 KTlvCapabilityConfigurationParametersTag );
       
   436 
       
   437             if ( ( KErrNone == returnValue )
       
   438                 && ( capabilityConfig.GetLength() ) )
       
   439                 {
       
   440                 // iCapabilityConfigParams is 8-bit string
       
   441                 setUpCallV1.iCapabilityConfigParams.Append( capabilityConfig.
       
   442                     GetData( ETLV_CapabilityConfigurationParameters ) );
       
   443 
       
   444                 TFLOGSTRING2("CSAT: CSatNotifySetUpCall::CompleteNotifyL, \
       
   445                    CapabilityParams: %s", &setUpCallV1.iCapabilityConfigParams );
       
   446                 }
       
   447 
       
   448             // Called Party SubAddress
       
   449             setUpCallV1.iSubAddress.Zero();
       
   450             CTlv subAddress;
       
   451             returnValue = berTlv.TlvByTagValue( &subAddress, KTlvSubaddressTag );
       
   452         
       
   453             if ( ( KErrNone == returnValue )
       
   454                 && ( subAddress.GetLength() ) )
       
   455                 {   
       
   456                 // Source is 8-bit string, converting to 16-bit
       
   457                 sourceString.Set( subAddress.GetData( ETLV_SubAddress) );
       
   458                 // The Authority and Format Identifier code 50 (in BCD) 
       
   459                 // indicates that the subaddress consists of IA5 characters
       
   460                 if ( KAuthorityFormatIdentifier == sourceString[1] )
       
   461                     {
       
   462                     TInt i( 0 );
       
   463                     for ( i = 2; i < sourceString.Length(); i++ )
       
   464                         {
       
   465                         // IA5 character as defined in ITU-T Recommendation 
       
   466                         // T.50/ISO 646 and then encoded into two semi-octets 
       
   467                         // according to the "preferred binary encoding" 
       
   468                         // defined in X.213/ISO 8348 AD2.
       
   469                         setUpCallV1.iSubAddress.Append( KZeroCharacterCode + 
       
   470                             ( ( sourceString[i] & 0xF0  ) >> 4 ) );
       
   471                         setUpCallV1.iSubAddress.Append( KZeroCharacterCode + 
       
   472                             ( sourceString[i] & 0x0F ) );
       
   473                         }
       
   474                     }
       
   475                 else
       
   476                     {
       
   477 
       
   478                     TSatUtility::Copy8to16LE( sourceString, 
       
   479                         setUpCallV1.iSubAddress );
       
   480                     }
       
   481                 
       
   482                 TFLOGSTRING2("CSAT: CSatNotifySetUpCall, SubAddress: %S", 
       
   483                     &setUpCallV1.iSubAddress );
       
   484                 }
       
   485 
       
   486             // Duration ( optional, maximum duration for the redial mechanism )
       
   487             CTlv callDuration;
       
   488             returnValue = berTlv.TlvByTagValue( &callDuration, 
       
   489                                                 KTlvDurationTag );
       
   490             if ( KErrNone == returnValue )
       
   491                 {
       
   492                 TInt durationTimeUnit( callDuration.GetShortInfo( 
       
   493                     ETLV_TimeUnit ) );
       
   494                 switch ( durationTimeUnit )
       
   495                     {
       
   496                     case KMinutes:
       
   497                         {
       
   498                         setUpCallV1.iDuration.iTimeUnit = RSat::EMinutes;
       
   499                         break;
       
   500                         }
       
   501                     case KSeconds:
       
   502                         {
       
   503                         setUpCallV1.iDuration.iTimeUnit = RSat::ESeconds;
       
   504                         break;
       
   505                         }
       
   506                     case KTenthsOfSeconds:
       
   507                         {
       
   508                         setUpCallV1.iDuration.iTimeUnit = 
       
   509                             RSat::ETenthsOfSeconds;
       
   510                         break;
       
   511                         }
       
   512                     default:
       
   513                         {
       
   514                         TFLOGSTRING("CSAT: CSatNotifySetupCall::\
       
   515                             CompleteNotifyL, time unit not set");
       
   516                         setUpCallV1.iDuration.iTimeUnit = 
       
   517                             RSat::ETimeUnitNotSet;
       
   518                         break;
       
   519                         }
       
   520                     }
       
   521             
       
   522                 // Time interval, valid range 1-255 (0x01 - 0xFF)
       
   523                 setUpCallV1.iDuration.iNumOfUnits = 
       
   524                     callDuration.GetShortInfo( ETLV_TimeInterval );
       
   525 
       
   526                 TFLOGSTRING("CSAT: CSatNotifySetUpCall::CompleteNotifyL Max \
       
   527                 	Duration for the Redial Mechanism" );
       
   528 
       
   529                 // Check that Time interval value is not invalid
       
   530                 if ( NULL == setUpCallV1.iDuration.iNumOfUnits )
       
   531                     {
       
   532                     // Set value to valid range
       
   533                     setUpCallV1.iDuration.iNumOfUnits = 0x1;    
       
   534                     }
       
   535                 }
       
   536             // Set SetUpCall flag on for Call connected event. To avoid situation
       
   537             // that event is send before terminal response
       
   538             if ( KErrNone == ret )
       
   539                 {
       
   540                 iNotificationsTsy->iSatTsy->SetSetUpCallStatus( ETrue );
       
   541                 }
       
   542             
       
   543             } // if ( KErrNone == aErrorCode )
       
   544         else
       
   545         	{
       
   546         	ret = aErrorCode;
       
   547         	}
       
   548         iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret );
       
   549         }        
       
   550     else
       
   551         {
       
   552         TFLOGSTRING("CSAT: CSatNotifySetupCall::CompleteNotifyL,\
       
   553             Request not ongoing");
       
   554         additionalInfo.Zero();
       
   555         additionalInfo.Append( KNoCause );
       
   556         // Request not on, returning response immediately
       
   557         CreateTerminalRespL( pCmdNumber, 
       
   558                 RSat::KMeUnableToProcessCmd,
       
   559                 additionalInfo ); 
       
   560         }
       
   561     return returnValue;
       
   562     }
       
   563 
       
   564 // -----------------------------------------------------------------------------
       
   565 // CSatNotifySetupCall::TerminalResponseL
       
   566 // Called by ETel server, passes terminal response to SIM card
       
   567 // -----------------------------------------------------------------------------
       
   568 //
       
   569 TInt CSatNotifySetUpCall::TerminalResponseL
       
   570         ( 
       
   571         TDes8* aRsp
       
   572         )
       
   573     {
       
   574     TFLOGSTRING("CSAT:CSatNotifySetUpCall::TerminalResponseL");
       
   575 
       
   576     TInt    ret( KErrNone );
       
   577     TBuf<1> additionalInfo;
       
   578 
       
   579     RSat::TSetUpCallRspV2Pckg* aRspPckg = 
       
   580             reinterpret_cast<RSat::TSetUpCallRspV2Pckg*>( aRsp );
       
   581     RSat::TSetUpCallRspV2& rspV2 = ( *aRspPckg ) ();
       
   582 
       
   583     // Proactive command number
       
   584     TUint8 pCmdNumber( rspV2.PCmdNumber() );
       
   585 
       
   586     // Check that general result values are valid
       
   587     if ( ( RSat::KSuccess != rspV2.iGeneralResult ) 
       
   588         && ( RSat::KSuccessRequestedIconNotDisplayed != rspV2.iGeneralResult )
       
   589         && ( RSat::KPSessionTerminatedByUser != rspV2.iGeneralResult )
       
   590         && ( RSat::KMeUnableToProcessCmd != rspV2.iGeneralResult )
       
   591         && ( RSat::KNetworkUnableToProcessCmd != rspV2.iGeneralResult )
       
   592         && ( RSat::KPCmdNotAcceptedByUser != rspV2.iGeneralResult )
       
   593         && ( RSat::KCallClearedBeforeConnectionOrReleased 
       
   594             != rspV2.iGeneralResult )
       
   595         && ( RSat::KCmdBeyondMeCapabilities  != rspV2.iGeneralResult )
       
   596         && ( RSat::KSsReturnError != rspV2.iGeneralResult )
       
   597         && ( RSat::KErrorRequiredValuesMissing != rspV2.iGeneralResult ) 
       
   598         && ( RSat::KInteractionWithCCPermanentError != rspV2.iGeneralResult) )
       
   599         {
       
   600         TFLOGSTRING("CSAT:CSatNotifySetUpCall::TerminalResponseL,\
       
   601             Invalid General Result");
       
   602         // Invalid general result
       
   603         ret = KErrCorrupt;
       
   604         }
       
   605 
       
   606     // If there is Me (Mobile Entity) error or network error,
       
   607     // additional info is needed
       
   608     if ( ( RSat::KSatNetworkErrorInfo == rspV2.iInfoType )
       
   609         || ( RSat::KMeProblem == rspV2.iInfoType ) )
       
   610         {
       
   611         // Check the length of additional info
       
   612         if ( rspV2.iAdditionalInfo.Length() )
       
   613             {
       
   614             additionalInfo.Zero();
       
   615             additionalInfo.Append( static_cast<TUint8>( 
       
   616                 rspV2.iAdditionalInfo[0] ) );
       
   617             }
       
   618         else
       
   619             {
       
   620             TFLOGSTRING("CSAT:CSatNotifySetUpCall::TerminalResponseL,\
       
   621                 Invalid Additional Info");
       
   622             ret = KErrCorrupt;
       
   623             }
       
   624         }
       
   625         
       
   626     iNotificationsTsy->iSatTsy->StoreProactiveAddress( NULL );
       
   627 
       
   628     // Creating the terminal response message
       
   629     CreateTerminalRespL( pCmdNumber, 
       
   630     	static_cast<TUint8>( rspV2.iGeneralResult ), additionalInfo );  
       
   631 
       
   632     // Clear flag
       
   633     iNotificationsTsy->iSatTsy->SetSetUpCallStatus( EFalse );
       
   634     
       
   635     // In the case of a call initiated through a SET UP CALL proactive command
       
   636     // while the call connected event is part of the current event list, the 
       
   637     // ME shall send both the TERMINAL RESPONSE related to the proactive 
       
   638     // command, and the EVENT DOWNLOAD command, in the order TERMINAL RESPONSE 
       
   639     // first, ENVELOPE(EVENT DOWNLOAD - call connected) second. 
       
   640 
       
   641     // Check if there is stored envelope in the buffer
       
   642     if ( iCallConnectedEvent.Length() )
       
   643         {
       
   644         // Pack data
       
   645         CSatDataPackage dataPackage;
       
   646 	    dataPackage.PackData( &iCallConnectedEvent);
       
   647         // Send envelope..
       
   648         iNotificationsTsy->iSatTsy->MessageManager()->
       
   649             HandleRequestL(ESatNotifySetUpCallPCmd, &dataPackage );
       
   650         // Clear the buffer
       
   651         iCallConnectedEvent.Zero();
       
   652         }
       
   653         
       
   654     return ret;
       
   655     }
       
   656 
       
   657 // -----------------------------------------------------------------------------
       
   658 // CSatNotifySetupCall::CreateTerminalRespL
       
   659 // Constructs SetUpCall specific part of terminal response and calls 
       
   660 // DOS to send the actual message. 
       
   661 // -----------------------------------------------------------------------------
       
   662 //
       
   663 TInt CSatNotifySetUpCall::CreateTerminalRespL
       
   664         ( 
       
   665         TUint8  aPCmdNumber,         
       
   666         TUint8  aGeneralResult,      
       
   667         TDesC16& aAdditionalInfo            
       
   668 		)
       
   669     {
       
   670     TFLOGSTRING("CSAT: CSatNotifySetUpCall::CreateTerminalRespL");    
       
   671     // Create and append response data
       
   672     TTlv tlvSpecificData;
       
   673     tlvSpecificData.AddTag( KTlvResultTag );
       
   674     // Result
       
   675     tlvSpecificData.AddByte( aGeneralResult );
       
   676     
       
   677     if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult ) ||
       
   678          ( RSat::KSuccessRequestedIconNotDisplayed == aGeneralResult ) || 
       
   679          ( RSat::KNetworkUnableToProcessCmd == aGeneralResult ) || 
       
   680          ( RSat::KInteractionWithCCPermanentError == aGeneralResult ) )
       
   681         {
       
   682         if ( aAdditionalInfo.Length() )
       
   683             {
       
   684             tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[0] ) );
       
   685             }
       
   686         else
       
   687             {
       
   688             TFLOGSTRING( "CSAT: CSatNotifySetUpCall::CreateTerminalRespL \
       
   689                 aAdditionalInfo.Length() == 0" ); 
       
   690             }
       
   691         }
       
   692     
       
   693      // Prepare data
       
   694     iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
       
   695     TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
       
   696 
       
   697     // Pack data
       
   698     CSatDataPackage dataPackage;
       
   699 	dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
       
   700 
       
   701     // Forward request to the DOS
       
   702     return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
       
   703 		ESatTerminalRsp, &dataPackage );
       
   704     }
       
   705 
       
   706 
       
   707 // -----------------------------------------------------------------------------
       
   708 // CSatNotifySetupCall::StoreCallConnectedEvent
       
   709 // Store a Call connected envelope to buffer
       
   710 // -----------------------------------------------------------------------------
       
   711 //
       
   712 void CSatNotifySetUpCall::StoreCallConnectedEvent
       
   713         ( 
       
   714         const TDesC8& aEnvelope
       
   715         )
       
   716     {
       
   717     TFLOGSTRING("CSAT: CSatNotifySetUpCall::StoreCallConnectedEvent");
       
   718     // Store it to the buffer
       
   719     iCallConnectedEvent = aEnvelope;
       
   720     } 
       
   721 
       
   722 // End of file