adaptationlayer/tsy/nokiatsy_dll/src/cmmphonemesshandler.cpp
changeset 0 63b37f68c1ce
child 5 8ccc39f9d787
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cmmmessagerouter.h"
       
    22 #include "cmmphonemesshandler.h"
       
    23 #include "cmmphonetsender.h"
       
    24 #include "cmmsmsmesshandler.h"
       
    25 #include "cmmstaticutility.h"
       
    26 #include "cmmsupplservmesshandler.h"
       
    27 #include "cmmnetmesshandler.h"
       
    28 #include "cmmnetoperatornamehandler.h"
       
    29 #include "tsylogger.h"
       
    30 #include "cmmuiccmesshandler.h"
       
    31 
       
    32 #include <call_modemisi.h>
       
    33 #include <ctsy/pluginapi/cmmdatapackage.h>
       
    34 #include <csdisi.h>
       
    35 #include <gpdsisi.h>
       
    36 #include <ctsy/serviceapi/gsmerror.h>
       
    37 #include <gssisi.h>
       
    38 #include <infoisi.h>
       
    39 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
       
    40 #include <ctsy/serviceapi/mmtsy_defaults.h>
       
    41 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
    42 #include <mtcisi.h>
       
    43 #else /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
    44 #include <mceisi.h>
       
    45 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
    46 #include <net_modemisi.h>
       
    47 #include <smsisi.h>
       
    48 #include <ss_wmisi.h>
       
    49 #include <tisi.h>
       
    50 #include <uiccisi.h>
       
    51 
       
    52 #include "osttracedefinitions.h"
       
    53 #ifdef OST_TRACE_COMPILER_IN_USE
       
    54 #include "cmmphonemesshandlertraces.h"
       
    55 #endif
       
    56 
       
    57 // EXTERNAL DATA STRUCTURES
       
    58     //None
       
    59 
       
    60 // EXTERNAL FUNCTION PROTOTYPES
       
    61     //None
       
    62 
       
    63 // MACROS
       
    64     //None
       
    65 
       
    66 // LOCAL CONSTANTS AND MACROS
       
    67 
       
    68 const TUint8 KPhoneTransId = 6; //hard coded transaction ID
       
    69 const TUint8 KImsiSize = 8;
       
    70 const TUint8 KServiceProviderSize = 36;
       
    71 const TUint8 KSpnFileSize = 16;
       
    72 
       
    73 // ------------------------------------------------------
       
    74 // --- Alternate Line Service (ALS)-related constants ---
       
    75 // ------------------------------------------------------
       
    76 // Consts for mapping the Als Line values, as used in SIMSON's
       
    77 // SIM_SERV_DYNAMIC_FLAGS_STR structure.
       
    78 const TUint8 KAlsAuxiliaryLine = 0x00; // ALS alternate line
       
    79 const TUint8 KAlsPrimaryLine = 0x01;   // ALS primary line
       
    80 
       
    81 // ----------------------------------------------
       
    82 // --- (U)ICC Service Table-related constants ---
       
    83 // ----------------------------------------------
       
    84 
       
    85 const TUint8  KUiccCspCallOfferingCode          ( 0x01 );
       
    86 const TUint8  KUiccCspCallRestrictionCode       ( 0x02 );
       
    87 const TUint8  KUiccCspOtherSupplServCode        ( 0x03 );
       
    88 const TUint8  KUiccCspCallCompletionCode        ( 0x04 );
       
    89 const TUint8  KUiccCspTeleServicesCode          ( 0x05 );
       
    90 const TUint8  KUiccCspCphsTeleServicesCode      ( 0x06 );
       
    91 const TUint8  KUiccCspCphsFeaturesCode          ( 0x07 );
       
    92 const TUint8  KUiccCspNumberIdentifCode         ( 0x08 );
       
    93 const TUint8  KUiccCspValueAddedServicesCode    ( 0xC0 );
       
    94 
       
    95 // MODULE DATA STRUCTURES
       
    96     //None
       
    97 
       
    98 // LOCAL FUNCTION PROTOTYPES
       
    99     //None
       
   100 
       
   101 // ==================== LOCAL FUNCTIONS =====================================
       
   102     //None
       
   103 
       
   104 // ================= MEMBER FUNCTIONS =======================================
       
   105 
       
   106 // --------------------------------------------------------------------------
       
   107 // CMmPhoneMessHandler::CMmPhoneMessHandler
       
   108 // C++ constructor.
       
   109 // --------------------------------------------------------------------------
       
   110 //
       
   111 CMmPhoneMessHandler::CMmPhoneMessHandler()
       
   112     {
       
   113 TFLOGSTRING("TSY: CMmPhoneMessHandler constructed.");
       
   114 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_CMMPHONEMESSHANDLER, "CMmPhoneMessHandler::CMmPhoneMessHandler" );
       
   115 
       
   116     iACLIsProgress = EFalse;
       
   117     iAPNList = NULL;
       
   118     iAPNReadOrDeleteIndex = 0;
       
   119     }
       
   120 
       
   121 // --------------------------------------------------------------------------
       
   122 // CMmPhoneMessHandler::NewL
       
   123 // Creates a new PhoneMessageHandler object instance.
       
   124 // --------------------------------------------------------------------------
       
   125 //
       
   126 CMmPhoneMessHandler* CMmPhoneMessHandler::NewL
       
   127         (
       
   128         CMmPhoNetSender* aPhoNetSender,  //a ptr to the phonet sender
       
   129         CMmPhoNetReceiver* aPhoNetReceiver,  //a ptr to the phonet receiver
       
   130         CMmMessageRouter* aMessageRouter, // pointer to the msg router
       
   131         CMmSupplServMessHandler* aSupplServMessHandler,
       
   132         CMmUiccMessHandler* aUiccMessHandler
       
   133         )
       
   134     {
       
   135 TFLOGSTRING("TSY: CMmPhoneMessHandler::NewL");
       
   136 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_NEWL, "CMmPhoneMessHandler::NewL" );
       
   137 
       
   138     CMmPhoneMessHandler* phoneMessHandler =
       
   139         new ( ELeave ) CMmPhoneMessHandler();
       
   140 
       
   141     CleanupStack::PushL( phoneMessHandler );
       
   142     phoneMessHandler->iPhoNetSender = aPhoNetSender;
       
   143     phoneMessHandler->ConstructL( aMessageRouter );
       
   144     phoneMessHandler->iSupplServMessHandler = aSupplServMessHandler;
       
   145     phoneMessHandler->iMmUiccMessHandler = aUiccMessHandler;
       
   146 
       
   147     aPhoNetReceiver->RegisterL(
       
   148         phoneMessHandler,
       
   149 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   150         PN_INFO,
       
   151 #else /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   152         PN_MODEM_INFO,
       
   153 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   154         INFO_SERIAL_NUMBER_READ_RESP );
       
   155 
       
   156     CleanupStack::Pop( phoneMessHandler );
       
   157 
       
   158     return phoneMessHandler;
       
   159     }
       
   160 
       
   161 // --------------------------------------------------------------------------
       
   162 // CMmPhoneMessHandler::ConstructL
       
   163 // Initialises object attributes.
       
   164 // --------------------------------------------------------------------------
       
   165 //
       
   166 void CMmPhoneMessHandler::ConstructL
       
   167         (
       
   168         CMmMessageRouter* aMessageRouter
       
   169         )
       
   170     {
       
   171 TFLOGSTRING("TSY: CMmPhoneMessHandler::ConstructL");
       
   172 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_CONSTRUCTL, "CMmPhoneMessHandler::ConstructL" );
       
   173 
       
   174     // Internal pointers, must be nulled before used.
       
   175     iSSTFileData = NULL;
       
   176     iStoreInfo = NULL;
       
   177     iLocIndex = 0;
       
   178 
       
   179     iMessageRouter = aMessageRouter;
       
   180 
       
   181     iCommonTSYRefreshPending = EFalse;
       
   182     iRefreshError = EFalse;
       
   183 
       
   184     iInternalRefreshFiles = 0;
       
   185 
       
   186     SubscribeEventsFromPhoNet();
       
   187 
       
   188     }
       
   189 
       
   190 // --------------------------------------------------------------------------
       
   191 // CMmPhoneMessHandler::~CMmPhoneMessHandler
       
   192 // C++ destructor.
       
   193 // --------------------------------------------------------------------------
       
   194 //
       
   195 CMmPhoneMessHandler::~CMmPhoneMessHandler()
       
   196     {
       
   197 TFLOGSTRING("TSY: CMmPhoneMessHandler destructed.");
       
   198 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEMESSHANDLER_CMMPHONEMESSHANDLER, "CMmPhoneMessHandler::~CMmPhoneMessHandler" );
       
   199 
       
   200     // Delete iStoreInfo and set it to NULL, if it exist.
       
   201     if( iStoreInfo )
       
   202         {
       
   203         delete iStoreInfo;
       
   204         }
       
   205 
       
   206     // Delete iSSTFileData and set it to NULL, if it exist.
       
   207     if( iSSTFileData )
       
   208         {
       
   209         // Delete object
       
   210         delete iSSTFileData;
       
   211         }
       
   212 
       
   213     if( iAPNList )
       
   214         {
       
   215         iAPNList->Reset();
       
   216         delete iAPNList;
       
   217         }
       
   218     }
       
   219 
       
   220 // --------------------------------------------------------------------------
       
   221 // CMmPhoneMessHandler::SubcribeEventsFromPhonet
       
   222 // Subscribes indications from PhoNet. The wanted indications
       
   223 // are first added to an array and the array is then passed to the PhoNet.
       
   224 // --------------------------------------------------------------------------
       
   225 //
       
   226 TInt CMmPhoneMessHandler::SubscribeEventsFromPhoNet()
       
   227     {
       
   228 TFLOGSTRING("TSY: CMmPhoneMessHandler::SubscribeEventsFromPhoNet");
       
   229 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_SUBSCRIBEEVENTSFROMPHONET, "CMmPhoneMessHandler::SubscribeEventsFromPhoNet" );
       
   230 
       
   231     // Cross check requests with PhonetReceiver
       
   232     TUint8 requestArray[] = {
       
   233 
       
   234         // CALL SERVER INDICATIONS
       
   235             // PhonetReceiver - PhoneDispatchList
       
   236             PN_MODEM_CALL, CALL_MODEM_DTMF_STATUS_IND,
       
   237             PN_MODEM_CALL, CALL_MODEM_DTMF_TONE_IND,
       
   238 
       
   239             // PhonetReceiver - LineDispatchList
       
   240             PN_MODEM_CALL, CALL_MODEM_COMING_IND,
       
   241 
       
   242             // PhonetReceiver - CallDispatchList
       
   243             PN_MODEM_CALL, CALL_MODEM_CONTROL_IND,
       
   244             PN_MODEM_CALL, CALL_MODEM_MO_ALERT_IND,
       
   245             PN_MODEM_CALL, CALL_MODEM_RELEASE_IND,
       
   246             PN_MODEM_CALL, CALL_MODEM_STATUS_IND, // used also in SimAtkTSY
       
   247             PN_MODEM_CALL, CALL_MODEM_TERMINATED_IND,
       
   248             PN_MODEM_CALL, CALL_MODEM_NOTIFICATION_IND,
       
   249             PN_MODEM_CALL, CALL_MODEM_SERVICE_DENIED_IND,
       
   250             PN_MODEM_CALL, CALL_MODEM_MESSAGE_IND, // Used also in simatktsy
       
   251             PN_MODEM_CALL, CALL_MODEM_PRESENT_IND, // Used also in simatktsy
       
   252             PN_MODEM_CALL, CALL_MODEM_RESOURCE_IND, // Used also in simatktsy
       
   253             PN_MODEM_CALL, CALL_MODEM_RESOURCE_CONF_IND, // Used only in simatktsy
       
   254 
       
   255             //CSD SERVER INDICATIONS
       
   256             PN_CSD, CSD_VIDEO_CALL_STATUS_IND,
       
   257             PN_CSD, CSD_MULTIMEDIA_DATA_RATE_IND,
       
   258 
       
   259         // NET SERVER INDICATIONS
       
   260             PN_MODEM_NETWORK, NET_MODEM_REG_STATUS_IND,
       
   261             PN_MODEM_NETWORK, NET_NITZ_NAME_IND,
       
   262             PN_MODEM_NETWORK, NET_CELL_INFO_IND, // used only in SimAtkTSY
       
   263             PN_MODEM_NETWORK, NET_RSSI_IND,
       
   264             PN_MODEM_NETWORK, NET_RAT_IND, // used also in SimAtkTSY
       
   265             PN_MODEM_NETWORK, NET_CIPHERING_IND,
       
   266             PN_MODEM_NETWORK, NET_TIME_IND, // used also in SimAtkTSY
       
   267             PN_MODEM_NETWORK, NET_RADIO_INFO_IND,
       
   268 
       
   269         // SS SERVER INDICATIONS
       
   270             PN_SS, SS_SERVICE_COMPLETED_IND,
       
   271             PN_SS, SS_STATUS_IND, // used also in SimAtkTSY
       
   272             PN_SS, SS_RESOURCE_CONTROL_IND, // used in SimAtkTSY
       
   273             PN_SS, SS_RESOURCE_CONF_IND, // used in SimAtkTSY
       
   274 
       
   275         // USSD
       
   276             PN_SS, SS_GSM_USSD_RECEIVE_IND,
       
   277 
       
   278         // SMS SERVER INDICATIONS
       
   279             PN_SMS, SMS_RECEIVED_SIM_MSG_IND, // used only in SimAtkTSY
       
   280             PN_SMS, SMS_RESOURCE_IND, // used only in SimAtkTSY
       
   281             PN_SMS, SMS_RECEIVED_MSG_IND,
       
   282             PN_SMS, SMS_CB_ROUTING_IND,
       
   283 
       
   284         // UICC SERVER INDICATIONS
       
   285             PN_UICC, UICC_CARD_IND,
       
   286             PN_UICC, UICC_IND,
       
   287 
       
   288 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   289         // MTC SERVER INDICATIONS
       
   290             PN_MTC, MTC_STATE_INFO_IND,
       
   291 #else /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   292         // MCE SERVER INDICATIONS
       
   293             PN_MODEM_MCE, MCE_MODEM_STATE_IND,
       
   294 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   295         // GPDS SERVER INDICATIONS
       
   296             PN_GPDS, GPDS_CONTEXT_ID_CREATE_IND,
       
   297             PN_GPDS, GPDS_CONTEXT_ID_DELETE_IND,
       
   298             PN_GPDS, GPDS_CONTEXT_ACTIVATE_IND,
       
   299             PN_GPDS, GPDS_CONTEXT_DEACTIVATE_IND,
       
   300             PN_GPDS, GPDS_CONTEXT_NWI_ACT_REQUEST_IND,
       
   301             PN_GPDS, GPDS_ATTACH_IND,
       
   302             PN_GPDS, GPDS_DETACH_IND,
       
   303             PN_GPDS, GPDS_TRANSFER_STATUS_IND,
       
   304             PN_GPDS, GPDS_CONTEXT_ACTIVATE_FAIL_IND,
       
   305             PN_GPDS, GPDS_CONTEXT_STATUS_IND,
       
   306             PN_GPDS, GPDS_CONTEXT_ACTIVATING_IND,
       
   307             PN_GPDS, GPDS_CONTEXT_DEACTIVATING_IND,
       
   308             PN_GPDS, GPDS_CONFIGURATION_INFO_IND,
       
   309             PN_GPDS, GPDS_CONTEXT_MODIFY_IND,
       
   310             PN_GPDS, GPDS_RADIO_ACTIVITY_IND,
       
   311             PN_GPDS, GPDS_RESOURCE_CONTROL_IND,
       
   312             PN_GPDS, GPDS_RESOURCE_CONF_IND,
       
   313 
       
   314         // NVD SERVER INDICATIONS
       
   315 
       
   316         // PIPE SERVER INDICATIONS
       
   317 
       
   318         // GSS SERVER INDICATIONS
       
   319             PN_GSS, GSS_HSXPA_USER_SETTING_IND,
       
   320 
       
   321         };
       
   322 
       
   323     TInt ret = iPhoNetSender->SubscribeEvents(
       
   324         TPtr8( &requestArray[0],
       
   325             sizeof( requestArray ),
       
   326             sizeof( requestArray ) ) );
       
   327 
       
   328     return ret;
       
   329     }
       
   330 
       
   331 // --------------------------------------------------------------------------
       
   332 // CMmPhoneMessHandler::ExtFuncL
       
   333 // Dispatches Etel requests to DOS level handlers
       
   334 // --------------------------------------------------------------------------
       
   335 //
       
   336 TInt CMmPhoneMessHandler::ExtFuncL
       
   337         (
       
   338         TInt aIpc,
       
   339         const CMmDataPackage* aDataPackage // Data package
       
   340         )
       
   341     {
       
   342 TFLOGSTRING2("TSY: CMmPhoneMessHandler::ExtFuncL. Licensee specific implemtantion. IPC: %d", aIpc);
       
   343 OstTrace1( TRACE_NORMAL, CMMPHONEMESSHANDLER_EXTFUNCL, "CMmPhoneMessHandler::ExtFuncL;Licensee specific implemtantion aIpc=%d", aIpc );
       
   344 
       
   345     //*************************************************************//
       
   346     // NOTE.
       
   347     //
       
   348     // LICENSEE SPECIFIC MESSAGE HANDLER IMPLEMENTATION STARTS HERE
       
   349     //
       
   350     //*************************************************************//
       
   351 
       
   352     TInt ret( KErrNone );
       
   353     TUint8 transId( KPhoneTransId );
       
   354 
       
   355     switch ( aIpc )
       
   356         {
       
   357         case EMobilePhoneGetALSLine:
       
   358             {
       
   359             ret = UiccReadDynamicFlagsReq();
       
   360             break;
       
   361             }
       
   362         case EMobilePhoneSetALSLine:
       
   363             {
       
   364             TUint8 alsLine;
       
   365             aDataPackage->UnPackData( alsLine );
       
   366             ret = UiccWriteDynamicFlagsReq( alsLine );
       
   367             break;
       
   368             }
       
   369         case EMobilePhoneGetCustomerServiceProfile:
       
   370             {
       
   371             ret = UiccCspFileReq();
       
   372             break;
       
   373             }
       
   374         case EMobilePhoneGetPhoneId:
       
   375             {
       
   376             // no packed parameters
       
   377             // read IMEI
       
   378             ret = InfoSerialNumberReadReq( transId, INFO_SN_IMEI_PLAIN );
       
   379             break;
       
   380             }
       
   381         case EMobilePhoneGetSubscriberId:
       
   382             {
       
   383             // read IMSI
       
   384             ret = UiccImsiReq();
       
   385             break;
       
   386             }
       
   387         case EMobilePhoneGetServiceProviderName:
       
   388             {
       
   389             ret = UiccReadServiceProviderName();
       
   390             break;
       
   391             }
       
   392         default:
       
   393             {
       
   394 TFLOGSTRING2("TSY: CMmPhoneMessHandler::ExtFuncL - Unknown IPC: %d", aIpc);
       
   395 OstTrace1( TRACE_NORMAL, DUP7_CMMPHONEMESSHANDLER_EXTFUNCL, "CMmPhoneMessHandler::ExtFuncL;Unknown aIpc=%d", aIpc );
       
   396             ret = KErrNotSupported;
       
   397             break;
       
   398             }
       
   399         }
       
   400 
       
   401     return ret;
       
   402     }
       
   403 
       
   404 // --------------------------------------------------------------------------
       
   405 // CMmPhoneMessHandler::ReceiveMessageL
       
   406 // Called by extension message handler when a common ISI
       
   407 // message has been received.
       
   408 // --------------------------------------------------------------------------
       
   409 //
       
   410 void CMmPhoneMessHandler::ReceiveMessageL
       
   411         (
       
   412         const TIsiReceiveC &aIsiMessage  // ISI message received
       
   413         )
       
   414     {
       
   415     TInt resource( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_RESOURCEID ) );
       
   416     TInt messageId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
       
   417 
       
   418 TFLOGSTRING3("TSY: CMmPhoneMessHandler::ReceiveMessageL, Resource: %d, Message: %d", resource, messageId );
       
   419 OstTraceExt2( TRACE_NORMAL, CMMPHONEMESSHANDLER_RECEIVEMESSAGEL, "CMmPhoneMessHandler::ReceiveMessageL;resource=%d;messageId=%d", resource, messageId );
       
   420 
       
   421     switch( resource )
       
   422         {
       
   423 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   424         case PN_INFO:
       
   425 #else /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   426         case PN_MODEM_INFO:
       
   427 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   428             {
       
   429             switch( messageId )
       
   430                 {
       
   431                 case INFO_SERIAL_NUMBER_READ_RESP:
       
   432                     {
       
   433                     InfoSerialNumberReadResp( aIsiMessage );
       
   434                     break;
       
   435                     }
       
   436                 default:
       
   437                     {
       
   438 TFLOGSTRING("TSY: CMmPhoneMessHandler::ReceiveMessageL, switch resource - case PN_MODEM_INFO, switch messageId - default.\n" );
       
   439 OstTrace0( TRACE_NORMAL, DUP4_CMMPHONEMESSHANDLER_RECEIVEMESSAGEL, "CMmPhoneMessHandler::ReceiveMessageL, switch resource - case PN_MODEM_INFO, switch messageId - default" );
       
   440                     break;
       
   441                     }
       
   442                 }
       
   443             break; // end case PN_MODEM_INFO
       
   444             }
       
   445         default:
       
   446             {
       
   447 TFLOGSTRING("TSY: CMmPhoneMessHandler::ReceiveMessageL, switch resource - default.\n" );
       
   448 OstTrace0( TRACE_NORMAL, DUP5_CMMPHONEMESSHANDLER_RECEIVEMESSAGEL, "CMmPhoneMessHandler::ReceiveMessageL, switch resource - default" );
       
   449             break;
       
   450             }
       
   451         } // End of switch
       
   452     }
       
   453 
       
   454 // --------------------------------------------------------------------------
       
   455 // CMmPhoneMessHandler::InfoSerialNumberReadReq
       
   456 // Constructs INFO_SERIAL_NUMBER_READ_REQ ISI message..
       
   457 // Returns KErrNone on success, other error value on failure.
       
   458 // --------------------------------------------------------------------------
       
   459 //
       
   460 TInt CMmPhoneMessHandler::InfoSerialNumberReadReq
       
   461         (
       
   462         TUint8 aTransactionId, // transaction id
       
   463         TUint8 aTarget // type of requested serial number
       
   464         )
       
   465     {
       
   466 TFLOGSTRING("TSY: CMmPhoneMessHandler::InfoSerialNumberReadReq.");
       
   467 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_INFOSERIALNUMBERREADREQ, "CMmPhoneMessHandler::InfoSerialNumberReadReq" );
       
   468 
       
   469     TBuf8<1> data;
       
   470     data.Append( aTarget ); // Target identifier ( INFO_SN_IMEI_PLAIN )
       
   471 
       
   472     return iPhoNetSender->Send(
       
   473 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   474         PN_INFO,
       
   475 #else /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   476         PN_MODEM_INFO,
       
   477 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   478         aTransactionId,
       
   479         INFO_SERIAL_NUMBER_READ_REQ,
       
   480         data );
       
   481     }
       
   482 
       
   483 // --------------------------------------------------------------------------
       
   484 // CMmPhoneMessHandler::InfoSerialNumberReadResp
       
   485 // Breaks a INFO_SERIAL_NUMBER_READ_RESP ISI-message.
       
   486 // --------------------------------------------------------------------------
       
   487 //
       
   488 void CMmPhoneMessHandler::InfoSerialNumberReadResp
       
   489         (
       
   490         const TIsiReceiveC& aIsiMessage
       
   491         )
       
   492     {
       
   493     TInt err( KErrNotFound );
       
   494 
       
   495     TBuf8<KSerialNumberLength> serialData;
       
   496 
       
   497     // Get status
       
   498     TUint8 status( aIsiMessage.Get8bit(
       
   499         ISI_HEADER_SIZE + INFO_SERIAL_NUMBER_READ_RESP_OFFSET_STATUS ) );
       
   500 
       
   501 TFLOGSTRING2("TSY: CMmPhoneMessHandler::InfoSerialNumberReadResp, status=0x%02x",status);
       
   502 OstTraceExt1( TRACE_NORMAL, CMMPHONEMESSHANDLER_INFOSERIALNUMBERREADRESP, "CMmPhoneMessHandler::InfoSerialNumberReadResp;status=%hhx", status );
       
   503 
       
   504     // If status is Ok get information from possible sub block(s).
       
   505     if ( INFO_OK == status )
       
   506         {
       
   507         // If sub blocks
       
   508         if ( 0 != aIsiMessage.Get8bit(
       
   509             ISI_HEADER_SIZE +
       
   510             INFO_SERIAL_NUMBER_READ_RESP_OFFSET_SUBBLOCKCOUNT ) )
       
   511             {
       
   512             TUint sbSerialNumberStartOffset( 0 );
       
   513 
       
   514             if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
   515                 ISI_HEADER_SIZE + SIZE_INFO_SERIAL_NUMBER_READ_RESP,
       
   516                 INFO_SB_SN_IMEI_PLAIN,
       
   517                 EIsiSubBlockTypeId8Len8,
       
   518                 sbSerialNumberStartOffset ) )
       
   519                 {
       
   520                 // Read the string length - the zero terminator...
       
   521                 TUint8 strLength( aIsiMessage.Get8bit(
       
   522                     sbSerialNumberStartOffset +
       
   523                     INFO_SB_SN_IMEI_PLAIN_OFFSET_STRLEN ) - 1 );
       
   524                 // ...and compare it to the available buffer size
       
   525                 // (50 bytes in etel),
       
   526                 // and choose the shorter one strLength =
       
   527                 // ( RMobilePhone::KPhoneSerialNumberSize > strLength )?
       
   528                 // strLength : RMobilePhone::KPhoneSerialNumberSize;
       
   529 
       
   530                 TUint8 dataOffset(
       
   531                     sbSerialNumberStartOffset +
       
   532                     INFO_SB_SN_IMEI_PLAIN_OFFSET_IMEIPLAINU8 );
       
   533 
       
   534                 serialData.Append( aIsiMessage.GetData(
       
   535                     dataOffset,
       
   536                     strLength ).Left( KSerialNumberLength ) );
       
   537 
       
   538                 err = KErrNone;
       
   539                 }
       
   540             }
       
   541         }
       
   542 
       
   543     // Complete to CommonTSY, ONLY if all data has already been received
       
   544     // packed parameter: TBuf8<KSerialNumberLength> serialData
       
   545     CMmDataPackage dataPackage;
       
   546     dataPackage.PackData( &serialData );
       
   547     iMessageRouter->Complete( EMobilePhoneGetPhoneId, &dataPackage, err );
       
   548     }
       
   549 
       
   550 // --------------------------------------------------------------------------
       
   551 // CMmPhoneMessHandler::UiccReadDynamicFlagsReq
       
   552 // Read dynamic flags
       
   553 // --------------------------------------------------------------------------
       
   554 //
       
   555 TInt CMmPhoneMessHandler::UiccReadDynamicFlagsReq()
       
   556     {
       
   557 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccReadDynamicFlagsReq");
       
   558 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCREADDYNAMICFLAGSREQ, "CMmPhoneMessHandler::UiccReadDynamicFlagsReq" );
       
   559 
       
   560     // Set parameters for UICC_APPL_CMD_REQ message
       
   561     TUiccWriteTransparent params;
       
   562     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
   563     params.trId = ETrIdReadDynamicFlags;
       
   564     params.dataOffset = 0;
       
   565     params.dataAmount = 0;
       
   566     params.fileId = KElemFileDynFlagsOrange;
       
   567     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
   568     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
   569     // File id path
       
   570     params.filePath.Append( KMasterFileId >> 8 );
       
   571     params.filePath.Append( KMasterFileId );
       
   572     params.filePath.Append( KOrangeDedicatedFile >> 8 );
       
   573     params.filePath.Append( KOrangeDedicatedFile );
       
   574 
       
   575     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
   576     }
       
   577 
       
   578 // --------------------------------------------------------------------------
       
   579 // CMmPhoneMessHandler::UiccWriteDynamicFlagsReq
       
   580 // Write dynamic flags
       
   581 // --------------------------------------------------------------------------
       
   582 //
       
   583 TInt CMmPhoneMessHandler::UiccWriteDynamicFlagsReq( TUint8 aInfo )
       
   584     {
       
   585 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccWriteDynamicFlagsReq");
       
   586 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCWRITEDYNAMICFLAGSREQ, "CMmPhoneMessHandler::UiccWriteDynamicFlagsReq" );
       
   587 
       
   588     TInt ret( KErrNone );
       
   589     TUint8 line( 0 );
       
   590 
       
   591     if ( RMobilePhone::EAlternateLinePrimary == aInfo )
       
   592         {
       
   593         line = KAlsPrimaryLine;
       
   594         iAlsLine = RMobilePhone::EAlternateLinePrimary;
       
   595         }
       
   596     else if ( RMobilePhone::EAlternateLineAuxiliary == aInfo )
       
   597         {
       
   598         line = KAlsAuxiliaryLine;
       
   599         iAlsLine = RMobilePhone::EAlternateLineAuxiliary;
       
   600         }
       
   601     else
       
   602         {
       
   603         iAlsLine = RMobilePhone::EAlternateLineUnknown;
       
   604         ret = KErrArgument;
       
   605         }
       
   606 
       
   607     if ( KErrNone == ret )
       
   608         {
       
   609         // Set parameters for UICC_APPL_CMD_REQ message
       
   610         TUiccWriteTransparent params;
       
   611         params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
   612         params.trId = ETrIdWriteDynamicFlags;
       
   613         params.dataOffset = 0;
       
   614         params.fileId = KElemFileDynFlagsOrange;
       
   615         params.fileIdSfi = UICC_SFI_NOT_PRESENT;
       
   616         params.serviceType = UICC_APPL_UPDATE_TRANSPARENT;
       
   617 
       
   618         // File id path
       
   619         params.filePath.Append( KMasterFileId >> 8 );
       
   620         params.filePath.Append( KMasterFileId );
       
   621         params.filePath.Append( KOrangeDedicatedFile >> 8 );
       
   622         params.filePath.Append( KOrangeDedicatedFile );
       
   623 
       
   624         params.fileData.Append( line );
       
   625         ret = iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
   626         }
       
   627     return ret;
       
   628     }
       
   629 
       
   630 // --------------------------------------------------------------------------
       
   631 // CMmPhoneMessHandler::UiccReadDynamicFlagsResp
       
   632 // Complete dynamic flags
       
   633 // --------------------------------------------------------------------------
       
   634 //
       
   635 void CMmPhoneMessHandler::UiccReadDynamicFlagsResp(
       
   636     TInt aStatus,
       
   637     const TDesC8& aFileData )
       
   638     {
       
   639 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccReadDynamicFlagsResp");
       
   640 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCREADDYNAMICFLAGSRESP, "CMmPhoneMessHandler::UiccReadDynamicFlagsResp" );
       
   641 
       
   642     RMobilePhone::TMobilePhoneALSLine alsLine
       
   643         ( RMobilePhone::EAlternateLineUnknown );
       
   644 
       
   645     TInt ret( KErrNone );
       
   646     if ( UICC_STATUS_OK == aStatus )
       
   647         {
       
   648         // Dynamic flags byte: if bit 0 is 1, it is line 1, else line 2
       
   649         if ( aFileData[0] & 0x1 )
       
   650             {
       
   651             alsLine = RMobilePhone::EAlternateLinePrimary;
       
   652             }
       
   653         else
       
   654             {
       
   655             alsLine = RMobilePhone::EAlternateLineAuxiliary;
       
   656             }
       
   657         }
       
   658 
       
   659     iSupplServMessHandler->SetVoiceCallForwardLine( alsLine );
       
   660 
       
   661     CMmDataPackage dataPackage;
       
   662     dataPackage.PackData ( &alsLine );
       
   663     iMessageRouter->Complete(
       
   664         EMobilePhoneGetALSLine,
       
   665         &dataPackage,
       
   666         ret );
       
   667     }
       
   668 
       
   669 // --------------------------------------------------------------------------
       
   670 // CMmPhoneMessHandler::UiccWriteDynamicFlagsResp
       
   671 // Complete write dynamic flags
       
   672 // --------------------------------------------------------------------------
       
   673 //
       
   674 void CMmPhoneMessHandler::UiccWriteDynamicFlagsResp( TInt aStatus )
       
   675     {
       
   676 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccWriteDynamicFlagsResp");
       
   677 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCWRITEDYNAMICFLAGSRESP, "CMmPhoneMessHandler::UiccWriteDynamicFlagsResp" );
       
   678 
       
   679     if ( UICC_STATUS_OK == aStatus )
       
   680         {
       
   681         iSupplServMessHandler->SetVoiceCallForwardLine( iAlsLine );
       
   682         iMessageRouter->Complete( EMobilePhoneSetALSLine, KErrNone );
       
   683         }
       
   684     else
       
   685         {
       
   686         iMessageRouter->Complete( EMobilePhoneSetALSLine, KErrGeneral );
       
   687         }
       
   688     }
       
   689 
       
   690 // --------------------------------------------------------------------------
       
   691 // CMmPhoneMessHandler::UiccCspFileReq
       
   692 // Read CSP
       
   693 // --------------------------------------------------------------------------
       
   694 TInt CMmPhoneMessHandler::UiccCspFileReq()
       
   695     {
       
   696 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccCspFileReq");
       
   697 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCCSPFILEREQ, "CMmPhoneMessHandler::UiccCspFileReq" );
       
   698 
       
   699     // Set parameters for UICC_APPL_CMD_REQ message
       
   700     TUiccReadTransparent params;
       
   701     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
   702     params.trId = ETrIdReadCsp;
       
   703     params.dataAmount = 18;
       
   704     params.dataOffset = 0; // Read from first byte
       
   705     params.fileId = KElemFileCustomerServiceProfile;
       
   706     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
   707 
       
   708     // File id path
       
   709     params.filePath.Append( KMasterFileId >> 8 );
       
   710     params.filePath.Append( KMasterFileId );
       
   711     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
   712 
       
   713     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
   714     }
       
   715 
       
   716 // --------------------------------------------------------------------------
       
   717 // CMmPhoneMessHandler::UiccCspFileResp
       
   718 // Complete CSP
       
   719 // --------------------------------------------------------------------------
       
   720 void CMmPhoneMessHandler::UiccCspFileResp(
       
   721     TInt aStatus,
       
   722     const TDesC8& aFileData )
       
   723     {
       
   724 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccHandleCallFwdFlagsResp");
       
   725 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCCSPFILERESP, "CMmPhoneMessHandler::UiccCspFileResp" );
       
   726 
       
   727     RMobilePhone::TMobilePhoneCspFileV1 cspFileEtel;
       
   728 
       
   729     if ( aStatus == KErrNone )
       
   730         {
       
   731         TUint8 i( 0 );
       
   732         // Call offering capabilities
       
   733         if ( KUiccCspCallOfferingCode == aFileData[i++] )
       
   734             {
       
   735             cspFileEtel.iCallOfferingServices = aFileData[i++];
       
   736             }
       
   737 
       
   738         // Call restriction capabilities
       
   739         if ( KUiccCspCallRestrictionCode == aFileData[i++] )
       
   740             {
       
   741             cspFileEtel.iCallRestrictionServices = aFileData[i++];
       
   742             }
       
   743 
       
   744         // Other supplementary services capabilities
       
   745         if ( KUiccCspOtherSupplServCode == aFileData[i++] )
       
   746             {
       
   747             cspFileEtel.iOtherSuppServices = aFileData[i++];
       
   748             }
       
   749 
       
   750         // Call completion capabilities
       
   751         if ( KUiccCspCallCompletionCode == aFileData[i++] )
       
   752             {
       
   753             cspFileEtel.iCallCompletionServices = aFileData[i++];
       
   754             }
       
   755 
       
   756         // Teleservices capabilities
       
   757         if ( KUiccCspTeleServicesCode == aFileData[i++] )
       
   758             {
       
   759             cspFileEtel.iTeleservices = aFileData[i++];
       
   760             }
       
   761 
       
   762         // CPHS teleservices capabilities
       
   763         if ( KUiccCspCphsTeleServicesCode == aFileData[i++] )
       
   764             {
       
   765             cspFileEtel.iCphsTeleservices = aFileData[i++];
       
   766             }
       
   767 
       
   768         // CPHS features capabilities
       
   769         if ( KUiccCspCphsFeaturesCode == aFileData[i++] )
       
   770             {
       
   771             cspFileEtel.iCphsFeatures = aFileData[i++];
       
   772             }
       
   773 
       
   774         // Number identification capabilities
       
   775         if ( KUiccCspNumberIdentifCode == aFileData[i++] )
       
   776             {
       
   777             cspFileEtel.iNumberIdentServices = aFileData[i++];
       
   778             }
       
   779 
       
   780         // Value added services capabilities
       
   781         if ( KUiccCspValueAddedServicesCode == aFileData[i++] )
       
   782             {
       
   783             cspFileEtel.iValueAddedServices = aFileData[i++];
       
   784             }
       
   785         } // End of if ( aStatus == KErrNone )
       
   786     else
       
   787         {
       
   788         aStatus = KErrNotFound;
       
   789         }
       
   790 
       
   791     // Complete with CSP data and error code
       
   792     CMmDataPackage dataPackage;
       
   793     dataPackage.PackData( &cspFileEtel );
       
   794 
       
   795     iMessageRouter->Complete(
       
   796         EMobilePhoneGetCustomerServiceProfile,
       
   797         &dataPackage,
       
   798         aStatus );
       
   799     }
       
   800 
       
   801 // --------------------------------------------------------------------------
       
   802 // CMmPhoneMessHandler::UiccImsiReq
       
   803 // Read IMSI
       
   804 // --------------------------------------------------------------------------
       
   805 //
       
   806 TInt CMmPhoneMessHandler::UiccImsiReq( )
       
   807     {
       
   808 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccImsiReq");
       
   809 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCIMSIREQ, "CMmPhoneMessHandler::UiccImsiReq" );
       
   810 
       
   811     // Set parameters for UICC_APPL_CMD_REQ message
       
   812     TUiccReadTransparent params;
       
   813     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
   814     params.trId = ETrIdReadImsi;
       
   815     params.dataAmount = 9; // Length + IMSI = 9 bytes
       
   816     params.dataOffset = 0; // Read from first byte
       
   817     params.fileId = KElemFileImsi;
       
   818     params.fileIdSfi = 7;
       
   819     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
   820 
       
   821     // File id path
       
   822     params.filePath.Append( KMasterFileId >> 8 );
       
   823     params.filePath.Append( KMasterFileId );
       
   824     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
   825 
       
   826     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
   827     }
       
   828 
       
   829 // --------------------------------------------------------------------------
       
   830 // CMmPhoneMessHandler::UiccImsiResp
       
   831 // Complete IMSI
       
   832 // --------------------------------------------------------------------------
       
   833 //
       
   834 void CMmPhoneMessHandler::UiccImsiResp( TInt aStatus, const TDesC8& aFileData )
       
   835     {
       
   836 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccImsiResp" );
       
   837 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCIMSIRESP, "CMmPhoneMessHandler::UiccImsiResp" );
       
   838 
       
   839     TInt err( KErrNone );
       
   840     TBuf8<RMobilePhone::KIMSISize> imsiData;
       
   841     if ( UICC_STATUS_OK == aStatus )
       
   842         {
       
   843         TUint8 i( 0 );
       
   844         TUint8 valueMSB( 0 );
       
   845         TUint8 valueLSB( 0 );
       
   846         // Get length of IMSI (the first byte)
       
   847         TUint8 lengthOfImsi( aFileData[0] );
       
   848         // Get the first IMSI number: MSB semioctet of byte 2
       
   849         valueMSB = static_cast<TUint8>( aFileData[1] >> 4 );
       
   850         // Check the validity
       
   851         if ( KImsiSize >= lengthOfImsi && 10 > valueMSB  )
       
   852             {
       
   853             imsiData.AppendNum( valueMSB, EDecimal);
       
   854             }
       
   855         else
       
   856             {
       
   857             err = KErrCorrupt;
       
   858             }
       
   859 
       
   860         if ( KErrNone == err )
       
   861             {
       
   862             // Check and append the rest of IMSI numbers
       
   863             for ( i = 2; i <= lengthOfImsi; i++ )
       
   864                 {
       
   865                 valueLSB = static_cast<TUint8>( aFileData[i] & 0x0F );
       
   866                 valueMSB = static_cast<TUint8>( aFileData[i] >> 4 );
       
   867 
       
   868                 // If both values are valid
       
   869                 if ( 10 > valueLSB && 10 > valueMSB )
       
   870                     {
       
   871                     imsiData.AppendNum( valueLSB, EDecimal);
       
   872                     imsiData.AppendNum( valueMSB, EDecimal);
       
   873                     }
       
   874                 // Last nibble is unused
       
   875                 else if( 10 > valueLSB && 0xF == valueMSB )
       
   876                     {
       
   877                     imsiData.AppendNum( valueLSB, EDecimal);
       
   878                     break;
       
   879                     }
       
   880                 // Either is invalid
       
   881                 else
       
   882                     {
       
   883                     err = KErrCorrupt;
       
   884                     break;
       
   885                     }
       
   886                 }
       
   887             }
       
   888         }
       
   889     else
       
   890         {
       
   891         err = KErrNotFound;
       
   892         }
       
   893 
       
   894     // Complete with packed parameter
       
   895     CMmDataPackage dataPackage;
       
   896     dataPackage.PackData( &imsiData );
       
   897 
       
   898     iMessageRouter->Complete(
       
   899         EMobilePhoneGetSubscriberId,
       
   900         &dataPackage,
       
   901         err );
       
   902     }
       
   903 
       
   904 // --------------------------------------------------------------------------
       
   905 // CMmPhoneMessHandler::UiccReadServiceProviderName
       
   906 // Read service provider name
       
   907 // --------------------------------------------------------------------------
       
   908 //
       
   909 TInt CMmPhoneMessHandler::UiccReadServiceProviderName()
       
   910     {
       
   911 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccReadServiceProviderName");
       
   912 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCREADSERVICEPROVIDERNAME, "CMmPhoneMessHandler::UiccReadServiceProviderName" );
       
   913 
       
   914     // Read SIM file '6F46', Service Provider Name
       
   915     // Set parameters for UICC_APPL_CMD_REQ message
       
   916     TUiccReadTransparent params;
       
   917     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
   918     params.trId = ETrIdReadServiceProviderName;
       
   919     // Read all 17 bytes
       
   920     params.dataAmount = 17;
       
   921     params.dataOffset = 0;
       
   922     params.fileId = KElemFileServiceProviderName;
       
   923     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
   924 
       
   925     // File id path
       
   926     params.filePath.Append( KMasterFileId >> 8 );
       
   927     params.filePath.Append( KMasterFileId );
       
   928     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
   929 
       
   930     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
   931     }
       
   932 
       
   933 // --------------------------------------------------------------------------
       
   934 // CMmPhoneMessHandler::UiccReadServiceProviderNameResp
       
   935 // Complete service provider name
       
   936 // --------------------------------------------------------------------------
       
   937 //
       
   938 void CMmPhoneMessHandler::UiccReadServiceProviderNameResp(
       
   939     TInt aStatus,
       
   940     const TDesC8& aFileData )
       
   941     {
       
   942 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccReadServiceProviderNameResp");
       
   943 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCREADSERVICEPROVIDERNAMERESP, "CMmPhoneMessHandler::UiccReadServiceProviderNameResp" );
       
   944 
       
   945     TInt ret( KErrNone );
       
   946     if ( KErrNone == aStatus )
       
   947         {
       
   948         // Store data and read SPN display info
       
   949         ret = UiccProcessServiceTypeCheck( aFileData );
       
   950         }
       
   951 
       
   952     if ( KErrNone != aStatus || KErrNone != ret )
       
   953         {
       
   954         // Complete error without data
       
   955         iMessageRouter->Complete(
       
   956             EMobilePhoneGetServiceProviderName,
       
   957             KErrNotFound );
       
   958         }
       
   959     }
       
   960 
       
   961 // -----------------------------------------------------------------------------
       
   962 // CMmPhoneMessHandler::ProcessUiccMsg
       
   963 // Handles data received from UICC server
       
   964 // -----------------------------------------------------------------------------
       
   965 //
       
   966 TInt CMmPhoneMessHandler::ProcessUiccMsg(
       
   967     TInt aTraId,
       
   968     TInt aStatus,
       
   969     const TDesC8& aFileData )
       
   970     {
       
   971 TFLOGSTRING3("TSY: CMmPhoneMessHandler::ProcessUiccMsg, transaction ID: %d, status %d", aTraId, aStatus );
       
   972 OstTraceExt2( TRACE_NORMAL, CMMPHONEMESSHANDLER_PROCESSUICCMSG, "CMmPhoneMessHandler::ProcessUiccMsg;aTraId=%d;aStatus=%d", aTraId, aStatus );
       
   973 
       
   974 switch( aTraId )
       
   975         {
       
   976         case ETrIdReadImsi:
       
   977             {
       
   978             UiccImsiResp( aStatus, aFileData );
       
   979             break;
       
   980             }
       
   981         case ETrIdReadServiceProviderName:
       
   982             {
       
   983             UiccReadServiceProviderNameResp( aStatus, aFileData );
       
   984             break;
       
   985             }
       
   986         case ETrIdReadServiceProviderDisplayInfo:
       
   987             {
       
   988             UiccProcessSpnNameInfo( aStatus, aFileData );
       
   989             break;
       
   990             }
       
   991         case ETrIdReadCsp:
       
   992             {
       
   993             UiccCspFileResp( aStatus, aFileData );
       
   994             }
       
   995         case ETrIdReadDynamicFlags:
       
   996             {
       
   997             UiccReadDynamicFlagsResp( aStatus, aFileData );
       
   998             break;
       
   999             }
       
  1000         case ETrIdWriteDynamicFlags:
       
  1001             {
       
  1002             UiccWriteDynamicFlagsResp( aStatus );
       
  1003             break;
       
  1004             }
       
  1005         default:
       
  1006             {
       
  1007 TFLOGSTRING("TSY: CMmPhoneMessHandler::ProcessUiccMsg - unknown transaction ID" );
       
  1008 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEMESSHANDLER_PROCESSUICCMSG, "CMmPhoneMessHandler::ProcessUiccMsg - unknown transaction ID" );
       
  1009             break;
       
  1010             }
       
  1011         }
       
  1012     return KErrNone;
       
  1013     }
       
  1014 
       
  1015 // --------------------------------------------------------------------------
       
  1016 // CMmPhoneMessHandler::UiccProcessServiceTypeCheck
       
  1017 // Process service type checking response
       
  1018 // --------------------------------------------------------------------------
       
  1019 //
       
  1020 TInt CMmPhoneMessHandler::UiccProcessServiceTypeCheck(
       
  1021     const TDesC8& aFileData )
       
  1022     {
       
  1023 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccProcessServiceTypeCheck");
       
  1024 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCPROCESSSERVICETYPECHECK, "CMmPhoneMessHandler::UiccProcessServiceTypeCheck" );
       
  1025 
       
  1026     // Copy service provider name, starting from byte 2
       
  1027     TBuf8<KSpnFileSize> spnBuffer( aFileData.Mid( 1 ) );
       
  1028     TBuf8<KServiceProviderSize> spnOutputBuffer;
       
  1029     CMmStaticUtility::ConvertGsmDataToUcs2(
       
  1030         spnBuffer,
       
  1031         KSpnFileSize,
       
  1032         spnOutputBuffer );
       
  1033 
       
  1034     // Get the display condition ( 1st byte )
       
  1035     const TUint8 displayCondition( aFileData[0] );
       
  1036 
       
  1037     // From TS 31.102:
       
  1038     // b1=1: display of registered PLMN name required when registered PLMN is
       
  1039     // either HPLMN or a PLMN in the service provider PLMN list.
       
  1040     if ( displayCondition & 0x01 )
       
  1041         {
       
  1042         iServiceProviderName.iDisplayReq = RMobilePhone::KDisplayPLMNRequired;
       
  1043         }
       
  1044     else
       
  1045         {
       
  1046         iServiceProviderName.iDisplayReq =
       
  1047             RMobilePhone::KDisplayPLMNNotRequired;
       
  1048         }
       
  1049 
       
  1050     // Set iSecondDisplayCondition as not required by default
       
  1051     iSecondDisplayCondition = RMobilePhone::KDisplaySPNNotRequired;
       
  1052 
       
  1053     // From TS 31.102:
       
  1054     // b2=0:  Display of the service provider name is required when
       
  1055     // registered PLMN is neither HPLMN nor a PLMN in the service provider
       
  1056     // PLMN list
       
  1057     if ( 0 == ( displayCondition & 0x02 ) )
       
  1058         {
       
  1059         iSecondDisplayCondition = RMobilePhone::KDisplaySPNRequired;
       
  1060         }
       
  1061 
       
  1062     // PLMN and SPN control information summed up to iDisplayReq field
       
  1063     iServiceProviderName.iDisplayReq =
       
  1064         iServiceProviderName.iDisplayReq + iSecondDisplayCondition;
       
  1065 TFLOGSTRING2("TSY: CMmPhoneMessHandler::UiccProcessServiceTypeCheck - display condition: %d", (TUint8)iServiceProviderName.iDisplayReq);
       
  1066 
       
  1067     // Buffer for service provider name
       
  1068     TBuf16<KSpnFileSize> tempBuf;
       
  1069     TIsiUtility::CopyFromBigEndian( spnOutputBuffer, tempBuf );
       
  1070     // Copy service provider name
       
  1071     iServiceProviderName.iSPName.Copy( tempBuf );
       
  1072 TFLOGSTRING2("TSY: CMmPhoneMessHandler::UiccProcessServiceTypeCheck - SPN Name: %S", &iServiceProviderName.iSPName);
       
  1073 
       
  1074 
       
  1075     // We still need to get the PLMN list to complete the information.
       
  1076     // Read the SIM file EF SPDI ('6FCD')
       
  1077     // Set parameters for UICC_APPL_CMD_REQ message
       
  1078     TUiccReadTransparent params;
       
  1079     params.messHandlerPtr = static_cast<MUiccOperationBase*>( this );
       
  1080     params.trId = ETrIdReadServiceProviderDisplayInfo;
       
  1081     // Read all the data
       
  1082     params.dataAmount = 0;
       
  1083     params.dataOffset = 0;
       
  1084     params.fileId = KElemFileServiceProviderDisplayInfo;
       
  1085     params.fileIdSfi = 0x1B;
       
  1086     params.serviceType = UICC_APPL_READ_TRANSPARENT;
       
  1087 
       
  1088     // File id path
       
  1089     params.filePath.Append( KMasterFileId >> 8 );
       
  1090     params.filePath.Append( KMasterFileId );
       
  1091     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
       
  1092 
       
  1093     return iMmUiccMessHandler->CreateUiccApplCmdReq( params );
       
  1094     }
       
  1095 
       
  1096 // --------------------------------------------------------------------------
       
  1097 // CMmPhoneMessHandler::UiccProcessSpnNameInfo
       
  1098 // Processes SPN name info response
       
  1099 // --------------------------------------------------------------------------
       
  1100 //
       
  1101 void CMmPhoneMessHandler::UiccProcessSpnNameInfo(
       
  1102     TInt aStatus,
       
  1103     const TDesC8& aFileData)
       
  1104     {
       
  1105 TFLOGSTRING("TSY: CMmPhoneMessHandler::UiccProcessSpnNameInfo");
       
  1106 OstTrace0( TRACE_NORMAL, CMMPHONEMESSHANDLER_UICCPROCESSSPNNAMEINFO, "CMmPhoneMessHandler::UiccProcessSpnNameInfo" );
       
  1107 
       
  1108     TInt numOfPlmns( 0 );
       
  1109     TInt lengthOfDataInBytes( 0 );
       
  1110     TInt i( 0 ); // Index used of data extracting
       
  1111     if ( KErrNone == aStatus )
       
  1112         {
       
  1113         TInt lengthOfLengthInBytes( 0 );
       
  1114 
       
  1115         // Display info is coded in TLV format in USIM.
       
  1116         // Check the tag
       
  1117         if ( 0xA3 == aFileData[i] )
       
  1118             {
       
  1119             i++;
       
  1120             // If bit8 is set, rest of bits tell the number of bytes used for
       
  1121             // length
       
  1122             if ( aFileData[i] & 0x80 )
       
  1123                 {
       
  1124                 lengthOfLengthInBytes = aFileData[i] & 0x7F;
       
  1125                 i += lengthOfLengthInBytes;
       
  1126                 }
       
  1127             i++;
       
  1128 
       
  1129             // Check the tag
       
  1130             if ( 0x80 == aFileData[i] )
       
  1131                 {
       
  1132                 // Check how many bytes are used for length field
       
  1133                 i++;
       
  1134                 if ( 0 ==  ( aFileData[i] & 0x80 ) )
       
  1135                     {
       
  1136                     lengthOfDataInBytes = aFileData[i] & 0x7F;
       
  1137                     numOfPlmns = lengthOfDataInBytes / 3;
       
  1138                     i++; // Data starting point
       
  1139                     }
       
  1140                 else
       
  1141                     {
       
  1142                     lengthOfLengthInBytes = aFileData[i] & 0x7F;
       
  1143                     i++; // Skip length tag
       
  1144                     if ( 1 == lengthOfLengthInBytes )
       
  1145                         {
       
  1146                         lengthOfDataInBytes = aFileData[i];
       
  1147                         numOfPlmns = lengthOfDataInBytes / 3;
       
  1148                         i++; // Data starting point
       
  1149                         }
       
  1150                     else // Length is in two bytes
       
  1151                         {
       
  1152                         lengthOfDataInBytes =
       
  1153                             ( aFileData[i] << 8 ) | aFileData[i+1];
       
  1154                         numOfPlmns = lengthOfDataInBytes / 3;
       
  1155                         i += 2; // Data starting point
       
  1156                         }
       
  1157                     }
       
  1158                 }
       
  1159             else // Incorrect tag
       
  1160                 {
       
  1161                 aStatus = KErrGeneral;
       
  1162                 }
       
  1163             }
       
  1164         else // Incorrect tag
       
  1165             {
       
  1166             aStatus = KErrGeneral;
       
  1167             }
       
  1168         }
       
  1169 
       
  1170     // Copy PLMNs and complete
       
  1171     if ( KErrNone == aStatus )
       
  1172         {
       
  1173         // Number of PLMNs cannot exceed 170
       
  1174         if ( 170 < numOfPlmns )
       
  1175             {
       
  1176             numOfPlmns = 170;
       
  1177             }
       
  1178 
       
  1179         // At first append number of PLMNs and second display condition
       
  1180         TUint16 word( static_cast<TUint16>(
       
  1181                 numOfPlmns << 8 | iSecondDisplayCondition ) );
       
  1182         iServiceProviderName.iPLMNField.Append( word );
       
  1183 
       
  1184         // Copy PLMNs to 16 bit buffer
       
  1185         for ( TUint8 j( 0 ); j < lengthOfDataInBytes / 2; j++, i += 2 )
       
  1186             {
       
  1187             // PLMN entries are copied to 16-bit buffer as follows:
       
  1188             // 1st byte to 8 LSB bits of 16-bit buffer
       
  1189             // 2nd byte to 8 MSB bits of 16-bit buffer
       
  1190             word = static_cast<TUint16>(
       
  1191                 ( aFileData[i+1] << 8 ) | aFileData[i] );
       
  1192             iServiceProviderName.iPLMNField.Append( word );
       
  1193             }
       
  1194         // Last word is added
       
  1195         iServiceProviderName.iPLMNField.Append( ( 0xFF << 8 ) | aFileData[i] );
       
  1196 
       
  1197         // Complete SPN info
       
  1198         CMmDataPackage dataPackage;
       
  1199         dataPackage.PackData( &iServiceProviderName );
       
  1200         iMessageRouter->Complete(
       
  1201             EMobilePhoneGetServiceProviderName,
       
  1202             &dataPackage,
       
  1203             KErrNone );
       
  1204         }
       
  1205     else // Complete error without data
       
  1206         {
       
  1207         iMessageRouter->Complete(
       
  1208              EMobilePhoneGetServiceProviderName,
       
  1209              KErrNotFound );
       
  1210         }
       
  1211 
       
  1212     // Reset iServiceProviderName for next time.
       
  1213     iServiceProviderName.iSPName.Zero();
       
  1214     iServiceProviderName.iPLMNField.Zero();
       
  1215     }
       
  1216 
       
  1217 // End of file