adaptationlayer/tsy/nokiatsy_dll/src/cmmcustommesshandler.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 // INCLUDE FILES
       
    20 
       
    21 #include "cmmcustommesshandler.h"
       
    22 #include "cmmsecuritymesshandler.h"
       
    23 #include "cmmstaticutility.h"
       
    24 #include "cmmnetmesshandler.h"
       
    25 #include "cmmnetoperatornamehandler.h"
       
    26 #include "cmmcallmesshandler.h"
       
    27 #include "cmmphonetsender.h"
       
    28 #include "cmmmessagerouter.h"
       
    29 #include "tsylogger.h"
       
    30 
       
    31 #include <tisi.h>
       
    32 #include <call_modemisi.h>
       
    33 #include <csdisi.h>
       
    34 #include <gssisi.h>
       
    35 
       
    36 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
    37 // Removed for Bridge camp!
       
    38 #include <mtcisi.h>
       
    39 #endif
       
    40 
       
    41 #include <infoisi.h>
       
    42 #include <net_modemisi.h>
       
    43 #include <uiccisi.h>
       
    44 #include <ss_wmisi.h>
       
    45 // #include <permisi.h> To be done in CPS
       
    46 #include <product_profile_definitions.h>
       
    47 
       
    48 #include <ctsy/serviceapi/mmgsmwcdmautils.h>
       
    49 #include <ctsy/pluginapi/cmmdatapackage.h>
       
    50 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
       
    51 
       
    52 #include <ctsy/serviceapi/gsmerror.h>
       
    53 #include <etelmmerr.h>
       
    54 
       
    55 #include "osttracedefinitions.h"
       
    56 #ifdef OST_TRACE_COMPILER_IN_USE
       
    57 #include "cmmcustommesshandlertraces.h"
       
    58 #endif
       
    59 
       
    60 // EXTERNAL DATA STRUCTURES
       
    61     //None
       
    62 
       
    63 // EXTERNAL FUNCTION PROTOTYPES
       
    64     //None
       
    65 
       
    66 // CONSTANTS
       
    67 // hard-coded transaction id for ISI messages
       
    68 const TUint8 KCustomTransId = 6;
       
    69 // const TUint8 KCustomWimTransId = 7;
       
    70 
       
    71 // Max length for HSXPA message request
       
    72 const TUint KHSxPAMaxMessageSize = 2;
       
    73 
       
    74 // Uicc Card Status Byte (hardcoded). Values are derived from APDU server
       
    75 // interface documentation. Bitfield READER_STATUS_BYTE
       
    76 const TUint8 KUiccCardStatusCardNotPresentOrPoweredOff = 0x10; //0001 0000
       
    77 const TUint8 KUiccCardStatusCardPresentAndPoweredOn = 0xD0; //1101 0000 (0001 0000|0x40|0x80)
       
    78 
       
    79 // Consts needed when constructing APDU's going to be sent to the UICC
       
    80 const TUint8 KEvenInstructionCode = 0x88;
       
    81 const TUint8 KOddInstructionCode  = 0x89;
       
    82 
       
    83 const TUint8 KFirstBlockOfAuthenticationData         = 0x80;
       
    84 const TUint8 KFirstBlockOfAuthenticationResponseData = 0xA0;
       
    85 
       
    86 const TUint8 KGsmAuthenticationContext  = 0x80; // 1000 0000
       
    87 const TUint8 K3GAuthenticationContext   = 0x81; // 1000 0001
       
    88 const TUint8 KGBAAuthenticationContext  = 0x84; // 1000 0100
       
    89 const TUint8 KMBMSAuthenticationContext = 0x85; // 1000 0101
       
    90 
       
    91 const TUint8 KMaximumLenOfDataExpected = 0x00;
       
    92 const TUint8 KRunGsmAlgorithmRespLen   = 0x0C;
       
    93 const TUint8 KClaNoSm = 0x00;
       
    94 const TUint8 KClaIcc  = 0xA0;
       
    95 
       
    96 const TUint8 KSw1Position = 0x02;
       
    97 const TUint8 KSw2Position = 0x01;
       
    98 
       
    99 const TUint8 KNormalCommandEnding                     = 0x00;
       
   100 const TUint8 KAppAuthErrorIncorrectMac                = 0x01;
       
   101 const TUint8 KCmdNotAllowedConditionsNotSatisfied     = 0x02;
       
   102 const TUint8 KWarningAuthRespAvailable                = 0x03;
       
   103 const TUint8 KWarningMoreDataAvailable                = 0x04;
       
   104 const TUint8 KAppErrorAuthMbmsKeyFresh                = 0x05;
       
   105 const TUint8 KAppErrorAuthMbmsOutOfMemMsk             = 0x06;
       
   106 const TUint8 KAppErrorAuthMbmsOutOfMemMuk             = 0x07;
       
   107 const TUint8 KWrongParametersDataNotFound             = 0x08;
       
   108 const TUint8 KCmdNotAllowedSecurityStatusNotSatisfied = 0x09;
       
   109 const TUint8 KUnknownCommandEnding                    = 0xFF;
       
   110 
       
   111 const TUint8 KApduOk  = 0x00;
       
   112 const TUint8 KApduNok = 0x01;
       
   113 
       
   114 const TUint8 KMinLenOfRes     = 0x04;
       
   115 const TUint8 KMaxLenOfRes     = 0x10;
       
   116 const TUint8 KLenOfSRes       = 0x04;
       
   117 const TUint8 KLenOfIk         = 0x10;
       
   118 const TUint8 KLenOfCk         = 0x10;
       
   119 const TUint8 KLenOfKc         = 0x08;
       
   120 const TUint8 KLenOfAuts       = 0x0E;
       
   121 const TUint8 KMaxMbmsMikeyLen = 0xFB;
       
   122 const TUint8 KMaxMbmsSaltLen  = 0xFB;
       
   123 const TUint8 KMaxApduSize     = 0xFF;
       
   124 const TUint8 KMaxParentalRatingDataSize = 0x02;
       
   125 const TUint8 KMaxSpeSize                = 0x01;
       
   126 
       
   127 const TUint8 KSuccessfull3GAuthTag    = 0xDB;
       
   128 const TUint8 KSyncFailureTag          = 0xDC;
       
   129 const TUint8 KGBABootstappingModeTag  = 0xDD;
       
   130 const TUint8 KGBANAFDerivationModeTag = 0xDE;
       
   131 const TUint8 KMBMSDataObjectTag       = 0x53;
       
   132 
       
   133 const TUint8 KMskUpdateMode                 = 0x01;
       
   134 const TUint8 KMtkGenerationMode             = 0x02;
       
   135 const TUint8 KMskDeletionMode               = 0x03;
       
   136 const TUint8 KSuccessfullMbmsOperationTag   = 0xDB;
       
   137 const TUint8 KMbmsOperationResponseTag53    = 0x53;
       
   138 const TUint8 KMbmsOperationResponseTag73    = 0x73;
       
   139 const TUint8 KOMABcastOperationResponseTag  = 0xAE;
       
   140 const TUint8 KBcastManagementDataTag = 0x80;
       
   141 const TUint8 KParentalRatingDataTag  = 0x8A;
       
   142 const TUint8 KSPETypeNotSupportedTag = 0x8B;
       
   143 const TUint8 KMikeyMessageTag        = 0x8C;
       
   144 const TUint8 KTekDataTag             = 0x86;
       
   145 const TUint8 KSaltDataTag            = 0x87;
       
   146 const TUint8 KParentalControlTag     = 0x88;
       
   147 
       
   148 const TUint8 KServiceGBA          = 0x44; // service no 68
       
   149 const TUint8 KServiceMBMSsecurity = 0x45; // service no 69
       
   150 
       
   151 
       
   152 // MACROS
       
   153     //None
       
   154 
       
   155 // LOCAL CONSTANTS AND MACROS
       
   156     //None
       
   157 
       
   158 // MODULE DATA STRUCTURES
       
   159     //None
       
   160 
       
   161 // LOCAL FUNCTION PROTOTYPES
       
   162     //None
       
   163 
       
   164 // ============================= LOCAL FUNCTIONS ===============================
       
   165     //None
       
   166 
       
   167 // ============================ MEMBER FUNCTIONS ===============================
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CMmCustomMessHandler::CMmCustomMessHandler
       
   171 // C++ default constructor
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 CMmCustomMessHandler::CMmCustomMessHandler()
       
   175     {
       
   176 TFLOGSTRING("TSY: CMmCustomMessHandler::CMmCustomMessHandler.\n" );
       
   177 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CMMCUSTOMMESSHANDLER, "CMmCustomMessHandler::CMmCustomMessHandler" );
       
   178     iSimCBTopicToBeDeleted = KUnusedCbMsgId;
       
   179     // Set to true because it doesn't delete topic at start up
       
   180     iTopicInSimMemoryDelete = ETrue;
       
   181     }
       
   182 
       
   183 // -----------------------------------------------------------------------------
       
   184 // CMmCustomMessHandler::~CMmCustomMessHandler
       
   185 // Destructor, deletes all allocated resources.
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 CMmCustomMessHandler::~CMmCustomMessHandler()
       
   189     {
       
   190 TFLOGSTRING("TSY: CMmCustomMessHandler::~CMmCustomMessHandler.\n" );
       
   191 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_CMMCUSTOMMESSHANDLER, "CMmCustomMessHandler::~CMmCustomMessHandler" );
       
   192 
       
   193     if( iListOfCiphValues )
       
   194         {
       
   195         //close the array of ciphering values
       
   196         iListOfCiphValues->Close();
       
   197         //delete the list of ciphering values
       
   198         delete iListOfCiphValues;
       
   199         }
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CMmCustomMessHandler::NewL
       
   204 // Two-phased constructor.
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 CMmCustomMessHandler* CMmCustomMessHandler::NewL
       
   208         (
       
   209         CMmPhoNetSender* aPhoNetSender, // pointer to the phonet sender
       
   210         CMmPhoNetReceiver* aPhoNetReceiver, // pointer to the phonet sender
       
   211         CMmNetMessHandler* aNetMessHandler, // pointer to the Net messHandler
       
   212         CMmSecurityMessHandler* aSecurityMessHandler, // pointer to the security
       
   213         CMmMessageRouter* aMessageRouter, //pointer to the message router
       
   214         CMmUiccMessHandler* aUiccMessHandler
       
   215         )
       
   216     {
       
   217 TFLOGSTRING("TSY: CMmCustomMessHandler::NewL.\n" );
       
   218 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NEWL, "CMmCustomMessHandler::NewL" );
       
   219 
       
   220     CMmCustomMessHandler* customMessHandler =
       
   221         new( ELeave ) CMmCustomMessHandler();
       
   222 
       
   223     CleanupStack::PushL( customMessHandler );
       
   224     customMessHandler->iPhoNetSender = aPhoNetSender;
       
   225     customMessHandler->iNetMessHandler = aNetMessHandler;
       
   226     customMessHandler->iSecurityMessHandler = aSecurityMessHandler;
       
   227     customMessHandler->iMessageRouter = aMessageRouter;
       
   228     customMessHandler->iMmUiccMessHandler = aUiccMessHandler;
       
   229 
       
   230     customMessHandler->ConstructL();
       
   231 
       
   232     // CALL
       
   233     aPhoNetReceiver->RegisterL(
       
   234         customMessHandler,
       
   235         PN_MODEM_CALL );
       
   236 
       
   237     // NETWORK
       
   238     aPhoNetReceiver->RegisterL(
       
   239         customMessHandler,
       
   240         PN_MODEM_NETWORK );
       
   241 
       
   242 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   243 
       
   244 // TO BE DONE WITH INFO_PP_DATA_READ_RESP
       
   245     aPhoNetReceiver->RegisterL(
       
   246         customMessHandler,
       
   247         PN_INFO,
       
   248         INFO_PP_READ_RESP );
       
   249 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   250     // SS
       
   251     aPhoNetReceiver->RegisterL(
       
   252         customMessHandler,
       
   253         PN_SS,
       
   254         SS_SERVICE_COMPLETED_IND );
       
   255     aPhoNetReceiver->RegisterL(
       
   256         customMessHandler,
       
   257         PN_SS,
       
   258         SS_SERVICE_FAILED_RESP );
       
   259     aPhoNetReceiver->RegisterL(
       
   260         customMessHandler,
       
   261         PN_SS,
       
   262         SS_GSM_USSD_SEND_RESP );
       
   263 
       
   264     // GSS
       
   265     aPhoNetReceiver->RegisterL(
       
   266         customMessHandler,
       
   267         PN_GSS,
       
   268         GSS_CS_SERVICE_RESP );
       
   269     aPhoNetReceiver->RegisterL(
       
   270         customMessHandler,
       
   271         PN_GSS,
       
   272         GSS_CS_SERVICE_FAIL_RESP );
       
   273     aPhoNetReceiver->RegisterL(
       
   274         customMessHandler,
       
   275         PN_GSS,
       
   276         GSS_HSXPA_USER_SETTING_READ_RESP );
       
   277     aPhoNetReceiver->RegisterL(
       
   278         customMessHandler,
       
   279         PN_GSS,
       
   280         GSS_HSXPA_USER_SETTING_WRITE_RESP );
       
   281     aPhoNetReceiver->RegisterL(
       
   282         customMessHandler,
       
   283         PN_GSS,
       
   284         GSS_HSXPA_USER_SETTING_IND );
       
   285 
       
   286 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   287     // MTC
       
   288     // Removed for Bridge camp
       
   289     aPhoNetReceiver->RegisterL(
       
   290         customMessHandler,
       
   291         PN_MTC,
       
   292         MTC_RAT_QUERY_RESP );
       
   293 #endif
       
   294 
       
   295     // PMM
       
   296     /* To be done in CPS
       
   297     aPhoNetReceiver->RegisterL( customMessHandler,
       
   298         PN_PERMANENT_DATA,
       
   299         PERM_PM_RECORD_READ_RESP );
       
   300 
       
   301     aPhoNetReceiver->RegisterL( customMessHandler,
       
   302         PN_PERMANENT_DATA,
       
   303         PERM_PM_RECORD_WRITE_RESP );*/
       
   304 
       
   305     // UICC
       
   306     aPhoNetReceiver->RegisterL(
       
   307         customMessHandler,
       
   308         PN_UICC,
       
   309         UICC_CARD_IND);
       
   310 
       
   311     CleanupStack::Pop( customMessHandler );
       
   312 
       
   313     // Send PERM_PM_RECORD_READ_REQ and update
       
   314     // iCallLifeTimer.
       
   315     customMessHandler->ReadLifeTimerFromPermanentMemory ( KCustomTransId );
       
   316 
       
   317     return customMessHandler;
       
   318     }
       
   319 
       
   320 // -----------------------------------------------------------------------------
       
   321 // CMmCustomMessHandler::ConstructL
       
   322 // Symbian 2nd phase constructor can leave.
       
   323 // -----------------------------------------------------------------------------
       
   324 //
       
   325 void CMmCustomMessHandler::ConstructL()
       
   326     {
       
   327 TFLOGSTRING("TSY: CMmCustomMessHandler::ConstructL.\n" );
       
   328 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CONSTRUCTL, "CMmCustomMessHandler::ConstructL" );
       
   329 
       
   330     // Initialize iListOfCiphValues
       
   331     iListOfCiphValues = new ( ELeave ) RArray<TCiphListEntry>( 1 );
       
   332 
       
   333     // Initialize refresh indication boolean
       
   334     iIsRefresh = EFalse;
       
   335 
       
   336     // Initialize ECID boolean
       
   337     iECIDInfoRequested = EFalse;
       
   338 
       
   339     // Initialize ECID information
       
   340     iECIDInfo.iMCC = 0; // Mobile Country Code
       
   341     iECIDInfo.iMNC = 0; // Mobile Network Code
       
   342     iECIDInfo.iCID = 0; // Cell identity
       
   343     iECIDInfo.iLAC = 0; // Location area code
       
   344 
       
   345     // Initialize Call Life Timer value.
       
   346     iCallLifeTimer = KCallLifeTimerNotSet;
       
   347     
       
   348     // initialize ISim application activation status
       
   349     iIsimApplActivated = EFalse;
       
   350     }
       
   351 
       
   352 // -----------------------------------------------------------------------------
       
   353 // CMmCustomMessHandler::ReceiveMessageL
       
   354 // Entry point for messages received from Domestic OS. Switches the message
       
   355 // to the correct method.
       
   356 // (other items were commented in a header).
       
   357 // -----------------------------------------------------------------------------
       
   358 //
       
   359 void CMmCustomMessHandler::ReceiveMessageL
       
   360         (
       
   361         const TIsiReceiveC& aIsiMessage  // ISI-message received
       
   362         )
       
   363     {
       
   364     TInt resource( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_RESOURCEID ) );
       
   365     TInt messageId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
       
   366 
       
   367 TFLOGSTRING3("TSY: CMmCustomMessHandler::ReceiveMessageL, Resource: %d, Message: %d", resource, messageId);
       
   368 OstTraceExt2( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_RECEIVEMESSAGEL, "CMmCustomMessHandler::ReceiveMessageL;resource=%d;messageId=%d", resource, messageId );
       
   369 
       
   370     switch( resource )
       
   371         {
       
   372         case PN_MODEM_CALL:
       
   373             {
       
   374             // switch according to the message id
       
   375             // and call the appropriate messagehandler method
       
   376             switch( messageId )
       
   377                 {
       
   378                 case CALL_MODEM_RELEASE_RESP:
       
   379                     {
       
   380                     CallReleaseResp( aIsiMessage );
       
   381                     break;
       
   382                     }
       
   383                 case CALL_MODEM_NOTIFICATION_IND:
       
   384                     {
       
   385                     CallGsmNotificationInd( aIsiMessage );
       
   386                     break;
       
   387                     }
       
   388                 case CALL_MODEM_MO_ALERT_IND:
       
   389                     {
       
   390                     CallMoAlertInd( aIsiMessage );
       
   391                     break;
       
   392                     }
       
   393                 case CALL_MODEM_TERMINATED_IND:
       
   394                     {
       
   395                     CallTerminateInd( aIsiMessage );
       
   396                     break;
       
   397                     }
       
   398                 case CALL_MODEM_RELEASE_IND:
       
   399                     {
       
   400                     CallReleaseInd( aIsiMessage );
       
   401                     break;
       
   402                     }
       
   403                 case CALL_MODEM_BLACKLIST_CLEAR_RESP:
       
   404                     {
       
   405                     CallGsmBlackListClearResp();
       
   406                     break;
       
   407                     }
       
   408                 case CALL_MODEM_EMERG_NBR_CHECK_RESP:
       
   409                     {
       
   410                     CallEmergencyNbrCheckResp( aIsiMessage );
       
   411                     break;
       
   412                     }
       
   413                 default:
       
   414                     {
       
   415 TFLOGSTRING("TSY: CMmCustomMessHandler::ReceiveMessageL - switch resource - case PN_MODEM_CALL, switch messageId - default");
       
   416 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_RECEIVEMESSAGEL, "CMmCustomMessHandler::ReceiveMessageL- switch resource - case PN_CALL, switch messageId - default" );
       
   417                     break;
       
   418                     }
       
   419                 }
       
   420             break;
       
   421             }
       
   422         case PN_GSS:
       
   423             {
       
   424             // switch according to the message id
       
   425             // and call the appropriate messagehandler method
       
   426             switch( messageId )
       
   427                 {
       
   428                 case GSS_CS_SERVICE_RESP:
       
   429                     {
       
   430                     GssCsServiceResp( aIsiMessage );
       
   431                     break;
       
   432                     }
       
   433                 case GSS_CS_SERVICE_FAIL_RESP:
       
   434                     {
       
   435                     GssCsServiceFailResp( aIsiMessage );
       
   436                     break;
       
   437                     }
       
   438                 case GSS_HSXPA_USER_SETTING_READ_RESP:
       
   439                     {
       
   440                     ReadHSxPAStatusResp( aIsiMessage );
       
   441                     break;
       
   442                     }
       
   443                 case GSS_HSXPA_USER_SETTING_WRITE_RESP:
       
   444                     {
       
   445                     WriteHSxPAStatusResp( aIsiMessage );
       
   446                     break;
       
   447                     }
       
   448                 case GSS_HSXPA_USER_SETTING_IND:
       
   449                     {
       
   450                     HSxPASettingInd( aIsiMessage );
       
   451                     break;
       
   452                     }
       
   453                 default:
       
   454                     {
       
   455 TFLOGSTRING("TSY: CMmCustomMessHandler::ReceiveMessageL - switch resource - case PN_GSS, switch messageId - default");
       
   456 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_RECEIVEMESSAGEL, "CMmCustomMessHandler::ReceiveMessageL- switch resource - case PN_GSS, switch messageId - default" );
       
   457                     break;
       
   458                     }
       
   459                 }
       
   460             break; // end case PN_GSS
       
   461             }
       
   462         case PN_MODEM_NETWORK:
       
   463             {
       
   464             // switch according to the message id
       
   465             // and call the appropriate messagehandler method
       
   466             switch( messageId )
       
   467                 {
       
   468                 case NET_CS_WAKEUP_RESP:
       
   469                     {
       
   470                     NetCsWakeupResp();
       
   471                     break;
       
   472                     }
       
   473                 case NET_MODEM_REG_STATUS_IND:
       
   474                     {
       
   475                     NetModemRegStatusInd( aIsiMessage );
       
   476                     break;
       
   477                     }
       
   478                 case NET_CIPHERING_IND:
       
   479                     {
       
   480                     NetCipheringInd( aIsiMessage );
       
   481                     break;
       
   482                     }
       
   483                 case NET_MODEM_REG_STATUS_GET_RESP:
       
   484                     {
       
   485                     NetModemRegStatusGetResp( aIsiMessage );
       
   486                     break;
       
   487                     }
       
   488                 case NET_SET_RESP:
       
   489                     {
       
   490                     NetSetResp( aIsiMessage );
       
   491                     break;
       
   492                     }
       
   493                 case NET_RAT_RESP:
       
   494                     {
       
   495                     NetRatResp( aIsiMessage );
       
   496                     break;
       
   497                     }
       
   498                 case NET_NEIGHBOUR_CELLS_RESP:
       
   499                     {
       
   500                     NetNeighbourCellsResp( aIsiMessage );
       
   501                     break;
       
   502                     }
       
   503                 default:
       
   504                     {
       
   505 TFLOGSTRING("TSY: CMmCustomMessHandler::ReceiveMessageL - switch resource - case PN_MODEM_NETWORK, switch messageId - default");
       
   506 OstTrace0( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_RECEIVEMESSAGEL, "CMmCustomMessHandler::ReceiveMessageL- switch resource - case PN_MODEM_NETWORK, switch messageId - default" );
       
   507                     break;
       
   508                     }
       
   509                 }
       
   510             break;
       
   511             }
       
   512 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   513         // Removed for Bridge camp
       
   514         case PN_MTC:
       
   515             {
       
   516             switch( messageId )
       
   517                 {
       
   518                 case MTC_RAT_QUERY_RESP:
       
   519                     {
       
   520                     MtcRatQueryResp( aIsiMessage );
       
   521                     break;
       
   522                     }
       
   523                 default:
       
   524                     {
       
   525 TFLOGSTRING("TSY: CMmCustomMessHandler::ReceiveMessageL - switch resource - case PN_MTC, switch messageId - default");
       
   526 OstTrace0( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_RECEIVEMESSAGEL, "CMmCustomMessHandler::ReceiveMessageL- switch resource - case PN_MTC, switch messageId - default" );
       
   527                     break;
       
   528                     }
       
   529                 }
       
   530             break;
       
   531             }
       
   532 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   533 
       
   534 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   535         case PN_INFO:
       
   536 #else /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   537         case PN_MODEM_INFO:
       
   538 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   539             {
       
   540             // switch according to the message id
       
   541             // and call the appropriate messagehandler method
       
   542             switch( messageId )
       
   543                 {
       
   544 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   545                  // TO BE DONE WITH INFO_PP_DATA_READ_RESP
       
   546                  case INFO_PP_READ_RESP:
       
   547                     {
       
   548                     InfoPpReadResp( aIsiMessage );
       
   549                     break;
       
   550                     }
       
   551 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   552                  default:
       
   553                     {
       
   554 TFLOGSTRING("TSY: CMmCustomMessHandler::ReceiveMessageL - switch resource - case PN_INFO, switch messageId - default");
       
   555 OstTrace0( TRACE_NORMAL, DUP6_CMMCUSTOMMESSHANDLER_RECEIVEMESSAGEL, "CMmCustomMessHandler::ReceiveMessageL- switch resource - case PN_INFO, switch messageId - default" );
       
   556                     break;
       
   557                     }
       
   558                 }
       
   559             break;
       
   560             }
       
   561         case PN_SS:
       
   562             {
       
   563             switch( messageId )
       
   564                 {
       
   565                 case SS_SERVICE_COMPLETED_IND:
       
   566                     {
       
   567                     SsServiceCompletedInd( aIsiMessage );
       
   568                     break;
       
   569                     }
       
   570                 case SS_SERVICE_FAILED_RESP:
       
   571                     {
       
   572                     SsServiceFailedResp( aIsiMessage );
       
   573                     break;
       
   574                     }
       
   575                 case SS_GSM_USSD_SEND_RESP:
       
   576                     {
       
   577                     SsGsmUssdSendResp( aIsiMessage );
       
   578                     break;
       
   579                     }
       
   580                 default:
       
   581                     {
       
   582 TFLOGSTRING("TSY: CMmCustomMessHandler::ReceiveMessageL - switch resource - case PN_SS, switch messageId - default");
       
   583 OstTrace0( TRACE_NORMAL, DUP12_CMMCUSTOMMESSHANDLER_RECEIVEMESSAGEL, "CMmCustomMessHandler::ReceiveMessageL- switch resource - case PN_SS, switch messageId - default" );
       
   584                     break;
       
   585                     }
       
   586                 }
       
   587             break;
       
   588             }
       
   589         /* To be done in CPS
       
   590         case PN_PERMANENT_DATA:
       
   591             {
       
   592             if ( KCustomTransId == aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID ) )
       
   593                 {
       
   594                 switch( messageId )
       
   595                     {
       
   596                     case PERM_PM_RECORD_READ_RESP:
       
   597                         {
       
   598                         LifeTimerFromPermanentMemoryReadResponse( aIsiMessage );
       
   599                         break;
       
   600                         }
       
   601 
       
   602                     case PERM_PM_RECORD_WRITE_RESP:
       
   603                         {
       
   604                         LifeTimerToPermanentMemoryWriteResponse( aIsiMessage );
       
   605                         break;
       
   606                         }
       
   607 
       
   608                     default:
       
   609                         {
       
   610                         TFLOGSTRING("TSY: CMmCustomMessHandler::ReceiveMessageL\
       
   611                             - switch resource - case PN_PERMANENT_DATA, switch messageId - default.\n");
       
   612 OstTrace0( TRACE_NORMAL, DUP16_CMMCUSTOMMESSHANDLER_RECEIVEMESSAGEL, "CMmCustomMessHandler::ReceiveMessageL - switch resource - case PN_PERMANENT_DATA, switch messageId - default." );
       
   613                         break;
       
   614                         }
       
   615                     }
       
   616                 TFLOGSTRING("TSY: CMmCustomMessHandler::ReceiveMessageL\
       
   617                             - switch resource - case PN_PERMANENT_DATA, transaction id is not KCustomTransId\n");
       
   618 OstTrace0( TRACE_NORMAL, DUP14_CMMCUSTOMMESSHANDLER_RECEIVEMESSAGEL, "CMmCustomMessHandler::ReceiveMessageL - switch resource - case PN_PERMANENT_DATA, transaction id is not KCustomTransId" );
       
   619                 }
       
   620             break;
       
   621             }*/
       
   622 
       
   623         case PN_UICC:
       
   624             {
       
   625             if( UICC_CARD_IND == messageId )
       
   626                 {
       
   627                 UiccCardInd( aIsiMessage );
       
   628                 }
       
   629             break;
       
   630             }
       
   631         default:
       
   632             {
       
   633 TFLOGSTRING("TSY: CMmCustomMessHandler::ReceiveMessageL - switch resource - default" );
       
   634 OstTrace0( TRACE_NORMAL, DUP13_CMMCUSTOMMESSHANDLER_RECEIVEMESSAGEL, "CMmCustomMessHandler::ReceiveMessageL- switch resource - default" );
       
   635             break; // server not known
       
   636             }
       
   637         } // end of switch
       
   638     }
       
   639 
       
   640 // -----------------------------------------------------------------------------
       
   641 // CMmCustomMessHandler::CallReleaseReq
       
   642 // Constructs CALL_MODEM_RELEASE_REQ ISI message from input parameters and sends
       
   643 // it through phonet. HangUp request message.
       
   644 // (other items were commented in a header).
       
   645 // -----------------------------------------------------------------------------
       
   646 //
       
   647 TInt CMmCustomMessHandler::CallReleaseReq
       
   648         (
       
   649         TUint8 aTransactionId, //transaction id
       
   650         TUint8 aCallId, //call id
       
   651         TUint8 aCause //cause value for releasing the call
       
   652         )
       
   653     {
       
   654     TFLOGSTRING("TSY: CMmCustomMessHandler::CallReleaseReq.\n" );
       
   655 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CALLRELEASEREQ, "CMmCustomMessHandler::CallReleaseReq" );
       
   656 
       
   657     iReleaseCauseValueSent = aCause;
       
   658 
       
   659     //Append data for ISI message
       
   660     TBuf8< 2 + SIZE_CALL_MODEM_SB_CAUSE > messageBuf;
       
   661 
       
   662     messageBuf.Append( aCallId );
       
   663     messageBuf.Append( 1 ); // Num of Subblocks
       
   664 
       
   665     //Call_Release_Req sub block
       
   666     messageBuf.Append( CALL_MODEM_SB_CAUSE );
       
   667     messageBuf.Append( SIZE_CALL_MODEM_SB_CAUSE );
       
   668     messageBuf.Append( CALL_MODEM_CAUSE_TYPE_CLIENT );
       
   669     messageBuf.Append( aCause );
       
   670 
       
   671     //send message via phonet
       
   672     return iPhoNetSender->Send( PN_MODEM_CALL, aTransactionId, CALL_MODEM_RELEASE_REQ,
       
   673       messageBuf );
       
   674     }
       
   675 
       
   676 // -----------------------------------------------------------------------------
       
   677 // CMmCustomMessHandler::CallReleaseResp
       
   678 // Breaks response to the HangUp request. In case of failure, HangUp is
       
   679 // completed to the Symbian OS layer. Otherwise HangUp handle the success case.
       
   680 // (other items were commented in a header).
       
   681 // -----------------------------------------------------------------------------
       
   682 //
       
   683 void CMmCustomMessHandler::CallReleaseResp
       
   684         (
       
   685         const TIsiReceiveC& aIsiMsg    //received ISI message
       
   686         )
       
   687     {
       
   688     TFLOGSTRING("TSY: CMmCustomMessHandler::CallReleaseResp.\n" );
       
   689 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CALLRELEASERESP, "CMmCustomMessHandler::CallReleaseResp" );
       
   690 
       
   691     //initialize the causeType and causeValue
       
   692     TUint8 causeType  = 0;
       
   693     TUint8 causeValue = 0;
       
   694     TInt ret = KErrNone;
       
   695 
       
   696     TUint sbStartOffSet( 0 );
       
   697 
       
   698     //get cause sub block
       
   699     //if subblock is present
       
   700     if( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
   701         ISI_HEADER_SIZE + SIZE_CALL_MODEM_RELEASE_RESP, CALL_MODEM_SB_CAUSE,
       
   702         EIsiSubBlockTypeId8Len8, sbStartOffSet ) )
       
   703       {
       
   704         //get cause type
       
   705         causeType = aIsiMsg.Get8bit( sbStartOffSet +
       
   706             CALL_MODEM_SB_CAUSE_OFFSET_CAUSETYPE );
       
   707 
       
   708         //get cause value
       
   709         causeValue = aIsiMsg.Get8bit( sbStartOffSet +
       
   710             CALL_MODEM_SB_CAUSE_OFFSET_CAUSE );
       
   711 
       
   712         if( iReleaseCauseValueSent != causeValue )
       
   713             {
       
   714             //map error value to ETEL error value
       
   715             ret = CMmStaticUtility::CSCauseToEpocError ( PN_MODEM_CALL,
       
   716                 causeType, causeValue );
       
   717             }
       
   718         }
       
   719   // no packed parameters for completion
       
   720   iMessageRouter->Complete( ECustomTerminateCallIPC, ret );
       
   721     }
       
   722 
       
   723 // -----------------------------------------------------------------------------
       
   724 // CMmCustomMessHandler::CallMoAlertInd
       
   725 // This method breaks the CallMo alerting indication message.
       
   726 // Trying to find Remote alerting information. In success case
       
   727 // send LocalRemoteAlertToneRequired value to SOS layer.
       
   728 // (other items were commented in a header).
       
   729 // -----------------------------------------------------------------------------
       
   730 //
       
   731 void CMmCustomMessHandler::CallMoAlertInd
       
   732         (
       
   733         const TIsiReceiveC& aIsiMsg    //received ISI message
       
   734         )
       
   735     {
       
   736     TFLOGSTRING("TSY: CMmCustomMessHandler::CallMoAlertInd.");
       
   737 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CALLMOALERTIND, "CMmCustomMessHandler::CallMoAlertInd" );
       
   738 
       
   739     TBool playRemoteAlertToneLocally( EFalse );
       
   740     TUint sbStartOffSet( 0 );
       
   741 
       
   742     // Get call alerting info sub block
       
   743     // if subblock was found
       
   744     if( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
   745         ISI_HEADER_SIZE + SIZE_CALL_MODEM_MO_ALERT_IND,
       
   746         CALL_MODEM_SB_ALERTING_INFO,
       
   747         EIsiSubBlockTypeId8Len8,
       
   748         sbStartOffSet ) )
       
   749         {
       
   750         TFLOGSTRING("TSY: CMmCustomMessHandler::CallMoAlertInd,\
       
   751             - CALL_MODEM_SB_ALERTING_INFO sub block found.");
       
   752 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_CALLMOALERTIND, "CMmCustomMessHandler::CallMoAlertInd, CALL_MODEM_SB_ALERTING_INFO sub block found" );
       
   753 
       
   754         // Get alerting info
       
   755         TUint8 callAlertingInfo( aIsiMsg.Get8bit(
       
   756             sbStartOffSet + CALL_MODEM_SB_ALERTING_INFO_OFFSET_ALERTINGINFO ) );
       
   757 
       
   758         // If LSB is "1" inform that remote alerting tone
       
   759         // should be generated locally.
       
   760         if ( callAlertingInfo & 0x01 )
       
   761             {
       
   762             playRemoteAlertToneLocally = ETrue;
       
   763             }
       
   764         }
       
   765 
       
   766     // Complete remote alerting tone notification
       
   767     // parameter for SOS layer: a TBool playRemoteAlertToneLocally
       
   768     CMmDataPackage dataPackage;
       
   769     dataPackage.PackData( &playRemoteAlertToneLocally );
       
   770     iMessageRouter->Complete( ECustomGetRemoteAlertingToneStatusIPC,
       
   771         &dataPackage,
       
   772         KErrNone );
       
   773     }
       
   774 
       
   775 // -----------------------------------------------------------------------------
       
   776 // CMmCustomMessHandler::UiccReadCiReq
       
   777 // Read ciphering indicator status from UICC
       
   778 // -----------------------------------------------------------------------------
       
   779 //
       
   780 TInt CMmCustomMessHandler::UiccReadCiReq( TInt aTrId )
       
   781     {
       
   782 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccReadCiReq, transaction ID: %d", aTrId );
       
   783 OstTrace1( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADCIREQ, "CMmCustomMessHandler::UiccReadCiReq;aTrId=%d", aTrId );
       
   784 
       
   785     // Set parameters for UICC_APPL_CMD_REQ message
       
   786     TUiccReadTransparent params;
       
   787     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
   788     params.trId = static_cast<TUiccTrId>( aTrId );
       
   789     // We need to know the CI status info which is located in byte 3 in EF AD
       
   790     // b1=0: ciphering indicator feature disabled
       
   791     // b1=1: ciphering indicator feature enabled
       
   792     params.dataAmount = 1;
       
   793     params.dataOffset = 2;
       
   794     params.fileId = KElemFileAdministrativeData;
       
   795     params.fileIdSfi = 3;
       
   796     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
   797 
       
   798     // File id path
       
   799     params.filePath.Append( KMasterFileId >> 8 );
       
   800     params.filePath.Append( KMasterFileId );
       
   801     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
   802 
       
   803     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
   804     }
       
   805 
       
   806 // -----------------------------------------------------------------------------
       
   807 // CMmCustomMessHandler::UiccReadCiResp
       
   808 // Complete ciphering indicator status
       
   809 // -----------------------------------------------------------------------------
       
   810 //
       
   811 void CMmCustomMessHandler::UiccReadCiResp(
       
   812     TInt aStatus,
       
   813     TInt aTrId,
       
   814     const TDesC8& aFileData )
       
   815     {
       
   816 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccReadCiResp" );
       
   817 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADCIRESP, "CMmCustomMessHandler::UiccReadCiResp" );
       
   818 
       
   819     TInt ret( KErrNone );
       
   820     TBool cipherIndicatorStatus( EFalse );
       
   821 
       
   822     if( UICC_STATUS_OK == aStatus  )
       
   823         {
       
   824         // Get ciphering indicator info ( bit 0)
       
   825         TUint8 cipheringIndicator(aFileData[0] & 0x01 );
       
   826         if ( cipheringIndicator )
       
   827             {
       
   828             cipherIndicatorStatus = ETrue;
       
   829             }
       
   830         }
       
   831     else
       
   832         {
       
   833         ret = KErrNotFound;
       
   834         }
       
   835 
       
   836     if ( ETrIdReadCipheringIndicatorStatusCustom == aTrId )
       
   837         {
       
   838         // Complete GetCipheringInfo
       
   839         // packed parameter: TBool (ciphering indicator required/not required)
       
   840         CMmDataPackage dataPackage;
       
   841         dataPackage.PackData( &cipherIndicatorStatus );
       
   842         iMessageRouter->Complete(
       
   843             ECustomGetCipheringInfoIPC,
       
   844             &dataPackage,
       
   845             ret );
       
   846         }
       
   847     else if( ETrIdNotifyCipheringIndicatorStatusCustom == aTrId )
       
   848         {
       
   849         CMmDataPackage dataPackage;
       
   850         TCiphListEntry chiplistentry;
       
   851         chiplistentry.iTraId = aTrId;
       
   852 
       
   853         // Find the right value of ciphering for this resp message
       
   854         TInt index ( iListOfCiphValues->Find( chiplistentry, Match ) );
       
   855 
       
   856         // If the right value is found
       
   857         if ( KErrNotFound != index )
       
   858             {
       
   859             TBool cipheringOn( ( *iListOfCiphValues )[index ].iCiphStatus );
       
   860             dataPackage.PackData( &cipherIndicatorStatus, &cipheringOn );
       
   861 
       
   862             // Delete the used ciphering value from the list
       
   863             iListOfCiphValues->Remove( index );
       
   864             // Compress the list
       
   865             iListOfCiphValues->Compress();
       
   866             }
       
   867         else
       
   868             {
       
   869             TBool constantFalse( EFalse );
       
   870             dataPackage.PackData( &constantFalse, &constantFalse );
       
   871             ret = KErrGeneral;
       
   872             }
       
   873 
       
   874         iMessageRouter->Complete(
       
   875             ECustomNotifyCipheringInfoChangeIPC,
       
   876             &dataPackage,
       
   877             ret );
       
   878         }
       
   879     //No else
       
   880     }
       
   881 
       
   882 // -----------------------------------------------------------------------------
       
   883 // CMmCustomMessHandler::NetCsWakeupReq
       
   884 // Constructs NET_CS_WAKEUP_REQ ISI message from input parameters and sends
       
   885 // it through phonet.
       
   886 // (other items were commented in a header).
       
   887 // -----------------------------------------------------------------------------
       
   888 //
       
   889 TInt CMmCustomMessHandler::NetCsWakeupReq( TUint8 aTransId )
       
   890     {
       
   891 TFLOGSTRING("TSY: CMmCustomMessHandler::NetCsWakeupReq.\n" );
       
   892 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETCSWAKEUPREQ, "CMmCustomMessHandler::NetCsWakeupReq" );
       
   893 
       
   894     //Data buffer length is 2
       
   895     TBuf8<2> data;
       
   896     data.Append( aTransId );
       
   897     data.Append( NET_CS_WAKEUP_REQ );
       
   898 
       
   899     TIsiSend isimsg( iPhoNetSender->SendBufferDes() );
       
   900     isimsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_MODEM_NETWORK );
       
   901     isimsg.CopyData( ISI_HEADER_SIZE, data );
       
   902 
       
   903     return( iPhoNetSender->Send( isimsg.Complete() ) );
       
   904     }
       
   905 
       
   906 // -----------------------------------------------------------------------------
       
   907 // CMmCustomMessHandler::NetCsWakeupResp
       
   908 // Breaks a NET_CS_WAKEUP_RESP ISI message and complete NetWakeup with
       
   909 // KErrNone to SOS layer
       
   910 // (other items were commented in a header).
       
   911 // -----------------------------------------------------------------------------
       
   912 //
       
   913 void CMmCustomMessHandler::NetCsWakeupResp()
       
   914     {
       
   915     TFLOGSTRING("TSY: CMmCustomMessHandler::NetCsWakeupResp.\n" );
       
   916 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETCSWAKEUPRESP, "CMmCustomMessHandler::NetCsWakeupResp" );
       
   917 
       
   918     //getting this message indicates that the wakeup was successful
       
   919     //complete NetWakeup method (no packed parameters)
       
   920     iMessageRouter->Complete( ECustomNetWakeupIPC, KErrNone );
       
   921 
       
   922     }
       
   923 
       
   924 // -----------------------------------------------------------------------------
       
   925 // CMmCustomMessHandler::NetCipheringInd
       
   926 // This method breaks the ciphering indication message.
       
   927 // This indication saves the ciphering status and calls SimReadCiReq to get the
       
   928 // status of the ciphering indicator
       
   929 // (other items were commented in a header).
       
   930 // -----------------------------------------------------------------------------
       
   931 //
       
   932 void CMmCustomMessHandler::NetCipheringInd(
       
   933         const TIsiReceiveC &aIsiMsg )
       
   934     {
       
   935     TFLOGSTRING("TSY: CMmCustomMessHandler::NetCipheringInd.\n" );
       
   936 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETCIPHERINGIND, "CMmCustomMessHandler::NetCipheringInd" );
       
   937 
       
   938     //set chipering to False
       
   939     TBool cipher( EFalse );
       
   940 
       
   941     //get the ciphering status
       
   942     TUint8 cipheringStatus( aIsiMsg.Get8bit( ISI_HEADER_SIZE +
       
   943       NET_CIPHERING_IND_OFFSET_CIPHERINGSTATUS ) );
       
   944 
       
   945     //check the value of the ciphering status
       
   946     if ( NET_CIPHERING_INDICATOR_ON == cipheringStatus )
       
   947         {
       
   948         cipher = ETrue;
       
   949         }
       
   950 
       
   951     TUint8 traId( ETrIdNotifyCipheringIndicatorStatusCustom );
       
   952 
       
   953     //save the ciphering information for later completion in the list.
       
   954     //this method has to request the sim to complete, so new indication
       
   955     //might come, values must be buffered.
       
   956     TCiphListEntry chiplistentry;
       
   957     chiplistentry.iTraId = traId;
       
   958     chiplistentry.iCiphStatus = cipher;
       
   959     iListOfCiphValues->Append( chiplistentry );
       
   960 
       
   961     //get the ciphering indicator information from SIM card
       
   962     //the response of this method will call the completion for the
       
   963     //notification
       
   964     UiccReadCiReq( ETrIdNotifyCipheringIndicatorStatusCustom );
       
   965     }
       
   966 
       
   967 // -----------------------------------------------------------------------------
       
   968 // CMmCustomMessHandler::NetModemRegStatusInd
       
   969 // This method breaks the NET_MODEM_REG_STATUS_IND message.
       
   970 // (other items were commented in a header).
       
   971 // -----------------------------------------------------------------------------
       
   972 //
       
   973 void CMmCustomMessHandler::NetModemRegStatusInd
       
   974         (
       
   975         const TIsiReceiveC& aIsiMsg
       
   976         )
       
   977     {
       
   978 TFLOGSTRING("TSY: CMmCustomMessHandler::NetModemRegStatusInd");
       
   979 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETMODEMREGSTATUSIND, "CMmCustomMessHandler::NetModemRegStatusInd" );
       
   980 
       
   981     if ( 0 != aIsiMsg.Get8bit(
       
   982         ISI_HEADER_SIZE +
       
   983         NET_MODEM_REG_STATUS_IND_OFFSET_SUBBLOCKCOUNT ) )
       
   984         {
       
   985         TUint sbStartOffSet( 0 );
       
   986 
       
   987         TInt retValue( aIsiMsg.FindSubBlockOffsetById(
       
   988             ISI_HEADER_SIZE + SIZE_NET_MODEM_REG_STATUS_IND,
       
   989             NET_MODEM_REG_INFO_COMMON,
       
   990             EIsiSubBlockTypeId8Len8,
       
   991             sbStartOffSet ) );
       
   992 
       
   993         // Check if NET_MODEM_REG_INFO_COMMON sub block is present.
       
   994         if ( KErrNone == retValue )
       
   995             {
       
   996             // Get registration status
       
   997             TUint8 registrationStatus( aIsiMsg.Get8bit(
       
   998                 sbStartOffSet +
       
   999                 NET_MODEM_REG_INFO_COMMON_OFFSET_REGISTRATIONSTATUS ) );
       
  1000 
       
  1001             TBool nspsIsOn( EFalse );
       
  1002 
       
  1003             switch ( registrationStatus )
       
  1004                 {
       
  1005                 case NET_REG_STATUS_NSPS:
       
  1006                 case NET_REG_STATUS_NSPS_NO_COVERAGE:
       
  1007                     {
       
  1008                     nspsIsOn = ETrue;
       
  1009                     break;
       
  1010                     }
       
  1011                 case NET_REG_STATUS_NOSERV_NOSIM:
       
  1012                 case NET_REG_STATUS_NOSERV_SIM_REJECTED_BY_NW:
       
  1013                     {
       
  1014 TFLOGSTRING("TSY: CMmCustomMessHandler::NetModemRegStatusInd, No SIM");
       
  1015 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_NETMODEMREGSTATUSIND, "CMmCustomMessHandler::NetModemRegStatusInd, No SIM" );
       
  1016                     // Complete NetworkConnectionFailure notification
       
  1017                     // (no packed parameters).
       
  1018                     // If puk code is required notification shouldn't
       
  1019                     // be completed.
       
  1020                     TBool pukCodeRequired( iSecurityMessHandler->GetPukCodeReq() );
       
  1021                     if( !pukCodeRequired )
       
  1022                         {
       
  1023 TFLOGSTRING("TSY: CMmCustomMessHandler::NetModemRegStatusInd - Complete network connection failure");
       
  1024 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_NETMODEMREGSTATUSIND, "CMmCustomMessHandler::NetModemRegStatusInd - Complete network connection failure" );
       
  1025 
       
  1026                         iMessageRouter->Complete(
       
  1027                             ECustomNotifyNetworkConnectionFailureIPC,
       
  1028                             KErrNone );
       
  1029                         }
       
  1030                     break;
       
  1031                     }
       
  1032                 default:
       
  1033                     {
       
  1034 TFLOGSTRING("TSY: CMmCustomMessHandler::NetModemRegStatusInd, switch registrationStatus - default");
       
  1035 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_NETMODEMREGSTATUSIND, "CMmCustomMessHandler::NetModemRegStatusInd, switch registrationStatus - default" );
       
  1036                     break;
       
  1037                     }
       
  1038                 }
       
  1039 
       
  1040             // Inform of the status of NSPS.
       
  1041             // Packed parameter: TBool nspsIsOn.
       
  1042             CMmDataPackage dataPackage;
       
  1043             dataPackage.PackData( &nspsIsOn );
       
  1044 
       
  1045             iMessageRouter->Complete(
       
  1046                 ECustomNotifyNSPSStatusIPC,
       
  1047                 &dataPackage,
       
  1048                 KErrNone );
       
  1049             }
       
  1050         // No else
       
  1051 
       
  1052         // Check if ECID info needs to be updated.
       
  1053         CheckECIDInfo( aIsiMsg );
       
  1054         }
       
  1055     // No else
       
  1056     }
       
  1057 
       
  1058 // -----------------------------------------------------------------------------
       
  1059 // CMmCustomMessHandler::UiccReadDynamic2FlagsReq
       
  1060 // Read dynamic 2 flags from UICC
       
  1061 // -----------------------------------------------------------------------------
       
  1062 //
       
  1063 TInt CMmCustomMessHandler::UiccReadDynamic2FlagsReq()
       
  1064     {
       
  1065 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccReadDynamic2FlagsReq");
       
  1066 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADDYNAMIC2FLAGSREQ, "CMmCustomMessHandler::UiccReadDynamic2FlagsReq" );
       
  1067     // Set parameters for UICC_APPL_CMD_REQ message
       
  1068     TUiccWriteTransparent params;
       
  1069     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  1070     params.trId = ETrIdReadDynamic2Flags;
       
  1071     params.dataOffset = 0;
       
  1072     params.dataAmount = 0;
       
  1073     params.fileId = KElemFileDyn2FlagsOrange;
       
  1074     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  1075     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
  1076     // File id path
       
  1077     params.filePath.Append( KMasterFileId >> 8 );
       
  1078     params.filePath.Append( KMasterFileId );
       
  1079     params.filePath.Append( KOrangeDedicatedFile >> 8 );
       
  1080     params.filePath.Append( KOrangeDedicatedFile );
       
  1081     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  1082     }
       
  1083 
       
  1084 // -----------------------------------------------------------------------------
       
  1085 // CMmCustomMessHandler::UiccReadDynamic2FlagsResp
       
  1086 // Complete dynamic 2 flags
       
  1087 // -----------------------------------------------------------------------------
       
  1088 //
       
  1089 void CMmCustomMessHandler::UiccReadDynamic2FlagsResp(
       
  1090     TInt aStatus,
       
  1091     const TDesC8& aFileData )
       
  1092     {
       
  1093 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccReadDynamic2FlagsResp");
       
  1094 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADDYNAMIC2FLAGSRESP, "CMmCustomMessHandler::UiccReadDynamic2FlagsResp" );
       
  1095 
       
  1096     TInt ret( KErrNone );
       
  1097     RMmCustomAPI::TGetAlsBlockStatus blockStatus
       
  1098         ( RMmCustomAPI::EBlockStatusUnknown );
       
  1099 
       
  1100     if ( UICC_STATUS_OK == aStatus )
       
  1101         {
       
  1102         // The value of the block status is in the LSB byte
       
  1103         if ( aFileData[0] & 0x01 )
       
  1104             {
       
  1105             blockStatus = RMmCustomAPI::EBlockStatusActive;
       
  1106             }
       
  1107         else
       
  1108             {
       
  1109             blockStatus = RMmCustomAPI::EBlockStatusInactive;
       
  1110             }
       
  1111         }
       
  1112     else
       
  1113         {
       
  1114         blockStatus = RMmCustomAPI::EBlockStatusNotSupported;
       
  1115         ret = KErrNotFound;
       
  1116         }
       
  1117 
       
  1118     // Complete, packed parameter: TGetAlsBlockStatus (block status)
       
  1119     CMmDataPackage dataPackage;
       
  1120     dataPackage.PackData( &blockStatus );
       
  1121     iMessageRouter->Complete(
       
  1122         ECustomGetAlsBlockedIPC,
       
  1123         &dataPackage,
       
  1124         ret );
       
  1125     }
       
  1126 
       
  1127 // -----------------------------------------------------------------------------
       
  1128 // CMmCustomMessHandler::UiccWriteDynamic2FlagsReq
       
  1129 // Write dynamic 2 flags to UICC
       
  1130 // -----------------------------------------------------------------------------
       
  1131 //
       
  1132 TInt CMmCustomMessHandler::UiccWriteDynamic2FlagsReq( TUint8 aInfo )
       
  1133     {
       
  1134 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccWriteDynamic2FlagsReq");
       
  1135 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCWRITEDYNAMIC2FLAGSREQ, "CMmCustomMessHandler::UiccWriteDynamic2FlagsReq" );
       
  1136 
       
  1137     // Set parameters for UICC_APPL_CMD_REQ message
       
  1138     TUiccWriteTransparent params;
       
  1139     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  1140     params.trId = ETrIdWriteDynamic2Flags;
       
  1141     params.dataOffset = 0;
       
  1142     params.fileId = KElemFileDyn2FlagsOrange;
       
  1143     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  1144     params.serviceType = UICC_APPL_UPDATE_TRANSPARENT;
       
  1145 
       
  1146     // File id path
       
  1147     params.filePath.Append( KMasterFileId >> 8 );
       
  1148     params.filePath.Append( KMasterFileId );
       
  1149     params.filePath.Append( KOrangeDedicatedFile >> 8 );
       
  1150     params.filePath.Append( KOrangeDedicatedFile );
       
  1151 
       
  1152     params.fileData.Append( aInfo );
       
  1153     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  1154     }
       
  1155 
       
  1156 // -----------------------------------------------------------------------------
       
  1157 // CMmCustomMessHandler::UiccWriteDynamic2FlagsResp
       
  1158 // Complete write dynamic flags request ro UICC
       
  1159 // -----------------------------------------------------------------------------
       
  1160 //
       
  1161 void CMmCustomMessHandler::UiccWriteDynamic2FlagsResp( TInt aStatus )
       
  1162     {
       
  1163 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccWriteDynamic2FlagsReq");
       
  1164 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCWRITEDYNAMIC2FLAGSRESP, "CMmCustomMessHandler::UiccWriteDynamic2FlagsResp" );
       
  1165 
       
  1166     TInt ret( KErrNone );
       
  1167 
       
  1168     if ( UICC_STATUS_OK != aStatus )
       
  1169         {
       
  1170         ret = KErrGeneral;
       
  1171         }
       
  1172 
       
  1173     iMessageRouter->Complete( ECustomSetAlsBlockedIPC, ret );
       
  1174     }
       
  1175 
       
  1176 // -----------------------------------------------------------------------------
       
  1177 // CMmCustomMessHandler::CallTerminateInd
       
  1178 // This method breaks the CALL_MODEM_TERMINATE_IND
       
  1179 // indication message. Gets CALL_MODEM_SB_SS_DIAGNOSTICS sub blocks and sets
       
  1180 // information into a call object.
       
  1181 // (other items were commented in a header).
       
  1182 // -----------------------------------------------------------------------------
       
  1183 //
       
  1184 void CMmCustomMessHandler::CallTerminateInd
       
  1185         (
       
  1186         const TIsiReceiveC& aIsiMsg    //received ISI message
       
  1187         )
       
  1188     {
       
  1189     TFLOGSTRING("TSY: CMmCustomMessHandler::CallTerminateInd.\n" );
       
  1190 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CALLTERMINATEIND, "CMmCustomMessHandler::CallTerminateInd" );
       
  1191 
       
  1192     //unique call id (without possible generic id)
       
  1193     TInt callId = static_cast<TInt>( aIsiMsg.Get8bit( ISI_HEADER_SIZE +
       
  1194         CALL_MODEM_TERMINATED_IND_OFFSET_CALLID ) & 0x07 );
       
  1195 
       
  1196     if ( CALL_MODEM_ID_NONE != callId )
       
  1197         {
       
  1198         TUint sbStartOffSet( 0 );
       
  1199 
       
  1200         TUint8 ssDiagnostics = 0;
       
  1201 
       
  1202         //find sub block
       
  1203         if( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  1204           ISI_HEADER_SIZE + SIZE_CALL_MODEM_TERMINATED_IND, CALL_MODEM_SB_SS_DIAGNOSTICS,
       
  1205           EIsiSubBlockTypeId8Len8, sbStartOffSet ) )
       
  1206           {
       
  1207             //get ss diagnostics
       
  1208             ssDiagnostics = aIsiMsg.Get8bit( sbStartOffSet +
       
  1209                 CALL_MODEM_SB_SS_DIAGNOSTICS_OFFSET_DIAGNOSTICS );
       
  1210 
       
  1211             // Set highest bit to 1 if there is some diagnostic information
       
  1212             // (This is in accordance with 3GPP TS 24.008 "Mobile radio
       
  1213             // interface Layer 3 specification; Core network protocols" and with
       
  1214             // Series 60 Supplementary Services UI Specification)
       
  1215             if ( 0 != ssDiagnostics )
       
  1216                 {
       
  1217                 ssDiagnostics |= 0x80; // binary 10000000
       
  1218                 TFLOGSTRING3("TSY:CMmCustomMessHandler::CallTerminatedInd: Diagnostic octet=%d received for call id=%d",
       
  1219                     ssDiagnostics, callId );
       
  1220 OstTraceExt2( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_CALLTERMINATEIND, "CMmCustomMessHandler::CallTerminateInd;Diagnostic octet==%hhu received for call id=%d", ssDiagnostics, callId );
       
  1221                 }
       
  1222             }
       
  1223 
       
  1224         // set the diagnostics in call object (might be zero)
       
  1225         // parameters for SOS layer: Call id and TUint8 with diagnostics
       
  1226         CMmDataPackage dataPackage;
       
  1227         dataPackage.PackData( &callId, &ssDiagnostics );
       
  1228         iMessageRouter->Complete( ECustomGetDiagnosticOctetsIPC, &dataPackage,
       
  1229            KErrNone );
       
  1230 
       
  1231         }
       
  1232     }
       
  1233 
       
  1234 // -----------------------------------------------------------------------------
       
  1235 // CMmCustomMessHandler::CallReleaseInd
       
  1236 // This method breaks the CALL_MODEM_RELEASE_IND.
       
  1237 // indication message. Gets CALL_MODEM_SB_SS_DIAGNOSTICS sub blocks and sets
       
  1238 // information into a call object.
       
  1239 // (other items were commented in a header).
       
  1240 // -----------------------------------------------------------------------------
       
  1241 //
       
  1242 void CMmCustomMessHandler::CallReleaseInd
       
  1243         (
       
  1244         const TIsiReceiveC& aIsiMsg    //received ISI message
       
  1245         )
       
  1246     {
       
  1247     TFLOGSTRING("TSY: CMmCustomMessHandler::CallReleaseInd.\n" );
       
  1248 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CALLRELEASEIND, "CMmCustomMessHandler::CallReleaseInd" );
       
  1249 
       
  1250     //unique call id (without possible generic id)
       
  1251     TInt callId = static_cast<TInt>( aIsiMsg.Get8bit( ISI_HEADER_SIZE +
       
  1252         CALL_MODEM_RELEASE_IND_OFFSET_CALLID ) & 0x07 );
       
  1253 
       
  1254     if ( CALL_MODEM_ID_NONE != callId )
       
  1255         {
       
  1256         TUint sbStartOffSet( 0 );
       
  1257 
       
  1258         TUint8 ssDiagnostics = 0;
       
  1259 
       
  1260         //get call operation sub block
       
  1261         if( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  1262           ISI_HEADER_SIZE + SIZE_CALL_MODEM_RELEASE_IND, CALL_MODEM_SB_SS_DIAGNOSTICS,
       
  1263           EIsiSubBlockTypeId8Len8, sbStartOffSet ) )
       
  1264           {
       
  1265             //get ss diagnostics
       
  1266             ssDiagnostics = aIsiMsg.Get8bit( sbStartOffSet +
       
  1267                 CALL_MODEM_SB_SS_DIAGNOSTICS_OFFSET_DIAGNOSTICS );
       
  1268 
       
  1269             // Set highest bit to 1 if there is some diagnostic information
       
  1270             // (This is in accordance with 3GPP TS 24.008 "Mobile radio
       
  1271             // interface Layer 3 specification; Core network protocols" and with
       
  1272             // Series 60 Supplementary Services UI Specification)
       
  1273             if ( 0 != ssDiagnostics )
       
  1274                 {
       
  1275                 ssDiagnostics |= 0x80; // binary 10000000
       
  1276                 TFLOGSTRING3("TSY:CMmCustomMessHandler::CallReleaseInd: Diagnostic octet=%d received for call id=%d",
       
  1277                     ssDiagnostics, callId );
       
  1278 OstTraceExt2( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_CALLRELEASEIND, "CMmCustomMessHandler::CallReleaseInd;Diagnostic octet==%hhu received for call id=%d", ssDiagnostics, callId );
       
  1279                 }
       
  1280             }
       
  1281 
       
  1282         // set the diagnostics in call object (might be zero)
       
  1283         // parameters for SOS layer: Call id and TUint8 with diagnostics
       
  1284         CMmDataPackage dataPackage;
       
  1285         dataPackage.PackData( &callId, &ssDiagnostics );
       
  1286         iMessageRouter->Complete( ECustomGetDiagnosticOctetsIPC, &dataPackage,
       
  1287            KErrNone );
       
  1288 
       
  1289         }
       
  1290     }
       
  1291 
       
  1292 
       
  1293 // -----------------------------------------------------------------------------
       
  1294 // CMmCustomMessHandler::InfoPpReadReq
       
  1295 // Constructs INFO_PP_READ_REQ ISI message from input parameters and sends
       
  1296 // it through phonet. This message can be used to read ALS or Two Digit Dialling
       
  1297 // support status in the product profiles from INFO server.
       
  1298 // (other items were commented in a header).
       
  1299 // -----------------------------------------------------------------------------
       
  1300 //
       
  1301 TInt CMmCustomMessHandler::InfoPpReadReq
       
  1302         (
       
  1303         TProductProfileRequestType aReqType // request type, used as
       
  1304         )
       
  1305     {
       
  1306     TFLOGSTRING("TSY: CMmCustomMessHandler::InfoPpReadReq.\n" );
       
  1307 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_INFOPPREADREQ, "CMmCustomMessHandler::InfoPpReadReq" );
       
  1308 
       
  1309 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
  1310     //create the buffer for SB_PP subblock
       
  1311     TBuf8<SIZE_INFO_SB_PP> sbPPSubBlockBuf( 0 );
       
  1312     TIsiSubBlock sbPPSubBlock( sbPPSubBlockBuf, INFO_SB_PP, EIsiSubBlockTypeId8Len8 );
       
  1313     //add 0x00 as the Dynamic Value ID, not needed cause we want to get
       
  1314     //a static value
       
  1315     sbPPSubBlockBuf.Append( 0x00 );
       
  1316 
       
  1317     //add 0x01 as the length of the product profile, we want only als
       
  1318     //profile, thus lenght is 1
       
  1319     sbPPSubBlockBuf.Append( 0x01 );
       
  1320 
       
  1321     //add the product profile number
       
  1322     if ( EGetAlsPPSupport == aReqType )
       
  1323         {
       
  1324         sbPPSubBlockBuf.Append( INFO_PP_ALS );
       
  1325         }
       
  1326     else if ( ECheckTwoDigitDialSupport == aReqType )
       
  1327         {
       
  1328         sbPPSubBlockBuf.Append( KinfoPpTwoDigitDial );
       
  1329         }
       
  1330   else
       
  1331     {
       
  1332     // not supported
       
  1333     return KErrArgument;
       
  1334     }
       
  1335 
       
  1336     //value of the product profile is 0x00, not need cause we are reading
       
  1337     sbPPSubBlockBuf.Append( 0x00 );
       
  1338 
       
  1339   // Construct INFO_PP_READ_REQ message (1 data byte +
       
  1340   // sub block count + INFO_SB_PP sub block)
       
  1341   TBuf8< 2 + SIZE_INFO_SB_PP > infoPpReadReq;
       
  1342 
       
  1343     //set pp batch reading to read specific product profile, thus 0.
       
  1344     infoPpReadReq.Append( INFO_PP_PROD_PROFILE_FEATURE );
       
  1345 
       
  1346     // add sub block
       
  1347     infoPpReadReq.Append( 1 ); // number of sub blocks
       
  1348     infoPpReadReq.Append( sbPPSubBlock.CompleteSubBlock() );
       
  1349 
       
  1350     //create the isi message
       
  1351   //transaction id = request type
       
  1352   TUint8 transId = static_cast<TUint8>( aReqType );
       
  1353 
       
  1354     return iPhoNetSender->Send( PN_INFO, transId, INFO_PP_READ_REQ, infoPpReadReq );
       
  1355 
       
  1356 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
  1357     return KErrNone;
       
  1358     }
       
  1359 
       
  1360 // -----------------------------------------------------------------------------
       
  1361 // CMmCustomMessHandler::InfoPpReadResp
       
  1362 // Breaks a INFO_PP_READ_RESP ISI message. This method
       
  1363 // gets the status of the ALS or two digit support.
       
  1364 // Complete with packed parameter RMmCustomAPI::TAlsSupport or
       
  1365 // RMmCustomAPI::TTwoDigitDialSupport to SOS layer.
       
  1366 // (other items were commented in a header).
       
  1367 // -----------------------------------------------------------------------------
       
  1368 //
       
  1369 void CMmCustomMessHandler::InfoPpReadResp
       
  1370         (
       
  1371         const TIsiReceiveC& aIsiMessage    //received ISI message
       
  1372         )
       
  1373     {
       
  1374     TFLOGSTRING("TSY: CMmCustomMessHandler::InfoPpReadResp.\n" );
       
  1375 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_INFOPPREADRESP, "CMmCustomMessHandler::InfoPpReadResp" );
       
  1376 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
  1377     TInt errorValue( KErrGeneral );
       
  1378 
       
  1379     // Get Status
       
  1380     TUint8 status = aIsiMessage.Get8bit( ISI_HEADER_SIZE + INFO_PP_READ_RESP_OFFSET_STATUS );
       
  1381 
       
  1382     //initialize the als support with off
       
  1383     RMmCustomAPI::TAlsSupport alsSupport( RMmCustomAPI::EAlsSupportOff );
       
  1384 
       
  1385     //initialize two digit support with off
       
  1386     RMmCustomAPI::TTwoDigitDialSupport twoDigitDialSupport(
       
  1387         RMmCustomAPI::ETwoDigitDialSupportOff );
       
  1388 
       
  1389   TFLOGSTRING2("TSY: CMmCustomMessHandler::InfoPpReadResp - Status: %d",
       
  1390     status );
       
  1391 OstTraceExt1( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_INFOPPREADRESP, "CMmCustomMessHandler::InfoPpReadResp;status=%hhu", status );
       
  1392 
       
  1393     switch ( status )
       
  1394         {
       
  1395         case INFO_OK:
       
  1396             {
       
  1397 
       
  1398           TUint sbInfoPpReadStartOffset( 0 );
       
  1399 
       
  1400 
       
  1401             if ( KErrNone == aIsiMessage.FindSubBlockOffsetById( ISI_HEADER_SIZE + SIZE_INFO_PP_READ_RESP,
       
  1402               INFO_SB_PP, EIsiSubBlockTypeId8Len8, sbInfoPpReadStartOffset ) )
       
  1403 
       
  1404                 {
       
  1405 
       
  1406                 TInt length = aIsiMessage.Get8bit( sbInfoPpReadStartOffset + INFO_SB_PP_OFFSET_STRLEN  );
       
  1407 
       
  1408         TFLOGSTRING2("TSY: CMmCustomMessHandler::InfoPpReadResp - Info length: %d",
       
  1409           length );
       
  1410 OstTrace1( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_INFOPPREADRESP, "CMmCustomMessHandler::InfoPpReadResp - Info length=%d", length );
       
  1411 
       
  1412                 if ( 1 == length )
       
  1413                     {
       
  1414                     //introduce the pPFeatures buffer to hold the feature value,
       
  1415                     //buffer size is 2
       
  1416                     TBuf8<KTwo> pPFeatures;
       
  1417 
       
  1418                     //copy the 2 bytes from product profile
       
  1419                     pPFeatures.Copy( aIsiMessage.GetData( sbInfoPpReadStartOffset
       
  1420                       + INFO_SB_PP_OFFSET_PRODUCTPROFILE, KTwo ) );
       
  1421 
       
  1422           TFLOGSTRING2("TSY: CMmCustomMessHandler::InfoPpReadResp - Info data: %S",
       
  1423             &pPFeatures );
       
  1424 OstTraceExt1( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_INFOPPREADRESP, "CMmCustomMessHandler::InfoPpReadResp;pPfeatures=%s", pPFeatures );
       
  1425 
       
  1426                     //check that product profile is requested one
       
  1427                     if ( INFO_PP_ALS == pPFeatures [0] )
       
  1428                         {
       
  1429                         //Get the value of the Als feature
       
  1430                         if ( 0 != pPFeatures [1] )
       
  1431                             {
       
  1432               TFLOGSTRING("TSY: CMmCustomMessHandler::InfoPpReadResp - EAlsSupportOn");
       
  1433 OstTrace0( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_INFOPPREADRESP, "CMmCustomMessHandler::InfoPpReadResp - EAlsSupportOn" );
       
  1434               alsSupport = RMmCustomAPI::EAlsSupportOn;
       
  1435                             }
       
  1436                         //set the error value to KErrNone
       
  1437                         errorValue = KErrNone;
       
  1438                         }
       
  1439                     else if ( KinfoPpTwoDigitDial == pPFeatures [0] )
       
  1440                         {
       
  1441                         //Get the value of the two digit dial feature
       
  1442                         if ( 0 != pPFeatures [1] )
       
  1443                             {
       
  1444               TFLOGSTRING("TSY: CMmCustomMessHandler::InfoPpReadResp - EAlsSupportOff");
       
  1445 OstTrace0( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_INFOPPREADRESP, "CMmCustomMessHandler::InfoPpReadResp - EAlsSupportOff" );
       
  1446               twoDigitDialSupport =
       
  1447                 RMmCustomAPI::ETwoDigitDialSupportOn;
       
  1448                             }
       
  1449                         //set the error value to KErrNone
       
  1450                         errorValue = KErrNone;
       
  1451                         }
       
  1452 
       
  1453                     //No else
       
  1454 
       
  1455                     }
       
  1456                 }
       
  1457             break;
       
  1458             }
       
  1459         case INFO_FAIL:
       
  1460             {
       
  1461             //error in operation
       
  1462             errorValue = KErrGeneral;
       
  1463             break;
       
  1464             }
       
  1465         case INFO_NO_NUMBER:
       
  1466             {
       
  1467             //information is not found
       
  1468             errorValue = KErrNotFound;
       
  1469             break;
       
  1470             }
       
  1471         default:
       
  1472             {
       
  1473             TFLOGSTRING("TSY: CMmCustomMessHandler::InfoPpReadResp, switch status - default.\n" );
       
  1474 OstTrace0( TRACE_NORMAL, DUP6_CMMCUSTOMMESSHANDLER_INFOPPREADRESP, "CMmCustomMessHandler::InfoPpReadResp, switch status - default" );
       
  1475             errorValue = KErrNotSupported;
       
  1476             break;
       
  1477             }
       
  1478         }
       
  1479 
       
  1480   TUint8 traId = aIsiMessage.Get8bit( ISI_HEADER_SIZE + INFO_PP_READ_RESP_OFFSET_TRANSID );
       
  1481     if ( EGetAlsPPSupport == traId )
       
  1482         {
       
  1483     // complete with packed parameter RMmCustomAPI::TAlsSupport
       
  1484     CMmDataPackage dataPackage;
       
  1485     dataPackage.PackData( &alsSupport );
       
  1486     iMessageRouter->Complete( ECustomCheckAlsPpSupportIPC,
       
  1487       &dataPackage, errorValue );
       
  1488         }
       
  1489     else if ( ECheckTwoDigitDialSupport == traId )
       
  1490         {
       
  1491     // complete with packed parameter RMmCustomAPI::TTwoDigitDialSupport
       
  1492     CMmDataPackage dataPackage;
       
  1493     dataPackage.PackData( &twoDigitDialSupport );
       
  1494     iMessageRouter->Complete( ECustomCheckTwoDigitDialSupportIPC,
       
  1495       &dataPackage, errorValue );
       
  1496         }
       
  1497 
       
  1498     //No else
       
  1499 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
  1500     }
       
  1501 
       
  1502 // -----------------------------------------------------------------------------
       
  1503 // CMmCustomMessHandler::CallGsmBlackListClearReq
       
  1504 // Constructs CALL_MODEM_BLACKLIST_CLEAR_REQ ISI message from input parameters and
       
  1505 // sends it through phonet.
       
  1506 // (other items were commented in a header).
       
  1507 // -----------------------------------------------------------------------------
       
  1508 //
       
  1509 TInt CMmCustomMessHandler::CallGsmBlackListClearReq
       
  1510         (
       
  1511          TUint8 aTransId // Transaction Id
       
  1512         )
       
  1513     {
       
  1514     TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmBlackListClearReq.\n" );
       
  1515 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CALLGSMBLACKLISTCLEARREQ, "CMmCustomMessHandler::CallGsmBlackListClearReq" );
       
  1516 
       
  1517   // Construct CALL_MODEM_BLACKLIST_CLEAR_REQ message (1 data byte +
       
  1518   // sub block count)
       
  1519   TBuf8<2> blackListClearReq;
       
  1520 
       
  1521     blackListClearReq.Append( KCustomPadding );
       
  1522     blackListClearReq.Append( 0x00 ); // sub block count
       
  1523 
       
  1524     //Send message via PhoNet
       
  1525     return iPhoNetSender->Send( PN_MODEM_CALL, aTransId, CALL_MODEM_BLACKLIST_CLEAR_REQ,
       
  1526       blackListClearReq );
       
  1527     }
       
  1528 
       
  1529 // -----------------------------------------------------------------------------
       
  1530 // CMmCustomMessHandler::CallGsmBlackListClearResp
       
  1531 // Breaks a CALL_MODEM_BLACKLIST_CLEAR_RESP ISI message. This method
       
  1532 // gets indicates that the clear blacklist was successful.
       
  1533 // Complete CallGsmBlackListClear with KErrNone to SOS layer.
       
  1534 // (other items were commented in a header).
       
  1535 // -----------------------------------------------------------------------------
       
  1536 //
       
  1537 void CMmCustomMessHandler::CallGsmBlackListClearResp
       
  1538         (
       
  1539 //         const TIsiReceiveC& aIsiMsg // Received isi messge
       
  1540         )
       
  1541     {
       
  1542     TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmBlackListClearResp.\n" );
       
  1543 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CALLGSMBLACKLISTCLEARRESP, "CMmCustomMessHandler::CallGsmBlackListClearResp" );
       
  1544 
       
  1545     // call server response
       
  1546     //getting this message indicates that the clear blacklist was successful
       
  1547     //complete SOS layer method
       
  1548   iMessageRouter->Complete( ECustomClearCallBlackListIPC, KErrNone );
       
  1549     }
       
  1550 
       
  1551 // -----------------------------------------------------------------------------
       
  1552 // CMmCustomMessHandler::SsServiceCompletedInd
       
  1553 // This method breaks the SS_SERVICE_COMPLETED_IND ISI message.
       
  1554 // Complete SsRequestCompleteNotification method from custom api or
       
  1555 // Complete NotifySsAdditionalInfo to SOS layer.
       
  1556 // (other items were commented in a header).
       
  1557 // -----------------------------------------------------------------------------
       
  1558 //
       
  1559 void CMmCustomMessHandler::SsServiceCompletedInd
       
  1560         (
       
  1561         const TIsiReceiveC& aIsiMessage //received ISI message
       
  1562         )
       
  1563     {
       
  1564     TFLOGSTRING("TSY: CMmCustomMessHandler::SsServiceCompletedInd");
       
  1565 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_SSSERVICECOMPLETEDIND, "CMmCustomMessHandler::SsServiceCompletedInd" );
       
  1566 
       
  1567     if ( 0 < aIsiMessage.Get8bit( ISI_HEADER_SIZE +
       
  1568                 SS_SERVICE_COMPLETED_IND_OFFSET_SUBBLOCKCOUNT ) )
       
  1569         {
       
  1570         TUint ssStatus( 0 );
       
  1571         TUint8 sbSsStatus( 0 );
       
  1572         TUint sbForwardingFeatureOffset( 0 );
       
  1573         TUint sbBarringFeatureOffset( 0 );
       
  1574 
       
  1575         TUint sbStartOffset(0);
       
  1576         // SS_STATUS_RESULT sub block
       
  1577         if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  1578                 ISI_HEADER_SIZE + SIZE_SS_SERVICE_COMPLETED_IND,
       
  1579                 SS_STATUS_RESULT,
       
  1580                 EIsiSubBlockTypeId8Len8,
       
  1581                 sbStartOffset ) )
       
  1582             {
       
  1583             sbSsStatus = aIsiMessage.Get8bit( sbStartOffset +
       
  1584                                               SS_STATUS_RESULT_OFFSET_SSSTATUS );
       
  1585             }
       
  1586 
       
  1587         // SS_GSM_FORWARDING_INFO sub block
       
  1588         if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  1589                 ISI_HEADER_SIZE + SIZE_SS_SERVICE_COMPLETED_IND,
       
  1590                 SS_GSM_FORWARDING_INFO,
       
  1591                 EIsiSubBlockTypeId8Len8,
       
  1592                 sbStartOffset ) )
       
  1593             {
       
  1594             // Sub block's sub block SS_GSM_FORWARDING_FEATURE:
       
  1595             if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  1596                             sbStartOffset + SIZE_SS_GSM_FORWARDING_INFO,
       
  1597                             SS_GSM_FORWARDING_FEATURE,
       
  1598                             EIsiSubBlockTypeId8Len8,
       
  1599                             sbForwardingFeatureOffset
       
  1600                             ) )
       
  1601                 {
       
  1602                 sbSsStatus = aIsiMessage.Get8bit( sbForwardingFeatureOffset +
       
  1603                                 SS_GSM_FORWARDING_FEATURE_OFFSET_SSSTATUS );
       
  1604                 }
       
  1605       //Cases which don't return the other sub block should still be ok.
       
  1606       else
       
  1607         {
       
  1608         // This simulates successfull SS case, where the info subblock
       
  1609         // is received, but the forwarding feature isn't(the real status
       
  1610         // cannot be read).
       
  1611         sbSsStatus = SS_GSM_ACTIVE;
       
  1612         }
       
  1613             }
       
  1614 
       
  1615         // SS_GSM_BARRING_INFO sub block
       
  1616         if ( 0 == sbSsStatus && KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  1617                 ISI_HEADER_SIZE + SIZE_SS_SERVICE_COMPLETED_IND,
       
  1618                 SS_GSM_BARRING_INFO,
       
  1619                 EIsiSubBlockTypeId8Len8,
       
  1620                 sbStartOffset
       
  1621                 ) )
       
  1622             {
       
  1623             // Sub block's sub block SS_GSM_BARRING_FEATURE
       
  1624             if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  1625                             sbStartOffset + SIZE_SS_GSM_BARRING_FEATURE,
       
  1626                             SS_GSM_BARRING_FEATURE,
       
  1627                             EIsiSubBlockTypeId8Len8,
       
  1628                             sbBarringFeatureOffset
       
  1629                             ) )
       
  1630                 {
       
  1631 
       
  1632                 sbSsStatus = aIsiMessage.Get8bit( sbBarringFeatureOffset +
       
  1633                                     SS_GSM_BARRING_FEATURE_OFFSET_SSSTATUS );
       
  1634                 }
       
  1635             }
       
  1636 
       
  1637 
       
  1638         // SS_GSM_GENERIC_SERVICE_INFO sub block
       
  1639         if ( 0 == sbSsStatus && KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  1640                 ISI_HEADER_SIZE + SIZE_SS_SERVICE_COMPLETED_IND,
       
  1641                 SS_GSM_GENERIC_SERVICE_INFO,
       
  1642                 EIsiSubBlockTypeId8Len8,
       
  1643                 sbStartOffset
       
  1644                 ) )
       
  1645             {
       
  1646             sbSsStatus = aIsiMessage.Get8bit( sbStartOffset +
       
  1647                                               SS_GSM_GENERIC_SERVICE_INFO_OFFSET_SSSTATUS );
       
  1648             }
       
  1649 
       
  1650         // SS_GSM_DATA sub block
       
  1651         if ( 0 == sbSsStatus && KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  1652                 ISI_HEADER_SIZE + SIZE_SS_SERVICE_COMPLETED_IND,
       
  1653                 SS_GSM_DATA,
       
  1654                 EIsiSubBlockTypeId8Len8,
       
  1655                 sbStartOffset
       
  1656                 ) )
       
  1657             {
       
  1658             sbSsStatus = aIsiMessage.Get8bit( sbStartOffset +
       
  1659                                               SS_GSM_DATA_OFFSET_SSSTATUS );
       
  1660             }
       
  1661 
       
  1662         if ( 0 != sbSsStatus )
       
  1663             {
       
  1664             //Found SS status info from SS_SERVICE_COMPLETED_IND
       
  1665             if ( SS_GSM_ACTIVE & sbSsStatus )
       
  1666                 {
       
  1667                 ssStatus = KCustomApiSsGsmActive;
       
  1668                 }
       
  1669             else if ( SS_GSM_REGISTERED & sbSsStatus )
       
  1670                 {
       
  1671                 ssStatus = KCustomApiSsGsmRegistered;
       
  1672                 }
       
  1673             else if ( SS_GSM_PROVISIONED & sbSsStatus )
       
  1674                 {
       
  1675                 ssStatus = KCustomApiSsGsmProvisioned;
       
  1676                 }
       
  1677             else
       
  1678                 {
       
  1679                 ssStatus = KCustomApiSsGsmQuiescent;
       
  1680                 }
       
  1681       TFLOGSTRING2("TSY: CMmCustomMessHandler::SsServiceCompletedInd: Complete SsRequestCompleteNotification ssStatus:%d",
       
  1682         ssStatus );
       
  1683 OstTrace1( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_SSSERVICECOMPLETEDIND, "CMmCustomMessHandler::SsServiceCompletedInd;Complete SsRequestCompleteNotification ssStatus=%u", ssStatus );
       
  1684 
       
  1685             CMmDataPackage dataPackage;
       
  1686             // pack parameter: a TInt with SS status
       
  1687             dataPackage.PackData( &ssStatus );
       
  1688             iMessageRouter->Complete( ECustomNotifySsRequestCompleteIPC,
       
  1689                 &dataPackage, KErrNone );
       
  1690 
       
  1691             }
       
  1692 
       
  1693         if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  1694                 ISI_HEADER_SIZE + SIZE_SS_SERVICE_COMPLETED_IND,
       
  1695                 SS_GSM_ADDITIONAL_INFO,
       
  1696                 EIsiSubBlockTypeId8Len8,
       
  1697                 sbStartOffset ) )
       
  1698             {
       
  1699             //create SsAdditionalInfo structure
       
  1700             RMmCustomAPI::TSsAdditionalInfo additionalInfo;
       
  1701 
       
  1702             additionalInfo.iOperationCode =
       
  1703                 aIsiMessage.Get8bit( ISI_HEADER_SIZE +
       
  1704                     SS_SERVICE_COMPLETED_IND_OFFSET_OPERATION );
       
  1705 
       
  1706             TUint8 length = aIsiMessage.Get8bit( sbStartOffset +
       
  1707                 SS_GSM_ADDITIONAL_INFO_OFFSET_RETURNRESULTLEN );
       
  1708 
       
  1709             additionalInfo.iAdditionalInfo.Copy( aIsiMessage.GetData(
       
  1710                 sbStartOffset + SS_GSM_ADDITIONAL_INFO_OFFSET_RETURNRESULT,
       
  1711                 length  ) );
       
  1712 
       
  1713       TFLOGSTRING("TSY: CMmCustomMessHandler::SsServiceCompletedInd: Complete SsAdditionalInfoNotification");
       
  1714 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_SSSERVICECOMPLETEDIND, "CMmCustomMessHandler::SsServiceCompletedInd - Complete SsAdditionalInfoNotification" );
       
  1715 
       
  1716       // complete notification
       
  1717             CMmDataPackage dataPackage;
       
  1718             // pack parameter: pointer to RMmCustomAPI::TSsAdditionalInfo
       
  1719             RMmCustomAPI::TSsAdditionalInfo* additionalInfoPtr =
       
  1720               &additionalInfo;
       
  1721             dataPackage.PackData( &additionalInfoPtr );
       
  1722             iMessageRouter->Complete( ECustomSsAdditionalInfoNotificationIPC,
       
  1723                 &dataPackage, KErrNone );
       
  1724 
       
  1725             }
       
  1726         }
       
  1727     else  // No subblock found, e.g. in AlterEgo functionality
       
  1728         {
       
  1729         TInt ssStatus( KCustomApiSsGsmQuiescent );
       
  1730 
       
  1731          CMmDataPackage dataPackage;
       
  1732          // pack parameter: a TInt with SS status
       
  1733          dataPackage.PackData( &ssStatus );
       
  1734          iMessageRouter->Complete( ECustomNotifySsRequestCompleteIPC,
       
  1735                 &dataPackage, KErrNone );
       
  1736         }
       
  1737     }
       
  1738 
       
  1739 // -----------------------------------------------------------------------------
       
  1740 // CMmCustomMessHandler::SsServiceFailedResp
       
  1741 // Breaks a SS_SERVICE_FAILED_RESP ISI message. This method
       
  1742 // triggers SsRequestCompleteNotification notification.
       
  1743 // Completes SsRequestCompleteNotification method from custom tsy with
       
  1744 // status value 0xFFFF to SOS layer.
       
  1745 // (other items were commented in a header).
       
  1746 // -----------------------------------------------------------------------------
       
  1747 //
       
  1748 void CMmCustomMessHandler::SsServiceFailedResp
       
  1749         (
       
  1750         const TIsiReceiveC& aIsiMessage //received ISI message
       
  1751         )
       
  1752     {
       
  1753     TFLOGSTRING("TSY: CMmCustomMessHandler::SsServiceFailedResp");
       
  1754 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_SSSERVICEFAILEDRESP, "CMmCustomMessHandler::SsServiceFailedResp" );
       
  1755 
       
  1756     TInt ssStatus( RMmCustomAPI::KSsStatusReturnError );
       
  1757 
       
  1758     CMmDataPackage dataPackage;
       
  1759 
       
  1760     TUint sbStartOffset( 0 );
       
  1761 
       
  1762     //create SsAdditionalInfo structure
       
  1763     RMmCustomAPI::TSsAdditionalInfo additionalInfo;
       
  1764 
       
  1765     // this data is not available, set to 0 just in case
       
  1766     additionalInfo.iOperationCode = 0x00;
       
  1767 
       
  1768     //if sub block exists
       
  1769     if ( KErrNone == aIsiMessage.FindSubBlockOffsetByIndex(
       
  1770         ISI_HEADER_SIZE + SIZE_SS_SERVICE_FAILED_RESP,
       
  1771         1,
       
  1772         EIsiSubBlockTypeId8Len8,
       
  1773         sbStartOffset ) )
       
  1774         {
       
  1775         TUint8 subBlockId( aIsiMessage.Get8bit( sbStartOffset ) );
       
  1776         switch ( subBlockId )
       
  1777             {
       
  1778             case SS_GSM_INDICATE_PASSWORD_ERROR:
       
  1779                 {
       
  1780                 // Set error code to additional info. No mapping needed because
       
  1781                 // client wants error code as it was received from network.
       
  1782                 additionalInfo.iAdditionalInfo.Append(
       
  1783                     aIsiMessage.Get8bit( sbStartOffset +
       
  1784                         SS_GSM_INDICATE_PASSWORD_ERROR_OFFSET_GUIDANCEINFO ) );
       
  1785                 break;
       
  1786                 }
       
  1787             case SS_GSM_INDICATE_ERROR:
       
  1788                 {
       
  1789                 additionalInfo.iAdditionalInfo.Append( aIsiMessage.Get8bit(
       
  1790                     sbStartOffset + SS_GSM_INDICATE_ERROR_OFFSET_ERRORCODE ) );
       
  1791                 // If additional indication is not default, add it to buffer
       
  1792                 TUint8 addIndication(
       
  1793                     aIsiMessage.Get8bit( sbStartOffset +
       
  1794                         SS_GSM_INDICATE_ERROR_OFFSET_ADDITIONALINDICATION ) );
       
  1795                 // Just to keep previous functionality, the default value
       
  1796                 // not added to buffer
       
  1797                 if ( SS_DEFAULT_VALUE != addIndication )
       
  1798                     {
       
  1799                     additionalInfo.iAdditionalInfo.Append( addIndication );
       
  1800                     }
       
  1801                 break;
       
  1802                 }
       
  1803             case SS_GSM_INDICATE_PROBLEM:
       
  1804                 {
       
  1805                 // Problem code is added to additional info only if RELEASE
       
  1806                 // COMPLETE message from network includes Return Result
       
  1807                 // component
       
  1808                 if ( SS_GSM_RETURN_RESULT_PROBLEM ==
       
  1809                     aIsiMessage.Get8bit( sbStartOffset +
       
  1810                         SS_GSM_INDICATE_PROBLEM_OFFSET_PROBLEMTYPE ) )
       
  1811                     {
       
  1812                     additionalInfo.iAdditionalInfo.Append(
       
  1813                         aIsiMessage.Get8bit( sbStartOffset +
       
  1814                             SS_GSM_INDICATE_PROBLEM_OFFSET_PROBLEMCODE ) );
       
  1815                     }
       
  1816                 break;
       
  1817                 }
       
  1818             case SS_GSM_INDICATE_MSG_ERROR:
       
  1819                 {
       
  1820                 additionalInfo.iAdditionalInfo.Append(
       
  1821                     aIsiMessage.Get8bit( sbStartOffset +
       
  1822                         SS_GSM_INDICATE_MSG_ERROR_OFFSET_MESSAGEERRORCODE ) );
       
  1823                 break;
       
  1824                 }
       
  1825             case SS_OTHER_ERROR:
       
  1826                 {
       
  1827                 additionalInfo.iAdditionalInfo.Append( aIsiMessage.Get8bit(
       
  1828                     sbStartOffset + SS_OTHER_ERROR_OFFSET_ERRORCODE ) );
       
  1829                 break;
       
  1830                 }
       
  1831             case SS_GSM_MM_RELEASED:
       
  1832                 {
       
  1833                 // This subblock occurs when network has released SS request,
       
  1834                 // therefore SS status is set accordingly
       
  1835                 ssStatus = RMmCustomAPI::KSsStatusNetworkFailure;
       
  1836 
       
  1837                 additionalInfo.iAdditionalInfo.Append( aIsiMessage.Get8bit(
       
  1838                     sbStartOffset + SS_GSM_MM_RELEASED_OFFSET_CAUSE ) );
       
  1839                 break;
       
  1840                 }
       
  1841             default:
       
  1842                 {
       
  1843                 // unknown error sub block
       
  1844                 additionalInfo.iAdditionalInfo.Append( 0x00 );
       
  1845                 break;
       
  1846                 }
       
  1847             }
       
  1848         TFLOGSTRING2("TSY: CMmCustomMessHandler::SsServiceFailedResp: Ss Status: %d", ssStatus );
       
  1849 OstTrace1( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_SSSERVICEFAILEDRESP, "CMmCustomMessHandler::SsServiceFailedResp;Ss Status=%d", ssStatus );
       
  1850         // pack parameter: a TInt with SS status
       
  1851         dataPackage.PackData( &ssStatus );
       
  1852 
       
  1853         // To complete outstanding SsRequestCompleteNotification
       
  1854         iMessageRouter->Complete(
       
  1855             ECustomNotifySsRequestCompleteIPC,
       
  1856             &dataPackage,
       
  1857             KErrNone );
       
  1858 
       
  1859         TFLOGSTRING2("TSY: CMmCustomMessHandler::SsServiceFailedResp: SB ID: 0x%x",subBlockId );
       
  1860 OstTraceExt1( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_SSSERVICEFAILEDRESP, "CMmCustomMessHandler::SsServiceFailedResp;subBlockId=%hhx", subBlockId );
       
  1861         // pack parameter: pointer to RMmCustomAPI::TSsAdditionalInfo
       
  1862         RMmCustomAPI::TSsAdditionalInfo* additionalInfoPtr = &additionalInfo;
       
  1863         dataPackage.PackData( &additionalInfoPtr );
       
  1864 
       
  1865         // To complete outstanding SsAdditionalInfoNotification
       
  1866         iMessageRouter->Complete(
       
  1867             ECustomSsAdditionalInfoNotificationIPC,
       
  1868             &dataPackage,
       
  1869             KErrNone );
       
  1870         }
       
  1871     else
       
  1872         {
       
  1873         TFLOGSTRING("TSY: CMmCustomMessHandler::SsServiceFailedResp: No subblock's");
       
  1874 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_SSSERVICEFAILEDRESP, "CMmCustomMessHandler::SsServiceFailedResp - No subblock's" );
       
  1875 
       
  1876         dataPackage.PackData( &ssStatus );
       
  1877 
       
  1878         // No subblocks, complete with default values
       
  1879         iMessageRouter->Complete( ECustomNotifySsRequestCompleteIPC,
       
  1880                               &dataPackage,
       
  1881                               KErrNone );
       
  1882         // No additional info given, no need to complete
       
  1883         // ECustomSsAdditionalInfoNotificationIPC
       
  1884         }
       
  1885     }
       
  1886 
       
  1887 // -----------------------------------------------------------------------------
       
  1888 // CMmCustomMessHandler::CallEmergencyNbrCheckReq
       
  1889 // Constructs CALL_MODEM_EMERGENCY_NBR_CHECK_REQ ISI message from input parameters
       
  1890 // and sends it through phonet. This message can be used to check if given
       
  1891 // number is an emrgency number.
       
  1892 // (other items were commented in a header).
       
  1893 // -----------------------------------------------------------------------------
       
  1894 //
       
  1895 TInt CMmCustomMessHandler::CallEmergencyNbrCheckReq
       
  1896         (
       
  1897         TUint8 aTransId,              // Transaction Id
       
  1898         RMmCustomAPI::TMobileTelNumber& aNumber,  // Telnumber
       
  1899         RMmCustomAPI::TCheckMode aCheckMode     // Check mode
       
  1900         )
       
  1901     {
       
  1902   TFLOGSTRING( "TSY: CMmCustomMessHandler::CallEmergencyNbrCheckReq" );
       
  1903 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CALLEMERGENCYNBRCHECKREQ, "CMmCustomMessHandler::CallEmergencyNbrCheckReq" );
       
  1904 
       
  1905     //save the information to match it when the response is got
       
  1906     iUsedEmergencyNbrCheckMode = aCheckMode;
       
  1907     iEmergencyNumberLength = aNumber.Length();
       
  1908 
       
  1909   // Construct CALL_MODEM_EMERG_NBR_CHECK_REQ message (1 filler +
       
  1910   // sub block count + bytes for CALL_MODEM_SB_DESTINATION_ADDRESS sub block)
       
  1911   TBuf8< 2 + SIZE_CALL_MODEM_SB_DESTINATION_ADDRESS +
       
  1912       ( RMobilePhone::KMaxMobileTelNumberSize * 2 ) > callEmergencyNbrCheckReq;
       
  1913 
       
  1914     // Filler
       
  1915     callEmergencyNbrCheckReq.Append( KCustomPadding );
       
  1916     // Sub block count
       
  1917     callEmergencyNbrCheckReq.Append( 1 );
       
  1918 
       
  1919     //create the CALL_MODEM_DESTINATION_ADDRESS subblock
       
  1920     TBuf8<SIZE_CALL_MODEM_SB_DESTINATION_ADDRESS +
       
  1921         ( RMobilePhone::KMaxMobileTelNumberSize * 2 )>
       
  1922         destinationAddressBuf( 0 );
       
  1923     TIsiSubBlock destinationAddressSb( destinationAddressBuf,
       
  1924         CALL_MODEM_SB_DESTINATION_ADDRESS, EIsiSubBlockTypeId8Len8 );
       
  1925 
       
  1926     //add the Address type, not needed because this is not checked on ISA side
       
  1927     destinationAddressBuf.Append( CALL_MODEM_NBR_PLAN_UNKNOWN );
       
  1928 
       
  1929     //add padding bytes
       
  1930     destinationAddressBuf.Append( KCustomPadding );
       
  1931     destinationAddressBuf.Append( KCustomPadding );
       
  1932 
       
  1933     //add number length
       
  1934   //lint -e{732} Warning about "loss of sign". Root cause is that
       
  1935   //TDesC::Length() returns a signed TInt
       
  1936     destinationAddressBuf.Append( aNumber.Length() );
       
  1937 
       
  1938     //add the number string
       
  1939     TIsiUtility::CopyToBigEndian( aNumber, destinationAddressBuf );
       
  1940 
       
  1941     // add the CALL_MODEM_DESTINATION_ADDRESS subblock
       
  1942     callEmergencyNbrCheckReq.Append( destinationAddressSb.CompleteSubBlock() );
       
  1943 
       
  1944     // Sending message to phonet
       
  1945     return iPhoNetSender->Send( PN_MODEM_CALL, aTransId, CALL_MODEM_EMERG_NBR_CHECK_REQ,
       
  1946       callEmergencyNbrCheckReq );
       
  1947     }
       
  1948 
       
  1949 // -----------------------------------------------------------------------------
       
  1950 // CMmCustomMessHandler::CallEmergencyNbrCheckResp
       
  1951 // Breaks a CALL_EMERGENCY_CHECK_RESP ISI message. This method
       
  1952 // provides information whether the given number was an emergency number or not.
       
  1953 // Complete CompleteCheckEmergencyNumber with status and errorValue to SOS layer
       
  1954 // (other items were commented in a header).
       
  1955 // -----------------------------------------------------------------------------
       
  1956 //
       
  1957 
       
  1958 void CMmCustomMessHandler::CallEmergencyNbrCheckResp
       
  1959         (
       
  1960         const TIsiReceiveC& aIsiMsg        // Received ISI message
       
  1961         )
       
  1962     {
       
  1963   TFLOGSTRING("TSY: CMmCustomMessHandler::CallEmergencyNbrCheckResp" );
       
  1964 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CALLEMERGENCYNBRCHECKRESP, "CMmCustomMessHandler::CallEmergencyNbrCheckResp" );
       
  1965 
       
  1966     // Get Status
       
  1967     TUint8 status( aIsiMsg.Get8bit( ISI_HEADER_SIZE +
       
  1968         CALL_MODEM_EMERG_NBR_CHECK_RESP_OFFSET_STATUS ));
       
  1969 
       
  1970   RMmCustomAPI::TMobileTelNumber telNumber;
       
  1971 
       
  1972     //Using the advance checking of the call server forces us to make sure
       
  1973     //that the call server is not is not misleading us...
       
  1974     if ( CALL_MODEM_EMERG_NBR_CHECK_PASS == status )
       
  1975         {
       
  1976         TUint sbStartOffSet( 0 );
       
  1977 
       
  1978         if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  1979           ISI_HEADER_SIZE + SIZE_CALL_MODEM_EMERG_NBR_CHECK_RESP,
       
  1980           CALL_MODEM_SB_EMERG_NUMBER, EIsiSubBlockTypeId8Len8, sbStartOffSet ) )
       
  1981             {
       
  1982             //get length of returned number (number of Unicode characters)
       
  1983             TUint8 numberLength( aIsiMsg.Get8bit( sbStartOffSet +
       
  1984                 CALL_MODEM_SB_EMERG_NUMBER_OFFSET_ADDRLEN ));
       
  1985 
       
  1986              //copy 8-bit number to the 16-bit target using correct endianess
       
  1987              //ISI message contains one Unicode digit in two bytes ==> multiply length by 2
       
  1988              TIsiUtility::CopyFromBigEndian( aIsiMsg.GetData( sbStartOffSet +
       
  1989                  CALL_MODEM_SB_EMERG_NUMBER_OFFSET_ADDR,
       
  1990                  numberLength * 2 ), telNumber );
       
  1991 
       
  1992             //Check that the Number length returned by call server doesn't
       
  1993             //differ from original phone number.
       
  1994             //Call server uses advanced mode while checking
       
  1995             //numbers. For example 2112 is valid emergency number for
       
  1996             //call server -> server returns number 112. However 2112 is not
       
  1997             //emergency number.
       
  1998             if ( RMmCustomAPI::EEmerNumberCheckNormal ==
       
  1999               iUsedEmergencyNbrCheckMode && numberLength !=
       
  2000               iEmergencyNumberLength )
       
  2001                 {
       
  2002                 status = CALL_MODEM_EMERG_NBR_CHECK_FAIL;
       
  2003                 }
       
  2004             }
       
  2005         else
       
  2006             {
       
  2007             //acording to call server feature description, in case of succesful
       
  2008             //checking the sub block should be present. Therefore we consider
       
  2009             //this case as a failure.
       
  2010             status = CALL_MODEM_EMERG_NBR_CHECK_FAIL;
       
  2011             }
       
  2012         }
       
  2013 
       
  2014   // map to result: failed is 0, successful is ptr to number
       
  2015   RMmCustomAPI::TMobileTelNumber* result =
       
  2016     ( ( CALL_MODEM_EMERG_NBR_CHECK_FAIL == status ) ?
       
  2017       0 : &telNumber );
       
  2018 
       
  2019   // packed parameter: TBool result
       
  2020   CMmDataPackage dataPackage;
       
  2021   dataPackage.PackData( &result );
       
  2022   
       
  2023   TFLOGSTRING2( "TSY: TSY: CMmCustomMessHandler::CallEmergencyNbrCheckResp status: %d", status);
       
  2024   TFLOGSTRING2( "TSY: TSY: CMmCustomMessHandler::CallEmergencyNbrCheckResp emergency number: %S", &telNumber);
       
  2025     //we complete with KErrNone as there is always a value to return
       
  2026   iMessageRouter->Complete( ECustomCheckEmergencyNumberIPC, &dataPackage,
       
  2027     KErrNone );
       
  2028 
       
  2029     }
       
  2030 
       
  2031 // -----------------------------------------------------------------------------
       
  2032 // CMmCustomMessHandler::UiccOperatorReq
       
  2033 // Read operator name from UICC
       
  2034 // -----------------------------------------------------------------------------
       
  2035 //
       
  2036 TInt CMmCustomMessHandler::UiccOperatorReq()
       
  2037     {
       
  2038 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccOperatorReq" );
       
  2039 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCOPERATORREQ, "CMmCustomMessHandler::UiccOperatorReq" );
       
  2040 
       
  2041     // Set parameters for UICC_APPL_CMD_REQ message
       
  2042     TUiccReadTransparent params;
       
  2043     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  2044     params.trId = ETrIdReadOperatorNameCustom;
       
  2045     params.dataOffset = 0;
       
  2046     params.dataAmount = 0;
       
  2047     params.fileId = KElemFileOperatorName;
       
  2048     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  2049     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
  2050 
       
  2051     // File id path
       
  2052     params.filePath.Append( KMasterFileId >> 8 );
       
  2053     params.filePath.Append( KMasterFileId );
       
  2054     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
  2055 
       
  2056     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  2057     }
       
  2058 
       
  2059 // -----------------------------------------------------------------------------
       
  2060 // CMmCustomMessHandler::UiccOperatorResp
       
  2061 // Complete operator name
       
  2062 // -----------------------------------------------------------------------------
       
  2063 //
       
  2064 void CMmCustomMessHandler::UiccOperatorResp(
       
  2065     TInt aStatus,
       
  2066     const TDesC8& aFileData )
       
  2067     {
       
  2068 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccOperatorResp" );
       
  2069 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCOPERATORRESP, "CMmCustomMessHandler::UiccOperatorResp" );
       
  2070 
       
  2071     TInt errorValue( KErrGeneral );
       
  2072 
       
  2073     // Network provider name
       
  2074     TBuf<KNwProviderNameLength> name;
       
  2075 
       
  2076     if ( KErrNone == aStatus )
       
  2077         {
       
  2078         errorValue = KErrNone;
       
  2079         name.Copy( aFileData );
       
  2080         }
       
  2081 
       
  2082     // Packed parameter: TDes* (network provider name)
       
  2083     CMmDataPackage dataPackage;
       
  2084     TDes* namePtr( &name );
       
  2085     dataPackage.PackData( &namePtr );
       
  2086 
       
  2087     iMessageRouter->Complete(
       
  2088         ECustomGetNetworkProviderNameIPC,
       
  2089         &dataPackage,
       
  2090         errorValue );
       
  2091     }
       
  2092 
       
  2093 // -----------------------------------------------------------------------------
       
  2094 // CMmCustomMessHandler::SsGsmUssdSendReq
       
  2095 // Constructs SS_GSM_USSD_SEND_REQ ISI message from input parameters
       
  2096 // and sends it through phonet.
       
  2097 // This message can be used only to cancel ussd session.
       
  2098 // (other items were commented in a header).
       
  2099 // -----------------------------------------------------------------------------
       
  2100 //
       
  2101 TInt CMmCustomMessHandler::SsGsmUssdSendReq
       
  2102         (
       
  2103         TUint8 aTransId             //transaction Id
       
  2104         )
       
  2105     {
       
  2106     TFLOGSTRING("TSY: CMmCustomMessHandler::SsGsmUssdSendReq" );
       
  2107 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_SSGSMUSSDSENDREQ, "CMmCustomMessHandler::SsGsmUssdSendReq" );
       
  2108 
       
  2109     // create buffer for isi msg data
       
  2110     TBuf8<2> data;
       
  2111     data.Append( SS_GSM_USSD_END );
       
  2112     //number of sub blocks
       
  2113     data.Append( 0 );
       
  2114 
       
  2115     // Message sent via Phonet and return
       
  2116     return iPhoNetSender->Send( PN_SS, aTransId, SS_GSM_USSD_SEND_REQ, data  );
       
  2117 
       
  2118     }
       
  2119 
       
  2120 
       
  2121 // -----------------------------------------------------------------------------
       
  2122 // CMmCustomMessHandler::SsGsmUssdSendResp
       
  2123 // Breaks a SS_USSD_SEND_RESP ISI message.
       
  2124 // This method gets USSD type information from message and completes cancelling
       
  2125 // of ussd session. Complete CancelUssdSession with KErrNone to SOS layer.
       
  2126 // (other items were commented in a header).
       
  2127 // -----------------------------------------------------------------------------
       
  2128 //
       
  2129 void CMmCustomMessHandler::SsGsmUssdSendResp
       
  2130         (
       
  2131         const TIsiReceiveC& aIsiMessage //received ISI message
       
  2132         )
       
  2133     {
       
  2134     TFLOGSTRING("TSY: CMmCustomMessHandler::SsGsmUssdSendResp" );
       
  2135 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_SSGSMUSSDSENDRESP, "CMmCustomMessHandler::SsGsmUssdSendResp" );
       
  2136 
       
  2137 
       
  2138     TUint ussdType( aIsiMessage.Get8bit(
       
  2139                         ISI_HEADER_SIZE +
       
  2140                         SS_GSM_USSD_SEND_RESP_OFFSET_USSDTYPE ) );
       
  2141 
       
  2142     if ( SS_GSM_USSD_END == ussdType )
       
  2143         {
       
  2144         // no packed parameters for completion
       
  2145         iMessageRouter->Complete( ECustomCancelUssdSessionIPC, KErrNone );
       
  2146         }
       
  2147 
       
  2148     }
       
  2149 
       
  2150 // -----------------------------------------------------------------------------
       
  2151 // CMmCustomMessHandler::Match
       
  2152 // This method can be checks if two TCiphListEntry entries are same.
       
  2153 // (other items were commented in a header).
       
  2154 // -----------------------------------------------------------------------------
       
  2155 //
       
  2156 TBool CMmCustomMessHandler::Match
       
  2157         (
       
  2158         const TCiphListEntry& aArg1, //first argument
       
  2159         const TCiphListEntry& aArg2  //second argument
       
  2160         )
       
  2161     {
       
  2162     TFLOGSTRING("TSY: CMmCustomMessHandler::Match.\n" );
       
  2163 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_MATCH, "CMmCustomMessHandler::Match" );
       
  2164 
       
  2165     TBool ret ( EFalse );
       
  2166 
       
  2167     //we are interested only in the traId value
       
  2168     if ( aArg1.iTraId == aArg2.iTraId )
       
  2169         {
       
  2170         ret = ETrue;
       
  2171         }
       
  2172 
       
  2173     return ret;
       
  2174     }
       
  2175 
       
  2176 // -----------------------------------------------------------------------------
       
  2177 // CMmCustomMessHandler::NetModemRegStatusGetReq
       
  2178 // Constructs NET_MODEM_REG_STATUS_GET_REQ ISI message from input parameters
       
  2179 // and sends it through phonet.
       
  2180 // (other items were commented in a header).
       
  2181 // -----------------------------------------------------------------------------
       
  2182 //
       
  2183 TInt CMmCustomMessHandler::NetModemRegStatusGetReq
       
  2184         (
       
  2185         const TUint8 aTransactionId
       
  2186         )
       
  2187     {
       
  2188 TFLOGSTRING("TSY: CMmCustomMessHandler::NetModemRegStatusGetReq." );
       
  2189 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETMODEMREGSTATUSGETREQ, "CMmCustomMessHandler::NetModemRegStatusGetReq" );
       
  2190 
       
  2191     // Data length buffer is 2.
       
  2192     TBuf8<2> data;
       
  2193     data.Append( aTransactionId );
       
  2194     data.Append( NET_MODEM_REG_STATUS_GET_REQ );
       
  2195 
       
  2196     TIsiSend isimsg( iPhoNetSender->SendBufferDes() );
       
  2197     isimsg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_MODEM_NETWORK );
       
  2198     isimsg.CopyData( ISI_HEADER_SIZE, data );
       
  2199 
       
  2200     return( iPhoNetSender->Send( isimsg.Complete() ) );
       
  2201     }
       
  2202 
       
  2203 // -----------------------------------------------------------------------------
       
  2204 // CMmCustomMessHandler::NetModemRegStatusGetResp
       
  2205 // NET_MODEM_REG_STATUS_GET_RESP message is handled in queue functionality
       
  2206 // in cmmnetmesshandler/cmmnetoperatornamehandler and will be completed
       
  2207 // there after handling.
       
  2208 // This method check if ECID info needs to be updated.
       
  2209 // -----------------------------------------------------------------------------
       
  2210 //
       
  2211 void CMmCustomMessHandler::NetModemRegStatusGetResp(
       
  2212        const TIsiReceiveC& aIsiMsg )
       
  2213     {
       
  2214 TFLOGSTRING("TSY: CMmCustomMessHandler::NetModemRegStatusGetResp" );
       
  2215 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETMODEMREGSTATUSGETRESP, "CMmCustomMessHandler::NetModemRegStatusGetResp" );
       
  2216 
       
  2217     // Get the success code.
       
  2218     TUint8 successCode( aIsiMsg.Get8bit(
       
  2219         ISI_HEADER_SIZE +
       
  2220         NET_MODEM_REG_STATUS_GET_RESP_OFFSET_SUCCESSCODE ) );
       
  2221 
       
  2222     if ( NET_CAUSE_OK == successCode )
       
  2223         {
       
  2224         // Check if ECID info needs to be updated.
       
  2225         CheckECIDInfo( aIsiMsg );
       
  2226         }
       
  2227     }
       
  2228 
       
  2229 // -----------------------------------------------------------------------------
       
  2230 // CMmCustomMessHandler::CallGsmNotificationInd
       
  2231 // This method breaks the CALL_MODEM_NOTIFICATION_IND ISI message.
       
  2232 // Complete: ECustomNotifySsNetworkEventIPC to SOS layer.
       
  2233 // If CALL_MODEM_SB_ALERTING_INFO sub block exist ECustomGetRemoteAlertingToneStatusIPC
       
  2234 // is completed to SOS layer.
       
  2235 // (other items were commented in a header).
       
  2236 // -----------------------------------------------------------------------------
       
  2237 //
       
  2238 void CMmCustomMessHandler::CallGsmNotificationInd
       
  2239         (
       
  2240         const TIsiReceiveC& aIsiMsg // received ISI message
       
  2241         )
       
  2242     {
       
  2243     TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmNotificationInd");
       
  2244 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CALLGSMNOTIFICATIONIND, "CMmCustomMessHandler::CallGsmNotificationInd" );
       
  2245 
       
  2246     TInt ret( KErrNone );
       
  2247 
       
  2248     // For packaging
       
  2249     CMmDataPackage dataPackage;
       
  2250 
       
  2251     RMmCustomAPI::TSsTypeAndMode ssTypeAndMode;
       
  2252     RMmCustomAPI::TSsInfo ssInfo;
       
  2253 
       
  2254     // Initialize the default values
       
  2255     ssInfo.iCallHold = RMmCustomAPI::ESsHoldNotActive;
       
  2256     ssInfo.iEctCallState = RMmCustomAPI::ESsEctNotActive;
       
  2257     ssInfo.iCallWait = EFalse;
       
  2258     ssInfo.iConfInd = EFalse;
       
  2259     ssInfo.iClirSuppReject = EFalse;
       
  2260     ssInfo.iForwMode = RMmCustomAPI::EForwNotActive;
       
  2261     ssInfo.iCugIndex = CALL_MODEM_CUG_DEFAULT;
       
  2262     ssInfo.iChoice = RMmCustomAPI::ESsChoiceUnknown;
       
  2263     ssInfo.iRemoteAddress.FillZ();
       
  2264     ssTypeAndMode.iSsMode = RMmCustomAPI::ESsModeUnknown;
       
  2265     ssTypeAndMode.iSsType = RMmCustomAPI::ESsAllSs;
       
  2266 
       
  2267     TUint sbStartOffSet( 0 );
       
  2268 
       
  2269     // Get CALL_MODEM_SB_SS_CODE sub block
       
  2270     if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  2271         ISI_HEADER_SIZE + SIZE_CALL_MODEM_NOTIFICATION_IND,
       
  2272         CALL_MODEM_SB_SS_CODE,
       
  2273         EIsiSubBlockTypeId8Len8,
       
  2274         sbStartOffSet ) )
       
  2275         {
       
  2276         TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmNotificationInd,\
       
  2277             - CALL_MODEM_SB_SS_CODE sub block founded");
       
  2278 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_CALLGSMNOTIFICATIONIND, "CMmCustomMessHandler::CallGsmNotificationInd, CALL_MODEM_SB_SS_CODE sub block found" );
       
  2279 
       
  2280         TUint16 ssCode( aIsiMsg.Get16bit(
       
  2281             sbStartOffSet + CALL_MODEM_SB_SS_CODE_OFFSET_MMISSCODE ) );
       
  2282 
       
  2283         switch ( ssCode )
       
  2284             {
       
  2285             case CALL_MODEM_SSC_ALL_FWDS:
       
  2286             case CALL_MODEM_SSC_CFU:
       
  2287             case CALL_MODEM_SSC_CFB:
       
  2288             case CALL_MODEM_SSC_CFNRY:
       
  2289             case CALL_MODEM_SSC_CFGNC:
       
  2290             case CALL_MODEM_SSC_ALL_COND_FWD:
       
  2291                 {
       
  2292                 HandleForwarding( ssCode, aIsiMsg, ssTypeAndMode );
       
  2293                 break;
       
  2294                 }
       
  2295             case CALL_MODEM_SSC_OUTGOING_BARR_SERV:
       
  2296             case CALL_MODEM_SSC_INCOMING_BARR_SERV:
       
  2297                 {
       
  2298                 HandleBarring( ssCode, aIsiMsg, ssTypeAndMode );
       
  2299                 break;
       
  2300                 }
       
  2301             case CALL_MODEM_SSC_CALL_WAITING:
       
  2302                 {
       
  2303                 ssTypeAndMode.iSsType = RMmCustomAPI::ESsCallWaiting;
       
  2304                 break;
       
  2305                 }
       
  2306             case CALL_MODEM_SSC_CLIP:
       
  2307                 {
       
  2308                 ssTypeAndMode.iSsType = RMmCustomAPI::ESsClip;
       
  2309                 break;
       
  2310                 }
       
  2311             case CALL_MODEM_SSC_CLIR:
       
  2312                 {
       
  2313                 ssTypeAndMode.iSsType = RMmCustomAPI::ESsClir;
       
  2314                 break;
       
  2315                 }
       
  2316             case CALL_MODEM_SSC_COLP:
       
  2317                 {
       
  2318                 ssTypeAndMode.iSsType = RMmCustomAPI::ESsColp;
       
  2319                 break;
       
  2320                 }
       
  2321             case CALL_MODEM_SSC_COLR:
       
  2322                 {
       
  2323                 ssTypeAndMode.iSsType = RMmCustomAPI::ESsColr;
       
  2324                 break;
       
  2325                 }
       
  2326             default:
       
  2327                 {
       
  2328                 TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmNotificationInd,\
       
  2329                     switch ssCode - default.");
       
  2330 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_CALLGSMNOTIFICATIONIND, "CMmCustomMessHandler::CallGsmNotificationInd, switch ssCode - default" );
       
  2331                 break;
       
  2332                 }
       
  2333             }
       
  2334         }
       
  2335 
       
  2336     // Get CALL_GSM_SS_NOTIFY sub block
       
  2337     if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  2338         ISI_HEADER_SIZE + SIZE_CALL_MODEM_NOTIFICATION_IND,
       
  2339         CALL_MODEM_SB_SS_NOTIFY,
       
  2340         EIsiSubBlockTypeId8Len8,
       
  2341         sbStartOffSet ) )
       
  2342         {
       
  2343         TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmNotificationInd,\
       
  2344             - CALL_MODEM_SB_SS_NOTIFY sub block founded");
       
  2345 OstTrace0( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_CALLGSMNOTIFICATIONIND, "CMmCustomMessHandler::CallGsmNotificationInd, CALL_MODEM_SB_SS_NOTIFY sub block found" );
       
  2346 
       
  2347         // Get the SsNotifyIndictor
       
  2348         TUint8 ssNotify( aIsiMsg.Get8bit(
       
  2349             sbStartOffSet + CALL_MODEM_SB_SS_NOTIFY_OFFSET_SSNOTIFICATION ) );
       
  2350 
       
  2351         // Mask the value
       
  2352         // Incoming call is a forwarded call
       
  2353         if ( CALL_MODEM_SSN_INCOMING_IS_FWD == ssNotify )
       
  2354             {
       
  2355             ssInfo.iForwMode = RMmCustomAPI::ESsIncCallIsForw;
       
  2356             }
       
  2357         // Incoming call has been forwarded to C
       
  2358         else if ( CALL_MODEM_SSN_INCOMING_FWD == ssNotify )
       
  2359             {
       
  2360             ssInfo.iForwMode = RMmCustomAPI::ESsIncCallForwToC;
       
  2361             }
       
  2362         //Outgoing call is fowarded to C
       
  2363         else if ( CALL_MODEM_SSN_OUTGOING_FWD == ssNotify )
       
  2364             {
       
  2365             ssInfo.iForwMode = RMmCustomAPI::ESsOutCallForwToC;
       
  2366             }
       
  2367         // No else
       
  2368         }
       
  2369 
       
  2370     // Get CALL_MODEM_SB_SS_NOTIFY_INDICATOR sub block
       
  2371     if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  2372         ISI_HEADER_SIZE + SIZE_CALL_MODEM_NOTIFICATION_IND,
       
  2373         CALL_MODEM_SB_SS_NOTIFY_INDICATOR,
       
  2374         EIsiSubBlockTypeId8Len8,
       
  2375         sbStartOffSet ) )
       
  2376         {
       
  2377         TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmNotificationInd,\
       
  2378             - CALL_MODEM_SB_SS_NOTIFY_INDICATOR sub block founded");
       
  2379 OstTrace0( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_CALLGSMNOTIFICATIONIND, "CMmCustomMessHandler::CallGsmNotificationInd, CALL_MODEM_SB_SS_NOTIFY_INDICATOR sub block found" );
       
  2380 
       
  2381         // Get the SsNotifyIndictor
       
  2382         TUint8 ssNotifyIndicator( aIsiMsg.Get8bit( sbStartOffSet +
       
  2383             CALL_MODEM_SB_SS_NOTIFY_INDICATOR_OFFSET_SSINDICATOR ) );
       
  2384 
       
  2385         // Mask the value of the Indicator
       
  2386         if ( CALL_MODEM_SSI_CALL_IS_WAITING == ssNotifyIndicator ) // Call waiting
       
  2387             {
       
  2388             ssInfo.iCallWait = ETrue;
       
  2389             }
       
  2390         else if ( CALL_MODEM_SSI_MPTY == ssNotifyIndicator ) // Conference call
       
  2391             {
       
  2392             ssInfo.iConfInd = ETrue;
       
  2393             }
       
  2394         // CLIR suppresion rejected
       
  2395         else if ( CALL_MODEM_SSI_CLIR_SUPPR_REJ == ssNotifyIndicator )
       
  2396             {
       
  2397             ssInfo.iClirSuppReject = ETrue;
       
  2398             }
       
  2399         // No else
       
  2400         }
       
  2401 
       
  2402     // Get CALL_MODEM_SB_SS_HOLD_INDICATOR sub block
       
  2403     if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  2404         ISI_HEADER_SIZE + SIZE_CALL_MODEM_NOTIFICATION_IND,
       
  2405         CALL_MODEM_SB_SS_HOLD_INDICATOR,
       
  2406         EIsiSubBlockTypeId8Len8,
       
  2407         sbStartOffSet ) )
       
  2408         {
       
  2409         TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmNotificationInd,\
       
  2410             - CALL_MODEM_SB_SS_HOLD_INDICATOR sub block founded");
       
  2411 OstTrace0( TRACE_NORMAL, DUP6_CMMCUSTOMMESSHANDLER_CALLGSMNOTIFICATIONIND, "CMmCustomMessHandler::CallGsmNotificationInd, CALL_MODEM_SB_SS_HOLD_INDICATOR sub block found" );
       
  2412 
       
  2413         // Get the ectIndictor
       
  2414         TUint8 holdIndicator( aIsiMsg.Get8bit( sbStartOffSet +
       
  2415             CALL_MODEM_SB_SS_HOLD_INDICATOR_OFFSET_SSHOLDINDICATOR ) );
       
  2416 
       
  2417         // If hold indicator is 1
       
  2418         if ( holdIndicator )
       
  2419             {
       
  2420             ssInfo.iCallHold = RMmCustomAPI::ESsHoldActive;
       
  2421             }
       
  2422         else // hold indicator is 0
       
  2423             {
       
  2424             ssInfo.iCallHold = RMmCustomAPI::ESsHoldResume;
       
  2425             }
       
  2426         }
       
  2427 
       
  2428     // Get CALL_MODEM_SB_CUG_INFO sub block
       
  2429     if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  2430         ISI_HEADER_SIZE + SIZE_CALL_MODEM_NOTIFICATION_IND,
       
  2431         CALL_MODEM_SB_CUG_INFO,
       
  2432         EIsiSubBlockTypeId8Len8,
       
  2433         sbStartOffSet ) )
       
  2434         {
       
  2435         TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmNotificationInd,\
       
  2436             - CALL_MODEM_SB_CUG_INFO sub block founded");
       
  2437 OstTrace0( TRACE_NORMAL, DUP7_CMMCUSTOMMESSHANDLER_CALLGSMNOTIFICATIONIND, "CMmCustomMessHandler::CallGsmNotificationInd, CALL_MODEM_SB_CUG_INFO sub block found" );
       
  2438 
       
  2439         // Get the CUG index
       
  2440         ssInfo.iCugIndex = aIsiMsg.Get16bit(
       
  2441             sbStartOffSet + CALL_MODEM_SB_CUG_INFO_OFFSET_CUGIND );
       
  2442         }
       
  2443 
       
  2444     // Get CALL_MODEM_SB_SS_ECT_INDICATOR sub block
       
  2445     if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  2446         ISI_HEADER_SIZE + SIZE_CALL_MODEM_NOTIFICATION_IND,
       
  2447         CALL_MODEM_SB_SS_ECT_INDICATOR,
       
  2448         EIsiSubBlockTypeId8Len8,
       
  2449         sbStartOffSet ) )
       
  2450         {
       
  2451         TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmNotificationInd,\
       
  2452             - CALL_MODEM_SB_SS_ECT_INDICATOR sub block founded");
       
  2453 OstTrace0( TRACE_NORMAL, DUP8_CMMCUSTOMMESSHANDLER_CALLGSMNOTIFICATIONIND, "CMmCustomMessHandler::CallGsmNotificationInd, CALL_MODEM_SB_SS_ECT_INDICATOR sub block found" );
       
  2454 
       
  2455         // Get the ectIndictor
       
  2456         TUint8 ectIndicator( aIsiMsg.Get8bit(
       
  2457             sbStartOffSet + CALL_MODEM_SB_SS_ECT_INDICATOR_OFFSET_SSECTINDICATOR ) );
       
  2458 
       
  2459         // If ect is 1
       
  2460         if ( ectIndicator )
       
  2461             {
       
  2462             ssInfo.iEctCallState = RMmCustomAPI::ESsEctActive;
       
  2463             }
       
  2464         else // ect is 0
       
  2465             {
       
  2466             ssInfo.iEctCallState = RMmCustomAPI::ESsEctAlerting;
       
  2467             }
       
  2468         }
       
  2469 
       
  2470     // Get CALL_MODEM_SB_REMOTE_ADDRESS sub block
       
  2471     if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  2472         ISI_HEADER_SIZE + SIZE_CALL_MODEM_NOTIFICATION_IND,
       
  2473         CALL_MODEM_SB_REMOTE_ADDRESS,
       
  2474         EIsiSubBlockTypeId8Len8,
       
  2475         sbStartOffSet ) )
       
  2476         {
       
  2477         TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmNotificationInd,\
       
  2478             - CALL_MODEM_SB_REMOTE_ADDRESS sub block founded");
       
  2479 OstTrace0( TRACE_NORMAL, DUP9_CMMCUSTOMMESSHANDLER_CALLGSMNOTIFICATIONIND, "CMmCustomMessHandler::CallGsmNotificationInd, CALL_MODEM_SB_REMOTE_ADDRESS sub block found" );
       
  2480 
       
  2481         // Get the presentation
       
  2482 
       
  2483         TUint8 presentationIndicator( aIsiMsg.Get8bit(
       
  2484             sbStartOffSet + CALL_MODEM_SB_REMOTE_ADDRESS_OFFSET_PRESENTATION ) );
       
  2485         // Mask with 0110 0000 to get bits 6-7
       
  2486         presentationIndicator &= 0x60;
       
  2487 
       
  2488         switch ( presentationIndicator )
       
  2489             {
       
  2490             case CALL_MODEM_PRESENTATION_ALLOWED:
       
  2491                 {
       
  2492                 ssInfo.iChoice = RMmCustomAPI::ESsPresAllowed;
       
  2493                 break;
       
  2494                 }
       
  2495             case CALL_MODEM_PRESENTATION_RESTRICTED:
       
  2496                 {
       
  2497                 ssInfo.iChoice = RMmCustomAPI::ESsPresRestricted;
       
  2498                 break;
       
  2499                 }
       
  2500             case CALL_MODEM_PRESENTATION_UNAVAILABLE:
       
  2501                 {
       
  2502                 ssInfo.iChoice = RMmCustomAPI::ESsNumberNotAvailable;
       
  2503                 break;
       
  2504                 }
       
  2505             default:
       
  2506                 {
       
  2507                 TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmNotificationInd,\
       
  2508                     - CALL_MODEM_SB_REMOTE_ADDRESS sub block\
       
  2509                     - switch presentationIndicator - default.");
       
  2510 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_CALLGSMNOTIFICATIONIND, "CMmCustomMessHandler::CallGsmNotificationInd, switch presentationIndicator - default" );
       
  2511                 // The variable already has a default value
       
  2512                 break;
       
  2513                 }
       
  2514             }
       
  2515 
       
  2516         // Copy the number with rigth endianess
       
  2517         TUint8 remoteAddressLength( aIsiMsg.Get8bit(
       
  2518             sbStartOffSet + CALL_MODEM_SB_REMOTE_ADDRESS_OFFSET_ADDRLEN ) );
       
  2519 
       
  2520         // Copy 8-bit name to the 16-bit target using correct endianess
       
  2521         TIsiUtility::CopyFromBigEndian( aIsiMsg.GetData(
       
  2522             sbStartOffSet + CALL_MODEM_SB_REMOTE_ADDRESS_OFFSET_ADDR,
       
  2523             remoteAddressLength ),
       
  2524             ssInfo.iRemoteAddress );
       
  2525         }
       
  2526 
       
  2527     // Get CALL_MODEM_SB_ALERTING_INFO sub block
       
  2528     if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  2529         ISI_HEADER_SIZE + SIZE_CALL_MODEM_NOTIFICATION_IND,
       
  2530         CALL_MODEM_SB_ALERTING_INFO,
       
  2531         EIsiSubBlockTypeId8Len8,
       
  2532         sbStartOffSet ) )
       
  2533         {
       
  2534         TFLOGSTRING("TSY: CMmCustomMessHandler::CallGsmNotificationInd,\
       
  2535             - CALL_MODEM_SB_ALERTING_INFO sub block founded");
       
  2536 OstTrace0( TRACE_NORMAL, DUP10_CMMCUSTOMMESSHANDLER_CALLGSMNOTIFICATIONIND, "CMmCustomMessHandler::CallGsmNotificationInd, CALL_MODEM_SB_ALERTING_INFO sub block found" );
       
  2537 
       
  2538         TBool playRemoteAlertToneLocally( EFalse );
       
  2539 
       
  2540         // Get alerting info
       
  2541         TUint8 callAlertingInfo( aIsiMsg.Get8bit(
       
  2542             sbStartOffSet + CALL_MODEM_SB_ALERTING_INFO_OFFSET_ALERTINGINFO ) );
       
  2543 
       
  2544         // If LSB is "1" inform that remote alerting tone
       
  2545         // should be generated locally.
       
  2546         if ( callAlertingInfo & 0x01 )
       
  2547             {
       
  2548             playRemoteAlertToneLocally = ETrue;
       
  2549             }
       
  2550 
       
  2551         // Complete remote alerting tone notification
       
  2552         // Parameter for SOS layer: a TBool playRemoteAlertToneLocally
       
  2553         dataPackage.PackData( &playRemoteAlertToneLocally );
       
  2554         iMessageRouter->Complete( ECustomGetRemoteAlertingToneStatusIPC,
       
  2555             &dataPackage,
       
  2556             KErrNone );
       
  2557         }
       
  2558 
       
  2559     // Complete SsNetworkEvent notification
       
  2560     // Pack parameter: a RMmCustomAPI::TSsTypeAndMode and
       
  2561     // a RMmCustomAPI::TSsInfo
       
  2562     dataPackage.PackData( &ssTypeAndMode, &ssInfo );
       
  2563     iMessageRouter->Complete( ECustomNotifySsNetworkEventIPC,
       
  2564         &dataPackage,
       
  2565         ret );
       
  2566     }
       
  2567 
       
  2568 // -----------------------------------------------------------------------------
       
  2569 // CMmCustomMessHandler::HandleForwarding
       
  2570 // Breaks a CALL_MODEM_NOTIFICATION_IND ISI message.
       
  2571 // Gets forwardfing related information from message and sets it in
       
  2572 // aSsTypeAndMode for further completion in the method CallGsmNotificationIndL2
       
  2573 // to SOS layer.
       
  2574 // (other items were commented in a header).
       
  2575 // -----------------------------------------------------------------------------
       
  2576 //
       
  2577 void CMmCustomMessHandler::HandleForwarding
       
  2578         (
       
  2579         TUint16 aSsCode, //SS code
       
  2580         const TIsiReceiveC& aIsiMsg,  //Isi message
       
  2581         RMmCustomAPI::TSsTypeAndMode& aSsTypeAndMode //ss type and mode
       
  2582         ) const
       
  2583     {
       
  2584     TFLOGSTRING("TSY: CMmCustomMessHandler::HandleForwarding.\n" );
       
  2585 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_HANDLEFORWARDING, "CMmCustomMessHandler::HandleForwarding" );
       
  2586 
       
  2587     //identify the kind of forwarding
       
  2588     switch ( aSsCode )
       
  2589         {
       
  2590         case CALL_MODEM_SSC_ALL_FWDS:
       
  2591             aSsTypeAndMode.iSsType = RMmCustomAPI::ESsAllForwardings;
       
  2592             break;
       
  2593         case CALL_MODEM_SSC_CFU:
       
  2594             aSsTypeAndMode.iSsType = RMmCustomAPI::ESsForwUncond;
       
  2595             break;
       
  2596         case CALL_MODEM_SSC_CFB:
       
  2597             aSsTypeAndMode.iSsType = RMmCustomAPI::ESsForwBusy;
       
  2598             break;
       
  2599         case CALL_MODEM_SSC_CFNRY:
       
  2600             aSsTypeAndMode.iSsType = RMmCustomAPI::ESsForwNoReply;
       
  2601             break;
       
  2602         case CALL_MODEM_SSC_CFGNC:
       
  2603             aSsTypeAndMode.iSsType = RMmCustomAPI::ESsForwNoReach;
       
  2604             break;
       
  2605         case CALL_MODEM_SSC_ALL_COND_FWD:
       
  2606             aSsTypeAndMode.iSsType = RMmCustomAPI::ESsAllCondForwardings;
       
  2607             break;
       
  2608         default:
       
  2609             TFLOGSTRING("TSY: CMmCustomMessHandler::HandleForwarding, switch aSsCode - default.\n" );
       
  2610 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_HANDLEFORWARDING, "CMmCustomMessHandler::HandleForwarding, switch aSsCode - default" );
       
  2611             //this case is imposible, added due code convention
       
  2612             break;
       
  2613         }
       
  2614 
       
  2615     TUint sbStartOffSet( 0 );
       
  2616 
       
  2617     //get call gsm ss status sub block
       
  2618     if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  2619         ISI_HEADER_SIZE + SIZE_CALL_MODEM_NOTIFICATION_IND,
       
  2620         CALL_MODEM_SB_SS_STATUS, EIsiSubBlockTypeId8Len8, sbStartOffSet ) )
       
  2621         {
       
  2622         //get the ss status
       
  2623         TUint8 ssStatus ( aIsiMsg.Get8bit( sbStartOffSet +
       
  2624             CALL_MODEM_SB_SS_STATUS_OFFSET_SSSTATUS ) );
       
  2625 
       
  2626         //set the right status for the bit configuration of ssStatus
       
  2627         if ( CALL_MODEM_SS_STATUS_ACTIVE & ssStatus ) //if active is present
       
  2628             {
       
  2629             aSsTypeAndMode.iSsMode = RMmCustomAPI::ESsModeActive;
       
  2630             }
       
  2631         // if quiescent is present
       
  2632         else if ( CALL_MODEM_SS_STATUS_QUIESCENT & ssStatus )
       
  2633             {
       
  2634             //if registered and provisioned, and not active or quiescent
       
  2635             aSsTypeAndMode.iSsMode = RMmCustomAPI::ESsModeNotAvailable;
       
  2636             }
       
  2637         //if registered and provisioned, and not active or quiescent
       
  2638         else if ( ( CALL_MODEM_SS_STATUS_REGISTERED | CALL_MODEM_SS_STATUS_PROVISIONED )
       
  2639           == ssStatus )
       
  2640             {
       
  2641             aSsTypeAndMode.iSsMode = RMmCustomAPI::ESsModeNotActive;
       
  2642             }
       
  2643         else if ( CALL_MODEM_SS_STATUS_PROVISIONED == ssStatus ) //only provisioned
       
  2644             {
       
  2645             aSsTypeAndMode.iSsMode = RMmCustomAPI::ESsModeNotRegistered;
       
  2646             }
       
  2647         else //not provisioned
       
  2648             {
       
  2649             aSsTypeAndMode.iSsMode = RMmCustomAPI::ESsModeNotProvisioned;
       
  2650             }
       
  2651         }
       
  2652     }
       
  2653 
       
  2654 // -----------------------------------------------------------------------------
       
  2655 // CMmCustomMessHandler::HandleBarring
       
  2656 // Breaks a CALL_MODEM_NOTIFICATION_IND ISI message.
       
  2657 // Gets barring related information from message and sets it in
       
  2658 // aSsTypeAndMode for further completion in the method CallGsmNotificationIndL2.
       
  2659 // to SOS layer.
       
  2660 // (other items were commented in a header).
       
  2661 // -----------------------------------------------------------------------------
       
  2662 //
       
  2663 void CMmCustomMessHandler::HandleBarring
       
  2664         (
       
  2665         TUint16 aSsCode,       //SS code
       
  2666         const TIsiReceiveC& aIsiMsg,  //ISI message
       
  2667         RMmCustomAPI::TSsTypeAndMode& aSsTypeAndMode //Ss type and mode
       
  2668         ) const
       
  2669     {
       
  2670     TFLOGSTRING("TSY: CMmCustomMessHandler::HandleBarring.\n" );
       
  2671 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_HANDLEBARRING, "CMmCustomMessHandler::HandleBarring" );
       
  2672 
       
  2673     //identify the kind of barring
       
  2674     switch ( aSsCode )
       
  2675         {
       
  2676          case CALL_MODEM_SSC_OUTGOING_BARR_SERV:
       
  2677              aSsTypeAndMode.iSsType = RMmCustomAPI::ESsOutgoingBarrServ;
       
  2678              break;
       
  2679          case CALL_MODEM_SSC_INCOMING_BARR_SERV:
       
  2680              aSsTypeAndMode.iSsType = RMmCustomAPI::ESsIncomingBarrServ;
       
  2681              break;
       
  2682          default:
       
  2683              TFLOGSTRING("TSY: CMmCustomMessHandler::HandleBarring, switch aSsCode - default.\n" );
       
  2684 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_HANDLEBARRING, "CMmCustomMessHandler::HandleBarring, switch aSsCode - default" );
       
  2685              //this case is imposible, added due code convention
       
  2686              break;
       
  2687         }
       
  2688 
       
  2689     TUint sbStartOffSet( 0 );
       
  2690 
       
  2691     //get call gsm ss status sub block
       
  2692     if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
       
  2693         ISI_HEADER_SIZE + SIZE_CALL_MODEM_NOTIFICATION_IND,
       
  2694         CALL_MODEM_SB_SS_STATUS, EIsiSubBlockTypeId8Len8, sbStartOffSet ) )
       
  2695         {
       
  2696         //get the ss status
       
  2697         TUint8 ssStatus ( aIsiMsg.Get8bit( sbStartOffSet +
       
  2698             CALL_MODEM_SB_SS_STATUS_OFFSET_SSSTATUS ) );
       
  2699 
       
  2700         //set the right status for the bit configuration of ssStatus
       
  2701         if ( CALL_MODEM_SS_STATUS_ACTIVE & ssStatus ) //if active is present
       
  2702             {
       
  2703             aSsTypeAndMode.iSsMode = RMmCustomAPI::ESsModeActive;
       
  2704             }
       
  2705         //if quiescent is present
       
  2706         else if ( CALL_MODEM_SS_STATUS_QUIESCENT & ssStatus )
       
  2707             {
       
  2708             aSsTypeAndMode.iSsMode = RMmCustomAPI::ESsModeNotAvailable;
       
  2709             }
       
  2710         else if ( CALL_MODEM_SS_STATUS_PROVISIONED == ssStatus ) //only provisioned
       
  2711             {
       
  2712             aSsTypeAndMode.iSsMode = RMmCustomAPI::ESsModeNotRegistered;
       
  2713             }
       
  2714         else
       
  2715             {
       
  2716             aSsTypeAndMode.iSsMode = RMmCustomAPI::ESsModeNotProvisioned;
       
  2717             }
       
  2718         }
       
  2719     }
       
  2720 
       
  2721 // -----------------------------------------------------------------------------
       
  2722 // CMmCustomMessHandler::NetSetReq
       
  2723 // Constructs NET_SET_REQ ISI message from input parameters
       
  2724 // and sends it through phonet.
       
  2725 // This message is created for reseting the network server
       
  2726 // to previous registered network when the user doesn't select
       
  2727 // a network from the network list got in a search
       
  2728 // (other items were commented in a header).
       
  2729 // -----------------------------------------------------------------------------
       
  2730 //
       
  2731 TInt CMmCustomMessHandler::NetSetReq( TUint8 aTransId )
       
  2732     {
       
  2733 TFLOGSTRING("TSY: CMmCustomMessHandler::NetSetReq");
       
  2734 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETSETREQ, "CMmCustomMessHandler::NetSetReq" );
       
  2735 
       
  2736     // Data for ISI message, buffer size is one
       
  2737     TBuf8<2 + SIZE_NET_OPERATOR_INFO_COMMON> netSetReq;
       
  2738     // Registered in another protocol is set to 0
       
  2739     netSetReq.Append ( 0 );
       
  2740 
       
  2741     // 1 SubBlock
       
  2742     netSetReq.Append ( 1 );
       
  2743 
       
  2744     TBuf8<SIZE_NET_OPERATOR_INFO_COMMON> netGsmOperatorInfoCommonBuf;
       
  2745     TIsiSubBlock netGsmOperatorInfoCommonSb(
       
  2746         netGsmOperatorInfoCommonBuf,
       
  2747         NET_OPERATOR_INFO_COMMON,
       
  2748         EIsiSubBlockTypeId8Len8 );
       
  2749 
       
  2750     netGsmOperatorInfoCommonBuf.Append( NET_SELECT_MODE_NO_SELECTION );
       
  2751     netGsmOperatorInfoCommonBuf.Append( NET_INDEX_NOT_USED );
       
  2752 
       
  2753     netSetReq.Append( netGsmOperatorInfoCommonSb.CompleteSubBlock() );
       
  2754 
       
  2755     // Send message via Phonet
       
  2756     return iPhoNetSender->Send(
       
  2757         PN_MODEM_NETWORK,
       
  2758         aTransId,
       
  2759         NET_SET_REQ,
       
  2760         netSetReq );
       
  2761     }
       
  2762 
       
  2763 // -----------------------------------------------------------------------------
       
  2764 // CMmCustomMessHandler::NetSetResp
       
  2765 // Breaks a NET_SERVER_RESP ISI message.
       
  2766 // This message maps the CS cause value to ETel error value and complete
       
  2767 // CompleteResetNetServer to SOS layer.
       
  2768 // (other items were commented in a header).
       
  2769 // -----------------------------------------------------------------------------
       
  2770 //
       
  2771 void CMmCustomMessHandler::NetSetResp( const TIsiReceiveC& aIsiMsg )
       
  2772     {
       
  2773 TFLOGSTRING("TSY: CMmCustomMessHandler::NetSetResp");
       
  2774 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETSETRESP, "CMmCustomMessHandler::NetSetResp" );
       
  2775 
       
  2776     // Get the cause
       
  2777     TUint8 cause( aIsiMsg.Get8bit(
       
  2778         ISI_HEADER_SIZE +
       
  2779         NET_SET_RESP_OFFSET_SUCCESSCODE ) );
       
  2780 
       
  2781     // Map the cs error as symbian value
       
  2782     TInt error( CMmStaticUtility::CSCauseToEpocError(
       
  2783         PN_MODEM_NETWORK,
       
  2784         KTsyNetCauseCommon,
       
  2785         cause ) );
       
  2786 
       
  2787     // Completion ResetNetServer method (no packed parameters)
       
  2788     iMessageRouter->Complete( ECustomResetNetServerIPC, error );
       
  2789     }
       
  2790 
       
  2791 // -----------------------------------------------------------------------------
       
  2792 // CMmCustomMessHandler::NetRatResp
       
  2793 // Breaks a NET_SERVER_RESP ISI message.
       
  2794 // This method get RatName sub blocks maps the CS cause value to ETel error
       
  2795 // value and complete ResetNetServer to SOS layer.
       
  2796 // (other items were commented in a header).
       
  2797 // -----------------------------------------------------------------------------
       
  2798 //
       
  2799 void CMmCustomMessHandler::NetRatResp( const TIsiReceiveC& aIsiMsg )
       
  2800     {
       
  2801 TFLOGSTRING( "TSY: CMmCustomMessHandler::NetRatResp");
       
  2802 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETRATRESP, "CMmCustomMessHandler::NetRatResp" );
       
  2803 
       
  2804     // Get the success code
       
  2805     TUint8 successCode( aIsiMsg.Get8bit(
       
  2806         ISI_HEADER_SIZE + NET_RAT_RESP_OFFSET_SUCCESSCODE ) );
       
  2807 
       
  2808     TInt ret( KErrNone );
       
  2809 
       
  2810     TUint32 supportedNetworkModes( 0 );
       
  2811 
       
  2812 TFLOGSTRING2( "TSY: CMmCustomMessHandler::NetRatResp successCode : %d", successCode);
       
  2813 OstTraceExt1( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_NETRATRESP, "CMmCustomMessHandler::NetRatResp;successCode=%hhu", successCode );
       
  2814 
       
  2815     // Check if we have sub blocks in the message
       
  2816     if ( aIsiMsg.Get8bit( ISI_HEADER_SIZE + NET_RAT_RESP_OFFSET_SUBBLOCKCOUNT )
       
  2817         != 0 && NET_CAUSE_OK == successCode )
       
  2818         {
       
  2819         TUint8 subBlockIndex( 1 );
       
  2820         TUint sbStartOffSet( 0 );
       
  2821 
       
  2822         // NET_RAT_INFO sub block
       
  2823         while ( KErrNone == aIsiMsg.FindSubBlockOffsetByIndex(
       
  2824             ISI_HEADER_SIZE + SIZE_NET_RAT_RESP,
       
  2825             subBlockIndex,
       
  2826             EIsiSubBlockTypeId8Len8,
       
  2827             sbStartOffSet ) )
       
  2828             {
       
  2829             // Get ratName
       
  2830             TUint8 ratName( aIsiMsg.Get8bit(
       
  2831                 sbStartOffSet + NET_RAT_INFO_OFFSET_RATNAME ) );
       
  2832 
       
  2833             switch ( ratName )
       
  2834                 {
       
  2835                 case NET_GSM_RAT:
       
  2836                     {
       
  2837                     supportedNetworkModes += RMmCustomAPI::KCapsNetworkModeGsm;
       
  2838                     break;
       
  2839                     }
       
  2840                 case NET_UMTS_RAT:
       
  2841                     {
       
  2842                     supportedNetworkModes += RMmCustomAPI::KCapsNetworkModeUmts;
       
  2843                     break;
       
  2844                     }
       
  2845                 }
       
  2846             subBlockIndex++;
       
  2847             }
       
  2848         }
       
  2849     else
       
  2850         {
       
  2851         // Map the cs error as symbian value
       
  2852         ret = CMmStaticUtility::CSCauseToEpocError(
       
  2853             PN_MODEM_NETWORK,
       
  2854             KTsyNetCauseCommon,
       
  2855             successCode );
       
  2856         }
       
  2857 
       
  2858     CMmDataPackage dataPackage;
       
  2859     dataPackage.PackData( &supportedNetworkModes );
       
  2860 
       
  2861 TFLOGSTRING2( "TSY: CMmCustomMessHandler::NetRatResp - ret: %d", ret);
       
  2862 OstTrace1( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_NETRATRESP, "CMmCustomMessHandler::NetRatResp;ret=%d", ret );
       
  2863 
       
  2864     // Completion ResetNetServer method (packed parameters)
       
  2865     iMessageRouter->Complete(
       
  2866         ECustomGetSystemNetworkModesIPC,
       
  2867         &dataPackage,
       
  2868         ret );
       
  2869     }
       
  2870 
       
  2871 // -----------------------------------------------------------------------------
       
  2872 // CMmCustomMessHandler::GssCsServiceResp
       
  2873 // Breaks a GSS_CS_SERVICE_RESP ISI message.
       
  2874 // completes ECustomSetSystemNetworkModeIPC, ECustomSetBandSelectionIPC or
       
  2875 // ECustomGetBandSelectionIPC with KErrNone to SOS layer.
       
  2876 // (other items were commented in a header).
       
  2877 // -----------------------------------------------------------------------------
       
  2878 //
       
  2879 void CMmCustomMessHandler::GssCsServiceResp (
       
  2880         const TIsiReceiveC& aIsiMessage ) // Received isi message
       
  2881     {
       
  2882     TFLOGSTRING( "TSY: CMmCustomMessHandler::GssCsServiceResp" );
       
  2883 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_GSSCSSERVICERESP, "CMmCustomMessHandler::GssCsServiceResp" );
       
  2884 
       
  2885     TUint8 transactId ( aIsiMessage.Get8bit(
       
  2886         ISI_HEADER_SIZE + GSS_CS_SERVICE_RESP_OFFSET_TRANSID ) );
       
  2887 
       
  2888     TUint8 operation ( aIsiMessage.Get8bit(
       
  2889         ISI_HEADER_SIZE + GSS_CS_SERVICE_RESP_OFFSET_OPERATION ) );
       
  2890 
       
  2891     // GSS_SELECTED_RAT_WRITE (0x0E)
       
  2892     if ( KCustomTransId == transactId && GSS_SELECTED_RAT_WRITE == operation )
       
  2893         {
       
  2894         //completion ResetGssServer method (no packed parameters)
       
  2895         TFLOGSTRING("TSY: CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetSystemNetworkModeIPC");
       
  2896 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_GSSCSSERVICERESP, "CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetSystemNetworkModeIPC" );
       
  2897         iMessageRouter->Complete( ECustomSetSystemNetworkModeIPC, KErrNone );
       
  2898         }
       
  2899 
       
  2900 // not suppoted for S60 ver 3.2
       
  2901 #if ( NCP_COMMON_S60_VERSION_SUPPORT != S60_VERSION_32 )
       
  2902 
       
  2903     // GSS_SELECTED_BANDS_WRITE (0x9D)
       
  2904     else if ( GSS_SELECTED_BANDS_WRITE == operation )
       
  2905         {
       
  2906         TFLOGSTRING("TSY: CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetBandSelectionIPC");
       
  2907 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_GSSCSSERVICERESP, "CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetBandSelectionIPC" );
       
  2908         iMessageRouter->Complete( ECustomSetBandSelectionIPC, KErrNone );
       
  2909         }
       
  2910     // GSS_SELECTED_BANDS_READ (0x9E)
       
  2911     else if ( GSS_SELECTED_BANDS_READ == operation )
       
  2912         {
       
  2913         CompleteGetBandSelection( aIsiMessage );
       
  2914         }
       
  2915 #endif // NCP_COMMON_S60_VERSION_SUPPORT
       
  2916     }
       
  2917 
       
  2918 // -----------------------------------------------------------------------------
       
  2919 // CMmCustomMessHandler::GssCsServiceFailResp
       
  2920 // Breaks a GSS_CS_SERVICE_FAIL_RESP ISI message.
       
  2921 // completes ECustomSetSystemNetworkModeIPC, ECustomSetBandSelectionIPC
       
  2922 // or ECustomGetBandSelectionIPC with error value to SOS layer.
       
  2923 // (other items were commented in a header).
       
  2924 // -----------------------------------------------------------------------------
       
  2925 //
       
  2926 void CMmCustomMessHandler::GssCsServiceFailResp (
       
  2927         const TIsiReceiveC& aIsiMessage ) // Received isi message
       
  2928     {
       
  2929     TFLOGSTRING( "TSY: CMmCustomMessHandler::GssCsServiceFailResp" );
       
  2930 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_GSSCSSERVICEFAILRESP, "CMmCustomMessHandler::GssCsServiceFailResp" );
       
  2931 
       
  2932     TUint8 transactId ( aIsiMessage.Get8bit( ISI_HEADER_SIZE +
       
  2933         GSS_CS_SERVICE_FAIL_RESP_OFFSET_TRANSID ) );
       
  2934     TUint8 operation ( aIsiMessage.Get8bit( ISI_HEADER_SIZE +
       
  2935         GSS_CS_SERVICE_FAIL_RESP_OFFSET_OPERATION ) );
       
  2936 
       
  2937     // GSS_SELECTED_RAT_WRITE (0x0E)
       
  2938     if ( KCustomTransId == transactId && GSS_SELECTED_RAT_WRITE == operation )
       
  2939         {
       
  2940         //completion ResetGssServer method (no packed parameters)
       
  2941         TFLOGSTRING("TSY: CMmCustomMessHandler::GssCsServiceFailResp - ECustomSetSystemNetworkModeIPC");
       
  2942 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_GSSCSSERVICEFAILRESP, "CMmCustomMessHandler::GssCsServiceFailResp - ECustomSetSystemNetworkModeIPC" );
       
  2943         iMessageRouter->Complete( ECustomSetSystemNetworkModeIPC, KErrGeneral );
       
  2944         }
       
  2945 // not suppoted for S60 ver 3.2
       
  2946 #if ( NCP_COMMON_S60_VERSION_SUPPORT != S60_VERSION_32 )
       
  2947 
       
  2948     else if ( GSS_SELECTED_BANDS_WRITE == operation )
       
  2949         {
       
  2950         TFLOGSTRING("TSY: CMmCustomMessHandler::GssCsServiceFailResp - ECustomSetBandSelectionIPC");
       
  2951 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_GSSCSSERVICEFAILRESP, "CMmCustomMessHandler::GssCsServiceFailResp - ECustomSetBandSelectionIPC" );
       
  2952         iMessageRouter->Complete( ECustomSetBandSelectionIPC, KErrGeneral );
       
  2953         }
       
  2954     else if ( GSS_SELECTED_BANDS_READ == operation )
       
  2955         {
       
  2956         TFLOGSTRING("TSY: CMmCustomMessHandler::GssCsServiceFailResp - ECustomGetBandSelectionIPC");
       
  2957 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_GSSCSSERVICEFAILRESP, "CMmCustomMessHandler::GssCsServiceFailResp - ECustomGetBandSelectionIPC" );
       
  2958         iMessageRouter->Complete( ECustomGetBandSelectionIPC, KErrGeneral );
       
  2959         }
       
  2960 #endif // NCP_COMMON_S60_VERSION_SUPPORT
       
  2961     }
       
  2962 
       
  2963 // -----------------------------------------------------------------------------
       
  2964 // CMmCustomMessHandler::UiccReadFieldReq
       
  2965 // Read given file from UICC
       
  2966 // -----------------------------------------------------------------------------
       
  2967 //
       
  2968 TInt CMmCustomMessHandler::UiccReadFieldReq(
       
  2969     RMmCustomAPI::TSimFileInfo& aSimFileInfo )
       
  2970     {
       
  2971 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccReadFieldReq" );
       
  2972 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADFIELDREQ, "CMmCustomMessHandler::UiccReadFieldReq" );
       
  2973 
       
  2974     // We have received only file path, file ID is two last bytes of path
       
  2975     TInt length( aSimFileInfo.iPath.Length() );
       
  2976     TBuf8<2> temp;
       
  2977     if ( 2 <= length )
       
  2978         {
       
  2979         temp.Append( aSimFileInfo.iPath.Mid( length - 2 ) );
       
  2980         }
       
  2981     TUint16 fileId( static_cast<TUint16> ( (temp[0] << 8 ) | temp[1] ) );
       
  2982 
       
  2983     // Set parameters for UICC_APPL_CMD_REQ message
       
  2984     TUiccReadTransparent params;
       
  2985     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  2986     params.trId = ETrIdReadField;
       
  2987     params.dataAmount = aSimFileInfo.iSize;
       
  2988     params.dataOffset = aSimFileInfo.iOffSet;
       
  2989     params.fileId = fileId;
       
  2990     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
  2991     params.filePath = aSimFileInfo.iPath.Mid( 0, length - 2 );
       
  2992 
       
  2993     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  2994     }
       
  2995 
       
  2996 // -----------------------------------------------------------------------------
       
  2997 // CMmCustomMessHandler::UiccReadFieldResp
       
  2998 // Complete read file
       
  2999 // -----------------------------------------------------------------------------
       
  3000 //
       
  3001 void CMmCustomMessHandler::UiccReadFieldResp(
       
  3002     TInt aStatus,
       
  3003     const TDesC8& aFileData )
       
  3004     {
       
  3005 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccReadFieldResp" );
       
  3006 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADFIELDRESP, "CMmCustomMessHandler::UiccReadFieldResp" );
       
  3007 
       
  3008     TInt error( KErrNone );
       
  3009     if ( aStatus != KErrNone )
       
  3010         {
       
  3011         error = KErrNotFound;
       
  3012         }
       
  3013 
       
  3014     // Packed parameter for completion: pointer to TDesC8 with data
       
  3015     const TDesC8* dataPtr = &aFileData;
       
  3016     CMmDataPackage dataPackage;
       
  3017     dataPackage.PackData( &dataPtr );
       
  3018     iMessageRouter->Complete( ECustomReadSimFileIPC, &dataPackage, error);
       
  3019     }
       
  3020 
       
  3021 // -----------------------------------------------------------------------------
       
  3022 // CMmCustomMessHandler::NetRatReq
       
  3023 // Constructs NET_RAT_REQ ISI message from input parameters and
       
  3024 // sends it through phonet.This message is created to read Supported Net Rats
       
  3025 // (other items were commented in a header).
       
  3026 // -----------------------------------------------------------------------------
       
  3027 //
       
  3028 TInt CMmCustomMessHandler::NetRatReq
       
  3029         (
       
  3030         TUint8 aTransId, // transaction Id
       
  3031         TBool aUseCurrentRats // use current rats setting
       
  3032         )
       
  3033     {
       
  3034 TFLOGSTRING("TSY: CMmCustomMessHandler::NetRatReq");
       
  3035 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETRATREQ, "CMmCustomMessHandler::NetRatReq" );
       
  3036 
       
  3037 TFLOGSTRING3( "TSY: CCMmCustomMessHandler::NetRatReq - aTransId: %d, aUseCurrentRats: %d", aTransId, aUseCurrentRats );
       
  3038 OstTraceExt2( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_NETRATREQ, "CMmCustomMessHandler::NetRatReq;aTransId=%hhu;aUseCurrentRats=%hhu", aTransId, aUseCurrentRats );
       
  3039 
       
  3040     // Create message data buffer for service type, buffer size is 1
       
  3041     TBuf8<1> messageData;
       
  3042     // Append service type
       
  3043     if ( aUseCurrentRats )
       
  3044         {
       
  3045         messageData.Append( NET_CURRENT_RAT );
       
  3046         }
       
  3047     else
       
  3048         {
       
  3049         messageData.Append( NET_SUPPORTED_RATS );
       
  3050         }
       
  3051 
       
  3052     // Sending message to phonet
       
  3053     return iPhoNetSender->Send(
       
  3054         PN_MODEM_NETWORK,
       
  3055         aTransId,
       
  3056         NET_RAT_REQ,
       
  3057         messageData );
       
  3058     }
       
  3059 
       
  3060 // -----------------------------------------------------------------------------
       
  3061 // CMmCustomMessHandler::GssCsServiceReq
       
  3062 // Constructs GSS_CS_SERVICE_REQ ISI message from input parameters and
       
  3063 // sends it through phonet.This message is created to set System network mode
       
  3064 // (other items were commented in a header).
       
  3065 // -----------------------------------------------------------------------------
       
  3066 //
       
  3067 TInt CMmCustomMessHandler::GssCsServiceReq
       
  3068         (
       
  3069         TUint8 aTransId,             //transaction Id
       
  3070         RMmCustomAPI::TNetworkModeCaps aNetworkModeCaps //network mode caps
       
  3071         )
       
  3072     {
       
  3073 
       
  3074     TFLOGSTRING2( "TSY: CMmCustomMessHandler::GssCsServiceReq - aTransId: %d",
       
  3075                     aTransId );
       
  3076 OstTraceExt1( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_GSSCSSERVICEREQ, "CMmCustomMessHandler::GssCsServiceReq;aTransId=%hhu", aTransId );
       
  3077 
       
  3078     // create message data buffer for service type, buffer size is 6
       
  3079     TBuf8< KGssCsBufferSize > messageData;
       
  3080 
       
  3081     // append service type, GSS_SELECTED_RAT_WRITE (0x0E)
       
  3082     messageData.Append( GSS_SELECTED_RAT_WRITE );
       
  3083 
       
  3084     // Number of sub blocks
       
  3085     messageData.Append( 1 );
       
  3086 
       
  3087     // add the GSS_RAT_INFO (0x0B) subblock into ISI
       
  3088     messageData.Append( GSS_RAT_INFO );
       
  3089 
       
  3090     // Length of sub block is 4 (SIZE_GSS_RAT_INFO)
       
  3091     messageData.Append( SIZE_GSS_RAT_INFO );
       
  3092 
       
  3093     //Sub block for GSS_RAT_INFO_FUNCTIONS
       
  3094     if ( RMmCustomAPI::KCapsNetworkModeGsm == aNetworkModeCaps )
       
  3095         {
       
  3096         // GSS_GSM_RAT (0x01) is GSM mode
       
  3097         messageData.Append( GSS_GSM_RAT );
       
  3098         }
       
  3099     else if ( RMmCustomAPI::KCapsNetworkModeUmts == aNetworkModeCaps )
       
  3100         {
       
  3101         // GSS_UMTS_RAT (0x02) is Umts mode
       
  3102         messageData.Append( GSS_UMTS_RAT );
       
  3103         }
       
  3104     else
       
  3105         {
       
  3106         // GSS_DUAL_RAT (0x00) is Dual mode
       
  3107         messageData.Append( GSS_DUAL_RAT );
       
  3108         }
       
  3109 
       
  3110     // Padding byte
       
  3111     messageData.Append( KCustomPadding );
       
  3112 
       
  3113     // Sending message to phonet
       
  3114     return iPhoNetSender->Send( PN_GSS, aTransId, GSS_CS_SERVICE_REQ, messageData );
       
  3115 
       
  3116     }
       
  3117 
       
  3118 // -----------------------------------------------------------------------------
       
  3119 // CMmCustomMessHandler::ExtFuncL
       
  3120 // Forwards requests coming from the Symbian OS layer to the
       
  3121 // specific method.
       
  3122 // -----------------------------------------------------------------------------
       
  3123 //
       
  3124 TInt CMmCustomMessHandler::ExtFuncL
       
  3125         (
       
  3126         TInt aIpc, //Ipc
       
  3127         const CMmDataPackage* aDataPackage  //data package
       
  3128         )
       
  3129     {
       
  3130 
       
  3131     //*************************************************************//
       
  3132     // NOTE
       
  3133     //
       
  3134     // LICENSEE SPECIFIC MESSAGE HANDLER IMPLEMENTATION STARTS HERE
       
  3135     //
       
  3136     //*************************************************************//
       
  3137 
       
  3138     TInt ret( KErrNone );
       
  3139 
       
  3140     TUint8 transId = KCustomTransId;
       
  3141 
       
  3142     TFLOGSTRING2("TSY: CMmCustomMessHandler::ExtFuncL -- aIpc -- (%d)", aIpc );
       
  3143 OstTrace1( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_EXTFUNCL, "CMmCustomMessHandler::ExtFuncL;aIpc=%d", aIpc );
       
  3144 
       
  3145     switch ( aIpc )
       
  3146         {
       
  3147         case ECustomCancelUssdSessionIPC:
       
  3148             {
       
  3149             //no packed parameters
       
  3150             ret = SsGsmUssdSendReq( transId );
       
  3151             break;
       
  3152             }
       
  3153         case ECustomClearCallBlackListIPC:
       
  3154             {
       
  3155             //no packed parameters
       
  3156             ret = CallGsmBlackListClearReq( transId );
       
  3157             break;
       
  3158             }
       
  3159         case ECustomCheckEmergencyNumberIPC:
       
  3160             {
       
  3161             // packed parameter: a RMmCustomAPI::TEmerNumberCheckMode
       
  3162             RMmCustomAPI::TEmerNumberCheckMode checkMode;
       
  3163             aDataPackage->UnPackData( checkMode );
       
  3164             ret = CallEmergencyNbrCheckReq( transId, checkMode.iNumber,
       
  3165                                             checkMode.iCheckMode );
       
  3166             break;
       
  3167             }
       
  3168         case ECustomTerminateCallIPC:
       
  3169             {
       
  3170             // packed parameters: pointer to an array of TInt (Call Id)
       
  3171             // and TBool isError
       
  3172             TInt callId;
       
  3173             TBool isError;
       
  3174             aDataPackage->UnPackData( callId, isError );
       
  3175 
       
  3176             // map Custom API values to ISA values
       
  3177             // cause Value (error or user request)
       
  3178             TUint8 causeValue =
       
  3179                 ( isError ? CALL_MODEM_CAUSE_ERROR_REQUEST : CALL_MODEM_CAUSE_RELEASE_BY_USER );
       
  3180 
       
  3181             // call Id
       
  3182             TUint8 callIdISA = 0;
       
  3183             // martpiir 27-May-2004: This cannot remain, must be checked
       
  3184             // jlof 29-Sep-2004: "all calls" id was originally -2, but now
       
  3185             // negative or zero
       
  3186             // call id means all calls. Taking absolute value of it gives
       
  3187             // alerting call id.
       
  3188             if ( 0 >= callId )
       
  3189                 {
       
  3190                 TFLOGSTRING("TSY: CMmCustomMessHandler::ExtFuncL -- ECustomTerminateCallIPC -- (hold+active+alerting)");
       
  3191 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_EXTFUNCL, "CMmCustomMessHandler::ExtFuncL - ECustomTerminateCallIPC - (hold+active+alerting)" );
       
  3192                 // alerting call (if any) is included as negated value..
       
  3193                 callIdISA = TUint8( CALL_MODEM_ID_HOLD | CALL_MODEM_ID_ACTIVE | ( -callId ));
       
  3194                 }
       
  3195             else if ( 1 <= callId && 7 >= callId )
       
  3196                 {
       
  3197                 TFLOGSTRING2("TSY: CMmCustomMessHandler::ExtFuncL -- ECustomTerminateCallIPC -- (%d)", TInt(callId) );
       
  3198 OstTrace1( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_EXTFUNCL, "CMmCustomMessHandler::ExtFuncL;callId=%d", callId );
       
  3199                 callIdISA = static_cast<TUint8>( callId );
       
  3200                 }
       
  3201             else
       
  3202                 {
       
  3203                 // no call found
       
  3204                 ret = KErrArgument;
       
  3205                 }
       
  3206 
       
  3207             if ( KErrNone == ret )
       
  3208                 {
       
  3209                 ret = CallReleaseReq( transId, callIdISA, causeValue );
       
  3210                 }
       
  3211             break;
       
  3212             }
       
  3213         case ECustomGetAlsBlockedIPC:
       
  3214             {
       
  3215             ret = UiccReadDynamic2FlagsReq();
       
  3216             break;
       
  3217             }
       
  3218         case ECustomSetAlsBlockedIPC:
       
  3219             {
       
  3220             // Packed parameter: TSetAlsBlock (block status)
       
  3221             RMmCustomAPI::TSetAlsBlock blockStatus;
       
  3222             aDataPackage->UnPackData( blockStatus );
       
  3223 
       
  3224             // Map Custom API values to ISA values
       
  3225             TUint8 blockStatusISA = static_cast<TUint8>( blockStatus );
       
  3226             ret = UiccWriteDynamic2FlagsReq( blockStatusISA );
       
  3227             break;
       
  3228             }
       
  3229         case ECustomCheckAlsPpSupportIPC:
       
  3230             {
       
  3231             //no packed parameters
       
  3232             // request type is used as transaction id. needed for
       
  3233             // completion.
       
  3234             ret = InfoPpReadReq( EGetAlsPPSupport );
       
  3235             break;
       
  3236             }
       
  3237         case ECustomCheckTwoDigitDialSupportIPC:
       
  3238             {
       
  3239             //no packed parameters
       
  3240             // request type is used as transaction id. needed for
       
  3241             // completion.
       
  3242             ret = InfoPpReadReq( ECheckTwoDigitDialSupport );
       
  3243             break;
       
  3244             }
       
  3245         case ECustomGetCipheringInfoIPC:
       
  3246             {
       
  3247             //no packed parameters
       
  3248             ret = UiccReadCiReq( ETrIdReadCipheringIndicatorStatusCustom );
       
  3249             break;
       
  3250             }
       
  3251         case ECustomNetWakeupIPC:
       
  3252             {
       
  3253             //no packed parameters
       
  3254             ret = NetCsWakeupReq( transId );
       
  3255             break;
       
  3256             }
       
  3257         case ECustomGetOperatorNameIPC:
       
  3258             {
       
  3259             //no packed parameters
       
  3260             ret = NetModemRegStatusGetReq( transId );
       
  3261             break;
       
  3262             }
       
  3263         case ECustomResetNetServerIPC:
       
  3264             {
       
  3265             //no packed parameters
       
  3266             ret = NetSetReq( transId );
       
  3267             break;
       
  3268             }
       
  3269         case ECustomGetNetworkProviderNameIPC:
       
  3270             {
       
  3271             ret = UiccOperatorReq();
       
  3272             break;
       
  3273             }
       
  3274         case ECustomReadSimFileIPC:
       
  3275             {
       
  3276             //packed parameter: RMmCustomAPI::TSimFileInfo
       
  3277             RMmCustomAPI::TSimFileInfo simFileInfo;
       
  3278             aDataPackage->UnPackData( simFileInfo );
       
  3279             ret = UiccReadFieldReq( simFileInfo );
       
  3280             break;
       
  3281             }
       
  3282         case EMobilePhoneIMSAuthenticate:
       
  3283             {
       
  3284             ret = UiccHandleImsAuthentication( *aDataPackage );
       
  3285             break;
       
  3286             }
       
  3287         case ECustomGetSimAuthenticationDataIPC:
       
  3288             {
       
  3289             ret = UiccSendAuthenticateApdu( *aDataPackage );
       
  3290             break;
       
  3291             }
       
  3292         // Supported network modes
       
  3293         case ECustomGetSystemNetworkModesIPC:
       
  3294             {
       
  3295             TBool useCurrentRats;
       
  3296             aDataPackage->UnPackData( useCurrentRats );
       
  3297             ret = NetRatReq( transId, useCurrentRats );
       
  3298             break;
       
  3299             }
       
  3300         // Set system network mode
       
  3301         case ECustomSetSystemNetworkModeIPC:
       
  3302             {
       
  3303             RMmCustomAPI::TNetworkModeCaps networkModeCaps;
       
  3304             aDataPackage->UnPackData( networkModeCaps );
       
  3305             ret = GssCsServiceReq( transId, networkModeCaps  );
       
  3306             break;
       
  3307             }
       
  3308 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
  3309         // Current network modes
       
  3310         // Removed for Bridge camp!
       
  3311         case ECustomGetCurrentSystemNetworkModesIPC:
       
  3312             {
       
  3313             ret = MtcRatQueryReq( transId );
       
  3314             break;
       
  3315             }
       
  3316 #endif /*  INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
  3317 
       
  3318         // Get GSM/WCDMA cell info
       
  3319         case ECustomGetCellInfoIPC:
       
  3320             {
       
  3321             iECIDInfoRequested = ETrue;
       
  3322             ret = NetNeighbourCellsReq( transId );
       
  3323             break;
       
  3324             }
       
  3325 
       
  3326         case ECustomSimWarmResetIPC:
       
  3327             {
       
  3328             ret = UiccSimWarmResetReq();
       
  3329             break;
       
  3330             }
       
  3331 
       
  3332         case ECustomGetATRIPC:
       
  3333             {
       
  3334             ret = UiccSimGetAtrReq();
       
  3335             break;
       
  3336             }
       
  3337 
       
  3338         case ECustomGetSimCardReaderStatusIPC:
       
  3339             {
       
  3340             ret = UiccCardReaderStatusReq();
       
  3341             break;
       
  3342             }
       
  3343 
       
  3344         case ECustomSendAPDUReqV2IPC:
       
  3345             {
       
  3346             // packed parameter: RMmCustomAPI::TApduParameters
       
  3347             RMmCustomAPI::TApduParameters apduParameters;
       
  3348             TInt traId( ETrIdSendAPDUv2 );
       
  3349 
       
  3350             //Unpack aDataPackage
       
  3351             aDataPackage->UnPackData( apduParameters );
       
  3352 
       
  3353             ret = UiccSendAPDUReq( apduParameters, traId);
       
  3354             break;
       
  3355             }
       
  3356         case ECustomPowerSimOnIPC:
       
  3357             {
       
  3358             ret = UiccSimPowerOnReq();
       
  3359             break;
       
  3360             }
       
  3361         case ECustomPowerSimOffIPC:
       
  3362             {
       
  3363             ret = UiccSimPowerOffReq();
       
  3364             break;
       
  3365             }
       
  3366 
       
  3367         case ECustomSendAPDUReqIPC:
       
  3368             {
       
  3369             // packed parameter: RMmCustomAPI::TApdu
       
  3370             RMmCustomAPI::TApdu apduData;
       
  3371             RMmCustomAPI::TApduParameters apduParameters;
       
  3372             TInt traId( ETrIdSendAPDU );
       
  3373 
       
  3374             //Unpack aDataPackage
       
  3375             aDataPackage->UnPackData( apduData );
       
  3376 
       
  3377             apduParameters.iCmdData.Append(*apduData.iData);
       
  3378 
       
  3379             ret = UiccSendAPDUReq( apduParameters, traId );
       
  3380             break;
       
  3381             }
       
  3382 
       
  3383         //from MmSIMMessHandler
       
  3384         case ECustomStartSimCbTopicBrowsingIPC:
       
  3385             {
       
  3386             ret = UiccReadCbMsgIdsReq( ETrIdReadCbMsgIds );
       
  3387             break;
       
  3388             }
       
  3389         case ECustomDeleteSimCbTopicIPC:
       
  3390             {
       
  3391             // packed parameter: TUint with topic id
       
  3392             aDataPackage->UnPackData( iSimCBTopicToBeDeleted,
       
  3393                 iTopicInSimMemoryDelete );
       
  3394             ret = UiccReadCbMsgIdsReq( ETrIdUpdateCbMsgIdsPhase1 );
       
  3395             break;
       
  3396             }
       
  3397         case EReadViagHomeZoneParamsIPC:
       
  3398             {
       
  3399             ret = UiccReadViagHomeZoneParametersReq();
       
  3400             break;
       
  3401             }
       
  3402         case EReadViagHomeZoneCacheIPC:
       
  3403             {
       
  3404             // packed parameter: RMmCustomAPI::TViagCacheRecordId
       
  3405             RMmCustomAPI::TViagCacheRecordId recordId;
       
  3406             aDataPackage->UnPackData( recordId );
       
  3407             ret = UiccReadViagHomeZoneCacheReq( recordId );
       
  3408             break;
       
  3409             }
       
  3410         case EWriteViagHomeZoneCacheIPC:
       
  3411             {
       
  3412             // packed parameters: RMmCustomAPI::TViagCacheRecordId
       
  3413             // and RMmCustomAPI::TViagCacheRecordContent
       
  3414             RMmCustomAPI::TViagCacheRecordId recordId;
       
  3415             RMmCustomAPI::TViagCacheRecordContent recordContent;
       
  3416             aDataPackage->UnPackData( recordId, recordContent );
       
  3417             ret = UiccWriteViagHomeZoneCacheReq( recordId, recordContent );
       
  3418             break;
       
  3419             }
       
  3420         //WCDMA HZ
       
  3421         case EWriteViagHomeZoneUHZIUESettingsIPC:
       
  3422             {
       
  3423             //Unpack the packed settings data
       
  3424             RMmCustomAPI::TViagUHZIUESettings settingUhziui;
       
  3425             aDataPackage->UnPackData( settingUhziui );
       
  3426             ret = UiccWriteViagHomeZoneUhziueSettingsReq( settingUhziui );
       
  3427             break;
       
  3428             }
       
  3429         case ECustomWriteHSxPAStatusIPC:
       
  3430             {
       
  3431             RMmCustomAPI::THSxPAStatus aStatus;
       
  3432             aDataPackage->UnPackData( aStatus );
       
  3433             ret = WriteHSxPAStatusReq( transId, aStatus );
       
  3434             break;
       
  3435             }
       
  3436 
       
  3437         case ECustomReadHSxPAStatusIPC:
       
  3438             {
       
  3439             ret = ReadHSxPAStatusReq( transId );
       
  3440             break;
       
  3441             }
       
  3442 
       
  3443 // not suppoted for S60 ver 3.2
       
  3444 #if ( NCP_COMMON_S60_VERSION_SUPPORT != S60_VERSION_32 )
       
  3445 
       
  3446         // Set custom band selection
       
  3447         case ECustomSetBandSelectionIPC:
       
  3448             {
       
  3449             RMmCustomAPI::TNetworkModeCaps networkModeCaps;
       
  3450             RMmCustomAPI::TBandSelection bandSelection;
       
  3451             aDataPackage->UnPackData( bandSelection, networkModeCaps );
       
  3452 
       
  3453             ret = GssCsServiceSetBandReq( transId,
       
  3454                 networkModeCaps,
       
  3455                 bandSelection );
       
  3456             break;
       
  3457             }
       
  3458 
       
  3459         // Get custom band selection
       
  3460         case ECustomGetBandSelectionIPC:
       
  3461             {
       
  3462             ret = GssCsServiceGetBandReq( transId );
       
  3463             break;
       
  3464             }
       
  3465 
       
  3466 #endif // NCP_COMMON_S60_VERSION_SUPPORT
       
  3467 
       
  3468         case EMmTsyUpdateLifeTimeIPC:
       
  3469             {
       
  3470             TTimeIntervalSeconds time;
       
  3471             aDataPackage->UnPackData( time );
       
  3472 
       
  3473             ret = WriteLifeTimerToPermanentMemory( transId, time );
       
  3474 
       
  3475             break;
       
  3476             }
       
  3477 
       
  3478         case ECustomGetLifeTimeIPC:
       
  3479             {
       
  3480             //no packed parameters
       
  3481             ret = GetTotalLifeTimerValue();
       
  3482             break;
       
  3483             }
       
  3484 
       
  3485         default:
       
  3486             {
       
  3487             // this method should only be called for Custom Tsy cases
       
  3488             TFLOGSTRING2("TSY: CMmCustomMessHandler::ExtFuncL - Unknown IPC: %d", aIpc);
       
  3489 OstTrace1( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_EXTFUNCL, "CMmCustomMessHandler::ExtFuncL;aIpc=%d", aIpc );
       
  3490             ret = KErrArgument;
       
  3491             break;
       
  3492             }
       
  3493         }
       
  3494 
       
  3495     return ret;
       
  3496   }
       
  3497 
       
  3498 
       
  3499 // -----------------------------------------------------------------------------
       
  3500 // CMmCustomMessHandler::ProcessUiccMsg
       
  3501 // Handles data received from UICC server
       
  3502 // -----------------------------------------------------------------------------
       
  3503 //
       
  3504 TInt CMmCustomMessHandler::ProcessUiccMsg(
       
  3505     TInt aTraId,
       
  3506     TInt aStatus,
       
  3507     const TDesC8& aFileData )
       
  3508     {
       
  3509 TFLOGSTRING3("TSY: CMmCustomMessHandler::ProcessUiccMsg, transaction ID: %d, status: %d", aTraId, aStatus );
       
  3510 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_PROCESSUICCMSG, "CMmCustomMessHandler::ProcessUiccMsg" );
       
  3511 
       
  3512     TInt ret( KErrNone );
       
  3513 
       
  3514     switch( aTraId )
       
  3515         {
       
  3516         case ETrIdReadField:
       
  3517             {
       
  3518             UiccReadFieldResp( aStatus, aFileData );
       
  3519             break;
       
  3520             }
       
  3521         case ETrIdReadCbMsgIds:
       
  3522         case ETrIdUpdateCbMsgIdsPhase1:
       
  3523             {
       
  3524             UiccReadCbMsgIdsResp( aStatus, aTraId, aFileData );
       
  3525             break;
       
  3526             }
       
  3527         case ETrIdUpdateCbMsgIdsPhase2:
       
  3528             {
       
  3529             UiccDeleteCbMsgIdResp( aStatus );
       
  3530             break;
       
  3531             }
       
  3532         case ETrIdReadCipheringIndicatorStatusCustom:
       
  3533         case ETrIdNotifyCipheringIndicatorStatusCustom:
       
  3534             {
       
  3535             UiccReadCiResp( aStatus, aTraId, aFileData );
       
  3536             break;
       
  3537             }
       
  3538         case ETrIdReadOperatorNameCustom:
       
  3539             {
       
  3540             UiccOperatorResp( aStatus, aFileData );
       
  3541             break;
       
  3542             }
       
  3543         case ETrIdReadViagHomeZoneParamsCustom:
       
  3544             {
       
  3545             UiccReadViagHomeZoneParametersResp( aStatus, aFileData );
       
  3546             break;
       
  3547             }
       
  3548         case ETrIdReadViagHomeZoneCacheCustom:
       
  3549             {
       
  3550             UiccReadViagHomeZoneCacheResp( aStatus, aFileData );
       
  3551             break;
       
  3552             }
       
  3553         case ETrIdWriteViagHomeZoneCacheCustom:
       
  3554             {
       
  3555             UiccWriteViagHomeZoneCacheResp( aStatus );
       
  3556             break;
       
  3557             }
       
  3558         case ETrIdWriteViagHomeZoneUhziueSettingsCustom:
       
  3559             {
       
  3560             UiccWriteViagHomeZoneUhziueSettingsResp( aStatus );
       
  3561             break;
       
  3562             }
       
  3563         case ETrIdReadDynamic2Flags:
       
  3564             {
       
  3565             UiccReadDynamic2FlagsResp( aStatus, aFileData );
       
  3566             break;
       
  3567             }
       
  3568         case ETrIdWriteDynamic2Flags:
       
  3569             {
       
  3570             UiccWriteDynamic2FlagsResp( aStatus );
       
  3571             break;
       
  3572             }
       
  3573 
       
  3574         case ETrIdSimPowerOff:
       
  3575             {
       
  3576             UiccSimPowerOffResp( aStatus );
       
  3577             break;
       
  3578             }
       
  3579 
       
  3580         case ETrIdSimWarmReset:
       
  3581             {
       
  3582             UiccSimWarmResetResp( aStatus );
       
  3583             break;
       
  3584             }
       
  3585 
       
  3586         case ETrIdSimGetATR:
       
  3587             {
       
  3588             UiccSimGetAtrResp( aStatus, aFileData );
       
  3589             break;
       
  3590             }
       
  3591 
       
  3592         case ETrIdSimPowerOn:
       
  3593             {
       
  3594             UiccSimPowerOnResp( aStatus );
       
  3595             break;
       
  3596             }
       
  3597 
       
  3598         case ETrIdSendAPDUv2:
       
  3599         case ETrIdSendAPDU:
       
  3600             {
       
  3601             UiccSendAPDUResp( aStatus, aFileData, aTraId );
       
  3602             break;
       
  3603             }
       
  3604 
       
  3605         case ETrIdCardReaderStatus:
       
  3606             {
       
  3607             UiccCardReaderStatusResp( aStatus, aFileData );
       
  3608             break;
       
  3609             }
       
  3610         case ETrIdEEapSimAuthenticate:
       
  3611             {
       
  3612             UiccGsmSecurityContextApduResp( aTraId, aStatus, aFileData );
       
  3613             break;
       
  3614             }
       
  3615         case ETrIdEEapAkaAuthenticate:
       
  3616         case ETrIdEEapAkaAuthenticateIms:
       
  3617             {
       
  3618             Uicc3GSecurityContextApduResp( aTraId, aStatus, aFileData );
       
  3619             break;
       
  3620             }
       
  3621         case ETrIdEGbaBootstrap:
       
  3622             {
       
  3623             UiccGBABootstrappingApduResp( aTraId, aStatus, aFileData );
       
  3624             break;
       
  3625             }
       
  3626         case ETrIdEGbaBootstrapRead:
       
  3627             {
       
  3628             UiccGBABootstrapReadResp( aStatus, aFileData );
       
  3629             break;
       
  3630             }
       
  3631         case ETrIdEGbaBootstrapUpdate:
       
  3632             {
       
  3633             UiccGBABootstrapUpdateResp( aStatus );
       
  3634             break;
       
  3635             }
       
  3636         case ETrIdEGbaNafDerivation:
       
  3637             {
       
  3638             UiccGBANafDerivationApduResp( aTraId, aStatus, aFileData );
       
  3639             break;
       
  3640             }
       
  3641         case ETrIdEMbmsMskUpdate:
       
  3642             {
       
  3643             UiccMbmsMskUpdateApduResp( aStatus, aFileData );
       
  3644             break;
       
  3645             }
       
  3646         case ETrIdEMbmsMtkGeneration:
       
  3647             {
       
  3648             UiccMbmsMtkGenerationApduResp( aStatus, aFileData );
       
  3649             break;
       
  3650             }
       
  3651         case ETrIdEMbmsMskDeletion:
       
  3652             {
       
  3653             UiccMbmsMskDeletionApduResp( aStatus, aFileData );
       
  3654             break;
       
  3655             }
       
  3656         case ETrIdRunGsmAlgorithmSim:
       
  3657         case ETrIdRunGsmAlgorithmAka:
       
  3658         case ETrIdRunGsmAlgorithmIms:
       
  3659             {
       
  3660             UiccRunGsmAlgorithmApduResp( aTraId, aStatus, aFileData );
       
  3661             break;
       
  3662             }
       
  3663         case ETrIdActivateIsimApplication:
       
  3664             {
       
  3665             UiccHandleIsimActivationResp( aStatus );
       
  3666             break;
       
  3667             }
       
  3668         default:
       
  3669             {
       
  3670 TFLOGSTRING("TSY: CMmNetMessHandler::ProcessUiccMsg - unknown transaction ID" );
       
  3671 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_PROCESSUICCMSG, "CMmCustomMessHandler::ProcessUiccMsg - unknown transaction ID" );
       
  3672 
       
  3673             break;
       
  3674             }
       
  3675         }
       
  3676     return ret;
       
  3677     }
       
  3678 
       
  3679 // -----------------------------------------------------------------------------
       
  3680 // CMmCustomMessHandler::MtcRatQueryReq
       
  3681 // Constructs MTC_RAT_QUERY_REQ ISI message from input parameters and
       
  3682 // sends it through phonet.
       
  3683 // (other items were commented in a header).
       
  3684 // -----------------------------------------------------------------------------
       
  3685 //
       
  3686 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
  3687 // Removed for Bridge camp
       
  3688 TInt CMmCustomMessHandler::MtcRatQueryReq
       
  3689         (
       
  3690         TUint8 aTransId   //transaction Id
       
  3691         )
       
  3692     {
       
  3693     TFLOGSTRING("TSY: CMmCustomMessHandler::MtcRatQueryReq.\n" );
       
  3694 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_MTCRATQUERYREQ, "CMmCustomMessHandler::MtcRatQueryReq" );
       
  3695 
       
  3696     TBuf8<KTwo> messageData;
       
  3697 
       
  3698     //append padding bytes
       
  3699     messageData.Append( 0 );
       
  3700     messageData.Append( 0 );
       
  3701 
       
  3702     // Sending message to phonet
       
  3703     return iPhoNetSender->Send( PN_MTC, aTransId, MTC_RAT_QUERY_REQ, messageData );
       
  3704     }
       
  3705 
       
  3706 // -----------------------------------------------------------------------------
       
  3707 // CMmCustomMessHandler::MtcRatQueryResp
       
  3708 // Breaks a MTC_RAT_QUERY_RESP ISI message.
       
  3709 // This method get the ratMode and complete the request with error value
       
  3710 // to SOS layer.
       
  3711 // (other items were commented in a header).
       
  3712 // -----------------------------------------------------------------------------
       
  3713 //
       
  3714 // Removed for Bridge camp
       
  3715 void CMmCustomMessHandler::MtcRatQueryResp
       
  3716         (
       
  3717         const TIsiReceiveC& aIsiMessage // Received isi message
       
  3718         )
       
  3719     {
       
  3720     TInt ret ( KErrNone );
       
  3721 
       
  3722     TUint32 ratMode ( RMmCustomAPI::KCapsNetworkModeDual );
       
  3723     TUint8 mode = aIsiMessage.Get8bit( ISI_HEADER_SIZE + MTC_RAT_QUERY_RESP_OFFSET_RAT );
       
  3724 
       
  3725 TFLOGSTRING3("TSY: CMmCustomMessHandler::MtcRatQueryResp. RatMode:%d, mode:%d", ratMode, mode);
       
  3726 OstTraceExt2( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_MTCRATQUERYRESP, "CMmCustomMessHandler::MtcRatQueryResp;mode=%hhu;ratMode=%u", mode, ratMode );
       
  3727 
       
  3728     switch ( mode )
       
  3729         {
       
  3730         case MTC_GSM_RAT:
       
  3731             {
       
  3732             ratMode = RMmCustomAPI::KCapsNetworkModeGsm;
       
  3733             break;
       
  3734             }
       
  3735         case MTC_UMTS_RAT:
       
  3736             {
       
  3737             ratMode = RMmCustomAPI::KCapsNetworkModeUmts;
       
  3738             break;
       
  3739             }
       
  3740         case MTC_NO_RAT_SELECTION: //this means dual mode
       
  3741             {
       
  3742             //value already initalized to dual
       
  3743             break;
       
  3744             }
       
  3745         default: // MTC_UNKNOWN_RAT
       
  3746             {
       
  3747             TFLOGSTRING("TSY: CMmCustomMessHandler::MtcRatQueryResp, switch mode - default.\n" );
       
  3748 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_MTCRATQUERYRESP, "CMmCustomMessHandler::MtcRatQueryResp, switch mode - default" );
       
  3749             ret = KErrGeneral;
       
  3750             break;
       
  3751             }
       
  3752         }
       
  3753 
       
  3754     CMmDataPackage dataPackage;
       
  3755     dataPackage.PackData( &ratMode );
       
  3756 
       
  3757     //completion ResetNetServer method (packed parameters)
       
  3758     iMessageRouter->Complete( ECustomGetCurrentSystemNetworkModesIPC,
       
  3759         &dataPackage, ret );
       
  3760 
       
  3761     }
       
  3762 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
  3763 
       
  3764 // -----------------------------------------------------------------------------
       
  3765 // CMmCustomMessHandler::UiccReadViagHomeZoneParametersReq
       
  3766 // Read home zone parameters from UICC
       
  3767 // -----------------------------------------------------------------------------
       
  3768 //
       
  3769 TInt CMmCustomMessHandler::UiccReadViagHomeZoneParametersReq()
       
  3770     {
       
  3771 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccReadViagHomeZoneParametersReq" );
       
  3772 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADVIAGHOMEZONEPARAMETERSREQ, "CMmCustomMessHandler::UiccReadViagHomeZoneParametersReq" );
       
  3773 
       
  3774     // Set parameters for UICC_APPL_CMD_REQ message
       
  3775     TUiccReadTransparent params;
       
  3776     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  3777     params.trId = ETrIdReadViagHomeZoneParamsCustom;
       
  3778     params.dataAmount = 0;
       
  3779     params.dataOffset = 0;
       
  3780     params.fileId = KElemFileHomeZone;
       
  3781     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
  3782 
       
  3783     // File id path
       
  3784     params.filePath.Append( KMasterFileId >> 8 );
       
  3785     params.filePath.Append( KMasterFileId );
       
  3786     params.filePath.Append( KO2DedicatedFile >> 8 );
       
  3787     params.filePath.Append( KO2DedicatedFile );
       
  3788 
       
  3789     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  3790     }
       
  3791 
       
  3792 // -----------------------------------------------------------------------------
       
  3793 // CMmCustomMessHandler::UiccReadViagHomeZoneParametersResp
       
  3794 // Complete home zone parameters
       
  3795 // -----------------------------------------------------------------------------
       
  3796 //
       
  3797 void CMmCustomMessHandler::UiccReadViagHomeZoneParametersResp(
       
  3798     TInt aStatus,
       
  3799     const TDesC8& aFileData )
       
  3800     {
       
  3801 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccReadViagHomeZoneParametersResp" );
       
  3802 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADVIAGHOMEZONEPARAMETERSRESP, "CMmCustomMessHandler::UiccReadViagHomeZoneParametersResp" );
       
  3803 
       
  3804     TInt error( KErrNone );
       
  3805     if ( KErrNone == aStatus )
       
  3806         {
       
  3807         TUint8 length( 0 );
       
  3808         TUint8 i( 0 );
       
  3809         TUint8 j( 0 );
       
  3810         TUint8 index( 2 );
       
  3811 
       
  3812         // Viag params, reset
       
  3813         iViagParams.iScp.Zero();
       
  3814         iViagParams.iSmsC.Zero();
       
  3815         iViagParams.iSubscribedZoneAndVersion = 0;
       
  3816 
       
  3817         // Set homezone subscription and version ( byte 1 )
       
  3818         iViagParams.iSubscribedZoneAndVersion = aFileData[0];
       
  3819 
       
  3820         // Set SMSC number ( 7 bytes, not include length )
       
  3821         length = aFileData[1];
       
  3822         for ( i = 0; i < length; i++ )
       
  3823             {
       
  3824             iViagParams.iSmsC.Append( aFileData[index++] );
       
  3825             }
       
  3826 
       
  3827         // Set SCP number
       
  3828         length = aFileData[9];
       
  3829         index = 10;
       
  3830         for ( i = 0; i < length; i++ )
       
  3831             {
       
  3832             iViagParams.iScp.Append( aFileData[index++] );
       
  3833             }
       
  3834 
       
  3835         // Viag elements
       
  3836         RMmCustomAPI::TViagElements* viagElems(
       
  3837             new (ELeave) RMmCustomAPI::TViagElements
       
  3838             ( RMmCustomAPI::KViagElementCount ) );
       
  3839         CleanupStack::PushL( viagElems );
       
  3840         TUint8 elemDataIndex( 17 ); // Home zone elements stars from byte 18
       
  3841         TUint32 tempCoordinate( 0 );
       
  3842 
       
  3843         TUint8 byte1( 0 );
       
  3844         TUint8 byte2( 0 );
       
  3845         TUint8 byte3( 0 );
       
  3846         TUint8 byte4( 0 );
       
  3847 
       
  3848         // Set viag elements
       
  3849         for ( ; j < RMmCustomAPI::KViagElementCount; j++ )
       
  3850             {
       
  3851             RMmCustomAPI::TViagElement elem;
       
  3852             // Set zone id
       
  3853             elem.iCoordinates.iZoneId = aFileData[ elemDataIndex ];
       
  3854 
       
  3855             // Next four bytes are for x coordinate
       
  3856             byte1 = aFileData[++elemDataIndex];
       
  3857             byte2 = aFileData[++elemDataIndex];
       
  3858             byte3 = aFileData[++elemDataIndex];
       
  3859             byte4 = aFileData[++elemDataIndex];
       
  3860 
       
  3861             tempCoordinate = ( byte1 << 24 ) |
       
  3862                 ( byte2 << 16 ) |
       
  3863                 ( byte3 << 8 ) |
       
  3864                 ( byte4 );
       
  3865             elem.iCoordinates.iX = tempCoordinate;
       
  3866 
       
  3867             // Next four bytes are for y coordinate
       
  3868             byte1 = aFileData[++elemDataIndex];
       
  3869             byte2 = aFileData[++elemDataIndex];
       
  3870             byte3 = aFileData[++elemDataIndex];
       
  3871             byte4 = aFileData[++elemDataIndex];
       
  3872 
       
  3873             tempCoordinate = ( byte1 << 24 ) |
       
  3874                 ( byte2 << 16 ) |
       
  3875                 ( byte3 << 8 ) |
       
  3876                 ( byte4 );
       
  3877             elem.iCoordinates.iY = tempCoordinate;
       
  3878 
       
  3879             // Next four bytes are for r2
       
  3880             byte1 = aFileData[++elemDataIndex];
       
  3881             byte2 = aFileData[++elemDataIndex];
       
  3882             byte3 = aFileData[++elemDataIndex];
       
  3883             byte4 = aFileData[++elemDataIndex];
       
  3884 
       
  3885             tempCoordinate = ( byte1 << 24 ) |
       
  3886                 ( byte2 << 16 ) |
       
  3887                 ( byte3 << 8 ) |
       
  3888                 ( byte4 );
       
  3889             elem.iCoordinates.iR2 = tempCoordinate;
       
  3890 
       
  3891             // Set active flag
       
  3892             // Bit 1 indicates homzone active
       
  3893             TBool isActive(
       
  3894                 ( aFileData[++elemDataIndex] & KHomeZoneActiveBit ) );
       
  3895 
       
  3896             if ( isActive )
       
  3897                 {
       
  3898                 // Bit 2 indicates if an active homezone is marked as a cityzone
       
  3899                 TBool isCityZone(
       
  3900                     ( aFileData[elemDataIndex] & KCityZoneActiveBit ) );
       
  3901                 if ( isCityZone )
       
  3902                     {
       
  3903                     elem.iActiveFlag = RMmCustomAPI::ECityZone;
       
  3904                     }
       
  3905                 else
       
  3906                     {
       
  3907                     elem.iActiveFlag = RMmCustomAPI::EHomeZone;
       
  3908                     }
       
  3909                 }
       
  3910             else
       
  3911                 {
       
  3912                 elem.iActiveFlag = RMmCustomAPI::ENotActive;
       
  3913                 }
       
  3914 
       
  3915             // Set name (12 bytes)
       
  3916             elem.iName.Zero();
       
  3917             for ( i = 0; i < 12; i++ )
       
  3918                 {
       
  3919                 elem.iName.Append( aFileData[++elemDataIndex] );
       
  3920                 }
       
  3921 
       
  3922             viagElems->AppendL( elem );
       
  3923             elemDataIndex++;
       
  3924             }
       
  3925 
       
  3926         // Complete
       
  3927         CMmDataPackage dataPackage;
       
  3928         dataPackage.PackData( &iViagParams, &viagElems );
       
  3929         iMessageRouter->Complete( EReadViagHomeZoneParamsIPC,
       
  3930             &dataPackage, error );
       
  3931 
       
  3932         //delete iViagElems;
       
  3933         CleanupStack::PopAndDestroy(viagElems);
       
  3934         }
       
  3935     else
       
  3936         {
       
  3937         // Complete with error value
       
  3938         iMessageRouter->Complete(
       
  3939             EReadViagHomeZoneParamsIPC,
       
  3940             KErrAccessDenied );
       
  3941         }
       
  3942     }
       
  3943 
       
  3944 // -----------------------------------------------------------------------------
       
  3945 // CMmCustomMessHandler::UiccReadVIAGHomeZoneCacheReq
       
  3946 // Read home zone cache
       
  3947 // -----------------------------------------------------------------------------
       
  3948 //
       
  3949 TInt CMmCustomMessHandler::UiccReadViagHomeZoneCacheReq(
       
  3950     const RMmCustomAPI::TViagCacheRecordId& aRecordId )
       
  3951     {
       
  3952 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccReadViagHomeZoneCacheReq" );
       
  3953 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADVIAGHOMEZONECACHEREQ, "CMmCustomMessHandler::UiccReadViagHomeZoneCacheReq" );
       
  3954 
       
  3955     TUint8 cacheId( aRecordId.iCacheId );
       
  3956     TUint8 recordId( aRecordId.iRecordId );
       
  3957     TUint16 fileId( 0 );
       
  3958 
       
  3959     // The record numbers in SIM Server range from 1 to 21. Client's record
       
  3960     // numbers range from 0 to 20. We have to increase the index by one.
       
  3961     recordId++;
       
  3962 
       
  3963     // Define file ID according to cache ID
       
  3964     switch( cacheId )
       
  3965         {
       
  3966         case 1:
       
  3967             {
       
  3968             fileId = KElemFileHomeZoneCache1;
       
  3969             break;
       
  3970             }
       
  3971         case 2:
       
  3972             {
       
  3973             fileId = KElemFileHomeZoneCache2;
       
  3974             break;
       
  3975             }
       
  3976         case 3:
       
  3977             {
       
  3978             fileId = KElemFileHomeZoneCache3;
       
  3979             break;
       
  3980             }
       
  3981         case 4:
       
  3982             {
       
  3983             fileId = KElemFileHomeZoneCache4;
       
  3984             break;
       
  3985             }
       
  3986         default:
       
  3987             {
       
  3988             break;
       
  3989             }
       
  3990         }
       
  3991 
       
  3992     // Set parameters for UICC_APPL_CMD_REQ message
       
  3993     TUiccReadLinearFixed params;
       
  3994     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  3995     params.trId = ETrIdReadViagHomeZoneCacheCustom;
       
  3996     params.dataOffset = 0;
       
  3997     params.dataAmount = 0;
       
  3998     params.record = recordId;
       
  3999 
       
  4000     params.fileId = fileId;
       
  4001     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  4002     params.serviceType = UICC_APPL_READ_LINEAR_FIXED;
       
  4003 
       
  4004     // File id path
       
  4005     params.filePath.Append( KMasterFileId >> 8 );
       
  4006     params.filePath.Append( KMasterFileId );
       
  4007     params.filePath.Append( KO2DedicatedFile >> 8 );
       
  4008     params.filePath.Append( KO2DedicatedFile );
       
  4009 
       
  4010     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  4011     }
       
  4012 
       
  4013 // -----------------------------------------------------------------------------
       
  4014 // CMmCustomMessHandler::UiccReadViagHomeZoneCacheResp
       
  4015 // Complete home zone cache
       
  4016 // -----------------------------------------------------------------------------
       
  4017 //
       
  4018 void CMmCustomMessHandler::UiccReadViagHomeZoneCacheResp(
       
  4019     TInt aStatus,
       
  4020     const TDesC8& aFileData )
       
  4021     {
       
  4022 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccReadViagHomeZoneCacheResp" );
       
  4023 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADVIAGHOMEZONECACHERESP, "CMmCustomMessHandler::UiccReadViagHomeZoneCacheResp" );
       
  4024 
       
  4025     TInt ret( KErrAccessDenied );
       
  4026 
       
  4027     RMmCustomAPI::TViagCacheRecordContent viagRecord;
       
  4028 
       
  4029     if ( KErrNone == aStatus )
       
  4030         {
       
  4031         viagRecord.iLac = ( aFileData[0] << 8 ) | aFileData[1];
       
  4032         viagRecord.iCellId = ( aFileData[2] << 8 ) | aFileData[3];
       
  4033         ret = KErrNone;
       
  4034         }
       
  4035     else
       
  4036         {
       
  4037         viagRecord.iLac = NULL;
       
  4038         viagRecord.iCellId = NULL;
       
  4039         }
       
  4040 
       
  4041     // Complete, packed parameter: RMmCustomAPI::TViagCacheRecordContent
       
  4042     CMmDataPackage dataPackage;
       
  4043     dataPackage.PackData( &viagRecord );
       
  4044     iMessageRouter->Complete( EReadViagHomeZoneCacheIPC, &dataPackage, ret );
       
  4045 
       
  4046     return;
       
  4047     }
       
  4048 
       
  4049 
       
  4050 // -----------------------------------------------------------------------------
       
  4051 // CMmCustomMessHandler::UiccWriteVIAGHomeZoneCacheReq
       
  4052 // Write home zone cache
       
  4053 // -----------------------------------------------------------------------------
       
  4054 //
       
  4055 TInt CMmCustomMessHandler::UiccWriteViagHomeZoneCacheReq(
       
  4056     const RMmCustomAPI::TViagCacheRecordId& aRecordId,
       
  4057     const RMmCustomAPI::TViagCacheRecordContent& aViagRecordContent )
       
  4058     {
       
  4059 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccWriteViagHomeZoneCacheReq" );
       
  4060 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCWRITEVIAGHOMEZONECACHEREQ, "CMmCustomMessHandler::UiccWriteViagHomeZoneCacheReq" );
       
  4061 
       
  4062     TUint8 cacheId( (TUint8)aRecordId.iCacheId );
       
  4063     TUint8 recordId( (TUint8)aRecordId.iRecordId );
       
  4064     TUint16 lac( (TUint16)aViagRecordContent.iLac );
       
  4065     TUint16 cellId( (TUint16)aViagRecordContent.iCellId );
       
  4066     TUint16 fileId( 0 );
       
  4067 
       
  4068     // The record numbers in SIM Server range from 1 to 21. Client's record
       
  4069     // numbers range from 0 to 20. We have to shift the index by one.
       
  4070     recordId++;
       
  4071 
       
  4072     // Define file ID according to cache ID
       
  4073     switch( cacheId )
       
  4074         {
       
  4075         case 1:
       
  4076             {
       
  4077             fileId = KElemFileHomeZoneCache1;
       
  4078             break;
       
  4079             }
       
  4080         case 2:
       
  4081             {
       
  4082             fileId = KElemFileHomeZoneCache2;
       
  4083             break;
       
  4084             }
       
  4085         case 3:
       
  4086             {
       
  4087             fileId = KElemFileHomeZoneCache3;
       
  4088             break;
       
  4089             }
       
  4090         case 4:
       
  4091             {
       
  4092             fileId = KElemFileHomeZoneCache4;
       
  4093             break;
       
  4094             }
       
  4095         default:
       
  4096             {
       
  4097             break;
       
  4098             }
       
  4099         }
       
  4100 
       
  4101     // Set parameters for UICC_APPL_CMD_REQ message
       
  4102     TUiccWriteLinearFixed params;
       
  4103     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  4104     params.trId = ETrIdWriteViagHomeZoneCacheCustom;
       
  4105     params.dataOffset = 0;
       
  4106     params.dataAmount = 0;
       
  4107     params.record = recordId;
       
  4108 
       
  4109     params.fileId = fileId;
       
  4110     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  4111     params.serviceType = UICC_APPL_UPDATE_LINEAR_FIXED;
       
  4112 
       
  4113     // File id path
       
  4114     params.filePath.Append( KMasterFileId >> 8 );
       
  4115     params.filePath.Append( KMasterFileId );
       
  4116     params.filePath.Append( KO2DedicatedFile >> 8 );
       
  4117     params.filePath.Append( KO2DedicatedFile );
       
  4118 
       
  4119     // File data to be updated.
       
  4120     TBuf8<4> fileDataBuf;
       
  4121     fileDataBuf.Append( lac >> 8 );
       
  4122     fileDataBuf.Append( lac & 0x00FF );
       
  4123     fileDataBuf.Append( cellId >> 8);
       
  4124     fileDataBuf.Append( cellId & 0x00FF );
       
  4125     params.fileData.Append( fileDataBuf );
       
  4126 
       
  4127     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  4128     }
       
  4129 
       
  4130 
       
  4131 // -----------------------------------------------------------------------------
       
  4132 // CMmCustomMessHandler::UiccWriteViagHomeZoneCacheResp
       
  4133 // Complete home zone cache
       
  4134 // -----------------------------------------------------------------------------
       
  4135 //
       
  4136 void CMmCustomMessHandler::UiccWriteViagHomeZoneCacheResp( TInt aStatus )
       
  4137     {
       
  4138 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccWriteViagHomeZoneCacheResp" );
       
  4139 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCWRITEVIAGHOMEZONECACHERESP, "CMmCustomMessHandler::UiccWriteViagHomeZoneCacheResp" );
       
  4140 
       
  4141     if ( KErrNone == aStatus )
       
  4142         {
       
  4143         iMessageRouter->Complete( EWriteViagHomeZoneCacheIPC, KErrNone );
       
  4144         }
       
  4145     else
       
  4146         {
       
  4147         iMessageRouter->Complete( EWriteViagHomeZoneCacheIPC, KErrGeneral );
       
  4148         }
       
  4149     }
       
  4150 
       
  4151 // -----------------------------------------------------------------------------
       
  4152 // CMmCustomMessHandler::UiccWriteViagHomeZoneUhziueSettingsReq
       
  4153 // Write home zone settings to UICC
       
  4154 // -----------------------------------------------------------------------------
       
  4155 //
       
  4156 TInt CMmCustomMessHandler::UiccWriteViagHomeZoneUhziueSettingsReq(
       
  4157     const RMmCustomAPI::TViagUHZIUESettings& aUhziuiSettings )
       
  4158     {
       
  4159 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccWriteViagHomeZoneUhziueSettingsReq" );
       
  4160 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCWRITEVIAGHOMEZONEUHZIUESETTINGSREQ, "CMmCustomMessHandler::UiccWriteViagHomeZoneUhziueSettingsReq" );
       
  4161 
       
  4162     TUint8 settingsField( aUhziuiSettings.iSettings );
       
  4163     TUint8 versionField( aUhziuiSettings.iVersion );
       
  4164 
       
  4165     // Set parameters for UICC_APPL_CMD_REQ message
       
  4166     TUiccWriteTransparent params;
       
  4167     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  4168     params.trId = ETrIdWriteViagHomeZoneUhziueSettingsCustom;
       
  4169     params.dataOffset = 0;
       
  4170 
       
  4171     params.fileId = KElemFileUhziueSettings;
       
  4172     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  4173     params.serviceType = UICC_APPL_UPDATE_TRANSPARENT;
       
  4174 
       
  4175     // File id path
       
  4176     params.filePath.Append( KMasterFileId >> 8 );
       
  4177     params.filePath.Append( KMasterFileId );
       
  4178     params.filePath.Append( KO2DedicatedFile >> 8 );
       
  4179     params.filePath.Append( KO2DedicatedFile );
       
  4180 
       
  4181     // File data to be updated.
       
  4182     TBuf8<2> fileDataBuf;
       
  4183     fileDataBuf.Append( settingsField );
       
  4184     fileDataBuf.Append( versionField);
       
  4185     params.fileData.Append( fileDataBuf );
       
  4186 
       
  4187     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  4188     }
       
  4189 
       
  4190 // -----------------------------------------------------------------------------
       
  4191 // CMmCustomMessHandler::UiccWriteViagHomeZoneUhziueSettingsResp
       
  4192 // Complete home zone settings
       
  4193 // -----------------------------------------------------------------------------
       
  4194 //
       
  4195 void CMmCustomMessHandler::UiccWriteViagHomeZoneUhziueSettingsResp(
       
  4196     TInt aStatus )
       
  4197     {
       
  4198 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccWriteViagHomeZoneUhziueSettingsResp" );
       
  4199 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCWRITEVIAGHOMEZONEUHZIUESETTINGSRESP, "CMmCustomMessHandler::UiccWriteViagHomeZoneUhziueSettingsResp" );
       
  4200 
       
  4201     TInt status( KErrAccessDenied );
       
  4202 
       
  4203     if ( KErrNone == aStatus  )
       
  4204         {
       
  4205         status = KErrNone;
       
  4206         }
       
  4207     iMessageRouter->Complete( EWriteViagHomeZoneUHZIUESettingsIPC, status );
       
  4208     }
       
  4209 
       
  4210 // -----------------------------------------------------------------------------
       
  4211 // CMmCustomMessHandler::UiccReadCbMsgIdsReq
       
  4212 // Read CB message IDs from UICC
       
  4213 // -----------------------------------------------------------------------------
       
  4214 //
       
  4215 TInt CMmCustomMessHandler::UiccReadCbMsgIdsReq( TUiccTrId aTrId )
       
  4216     {
       
  4217 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccReadCbMsgIdsReq" );
       
  4218 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADCBMSGIDSREQ, "CMmCustomMessHandler::UiccReadCbMsgIdsReq" );
       
  4219 
       
  4220     // Set parameters for UICC_APPL_CMD_REQ message
       
  4221     TUiccReadTransparent params;
       
  4222     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  4223     params.trId = aTrId;
       
  4224     params.dataOffset = 0;
       
  4225     params.dataAmount = 0;
       
  4226     params.fileId = KElemFileCellBroadcastMessId;
       
  4227     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  4228     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
  4229 
       
  4230     // File id path
       
  4231     params.filePath.Append( KMasterFileId >> 8 );
       
  4232     params.filePath.Append( KMasterFileId );
       
  4233     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
  4234 
       
  4235     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  4236     }
       
  4237 
       
  4238 // -----------------------------------------------------------------------------
       
  4239 // CMmCustomMessHandler::UiccReadCbMsgIdsResp
       
  4240 // Complete CB message IDs
       
  4241 // -----------------------------------------------------------------------------
       
  4242 //
       
  4243 void CMmCustomMessHandler::UiccReadCbMsgIdsResp(
       
  4244     TInt aStatus,
       
  4245     TInt aTraId,
       
  4246     const TDesC8& aFileData )
       
  4247     {
       
  4248 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccReadCbMsgIdsResp" );
       
  4249 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCREADCBMSGIDSRESP, "CMmCustomMessHandler::UiccReadCbMsgIdsResp" );
       
  4250 
       
  4251     TInt numOfCbIds( 0 );
       
  4252     // File data in bytes
       
  4253     TInt length( aFileData.Length() );
       
  4254     // Divide by two to get number of 16-bit CB ids
       
  4255     numOfCbIds = length >> 1;
       
  4256     // Buffer for 16 bits CB identifiers
       
  4257     TBuf16<KSimNumberOfCbMsgIds> cbIds;
       
  4258     TInt i( 0 );
       
  4259     TInt j( 0 );
       
  4260     // Loop all the bytes and append 16 bit id to buffer
       
  4261     for ( ; i < length && j < numOfCbIds; i += 2, j++ )
       
  4262         {
       
  4263         TUint16 cbId ( ( aFileData[i] << 8 ) | ( aFileData[i+1] ) );
       
  4264         cbIds.Append( cbId );
       
  4265         }
       
  4266     // Read request, complete CB topic list to CTSY
       
  4267     if ( KErrNone == aStatus && ETrIdReadCbMsgIds == aTraId && numOfCbIds > 0 )
       
  4268         {
       
  4269         CArrayFixFlat<RMmCustomAPI::TSimCbTopic>* simCbTopics = new ( ELeave )
       
  4270             CArrayFixFlat<RMmCustomAPI::TSimCbTopic> ( numOfCbIds );
       
  4271 
       
  4272         for ( i = 0; i < numOfCbIds; i++ )
       
  4273             {
       
  4274             if ( KUnusedCbMsgId != cbIds[i] )
       
  4275                 {
       
  4276                 RMmCustomAPI::TSimCbTopic simCbTopic;
       
  4277                 // CB ID
       
  4278                 simCbTopic.iNumber = cbIds[i];
       
  4279                 // Topic names are not stored on the SIM
       
  4280                 simCbTopic.iName.Zero();
       
  4281                 // Add CB topic to array
       
  4282                 simCbTopics->AppendL( simCbTopic );
       
  4283                 }
       
  4284              }
       
  4285         simCbTopics->Compress();
       
  4286 
       
  4287         // Complete to SOS layer with packed parameter:
       
  4288         // pointer to array with CB topics
       
  4289         CMmDataPackage dataPackage;
       
  4290         dataPackage.PackData( &simCbTopics );
       
  4291 
       
  4292         iMessageRouter->Complete(
       
  4293             ECustomStartSimCbTopicBrowsingIPC,
       
  4294             &dataPackage,
       
  4295             KErrNone );
       
  4296         }
       
  4297     // Delete request, update EF CBMI with new topic list
       
  4298     else if ( KErrNone == aStatus && ETrIdUpdateCbMsgIdsPhase1 == aTraId &&
       
  4299         numOfCbIds > 0 && iTopicInSimMemoryDelete )
       
  4300         {
       
  4301         // Set parameters for UICC_APPL_CMD_REQ message
       
  4302         TUiccWriteTransparent params;
       
  4303         params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  4304         params.trId = ETrIdUpdateCbMsgIdsPhase2;
       
  4305         params.dataOffset = 0;
       
  4306         params.fileId = KElemFileCellBroadcastMessId;
       
  4307         params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  4308         params.serviceType = UICC_APPL_UPDATE_TRANSPARENT;
       
  4309 
       
  4310         // File id path
       
  4311         params.filePath.Append( KMasterFileId >> 8 );
       
  4312         params.filePath.Append( KMasterFileId );
       
  4313         params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
  4314 
       
  4315         // File data to be updated.
       
  4316         TBuf8<KSimNumberOfCbMsgIds*2> fileDataBuf;
       
  4317         for ( i = 0; i < numOfCbIds; i++ )
       
  4318             {
       
  4319             if ( cbIds[ i ] != iSimCBTopicToBeDeleted )
       
  4320                 {
       
  4321                 fileDataBuf.Append( cbIds[ i ] >> 8 ); // MSB
       
  4322                 fileDataBuf.Append( cbIds[ i ] & 0x00FF ); // LSB
       
  4323                 }
       
  4324             else // This CB id is deleted-> set unused
       
  4325                 {
       
  4326                 fileDataBuf.Append( 0xFF );
       
  4327                 fileDataBuf.Append( 0xFF );
       
  4328                 }
       
  4329             }
       
  4330         iSimCBTopicToBeDeleted = KUnusedCbMsgId;
       
  4331         params.fileData.Append( fileDataBuf );
       
  4332         iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  4333         }
       
  4334     else // Complete error values
       
  4335         {
       
  4336         if ( ETrIdReadCbMsgIds == aTraId )
       
  4337             {
       
  4338             iMessageRouter->Complete(
       
  4339                 ECustomStartSimCbTopicBrowsingIPC,
       
  4340                 KErrNotFound );
       
  4341             }
       
  4342         else // Delete request
       
  4343             {
       
  4344             iMessageRouter->Complete(
       
  4345                 ECustomDeleteSimCbTopicIPC,
       
  4346                 KErrNotFound );
       
  4347             }
       
  4348         iTopicInSimMemoryDelete = ETrue;
       
  4349         }
       
  4350     }
       
  4351 
       
  4352 // -----------------------------------------------------------------------------
       
  4353 // CMmCustomMessHandler::UiccDeleteCbMsgIdResp
       
  4354 // Delete CB message ID
       
  4355 // -----------------------------------------------------------------------------
       
  4356 //
       
  4357 void CMmCustomMessHandler::UiccDeleteCbMsgIdResp( TInt aStatus )
       
  4358     {
       
  4359 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccDeleteCbMsgIdResp" );
       
  4360 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCDELETECBMSGIDRESP, "CMmCustomMessHandler::UiccDeleteCbMsgIdResp" );
       
  4361 
       
  4362     TInt err( KErrNone );
       
  4363     if ( KErrNone != aStatus )
       
  4364         {
       
  4365         err = KErrAccessDenied;
       
  4366         }
       
  4367 
       
  4368     iMessageRouter->Complete( ECustomDeleteSimCbTopicIPC, err );
       
  4369     }
       
  4370 
       
  4371 // -----------------------------------------------------------------------------
       
  4372 // CMmCustomMessHandler::WriteHSxPAStatusReq
       
  4373 //
       
  4374 // (other items were commented in a header).
       
  4375 // -----------------------------------------------------------------------------
       
  4376 //
       
  4377 TInt CMmCustomMessHandler::WriteHSxPAStatusReq
       
  4378         (
       
  4379         TUint8 aTraId,                      // Transaction identification
       
  4380         RMmCustomAPI::THSxPAStatus status   // HSxPA status
       
  4381         )
       
  4382     {
       
  4383     TFLOGSTRING("TSY: CMmCustomMessHandler::WriteHSxPAStatusReq");
       
  4384 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_WRITEHSXPASTATUSREQ, "CMmCustomMessHandler::WriteHSxPAStatusReq" );
       
  4385 
       
  4386     TBuf8<KHSxPAMaxMessageSize> data;
       
  4387     TUint8 value(0);
       
  4388 
       
  4389     if ( RMmCustomAPI::EHSxPAEnabled == status )
       
  4390         {
       
  4391         value = GSS_HSXPA_ALLOWED;
       
  4392         }
       
  4393     else // ( RMmCustomAPI::EHSxPADisabled == status )
       
  4394         {
       
  4395         value = GSS_HSXPA_DISABLED;
       
  4396         }
       
  4397 
       
  4398     data.Append( value );
       
  4399     data.Append( KCustomPadding ); //Filler
       
  4400 
       
  4401     return iPhoNetSender->Send( PN_GSS,
       
  4402                                 aTraId,
       
  4403                                 GSS_HSXPA_USER_SETTING_WRITE_REQ,
       
  4404                                 data );
       
  4405     }
       
  4406 
       
  4407 // -----------------------------------------------------------------------------
       
  4408 // CMmCustomMessHandler::WriteHSxPAStatusResp
       
  4409 //
       
  4410 // (other items were commented in a header).
       
  4411 // -----------------------------------------------------------------------------
       
  4412 //
       
  4413 void CMmCustomMessHandler::WriteHSxPAStatusResp
       
  4414         (
       
  4415         const TIsiReceiveC& aIsiMessage    // an ISI message
       
  4416         )
       
  4417     {
       
  4418     TFLOGSTRING("TSY: CMmCustomMessHandler::WriteHSxPAStatusResp");
       
  4419 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_WRITEHSXPASTATUSRESP, "CMmCustomMessHandler::WriteHSxPAStatusResp" );
       
  4420 
       
  4421     TInt epocError( KErrWrite );
       
  4422 
       
  4423     TUint8 writeStatus = aIsiMessage.Get8bit(
       
  4424       ISI_HEADER_SIZE + GSS_HSXPA_USER_SETTING_WRITE_RESP_OFFSET_WRITESTATUS );
       
  4425 
       
  4426     TUint8 reason = aIsiMessage.Get8bit(
       
  4427         ISI_HEADER_SIZE + GSS_HSXPA_USER_SETTING_WRITE_RESP_OFFSET_FAILCAUSE );
       
  4428 
       
  4429     if ( GSS_OK == writeStatus )
       
  4430         {
       
  4431         epocError = KErrNone;
       
  4432         }
       
  4433     // GSS_FAIL == writeStatus and PP bit is disabled
       
  4434     else if ( GSS_HSXPA_DISABLED_VIA_PP == reason )
       
  4435         {
       
  4436         TFLOGSTRING("TSY: CMmCustomMessHandler::WriteHSxPAStatusResp. KErrNotSupported");
       
  4437 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_WRITEHSXPASTATUSRESP, "CMmCustomMessHandler::WriteHSxPAStatusResp, KErrNotSupported" );
       
  4438         epocError = KErrNotSupported;
       
  4439         }
       
  4440 
       
  4441     iMessageRouter->Complete( ECustomWriteHSxPAStatusIPC, epocError );
       
  4442     }
       
  4443 
       
  4444 // -----------------------------------------------------------------------------
       
  4445 // CMmCustomMessHandler::ReadHSxPAStatusReq
       
  4446 //
       
  4447 // (other items were commented in a header).
       
  4448 // -----------------------------------------------------------------------------
       
  4449 //
       
  4450 TInt CMmCustomMessHandler::ReadHSxPAStatusReq
       
  4451         (
       
  4452         TUint8 aTraId              // Transaction identification
       
  4453         )
       
  4454     {
       
  4455     TFLOGSTRING("TSY: CMmCustomMessHandler::ReadHSxPAStatusReq");
       
  4456 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_READHSXPASTATUSREQ, "CMmCustomMessHandler::ReadHSxPAStatusReq" );
       
  4457 
       
  4458     TBuf8<KHSxPAMaxMessageSize> data;
       
  4459     data.Append( KCustomPadding ); //Filler
       
  4460     data.Append( KCustomPadding ); //Filler
       
  4461 
       
  4462     return iPhoNetSender->Send( PN_GSS,
       
  4463                                 aTraId,
       
  4464                                 GSS_HSXPA_USER_SETTING_READ_REQ,
       
  4465                                 data );
       
  4466     }
       
  4467 
       
  4468 // -----------------------------------------------------------------------------
       
  4469 // CMmCustomMessHandler::ReadHSxPAStatusResp
       
  4470 //
       
  4471 // (other items were commented in a header).
       
  4472 // -----------------------------------------------------------------------------
       
  4473 //
       
  4474 void CMmCustomMessHandler::ReadHSxPAStatusResp
       
  4475         (
       
  4476         const TIsiReceiveC& aIsiMessage    // an ISI message
       
  4477         )
       
  4478     {
       
  4479     TFLOGSTRING("TSY: CMmCustomMessHandler::ReadHSxPAStatusResp");
       
  4480 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_READHSXPASTATUSRESP, "CMmCustomMessHandler::ReadHSxPAStatusResp" );
       
  4481 
       
  4482     CMmDataPackage dataPackage;
       
  4483 
       
  4484     TUint8 state = aIsiMessage.Get8bit(
       
  4485       ISI_HEADER_SIZE + GSS_HSXPA_USER_SETTING_READ_RESP_OFFSET_HSXPAUSERSETTING );
       
  4486     TUint8 causeBit = aIsiMessage.Get8bit(
       
  4487         ISI_HEADER_SIZE + GSS_HSXPA_USER_SETTING_READ_RESP_OFFSET_CAUSE );
       
  4488 
       
  4489     RMmCustomAPI::THSxPAStatus  hsxpaStatus;
       
  4490     TInt epocError( KErrNone );
       
  4491 
       
  4492     if ( GSS_HSXPA_DISABLED_VIA_PP != causeBit  )
       
  4493         {
       
  4494 
       
  4495         if ( GSS_HSXPA_ALLOWED == state )
       
  4496             {
       
  4497             hsxpaStatus = RMmCustomAPI::EHSxPAEnabled;
       
  4498             }
       
  4499         else if ( GSS_HSXPA_DISABLED == state )
       
  4500             {
       
  4501             hsxpaStatus = RMmCustomAPI::EHSxPADisabled;
       
  4502             }
       
  4503         else //default -> general error occurs
       
  4504             {
       
  4505             epocError = KErrGeneral;
       
  4506             }
       
  4507 
       
  4508         // complete with packed parameter
       
  4509         dataPackage.PackData( &hsxpaStatus );
       
  4510         }
       
  4511     else  // PPbit is disabled -> not supported
       
  4512         {
       
  4513         epocError =  KErrNotSupported;
       
  4514         }
       
  4515 
       
  4516     iMessageRouter->Complete( ECustomReadHSxPAStatusIPC, &dataPackage, epocError );
       
  4517     }
       
  4518 
       
  4519 // -----------------------------------------------------------------------------
       
  4520 // CMmCustomMessHandler::HSxPASettingInd
       
  4521 // This method breaks the GSS_HSXPA_SETTING_IND ISI.
       
  4522 // (other items were commented in a header).
       
  4523 // -----------------------------------------------------------------------------
       
  4524 //
       
  4525 void CMmCustomMessHandler::HSxPASettingInd
       
  4526         (
       
  4527         const TIsiReceiveC& aIsiMessage    // an ISI message
       
  4528         )
       
  4529     {
       
  4530     TFLOGSTRING("TSY: CMmCustomMessHandler::HSxPASettingInd");
       
  4531 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_HSXPASETTINGIND, "CMmCustomMessHandler::HSxPASettingInd" );
       
  4532 
       
  4533     CMmDataPackage dataPackage;
       
  4534     RMmCustomAPI::THSxPAStatus hsxpaStatus;
       
  4535 
       
  4536     TUint8 currentState = aIsiMessage.Get8bit(
       
  4537       ISI_HEADER_SIZE + GSS_HSXPA_USER_SETTING_IND_OFFSET_HSXPAUSERSETTING );
       
  4538 
       
  4539     if ( GSS_HSXPA_ALLOWED == currentState )
       
  4540         {
       
  4541         hsxpaStatus = RMmCustomAPI::EHSxPAEnabled;
       
  4542         }
       
  4543     else // ( GSS_HSXPA_DISABLED == currentState )
       
  4544         {
       
  4545         hsxpaStatus = RMmCustomAPI::EHSxPADisabled;
       
  4546         }
       
  4547 
       
  4548     // complete with packed parameter
       
  4549     dataPackage.PackData( &hsxpaStatus );
       
  4550     iMessageRouter->Complete( ECustomNotifyHSxPAStatusIPC, &dataPackage, KErrNone );
       
  4551     }
       
  4552 
       
  4553 // -----------------------------------------------------------------------------
       
  4554 // CMmCustomMessHandler::NetNeighbourCellsReq
       
  4555 // (other items were commented in a header).
       
  4556 // -----------------------------------------------------------------------------
       
  4557 //
       
  4558 TInt CMmCustomMessHandler::NetNeighbourCellsReq( const TUint8 aTraId )
       
  4559     {
       
  4560 TFLOGSTRING("TSY: CMmCustomMessHandler::NetNeighbourCellsReq");
       
  4561 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETNEIGHBOURCELLSREQ, "CMmCustomMessHandler::NetNeighbourCellsReq" );
       
  4562 
       
  4563     // Add NET_NEIGHBOUR_CELL_INFO_TYPE
       
  4564     // (data size is allways 1)
       
  4565     TBuf8<1> data;
       
  4566     data.Append( NET_ECID_INFORMATION );
       
  4567 
       
  4568     return iPhoNetSender->Send(
       
  4569         PN_MODEM_NETWORK,
       
  4570         aTraId,
       
  4571         NET_NEIGHBOUR_CELLS_REQ,
       
  4572         data );
       
  4573     }
       
  4574 
       
  4575 // -----------------------------------------------------------------------------
       
  4576 // CMmCustomMessHandler::NetNeighbourCellsResp
       
  4577 // This method breaks the NET_NEIGHBOUR_CELLS_RESP message.
       
  4578 // (other items were commented in a header).
       
  4579 // -----------------------------------------------------------------------------
       
  4580 //
       
  4581 void CMmCustomMessHandler::NetNeighbourCellsResp(
       
  4582     const TIsiReceiveC& aIsiMessage )
       
  4583     {
       
  4584 TFLOGSTRING("TSY: CMmCustomMessHandler::NetNeighbourCellsResp");
       
  4585 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_NETNEIGHBOURCELLSRESP, "CMmCustomMessHandler::NetNeighbourCellsResp" );
       
  4586 
       
  4587     TECIDInfo tempECIDInfo;
       
  4588     TInt ret( KErrNone );
       
  4589 
       
  4590     // Get the success code.
       
  4591     TUint8 successCode( aIsiMessage.Get8bit(
       
  4592         ISI_HEADER_SIZE +
       
  4593         NET_NEIGHBOUR_CELLS_RESP_OFFSET_SUCCESSCODE ) );
       
  4594 
       
  4595     if ( NET_CAUSE_OK == successCode )
       
  4596         {
       
  4597 TFLOGSTRING("TSY: CMmCustomMessHandler::NetNeighbourCellsResp - NET_CAUSE_OK");
       
  4598 OstTrace0( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_NETNEIGHBOURCELLSRESP, "CMmCustomMessHandler::NetNeighbourCellsResp, NET_CAUSE_OK" );
       
  4599 
       
  4600         TUint sbOffset( 0 );
       
  4601 
       
  4602         if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  4603             ISI_HEADER_SIZE + SIZE_NET_NEIGHBOUR_CELLS_RESP,
       
  4604             NET_ECID_GERAN_INFO,
       
  4605             EIsiSubBlockTypeId8Len8,
       
  4606             sbOffset ) )
       
  4607             {
       
  4608             // GSM cell info.
       
  4609 TFLOGSTRING("TSY: CMmCustomMessHandler::NetNeighbourCellsResp - NET_ECID_GERAN_INFO found");
       
  4610 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_NETNEIGHBOURCELLSRESP, "CMmCustomMessHandler::NetNeighbourCellsResp - NET_ECID_GERAN_INFO found" );
       
  4611             // Set mode
       
  4612             tempECIDInfo.iCellInfo.iMode = RMmCustomAPI::TMmCellInfo::EGSM;
       
  4613 
       
  4614             // Set Current MCC.
       
  4615             tempECIDInfo.iMCC = aIsiMessage.Get16bit(
       
  4616                 sbOffset + NET_ECID_GERAN_INFO_OFFSET_CURRENTMCC );
       
  4617 
       
  4618             // Set Current MNC.
       
  4619             tempECIDInfo.iMNC = aIsiMessage.Get16bit(
       
  4620                 sbOffset + NET_ECID_GERAN_INFO_OFFSET_CURRENTMNC );
       
  4621 
       
  4622             // Set Current LAC.
       
  4623             tempECIDInfo.iLAC = aIsiMessage.Get16bit(
       
  4624                 sbOffset + NET_ECID_GERAN_INFO_OFFSET_CURRENTLAC );
       
  4625 
       
  4626             // Set Current Cell ID.
       
  4627             tempECIDInfo.iCID = aIsiMessage.Get16bit(
       
  4628                 sbOffset + NET_ECID_GERAN_INFO_OFFSET_CURRENTCELLID );
       
  4629 
       
  4630             // Set Current TA.
       
  4631             TUint8 temp8bitUVal( aIsiMessage.Get8bit(
       
  4632                 sbOffset + NET_ECID_GERAN_INFO_OFFSET_CURRENTTA ) );
       
  4633 
       
  4634             if ( NET_ECID_TA_UNDEFINED != temp8bitUVal )
       
  4635                 {
       
  4636                 tempECIDInfo.iCellInfo.iGsmCellInfo.iTA = temp8bitUVal;
       
  4637                 }
       
  4638             // No else.
       
  4639 
       
  4640             // Get Number of Neighbours included.
       
  4641             TUint8 nmrCount( aIsiMessage.Get8bit(
       
  4642                 sbOffset + NET_ECID_GERAN_INFO_OFFSET_NNMR ) );
       
  4643 
       
  4644             // Set NMR list.
       
  4645             for ( TUint8 i = 0; i < nmrCount; i++ )
       
  4646                 {
       
  4647                 // Set Carrier number.
       
  4648                 tempECIDInfo.iCellInfo.iGsmCellInfo.iNmr[ i ].iARFCN =
       
  4649                     aIsiMessage.Get16bit(
       
  4650                         sbOffset + NET_ECID_GERAN_INFO_OFFSET_GSMNMRLIST +
       
  4651                         ( i * SIZE_NET_GSM_NMR_LIST_SEQ ) +
       
  4652                         NET_GSM_NMR_LIST_SEQ_OFFSET_ARFCN );
       
  4653                 // Set BSIC.
       
  4654                 tempECIDInfo.iCellInfo.iGsmCellInfo.iNmr[ i ].iBSIC =
       
  4655                     aIsiMessage.Get8bit(
       
  4656                         sbOffset + NET_ECID_GERAN_INFO_OFFSET_GSMNMRLIST +
       
  4657                         ( i * SIZE_NET_GSM_NMR_LIST_SEQ ) +
       
  4658                         NET_GSM_NMR_LIST_SEQ_OFFSET_BSIC );
       
  4659                 // Set RX level.
       
  4660                 tempECIDInfo.iCellInfo.iGsmCellInfo.iNmr[ i ].iRxLEV =
       
  4661                     aIsiMessage.Get8bit(
       
  4662                         sbOffset + NET_ECID_GERAN_INFO_OFFSET_GSMNMRLIST +
       
  4663                         ( i * SIZE_NET_GSM_NMR_LIST_SEQ ) +
       
  4664                         NET_GSM_NMR_LIST_SEQ_OFFSET_RXLEVEL );
       
  4665                 }
       
  4666             }
       
  4667         else if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  4668             ISI_HEADER_SIZE + SIZE_NET_NEIGHBOUR_CELLS_RESP,
       
  4669             NET_ECID_UTRAN_FDD_INFO,
       
  4670             EIsiSubBlockTypeId8Len16,
       
  4671             sbOffset ) )
       
  4672             {
       
  4673             // WCDMA cell info.
       
  4674 TFLOGSTRING("TSY: CMmCustomMessHandler::NetNeighbourCellsResp - NET_ECID_UTRAN_FDD_INFO found");
       
  4675 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_NETNEIGHBOURCELLSRESP, "CMmCustomMessHandler::NetNeighbourCellsResp - NET_ECID_UTRAN_FDD_INFO found" );
       
  4676             // Set mode.
       
  4677             tempECIDInfo.iCellInfo.iMode = RMmCustomAPI::TMmCellInfo::EWCDMA;
       
  4678 
       
  4679             // Set UCID.
       
  4680             tempECIDInfo.iCID = aIsiMessage.Get32bit(
       
  4681                 sbOffset + NET_ECID_UTRAN_FDD_INFO_OFFSET_UCID );
       
  4682 
       
  4683             // Set current MCC.
       
  4684             tempECIDInfo.iMCC = aIsiMessage.Get16bit(
       
  4685                 sbOffset + NET_ECID_UTRAN_FDD_INFO_OFFSET_CURRENTMCC );
       
  4686 
       
  4687             // Set current MNC.
       
  4688             tempECIDInfo.iMNC = aIsiMessage.Get16bit(
       
  4689                 sbOffset + NET_ECID_UTRAN_FDD_INFO_OFFSET_CURRENTMNC );
       
  4690 
       
  4691             // Set current LAC (new value not received here).
       
  4692             tempECIDInfo.iLAC = iECIDInfo.iLAC;
       
  4693 
       
  4694             // Set primary scrambling code.
       
  4695             tempECIDInfo.iCellInfo.iWcdmaCellInfo.iPrimaryScrambilingCode =
       
  4696                 aIsiMessage.Get16bit(
       
  4697                     sbOffset + NET_ECID_UTRAN_FDD_INFO_OFFSET_PRISCRAMBLING );
       
  4698 
       
  4699             // Set Frequency Info.
       
  4700             // Set frequency Info (Uplink UARFCN and UARFCN-Nt not available)
       
  4701             // Downlink UARFCN.
       
  4702             tempECIDInfo.iCellInfo.iWcdmaCellInfo.iFrequencyInfo.iFddDL =
       
  4703                 aIsiMessage.Get16bit(
       
  4704                     sbOffset + NET_ECID_UTRAN_FDD_INFO_OFFSET_UARFCNDL );
       
  4705 
       
  4706             // Get number of neighbours included.
       
  4707             TUint8 nmrCount( aIsiMessage.Get8bit(
       
  4708                 sbOffset + NET_ECID_UTRAN_FDD_INFO_OFFSET_NNMR ) );
       
  4709 
       
  4710             // Set nmrListOffset to starting position of first NMR list.
       
  4711             TUint nmrListOffset(
       
  4712                 sbOffset + NET_ECID_UTRAN_FDD_INFO_OFFSET_WCDMANMRLIST );
       
  4713 
       
  4714             // Handle NMR lists.
       
  4715             for ( TUint8 i( 0 ); i < nmrCount; i++ )
       
  4716                 {
       
  4717                 // Set Frequency Info: Downlink UARFCN.
       
  4718                 tempECIDInfo.iCellInfo.iWcdmaCellInfo.
       
  4719                     iNwkMeasureReport[i].iFrequencyInfo.iFddDL =
       
  4720                         aIsiMessage.Get16bit( nmrListOffset );
       
  4721 
       
  4722                 // Uplink UARFCN and UARFCN-Nt not available, set to -1.
       
  4723                 tempECIDInfo.iCellInfo.iWcdmaCellInfo.
       
  4724                     iNwkMeasureReport[i].iFrequencyInfo.iFddUL = -1;
       
  4725                 tempECIDInfo.iCellInfo.iWcdmaCellInfo.
       
  4726                     iNwkMeasureReport[i].iFrequencyInfo.iTddNt = -1;
       
  4727 
       
  4728                 // Set UTRA Carrier RSSI.
       
  4729                 tempECIDInfo.iCellInfo.iWcdmaCellInfo.
       
  4730                     iNwkMeasureReport[i].iCarrierRSSI =
       
  4731                         aIsiMessage.Get8bit(
       
  4732                             nmrListOffset +
       
  4733                             NET_UTRAN_NEIGH_LIST_SEQ_OFFSET_UCRSSI );
       
  4734 
       
  4735                 // Get number of cells included.
       
  4736                 TUint8 cellCount( aIsiMessage.Get8bit(
       
  4737                     nmrListOffset + NET_UTRAN_NEIGH_LIST_SEQ_OFFSET_NCELL ) );
       
  4738 
       
  4739                 // Set nmrListOffset to starting position of first 'detailed
       
  4740                 // cell information'.
       
  4741                 nmrListOffset += 4;
       
  4742 
       
  4743                 // Handle detailed cell information.
       
  4744                 for ( TUint8 f( 0 ); f < cellCount; f++ )
       
  4745                     {
       
  4746                     // Set UCID.
       
  4747                     TUint32 temp32bitUVal(
       
  4748                         aIsiMessage.Get32bit( nmrListOffset ) );
       
  4749 
       
  4750                     if ( NET_ECID_UCID_UNDEFINED != temp32bitUVal )
       
  4751                         {
       
  4752                         tempECIDInfo.iCellInfo.iWcdmaCellInfo.
       
  4753                             iNwkMeasureReport[i].iCellMeasuredResult[f].iCID =
       
  4754                                 temp32bitUVal;
       
  4755                         }
       
  4756                     // No else.
       
  4757 
       
  4758                     // Set Primary CPICH.
       
  4759                     tempECIDInfo.iCellInfo.iWcdmaCellInfo.
       
  4760                         iNwkMeasureReport[i].iCellMeasuredResult[f].
       
  4761                             iFddInfo.iPrimaryCPICH = aIsiMessage.Get16bit(
       
  4762                                 nmrListOffset +
       
  4763                                     NET_UTRAN_CELL_LIST_SEQ_OFFSET_PCPICH );
       
  4764 
       
  4765                     // Set CPICH Ec NO.
       
  4766                     TUint8 temp8bitUVal( aIsiMessage.Get8bit(
       
  4767                         nmrListOffset +
       
  4768                             NET_UTRAN_CELL_LIST_SEQ_OFFSET_CPICHECNO ) );
       
  4769 
       
  4770                     if ( NET_ECID_CPICH_ECNO_UNDEFINED != temp8bitUVal )
       
  4771                         {
       
  4772                         tempECIDInfo.iCellInfo.iWcdmaCellInfo.
       
  4773                             iNwkMeasureReport[i].iCellMeasuredResult[f].
       
  4774                                 iFddInfo.iCpichEcN0 = temp8bitUVal;
       
  4775                         }
       
  4776                     // No else.
       
  4777 
       
  4778                     // Set CPICH RSCP.
       
  4779                     tempECIDInfo.iCellInfo.iWcdmaCellInfo.
       
  4780                         iNwkMeasureReport[i].iCellMeasuredResult[f].
       
  4781                             iFddInfo.iCpichRscp = aIsiMessage.Get8bit(
       
  4782                                 nmrListOffset +
       
  4783                                     NET_UTRAN_CELL_LIST_SEQ_OFFSET_CPICHRSCP );
       
  4784 
       
  4785                     // Set Pathloss.
       
  4786                     temp8bitUVal = aIsiMessage.Get8bit(
       
  4787                             nmrListOffset +
       
  4788                                 NET_UTRAN_CELL_LIST_SEQ_OFFSET_PATHLOSS );
       
  4789 
       
  4790                     if ( NET_ECID_PATHLOSS_UNDEFINED != temp8bitUVal )
       
  4791                         {
       
  4792                         tempECIDInfo.iCellInfo.iWcdmaCellInfo.
       
  4793                             iNwkMeasureReport[i].iCellMeasuredResult[f].
       
  4794                                 iFddInfo.iPathloss = temp8bitUVal;
       
  4795                         }
       
  4796                     // No else.
       
  4797 
       
  4798                     // Increase nmrListOffset to starting point of the next
       
  4799                     // element of 'detailed cell information'.
       
  4800                     nmrListOffset += SIZE_NET_UTRAN_CELL_LIST_SEQ;
       
  4801                     }
       
  4802                 }
       
  4803             }
       
  4804         else
       
  4805             {
       
  4806 TFLOGSTRING("TSY: CMmCustomMessHandler::NetNeighbourCellsResp - No ECID data found");
       
  4807 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_NETNEIGHBOURCELLSRESP, "CMmCustomMessHandler::NetNeighbourCellsResp - No ECID data found" );
       
  4808             ret = KErrNotFound;
       
  4809             }
       
  4810         }
       
  4811     else
       
  4812         {
       
  4813 TFLOGSTRING2("TSY: CMmCustomMessHandler::NetNeighbourCellsResp - NET Server Error, Success Code: %d", successCode);
       
  4814 OstTraceExt1( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_NETNEIGHBOURCELLSRESP, "CMmCustomMessHandler::NetNeighbourCellsResp;NET Server Error, Success Code=%hhu", successCode );
       
  4815 
       
  4816         // Map cause to symbian error value.
       
  4817         ret = CMmStaticUtility::CSCauseToEpocError(
       
  4818             PN_MODEM_NETWORK,
       
  4819             KTsyNetCauseCommon,
       
  4820             successCode );
       
  4821         }
       
  4822 
       
  4823     // Complete get request.
       
  4824     if ( iECIDInfoRequested )
       
  4825         {
       
  4826         iECIDInfoRequested = EFalse;
       
  4827 
       
  4828         // Complete with packed parameter.
       
  4829         CMmDataPackage dataPackage;
       
  4830         dataPackage.PackData( &tempECIDInfo.iCellInfo );
       
  4831 
       
  4832         iMessageRouter->Complete(
       
  4833             ECustomGetCellInfoIPC,
       
  4834             &dataPackage,
       
  4835             ret );
       
  4836         }
       
  4837     // No else.
       
  4838 
       
  4839     // If info received, save and complete change notification.
       
  4840     if ( KErrNone == ret )
       
  4841         {
       
  4842         if ( iECIDInfo.iCellInfo.iMode != tempECIDInfo.iCellInfo.iMode ||
       
  4843             iECIDInfo.iMCC != tempECIDInfo.iMCC ||
       
  4844             iECIDInfo.iMNC != tempECIDInfo.iMNC ||
       
  4845             iECIDInfo.iCID != tempECIDInfo.iCID ||
       
  4846             iECIDInfo.iLAC != tempECIDInfo.iLAC )
       
  4847             {
       
  4848             // Complete with packed parameter.
       
  4849             CMmDataPackage dataPackage;
       
  4850             dataPackage.PackData( &tempECIDInfo.iCellInfo );
       
  4851 
       
  4852             iMessageRouter->Complete(
       
  4853                 ECustomNotifyCellInfoChangeIPC,
       
  4854                 &dataPackage,
       
  4855                 KErrNone );
       
  4856             }
       
  4857         // No else.
       
  4858 
       
  4859         // Save ECID information.
       
  4860         iECIDInfo = tempECIDInfo;
       
  4861         }
       
  4862     // No else.
       
  4863     }
       
  4864 
       
  4865 // -----------------------------------------------------------------------------
       
  4866 // CMmCustomMessHandler::CheckECIDInfo
       
  4867 // This method breaks received NET_MODEM_REG_STATUS_IND or
       
  4868 // NET_MODEM_REG_STATUS_GET_RESP message and checks if enhanced cell
       
  4869 // information is chaged ( => needs to be requested/updated ).
       
  4870 // (other items were commented in a header).
       
  4871 // -----------------------------------------------------------------------------
       
  4872 //
       
  4873 void CMmCustomMessHandler::CheckECIDInfo(
       
  4874     const TIsiReceiveC& aIsiMessage )
       
  4875     {
       
  4876 TFLOGSTRING("TSY: CMmCustomMessHandler::CheckECIDInfo");
       
  4877 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_CHECKECIDINFO, "CMmCustomMessHandler::CheckECIDInfo" );
       
  4878 
       
  4879     TUint8 msgId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
       
  4880 
       
  4881     if ( NET_MODEM_REG_STATUS_IND == msgId ||
       
  4882         NET_MODEM_REG_STATUS_GET_RESP == msgId )
       
  4883         {
       
  4884         // Check if cell information needs to be updated.
       
  4885         TBool isNetRetStatusInd( NET_MODEM_REG_STATUS_IND == msgId );
       
  4886 
       
  4887 TFLOGSTRING("TSY:CMmCustomMessHandler::CheckECIDInfo - Find NET_MODEM_CURRENT_CELL_INFO SubBlock");
       
  4888 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_CHECKECIDINFO, "CMmCustomMessHandler::CheckECIDInfo - Find NET_MODEM_CURRENT_CELL_INFO SubBlock" );
       
  4889         // Get NET_MODEM_CURRENT_CELL_INFO sub block
       
  4890         // (should be always used when exists (coming when in 3G/RRC
       
  4891         // connected mode), otherwise NET_MODEM_GSM_REG_INFO is used).
       
  4892 
       
  4893         TUint sbStartOffSet( 0 );
       
  4894         TInt retValue( KErrNone );
       
  4895 
       
  4896         if ( isNetRetStatusInd )
       
  4897             {
       
  4898             retValue = aIsiMessage.FindSubBlockOffsetById(
       
  4899                 ISI_HEADER_SIZE + SIZE_NET_MODEM_REG_STATUS_IND,
       
  4900                 NET_MODEM_CURRENT_CELL_INFO,
       
  4901                 EIsiSubBlockTypeId8Len8,
       
  4902                 sbStartOffSet );
       
  4903             }
       
  4904         else
       
  4905             {
       
  4906             retValue = aIsiMessage.FindSubBlockOffsetById(
       
  4907                 ISI_HEADER_SIZE + SIZE_NET_MODEM_REG_STATUS_GET_RESP,
       
  4908                 NET_MODEM_CURRENT_CELL_INFO,
       
  4909                 EIsiSubBlockTypeId8Len8,
       
  4910                 sbStartOffSet );
       
  4911             }
       
  4912 
       
  4913         // Get NET_MODEM_GSM_REG_INFO sub block.
       
  4914         if ( KErrNone != retValue )
       
  4915             {
       
  4916 TFLOGSTRING("TSY:CMmCustomMessHandler::CheckECIDInfo - Find NET_MODEM_GSM_REG_INFO SubBlock");
       
  4917 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_CHECKECIDINFO, "CMmCustomMessHandler::CheckECIDInfo - Find NET_MODEM_GSM_REG_INFO SubBlock" );
       
  4918 
       
  4919             sbStartOffSet = 0;
       
  4920 
       
  4921             if ( isNetRetStatusInd )
       
  4922                 {
       
  4923                 retValue = aIsiMessage.FindSubBlockOffsetById(
       
  4924                     ISI_HEADER_SIZE + SIZE_NET_MODEM_REG_STATUS_IND,
       
  4925                     NET_MODEM_GSM_REG_INFO,
       
  4926                     EIsiSubBlockTypeId8Len8,
       
  4927                     sbStartOffSet );
       
  4928                 }
       
  4929             else
       
  4930                 {
       
  4931                 retValue = aIsiMessage.FindSubBlockOffsetById(
       
  4932                     ISI_HEADER_SIZE + SIZE_NET_MODEM_REG_STATUS_GET_RESP,
       
  4933                     NET_MODEM_GSM_REG_INFO,
       
  4934                     EIsiSubBlockTypeId8Len8,
       
  4935                     sbStartOffSet );
       
  4936                 }
       
  4937             }
       
  4938         // No else.
       
  4939 
       
  4940         // If subblock found.
       
  4941         if ( KErrNone == retValue )
       
  4942             {
       
  4943 TFLOGSTRING("TSY:CMmCustomMessHandler::CheckECIDInfo - SubBlock Found");
       
  4944 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_CHECKECIDINFO, "CMmCustomMessHandler::CheckECIDInfo, SubBlock Found" );
       
  4945             TUint tempMCC( 0 ); // Mobile Country Code.
       
  4946             TUint tempMNC( 0 ); // Mobile Network Code.
       
  4947             TUint tempCID( 0 ); // Cell identity.
       
  4948             TUint tempLAC( 0 ); // Location area code.
       
  4949 
       
  4950             // Get the Location Area Code.
       
  4951             tempLAC = aIsiMessage.Get16bit(
       
  4952                 sbStartOffSet +
       
  4953                 NET_MODEM_CURRENT_CELL_INFO_OFFSET_CURRENTLAC );
       
  4954             // Get the Cell Id.
       
  4955             tempCID = aIsiMessage.Get32bit(
       
  4956                 sbStartOffSet +
       
  4957                 NET_MODEM_CURRENT_CELL_INFO_OFFSET_CURRENTCELLID );
       
  4958 
       
  4959             // Get the operator code. Size is 3 bytes.
       
  4960             TPtrC8 operatorCode( aIsiMessage.GetData(
       
  4961                 sbStartOffSet +
       
  4962                 NET_MODEM_CURRENT_CELL_INFO_OFFSET_OPERATORCODE,
       
  4963                 3 ) );
       
  4964 
       
  4965             // Map the operator code to symbian values (MCC and MNC).
       
  4966             RMobilePhone::TMobilePhoneNetworkIdentity networkId;
       
  4967             RMobilePhone::TMobilePhoneNetworkCountryCode countryCode;
       
  4968             iNetMessHandler->MapOperatorAndCountryCode(
       
  4969                                  operatorCode,
       
  4970                                  networkId,
       
  4971                                  countryCode );
       
  4972             // Convert descriptor contained number to integer.
       
  4973             CMmStaticUtility::GetIntFromDescriptor(
       
  4974                 tempMCC,
       
  4975                 countryCode );
       
  4976             CMmStaticUtility::GetIntFromDescriptor(
       
  4977                 tempMNC,
       
  4978                 networkId );
       
  4979 
       
  4980             // If changed, request new ECID information.
       
  4981             if ( iECIDInfo.iMCC != tempMCC ||
       
  4982                 iECIDInfo.iMNC != tempMNC ||
       
  4983                 iECIDInfo.iCID != tempCID ||
       
  4984                 iECIDInfo.iLAC != tempLAC )
       
  4985                 {
       
  4986                 TUint8 transId( KCustomTransId );
       
  4987                 NetNeighbourCellsReq( transId );
       
  4988                 // Save current LAC.
       
  4989                 // (not received in NetNeighbourCellsResp when in 3G).
       
  4990                 iECIDInfo.iLAC = tempLAC;
       
  4991                 }
       
  4992             // No else.
       
  4993             }
       
  4994         // No else.
       
  4995         }
       
  4996     // No else.
       
  4997     }
       
  4998 
       
  4999 // -----------------------------------------------------------------------------
       
  5000 // CMmCustomMessHandler::HandleError
       
  5001 // Handles CMmCustomMessHandler's errors that comes
       
  5002 // via PhoNetReceiver RunError method.
       
  5003 // (other items were commented in a header).
       
  5004 // -----------------------------------------------------------------------------
       
  5005 //
       
  5006 void CMmCustomMessHandler::HandleError
       
  5007     (
       
  5008       const TIsiReceiveC& aIsiMessage, TInt aError
       
  5009       )
       
  5010     {
       
  5011     TFLOGSTRING2( "TSY: CMmCustomMessHandler::HandleError - Error: %d", aError );
       
  5012 OstTrace1( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_HANDLEERROR, "CMmCustomMessHandler::HandleError;aError=%d", aError );
       
  5013 
       
  5014     TInt resource( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_RESOURCEID ) );
       
  5015     TInt messageId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
       
  5016     TUint8 transId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID ) );
       
  5017     TUint8 serviceType( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_SUBMESSAGEID ) );
       
  5018 
       
  5019     switch( resource )
       
  5020         {
       
  5021         default:
       
  5022             {
       
  5023             TFLOGSTRING("TSY: CMmCustomMessHandler::HandleError, switch resource - default.\n" );
       
  5024 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_HANDLEERROR, "CMmCustomMessHandler::HandleError, switch resource - default" );
       
  5025             // Nothing to do here.
       
  5026             break;
       
  5027             }
       
  5028         } // end switch ( resource )
       
  5029     }
       
  5030 
       
  5031 // not suppoted for S60 ver 3.2
       
  5032 #if ( NCP_COMMON_S60_VERSION_SUPPORT != S60_VERSION_32 )
       
  5033 
       
  5034 // -----------------------------------------------------------------------------
       
  5035 // CMmCustomMessHandler::GssCsServiceSetBandReq
       
  5036 // Creates and sends via phonet a GSS_CS_SERVICE_REQ including
       
  5037 // selected band mode (ENetworkBandAny, ENetworkBandUmts850, ENetworkBandUmts2100).
       
  5038 // Affects only in Umts or Dual mode.
       
  5039 // -----------------------------------------------------------------------------
       
  5040 //
       
  5041 TInt CMmCustomMessHandler::GssCsServiceSetBandReq( TUint8 aTransId, // transaction Id
       
  5042         RMmCustomAPI::TNetworkModeCaps aNetworkModeCaps, // network mode caps
       
  5043         RMmCustomAPI::TBandSelection aBandSelection ) // band selection
       
  5044     {
       
  5045     TFLOGSTRING2( "TSY: CMmCustomMessHandler::GssCsServiceSetBandReq - aTransId: %d", aTransId );
       
  5046 OstTraceExt1( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_GSSCSSERVICESETBANDREQ, "CMmCustomMessHandler::GssCsServiceSetBandReq;aTransId=%hhu", aTransId );
       
  5047 
       
  5048     if ( RMmCustomAPI::KCapsNetworkModeUmts == aNetworkModeCaps ||
       
  5049          RMmCustomAPI::KCapsNetworkModeDual == aNetworkModeCaps )
       
  5050         {
       
  5051         TFLOGSTRING3( "TSY: CMmCustomMessHandler::GssCsServiceSetBandReq - NWModeCaps: %d - Band: %d",
       
  5052             aNetworkModeCaps, aBandSelection );
       
  5053 OstTraceExt2( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_GSSCSSERVICESETBANDREQ, "CMmCustomMessHandler::GssCsServiceSetBandReq; - NWModeCaps=%d - Band=%d", aNetworkModeCaps, aBandSelection );
       
  5054 
       
  5055         // create message data buffer
       
  5056         TBuf8< 20 > messageData;
       
  5057         messageData.Append( GSS_SELECTED_BANDS_WRITE ); // append service type
       
  5058         messageData.Append( 1 ); // number of subblocks
       
  5059 
       
  5060         // subblock
       
  5061         messageData.Append( GSS_SELECTED_UMTS_BAND_INFO ); // append band info
       
  5062         messageData.Append( 0x08 ); // subblock length
       
  5063         messageData.Append( KCustomPadding );
       
  5064         messageData.Append( KCustomPadding );
       
  5065 
       
  5066         if ( RMmCustomAPI::ENetworkBandUmts850 == aBandSelection )
       
  5067             {
       
  5068             messageData.Append( TUint8( GSS_UMTS_BAND_V_MASK >> 24 ) );
       
  5069             messageData.Append( TUint8( GSS_UMTS_BAND_V_MASK >> 16 ) );
       
  5070             messageData.Append( TUint8( GSS_UMTS_BAND_V_MASK >> 8 ) );
       
  5071             messageData.Append( TUint8( GSS_UMTS_BAND_V_MASK ) );
       
  5072             }
       
  5073         else if ( RMmCustomAPI::ENetworkBandUmts2100 == aBandSelection )
       
  5074             {
       
  5075             messageData.Append( TUint8( GSS_UMTS_BAND_I_MASK >> 24 ) );
       
  5076             messageData.Append( TUint8( GSS_UMTS_BAND_I_MASK >> 16 ) );
       
  5077             messageData.Append( TUint8( GSS_UMTS_BAND_I_MASK >> 8 ) );
       
  5078             messageData.Append( TUint8( GSS_UMTS_BAND_I_MASK ) );
       
  5079             }
       
  5080         else // ENetworkBandAny
       
  5081             {
       
  5082             messageData.Append( TUint8( GSS_UMTS_ALL_BANDS >> 24 ) );
       
  5083             messageData.Append( TUint8( GSS_UMTS_ALL_BANDS >> 16 ) );
       
  5084             messageData.Append( TUint8( GSS_UMTS_ALL_BANDS >> 8 ) );
       
  5085             messageData.Append( TUint8( GSS_UMTS_ALL_BANDS ) );
       
  5086             }
       
  5087 
       
  5088         return iPhoNetSender->Send( PN_GSS, aTransId, GSS_CS_SERVICE_REQ, messageData );
       
  5089         }
       
  5090 
       
  5091     return KErrNotSupported;
       
  5092     }
       
  5093 
       
  5094 // -----------------------------------------------------------------------------
       
  5095 // CMmCustomMessHandler::GssCsServiceGetBandReq
       
  5096 // Creates request to get current band.
       
  5097 // -----------------------------------------------------------------------------
       
  5098 //
       
  5099 TInt CMmCustomMessHandler::GssCsServiceGetBandReq( TUint8 aTransId ) //transaction Id
       
  5100     {
       
  5101     TFLOGSTRING2( "TSY: CMmCustomMessHandler::GssCsServiceGetBandReq - aTransId: %d", aTransId );
       
  5102 OstTraceExt1( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_GSSCSSERVICEGETBANDREQ, "CMmCustomMessHandler::GssCsServiceGetBandReq;aTransId=%hhu", aTransId );
       
  5103 
       
  5104     // create message data buffer
       
  5105     TBuf8< 4 > messageData;
       
  5106     messageData.Append( GSS_SELECTED_BANDS_READ ); // append service type
       
  5107     messageData.Append( 0 ); // No subblocks
       
  5108 
       
  5109     return iPhoNetSender->Send( PN_GSS, aTransId, GSS_CS_SERVICE_REQ, messageData );
       
  5110     }
       
  5111 
       
  5112 
       
  5113 // -----------------------------------------------------------------------------
       
  5114 // CMmCustomMessHandler::CompleteGetBandSelection
       
  5115 // Completes and breaks Get band selection request via PhoNetReceiver method.
       
  5116 // -----------------------------------------------------------------------------
       
  5117 //
       
  5118 void CMmCustomMessHandler::CompleteGetBandSelection( const TIsiReceiveC& aIsiMessage )
       
  5119     {
       
  5120     TFLOGSTRING("TSY: CMmCustomMessHandler::CompleteGetBandSelection");
       
  5121 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_COMPLETEGETBANDSELECTION, "CMmCustomMessHandler::CompleteGetBandSelection" );
       
  5122 
       
  5123     RMmCustomAPI::TNetworkModeCaps nwModeCaps; // network mode caps
       
  5124     RMmCustomAPI::TBandSelection bandSelection; // band selection
       
  5125     bandSelection = RMmCustomAPI::ENetworkBandAny; // set "any" as a default
       
  5126 
       
  5127     TUint8 nrOfSubblocks ( aIsiMessage.Get8bit( ISI_HEADER_SIZE +
       
  5128         GSS_CS_SERVICE_RESP_OFFSET_NBROFSUBBLOCKS ) );
       
  5129 
       
  5130     // first subblocks start from 'GSS_CS_SERVICE_RESP_OFFSET_NBROFSUBBLOCKS' + 1
       
  5131     TUint8 sbOffset ( ISI_HEADER_SIZE +
       
  5132         GSS_CS_SERVICE_RESP_OFFSET_NBROFSUBBLOCKS + 1 );
       
  5133 
       
  5134     TUint8 firstSubblock ( aIsiMessage.Get8bit( sbOffset ) );
       
  5135 
       
  5136     TFLOGSTRING2("TSY: CMmCustomMessHandler::CompleteGetBandSelection - ECustomGetBandSelectionIPC. NrOfSubblocks:%d", nrOfSubblocks);
       
  5137 OstTraceExt1( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_COMPLETEGETBANDSELECTION, "CMmCustomMessHandler::CompleteGetBandSelection;nrOfSubblocks=%hhu", nrOfSubblocks );
       
  5138 
       
  5139     // In 2G only products only sub block GSS_SELECTED_GSM_BANDS_INFO is returned.
       
  5140     if ( 1 == nrOfSubblocks && firstSubblock == GSS_SELECTED_GSM_BAND_INFO )
       
  5141         {
       
  5142         nwModeCaps = RMmCustomAPI::KCapsNetworkModeGsm;
       
  5143         }
       
  5144     else // 1 < nrOfSubblocks || GSS_SELECTED_UMTS_BAND_INFO
       
  5145         {
       
  5146         //Band info offsets for reading
       
  5147         TUint8 gsmBandInfoOffset = 0;
       
  5148         TUint8 umtsBandInfoOffset = 0;
       
  5149 
       
  5150         // first SB is GSS_SELECTED_GSM_BAND_INFO
       
  5151         if ( GSS_SELECTED_GSM_BAND_INFO == firstSubblock )
       
  5152             {
       
  5153             TFLOGSTRING("TSY: CMmCustomMessHandler::CompleteGetBandSelection - 1st SB = GSM BAND INFO");
       
  5154 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_COMPLETEGETBANDSELECTION, "CMmCustomMessHandler::CompleteGetBandSelection - 1st SB = GSM BAND INFO" );
       
  5155 
       
  5156             // calculate offsets
       
  5157             gsmBandInfoOffset = sbOffset +
       
  5158                 GSS_SELECTED_GSM_BAND_INFO_OFFSET_SELECTEDGSMBANDS;
       
  5159 
       
  5160             // if there are more than one subblock read offset for second one
       
  5161             if ( 1 < nrOfSubblocks )
       
  5162                 {
       
  5163                 umtsBandInfoOffset = sbOffset +
       
  5164                     SIZE_GSS_SELECTED_GSM_BAND_INFO +
       
  5165                     GSS_SELECTED_UMTS_BAND_INFO_OFFSET_SELECTEDUMTSBANDS;
       
  5166                 }
       
  5167             }
       
  5168         else if ( GSS_SELECTED_UMTS_BAND_INFO == firstSubblock )
       
  5169             {
       
  5170             TFLOGSTRING("TSY: CMmCustomMessHandler::CompleteGetBandSelection - 1st SB = UMTS BAND INFO");
       
  5171 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_COMPLETEGETBANDSELECTION, "CMmCustomMessHandler::CompleteGetBandSelection - 1st SB = UMTS BAND INFO" );
       
  5172 
       
  5173             // calculate offsets
       
  5174             umtsBandInfoOffset = sbOffset +
       
  5175                 GSS_SELECTED_UMTS_BAND_INFO_OFFSET_SELECTEDUMTSBANDS;
       
  5176 
       
  5177             // if there are more than one subblock read offset for second one
       
  5178             if ( 1 < nrOfSubblocks )
       
  5179                 {
       
  5180                 gsmBandInfoOffset = sbOffset +
       
  5181                     SIZE_GSS_SELECTED_UMTS_BAND_INFO +
       
  5182                     GSS_SELECTED_GSM_BAND_INFO_OFFSET_SELECTEDGSMBANDS;
       
  5183                 }
       
  5184             }
       
  5185 
       
  5186         //If phone is forced to GSM, value in GSS_SELECTED_UMTS_BAND_INFO shall be GSS_UMTS_NO_BANDS
       
  5187         if ( GSS_UMTS_NO_BANDS == aIsiMessage.Get32bit( umtsBandInfoOffset ) ) // forced GSM
       
  5188             {
       
  5189             TFLOGSTRING("TSY: CMmCustomMessHandler::CompleteGetBandSelection - umtsBandInfo==GSS_UMTS_NO_BANDS => Forced GSM");
       
  5190 OstTrace0( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_COMPLETEGETBANDSELECTION, "CMmCustomMessHandler::CompleteGetBandSelection - umtsBandInfo==GSS_UMTS_NO_BANDS => Forced GSM" );
       
  5191             nwModeCaps = RMmCustomAPI::KCapsNetworkModeGsm;
       
  5192             }
       
  5193         else
       
  5194             {
       
  5195             //If phone is forced to GSM, value in GSS_SELECTED_UMTS_BAND_INFO shall be GSS_UMTS_NO_BANDS.
       
  5196             if ( 0 < gsmBandInfoOffset && GSS_GSM_NO_BANDS == aIsiMessage.Get8bit( gsmBandInfoOffset ) ) // forced UMTS
       
  5197                 {
       
  5198                 TFLOGSTRING("TSY: CMmCustomMessHandler::CompleteGetBandSelection - gsmBandInfo==GSS_GSM_NO_BANDS => Forced UMTS");
       
  5199 OstTrace0( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_COMPLETEGETBANDSELECTION, "CMmCustomMessHandler::CompleteGetBandSelection - gsmBandInfo==GSS_GSM_NO_BANDS => Forced UMTS" );
       
  5200                 nwModeCaps = RMmCustomAPI::KCapsNetworkModeUmts;
       
  5201                 }
       
  5202             else // dual mode
       
  5203                 {
       
  5204                 TFLOGSTRING("TSY: CMmCustomMessHandler::CompleteGetBandSelection - Dual mode");
       
  5205 OstTrace0( TRACE_NORMAL, DUP6_CMMCUSTOMMESSHANDLER_COMPLETEGETBANDSELECTION, "CMmCustomMessHandler::CompleteGetBandSelection - Dual mode" );
       
  5206                 nwModeCaps = RMmCustomAPI::KCapsNetworkModeDual;
       
  5207                 }
       
  5208 
       
  5209             // Set network band
       
  5210             if ( GSS_UMTS_BAND_V_MASK == aIsiMessage.Get32bit( umtsBandInfoOffset ) )
       
  5211                 {
       
  5212                 TFLOGSTRING("TSY: CMmCustomMessHandler::CompleteGetBandSelection - UMTS850");
       
  5213 OstTrace0( TRACE_NORMAL, DUP7_CMMCUSTOMMESSHANDLER_COMPLETEGETBANDSELECTION, "CMmCustomMessHandler::CompleteGetBandSelection - UMTS850" );
       
  5214                 bandSelection = RMmCustomAPI::ENetworkBandUmts850;
       
  5215                 }
       
  5216             else if( GSS_UMTS_BAND_I_MASK == aIsiMessage.Get32bit( umtsBandInfoOffset ) )
       
  5217                 {
       
  5218                 TFLOGSTRING("TSY: CMmCustomMessHandler::CompleteGetBandSelection - UMTS2100");
       
  5219 OstTrace0( TRACE_NORMAL, DUP8_CMMCUSTOMMESSHANDLER_COMPLETEGETBANDSELECTION, "CMmCustomMessHandler::CompleteGetBandSelection - UMTS2100" );
       
  5220                 bandSelection = RMmCustomAPI::ENetworkBandUmts2100;
       
  5221                 }
       
  5222             }
       
  5223         }
       
  5224 
       
  5225     CMmDataPackage dataPackage;
       
  5226     dataPackage.PackData( &bandSelection, &nwModeCaps );
       
  5227     return iMessageRouter->Complete( ECustomGetBandSelectionIPC, &dataPackage, KErrNone );
       
  5228     }
       
  5229 
       
  5230 #endif // NCP_COMMON_S60_VERSION_SUPPORT
       
  5231 
       
  5232 // -----------------------------------------------------------------------------
       
  5233 // CMmCustomMessHandler::ReadLifeTimerFromPermanentMemory
       
  5234 // Constructs PERM_PM_RECORD_READ_REQ ISI message from input parameters and send
       
  5235 // it through phonet.
       
  5236 // -----------------------------------------------------------------------------
       
  5237 //
       
  5238 TInt CMmCustomMessHandler::ReadLifeTimerFromPermanentMemory
       
  5239         (
       
  5240         const TUint8 //aTransId
       
  5241         )
       
  5242     {
       
  5243 TFLOGSTRING("TSY: CMmCustomMessHandler::ReadLifeTimerFromPermanentMemory.\n" );
       
  5244 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_READLIFETIMERFROMPERMANENTMEMORY, "CMmCustomMessHandler::ReadLifeTimerFromPermanentMemory" );
       
  5245 
       
  5246     // Group ID 2 + Index 2 + Filler 2 + Offset 4 + Data amount to be read 4 = 14
       
  5247     TBuf8<14> data;
       
  5248 
       
  5249     // Append Group ID
       
  5250     data.Append( static_cast<TUint8>( KPmmGroupNokiaTsy >> 8 ) );
       
  5251     data.Append( static_cast<TUint8>( KPmmGroupNokiaTsy ) );
       
  5252 
       
  5253     // Append Call Life Timer Index
       
  5254     data.Append( static_cast<TUint8>( KCallLifeTimerPmmIndexValue >> 8 ) );
       
  5255     data.Append( static_cast<TUint8>( KCallLifeTimerPmmIndexValue ) );
       
  5256 
       
  5257     // Append Filler
       
  5258     data.AppendFill( KCustomPadding, KTwo );
       
  5259 
       
  5260     // Append Offset
       
  5261     data.AppendFill( KCustomPadding, KFour );
       
  5262 
       
  5263     // Append Data amount to be read
       
  5264     data.Append( static_cast<TUint8>( KCallLifeTimerDataAmount >> 24 ) );
       
  5265     data.Append( static_cast<TUint8>( KCallLifeTimerDataAmount >> 16 ) );
       
  5266     data.Append( static_cast<TUint8>( KCallLifeTimerDataAmount >> 8 ) );
       
  5267     data.Append( static_cast<TUint8>( KCallLifeTimerDataAmount ) );
       
  5268 
       
  5269     /* To be done in CPS
       
  5270     return iPhoNetSender->Send( PN_PERMANENT_DATA,
       
  5271         aTransId,
       
  5272         PERM_PM_RECORD_READ_REQ,
       
  5273         data );*/
       
  5274     return KErrNone;
       
  5275     }
       
  5276 
       
  5277 // -----------------------------------------------------------------------------
       
  5278 // CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse
       
  5279 // Breaks  PERM_PM_RECORD_READ_RESP message.
       
  5280 // -----------------------------------------------------------------------------
       
  5281 //
       
  5282 /* To be done in CPS
       
  5283 void CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse
       
  5284         (
       
  5285         const TIsiReceiveC& aIsiMessage    // an ISI message
       
  5286         )
       
  5287     {
       
  5288 TFLOGSTRING("TSY: CCMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse.\n" );
       
  5289 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_LIFETIMERFROMPERMANENTMEMORYREADRESPONSE, "CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse" );
       
  5290 
       
  5291     TInt ret( KErrNone );
       
  5292 
       
  5293     TUint8 pmmStatus = aIsiMessage.Get8bit(
       
  5294                ISI_HEADER_SIZE +
       
  5295                PERM_PM_RECORD_READ_RESP_OFFSET_PMMSTATUS );
       
  5296 
       
  5297     if ( PMM_OK == pmmStatus )
       
  5298         {
       
  5299         iPMMReadRetryCounter = 0; // NUL trial counter
       
  5300         TUint sbStartOffSet( 0 );
       
  5301         ret = aIsiMessage.FindSubBlockOffsetById(
       
  5302             ISI_HEADER_SIZE + SIZE_PERM_PM_RECORD_READ_RESP,
       
  5303             PERM_SB_PM_DATA,
       
  5304             EIsiSubBlockTypeId8Len8, sbStartOffSet );
       
  5305 
       
  5306         if ( KErrNone == ret )
       
  5307             {
       
  5308             TUint32 dataSize( aIsiMessage.Get32bit( sbStartOffSet +
       
  5309                         PERM_SB_PM_DATA_OFFSET_SIZE ) );
       
  5310             // Timer value size in message is 4 bytes. If some else length
       
  5311             // has been returned error code KErrGeneral is set and
       
  5312             // assert is done.
       
  5313             if ( KCallLifeTimerDataAmount == dataSize )
       
  5314                 {
       
  5315                 iCallLifeTimer = aIsiMessage.Get32bit( sbStartOffSet +
       
  5316                                      PERM_SB_PM_DATA_OFFSET_DATA );
       
  5317 TFLOGSTRING2( "TSY: CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse - iCallLifeTimer: %d", iCallLifeTimer );
       
  5318 OstTrace1( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_LIFETIMERFROMPERMANENTMEMORYREADRESPONSE, "CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse;iCallLifeTimer=%d", iCallLifeTimer );
       
  5319                 }
       
  5320             else
       
  5321                 {
       
  5322 TFLOGSTRING2( "TSY: CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse - Incorrect data size: %d", dataSize );
       
  5323 OstTrace1( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_LIFETIMERFROMPERMANENTMEMORYREADRESPONSE, "CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse - Incorrect data size=%u", dataSize );
       
  5324                 TF_ASSERT( KCallLifeTimerDataAmount != dataSize );
       
  5325                 ret = KErrGeneral;
       
  5326                 }
       
  5327             }
       
  5328         }
       
  5329     else
       
  5330         {
       
  5331         if ( PMM_NOT_READY == pmmStatus )
       
  5332             {
       
  5333             // Send request again max 3 times
       
  5334 TFLOGSTRING("TSY: CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse - PMM not ready. Send request again\n" );
       
  5335 OstTrace0( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_LIFETIMERFROMPERMANENTMEMORYREADRESPONSE, "CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse - PMM not ready. Send request again" );
       
  5336             iPMMReadRetryCounter++;
       
  5337             if ( KMaxPMMReadRequests > iPMMReadRetryCounter )
       
  5338                 {
       
  5339                 ReadLifeTimerFromPermanentMemory ( KCustomTransId );
       
  5340                 }
       
  5341             }
       
  5342         else if ( PMM_RECORD_NOT_FOUND == pmmStatus )
       
  5343             {
       
  5344             // The first boot of the phone.
       
  5345 TFLOGSTRING("TSY: CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse - The first boot. Set iCallLifeTimer 0\n" );
       
  5346             OstTrace0( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_LIFETIMERFROMPERMANENTMEMORYREADRESPONSE, "CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse - The first boot. Set iCallLifeTimer 0" );
       
  5347             iCallLifeTimer = 0;
       
  5348             }
       
  5349         else
       
  5350             {
       
  5351 TFLOGSTRING2( "TSY: CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse - PMM Status NOT OK: %d", pmmStatus );
       
  5352 OstTraceExt1( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_LIFETIMERFROMPERMANENTMEMORYREADRESPONSE, "CMmCustomMessHandler::LifeTimerFromPermanentMemoryReadResponse - PMM Status NOT OK=%hhu", pmmStatus );
       
  5353             }
       
  5354         }
       
  5355     }*/
       
  5356 
       
  5357 // -----------------------------------------------------------------------------
       
  5358 // CMmCustomMessHandler::WriteLifeTimerToPermanentMemory
       
  5359 // Constructs PERM_PM_RECORD_WRITE_REQ ISI message from input parameters and send
       
  5360 // it through phonet.
       
  5361 // -----------------------------------------------------------------------------
       
  5362 //
       
  5363 TInt CMmCustomMessHandler::WriteLifeTimerToPermanentMemory
       
  5364         (
       
  5365         const TUint8 /*aTransId*/,
       
  5366         TTimeIntervalSeconds aTime
       
  5367         )
       
  5368     {
       
  5369 TFLOGSTRING("TSY: CMmCustomMessHandler::WriteLifeTimerToPermanentMemory.\n" );
       
  5370 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_WRITELIFETIMERTOPERMANENTMEMORY, "CMmCustomMessHandler::WriteLifeTimerToPermanentMemory" );
       
  5371 
       
  5372     // Group ID 2 + Index 2 + Filler 2 + Offset 4 + Data amount to be read 4 = 14
       
  5373     TBuf8<14> data;
       
  5374 
       
  5375     // Append Group ID
       
  5376     data.Append( static_cast<TUint8>( KPmmGroupNokiaTsy >> 8 ) );
       
  5377     data.Append( static_cast<TUint8>( KPmmGroupNokiaTsy ) );
       
  5378 
       
  5379     // Append Call Life Timer Index
       
  5380     data.Append( static_cast<TUint8>( KCallLifeTimerPmmIndexValue >> 8 ) );
       
  5381     data.Append( static_cast<TUint8>( KCallLifeTimerPmmIndexValue ) );
       
  5382 
       
  5383     // Append Filler
       
  5384     data.AppendFill( KCustomPadding, KTwo );
       
  5385 
       
  5386     // Append Data amount to be written
       
  5387     data.Append( static_cast<TUint8>( KCallLifeTimerDataAmount >> 24 ) );
       
  5388     data.Append( static_cast<TUint8>( KCallLifeTimerDataAmount >> 16 ) );
       
  5389     data.Append( static_cast<TUint8>( KCallLifeTimerDataAmount >> 8 ) );
       
  5390     data.Append( static_cast<TUint8>( KCallLifeTimerDataAmount ) );
       
  5391 
       
  5392     if ( KCallLifeTimerNotSet == iCallLifeTimer )
       
  5393         {
       
  5394 TFLOGSTRING( "TSY: CMmCustomMessHandler::WriteLifeTimerToPermanentMemory - Call Life Timer is not set from PMM ret KErrNotReady\n" );
       
  5395 TFLOGSTRING("TSY: CMmCustomMessHandler::WriteLifeTimerToPermanentMemory - PERM_PM_RECORD_WRITE_REQ is NOT send\n" );
       
  5396 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_WRITELIFETIMERTOPERMANENTMEMORY, "CMmCustomMessHandler::WriteLifeTimerToPermanentMemory - Call Life Timer is not set from PMM ret KErrNotReady" );
       
  5397 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_WRITELIFETIMERTOPERMANENTMEMORY, "CMmCustomMessHandler::WriteLifeTimerToPermanentMemory - PERM_PM_RECORD_WRITE_REQ is NOT send" );
       
  5398 
       
  5399         // Return request with KErrNotReady
       
  5400         return ( KErrNotReady );
       
  5401         }
       
  5402     else
       
  5403         {
       
  5404         // Update Life Timer Value
       
  5405         iCallLifeTimer += aTime.Int();
       
  5406 
       
  5407         // Append Data
       
  5408         data.Append( static_cast<TUint8>( iCallLifeTimer >> 24 ) );
       
  5409         data.Append( static_cast<TUint8>( iCallLifeTimer >> 16 ) );
       
  5410         data.Append( static_cast<TUint8>( iCallLifeTimer >> 8 ) );
       
  5411         data.Append( static_cast<TUint8>( iCallLifeTimer ) );
       
  5412 
       
  5413         /* To be done in CPS
       
  5414         return iPhoNetSender->Send( PN_PERMANENT_DATA,
       
  5415             aTransId,
       
  5416             PERM_PM_RECORD_WRITE_REQ,
       
  5417             data );*/
       
  5418         return KErrNone;
       
  5419         }
       
  5420     }
       
  5421 
       
  5422 // -----------------------------------------------------------------------------
       
  5423 // CMmCustomMessHandler::LifeTimerToPermanentMemoryWriteResponse
       
  5424 // Breaks  PERM_PM_RECORD_WRITE_RESP message.
       
  5425 // -----------------------------------------------------------------------------
       
  5426 //
       
  5427 /* To be done in CPS
       
  5428 void CMmCustomMessHandler::LifeTimerToPermanentMemoryWriteResponse
       
  5429         (
       
  5430         const TIsiReceiveC& aIsiMessage    // an ISI message
       
  5431         )
       
  5432     {
       
  5433 TFLOGSTRING("TSY: CMmCustomMessHandler::LifeTimerToPermanentMemoryWriteResponse.\n" );
       
  5434 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_LIFETIMERTOPERMANENTMEMORYWRITERESPONSE, "CMmCustomMessHandler::LifeTimerToPermanentMemoryWriteResponse" );
       
  5435 
       
  5436     TInt ret( KErrNone );
       
  5437 
       
  5438     TUint8 pmmStatus = aIsiMessage.Get8bit(
       
  5439                ISI_HEADER_SIZE +
       
  5440                PERM_PM_RECORD_WRITE_RESP_OFFSET_PMMSTATUS );
       
  5441 TFLOGSTRING2( "TSY: CMmCustomMessHandler::LifeTimerToPermanentMemoryWriteResponse - pmmStatus: %d", pmmStatus );
       
  5442 OstTraceExt1( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_LIFETIMERTOPERMANENTMEMORYWRITERESPONSE, "CMmCustomMessHandler::LifeTimerToPermanentMemoryWriteResponse;pmmStatus=%hhu", pmmStatus );
       
  5443 
       
  5444     if ( PMM_OK != pmmStatus )
       
  5445         {
       
  5446         ret = KErrNotReady;
       
  5447         TF_ASSERT( PMM_OK != pmmStatus );
       
  5448 TFLOGSTRING2( "TSY: CMmCustomMessHandler::LifeTimerToPermanentMemoryWriteResponse - Call Life Timer is not updated / error from PMM ret: %d", ret );
       
  5449 OstTrace1( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_LIFETIMERTOPERMANENTMEMORYWRITERESPONSE, "CMmCustomMessHandler::LifeTimerToPermanentMemoryWriteResponse - Call Life Timer is not updated / error from PMM ret=%d", ret );
       
  5450         }
       
  5451 
       
  5452     return iMessageRouter->Complete( EMmTsyUpdateLifeTimeIPC, ret );
       
  5453     }*/
       
  5454 
       
  5455 // -----------------------------------------------------------------------------
       
  5456 // CMmCustomMessHandler::GetTotalLifeTimerValue
       
  5457 // Breaks  PERM_PM_RECORD_WRITE_RESP message.
       
  5458 // -----------------------------------------------------------------------------
       
  5459 //
       
  5460 TInt CMmCustomMessHandler::GetTotalLifeTimerValue
       
  5461         (
       
  5462         )
       
  5463     {
       
  5464 TFLOGSTRING("TSY: CMmCustomMessHandler::GetTotalLifeTimerValue.\n" );
       
  5465 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_GETTOTALLIFETIMERVALUE, "CMmCustomMessHandler::GetTotalLifeTimerValue" );
       
  5466 
       
  5467     TInt ret( KErrNone );
       
  5468     RMmCustomAPI::TLifeTimeData timeInfo;
       
  5469 
       
  5470     timeInfo.iHours = 0;
       
  5471     timeInfo.iMinutes = 0;
       
  5472 
       
  5473     if ( KCallLifeTimerNotSet == iCallLifeTimer )
       
  5474         {
       
  5475         ret = KErrNotReady;
       
  5476 TFLOGSTRING( "TSY: CMmCustomMessHandler::GetTotalLifeTimerValue - PMM has not been able to be read ret: KErrNotReady\n" );
       
  5477 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_GETTOTALLIFETIMERVALUE, "CMmCustomMessHandler::GetTotalLifeTimerValue - PMM has not been able to be read ret: KErrNotReady" );
       
  5478         }
       
  5479     else
       
  5480         {
       
  5481         //set the data into timeInfo class, one hour is 3600 seconds.
       
  5482         timeInfo.iHours = iCallLifeTimer / KSecsInHour ;
       
  5483         timeInfo.iMinutes =
       
  5484             static_cast<TUint8>( ( iCallLifeTimer % KSecsInHour ) /
       
  5485                                    KMinsInHour );
       
  5486         //update the caps
       
  5487         timeInfo.iCaps |=
       
  5488             RMmCustomAPI::TLifeTimeData::ELifeTimeDataCapsLifeTime;
       
  5489 TFLOGSTRING2( "TSY: TSY: CMmCustomMessHandler::GetTotalLifeTimerValue - iCallLifeTimer: %d", iCallLifeTimer );
       
  5490 TFLOGSTRING2( "TSY: TSY: CMmCustomMessHandler::GetTotalLifeTimerValue - timeInfo.iHours: %d", timeInfo.iHours );
       
  5491 TFLOGSTRING2( "TSY: TSY: CMmCustomMessHandler::GetTotalLifeTimerValue - timeInfo.iMinutes: %d", timeInfo.iMinutes );
       
  5492 OstTrace1( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_GETTOTALLIFETIMERVALUE, "CMmCustomMessHandler::GetTotalLifeTimerValue;iCallLifeTimer=%d", iCallLifeTimer );
       
  5493 OstTrace1( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_GETTOTALLIFETIMERVALUE, "CMmCustomMessHandler::GetTotalLifeTimerValue;timeInfo.iHours=%u", timeInfo.iHours );
       
  5494 OstTraceExt1( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_GETTOTALLIFETIMERVALUE, "CMmCustomMessHandler::GetTotalLifeTimerValue;timeInfo.iMinutes=%hhu", timeInfo.iMinutes );
       
  5495         }
       
  5496 
       
  5497     CMmDataPackage dataPackage;
       
  5498     dataPackage.PackData( &timeInfo );
       
  5499     iMessageRouter->Complete( ECustomGetLifeTimeIPC, &dataPackage, ret );
       
  5500 
       
  5501     return( ret );
       
  5502     }
       
  5503 
       
  5504 // -----------------------------------------------------------------------------
       
  5505 // CMmCustomMessHandler::UiccSimPowerOffReq
       
  5506 // Disconnects UICC server from smartcard and activates UICC SAP APDU interface
       
  5507 // -----------------------------------------------------------------------------
       
  5508 //
       
  5509 TInt CMmCustomMessHandler::UiccSimPowerOffReq()
       
  5510     {
       
  5511 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSimPowerOffReq.\n");
       
  5512 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSIMPOWEROFFREQ, "CMmCustomMessHandler::UiccSimPowerOffReq" );
       
  5513 
       
  5514     iSapApduIfState = EUiccSapIfStatus1;
       
  5515     // Set parameters for UICC_CONNECTION_REQ message
       
  5516     TUiccParamsBase params;
       
  5517     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  5518     params.trId = ETrIdSimPowerOff;
       
  5519     params.serviceType = UICC_DISCONNECT;
       
  5520 
       
  5521     return iMmUiccMessHandler->CreateUiccConnectorReq( params );
       
  5522     }
       
  5523 
       
  5524 // -----------------------------------------------------------------------------
       
  5525 // CMmCustomMessHandler::UiccSimPowerOffResp
       
  5526 //
       
  5527 // -----------------------------------------------------------------------------
       
  5528 //
       
  5529 void CMmCustomMessHandler::UiccSimPowerOffResp( TInt aStatus )
       
  5530     {
       
  5531 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSimPowerOffResp.\n" );
       
  5532 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSIMPOWEROFFRESP, "CMmCustomMessHandler::UiccSimPowerOffResp" );
       
  5533 
       
  5534     TInt err ( KErrNone );
       
  5535 
       
  5536     if( aStatus == UICC_STATUS_OK )
       
  5537         {
       
  5538         switch( iSapApduIfState )
       
  5539             {
       
  5540             case EUiccSapIfStatus1:
       
  5541                 {
       
  5542                 // Set parameters for UICC_APDU_REQ message
       
  5543                 TUiccParamsApduReq params;
       
  5544                 params.messHandlerPtr = static_cast<MUiccOperationBase*>(
       
  5545                     this );
       
  5546                 params.trId = ETrIdSimPowerOff;
       
  5547                 params.serviceType = UICC_APDU_CONTROL;
       
  5548                 params.action = UICC_CONTROL_CARD_ACTIVATE;
       
  5549 
       
  5550                 err = iMmUiccMessHandler->CreateUiccApduReq( params );
       
  5551 
       
  5552                 iSapApduIfState = EUiccSapIfStatus2;
       
  5553                 break;
       
  5554                 }
       
  5555 
       
  5556             case EUiccSapIfStatus2:
       
  5557                 {
       
  5558                 // No handling for UICC_APDU_RESP,
       
  5559                 // wait for UICC_APDU_RESET_IND
       
  5560                 iSapApduIfState = EUiccSapIfStatus3;
       
  5561                 break;
       
  5562                 }
       
  5563 
       
  5564             case EUiccSapIfStatus3:
       
  5565                 {
       
  5566                 // UICC_APDU_RESET_IND, UICC_READY, SAP IF active
       
  5567                 iMessageRouter->Complete( ECustomPowerSimOffIPC, err );
       
  5568                 break;
       
  5569                 }
       
  5570             }
       
  5571         }
       
  5572     else
       
  5573         {
       
  5574         if( aStatus == UICC_STATUS_SHUTTING_DOWN )
       
  5575             {
       
  5576             err = CMmStaticUtility::EpocErrorCode( KErrNotReady, KErrNotFound );
       
  5577             }
       
  5578         else
       
  5579             {
       
  5580             // UICC_STATUS_FAIL
       
  5581             err = CMmStaticUtility::EpocErrorCode( KErrGeneral, KErrNotFound );
       
  5582             }
       
  5583         iMessageRouter->Complete( ECustomPowerSimOffIPC, err );
       
  5584         }
       
  5585     }
       
  5586 
       
  5587 // -----------------------------------------------------------------------------
       
  5588 // CMmCustomMessHandler::UiccSimWarmResetReq
       
  5589 //
       
  5590 // -----------------------------------------------------------------------------
       
  5591 //
       
  5592 TInt CMmCustomMessHandler::UiccSimWarmResetReq()
       
  5593     {
       
  5594 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSimWarmResetReq.\n" );
       
  5595 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSIMWARMRESETREQ, "CMmCustomMessHandler::UiccSimWarmResetReq" );
       
  5596 
       
  5597     TUiccParamsApduReq params;
       
  5598     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  5599     params.trId = ETrIdSimWarmReset;
       
  5600     params.serviceType = UICC_APDU_CONTROL;
       
  5601     params.action = UICC_CONTROL_WARM_RESET;
       
  5602 
       
  5603     return iMmUiccMessHandler->CreateUiccApduReq( params );
       
  5604     }
       
  5605 
       
  5606 // -----------------------------------------------------------------------------
       
  5607 // CMmCustomMessHandler::UiccSimWarmResetResp
       
  5608 //
       
  5609 // -----------------------------------------------------------------------------
       
  5610 //
       
  5611 void CMmCustomMessHandler::UiccSimWarmResetResp( TInt aStatus )
       
  5612     {
       
  5613 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSimWarmResetResp.\n" );
       
  5614 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSIMWARMRESETRESP, "CMmCustomMessHandler::UiccSimWarmResetResp" );
       
  5615 
       
  5616     TInt err ( KErrNone );
       
  5617 
       
  5618     if( aStatus != UICC_STATUS_OK )
       
  5619         {
       
  5620         if( aStatus == UICC_STATUS_SHUTTING_DOWN )
       
  5621             {
       
  5622             err = CMmStaticUtility::EpocErrorCode( KErrNotReady, KErrNotFound );
       
  5623             }
       
  5624         else
       
  5625             {
       
  5626             // UICC_STATUS_FAIL
       
  5627             err = CMmStaticUtility::EpocErrorCode( KErrGeneral, KErrNotFound );
       
  5628             }
       
  5629         }
       
  5630     iMessageRouter->Complete( ECustomSimWarmResetIPC, err );
       
  5631 
       
  5632     }
       
  5633 
       
  5634 // -----------------------------------------------------------------------------
       
  5635 // CMmCustomMessHandler::UiccSimGetAtrReq
       
  5636 //
       
  5637 // -----------------------------------------------------------------------------
       
  5638 //
       
  5639 TInt CMmCustomMessHandler::UiccSimGetAtrReq()
       
  5640     {
       
  5641 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSimGetAtrReq.\n" );
       
  5642 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSIMGETATRREQ, "CMmCustomMessHandler::UiccSimGetAtrReq" );
       
  5643 
       
  5644     TUiccParamsApduReq params;
       
  5645     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  5646     params.trId = ETrIdSimGetATR;
       
  5647     params.serviceType = UICC_APDU_ATR_GET;
       
  5648 
       
  5649     return iMmUiccMessHandler->CreateUiccApduReq( params );
       
  5650     }
       
  5651 
       
  5652 // -----------------------------------------------------------------------------
       
  5653 // CMmCustomMessHandler::UiccSimGetAtrResp
       
  5654 //
       
  5655 // -----------------------------------------------------------------------------
       
  5656 //
       
  5657 void CMmCustomMessHandler::UiccSimGetAtrResp(
       
  5658     TInt aStatus,
       
  5659     const TDesC8& aFileData )
       
  5660     {
       
  5661 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSimGetAtrResp.\n" );
       
  5662 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSIMGETATRRESP, "CMmCustomMessHandler::UiccSimGetAtrResp" );
       
  5663 
       
  5664     TInt err( KErrNone );
       
  5665     const TDesC8* dataPtr = &aFileData;
       
  5666     CMmDataPackage dataPackage;
       
  5667     dataPackage.PackData( &dataPtr );
       
  5668 
       
  5669     if( aStatus != UICC_STATUS_OK )
       
  5670         {
       
  5671         if( aStatus == UICC_STATUS_SHUTTING_DOWN )
       
  5672             {
       
  5673             err = CMmStaticUtility::EpocErrorCode( KErrNotReady, KErrNotFound );
       
  5674             }
       
  5675         else
       
  5676             {
       
  5677             // UICC_STATUS_FAIL
       
  5678             err = CMmStaticUtility::EpocErrorCode( KErrGeneral, KErrNotFound );
       
  5679             }
       
  5680         }
       
  5681 
       
  5682     iMessageRouter->Complete( ECustomGetATRIPC, &dataPackage, err );
       
  5683     }
       
  5684 
       
  5685 // -----------------------------------------------------------------------------
       
  5686 // CMmCustomMessHandler::UiccSimPowerOnReq
       
  5687 // Connects UICC server to smartcard and deactivates UICC SAP APDU interface
       
  5688 // -----------------------------------------------------------------------------
       
  5689 //
       
  5690 TInt CMmCustomMessHandler::UiccSimPowerOnReq()
       
  5691     {
       
  5692 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSimPowerOnReq.\n" );
       
  5693 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSIMPOWERONREQ, "CMmCustomMessHandler::UiccSimPowerOnReq" );
       
  5694 
       
  5695     //Set APDU interface state
       
  5696     iSapApduIfState = EUiccSapIfStatus1;
       
  5697 
       
  5698     // Set parameters for UICC_CONNECTION_REQ message
       
  5699     TUiccParamsBase params;
       
  5700     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  5701     params.trId = ETrIdSimPowerOn;
       
  5702     params.serviceType = UICC_CONNECT;
       
  5703 
       
  5704     return iMmUiccMessHandler->CreateUiccConnectorReq( params );
       
  5705     }
       
  5706 
       
  5707 // -----------------------------------------------------------------------------
       
  5708 // CMmCustomMessHandler::UiccSimPowerOnResp
       
  5709 //
       
  5710 // -----------------------------------------------------------------------------
       
  5711 //
       
  5712 void CMmCustomMessHandler::UiccSimPowerOnResp( TInt aStatus )
       
  5713     {
       
  5714 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSimPowerOnResp.\n" );
       
  5715 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSIMPOWERONRESP, "CMmCustomMessHandler::UiccSimPowerOnResp" );
       
  5716 
       
  5717     TInt err( KErrNone );
       
  5718 
       
  5719     if( aStatus == UICC_STATUS_OK )
       
  5720         {
       
  5721         switch( iSapApduIfState )
       
  5722             {
       
  5723             case EUiccSapIfStatus1:
       
  5724                 {
       
  5725                 // No handling for UICC_CONNECTOR_RESP
       
  5726                 // wait for UICC_APPLICATION_IND
       
  5727                 iSapApduIfState = EUiccSapIfStatus2;
       
  5728                 break;
       
  5729                 }
       
  5730 
       
  5731             case EUiccSapIfStatus2:
       
  5732                 {
       
  5733                 // UICC_APPLICATION_IND (UICC_APPL_ACTIVATED) received
       
  5734                 // SAP IF deactivated
       
  5735                 iMessageRouter->Complete( ECustomPowerSimOnIPC, err );
       
  5736                 break;
       
  5737                 }
       
  5738             }
       
  5739         }
       
  5740     else
       
  5741         {
       
  5742         if( aStatus == UICC_STATUS_SHUTTING_DOWN )
       
  5743             {
       
  5744             err = CMmStaticUtility::EpocErrorCode( KErrNotReady, KErrNotFound );
       
  5745             }
       
  5746         else
       
  5747             {
       
  5748             // UICC_STATUS_FAIL
       
  5749             err = CMmStaticUtility::EpocErrorCode( KErrGeneral, KErrNotFound );
       
  5750             }
       
  5751         iMessageRouter->Complete( ECustomPowerSimOnIPC, err );
       
  5752         }
       
  5753     }
       
  5754 
       
  5755 // -----------------------------------------------------------------------------
       
  5756 // CMmCustomMessHandler::UiccSimSendAPDUReq
       
  5757 //
       
  5758 // -----------------------------------------------------------------------------
       
  5759 //
       
  5760 TInt CMmCustomMessHandler::UiccSendAPDUReq(
       
  5761     const RMmCustomAPI::TApduParameters& aApduParameters,
       
  5762     TInt aTraId )
       
  5763     {
       
  5764 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSimSendAPDUReq.\n" );
       
  5765 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSIMSENAPDUREQ, "CMmCustomMessHandler::UiccSendAPDUReq" );
       
  5766 
       
  5767     TUiccParamsApduReq params;
       
  5768     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  5769     params.trId = ( TUiccTrId )aTraId;
       
  5770     params.serviceType = UICC_APDU_SEND;
       
  5771     params.apduData.Append( aApduParameters.iCmdData );
       
  5772 
       
  5773     return iMmUiccMessHandler->CreateUiccApduReq( params );
       
  5774     }
       
  5775 
       
  5776 // -----------------------------------------------------------------------------
       
  5777 // CMmCustomMessHandler::UiccSendAPDUResp
       
  5778 //
       
  5779 // -----------------------------------------------------------------------------
       
  5780 //
       
  5781 void CMmCustomMessHandler::UiccSendAPDUResp(
       
  5782     TInt aStatus,
       
  5783     const TDesC8& aFileData,
       
  5784     TInt aTraId )
       
  5785     {
       
  5786 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSendAPDUResp.\n" );
       
  5787 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSIMSENAPDURESP, "CMmCustomMessHandler::UiccSendAPDUResp" );
       
  5788 
       
  5789     TInt err( KErrNone );
       
  5790     const TDesC8* dataPtr = &aFileData;
       
  5791     CMmDataPackage dataPackage;
       
  5792     dataPackage.PackData( &dataPtr );
       
  5793 
       
  5794     if( aStatus != UICC_STATUS_OK )
       
  5795         {
       
  5796         if( aStatus == UICC_STATUS_SHUTTING_DOWN )
       
  5797             {
       
  5798             err = CMmStaticUtility::EpocErrorCode( KErrNotReady, KErrNotFound );
       
  5799             }
       
  5800         else
       
  5801             {
       
  5802             // UICC_STATUS_FAIL
       
  5803             err = CMmStaticUtility::EpocErrorCode( KErrGeneral, KErrNotFound );
       
  5804             }
       
  5805         }
       
  5806 
       
  5807     if( aTraId == ETrIdSendAPDUv2 )
       
  5808         {
       
  5809         iMessageRouter->Complete(
       
  5810             ECustomSendAPDUReqV2IPC,
       
  5811             &dataPackage,
       
  5812             err );
       
  5813         }
       
  5814     else
       
  5815         {
       
  5816         iMessageRouter->Complete(
       
  5817             ECustomSendAPDUReqIPC,
       
  5818             &dataPackage,
       
  5819             err );
       
  5820         }
       
  5821 
       
  5822     }
       
  5823 
       
  5824 // -----------------------------------------------------------------------------
       
  5825 // CMmCustomMessHandler::UiccCardReaderStatusReq
       
  5826 //
       
  5827 // -----------------------------------------------------------------------------
       
  5828 //
       
  5829 TInt CMmCustomMessHandler::UiccCardReaderStatusReq()
       
  5830     {
       
  5831 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCardReaderStatusReq.\n" );
       
  5832 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCARDREADERSTATUSREQ, "CMmCustomMessHandler::UiccCardReaderStatusReq" );
       
  5833 
       
  5834     TUiccParamsApduReq params;
       
  5835     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  5836     params.trId = ETrIdCardReaderStatus;
       
  5837     params.serviceType = UICC_CARD_STATUS_GET;
       
  5838 
       
  5839     // Current UICC IF implementatation does not support getting
       
  5840     // READER_STATUS_BYTE. However, apdu server uses hard coded values
       
  5841     // for READER STATUS BYTE bits 1 to 6
       
  5842     // and information contained in bits 7 and 8 can be acquired with
       
  5843     // UICC_CARD_REQ request.
       
  5844 
       
  5845     return iMmUiccMessHandler->CreateUiccCardReq( params );
       
  5846     }
       
  5847 
       
  5848 // -----------------------------------------------------------------------------
       
  5849 // CMmCustomMessHandler::UiccCardReaderStatusResp
       
  5850 //
       
  5851 // -----------------------------------------------------------------------------
       
  5852 //
       
  5853 void CMmCustomMessHandler::UiccCardReaderStatusResp(
       
  5854     TInt aStatus,
       
  5855     const TDesC8& aFileData )
       
  5856     {
       
  5857 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCardReaderStatusResp.\n" );
       
  5858 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCARDREADERSTATUSRESP, "CMmCustomMessHandler::UiccCardReaderStatusResp" );
       
  5859 
       
  5860     TInt err ( KErrNone );
       
  5861     CMmDataPackage dataPackage;
       
  5862     TUint8 cardStatus( 0 );
       
  5863     TBuf8<1> statusByte;
       
  5864 
       
  5865     cardStatus = aFileData[0];
       
  5866 
       
  5867     if( aStatus == UICC_STATUS_OK )
       
  5868         {
       
  5869         switch( cardStatus )
       
  5870             {
       
  5871             case UICC_STATUS_CARD_READY:
       
  5872                 {
       
  5873                 // UICC Card Status: UICC_STATUS_CARD_READY ->
       
  5874                 // Card reader status byte: B1101_0000
       
  5875                 statusByte.Append(KUiccCardStatusCardPresentAndPoweredOn);
       
  5876                 break;
       
  5877                 }
       
  5878 
       
  5879             case UICC_STATUS_CARD_DISCONNECTED:
       
  5880             case UICC_STATUS_CARD_NOT_PRESENT:
       
  5881                 {
       
  5882                 // UICC Card Status: UICC_STATUS_CARD_DISCONNECTED or
       
  5883                 // UICC_STATUS_CARD_NOT_PRESENT ->
       
  5884                 // Card reader status byte: B0001_0000
       
  5885                 statusByte.Append(KUiccCardStatusCardNotPresentOrPoweredOff);
       
  5886                 break;
       
  5887                 }
       
  5888 
       
  5889             default:
       
  5890                 break;
       
  5891             }
       
  5892         dataPackage.PackData( &statusByte );
       
  5893 
       
  5894         }
       
  5895     else
       
  5896         {
       
  5897         if( aStatus == UICC_STATUS_SHUTTING_DOWN )
       
  5898             {
       
  5899             err = CMmStaticUtility::EpocErrorCode( KErrNotReady, KErrNotFound );
       
  5900             }
       
  5901         else
       
  5902             {
       
  5903             // UICC_STATUS_FAIL
       
  5904             err = CMmStaticUtility::EpocErrorCode( KErrGeneral, KErrNotFound );
       
  5905             }
       
  5906         }
       
  5907 
       
  5908         iMessageRouter->Complete(
       
  5909             ECustomGetSimCardReaderStatusIPC,
       
  5910             &dataPackage,
       
  5911             err );
       
  5912     }
       
  5913 
       
  5914 // -----------------------------------------------------------------------------
       
  5915 // CMmCustomMessHandler::UiccCardInd
       
  5916 // Breaks UICC_CARD_IND ISI-message and completes " Notify SimCard Status"
       
  5917 // to CommonTSY.
       
  5918 // -----------------------------------------------------------------------------
       
  5919 //
       
  5920 void CMmCustomMessHandler::UiccCardInd( const TIsiReceiveC& aIsiMessage )
       
  5921     {
       
  5922     // Get service type
       
  5923     TUint8 serviceType( aIsiMessage.Get8bit(
       
  5924         ISI_HEADER_SIZE + UICC_IND_OFFSET_SERVICETYPE ) );
       
  5925 
       
  5926 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccCardInd, service type: %d", serviceType );
       
  5927 OstTraceExt1( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCIND, "CMmCustomMessHandler::UiccCardInd;serviceType=%hhu", serviceType );
       
  5928 
       
  5929     RMmCustomAPI::TSIMCardStatus returnStatus;
       
  5930     returnStatus = RMmCustomAPI::SimCardUnknowError;
       
  5931 
       
  5932     switch ( serviceType )
       
  5933         {
       
  5934         case UICC_CARD_READY :
       
  5935             {
       
  5936             returnStatus = RMmCustomAPI::SimCardInserted;
       
  5937             break;
       
  5938             }
       
  5939         case UICC_CARD_DISCONNECTED:
       
  5940             {
       
  5941             returnStatus = RMmCustomAPI::SimCardRemoved;
       
  5942             break;
       
  5943             }
       
  5944         default:
       
  5945             {
       
  5946             break;
       
  5947             }
       
  5948         }
       
  5949 
       
  5950     CMmDataPackage dataPackage;
       
  5951     dataPackage.PackData( &returnStatus );
       
  5952     iMessageRouter->Complete(
       
  5953         ECustomNotifySimCardStatusIPC,
       
  5954         &dataPackage,
       
  5955         KErrNone );
       
  5956    }
       
  5957 
       
  5958 
       
  5959 // -----------------------------------------------------------------------------
       
  5960 // CMmCustomMessHandler::UiccSendAuthenticateApdu
       
  5961 // Constructs and sends AUTHENTICATE APDU to the UICC server
       
  5962 // -----------------------------------------------------------------------------
       
  5963 //
       
  5964 TInt CMmCustomMessHandler::UiccSendAuthenticateApdu( 
       
  5965     const CMmDataPackage& aDataPackage )
       
  5966     {
       
  5967 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu.\n" );
       
  5968 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApdu" );
       
  5969 
       
  5970     TInt ret( KErrNone );
       
  5971     TBool apduSendNeeded( EFalse );
       
  5972 
       
  5973     // Let's construct AUTHENTICATE APDU based on authenticate type
       
  5974     RMmCustomAPI::TSimAuthenticationBase authBase;
       
  5975     aDataPackage.UnPackData( authBase );
       
  5976     TUint8 simAuthType( authBase.ExtensionId() );
       
  5977 
       
  5978     // Fill parameters to instance created from TUiccSendApdu
       
  5979     // needed for APDU sending
       
  5980     TUiccSendApdu params;
       
  5981     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  5982     params.serviceType = UICC_APPL_APDU_SEND;
       
  5983     params.fileId = UICC_EF_ID_NOT_PRESENT;
       
  5984     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  5985     params.filePath.Append( KMasterFileId >> 8 );
       
  5986     params.filePath.Append( KMasterFileId );
       
  5987     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
  5988 
       
  5989     TUint8 cardType( iMmUiccMessHandler->GetCardType() );
       
  5990     TBool serviceStatus( EFalse );
       
  5991 
       
  5992     switch( simAuthType )
       
  5993         {
       
  5994         case RMmCustomAPI::TSimAuthenticationBase::EEapSim:
       
  5995             {
       
  5996             if( UICC_CARD_TYPE_ICC == cardType )
       
  5997                 {
       
  5998                 RMmCustomAPI::TSimAuthenticationEapSim eapSim;
       
  5999                 aDataPackage.UnPackData( eapSim );
       
  6000 
       
  6001                 // In 2G we need to send command RUN GSM ALGORITHM to the ICC
       
  6002                 UiccCreateRunGsmAlgorithmApdu( params, eapSim.iRandomParameters, ETrIdRunGsmAlgorithmSim );
       
  6003                 apduSendNeeded = ETrue;
       
  6004                 }
       
  6005             else if( UICC_CARD_TYPE_UICC == cardType )
       
  6006                 {
       
  6007                 // In 3G we need to send command AUTHENTICATE to the UICC
       
  6008                 UiccCreateGsmSecurityContextApdu( params, aDataPackage );
       
  6009                 apduSendNeeded = ETrue;
       
  6010                 }
       
  6011             break;
       
  6012             }
       
  6013         case RMmCustomAPI::TSimAuthenticationBase::EEapAka:
       
  6014             {
       
  6015             RMmCustomAPI::TSimAuthenticationEapAka eapAka;
       
  6016             aDataPackage.UnPackData( eapAka );
       
  6017 
       
  6018             if( UICC_CARD_TYPE_ICC == cardType )
       
  6019                 {
       
  6020                 // In 2G we need to send command RUN GSM ALGORITHM to the ICC
       
  6021                 UiccCreateRunGsmAlgorithmApdu( params, eapAka.iRandomParameters, ETrIdRunGsmAlgorithmAka );
       
  6022                 apduSendNeeded = ETrue;
       
  6023                 }
       
  6024             else if( UICC_CARD_TYPE_UICC == cardType )
       
  6025                 {
       
  6026                 // In 3G we need to send command AUTHENTICATE to the UICC
       
  6027                 UiccCreate3GSecurityContextApdu( 
       
  6028                     params, 
       
  6029                     eapAka.iRandomParameters, 
       
  6030                     eapAka.iAUTN,
       
  6031                     ETrIdEEapAkaAuthenticate );
       
  6032                 apduSendNeeded = ETrue;
       
  6033                 }
       
  6034             break;
       
  6035             }
       
  6036         case RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrap:
       
  6037             {
       
  6038             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceGBA );
       
  6039 
       
  6040             if( UICC_CARD_TYPE_UICC == cardType && 
       
  6041                 EFalse != serviceStatus )
       
  6042                 {
       
  6043                 UiccCreateGBABootstrappingApdu( params, aDataPackage );
       
  6044                 apduSendNeeded = ETrue;
       
  6045                 }
       
  6046             else
       
  6047                 {
       
  6048                 // GBA not supported if card type is ICC or GBA not supported in EFust
       
  6049 TFLOGSTRING3("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu: GBA not supported (card type: 0x%x, ss: 0x%x)\n", cardType, serviceStatus );
       
  6050 OstTraceExt2( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApdu: GBA not supported (card type: %x, ss: 0x%x)", cardType, serviceStatus );
       
  6051                 ret = KErrGeneral;
       
  6052                 }
       
  6053             break;
       
  6054             }
       
  6055         case RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrapUpdate:
       
  6056             {
       
  6057             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceGBA );
       
  6058 
       
  6059             if( UICC_CARD_TYPE_UICC == cardType && 
       
  6060                 EFalse != serviceStatus )
       
  6061                 {
       
  6062                 UiccGBABootstrapUpdate( aDataPackage );
       
  6063                 }
       
  6064             else
       
  6065                 {
       
  6066                 // GBA not supported if card type is ICC or GBA not supported in EFust
       
  6067 TFLOGSTRING3("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu: GBA not supported (card type: 0x%x, ss: 0x%x)\n", cardType, serviceStatus );
       
  6068 OstTraceExt2( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApdu: GBA not supported (card type: 0x%x, ss: 0x%x)", cardType, serviceStatus );
       
  6069                 ret = KErrGeneral;
       
  6070                 }
       
  6071             break;
       
  6072               }
       
  6073         case RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrapNafDerivation:
       
  6074             {
       
  6075             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceGBA );
       
  6076 
       
  6077             if( UICC_CARD_TYPE_UICC == cardType && 
       
  6078                 EFalse != serviceStatus )
       
  6079                 {
       
  6080                 UiccCreateGBABootstrapNafDerivationApdu( params, aDataPackage );
       
  6081                 apduSendNeeded = ETrue;
       
  6082                 }
       
  6083             else
       
  6084                 {
       
  6085                 // GBA not supported if card type is ICC or GBA not supported in EFust
       
  6086 TFLOGSTRING3("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu: GBA not supported (card type: 0x%x, ss: 0x%x)\n", cardType, serviceStatus );
       
  6087 OstTraceExt2( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApdu: GBA not supported (card type: 0x%x, ss: 0x%x)", cardType, serviceStatus );
       
  6088                 ret = KErrGeneral;
       
  6089                 }
       
  6090             break;
       
  6091             }
       
  6092         case RMmCustomAPI::TSimAuthenticationBase::EMgvMskUpdate:
       
  6093             {
       
  6094             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceMBMSsecurity );
       
  6095 
       
  6096             if( UICC_CARD_TYPE_UICC == cardType && 
       
  6097                 EFalse != serviceStatus )
       
  6098                 {
       
  6099                 UiccCreateMbmsMskUpdateApdu( params, aDataPackage );
       
  6100                 apduSendNeeded = ETrue;
       
  6101                 }
       
  6102             else
       
  6103                 {
       
  6104                 // MBMS not supported if card type is ICC or MBMS not supported in EFust
       
  6105 TFLOGSTRING3("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu: MBMS security not supported (card type: 0x%x, ss: 0x%x)\n", cardType, serviceStatus );
       
  6106 OstTraceExt2( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApdu: MBMS security not supported (card type: 0x%x, ss: 0x%x)", cardType, serviceStatus );
       
  6107                 ret = KErrGeneral;
       
  6108                 }
       
  6109             break;
       
  6110             }
       
  6111         case RMmCustomAPI::TSimAuthenticationBase::EMgvMtkGeneration:
       
  6112             {
       
  6113             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceMBMSsecurity );
       
  6114 
       
  6115             if( UICC_CARD_TYPE_UICC == cardType && 
       
  6116                 EFalse != serviceStatus )
       
  6117                 {
       
  6118                 UiccCreateMbmsMtkGenerationApdu( params, aDataPackage );
       
  6119                 apduSendNeeded = ETrue;
       
  6120                 }
       
  6121             else
       
  6122                 {
       
  6123                 // MBMS not supported if card type is ICC or MBMS not supported in EFust
       
  6124 TFLOGSTRING3("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu: MBMS security not supported (card type: 0x%x, ss: 0x%x)\n", cardType, serviceStatus );
       
  6125 OstTraceExt2( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApdu: MBMS security not supported (card type: 0x%x, ss: 0x%x)", cardType, serviceStatus );
       
  6126                 ret = KErrGeneral;
       
  6127                 }
       
  6128             break;
       
  6129             }
       
  6130         case RMmCustomAPI::TSimAuthenticationBase::EMgvMskDeletion:
       
  6131             {
       
  6132             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceMBMSsecurity );
       
  6133 
       
  6134             if( UICC_CARD_TYPE_UICC == cardType && 
       
  6135                 EFalse != serviceStatus )
       
  6136                 {
       
  6137                 UiccCreateMbmsMskDeletionApdu( params, aDataPackage );
       
  6138                 apduSendNeeded = ETrue;
       
  6139                 }
       
  6140             else
       
  6141                 {
       
  6142                 // MBMS not supported if card type is ICC or MBMS not supported in EFust
       
  6143 TFLOGSTRING3("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu: MBMS security not supported (card type: 0x%x, ss: 0x%x)\n", cardType, serviceStatus );
       
  6144 OstTraceExt2( TRACE_NORMAL, DUP6_CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApdu: MBMS security not supported (card type: 0x%x, ss: 0x%x)", cardType, serviceStatus );
       
  6145                 ret = KErrGeneral;
       
  6146                 }
       
  6147             break;
       
  6148             }
       
  6149         default:
       
  6150             {
       
  6151 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu: Unknown APDU\n" );
       
  6152 OstTrace0( TRACE_NORMAL, DUP7_CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApdu: Unknown APDU" );
       
  6153             break;
       
  6154             }
       
  6155         }
       
  6156 
       
  6157     if( EFalse != apduSendNeeded )
       
  6158         {
       
  6159         // send the apdu to the UICC server
       
  6160         ret = iMmUiccMessHandler->CreateUiccApplCmdReq( params ); 
       
  6161         }
       
  6162     else
       
  6163         {
       
  6164 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu: APDU not sent\n" );
       
  6165 OstTrace0( TRACE_NORMAL, DUP8_CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApduu: APDU not sent" );
       
  6166         }
       
  6167     return ret;
       
  6168     }
       
  6169 
       
  6170 
       
  6171 // -----------------------------------------------------------------------------
       
  6172 // CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu
       
  6173 // Constructs GSM context AUTHENTICATE APDU
       
  6174 // -----------------------------------------------------------------------------
       
  6175 //
       
  6176 void CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu( 
       
  6177     TUiccSendApdu& aParams, 
       
  6178     const TDesC8& aRand,
       
  6179     TUiccTrId aTraId )
       
  6180     {
       
  6181 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu.\n" );
       
  6182 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATERUNGSMALGORITHMAPDU, "CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu" );
       
  6183 
       
  6184     aParams.trId = aTraId;
       
  6185     aParams.apdu.Append( KClaIcc );              // CLA
       
  6186     aParams.apdu.Append( KEvenInstructionCode ); // INS
       
  6187     aParams.apdu.Append( 0 ); // P1 is set to 0 in case of RUN GSM ALGORITH
       
  6188     aParams.apdu.Append( 0 ); // P2 is set to 0 in case of RUN GSM ALGORITH
       
  6189     aParams.apdu.Append( aRand.Size() );     // Lc
       
  6190     aParams.apdu.Append( aRand );            // Data
       
  6191     aParams.apdu.Append( KRunGsmAlgorithmRespLen ); // Le
       
  6192     }
       
  6193 
       
  6194 
       
  6195 // -----------------------------------------------------------------------------
       
  6196 // CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp
       
  6197 // Handles response APDU for RUN GSM ALGORITHM
       
  6198 // -----------------------------------------------------------------------------
       
  6199 //
       
  6200 void CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp(
       
  6201     TInt aTraId,
       
  6202     TInt aStatus,
       
  6203     const TDesC8& aFileData )
       
  6204     {
       
  6205 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp.\n" );
       
  6206 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCRUNGSMALGORITHMAPDURESP, "CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp" );
       
  6207 
       
  6208     TInt ret( KErrNone );
       
  6209     TInt ipc( ETrIdRunGsmAlgorithmIms == aTraId ? EMobilePhoneIMSAuthenticate : ECustomGetSimAuthenticationDataIPC );
       
  6210     RMmCustomAPI::TSimAuthenticationEapSim eapSim;
       
  6211     RMmCustomAPI::TSimAuthenticationEapAka eapAka;
       
  6212     RMobilePhone::TImsAuthenticateDataV5 ims;
       
  6213 
       
  6214     if( UICC_STATUS_OK == aStatus )
       
  6215         {
       
  6216         // get SW1 and SW2
       
  6217         TUint8 sw1( aFileData[aFileData.Length() - KSw1Position] );
       
  6218         TUint8 sw2( aFileData[aFileData.Length() - KSw2Position] );
       
  6219 
       
  6220         TUint8 result( MapSw1Sw2ToAuthenticateResult( sw1, sw2 ) );
       
  6221 
       
  6222         if( KNormalCommandEnding == result )
       
  6223             {
       
  6224             if( KApduOk == ValidateReceivedAuthenticateApdu( aTraId, aFileData ) )
       
  6225                 {
       
  6226                 // At the momen UICC server get the response from ICC, but in the
       
  6227                 // future it may be removed from UICC. So then we should get the
       
  6228                 // response from ICC.
       
  6229                 TUint8 index = 0;
       
  6230 
       
  6231                 if( ETrIdRunGsmAlgorithmSim == aTraId ) // EAP SIM
       
  6232                     {
       
  6233                     // get the SRES
       
  6234                     eapSim.iSRES.Copy( aFileData.Mid(index, KLenOfSRes) );
       
  6235                     index += KLenOfSRes;
       
  6236 
       
  6237                     // get the Kc
       
  6238                     eapSim.iKC.Copy( aFileData.Mid(index, KLenOfKc ) );
       
  6239                     }
       
  6240                 else if( ETrIdRunGsmAlgorithmIms == aTraId ) // IMS
       
  6241                     {
       
  6242                     // get the SRES
       
  6243                     ims.iRES.Copy( aFileData.Mid(index, KLenOfSRes) );
       
  6244                     index += KLenOfSRes;
       
  6245 
       
  6246                     // let's calculate ck and ik from kc
       
  6247                     DeriveCkFromKc( ims.iCK, aFileData.Mid(index, KLenOfKc ) );
       
  6248                     DeriveIkFromKc( ims.iIK, aFileData.Mid(index, KLenOfKc ) );
       
  6249                     }
       
  6250                 else // EAP AKA
       
  6251                     {
       
  6252                     // get the SRES
       
  6253                     eapAka.iRES.Copy( aFileData.Mid(index, KLenOfSRes) );
       
  6254                     index += KLenOfSRes;
       
  6255 
       
  6256                     // let's calculate ck and ik from kc
       
  6257                     DeriveCkFromKc( eapAka.iCK, aFileData.Mid(index, KLenOfKc ) );
       
  6258                     DeriveIkFromKc( eapAka.iIK, aFileData.Mid(index, KLenOfKc ) );
       
  6259                     }
       
  6260                 }
       
  6261             else
       
  6262                 {
       
  6263 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp. APDU validation fails\n" );
       
  6264 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICCRUNGSMALGORITHMAPDURESP, "CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp. APDU validation fails" );
       
  6265                 ret = KErrMMEtelAuthenticateFailed;
       
  6266                 }
       
  6267             }
       
  6268         else if( KCmdNotAllowedSecurityStatusNotSatisfied == result )
       
  6269             {
       
  6270 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp: Security conditions not satisfied\n" );
       
  6271 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_UICCRUNGSMALGORITHMAPDURESP, "CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp: Security conditions not satisfied" );
       
  6272             ret = CMmStaticUtility::EpocErrorCode( 
       
  6273                 KErrAccessDenied, 
       
  6274                 KErrGsm0707SimPin1Required );
       
  6275             }
       
  6276         else
       
  6277             {
       
  6278 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp. unknown result: 0x%X\n", result );
       
  6279 OstTrace1( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_UICCRUNGSMALGORITHMAPDURESP, "CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp. unknown result: 0x%x", result );
       
  6280             ret = KErrMMEtelAuthenticateFailed;
       
  6281             }
       
  6282         }
       
  6283     else
       
  6284         {
       
  6285 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp: UICC status not ok: 0x%x\n", aStatus );
       
  6286 OstTrace1( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_UICCRUNGSMALGORITHMAPDURESP, "CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp: UICC status not ok: 0x%x", aStatus );
       
  6287         ret = KErrMMEtelAuthenticateFailed;
       
  6288         }
       
  6289 
       
  6290     if( KErrNone != ret )
       
  6291         {
       
  6292         iMessageRouter->Complete(
       
  6293             ipc,
       
  6294             ret );
       
  6295         }
       
  6296     else
       
  6297         {
       
  6298         CMmDataPackage dataPackage;
       
  6299         if( ETrIdRunGsmAlgorithmSim == aTraId ) // EAP SIM
       
  6300             {
       
  6301             dataPackage.PackData( &eapSim );
       
  6302             }
       
  6303         else if( ETrIdRunGsmAlgorithmIms == aTraId )
       
  6304             {
       
  6305             dataPackage.PackData( &ims );
       
  6306             }
       
  6307         else
       
  6308             {
       
  6309             dataPackage.PackData( &eapAka );
       
  6310             }
       
  6311 
       
  6312         iMessageRouter->Complete(
       
  6313             ipc,
       
  6314             &dataPackage,
       
  6315             ret );
       
  6316         }
       
  6317     }
       
  6318 
       
  6319 // -----------------------------------------------------------------------------
       
  6320 // CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu
       
  6321 // Constructs GSM context AUTHENTICATE APDU
       
  6322 // -----------------------------------------------------------------------------
       
  6323 //
       
  6324 void CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu( 
       
  6325     TUiccSendApdu& params, 
       
  6326     const CMmDataPackage& aDataPackage )
       
  6327     {
       
  6328 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu.\n" );
       
  6329 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEGSMSECURITYCONTEXTAPDU, "CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu" );
       
  6330 
       
  6331     RMmCustomAPI::TSimAuthenticationEapSim eapSim;
       
  6332     aDataPackage.UnPackData( eapSim );
       
  6333 
       
  6334     params.trId = ETrIdEEapSimAuthenticate;
       
  6335     params.apdu.Append( KClaNoSm );             // CLA
       
  6336     params.apdu.Append( KEvenInstructionCode ); // INS
       
  6337     params.apdu.Append( 0 ); // P1 is set to 0 in case of even instruction
       
  6338     params.apdu.Append( KGsmAuthenticationContext ); // P2
       
  6339     params.apdu.Append( eapSim.iRandomParameters.Size() + 1 ); // Lc
       
  6340     params.apdu.Append( eapSim.iRandomParameters.Size() );     // Data
       
  6341     params.apdu.Append( eapSim.iRandomParameters );            // Data
       
  6342     params.apdu.Append( KMaximumLenOfDataExpected );           // Le
       
  6343     }
       
  6344 
       
  6345 // -----------------------------------------------------------------------------
       
  6346 // CMmCustomMessHandler::UiccGsmSecurityContextApduResp
       
  6347 // Handles response APDU for GSM context AUTHENTICATE APDU
       
  6348 // -----------------------------------------------------------------------------
       
  6349 //
       
  6350 void CMmCustomMessHandler::UiccGsmSecurityContextApduResp(
       
  6351     TInt aTraId,
       
  6352     TInt aStatus,
       
  6353     const TDesC8& aFileData )
       
  6354     {
       
  6355 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGsmSecurityContextApduResp.\n" );
       
  6356 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCGSMSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::UiccGsmSecurityContextApduResp" );
       
  6357 
       
  6358     TInt ret( KErrNone );
       
  6359     RMmCustomAPI::TSimAuthenticationEapSim eapSim;
       
  6360 
       
  6361     if( UICC_STATUS_OK == aStatus )
       
  6362         {
       
  6363         // get SW1 and SW2
       
  6364         TUint8 sw1( aFileData[aFileData.Length() - KSw1Position] );
       
  6365         TUint8 sw2( aFileData[aFileData.Length() - KSw2Position] );
       
  6366 
       
  6367         TUint8 result( MapSw1Sw2ToAuthenticateResult( sw1, sw2 ) );
       
  6368 
       
  6369         if( KNormalCommandEnding == result )
       
  6370             {
       
  6371             if( KApduOk == ValidateReceivedAuthenticateApdu( aTraId, aFileData ) )
       
  6372                 {
       
  6373                 // get the SRES
       
  6374                 TUint8 index( 0 );
       
  6375                 TUint8 len( aFileData[index++] );
       
  6376                 eapSim.iSRES.Copy( aFileData.Mid( index , len ) );
       
  6377                 index += len;
       
  6378 
       
  6379                 // get the Kc
       
  6380                 len = aFileData[index++];
       
  6381                 eapSim.iKC.Copy( aFileData.Mid( index , len ) );
       
  6382                 }
       
  6383             else
       
  6384                 {
       
  6385 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGsmSecurityContextApduResp: APDU validation failed\n" );
       
  6386 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICCGSMSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::UiccGsmSecurityContextApduResp: APDU validation failed" );
       
  6387                 ret = KErrMMEtelAuthenticateFailed;
       
  6388                 }
       
  6389             }
       
  6390         else
       
  6391             {
       
  6392 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGsmSecurityContextApduResp: unknown result\n" );
       
  6393 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_UICCGSMSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::UiccGsmSecurityContextApduResp: unknown result" );
       
  6394             ret = KErrMMEtelAuthenticateFailed;
       
  6395             }
       
  6396         }
       
  6397     else
       
  6398         {
       
  6399 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccGsmSecurityContextApduResp: UICC status not ok: 0x%x\n", aStatus );
       
  6400 OstTrace1( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_UICCGSMSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::UiccGsmSecurityContextApduResp: UICC status not ok: 0x%x", aStatus );
       
  6401         ret = KErrMMEtelAuthenticateFailed;
       
  6402         }
       
  6403 
       
  6404     if( KErrNone != ret )
       
  6405         {
       
  6406         iMessageRouter->Complete(
       
  6407             ECustomGetSimAuthenticationDataIPC,
       
  6408             ret );
       
  6409         }
       
  6410     else
       
  6411         {
       
  6412         CMmDataPackage dataPackage;
       
  6413         dataPackage.PackData( &eapSim );
       
  6414 
       
  6415         iMessageRouter->Complete(
       
  6416             ECustomGetSimAuthenticationDataIPC,
       
  6417             &dataPackage,
       
  6418             ret );
       
  6419         }
       
  6420     }
       
  6421 
       
  6422 // -----------------------------------------------------------------------------
       
  6423 // CMmCustomMessHandler::UiccCreate3GSecurityContextApdu
       
  6424 // Constructs 3G security context AUTHENTICATE APDU
       
  6425 // -----------------------------------------------------------------------------
       
  6426 //
       
  6427 void CMmCustomMessHandler::UiccCreate3GSecurityContextApdu( 
       
  6428     TUiccSendApdu& aParams, 
       
  6429     const TDesC8& aRand, 
       
  6430     const TDesC8& aAuth,
       
  6431     TUiccTrId aTraId )
       
  6432     {
       
  6433 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreate3GSecurityContextApdu.\n" );
       
  6434 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATE3GSECURITYCONTEXTAPDU, "CMmCustomMessHandler::UiccCreate3GSecurityContextApdu" );
       
  6435 
       
  6436     // len of data is sizeof RAND + sizeof AUTN + two length fields 
       
  6437     // (one for RAND len and one for AUTN len)
       
  6438     TUint8 lc( aRand.Size() + aAuth.Size() + 2 );
       
  6439 
       
  6440     aParams.trId = aTraId;
       
  6441     aParams.apdu.Append( KClaNoSm );             // CLA
       
  6442     aParams.apdu.Append( KEvenInstructionCode ); // INS
       
  6443     aParams.apdu.Append( 0 ); // P1 is set to 0 in case of even instruction
       
  6444     aParams.apdu.Append( K3GAuthenticationContext ); // P2
       
  6445     aParams.apdu.Append( lc );                       // Lc 
       
  6446     aParams.apdu.Append( aRand.Size() ); // len of RAND
       
  6447     aParams.apdu.Append( aRand );        // RAND
       
  6448     aParams.apdu.Append( aAuth.Size() );             // len of AUTN
       
  6449     aParams.apdu.Append( aAuth );                    // AUTN
       
  6450     aParams.apdu.Append( KMaximumLenOfDataExpected );       // Le
       
  6451     }
       
  6452 
       
  6453 // -----------------------------------------------------------------------------
       
  6454 // CMmCustomMessHandler::Uicc3GSecurityContextApduResp
       
  6455 // Handles response APDU for 3G security context AUTHENTICATE APDU
       
  6456 // -----------------------------------------------------------------------------
       
  6457 //
       
  6458 void CMmCustomMessHandler::Uicc3GSecurityContextApduResp(
       
  6459          TInt aTraId,
       
  6460          TInt aStatus,
       
  6461          const TDesC8& aFileData )
       
  6462     {
       
  6463 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp.\n" );
       
  6464 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp" );
       
  6465 
       
  6466     TInt ret( KErrNone );
       
  6467     TInt ipc( ETrIdEEapAkaAuthenticateIms == aTraId ? EMobilePhoneIMSAuthenticate : ECustomGetSimAuthenticationDataIPC );
       
  6468     RMmCustomAPI::TSimAuthenticationEapAka eapAka;
       
  6469     RMobilePhone::TImsAuthenticateDataV5 ims;
       
  6470 
       
  6471     if( UICC_STATUS_OK == aStatus )
       
  6472         {
       
  6473         // get SW1 and SW2
       
  6474         TUint8 sw1( aFileData[aFileData.Length() - KSw1Position] );
       
  6475         TUint8 sw2( aFileData[aFileData.Length() - KSw2Position] );
       
  6476 
       
  6477         TUint8 result( MapSw1Sw2ToAuthenticateResult( sw1, sw2 ) );
       
  6478 
       
  6479         if( KNormalCommandEnding == result )
       
  6480             {
       
  6481             if( KApduOk == ValidateReceivedAuthenticateApdu( aTraId, aFileData ) )
       
  6482                 {
       
  6483                 TUint32 index( 0 );
       
  6484 
       
  6485                 if( KSuccessfull3GAuthTag == aFileData[index] )
       
  6486                     {
       
  6487                     index++;
       
  6488 
       
  6489                     if( ETrIdEEapAkaAuthenticate == aTraId )
       
  6490                         {
       
  6491                         // get the RES
       
  6492                         TUint8 len( aFileData[index++] );
       
  6493                         eapAka.iRES.Copy( aFileData.Mid( index, len ) );
       
  6494                         index += len;
       
  6495 
       
  6496                         // get the CK
       
  6497                         len = aFileData[index++];
       
  6498                         eapAka.iCK.Copy( aFileData.Mid( index, len ) );
       
  6499                         index += len;
       
  6500 
       
  6501                         // get the IK
       
  6502                         len = aFileData[index++];
       
  6503                         eapAka.iIK.Copy( aFileData.Mid( index, len ) );
       
  6504                         index += len;
       
  6505 
       
  6506                         // Kc is not supported at the moment because of 
       
  6507                         // RMmCustomAPI::TSimAuthenticationEapAka doesn't
       
  6508                         // have parameter for that
       
  6509                         }
       
  6510                     else
       
  6511                         {
       
  6512                         // get the RES
       
  6513                         TUint8 len( aFileData[index++] );
       
  6514                         ims.iRES.Copy( aFileData.Mid( index, len ) );
       
  6515                         index += len;
       
  6516 
       
  6517                         // get the CK
       
  6518                         len = aFileData[index++];
       
  6519                         ims.iCK.Copy( aFileData.Mid( index, len ) );
       
  6520                         index += len;
       
  6521 
       
  6522                         // get the IK
       
  6523                         len = aFileData[index++];
       
  6524                         ims.iIK.Copy( aFileData.Mid( index, len ) );
       
  6525                         index += len;
       
  6526                         }
       
  6527                     }
       
  6528                 else if( KSyncFailureTag == aFileData[index] )
       
  6529                     {
       
  6530                     index++;
       
  6531 
       
  6532                     if( ETrIdEEapAkaAuthenticate == aTraId )
       
  6533                         {
       
  6534                         // get the AUTS
       
  6535                         TUint8 len( aFileData[index++] );
       
  6536                         eapAka.iAUTS.Copy( aFileData.Mid( index, len ) );
       
  6537                         }
       
  6538                     else
       
  6539                         {
       
  6540                         // get the AUTS
       
  6541                         TUint8 len( aFileData[index++] );
       
  6542                         ims.iAUTS.Copy( aFileData.Mid( index, len ) );
       
  6543                         }
       
  6544                     ret = KErrMMEtelSqnVerificationFailed;
       
  6545                     }
       
  6546                 }
       
  6547             else
       
  6548                 {
       
  6549 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: APDU validation failed\n" );
       
  6550 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: APDU validation failed" );
       
  6551                 ret = KErrMMEtelAuthenticateFailed;
       
  6552                 }
       
  6553             }            
       
  6554         else if( KAppAuthErrorIncorrectMac == result )
       
  6555             {
       
  6556 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: incorrect MAC\n" );
       
  6557 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: incorrect MAC" );
       
  6558             // no parameters in this case
       
  6559             ret = KErrMMEtelMacVerificationFailed;
       
  6560             }
       
  6561         else if( KCmdNotAllowedSecurityStatusNotSatisfied == result )
       
  6562             {
       
  6563 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: Security conditions not satisfied\n" );
       
  6564 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: Security conditions not satisfied" );
       
  6565             ret = CMmStaticUtility::EpocErrorCode( 
       
  6566                 KErrAccessDenied, 
       
  6567                 KErrGsm0707SimPin1Required );
       
  6568             }
       
  6569         else
       
  6570             {
       
  6571 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: unknown result\n" );
       
  6572 OstTrace0( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: unknown result" );
       
  6573             ret = KErrMMEtelAuthenticateFailed;
       
  6574             }
       
  6575         }
       
  6576     else
       
  6577         {
       
  6578 TFLOGSTRING2("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: UICC status not ok: 0x%x\n", aStatus );
       
  6579 OstTrace1( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: UICC status not ok: 0x%x", aStatus );
       
  6580         ret = ETrIdEEapAkaAuthenticateIms == aTraId ? KErrGeneral : KErrMMEtelAuthenticateFailed;
       
  6581         }
       
  6582 
       
  6583     if( KErrNone == ret || 
       
  6584         KErrMMEtelSqnVerificationFailed == ret || 
       
  6585         KErrMMEtelMacVerificationFailed == ret )
       
  6586         {
       
  6587         CMmDataPackage dataPackage;
       
  6588 
       
  6589         if( ETrIdEEapAkaAuthenticate == aTraId )
       
  6590             {
       
  6591             dataPackage.PackData( &eapAka );
       
  6592             }
       
  6593         else
       
  6594             {
       
  6595             dataPackage.PackData( &ims );
       
  6596             }
       
  6597 
       
  6598         iMessageRouter->Complete(
       
  6599             ipc,
       
  6600             &dataPackage,
       
  6601             ret );	
       
  6602         }
       
  6603     else
       
  6604         {
       
  6605         iMessageRouter->Complete(
       
  6606             ipc,
       
  6607             ret );
       
  6608         }
       
  6609     }
       
  6610 
       
  6611 
       
  6612 // -----------------------------------------------------------------------------
       
  6613 // CMmCustomMessHandler::UiccCreateGBABootstrappingApdu
       
  6614 // Constructs GBA security context AUTHENTICATE APDU (bootstrapping mode)
       
  6615 // -----------------------------------------------------------------------------
       
  6616 //
       
  6617 void CMmCustomMessHandler::UiccCreateGBABootstrappingApdu(
       
  6618     TUiccSendApdu& aParams, 
       
  6619     const CMmDataPackage& aDataPackage )
       
  6620     {
       
  6621 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateGBABootstrappingApdu.\n" );
       
  6622 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEGBABOOTSTRAPPINGAPDU, "CMmCustomMessHandler::UiccCreateGBABootstrappingApdu" );
       
  6623 
       
  6624     RMmCustomAPI::TSimAuthenticationGbaBootstrap gbaBootstrap;
       
  6625     aDataPackage.UnPackData( gbaBootstrap );
       
  6626 
       
  6627     // len of data is GBA bootstrapping mode tag (1 byte) + sizeof RAND 
       
  6628     // + sizeof AUTN + two length fields (one for RAND len and one for AUTN len)
       
  6629     TUint8 lc( 1 + gbaBootstrap.iRandomParameters.Size() + gbaBootstrap.iAUTN.Size() + 2 );
       
  6630 
       
  6631     aParams.trId = ETrIdEGbaBootstrap;
       
  6632     aParams.apdu.Append( KClaNoSm );             // CLA
       
  6633     aParams.apdu.Append( KEvenInstructionCode ); // INS
       
  6634     aParams.apdu.Append( 0 ); // P1 is set to 0 in case of even instruction
       
  6635     aParams.apdu.Append( KGBAAuthenticationContext ); // P2
       
  6636     aParams.apdu.Append( lc );                        // Lc 
       
  6637     aParams.apdu.Append( KGBABootstappingModeTag );   // GBA bootstrapping mode tag
       
  6638     aParams.apdu.Append( gbaBootstrap.iRandomParameters.Size() ); // len of RAND
       
  6639     aParams.apdu.Append( gbaBootstrap.iRandomParameters );        // RAND
       
  6640     aParams.apdu.Append( gbaBootstrap.iAUTN.Size() );             // len of AUTN
       
  6641     aParams.apdu.Append( gbaBootstrap.iAUTN );                    // AUTN
       
  6642     aParams.apdu.Append( KMaximumLenOfDataExpected );             // Le
       
  6643     }
       
  6644 
       
  6645 // -----------------------------------------------------------------------------
       
  6646 // CMmCustomMessHandler::UiccGBABootstrappingApduResp
       
  6647 // Handles response APDU for GBA security context AUTHENTICATE APDU 
       
  6648 // (bootstrapping mode)
       
  6649 // -----------------------------------------------------------------------------
       
  6650 //
       
  6651 void CMmCustomMessHandler::UiccGBABootstrappingApduResp(
       
  6652     TInt aTraId,
       
  6653     TInt aStatus,
       
  6654      const TDesC8& aFileData )
       
  6655     {
       
  6656 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrappingApduResp.\n" );
       
  6657 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPPINGAPDURESP, "CMmCustomMessHandler::UiccGBABootstrappingApduResp" );
       
  6658 
       
  6659     TInt ret( KErrNone );
       
  6660     RMmCustomAPI::TSimAuthenticationGbaBootstrap gbaBootstrap;
       
  6661 
       
  6662     if( UICC_STATUS_OK == aStatus )
       
  6663         {
       
  6664         // get SW1 and SW2
       
  6665         TUint8 sw1( aFileData[aFileData.Length() - KSw1Position] );
       
  6666         TUint8 sw2( aFileData[aFileData.Length() - KSw2Position] );
       
  6667 
       
  6668         TUint8 result( MapSw1Sw2ToAuthenticateResult( sw1, sw2 ) );
       
  6669 
       
  6670         if( KNormalCommandEnding == result )
       
  6671             {
       
  6672             if( KApduOk == ValidateReceivedAuthenticateApdu( aTraId, aFileData ) )
       
  6673                 {
       
  6674                 TUint32 index( 0 );
       
  6675 
       
  6676                 if( KSuccessfull3GAuthTag == aFileData[index] )
       
  6677                     {
       
  6678                     index++;
       
  6679 
       
  6680                     // get the RES
       
  6681                     TUint8 len( aFileData[index++] );
       
  6682                     gbaBootstrap.iRES.Copy( aFileData.Mid( index, len ) );
       
  6683                     }
       
  6684 
       
  6685                 else if( KSyncFailureTag == aFileData[index] )
       
  6686                     {
       
  6687                     index++;
       
  6688 
       
  6689                     // get the AUTS
       
  6690                     TUint8 len( aFileData[index++] );
       
  6691                     gbaBootstrap.iAUTS.Copy( aFileData.Mid( index, len ) );
       
  6692 
       
  6693                     ret = KErrMMEtelSqnVerificationFailed;
       
  6694                     }
       
  6695                 }
       
  6696             else
       
  6697                 {
       
  6698 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrappingApduResp: APDU validation failed\n" );
       
  6699 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPPINGAPDURESP, "CMmCustomMessHandler::UiccGBABootstrappingApduResp: APDU validation failed" );
       
  6700                 ret = KErrGeneral;
       
  6701                 }
       
  6702             }
       
  6703         else if( KAppAuthErrorIncorrectMac == result )
       
  6704             {
       
  6705 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrappingApduResp: incorrect MAC\n" );
       
  6706 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPPINGAPDURESP, "CMmCustomMessHandler::UiccGBABootstrappingApduResp: incorrect MAC" );
       
  6707             // no parameters in this case
       
  6708             ret = KErrMMEtelMacVerificationFailed;
       
  6709             }
       
  6710         else
       
  6711             {
       
  6712 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrappingApduResp: unknown result\n" );
       
  6713 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPPINGAPDURESP, "CMmCustomMessHandler::UiccGBABootstrappingApduResp: unknown result" );
       
  6714             ret = KErrGeneral;
       
  6715             }
       
  6716         }
       
  6717     else
       
  6718         {
       
  6719 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccGBABootstrappingApduResp: UICC status not ok: 0x%x\n", aStatus );
       
  6720 OstTrace1( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPPINGAPDURESP, "CMmCustomMessHandler::UiccGBABootstrappingApduResp: UICC status not ok: 0x%x", aStatus );
       
  6721         ret = KErrMMEtelAuthenticateFailed;
       
  6722         }
       
  6723 
       
  6724     if( KErrNone == ret || 
       
  6725         KErrMMEtelSqnVerificationFailed == ret || 
       
  6726         KErrMMEtelMacVerificationFailed == ret )
       
  6727         {
       
  6728         CMmDataPackage dataPackage;
       
  6729         dataPackage.PackData( &gbaBootstrap );
       
  6730 
       
  6731         iMessageRouter->Complete(
       
  6732             ECustomGetSimAuthenticationDataIPC,
       
  6733             &dataPackage,
       
  6734             ret );	
       
  6735         }
       
  6736     else
       
  6737         {
       
  6738         iMessageRouter->Complete(
       
  6739             ECustomGetSimAuthenticationDataIPC,
       
  6740             ret );
       
  6741         }
       
  6742     }
       
  6743 
       
  6744 
       
  6745 // -----------------------------------------------------------------------------
       
  6746 // CMmCustomMessHandler::UiccGBABootstrapUpdate
       
  6747 // starts GBA bootstrap update operation
       
  6748 // -----------------------------------------------------------------------------
       
  6749 //
       
  6750 void CMmCustomMessHandler::UiccGBABootstrapUpdate(
       
  6751     const CMmDataPackage& aDataPackage )
       
  6752     {
       
  6753 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrapUpdate.\n" );
       
  6754 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPUPDATE, "CMmCustomMessHandler::UiccGBABootstrapUpdate" );
       
  6755 
       
  6756     // GBA bootstrap update is done by first reading of elementary file EFgba.
       
  6757     // After that RAND is stored temporarily and B-Tid and keylifetime is written
       
  6758     // to EFgba. After write operation, RAND is completed to the client.
       
  6759 
       
  6760     RMmCustomAPI::TSimAuthenticationGbaBootstrapUpdate gbaBootstrapUpdate;
       
  6761     aDataPackage.UnPackData( gbaBootstrapUpdate );
       
  6762 
       
  6763     iBTidBuf.Zero();
       
  6764     iKeyLifetimeBuf.Zero();
       
  6765 
       
  6766     // Store B-TID temporarily
       
  6767     iBTidBuf.Append( gbaBootstrapUpdate.iBTid );
       
  6768 
       
  6769     // Store Key lifetime temporarily
       
  6770     iKeyLifetimeBuf.Append( gbaBootstrapUpdate.iKeyLifeTime );
       
  6771 
       
  6772     // Set parameters for UICC_APPL_CMD_REQ message
       
  6773     TUiccReadTransparent params;
       
  6774     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  6775     params.trId = ETrIdEGbaBootstrapRead;
       
  6776 
       
  6777     params.dataAmount = 0;
       
  6778     params.dataOffset = 0;
       
  6779     params.fileId = KElemGba;
       
  6780     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  6781     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
  6782 
       
  6783     // File id path
       
  6784     params.filePath.Append( KMasterFileId >> 8 );
       
  6785     params.filePath.Append( KMasterFileId );
       
  6786     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
  6787 
       
  6788     iMmUiccMessHandler->CreateUiccApplCmdReq( params ); 
       
  6789     }
       
  6790 
       
  6791 // -----------------------------------------------------------------------------
       
  6792 // CMmCustomMessHandler::UiccGBABootstrapReadResp
       
  6793 // Handles response to elementary file EFgba read operation
       
  6794 // -----------------------------------------------------------------------------
       
  6795 //  
       
  6796 void CMmCustomMessHandler::UiccGBABootstrapReadResp(
       
  6797     TInt aStatus,
       
  6798     const TDesC8& aFileData )
       
  6799     {
       
  6800 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrapReadResp.\n" );
       
  6801 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPREADRESP, "CMmCustomMessHandler::UiccGBABootstrapReadResp" );
       
  6802 
       
  6803     iRandBuf.Zero();
       
  6804 
       
  6805     if( UICC_STATUS_OK == aStatus)
       
  6806         {
       
  6807         // Get the rand len
       
  6808         TUint32 index( 0 );
       
  6809         TUint8 randLen( aFileData[index++] );
       
  6810 
       
  6811         if( aFileData.Length() >= randLen + 
       
  6812             iBTidBuf.Length() + 
       
  6813             iKeyLifetimeBuf.Length() + 
       
  6814             3 )
       
  6815             {
       
  6816             // store rand temporarily so that we can complete it
       
  6817             // when B-Tid and keylifetime is updated to the EFgba.
       
  6818             iRandBuf.Copy( aFileData.Mid( index, randLen ) );
       
  6819 
       
  6820             // Set parameters for UICC_APPL_CMD_REQ message
       
  6821             TUiccWriteTransparent params;
       
  6822             params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  6823             params.trId = ETrIdEGbaBootstrapUpdate;
       
  6824             params.dataOffset = randLen + 1;
       
  6825             params.fileId = KElemGba;
       
  6826             params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  6827             params.serviceType = UICC_APPL_UPDATE_TRANSPARENT;
       
  6828 
       
  6829             // File id path
       
  6830             params.filePath.Append( KMasterFileId >> 8 );
       
  6831             params.filePath.Append( KMasterFileId );
       
  6832             params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
  6833 
       
  6834             // fill file data
       
  6835             params.fileData.Append( iBTidBuf.Length() );
       
  6836             params.fileData.Append( iBTidBuf );
       
  6837             params.fileData.Append( iKeyLifetimeBuf.Length() );
       
  6838             params.fileData.Append( iKeyLifetimeBuf );
       
  6839 
       
  6840             iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  6841             }
       
  6842         else
       
  6843             {
       
  6844 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrapReadResp. File too small for update\n" );
       
  6845 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPREADRESP, "CMmCustomMessHandler::UiccGBABootstrapReadResp. File too small for update" );
       
  6846             iMessageRouter->Complete(
       
  6847                 ECustomGetSimAuthenticationDataIPC,
       
  6848                 KErrArgument );
       
  6849             }
       
  6850         }
       
  6851     else
       
  6852         {
       
  6853 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccGBABootstrapReadResp. EFgba reading failed (0x%x)\n", aStatus );
       
  6854 OstTrace1( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPREADRESP, "CMmCustomMessHandler::UiccGBABootstrapReadResp. EFgba reading failed (%x)", aStatus );
       
  6855         iMessageRouter->Complete(
       
  6856             ECustomGetSimAuthenticationDataIPC,
       
  6857             KErrMMEtelAuthenticateFailed );
       
  6858         }
       
  6859     }
       
  6860 
       
  6861 
       
  6862 // -----------------------------------------------------------------------------
       
  6863 // CMmCustomMessHandler::UiccGBABootstrapUpdateResp
       
  6864 // Handles response to elementary file EFgba write operation
       
  6865 // -----------------------------------------------------------------------------
       
  6866 //
       
  6867 void CMmCustomMessHandler::UiccGBABootstrapUpdateResp( TInt aStatus )
       
  6868     {
       
  6869 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrapUpdateResp.\n" );
       
  6870 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPUPDATERESP, "CMmCustomMessHandler::UiccGBABootstrapUpdateResp" );
       
  6871 
       
  6872     TInt ret( KErrGeneral );
       
  6873     RMmCustomAPI::TSimAuthenticationGbaBootstrapUpdate gbaBootstrapUpdate;
       
  6874 
       
  6875     if( UICC_STATUS_OK == aStatus )
       
  6876         {
       
  6877         ret = KErrNone;
       
  6878         gbaBootstrapUpdate.iRandomParameters.Copy( iRandBuf );
       
  6879         }
       
  6880     else
       
  6881         {
       
  6882         ret = KErrMMEtelAuthenticateFailed;
       
  6883         }
       
  6884 
       
  6885     if( KErrNone == ret )
       
  6886         {
       
  6887         CMmDataPackage dataPackage;
       
  6888         dataPackage.PackData( &gbaBootstrapUpdate );
       
  6889         iMessageRouter->Complete(
       
  6890             ECustomGetSimAuthenticationDataIPC,
       
  6891             &dataPackage,
       
  6892             ret );
       
  6893         }
       
  6894     else
       
  6895         {
       
  6896         iMessageRouter->Complete(
       
  6897             ECustomGetSimAuthenticationDataIPC,
       
  6898             ret );
       
  6899         }
       
  6900     }
       
  6901 
       
  6902 // -----------------------------------------------------------------------------
       
  6903 // CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu
       
  6904 // Constructs GBA security context AUTHENTICATE APDU (NAF derivation mode)
       
  6905 // -----------------------------------------------------------------------------
       
  6906 //
       
  6907 void CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu(
       
  6908     TUiccSendApdu& aParams, 
       
  6909     const CMmDataPackage& aDataPackage )
       
  6910     {
       
  6911 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu.\n" );
       
  6912 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEGBABOOTSTRAPNAFDERIVATIONAPDU, "CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu" );
       
  6913 
       
  6914     RMmCustomAPI::TSimAuthenticationGbaNafDerivation gbaBootstrapNafDerivation;
       
  6915     aDataPackage.UnPackData( gbaBootstrapNafDerivation );
       
  6916 
       
  6917     // len of data is GBA NAF derivation mode tag (1 byte) + sizeof NAFId 
       
  6918     // + sizeof IMPI + two length fields (one for NAFId len and one for IMPI len)
       
  6919     TUint8 lc( 1 + 
       
  6920                gbaBootstrapNafDerivation.iNafId.Size() + 
       
  6921                gbaBootstrapNafDerivation.iImpi.Size() + 
       
  6922                2 );
       
  6923 
       
  6924     aParams.trId = ETrIdEGbaNafDerivation;
       
  6925     aParams.apdu.Append( KClaNoSm );             // CLA
       
  6926     aParams.apdu.Append( KEvenInstructionCode ); // INS
       
  6927     aParams.apdu.Append( 0 ); // P1 is set to 0 in case of even instruction
       
  6928     aParams.apdu.Append( KGBAAuthenticationContext ); // P2
       
  6929     aParams.apdu.Append( lc );                        // Lc 
       
  6930     aParams.apdu.Append( KGBANAFDerivationModeTag );   // GBA bootstrapping mode tag
       
  6931     aParams.apdu.Append( gbaBootstrapNafDerivation.iNafId.Size() ); // len of NAFId
       
  6932     aParams.apdu.Append( gbaBootstrapNafDerivation.iNafId );        // NAFId
       
  6933     aParams.apdu.Append( gbaBootstrapNafDerivation.iImpi.Size() );  // len of IMPI
       
  6934     aParams.apdu.Append( gbaBootstrapNafDerivation.iImpi );         // IMPI
       
  6935     aParams.apdu.Append( KMaximumLenOfDataExpected );               // Le
       
  6936     }
       
  6937 
       
  6938 
       
  6939 // -----------------------------------------------------------------------------
       
  6940 // CMmCustomMessHandler::UiccGBABootstrapNafDerivationApduResp
       
  6941 // Handles response APDU for GBA security context AUTHENTICATE APDU 
       
  6942 // (NAF derivation mode)
       
  6943 // -----------------------------------------------------------------------------
       
  6944 //
       
  6945 void CMmCustomMessHandler::UiccGBANafDerivationApduResp(
       
  6946     TInt aTraId,
       
  6947     TInt aStatus,
       
  6948     const TDesC8& aFileData )
       
  6949     {
       
  6950 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrapNafDerivationApduResp.\n" );
       
  6951 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCGBANAFDERIVATIONAPDURESP, "CMmCustomMessHandler::UiccGBANafDerivationApduResp" );
       
  6952 
       
  6953     TInt ret( KErrNone );
       
  6954     RMmCustomAPI::TSimAuthenticationGbaNafDerivation gbaNafDerivation;
       
  6955 
       
  6956     if( UICC_STATUS_OK == aStatus )
       
  6957         {
       
  6958         // get SW1 and SW2
       
  6959         TUint8 sw1( aFileData[aFileData.Length() - KSw1Position] );
       
  6960         TUint8 sw2( aFileData[aFileData.Length() - KSw2Position] );
       
  6961 
       
  6962         TUint8 result( MapSw1Sw2ToAuthenticateResult( sw1, sw2 ) );
       
  6963 
       
  6964         if( KNormalCommandEnding == result )
       
  6965             {
       
  6966             if( KApduOk == ValidateReceivedAuthenticateApdu( aTraId, aFileData ) )
       
  6967                 {
       
  6968                 // Let's skip "Successful GBA operation" tag
       
  6969                 // and start with Length of Length of Ks ext NAF 
       
  6970                 TUint32 index( 1 );
       
  6971 
       
  6972                 // get the Ks ext NAF
       
  6973                 TUint8 len( aFileData[index++] );
       
  6974                 gbaNafDerivation.iKsExtNaf.Copy( aFileData.Mid( index, len ) );
       
  6975                 }
       
  6976             else
       
  6977                 {
       
  6978 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrapNafDerivationApduResp: APDU validation failed\n" );
       
  6979 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICCGBANAFDERIVATIONAPDURESP, "CMmCustomMessHandler::UiccGBANafDerivationApduResp: APDU validation failed" );
       
  6980                 ret = KErrGeneral;
       
  6981                 }
       
  6982             }
       
  6983         else if( KCmdNotAllowedConditionsNotSatisfied == result )
       
  6984             {
       
  6985             ret = KErrNotSupported;
       
  6986             }
       
  6987         else
       
  6988             {
       
  6989 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrapNafDerivationApduResp: unknown result\n" );
       
  6990 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_UICCGBANAFDERIVATIONAPDURESP, "CMmCustomMessHandler::UiccGBANafDerivationApduResp: unknown result" );
       
  6991             ret = KErrGeneral;
       
  6992             }
       
  6993         }
       
  6994     else
       
  6995         {
       
  6996 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccGBABootstrapNafDerivationApduResp: UICC status not ok: 0x%x\n", aStatus );
       
  6997 OstTrace1( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_UICCGBANAFDERIVATIONAPDURESP, "CMmCustomMessHandler::UiccGBANafDerivationApduResp: UICC status not ok: 0x%x", aStatus );
       
  6998         ret = KErrMMEtelAuthenticateFailed;
       
  6999         }
       
  7000 
       
  7001     if( KErrNone == ret )
       
  7002         {
       
  7003         CMmDataPackage dataPackage;
       
  7004         dataPackage.PackData( &gbaNafDerivation );
       
  7005 
       
  7006         iMessageRouter->Complete(
       
  7007             ECustomGetSimAuthenticationDataIPC,
       
  7008             &dataPackage,
       
  7009             ret );	
       
  7010         }
       
  7011     else
       
  7012         {
       
  7013         iMessageRouter->Complete(
       
  7014             ECustomGetSimAuthenticationDataIPC,
       
  7015             ret );
       
  7016         }
       
  7017     }
       
  7018 
       
  7019 
       
  7020 // -----------------------------------------------------------------------------
       
  7021 // CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu
       
  7022 // Constructs MBMS security context AUTHENTICATE APDU (MSK Update Mode)
       
  7023 // -----------------------------------------------------------------------------
       
  7024 //
       
  7025 void CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu(
       
  7026     TUiccSendApdu& params, 
       
  7027     const CMmDataPackage& aDataPackage )
       
  7028     {
       
  7029 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu.\n" );
       
  7030 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEMBMSMSKUPDATEAPDU, "CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu" );
       
  7031 
       
  7032     // Note. MBMS functionality is not tested in real hardware and in real environmen
       
  7033     //  because of there is no users for this authentication type. So this is implemented
       
  7034     // with the best knowledge at the moment and it can contain some bugs which 
       
  7035     // can be found when this is tested in real environment.
       
  7036 
       
  7037     RMmCustomAPI::TSimAuthenticationMgvMskUpdate mskUpdate;
       
  7038     aDataPackage.UnPackData( mskUpdate );
       
  7039 
       
  7040     // len of data is MBMS Data Object tag (1 byte) +
       
  7041     // MBMS Data Object length (1 byte) +
       
  7042     // MBMS Security Context Mode (1 byte) + size of Mikey
       
  7043     TUint8 lc( 1 + 1 + 1 + mskUpdate.iMikey.Size() );
       
  7044 
       
  7045     params.trId = ETrIdEMbmsMskUpdate;
       
  7046     params.apdu.Append( KClaNoSm );             // CLA
       
  7047     params.apdu.Append( KOddInstructionCode );  // INS
       
  7048     params.apdu.Append( KFirstBlockOfAuthenticationData ); // P1
       
  7049     params.apdu.Append( KMBMSAuthenticationContext ); // P2
       
  7050     params.apdu.Append( lc );                         // Lc 
       
  7051     params.apdu.Append( KMBMSDataObjectTag );          // MBMS Data object tag
       
  7052     params.apdu.Append( mskUpdate.iMikey.Size() + 1 ); // MBMS data obj len
       
  7053     params.apdu.Append( KMskUpdateMode );              // MBMS Security Context Mode
       
  7054     params.apdu.Append( mskUpdate.iMikey );            // Mikey
       
  7055     }
       
  7056 
       
  7057 
       
  7058 // -----------------------------------------------------------------------------
       
  7059 // CMmCustomMessHandler::UiccMbmsMskUpdateApduResp
       
  7060 // Handles response APDU for MBMS security context AUTHENTICATE APDU 
       
  7061 // (MSK Update Mode)
       
  7062 // -----------------------------------------------------------------------------
       
  7063 //
       
  7064 void CMmCustomMessHandler::UiccMbmsMskUpdateApduResp(
       
  7065     TInt aStatus,
       
  7066     const TDesC8& aFileData )
       
  7067     {
       
  7068 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMbmsMskUpdateApduResp.\n" );
       
  7069 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMBMSMSKUPDATEAPDURESP, "CMmCustomMessHandler::UiccMbmsMskUpdateApduResp" );
       
  7070 
       
  7071     // Note. MBMS functionality is not tested in real hardware and in real environment
       
  7072     // because of at the moment there is no users for this authentication type. 
       
  7073     // So this is implemented with the best knowledge at the moment and it can contain 
       
  7074     // some bugs which can be found when this is tested in real environment.
       
  7075 
       
  7076     TInt ret( KErrGeneral );
       
  7077     RMmCustomAPI::TSimAuthenticationMgvMskUpdate mskUpdate;
       
  7078     TBool completeNeeded( ETrue );
       
  7079 
       
  7080     if( UICC_STATUS_OK == aStatus )
       
  7081         {
       
  7082         // get SW1 and SW2
       
  7083         TUint8 sw1( aFileData[aFileData.Length() - KSw1Position] );
       
  7084         TUint8 sw2( aFileData[aFileData.Length() - KSw2Position] );
       
  7085 
       
  7086         TUint8 result( MapSw1Sw2ToAuthenticateResult( sw1, sw2 ) );
       
  7087 
       
  7088         switch( result )
       
  7089             {
       
  7090             case KNormalCommandEnding:
       
  7091             case KWarningMoreDataAvailable:
       
  7092                 {
       
  7093                 TBuf8<KMaxApduSize> mbmsOperationData;
       
  7094 
       
  7095                 if( FindTlvObject( KMbmsOperationResponseTag53, aFileData.Mid( 0, aFileData.Length() - 2 ), mbmsOperationData ) ||
       
  7096                     FindTlvObject( KMbmsOperationResponseTag73, aFileData.Mid( 0, aFileData.Length() - 2 ), mbmsOperationData ) )
       
  7097                     {
       
  7098                     ret = KErrNone;
       
  7099                     mskUpdate.iMikey.Zero();
       
  7100                     if( KSuccessfullMbmsOperationTag == mbmsOperationData[0] )
       
  7101                         {
       
  7102                         UiccMskUpdateHandleMbmsOperationData( mskUpdate, mbmsOperationData );
       
  7103                         }
       
  7104                     else
       
  7105                         {
       
  7106                         UiccMskUpdateHandleOMABcastOperationData( mskUpdate, mbmsOperationData );
       
  7107                         }
       
  7108                     }
       
  7109                 break;
       
  7110                 }
       
  7111             case KWarningAuthRespAvailable:
       
  7112                 {
       
  7113                 UiccCreateFirstBlockOfAuthRespApdu( ETrIdEMbmsMskUpdate );
       
  7114                 completeNeeded = EFalse;
       
  7115                 break;
       
  7116                 }
       
  7117             case KCmdNotAllowedConditionsNotSatisfied:
       
  7118                 {
       
  7119                 ret = KErrCustomSCCondOfuseNotSatisfied;
       
  7120                 break;
       
  7121                 }
       
  7122             case KAppErrorAuthMbmsOutOfMemMuk:
       
  7123                 {
       
  7124                 ret = KErrCustomSCNoMemSpaceAvailableMukAuthError;
       
  7125                 break;
       
  7126                 }
       
  7127             case KAppErrorAuthMbmsOutOfMemMsk:
       
  7128                 {
       
  7129                 ret = KErrCustomSCNoMemSpaceAvailableAuthError;
       
  7130                 break;
       
  7131                 }
       
  7132             case KAppAuthErrorIncorrectMac:
       
  7133                 {
       
  7134                 ret = KErrCustomSCIncorrectMACAuthError;
       
  7135                 break;
       
  7136                 }
       
  7137             case KWrongParametersDataNotFound:
       
  7138                 {
       
  7139                 ret = KErrCustomSCRefDataNotFound;
       
  7140                 break;
       
  7141                 }
       
  7142             default:
       
  7143                 {
       
  7144                 ret = KErrGeneral;
       
  7145                 break;
       
  7146                 }
       
  7147             }
       
  7148         }
       
  7149     else
       
  7150         {
       
  7151 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccMbmsMskUpdateApduResp: UICC status not ok: 0x%x\n", aStatus );
       
  7152 OstTrace1( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICCMBMSMSKUPDATEAPDURESP, "CMmCustomMessHandler::UiccMbmsMskUpdateApduResp: UICC status not ok: 0x%x", aStatus );
       
  7153         ret = KErrMMEtelAuthenticateFailed;
       
  7154         }
       
  7155 
       
  7156     if( completeNeeded )
       
  7157         {
       
  7158         if( KErrNone == ret )
       
  7159             {
       
  7160             CMmDataPackage dataPackage;
       
  7161             dataPackage.PackData( &mskUpdate );
       
  7162 
       
  7163             iMessageRouter->Complete(
       
  7164                 ECustomGetSimAuthenticationDataIPC,
       
  7165                 &dataPackage,
       
  7166                 ret );	
       
  7167             }
       
  7168         else
       
  7169             {
       
  7170             iMessageRouter->Complete(
       
  7171                 ECustomGetSimAuthenticationDataIPC,
       
  7172                 ret );
       
  7173             }
       
  7174         }
       
  7175     }
       
  7176 
       
  7177 
       
  7178 // -----------------------------------------------------------------------------
       
  7179 // CMmCustomMessHandler::UiccMskUpdateHandleMbmsOperationData
       
  7180 // Handles MBMS operation data from MSK Update authenticate APDU
       
  7181 // -----------------------------------------------------------------------------
       
  7182 //
       
  7183 void CMmCustomMessHandler::UiccMskUpdateHandleMbmsOperationData(
       
  7184     RMmCustomAPI::TSimAuthenticationMgvMskUpdate& aMskUpdate,
       
  7185     TDesC8& aMbmsData )
       
  7186     {
       
  7187 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMskUpdateHandleMbmsOperationData.\n" );
       
  7188 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMSKUPDATEHANDLEMBMSOPERATIONDATA, "CMmCustomMessHandler::UiccMskUpdateHandleMbmsOperationData" );
       
  7189 
       
  7190     TUint8 index( 0 );
       
  7191     TUint32 objLen( aMbmsData.Length() );
       
  7192 
       
  7193     if( KSuccessfullMbmsOperationTag == aMbmsData[index] &&
       
  7194         1 <= objLen && 
       
  7195         ( KMaxMbmsMikeyLen + 1 ) >= objLen  ) // + 1 for 0xDB TLV tag
       
  7196         {
       
  7197         index++;
       
  7198 
       
  7199         // len of MIKEY is obj len - 1 because of 
       
  7200         // obj data contains 1 byte for 
       
  7201         // Successfull Mbms Operation Tag
       
  7202         TUint8 mikeyLen = objLen - 1;
       
  7203         if( 0 < mikeyLen )
       
  7204             {
       
  7205             aMskUpdate.iMikey.Copy( aMbmsData.Mid( index, mikeyLen ) );
       
  7206             }
       
  7207         }
       
  7208     }
       
  7209 
       
  7210 
       
  7211 // -----------------------------------------------------------------------------
       
  7212 // CMmCustomMessHandler::UiccMskUpdateHandleMbmsOperationData
       
  7213 // Handles OMA BCAST operation data from authenticate APDU
       
  7214 // -----------------------------------------------------------------------------
       
  7215 //
       
  7216 void CMmCustomMessHandler::UiccMskUpdateHandleOMABcastOperationData( 
       
  7217                 RMmCustomAPI::TSimAuthenticationMgvMskUpdate& aMskUpdate,
       
  7218                 TDesC8& aMbmsData )
       
  7219     {
       
  7220 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMskUpdateHandleOMABcastOperationData.\n" );
       
  7221 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMSKUPDATEHANDLEOMABCASTOPERATIONDATA, "CMmCustomMessHandler::UiccMskUpdateHandleOMABcastOperationData" );
       
  7222 
       
  7223     TBuf8<KMaxApduSize> omaBcastData;
       
  7224 
       
  7225     if( FindTlvObject( KOMABcastOperationResponseTag, aMbmsData, omaBcastData ) )
       
  7226         {
       
  7227         TBuf8<KMaxApduSize> bcastManagementData;
       
  7228         TBuf8<KMaxParentalRatingDataSize> parentalRatingData;
       
  7229         TBuf8<KMaxSpeSize> speTypeNotSupportedData;
       
  7230         TBuf8<KMaxApduSize> mikeyData;
       
  7231 
       
  7232         if( FindTlvObject( KBcastManagementDataTag, omaBcastData, bcastManagementData ) )
       
  7233             {
       
  7234             aMskUpdate.iBCASTManagement.Copy( bcastManagementData );
       
  7235             }
       
  7236         if( FindTlvObject( KParentalRatingDataTag, omaBcastData, parentalRatingData ) )
       
  7237             {
       
  7238             aMskUpdate.iParentalRating.Copy( parentalRatingData );
       
  7239             }
       
  7240         if( FindTlvObject( KSPETypeNotSupportedTag, omaBcastData, speTypeNotSupportedData ) )
       
  7241             {
       
  7242             aMskUpdate.iSecurityPolicyExt.Copy( speTypeNotSupportedData );
       
  7243             }
       
  7244 
       
  7245         if( FindTlvObject( KMikeyMessageTag, omaBcastData, mikeyData ) )
       
  7246             {
       
  7247             aMskUpdate.iMikey.Copy( mikeyData );
       
  7248             }
       
  7249         }
       
  7250     }
       
  7251 
       
  7252 
       
  7253 // -----------------------------------------------------------------------------
       
  7254 // CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu
       
  7255 // Constructs MBMS security context AUTHENTICATE APDU (MTK Generation Mode)
       
  7256 // -----------------------------------------------------------------------------
       
  7257 //
       
  7258 void CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu(
       
  7259     TUiccSendApdu& params, 
       
  7260     const CMmDataPackage& aDataPackage )
       
  7261     {
       
  7262 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu.\n" );
       
  7263 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEMBMSMTKGENERATIONAPDU, "CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu" );
       
  7264 
       
  7265     // Note. MBMS functionality is not tested in real hardware and in real environment
       
  7266     // because of at the moment there is no users for this authentication type. 
       
  7267     // So this is implemented with the best knowledge at the moment and it can contain 
       
  7268     // some bugs which can be found when this is tested in real environment.
       
  7269 
       
  7270     RMmCustomAPI::TSimAuthenticationMgvMtkGeneration mtkGen;
       
  7271     aDataPackage.UnPackData( mtkGen );
       
  7272 
       
  7273     // len of data is MBMS Data Object tag (1 byte) +
       
  7274     // MBMS Data Object length (1 byte) +
       
  7275     // MBMS Security Context Mode (1 byte) + size of Mikey
       
  7276     TUint8 lc( 1 + 1 + 1 + mtkGen.iMikey.Size() );
       
  7277 
       
  7278     params.trId = ETrIdEMbmsMtkGeneration;
       
  7279     params.apdu.Append( KClaNoSm );             // CLA
       
  7280     params.apdu.Append( KOddInstructionCode );  // INS
       
  7281     params.apdu.Append( KFirstBlockOfAuthenticationData ); // P1
       
  7282     params.apdu.Append( KMBMSAuthenticationContext ); // P2
       
  7283     params.apdu.Append( lc );                         // Lc 
       
  7284     params.apdu.Append( KMBMSDataObjectTag );          // MBMS Data object tag
       
  7285     params.apdu.Append( mtkGen.iMikey.Size() + 1 ); // MBMS data obj len
       
  7286     params.apdu.Append( KMtkGenerationMode );          // MBMS Security Context Mode
       
  7287     params.apdu.Append( mtkGen.iMikey );            // Mikey
       
  7288     }
       
  7289 
       
  7290 
       
  7291 // -----------------------------------------------------------------------------
       
  7292 // CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp
       
  7293 // Handles response APDU for MBMS security context AUTHENTICATE APDU 
       
  7294 // (MTK Generation Mode)
       
  7295 // -----------------------------------------------------------------------------
       
  7296 //
       
  7297 void CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp(
       
  7298     TInt aStatus,
       
  7299     const TDesC8& aFileData )
       
  7300     {
       
  7301 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp.\n" );
       
  7302 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMBMSMTKGENERATIONAPDURESP, "CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp" );
       
  7303 
       
  7304     // Note. MBMS functionality is not tested in real hardware and in real environment
       
  7305     // because of at the moment there is no users for this authentication type. 
       
  7306     // So this is implemented with the best knowledge at the moment and it can contain 
       
  7307     // some bugs which can be found when this is tested in real environment.
       
  7308 
       
  7309     TInt ret( KErrGeneral );
       
  7310     RMmCustomAPI::TSimAuthenticationMgvMtkGeneration mtkGen;
       
  7311     TBool completeNeeded( ETrue );
       
  7312 
       
  7313     if( UICC_STATUS_OK == aStatus )
       
  7314         {
       
  7315         // get SW1 and SW2
       
  7316         TUint8 sw1( aFileData[aFileData.Length() - KSw1Position] );
       
  7317         TUint8 sw2( aFileData[aFileData.Length() - KSw2Position] );
       
  7318 
       
  7319         TUint8 result( MapSw1Sw2ToAuthenticateResult( sw1, sw2 ) );
       
  7320 
       
  7321         switch( result )
       
  7322             {
       
  7323             case KNormalCommandEnding:
       
  7324             case KWarningMoreDataAvailable:
       
  7325                 {
       
  7326                 TBuf8<KMaxApduSize> mbmsOperationData;
       
  7327 
       
  7328                 if( FindTlvObject( KMbmsOperationResponseTag53, aFileData.Mid( 0, aFileData.Length() - 2 ), mbmsOperationData ) || 
       
  7329                     FindTlvObject( KMbmsOperationResponseTag73, aFileData.Mid( 0, aFileData.Length() - 2 ), mbmsOperationData ) )
       
  7330                     {
       
  7331                     ret = KErrNone;
       
  7332                     if( KSuccessfullMbmsOperationTag == mbmsOperationData[0] )
       
  7333                         {
       
  7334                         UiccMtkGenHandleMbmsOperationData( mtkGen, mbmsOperationData );
       
  7335                         }
       
  7336                     else
       
  7337                         {
       
  7338                         UiccMtkGenHandleOMABcastOperationData( mtkGen, mbmsOperationData );
       
  7339                         }
       
  7340                     }
       
  7341                 break;
       
  7342                 }
       
  7343             case KWarningAuthRespAvailable:
       
  7344                 {
       
  7345                 UiccCreateFirstBlockOfAuthRespApdu( ETrIdEMbmsMtkGeneration );
       
  7346                 completeNeeded = EFalse;
       
  7347                 break;
       
  7348                 }
       
  7349             case KCmdNotAllowedConditionsNotSatisfied:
       
  7350                 {
       
  7351                 ret = KErrCustomSCCondOfuseNotSatisfied;
       
  7352                 break;
       
  7353                 }
       
  7354             case KAppErrorAuthMbmsKeyFresh:
       
  7355                 {
       
  7356                 ret = KErrCustomSCKeyRefreshFail;
       
  7357                 break;
       
  7358                 }
       
  7359             case KAppAuthErrorIncorrectMac:
       
  7360                 {
       
  7361                 ret = KErrCustomSCIncorrectMACAuthError;
       
  7362                 break;
       
  7363                 }
       
  7364             case KWrongParametersDataNotFound:
       
  7365                 {
       
  7366                 ret = KErrCustomSCRefDataNotFound;
       
  7367                 break;
       
  7368                 }
       
  7369             default:
       
  7370                 {
       
  7371                 ret = KErrGeneral;
       
  7372                 break;
       
  7373                 }
       
  7374             }
       
  7375         }
       
  7376     else
       
  7377         {
       
  7378 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp: UICC status not ok: 0x%x\n", aStatus );
       
  7379 OstTrace1( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICCMBMSMTKGENERATIONAPDURESP, "CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp: UICC status not ok: 0x%x", aStatus );
       
  7380         ret = KErrMMEtelAuthenticateFailed;
       
  7381         }
       
  7382 
       
  7383     if( completeNeeded )
       
  7384         {
       
  7385         if( KErrNone == ret )
       
  7386             {
       
  7387             CMmDataPackage dataPackage;
       
  7388             dataPackage.PackData( &mtkGen );
       
  7389 
       
  7390             iMessageRouter->Complete(
       
  7391                 ECustomGetSimAuthenticationDataIPC,
       
  7392                 &dataPackage,
       
  7393                 ret );	
       
  7394             }
       
  7395         else
       
  7396             {
       
  7397             iMessageRouter->Complete(
       
  7398                 ECustomGetSimAuthenticationDataIPC,
       
  7399                 ret );
       
  7400             }
       
  7401         }
       
  7402     }
       
  7403 
       
  7404 
       
  7405 // -----------------------------------------------------------------------------
       
  7406 // CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData
       
  7407 // Handles MBMS operation data from MTK Generation authenticate APDU
       
  7408 // -----------------------------------------------------------------------------
       
  7409 //
       
  7410 void CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData( 
       
  7411     RMmCustomAPI::TSimAuthenticationMgvMtkGeneration& aMtkGen,
       
  7412     TDesC8& aMbmsData )
       
  7413     {
       
  7414 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData.\n" );
       
  7415 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMTKGENHANDLEMBMSOPERATIONDATA, "CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData" );
       
  7416 
       
  7417     TUint8 index( 0 );
       
  7418     TUint32 objLen( aMbmsData.Length() );
       
  7419 
       
  7420     if( KSuccessfullMbmsOperationTag == aMbmsData[index] &&
       
  7421         1 <= objLen && 
       
  7422         ( KMaxMbmsSaltLen + 1 ) >= objLen  ) // + 1 for 0xDB TLV tag
       
  7423         {
       
  7424         index++;
       
  7425 
       
  7426         // len of SALT is obj len - 1 because of 
       
  7427         // obj data contains 1 byte for 
       
  7428         // Successfull Mbms Operation Tag
       
  7429         TUint8 saltLen( objLen - 1 );
       
  7430         if( 0 < saltLen )
       
  7431             {
       
  7432             aMtkGen.iMtkSalt.Copy( aMbmsData.Mid( index, saltLen ) );
       
  7433             }
       
  7434         }
       
  7435     }
       
  7436 
       
  7437 
       
  7438 // -----------------------------------------------------------------------------
       
  7439 // CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData
       
  7440 // Handles OMA BCAST operation data from authenticate APDU
       
  7441 // -----------------------------------------------------------------------------
       
  7442 //
       
  7443 void CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData( 
       
  7444          RMmCustomAPI::TSimAuthenticationMgvMtkGeneration& aMtkGen,
       
  7445          TDesC8& aMbmsData )
       
  7446     {
       
  7447 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData.\n" );
       
  7448 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMTKGENHANDLEOMABCASTOPERATIONDATA, "CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData" );
       
  7449 
       
  7450     TBuf8<KMaxApduSize> omaBcastData;
       
  7451 
       
  7452     if( FindTlvObject( KOMABcastOperationResponseTag, aMbmsData, omaBcastData ) )
       
  7453         {
       
  7454         TBuf8<KMaxApduSize> bcastManagementData;
       
  7455         TBuf8<KMaxApduSize> tekData;
       
  7456         TBuf8<KMaxApduSize> saltData;
       
  7457         TBuf8<KMaxApduSize> parentalControlData;
       
  7458 
       
  7459         if( FindTlvObject( KBcastManagementDataTag, omaBcastData, bcastManagementData ) )
       
  7460             {
       
  7461             aMtkGen.iBCASTManagement.Copy( bcastManagementData );
       
  7462             }
       
  7463         if( FindTlvObject( KTekDataTag, omaBcastData, tekData ) )
       
  7464             {
       
  7465             aMtkGen.iTrafficEncryptionKey.Copy( tekData );
       
  7466             }
       
  7467         if( FindTlvObject( KParentalControlTag, omaBcastData, parentalControlData ) )
       
  7468             {
       
  7469             // first parameter of parental control data is "key reference for second 
       
  7470             // application PIN defined for parental contol" but it's not supported 
       
  7471             // at the moment
       
  7472             aMtkGen.iParentalControl.Append( parentalControlData[1] ); // rating type
       
  7473             aMtkGen.iParentalControl.Append( parentalControlData[2] ); // rating value
       
  7474             aMtkGen.iParentalControl.Append( parentalControlData[3] ); // level granted value
       
  7475             }
       
  7476         if( FindTlvObject( KSaltDataTag, omaBcastData, saltData ) )
       
  7477             {
       
  7478             aMtkGen.iMtkSalt.Copy( saltData );
       
  7479             }
       
  7480         }
       
  7481     }
       
  7482 
       
  7483 
       
  7484 // -----------------------------------------------------------------------------
       
  7485 // CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu
       
  7486 // Constructs MBMS security context AUTHENTICATE APDU (MSK Deletion Mode)
       
  7487 // -----------------------------------------------------------------------------
       
  7488 //
       
  7489 void CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu(
       
  7490     TUiccSendApdu& params, 
       
  7491     const CMmDataPackage& aDataPackage )
       
  7492     {
       
  7493 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu.\n" );
       
  7494 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEMBMSMSKDELETIONAPDU, "CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu" );
       
  7495     
       
  7496     // Note. MBMS functionality is not tested in real hardware and in real environment
       
  7497     // because of at the moment there is no users for this authentication type. 
       
  7498     // So this is implemented with the best knowledge at the moment and it can contain 
       
  7499     // some bugs which can be found when this is tested in real environment.
       
  7500 
       
  7501     RMmCustomAPI::TSimAuthenticationMgvMskDeletion mskDel;
       
  7502     aDataPackage.UnPackData( mskDel );
       
  7503 
       
  7504     // len of data is MBMS Data Object tag (1 byte) +
       
  7505     // MBMS Data Object length (1 byte) +
       
  7506     // MBMS Security Context Mode (1 byte) + 
       
  7507     // size of Key Domain Id + size of Key Group Id Part
       
  7508     TUint8 lc( 1 + 
       
  7509                1 + 
       
  7510                1 + 
       
  7511                mskDel.iKeyDomainId.Size() + 
       
  7512                mskDel.iKeyGroupIdPart.Size() );
       
  7513 
       
  7514     // data size in MBMS Data Object Tag is:
       
  7515     // MBMS Security Context Mode (1 byte) + 
       
  7516     // size of Key Domain Id + size of Key Group Id Part
       
  7517     TUint8 dataSize( 1 + 
       
  7518                      mskDel.iKeyDomainId.Size() + 
       
  7519                      mskDel.iKeyGroupIdPart.Size() );
       
  7520 
       
  7521     params.trId = ETrIdEMbmsMskDeletion;
       
  7522     params.apdu.Append( KClaNoSm );             // CLA
       
  7523     params.apdu.Append( KOddInstructionCode );  // INS
       
  7524     params.apdu.Append( KFirstBlockOfAuthenticationData ); // P1
       
  7525     params.apdu.Append( KMBMSAuthenticationContext ); // P2
       
  7526     params.apdu.Append( lc );                         // Lc 
       
  7527     params.apdu.Append( KMBMSDataObjectTag );       // MBMS Data object tag
       
  7528     params.apdu.Append( dataSize );                 // MBMS data obj len
       
  7529     params.apdu.Append( KMskDeletionMode );         // MBMS Security Context Mode
       
  7530     params.apdu.Append( mskDel.iKeyDomainId );      // Key Domain Id
       
  7531     params.apdu.Append( mskDel.iKeyGroupIdPart );   // Key Group Id
       
  7532     }
       
  7533 
       
  7534 
       
  7535 // -----------------------------------------------------------------------------
       
  7536 // CMmCustomMessHandler::UiccMbmsMskDeletionApduResp
       
  7537 // Handles response APDU for MBMS security context AUTHENTICATE APDU 
       
  7538 // (MSK Deletion Mode)
       
  7539 // -----------------------------------------------------------------------------
       
  7540 //
       
  7541 void CMmCustomMessHandler::UiccMbmsMskDeletionApduResp(
       
  7542     TInt aStatus,
       
  7543     const TDesC8& aFileData )
       
  7544     {
       
  7545 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMbmsMskDeletionApduResp.\n" );
       
  7546 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMBMSMSKDELETIONAPDURESP, "CMmCustomMessHandler::UiccMbmsMskDeletionApduResp" );
       
  7547 
       
  7548     // Note. MBMS functionality is not tested in real hardware and in real environment
       
  7549     // because of at the moment there is no users for this authentication type. 
       
  7550     // So this is implemented with the best knowledge at the moment and it can contain 
       
  7551     // some bugs which can be found when this is tested in real environment.
       
  7552 
       
  7553     TInt ret( KErrGeneral );
       
  7554     RMmCustomAPI::TSimAuthenticationMgvMskDeletion mskDel;
       
  7555     TBool completeNeeded( ETrue );
       
  7556 
       
  7557     if( UICC_STATUS_OK == aStatus )
       
  7558         {
       
  7559         // get SW1 and SW2
       
  7560         TUint8 sw1( aFileData[aFileData.Length() - KSw1Position] );
       
  7561         TUint8 sw2(aFileData[aFileData.Length() - KSw2Position] );
       
  7562 
       
  7563         TUint8 result( MapSw1Sw2ToAuthenticateResult( sw1, sw2 ) );
       
  7564 
       
  7565         switch( result )
       
  7566             {
       
  7567             case KNormalCommandEnding:
       
  7568                 {
       
  7569                 TBuf8<KMaxApduSize> mbmsOperationData;
       
  7570 
       
  7571                 if( FindTlvObject( KMbmsOperationResponseTag53, aFileData.Mid( 0, aFileData.Length() - 2 ), mbmsOperationData ) )
       
  7572                     {
       
  7573                     if( KSuccessfullMbmsOperationTag == mbmsOperationData[0] )
       
  7574                         {
       
  7575                         ret = KErrNone;
       
  7576                         }
       
  7577                     }
       
  7578                 break;
       
  7579                 }
       
  7580             case KWarningAuthRespAvailable:
       
  7581                 {
       
  7582                 UiccCreateFirstBlockOfAuthRespApdu( ETrIdEMbmsMskDeletion );
       
  7583                 completeNeeded = EFalse;
       
  7584                 break;
       
  7585                 }
       
  7586             case KWrongParametersDataNotFound:
       
  7587                 {
       
  7588                 ret = KErrCustomSCRefDataNotFound;
       
  7589                 break;
       
  7590                 }
       
  7591             default:
       
  7592                 {
       
  7593                 ret = KErrGeneral;
       
  7594                 break;
       
  7595                 }
       
  7596             }
       
  7597         }
       
  7598     else
       
  7599         {
       
  7600 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccMbmsMskDeletionApduResp: UICC status not ok: 0x%x\n", aStatus );
       
  7601 OstTrace1( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICCMBMSMSKDELETIONAPDURESP, "CMmCustomMessHandler::UiccMbmsMskDeletionApduResp: UICC status not ok: 0x%x", aStatus );
       
  7602         ret = KErrMMEtelAuthenticateFailed;
       
  7603         }
       
  7604 
       
  7605     if( completeNeeded )
       
  7606         {
       
  7607         if( KErrNone == ret )
       
  7608             {
       
  7609             CMmDataPackage dataPackage;
       
  7610             dataPackage.PackData( &mskDel );
       
  7611 
       
  7612             iMessageRouter->Complete(
       
  7613                 ECustomGetSimAuthenticationDataIPC,
       
  7614                 &dataPackage,
       
  7615                 ret );	
       
  7616             }
       
  7617         else
       
  7618             {
       
  7619             iMessageRouter->Complete(
       
  7620                 ECustomGetSimAuthenticationDataIPC,
       
  7621                 ret );
       
  7622             }
       
  7623         }
       
  7624     }
       
  7625 
       
  7626 
       
  7627 // -----------------------------------------------------------------------------
       
  7628 // CMmCustomMessHandler::UiccCreateFirstBlockOfAuthRespApdu
       
  7629 // Constructs APDU to get authenticate response data in case of odd ins code
       
  7630 // -----------------------------------------------------------------------------
       
  7631 //
       
  7632 void CMmCustomMessHandler::UiccCreateFirstBlockOfAuthRespApdu( TUiccTrId aTrId )
       
  7633     {
       
  7634 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateFirstBlockOfAuthRespApdu.\n" );
       
  7635 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEFIRSTBLOCKOFAUTHRESPAPDU, "CMmCustomMessHandler::UiccCreateFirstBlockOfAuthRespApdu" );
       
  7636 
       
  7637     // Fill parameters to instance created from TUiccSendApdu
       
  7638     // needed for APDU sending
       
  7639     TUiccSendApdu params;
       
  7640     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  7641     params.serviceType = UICC_APPL_APDU_SEND;
       
  7642     params.fileId = UICC_EF_ID_NOT_PRESENT;
       
  7643     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  7644     params.filePath.Append( KMasterFileId >> 8 );
       
  7645     params.filePath.Append( KMasterFileId );
       
  7646     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
  7647 
       
  7648     params.trId = aTrId;
       
  7649     params.apdu.Append( KClaNoSm );             // CLA
       
  7650     params.apdu.Append( KOddInstructionCode );  // INS
       
  7651     params.apdu.Append( KFirstBlockOfAuthenticationResponseData ); // P1
       
  7652     params.apdu.Append( 0x00 ); // P2
       
  7653     params.apdu.Append( 0x00 ); // Le 
       
  7654 
       
  7655     iMmUiccMessHandler->CreateUiccApplCmdReq( params ); 
       
  7656     }
       
  7657 
       
  7658 
       
  7659 // -----------------------------------------------------------------------------
       
  7660 // CMmCustomMessHandler::MapSw1Sw2ToAuthenticateResult
       
  7661 // Maps sw1 and sw2 from response authenticate apdu to result 
       
  7662 // -----------------------------------------------------------------------------
       
  7663 //
       
  7664 TUint8 CMmCustomMessHandler::MapSw1Sw2ToAuthenticateResult( TUint8 sw1, TUint8 sw2 )
       
  7665     {
       
  7666 TFLOGSTRING3("TSY: CMmCustomMessHandler::MapSw1Sw2ToAuthenticateResult. sw1: 0x%x sw2: 0x%x\n", sw1, sw2 );
       
  7667 OstTraceExt2( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_MAPSW1SW2TOAUTHENTICATERESULT, "CMmCustomMessHandler::MapSw1Sw2ToAuthenticateResult. sw1: 0x%x sw2: 0x%x", sw1, sw2 );
       
  7668 
       
  7669     TUint8 ret( KUnknownCommandEnding );
       
  7670 
       
  7671     switch( sw1 )
       
  7672         {
       
  7673         case 0x90:
       
  7674             {
       
  7675             if( 0x00 == sw2 )
       
  7676                 {
       
  7677                 ret = KNormalCommandEnding;
       
  7678                 }
       
  7679             break;
       
  7680             }
       
  7681         case 0x62:
       
  7682             {
       
  7683             if( 0x00 == sw2 )
       
  7684                 {
       
  7685                 ret = KNormalCommandEnding;
       
  7686                 }
       
  7687             else if( 0xF1 == sw2 || 
       
  7688                      0xF2 == sw2 )
       
  7689                 {
       
  7690                 ret = KWarningMoreDataAvailable;
       
  7691                 }
       
  7692             else if( 0xF3 == sw2 )
       
  7693                 {
       
  7694                 ret = KWarningAuthRespAvailable;
       
  7695                 }
       
  7696             break;
       
  7697             }
       
  7698         case 0x91:
       
  7699             {
       
  7700             ret = KNormalCommandEnding;
       
  7701             break;
       
  7702             }
       
  7703         case 0x98:
       
  7704             {
       
  7705             if( 0x62 == sw2 )
       
  7706                 {
       
  7707                 ret = KAppAuthErrorIncorrectMac;
       
  7708                 }
       
  7709             else if( 0x65 == sw2 )
       
  7710                 {
       
  7711                 ret = KAppErrorAuthMbmsKeyFresh;
       
  7712                 }
       
  7713             else if( 0x66 == sw2 )
       
  7714                 {
       
  7715                 ret = KAppErrorAuthMbmsOutOfMemMsk;
       
  7716                 }
       
  7717             else if( 0x67 == sw2 )
       
  7718                 {
       
  7719                 ret = KAppErrorAuthMbmsOutOfMemMuk;
       
  7720                 }
       
  7721             break;
       
  7722             }
       
  7723         case 0x69:
       
  7724             {
       
  7725             if( 0x82 == sw2 )
       
  7726                 {
       
  7727                 ret = KCmdNotAllowedSecurityStatusNotSatisfied;
       
  7728                 }
       
  7729             else if( 0x85 == sw2 )
       
  7730                 {
       
  7731                 ret = KCmdNotAllowedConditionsNotSatisfied;
       
  7732                 }
       
  7733             break;
       
  7734             }
       
  7735         case 0x6A:
       
  7736             {
       
  7737             if( 0x88 == sw2 )
       
  7738                 {
       
  7739                 ret = KWrongParametersDataNotFound;
       
  7740                 }
       
  7741             break;
       
  7742             }
       
  7743         default:
       
  7744             {
       
  7745             break;
       
  7746             }
       
  7747         }
       
  7748 
       
  7749     return ret;
       
  7750     }
       
  7751 
       
  7752 
       
  7753 // -----------------------------------------------------------------------------
       
  7754 // CMmCustomMessHandler::ValidateReceivedAuthenticateApdu
       
  7755 // Validates received apdu
       
  7756 // -----------------------------------------------------------------------------
       
  7757 //
       
  7758 TUint8 CMmCustomMessHandler::ValidateReceivedAuthenticateApdu( 
       
  7759     TInt aTraId, 
       
  7760     const TDesC8& aApdu )
       
  7761     {
       
  7762     TUint8 ret( KApduOk );
       
  7763 
       
  7764     switch( aTraId )
       
  7765         {
       
  7766         case ETrIdEEapSimAuthenticate:
       
  7767             {
       
  7768             ret = ValidateGsmSecurityContextApduResp( aApdu );
       
  7769             break;
       
  7770             }
       
  7771         case ETrIdEEapAkaAuthenticate:
       
  7772         case ETrIdEEapAkaAuthenticateIms:
       
  7773             {
       
  7774             ret = Validate3GSecurityContextApduResp( aApdu );
       
  7775             break;
       
  7776             }
       
  7777         case ETrIdEGbaBootstrap:
       
  7778             {
       
  7779             ret = ValidateGBABootstrappingApduResp( aApdu );
       
  7780             break;
       
  7781             }
       
  7782        case ETrIdEGbaNafDerivation:
       
  7783             {
       
  7784             ret = ValidateGBANafDerivationApduResp( aApdu );
       
  7785             break;
       
  7786             }
       
  7787         case ETrIdRunGsmAlgorithmSim:
       
  7788         case ETrIdRunGsmAlgorithmAka:
       
  7789         case ETrIdRunGsmAlgorithmIms:
       
  7790             {
       
  7791             ret = ValidateRunGsmAlgorithmApduResp( aApdu );
       
  7792             break;
       
  7793             }
       
  7794         default:
       
  7795             {
       
  7796 TFLOGSTRING("TSY: CMmCustomMessHandler::ValidateReceivedAuthenticateApdu: unknown APDU\n" );
       
  7797 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATERECEIVEDAUTHENTICATEAPDU, "CMmCustomMessHandler::ValidateReceivedAuthenticateApdu: unknown APDU" );
       
  7798             ret = KApduNok;
       
  7799             break;
       
  7800             }
       
  7801         }
       
  7802     return ret;
       
  7803     }
       
  7804 
       
  7805 // -----------------------------------------------------------------------------
       
  7806 // CMmCustomMessHandler::ValidateGsmSecurityContextApduResp
       
  7807 // Validates received apdu
       
  7808 // -----------------------------------------------------------------------------
       
  7809 //
       
  7810 TUint8 CMmCustomMessHandler::ValidateGsmSecurityContextApduResp( const TDesC8& aApdu )
       
  7811     {
       
  7812 TFLOGSTRING("TSY: CMmCustomMessHandler::ValidateGsmSecurityContextApduResp.\n" );
       
  7813 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATEGSMSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::ValidateGsmSecurityContextApduResp" );
       
  7814     TUint8 ret( KApduNok );
       
  7815 
       
  7816     // apdu len is len of aApdu - 2 (because of 
       
  7817     // aApdu contains sw1 and sw2)
       
  7818     TUint apduLen( aApdu.Length() - 2 );
       
  7819     TUint32 index( 0 );
       
  7820 
       
  7821     index += aApdu[index] + 1;
       
  7822     TUint8 lenOfKc = aApdu[index++];
       
  7823 
       
  7824     if( KLenOfKc == lenOfKc && index + lenOfKc == apduLen )
       
  7825         {
       
  7826         ret = KApduOk;
       
  7827         }
       
  7828 
       
  7829     return ret;
       
  7830     }
       
  7831 
       
  7832 // -----------------------------------------------------------------------------
       
  7833 // CMmCustomMessHandler::Validate3GSecurityContextApduResp
       
  7834 // Validates received apdu
       
  7835 // -----------------------------------------------------------------------------
       
  7836 //
       
  7837 TUint8 CMmCustomMessHandler::Validate3GSecurityContextApduResp( const TDesC8& aApdu )
       
  7838     {
       
  7839 TFLOGSTRING("TSY: CMmCustomMessHandler::Validate3GSecurityContextApduResp.\n" );
       
  7840 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATE3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Validate3GSecurityContextApduResp" );
       
  7841 
       
  7842     TUint8 ret( KApduOk );
       
  7843 
       
  7844     // Let's calculate total APDU data len in aApdu. Length is 
       
  7845     // decremented by 2 because of aApdu contains also sw1 and sw2
       
  7846     // and these are total 2 bytes long.
       
  7847     TUint8 apduLen( aApdu.Length() - 2 );
       
  7848     TUint32 index( 0 );
       
  7849     TUint8 tag( aApdu[index++] );
       
  7850 
       
  7851     if( KSuccessfull3GAuthTag == tag  )
       
  7852         {
       
  7853         // check the len of RES
       
  7854         if( KMinLenOfRes > aApdu[index] || KMaxLenOfRes < aApdu[index] )
       
  7855             {
       
  7856 TFLOGSTRING("TSY: CMmCustomMessHandler::Validate3GSecurityContextApduResp: invalid RES\n" );
       
  7857 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_VALIDATE3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Validate3GSecurityContextApduResp: invalid RES" );
       
  7858             ret = KApduNok;
       
  7859             }
       
  7860         else
       
  7861             {
       
  7862             // move pointer to field length of CK
       
  7863             index += aApdu[index] + 1;
       
  7864             }
       
  7865 
       
  7866         // check the len of CK
       
  7867         if( KApduNok == ret ||
       
  7868             KLenOfCk != aApdu[index] )
       
  7869             {
       
  7870             if( KApduNok != ret )
       
  7871                 {
       
  7872 TFLOGSTRING("TSY: CMmCustomMessHandler::Validate3GSecurityContextApduResp: invalid CK\n" );
       
  7873 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_VALIDATE3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Validate3GSecurityContextApduResp: invalid CK" );
       
  7874                 ret = KApduNok;
       
  7875                 }
       
  7876             }
       
  7877         else
       
  7878             {
       
  7879             // move pointer to field length of IK
       
  7880             index += aApdu[index] + 1;
       
  7881             }
       
  7882 
       
  7883         // check the len of IK
       
  7884         if( KApduNok == ret ||
       
  7885             KLenOfIk != aApdu[index] )
       
  7886             {
       
  7887             if( KApduNok != ret )
       
  7888                 {
       
  7889 TFLOGSTRING("TSY: CMmCustomMessHandler::Validate3GSecurityContextApduResp: invalid IK\n" );
       
  7890 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_VALIDATE3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Validate3GSecurityContextApduResp: invalid IK" );
       
  7891                 ret = KApduNok;
       
  7892                 }
       
  7893             }
       
  7894         else
       
  7895             {
       
  7896             // move pointer to end of IK
       
  7897             index += aApdu[index];
       
  7898             }
       
  7899 
       
  7900         // check the len of Kc if present.
       
  7901         // This parameter is only present
       
  7902         // when service nro 27 is available
       
  7903         if( KApduOk == ret && index < apduLen - 1 )
       
  7904             {
       
  7905             // move pointer to field length of Kc
       
  7906             index++;
       
  7907 
       
  7908             // check the len of Kc
       
  7909             if( KLenOfKc != aApdu[index] )
       
  7910                 {
       
  7911 TFLOGSTRING("TSY: CMmCustomMessHandler::Validate3GSecurityContextApduResp: invalid Kc\n" );
       
  7912 OstTrace0( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_VALIDATE3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Validate3GSecurityContextApduResp: invalid Kc" );
       
  7913                 ret = KApduNok;
       
  7914                 }
       
  7915             else
       
  7916                 {
       
  7917                 // move pointer to end of Kc
       
  7918                 index += aApdu[index];
       
  7919                 }
       
  7920             }
       
  7921 
       
  7922         // let's check that pointer doesn't go over
       
  7923         // aApdu's limits.
       
  7924         if( KApduOk == ret && index > apduLen - 1 )
       
  7925             {
       
  7926 TFLOGSTRING("TSY: CMmCustomMessHandler::Validate3GSecurityContextApduResp: error, APDU buffer overflow\n" );
       
  7927 OstTrace0( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_VALIDATE3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Validate3GSecurityContextApduResp: error, APDU buffer overflow" );
       
  7928             ret = KApduNok;
       
  7929             }
       
  7930         }
       
  7931 
       
  7932     else if(KSyncFailureTag == tag)
       
  7933         {
       
  7934         // check the len of AUTS
       
  7935         if( KLenOfAuts != aApdu[index])
       
  7936             {
       
  7937 TFLOGSTRING("TSY: CMmCustomMessHandler::Validate3GSecurityContextApduResp: invalid AUTS\n" );
       
  7938 OstTrace0( TRACE_NORMAL, DUP6_CMMCUSTOMMESSHANDLER_VALIDATE3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Validate3GSecurityContextApduResp: invalid AUTS" );
       
  7939             ret = KApduNok;
       
  7940             }
       
  7941         else
       
  7942             {
       
  7943             // move pointer to end of AUTS
       
  7944             index += aApdu[index];
       
  7945             }
       
  7946 
       
  7947         // let's check that pointer doesn't go over
       
  7948         // aApdu's limits.
       
  7949         if( KApduOk == ret && index > apduLen - 1 )
       
  7950             {
       
  7951 TFLOGSTRING("TSY: CMmCustomMessHandler::Validate3GSecurityContextApduResp: error, APDU buffer overflow\n" );
       
  7952 OstTrace0( TRACE_NORMAL, DUP7_CMMCUSTOMMESSHANDLER_VALIDATE3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Validate3GSecurityContextApduResp: error, APDU buffer overflow" );
       
  7953             ret = KApduNok;
       
  7954             }
       
  7955         }
       
  7956     else
       
  7957         {
       
  7958 TFLOGSTRING("TSY: CMmCustomMessHandler::Validate3GSecurityContextApduResp: error, unknown tag\n" );
       
  7959 OstTrace0( TRACE_NORMAL, DUP8_CMMCUSTOMMESSHANDLER_VALIDATE3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Validate3GSecurityContextApduResp: error, unknown tag" );
       
  7960         ret = KApduNok;
       
  7961         }
       
  7962 
       
  7963     return ret;
       
  7964     }
       
  7965 
       
  7966 // -----------------------------------------------------------------------------
       
  7967 // CMmCustomMessHandler::ValidateGBABootstrappingApduResp
       
  7968 // Validates received apdu
       
  7969 // -----------------------------------------------------------------------------
       
  7970 //
       
  7971 TUint8 CMmCustomMessHandler::ValidateGBABootstrappingApduResp( const TDesC8& aApdu )
       
  7972     {
       
  7973 TFLOGSTRING("TSY: CMmCustomMessHandler::ValidateGBABootstrappingApduResp.\n" );
       
  7974 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATEGBABOOTSTRAPPINGAPDURESP, "CMmCustomMessHandler::ValidateGBABootstrappingApduResp" );
       
  7975 
       
  7976     TUint8 ret( KApduNok );
       
  7977 
       
  7978     // Let's calculate total APDU data len in aApdu. Length is 
       
  7979     // decremented by 2 because of aApdu contains also sw1 and sw2
       
  7980     // and these are total 2 bytes long.
       
  7981     TUint8 apduLen( aApdu.Length() - 2 );
       
  7982     TUint32 index( 0 );
       
  7983     TUint8 tag( aApdu[index++] );
       
  7984 
       
  7985     if( apduLen > 1 )
       
  7986         {
       
  7987         if( KSuccessfull3GAuthTag == tag ||
       
  7988             KSyncFailureTag == tag  )
       
  7989             {
       
  7990             if( apduLen >= aApdu[index] )
       
  7991                 {
       
  7992                 ret = KApduOk;
       
  7993                 }
       
  7994             }
       
  7995         }
       
  7996     return ret;
       
  7997     }
       
  7998 
       
  7999 
       
  8000 // -----------------------------------------------------------------------------
       
  8001 // CMmCustomMessHandler::ValidateGBANafDerivationApduResp
       
  8002 // Validates received apdu
       
  8003 // -----------------------------------------------------------------------------
       
  8004 //
       
  8005 TUint8 CMmCustomMessHandler::ValidateGBANafDerivationApduResp( const TDesC8& aApdu )
       
  8006     {
       
  8007 TFLOGSTRING("TSY: CMmCustomMessHandler::ValidateGBANafDerivationApduResp.\n" );
       
  8008 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATEGBANAFDERIVATIONAPDURESP, "CMmCustomMessHandler::ValidateGBANafDerivationApduResp" );
       
  8009 
       
  8010     TUint8 ret = KApduNok;
       
  8011 
       
  8012     // Let's calculate total APDU data len in aApdu. Length is 
       
  8013     // decremented by 2 because of aApdu contains also sw1 and sw2
       
  8014     // and these are total 2 bytes long.
       
  8015     TUint8 apduLen( aApdu.Length() - 2 );
       
  8016     TUint32 index( 0 );
       
  8017     TUint8 tag( aApdu[index++] );
       
  8018 
       
  8019     if( apduLen > 1 )
       
  8020         {
       
  8021         if( KSuccessfull3GAuthTag == tag )
       
  8022             {
       
  8023             // response apdu contains only parameter Ks Ext NAF 
       
  8024             // so, let's check that apdu len contains parameter
       
  8025             // correctly. So apduLen should be len of Ks Ext NAF
       
  8026             // + 2 ("Successful GBA operation" field + 
       
  8027             // Length of Ks_ext_NAF field)
       
  8028             if( apduLen == aApdu[index] + 2 )
       
  8029                 {
       
  8030                 ret = KApduOk;
       
  8031                 }
       
  8032             }
       
  8033         }
       
  8034     return ret;
       
  8035     }
       
  8036 
       
  8037 // -----------------------------------------------------------------------------
       
  8038 // CMmCustomMessHandler::ValidateRunGsmAlgorithmApduResp
       
  8039 // Validates received apdu
       
  8040 // -----------------------------------------------------------------------------
       
  8041 //
       
  8042 TUint8 CMmCustomMessHandler::ValidateRunGsmAlgorithmApduResp( const TDesC8& aApdu )
       
  8043     {
       
  8044 TFLOGSTRING("TSY: CMmCustomMessHandler::ValidateRunGsmAlgorithmApduResp.\n" );
       
  8045 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATERUNGSMALGORITHMAPDURESP, "CMmCustomMessHandler::ValidateRunGsmAlgorithmApduResp" );
       
  8046 
       
  8047     TUint8 ret( KApduNok );
       
  8048 
       
  8049     if( aApdu.Length() == KRunGsmAlgorithmRespLen + 2 )
       
  8050         {
       
  8051         ret = KApduOk;
       
  8052         }
       
  8053     return ret;
       
  8054     }
       
  8055 
       
  8056 
       
  8057 // -----------------------------------------------------------------------------
       
  8058 // CMmCustomMessHandler::FindTlvObject
       
  8059 // Finds TLV object
       
  8060 // -----------------------------------------------------------------------------
       
  8061 //  
       
  8062 TBool CMmCustomMessHandler::FindTlvObject(
       
  8063     TUint8 aTlvTag,
       
  8064     const TDesC8& aBerTlv,
       
  8065     TDes8& aTlvObject )
       
  8066     {
       
  8067 TFLOGSTRING2("TSY: CMmCustomMessHandler::FindTlvObject (tag: 0x%x)\n", aTlvTag );
       
  8068 OstTrace1( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_FINDTLVOBJECT, "CMmCustomMessHandler::FindTlvObject (tag: 0x%x)", aTlvTag );
       
  8069 
       
  8070     TBool ret( EFalse );
       
  8071     TUint32 index( 0 );
       
  8072     TUint8 tag( 0 );
       
  8073     TUint32 tlvLength( 0 );
       
  8074 
       
  8075     while( index + 2 < aBerTlv.Length() )
       
  8076         {
       
  8077         tag = aBerTlv[index++];
       
  8078         tlvLength = aBerTlv[index++];
       
  8079 
       
  8080         // let's check if len of tlv object is coded
       
  8081         // with one or two bytes        
       
  8082         if( 0x81 == tlvLength ||
       
  8083             0x82 == tlvLength )
       
  8084             {
       
  8085             TUint8 byteCount( tlvLength & 0x7F );
       
  8086             TUint8 ind( 0 );
       
  8087             tlvLength = 0;
       
  8088             do
       
  8089                 {
       
  8090                 tlvLength = tlvLength << 8;
       
  8091                 tlvLength = tlvLength + aBerTlv[index++];
       
  8092                 ind++;
       
  8093                 }
       
  8094             while ( ind < byteCount );
       
  8095             }
       
  8096 
       
  8097         if( tag == aTlvTag )
       
  8098             {
       
  8099             if( index + tlvLength <= aBerTlv.Length() )
       
  8100                 {
       
  8101                 if( tlvLength <= aTlvObject.MaxSize() )
       
  8102                     {
       
  8103                     // tlv object found
       
  8104 TFLOGSTRING2("TSY: CMmCustomMessHandler::FindTlvObject: tag: 0x%x found\n", aTlvTag );
       
  8105 OstTrace1( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_FINDTLVOBJECT, "CMmCustomMessHandler::FindTlvObject: tag: 0x%x found", aTlvTag );
       
  8106                     aTlvObject.Copy( aBerTlv.Mid( index , tlvLength ) );
       
  8107                     ret = ETrue;
       
  8108                     }
       
  8109                 else
       
  8110                     {
       
  8111 TFLOGSTRING3("TSY: CMmCustomMessHandler::FindTlvObject: length of aTlvObject is not enough, needed: %d max size: %d \n", tlvLength, aTlvObject.MaxSize() );
       
  8112 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_FINDTLVOBJECT, "CMmCustomMessHandler::FindTlvObject: length of aTlvObject is not enough" );
       
  8113 OstTrace1( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_FINDTLVOBJECT, "CMmCustomMessHandler::FindTlvObject: needed: %d", tlvLength );
       
  8114 OstTrace1( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_FINDTLVOBJECT, "CMmCustomMessHandler::FindTlvObject: max size: %d", aTlvObject.MaxSize() );
       
  8115                     }
       
  8116                 }
       
  8117             else
       
  8118                 {
       
  8119 TFLOGSTRING("TSY: CMmCustomMessHandler::FindTlvObject: buffer overflow \n" );
       
  8120 OstTrace0( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_FINDTLVOBJECT, "CMmCustomMessHandler::FindTlvObject: buffer overflow" );
       
  8121                 }
       
  8122             break;
       
  8123             }
       
  8124         else
       
  8125             {
       
  8126             index += tlvLength;
       
  8127             }
       
  8128         }
       
  8129 
       
  8130     return ret;
       
  8131     }
       
  8132 
       
  8133 
       
  8134 // -----------------------------------------------------------------------------
       
  8135 // CMmCustomMessHandler::DeriveCkFromKc
       
  8136 // derives Ck from Kc
       
  8137 // -----------------------------------------------------------------------------
       
  8138 //  
       
  8139 void CMmCustomMessHandler::DeriveCkFromKc(
       
  8140     TDes8& aCk,
       
  8141     const TDesC8& aKc )
       
  8142     {
       
  8143 TFLOGSTRING("TSY: CMmCustomMessHandler::DeriveCkFromKc.\n" );
       
  8144 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_DERIVECKFROMKC, "CMmCustomMessHandler::DeriveCkFromKc" );
       
  8145 
       
  8146     /* This operation calculates the UMTS Ciphering Key (CK) from the GSM
       
  8147        Ciphering Key (Kc). This is done by using the c4 algorithm defined in
       
  8148        3GPP TS 33.102 v3.8.0 (Release 1999).
       
  8149 
       
  8150        c4: CK = Kc || Kc;
       
  8151        where || means concatination.
       
  8152 
       
  8153        The resulting CK is as follows:
       
  8154        -----------------------------------------------------------------
       
  8155        |kc1|kc2|kc3|kc4|kc5|kc6|kc7|kc8|kc1|kc2|kc3|kc4|kc5|kc6|kc7|kc8|
       
  8156        ----------------------------------------------------------------- */
       
  8157     aCk.Copy( aKc );
       
  8158     aCk.Append( aKc );
       
  8159     }
       
  8160 
       
  8161 
       
  8162 // -----------------------------------------------------------------------------
       
  8163 // CMmCustomMessHandler::DeriveIkFromKc
       
  8164 // derives Ck from Kc
       
  8165 // -----------------------------------------------------------------------------
       
  8166 //
       
  8167 void CMmCustomMessHandler::DeriveIkFromKc(
       
  8168     TDes8& aIk,
       
  8169     const TDesC8& aKc )
       
  8170     {
       
  8171 TFLOGSTRING("TSY: CMmCustomMessHandler::DeriveIkFromKc.\n" );
       
  8172 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_DERIVEIKFROMKC, "CMmCustomMessHandler::DeriveIkFromKc" );
       
  8173 
       
  8174     /* This operation derives the UMTS Integrity Key (IK) from the GSM
       
  8175        Ciphering Key (Kc). This is done by using the c5 algorithm defined in
       
  8176        3GPP TS 33.102 v3.8.0 (release 1999).
       
  8177 
       
  8178        c5: IK = Kc1 xor Kc2 || Kc || Kc1 xor Kc2;
       
  8179        where Kc1 and Kc2 are both 4 bytes long and || means concatination.
       
  8180 
       
  8181        |--------------> Kc 8 bytes <-----------|
       
  8182        -----------------------------------------
       
  8183        | B1 | B2 | B3 | B4 | B5 | B6 | B7 | B8 |
       
  8184        -----------------------------------------
       
  8185        |--> Kc1,4 bytes <--|--> Kc2,4 bytes <--|
       
  8186 
       
  8187        Kx = Kc1 xor Kc2
       
  8188 
       
  8189        The resulting IK is as follows:
       
  8190 
       
  8191        |-----------------------> IK, 16 bytes <------------------------|
       
  8192        -----------------------------------------------------------------
       
  8193        |Kx1|Kx2|Kx3|Kx4|Kc1|Kc2|Kc3|Kc4|Kc5|Kc6|Kc7|Kc8|Kx1|Kx2|Kx3|Kx4|
       
  8194        -----------------------------------------------------------------
       
  8195        |----> Kx <-----|------------> Kc <-------------|-----> Kx <----| */
       
  8196 
       
  8197     TBuf8<KLenOfKc> kc1;
       
  8198     TBuf8<KLenOfKc> kc2;
       
  8199     TBuf8<KLenOfKc> kx;
       
  8200 
       
  8201     kc1.Copy( aKc.Mid( 0, 4 ) );
       
  8202     kc2.Copy( aKc.Mid( 4, 4 ) );
       
  8203 
       
  8204     for ( TUint8 i = 0; i < 4; i++ )
       
  8205         {
       
  8206         kx.Append( kc1[i] ^ kc2[i] );
       
  8207         }
       
  8208 
       
  8209     aIk.Append( kx );
       
  8210     aIk.Append( aKc );
       
  8211     aIk.Append( kx );
       
  8212     }
       
  8213 
       
  8214 
       
  8215 // -----------------------------------------------------------------------------
       
  8216 // CMmCustomMessHandler::DeriveIkFromKc
       
  8217 // derives Ck from Kc
       
  8218 // -----------------------------------------------------------------------------
       
  8219 //
       
  8220 TInt CMmCustomMessHandler::UiccHandleImsAuthentication( 
       
  8221     const CMmDataPackage& aDataPackage )
       
  8222     {
       
  8223 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccHandleImsAuthentication.\n" );
       
  8224 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCHANDLEIMSAUTHENTICATION, "CMmCustomMessHandler::UiccHandleImsAuthentication" );
       
  8225     TInt ret( KErrNone );
       
  8226 
       
  8227     // IMS authentication:
       
  8228     // If card type is ICC, we just send the RUN GSM ALGORITHM to the ICC
       
  8229     // If card type is UICC, we check is ISIM application activated:
       
  8230     //     * If ISIM application is activated, we send 3G security context
       
  8231     //     to the ISIM application.
       
  8232     //     * If ISIM application is NOT activated, we try to activate it.
       
  8233     //         * If actication succeeded, we send 3G security context to the
       
  8234     //         ISIM application
       
  8235     //         * If activation fails, we send 3G security context to the USIM
       
  8236     //         application
       
  8237 
       
  8238     RMobilePhone::TImsAuthenticateDataV5 authenticationData;
       
  8239     aDataPackage.UnPackData( authenticationData );
       
  8240 
       
  8241     TUiccSendApdu params;
       
  8242     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  8243     params.serviceType = UICC_APPL_APDU_SEND;
       
  8244     params.fileId = UICC_EF_ID_NOT_PRESENT;
       
  8245     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  8246     params.filePath.Append( KMasterFileId >> 8 );
       
  8247     params.filePath.Append( KMasterFileId );
       
  8248     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
  8249 
       
  8250     TUint8 cardType( iMmUiccMessHandler->GetCardType() );
       
  8251 
       
  8252     if( UICC_CARD_TYPE_ICC == cardType )
       
  8253         {
       
  8254         // no need to activate ISIM application, 
       
  8255         // let's just send the authentication APDU
       
  8256         UiccCreateRunGsmAlgorithmApdu(
       
  8257             params,
       
  8258             authenticationData.iRAND,
       
  8259             ETrIdRunGsmAlgorithmIms );
       
  8260 
       
  8261         ret = iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  8262         }
       
  8263     else if( UICC_CARD_TYPE_UICC == cardType )
       
  8264         {
       
  8265         // let's store RAND and AUTN while we try to acticate
       
  8266         // ISIM application
       
  8267         RMobilePhone::TImsAuthenticateDataV5 authenticationData;
       
  8268         aDataPackage.UnPackData( authenticationData );
       
  8269 
       
  8270         if( iMmUiccMessHandler->IsIsimApplicationFound() )
       
  8271             {
       
  8272             // let's check is ISIM application already tried to activate
       
  8273             if( iIsimApplActivated )
       
  8274                 {
       
  8275                 UiccCreate3GSecurityContextApdu( 
       
  8276                     params, 
       
  8277                     authenticationData.iRAND, 
       
  8278                     authenticationData.iAUTN,
       
  8279                     ETrIdEEapAkaAuthenticateIms );
       
  8280 
       
  8281                 ret = iMmUiccMessHandler->CreateUiccApplCmdReq( params, UICC_APPL_TYPE_UICC_ISIM );
       
  8282                 }
       
  8283             else
       
  8284                 {
       
  8285                 iRandBuf.Zero();
       
  8286                 iAutnBuf.Zero();
       
  8287 
       
  8288                 iRandBuf.Append( authenticationData.iRAND );
       
  8289                 iAutnBuf.Append( authenticationData.iAUTN );
       
  8290 
       
  8291                 TUiccParamsBase activationParams;
       
  8292                 activationParams.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  8293                 activationParams.trId = ETrIdActivateIsimApplication;
       
  8294 
       
  8295                 ret = iMmUiccMessHandler->CreateUiccApplicationReq(
       
  8296                           activationParams,
       
  8297                           UICC_APPL_HOST_ACTIVATE,
       
  8298                           UICC_APPL_TYPE_UICC_ISIM );
       
  8299                 }
       
  8300             }
       
  8301         else
       
  8302             {
       
  8303             // no ISim application, let's send authenticate apdu to the Uicc application
       
  8304             UiccCreate3GSecurityContextApdu(
       
  8305                     params,
       
  8306                     authenticationData.iRAND,
       
  8307                     authenticationData.iAUTN,
       
  8308                     ETrIdEEapAkaAuthenticateIms );
       
  8309 
       
  8310             ret = iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  8311             }
       
  8312         }
       
  8313     else
       
  8314         {
       
  8315         ret = KErrGeneral;
       
  8316         }
       
  8317     return ret;
       
  8318     }
       
  8319 
       
  8320 
       
  8321 // -----------------------------------------------------------------------------
       
  8322 // CMmCustomMessHandler::UiccHandleIsimActivationResp
       
  8323 // handles repsonse for ISim application activation
       
  8324 // -----------------------------------------------------------------------------
       
  8325 //
       
  8326 void CMmCustomMessHandler::UiccHandleIsimActivationResp( TInt aStatus )
       
  8327     {
       
  8328 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccHandleIsimActivationResp.\n" );
       
  8329 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCHANDLEISIMACTIVATIONRESP, "CMmCustomMessHandler::UiccHandleIsimActivationResp" );
       
  8330 
       
  8331     TUiccSendApdu params;
       
  8332     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  8333     params.serviceType = UICC_APPL_APDU_SEND;
       
  8334     params.fileId = UICC_EF_ID_NOT_PRESENT;
       
  8335     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
  8336     params.filePath.Append( KMasterFileId >> 8 );
       
  8337     params.filePath.Append( KMasterFileId );
       
  8338     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
  8339 
       
  8340     UiccCreate3GSecurityContextApdu( 
       
  8341         params, 
       
  8342         iRandBuf, 
       
  8343         iAutnBuf,
       
  8344         ETrIdEEapAkaAuthenticateIms );
       
  8345 
       
  8346     if( UICC_STATUS_OK == aStatus )
       
  8347         {
       
  8348         iIsimApplActivated = ETrue;
       
  8349 
       
  8350         // ISim application activated successfully, let's send authentication apdu
       
  8351         // to the ISim application
       
  8352         iMmUiccMessHandler->CreateUiccApplCmdReq( params, UICC_APPL_TYPE_UICC_ISIM );
       
  8353         }
       
  8354     else
       
  8355         {
       
  8356         // ISim application activation fails, le'ts send authentication apdu 
       
  8357         // to the USim application
       
  8358         iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  8359         }
       
  8360     }
       
  8361 
       
  8362 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
  8363     //None
       
  8364 
       
  8365 // End of File