adaptationlayer/tsy/simatktsy_dll/src/satmesshandler.cpp
changeset 0 63b37f68c1ce
child 5 8ccc39f9d787
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2007-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 the License "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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "satmesshandler.h"     // sat message handler class
       
    22 #include "satmessaging.h"       // sat messaging class
       
    23 #include "sattimer.h"           // sat timer class
       
    24 #include "sateventdownload.h"   // sat event download class
       
    25 #include "satdatadownload.h"    // sat data download class
       
    26 #include "saticon.h"            // sat icon class
       
    27 #include "satmosmsctrl.h"       // sat mo sms control class
       
    28 #include "satnotifications.h"   // sat notifications class
       
    29 #include "ber_tlv.h"            // sat ber-tlv classes
       
    30 #include "satutil.h"            // sat utility class
       
    31 #include "cmmphonetsender.h"    // phonet sender
       
    32 #include "terminalprofile.h"    // terminal profile
       
    33 #include "satflightmodestatus.h"// flight mode status
       
    34 
       
    35 #include <pn_const.h>           // server id constants
       
    36 #include <tisi.h>               // isi message
       
    37 #include <ss_wmisi.h>           // ss server
       
    38 #include <infoisi.h>            // info server
       
    39 #include <net_modemisi.h>       // net server
       
    40 #include <gssisi.h>             // gss server
       
    41 #include <call_modemisi.h>      // Call Modem server
       
    42 #include <smsisi.h>             // sms server
       
    43 #include <uiccisi.h>            // UICC server
       
    44 #include <gpdsisi.h>            // GPDS server
       
    45 
       
    46 #include <atk_sharedisi.h>
       
    47 #include <call_sharedisi.h>
       
    48 #include "osttracedefinitions.h"
       
    49 #ifdef OST_TRACE_COMPILER_IN_USE
       
    50 #include "satmesshandlertraces.h"
       
    51 #endif
       
    52 
       
    53 
       
    54 
       
    55 // CONSTANTS
       
    56 const TUint8 KOneByteLengthLimit                = 0x7F;
       
    57 // Maximum value for get input string
       
    58 const TUint8 KGetInputStringMaxSize             = 0xEF;
       
    59 // No transaction ongoing
       
    60 const TInt KNoTransactionOngoing                = -1;
       
    61 // Time zone not available
       
    62 const TUint8 KTimeZoneNotAvailable              = 0xFF;
       
    63 // Access Technology unknown
       
    64 const TUint8 KAccTechUnknown                    = 0xFF;
       
    65 // This is a common length constant (2 bytes)
       
    66 const TUint8 KLengthTwoBytes                    = 0x02;
       
    67 // Maximum polling interval of legacy phones
       
    68 const TUint8 KMaxLegacyPollInterval             = 0x19; // 25 decimal
       
    69 // Size of one clut entry in bytes
       
    70 const TUint16 KClutEntrySize                    = 3;
       
    71 
       
    72 // Padding bytes for UICC messages
       
    73 const TUint8 KUiccPadding                       = 0x00;
       
    74 // Size of terminal profile subblock
       
    75 const TUint8 KSizeOfTerminalProfileSb           = 40;
       
    76 // Offset of UICC_APPL_CMD_REQ message for adding subblocks
       
    77 const TUint8 KUiccApplCmdReqOffset(
       
    78     ISI_HEADER_SIZE + SIZE_UICC_APPL_CMD_REQ );
       
    79 // Size of UICC_SB_APPL_PATH
       
    80 const TUint8 KUiccSbApplPathSize(
       
    81     SIZE_UICC_SB_APPL_PATH + KUiccFilePathLength );
       
    82 // UICC file IDs
       
    83 const TUint16 KUiccMasterFileId( 0x3F00 );
       
    84 const TUint16 KUiccElemFileServiceTable( 0x6F38 );
       
    85 const TUint16 KUiccDedicatedFileTelecom( 0x7F10 );
       
    86 const TUint16 KUiccDedicatedFileGraphics( 0x5F50 );
       
    87 const TUint16 KUiccElemFileImg( 0x4F20 );
       
    88 const TUint8 KUiccSfiServiceTable( 4 );
       
    89 // Number of subblocks in UICC_APPL_CMD_REQ
       
    90 const TUint8 KNumOfSbsInUiccApplCmdReq( 3 );
       
    91 // Max size of UICC_SB_TERMINAL_PROFILE
       
    92 const TUint16 KMaxSizeOfUiccSbTerminalResponse( 264 );
       
    93 // Length of device identity TLV data object
       
    94 const TUint8 KTlvDeviceIdentityLength( 2 );
       
    95 // Max length of UICC_SB_AID
       
    96 const TUint16 KMaxLengthUiccSbAid( 260 );
       
    97 // Elementary file ID length
       
    98 const TUint8 KUiccFileIdLength( 2 );
       
    99 // Maximum size of envelope
       
   100 const TUint16  KMaxSizeOfEnvelope( 256 );
       
   101 
       
   102 
       
   103 // ==================== MEMBER FUNCTIONS ====================================
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CSatMessHandler::CSatMessHandler
       
   107 // C++ default constructor can NOT contain any code, that
       
   108 // might leave.
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 CSatMessHandler::CSatMessHandler
       
   112         (
       
   113         CTsySatMessaging*   aTsySatMessaging,
       
   114         CMmPhoNetSender*    aPnSend
       
   115         )
       
   116         :
       
   117         iTsySatMessaging( aTsySatMessaging ),
       
   118         iPnSend( aPnSend )
       
   119     {
       
   120     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_CSATMESSHANDLER, "CSatMessHandler::CSatMessHandler" );
       
   121     // >= 0 if there is ongoing transaction
       
   122     iTerminalRespTraId              = KNoTransactionOngoing;
       
   123     iGetIconSimReadFieldTraId       = KNoTransactionOngoing;
       
   124     iDataDownloadSimReadFieldTraId  = KNoTransactionOngoing;
       
   125 
       
   126     iCardId                         = KZero;
       
   127     iSerialNumberReadReceived       = EFalse;
       
   128     // By default, there's no need to request routing from SMS server
       
   129     iSmsCbRoutingComplete           = ETrue;
       
   130     iRefreshRequestIsOn             = EFalse;
       
   131     iTimingAdvance                  = GSS_TIMING_ADVANCE_NOT_AVAILABLE;
       
   132     iTaStatus                       = GSS_TIMING_ADVANCE_NOT_VALID;
       
   133     iTimeZone                       = KTimeZoneNotAvailable;
       
   134     iSimServerObjectId              = KZero;
       
   135     iCurrentAccTech                 = KAccTechUnknown;
       
   136     // Set polling status to the use of the default value (25 sec.)
       
   137     iPollingOff                     = ETrue;
       
   138     iSsStatus                       = ENotBusy;
       
   139     // No long poll interval requests yet
       
   140     iLongPollIntervalReq            = EFalse;
       
   141 
       
   142 #ifdef INFO_PP_ATK_MO_SM_CONTROL
       
   143     // MO SMS support not yet read from product profile
       
   144     iMoSmsSupportedInPp             = EFalse;
       
   145 #endif // INFO_PP_ATK_MO_SM_CONTROL
       
   146 
       
   147 #ifdef INFO_PP_ENHANCED_NETWORK_SELECTION
       
   148     // ENS support not yet read from product profile
       
   149     iEnsSupportedInPp               = EFalse;
       
   150     // SET UP EVENT LIST TR not yet sent
       
   151     iSetUpEventListTrSent           = EFalse;
       
   152 #endif // INFO_PP_ENHANCED_NETWORK_SELECTION
       
   153 
       
   154     // Init location info structure
       
   155     iLocInfo.iOperatorCode.FillZ( iLocInfo.iOperatorCode.MaxLength() );
       
   156     iLocInfo.iLac.FillZ( iLocInfo.iLac.MaxLength() );
       
   157     iLocInfo.iCellId.FillZ( iLocInfo.iCellId.MaxLength() );
       
   158     iLocInfo.iRegStatus = NET_NO_COVERAGE;
       
   159 
       
   160     // Init IMEI of the ME
       
   161     iIMEI.FillZ( 16 ); // KSerialNumberLength + 1
       
   162 
       
   163     // Clear NMR (Network Measurement result)
       
   164     iNMR.Zero();
       
   165 
       
   166     // Clear BCCH channel list
       
   167     iBCCHChannelList.Zero();
       
   168 
       
   169     // Clear UTRAN measurement result
       
   170     iUtranNMR.Set( KNullDesC8 );
       
   171 
       
   172     // ME is not yet in service during startup
       
   173     iPreviousRegistrationStatus = NET_REG_STATUS_NOSERV_SEARCHING;
       
   174 
       
   175     // INFO_PP_SIM_OLD_POLL_INTERVAL flag not read yet
       
   176     iOldPollIntervalSupportedInPp = ETrue;
       
   177     }
       
   178 
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // CSatMessHandler::~CSatMessHandler
       
   182 // Destructor.
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 CSatMessHandler::~CSatMessHandler()
       
   186     {
       
   187     OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_CSATMESSHANDLER, "CSatMessHandler::~CSatMessHandler" );
       
   188     }
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CSatMessHandler::NewL
       
   192 // Two-phased constructor.
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 CSatMessHandler* CSatMessHandler::NewL
       
   196         (
       
   197         CTsySatMessaging*   aTsySatMessaging,
       
   198         CMmPhoNetSender*    aPnSend
       
   199         )
       
   200     {
       
   201     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_NEWL, "CSatMessHandler::NewL" );
       
   202     TFLOGSTRING("TSY:CSatMessHandler::NewL");
       
   203 
       
   204     CSatMessHandler* self = new( ELeave ) CSatMessHandler( aTsySatMessaging,
       
   205         aPnSend );
       
   206     CleanupStack::PushL( self );
       
   207     self->ConstructL();
       
   208     CleanupStack::Pop( self );
       
   209     return self;
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CSatMessHandler::ConstructL
       
   214 // Symbian 2nd phase constructor can leave
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 void CSatMessHandler::ConstructL()
       
   218     {
       
   219     TFLOGSTRING("TSY:CSatMessHandler::ConstructL");
       
   220     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_CONSTRUCTL, "CSatMessHandler::ConstructL" );
       
   221 
       
   222     // This flag is set to 'true' when indication ESatUsatClientReadyIndication
       
   223     // is received from SAT server. CAT can be enabled when the state of this
       
   224     // flag is 'true' and also UICC server is ready.
       
   225     iSatReady = EFalse;
       
   226     // Application ID will be set when UICC_APPLICATION_IND is received
       
   227     iApplicationId = 0xFF;
       
   228     // UICC client ID will be set when UICC_APPLICATION_RESP is received
       
   229     iUiccClientId = 0;
       
   230     // Terminal profile status flag is set 'true' when terminal profile has been
       
   231     // sent to prevent CAT enabling request to be sent before terminal profile
       
   232     iTerminalProfileSent = EFalse;
       
   233     // Card type is not known yet
       
   234     iCardType = UICC_CARD_TYPE_UNKNOWN;
       
   235     // Application file id is initialize to 'FFFF'
       
   236     TBuf8<2> unknownFileId;
       
   237     unknownFileId.Append( 0xFF );
       
   238     unknownFileId.Append( 0xFF );
       
   239     iApplFileId.Copy( unknownFileId );
       
   240 
       
   241     iPollingInterval = KDefaultPollInterval;
       
   242     iImageCodingScheme = KBlackAndWhite;
       
   243     }
       
   244 
       
   245 // -----------------------------------------------------------------------------
       
   246 // CSatMessHandler::ProactiveProcedureMessageReceivedL
       
   247 // Called SatMessHandler::ReceivedL, handles Event download,
       
   248 // Call control, Data Download and MO-SMS Control related messages
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 void CSatMessHandler::ProactiveProcedureMessageReceivedL
       
   252         (
       
   253         const TIsiReceiveC& aIsiMessage
       
   254         )
       
   255     {
       
   256     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_PROACTIVEPROCEDUREMESSAGERECEIVEDL, "CSatMessHandler::ProactiveProcedureMessageReceivedL" );
       
   257     TFLOGSTRING("TSY:CSatMessHandler::ProactiveProcedureMessageReceivedL");
       
   258 
       
   259     // handle event download and related messages
       
   260     iTsySatMessaging->EventDownloadReceived( aIsiMessage );
       
   261 
       
   262     // handle call control and releated messages
       
   263     iTsySatMessaging->CallControlReceivedL( aIsiMessage );
       
   264 
       
   265     // handle Data Download and related messages
       
   266     iTsySatMessaging->DataDownloadReceivedL( aIsiMessage );
       
   267 
       
   268     // handle MO-SMS Control related messages
       
   269     iTsySatMessaging->MoSmsControlReceived( aIsiMessage );
       
   270     }
       
   271 
       
   272 // -----------------------------------------------------------------------------
       
   273 // CSatMessHandler::NetServerMessageReceived
       
   274 // Called from SatMessHandler::ReceivedL, handles Net Server related messages
       
   275 // -----------------------------------------------------------------------------
       
   276 //
       
   277 void CSatMessHandler::NetServerMessageReceived
       
   278         (
       
   279         const TIsiReceiveC& aIsiMessage // ISI message
       
   280         )
       
   281     {
       
   282     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_NETSERVERMESSAGERECEIVED, "CSatMessHandler::NetServerMessageReceived" );
       
   283     TFLOGSTRING("TSY:CSatMessHandler::NetServerMessageReceived");
       
   284 
       
   285     TInt messageId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
       
   286 
       
   287     switch ( messageId )
       
   288         {
       
   289         case NET_CELL_INFO_IND:
       
   290             {
       
   291             StoreNetServiceStatus( aIsiMessage );
       
   292             // If SMS CB routing is still pending, regenerate routing request.
       
   293             // This might be the case if CS was inactive or SIM is not ready
       
   294             // during the first request.
       
   295             if ( !iSmsCbRoutingComplete )
       
   296                 {
       
   297                 TFLOGSTRING("TSY:CSatMessHandler::NetServerMessageReceived \
       
   298                     Sending delayed SMS CB routing request.");
       
   299                 OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_NETSERVERMESSAGERECEIVED, "CSatMessHandler::NetServerMessageReceived Sending delayed SMS CB routing request." );
       
   300                 SmsCbRoutingReq(
       
   301                     iTsySatMessaging->GetTransactionId(), SMS_ROUTING_SET );
       
   302                 }
       
   303             break;
       
   304             }
       
   305         case NET_NEIGHBOUR_CELLS_RESP:
       
   306             {
       
   307             NetNeighbourCellResp( aIsiMessage );
       
   308             break;
       
   309             }
       
   310         case NET_CELL_INFO_GET_RESP:
       
   311             {
       
   312             NetCellInfoGetResp( aIsiMessage );
       
   313             break;
       
   314             }
       
   315         case NET_TIME_IND:
       
   316             {
       
   317             NetTimeInd( aIsiMessage );
       
   318             break;
       
   319             }
       
   320         case NET_RAT_RESP:
       
   321             {
       
   322             NetRatResp( aIsiMessage );
       
   323             break;
       
   324             }
       
   325         case NET_RAT_IND:
       
   326             {
       
   327             NetRatInd( aIsiMessage );
       
   328             break;
       
   329             }
       
   330         default:
       
   331             {
       
   332             // Do nothing
       
   333             break;
       
   334             }
       
   335         }
       
   336     }
       
   337 
       
   338 // -----------------------------------------------------------------------------
       
   339 // CSatMessHandler::PhoneInfoMessageReceived
       
   340 // Called from SatMessHandler::ReceivedL, handles Phone Info related messages
       
   341 // -----------------------------------------------------------------------------
       
   342 //
       
   343 void CSatMessHandler::PhoneInfoMessageReceived
       
   344         (
       
   345         const TIsiReceiveC& aIsiMessage // ISI message
       
   346         )
       
   347     {
       
   348     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_PHONEINFOMESSAGERECEIVED, "CSatMessHandler::PhoneInfoMessageReceived" );
       
   349     TFLOGSTRING("TSY:CSatMessHandler::PhoneInfoMessageReceived");
       
   350 
       
   351     TInt messageId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
       
   352 
       
   353     switch ( messageId )
       
   354         {
       
   355         case INFO_SERIAL_NUMBER_READ_RESP:
       
   356             {
       
   357             InfoSerialNumberReadResp( aIsiMessage );
       
   358             break;
       
   359             }
       
   360         case INFO_PP_READ_RESP:
       
   361             {
       
   362             InfoPpReadResp( aIsiMessage );
       
   363             break;
       
   364             }
       
   365         default:
       
   366             {
       
   367             // do nothing
       
   368             break;
       
   369             }
       
   370         }
       
   371     }
       
   372 
       
   373 
       
   374 // -----------------------------------------------------------------------------
       
   375 // CSatMessHandler::UiccServerMessageReceived
       
   376 // Called from SatMessHandler::ReceivedL, handles UICC Server messages
       
   377 // -----------------------------------------------------------------------------
       
   378 //
       
   379 TBool CSatMessHandler::UiccServerMessageReceived(
       
   380     const TIsiReceiveC& aIsiMessage )
       
   381     {
       
   382     TUint8 messageId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
       
   383     OstTraceExt1( TRACE_NORMAL, DUP3_CSATMESSHANDLER_UICCSERVERMESSAGERECEIVED, "CSatMessHandler::UiccServerMessageReceived;messageId=%hhu", messageId );
       
   384     TFLOGSTRING2("TSY:CSatMessHandler::UiccServerMessageReceived, message ID: %d", messageId );
       
   385 
       
   386     TBool handled( EFalse );
       
   387 
       
   388     switch ( messageId )
       
   389         {
       
   390         case UICC_CAT_IND:
       
   391             {
       
   392             UiccCatInd( aIsiMessage );
       
   393             break;
       
   394             }
       
   395         case UICC_CAT_RESP:
       
   396             {
       
   397             TUint8 serviceType(
       
   398                 aIsiMessage.Get8bit(
       
   399                     ISI_HEADER_SIZE + UICC_CAT_RESP_OFFSET_SERVICETYPE ) );
       
   400             TUint8 status(
       
   401                 aIsiMessage.Get8bit(
       
   402                     ISI_HEADER_SIZE + UICC_CAT_RESP_OFFSET_STATUS ) );
       
   403 
       
   404             TFLOGSTRING3("TSY:CSatMessHandler:: KUiccCatResp: service type %d, status %d", serviceType, status);
       
   405             OstTraceExt2( TRACE_NORMAL, DUP2_CSATMESSHANDLER_UICCSERVERMESSAGERECEIVED, "CSatMessHandler::KUiccCatResp;serviceType=%hhu;status=%hhu", serviceType, status );
       
   406 
       
   407             // If terminal profile was sent succesfully and SAT is ready,
       
   408             // start fetching proactive commands
       
   409             if ( UICC_CAT_TERMINAL_PROFILE == serviceType &&
       
   410                 UICC_STATUS_OK == status )
       
   411                 {
       
   412                 // If SAT is not ready, CAT enable request cannot be sent yet.
       
   413                 // When indication of SAT ready is received by satmessaging,
       
   414                 // CAT enable request is sent if this flag is set to 'true'.
       
   415                 iTerminalProfileSent = ETrue;
       
   416 
       
   417                 // Enable or disable proactive command fetching depending on
       
   418                 // flight mode status
       
   419                 if ( iSatReady )
       
   420                     {
       
   421                     // Get instance of CSatFlightModeStatus for flight mode
       
   422                     // status
       
   423                     CSatFlightModeStatus* satFlightModeStatus(
       
   424                         iTsySatMessaging->GetSatFlightModeStatus() );
       
   425                     if ( ! satFlightModeStatus->FlightModeStatusValue() )
       
   426                         {
       
   427                         UiccCatReq( UICC_CAT_ENABLE );
       
   428                         }
       
   429                     else
       
   430                         {
       
   431                         UiccCatReq( UICC_CAT_DISABLE );
       
   432                         }
       
   433                     }
       
   434                 }
       
   435             // Response for refresh command
       
   436             else if ( UICC_CAT_REFRESH == serviceType )
       
   437                 {
       
   438                 RefreshResult( status );
       
   439                 }
       
   440             // Response for polling set command
       
   441             else if ( UICC_CAT_POLLING_SET == serviceType  )
       
   442                 {
       
   443                 SetPollingResult(
       
   444                     status,
       
   445                     aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID ),
       
   446                     iPollingInterval );
       
   447                 }
       
   448             // Response for envelope
       
   449             else if ( UICC_CAT_ENVELOPE == serviceType )
       
   450                 {
       
   451                 handled = UiccCatRespEnvelope( aIsiMessage );
       
   452                 }
       
   453             // Response for terminal response
       
   454             else if ( UICC_CAT_TERMINAL_RESPONSE  == serviceType )
       
   455                 {
       
   456                 handled = UiccCatRespTerminalResponse( aIsiMessage );
       
   457                 }
       
   458             break;
       
   459             }
       
   460         case UICC_APPLICATION_RESP:
       
   461             {
       
   462             TUint uiccSbClientOffset( 0 );
       
   463             if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
   464                 ISI_HEADER_SIZE + SIZE_UICC_APPLICATION_RESP,
       
   465                 UICC_SB_CLIENT,
       
   466                 EIsiSubBlockTypeId16Len16,
       
   467                 uiccSbClientOffset ) )
       
   468                 {
       
   469                 iUiccClientId = aIsiMessage.Get8bit(
       
   470                     uiccSbClientOffset + UICC_SB_CLIENT_OFFSET_CLIENTID );
       
   471                 }
       
   472             break;
       
   473             }
       
   474         case UICC_APPLICATION_IND:
       
   475             {
       
   476             // Application ID is needed when reading data from UICC
       
   477             iApplicationId = aIsiMessage.Get8bit(
       
   478                 ISI_HEADER_SIZE + UICC_APPLICATION_IND_OFFSET_APPLID );
       
   479             // Access to UICC files is possible when application is active
       
   480             TUint8 serviceType( aIsiMessage.Get8bit(
       
   481                 ISI_HEADER_SIZE + UICC_APPLICATION_IND_OFFSET_SERVICETYPE ) );
       
   482             if ( UICC_APPL_ACTIVATED == serviceType )
       
   483                 {
       
   484                 // USIM and SIM: Read SMS-PP DD and Call Control from byte 4.
       
   485                 // Only USIM: MO-SMS control from byte 4
       
   486                 UiccReadServiceTableReq( KUiccTrIdServiceTableByte4, 3 );
       
   487 
       
   488                 if ( UICC_CARD_TYPE_UICC == iCardType )
       
   489                     {
       
   490                     // USIM: Read call control GPRS from byte 7
       
   491                     UiccReadServiceTableReq( KUiccTrIdServiceTableByte7, 6 );
       
   492                     }
       
   493                 else if ( UICC_CARD_TYPE_ICC == iCardType )
       
   494                     {
       
   495                     // SIM: Read MO-SMS control from byte 5
       
   496                     UiccReadServiceTableReq( KUiccTrIdServiceTableByte5, 4 );
       
   497                     }
       
   498                 }
       
   499             break;
       
   500             }
       
   501         case UICC_APPL_CMD_RESP:
       
   502             {
       
   503             UiccApplCmdResp( aIsiMessage );
       
   504             }
       
   505         } // End of switch ( messageId )
       
   506     return handled;
       
   507     }
       
   508 
       
   509 // -----------------------------------------------------------------------------
       
   510 // CSatMessHandler::SmsServerMessageReceived
       
   511 // Called from SatMessHandler::ReceivedL, handles SMS Server messages
       
   512 // -----------------------------------------------------------------------------
       
   513 //
       
   514 void CSatMessHandler::SmsServerMessageReceived
       
   515         (
       
   516         const TIsiReceiveC& aIsiMessage // ISI message from SMS server
       
   517         )
       
   518     {
       
   519     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SMSSERVERMESSAGERECEIVED, "CSatMessHandler::SmsServerMessageReceived" );
       
   520     TFLOGSTRING("TSY:CSatMessHandler::SmsServerMessageReceived");
       
   521 
       
   522     TInt messageId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
       
   523 
       
   524     switch ( messageId )
       
   525         {
       
   526         case SMS_CB_ROUTING_RESP:
       
   527             {
       
   528             SmsCbRoutingResp( aIsiMessage );
       
   529             break;
       
   530             }
       
   531         case SMS_RESOURCE_CONF_IND:
       
   532             {
       
   533             SmsResourceConfInd( aIsiMessage );
       
   534             break;
       
   535             }
       
   536         case SMS_RESOURCE_CONF_RESP:
       
   537             {
       
   538             // Take a log because result is always ok
       
   539             TFLOGSTRING("TSY:CSatMoSmsCtrl::SmsResourceConfRespReceived: Response for Resource confoguration Req, Receive response from SMS server");
       
   540             OstTrace0( TRACE_NORMAL, DUP1_CSATMOSMSCTRL_SMSRESOURCECONFRESPRECEIVED, "CSatMoSmsCtrl::SmsResourceRespReceived: Response for Resource Configuration Req, Receive response from SMS server" );
       
   541             break;
       
   542             }
       
   543         default:
       
   544             // do nothing
       
   545             break;
       
   546         }
       
   547     }
       
   548 
       
   549 
       
   550 // -----------------------------------------------------------------------------
       
   551 // CSatMessHandler::SsServerMessageReceived
       
   552 // Called from SatMessHandler::ReceivedL, handles SS Server messages
       
   553 // -----------------------------------------------------------------------------
       
   554 //
       
   555 void CSatMessHandler::SsServerMessageReceived
       
   556         (
       
   557         const TIsiReceiveC& aIsiMessage // ISI message
       
   558         )
       
   559     {
       
   560     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SSSERVERMESSAGERECEIVED, "CSatMessHandler::SsServerMessageReceived" );
       
   561     TFLOGSTRING("TSY:CSatMessHandler::SsServerMessageReceived");
       
   562 
       
   563     TInt messageId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
       
   564 
       
   565     switch ( messageId )
       
   566         {
       
   567         case SS_STATUS_IND:
       
   568             {
       
   569             SsStatusInd( aIsiMessage );
       
   570             break;
       
   571             }
       
   572          default:
       
   573             // do nothing
       
   574             break;
       
   575         }
       
   576     }
       
   577 
       
   578 
       
   579 // -----------------------------------------------------------------------------
       
   580 // CSatMessHandler::GsmStackServerMessageReceived
       
   581 // Called from SatMessHandler::ReceivedL, handles GSM Stack Server messages
       
   582 // -----------------------------------------------------------------------------
       
   583 //
       
   584 void CSatMessHandler::GsmStackServerMessageReceived
       
   585         (
       
   586         const TIsiReceiveC& aIsiMessage // ISI message
       
   587         )
       
   588     {
       
   589     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GSMSTACKSERVERMESSAGERECEIVED, "CSatMessHandler::GsmStackServerMessageReceived" );
       
   590     TFLOGSTRING("TSY:CSatMessHandler::GsmStackServerMessageReceived");
       
   591 
       
   592     switch ( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) )
       
   593         {
       
   594         case GSS_CS_SERVICE_RESP:
       
   595             {
       
   596             GssCsServiceResp( aIsiMessage );
       
   597             break;
       
   598             }
       
   599         case GSS_CS_SERVICE_FAIL_RESP:
       
   600             {
       
   601             GssCsServiceFailResp( aIsiMessage );
       
   602             break;
       
   603             }
       
   604         default:
       
   605             {
       
   606             // do nothing
       
   607             break;
       
   608             }
       
   609         }
       
   610     }
       
   611 
       
   612 
       
   613 // -----------------------------------------------------------------------------
       
   614 // CSatMessHandler::DisplayTextTerminalResp
       
   615 // Constructs DisplayText specific part of terminal
       
   616 // response and calls SendTerminalResponse to send the terminal response.
       
   617 // -----------------------------------------------------------------------------
       
   618 //
       
   619 TInt CSatMessHandler::DisplayTextTerminalResp
       
   620         (
       
   621         TUint8 aTransId,            // Transaction id
       
   622         TDes8& aCommandDetails,     // PCmd number
       
   623         TUint8 aGeneralResult,      // General Result
       
   624         TUint8 aAdditionalInfo      // Additional info
       
   625         )
       
   626     {
       
   627     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_DISPLAYTEXTTERMINALRESP, "CSatMessHandler::DisplayTextTerminalResp" );
       
   628     TFLOGSTRING("TSY:CSatMessHandler::DisplayTextTerminalResp");
       
   629 
       
   630     TTlv tlvSpecificData;
       
   631     // Create General Result TLV here
       
   632     tlvSpecificData.AddTag( KTlvResultTag );
       
   633 
       
   634     // General result
       
   635     tlvSpecificData.AddByte( aGeneralResult );
       
   636 
       
   637     if ( KMeCurrentlyUnableToProcessCommand == aGeneralResult )
       
   638         {
       
   639         tlvSpecificData.AddByte( aAdditionalInfo );
       
   640         }
       
   641 
       
   642     return UiccCatReqTerminalResponse(
       
   643         aCommandDetails,
       
   644         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
   645         aTransId );
       
   646     }
       
   647 
       
   648 // -----------------------------------------------------------------------------
       
   649 // CSatMessHandler::GetInkeyTerminalResp
       
   650 // Constructs GetInkey specific part of terminal
       
   651 // response and calls SendTerminalResponse to send the terminal response.
       
   652 // -----------------------------------------------------------------------------
       
   653 //
       
   654 TInt CSatMessHandler::GetInkeyTerminalResp
       
   655         (
       
   656         const TUint8 aTransId,            // Transaction id
       
   657         const TDes8& aCommandDetails,     // PCmd number
       
   658         const RSat::TGetInkeyRspV2& aRsp  // Response packet from Etel
       
   659         )
       
   660     {
       
   661     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GETINKEYTERMINALRESP, "CSatMessHandler::GetInkeyTerminalResp" );
       
   662     TFLOGSTRING("TSY:CSatMessHandler::GetInkeyTerminalRespL");
       
   663 
       
   664     TTlv tlvSpecificData;
       
   665 
       
   666     //General result
       
   667     TUint8 result( aRsp.iGeneralResult );
       
   668 
       
   669     tlvSpecificData.AddTag( KTlvResultTag );
       
   670     tlvSpecificData.AddByte( result );
       
   671 
       
   672     if ( CommandPerformedSuccessfully( result ) )
       
   673         {
       
   674         TUint8 dcs( K8BitDCS ); // Default
       
   675         TBuf8<2> character; // Unicode has 2 bytes
       
   676 
       
   677         // Text String Tlv
       
   678         if ( NULL != aRsp.iAdditionalInfo.Length() )
       
   679             {
       
   680             // Response contain on one character
       
   681             TPtrC16 unicodeChar( aRsp.iAdditionalInfo.Mid( 0, 1 ) );
       
   682             switch ( aRsp.iRspFormat )
       
   683                 {
       
   684                 case RSat::ECharUcs2Alphabet:
       
   685                     {
       
   686                     dcs = KUCS2DCS;
       
   687                     TIsiUtility::CopyToBigEndian( unicodeChar, character );
       
   688                     break;
       
   689                     }
       
   690                 case RSat::EDigitOnly:
       
   691                 case RSat::ECharSmsDefaultAlphabet:
       
   692                 case RSat::EYesNo:
       
   693                 default:
       
   694                     {
       
   695                     // Dcs already set to K8BitDCS
       
   696                     TSatUtility::ConvertUnicode16ToSms7(
       
   697                         character, unicodeChar );
       
   698                     break;
       
   699                     }
       
   700                 }
       
   701             }
       
   702         else
       
   703             {
       
   704             // Just in case
       
   705             dcs = K8BitDCS;
       
   706             character.Copy( NULL );
       
   707             }
       
   708 
       
   709         tlvSpecificData.AddTag( KTlvTextStringTag );
       
   710         tlvSpecificData.AddByte( dcs );
       
   711         tlvSpecificData.AddData( character );
       
   712         }
       
   713     else if ( RSat::KNoAdditionalInfo != aRsp.iInfoType )
       
   714         {
       
   715         // Command not successfull
       
   716         if ( NULL != aRsp.iAdditionalInfo.Length() )
       
   717             {
       
   718             tlvSpecificData.AddByte( TUint8 ( aRsp.iAdditionalInfo[0] ) );
       
   719             }
       
   720         }
       
   721     else
       
   722         {
       
   723         // Command was not successful but additional info was not provided
       
   724         }
       
   725 
       
   726     // Append Duration TLV, if provided
       
   727     TInt tlvTimeUnit( KErrNotFound );
       
   728     switch ( aRsp.iDuration.iTimeUnit )
       
   729         {
       
   730         case RSat::EMinutes:
       
   731             {
       
   732             tlvTimeUnit = KMinutes;
       
   733             break;
       
   734             }
       
   735         case RSat::ESeconds:
       
   736             {
       
   737             tlvTimeUnit = KSeconds;
       
   738             break;
       
   739             }
       
   740         case RSat::ETenthsOfSeconds:
       
   741             {
       
   742             tlvTimeUnit = KTenthsOfSeconds;
       
   743             break;
       
   744             }
       
   745         case RSat::ETimeUnitNotSet:
       
   746         case RSat::ENoDurationAvailable:
       
   747         default:
       
   748             {
       
   749             // Duration is not added to terminal response
       
   750             break;
       
   751             }
       
   752         }
       
   753     if ( KErrNotFound != tlvTimeUnit )
       
   754         {
       
   755         // Duration provided. Append it to terminal response.
       
   756         tlvSpecificData.AddTag( KTlvDurationTag );
       
   757         tlvSpecificData.AddByte( tlvTimeUnit );
       
   758         tlvSpecificData.AddByte( aRsp.iDuration.iNumOfUnits );
       
   759         }
       
   760 
       
   761     return UiccCatReqTerminalResponse(
       
   762         aCommandDetails,
       
   763         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
   764         aTransId );
       
   765 
       
   766     }
       
   767 
       
   768 // -----------------------------------------------------------------------------
       
   769 // CSatMessHandler::GetInputTerminalResp
       
   770 // Constructs Get Input specific part of terminal
       
   771 // response and calls SendTerminalResponse to send the terminal response.
       
   772 // -----------------------------------------------------------------------------
       
   773 //
       
   774 TInt CSatMessHandler::GetInputTerminalResp
       
   775         (
       
   776         TUint8 aTransId,            // Transaction id
       
   777         TDes8& aCommandDetails,     // Command details tlv
       
   778         TUint8 aGeneralResult,      // General result
       
   779         TUint8 aAdditionalInfo,     // Additional info
       
   780         TDesC16& aTextString,       // Response string
       
   781         TUint8 aDataCodingScheme    // Coding scheme
       
   782         )
       
   783     {
       
   784     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GETINPUTTERMINALRESP, "CSatMessHandler::GetInputTerminalResp" );
       
   785     TFLOGSTRING("TSY:CSatMessHandler::GetInputTerminalResp");
       
   786 
       
   787     TTlv tlvSpecificData;
       
   788     TBuf8<KGetInputStringMaxSize> string;
       
   789 
       
   790     tlvSpecificData.AddTag( KTlvResultTag );
       
   791     tlvSpecificData.AddByte( aGeneralResult );
       
   792     if ( RSat::KMeUnableToProcessCmd == aGeneralResult )
       
   793         {
       
   794         tlvSpecificData.AddByte( aAdditionalInfo );
       
   795         }
       
   796 
       
   797     if ( CommandPerformedSuccessfully( aGeneralResult ) )
       
   798         {
       
   799         // create TextString TLV
       
   800         tlvSpecificData.AddTag( KTlvTextStringTag );
       
   801 
       
   802         if ( aTextString.Length() )
       
   803             {
       
   804             switch ( aDataCodingScheme )
       
   805                 {
       
   806                 case RSat::EUcs2Alphabet:
       
   807                     {
       
   808                      // data coding scheme UCS2 (16-bit)
       
   809                     tlvSpecificData.AddByte( KUCS2DCS );
       
   810 
       
   811                     if ( aTextString.Length() )
       
   812                         {
       
   813                         TIsiUtility::CopyToBigEndian( aTextString, string );
       
   814                         tlvSpecificData.AddData( string );
       
   815                         }
       
   816                     break;
       
   817                     }
       
   818 
       
   819                 case RSat::EDigitOnlyPacked:
       
   820                 case RSat::ESmsDefaultAlphabetPacked:
       
   821                     {
       
   822                     // data coding scheme 7-bit default sms
       
   823                     tlvSpecificData.AddByte( K7BitDefaultSmsDCS );
       
   824                     TSatUtility::UCSToPacket7( aTextString, string );
       
   825                     tlvSpecificData.AddData( string );
       
   826                     break;
       
   827                     }
       
   828 
       
   829                 case RSat::EDigitOnlyUnpacked:
       
   830                 case RSat::ESmsDefaultAlphabetUnpacked:
       
   831                     {
       
   832                     // data coding scheme 8-bit
       
   833                     tlvSpecificData.AddByte( K8BitDCS );
       
   834                     TSatUtility::ConvertUnicode16ToSms7( string, aTextString );
       
   835                     tlvSpecificData.AddData( string );
       
   836                     break;
       
   837                     }
       
   838                 default:
       
   839                     // do nothing
       
   840                     break;
       
   841                 }
       
   842             }
       
   843         }
       
   844 
       
   845     return UiccCatReqTerminalResponse(
       
   846         aCommandDetails,
       
   847         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
   848         aTransId );
       
   849     }
       
   850 
       
   851 // -----------------------------------------------------------------------------
       
   852 // CSatMessHandler::PlayToneTerminateResponse
       
   853 // Constructs PlayTone specific part of terminal
       
   854 // response and calls SendTerminalResponse to send the terminal response.
       
   855 // -----------------------------------------------------------------------------
       
   856 //
       
   857 TInt CSatMessHandler::PlayToneTerminalResp
       
   858         (
       
   859         TUint8 aTransId,            // Transaction Id
       
   860         TDes8& aCommandDetails,     // Command details
       
   861         TUint8 aGeneralResult,      // General result
       
   862         TUint8 aAdditionalInfo      // Additional info
       
   863         )
       
   864     {
       
   865     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_PLAYTONETERMINALRESP, "CSatMessHandler::PlayToneTerminalResp" );
       
   866     TFLOGSTRING("TSY:CSatMessHandler::PlayToneTerminalResp");
       
   867 
       
   868     TTlv tlvSpecificData;
       
   869 
       
   870     tlvSpecificData.AddTag( KTlvResultTag );
       
   871     //General result
       
   872     tlvSpecificData.AddByte( aGeneralResult );
       
   873     if ( AdditionalInfoNeeded( aGeneralResult ) )
       
   874         {
       
   875         tlvSpecificData.AddByte( aAdditionalInfo );
       
   876         }
       
   877 
       
   878     return UiccCatReqTerminalResponse(
       
   879         aCommandDetails,
       
   880         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
   881         aTransId );
       
   882     }
       
   883 
       
   884 
       
   885 // -----------------------------------------------------------------------------
       
   886 // CSatMessHandler::SetUpMenuTerminalResp
       
   887 // Constructs SetUpMenu specific part of terminal
       
   888 // response and calls SendTerminalResponse to send the terminal response.
       
   889 // -----------------------------------------------------------------------------
       
   890 //
       
   891 TInt CSatMessHandler::SetUpMenuTerminalResp
       
   892         (
       
   893         TUint8 aTransId,            // Transaction id
       
   894         TDes8& aCommandDetails,     // aPCmdNumber
       
   895         TUint8 aGeneralResult,      // General result
       
   896         TUint8 aAdditionalInfo      // Additional info
       
   897         )
       
   898     {
       
   899     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SETUPMENUTERMINALRESP, "CSatMessHandler::SetUpMenuTerminalResp" );
       
   900     TFLOGSTRING("TSY:CSatMessHandler::SetUpMenuTerminalResp");
       
   901 
       
   902     // Create and append response data
       
   903     TTlv tlvSpecificData;
       
   904 
       
   905     //create General Result TLV here
       
   906     tlvSpecificData.AddTag( KTlvResultTag );
       
   907 
       
   908     //General result
       
   909     tlvSpecificData.AddByte( aGeneralResult );
       
   910 
       
   911     if ( RSat::KMeUnableToProcessCmd == aGeneralResult )
       
   912         {
       
   913         tlvSpecificData.AddByte( aAdditionalInfo );
       
   914         }
       
   915 
       
   916     return UiccCatReqTerminalResponse(
       
   917         aCommandDetails,
       
   918         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
   919         aTransId );
       
   920     }
       
   921 
       
   922 // -----------------------------------------------------------------------------
       
   923 // CSatMessHandler::SelectItemTerminalResp
       
   924 // Constructs SelectItem specific part of terminal
       
   925 // response and calls SendTerminalResponse to send the terminal response.
       
   926 // -----------------------------------------------------------------------------
       
   927 //
       
   928 TInt CSatMessHandler::SelectItemTerminalResp
       
   929         (
       
   930         TUint8 aTransId,            // Transaction id
       
   931         TDes8& aCommandDetails,     // Comamnd number
       
   932         TUint8 aGeneralResult,      // General result
       
   933         TUint8 aAdditionalInfo      // Additional info
       
   934         )
       
   935     {
       
   936     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SELECTITEMTERMINALRESP, "CSatMessHandler::SelectItemTerminalResp" );
       
   937     TFLOGSTRING("TSY:CSatMessHandler::SelectItemTerminalResp");
       
   938 
       
   939     TTlv tlvSpecificData;
       
   940     // Create general result TLV here
       
   941     tlvSpecificData.AddTag( KTlvResultTag );
       
   942     // General result
       
   943     tlvSpecificData.AddByte( aGeneralResult );
       
   944 
       
   945     if ( !( CommandPerformedSuccessfully( aGeneralResult ) ) )
       
   946         {
       
   947         switch ( aGeneralResult )
       
   948             {
       
   949             case RSat::KHelpRequestedByUser:
       
   950                 {
       
   951                 // add selected Item Id tag
       
   952                 tlvSpecificData.AddTag( KTlvItemIdentifierTag );
       
   953                 tlvSpecificData.AddByte( aAdditionalInfo ); // selected item
       
   954                 break;
       
   955                 }
       
   956             case RSat::KPSessionTerminatedByUser:
       
   957             case RSat::KBackwardModeRequestedByUser:
       
   958             case RSat::KNoResponseFromUser:
       
   959                 {
       
   960                 break;
       
   961                 }
       
   962             default:
       
   963                 {
       
   964                 tlvSpecificData.AddByte( aAdditionalInfo );
       
   965                 break;
       
   966                 }
       
   967             }
       
   968         }
       
   969     else
       
   970         {
       
   971         // add selected Item Id tag
       
   972         tlvSpecificData.AddTag( KTlvItemIdentifierTag );
       
   973         tlvSpecificData.AddByte( aAdditionalInfo ); // selected item
       
   974         }
       
   975 
       
   976     return UiccCatReqTerminalResponse(
       
   977         aCommandDetails,
       
   978         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
   979         aTransId );
       
   980     }
       
   981 
       
   982 // -----------------------------------------------------------------------------
       
   983 // CSatMessHandler::PollIntervalTerminateResp
       
   984 // Constructs PollInterval specific part of terminal
       
   985 // response and calls SendTerminalResponse to send the terminal response.
       
   986 // -----------------------------------------------------------------------------
       
   987 //
       
   988 TInt CSatMessHandler::PollIntervalTerminalResp
       
   989         (
       
   990         TUint8 aTransId,            // Transaction id
       
   991         TDes8& aCommandDetails,     // command number
       
   992         TUint8 aGeneralResult,      // General result
       
   993         TUint8 aAdditionalInfo,     // Additional info
       
   994         TUint8 aNumOfUnits          // Time interval
       
   995         )
       
   996     {
       
   997     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_POLLINTERVALTERMINALRESP, "CSatMessHandler::PollIntervalTerminalResp" );
       
   998     TFLOGSTRING("TSY:CSatMessHandler::PollIntervalTerminalResp");
       
   999 
       
  1000     TTlv tlvSpecificData;
       
  1001 
       
  1002     tlvSpecificData.AddTag( KTlvResultTag );
       
  1003     tlvSpecificData.AddByte( aGeneralResult );
       
  1004 
       
  1005     if ( !( CommandPerformedSuccessfully( aGeneralResult ) ) )
       
  1006         {
       
  1007         switch ( aGeneralResult )
       
  1008             {
       
  1009             // Cases in which additional info is not required
       
  1010             case RSat::KPSessionTerminatedByUser:
       
  1011             case RSat::KBackwardModeRequestedByUser:
       
  1012             case RSat::KNoResponseFromUser:
       
  1013             case RSat::KErrorRequiredValuesMissing:
       
  1014             case RSat::KHelpRequestedByUser:
       
  1015                 {
       
  1016                 break;
       
  1017                 }
       
  1018             default:
       
  1019                 {
       
  1020                 tlvSpecificData.AddByte( aAdditionalInfo );
       
  1021                 break;
       
  1022                 }
       
  1023             }
       
  1024         }
       
  1025     else
       
  1026         {
       
  1027         tlvSpecificData.AddTag( KTlvDurationTag );
       
  1028         tlvSpecificData.AddByte( KSeconds );
       
  1029         tlvSpecificData.AddByte( aNumOfUnits );
       
  1030         }
       
  1031 
       
  1032     return UiccCatReqTerminalResponse(
       
  1033         aCommandDetails,
       
  1034         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  1035         aTransId );
       
  1036 }
       
  1037 
       
  1038 // -----------------------------------------------------------------------------
       
  1039 // CSatMessHandler::SendSmTerminalResp
       
  1040 // Constructs SendSm specific part of terminal
       
  1041 // response and calls SendTerminalResponse to send the terminal response.
       
  1042 // -----------------------------------------------------------------------------
       
  1043 //
       
  1044 TInt CSatMessHandler::SendSmTerminalResp
       
  1045         (
       
  1046         TUint8 aTransId,            // Transaction id
       
  1047         TDes8& aCommandDetails,     // Command details
       
  1048         TUint8 aGeneralResult,      // General result
       
  1049         TUint8 aAdditionalInfo      // Additional info
       
  1050         )
       
  1051     {
       
  1052     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SENDSMTERMINALRESP, "CSatMessHandler::SendSmTerminalResp" );
       
  1053     TFLOGSTRING("TSY:CSatMessHandler::SendSmTerminalResp");
       
  1054 
       
  1055     // Create and append response data
       
  1056     TTlv tlvSpecificData;
       
  1057 
       
  1058     //create General Result TLV here
       
  1059     tlvSpecificData.AddTag( KTlvResultTag );
       
  1060 
       
  1061     //General result
       
  1062     tlvSpecificData.AddByte( aGeneralResult );
       
  1063 
       
  1064     if ( RSat::KMeUnableToProcessCmd == aGeneralResult ||
       
  1065         RSat::KNetworkUnableToProcessCmd == aGeneralResult ||
       
  1066         RSat::KSmsRpError == aGeneralResult ||
       
  1067         RSat::KInteractionWithCCPermanentError == aGeneralResult )
       
  1068         {
       
  1069         // if there is ME, Network or SMS error, append additional info
       
  1070         tlvSpecificData.AddByte( aAdditionalInfo );
       
  1071         }
       
  1072     // Send terminal response
       
  1073     return UiccCatReqTerminalResponse(
       
  1074         aCommandDetails,
       
  1075         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  1076         aTransId );
       
  1077     }
       
  1078 
       
  1079 // -----------------------------------------------------------------------------
       
  1080 // CSatMessHandler::SendSsTerminalResp
       
  1081 // Constructs SendSS specific part of terminal
       
  1082 // response and calls SendTerminalResponse to send the terminal response.
       
  1083 // -----------------------------------------------------------------------------
       
  1084 //
       
  1085 TInt CSatMessHandler::SendSsTerminalResp
       
  1086         (
       
  1087         TUint8  aTransId,           // Transaction id
       
  1088         TDes8&  aCommandDetails,    // Command details tlv
       
  1089         TUint8  aGeneralResult,     // General result
       
  1090         TDesC8& aAdditionalInfo     // Additional info
       
  1091         )
       
  1092     {
       
  1093     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SENDSSTERMINALRESP, "CSatMessHandler::SendSsTerminalResp" );
       
  1094     TFLOGSTRING("TSY:CSatMessHandler::SendSsTerminalResp");
       
  1095 
       
  1096     // Create and append response data
       
  1097     TTlv tlvSpecificData;
       
  1098     tlvSpecificData.AddTag( KTlvResultTag );
       
  1099     // Append general result
       
  1100     tlvSpecificData.AddByte( aGeneralResult );
       
  1101 
       
  1102     if ( RSat::KErrorRequiredValuesMissing != aGeneralResult &&
       
  1103         RSat::KCmdDataNotUnderstood != aGeneralResult )
       
  1104         {
       
  1105         tlvSpecificData.AddData( aAdditionalInfo );
       
  1106         }
       
  1107 
       
  1108     return UiccCatReqTerminalResponse(
       
  1109         aCommandDetails,
       
  1110         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  1111         aTransId );
       
  1112     }
       
  1113 
       
  1114 // -----------------------------------------------------------------------------
       
  1115 // CSatMessHandler::SendDtmfTerminalResp
       
  1116 // Constructs Send Dtmf specific part of terminal
       
  1117 // response and calls SendTerminalResponse to send the terminal response.
       
  1118 // -----------------------------------------------------------------------------
       
  1119 //
       
  1120 TInt CSatMessHandler::SendDtmfTerminalResp
       
  1121         (
       
  1122         TUint8 aTransId,
       
  1123         TDes8& aCommandDetails,
       
  1124         TUint8  aGeneralResult,     // General result
       
  1125         TUint8 aAdditionalInfo      // Additional info
       
  1126         )
       
  1127     {
       
  1128     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SENDDTMFTERMINALRESP, "CSatMessHandler::SendDtmfTerminalResp" );
       
  1129     TFLOGSTRING("CSatMessHandler::SendDtmfTerminalResp");
       
  1130 
       
  1131     TTlv tlvSpecificData;
       
  1132     // Append general result tag
       
  1133     tlvSpecificData.AddTag( KTlvResultTag );
       
  1134     // Append general result
       
  1135     tlvSpecificData.AddByte( aGeneralResult );
       
  1136 
       
  1137     if ( RSat::KMeUnableToProcessCmd == aGeneralResult )
       
  1138         {
       
  1139         // UnSuccessful result neccessitating additional info byte
       
  1140         tlvSpecificData.AddByte( aAdditionalInfo );
       
  1141         }
       
  1142 
       
  1143     return UiccCatReqTerminalResponse(
       
  1144         aCommandDetails,
       
  1145         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  1146         aTransId );
       
  1147     }
       
  1148 
       
  1149 // -----------------------------------------------------------------------------
       
  1150 // CSatMessHandler::SendUssdTerminalResponse
       
  1151 // Constructs and sends the Send USSD response to Phonet, in order
       
  1152 // to reach the CellMo side.
       
  1153 // -----------------------------------------------------------------------------
       
  1154 //
       
  1155 TInt CSatMessHandler::SendUssdTerminalResp
       
  1156         (
       
  1157         TUint8 aTransId,
       
  1158         TDes8& aCommandDetails,
       
  1159         TUint8  aGeneralResult,
       
  1160         TUint8 aAdditionalInfo,
       
  1161         TDes& aUssdData,
       
  1162         TUint8  aUssdCbsDataCodingScheme
       
  1163         )
       
  1164     {
       
  1165     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SENDUSSDTERMINALRESP, "CSatMessHandler::SendUssdTerminalResp" );
       
  1166     TFLOGSTRING("TSY:CSatMessHandler::SendUssdTerminalResp");
       
  1167 
       
  1168     TTlv tlvSpecificData;
       
  1169     TBuf8<RSat::KStringMaxSize> string;
       
  1170 
       
  1171     tlvSpecificData.AddTag( KTlvResultTag );
       
  1172     tlvSpecificData.AddByte( aGeneralResult );
       
  1173 
       
  1174     // For the general results '20', '21', '37', '38'
       
  1175     // it is mandatory for the ME to provide a specific
       
  1176     // cause value as additional
       
  1177     if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult )
       
  1178         || ( RSat::KNetworkUnableToProcessCmd == aGeneralResult )
       
  1179         || ( RSat::KUssdReturnError == aGeneralResult)
       
  1180         || ( RSat::KMultipleCardCmdsError == aGeneralResult) )
       
  1181         {
       
  1182         tlvSpecificData.AddByte( aAdditionalInfo );
       
  1183         }
       
  1184     // For general result '32' additional info or text string is not used
       
  1185     else if ( RSat::KCmdDataNotUnderstood != aGeneralResult )
       
  1186         {
       
  1187         // Append received Ussd text string, with a Text string tag
       
  1188         tlvSpecificData.AddTag( KTlvTextStringTag );
       
  1189 
       
  1190         // Decode DCS
       
  1191         // Remains to know if SatServer sets the general result to
       
  1192         // KUssdReturnError when the DCS has a reserved value.
       
  1193         TSmsDcs decodedDcs( ESmsUnknownOrReservedDcs );
       
  1194         decodedDcs = TSatUtility::DecodeCbsDcs( aUssdCbsDataCodingScheme );
       
  1195         //Data Coding Scheme for Text String
       
  1196         tlvSpecificData.AddByte( (TUint8)decodedDcs );
       
  1197         switch ( decodedDcs )
       
  1198             {
       
  1199             case ESms7BitDcs:
       
  1200                 {
       
  1201                 // Convert the Response string (which comes in the form of
       
  1202                 // a TBuf (unicode)) to 7-bit gsm format.
       
  1203                 TSatUtility::UCSToPacket7( aUssdData, string );
       
  1204                 break;
       
  1205                 }
       
  1206             case ESms8BitDcs:
       
  1207                 {
       
  1208                 // Convert the Response string (which comes in the form of
       
  1209                 // a TBuf (unicode)) to 7-bit gsm format.
       
  1210                 TSatUtility::ConvertUnicode16ToSms7( string, aUssdData );
       
  1211                 break;
       
  1212                 }
       
  1213             case ESms16BitDcs:
       
  1214                 {
       
  1215                 TIsiUtility::CopyToBigEndian( aUssdData, string );
       
  1216                 break;
       
  1217                 }
       
  1218             default:
       
  1219                 {
       
  1220                 // Reserved
       
  1221                 // The general result should in fact prevent reaching this
       
  1222                 // branch of the switch.
       
  1223                 TFLOGSTRING("TSY:CSatMessHandler::SendUssdTerminalResp, \
       
  1224                 The DCS sent by the network has a reserved value.");
       
  1225                 OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_SENDUSSDTERMINALRESP, "CSatMessHandler::SendUssdTerminalResp, The DCS sent by the network has a reserved value." );
       
  1226                 break;
       
  1227                 }
       
  1228             }
       
  1229         // Text
       
  1230         tlvSpecificData.AddData( string );
       
  1231         }
       
  1232 
       
  1233     return UiccCatReqTerminalResponse(
       
  1234         aCommandDetails,
       
  1235         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  1236         aTransId );
       
  1237     }
       
  1238 
       
  1239 // -----------------------------------------------------------------------------
       
  1240 // CSatMessHandler::SetUpCallTerminalResp
       
  1241 // Constructs SetUpCall specific part of terminal
       
  1242 // response and calls SendTerminalResponse to send the terminal response
       
  1243 // -----------------------------------------------------------------------------
       
  1244 //
       
  1245 TInt CSatMessHandler::SetUpCallTerminalResp
       
  1246         (
       
  1247         TUint8 aTransId,            // Transaction id
       
  1248         TDes8& aCommandDetails,     // Command Details tlv
       
  1249         TUint8 aGeneralResult,      // General result
       
  1250         TUint8 aAdditionalInfo      // Additional info
       
  1251         )
       
  1252     {
       
  1253     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SETUPCALLTERMINALRESP, "CSatMessHandler::SetUpCallTerminalResp" );
       
  1254     TFLOGSTRING("TSY:CSatMessHandler::SetUpCallTerminalResp");
       
  1255 
       
  1256     // Create and append response data
       
  1257     TTlv tlvSpecificData;
       
  1258     tlvSpecificData.AddTag( KTlvResultTag );
       
  1259     // Result
       
  1260     tlvSpecificData.AddByte( aGeneralResult );
       
  1261 
       
  1262     if ( RSat::KMeUnableToProcessCmd == aGeneralResult ||
       
  1263         RSat::KNetworkUnableToProcessCmd == aGeneralResult ||
       
  1264         RSat::KInteractionWithCCPermanentError == aGeneralResult )
       
  1265         {
       
  1266         // If there was ME or network error, add additional info
       
  1267         tlvSpecificData.AddByte( aAdditionalInfo );
       
  1268         }
       
  1269 
       
  1270     return UiccCatReqTerminalResponse(
       
  1271         aCommandDetails,
       
  1272         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  1273         aTransId );
       
  1274     }
       
  1275 
       
  1276 // -----------------------------------------------------------------------------
       
  1277 // CSatMessHandler::RefreshTerminalResp
       
  1278 // Constructs Refresh specific part of terminal
       
  1279 // response and calls SendTerminalResponse to send the terminal response
       
  1280 // -----------------------------------------------------------------------------
       
  1281 //
       
  1282 TInt CSatMessHandler::RefreshTerminalResp
       
  1283         (
       
  1284         TUint8 aTransId,            // Transaction id
       
  1285         TDes8& aCommandDetails,     // Command number
       
  1286         TUint8 aGeneralResult,      // General result
       
  1287         TUint8 aAdditionalInfo      // Additional info
       
  1288         )
       
  1289     {
       
  1290     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_REFRESHTERMINALRESP, "CSatMessHandler::RefreshTerminalResp" );
       
  1291     TFLOGSTRING("TSY:CSatMessHandler::RefreshTerminalResp");
       
  1292 
       
  1293     // Create and append response data
       
  1294     TTlv tlvSpecificData;
       
  1295     // append result tag
       
  1296     tlvSpecificData.AddTag( KTlvResultTag );
       
  1297 
       
  1298     // General result
       
  1299     tlvSpecificData.AddByte( aGeneralResult );
       
  1300 
       
  1301     if ( RSat::KMeUnableToProcessCmd == aGeneralResult )
       
  1302         {
       
  1303         tlvSpecificData.AddByte( aAdditionalInfo );
       
  1304         }
       
  1305 
       
  1306     return UiccCatReqTerminalResponse(
       
  1307         aCommandDetails,
       
  1308         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  1309         aTransId );
       
  1310     }
       
  1311 
       
  1312 // -----------------------------------------------------------------------------
       
  1313 // CSatMessHandler::MenuSelectionInd
       
  1314 // Constructs and sends the Menu Selection response to phonet
       
  1315 // -----------------------------------------------------------------------------
       
  1316 //
       
  1317 void CSatMessHandler::MenuSelectionInd
       
  1318         (
       
  1319         TUint8 aTransId,        // Transaction id
       
  1320         TUint8 aItemIdentifier, // Item identifier
       
  1321         TUint8 aHelp            // Help requested status
       
  1322         )
       
  1323     {
       
  1324     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_MENUSELECTIONIND, "CSatMessHandler::MenuSelectionInd" );
       
  1325     TFLOGSTRING("TSY:CSatMessHandler::MenuSelectionInd");
       
  1326 
       
  1327     TTlv tlvSpecificData;
       
  1328 
       
  1329     tlvSpecificData.Begin( KBerTlvMenuSelectionTag );
       
  1330     tlvSpecificData.AddTag( KTlvDeviceIdentityTag );
       
  1331     tlvSpecificData.AddByte( KKeypad );
       
  1332     tlvSpecificData.AddByte( KSim );
       
  1333     tlvSpecificData.AddTag( KTlvItemIdentifierTag );
       
  1334     tlvSpecificData.AddByte( aItemIdentifier );
       
  1335     if ( aHelp )
       
  1336         {
       
  1337         tlvSpecificData.AddTag( KTlvHelpRequestTag );
       
  1338         }
       
  1339 
       
  1340     // Save menu selection envelope's transaction id, because SIM session
       
  1341     // has to be completed if menu selection does not have successive commands.
       
  1342     iTerminalRespTraId = TInt( aTransId );
       
  1343     UiccCatReqEnvelope( aTransId, tlvSpecificData.End(), EFalse );
       
  1344     }
       
  1345 
       
  1346 // -----------------------------------------------------------------------------
       
  1347 // CSatMessHandler::LaunchBrowserTerminalResp
       
  1348 // Constructs and sends the Launch Browser response to phonet
       
  1349 // -----------------------------------------------------------------------------
       
  1350 //
       
  1351 TInt CSatMessHandler::LaunchBrowserTerminalResp
       
  1352         (
       
  1353         TUint8 aTransId,        // aTransId
       
  1354         TDes8& aCommandDetails, // command number
       
  1355         TUint8 aGeneralResult,  // Result
       
  1356         TUint8 aAdditionalInfo  // additional info
       
  1357         )
       
  1358     {
       
  1359     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_LAUNCHBROWSERTERMINALRESP, "CSatMessHandler::LaunchBrowserTerminalResp" );
       
  1360     TFLOGSTRING("TSY:CSatMessHandler::LaunchBrowserTerminalResp");
       
  1361 
       
  1362     TTlv tlvSpecificData;
       
  1363 
       
  1364     tlvSpecificData.AddTag( KTlvResultTag );
       
  1365    //create General Result TLV here
       
  1366     tlvSpecificData.AddByte( aGeneralResult );
       
  1367     if ( !( CommandPerformedSuccessfully( aGeneralResult ) ) )
       
  1368         {
       
  1369         if ( RSat::KCmdTypeNotUnderstood != aGeneralResult
       
  1370             && RSat::KCmdDataNotUnderstood != aGeneralResult
       
  1371             && RSat::KErrorRequiredValuesMissing != aGeneralResult )
       
  1372             {
       
  1373             // additional info
       
  1374             tlvSpecificData.AddByte( aAdditionalInfo );
       
  1375             }
       
  1376         }
       
  1377 
       
  1378     return UiccCatReqTerminalResponse(
       
  1379         aCommandDetails,
       
  1380         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  1381         aTransId );
       
  1382     }
       
  1383 
       
  1384 
       
  1385 // -----------------------------------------------------------------------------
       
  1386 // CSatMessHandler::CommandPerformedSuccessfully
       
  1387 // Test if a proactive command was performed successfully
       
  1388 // -----------------------------------------------------------------------------
       
  1389 //
       
  1390 TBool CSatMessHandler::CommandPerformedSuccessfully
       
  1391         (
       
  1392         TUint8 aGeneralResult
       
  1393         )
       
  1394     {
       
  1395     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_COMMANDPERFORMEDSUCCESSFULLY, "CSatMessHandler::CommandPerformedSuccessfully" );
       
  1396     TFLOGSTRING("TSY:CSatMessHandler::CommandPerformedSuccessfully");
       
  1397 
       
  1398     TBool ret( EFalse );
       
  1399     switch ( aGeneralResult )
       
  1400         {
       
  1401         case RSat::KSuccess:
       
  1402         case RSat::KPartialComprehension:
       
  1403         case RSat::KMissingInformation:
       
  1404         case RSat::KRefreshAdditionEFRead:
       
  1405         case RSat::KSuccessRequestedIconNotDisplayed:
       
  1406         case RSat::KModifiedByCallControl:
       
  1407         case RSat::KSuccessLimitedService:
       
  1408         case RSat::KPerformedWithModifications:
       
  1409         case RSat::KRefreshUSIMNotActive:
       
  1410             {
       
  1411             ret = ETrue;
       
  1412             break;
       
  1413             }
       
  1414         default:
       
  1415             {
       
  1416             ret = EFalse;
       
  1417             break;
       
  1418             }
       
  1419         }
       
  1420     return ret;
       
  1421    }
       
  1422 
       
  1423 
       
  1424 // -----------------------------------------------------------------------------
       
  1425 // CSatMessHandler::SetUpIdleModeTextTerminalResp
       
  1426 // Constructs SetUpIdleModeText specific part of terminal
       
  1427 // response and calls SendTerminalResponse to send the terminal response
       
  1428 // -----------------------------------------------------------------------------
       
  1429 //
       
  1430 TInt CSatMessHandler::SetUpIdleModeTextTerminalResp
       
  1431         (
       
  1432         TUint8 aTransId,            // Transaction id
       
  1433         TDes8& aCommandDetails,     // command number
       
  1434         TUint8 aGeneralResult,      // Result
       
  1435         TUint8 aAdditionalInfo      // Additional info
       
  1436         )
       
  1437     {
       
  1438     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SETUPIDLEMODETEXTTERMINALRESP, "CSatMessHandler::SetUpIdleModeTextTerminalResp" );
       
  1439     TFLOGSTRING("TSY:CSatMessHandler::SetUpIdleModeTextTerminalResp");
       
  1440 
       
  1441     TTlv tlvSpecificData;
       
  1442 
       
  1443     //create General Result TLV here
       
  1444     tlvSpecificData.AddTag( KTlvResultTag );
       
  1445     //General result
       
  1446     tlvSpecificData.AddByte( aGeneralResult );
       
  1447 
       
  1448     if ( !( CommandPerformedSuccessfully( aGeneralResult ) ) )
       
  1449         {
       
  1450         switch ( aGeneralResult )
       
  1451             {
       
  1452             // Cases in which additional info is not required
       
  1453             case RSat::KPSessionTerminatedByUser:
       
  1454             case RSat::KBackwardModeRequestedByUser:
       
  1455             case RSat::KNoResponseFromUser:
       
  1456             case RSat::KErrorRequiredValuesMissing:
       
  1457             case RSat::KHelpRequestedByUser:
       
  1458             case RSat::KCmdDataNotUnderstood:
       
  1459                 {
       
  1460                 break;
       
  1461                 }
       
  1462             default:
       
  1463                 {
       
  1464                 tlvSpecificData.AddByte( aAdditionalInfo );
       
  1465                 break;
       
  1466                 }
       
  1467             }
       
  1468         }
       
  1469 
       
  1470     return UiccCatReqTerminalResponse(
       
  1471         aCommandDetails,
       
  1472         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  1473         aTransId );
       
  1474 }
       
  1475 
       
  1476 
       
  1477 // -----------------------------------------------------------------------------
       
  1478 // CSatMessHandler::UiccCatReqEnvelope
       
  1479 // Create and send UICC_CAT_REQ with UICC_SB_ENVELOPE
       
  1480 // -----------------------------------------------------------------------------
       
  1481 //
       
  1482 TInt CSatMessHandler::UiccCatReqEnvelope
       
  1483         (
       
  1484         TUint8 aTransId,
       
  1485         const TDesC8& aBerTlv,  // BER-TLV specific data
       
  1486         TBool aStore            // Is envelope stored for resending
       
  1487         )
       
  1488     {
       
  1489     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_UICCCATREQENVELOPE, "CSatMessHandler::UiccCatReqEnvelope" );
       
  1490     TFLOGSTRING("TSY:CSatMessHandler::UiccCatReqEnvelope");
       
  1491 
       
  1492     TIsiSend isiMsg( iPnSend->SendBufferDes() );
       
  1493     isiMsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_UICC );
       
  1494     isiMsg.Set8bit(
       
  1495         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_TRANSID,
       
  1496         aTransId );
       
  1497     isiMsg.Set8bit(
       
  1498         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_MESSAGEID,
       
  1499         UICC_CAT_REQ );
       
  1500     isiMsg.Set8bit(
       
  1501         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_SERVICETYPE,
       
  1502         UICC_CAT_ENVELOPE );
       
  1503     isiMsg.Set8bit(
       
  1504         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_NSB,
       
  1505         1 );
       
  1506 
       
  1507     // Add UICC_SB_ENVELOPE
       
  1508     TBuf8<SIZE_UICC_SB_ENVELOPE + KMaxSizeOfEnvelope> uiccSbEnvelopeBuf( 0 );
       
  1509     TIsiSubBlock uiccSbEnvelope(
       
  1510         uiccSbEnvelopeBuf,
       
  1511         UICC_SB_ENVELOPE,
       
  1512         EIsiSubBlockTypeId16Len16 );
       
  1513 
       
  1514     // 2x filler
       
  1515     uiccSbEnvelopeBuf.Append( KUiccPadding );
       
  1516     uiccSbEnvelopeBuf.Append( KUiccPadding );
       
  1517 
       
  1518     uiccSbEnvelopeBuf.Append( aBerTlv.Length() >> 8 ); // Length of envelope
       
  1519     uiccSbEnvelopeBuf.Append( aBerTlv.Length() );
       
  1520     uiccSbEnvelopeBuf.Append( aBerTlv ); // Envelope
       
  1521 
       
  1522     // Append subblock to ISI message
       
  1523     isiMsg.CopyData(
       
  1524         ISI_HEADER_SIZE + SIZE_UICC_CAT_REQ,
       
  1525         uiccSbEnvelope.CompleteSubBlock() );
       
  1526 
       
  1527     // Store information if needed for possible resending
       
  1528     if ( aStore )
       
  1529         {
       
  1530         iTsySatMessaging->GetSatTimer()->StoreEnvelope( aTransId, aBerTlv );
       
  1531         }
       
  1532 
       
  1533     return( iPnSend->Send( isiMsg.Complete() ) );
       
  1534     }
       
  1535 
       
  1536 
       
  1537 // -----------------------------------------------------------------------------
       
  1538 // CSatMessHandler::StoreNetServiceStatus
       
  1539 // Stores location information and network service status
       
  1540 // -----------------------------------------------------------------------------
       
  1541 //
       
  1542 void CSatMessHandler::StoreNetServiceStatus
       
  1543         (
       
  1544         const TIsiReceiveC& aIsiMessage
       
  1545         )
       
  1546     {
       
  1547     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_STORENETSERVICESTATUS, "CSatMessHandler::StoreNetServiceStatus" );
       
  1548     TFLOGSTRING("TSY: CSatMessHandler::StoreNetServiceStatus");
       
  1549 
       
  1550     // SubBlock offset
       
  1551     TUint sbOffset( 0 );
       
  1552 
       
  1553     TInt messageId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
       
  1554 
       
  1555     TInt headerSize( KErrNotFound );
       
  1556 
       
  1557     if ( NET_CELL_INFO_IND == messageId )
       
  1558         {
       
  1559         headerSize = SIZE_NET_CELL_INFO_IND;
       
  1560         }
       
  1561     else if ( NET_CELL_INFO_GET_RESP == messageId )
       
  1562         {
       
  1563         headerSize = SIZE_NET_CELL_INFO_GET_RESP;
       
  1564         }
       
  1565     else
       
  1566         {
       
  1567         // Header size contains already an error value as default.
       
  1568         }
       
  1569 
       
  1570     if ( KErrNotFound != headerSize )
       
  1571         {
       
  1572         // Find NET_GSM_CELL_INFO or NET_WCDMA_CELL_INFO subblock
       
  1573         TInt retGsmSb( aIsiMessage.FindSubBlockOffsetById(
       
  1574             ISI_HEADER_SIZE + headerSize,
       
  1575             NET_GSM_CELL_INFO,
       
  1576             EIsiSubBlockTypeId8Len8,
       
  1577             sbOffset ) );
       
  1578 
       
  1579         TInt retWcdmaSb( aIsiMessage.FindSubBlockOffsetById(
       
  1580             ISI_HEADER_SIZE + headerSize,
       
  1581             NET_WCDMA_CELL_INFO,
       
  1582             EIsiSubBlockTypeId8Len8,
       
  1583             sbOffset ) );
       
  1584 
       
  1585         // Check if subblock exists.
       
  1586         if ( KErrNone == retGsmSb || KErrNone == retWcdmaSb )
       
  1587             {
       
  1588             // NET_GSM_CELL_INFO and NET_WCDMA_CELL_INFO subblocks have identical
       
  1589             // bytes and sizes ,use only NET_GSM_CELL_INFO subblock offset
       
  1590             // values when getting data.
       
  1591 
       
  1592             // Get registration status value
       
  1593             iLocInfo.iRegStatus = aIsiMessage.Get8bit(
       
  1594                 sbOffset + NET_GSM_CELL_INFO_OFFSET_SERVICESTATUS );
       
  1595 
       
  1596             TFLOGSTRING2("TSY: CSatMessHandler::StoreNetServiceStatus: \
       
  1597                 NET_REGISTRATION_STATUS = %d", iLocInfo.iRegStatus );
       
  1598             OstTrace1( TRACE_NORMAL, DUP1_CSATMESSHANDLER_STORENETSERVICESTATUS, "CSatMessHandler::StoreNetServiceStatus NET_REGISTRATION_STATUS = %d", iLocInfo.iRegStatus );
       
  1599 
       
  1600             if ( NET_SERVICE == iLocInfo.iRegStatus ||
       
  1601                 NET_LIMITED_SERVICE == iLocInfo.iRegStatus )
       
  1602                 {
       
  1603                 // Get country code
       
  1604                 iLocInfo.iOperatorCode.Copy(
       
  1605                     aIsiMessage.GetData(
       
  1606                         sbOffset + NET_GSM_CELL_INFO_OFFSET_OPERATORCODE,
       
  1607                         3 ) );
       
  1608 
       
  1609                 // Set location area code, 2 bytes
       
  1610                 iLocInfo.iLac.Copy(
       
  1611                     aIsiMessage.GetData(
       
  1612                         sbOffset + NET_GSM_CELL_INFO_OFFSET_CURRENTLAC,
       
  1613                         2 ) );
       
  1614 
       
  1615                 // Cell id + Extented Cell id, 4 bytes
       
  1616                 // Id's are included to Location Information TLV
       
  1617                 // reverse order, see 31.111, 8.19
       
  1618                 TPtrC8 tempCellId( aIsiMessage.GetData(
       
  1619                     sbOffset + NET_GSM_CELL_INFO_OFFSET_CURRENTCELLID,
       
  1620                     4 ) );
       
  1621                 // Copy cell id to be first in buffer
       
  1622                 iLocInfo.iCellId.Copy( tempCellId.Mid( 2 ) );
       
  1623                 // Append extented cell id part
       
  1624                 iLocInfo.iCellId.Append( tempCellId.Left( 2 ) );
       
  1625 
       
  1626                 // Network type
       
  1627                 if ( NET_GSM_CELL_INFO == aIsiMessage.Get8bit(
       
  1628                     sbOffset + NET_GSM_CELL_INFO_OFFSET_SUBBLOCKID ) )
       
  1629                     {
       
  1630                     iCurrentAccTech = KNetworkModeGsm;
       
  1631                     }
       
  1632                 else
       
  1633                     {
       
  1634                     iCurrentAccTech = KNetworkModeUtran;
       
  1635                     }
       
  1636                 }
       
  1637             }
       
  1638         else
       
  1639             {
       
  1640             TFLOGSTRING("TSY: CSatMessHandler::StoreNetServiceStatus \
       
  1641                 NET_GSM_CELL_INFO or NET_WCDMA_CELL_INFO not found!");
       
  1642             OstTrace0( TRACE_NORMAL, DUP2_CSATMESSHANDLER_STORENETSERVICESTATUS, "CSatMessHandler::StoreNetServiceStatus NET_GSM_CELL_INFO or NET_WCDMA_CELL_INFO not found!" );
       
  1643             }
       
  1644         }
       
  1645     else
       
  1646         {
       
  1647         TFLOGSTRING2("TSY: CSatMessHandler::StoreNetServiceStatus \
       
  1648             Unexpected message id: %d", messageId );
       
  1649         OstTrace1( TRACE_NORMAL, DUP3_CSATMESSHANDLER_STORENETSERVICESTATUS, "CSatMessHandler::StoreNetServiceStatus Unexpected message id: %d", messageId );
       
  1650         }
       
  1651     }
       
  1652 
       
  1653 // -----------------------------------------------------------------------------
       
  1654 // CSatMessHandler::SetUpEventListTerminalResp
       
  1655 // Constructs Setup EventList and calls
       
  1656 // SendTerminalResponse to send the terminal response
       
  1657 // -----------------------------------------------------------------------------
       
  1658 //
       
  1659 TInt CSatMessHandler::SetUpEventListTerminalResp
       
  1660         (
       
  1661         TUint8 aTransId,             // Transaction id
       
  1662         TDes8& aCommandDetails,      // Command details
       
  1663         TUint8 aGeneralResult,       // General result
       
  1664         TUint8 aAdditionalInfo       // Additional info
       
  1665         )
       
  1666     {
       
  1667     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SETUPEVENTLISTTERMINALRESP, "CSatMessHandler::SetUpEventListTerminalResp" );
       
  1668     TFLOGSTRING("TSY:CSatMessHandler::SetUpEventListTerminalResp");
       
  1669     // create responce data
       
  1670     TTlv tlvSpecificData;
       
  1671 
       
  1672     //create General Result TLV here
       
  1673     tlvSpecificData.AddTag( KTlvResultTag );
       
  1674 
       
  1675     //General result
       
  1676     tlvSpecificData.AddByte( aGeneralResult );
       
  1677 
       
  1678     if ( RSat::KSuccess != aGeneralResult &&
       
  1679         RSat::KCmdBeyondMeCapabilities != aGeneralResult &&
       
  1680         RSat::KErrorRequiredValuesMissing != aGeneralResult)
       
  1681         {
       
  1682         tlvSpecificData.AddByte( aAdditionalInfo );
       
  1683         }
       
  1684 
       
  1685 #ifdef INFO_PP_ENHANCED_NETWORK_SELECTION
       
  1686     iSetUpEventListTrSent = ETrue;
       
  1687 #endif // INFO_PP_ENHANCED_NETWORK_SELECTION
       
  1688 
       
  1689     return UiccCatReqTerminalResponse(
       
  1690         aCommandDetails,
       
  1691         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  1692         aTransId );
       
  1693     }
       
  1694 
       
  1695 // -----------------------------------------------------------------------------
       
  1696 // CSatMessHandler::PollingOffTerminalResp
       
  1697 // Constructs PollingOff specific part of terminal
       
  1698 // response and calls SendTerminalResponse
       
  1699 // -----------------------------------------------------------------------------
       
  1700 //
       
  1701 TInt CSatMessHandler::PollingOffTerminalResp
       
  1702         (
       
  1703         TUint8 aTransId,
       
  1704         TDes8& aCommandDetails,         // Transaction id
       
  1705         TUint8 aGeneralResult,          // General result
       
  1706         TUint8 aAdditionalInfo          // Additional info
       
  1707         )
       
  1708     {
       
  1709     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_POLLINGOFFTERMINALRESP, "CSatMessHandler::PollingOffTerminalResp" );
       
  1710     TFLOGSTRING("TSY:CSatMessHandler::PollingOffTerminalResp");
       
  1711 
       
  1712     TTlv tlvSpecificData;
       
  1713 
       
  1714     tlvSpecificData.AddTag( KTlvResultTag );
       
  1715     tlvSpecificData.AddByte( aGeneralResult );
       
  1716 
       
  1717     if ( !( CommandPerformedSuccessfully( aGeneralResult ) ) )
       
  1718         {
       
  1719         switch ( aGeneralResult )
       
  1720             {
       
  1721             // Cases in which additional info is not required
       
  1722             case RSat::KPSessionTerminatedByUser:
       
  1723             case RSat::KBackwardModeRequestedByUser:
       
  1724             case RSat::KNoResponseFromUser:
       
  1725             case RSat::KErrorRequiredValuesMissing:
       
  1726             case RSat::KHelpRequestedByUser:
       
  1727                 {
       
  1728                 break;
       
  1729                 }
       
  1730             default:
       
  1731                 {
       
  1732                 tlvSpecificData.AddByte( aAdditionalInfo );
       
  1733                 break;
       
  1734                 }
       
  1735             }
       
  1736         }
       
  1737 
       
  1738     return UiccCatReqTerminalResponse(
       
  1739         aCommandDetails,
       
  1740         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  1741         aTransId );
       
  1742     }
       
  1743 
       
  1744 // -----------------------------------------------------------------------------
       
  1745 // CSatMessHandler::LocalInfoTerminalResp
       
  1746 // Constructs and sends the Local information response to
       
  1747 // the SIM card.
       
  1748 // -----------------------------------------------------------------------------
       
  1749 //
       
  1750 TInt CSatMessHandler::LocalInfoTerminalResp
       
  1751         (
       
  1752         TUint8 aTransId,            // Transaction id
       
  1753         TDes8& aCommandDetails,     // Command details tlv
       
  1754         TUint8 aGeneralResult,      // General result
       
  1755         TDes& aAdditionalInfo       // Additional info
       
  1756         )
       
  1757     {
       
  1758     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_LOCALINFOTERMINALRESP, "CSatMessHandler::LocalInfoTerminalResp" );
       
  1759     TFLOGSTRING("TSY: CSatMessHandler::LocalInfoTerminalResp");
       
  1760     // Create and append response data
       
  1761     TTlv tlvData;
       
  1762     // Create General Result TLV
       
  1763     tlvData.AddTag( KTlvResultTag );
       
  1764 
       
  1765     // General result
       
  1766     tlvData.AddByte( aGeneralResult );
       
  1767 
       
  1768     if ( RSat::KSuccess != aGeneralResult
       
  1769         && RSat::KSuccessLimitedService != aGeneralResult )
       
  1770         {
       
  1771         if ( aAdditionalInfo.Length() )
       
  1772             {
       
  1773             tlvData.AddByte( TUint8( aAdditionalInfo[0] & 0xFF ) );
       
  1774             }
       
  1775         }
       
  1776     else
       
  1777         {
       
  1778         switch ( aCommandDetails[KCommandQualifier] )
       
  1779             {
       
  1780             case RSat::KProvideLocalInfo:
       
  1781                 {
       
  1782                 const TLocationInfo& locInfo = LocationInfo();
       
  1783                 // Create Location Information TLV
       
  1784                 tlvData.AddTag( KTlvLocationInformationTag );
       
  1785                 // Append Mobile Country  & Network Codes, 3 bytes
       
  1786                 tlvData.AddData( locInfo.iOperatorCode );
       
  1787 
       
  1788                 // Append LAC code
       
  1789                 tlvData.AddData( locInfo.iLac );
       
  1790 
       
  1791                 // Append CellId
       
  1792                 tlvData.AddData( locInfo.iCellId );
       
  1793                  break;
       
  1794                 }
       
  1795             case RSat::KProvideLocalInfoImei:
       
  1796                 {
       
  1797                 // Add tlv tag
       
  1798                 tlvData.AddTag( KTlvImeiTag );
       
  1799                 TBuf8<8> bcdImei;
       
  1800                 // Convert IMEI to BCD format
       
  1801                 _LIT8( KTen, "*" );
       
  1802                 _LIT8( KZero, "0" );
       
  1803 
       
  1804                 // Check if required changes is allready done for the IMEI
       
  1805                 if ( '*' != iIMEI[0] )
       
  1806                     {
       
  1807                     // Processing BCD string is much harder than ASCII so
       
  1808                     // required changes is done before BCD conversion.
       
  1809                     // (lot's of shifting etc..)
       
  1810                     // Insert '*'(0x2A) as a first character which is converted
       
  1811                     // to 0xA in AsciiToBCD method.
       
  1812                     // Type of identity for IMEI code is 0xA "1010b"
       
  1813                     // See 3GPP TS 04.08
       
  1814                     iIMEI.Insert( 0, KTen );
       
  1815 
       
  1816                     // Spare digit: this digit shall be zero, when transmitted
       
  1817                     // by the Mobile Station.
       
  1818                     // See GSM 03.03
       
  1819                     iIMEI.Replace( iIMEI.Length() - 1, 1 , KZero );
       
  1820                     }
       
  1821 
       
  1822                 TSatUtility::AsciiToBCD( iIMEI, bcdImei );
       
  1823                 // Add IMEI code to the terminal response
       
  1824                 tlvData.AddData( bcdImei );
       
  1825                 break;
       
  1826                 }
       
  1827             case RSat::KProvideLocalInformationNmr:
       
  1828                 {
       
  1829                 // Check if NMR's were for UTRAN
       
  1830                 if ( iUtranNMR.Length() )
       
  1831                     {
       
  1832                     tlvData.AddTag( KTlvNetworkMeasurementResultsTag );
       
  1833                     tlvData.AddData( iUtranNMR );
       
  1834                     }
       
  1835                 else
       
  1836                     {
       
  1837                     // NMR's were for GSM
       
  1838                     if ( iNMR.Length() )
       
  1839                         {
       
  1840                         // Network measurement result
       
  1841                         tlvData.AddTag( KTlvNetworkMeasurementResultsTag );
       
  1842                         tlvData.AddData( iNMR );
       
  1843                         }
       
  1844 
       
  1845                     if ( iBCCHChannelList.Length() )
       
  1846                         {
       
  1847                         // append BCCH channel list tag
       
  1848                         tlvData.AddTag( KTlvBccdChannelListTag );
       
  1849 
       
  1850                         TInt i( 0 );
       
  1851                         TInt mask( 3 );
       
  1852                         TInt shiftMove( 2 );
       
  1853                         TUint8 nextChar( 0 );
       
  1854 
       
  1855                         // Convert BCCH channel list from 16-bit to 10-bit
       
  1856                         // format
       
  1857                         for ( i = 0; i < iBCCHChannelList.Length(); i++ )
       
  1858                             {
       
  1859                             TUint char2 =  ( iBCCHChannelList[i] & 0x03FF );
       
  1860                             TUint8 char1 = TUint8( char2 >> shiftMove);
       
  1861 
       
  1862                             // append byte
       
  1863                             tlvData.AddByte( TUint8( char1 | nextChar ) );
       
  1864 
       
  1865                             nextChar = TUint8 ( ( char2 & mask )
       
  1866                                 << ( 8 - shiftMove ) );
       
  1867 
       
  1868                             if ( 8 == shiftMove )
       
  1869                                 {
       
  1870                                 shiftMove = 2;
       
  1871                                 nextChar = 0;
       
  1872                                 tlvData.AddByte( TUint8( char2 & 0x00FF ) );
       
  1873                                 mask = 3;
       
  1874                                 }
       
  1875                             else
       
  1876                                 {
       
  1877                                 shiftMove += 2;
       
  1878                                 mask = ( 1L << shiftMove) - 1;
       
  1879                                 }
       
  1880                             }
       
  1881                         // add last byte
       
  1882                         tlvData.AddByte( nextChar );
       
  1883                         }
       
  1884                     }
       
  1885                 // clear nmr
       
  1886                 iNMR.Zero();
       
  1887                 // clear BCCH channel list
       
  1888                 iBCCHChannelList.Zero();
       
  1889                 // clear UTRAN NMR's
       
  1890                 iUtranNMR.Set( KNullDesC8 );
       
  1891                 break;
       
  1892                 }
       
  1893             case RSat::KProvideLocalInfoDateTimeTimeZone:
       
  1894                 {
       
  1895                 tlvData.AddTag( KTlvDateTimeAndTimeZoneTag );
       
  1896                 // append current date/time/timezone to the terminal response
       
  1897                 TInt i( 0 );
       
  1898                 for ( i = 0; i < aAdditionalInfo.Length(); i++ )
       
  1899                     {
       
  1900                     tlvData.AddByte( TUint8( aAdditionalInfo[i] & 0x00FF ) );
       
  1901                     }
       
  1902                 break;
       
  1903                 }
       
  1904             case RSat::KProvideLocalInfoTimingAdv:
       
  1905                 {
       
  1906                  TFLOGSTRING("TSY: CSatMessHandler::LocalInfoTerminalResp,\
       
  1907                     TimingAdvance");
       
  1908                  OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_LOCALINFOTERMINALRESP, "CSatMessHandler::LocalInfoTerminalResp, TimingAdvance" );
       
  1909 
       
  1910                  // Timing advance result
       
  1911                  tlvData.AddTag( KTlvTimingAdvanceTag );
       
  1912                  tlvData.AddByte( iTaStatus );
       
  1913                  tlvData.AddByte( iTimingAdvance );
       
  1914                 break;
       
  1915                 }
       
  1916             case RSat::KProvideLocalInfoLanguage:
       
  1917                 {
       
  1918                 TFLOGSTRING("TSY: CSatMessHandler::LocalInfoTerminalResp,\
       
  1919                     LocalInfoLanguage");
       
  1920                 OstTrace0( TRACE_NORMAL, DUP2_CSATMESSHANDLER_LOCALINFOTERMINALRESP, "CSatMessHandler::LocalInfoTerminalResp, LocalInfoLanguage" );
       
  1921 
       
  1922                 if ( aAdditionalInfo.Length() )
       
  1923                     {
       
  1924                     // create Language TLV
       
  1925                     tlvData.AddTag( KTlvLanguageTag );
       
  1926                     TBuf8<2> character;
       
  1927                     TIsiUtility::CopyToBigEndian( aAdditionalInfo, character);
       
  1928                     tlvData.AddData( character );
       
  1929                     }
       
  1930                 break;
       
  1931                 }
       
  1932             case RSat::KProvideLocalInfoAccTech:
       
  1933                 {
       
  1934                 TFLOGSTRING("TSY: CSatMessHandler::LocalInfoTerminalResp,\
       
  1935                     Access Technology");
       
  1936                 OstTrace0( TRACE_NORMAL, DUP3_CSATMESSHANDLER_LOCALINFOTERMINALRESP, "CSatMessHandler::LocalInfoTerminalResp, Access Technology" );
       
  1937 
       
  1938                 // Access technology result
       
  1939                 tlvData.AddTag( KTlvAccessTechnologyTag );
       
  1940                 tlvData.AddByte( iCurrentAccTech );
       
  1941 
       
  1942                 break;
       
  1943                 }
       
  1944             default:
       
  1945                 {
       
  1946                 break;
       
  1947                 }
       
  1948             }
       
  1949         }
       
  1950     return UiccCatReqTerminalResponse(
       
  1951         aCommandDetails,
       
  1952         tlvData.GetDataWithoutTopLevelTag(),
       
  1953         aTransId );
       
  1954     }
       
  1955 // -----------------------------------------------------------------------------
       
  1956 // CSatMessHandler::InfoSerialNumberReadReq
       
  1957 // Constructs INFO_SERIAL_NUMBER_READ_REQ ISI message.
       
  1958 // Called from CTsySatMessaging::ConstructL method.
       
  1959 // -----------------------------------------------------------------------------
       
  1960 //
       
  1961 TInt CSatMessHandler::InfoSerialNumberReadReq
       
  1962         (
       
  1963         TUint8 aTransId,     // Transactio id
       
  1964         TUint8 aTarget
       
  1965         )
       
  1966     {
       
  1967     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_INFOSERIALNUMBERREADREQ, "CSatMessHandler::InfoSerialNumberReadReq" );
       
  1968     TFLOGSTRING("TSY:CSatMessHandler::InfoSerialNumberReadReq");
       
  1969 
       
  1970     //set infoSerialNumberReadReq to point to the send buffer
       
  1971     TIsiSend infoSerialNumberReadReq( iPnSend->SendBufferDes() );
       
  1972     infoSerialNumberReadReq.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_INFO );
       
  1973     infoSerialNumberReadReq.Set8bit( ISI_HEADER_OFFSET_TRANSID, aTransId );
       
  1974     infoSerialNumberReadReq.Set8bit( ISI_HEADER_OFFSET_MESSAGEID,
       
  1975                                         INFO_SERIAL_NUMBER_READ_REQ );
       
  1976 
       
  1977     infoSerialNumberReadReq.Set8bit( ISI_HEADER_SIZE
       
  1978                     + INFO_SERIAL_NUMBER_READ_REQ_OFFSET_TARGET, aTarget );
       
  1979 
       
  1980     //send message via Phonet
       
  1981     return iPnSend->Send( infoSerialNumberReadReq.Complete() );
       
  1982 
       
  1983     }
       
  1984 
       
  1985 // -----------------------------------------------------------------------------
       
  1986 // CSatMessHandler::InfoSerialNumberReadResp
       
  1987 // Breaks a INFO_SERIAL_NUMBER_READ_RESP ISI-message.
       
  1988 // -----------------------------------------------------------------------------
       
  1989 //
       
  1990 void CSatMessHandler::InfoSerialNumberReadResp
       
  1991         (
       
  1992         const TIsiReceiveC& aIsiMessage    // received ISI-message
       
  1993         )
       
  1994     {
       
  1995     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_INFOSERIALNUMBERREADRESP, "CSatMessHandler::InfoSerialNumberReadResp" );
       
  1996     TFLOGSTRING("TSY:CSatMessHandler::InfoSerialNumberReadResp");
       
  1997 
       
  1998     TUint sbStartOffset( 0 );
       
  1999 
       
  2000     TInt retValue( aIsiMessage.FindSubBlockOffsetById(
       
  2001                     ISI_HEADER_SIZE + SIZE_INFO_SERIAL_NUMBER_READ_RESP,
       
  2002                     INFO_SB_SN_IMEI_PLAIN, EIsiSubBlockTypeId8Len8,
       
  2003                     sbStartOffset ) );
       
  2004     //check if INFO_SB_SN_IMEI_PLAIN sub block is present
       
  2005     if ( KErrNone == retValue )
       
  2006         {
       
  2007         //store imei code
       
  2008         iIMEI.Copy( aIsiMessage.GetData(
       
  2009                     sbStartOffset + INFO_SB_SN_IMEI_PLAIN_OFFSET_IMEIPLAINU8,
       
  2010                     aIsiMessage.Get8bit( sbStartOffset +
       
  2011                     INFO_SB_SN_IMEI_PLAIN_OFFSET_STRLEN ) - 1 ) );
       
  2012         //Set the flag to inform that needed data has been received
       
  2013         iSerialNumberReadReceived = ETrue;
       
  2014         TFLOGSTRING("TSY: SAT, Imei received.");
       
  2015         OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_INFOSERIALNUMBERREADRESP, "SAT, Imei received." );
       
  2016         }
       
  2017     }
       
  2018 
       
  2019 // -----------------------------------------------------------------------------
       
  2020 // CSatMessHandler::NetNeighbourCellsReq
       
  2021 // Constructs NET_NEIGHBOUR_CELLS_REQ ISI message.
       
  2022 // -----------------------------------------------------------------------------
       
  2023 //
       
  2024 TInt CSatMessHandler::NetNeighbourCellsReq
       
  2025         (
       
  2026         TUint8 aTransId,        // Transaction Id
       
  2027         TUint8 aCellInfoType    // Cell info type
       
  2028         )
       
  2029     {
       
  2030     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_NETNEIGHBOURCELLSREQ, "CSatMessHandler::NetNeighbourCellsReq" );
       
  2031     TFLOGSTRING("TSY:CSatMessHandler::NetNeighbourCellsReq");
       
  2032 
       
  2033     TBuf8<1> data;
       
  2034     data.Append( aCellInfoType );
       
  2035 
       
  2036     return iPnSend->Send(
       
  2037         PN_MODEM_NETWORK,
       
  2038         aTransId,
       
  2039         NET_NEIGHBOUR_CELLS_REQ,
       
  2040         data );
       
  2041     }
       
  2042 
       
  2043 
       
  2044 // -----------------------------------------------------------------------------
       
  2045 // CSatMessHandler::NetNeighbourCellResp
       
  2046 // Parse NET_NEIGHBOUR_CELLS_RESP message and read from it BCCH
       
  2047 // channel list and Network measurement results.
       
  2048 // -----------------------------------------------------------------------------
       
  2049 //
       
  2050 void CSatMessHandler::NetNeighbourCellResp
       
  2051         (
       
  2052         const TIsiReceiveC& aIsiMessage
       
  2053         )
       
  2054     {
       
  2055     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_NETNEIGHBOURCELLRESP, "CSatMessHandler::NetNeighbourCellResp" );
       
  2056     TFLOGSTRING("TSY:CSatMessHandler::NetNeighbourCellResp");
       
  2057 
       
  2058     TUint8 result( RSat::KSuccess );
       
  2059 
       
  2060     if ( iTsySatMessaging->GetNotifyLocalInfo()->Status() )
       
  2061         {
       
  2062         // Provide local info proactive command is ongoing
       
  2063 
       
  2064         // Subblock offset
       
  2065         TUint sbOffset( 0 );
       
  2066 
       
  2067         TInt successCode ( aIsiMessage.Get8bit(
       
  2068             ISI_HEADER_SIZE + NET_NEIGHBOUR_CELLS_RESP_OFFSET_SUCCESSCODE ) );
       
  2069 
       
  2070         // Additional info
       
  2071         TBuf<1> additionalInfo;
       
  2072         additionalInfo.Zero();
       
  2073 
       
  2074         // Get transaction id
       
  2075         TUint8 transId(
       
  2076             iTsySatMessaging->GetNotifyLocalInfo()->GetTransactionId() );
       
  2077 
       
  2078         // Get command details tlv
       
  2079         TBuf8<5> commandDetails;
       
  2080         commandDetails =
       
  2081             iTsySatMessaging->GetNotifyLocalInfo()->GetCmdDetails();
       
  2082 
       
  2083         TInt sbIndex( 1 );
       
  2084 
       
  2085         TInt retValue( aIsiMessage.FindSubBlockOffsetByIndex(
       
  2086             ISI_HEADER_SIZE + SIZE_NET_NEIGHBOUR_CELLS_RESP,
       
  2087             sbIndex,
       
  2088             EIsiSubBlockTypeId8Len8,
       
  2089             sbOffset ) );
       
  2090 
       
  2091         if ( NET_CAUSE_OK == successCode && KErrNone == retValue )
       
  2092             {
       
  2093             if ( NET_LIMITED_SERVICE == iLocInfo.iRegStatus )
       
  2094                 {
       
  2095                 result = RSat::KSuccessLimitedService;
       
  2096                 }
       
  2097 
       
  2098             switch( aIsiMessage.Get8bit( sbOffset ) )
       
  2099                 {
       
  2100                 case NET_GSM_SIM_NMR_INFO:
       
  2101                     {
       
  2102                     // Store network measurements results, 16 bytes
       
  2103                     iNMR = aIsiMessage.GetData( sbOffset
       
  2104                         + NET_GSM_SIM_NMR_INFO_OFFSET_MEASUREMENTRESULTS,
       
  2105                         16 );
       
  2106 
       
  2107                     // Get BCCH channel list
       
  2108                     TUint numChannels( aIsiMessage.Get8bit( sbOffset
       
  2109                         + NET_GSM_SIM_NMR_INFO_OFFSET_NUMBEROFCHANNELS ) );
       
  2110 
       
  2111                     // Each channel takes 2 bytes
       
  2112                     TPtrC8 bcchList( aIsiMessage.GetData(
       
  2113                         sbOffset + NET_GSM_SIM_NMR_INFO_OFFSET_ARFCN,
       
  2114                         2 * numChannels ) );
       
  2115 
       
  2116                     for ( TInt i = 0; i < bcchList.Length(); i+=2 )
       
  2117                         {
       
  2118                         iBCCHChannelList.Append(
       
  2119                             bcchList[i] << 8 | bcchList[i+1] );
       
  2120                         }
       
  2121                     // Call local info terminal response method to send
       
  2122                     // terminal response to the sim card.
       
  2123                     LocalInfoTerminalResp( transId,
       
  2124                         commandDetails,
       
  2125                         result,
       
  2126                         additionalInfo );
       
  2127                     break;
       
  2128                     }
       
  2129                 case NET_UTRAN_SIM_NMR_INFO:
       
  2130                     {
       
  2131                     TUint8 reportLength( aIsiMessage.Get8bit( sbOffset
       
  2132                         + NET_UTRAN_SIM_NMR_INFO_OFFSET_MEASREPORTLENGTH ) );
       
  2133 
       
  2134                     iUtranNMR.Set( aIsiMessage.GetData(
       
  2135                         sbOffset + NET_UTRAN_SIM_NMR_INFO_OFFSET_MEASREPORT,
       
  2136                         reportLength ) );
       
  2137 
       
  2138                     LocalInfoTerminalResp( transId,
       
  2139                         commandDetails,
       
  2140                         result,
       
  2141                         additionalInfo );
       
  2142                     break;
       
  2143                     }
       
  2144                 default:
       
  2145                     {
       
  2146                     //Response included unexpected subblock
       
  2147                     iNMR.Zero();
       
  2148                     iBCCHChannelList.Zero();
       
  2149                     iUtranNMR.Set( KNullDesC8 );
       
  2150                     additionalInfo.Append( RSat::KNoService );
       
  2151                     // Send terminal response to the sim card
       
  2152                     LocalInfoTerminalResp( transId,
       
  2153                         commandDetails,
       
  2154                         RSat::KMeUnableToProcessCmd,
       
  2155                         additionalInfo );
       
  2156                     break;
       
  2157                     }
       
  2158                 }
       
  2159             }
       
  2160         else
       
  2161             {
       
  2162             // No service
       
  2163             iNMR.Zero();
       
  2164             iBCCHChannelList.Zero();
       
  2165             iUtranNMR.Set( KNullDesC8 );
       
  2166             additionalInfo.Append( RSat::KNoService );
       
  2167             // Send terminal response to the sim card
       
  2168             LocalInfoTerminalResp( transId,
       
  2169                 commandDetails,
       
  2170                 RSat::KMeUnableToProcessCmd,
       
  2171                 additionalInfo );
       
  2172             }
       
  2173         // Clear local info flag
       
  2174         iTsySatMessaging->GetNotifyLocalInfo()->Status( ETrue );
       
  2175         }
       
  2176     }
       
  2177 
       
  2178 
       
  2179 // -----------------------------------------------------------------------------
       
  2180 // CSatMessHandler::CallModemResourceReq
       
  2181 // Sends a CALL_MODEM_RESOURCE_REQ ISI message.
       
  2182 // -----------------------------------------------------------------------------
       
  2183 //
       
  2184 TInt CSatMessHandler::CallModemResourceReq( 
       
  2185     TUint8 aTransId,
       
  2186     const TDesC8& aMsg 
       
  2187     )
       
  2188     {
       
  2189     TFLOGSTRING("TSY:CSatMessHandler::CallModemResourceReq");
       
  2190     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_CALLMODEMRESOURCEREQ, "TSY:CSatMessHandler::CallModemResourceReq" );
       
  2191 
       
  2192     return iPnSend->Send( PN_MODEM_CALL, aTransId, CALL_MODEM_RESOURCE_REQ, aMsg );
       
  2193     }
       
  2194 
       
  2195 // -----------------------------------------------------------------------------
       
  2196 // CSatMessHandler::CallModemResourceConfReq
       
  2197 // Sends a CALL_MODEM_RESOURCE_CONF_REQ ISI message.
       
  2198 // -----------------------------------------------------------------------------
       
  2199 //
       
  2200 TInt CSatMessHandler::CallModemResourceConfReq(
       
  2201     TUint16 aResourceId,
       
  2202     TUint16 aResourceIdMask )
       
  2203     {
       
  2204     TFLOGSTRING("TSY:CSatMessHandler::CallModemResourceConfReq");
       
  2205     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_CALLMODEMRESOURCECONFREQ, "TSY:CSatMessHandler::CallModemResourceConfReq" );
       
  2206 
       
  2207     TBuf8< SIZE_CALL_MODEM_RESOURCE_CONF_REQ + 
       
  2208         SIZE_CALL_MODEM_SB_RESOURCE_CONF> msg;
       
  2209 
       
  2210     // CALL_MODEM_RES_CONF_OPERATION
       
  2211     msg.Append( CALL_MODEM_RES_CONF_SET );
       
  2212     // Nbr of sb's
       
  2213     msg.Append( 1 );
       
  2214     
       
  2215     TIsiSubBlock sbResourceConf(
       
  2216         msg,
       
  2217         CALL_MODEM_SB_RESOURCE_CONF,
       
  2218         EIsiSubBlockTypeId8Len8 );
       
  2219     
       
  2220     TSatUtility::AppendWord( aResourceId, msg );
       
  2221     TSatUtility::AppendWord( aResourceIdMask, msg);
       
  2222     
       
  2223     sbResourceConf.CompleteSubBlock();
       
  2224     
       
  2225     return iPnSend->Send( 
       
  2226         PN_MODEM_CALL, 
       
  2227         iTsySatMessaging->GetTransactionId(),
       
  2228         CALL_MODEM_RESOURCE_CONF_REQ,
       
  2229         msg );
       
  2230     }
       
  2231 
       
  2232 // -----------------------------------------------------------------------------
       
  2233 // CSatMessHandler::SsResourceConfReq
       
  2234 // Sends a SS_RESOURCE_CONF_REQ ISI message.
       
  2235 // -----------------------------------------------------------------------------
       
  2236 //
       
  2237 TInt CSatMessHandler::SsResourceConfReq()
       
  2238     {
       
  2239     TFLOGSTRING("TSY:CSatMessHandler::SsResourceConfReq");
       
  2240     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SSRESOURCECONFREQ, "TSY:CSatMessHandler::SsResourceConfReq" );
       
  2241      
       
  2242     TBuf8< SIZE_SS_RESOURCE_CONF_REQ  + 
       
  2243         SIZE_SS_SB_RESOURCE_CONF > msg;
       
  2244 
       
  2245     // SS_RESOURCE_CONF_OPERATION 
       
  2246     msg.Append( SS_RESOURCE_CONF_SET );
       
  2247     // Nbr of sb's
       
  2248     msg.Append( 1 );
       
  2249     
       
  2250     TIsiSubBlock sbResourceConf(
       
  2251         msg,
       
  2252         SS_SB_RESOURCE_CONF,
       
  2253         EIsiSubBlockTypeId8Len8 );
       
  2254     
       
  2255     TSatUtility::AppendWord( SS_RES_ID_MO_SS_OPERATION, msg );
       
  2256     TSatUtility::AppendWord( SS_RES_ID_MO_SS_OPERATION_MASK, msg);
       
  2257     
       
  2258     sbResourceConf.CompleteSubBlock();
       
  2259     
       
  2260     return iPnSend->Send( 
       
  2261         PN_SS, 
       
  2262         iTsySatMessaging->GetTransactionId(),
       
  2263         SS_RESOURCE_CONF_REQ,
       
  2264         msg );
       
  2265     }
       
  2266 
       
  2267 // -----------------------------------------------------------------------------
       
  2268 // CSatMessHandler::SsResourceControlReq
       
  2269 // Sends a SS_RESOURCE_CONNTROL_REQ ISI message.
       
  2270 // -----------------------------------------------------------------------------
       
  2271 //
       
  2272 TInt CSatMessHandler::SsResourceControlReq( 
       
  2273     TUint8 aTransId,
       
  2274     const TDesC8& aMsg 
       
  2275     )
       
  2276     {
       
  2277     TFLOGSTRING("TSY:CSatMessHandler::SsResourceControlReq");
       
  2278     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SSRESOURCECONTROLREQ, "TSY:CSatMessHandler::SsResourceControlReq" );
       
  2279 
       
  2280     return iPnSend->Send(
       
  2281         PN_SS,
       
  2282         aTransId,
       
  2283         SS_RESOURCE_CONTROL_REQ,
       
  2284         aMsg );
       
  2285     }
       
  2286 
       
  2287 // -----------------------------------------------------------------------------
       
  2288 // CSatMessHandler::GpdsResourceConfReq
       
  2289 // Sends a GPDS_RESOURCE_CONF_REQISI message.
       
  2290 // -----------------------------------------------------------------------------
       
  2291 //
       
  2292 TInt CSatMessHandler::GpdsResourceConfReq()
       
  2293     {
       
  2294     TFLOGSTRING("TSY:CSatMessHandler::GpdsResourceConfReq");
       
  2295     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GPDSRESOURCECONFREQ, "TSY:CSatMessHandler::GpdsResourceConfReq" );
       
  2296     
       
  2297     TBuf8< SIZE_GPDS_RESOURCE_CONF_REQ  + 
       
  2298         SIZE_GPDS_RESOURCE_CONF > msg;
       
  2299 
       
  2300     // SS_RESOURCE_CONF_OPERATION 
       
  2301     msg.Append( GPDS_RESOURCE_CONF_SET );
       
  2302     // Nbr of sb's
       
  2303     msg.Append( 1 );
       
  2304 
       
  2305     TIsiSubBlock sbResourceConf(
       
  2306         msg,
       
  2307         GPDS_RESOURCE_CONF,
       
  2308         EIsiSubBlockTypeId8Len8 );
       
  2309 
       
  2310     TSatUtility::AppendWord( GPDS_RES_ID_CC_FOR_GPRS, msg );
       
  2311     TSatUtility::AppendWord( GPDS_RES_ID_MASK_CC_FOR_GPRS, msg);
       
  2312 
       
  2313     sbResourceConf.CompleteSubBlock();
       
  2314 
       
  2315     return iPnSend->Send( 
       
  2316         PN_GPDS, 
       
  2317         iTsySatMessaging->GetTransactionId(),
       
  2318         GPDS_RESOURCE_CONF_REQ,
       
  2319         msg );
       
  2320         }
       
  2321 
       
  2322 // -----------------------------------------------------------------------------
       
  2323 // CSatMessHandler::GpdsResourceControlReq
       
  2324 // Sends a GPDS_RESOURCE_CONNTROL_REQ ISI message.
       
  2325 // -----------------------------------------------------------------------------
       
  2326 //
       
  2327 TInt CSatMessHandler::GpdsResourceControlReq( 
       
  2328     TUint8 aTransId,
       
  2329     const TDesC8& aMsg 
       
  2330     )
       
  2331     {
       
  2332     TFLOGSTRING("TSY:CSatMessHandler::GpdsResourceControlReq");
       
  2333 OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GPDSRESOURCECONTROLREQ, "CSatMessHandler::GpdsResourceControlReq" );
       
  2334 
       
  2335     return iPnSend->Send(
       
  2336         PN_GPDS,
       
  2337         aTransId,
       
  2338         GPDS_RESOURCE_CONTROL_REQ,
       
  2339         aMsg );
       
  2340     }
       
  2341 
       
  2342 // -----------------------------------------------------------------------------
       
  2343 // CSatMessHandler::SetPollingInterval
       
  2344 // Set Polling Interval, sending a request to sim server
       
  2345 // -----------------------------------------------------------------------------
       
  2346 //
       
  2347 void CSatMessHandler::SetPollingInterval( TUint8 aTraId, TUint8 aValue )
       
  2348     {
       
  2349     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SETPOLLINGINTERVAL, "CSatMessHandler::SetPollingInterval" );
       
  2350     TFLOGSTRING("TSY:CSatMessHandler::SetPollingInterval");
       
  2351 
       
  2352     iPollingInterval = aValue;
       
  2353 
       
  2354     TIsiSend isiMsg( iPnSend->SendBufferDes() );
       
  2355     isiMsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_UICC );
       
  2356     isiMsg.Set8bit(
       
  2357         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_TRANSID,
       
  2358         aTraId );
       
  2359     isiMsg.Set8bit(
       
  2360         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_MESSAGEID,
       
  2361         UICC_CAT_REQ );
       
  2362     isiMsg.Set8bit(
       
  2363         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_SERVICETYPE,
       
  2364         UICC_CAT_POLLING_SET );
       
  2365     isiMsg.Set8bit(
       
  2366         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_NSB,
       
  2367         1 );
       
  2368 
       
  2369     // Add UICC_SB_POLLING_SET
       
  2370     TBuf8<SIZE_UICC_SB_POLLING_SET> uiccSbPollingBuf( 0 );
       
  2371     TIsiSubBlock uiccSbPolling(
       
  2372         uiccSbPollingBuf,
       
  2373         UICC_SB_POLLING_SET,
       
  2374         EIsiSubBlockTypeId16Len16 );
       
  2375 
       
  2376     // Polling interval
       
  2377     uiccSbPollingBuf.Append( aValue >> 8 );
       
  2378     uiccSbPollingBuf.Append( aValue );
       
  2379 
       
  2380     // 2x filler
       
  2381     uiccSbPollingBuf.Append( KPadding );
       
  2382     uiccSbPollingBuf.Append( KPadding );
       
  2383 
       
  2384     // Append subblock to ISI message
       
  2385     isiMsg.CopyData(
       
  2386         ISI_HEADER_SIZE + SIZE_UICC_CAT_REQ,
       
  2387         uiccSbPolling.CompleteSubBlock() );
       
  2388 
       
  2389     iPnSend->Send( isiMsg.Complete() );
       
  2390     }
       
  2391 
       
  2392 
       
  2393 // -----------------------------------------------------------------------------
       
  2394 // CSatMessHandler::TimerMgmtTerminalResp
       
  2395 // Constructs and sends the Local information response to phonet
       
  2396 // -----------------------------------------------------------------------------
       
  2397 //
       
  2398 TInt CSatMessHandler::TimerMgmtTerminalResp
       
  2399         (
       
  2400         TUint8 aTransId,              // Transaction id
       
  2401         TDes8& aCommandDetails,       // command details
       
  2402         TUint8 aGeneralResult,        // General result
       
  2403         TUint8 aTimerValue[3],        // Timer Value
       
  2404         TUint8 aTimerId,              // Timer Identifier
       
  2405         TUint8 aAdditionalInfo       // Additional info
       
  2406         )
       
  2407     {
       
  2408     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_TIMERMGMTTERMINALRESP, "CSatMessHandler::TimerMgmtTerminalResp" );
       
  2409     TFLOGSTRING("TSY:CSatMessHandler::TimerMgmtTerminalResp");
       
  2410 
       
  2411     // Create and append response data
       
  2412     TTlv tlvSpecificData;
       
  2413 
       
  2414     //create General Result TLV here
       
  2415     tlvSpecificData.AddTag( KTlvResultTag );
       
  2416 
       
  2417     //General result
       
  2418     tlvSpecificData.AddByte( aGeneralResult );
       
  2419 
       
  2420     //include timer value and id only when command is performed successfully
       
  2421     if( RSat::KSuccess == aGeneralResult )
       
  2422         {
       
  2423 
       
  2424         //Timer Id
       
  2425         //Value KTlvTimerIdentifierTagCRBitOn ( 0xA4 ) is added,
       
  2426         //because used KTlvTimerIdentifierTag ( 0x24 ) doesn't
       
  2427         //include comprehension bit in tag the value and it is expected
       
  2428         //to be present in indications and terminal responses.
       
  2429         tlvSpecificData.AddTag( KTlvTimerIdentifierTagCRBitOn );
       
  2430 
       
  2431         tlvSpecificData.AddByte( aTimerId );
       
  2432 
       
  2433         //Timer value is included when the Command Qualifier is indicating
       
  2434         //"deactivate" or "get the current value of the timer"
       
  2435         if ( aCommandDetails[4] )
       
  2436             {
       
  2437             tlvSpecificData.AddTag( KTlvTimerValueTag );
       
  2438             //Timer value in semi-octets
       
  2439             tlvSpecificData.AddByte( aTimerValue[0] ); //hours
       
  2440             tlvSpecificData.AddByte( aTimerValue[1] ); //minutes
       
  2441             tlvSpecificData.AddByte( aTimerValue[2] ); //seconds
       
  2442             }
       
  2443         }
       
  2444     else if( RSat::KContradictionWithTimerState != aGeneralResult &&
       
  2445              RSat::KErrorRequiredValuesMissing != aGeneralResult &&
       
  2446              RSat::KCmdDataNotUnderstood != aGeneralResult &&
       
  2447              RSat::KCmdTypeNotUnderstood != aGeneralResult )
       
  2448         {
       
  2449         tlvSpecificData.AddByte( aAdditionalInfo );
       
  2450         }
       
  2451     else
       
  2452         {
       
  2453         TFLOGSTRING("TSY: CSatMessHandler::TimerMgmtTerminalResp, Unknown result.");
       
  2454         OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_TIMERMGMTTERMINALRESP, "CSatMessHandler::TimerMgmtTerminalResp, Unknown result." );
       
  2455         }
       
  2456 
       
  2457     return UiccCatReqTerminalResponse(
       
  2458         aCommandDetails,
       
  2459         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  2460         aTransId );
       
  2461     }
       
  2462 
       
  2463 
       
  2464 // -----------------------------------------------------------------------------
       
  2465 // CSatMessHandler::TimerExpirationInd
       
  2466 // Constructs TimerExpiration and calls SendAtkEnvelopeNtf to send the indication
       
  2467 // -----------------------------------------------------------------------------
       
  2468 //
       
  2469 TInt CSatMessHandler::TimerExpirationInd
       
  2470         (
       
  2471         TUint8 aTransId,        // Transaction id
       
  2472         TUint8 aTimerId,        // Timer Identifier
       
  2473         TUint8 aTimerValue[3]   // Timer Value
       
  2474         )
       
  2475     {
       
  2476     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_TIMEREXPIRATIONIND, "CSatMessHandler::TimerExpirationInd" );
       
  2477     TFLOGSTRING("TSY:CSatMessHandler::TimerExpirationInd");
       
  2478 
       
  2479     TTlv data;
       
  2480 
       
  2481     data.Begin( KBerTlvTimerExpirationTag );
       
  2482 
       
  2483     //Create Device Identity TLV
       
  2484     //Device identity tag
       
  2485     data.AddTag( KTlvDeviceIdentityTag );
       
  2486     //Source device identity = ME
       
  2487     data.AddByte( KMe );
       
  2488     //Destination device identity = SIM
       
  2489     data.AddByte( KSim );
       
  2490 
       
  2491     //Value KTlvTimerIdentifierTagCRBitOn ( 0xA4 ) is added,
       
  2492     //because used KTlvTimerIdentifierTag ( 0x24 ) doesn't
       
  2493     //include comprehension bit in tag the value and it is expected
       
  2494     //to be present in indications and terminal responses.
       
  2495     data.AddTag( KTlvTimerIdentifierTagCRBitOn );
       
  2496     data.AddByte( aTimerId);
       
  2497     //Timer value in semi-octets
       
  2498     data.AddTag( KTlvTimerValueTag );
       
  2499     data.AddByte( aTimerValue[0] ); //hours
       
  2500     data.AddByte( aTimerValue[1] ); //minutes
       
  2501     data.AddByte( aTimerValue[2] ); //seconds
       
  2502 
       
  2503     return UiccCatReqEnvelope( aTransId, data.End() );
       
  2504     }
       
  2505 
       
  2506 // -----------------------------------------------------------------------------
       
  2507 // CSatMessHandler::RefreshResult
       
  2508 // Method to analyze refresh result from SIM Server.
       
  2509 // Called by CSatMessHandler::SimAtkResp.
       
  2510 // -----------------------------------------------------------------------------
       
  2511 //
       
  2512 void CSatMessHandler::RefreshResult( TUint8 aStatus ) // UICC server status
       
  2513     {
       
  2514     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_REFRESHRESULT, "CSatMessHandler::RefreshResult" );
       
  2515     TFLOGSTRING("TSY:CSatMessHandler::RefreshResult");
       
  2516 
       
  2517     TUint8 result( RSat::KSuccess );
       
  2518     TUint8 additionalInfo( 0 );
       
  2519     TInt ret( KErrNone );
       
  2520 
       
  2521     if ( iRefreshRequestIsOn )
       
  2522         {
       
  2523         switch ( aStatus )
       
  2524             {
       
  2525             case UICC_STATUS_OK:
       
  2526                 {
       
  2527                 // Refresh is done!
       
  2528                 TFLOGSTRING("TSY: CSatMessHandler::RefreshResult, ISA has performed refresh successfully ");
       
  2529                 TFLOGSTRING("TSY: CSatMessHandler::RefreshResult, Inform S60 to re-read SIM data");
       
  2530                 OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_REFRESHRESULT, "CSatMessHandler::RefreshResult, ISA has performed refresh successfully " );
       
  2531                 OstTrace0( TRACE_NORMAL, DUP2_CSATMESSHANDLER_REFRESHRESULT, "CSatMessHandler::RefreshResult, Inform S60 to re-read SIM data" );
       
  2532 
       
  2533                 // Read service table
       
  2534                 if ( CSatNotifyRefresh::KCacheEFSST &
       
  2535                     iTsySatMessaging->GetNotifyRefresh()->CachedFiles() )
       
  2536                     {
       
  2537                     // Re-read EF-UST
       
  2538                     // Call control in USSD is supported only in SIM, byte 6
       
  2539                     if ( UICC_CARD_TYPE_ICC == iCardType )
       
  2540                         {
       
  2541                         UiccReadServiceTableReq( KUiccTrIdServiceTableByte6, 5 );
       
  2542                         }
       
  2543 
       
  2544                     // Call control, byte 4 from service table
       
  2545                     UiccReadServiceTableReq( KUiccTrIdServiceTableByte4, 3 );
       
  2546 #ifdef INFO_PP_ATK_MO_SM_CONTROL
       
  2547                     // Check MO SMS control is supported by product profile
       
  2548                     // USIM: byte 4, SIM: byte 5
       
  2549                     TUint8 serviceTableTrIdMoSms( KUiccTrIdServiceTableByte4 );
       
  2550                     TUint8 serviceTableOffsetMoSms( 3 );
       
  2551                     if ( UICC_CARD_TYPE_ICC == iCardType )
       
  2552                         {
       
  2553                         // Transaction ID and byte offset for SIM
       
  2554                         serviceTableTrIdMoSms = KUiccTrIdServiceTableByte5;
       
  2555                         serviceTableOffsetMoSms = 4;
       
  2556                         }
       
  2557                     if ( iMoSmsSupportedInPp )
       
  2558                         {
       
  2559                         // ...and by SIM service table
       
  2560                         UiccReadServiceTableReq(
       
  2561                             serviceTableTrIdMoSms,
       
  2562                             serviceTableOffsetMoSms );
       
  2563                         }
       
  2564 #else
       
  2565                     // If flag not defined, check feature availability only
       
  2566                     // from USIM
       
  2567                     UiccReadServiceTableReq(
       
  2568                         serviceTableTrIdMoSms,
       
  2569                         serviceTableOffsetMoSms );
       
  2570 #endif // INFO_PP_ATK_MO_SM_CONTROL
       
  2571                     }
       
  2572                 break;
       
  2573                 }
       
  2574             default:
       
  2575                 {
       
  2576                 TFLOGSTRING2("TSY: CSatMessHandler::RefreshResult, refresh failed, UICC STATUS: 0x%x", aStatus );
       
  2577                 OstTraceExt1( TRACE_NORMAL, DUP4_CSATMESSHANDLER_REFRESHRESULT, "CSatMessHandler::RefreshResult, refresh failed, UICC STATUS: 0x%hhx", aStatus );
       
  2578                 result = RSat::KMeUnableToProcessCmd;
       
  2579                 additionalInfo = RSat::KNoSpecificMeProblem;
       
  2580                 ret = KErrGeneral;
       
  2581                 break;
       
  2582                 }
       
  2583             }
       
  2584 
       
  2585         if ( RSat::KSuccess != result )
       
  2586             {
       
  2587             // If result was not successfull then send terminal response
       
  2588             // Otherwise terminal response is sent by the Client.
       
  2589             RefreshTerminalResp(
       
  2590                 iTsySatMessaging->GetNotifyRefresh()->GetTransactionId(),
       
  2591                 iTsySatMessaging->GetNotifyRefresh()->GetCmdDetails(),
       
  2592                 result,
       
  2593                 additionalInfo );
       
  2594             }
       
  2595         // Complete refresh to the client even if it was not successfully,
       
  2596         // for buffer cleaning purposes. Also this way the Client will know
       
  2597         // that refresh was terminated.
       
  2598         iTsySatMessaging->GetNotifyRefresh()->CompleteRequest( ret );
       
  2599         // Refresh is now handled, clear refresh flag
       
  2600         iRefreshRequestIsOn = EFalse;
       
  2601         }
       
  2602     }
       
  2603 
       
  2604 
       
  2605 // -----------------------------------------------------------------------------
       
  2606 // CSatMessHandler::SendSmsReportReq
       
  2607 // Send a Sms-Pp report to SMS server using a request
       
  2608 // -----------------------------------------------------------------------------
       
  2609 //
       
  2610 void CSatMessHandler::SendSmsReportReq
       
  2611         (
       
  2612         TUint8 aTransId,
       
  2613         TDesC8& aData
       
  2614         )
       
  2615     {
       
  2616     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SENDSMSREPORTREQ, "CSatMessHandler::SendSmsReportReq" );
       
  2617     TFLOGSTRING("CSatMessHandler::SendSmsReportReq");
       
  2618 
       
  2619     iPnSend->Send( PN_SMS, aTransId, SMS_RECEIVED_MSG_REPORT_REQ, aData );
       
  2620     }
       
  2621 
       
  2622 // -----------------------------------------------------------------------------
       
  2623 // CSatMessHandler::SmsResourceConfReq
       
  2624 // Send a request to SMS server
       
  2625 // -----------------------------------------------------------------------------
       
  2626 //
       
  2627 void CSatMessHandler::SmsResoureConfReq
       
  2628         (
       
  2629         TUint8 aTransId,
       
  2630         TUint8 aMsgId,
       
  2631         TDesC8& aData
       
  2632         )
       
  2633     {
       
  2634     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SMSRESOURCECONFREQ, "CSatMessHandler::SmsResourceConfReq" );
       
  2635     TFLOGSTRING("CSatMessHandler::SmsResourceConfReq");
       
  2636 
       
  2637     iPnSend->Send( PN_SMS, aTransId, aMsgId, aData );
       
  2638     }
       
  2639 
       
  2640 // -----------------------------------------------------------------------------
       
  2641 // CSatMessHandler::SetPollingResult
       
  2642 // Sends terminal response according to the response coming from Sim server
       
  2643 // to a request having a service type KSimStSetPolling.
       
  2644 // This method handles both PollingInterval and PollingOff proactive commands.
       
  2645 // Called by SimAtkResp.
       
  2646 // -----------------------------------------------------------------------------
       
  2647 //
       
  2648 void CSatMessHandler::SetPollingResult(
       
  2649         TUint8 aStatus,
       
  2650         TUint8 aTransId,
       
  2651         TUint8 aInterval
       
  2652         )
       
  2653     {
       
  2654     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SETPOLLINGRESULT, "CSatMessHandler::SetPollingResult" );
       
  2655     TFLOGSTRING("TSY:CSatMessHandler::SetPollingResult ");
       
  2656 
       
  2657     if ( UICC_STATUS_OK == aStatus )
       
  2658         {
       
  2659         // The response can be from a PollInterval or a PollingOff command
       
  2660         if ( iPollingOff )
       
  2661             {
       
  2662             TFLOGSTRING("TSY:CSatMessHandler::SetPollingResult, iPollingOff = ETrue");
       
  2663             OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_SETPOLLINGRESULT, "CSatMessHandler::SetPollingResult, iPollingOff = ETrue" );
       
  2664             PollingOffTerminalResp(
       
  2665                 aTransId,
       
  2666                 iTsySatMessaging->GetNotifyPollingOff()->GetCmdDetails(),
       
  2667                 RSat::KSuccess,
       
  2668                 RSat::KNoAdditionalInfo );
       
  2669             }
       
  2670         else
       
  2671             {
       
  2672             TFLOGSTRING("TSY:CSatMessHandler::SetPollingResult, iPollingOff = EFalse");
       
  2673             OstTrace0( TRACE_NORMAL, DUP2_CSATMESSHANDLER_SETPOLLINGRESULT, "CSatMessHandler::SetPollingResult, iPollingOff = EFalse" );
       
  2674             PollIntervalTerminalResp(
       
  2675                 aTransId,
       
  2676                 iTsySatMessaging->GetNotifyPollInterval()->GetCmdDetails(),
       
  2677                 RSat::KSuccess,
       
  2678                 RSat::KNoAdditionalInfo,
       
  2679                 aInterval );
       
  2680             }
       
  2681         }
       
  2682     else
       
  2683         {
       
  2684         if ( iPollingOff )
       
  2685             {
       
  2686             // PollingOff was actually not executed, then set iPollingOff to false
       
  2687             iPollingOff = EFalse;
       
  2688             PollingOffTerminalResp(
       
  2689                 aTransId,
       
  2690                 iTsySatMessaging->GetNotifyPollingOff()->GetCmdDetails(),
       
  2691                 RSat::KMeUnableToProcessCmd,
       
  2692                 RSat::KNoSpecificMeProblem );
       
  2693             }
       
  2694         else
       
  2695             {
       
  2696             // If last request rejected and request was over 25 seconds,
       
  2697             // renew the request with legacy maximum. Otherwise there was
       
  2698             // an actual error
       
  2699             if ( iLongPollIntervalReq )
       
  2700                 {
       
  2701                 SetPollingInterval(aTransId, KMaxLegacyPollInterval );
       
  2702                 iLongPollIntervalReq = EFalse;
       
  2703                 }
       
  2704             else
       
  2705                 {
       
  2706                 PollIntervalTerminalResp(
       
  2707                 aTransId,
       
  2708                 iTsySatMessaging->GetNotifyPollInterval()->GetCmdDetails(),
       
  2709                 RSat::KMeUnableToProcessCmd,
       
  2710                 RSat::KNoSpecificMeProblem,
       
  2711                 aInterval );
       
  2712                 }
       
  2713             }
       
  2714         }
       
  2715 
       
  2716         // Terminal Response is sent, reset flag
       
  2717         iLongPollIntervalReq = EFalse;
       
  2718     }
       
  2719 
       
  2720 // -----------------------------------------------------------------------------
       
  2721 // CSatMessHandler::CheckProactiveCommand
       
  2722 // Method to check validity of received proactive command.
       
  2723 // Checked fields are: Proactive command tag, length, device id and
       
  2724 // command details tag.
       
  2725 // -----------------------------------------------------------------------------
       
  2726 //
       
  2727 TInt CSatMessHandler::CheckProactiveCommand
       
  2728         (
       
  2729         const TIsiReceiveC& aIsiMessage // received isi message
       
  2730         )
       
  2731     {
       
  2732     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_CHECKPROACTIVECOMMAND, "CSatMessHandler::CheckProactiveCommand" );
       
  2733     TFLOGSTRING("TSY:CSatMessHandler::CheckProactiveCommand");
       
  2734 
       
  2735     TTlv data;
       
  2736     // Get ber tlv
       
  2737     CBerTlv berTlv;
       
  2738     TBuf8<5> commandDetailsTlv; // 5 = command details data length
       
  2739 
       
  2740     // BerTlv method checks Proactive command tag 'D0'.
       
  2741     if ( KErrNone == berTlv.BerTlv( aIsiMessage ) )
       
  2742         {
       
  2743         TInt ret( KErrNone );
       
  2744         TUint8 generalResult( 0 );
       
  2745 
       
  2746         CTlv commandDetails;
       
  2747         CTlv deviceId;
       
  2748         // Get length part of TLV
       
  2749         TUint16 length( berTlv.GetLength() );
       
  2750 
       
  2751         // compare TLVs length value and real length
       
  2752         if ( length > KOneByteLengthLimit )
       
  2753             {
       
  2754             // 5 = Proactive command tag + two byte length tag + length + SW1
       
  2755             // + SW2
       
  2756             // GetSize returns total size.
       
  2757             if ( ( length + 5 ) !=  berTlv.GetSize() )
       
  2758                 {
       
  2759                 // result
       
  2760                 generalResult = RSat::KCmdDataNotUnderstood;
       
  2761                 ret = KErrCorrupt;
       
  2762                 }
       
  2763             }
       
  2764         // 4 = Proactive command tag + length + SW1 + SW2
       
  2765         else if ( ( length + 4 ) !=  berTlv.GetSize() )
       
  2766             {
       
  2767             // result
       
  2768             generalResult = RSat::KCmdDataNotUnderstood;
       
  2769             ret = KErrCorrupt;
       
  2770             }
       
  2771         else if ( KErrNone != CheckTlvObjects( berTlv ) )
       
  2772             {
       
  2773             // result
       
  2774             generalResult = RSat::KCmdDataNotUnderstood;
       
  2775             ret = KErrCorrupt;
       
  2776             }
       
  2777 
       
  2778         // Check command details tlv and device id tlv
       
  2779         else if ( ( KErrNotFound == berTlv.TlvByTagValue( &commandDetails,
       
  2780             KTlvCommandDetailsTag ) )
       
  2781             || ( KErrNotFound == berTlv.TlvByTagValue( &deviceId,
       
  2782                 KTlvDeviceIdentityTag ) ) )
       
  2783             {
       
  2784             // result
       
  2785             generalResult = RSat::KErrorRequiredValuesMissing;
       
  2786             ret = KErrCorrupt;
       
  2787             }
       
  2788 
       
  2789         // Check that len of command details is correct
       
  2790         else if( 5 != commandDetails.GetSize() )
       
  2791             {
       
  2792             generalResult = RSat::KCmdDataNotUnderstood;
       
  2793             ret = KErrCorrupt;
       
  2794             }
       
  2795         else
       
  2796             {
       
  2797             TFLOGSTRING("TSY: CSatMessHandler::CheckProactiveCommand. Proactive command Ok.");
       
  2798             OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_CHECKPROACTIVECOMMAND, "CSatMessHandler::CheckProactiveCommand Proactive command Ok." );
       
  2799             }
       
  2800 
       
  2801         if ( KErrCorrupt == ret )
       
  2802             {
       
  2803             if ( !berTlv.TlvByTagValue( &commandDetails,
       
  2804                 KTlvCommandDetailsTag ) && 
       
  2805                 5 == commandDetails.GetSize()  )
       
  2806                 {
       
  2807                 commandDetailsTlv.Copy( commandDetails.Data() );
       
  2808                 }
       
  2809             else
       
  2810                 {
       
  2811                 // The SIM shall interpret a Terminal Response with a command
       
  2812                 // number '00' as belonging to the last proactive command
       
  2813                 // having been sent to the ME.
       
  2814                 // See 3GPP TS 11.14
       
  2815                 commandDetailsTlv.FillZ( 5 ); // 5 = command details data length
       
  2816                 }
       
  2817 
       
  2818             data.AddTag( KTlvResultTag );
       
  2819             data.AddByte( generalResult );
       
  2820 
       
  2821             UiccCatReqTerminalResponse(
       
  2822                 commandDetailsTlv,
       
  2823                 data.GetDataWithoutTopLevelTag(),
       
  2824                 aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID ) );
       
  2825             return KErrCorrupt;
       
  2826             }
       
  2827 
       
  2828         return KErrNone;
       
  2829         }
       
  2830     // 'D0' is missing in the begin of the proactive command.
       
  2831     data.AddTag( KTlvResultTag );
       
  2832     // result
       
  2833     data.AddByte( RSat::KErrorRequiredValuesMissing );
       
  2834     // Set command details tlv to Zero, because method to read command details
       
  2835     // does not work if 'D0' is missing...
       
  2836     commandDetailsTlv.FillZ( 5 ); // 5 = command details data length
       
  2837     UiccCatReqTerminalResponse(
       
  2838         commandDetailsTlv,
       
  2839         data.GetDataWithoutTopLevelTag(),
       
  2840         aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID ) );
       
  2841     return KErrCorrupt;
       
  2842     }
       
  2843 
       
  2844 // -----------------------------------------------------------------------------
       
  2845 // CSatMessHandler::MoreTimeTerminalResp
       
  2846 // Constructs and sends the More Time response to phonet
       
  2847 // -----------------------------------------------------------------------------
       
  2848 //
       
  2849 TInt CSatMessHandler::MoreTimeTerminalResp
       
  2850         (
       
  2851         TUint8 aTransId,            // Transaction id
       
  2852         TDes8& aCommandDetails,     // Command details
       
  2853         TUint8 aGeneralResult       // General result
       
  2854         )
       
  2855     {
       
  2856     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_MORETIMETERMINALRESP, "CSatMessHandler::MoreTimeTerminalResp" );
       
  2857     TFLOGSTRING("TSY:CSatMessHandler::MoreTimeTerminalResp");
       
  2858 
       
  2859     // Create and append response data
       
  2860     TTlv tlvSpecificData;
       
  2861 
       
  2862     //create General Result TLV here
       
  2863     tlvSpecificData.AddTag( KTlvResultTag );
       
  2864 
       
  2865     //General result
       
  2866     tlvSpecificData.AddByte( aGeneralResult );
       
  2867 
       
  2868     return UiccCatReqTerminalResponse(
       
  2869         aCommandDetails,
       
  2870         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  2871         aTransId );
       
  2872     }
       
  2873 
       
  2874 // -----------------------------------------------------------------------------
       
  2875 // CSatMessHandler::SmsCbRoutingReq
       
  2876 // Sends a request to Sms server to allow routing of Cell Broadcast messages.
       
  2877 // -----------------------------------------------------------------------------
       
  2878 //
       
  2879 TInt CSatMessHandler::SmsCbRoutingReq
       
  2880         (
       
  2881         TUint8 aTransId,        // Transaction Id
       
  2882         TUint8 aRoutingCommand  // Routing command
       
  2883         )
       
  2884     {
       
  2885     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SMSCBROUTINGREQ, "CSatMessHandler::SmsCbRoutingReq" );
       
  2886     TFLOGSTRING("TSY:CSatMessHandler::SmsRoutingReq");
       
  2887 
       
  2888     TInt ret( KErrNone );
       
  2889 
       
  2890         // Routing is ongoing
       
  2891         iSmsCbRoutingComplete = EFalse;
       
  2892 
       
  2893         // TBuf8<SIZE_SMS_CB_ROUTING_REQ> because we are sending [U]SIM EF CBMID Message
       
  2894         // Subscription;
       
  2895         TBuf8<SIZE_SMS_CB_ROUTING_REQ> data;
       
  2896         
       
  2897         // Append Routing command
       
  2898         data.Append( aRoutingCommand );
       
  2899         // Append Subscription number
       
  2900         data.Append( SMS_NEW_SUBSCRIPTION );
       
  2901         // append Subscription type
       
  2902         data.Append( SMS_TYPE_SIM );
       
  2903         // Append Filler bytes
       
  2904         data.AppendFill( KPadding, 2 );
       
  2905         // Append no of Subblocks
       
  2906         data.Append( 0 );
       
  2907 
       
  2908         // Send Subscription request 
       
  2909         ret = iPnSend->Send( PN_SMS, aTransId, SMS_CB_ROUTING_REQ,
       
  2910                 data );
       
  2911 
       
  2912     return ret;
       
  2913     }
       
  2914 
       
  2915 // -----------------------------------------------------------------------------
       
  2916 // CSatMessHandler::SmsCbRoutingResp
       
  2917 // Handles response from Sms server for a request of type SmsGsmTempCbRoutingReq.
       
  2918 // -----------------------------------------------------------------------------
       
  2919 //
       
  2920 void CSatMessHandler::SmsCbRoutingResp
       
  2921         (
       
  2922         const TIsiReceiveC& aIsiMessage
       
  2923         )
       
  2924     {
       
  2925     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SMSCBROUTINGRESP, "CSatMessHandler::SmsCbRoutingResp" );
       
  2926     TFLOGSTRING("TSY:CSatMessHandler::SmsCbRoutingResp");
       
  2927 
       
  2928     TUint8 cause( aIsiMessage.Get8bit(
       
  2929         ISI_HEADER_SIZE + SMS_CB_ROUTING_RESP_OFFSET_SMSCAUSE ) );
       
  2930 
       
  2931     switch ( cause )
       
  2932         {
       
  2933         case SMS_ERR_CS_INACTIVE:
       
  2934         case SMS_ERR_SUBJECT_COUNT_OVERFLOW:
       
  2935         case SMS_ERR_DCS_COUNT_OVERFLOW:
       
  2936             {
       
  2937             TFLOGSTRING2("TSY:CSatMessHandler::SmsCbRoutingResp \
       
  2938                 Routing req failed on temporary problem: %d", cause );
       
  2939             OstTraceExt1( TRACE_NORMAL, DUP1_CSATMESSHANDLER_SMSCBROUTINGRESP, "CSatMessHandler::SmsCbRoutingResp Routing req failed on temporary problem: %hhu", cause );
       
  2940             iSmsCbRoutingComplete = EFalse;
       
  2941             break;
       
  2942             }
       
  2943         case SMS_OK:
       
  2944         case SMS_ERR_INVALID_SUBSCRIPTION_NR:
       
  2945         case SMS_ERR_INVALID_PARAMETER:
       
  2946         case SMS_ERR_ALL_SUBSCRIPTIONS_ALLOCATED:
       
  2947         default:
       
  2948             {
       
  2949             // Routing req was either completed successfully, or permanent
       
  2950             // problem occured. In both cases, no need to retry.
       
  2951             iSmsCbRoutingComplete = ETrue;
       
  2952             break;
       
  2953             }
       
  2954         }
       
  2955     }
       
  2956 
       
  2957 
       
  2958 // -----------------------------------------------------------------------------
       
  2959 // CSatMessHandler::SmsResourceConfInd
       
  2960 // Handles Indication from SMS Server for resource configuration Startup 
       
  2961 // and reconfigure condition .
       
  2962 // -----------------------------------------------------------------------------
       
  2963 //
       
  2964 
       
  2965 void CSatMessHandler::SmsResourceConfInd
       
  2966         (
       
  2967         const TIsiReceiveC& aIsiMessage
       
  2968         )
       
  2969     {
       
  2970     TFLOGSTRING("TSY:CSatMoSmsCtrl::SmsResourceConfIndReceived: Response for Resource confoguration Indication, Receive Indication from SMS server");
       
  2971     OstTrace0( TRACE_NORMAL, DUP1_CSATMOSMSCTRL_SMSRESOURCECONFINDRECEIVED, "CSatMoSmsCtrl::SmsResourceRespReceived: Response for Resource Configuration Ind, Receive indication from SMS server" );
       
  2972 
       
  2973     // To check The receive indication is for startup or reconfiguration
       
  2974     if ( SMS_RES_CONF_STARTUP == aIsiMessage.Get8bit( ISI_HEADER_SIZE
       
  2975         + SMS_RESOURCE_CONF_IND_OFFSET_CONFSTATUS ) )
       
  2976         {
       
  2977         TUint sbStartOffset( 0 );
       
  2978         TInt retValue( KErrNotFound );
       
  2979         // Check if resource control is requested for MO SM.
       
  2980         if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  2981             ISI_HEADER_SIZE + SIZE_SMS_RESOURCE_CONF_IND,
       
  2982             SMS_SB_RESOURCE_CONF_REQUIRED,
       
  2983             EIsiSubBlockTypeId16Len16,
       
  2984             sbStartOffset ) )
       
  2985             {
       
  2986             TUint16 resource( aIsiMessage.Get16bit( sbStartOffset +
       
  2987                 SMS_SB_RESOURCE_CONF_REQUIRED_OFFSET_RESPP ) );
       
  2988             // Check MO SMS control is supported by SIM service table
       
  2989             if ( SMS_RES_ID_CONF_MO_SM_INIT == resource )
       
  2990                 {
       
  2991                 if ( UICC_CARD_TYPE_UICC == iCardType )
       
  2992                     {
       
  2993                     // USIM: Read MO-SMS control from byte 4
       
  2994                     UiccReadServiceTableReq( KUiccTrIdServiceTableByte4, 3 );
       
  2995                     }
       
  2996                 else if ( UICC_CARD_TYPE_ICC == iCardType )
       
  2997                     {
       
  2998                     // SIM: Read MO-SMS control from byte 5
       
  2999                     UiccReadServiceTableReq( KUiccTrIdServiceTableByte5, 4 );
       
  3000                     }
       
  3001                 }
       
  3002             }
       
  3003         }
       
  3004     }
       
  3005 
       
  3006 // -----------------------------------------------------------------------------
       
  3007 // CSatMessHandler::NetCellInfoGetReq
       
  3008 // Creates NET_CELL_INFO_GET_REQ ISI message and sends it to Phonet
       
  3009 // -----------------------------------------------------------------------------
       
  3010 //
       
  3011 TInt CSatMessHandler::NetCellInfoGetReq
       
  3012         (
       
  3013         TUint8 aTransId
       
  3014         )
       
  3015     {
       
  3016     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_NETCELLINFOGETREQ, "CSatMessHandler::NetCellInfoGetReq" );
       
  3017     TFLOGSTRING("TSY:CSatMessHandler::NetCellInfoGetReq");
       
  3018 
       
  3019     TBuf8<1> noData;
       
  3020     return iPnSend->Send(
       
  3021         PN_MODEM_NETWORK,
       
  3022         aTransId,
       
  3023         NET_CELL_INFO_GET_REQ,
       
  3024         noData );
       
  3025     }
       
  3026 
       
  3027 // -----------------------------------------------------------------------------
       
  3028 // CSatMessHandler::NetCellInfoGetResp
       
  3029 // Breaks a NET_CELL_INFO_GET_RESP ISI-message and if this response is for
       
  3030 // local info proactive command then send a terminal response to the sim card.
       
  3031 // -----------------------------------------------------------------------------
       
  3032 //
       
  3033 void CSatMessHandler::NetCellInfoGetResp
       
  3034         (
       
  3035         const TIsiReceiveC& aIsiMessage
       
  3036         )
       
  3037     {
       
  3038     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_NETCELLINFOGETRESP, "CSatMessHandler::NetCellInfoGetResp" );
       
  3039     TFLOGSTRING("TSY: CSatMessHandler::NetCellInfoGetResp");
       
  3040 
       
  3041     TBuf<1> additionalInfo;
       
  3042 
       
  3043     // Default result
       
  3044     TUint8 result( RSat::KMeUnableToProcessCmd );
       
  3045 
       
  3046     // Store recieved network parameters
       
  3047     StoreNetServiceStatus( aIsiMessage );
       
  3048 
       
  3049     switch ( iLocInfo.iRegStatus )
       
  3050         {
       
  3051         case NET_SERVICE:
       
  3052             {
       
  3053             result = RSat::KSuccess;
       
  3054             break;
       
  3055             }
       
  3056         case NET_LIMITED_SERVICE:
       
  3057             {
       
  3058             result = RSat::KSuccessLimitedService;
       
  3059             break;
       
  3060             }
       
  3061         case NET_NO_COVERAGE:
       
  3062             {
       
  3063             // Default result value already set
       
  3064             additionalInfo.Append( RSat::KNoService );
       
  3065             break;
       
  3066             }
       
  3067         default:
       
  3068             {
       
  3069             // Default result value already set
       
  3070             TFLOGSTRING2("TSY: CSatMessHandler::NetCellInfoGetResp, Unexpected iRegStatus: %d", iLocInfo.iRegStatus );
       
  3071             OstTrace1( TRACE_NORMAL, DUP1_CSATMESSHANDLER_NETCELLINFOGETRESP, "CSatMessHandler::NetCellInfoGetResp Unexpected iRegStatus: %d", iLocInfo.iRegStatus );
       
  3072             additionalInfo.Append( RSat::KNoSpecificMeProblem );
       
  3073             break;
       
  3074             }
       
  3075         }
       
  3076 
       
  3077     TInt trId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID ) );
       
  3078 
       
  3079     // Check if this response is for provide local info proactive command.
       
  3080     if ( iTsySatMessaging->GetNotifyLocalInfo()->Status()
       
  3081         && iTsySatMessaging->GetNotifyLocalInfo()->GetTransactionId()
       
  3082             == trId )
       
  3083         {
       
  3084         // Send terminal response
       
  3085         LocalInfoTerminalResp( iTsySatMessaging->GetNotifyLocalInfo()
       
  3086                                     ->GetTransactionId(),
       
  3087                                 iTsySatMessaging->GetNotifyLocalInfo()
       
  3088                                     ->GetCmdDetails(),
       
  3089                                 result,
       
  3090                                 additionalInfo );
       
  3091         // Clear local info flag
       
  3092         iTsySatMessaging->GetNotifyLocalInfo()->Status( ETrue );
       
  3093         }
       
  3094     }
       
  3095 
       
  3096 
       
  3097 // -----------------------------------------------------------------------------
       
  3098 // CSatMessHandler::GssCsServiceReq
       
  3099 // Constructs GSS_CS_SERVICE_REQ ISI message.
       
  3100 // -----------------------------------------------------------------------------
       
  3101 //
       
  3102 TInt CSatMessHandler::GssCsServiceReq
       
  3103         (
       
  3104         TUint8 aTransId,          // Transaction Id
       
  3105         TUint8 aOperation         // Gss operation
       
  3106         )
       
  3107     {
       
  3108     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GSSCSSERVICEREQ, "CSatMessHandler::GssCsServiceReq" );
       
  3109     TFLOGSTRING("TSY: CSatMessHandler::GssCsServiceReq ");
       
  3110 
       
  3111     TBuf8<2> data;
       
  3112     data.Append( aOperation );
       
  3113     data.Append( 0x00 ); // number of subblocks
       
  3114     return iPnSend->Send( PN_GSS, aTransId, GSS_CS_SERVICE_REQ, data );
       
  3115     }
       
  3116 
       
  3117 // -----------------------------------------------------------------------------
       
  3118 // CSatMessHandler::GssCsServiceResp
       
  3119 // Breaks GSS_CS_SERVICE_RESP ISI message.
       
  3120 // -----------------------------------------------------------------------------
       
  3121 //
       
  3122 void CSatMessHandler::GssCsServiceResp
       
  3123         (
       
  3124         const TIsiReceiveC& aIsiMessage // Received isi messge
       
  3125         )
       
  3126     {
       
  3127     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GSSCSSERVICERESP, "CSatMessHandler::GssCsServiceResp" );
       
  3128     TFLOGSTRING("CSatMessHandler::GssCsServiceResp ");
       
  3129 
       
  3130     if ( iTsySatMessaging->GetNotifyLocalInfo()->Status() )
       
  3131         {
       
  3132         TUint8 generalResult ( RSat::KSuccess );
       
  3133 
       
  3134         // Provide local info proactive command is ongoing
       
  3135 
       
  3136         TBuf<1> additionalInfo;
       
  3137         additionalInfo.Zero();
       
  3138 
       
  3139         // Get transaction id
       
  3140         TUint8 transId(
       
  3141             iTsySatMessaging->GetNotifyLocalInfo()->GetTransactionId() );
       
  3142         // Get command details tlv
       
  3143         TBuf8<5> commandDetails;
       
  3144         commandDetails =
       
  3145             iTsySatMessaging->GetNotifyLocalInfo()->GetCmdDetails();
       
  3146 
       
  3147         // If this is a Timing advance response and message includes subblocks
       
  3148         if ( GSS_ATK_TIMING_ADVANCE_GET == aIsiMessage.Get8bit(
       
  3149              ISI_HEADER_SIZE + GSS_CS_SERVICE_RESP_OFFSET_OPERATION )
       
  3150              &&
       
  3151              0 < aIsiMessage.Get8bit(
       
  3152              ISI_HEADER_SIZE + GSS_CS_SERVICE_RESP_OFFSET_NBROFSUBBLOCKS ) )
       
  3153             {
       
  3154             // GSS_ATK_TIMING_ADVANCE sub block
       
  3155 
       
  3156             // SubBlock offset
       
  3157             TUint sbOffset( 0 );
       
  3158 
       
  3159             if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  3160                 ISI_HEADER_SIZE + SIZE_GSS_CS_SERVICE_RESP,
       
  3161                 GSS_ATK_TIMING_ADVANCE,
       
  3162                 EIsiSubBlockTypeId8Len8,
       
  3163                 sbOffset) )
       
  3164                 {
       
  3165                 // Store Timing Advance Status
       
  3166                 iTaStatus = aIsiMessage.Get8bit(
       
  3167                     sbOffset + GSS_ATK_TIMING_ADVANCE_OFFSET_TASTATUS );
       
  3168 
       
  3169                 TFLOGSTRING2("TSY: CSatMessHandler::GssCsServiceResp iTaStatus=%d", iTaStatus);
       
  3170                 OstTraceExt1( TRACE_NORMAL, DUP1_CSATMESSHANDLER_GSSCSSERVICERESP, "CSatMessHandler::GssCsServiceResp iTaStatus: %hhu", iTaStatus );
       
  3171 
       
  3172                 // Store timing advance
       
  3173                 iTimingAdvance = aIsiMessage.Get8bit(
       
  3174                     sbOffset + GSS_ATK_TIMING_ADVANCE_OFFSET_TIMINGADVANCE );
       
  3175 
       
  3176                 TFLOGSTRING2("TSY: CSatMessHandler::GssCsServiceResp \
       
  3177                     iTimingAdvance=%d", iTimingAdvance);
       
  3178                 OstTraceExt1( TRACE_NORMAL, DUP2_CSATMESSHANDLER_GSSCSSERVICERESP, "CSatMessHandler::GssCsServiceResp iTimingAdvance: %hhu", iTimingAdvance );
       
  3179 
       
  3180                 if ( GSS_TIMING_ADVANCE_NOT_AVAILABLE == iTimingAdvance )
       
  3181                     {
       
  3182                     generalResult = RSat::KMeUnableToProcessCmd;
       
  3183                     }
       
  3184                 }
       
  3185             else
       
  3186                 {
       
  3187                  generalResult = RSat::KErrorRequiredValuesMissing;
       
  3188                 }
       
  3189 
       
  3190             // Call local info terminal response method to send
       
  3191             // terminal response to the sim card.
       
  3192             LocalInfoTerminalResp( transId,
       
  3193                                     commandDetails,
       
  3194                                     generalResult,
       
  3195                                     additionalInfo );
       
  3196 
       
  3197             // Clear local info flag
       
  3198             iTsySatMessaging->GetNotifyLocalInfo()->Status( ETrue );
       
  3199             }
       
  3200         else
       
  3201             {
       
  3202             // No service
       
  3203             additionalInfo.Append( RSat::KNoService );
       
  3204 
       
  3205             // Clear local info flag
       
  3206             iTsySatMessaging->GetNotifyLocalInfo()->Status( ETrue );
       
  3207 
       
  3208             // Call local info terminal response method to send
       
  3209             // terminal response to the sim card.
       
  3210             LocalInfoTerminalResp( transId,
       
  3211                                     commandDetails,
       
  3212                                     RSat::KMeUnableToProcessCmd,
       
  3213                                     additionalInfo );
       
  3214             }
       
  3215         }
       
  3216     }
       
  3217 
       
  3218 // -----------------------------------------------------------------------------
       
  3219 // CSatMessHandler::GssCsServiceFailResp
       
  3220 // Breaks a GSS_CS_SERVICE_FAIL_RESP ISI message.
       
  3221 // -----------------------------------------------------------------------------
       
  3222 //
       
  3223 void CSatMessHandler::GssCsServiceFailResp
       
  3224         (
       
  3225         const TIsiReceiveC& aIsiMessage // Received isi messge
       
  3226         )
       
  3227     {
       
  3228     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GSSCSSERVICEFAILRESP, "CSatMessHandler::GssCsServiceFailResp" );
       
  3229     TFLOGSTRING("CSatMessHandler::GssCsServiceFailResp ");
       
  3230 
       
  3231     if ( iTsySatMessaging->GetNotifyLocalInfo()->Status() )
       
  3232         {
       
  3233         if ( GSS_ATK_TIMING_ADVANCE_GET == aIsiMessage.Get8bit(
       
  3234              ISI_HEADER_SIZE + GSS_CS_SERVICE_RESP_OFFSET_OPERATION ) )
       
  3235             {
       
  3236             TBuf<1> additionalInfo;
       
  3237             additionalInfo.Zero();
       
  3238             additionalInfo.Append( RSat::KNoService );
       
  3239             // Get transaction id
       
  3240             TUint8 transId(
       
  3241                 iTsySatMessaging->GetNotifyLocalInfo()->GetTransactionId() );
       
  3242             // Get command details tlv
       
  3243             TBuf8<5> commandDetails;
       
  3244             commandDetails =
       
  3245                 iTsySatMessaging->GetNotifyLocalInfo()->GetCmdDetails();
       
  3246 
       
  3247             // Call local info terminal response method to send
       
  3248             // terminal response to the sim card.
       
  3249             LocalInfoTerminalResp( transId,
       
  3250                                     commandDetails,
       
  3251                                     RSat::KMeUnableToProcessCmd,
       
  3252                                     additionalInfo );
       
  3253 
       
  3254             // Clear local info flag
       
  3255             iTsySatMessaging->GetNotifyLocalInfo()->Status( ETrue );
       
  3256             }
       
  3257         }
       
  3258     }
       
  3259 
       
  3260 // -----------------------------------------------------------------------------
       
  3261 // CSatMessHandler::LanguageNotificationTerminalResp
       
  3262 // Constructs LanguageNotification specific part of terminal
       
  3263 // response and calls SendTerminalResponse to send the terminal response
       
  3264 // -----------------------------------------------------------------------------
       
  3265 //
       
  3266 TInt CSatMessHandler::LanguageNotificationTerminalResp
       
  3267         (
       
  3268         TUint8 aTransId,            // Transaction id
       
  3269         TDes8& aCommandDetails,     // Comamnd number
       
  3270         TUint8 aGeneralResult,      // General result
       
  3271         TUint8 aAdditionalInfo      // additional info
       
  3272         )
       
  3273     {
       
  3274     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_LANGUAGENOTIFICATIONTERMINALRESP, "CSatMessHandler::LanguageNotificationTerminalResp" );
       
  3275     TFLOGSTRING("TSY:CSatMessHandler::LanguageNotificationTerminalResp");
       
  3276 
       
  3277     TTlv tlvSpecificData;
       
  3278     // Create general result TLV here
       
  3279     tlvSpecificData.AddTag( KTlvResultTag );
       
  3280 
       
  3281     // General result
       
  3282     tlvSpecificData.AddByte( aGeneralResult );
       
  3283 
       
  3284     if ( RSat::KSuccess != aGeneralResult )
       
  3285         {
       
  3286         tlvSpecificData.AddByte( aAdditionalInfo );
       
  3287         }
       
  3288 
       
  3289     return UiccCatReqTerminalResponse(
       
  3290         aCommandDetails,
       
  3291         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  3292         aTransId );
       
  3293     }
       
  3294 
       
  3295 // -----------------------------------------------------------------------------
       
  3296 // CSatMessHandler::NetTimeInd
       
  3297 // Break's a NET_TIME_IND isi-message and stores time zone information.
       
  3298 // Time zone is needed in provide local information proactive command.
       
  3299 // -----------------------------------------------------------------------------
       
  3300 //
       
  3301 void CSatMessHandler::NetTimeInd
       
  3302         (
       
  3303         const TIsiReceiveC& aIsiMessage
       
  3304         )
       
  3305     {
       
  3306     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_NETTIMEIND, "CSatMessHandler::NetTimeInd" );
       
  3307     TFLOGSTRING("TSY: CSatMessHandler::NetTimeInd");
       
  3308 
       
  3309     // NET_TIME_INFO is mandatory sub block
       
  3310 
       
  3311     // SubBlock offset
       
  3312     TUint sbOffset( 0 );
       
  3313 
       
  3314     // Find NET_TIME_INFO subblock
       
  3315     TInt ret ( aIsiMessage.FindSubBlockOffsetById(
       
  3316                 ISI_HEADER_SIZE + SIZE_NET_TIME_IND,
       
  3317                 NET_TIME_INFO,
       
  3318                 EIsiSubBlockTypeId8Len8,
       
  3319                 sbOffset ) );
       
  3320 
       
  3321     if ( KErrNone == ret )
       
  3322         {
       
  3323         // Get timezone
       
  3324         // If the time zone is invalid or time zone is unknown, all bits are
       
  3325         // set to 1 (including B6).
       
  3326         iTimeZone = aIsiMessage.Get8bit( sbOffset + NET_TIME_INFO_OFFSET_TIMEZONE );
       
  3327         TFLOGSTRING2("TSY: CSatMessHandler::NetTimeInd, Time zone: 0x%x", iTimeZone );
       
  3328         OstTraceExt1( TRACE_NORMAL, DUP1_CSATMESSHANDLER_NETTIMEIND, "CSatMessHandler::NetTimeInd Time zone: %hhu", iTimeZone );
       
  3329         }
       
  3330     }
       
  3331 
       
  3332 // -----------------------------------------------------------------------------
       
  3333 // CSatMessHandler::NetRatReq
       
  3334 // Constructs NET_RAT_REQ ISI message.
       
  3335 // -----------------------------------------------------------------------------
       
  3336 //
       
  3337 TInt CSatMessHandler::NetRatReq
       
  3338         (
       
  3339         TUint8 aTransId         // Transaction Id
       
  3340         )
       
  3341     {
       
  3342     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_NETRATREQ, "CSatMessHandler::NetRatReq" );
       
  3343     TFLOGSTRING("TSY: CSatMessHandler::NetRatReq ");
       
  3344 
       
  3345     TBuf8<1> data;
       
  3346     //we need to know the current RAT
       
  3347     data.Append( NET_CURRENT_RAT );
       
  3348 
       
  3349     return iPnSend->Send( PN_MODEM_NETWORK, aTransId, NET_RAT_REQ, data );
       
  3350     }
       
  3351 
       
  3352 // -----------------------------------------------------------------------------
       
  3353 // CSatMessHandler::NetRatResp
       
  3354 // Constructs NET_RAT_RESP ISI message.
       
  3355 // -----------------------------------------------------------------------------
       
  3356 //
       
  3357 void CSatMessHandler::NetRatResp
       
  3358         (
       
  3359         const TIsiReceiveC& aIsiMessage //received ISI message
       
  3360         )
       
  3361     {
       
  3362     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_NETRATRESP, "CSatMessHandler::NetRatResp" );
       
  3363     TFLOGSTRING("TSY:CSatMessHandler::NetRatResp");
       
  3364 
       
  3365     if ( iTsySatMessaging->GetNotifyLocalInfo()->Status() )
       
  3366         {
       
  3367         TBuf<1> additionalInfo;
       
  3368         additionalInfo.Zero();
       
  3369 
       
  3370         // Get transaction id
       
  3371         TUint8 transId(
       
  3372             iTsySatMessaging->GetNotifyLocalInfo()->GetTransactionId() );
       
  3373 
       
  3374         // Get command details tlv
       
  3375         TBuf8<5> commandDetails;
       
  3376         commandDetails =
       
  3377             iTsySatMessaging->GetNotifyLocalInfo()->GetCmdDetails();
       
  3378 
       
  3379         if ( NET_CAUSE_OK == aIsiMessage.Get8bit(
       
  3380             ISI_HEADER_SIZE + NET_RAT_RESP_OFFSET_SUCCESSCODE ) )
       
  3381             {
       
  3382             TUint8 generalResult ( RSat::KSuccess );
       
  3383 
       
  3384             // Subblock offset
       
  3385             TUint sbOffset( 0 );
       
  3386 
       
  3387             // Check if NET_RAT_INFO sub block is present
       
  3388             TInt ret( aIsiMessage.FindSubBlockOffsetById(
       
  3389                 ISI_HEADER_SIZE + SIZE_NET_RAT_RESP,
       
  3390                 NET_RAT_INFO,
       
  3391                 EIsiSubBlockTypeId8Len8,
       
  3392                 sbOffset ) );
       
  3393 
       
  3394             if ( KErrNone == ret )
       
  3395                 {
       
  3396                 // Get ratName
       
  3397                 TUint8 ratName( aIsiMessage.Get8bit(
       
  3398                     sbOffset + NET_RAT_INFO_OFFSET_RATNAME ) );
       
  3399 
       
  3400                 switch ( ratName )
       
  3401                     {
       
  3402                     case NET_GSM_RAT:
       
  3403                         {
       
  3404                         iCurrentAccTech = KNetworkModeGsm;
       
  3405                         break;
       
  3406                         }
       
  3407                     case NET_UMTS_RAT:
       
  3408                         {
       
  3409                         iCurrentAccTech = KNetworkModeUtran;
       
  3410                         break;
       
  3411                         }
       
  3412                     default:
       
  3413                         {
       
  3414                         generalResult= RSat::KMeUnableToProcessCmd;
       
  3415                         break;
       
  3416                         }
       
  3417                     }
       
  3418                 }
       
  3419             else
       
  3420                 {
       
  3421                 generalResult = RSat::KMeUnableToProcessCmd;
       
  3422                 }
       
  3423 
       
  3424             // Call local info terminal response method to send
       
  3425             // terminal response to the sim card.
       
  3426             LocalInfoTerminalResp( transId,
       
  3427                                 commandDetails,
       
  3428                                 generalResult,
       
  3429                                 additionalInfo );
       
  3430 
       
  3431             // Clear local info flag
       
  3432             iTsySatMessaging->GetNotifyLocalInfo()->Status( ETrue );
       
  3433 
       
  3434             }
       
  3435          else
       
  3436             {
       
  3437             // No service
       
  3438             additionalInfo.Append( RSat::KNoService );
       
  3439 
       
  3440             // Clear local info flag
       
  3441             iTsySatMessaging->GetNotifyLocalInfo()->Status( ETrue );
       
  3442 
       
  3443             // Call local info terminal response method to send
       
  3444             // terminal response to the sim card.
       
  3445             LocalInfoTerminalResp( transId,
       
  3446                                     commandDetails,
       
  3447                                     RSat::KMeUnableToProcessCmd,
       
  3448                                     additionalInfo );
       
  3449             }
       
  3450         }
       
  3451     }
       
  3452 
       
  3453 // -----------------------------------------------------------------------------
       
  3454 // CSatMessHandler::OpenChannelTerminalResp
       
  3455 // Constructs Open Channel specific part of terminal
       
  3456 // response and calls SendTerminalResponse to send the terminal response.
       
  3457 // -----------------------------------------------------------------------------
       
  3458 //
       
  3459 TInt CSatMessHandler::OpenChannelTerminalResp
       
  3460         (
       
  3461         TUint8 aTransId,            // Transaction Id
       
  3462         TDes8& aCommandDetails,     // Command details
       
  3463         TUint8 aGeneralResult,      // General Result
       
  3464         TDes8& aAdditionalInfo,     // Additional Info
       
  3465         TUint8 aBearerType,         // Bearer type
       
  3466         TDesC8& aBearer,            // Bearer
       
  3467         TUint16 aBufferSize         // Buffer size
       
  3468         )
       
  3469     {
       
  3470     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_OPENCHANNELTERMINALRESP, "CSatMessHandler::OpenChannelTerminalResp" );
       
  3471     TFLOGSTRING("CSatMessHandler::OpenChannelTerminalResp");
       
  3472 
       
  3473     // Create and append response data
       
  3474     TTlv tlvSpecificData;
       
  3475 
       
  3476     //create General Result TLV here
       
  3477     tlvSpecificData.AddTag( KTlvResultTag );
       
  3478 
       
  3479     //General result
       
  3480     tlvSpecificData.AddByte( aGeneralResult );
       
  3481 
       
  3482     if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult )
       
  3483         || ( RSat::KNetworkUnableToProcessCmd == aGeneralResult )
       
  3484         || ( RSat::KInteractionWithCCPermanentError == aGeneralResult )
       
  3485         || ( RSat::KErrorRequiredValuesMissing == aGeneralResult )
       
  3486         || ( RSat::KBearerIndepProtocolError == aGeneralResult ) )
       
  3487         {
       
  3488         if( aAdditionalInfo.Length())
       
  3489         // UNSuccessful result neccessitating additional info byte
       
  3490         tlvSpecificData.AddByte( aAdditionalInfo[1] );
       
  3491         }
       
  3492     else if ( RSat::KSuccess == aGeneralResult
       
  3493         || ( RSat::KPartialComprehension == aGeneralResult )
       
  3494         || ( RSat::KMissingInformation == aGeneralResult )
       
  3495         || ( RSat::KPerformedWithModifications == aGeneralResult )
       
  3496         || ( RSat::KSuccessRequestedIconNotDisplayed == aGeneralResult ) )
       
  3497         {
       
  3498         // Successful result: append Channel Status using
       
  3499         // additional info.
       
  3500         for ( TInt i=0; i<aAdditionalInfo.Length();i+=4 )
       
  3501             {
       
  3502             tlvSpecificData.AddTag( KTlvChannelStatusTag );
       
  3503             tlvSpecificData.AddByte( aAdditionalInfo[i+1] );
       
  3504             tlvSpecificData.AddByte( aAdditionalInfo[i+3] );
       
  3505             }
       
  3506         }
       
  3507     else
       
  3508         {
       
  3509         TFLOGSTRING("TSY: CSatMessHandler::OpenChannelTerminalResp, General result did not match.");
       
  3510         OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_OPENCHANNELTERMINALRESP, "CSatMessHandler::OpenChannelTerminalResp, General result did not match." );
       
  3511         }
       
  3512 
       
  3513     // For any result:
       
  3514     // Append Bearer Description data
       
  3515 
       
  3516     if ( aBearer.Length() )
       
  3517         {
       
  3518         tlvSpecificData.AddTag( KTlvBearerDescriptionTag );
       
  3519         tlvSpecificData.AddByte( aBearerType );
       
  3520         tlvSpecificData.AddData( aBearer );
       
  3521         }
       
  3522     else
       
  3523         {
       
  3524         // Well, if Sat Server doesn't provide it,
       
  3525         // then what values should we use in here??
       
  3526 
       
  3527         }
       
  3528     // Append Buffer Size
       
  3529     tlvSpecificData.AddTag( KTlvBufferSizeTag );
       
  3530     tlvSpecificData.AddByte( TUint8( (aBufferSize&0xFF00)>>8 ));
       
  3531     tlvSpecificData.AddByte( TUint8( aBufferSize&0x00FF ) );
       
  3532 
       
  3533     return UiccCatReqTerminalResponse(
       
  3534         aCommandDetails,
       
  3535         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  3536         aTransId );
       
  3537     }
       
  3538 
       
  3539 // -----------------------------------------------------------------------------
       
  3540 // CSatMessHandler::GetChannelStatusTerminalResp
       
  3541 // Constructs Get Channel Status specific part of terminal
       
  3542 // response and calls SendTerminalResponse method to send it.
       
  3543 // -----------------------------------------------------------------------------
       
  3544 //
       
  3545 TInt CSatMessHandler::GetChannelStatusTerminalResp
       
  3546         (
       
  3547         TUint8 aTransId,
       
  3548         TDes8 &aCommandDetails,
       
  3549         TUint8 aGeneralResult,
       
  3550         const TDes8& aAdditionalInfo
       
  3551         )
       
  3552     {
       
  3553     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GETCHANNELSTATUSTERMINALRESP, "CSatMessHandler::GetChannelStatusTerminalResp" );
       
  3554     TFLOGSTRING("CSatMessHandler::GetChannelStatusTerminalResp");
       
  3555     TTlv tlvSpecificData;
       
  3556     // Append general result tag
       
  3557     tlvSpecificData.AddTag( KTlvResultTag );
       
  3558     // Append general result
       
  3559     tlvSpecificData.AddByte( aGeneralResult );
       
  3560 
       
  3561     if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult )
       
  3562         || ( RSat::KNetworkUnableToProcessCmd == aGeneralResult )
       
  3563         || ( RSat::KInteractionWithCCPermanentError == aGeneralResult )
       
  3564         || ( RSat::KErrorRequiredValuesMissing == aGeneralResult )
       
  3565         || ( RSat::KBearerIndepProtocolError == aGeneralResult ) )
       
  3566         {
       
  3567         // UNSuccessful result neccessitating additional info byte
       
  3568         tlvSpecificData.AddData( aAdditionalInfo );
       
  3569         }
       
  3570     else if ( RSat::KSuccess == aGeneralResult )
       
  3571         {
       
  3572         // Length check is carried out in
       
  3573         // CSatNotifyGetChannelStatus::TerminalResponseL
       
  3574         for ( TInt i=0; i<aAdditionalInfo.Length();i+=4 )
       
  3575             {
       
  3576             tlvSpecificData.AddTag( KTlvChannelStatusTag );
       
  3577             tlvSpecificData.AddByte( aAdditionalInfo[i+1] );
       
  3578             tlvSpecificData.AddByte( aAdditionalInfo[i+3] );
       
  3579             }
       
  3580 
       
  3581         }
       
  3582     else
       
  3583         {
       
  3584         TFLOGSTRING("CSatMessHandler::GetChannelStatusTerminalResp - mandatory channel status missing");
       
  3585         OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_GETCHANNELSTATUSTERMINALRESP, "CSatMessHandler::GetChannelStatusTerminalResp - mandatory channel status missing" );
       
  3586         }
       
  3587 
       
  3588     return UiccCatReqTerminalResponse(
       
  3589         aCommandDetails,
       
  3590         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  3591         aTransId );
       
  3592     }
       
  3593 
       
  3594 // -----------------------------------------------------------------------------
       
  3595 // CSatMessHandler::CloseChannelTerminalResp
       
  3596 // Constructs Close Channel specific part of terminal
       
  3597 // response and calls SendTerminalResponse method to send it.
       
  3598 // -----------------------------------------------------------------------------
       
  3599 //
       
  3600 TInt CSatMessHandler::CloseChannelTerminalResp
       
  3601         (
       
  3602         TUint8 aTransId,
       
  3603         TDes8 &aCommandDetails,
       
  3604         TUint8 aGeneralResult,
       
  3605         const TDes8& aAdditionalInfo
       
  3606         )
       
  3607     {
       
  3608     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_CLOSECHANNELTERMINALRESP, "CSatMessHandler::CloseChannelTerminalResp" );
       
  3609     TFLOGSTRING("CSatMessHandler::CloseChannelTerminalResp");
       
  3610     TTlv tlvSpecificData;
       
  3611     // Append general result tag
       
  3612     tlvSpecificData.AddTag( KTlvResultTag );
       
  3613     // Append general result
       
  3614     tlvSpecificData.AddByte( aGeneralResult );
       
  3615 
       
  3616     if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult )
       
  3617         || ( RSat::KNetworkUnableToProcessCmd == aGeneralResult )
       
  3618         || ( RSat::KInteractionWithCCPermanentError == aGeneralResult )
       
  3619         || ( RSat::KErrorRequiredValuesMissing == aGeneralResult )
       
  3620         || ( RSat::KBearerIndepProtocolError == aGeneralResult ) )
       
  3621         {
       
  3622         // UNSuccessful result neccessitating additional info byte
       
  3623         tlvSpecificData.AddData( aAdditionalInfo );
       
  3624         }
       
  3625 
       
  3626     // Successful result: no additional info,
       
  3627     // no parameters
       
  3628 
       
  3629     return UiccCatReqTerminalResponse(
       
  3630         aCommandDetails,
       
  3631         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  3632         aTransId );
       
  3633     }
       
  3634 
       
  3635 // -----------------------------------------------------------------------------
       
  3636 // CSatMessHandler::SendDataTerminalResp
       
  3637 // Constructs Send Data specific part of terminal
       
  3638 // response and calls SendTerminalResponse method to send it.
       
  3639 // -----------------------------------------------------------------------------
       
  3640 //
       
  3641 TInt CSatMessHandler::SendDataTerminalResp
       
  3642         (
       
  3643         TUint8 aTransId,
       
  3644         TDes8 &aCommandDetails,
       
  3645         TUint8 aGeneralResult,
       
  3646         const TDes8& aAdditionalInfo,
       
  3647         TUint8 aChannelDataLength
       
  3648         )
       
  3649     {
       
  3650     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SENDDATATERMINALRESP, "CSatMessHandler::SendDataTerminalResp" );
       
  3651     TFLOGSTRING("CSatMessHandler::SendDataTerminalResp");
       
  3652     TTlv tlvSpecificData;
       
  3653     // Append general result tag
       
  3654     tlvSpecificData.AddTag( KTlvResultTag );
       
  3655     // Append general result
       
  3656     tlvSpecificData.AddByte( aGeneralResult );
       
  3657     if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult )
       
  3658         || ( RSat::KNetworkUnableToProcessCmd == aGeneralResult )
       
  3659         || ( RSat::KInteractionWithCCPermanentError == aGeneralResult )
       
  3660         || ( RSat::KErrorRequiredValuesMissing == aGeneralResult )
       
  3661         || ( RSat::KBearerIndepProtocolError == aGeneralResult ) )
       
  3662         {
       
  3663         // UNSuccessful result neccessitating additional info byte
       
  3664         tlvSpecificData.AddData( aAdditionalInfo );
       
  3665         }
       
  3666     else if (( RSat::KSuccess == aGeneralResult )
       
  3667        || ( RSat::KSuccessRequestedIconNotDisplayed == aGeneralResult ))
       
  3668         {
       
  3669         // Successful result:
       
  3670         // append Channel Status
       
  3671         tlvSpecificData.AddTag( KTlvChannelDataLengthTag );
       
  3672         tlvSpecificData.AddByte( aChannelDataLength );
       
  3673         }
       
  3674     else
       
  3675         {
       
  3676         TFLOGSTRING("TSY: CSatMessHandler::SendDataTerminalResp, General result did not match.");
       
  3677         OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_SENDDATATERMINALRESP, "CSatMessHandler::SendDataTerminalResp, General result did not match." );
       
  3678         }
       
  3679 
       
  3680     return UiccCatReqTerminalResponse(
       
  3681         aCommandDetails,
       
  3682         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  3683         aTransId );
       
  3684     }
       
  3685 
       
  3686 // -----------------------------------------------------------------------------
       
  3687 // CSatMessHandler::ReceiveDataTerminalResp
       
  3688 // Constructs Receive Data specific part of terminal
       
  3689 // response and calls SendTerminalResponse method to send it.
       
  3690 // -----------------------------------------------------------------------------
       
  3691 //
       
  3692 TInt CSatMessHandler::ReceiveDataTerminalResp
       
  3693         (
       
  3694         TUint8 aTransId,
       
  3695         TDes8& aCommandDetails,
       
  3696         TUint8 aGeneralResult,
       
  3697         const TDes8& aAdditionalInfo,
       
  3698         TUint8 aChannelDataLength
       
  3699         )
       
  3700     {
       
  3701     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_RECEIVEDATATERMINALRESP, "CSatMessHandler::ReceiveDataTerminalResp" );
       
  3702     TFLOGSTRING("CSatMessHandler::ReceiveDataTerminalResp");
       
  3703     TTlv tlvSpecificData;
       
  3704     // Append general result tag
       
  3705     tlvSpecificData.AddTag( KTlvResultTag );
       
  3706     // Append general result
       
  3707     tlvSpecificData.AddByte( aGeneralResult );
       
  3708     if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult )
       
  3709         || ( RSat::KNetworkUnableToProcessCmd == aGeneralResult )
       
  3710         || ( RSat::KInteractionWithCCPermanentError == aGeneralResult )
       
  3711         || ( RSat::KErrorRequiredValuesMissing == aGeneralResult )
       
  3712         || ( RSat::KBearerIndepProtocolError == aGeneralResult ) )
       
  3713         {
       
  3714         // UNSuccessful result neccessitating additional info byte
       
  3715         tlvSpecificData.AddData( aAdditionalInfo );
       
  3716         }
       
  3717     else if (( RSat::KSuccess == aGeneralResult )
       
  3718     || ( RSat::KSuccessRequestedIconNotDisplayed == aGeneralResult )
       
  3719     || ( RSat::KMissingInformation == aGeneralResult ))
       
  3720         {
       
  3721         // Successful result:
       
  3722         //append Channel Data using additional info
       
  3723         tlvSpecificData.AddTag( KTlvChannelDataTag );
       
  3724         tlvSpecificData.AddData( aAdditionalInfo );
       
  3725         // Channel data length
       
  3726         tlvSpecificData.AddTag( KTlvChannelDataLengthTag );
       
  3727         tlvSpecificData.AddByte( aChannelDataLength );
       
  3728         }
       
  3729     else
       
  3730         {
       
  3731         TFLOGSTRING("TSY: CSatMessHandler::ReceiveDataTerminalResp, General result did not match.");
       
  3732         OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_RECEIVEDATATERMINALRESP, "CSatMessHandler::ReceiveDataTerminalResp, General result did not match." );
       
  3733         }
       
  3734 
       
  3735     return UiccCatReqTerminalResponse(
       
  3736         aCommandDetails,
       
  3737         tlvSpecificData.GetDataWithoutTopLevelTag(),
       
  3738         aTransId );
       
  3739     }
       
  3740 
       
  3741 
       
  3742 // -----------------------------------------------------------------------------
       
  3743 // CSatMessHandler::SendSmsResourceReq
       
  3744 // Send a response to SMS server after reception of SmsResourceInd.
       
  3745 // This response tells whether the SMS can be sent or not.
       
  3746 // -----------------------------------------------------------------------------
       
  3747 //
       
  3748 TInt CSatMessHandler::SendSmsResourceReq
       
  3749         (
       
  3750         TUint8 aTransId,
       
  3751         TDesC8& aData,
       
  3752         TUint8 aReceiverObject
       
  3753         )
       
  3754     {
       
  3755     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SENDSMSRESOURCERESP, "CSatMessHandler::SendSmsResourceResp" );
       
  3756     TFLOGSTRING("TSY:CSatMessHandler::SendSmsResourceResp");
       
  3757 
       
  3758     TIsiSend isimsg( iPnSend->SendBufferDes() );
       
  3759     isimsg.Set8bit( ISI_HEADER_OFFSET_RECEIVEROBJECT, aReceiverObject );
       
  3760     isimsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_SMS );
       
  3761     isimsg.Set8bit( ISI_HEADER_OFFSET_TRANSID , aTransId );
       
  3762     isimsg.Set8bit( ISI_HEADER_OFFSET_MESSAGEID, SMS_RESOURCE_REQ );
       
  3763     isimsg.CopyData( ISI_HEADER_SIZE + SMS_RESOURCE_REQ_OFFSET_FILLERBYTE1,
       
  3764                     aData );
       
  3765 
       
  3766     // add padding
       
  3767     while ( iPnSend->SendBufferDes().Length() % 4 )
       
  3768         {
       
  3769         iPnSend->SendBufferDes().Append( 0x00 );
       
  3770         }
       
  3771 
       
  3772     //send message
       
  3773     return iPnSend->Send( isimsg.Complete() );
       
  3774     }
       
  3775 
       
  3776 // -----------------------------------------------------------------------------
       
  3777 // CSatMessHandler::SsStatusInd
       
  3778 // Break's a SS_STATUS_IND isi-message and stores status information
       
  3779 // -----------------------------------------------------------------------------
       
  3780 //
       
  3781 void CSatMessHandler::SsStatusInd
       
  3782         (
       
  3783         const TIsiReceiveC& aIsiMessage
       
  3784         )
       
  3785     {
       
  3786     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SSSTATUSIND, "CSatMessHandler::SsStatusInd" );
       
  3787     TFLOGSTRING("TSY: CSatMessHandler::SsStatusInd");
       
  3788 
       
  3789     TUint8 ssStatus  = aIsiMessage.Get8bit( ISI_HEADER_SIZE
       
  3790             + SS_STATUS_IND_OFFSET_SSSTATUSINDICATION );
       
  3791 
       
  3792     if( ( SS_STATUS_REQUEST_SERVICE_BUSY == ssStatus )
       
  3793        || ( SS_STATUS_REQUEST_SERVICE_START == ssStatus  ) )
       
  3794         {
       
  3795         iSsStatus = ESsBusy;
       
  3796         }
       
  3797     else if( ( SS_GSM_STATUS_REQUEST_USSD_BUSY == ssStatus )
       
  3798             || ( SS_GSM_STATUS_REQUEST_USSD_START == ssStatus  ) )
       
  3799         {
       
  3800         iSsStatus = EUssdBusy;
       
  3801         }
       
  3802     else
       
  3803         {
       
  3804         iSsStatus = ENotBusy;
       
  3805         }
       
  3806     }
       
  3807 
       
  3808 // -----------------------------------------------------------------------------
       
  3809 // CSatMessHandler::AdditionalInfoNeeded
       
  3810 // Checks if given result requires an additional info byte(s)
       
  3811 // -----------------------------------------------------------------------------
       
  3812 //
       
  3813 TBool CSatMessHandler::AdditionalInfoNeeded
       
  3814         (
       
  3815         const TUint8 aGeneralResult
       
  3816         )
       
  3817     {
       
  3818     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_ADDITIONALINFONEEDED, "CSatMessHandler::AdditionalInfoNeeded" );
       
  3819     // NOTE: This method shall not be used with SendSS proactive command as its
       
  3820     // additional info handling differs from other commands.
       
  3821 
       
  3822     TBool ret( EFalse );
       
  3823 
       
  3824     switch ( aGeneralResult )
       
  3825         {
       
  3826         // This list is based on 3GPP TS 11.14 chapter 12.12
       
  3827         case RSat::KMeUnableToProcessCmd:
       
  3828         case RSat::KNetworkUnableToProcessCmd:
       
  3829         case RSat::KLaunchBrowserError:
       
  3830         case RSat::KSsReturnError:
       
  3831         case RSat::KSmsRpError:
       
  3832         case RSat::KUssdReturnError:
       
  3833         case RSat::KMultipleCardCmdsError:
       
  3834         case RSat::KInteractionWithCCPermanentError:
       
  3835         case RSat::KBearerIndepProtocolError:
       
  3836             {
       
  3837             ret = ETrue;
       
  3838             break;
       
  3839             }
       
  3840         default:
       
  3841             {
       
  3842             // do nothing. ret is already set to EFalse
       
  3843             break;
       
  3844             }
       
  3845         }
       
  3846     return ret;
       
  3847     }
       
  3848 
       
  3849 
       
  3850 // -----------------------------------------------------------------------------
       
  3851 // CSatMessHandler:: ReceiveMessageL
       
  3852 // Called by phonet receiver when an ISI message
       
  3853 // has been received
       
  3854 // -----------------------------------------------------------------------------
       
  3855 //
       
  3856 void CSatMessHandler::ReceiveMessageL
       
  3857         (
       
  3858         const TIsiReceiveC& aIsiMessage
       
  3859         )
       
  3860     {
       
  3861     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_RECEIVEMESSAGEL, "CSatMessHandler::ReceiveMessageL" );
       
  3862     TFLOGSTRING("TSY: CSatMessHandler::ReceiveMessageL");
       
  3863 
       
  3864     // Get ISI message resource and id
       
  3865     TInt resource ( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_RESOURCEID ) );
       
  3866 
       
  3867     // Received AtkSwDataNtf-message can be response for an envelope
       
  3868     // or terminal response. Responses for TR and failed envelopes (SIM busy)
       
  3869     // are handled in AtkServerMessageReceivedL. All other cases are passed
       
  3870     // ProactiveProcedureMessageReceivedL-method
       
  3871     TBool handled( EFalse );
       
  3872 
       
  3873     switch ( resource )
       
  3874         {
       
  3875         case PN_SS:
       
  3876             {
       
  3877             SsServerMessageReceived( aIsiMessage );
       
  3878             break;
       
  3879             }
       
  3880         case PN_PHONE_INFO:
       
  3881             {
       
  3882             PhoneInfoMessageReceived( aIsiMessage );
       
  3883             break;
       
  3884             }
       
  3885         case PN_MODEM_NETWORK:
       
  3886             {
       
  3887             NetServerMessageReceived( aIsiMessage );
       
  3888             break;
       
  3889             }
       
  3890         case PN_GSS:
       
  3891             {
       
  3892             GsmStackServerMessageReceived( aIsiMessage );
       
  3893             break;
       
  3894             }
       
  3895         case PN_SMS:
       
  3896             {
       
  3897             SmsServerMessageReceived( aIsiMessage );
       
  3898             break;
       
  3899             }
       
  3900         case PN_UICC:
       
  3901             {
       
  3902             handled = UiccServerMessageReceived( aIsiMessage );
       
  3903             break;
       
  3904             }
       
  3905         default:
       
  3906             {
       
  3907             // Do nothing
       
  3908             break;
       
  3909             }
       
  3910         }
       
  3911 
       
  3912     if ( !handled )
       
  3913         {
       
  3914         ProactiveProcedureMessageReceivedL( aIsiMessage );
       
  3915         }
       
  3916     }
       
  3917 
       
  3918 // -----------------------------------------------------------------------------
       
  3919 // CSatMessHandler::HandleError
       
  3920 // Handles CSatMessHandler's errors that comes via PhoNetReceiver
       
  3921 // RunError method.
       
  3922 // -----------------------------------------------------------------------------
       
  3923 //
       
  3924 void CSatMessHandler::HandleError
       
  3925         (
       
  3926         const TIsiReceiveC& /*aIsiMessage*/,
       
  3927         TInt /*aErrorCode*/
       
  3928         )
       
  3929     {
       
  3930     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_HANDLEERROR, "CSatMessHandler::HandleError" );
       
  3931     // No implementation
       
  3932     }
       
  3933 
       
  3934 
       
  3935 // -----------------------------------------------------------------------------
       
  3936 // CSatMessHandler::NetRatInd
       
  3937 // Breaks a NET_RAT_IND isi-message
       
  3938 // -----------------------------------------------------------------------------
       
  3939 //
       
  3940 void CSatMessHandler::NetRatInd
       
  3941         (
       
  3942         const TIsiReceiveC& aIsiMessage // ISI message
       
  3943         )
       
  3944     {
       
  3945     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_NETRATIND, "CSatMessHandler::NetRatInd" );
       
  3946     TFLOGSTRING("TSY:CSatMessHandler::NetRatInd");
       
  3947 
       
  3948     // Check the presence of subblocks
       
  3949     if ( 0 != aIsiMessage.Get8bit(
       
  3950         ISI_HEADER_SIZE + NET_RAT_IND_OFFSET_SUBBLOCKCOUNT ) )
       
  3951         {
       
  3952         // Subblock offset
       
  3953         TUint sbOffset( 0 );
       
  3954 
       
  3955         // NET_RAT_INFO sub block
       
  3956         TInt ret = aIsiMessage.FindSubBlockOffsetById(
       
  3957             ISI_HEADER_SIZE + SIZE_NET_RAT_IND,
       
  3958             NET_RAT_INFO,
       
  3959             EIsiSubBlockTypeId8Len8,
       
  3960             sbOffset );
       
  3961 
       
  3962         // Check if NET_RAT_INFO sub block is present
       
  3963         if( KErrNone == ret )
       
  3964             {
       
  3965             // Get ratName
       
  3966             TUint8 ratName( aIsiMessage.Get8bit(
       
  3967                 sbOffset + NET_RAT_INFO_OFFSET_RATNAME ) );
       
  3968 
       
  3969             switch ( ratName )
       
  3970                 {
       
  3971                 case NET_GSM_RAT:
       
  3972                     {
       
  3973                     iCurrentAccTech = KNetworkModeGsm;
       
  3974                     iTsySatMessaging->GetEventDownload()
       
  3975                     ->SendAccessTechnologyChangeEnvelope( KNetworkModeGsm );
       
  3976                     break;
       
  3977                     }
       
  3978                 case NET_UMTS_RAT:
       
  3979                     {
       
  3980                     iCurrentAccTech = KNetworkModeUtran;
       
  3981                     iTsySatMessaging->GetEventDownload()
       
  3982                     ->SendAccessTechnologyChangeEnvelope( KNetworkModeUtran );
       
  3983                     break;
       
  3984                     }
       
  3985                 default:
       
  3986                     {
       
  3987                     // Do nothing
       
  3988                     break;
       
  3989                     }
       
  3990                 }
       
  3991             }
       
  3992         TFLOGSTRING2("TSY:CSatMessHandler::NetRatInd - Current Acc Tech: %d",iCurrentAccTech);
       
  3993         OstTraceExt1( TRACE_NORMAL, DUP1_CSATMESSHANDLER_NETRATIND, "CSatMessHandler::NetRatInd - Current Acc Tech: %hhu", iCurrentAccTech );
       
  3994         }
       
  3995 
       
  3996     }
       
  3997 
       
  3998 // -----------------------------------------------------------------------------
       
  3999 // CSatMessHandler::LocationInfo
       
  4000 // Getter for location information structure
       
  4001 // -----------------------------------------------------------------------------
       
  4002 //
       
  4003 const CSatMessHandler::TLocationInfo& CSatMessHandler::LocationInfo()
       
  4004     {
       
  4005     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_LOCATIONINFO, "CSatMessHandler::LocationInfo" );
       
  4006     // Extended Cell Id is provided only if both USIM and
       
  4007     // 3G network are present.
       
  4008     if ( KNetworkModeUtran != iCurrentAccTech
       
  4009         || UICC_CARD_TYPE_UICC != iCardType )
       
  4010         {
       
  4011         // Exclude the extended Cell Id
       
  4012 
       
  4013         iLocInfo.iCellId.SetLength( 2 );
       
  4014         }
       
  4015     else
       
  4016         {
       
  4017         iLocInfo.iCellId.SetLength( 4 );
       
  4018         }
       
  4019 
       
  4020     return iLocInfo;
       
  4021     }
       
  4022 
       
  4023 // -----------------------------------------------------------------------------
       
  4024 // CSatMessHandler::SendPnAtkMessage
       
  4025 // Sends a PN_ATK message with the given data, sets also possible filler bytes
       
  4026 // -----------------------------------------------------------------------------
       
  4027 //
       
  4028 TInt CSatMessHandler::SendPnAtkMessage
       
  4029         (
       
  4030         const TUint8 aReceiverObject,
       
  4031         const TUint8 aTransactionId,
       
  4032         const TInt aMessageId,
       
  4033         const TDesC8& aData
       
  4034         )
       
  4035     {
       
  4036     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SENDPNATKMESSAGE, "CSatMessHandler::SendPnAtkMessage" );
       
  4037     TFLOGSTRING("TSY:CSatMessHandler::SendPnAtkMessage");
       
  4038 
       
  4039     TBuf8<KLengthTwoBytes> data;
       
  4040     data.Append( aTransactionId );
       
  4041     data.Append( aMessageId );
       
  4042 
       
  4043     // Create send buffer (sets the msg length to NULL)
       
  4044     TIsiSend isimsg( iPnSend->SendBufferDes() );
       
  4045 
       
  4046     // Set the receiver object and resource ID
       
  4047     isimsg.Set8bit( ISI_HEADER_OFFSET_RECEIVEROBJECT, aReceiverObject );
       
  4048     isimsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_ATK );
       
  4049     // Set Transaction ID and Msg ID at the end of the message buffer
       
  4050     isimsg.CopyData( ISI_HEADER_SIZE, data );
       
  4051     // Copy the message data at the end of the message buffer
       
  4052     isimsg.CopyData( ( ISI_HEADER_SIZE + KLengthTwoBytes ), aData );
       
  4053 
       
  4054     // Add padding(s)
       
  4055     while ( iPnSend->SendBufferDes().Length() % 4 )
       
  4056         {
       
  4057         iPnSend->SendBufferDes().Append( 0x00 );
       
  4058         }
       
  4059 
       
  4060     // Send message
       
  4061     return iPnSend->Send( isimsg.Complete() );
       
  4062     }
       
  4063 
       
  4064 // -----------------------------------------------------------------------------
       
  4065 // CSatMessHandler::UiccApplCmdResp
       
  4066 // (other items were commented in a header).
       
  4067 // -----------------------------------------------------------------------------
       
  4068 //
       
  4069 void CSatMessHandler::UiccApplCmdResp( const TIsiReceiveC& aIsiMessage )
       
  4070     {
       
  4071     TFLOGSTRING("TSY: CSatMessHandler::UiccApplCmdResp");
       
  4072     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_UICCAPPLCMDRESP, "CSatMessHandler::UiccApplCmdResp" );
       
  4073 
       
  4074     TInt error( KErrNone );
       
  4075     // Get transaction ID, status and service type
       
  4076     TUint8 trId( aIsiMessage.Get8bit(
       
  4077         ISI_HEADER_SIZE + UICC_APPL_CMD_RESP_OFFSET_TRANSID ) );
       
  4078     TUint8 status( aIsiMessage.Get8bit(
       
  4079         ISI_HEADER_SIZE + UICC_APPL_CMD_RESP_OFFSET_STATUS ) );
       
  4080     TUint8 serviceType( aIsiMessage.Get8bit(
       
  4081         ISI_HEADER_SIZE +
       
  4082         UICC_APPL_CMD_RESP_OFFSET_SERVICETYPE ) );
       
  4083 
       
  4084     // Card type
       
  4085     iCardType = aIsiMessage.Get8bit(
       
  4086         ISI_HEADER_SIZE + UICC_APPL_CMD_RESP_OFFSET_CARDTYPE );
       
  4087 
       
  4088     // Read file data from UICC_SB_FILE_DATA
       
  4089     TInt fileDataLength( 0 );
       
  4090     TPtrC8 fileData;
       
  4091     TUint uiccSbFileDataOffset( 0 );
       
  4092     if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  4093         ISI_HEADER_SIZE + SIZE_UICC_APPL_CMD_RESP,
       
  4094         UICC_SB_FILE_DATA,
       
  4095         EIsiSubBlockTypeId16Len16,
       
  4096         uiccSbFileDataOffset ) )
       
  4097         {
       
  4098         fileDataLength = aIsiMessage.Get32bit(
       
  4099             uiccSbFileDataOffset + UICC_SB_FILE_DATA_OFFSET_DATALENGTH );
       
  4100         fileData.Set( aIsiMessage.GetData(
       
  4101             uiccSbFileDataOffset + UICC_SB_FILE_DATA_OFFSET_DATA,
       
  4102             fileDataLength ) );
       
  4103         }
       
  4104     else // Subblock is mandatory
       
  4105         {
       
  4106         TFLOGSTRING("TSY: CSatMessHandler::UiccApplCmdResp - Mandatory subblock UICC_SB_FILE_DATA not found");
       
  4107         OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_UICCAPPLCMDRESP, "CSatMessHandler::UiccApplCmdResp - Mandatory subblock UICC_SB_FILE_DATA not found" );
       
  4108         error = KErrNotFound;
       
  4109         }
       
  4110 
       
  4111     switch( trId )
       
  4112         {
       
  4113         // Call control, SMS PP DD, USIM MO-SMS control
       
  4114         case KUiccTrIdServiceTableByte4:
       
  4115             {
       
  4116             if ( KErrNone == error )
       
  4117                 {
       
  4118                 TUint8 usedBitMaskSmsPpDd( KSmsPpDdBitMaskUsim );
       
  4119                 if ( UICC_CARD_TYPE_ICC == iCardType )
       
  4120                     {
       
  4121                     usedBitMaskSmsPpDd = KSmsPpDdBitMaskSim;
       
  4122                     }
       
  4123                 else
       
  4124                     {
       
  4125                     // MO SMS control status, only in case of USIM
       
  4126                     SimMoSmsControlAvail(
       
  4127                         fileData[0] & KMoSmsControlBitMaskUsim );
       
  4128                     }
       
  4129                 // Get status of SMS PP DD and report to DataDownload
       
  4130                 iTsySatMessaging->GetDataDownload()->SmsPpDlSupported(
       
  4131                     ( fileData[0] & usedBitMaskSmsPpDd ) ? ETrue : EFalse );
       
  4132                 }
       
  4133             break;
       
  4134             }
       
  4135         // MO SMS control ( this transaction ID is used for SIM only )
       
  4136         case KUiccTrIdServiceTableByte5:
       
  4137             {
       
  4138             if ( KErrNone == error )
       
  4139                 {
       
  4140                 SimMoSmsControlAvail( fileData[0] & KMoSmsControlBitMaskSim );
       
  4141                 }
       
  4142             break;
       
  4143             }
       
  4144         // USSD in Call Control ( this transaction ID is used for SIM only )
       
  4145         case KUiccTrIdServiceTableByte6:
       
  4146             {
       
  4147             iTsySatMessaging->SetStatusOfUssdSupport(
       
  4148                 fileData[0] & KMoUssdCallControlBitMaskSim );
       
  4149             break;
       
  4150             }
       
  4151         // SAT icon
       
  4152         case KUiccTrIdReadSatIcon:
       
  4153             {
       
  4154             TBuf8<1> infoNotSet( 0 );
       
  4155             iTsySatMessaging->GetSatIcon()->
       
  4156                 CompleteIconRequest( error, fileData, infoNotSet );
       
  4157             break;
       
  4158             }
       
  4159         // SAT icon instance
       
  4160         case KUiccTrIdReadIconInstancePhase1:
       
  4161         case KUiccTrIdReadIconInstancePhase2:
       
  4162         case KUiccTrIdReadIconClut:
       
  4163             {
       
  4164             if ( KUiccTrIdReadIconInstancePhase1 == trId )
       
  4165                 {
       
  4166                 // See image instance data context coding from
       
  4167                 // 3GPP 31.102 v8.3.0. ANNEX B
       
  4168                 // Save image coding scaheme
       
  4169                 iImageCodingScheme = fileData[2];
       
  4170                 // File ID of instance is in bytes 4 and 5
       
  4171                 // Read instance file in phase 2
       
  4172                 TUint16 fileId( ( fileData[3] << 8 ) | fileData[4] );
       
  4173                 UiccReadSatIconInstanceReq( fileId );
       
  4174                 }
       
  4175             else // Instance data and clut are set here
       
  4176                 {
       
  4177                 TPtrC8 data;
       
  4178                 TBuf8<6> info;
       
  4179                 TUint8 width( fileData[0] );
       
  4180                 TUint8 heigth( fileData[1] );
       
  4181                 TUint8 colorDepth( 1 );
       
  4182                 TUint16 clutOffset( 0 );
       
  4183                 TUint offset( 2 ); // instance data offset in basic coding
       
  4184 
       
  4185                 // Set in case of coulor image coding
       
  4186                 iNumberOfClut = 0;
       
  4187 
       
  4188                 info.Append( width );
       
  4189                 info.Append( heigth );
       
  4190 
       
  4191                 // Colour image coding scheme
       
  4192                 if ( KBlackAndWhite != iImageCodingScheme )
       
  4193                     {
       
  4194                     colorDepth = fileData[2];
       
  4195                     iNumberOfClut = fileData[3];
       
  4196                     clutOffset = ( fileData[4] << 8 | fileData[5] );
       
  4197                     offset = 6;
       
  4198 
       
  4199                     // Save clut data for clut request.
       
  4200                     // So it is not needed to read instance file from UICC
       
  4201                     // again.
       
  4202                     TInt clutLength( KClutEntrySize * iNumberOfClut );
       
  4203                     if ( 0 == clutLength )
       
  4204                         {
       
  4205                         clutLength = KClutEntrySize * 256;
       
  4206                         }
       
  4207                     iClutData.Set( fileData.Mid( clutOffset, clutLength ));
       
  4208                     }
       
  4209 
       
  4210                 info.Append( colorDepth );
       
  4211                 info.Append( iNumberOfClut );
       
  4212                 info.Append( 0x00 );  // offset (default value added)
       
  4213                 info.Append( 0x00 );  // offset (default value added)
       
  4214 
       
  4215                 TUint lengthInBits( width * heigth * colorDepth );
       
  4216                 TUint lengthInBytes( lengthInBits / 8 );
       
  4217 
       
  4218                 // There might be rounding error in statement above, if
       
  4219                 // length in bits is not evenly divisible by 8 ( one byte ).
       
  4220                 if ( lengthInBits % 8 )
       
  4221                     {
       
  4222                     lengthInBytes++;
       
  4223                     }
       
  4224 
       
  4225                 data.Set( fileData.Mid( offset, lengthInBytes ) );
       
  4226                 iTsySatMessaging->GetSatIcon()->
       
  4227                     CompleteIconRequest( error, data, info);
       
  4228                 }
       
  4229             break;
       
  4230             }
       
  4231         default:
       
  4232             {
       
  4233             break;
       
  4234             }
       
  4235         } // End of switch( trId )
       
  4236     }
       
  4237 
       
  4238 
       
  4239 // -----------------------------------------------------------------------------
       
  4240 // CSatMessHandler::UiccCatInd
       
  4241 // Breaks UICC_CAT_IND ISI-message.
       
  4242 // -----------------------------------------------------------------------------
       
  4243 //
       
  4244 void CSatMessHandler::UiccCatInd
       
  4245     (
       
  4246     const TIsiReceiveC& aIsiMessage // Received ISI message
       
  4247     )
       
  4248     {
       
  4249     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_UICCCATIND, "CSatMessHandler::UiccCatInd" );
       
  4250     TFLOGSTRING("TSY: CSatMessHandler::UiccCatInd");
       
  4251 
       
  4252     // UICC status
       
  4253     TUint8 serviceType( aIsiMessage.Get8bit(
       
  4254         ISI_HEADER_SIZE + UICC_CAT_IND_OFFSET_SERVICETYPE ) );
       
  4255 
       
  4256     if ( UICC_READY == serviceType )
       
  4257         {
       
  4258         // Card type
       
  4259         iCardType = aIsiMessage.Get8bit(
       
  4260             ISI_HEADER_SIZE + UICC_CAT_IND_OFFSET_CARDTYPE );
       
  4261 
       
  4262         // Application file ID is concluded from card type
       
  4263         if ( UICC_CARD_TYPE_UICC == iCardType )
       
  4264             {
       
  4265             // ADF USIM is used, ID = '7FFF'
       
  4266             TBuf8<2> umtsFileId;
       
  4267             umtsFileId.Append( 0x7F );
       
  4268             umtsFileId.Append( 0xFF );
       
  4269             iApplFileId.Copy( umtsFileId );
       
  4270             }
       
  4271         else if ( UICC_CARD_TYPE_ICC == iCardType )
       
  4272             {
       
  4273             // DF GSM is used, ID = '7F20'
       
  4274             TBuf8<2> gsmFileId;
       
  4275             gsmFileId.Append( 0x7F );
       
  4276             gsmFileId.Append( 0x20 );
       
  4277             iApplFileId.Copy( gsmFileId );
       
  4278             }
       
  4279         // No else, initialized to 'FFFF' in constructor.
       
  4280 
       
  4281         // Send terminal profile
       
  4282         UiccTerminalProfileReq();
       
  4283         }
       
  4284     // Proactive command was fetched from SIM
       
  4285     else if ( UICC_CAT_FETCHED_CMD == serviceType )
       
  4286         {
       
  4287         if ( KErrNone == CheckProactiveCommand( aIsiMessage ) )
       
  4288             {
       
  4289             iTsySatMessaging->PCmdReceivedL( aIsiMessage );
       
  4290             }
       
  4291         else
       
  4292             {
       
  4293             TFLOGSTRING("TSY: Received SAT message was not valid!");
       
  4294             OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_UICCCATIND, "CSatMessHandler::UiccCatInd. Received SAT message was not valid!" );
       
  4295             }
       
  4296         }
       
  4297     }
       
  4298 
       
  4299 // -----------------------------------------------------------------------------
       
  4300 // CSatMessHandler::InfoPpReadReq
       
  4301 // Construct a INFO_PP_READ_REQ ISI message
       
  4302 // -----------------------------------------------------------------------------
       
  4303 //
       
  4304 TInt CSatMessHandler::InfoPpReadReq
       
  4305         (
       
  4306         const TUint8 aReqType // request type
       
  4307         )
       
  4308     {
       
  4309     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_INFOPPREADREQ, "CSatMessHandler::InfoPpReadReq" );
       
  4310     TFLOGSTRING("TSY: CSatMessHandler::InfoPpReadReq" );
       
  4311 
       
  4312     // Construct INFO_PP_READ_REQ message (INFO_BATCH_TYPE +
       
  4313     // sub block count + INFO_SB_PP sub block)
       
  4314     TBuf8<2 + SIZE_INFO_SB_PP> infoPpReadReq;
       
  4315 
       
  4316     //set pp batch reading to read specific product profile, thus 0.
       
  4317     infoPpReadReq.Append( INFO_PP_PROD_PROFILE_FEATURE );
       
  4318 
       
  4319     // add sub block
       
  4320     infoPpReadReq.Append( 1 ); // number of sub blocks
       
  4321 
       
  4322     // create INFO_SB_PP sub block
       
  4323     TIsiSubBlock sbPPSubBlock( infoPpReadReq, INFO_SB_PP,
       
  4324                                 EIsiSubBlockTypeId8Len8 );
       
  4325     // Add 0x00 as the Dynamic Value ID, used to read a static value
       
  4326     infoPpReadReq.Append( 0x00 );
       
  4327 
       
  4328     // Add 0x01 as the length of the product profile, reading only one profile
       
  4329     infoPpReadReq.Append( 0x01 );
       
  4330 
       
  4331     // Add the product profile feature number being requested
       
  4332     infoPpReadReq.Append( aReqType );
       
  4333 
       
  4334     // Value of the product profile is 0x00, since reading
       
  4335     infoPpReadReq.Append( 0x00 );
       
  4336 
       
  4337     // complete sub block and append to INFO_PP_READ_REQ
       
  4338     sbPPSubBlock.CompleteSubBlock();
       
  4339 
       
  4340     TUint8 tempTraId( iTsySatMessaging->GetTransactionId() );
       
  4341 
       
  4342 #ifdef INFO_PP_ATK_MO_SM_CONTROL
       
  4343     if ( INFO_PP_ATK_MO_SM_CONTROL == aReqType )
       
  4344         {
       
  4345         // Save transaction id to separate actions in InfoPpReadResp.
       
  4346         // INFO_PP_ATK_MO_SM_CONTROL is the only PP flag which causes actions
       
  4347         // if response is unsuccessful and there can be several simultaneous
       
  4348         // PP queries ongoing
       
  4349         iInfoPpMoSmsTraId = tempTraId;
       
  4350         }
       
  4351 #endif
       
  4352 
       
  4353     //create the isi message
       
  4354     return iPnSend->Send(
       
  4355         PN_INFO,
       
  4356         tempTraId,
       
  4357         INFO_PP_READ_REQ,
       
  4358         infoPpReadReq );
       
  4359     }
       
  4360 
       
  4361 // -----------------------------------------------------------------------------
       
  4362 // CSatMessHandler::InfoPpReadResp
       
  4363 // Breaks a INFO_PP_READ_RESP ISI-message.
       
  4364 // -----------------------------------------------------------------------------
       
  4365 //
       
  4366 void CSatMessHandler::InfoPpReadResp
       
  4367         (
       
  4368         const TIsiReceiveC& aIsiMessage
       
  4369         )
       
  4370     {
       
  4371     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_INFOPPREADRESP, "CSatMessHandler::InfoPpReadResp" );
       
  4372     TFLOGSTRING("TSY: CSatMessHandler::InfoPpReadResp" );
       
  4373 
       
  4374     TUint8 traId( aIsiMessage.Get8bit( ISI_HEADER_SIZE +
       
  4375                             INFO_PP_READ_RESP_OFFSET_TRANSID ) );
       
  4376 
       
  4377     TUint8 status( aIsiMessage.Get8bit( ISI_HEADER_SIZE +
       
  4378                             INFO_PP_READ_RESP_OFFSET_STATUS ) );
       
  4379 
       
  4380     TFLOGSTRING2("TSY: CSatMessHandler::InfoPpReadResp - Status: %d",
       
  4381         status );
       
  4382     OstTraceExt1( TRACE_NORMAL, DUP1_CSATMESSHANDLER_INFOPPREADRESP, "CSatMessHandler::InfoPpReadResp - Status: %hhu", status );
       
  4383 
       
  4384 
       
  4385     switch ( status )
       
  4386         {
       
  4387         case INFO_OK:
       
  4388             {
       
  4389             TUint sbInfoPpReadStartOffset( 0 );
       
  4390 
       
  4391             if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  4392                 ISI_HEADER_SIZE + SIZE_INFO_PP_READ_RESP, INFO_SB_PP,
       
  4393                 EIsiSubBlockTypeId8Len8, sbInfoPpReadStartOffset ) )
       
  4394                 {
       
  4395                 TInt length( aIsiMessage.Get8bit( sbInfoPpReadStartOffset +
       
  4396                             INFO_SB_PP_OFFSET_STRLEN ) );
       
  4397 
       
  4398                 if ( length )
       
  4399                     {
       
  4400                     // Buffer to hold product profile feature and its
       
  4401                     // corresponding value, thus buffer size is 2
       
  4402                     TBuf8<2> pPFeatures;
       
  4403 
       
  4404                     // copy 2 bytes from product profile
       
  4405                     // 1st byte = PP Feature
       
  4406                     // 2nd byte = PP Value
       
  4407                     pPFeatures.Copy( aIsiMessage.GetData(
       
  4408                         sbInfoPpReadStartOffset +
       
  4409                         INFO_SB_PP_OFFSET_PRODUCTPROFILE, 2 ) );
       
  4410 
       
  4411 #ifdef INFO_PP_ATK_MO_SM_CONTROL
       
  4412                     // Check that product profile is requested one
       
  4413                     if ( INFO_PP_ATK_MO_SM_CONTROL == pPFeatures [0] )
       
  4414                         {
       
  4415                         //Get the value of the MO SMS control feature
       
  4416                         if ( INFO_PP_FALSE != pPFeatures [1] )
       
  4417                             {
       
  4418                             TFLOGSTRING("TSY: CSatMessHandler::InfoPpReadResp, MO SMS control supported by ME product profile" );
       
  4419                             OstTrace0( TRACE_NORMAL, DUP2_CSATMESSHANDLER_INFOPPREADRESP, "CSatMessHandler::InfoPpReadResp, MO SMS control supported by ME product profile" );
       
  4420                             iMoSmsSupportedInPp = ETrue;
       
  4421                             // Continue MO SMS control check by checking
       
  4422                             // feature availability from USIM
       
  4423                             if ( UICC_CARD_TYPE_UICC == iCardType )
       
  4424                                 {
       
  4425                                 // USIM: Read MO-SMS control from byte 4
       
  4426                                 UiccReadServiceTableReq( KUiccTrIdServiceTableByte4, 5 );
       
  4427                                 }
       
  4428                             else if ( UICC_CARD_TYPE_ICC == iCardType )
       
  4429                                 {
       
  4430                                 // SIM: Read MO-SMS control from byte 5
       
  4431                                 UiccReadServiceTableReq( KUiccTrIdServiceTableByte5, 6 );
       
  4432                                 }
       
  4433                             }
       
  4434                         else
       
  4435                             {
       
  4436                             TFLOGSTRING("TSY: CSatMessHandler::InfoPpReadResp, MO SMS control not supported by ME product profile" );
       
  4437                             OstTrace0( TRACE_NORMAL, DUP3_CSATMESSHANDLER_INFOPPREADRESP, "CSatMessHandler::InfoPpReadResp, MO SMS control not supported by ME product profile" );
       
  4438                             iMoSmsSupportedInPp = EFalse;
       
  4439                             // Feature was not activated in product profile
       
  4440                             // Set MoSmsCtrl object´s member
       
  4441                             // iIsMoSmsCtrlActivated to EFalse
       
  4442                             iTsySatMessaging->GetMoSmsCtrl()->Deactivate();
       
  4443                             }
       
  4444                         }
       
  4445 #endif // INFO_PP_ATK_MO_SM_CONTROL
       
  4446 
       
  4447 #ifdef INFO_PP_ENHANCED_NETWORK_SELECTION
       
  4448                     if ( INFO_PP_ENHANCED_NETWORK_SELECTION == pPFeatures [0] )
       
  4449                         {
       
  4450                         //Get the value of the ENS feature
       
  4451                         if ( INFO_PP_FALSE != pPFeatures [1] )
       
  4452                             {
       
  4453                             TFLOGSTRING("TSY: CSatMessHandler::InfoPpReadResp, INFO_PP_ENHANCED_NETWORK_SELECTION supported by ME product profile" );
       
  4454                             OstTrace0( TRACE_NORMAL, DUP8_CSATMESSHANDLER_INFOPPREADRESP, "CSatMessHandler::InfoPpReadResp, INFO_PP_ENHANCED_NETWORK_SELECTION supported by ME product profile" );
       
  4455                             iEnsSupportedInPp = ETrue;
       
  4456                             }
       
  4457                         else
       
  4458                             {
       
  4459                             TFLOGSTRING("TSY: CSatMessHandler::InfoPpReadResp, INFO_PP_ENHANCED_NETWORK_SELECTION not supported by ME product profile" );
       
  4460                             OstTrace0( TRACE_NORMAL, DUP9_CSATMESSHANDLER_INFOPPREADRESP, "CSatMessHandler::InfoPpReadResp, INFO_PP_ENHANCED_NETWORK_SELECTION not supported by ME product profile" );
       
  4461                             iEnsSupportedInPp = EFalse;
       
  4462                             }
       
  4463                         }
       
  4464 #endif // INFO_PP_ENHANCED_NETWORK_SELECTION
       
  4465 
       
  4466 #ifdef INFO_PP_SIM_OLD_POLL_INTERVAL
       
  4467                     if ( INFO_PP_SIM_OLD_POLL_INTERVAL == pPFeatures [0] )
       
  4468                         {
       
  4469                         //Get the value of the SIM_POLL_INTERVAL control feature
       
  4470                         if ( INFO_PP_FALSE != pPFeatures [1] )
       
  4471                             {
       
  4472                             TFLOGSTRING("TSY: CSatMessHandler::InfoPpReadResp, INFO_PP_SIM_OLD_POLL_INTERVAL supported by ME product profile" );
       
  4473                             OstTrace0( TRACE_NORMAL, DUP4_CSATMESSHANDLER_INFOPPREADRESP, "CSatMessHandler::InfoPpReadResp, INFO_PP_SIM_OLD_POLL_INTERVAL supported by ME product profile" );
       
  4474                             iOldPollIntervalSupportedInPp = ETrue;
       
  4475                             }
       
  4476                         else
       
  4477                             {
       
  4478                             TFLOGSTRING("TSY: CSatMessHandler::InfoPpReadResp, INFO_PP_SIM_OLD_POLL_INTERVAL not supported by ME product profile" );
       
  4479                             OstTrace0( TRACE_NORMAL, DUP5_CSATMESSHANDLER_INFOPPREADRESP, "CSatMessHandler::InfoPpReadResp, INFO_PP_SIM_OLD_POLL_INTERVAL not supported by ME product profile" );
       
  4480                             iOldPollIntervalSupportedInPp = EFalse;
       
  4481                             }
       
  4482                         }
       
  4483 #endif // INFO_PP_SIM_OLD_POLL_INTERVAL
       
  4484                     //no else
       
  4485                     }
       
  4486                 }
       
  4487             break;
       
  4488             }
       
  4489         case INFO_NO_NUMBER:
       
  4490             {
       
  4491             TFLOGSTRING("TSY: CSatMessHandler::InfoPpReadResp, Requested feature not defined in product profile" );
       
  4492             OstTrace0( TRACE_NORMAL, DUP6_CSATMESSHANDLER_INFOPPREADRESP, "CSatMessHandler::InfoPpReadResp, Requested feature not defined in product profile" );
       
  4493 #ifdef INFO_PP_ATK_MO_SM_CONTROL
       
  4494             // Request was for INFO_PP_ATK_MO_SM_CONTROL
       
  4495             if ( traId == iInfoPpMoSmsTraId )
       
  4496                 {
       
  4497                 // If the MO SMS feature is not defined in product profile,
       
  4498                 // internal Boolean used as feature supported ( for refresh )
       
  4499                 iMoSmsSupportedInPp = ETrue;
       
  4500                 // Continue as usual by checking feature avalability from USIM
       
  4501                 if ( UICC_CARD_TYPE_UICC == iCardType )
       
  4502                     {
       
  4503                     // USIM: Read MO-SMS control from byte 4
       
  4504                     UiccReadServiceTableReq( KUiccTrIdServiceTableByte4, 5 );
       
  4505                     }
       
  4506                 else if ( UICC_CARD_TYPE_ICC == iCardType )
       
  4507                     {
       
  4508                     // SIM: Read MO-SMS control from byte 5
       
  4509                     UiccReadServiceTableReq( KUiccTrIdServiceTableByte5, 6 );
       
  4510                     }
       
  4511                 }
       
  4512 #endif // INFO_PP_ATK_MO_SM_CONTROL
       
  4513 
       
  4514             break;
       
  4515             }
       
  4516         case INFO_FAIL:
       
  4517         default:
       
  4518             {
       
  4519             TFLOGSTRING("TSY: CSatMessHandler::InfoPpReadResp, - default Requested feature not supported by ME product profile" );
       
  4520             OstTrace0( TRACE_NORMAL, DUP7_CSATMESSHANDLER_INFOPPREADRESP, "CSatMessHandler::InfoPpReadResp, - default Requested feature not supported by ME product profile" );
       
  4521 #ifdef INFO_PP_ATK_MO_SM_CONTROL
       
  4522             // Request was for INFO_PP_ATK_MO_SM_CONTROL
       
  4523             if ( traId == iInfoPpMoSmsTraId )
       
  4524                 {
       
  4525                 iMoSmsSupportedInPp = EFalse;
       
  4526                 iTsySatMessaging->GetMoSmsCtrl()->Deactivate();
       
  4527                 }
       
  4528 #endif // INFO_PP_ATK_MO_SM_CONTROL
       
  4529 
       
  4530             break;
       
  4531             }
       
  4532         }
       
  4533     // Zero iInfoPpMoSmsTraId if used. Not used by default.
       
  4534     if ( traId == iInfoPpMoSmsTraId )
       
  4535         {
       
  4536         iInfoPpMoSmsTraId = 0;
       
  4537         }
       
  4538     }
       
  4539 
       
  4540 
       
  4541 // -----------------------------------------------------------------------------
       
  4542 // CSatMessHandler::CheckTlvObjects
       
  4543 // Validates every simple tlv object from proactive command
       
  4544 // -----------------------------------------------------------------------------
       
  4545 //
       
  4546 TInt CSatMessHandler::CheckTlvObjects( CBerTlv& berTlv )
       
  4547     {
       
  4548     TFLOGSTRING("TSY: CSatMessHandler::CheckTlvObjects" );
       
  4549     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_CHECKTLVOBJECTS, "CSatMessHandler::CheckTlvObjects" );
       
  4550 
       
  4551     TInt ret( KErrNone );
       
  4552     TPtrC8 dataPtr = berTlv.Data();
       
  4553     TUint16 berTlvLength( berTlv.GetLength() );
       
  4554     TInt totalLength = 0;
       
  4555 
       
  4556     // index is set to beginning of data inside BER-TLV object. If length
       
  4557     // of BER-TLV object is coded as one byte, data starts from index 2
       
  4558     // and if length of BER-TLV object is coded as two bytes, data starts
       
  4559     // from index 3.
       
  4560     TInt index = 2;
       
  4561 
       
  4562     if( KTwoByteLengthCoding == dataPtr[KTlvLengthStartPosition] )
       
  4563         {
       
  4564         // data len is coded as two bytes, let's increment these variables
       
  4565         // so that two byte len is handled correctly
       
  4566         index++;
       
  4567         }
       
  4568 
       
  4569     while( berTlvLength > ( index - 2 ) )
       
  4570         {
       
  4571         // now index points to tag of simple TLV object, let's increment
       
  4572         // index by one so that it points to length of the simple TLV object
       
  4573         index++;
       
  4574 
       
  4575         // totalLength is incremented by 2 so that tag & len fields of the current
       
  4576         // simple tlv object are calcucated to total length of BER TLV object
       
  4577         totalLength += 2;
       
  4578 
       
  4579         if( KTwoByteLengthCoding == dataPtr[index] )
       
  4580             {
       
  4581             // data len is coded as two bytes, let's increment these variables
       
  4582             // so that two byte len is handled correctly
       
  4583             index++;
       
  4584             totalLength++;
       
  4585 
       
  4586             // if length of the simple TLV value is coded with two bytes,
       
  4587             // length of the simple TLV value must be 128-255, otherwise
       
  4588             // it is treaded as error
       
  4589             if( 0x80 > dataPtr[index] || 0xFF < dataPtr[index] )
       
  4590                 {
       
  4591                 TFLOGSTRING2("TSY: CSatMessHandler::CheckTlvObjects: corrupted simple tlv obj, len: %d even it should be 128-255", dataPtr[index] );
       
  4592 OstTrace1( TRACE_NORMAL, DUP1_CSATMESSHANDLER_CHECKTLVOBJECTS, "CSatMessHandler::CheckTlvObjects; corrupted simple tlv obj, len: %d even it should be 128-255", dataPtr[index] );
       
  4593                 ret = KErrCorrupt;
       
  4594                 break;
       
  4595                 }
       
  4596             }
       
  4597 
       
  4598         else
       
  4599             {
       
  4600             // if length of the simple TLV value is coded with one byte,
       
  4601             // length of the simple TLV value must be 0-127, otherwise
       
  4602             // it is treaded as error
       
  4603             if( 0x80 <= dataPtr[index] )
       
  4604                 {
       
  4605                 TFLOGSTRING2("TSY: CSatMessHandler::CheckTlvObjects: corrupted simple tlv obj, len: %d even it should be 0-127", dataPtr[index] );
       
  4606 OstTrace1( TRACE_NORMAL, DUP2_CSATMESSHANDLER_CHECKTLVOBJECTS, "CSatMessHandler::CheckTlvObjects; corrupted simple tlv obj, len: %d even it should be 0-127", dataPtr[index] );
       
  4607                 ret = KErrCorrupt;
       
  4608                 break;
       
  4609                 }
       
  4610             }
       
  4611 
       
  4612         // total length is incremented by data len of the current simple
       
  4613         // tlv object
       
  4614         totalLength += dataPtr[index];
       
  4615 
       
  4616         // let's move index to beginning of next simple TLV object. So
       
  4617         // after incrementing the index, it points to next simple TLV
       
  4618         // object's tag value
       
  4619         index += dataPtr[index] + 1;
       
  4620         } // end of while
       
  4621 
       
  4622     // let's check does length from proactive command match to
       
  4623     // calculated length
       
  4624     if( berTlvLength != totalLength )
       
  4625         {
       
  4626         TFLOGSTRING3("TSY: CSatMessHandler::CheckTlvObjects: proactive command len (%d) and calculated len (%d) doesn't match", berTlvLength, totalLength );
       
  4627 OstTraceExt2( TRACE_NORMAL, DUP3_CSATMESSHANDLER_CHECKTLVOBJECTS, "CSatMessHandler::CheckTlvObjects; proactive command len (%d) and calculated len (%d) doesn't match", berTlvLength, totalLength );
       
  4628         ret = KErrCorrupt;
       
  4629         }
       
  4630 
       
  4631     return ret;
       
  4632     }
       
  4633 
       
  4634 
       
  4635 // -----------------------------------------------------------------------------
       
  4636 // CSatMessHandler::SimMoSmsControlAvail
       
  4637 // Activate or deactivate MO SMS Control on SMS Server
       
  4638 // -----------------------------------------------------------------------------
       
  4639 //
       
  4640 void CSatMessHandler::SimMoSmsControlAvail( TUint8 aStatus )
       
  4641     {
       
  4642     TFLOGSTRING("TSY: CSatMessHandler::SimMoSmsControlAvail" );
       
  4643     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SIMMOSMSCONTROLAVAIL, "CSatMessHandler::SimMoSmsControlAvail" );
       
  4644 
       
  4645     // Activate the MO-SMS Control in SMS server. This is done by
       
  4646     // sending a request SMS_RESOURCE_CONF_REQ to SMS server
       
  4647     TBuf8<SIZE_SMS_RESOURCE_CONF_REQ + SIZE_SMS_SB_RESOURCE_CONF> data;
       
  4648     // Append Confoguration operation
       
  4649     data.Append( SMS_RES_CONF_SET );
       
  4650     // Number of Subblocks
       
  4651     data.Append( 1 );
       
  4652     // Add Subblock
       
  4653     TIsiSubBlock ResourceConfReqSb(
       
  4654         data,
       
  4655         SMS_SB_RESOURCE_CONF,
       
  4656         EIsiSubBlockTypeId16Len16 );
       
  4657 
       
  4658     TSatUtility::AppendWord( SMS_RES_ID_MO_SM_INIT, data );
       
  4659 
       
  4660     if( aStatus )
       
  4661         {
       
  4662         // Set MoSmsCtrl object´s member iIsMoSmsCtrlActivated to ETrue
       
  4663         iTsySatMessaging->GetMoSmsCtrl()->Activate();
       
  4664         TSatUtility::AppendWord( SMS_RES_ID_MASK_MO_SM_INIT, data);
       
  4665         }
       
  4666     else
       
  4667         {
       
  4668         // Set MoSmsCtrl object´s member IsMoSmsCtrlDeActivated to EFalse
       
  4669         iTsySatMessaging->GetMoSmsCtrl()->Deactivate();
       
  4670         TSatUtility::AppendWord( 0x0000, data);
       
  4671         }
       
  4672     ResourceConfReqSb.CompleteSubBlock();
       
  4673     SmsResoureConfReq(
       
  4674         iTsySatMessaging->GetTransactionId(),
       
  4675         SMS_RESOURCE_CONF_REQ,
       
  4676         data );
       
  4677     }
       
  4678 
       
  4679 
       
  4680 // -----------------------------------------------------------------------------
       
  4681 // CSatMessHandler::UiccTerminalProfileReq
       
  4682 // Send terminal profile
       
  4683 // -----------------------------------------------------------------------------
       
  4684 //
       
  4685 void CSatMessHandler::UiccTerminalProfileReq()
       
  4686     {
       
  4687     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_UICCTERMINALPROFILEREQ, "CSatMessHandler::UiccTerminalProfileReq" );
       
  4688     TFLOGSTRING("TSY: CSatMessHandler::UiccTerminalProfileReq");
       
  4689 
       
  4690     // Pointer to terminal profile buffer
       
  4691     const TUint8* terminalProfilePtr( NULL );
       
  4692     // Size of terminal profile
       
  4693     TInt sizeofTerminalProfile( 0 );
       
  4694 
       
  4695     if ( UICC_CARD_TYPE_UICC == iCardType )
       
  4696         {
       
  4697         terminalProfilePtr = &KTerminalProfileUicc[0];
       
  4698         sizeofTerminalProfile = sizeof( KTerminalProfileUicc );
       
  4699         }
       
  4700     else // ICC type
       
  4701         {
       
  4702         terminalProfilePtr = &KTerminalProfileIcc[0];
       
  4703         sizeofTerminalProfile = sizeof( KTerminalProfileIcc );
       
  4704         }
       
  4705 
       
  4706     // Create UICC_CAT_REQ message
       
  4707     TIsiSend isiMsg( iPnSend->SendBufferDes() );
       
  4708     isiMsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_UICC );
       
  4709     isiMsg.Set8bit(
       
  4710         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_TRANSID,
       
  4711         KUiccTrIdCommon );
       
  4712     isiMsg.Set8bit(
       
  4713         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_MESSAGEID,
       
  4714         UICC_CAT_REQ );
       
  4715     isiMsg.Set8bit(
       
  4716         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_SERVICETYPE,
       
  4717         UICC_CAT_TERMINAL_PROFILE );
       
  4718     isiMsg.Set8bit( ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_NSB, 1 );
       
  4719 
       
  4720     // Create UICC_SB_TERMINAL_PROFILE subblock
       
  4721     TBuf8<KSizeOfTerminalProfileSb> terminalProfileBuf( 0 );
       
  4722     TIsiSubBlock uiccSbTerminalProfile(
       
  4723         terminalProfileBuf,
       
  4724         UICC_SB_TERMINAL_PROFILE,
       
  4725         EIsiSubBlockTypeId16Len16 );
       
  4726 
       
  4727     // 2x filler
       
  4728     terminalProfileBuf.Append( KUiccPadding );
       
  4729     terminalProfileBuf.Append( KUiccPadding );
       
  4730 
       
  4731     // Terminal profile length (16-bit)
       
  4732     terminalProfileBuf.Append( 0 );
       
  4733     terminalProfileBuf.Append( sizeofTerminalProfile );
       
  4734 
       
  4735     // Terminal profile
       
  4736     terminalProfileBuf.Append( terminalProfilePtr, sizeofTerminalProfile );
       
  4737 
       
  4738     // Append subblock to ISI message
       
  4739     isiMsg.CopyData(
       
  4740         ISI_HEADER_SIZE + SIZE_UICC_CAT_REQ,
       
  4741         uiccSbTerminalProfile.CompleteSubBlock() );
       
  4742 
       
  4743     iPnSend->Send( isiMsg.Complete() );
       
  4744     }
       
  4745 
       
  4746 
       
  4747 // -----------------------------------------------------------------------------
       
  4748 // CSatMessHandler::UiccReadServiceTable
       
  4749 // (other items were commented in a header).
       
  4750 // -----------------------------------------------------------------------------
       
  4751 //
       
  4752 TInt CSatMessHandler::UiccReadServiceTableReq(
       
  4753     TUint8 aTrId,
       
  4754     TUint16 aFileOffset )
       
  4755     {
       
  4756     TFLOGSTRING2("TSY: CSatMessHandler::UiccReadServiceTableReq, transaction ID: %d", aTrId );
       
  4757     OstTraceExt1( TRACE_NORMAL, CSATMESSHANDLER_UICCREADSERVICETABLE, "CSatMessHandler::UiccReadServiceTableReq;aTrId=%hhu", aTrId );
       
  4758 
       
  4759     TIsiSend isiMsg( iPnSend->SendBufferDes() );
       
  4760     isiMsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_UICC );
       
  4761     isiMsg.Set8bit(
       
  4762         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_TRANSID,
       
  4763         aTrId );
       
  4764     isiMsg.Set8bit(
       
  4765         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_MESSAGEID,
       
  4766         UICC_APPL_CMD_REQ );
       
  4767     isiMsg.Set8bit(
       
  4768         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_SERVICETYPE,
       
  4769         UICC_APPL_READ_TRANSPARENT );
       
  4770     isiMsg.Set8bit(
       
  4771         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_APPLID,
       
  4772         iApplicationId );
       
  4773     isiMsg.Set8bit(
       
  4774         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_SESSIONID,
       
  4775         UICC_SESSION_ID_NOT_USED );
       
  4776     isiMsg.Set16bit(
       
  4777         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_FILLERBYTE1,
       
  4778         KUiccPadding );
       
  4779     isiMsg.Set8bit(
       
  4780         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_NSB,
       
  4781         KNumOfSbsInUiccApplCmdReq );
       
  4782 
       
  4783     // UICC_SB_CLIENT
       
  4784     TBuf8<SIZE_UICC_SB_CLIENT> uiccSbClientBuf( 0 );
       
  4785     TIsiSubBlock uiccSbClient(
       
  4786         uiccSbClientBuf,
       
  4787         UICC_SB_CLIENT,
       
  4788         EIsiSubBlockTypeId16Len16 );
       
  4789     // 3x padding
       
  4790     uiccSbClientBuf.Append( KUiccPadding );
       
  4791     uiccSbClientBuf.Append( KUiccPadding );
       
  4792     uiccSbClientBuf.Append( KUiccPadding );
       
  4793     uiccSbClientBuf.Append( iUiccClientId );
       
  4794     // Append subblock to ISI message
       
  4795     isiMsg.CopyData( KUiccApplCmdReqOffset, uiccSbClient.CompleteSubBlock() );
       
  4796 
       
  4797     // UICC_SB_TRANSPARENT
       
  4798     TBuf8<SIZE_UICC_SB_TRANSPARENT> uiccSbTransparentBuf( 0 );
       
  4799     TIsiSubBlock uiccSbTransparent(
       
  4800         uiccSbTransparentBuf,
       
  4801         UICC_SB_TRANSPARENT,
       
  4802         EIsiSubBlockTypeId16Len16 );
       
  4803     // File offset defines which service is read, 16-bit.
       
  4804     // Service table is max. 10 bytes so MSB bytes are set to 0
       
  4805     uiccSbTransparentBuf.Append( 0 );
       
  4806     uiccSbTransparentBuf.Append( aFileOffset );
       
  4807     // Data amount, 16-bit
       
  4808     // Read only one byte -> MSB bits are set to 0
       
  4809     uiccSbTransparentBuf.Append( 0 );
       
  4810     uiccSbTransparentBuf.Append( 1 );
       
  4811     // Append subblock to ISI message
       
  4812     isiMsg.CopyData(
       
  4813         KUiccApplCmdReqOffset + SIZE_UICC_SB_CLIENT,
       
  4814         uiccSbTransparent.CompleteSubBlock() );
       
  4815 
       
  4816     // UICC_SB_APPL_PATH
       
  4817     TBuf8<KUiccSbApplPathSize> uiccSbApplPathBuf( 0 );
       
  4818     TIsiSubBlock uiccSbApplPath(
       
  4819         uiccSbApplPathBuf,
       
  4820         UICC_SB_APPL_PATH,
       
  4821         EIsiSubBlockTypeId16Len16 );
       
  4822     // File ID is '6F38', EF UST
       
  4823     uiccSbApplPathBuf.Append( KUiccElemFileServiceTable >> 8 );
       
  4824     uiccSbApplPathBuf.Append( KUiccElemFileServiceTable );
       
  4825     // File ID SFI, 8-bit
       
  4826     uiccSbApplPathBuf.Append( KUiccSfiServiceTable );
       
  4827     // Filler, 8-bit
       
  4828     uiccSbApplPathBuf.Append( KUiccPadding );
       
  4829     // Length of the DF path, 8-bit
       
  4830     uiccSbApplPathBuf.Append( KUiccFilePathLengthServiceTable );
       
  4831     // Filler, 8-bit
       
  4832     uiccSbApplPathBuf.Append( KUiccPadding );
       
  4833     // Application file path:
       
  4834     // master file ID + application file ID
       
  4835     uiccSbApplPathBuf.Append( KUiccMasterFileId >> 8 );
       
  4836     uiccSbApplPathBuf.Append( KUiccMasterFileId );
       
  4837     uiccSbApplPathBuf.Append( iApplFileId );
       
  4838 
       
  4839     // Append subblock to ISI message
       
  4840     isiMsg.CopyData(
       
  4841         KUiccApplCmdReqOffset + SIZE_UICC_SB_CLIENT + SIZE_UICC_SB_TRANSPARENT,
       
  4842         uiccSbApplPath.CompleteSubBlock() );
       
  4843 
       
  4844     return( iPnSend->Send( isiMsg.Complete() ) );
       
  4845     }
       
  4846 
       
  4847 
       
  4848 // -----------------------------------------------------------------------------
       
  4849 // CSatMessHandler::UiccReadSatIconReq
       
  4850 // (other items were commented in a header).
       
  4851 // -----------------------------------------------------------------------------
       
  4852 //
       
  4853 TInt CSatMessHandler::UiccReadSatIconReq(
       
  4854     TUint8 aRecordNumber,
       
  4855     TUint8 aFileOffset,
       
  4856     TUint8 aDataAmount,
       
  4857     TUint8 aTrId )
       
  4858     {
       
  4859     TIsiSend isiMsg( iPnSend->SendBufferDes() );
       
  4860     isiMsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_UICC );
       
  4861     isiMsg.Set8bit(
       
  4862         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_TRANSID,
       
  4863         aTrId );
       
  4864     isiMsg.Set8bit(
       
  4865         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_MESSAGEID,
       
  4866         UICC_APPL_CMD_REQ );
       
  4867     isiMsg.Set8bit(
       
  4868         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_SERVICETYPE,
       
  4869         UICC_APPL_READ_TRANSPARENT );
       
  4870     isiMsg.Set8bit(
       
  4871         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_APPLID,
       
  4872         iApplicationId );
       
  4873     isiMsg.Set8bit(
       
  4874         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_SESSIONID,
       
  4875         UICC_SESSION_ID_NOT_USED );
       
  4876     isiMsg.Set16bit(
       
  4877         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_FILLERBYTE1,
       
  4878         KUiccPadding );
       
  4879     isiMsg.Set8bit(
       
  4880         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_NSB,
       
  4881         KNumOfSbsInUiccApplCmdReq );
       
  4882 
       
  4883     // UICC_SB_CLIENT
       
  4884     TBuf8<SIZE_UICC_SB_CLIENT> uiccSbClientBuf( 0 );
       
  4885     TIsiSubBlock uiccSbClient(
       
  4886         uiccSbClientBuf,
       
  4887         UICC_SB_CLIENT,
       
  4888         EIsiSubBlockTypeId16Len16 );
       
  4889     // 3x padding
       
  4890     uiccSbClientBuf.Append( KUiccPadding );
       
  4891     uiccSbClientBuf.Append( KUiccPadding );
       
  4892     uiccSbClientBuf.Append( KUiccPadding );
       
  4893     uiccSbClientBuf.Append( iUiccClientId );
       
  4894     // Append subblock to ISI message
       
  4895     isiMsg.CopyData( KUiccApplCmdReqOffset, uiccSbClient.CompleteSubBlock() );
       
  4896 
       
  4897     // UICC_SB_LINEAR_FIXED
       
  4898     TBuf8<SIZE_UICC_SB_LINEAR_FIXED> uiccSbLinearFixedBuf( 0 );
       
  4899     TIsiSubBlock uiccSbLinearFixed(
       
  4900         uiccSbLinearFixedBuf,
       
  4901         UICC_SB_LINEAR_FIXED,
       
  4902         EIsiSubBlockTypeId16Len16 );
       
  4903     // Record number, 8-bit
       
  4904     uiccSbLinearFixedBuf.Append( aRecordNumber );
       
  4905     // File offset, 8-bit
       
  4906     uiccSbLinearFixedBuf.Append( aFileOffset );
       
  4907     // Data amount, 8-bit
       
  4908     uiccSbLinearFixedBuf.Append( aDataAmount );
       
  4909     // Append subblock to ISI message
       
  4910     isiMsg.CopyData(
       
  4911         KUiccApplCmdReqOffset + SIZE_UICC_SB_CLIENT,
       
  4912         uiccSbLinearFixed.CompleteSubBlock() );
       
  4913 
       
  4914     // UICC_SB_APPL_PATH
       
  4915     TBuf8<KUiccSbApplPathSize> uiccSbApplPathBuf( 0 );
       
  4916     TIsiSubBlock uiccSbApplPath(
       
  4917         uiccSbApplPathBuf,
       
  4918         UICC_SB_APPL_PATH,
       
  4919         EIsiSubBlockTypeId16Len16 );
       
  4920     // File ID is '4F20', EF IMG
       
  4921     uiccSbApplPathBuf.Append( KUiccElemFileImg >> 8 );
       
  4922     uiccSbApplPathBuf.Append( KUiccElemFileImg );
       
  4923     // File ID SFI, 8-bit
       
  4924     uiccSbApplPathBuf.Append( UICC_SFI_NOT_PRESENT );
       
  4925     // Filler, 8-bit
       
  4926     uiccSbApplPathBuf.Append( KUiccPadding );
       
  4927     // Length of the DF path, 8-bit
       
  4928     uiccSbApplPathBuf.Append( KUiccFilePathLength );
       
  4929     // Filler, 8-bit
       
  4930     uiccSbApplPathBuf.Append( KUiccPadding );
       
  4931     // Application file path:
       
  4932     // master file + application file + dedicated file +
       
  4933     // elementary file
       
  4934     uiccSbApplPathBuf.Append( KUiccMasterFileId >> 8 );
       
  4935     uiccSbApplPathBuf.Append( KUiccMasterFileId );
       
  4936     uiccSbApplPathBuf.Append( KUiccDedicatedFileTelecom >> 8 );
       
  4937     uiccSbApplPathBuf.Append( KUiccDedicatedFileTelecom );
       
  4938     uiccSbApplPathBuf.Append( KUiccDedicatedFileGraphics >> 8 );
       
  4939     uiccSbApplPathBuf.Append( KUiccDedicatedFileGraphics );
       
  4940 
       
  4941     // Append subblock to ISI message
       
  4942     isiMsg.CopyData(
       
  4943         KUiccApplCmdReqOffset + SIZE_UICC_SB_CLIENT +
       
  4944         SIZE_UICC_SB_LINEAR_FIXED,
       
  4945         uiccSbApplPath.CompleteSubBlock() );
       
  4946 
       
  4947     return( iPnSend->Send( isiMsg.Complete() ) );
       
  4948     }
       
  4949 
       
  4950 
       
  4951 // -----------------------------------------------------------------------------
       
  4952 // CSatMessHandler::UiccReadSatIconInstanceReq
       
  4953 // (other items were commented in a header).
       
  4954 // -----------------------------------------------------------------------------
       
  4955 //
       
  4956 TInt CSatMessHandler::UiccReadSatIconInstanceReq( TUint16 aFileId )
       
  4957     {
       
  4958     TIsiSend isiMsg( iPnSend->SendBufferDes() );
       
  4959     isiMsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_UICC );
       
  4960     isiMsg.Set8bit(
       
  4961         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_TRANSID,
       
  4962         KUiccTrIdReadIconInstancePhase2 );
       
  4963     isiMsg.Set8bit(
       
  4964         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_MESSAGEID,
       
  4965         UICC_APPL_CMD_REQ );
       
  4966     isiMsg.Set8bit(
       
  4967         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_SERVICETYPE,
       
  4968         UICC_APPL_READ_TRANSPARENT );
       
  4969     isiMsg.Set8bit(
       
  4970         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_APPLID,
       
  4971         iApplicationId );
       
  4972     isiMsg.Set8bit(
       
  4973         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_SESSIONID,
       
  4974         UICC_SESSION_ID_NOT_USED );
       
  4975     isiMsg.Set16bit(
       
  4976         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_FILLERBYTE1,
       
  4977         KUiccPadding );
       
  4978     isiMsg.Set8bit(
       
  4979         ISI_HEADER_SIZE + UICC_APPL_CMD_REQ_OFFSET_NSB,
       
  4980         KNumOfSbsInUiccApplCmdReq );
       
  4981 
       
  4982     // UICC_SB_CLIENT
       
  4983     TBuf8<SIZE_UICC_SB_CLIENT> uiccSbClientBuf( 0 );
       
  4984     TIsiSubBlock uiccSbClient(
       
  4985         uiccSbClientBuf,
       
  4986         UICC_SB_CLIENT,
       
  4987         EIsiSubBlockTypeId16Len16 );
       
  4988     // 3x padding
       
  4989     uiccSbClientBuf.Append( KUiccPadding );
       
  4990     uiccSbClientBuf.Append( KUiccPadding );
       
  4991     uiccSbClientBuf.Append( KUiccPadding );
       
  4992     uiccSbClientBuf.Append( iUiccClientId );
       
  4993     // Append subblock to ISI message
       
  4994     isiMsg.CopyData( KUiccApplCmdReqOffset, uiccSbClient.CompleteSubBlock() );
       
  4995 
       
  4996     // UICC_SB_LINEAR_FIXED
       
  4997     TBuf8<SIZE_UICC_SB_TRANSPARENT> uiccSbTransparentBuf( 0 );
       
  4998     TIsiSubBlock uiccSbTransparent(
       
  4999         uiccSbTransparentBuf,
       
  5000         UICC_SB_TRANSPARENT,
       
  5001         EIsiSubBlockTypeId16Len16 );
       
  5002     // File offset, 8-bit
       
  5003     uiccSbTransparentBuf.Append( 0 );
       
  5004     // Data amount, 8-bit
       
  5005     uiccSbTransparentBuf.Append( 0 );
       
  5006     // Append subblock to ISI message
       
  5007     isiMsg.CopyData(
       
  5008         KUiccApplCmdReqOffset + SIZE_UICC_SB_CLIENT,
       
  5009         uiccSbTransparent.CompleteSubBlock() );
       
  5010 
       
  5011     // UICC_SB_APPL_PATH
       
  5012     TBuf8<KUiccSbApplPathSize> uiccSbApplPathBuf( 0 );
       
  5013     TIsiSubBlock uiccSbApplPath(
       
  5014         uiccSbApplPathBuf,
       
  5015         UICC_SB_APPL_PATH,
       
  5016         EIsiSubBlockTypeId16Len16 );
       
  5017     // File ID is '4F20', EF IMG
       
  5018     uiccSbApplPathBuf.Append( aFileId >> 8 );
       
  5019     uiccSbApplPathBuf.Append( aFileId );
       
  5020     // File ID SFI, 8-bit
       
  5021     uiccSbApplPathBuf.Append( UICC_EF_ID_NOT_PRESENT );
       
  5022     // Filler, 8-bit
       
  5023     uiccSbApplPathBuf.Append( KUiccPadding );
       
  5024     // Length of the DF path, 8-bit
       
  5025     uiccSbApplPathBuf.Append( KUiccFilePathLength );
       
  5026     // Filler, 8-bit
       
  5027     uiccSbApplPathBuf.Append( KUiccPadding );
       
  5028     // Application file path:
       
  5029     // master file + application file + dedicated file +
       
  5030     // elementary file
       
  5031     uiccSbApplPathBuf.Append( KUiccMasterFileId >> 8 );
       
  5032     uiccSbApplPathBuf.Append( KUiccMasterFileId );
       
  5033     uiccSbApplPathBuf.Append( KUiccDedicatedFileTelecom >> 8 );
       
  5034     uiccSbApplPathBuf.Append( KUiccDedicatedFileTelecom );
       
  5035     uiccSbApplPathBuf.Append( KUiccDedicatedFileGraphics >> 8 );
       
  5036     uiccSbApplPathBuf.Append( KUiccDedicatedFileGraphics );
       
  5037 
       
  5038     // Append subblock to ISI message
       
  5039     isiMsg.CopyData(
       
  5040         KUiccApplCmdReqOffset + SIZE_UICC_SB_CLIENT +
       
  5041         SIZE_UICC_SB_TRANSPARENT,
       
  5042         uiccSbApplPath.CompleteSubBlock() );
       
  5043 
       
  5044     return( iPnSend->Send( isiMsg.Complete() ) );
       
  5045     }
       
  5046 
       
  5047 
       
  5048 // -----------------------------------------------------------------------------
       
  5049 // CSatMessHandler::UiccCatReq
       
  5050 // Create and send UICC_CAT_REQ ISI message
       
  5051 // -----------------------------------------------------------------------------
       
  5052 //
       
  5053 TInt CSatMessHandler::UiccCatReq( TUint8 aCommand )
       
  5054     {
       
  5055     TFLOGSTRING("TSY: CSatMessHandler::UiccCatReq");
       
  5056     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_UICCCATREQ, "CSatMessHandler::UiccCatReq" );
       
  5057 
       
  5058     TIsiSend isiMsg( iPnSend->SendBufferDes() );
       
  5059     isiMsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_UICC );
       
  5060     isiMsg.Set8bit(
       
  5061         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_TRANSID,
       
  5062         KUiccTrIdCommon );
       
  5063     isiMsg.Set8bit(
       
  5064         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_MESSAGEID,
       
  5065         UICC_CAT_REQ );
       
  5066     isiMsg.Set8bit(
       
  5067         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_SERVICETYPE,
       
  5068         aCommand );
       
  5069 
       
  5070     // No subblocks
       
  5071     isiMsg.Set8bit(
       
  5072         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_NSB,
       
  5073         0 );
       
  5074 
       
  5075     return( iPnSend->Send( isiMsg.Complete() ) );
       
  5076     }
       
  5077 
       
  5078 
       
  5079 // -----------------------------------------------------------------------------
       
  5080 // CSatMessHandler::UiccCatReqRefresh
       
  5081 // Create and send UICC_CAT_REQ ISI message for refresh command
       
  5082 // -----------------------------------------------------------------------------
       
  5083 //
       
  5084 TInt CSatMessHandler::UiccCatReqRefresh(
       
  5085     const TUint8 aTransId,        // Transaction ID
       
  5086     const TUint8 aServiceType,    // Type of refresh
       
  5087     TDes8& aFileList,             // List of files
       
  5088     const TDesC8& aAid )          // Application ID (USIM)
       
  5089     {
       
  5090     TFLOGSTRING("TSY: CSatMessHandler::UiccCatReqRefresh");
       
  5091     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_UICCCATREQREFRESH, "CSatMessHandler::UiccCatReqRefresh" );
       
  5092 
       
  5093     TUint8 numOfSubblocks( 1 ); // One mandatory subblock UICC_SB_REFRESH
       
  5094     TUint8 uiccSbOffset(
       
  5095         ISI_HEADER_SIZE + SIZE_UICC_CAT_REQ + SIZE_UICC_SB_REFRESH );
       
  5096 
       
  5097     TIsiSend isiMsg( iPnSend->SendBufferDes() );
       
  5098     isiMsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_UICC );
       
  5099     isiMsg.Set8bit(
       
  5100         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_TRANSID,
       
  5101         aTransId );
       
  5102     isiMsg.Set8bit(
       
  5103         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_MESSAGEID,
       
  5104         UICC_CAT_REQ );
       
  5105     isiMsg.Set8bit(
       
  5106         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_SERVICETYPE,
       
  5107         UICC_CAT_REFRESH );
       
  5108 
       
  5109     // Add UICC_SB_REFRESH
       
  5110     TBuf8<SIZE_UICC_SB_REFRESH> uiccSbRefreshBuf( 0 );
       
  5111     TIsiSubBlock uiccSbRefresh(
       
  5112         uiccSbRefreshBuf,
       
  5113         UICC_SB_REFRESH,
       
  5114         EIsiSubBlockTypeId16Len16 );
       
  5115     // Type of refresh
       
  5116     uiccSbRefreshBuf.Append( aServiceType );
       
  5117     // 3x filler
       
  5118     uiccSbRefreshBuf.Append( KUiccPadding );
       
  5119     uiccSbRefreshBuf.Append( KUiccPadding );
       
  5120     uiccSbRefreshBuf.Append( KUiccPadding );
       
  5121     // Append subblock to ISI message
       
  5122     isiMsg.CopyData(
       
  5123         ISI_HEADER_SIZE + SIZE_UICC_CAT_REQ,
       
  5124         uiccSbRefresh.CompleteSubBlock() );
       
  5125 
       
  5126     // Add UICC_SB_AID if needed
       
  5127     if ( aAid.Length() )
       
  5128         {
       
  5129         numOfSubblocks++;
       
  5130         TBuf8<KMaxLengthUiccSbAid> uiccSbAidBuf( 0 );
       
  5131         TIsiSubBlock uiccSbAid(
       
  5132             uiccSbAidBuf,
       
  5133             UICC_SB_AID,
       
  5134             EIsiSubBlockTypeId16Len16 );
       
  5135         // AID length
       
  5136         uiccSbAidBuf.Append( aAid.Length() );
       
  5137         // Add AID
       
  5138         uiccSbAidBuf.Append( aAid );
       
  5139         // Append subblock to ISI message
       
  5140         isiMsg.CopyData( uiccSbOffset, uiccSbAid.CompleteSubBlock() );
       
  5141 
       
  5142         // Calculate offset for next subblock
       
  5143         TUint16 lengthOfUiccSbAid( uiccSbAidBuf.Length() ); // Length of UICC_SB_AID
       
  5144         uiccSbOffset += lengthOfUiccSbAid;
       
  5145         }
       
  5146 
       
  5147     // Add UICC_SB_APPL_PATH subblock(s) if needed
       
  5148     while ( aFileList.Length() )
       
  5149         {
       
  5150         numOfSubblocks++;
       
  5151         // Search last file's start position
       
  5152         TInt position( aFileList.LocateReverse( KRefreshMasterFileHeader ) );
       
  5153         if ( KErrNotFound == position )
       
  5154             {
       
  5155             // File path is corrupted
       
  5156             TFLOGSTRING("TSY: CSatMessHandler::SimAtkReq, File path is corrupted");
       
  5157             OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_UICCCATREQREFRESH, "CSatMessHandler::UiccCatReqRefresh,File path is corrupted" );
       
  5158             break;
       
  5159             }
       
  5160 
       
  5161         // Length of file path
       
  5162         TUint8 length( (TUint8) ( aFileList.Length() - position ) );
       
  5163         // File path
       
  5164         TBuf8<KUiccFilePathLength> filePath(
       
  5165             aFileList.Mid( position, length ) );
       
  5166         // File ID is two last bytes
       
  5167         TBuf8<KUiccFileIdLength> fileId(
       
  5168             filePath.Mid( filePath.Length() - 2 ) );
       
  5169 
       
  5170         TBuf8<SIZE_UICC_SB_APPL_PATH + KUiccFilePathLength>
       
  5171             uiccSbApplPathBuf( 0 );
       
  5172         TIsiSubBlock uiccSbApplPath(
       
  5173             uiccSbApplPathBuf,
       
  5174             UICC_SB_APPL_PATH,
       
  5175             EIsiSubBlockTypeId16Len16 );
       
  5176         // Append file ID
       
  5177         uiccSbApplPathBuf.Append( fileId );
       
  5178         // File ID SFI is not known
       
  5179         uiccSbApplPathBuf.Append( UICC_SFI_NOT_PRESENT );
       
  5180         // Filler
       
  5181         uiccSbApplPathBuf.Append( KUiccPadding );
       
  5182         // File path length in bytes
       
  5183         uiccSbApplPathBuf.Append( length );
       
  5184         // Filler
       
  5185         uiccSbApplPathBuf.Append( KUiccPadding );
       
  5186         // File path
       
  5187         uiccSbApplPathBuf.Append( filePath );
       
  5188         // Append subblock to ISI message
       
  5189         isiMsg.CopyData( uiccSbOffset, uiccSbApplPath.CompleteSubBlock() );
       
  5190         // Update subblock offset
       
  5191         uiccSbOffset += uiccSbApplPathBuf.Length();
       
  5192 
       
  5193         // Remove already added file from buffer
       
  5194         aFileList.SetLength( aFileList.Length() - length );
       
  5195         // Clear buffer for a new sub block
       
  5196         uiccSbApplPathBuf.Zero();
       
  5197         }
       
  5198 
       
  5199     isiMsg.Set8bit(
       
  5200         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_NSB,
       
  5201         numOfSubblocks );
       
  5202 
       
  5203     // set flag on that we are waiting a response for a refresh request
       
  5204     iRefreshRequestIsOn = ETrue;
       
  5205 
       
  5206     return( iPnSend->Send( isiMsg.Complete() ) );
       
  5207     }
       
  5208 
       
  5209 
       
  5210 // -----------------------------------------------------------------------------
       
  5211 // CSatMessHandler::UiccCatReqTerminalResponse
       
  5212 // Send UICC_CAT_REQ ISI message for sending terminal response to UICC
       
  5213 // -----------------------------------------------------------------------------
       
  5214 //
       
  5215 TInt CSatMessHandler::UiccCatReqTerminalResponse(
       
  5216     const TDes8& aCommandDetails,         // Command details tlv
       
  5217     const TDesC8& aBerTlvSpecificData,    // BER-TLV specific data
       
  5218     const TUint8 aTransId )
       
  5219     {
       
  5220     TFLOGSTRING("TSY: CSatMessHandler::UiccCatReqTerminalResponse");
       
  5221     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_UICCCATREQTERMINALRESPONSE, "CSatMessHandler::UiccCatReqTerminalResponse" );
       
  5222 
       
  5223     TIsiSend isiMsg( iPnSend->SendBufferDes() );
       
  5224     isiMsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_UICC );
       
  5225     isiMsg.Set8bit(
       
  5226         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_TRANSID,
       
  5227         aTransId );
       
  5228     isiMsg.Set8bit(
       
  5229         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_MESSAGEID,
       
  5230         UICC_CAT_REQ );
       
  5231     isiMsg.Set8bit(
       
  5232         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_SERVICETYPE,
       
  5233         UICC_CAT_TERMINAL_RESPONSE );
       
  5234     // One subblock, UICC_SB_TERMINAL_RESPONSE
       
  5235     isiMsg.Set8bit(
       
  5236         ISI_HEADER_SIZE + UICC_CAT_REQ_OFFSET_NSB,
       
  5237         1 );
       
  5238 
       
  5239     // UICC_SB_TERMINAL_RESPONSE
       
  5240     TBuf8<KMaxSizeOfUiccSbTerminalResponse> uiccSbTerminalResponseBuf( 0 );
       
  5241     TIsiSubBlock uiccSbTerminalResponse(
       
  5242         uiccSbTerminalResponseBuf,
       
  5243         UICC_SB_TERMINAL_RESPONSE,
       
  5244         EIsiSubBlockTypeId16Len16 );
       
  5245 
       
  5246     // 2x filler
       
  5247     uiccSbTerminalResponseBuf.Append( KUiccPadding );
       
  5248     uiccSbTerminalResponseBuf.Append( KUiccPadding );
       
  5249 
       
  5250     if ( aCommandDetails.Length() )
       
  5251         {
       
  5252         // Calculate terminal response data length
       
  5253         // 9 = command details lenght + device identity length
       
  5254         TUint16 lengthOfData( ( TUint16 ) ( 9 + aBerTlvSpecificData.Length() ) );
       
  5255         // Terminal response data length (2 bytes)
       
  5256         uiccSbTerminalResponseBuf.Append( lengthOfData >> 8 );
       
  5257         uiccSbTerminalResponseBuf.Append( lengthOfData );
       
  5258 
       
  5259         // Add command details
       
  5260         uiccSbTerminalResponseBuf.Append( aCommandDetails );
       
  5261 
       
  5262         // Add device identity TLV
       
  5263         // Device identity tag
       
  5264         uiccSbTerminalResponseBuf.Append( KTlvDeviceIdentityTag );
       
  5265         // Device identity TLV length
       
  5266         uiccSbTerminalResponseBuf.Append( KTlvDeviceIdentityLength );
       
  5267         // Source device identity = ME
       
  5268         uiccSbTerminalResponseBuf.Append( KMe );
       
  5269         // Destination device identity = SIM
       
  5270         uiccSbTerminalResponseBuf.Append( KSim );
       
  5271 
       
  5272         // Add TLV specific data
       
  5273         uiccSbTerminalResponseBuf.Append( aBerTlvSpecificData );
       
  5274         }
       
  5275     else // Empty terminal response =>  length is zero
       
  5276         {
       
  5277         uiccSbTerminalResponseBuf.Append( 0 );
       
  5278         uiccSbTerminalResponseBuf.Append( 0 );
       
  5279         }
       
  5280 
       
  5281     // Save terminal resp transaction id
       
  5282     iTerminalRespTraId = aTransId;
       
  5283     TFLOGSTRING2("TSY: CSatMessHandler::UiccCatReqTerminalResponse iTerminalRespTraId=%d", iTerminalRespTraId);
       
  5284     OstTrace1( TRACE_NORMAL, DUP1_CSATMESSHANDLER_UICCCATREQTERMINALRESPONSE, "CSatMessHandler::UiccCatReqTerminalResponse;iTerminalRespTraId=%d", iTerminalRespTraId );
       
  5285 
       
  5286     // Append subblock to ISI message
       
  5287     isiMsg.CopyData(
       
  5288         ISI_HEADER_SIZE + SIZE_UICC_CAT_REQ,
       
  5289         uiccSbTerminalResponse.CompleteSubBlock() );
       
  5290 
       
  5291     return( iPnSend->Send( isiMsg.Complete() ) );
       
  5292     }
       
  5293 
       
  5294 // -----------------------------------------------------------------------------
       
  5295 // CSatMessHandler::UiccCatRespEnvelope
       
  5296 // Handles UICC response for envelope
       
  5297 // -----------------------------------------------------------------------------
       
  5298 //
       
  5299 TBool CSatMessHandler::UiccCatRespEnvelope( const TIsiReceiveC& aIsiMessage )
       
  5300     {
       
  5301     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_UICCCATENVELOPERESP, "CSatMessHandler::UiccCatRespEnvelope" );
       
  5302     TFLOGSTRING("TSY:CSatMessHandler::UiccCatRespEnvelope");
       
  5303 
       
  5304     TBool handled( EFalse );
       
  5305     TUint8 trId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID ) );
       
  5306 
       
  5307     TUint uiccSbApduOffset( 0 );
       
  5308     if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  5309         ISI_HEADER_SIZE + SIZE_UICC_CAT_RESP,
       
  5310         UICC_SB_APDU,
       
  5311         EIsiSubBlockTypeId16Len16,
       
  5312         uiccSbApduOffset ) )
       
  5313         {
       
  5314         TPtrC8 apduData;
       
  5315         TUint16 apduLength( aIsiMessage.Get16bit(
       
  5316             uiccSbApduOffset + UICC_SB_APDU_OFFSET_APDULENGTH ) );
       
  5317         apduData.Set( aIsiMessage.GetData(
       
  5318             uiccSbApduOffset + UICC_SB_APDU_OFFSET_APDU,
       
  5319             apduLength ) );
       
  5320         // Status bytes are two last bytes in APDU
       
  5321         TUint8 sw1( apduData[apduLength - 2] );
       
  5322         TUint8 sw2( apduData[apduLength - 1] );
       
  5323 
       
  5324         if ( KAtkSwDataNtfSw1NormalEnding == sw1
       
  5325             && KAtkSwDataNtfSw2NormalEnding == sw2 )
       
  5326             {
       
  5327             // SIM responded OK. Remove stored envelope.
       
  5328             iTsySatMessaging->GetSatTimer()->RemoveEnvelope( trId );
       
  5329             }
       
  5330         else
       
  5331             {
       
  5332             // Problems in envelope sending, resend envelope if appropriate.
       
  5333             if ( KErrNone == iTsySatMessaging->GetSatTimer()->
       
  5334                 ActivateEnvelopeResend( trId, sw1 ) )
       
  5335                 {
       
  5336                 TFLOGSTRING( "TSY:CSatMessHandler::UiccCatRespEnvelope, resending of envelope" );
       
  5337                 OstTrace0( TRACE_NORMAL, DUP2_CSATMESSHANDLER_UICCCATENVELOPERESP, "CSatMessHandler::UiccCatRespEnvelope,resending of envelope" );
       
  5338                 // Envelope will be resent, mark as handled
       
  5339                 handled = ETrue;
       
  5340                 }
       
  5341             }
       
  5342         }
       
  5343     else // Subblock is mandatory
       
  5344         {
       
  5345         TFLOGSTRING("TSY: CSatMessHandler::UiccCatRespEnvelope - Mandatory subblock UICC_SB_APDU not found");
       
  5346         OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_UICCCATENVELOPERESP, "CSatMessHandler::UiccCatRespEnvelope- Mandatory subblock UICC_SB_APDU not found" );
       
  5347         }
       
  5348 
       
  5349     return handled;
       
  5350     }
       
  5351 
       
  5352 
       
  5353 // -----------------------------------------------------------------------------
       
  5354 // CSatMessHandler::UiccCatRespTerminalResponse
       
  5355 // Handles UICC response for envelope
       
  5356 // -----------------------------------------------------------------------------
       
  5357 //
       
  5358 TBool CSatMessHandler::UiccCatRespTerminalResponse(
       
  5359     const TIsiReceiveC& aIsiMessage )
       
  5360     {
       
  5361     OstTrace0( TRACE_NORMAL, DUP2_CSATMESSHANDLER_UICCCATRESPTERMINALRESPONSE, "CSatMessHandler::UiccCatRespTerminalResponse" );
       
  5362     TFLOGSTRING("TSY:CSatMessHandler::UiccCatRespTerminalResponse");
       
  5363 
       
  5364     TBool handled( EFalse );
       
  5365     TUint8 trId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID ) );
       
  5366 
       
  5367     TUint uiccSbApduOffset( 0 );
       
  5368     if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  5369         ISI_HEADER_SIZE + SIZE_UICC_CAT_RESP,
       
  5370         UICC_SB_APDU,
       
  5371         EIsiSubBlockTypeId16Len16,
       
  5372         uiccSbApduOffset ) )
       
  5373         {
       
  5374         TPtrC8 apduData;
       
  5375         TUint16 apduLength( aIsiMessage.Get16bit(
       
  5376             uiccSbApduOffset + UICC_SB_APDU_OFFSET_APDULENGTH ) );
       
  5377         apduData.Set( aIsiMessage.GetData(
       
  5378             uiccSbApduOffset + UICC_SB_APDU_OFFSET_APDU,
       
  5379             apduLength ) );
       
  5380         // Status bytes are two last bytes in APDU
       
  5381         TUint8 sw1( apduData[apduLength - 2] );
       
  5382         TUint8 sw2( apduData[apduLength - 1] );
       
  5383 
       
  5384         if ( KAtkSwDataNtfSw1NormalEnding == sw1
       
  5385             && KAtkSwDataNtfSw2NormalEnding == sw2 )
       
  5386             {
       
  5387             TFLOGSTRING("CSatMessHandler::UiccCatRespTerminalResponse, - SIM SESSION END, 90 00 -");
       
  5388             OstTrace0( TRACE_NORMAL, DUP1_CSATMESSHANDLER_UICCCATRESPTERMINALRESPONSE, "CSatMessHandler::UiccCatRespTerminalResponse" );
       
  5389 
       
  5390             iTsySatMessaging->SessionEnd( aIsiMessage );
       
  5391 
       
  5392             // Set flag to indicate that terminal response has been
       
  5393             // processed by the SIM with status '90 00'.
       
  5394             iTsySatMessaging->GetSatTimer()->
       
  5395                 SetProactiveCommandOnGoingStatus( EFalse );
       
  5396             }
       
  5397         handled = ETrue;
       
  5398 
       
  5399 #ifdef INFO_PP_ENHANCED_NETWORK_SELECTION
       
  5400         // Only if SET UP EVENT LIST TR is sent
       
  5401         if ( iSetUpEventListTrSent )
       
  5402             {
       
  5403             iSetUpEventListTrSent = EFalse;
       
  5404             iTsySatMessaging->GetEventDownload()->ForceLocationStatusEnvelope();
       
  5405             }
       
  5406 #endif // INFO_PP_ENHANCED_NETWORK_SELECTION
       
  5407         }
       
  5408     else // Subblock is not found
       
  5409         {
       
  5410         TFLOGSTRING("TSY: CSatMessHandler::UiccCatRespTerminalResponse - Subblock UICC_SB_APDU not found");
       
  5411         OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_UICCCATRESPTERMINALRESPONSE, "CSatMessHandler::UiccCatRespTerminalResponse" );
       
  5412         }
       
  5413 
       
  5414     return handled;
       
  5415     }
       
  5416 
       
  5417 
       
  5418 // -----------------------------------------------------------------------------
       
  5419 // CSatMessHandler::GetApplicationId
       
  5420 // (other items were commented in a header).
       
  5421 // -----------------------------------------------------------------------------
       
  5422 //
       
  5423 const TDesC8& CSatMessHandler::GetApplicationFileId()
       
  5424     {
       
  5425     TFLOGSTRING("TSY: CSatMessHandler::GetApplicationId");
       
  5426     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GETAPPLICATIONID, "CSatMessHandler::GetApplicationId" );
       
  5427     return iApplFileId;
       
  5428     }
       
  5429 
       
  5430 
       
  5431 // -----------------------------------------------------------------------------
       
  5432 // CSatMessHandler::SetSatReadyStatus
       
  5433 // Set status of iSatReady flag
       
  5434 // -----------------------------------------------------------------------------
       
  5435 //
       
  5436 void CSatMessHandler::SetSatReadyStatus( TBool aSatReadyStatus )
       
  5437     {
       
  5438     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_SETSATREADYSTATUS, "CSatMessHandler::SetSatReadyStatus" );
       
  5439     TFLOGSTRING("TSY: CSatMessHandler::SetSatReadyStatus");
       
  5440     iSatReady = aSatReadyStatus;
       
  5441     }
       
  5442 
       
  5443 
       
  5444 // -----------------------------------------------------------------------------
       
  5445 // CSatMessHandler::GetSatReadyStatus
       
  5446 // Set status of iSatReady flag
       
  5447 // -----------------------------------------------------------------------------
       
  5448 //
       
  5449 TBool CSatMessHandler::GetSatReadyStatus()
       
  5450     {
       
  5451     TFLOGSTRING("TSY: CSatMessHandler::GetSatReadyStatus");
       
  5452     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GETSATREADYSTATUS, "CSatMessHandler::GetSatReadyStatus" );
       
  5453     return iSatReady;
       
  5454     }
       
  5455 
       
  5456 
       
  5457 // -----------------------------------------------------------------------------
       
  5458 // CSatMessHandler::GetTerminalProfileStatus
       
  5459 // Get status of iTerminalProfileSent flag
       
  5460 // -----------------------------------------------------------------------------
       
  5461 //
       
  5462 TBool CSatMessHandler::GetTerminalProfileStatus()
       
  5463     {
       
  5464     TFLOGSTRING("TSY: CSatMessHandler::GetTerminalProfileStatus");
       
  5465     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GETTERMINALPROFILESTATUS, "CSatMessHandler::GetTerminalProfileStatus" );
       
  5466     return iTerminalProfileSent;
       
  5467     }
       
  5468 
       
  5469 
       
  5470 // -----------------------------------------------------------------------------
       
  5471 // CSatMessHandler::GetClut
       
  5472 // Get clut data
       
  5473 // -----------------------------------------------------------------------------
       
  5474 //
       
  5475 const TDesC8& CSatMessHandler::GetClut()
       
  5476     {
       
  5477     TFLOGSTRING("TSY: CSatMessHandler::SetImageInstanceRequestStatus");
       
  5478     OstTrace0( TRACE_NORMAL, CSATMESSHANDLER_GETCLUT, "CSatMessHandler::GetClut" );
       
  5479     return iClutData;
       
  5480     }
       
  5481 
       
  5482 
       
  5483 // End of file