adaptationlayer/tsy/nokiatsy_dll/src/cmmnetoperatornamehandler.cpp
changeset 0 63b37f68c1ce
child 5 8ccc39f9d787
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2008 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 "cmmnetoperatornamehandler.h"
       
    22 #include "cmmmessagerouter.h"
       
    23 #include "cmmphonemesshandler.h"
       
    24 #include "cmmphonetsender.h"
       
    25 #include "cmmstaticutility.h"
       
    26 #include "toperatornames.h"
       
    27 #include "tsylogger.h"
       
    28 
       
    29 #include <etelmm.h>
       
    30 #include <mmlist.h> // For network list functionality
       
    31 #include <net_modemisi.h>
       
    32 #include <infoisi.h>
       
    33 #include <product_profile_definitions.h>
       
    34 #include <tisi.h>
       
    35 //#include <permisi.h> To be done in CPS
       
    36 
       
    37 #include "osttracedefinitions.h"
       
    38 #ifdef OST_TRACE_COMPILER_IN_USE
       
    39 #include "cmmnetoperatornamehandlertraces.h"
       
    40 #endif
       
    41 
       
    42 // EXTERNAL DATA STRUCTURES
       
    43     //None
       
    44 
       
    45 // EXTERNAL FUNCTION PROTOTYPES
       
    46     //None
       
    47 
       
    48 // CONSTANTS
       
    49 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
    50 const TUint8 KNetTransId = 0x04; // TO BE DONE WITH INFO_PP_DATA_READ_REQ
       
    51 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
    52 const TUint8 KNetPadding = 0x00;
       
    53 
       
    54 // PNN record indentifiers in HPLMN.
       
    55 const TUint8 KNetNoHplmnPnnRecordNumber = 0x00;
       
    56 const TUint8 KNetHplmnPnnRecordNumber = 0x01;
       
    57 
       
    58 // Max buffer length for Operator name.
       
    59 const TInt KMaxLengthOfOperatorName = 124;
       
    60 
       
    61 // Max data string length in FULL_NAME or SHORT_NAME.
       
    62 // Length is enough big to hold max data length converted
       
    63 // to 7-bit characters.
       
    64 const TInt KDataStringMaxLength = 300;
       
    65 
       
    66 // Shifting & masking.
       
    67 const TUint8 KSiftedSixTimes = 0x06;
       
    68 const TUint8 KSpareBitsMask = 0x07; // Mask bits 1-3.
       
    69 const TUint8 KCountryInitialsMask = 0x08; // Mask bit 4.
       
    70 const TUint8 KCodingSchemeMask = 0x70; // Mask bits 5-7.
       
    71 
       
    72 // Wild char mask for BCD code checking.
       
    73 const TUint8 KBCDWildChar = 0x0D;
       
    74 // Character mask.
       
    75 const TUint8 KBCDOneCharMask = 0x0F;
       
    76 
       
    77 // Extended table.
       
    78 const TUint8 KExtendedTable = 0x1B;
       
    79 
       
    80 // Message data buffer length for PMM write request (74 bytes).
       
    81 const TUint8 KPmmDataLengthWriteReq = 0x4A;
       
    82 // Message data buffer length for PMM read request (14 bytes).
       
    83 const TUint8 KPmmDataLengthReadReq = 0x0E;
       
    84 // NITZ data length for PMM (64 bytes).
       
    85 const TUint32 KNitzPmmDataLength = 0x00000040;
       
    86 // NITZ data read offset values for PMM.
       
    87 const TUint32 KNitzPmmDataOffset = 0x00000000;
       
    88 //const TUint8 KNitzPmmLongNameOffset = 0x04; To be done in CPS
       
    89 //const TUint8 KNitzPmmShortNameOffset = 0x2C; To be done in CPS
       
    90 // NITZ name lengths in 8bit buffers.
       
    91 //const TUint8 KNitzPmmLongNamelength8Bit = 40; To be done in CPS
       
    92 //const TUint8 KNitzPmmShortNameLength8Bit = 20; To be done in CPS
       
    93 
       
    94 // MACROS
       
    95     //None
       
    96 
       
    97 // LOCAL CONSTANTS AND MACROS
       
    98     //None
       
    99 
       
   100 // MODULE DATA STRUCTURES
       
   101 
       
   102 // GSM 7-bit -> unicode translation table.
       
   103 // See 3GPP TS 23.038.
       
   104 const TUint16 KUnicode[128] =
       
   105     {
       
   106     0x0040, 0x00A3, 0x0024, 0x00A5, 0x00E8, 0x00E9, 0x00F9, 0x00EC,
       
   107     0x00F2, 0x00E7, 0x000A, 0x00D8, 0x00F8, 0x000D, 0x00C5, 0x00E5,
       
   108     0x0394, 0x005F, 0x03A6, 0x0393, 0x039B, 0x03A9, 0x03A0, 0x03A8,
       
   109     0x03A3, 0x0398, 0x039E, 0x00A0, 0x00C6, 0x00E6, 0x00DF, 0x00C9,
       
   110     0x0020, 0x0021, 0x0022, 0x0023, 0x00A4, 0x0025, 0x0026, 0x0027,
       
   111     0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
       
   112     0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
       
   113     0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
       
   114     0x00A1, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
       
   115     0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
       
   116     0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
       
   117     0x0058, 0x0059, 0x005A, 0x00C4, 0x00D6, 0x00D1, 0x00DC, 0x00A7,
       
   118     0x00BF, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
       
   119     0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
       
   120     0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
       
   121     0x0078, 0x0079, 0x007A, 0x00E4, 0x00F6, 0x00F1, 0x00FC, 0x00E0
       
   122     };
       
   123 
       
   124 // LOCAL FUNCTION PROTOTYPES
       
   125     //None
       
   126 
       
   127 // FORWARD DECLARATIONS
       
   128     //None
       
   129 
       
   130 // ============================= LOCAL FUNCTIONS ===============================
       
   131     //None
       
   132 
       
   133 // ============================ MEMBER FUNCTIONS ===============================
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CMmNetOperatorNameHandler::CMmNetOperatorNameHandler
       
   137 // C++ default constructor
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 CMmNetOperatorNameHandler::CMmNetOperatorNameHandler()
       
   141     {
       
   142 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::CMmNetOperatorNameHandler()");
       
   143 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_CMMNETOPERATORNAMEHANDLER, "CMmNetOperatorNameHandler::CMmNetOperatorNameHandler" );
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CMmNetOperatorNameHandler::NewL
       
   148 // Two-phased constructor.
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 CMmNetOperatorNameHandler* CMmNetOperatorNameHandler::NewL
       
   152         (
       
   153         CMmNetMessHandler* aNetMessHandler // Pointer to the NetMessHandler.
       
   154         )
       
   155     {
       
   156 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::NewL");
       
   157 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_NEWL, "CMmNetOperatorNameHandler::NewL" );
       
   158 
       
   159     CMmNetOperatorNameHandler* netOperatorNameHandler =
       
   160         new ( ELeave ) CMmNetOperatorNameHandler();
       
   161 
       
   162     CleanupStack::PushL( netOperatorNameHandler );
       
   163 
       
   164     netOperatorNameHandler->iNetMessHandler = aNetMessHandler;
       
   165     netOperatorNameHandler->ConstructL();
       
   166 
       
   167     CleanupStack::Pop( netOperatorNameHandler );
       
   168 
       
   169     return netOperatorNameHandler;
       
   170     }
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // CMmNetOperatorNameHandler::ConstructL
       
   174 // Symbian 2nd phase constructor. Initialises internal attributes.
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 void CMmNetOperatorNameHandler::ConstructL()
       
   178     {
       
   179 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::ConstructL()");
       
   180 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_CONSTRUCTL, "CMmNetOperatorNameHandler::ConstructL" );
       
   181 
       
   182     // Initialization of NITZ data.
       
   183     iNitzName.iMCC = 0;
       
   184     iNitzName.iMNC = 0;
       
   185     iNitzName.iLongName.Zero();
       
   186     iNitzName.iShortName.Zero();
       
   187 
       
   188     // Initialization of EONS data.
       
   189     iEonsName.iMCC = 0;
       
   190     iEonsName.iMNC = 0;
       
   191     iEonsName.iLongName.Zero();
       
   192     iEonsName.iShortName.Zero();
       
   193     iEonsName.iPNNIdentifier = 0;
       
   194 
       
   195     // Initialization of NITZ name stored to PMM.
       
   196     iNitzNamePmm.iMCC = 0;
       
   197     iNitzNamePmm.iMNC = 0;
       
   198     iNitzNamePmm.iLongName.Zero();
       
   199     iNitzNamePmm.iShortName.Zero();
       
   200 
       
   201     // Initialize CustomAPI values.
       
   202     iOperNameInfo.iType = RMmCustomAPI::EOperatorNameFlexiblePlmn;
       
   203     iOperNameInfo.iName.Zero();
       
   204 
       
   205     // Initialization of Operator Name String (ONS).
       
   206     iOperatorNameString.Zero();
       
   207 
       
   208     // Operator PLMN list available flag initialization.
       
   209     iOplListAvailable = EFalse;
       
   210 
       
   211     // OPL rules read flag initialization.
       
   212     iOplRulesRead = EFalse;
       
   213 
       
   214     // OPL rule match flag initialization.
       
   215     iOplRuleMatch = EFalse;
       
   216 
       
   217     // Initialize.
       
   218     iFromGetOperatorName = EFalse;
       
   219     iFromGetManualSearchOperatorName = EFalse;
       
   220 
       
   221     iManualSearchIndexValue = 0;
       
   222 
       
   223     // Initialization of PP bit value, initialized to non used value.
       
   224 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   225     iInfoPpEonsFeatValue = 0xFF;
       
   226 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   227     // TO BE DONE WITH INFO_PP_DATA_READ_RESP
       
   228     iInfoPpEonsFeatValue = INFO_PP_EONS_FEAT_0;
       
   229     
       
   230     // Read INFO_PP_EONS_FEAT PP bit value.
       
   231     InfoPpReadReq();
       
   232 
       
   233     // Read NITZ data from PMM.
       
   234     PermPmRecordReadReq();
       
   235     }
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // CMmNetOperatorNameHandler::~CMmNetOperatorNameHandler
       
   239 // Destructor
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 CMmNetOperatorNameHandler::~CMmNetOperatorNameHandler()
       
   243     {
       
   244 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::~CMmNetOperatorNameHandler()");
       
   245 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_CMMNETOPERATORNAMEHANDLER, "CMmNetOperatorNameHandler::~CMmNetOperatorNameHandler" );
       
   246 
       
   247     // Closes the array and frees all memory allocated to the array.
       
   248     iOperatorPlmnListTable.Close();
       
   249     iManualSearchNetworkList.Close();
       
   250     iManualSearchDataList.Close();
       
   251     }
       
   252 
       
   253 // -----------------------------------------------------------------------------
       
   254 // CMmNetOperatorNameHandler::NetNitzNameInd
       
   255 // Breaks a NET_NITZ_NAME_IND ISI-message.
       
   256 // -----------------------------------------------------------------------------
       
   257 //
       
   258 void CMmNetOperatorNameHandler::NetNitzNameInd
       
   259         (
       
   260         const TIsiReceiveC& aIsiMessage
       
   261         )
       
   262     {
       
   263 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::NetNitzNameInd");
       
   264 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_NETNITZNAMEIND, "CMmNetOperatorNameHandler::NetNitzNameInd" );
       
   265 
       
   266     // Reset NITZ data.
       
   267     iNitzName.iMCC = 0;
       
   268     iNitzName.iMNC = 0;
       
   269     iNitzName.iLongName.Zero();
       
   270     iNitzName.iShortName.Zero();
       
   271 
       
   272     // Initialize.
       
   273     TUint tempMCC( 0 ); // Mobile Country Code
       
   274     TUint tempMNC( 0 ); // Mobile Network Code
       
   275     TUint sbStartOffSet( 0 );
       
   276 
       
   277     RMobilePhone::TMobilePhoneNetworkCountryCode countryCode;
       
   278     RMobilePhone::TMobilePhoneNetworkIdentity networkId;
       
   279 
       
   280     // Get the operator code. Size is 3 bytes.
       
   281     TPtrC8 operatorCode( aIsiMessage.GetData(
       
   282         ISI_HEADER_SIZE + NET_NITZ_NAME_IND_OFFSET_OPERATORCODE,
       
   283         3 ) );
       
   284 
       
   285     // Map the operator code and country code to symbian values.
       
   286     iNetMessHandler->MapOperatorAndCountryCode(
       
   287                          operatorCode,
       
   288                          networkId,
       
   289                          countryCode );
       
   290 
       
   291     // Convert descriptor contained number to integer.
       
   292     CMmStaticUtility::GetIntFromDescriptor( tempMCC, countryCode );
       
   293     CMmStaticUtility::GetIntFromDescriptor( tempMNC, networkId );
       
   294 
       
   295     // Store Country Code and Network Code.
       
   296     iNitzName.iMCC = tempMCC;
       
   297     iNitzName.iMNC = tempMNC;
       
   298 
       
   299     // Get NET_FULL_NITZ_NAME sub block.
       
   300     TInt retValue( aIsiMessage.FindSubBlockOffsetById(
       
   301         ISI_HEADER_SIZE + SIZE_NET_NITZ_NAME_IND,
       
   302         NET_FULL_NITZ_NAME,
       
   303         EIsiSubBlockTypeId8Len8,
       
   304         sbStartOffSet ) );
       
   305 
       
   306     if ( KErrNone == retValue )
       
   307         {
       
   308 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::NetNitzNameInd - NET_FULL_NITZ_NAME sub block");
       
   309 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_NETNITZNAMEIND, "CMmNetOperatorNameHandler::NetNitzNameInd - NET_FULL_NITZ_NAME sub block" );
       
   310         // Temporaly buffer for Long NITZ name.
       
   311         TBuf<KMaxLengthOfOperatorName> longNitzName;
       
   312 
       
   313         // Get data length.
       
   314         TUint8 dataLength( aIsiMessage.Get8bit(
       
   315             sbStartOffSet + NET_FULL_NITZ_NAME_OFFSET_DATALENGTH ) );
       
   316 
       
   317         // Get NITZ data from data field.
       
   318         TPtrC8 nitzFullNameData( aIsiMessage.GetData(
       
   319             sbStartOffSet + NET_FULL_NITZ_NAME_OFFSET_DATA,
       
   320             dataLength ) );
       
   321 
       
   322         // Convert NITZ data field to NITZ operator name.
       
   323         ConvertOperatorName(
       
   324             ENetNitzName,
       
   325             iNitzName.iMCC,
       
   326             nitzFullNameData,
       
   327             longNitzName );
       
   328 
       
   329         // Store NITZ Long name.
       
   330         iNitzName.iLongName.Copy( longNitzName.Left(
       
   331             iNitzName.iLongName.MaxLength() ) );
       
   332         }
       
   333 
       
   334     // Get NET_SHORT_NITZ_NAME sub block.
       
   335     retValue = aIsiMessage.FindSubBlockOffsetById(
       
   336         ISI_HEADER_SIZE + SIZE_NET_NITZ_NAME_IND,
       
   337         NET_SHORT_NITZ_NAME,
       
   338         EIsiSubBlockTypeId8Len8,
       
   339         sbStartOffSet );
       
   340 
       
   341     if ( KErrNone == retValue )
       
   342         {
       
   343 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::NetNitzNameInd - NET_SHORT_NITZ_NAME sub block");
       
   344 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_NETNITZNAMEIND, "CMmNetOperatorNameHandler::NetNitzNameInd - NET_SHORT_NITZ_NAME sub block" );
       
   345         // Temporaly buffer for Short NITZ name.
       
   346         TBuf<KMaxLengthOfOperatorName> shortNitzName;
       
   347 
       
   348         // Get data length.
       
   349         TUint8 dataLength( aIsiMessage.Get8bit(
       
   350             sbStartOffSet + NET_SHORT_NITZ_NAME_OFFSET_DATALENGTH ) );
       
   351 
       
   352         // Get NITZ data from data field.
       
   353         TPtrC8 nitzShortNameData( aIsiMessage.GetData(
       
   354             sbStartOffSet + NET_SHORT_NITZ_NAME_OFFSET_DATA,
       
   355             dataLength ) );
       
   356 
       
   357         // Convert NITZ data field to NITZ operator name.
       
   358         ConvertOperatorName(
       
   359             ENetNitzName,
       
   360             iNitzName.iMCC,
       
   361             nitzShortNameData,
       
   362             shortNitzName );
       
   363 
       
   364         // Store NITZ Short name.
       
   365         iNitzName.iShortName.Copy( shortNitzName.Left(
       
   366             iNitzName.iShortName.MaxLength() ) );
       
   367         }
       
   368 
       
   369 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::NetNitzNameInd - iNitzName.iMCC: %d", iNitzName.iMCC);
       
   370 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::NetNitzNameInd - iNitzName.iMNC: %d", iNitzName.iMNC);
       
   371 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::NetNitzNameInd - iNitzName.iLongName: %S", &iNitzName.iLongName);
       
   372 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::NetNitzNameInd - iNitzName.iShortName: %S", &iNitzName.iShortName);
       
   373 OstTrace1( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_NETNITZNAMEIND, "CMmNetOperatorNameHandler::NetNitzNameInd - iNitzName.iMCC=%u", iNitzName.iMCC );
       
   374 OstTrace1( TRACE_NORMAL, DUP4_CMMNETOPERATORNAMEHANDLER_NETNITZNAMEIND, "CMmNetOperatorNameHandler::NetNitzNameInd - iNitzName.iMNC=%u", iNitzName.iMNC );
       
   375 OstTraceExt1( TRACE_NORMAL, DUP5_CMMNETOPERATORNAMEHANDLER_NETNITZNAMEIND, "CMmNetOperatorNameHandler::NetNitzNameInd - iNitzName.iLongName=%S", iNitzName.iLongName );
       
   376 OstTraceExt1( TRACE_NORMAL, DUP6_CMMNETOPERATORNAMEHANDLER_NETNITZNAMEIND, "CMmNetOperatorNameHandler::NetNitzNameInd - iNitzName.iShortName=%S", iNitzName.iShortName );
       
   377 
       
   378     // Compare NITZ name got in NET_NITZ_NAME_IND to stored values in PMM.
       
   379     CompareNitzNameToPmmValues();
       
   380     }
       
   381 
       
   382 // -----------------------------------------------------------------------------
       
   383 // CMmNetOperatorNameHandler::ConvertOperatorName
       
   384 // Convert received data to operator name string according to coding scheme.
       
   385 // -----------------------------------------------------------------------------
       
   386 //
       
   387 void CMmNetOperatorNameHandler::ConvertOperatorName
       
   388         (
       
   389         TNetOperatorNameType aNameType, // Name type
       
   390         TUint aMCC, // Country code
       
   391         TPtrC8& aNameData, // Operator name data
       
   392         TDes& aOperatorName // Converted operator name
       
   393         )
       
   394     {
       
   395 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::ConvertOperatorName");
       
   396 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_CONVERTOPERATORNAME, "CMmNetOperatorNameHandler::ConvertOperatorName" );
       
   397 
       
   398     // Network Name information element.
       
   399     // See 3GPP 24.008 figure 10.5.80 and table 10.5.94.
       
   400     //
       
   401     //   8   7   6   5   4   3   2   1
       
   402     //  -------------------------------
       
   403     // |   |     Network Name IEI      |octet 1
       
   404     // |-------------------------------|
       
   405     // |Length of Network name contents|octet 2
       
   406     // |-------------------------------|
       
   407     // |ext|  coding   |Add| number of |
       
   408     // | 1 |  scheme   |CI | spare bits|octet 3
       
   409     // |-------------------------------|
       
   410     // |                               |octet 4
       
   411     // |          Text String          |  to
       
   412     // |                               |octet n
       
   413     //  -------------------------------
       
   414 
       
   415     // Initialze values for offsets.
       
   416     TInt offsetValueForOctet2( 0 );
       
   417     TInt offsetValueForOctet3( 0 );
       
   418     TInt offsetValueForOctet4( 0 );
       
   419 
       
   420     // Initialize length of Text String.
       
   421     TInt lengthOfTextString( 0 );
       
   422 
       
   423     // Operator name max length.
       
   424     TInt operatorNameMaxLength( aOperatorName.MaxLength() );
       
   425 
       
   426     // Check what name type is handled.
       
   427     if ( ENetEonsName == aNameType )
       
   428         {
       
   429         // EONS name data doesn't include Network Name IEI octed
       
   430         // and Length of Network Name contents octed,
       
   431         // so we need adjust offsets for reading correct position.
       
   432         offsetValueForOctet3 = 0;
       
   433         offsetValueForOctet4 = 1;
       
   434 
       
   435         // Get length of Text String.
       
   436         // Data includes also octet3, take that out
       
   437         // for real length of text string.
       
   438         lengthOfTextString = aNameData.Length() - 1;
       
   439         }
       
   440     else if ( ENetNitzName == aNameType )
       
   441         {
       
   442         // NITZ name data handling.
       
   443         // Offsets are according to figure 10.5.80.
       
   444         offsetValueForOctet2 = 1;
       
   445         offsetValueForOctet3 = 2;
       
   446         offsetValueForOctet4 = 3;
       
   447 
       
   448         // Get length of Text String.
       
   449         // Length of Network name contents includes also octet3,
       
   450         // take that out for real length of text string.
       
   451         lengthOfTextString = aNameData[offsetValueForOctet2] - 1;
       
   452         }
       
   453 
       
   454     // Get number of spare bits in last octet.
       
   455     // Mask bits 1-3 from octet 3.
       
   456     TUint8 numberOfSpareBits(
       
   457         aNameData[offsetValueForOctet3] & KSpareBitsMask );
       
   458 
       
   459     // Check out if Country's initials is needed.
       
   460     // Mask bit 4 from octet 3.
       
   461     TBool countryInitialsNeeded(
       
   462         aNameData[offsetValueForOctet3] & KCountryInitialsMask );
       
   463 
       
   464     // Get used Coding Scheme.
       
   465     // Mask bits 5-7 from octet 3.
       
   466     TUint8 codingSchemeInUse(
       
   467         aNameData[offsetValueForOctet3] & KCodingSchemeMask );
       
   468 
       
   469     // Pointer to operator name Text String.
       
   470     TPtrC8 textString( aNameData.Mid(
       
   471         offsetValueForOctet4,
       
   472         lengthOfTextString ) );
       
   473 
       
   474     // Add country's initials if needed to operator name string.
       
   475     if ( countryInitialsNeeded )
       
   476         {
       
   477 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::ConvertOperatorName - Country's Initials needed");
       
   478 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_CONVERTOPERATORNAME, "CMmNetOperatorNameHandler::ConvertOperatorName - Country's Initials needed" );
       
   479 
       
   480         // Initialize ret value.
       
   481         TInt ret( KErrNotFound );
       
   482 
       
   483         // Country's initials is needed.
       
   484         ret = TOperatorNames::GetCountryID( aMCC, aOperatorName );
       
   485 
       
   486         // Country was found and initials has added.
       
   487         if ( KErrNone == ret )
       
   488             {
       
   489             // Add also 'space' between Country's initials
       
   490             // and operator name string.
       
   491             aOperatorName.Append(' ');
       
   492             }
       
   493         // No else.
       
   494 
       
   495         }
       
   496 
       
   497     // Check Coding Scheme and convert string as needed.
       
   498     if ( EGSMDefaultAlphabetCoding == codingSchemeInUse )
       
   499         {
       
   500 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::ConvertOperatorName - 7-Bit coding used");
       
   501 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_CONVERTOPERATORNAME, "CMmNetOperatorNameHandler::ConvertOperatorName - 7-Bit coding used" );
       
   502         // Used coding is GSM 7-bit Default alphabet.
       
   503         //
       
   504         // Calculate correct value of GSM 7-bit characters.
       
   505         // numberOf7BitChars includes count of 7-bit characters
       
   506         // in 8-bit text string buffer.
       
   507         TInt numberOf7BitChars(
       
   508             ( ( lengthOfTextString * 8 ) - numberOfSpareBits ) / 7 );
       
   509 
       
   510         // Temporaly buffer for 8-bit string.
       
   511         TBuf8<KDataStringMaxLength> string8Bit;
       
   512         // Convert string first to 8-bit format.
       
   513         Packed7to8Format( numberOf7BitChars, textString, string8Bit );
       
   514 
       
   515         // Convert 8-bit string to unicode 16-bit format.
       
   516         // Temporaly buffer for 16-bit string.
       
   517         TBuf<KDataStringMaxLength> converted16BitString;
       
   518         // Convert to 16-bit.
       
   519         ConvertGsm7ToUnicode16( converted16BitString, string8Bit );
       
   520 
       
   521         // Converted string length.
       
   522         TInt converted16BitStringLength( converted16BitString.Length() );
       
   523 
       
   524         // Append operator name Text String.
       
   525         for ( TInt i = 0;
       
   526             i < converted16BitStringLength && operatorNameMaxLength > aOperatorName.Length();
       
   527             i++ )
       
   528             {
       
   529             aOperatorName.Append( converted16BitString[i] );
       
   530             }
       
   531         }
       
   532     else if ( EUCS2Coding == codingSchemeInUse )
       
   533         {
       
   534 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::ConvertOperatorName - UCS2 coding used");
       
   535 OstTrace0( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_CONVERTOPERATORNAME, "CMmNetOperatorNameHandler::ConvertOperatorName - UCS2 coding used" );
       
   536         // Used coding is UCS2(16-bit).
       
   537         //
       
   538         // Append operator name Text String.
       
   539         for ( TInt i = 0;
       
   540             i < lengthOfTextString && operatorNameMaxLength > aOperatorName.Length();
       
   541             i += 2 )
       
   542             {
       
   543             aOperatorName.Append(
       
   544                 TUint16( textString[i + 1] | ( textString[i] << 8 ) ) );
       
   545             }
       
   546         }
       
   547 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::ConvertOperatorName - Converted Operator Name: %S", &aOperatorName);
       
   548 OstTraceExt1( TRACE_NORMAL, DUP4_CMMNETOPERATORNAMEHANDLER_CONVERTOPERATORNAME, "CMmNetOperatorNameHandler::ConvertOperatorName - Converted Operator Name=%S", aOperatorName );
       
   549     }
       
   550 
       
   551 // -----------------------------------------------------------------------------
       
   552 // CMmNetOperatorNameHandler::GetOperatorName
       
   553 // Gets correct Operator name according priority order.
       
   554 // -----------------------------------------------------------------------------
       
   555 //
       
   556 void CMmNetOperatorNameHandler::GetOperatorName
       
   557         (
       
   558         TBool aCampedInHplmn, // Camped in HPLMN
       
   559         TUint8 aNetworkType, // Network type
       
   560         const TDesC8& aOperatorCode, // Operator Code in BCD format
       
   561         const RMobilePhone::TMobilePhoneLocationAreaV1& aLocationArea, // LAC info
       
   562         RMobilePhone::TMobilePhoneNetworkInfoV5& aNetworkName // Network info
       
   563         )
       
   564     {
       
   565 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetOperatorName");
       
   566 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName" );
       
   567 
       
   568     // Buffer for Display tag.
       
   569     TBuf<KDisplayTagLength> tempDisplayTag;
       
   570     // Hard coded name type.
       
   571     TInt hardCodedNameType( ENetNameNotSet );
       
   572     // PNN record number.
       
   573     TUint8 tempPnnIdentifier( 0 );
       
   574     // Reset operator name info data.
       
   575     iOperNameInfo.iType = RMmCustomAPI::EOperatorNameFlexiblePlmn;
       
   576     iOperNameInfo.iName.Zero();
       
   577 
       
   578     // Is NITZ name checking needed. Value initialization to ETrue.
       
   579     TBool checkNitzName( ETrue );
       
   580 
       
   581     // Initialize value for completing.
       
   582     TBool completeNow( ETrue );
       
   583 
       
   584     // Location Area Code.
       
   585     TUint lac( aLocationArea.iLocationAreaCode );
       
   586 
       
   587     // Initialize.
       
   588     TUint tempMCC( 0 ); // Country Code.
       
   589     TUint tempMNC( 0 ); // Network Code.
       
   590     // Convert descriptor contained number to integer.
       
   591     CMmStaticUtility::GetIntFromDescriptor(
       
   592         tempMCC,
       
   593         aNetworkName.iCountryCode );
       
   594     CMmStaticUtility::GetIntFromDescriptor(
       
   595         tempMNC,
       
   596         aNetworkName.iNetworkId );
       
   597 
       
   598 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetOperatorName - Current MCC: %d", tempMCC);
       
   599 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetOperatorName - Current MNC: %d", tempMNC);
       
   600 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetOperatorName - Current LAC: %d", lac);
       
   601 TFLOGSTRING4("TSY: CMmNetOperatorNameHandler::GetOperatorName - Operator Code BCD string: %02X %02X %02X", aOperatorCode[0], aOperatorCode[1], aOperatorCode[2]);
       
   602 OstTrace1( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - Current MCC=%u", tempMCC );
       
   603 OstTrace1( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - Current MNC=%u", tempMNC );
       
   604 OstTrace1( TRACE_NORMAL, DUP4_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - Current LAC=%u", lac );
       
   605 OstTraceExt3( TRACE_NORMAL, DUP10_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - Operator Code BCD string=%hhx %hhx %hhx", aOperatorCode[0], aOperatorCode[1], aOperatorCode[2] );
       
   606 
       
   607     // Starting to get Network name in priority order.
       
   608     //
       
   609     // Get Hard coded name from operators.h
       
   610     hardCodedNameType = TOperatorNames::GetName(
       
   611         tempMCC,
       
   612         tempMNC,
       
   613         tempDisplayTag );
       
   614 
       
   615     // Handle ONS and Hard coded name.
       
   616     HandleOnsAndHardCodedName(
       
   617         aNetworkType,
       
   618         hardCodedNameType,
       
   619         tempDisplayTag,
       
   620         aNetworkName );
       
   621 
       
   622     // Check PP bit INFO_PP_EONS_FEAT value impact to PNN record
       
   623     // when registered to HPLMN.
       
   624     if ( aCampedInHplmn )
       
   625         {
       
   626 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetOperatorName - Registered to HPLMN");
       
   627 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - Registered to HPLMN" );
       
   628         // Handle PP bit values.
       
   629         tempPnnIdentifier = HandlePnnRecordWithPPbitValueInHplmn(
       
   630             aOperatorCode,
       
   631             lac );
       
   632 
       
   633         // Is there PNN record to read.
       
   634         if ( KNetNoHplmnPnnRecordNumber != tempPnnIdentifier )
       
   635             {
       
   636             // If matching PNN record is not stored in internal memory
       
   637             // it will be read from SIM.
       
   638 
       
   639             // Check if matching PNN record is same than stored
       
   640             // PNN record number.
       
   641             if ( iEonsName.iPNNIdentifier == tempPnnIdentifier )
       
   642                 {
       
   643                 // Matching PNN record has read earlier from SIM,
       
   644                 // no need to read again.
       
   645                 // Copy EONS names if exist.
       
   646                 if ( 0 < iEonsName.iLongName.Length() )
       
   647                     {
       
   648 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetOperatorName - PNN Record is read earlier and EONS names exist");
       
   649 OstTrace0( TRACE_NORMAL, DUP13_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - PNN Record is read earlier and EONS names exist" );
       
   650                     CopyEonsName( aNetworkName );
       
   651 
       
   652                     // EONS name handled. No need to check NITZ.
       
   653                     checkNitzName = EFalse;
       
   654                     }
       
   655                 }
       
   656             else
       
   657                 {
       
   658 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetOperatorName - PNN Record not read earlier");
       
   659 OstTrace0( TRACE_NORMAL, DUP6_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - PNN Record not read earlier" );
       
   660                 // Setting iFromGetOperatorName flag to ETrue as
       
   661                 // SimOperatorReqReadPnn request is sended from
       
   662                 // GetOperatorName method.
       
   663                 // This flag is needed to handle correct IPC value.
       
   664                 iFromGetOperatorName = ETrue;
       
   665 
       
   666                 // No need to check NITZ.
       
   667                 checkNitzName = EFalse;
       
   668 
       
   669                 // Set EFalse as completing will be done after
       
   670                 // SimOperatorRespReadPnn message is handled.
       
   671                 // completeNow = EFalse;
       
   672                 }
       
   673             }
       
   674         }
       
   675     else
       
   676         {
       
   677 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetOperatorName - Not registered to HPLMN");
       
   678 OstTrace0( TRACE_NORMAL, DUP7_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - Not registered to HPLMN" );
       
   679         // OPL rules are read and list available.
       
   680         if ( iOplRulesRead && iOplListAvailable )
       
   681             {
       
   682 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetOperatorName - OPL Rules handling");
       
   683 OstTrace0( TRACE_NORMAL, DUP8_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - OPL Rules handling" );
       
   684             // EONS name consists of OPL rule and PNN record. One OPL rule consist
       
   685             // of PLMN code, LAC range and PNN record number. OPL rules are read
       
   686             // from SIM when EMmTsyBootNotifySimStatusReadyIPC is completed and
       
   687             // when refresh happens.
       
   688             //
       
   689             // Note: BCD value of 'D' in any of the MCC and/or MNC digits shall be
       
   690             // used to indicate a "wild" value for that corresponding MCC/MNC digit
       
   691             // (spec 31.102/4.2.59).
       
   692             tempPnnIdentifier = OplRulesChecker( aOperatorCode, lac );
       
   693 
       
   694             // Is match found from OPL list.
       
   695             if ( iOplRuleMatch )
       
   696                 {
       
   697 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetOperatorName - OPL Rules match");
       
   698 OstTrace0( TRACE_NORMAL, DUP9_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - OPL Rules match" );
       
   699                 // OPL rule exist for current network.
       
   700                 //
       
   701                 // If matching PNN record is not stored in internal memory
       
   702                 // it will be read from SIM.
       
   703 
       
   704                 // Check if matching PNN record is same than stored
       
   705                 // PNN record number.
       
   706                 if ( iEonsName.iPNNIdentifier == tempPnnIdentifier )
       
   707                     {
       
   708                     // Matching PNN record has read earlier from SIM,
       
   709                     // no need to read again.
       
   710                     // Copy EONS names if exist.
       
   711                     if ( 0 < iEonsName.iLongName.Length() )
       
   712                         {
       
   713 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetOperatorName - PNN Record is read earlier and EONS names exist");
       
   714 OstTrace0( TRACE_NORMAL, DUP5_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - PNN Record is read earlier and EONS names exist" );
       
   715                         CopyEonsName( aNetworkName );
       
   716 
       
   717                         // EONS name handled. No need to check NITZ.
       
   718                         checkNitzName = EFalse;
       
   719                         }
       
   720                     }
       
   721                 else
       
   722                     {
       
   723 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetOperatorName - PNN Record not read earlier");
       
   724 OstTrace0( TRACE_NORMAL, DUP11_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - PNN Record not read earlier" );
       
   725                     // Setting iFromGetOperatorName flag to ETrue as
       
   726                     // SimOperatorReqReadPnn request is sended from
       
   727                     // GetOperatorName method.
       
   728                     // This flag is needed to handle correct IPC value.
       
   729                     iFromGetOperatorName = ETrue;
       
   730 
       
   731                     // No need to check NITZ.
       
   732                     checkNitzName = EFalse;
       
   733 
       
   734                     // Set EFalse as completing will be done after
       
   735                     // SimOperatorRespReadPnn message is handled.
       
   736                     completeNow = EFalse;
       
   737                     }
       
   738                 }
       
   739             }
       
   740         }
       
   741 
       
   742     // Is NITZ name needed to be checked.
       
   743     if ( checkNitzName )
       
   744         {
       
   745 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetOperatorName - NITZ name is needed to check");
       
   746 OstTrace0( TRACE_NORMAL, DUP12_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - NITZ name is needed to check" );
       
   747         // Check if NITZ long/short name exist and NITZ data will match for
       
   748         // current Country and Network codes.
       
   749         NitzNameChecker( tempMCC, tempMNC, aNetworkName );
       
   750         }
       
   751 
       
   752     // Complete here if not needed to make read request for PNN record.
       
   753     if ( completeNow )
       
   754         {
       
   755 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetOperatorName - Completing");
       
   756 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetOperatorName, Operator display tag: %S", &aNetworkName.iDisplayTag);
       
   757 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetOperatorName, Operator long name: %S", &aNetworkName.iLongName);
       
   758 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetOperatorName, Operator short name: %S", &aNetworkName.iShortName);
       
   759 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetOperatorName, RMmCustomAPI::TOperatorNameInfo, Name: %S", &iOperNameInfo.iName);
       
   760 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetOperatorName, RMmCustomAPI::TOperatorNameInfo, Type: %d", iOperNameInfo.iType);
       
   761 
       
   762 OstTrace0( TRACE_NORMAL, DUP14_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName - Completing" );
       
   763 OstTraceExt1( TRACE_NORMAL, DUP15_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName, Operator display tag=%S", aNetworkName.iDisplayTag );
       
   764 OstTraceExt1( TRACE_NORMAL, DUP16_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName, Operator long name=%S", aNetworkName.iLongName );
       
   765 OstTraceExt1( TRACE_NORMAL, DUP17_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName, Operator short name=%S", aNetworkName.iShortName );
       
   766 OstTraceExt2( TRACE_NORMAL, DUP21_CMMNETOPERATORNAMEHANDLER_GETOPERATORNAME, "CMmNetOperatorNameHandler::GetOperatorName, RMmCustomAPI::TOperatorNameInfo - Name=%S;Type=%hhu", iOperNameInfo.iName, iOperNameInfo.iType );
       
   767 
       
   768         // Complete ECustomGetOperatorNameIPC.
       
   769         // Packed parameter: a RMmCustomAPI::TOperatorNameInfo.
       
   770         CMmDataPackage dataPackage;
       
   771         dataPackage.PackData( &iOperNameInfo );
       
   772 
       
   773         iNetMessHandler->GetMessageRouter()->Complete(
       
   774             ECustomGetOperatorNameIPC,
       
   775             &dataPackage,
       
   776             KErrNone );
       
   777 
       
   778         // Complete EMobilePhoneNotifyCurrentNetworkChange with
       
   779         // operator names.
       
   780         iNetMessHandler->CompleteMobilePhoneNotifyCurrentNetworkChange(
       
   781             aLocationArea,
       
   782             aNetworkName );
       
   783 
       
   784         // Reset operator name info data as these are completed.
       
   785         iOperNameInfo.iType = RMmCustomAPI::EOperatorNameFlexiblePlmn;
       
   786         iOperNameInfo.iName.Zero();
       
   787         }
       
   788     }
       
   789 
       
   790 // -----------------------------------------------------------------------------
       
   791 // CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL
       
   792 // Breaks a NET_MODEM_AVAILABLE_GET_RESP ISI-message and handles succes case.
       
   793 // -----------------------------------------------------------------------------
       
   794 //
       
   795 void CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL
       
   796         (
       
   797         const TIsiReceiveC& aIsiMessage
       
   798         )
       
   799     {
       
   800 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL");
       
   801 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_HANDLEMANUALSEARCHSUCCESSCASEL, "CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL" );
       
   802 
       
   803     TUint8 nbOfSubBlocks( aIsiMessage.Get8bit(
       
   804         ISI_HEADER_SIZE + NET_MODEM_AVAILABLE_GET_RESP_OFFSET_SUBBLOCKCOUNT ) );
       
   805 
       
   806     // There are always 2 sub blocks per one detected network,
       
   807     // so divide by 2.
       
   808     TUint8 amountOfNetworks( nbOfSubBlocks / 2 );
       
   809 
       
   810 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL - Found networks: %d", amountOfNetworks);
       
   811 OstTraceExt1( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_HANDLEMANUALSEARCHSUCCESSCASEL, "CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL - Found networks=%hhu", amountOfNetworks );
       
   812 
       
   813     // Reset manual network search list array that it can be reused.
       
   814     iManualSearchNetworkList.Reset();
       
   815     // Reset manual search data list array that it can be reused.
       
   816     iManualSearchDataList.Reset();
       
   817 
       
   818     // Create the reusable temp variables.
       
   819     RMobilePhone::TMobilePhoneNetworkInfoV5 entry;
       
   820     TManualSearchDataList tempManualSearchDataList;
       
   821 
       
   822     // Set the CDMA specific values to 0, those
       
   823     // values remains the same for all entries.
       
   824     entry.iAnalogSID.FillZ( 0 );
       
   825     entry.iCdmaSID.FillZ( 0 );
       
   826     entry.iBandInfo = RMobilePhone::EBandUnknown;
       
   827 
       
   828     // The NET Server returns all blocks of same type together,
       
   829     // so same network's information is not contiguous in the
       
   830     // ISI message, we need two loops to get the information
       
   831     // due ISIMSG implementation to get contiguous subblocks.
       
   832 
       
   833     // Temporaly array for handling network status.
       
   834     RArray<RMobilePhone::TMobilePhoneNetworkStatus> networkStatusList;
       
   835 
       
   836     TUint sbStartOffSet( 0 );
       
   837     TUint8 subBlockIndex( 1 );
       
   838 
       
   839     // Initialize value for data append handled successfully.
       
   840     TBool handlingSuccessful( ETrue );
       
   841 
       
   842     // Get all NET_MODEM_AVAIL_NETWORK_INFO_COMMON subblocks first,
       
   843     // keep data in the networkStatusList.
       
   844     for ( TUint8 i = 0; i < amountOfNetworks; i++ )
       
   845         {
       
   846         // Helper variable.
       
   847         RMobilePhone::TMobilePhoneNetworkStatus status(
       
   848             RMobilePhone::ENetworkStatusUnknown );
       
   849 
       
   850         // SubBlock NET_MODEM_AVAIL_NETWORK_INFO_COMMON.
       
   851         if ( ( KErrNone == aIsiMessage.FindSubBlockOffsetByIndex(
       
   852             ISI_HEADER_SIZE + SIZE_NET_MODEM_AVAILABLE_GET_RESP,
       
   853             subBlockIndex,
       
   854             EIsiSubBlockTypeId8Len8,
       
   855             sbStartOffSet ) )
       
   856             && ( NET_MODEM_AVAIL_NETWORK_INFO_COMMON == aIsiMessage.Get8bit(
       
   857             sbStartOffSet +
       
   858             NET_MODEM_AVAIL_NETWORK_INFO_COMMON_OFFSET_SUBBLOCKID ) ) )
       
   859             {
       
   860 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL - NET_MODEM_AVAIL_NETWORK_INFO_COMMON subblock");
       
   861 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_HANDLEMANUALSEARCHSUCCESSCASEL, "CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL - NET_MODEM_AVAIL_NETWORK_INFO_COMMON subblock" );
       
   862 
       
   863             // Network status.
       
   864             TUint8 networkStatus( aIsiMessage.Get8bit(
       
   865                 sbStartOffSet +
       
   866                 NET_MODEM_AVAIL_NETWORK_INFO_COMMON_OFFSET_NETWORKSTATUS ) );
       
   867 
       
   868             // Map the network status.
       
   869             iNetMessHandler->MapNwStatus( networkStatus, status );
       
   870 
       
   871             // Add the status into the status list, at the next empty location.
       
   872             networkStatusList.Append( status );
       
   873             }
       
   874 
       
   875         if ( KErrNone == aIsiMessage.FindSubBlockOffsetByIndex(
       
   876             ISI_HEADER_SIZE + SIZE_NET_MODEM_AVAILABLE_GET_RESP,
       
   877             subBlockIndex,
       
   878             EIsiSubBlockTypeId8Len8,
       
   879             sbStartOffSet ) )
       
   880             {
       
   881             subBlockIndex++;
       
   882             }
       
   883         // No else
       
   884 
       
   885         sbStartOffSet = 0;
       
   886         }
       
   887 
       
   888     // Another loop to get the NET_MODEM_DETAILED_NETWORK_INFO subblocks,
       
   889     // update the iManualSearchNetworkList and iManualSearchDataList
       
   890     // with the new values.
       
   891     for ( TUint8 j = 0; j < amountOfNetworks; j++ )
       
   892         {
       
   893         // SubBlock NET_MODEM_DETAILED_NETWORK_INFO.
       
   894         if ( ( KErrNone == aIsiMessage.FindSubBlockOffsetByIndex(
       
   895             ISI_HEADER_SIZE + SIZE_NET_MODEM_AVAILABLE_GET_RESP,
       
   896             subBlockIndex,
       
   897             EIsiSubBlockTypeId8Len8,
       
   898             sbStartOffSet ) )
       
   899             && ( NET_MODEM_DETAILED_NETWORK_INFO == aIsiMessage.Get8bit(
       
   900             sbStartOffSet +
       
   901             NET_MODEM_DETAILED_NETWORK_INFO_OFFSET_SUBBLOCKID ) )
       
   902             && handlingSuccessful )
       
   903             {
       
   904 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL - NET_MODEM_DETAILED_NETWORK_INFO subblock");
       
   905 OstTrace0( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_HANDLEMANUALSEARCHSUCCESSCASEL, "CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL - NET_MODEM_DETAILED_NETWORK_INFO subblock" );
       
   906             // Set the network status from the networkStatusList created in the
       
   907             // previous loop.
       
   908             entry.iStatus = networkStatusList[j];
       
   909 
       
   910             // Get the operator code.
       
   911             // Length of the operator code is 3 bytes.
       
   912             tempManualSearchDataList.iOperatorCode = aIsiMessage.GetData(
       
   913                 sbStartOffSet +
       
   914                 NET_MODEM_DETAILED_NETWORK_INFO_OFFSET_OPERCODE,
       
   915                 3 );
       
   916 
       
   917             // Map the Operator and country code to symbian values.
       
   918             TBool networkCodeMapped( iNetMessHandler->MapOperatorAndCountryCode(
       
   919                 tempManualSearchDataList.iOperatorCode,
       
   920                 entry.iNetworkId,
       
   921                 entry.iCountryCode ) );
       
   922 
       
   923             // Convert descriptor contained number to integer.
       
   924             CMmStaticUtility::GetIntFromDescriptor(
       
   925                 tempManualSearchDataList.iMCC,
       
   926                 entry.iCountryCode );
       
   927             CMmStaticUtility::GetIntFromDescriptor(
       
   928                 tempManualSearchDataList.iMNC,
       
   929                 entry.iNetworkId );
       
   930 
       
   931             // Get Network type.
       
   932             tempManualSearchDataList.iNetworkType = aIsiMessage.Get8bit(
       
   933                 sbStartOffSet +
       
   934                 NET_MODEM_DETAILED_NETWORK_INFO_OFFSET_NETWORKTYPE );
       
   935 
       
   936             // Get Location Area Code.
       
   937             tempManualSearchDataList.iLocationAreaCode = aIsiMessage.Get16bit(
       
   938                 sbStartOffSet +
       
   939                 NET_MODEM_DETAILED_NETWORK_INFO_OFFSET_CURRENTLAC );
       
   940 
       
   941             // Check if "0" is added at the end of the networkId.
       
   942             if ( networkCodeMapped )
       
   943                 {
       
   944                 // We need to remove Null string from networkId
       
   945                 // to match network code received from NET Server.
       
   946                 // Without this operation in some case network
       
   947                 // can't be selected due the added "extra null".
       
   948                 entry.iNetworkId.Delete(
       
   949                     ( entry.iNetworkId.Length() - 1 ),
       
   950                     1 );
       
   951                 }
       
   952 
       
   953             // Band info.
       
   954             TUint8 band( aIsiMessage.Get8bit(
       
   955                 sbStartOffSet +
       
   956                 NET_MODEM_DETAILED_NETWORK_INFO_OFFSET_BANDINFO ) );
       
   957             // RAT info.
       
   958             TUint8 rat( aIsiMessage.Get8bit(
       
   959                 sbStartOffSet +
       
   960                 NET_MODEM_DETAILED_NETWORK_INFO_OFFSET_UMTSAVAILABLE ) );
       
   961 
       
   962             // Band info = 900_1800.
       
   963             // Rat info = Umts not available (GSM only).
       
   964             if ( NET_GSM_BAND_900_1800 == band &&
       
   965                 NET_UMTS_NOT_AVAILABLE == rat )
       
   966                 {
       
   967                 entry.iMode = RMobilePhone::ENetworkModeGsm;
       
   968                 entry.iAccess = RMobilePhone::ENetworkAccessGsm;
       
   969                 }
       
   970             // Band info = Not available.
       
   971             // Rat info = Umts available (WCDMA only).
       
   972             else if ( NET_GSM_BAND_INFO_NOT_AVAIL == band &&
       
   973                 NET_UMTS_AVAILABLE == rat )
       
   974                 {
       
   975                 entry.iMode = RMobilePhone::ENetworkModeWcdma;
       
   976                 entry.iAccess = RMobilePhone::ENetworkAccessUtran;
       
   977                 }
       
   978             // Band info = 900_1800.
       
   979             // Rat info = Umts available (GSM+WCDMA).
       
   980             else if ( NET_GSM_BAND_900_1800 == band &&
       
   981                 NET_UMTS_AVAILABLE == rat )
       
   982                 {
       
   983                 // Add only the WCDMA network
       
   984                 entry.iMode = RMobilePhone::ENetworkModeWcdma;
       
   985                 entry.iAccess = RMobilePhone::ENetworkAccessUtran;
       
   986                 }
       
   987 
       
   988 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL, MCC: %d", tempManualSearchDataList.iMCC);
       
   989 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL, MNC: %d", tempManualSearchDataList.iMNC);
       
   990 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL, LocationAreaCode: %d", tempManualSearchDataList.iLocationAreaCode);
       
   991 OstTrace1( TRACE_NORMAL, DUP4_CMMNETOPERATORNAMEHANDLER_HANDLEMANUALSEARCHSUCCESSCASEL, "CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL; MCC=%u", tempManualSearchDataList.iMCC );
       
   992 OstTrace1( TRACE_NORMAL, DUP5_CMMNETOPERATORNAMEHANDLER_HANDLEMANUALSEARCHSUCCESSCASEL, "CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL; MNC=%u", tempManualSearchDataList.iMNC );
       
   993 OstTrace1( TRACE_NORMAL, DUP6_CMMNETOPERATORNAMEHANDLER_HANDLEMANUALSEARCHSUCCESSCASEL, "CMmNetOperatorNameHandler::HandleManualSearchSuccessCaseL; LocationAreaCode=%u", tempManualSearchDataList.iLocationAreaCode );
       
   994 
       
   995             // Add entry to iManualSearchNetworkList array.
       
   996             // Catch possible error in append.
       
   997             TInt errValue1( iManualSearchNetworkList.Append( entry ) );
       
   998             // Add temp manual search data to iManualSearchDataList array.
       
   999             // Catch possible error in append.
       
  1000             TInt errValue2( iManualSearchDataList.Append(
       
  1001                 tempManualSearchDataList ) );
       
  1002 
       
  1003             // Check possible error.
       
  1004             if ( KErrNone != errValue1 || KErrNone != errValue2 )
       
  1005                 {
       
  1006                 // There was error when append data to array.
       
  1007                 // Set handlingSuccessful to false.
       
  1008                 handlingSuccessful = EFalse;
       
  1009 
       
  1010                 // Reset arrays.
       
  1011                 iManualSearchNetworkList.Reset();
       
  1012                 iManualSearchDataList.Reset();
       
  1013                 }
       
  1014 
       
  1015             // Reset the buffers before next loop.
       
  1016             tempManualSearchDataList.iOperatorCode.Zero();
       
  1017             entry.iNetworkId.Zero();
       
  1018             entry.iCountryCode.Zero();
       
  1019             entry.iDisplayTag.Zero();
       
  1020             entry.iLongName.Zero();
       
  1021             entry.iShortName.Zero();
       
  1022             }
       
  1023 
       
  1024         if ( KErrNone == aIsiMessage.FindSubBlockOffsetByIndex(
       
  1025             ISI_HEADER_SIZE + SIZE_NET_MODEM_AVAILABLE_GET_RESP,
       
  1026             subBlockIndex,
       
  1027             EIsiSubBlockTypeId8Len8,
       
  1028             sbStartOffSet ) )
       
  1029             {
       
  1030             subBlockIndex++;
       
  1031             }
       
  1032         // No else.
       
  1033 
       
  1034         sbStartOffSet = 0;
       
  1035         }
       
  1036 
       
  1037     // networkStatusList is not needed anymore.
       
  1038     networkStatusList.Reset();
       
  1039     networkStatusList.Close();
       
  1040 
       
  1041     // Is handling successful.
       
  1042     if ( handlingSuccessful )
       
  1043         {
       
  1044         // Start index value for manual search network list.
       
  1045         iManualSearchIndexValue = 0;
       
  1046 
       
  1047         // Get Operator names to all networks.
       
  1048         // EMobilePhoneGetDetectedNetworksV2Phase1 will be completed after
       
  1049         // Network names are handled.
       
  1050         GetManualSearchOperatorNameL();
       
  1051         }
       
  1052     else
       
  1053         {
       
  1054         // There was error when append data to array,
       
  1055         // continue to complete.
       
  1056         CompleteMobilePhoneGetDetectedNetworksV2Phase1L();
       
  1057         }
       
  1058     }
       
  1059 
       
  1060 // -----------------------------------------------------------------------------
       
  1061 // CMmNetOperatorNameHandler::GetManualSearchOperatorNameL
       
  1062 // Gets correct Operator name in manual search.
       
  1063 // -----------------------------------------------------------------------------
       
  1064 //
       
  1065 void CMmNetOperatorNameHandler::GetManualSearchOperatorNameL()
       
  1066     {
       
  1067 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL");
       
  1068 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL" );
       
  1069 
       
  1070     // Amount of networks to be checked.
       
  1071     TUint8 amountOfNetworks( iManualSearchNetworkList.Count() );
       
  1072 
       
  1073 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - amount of networks: %d", amountOfNetworks);
       
  1074 OstTraceExt1( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - amount of networks=%hhu", amountOfNetworks );
       
  1075 
       
  1076     // Temporaly network name data.
       
  1077     RMobilePhone::TMobilePhoneNetworkInfoV5 networkName;
       
  1078     // Temporaly location area data.
       
  1079     RMobilePhone::TMobilePhoneLocationAreaV1 locationArea;
       
  1080     // Buffer for Display tag.
       
  1081     TBuf<KDisplayTagLength> tempDisplayTag;
       
  1082     // Initialize value for completing.
       
  1083     TBool completeNow( ETrue );
       
  1084     // Setting EFalse first.
       
  1085     // This will be ETrue when all found networks are handled.
       
  1086     TBool allNetworksInManualSearchHandled( EFalse );
       
  1087 
       
  1088     // Check every network and update operator names.
       
  1089     // If EONS name needed, then handling of iManualSearchNetworkList
       
  1090     // continues after PNN record has read and handled.
       
  1091     while ( ( iManualSearchIndexValue < amountOfNetworks )
       
  1092         && completeNow )
       
  1093         {
       
  1094 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Index value: %d", iManualSearchIndexValue);
       
  1095 OstTraceExt1( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Index value=%hhu", iManualSearchIndexValue );
       
  1096 
       
  1097         // Hard coded name type.
       
  1098         TInt hardCodedNameType( ENetNameNotSet );
       
  1099         // PNN record number.
       
  1100         TUint8 tempPnnIdentifier( 0 );
       
  1101 
       
  1102         // Country Code and Network Code.
       
  1103         TUint mcc( iManualSearchDataList[iManualSearchIndexValue].iMCC );
       
  1104         TUint mnc( iManualSearchDataList[iManualSearchIndexValue].iMNC );
       
  1105         // Network Type.
       
  1106         TUint8 networkType(
       
  1107             iManualSearchDataList[iManualSearchIndexValue].iNetworkType );
       
  1108         // Location Area Code.
       
  1109         TUint locationAreaCode(
       
  1110             iManualSearchDataList[iManualSearchIndexValue].iLocationAreaCode );
       
  1111         // Operator code in BCD format.
       
  1112         TBuf8<KBCDLength> operatorCode(
       
  1113             iManualSearchDataList[iManualSearchIndexValue].iOperatorCode );
       
  1114 
       
  1115 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL, MCC: %d", mcc);
       
  1116 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL, MNC: %d", mnc);
       
  1117 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL, LocationAreaCode: %d", locationAreaCode);
       
  1118 OstTrace1( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL; MCC=%u", mcc );
       
  1119 OstTrace1( TRACE_NORMAL, DUP4_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL; MNC=%u", mnc );
       
  1120 OstTrace1( TRACE_NORMAL, DUP5_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL; LocationAreaCode=%u", locationAreaCode );
       
  1121 
       
  1122         // Starting to get Network name in priority order.
       
  1123         //
       
  1124         // Get Hard coded name from operators.h
       
  1125         hardCodedNameType = TOperatorNames::GetName(
       
  1126             mcc,
       
  1127             mnc,
       
  1128             tempDisplayTag );
       
  1129 
       
  1130         // Handle ONS and Hard coded name.
       
  1131         HandleOnsAndHardCodedName(
       
  1132             networkType,
       
  1133             hardCodedNameType,
       
  1134             tempDisplayTag,
       
  1135             networkName );
       
  1136 
       
  1137         // Copy iDisplayTag to correct index.
       
  1138         iManualSearchNetworkList[iManualSearchIndexValue].iDisplayTag.Copy(
       
  1139             networkName.iDisplayTag );
       
  1140 
       
  1141         // Copy location area code to temporaly location area data.
       
  1142         locationArea.iLocationAreaCode = locationAreaCode;
       
  1143 
       
  1144         // Check PP bit INFO_PP_EONS_FEAT value impact to PNN record
       
  1145         // when registered to HPLMN.
       
  1146         if ( NET_GSM_HOME_PLMN == networkType )
       
  1147             {
       
  1148 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Registered to HPLMN");
       
  1149 OstTrace0( TRACE_NORMAL, DUP6_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Registered to HPLMN" );
       
  1150             // Handle PP bit values.
       
  1151             tempPnnIdentifier = HandlePnnRecordWithPPbitValueInHplmn(
       
  1152                 operatorCode,
       
  1153                 locationAreaCode );
       
  1154 
       
  1155             // Is there PNN record to read.
       
  1156             if ( KNetNoHplmnPnnRecordNumber != tempPnnIdentifier )
       
  1157                 {
       
  1158                 // If matching PNN record is not stored in internal memory
       
  1159                 // it will be read from SIM.
       
  1160 
       
  1161                 // Check if matching PNN record is same than stored
       
  1162                 // PNN record number.
       
  1163                 if ( iEonsName.iPNNIdentifier == tempPnnIdentifier )
       
  1164                     {
       
  1165 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - PNN Record is read earlier");
       
  1166 OstTrace0( TRACE_NORMAL, DUP7_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - PNN Record is read earlier" );
       
  1167                     // Matching PNN record has read earlier from SIM,
       
  1168                     // no need to read again.
       
  1169                     // Copy EONS names.
       
  1170                     CopyEonsName( networkName );
       
  1171                     }
       
  1172                 else
       
  1173                     {
       
  1174 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - PNN Record not read earlier");
       
  1175 OstTrace0( TRACE_NORMAL, DUP8_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - PNN Record not read earlier" );
       
  1176                     // Setting iFromGetManualSearchOperatorName flag to
       
  1177                     // ETrue as SimOperatorReqReadPnn request is sended
       
  1178                     // from GetManualSearchOperatorName method.
       
  1179                     // This flag is needed to handle correct IPC value.
       
  1180                     iFromGetManualSearchOperatorName = ETrue;
       
  1181 
       
  1182                     // Set EFalse as completing will be done after
       
  1183                     // SimOperatorRespReadPnn message is handled.
       
  1184                     // completeNow = EFalse;
       
  1185                     }
       
  1186                 }
       
  1187             // No else.
       
  1188             }
       
  1189         else
       
  1190             {
       
  1191 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Not registered to HPLMN");
       
  1192 OstTrace0( TRACE_NORMAL, DUP9_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Not registered to HPLMN" );
       
  1193             // OPL rules are read and list available.
       
  1194             if ( iOplRulesRead && iOplListAvailable )
       
  1195                 {
       
  1196 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - OPL Rules handling");
       
  1197 OstTrace0( TRACE_NORMAL, DUP10_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - OPL Rules handling" );
       
  1198                 // EONS name consists of OPL rule and PNN record. One OPL rule consist
       
  1199                 // of PLMN code, LAC range and PNN record number. OPL rules are read
       
  1200                 // from SIM when EMmTsyBootNotifySimStatusReadyIPC is completed and
       
  1201                 // when refresh happens.
       
  1202                 //
       
  1203                 // Note: BCD value of 'D' in any of the MCC and/or MNC digits shall be
       
  1204                 // used to indicate a "wild" value for that corresponding MCC/MNC digit
       
  1205                 // (spec 31.102/4.2.59).
       
  1206                 tempPnnIdentifier = OplRulesChecker(
       
  1207                     operatorCode,
       
  1208                     locationAreaCode );
       
  1209 
       
  1210                 // Is match found from OPL list.
       
  1211                 if ( iOplRuleMatch )
       
  1212                     {
       
  1213 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - OPL Rules match");
       
  1214 OstTrace0( TRACE_NORMAL, DUP11_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - OPL Rules match" );
       
  1215                     // OPL rule exist for current network.
       
  1216                     //
       
  1217                     // If matching PNN record is not stored in internal memory
       
  1218                     // it will be read from SIM.
       
  1219 
       
  1220                     // Check if matching PNN record is same than stored
       
  1221                     // PNN record number.
       
  1222                     if ( iEonsName.iPNNIdentifier == tempPnnIdentifier )
       
  1223                         {
       
  1224 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - PNN Record is read earlier");
       
  1225 OstTrace0( TRACE_NORMAL, DUP12_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - PNN Record is read earlier" );
       
  1226                         // Matching PNN record has read earlier from SIM,
       
  1227                         // no need to read again.
       
  1228                         // Copy EONS names.
       
  1229                         CopyEonsName( networkName );
       
  1230                         }
       
  1231                     else
       
  1232                         {
       
  1233 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - PNN Record not read earlier");
       
  1234 OstTrace0( TRACE_NORMAL, DUP13_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - PNN Record not read earlier" );
       
  1235                         // Setting iFromGetManualSearchOperatorName flag to
       
  1236                         // ETrue as SimOperatorReqReadPnn request is sended
       
  1237                         // from GetManualSearchOperatorName method.
       
  1238                         // This flag is needed to handle correct IPC value.
       
  1239                         iFromGetManualSearchOperatorName = ETrue;
       
  1240 
       
  1241                         // Set EFalse as completing will be done after
       
  1242                         // SimOperatorRespReadPnn message is handled.
       
  1243                         // completeNow = EFalse;
       
  1244                         }
       
  1245                     }
       
  1246                 // No else.
       
  1247                 }
       
  1248             // No else.
       
  1249             }
       
  1250 
       
  1251         // EONS name will be added here if exist and if didn't needed
       
  1252         // to read PNN record.
       
  1253         // If EONS name didn't exist DisplayTag will copied
       
  1254         // to long and short name buffers.
       
  1255         if ( completeNow )
       
  1256             {
       
  1257             // Check is EONS Long name exist.
       
  1258             // If no Long EONS name there is no short EONS name either.
       
  1259             if ( 0 < networkName.iLongName.Length() )
       
  1260                 {
       
  1261 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - EONS name available");
       
  1262 OstTrace0( TRACE_NORMAL, DUP14_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - EONS name available" );
       
  1263                 // Copy EONS Long name to correct index.
       
  1264                 iManualSearchNetworkList[iManualSearchIndexValue].iLongName.Copy(
       
  1265                     networkName.iLongName );
       
  1266 
       
  1267                 // Check is EONS Short name exist.
       
  1268                 if ( 0 < networkName.iShortName.Length() )
       
  1269                     {
       
  1270                     // Copy EONS Short name to correct index.
       
  1271                     iManualSearchNetworkList[iManualSearchIndexValue].iShortName.Copy(
       
  1272                         networkName.iShortName );
       
  1273                     }
       
  1274                 }
       
  1275             else
       
  1276                 {
       
  1277 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - No EONS name available, DisplayTag name added to Long and Short names");
       
  1278 OstTrace0( TRACE_NORMAL, DUP15_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - No EONS name available, DisplayTag name added to Long and Short names" );
       
  1279                 // If no EONS name, copy DisplayTag to long and short name buffers.
       
  1280                 networkName.iLongName.Copy(
       
  1281                     networkName.iDisplayTag.Left(
       
  1282                     networkName.iLongName.MaxLength() ) );
       
  1283                 networkName.iShortName.Copy(
       
  1284                     networkName.iDisplayTag.Left(
       
  1285                     networkName.iShortName.MaxLength() ) );
       
  1286 
       
  1287                 iManualSearchNetworkList[iManualSearchIndexValue].iLongName.Copy(
       
  1288                     networkName.iLongName );
       
  1289                 iManualSearchNetworkList[iManualSearchIndexValue].iShortName.Copy(
       
  1290                     networkName.iShortName );
       
  1291                 }
       
  1292 
       
  1293 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Operator display tag: %S", &networkName.iDisplayTag);
       
  1294 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Operator long name: %S", &networkName.iLongName);
       
  1295 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Operator short name: %S", &networkName.iShortName);
       
  1296 OstTraceExt1( TRACE_NORMAL, DUP16_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Operator display tag=%S", networkName.iDisplayTag );
       
  1297 OstTraceExt1( TRACE_NORMAL, DUP17_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Operator long name=%S", networkName.iLongName );
       
  1298 OstTraceExt1( TRACE_NORMAL, DUP18_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Operator short name=%S", networkName.iShortName );
       
  1299 
       
  1300             // Update index value.
       
  1301             iManualSearchIndexValue++;
       
  1302             }
       
  1303 
       
  1304         // Reset the buffers before next loop.
       
  1305         networkName.iDisplayTag.Zero();
       
  1306         networkName.iLongName.Zero();
       
  1307         networkName.iShortName.Zero();
       
  1308         } // End of while
       
  1309 
       
  1310     // Check is all found network handled.
       
  1311     if ( iManualSearchIndexValue == amountOfNetworks )
       
  1312         {
       
  1313 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - All found Networks are handled");
       
  1314 OstTrace0( TRACE_NORMAL, DUP19_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - All found Networks are handled" );
       
  1315         // All found networks are handled.
       
  1316         allNetworksInManualSearchHandled = ETrue;
       
  1317         }
       
  1318 
       
  1319     // All networks found in manual search is now handled.
       
  1320     // Continue to completing.
       
  1321     if ( allNetworksInManualSearchHandled && completeNow )
       
  1322         {
       
  1323 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Completing");
       
  1324 OstTrace0( TRACE_NORMAL, DUP20_CMMNETOPERATORNAMEHANDLER_GETMANUALSEARCHOPERATORNAMEL, "CMmNetOperatorNameHandler::GetManualSearchOperatorNameL - Completing" );
       
  1325 
       
  1326         // Complete.
       
  1327         CompleteMobilePhoneGetDetectedNetworksV2Phase1L();
       
  1328         }
       
  1329     }
       
  1330 
       
  1331 // -----------------------------------------------------------------------------
       
  1332 // CMmNetOperatorNameHandler::InfoPpReadReq
       
  1333 // Creates Product Profile request to read INFO_PP_EONS_FEAT bit.
       
  1334 // -----------------------------------------------------------------------------
       
  1335 //
       
  1336 void CMmNetOperatorNameHandler::InfoPpReadReq()
       
  1337     {
       
  1338 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::InfoPpReadReq");
       
  1339 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_INFOPPREADREQ, "CMmNetOperatorNameHandler::InfoPpReadReq" );
       
  1340 
       
  1341 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
  1342 // TO BE DONE WITH INFO_PP_DATA_READ_REQ
       
  1343     // Construct INFO_PP_READ_REQ message.
       
  1344     // Data length is INFO_BATCH_TYPE + sub block count + INFO_SB_PP sub block.
       
  1345     TBuf8<2 + SIZE_INFO_SB_PP> infoPpReadReqData;
       
  1346 
       
  1347     // Set PP Batch Reading to read specific product profile.
       
  1348     infoPpReadReqData.Append( INFO_PP_PROD_PROFILE_FEATURE );
       
  1349 
       
  1350     // Add number of sub blocks.
       
  1351     infoPpReadReqData.Append( 1 );
       
  1352 
       
  1353     // Create INFO_SB_PP sub block.
       
  1354     TIsiSubBlock sbPPSubBlock(
       
  1355         infoPpReadReqData,
       
  1356         INFO_SB_PP,
       
  1357         EIsiSubBlockTypeId8Len8 );
       
  1358 
       
  1359     // Add 0x00 as the Dynamic Value ID, used to read a static value.
       
  1360     infoPpReadReqData.Append( 0x00 );
       
  1361 
       
  1362     // Add 0x01 as the length of the product profile, reading only one profile.
       
  1363     infoPpReadReqData.Append( 0x01 );
       
  1364 
       
  1365     // Add the product profile feature number being requested.
       
  1366     infoPpReadReqData.Append( INFO_PP_EONS_FEAT );
       
  1367 
       
  1368     // Value of the product profile is 0x00, since reading.
       
  1369     infoPpReadReqData.Append( 0x00 );
       
  1370 
       
  1371     // Complete sub block and append to INFO_PP_READ_REQ.
       
  1372     sbPPSubBlock.CompleteSubBlock();
       
  1373 
       
  1374     // Sending message to phonet.
       
  1375     iNetMessHandler->GetPhoNetSender()->Send(
       
  1376         PN_INFO,
       
  1377         KNetTransId,
       
  1378         INFO_PP_READ_REQ,
       
  1379         infoPpReadReqData );
       
  1380 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
  1381     }
       
  1382 
       
  1383 // -----------------------------------------------------------------------------
       
  1384 // CMmNetOperatorNameHandler::InfoPpReadResp
       
  1385 // Breaks a INFO_PP_READ_RESP ISI-message.
       
  1386 // Gets the status of the INFO_PP_EONS_FEAT values. This value affects to
       
  1387 // deciding of used PNN record number for given PLMN and LAC.
       
  1388 // -----------------------------------------------------------------------------
       
  1389 //
       
  1390 void CMmNetOperatorNameHandler::InfoPpReadResp
       
  1391         (
       
  1392         const TIsiReceiveC& aIsiMessage
       
  1393         )
       
  1394     {
       
  1395     // Get status.
       
  1396 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
  1397 // TO BE DONE WITH INFO_PP_DATA_READ_RESP  
       
  1398     TUint8 status( aIsiMessage.Get8bit(
       
  1399         ISI_HEADER_SIZE + INFO_PP_READ_RESP_OFFSET_STATUS ) );
       
  1400 
       
  1401 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::InfoPpReadResp - Status: %d", status);
       
  1402 OstTraceExt1( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_INFOPPREADRESP, "CMmNetOperatorNameHandler::InfoPpReadResp;status=%hhu", status );
       
  1403 
       
  1404     if ( INFO_OK == status )
       
  1405         {
       
  1406         TUint sbStartOffSet( 0 );
       
  1407 
       
  1408         if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  1409             ISI_HEADER_SIZE + SIZE_INFO_PP_READ_RESP,
       
  1410             INFO_SB_PP,
       
  1411             EIsiSubBlockTypeId8Len8,
       
  1412             sbStartOffSet ) )
       
  1413             {
       
  1414             TInt lengthOfPp( aIsiMessage.Get8bit(
       
  1415                 sbStartOffSet + INFO_SB_PP_OFFSET_STRLEN ) );
       
  1416 
       
  1417             if ( lengthOfPp )
       
  1418                 {
       
  1419                 // Buffer to hold product profile feature and its
       
  1420                 // corresponding value, thus buffer size is 2.
       
  1421                 TBuf8<2> pPFeatures;
       
  1422 
       
  1423                 // Copy bytes from product profile:
       
  1424                 // 1st byte = PP Feature
       
  1425                 // 2nd byte = PP Value
       
  1426                 pPFeatures.Copy( aIsiMessage.GetData(
       
  1427                     sbStartOffSet + INFO_SB_PP_OFFSET_PRODUCTPROFILE,
       
  1428                     2 ) );
       
  1429 
       
  1430                 // Check that product profile is requested one.
       
  1431                 if ( INFO_PP_EONS_FEAT == pPFeatures[0] )
       
  1432                     {
       
  1433                     // Get the value of used PNN record number configuration.
       
  1434                     if ( INFO_PP_EONS_FEAT_0 == pPFeatures[1] )
       
  1435                         {
       
  1436 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::InfoPpReadResp - PP Value - INFO_PP_EONS_FEAT_0");
       
  1437 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_INFOPPREADRESP, "CMmNetOperatorNameHandler::InfoPpReadResp - PP Value - INFO_PP_EONS_FEAT_0" );
       
  1438                         // Phone will always assume that there is a name
       
  1439                         // for HPLMN in PNN#1 (in PNN record number one),
       
  1440                         // without checking rules from EF-OPL first.
       
  1441                         iInfoPpEonsFeatValue = INFO_PP_EONS_FEAT_0;
       
  1442                         }
       
  1443                     else if ( INFO_PP_EONS_FEAT_1 == pPFeatures[1] )
       
  1444                         {
       
  1445 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::InfoPpReadResp - PP Value - INFO_PP_EONS_FEAT_1");
       
  1446 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_INFOPPREADRESP, "CMmNetOperatorNameHandler::InfoPpReadResp - PP Value - INFO_PP_EONS_FEAT_1" );
       
  1447                         // Phone will go through rules from OPL even when
       
  1448                         // in service in HPLMN, if rule for HPLMN is not
       
  1449                         // found from OPL, then it assumes that PNN#1
       
  1450                         // is reserved to HPLMN.
       
  1451                         iInfoPpEonsFeatValue = INFO_PP_EONS_FEAT_1;
       
  1452                         }
       
  1453                     else if ( INFO_PP_EONS_FEAT_2 == pPFeatures[1] )
       
  1454                         {
       
  1455 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::InfoPpReadResp - PP Value - INFO_PP_EONS_FEAT_2");
       
  1456 OstTrace0( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_INFOPPREADRESP, "CMmNetOperatorNameHandler::InfoPpReadResp - PP Value - INFO_PP_EONS_FEAT_2" );
       
  1457                         // Phone will never assume that there is a name
       
  1458                         // for HPLMN in PNN#1. It will show EONS name for
       
  1459                         // HPLMN only when it is found from EF-OPL, except
       
  1460                         // when EF-OPL does not exist at all.
       
  1461                         iInfoPpEonsFeatValue = INFO_PP_EONS_FEAT_2;
       
  1462                         }
       
  1463                     else if ( INFO_PP_EONS_FEAT_3 == pPFeatures[1] )
       
  1464                         {
       
  1465 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::InfoPpReadResp - PP Value - INFO_PP_EONS_FEAT_3");
       
  1466 OstTrace0( TRACE_NORMAL, DUP4_CMMNETOPERATORNAMEHANDLER_INFOPPREADRESP, "CMmNetOperatorNameHandler::InfoPpReadResp - PP Value - INFO_PP_EONS_FEAT_3" );
       
  1467                         // Phone will never assume that there is a name
       
  1468                         // for HPLMN in PNN#1. It will show EONS name for
       
  1469                         // HPLMN only when it is found from EF-OPL, except
       
  1470                         // when EF-OPL does not exist at all or when only
       
  1471                         // one PNN record exists in the card.
       
  1472                         iInfoPpEonsFeatValue = INFO_PP_EONS_FEAT_3;
       
  1473                         }
       
  1474                     }
       
  1475                 }
       
  1476             }
       
  1477         }
       
  1478 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
  1479     }
       
  1480 
       
  1481 
       
  1482 // -----------------------------------------------------------------------------
       
  1483 // CMmNetOperatorNameHandler::PermPmRecordWriteReq
       
  1484 // Creates PERM_PM_RECORD_WRITE_REQ ISI message and sends it through phonet.
       
  1485 // This request is used to write NITZ data to PMM.
       
  1486 // -----------------------------------------------------------------------------
       
  1487 //
       
  1488 void CMmNetOperatorNameHandler::PermPmRecordWriteReq()
       
  1489     {
       
  1490 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::PermPmRecordWriteReq");
       
  1491 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_PERMPMRECORDWRITEREQ, "CMmNetOperatorNameHandler::PermPmRecordWriteReq" );
       
  1492 
       
  1493     // Temporaly buffers for names.
       
  1494     RMobilePhone::TMobilePhoneNetworkLongName tempLongName;
       
  1495     RMobilePhone::TMobilePhoneNetworkShortName tempShortName;
       
  1496 
       
  1497     // Create message data buffer (72 bytes) for
       
  1498     // - Group ID (2 bytes),
       
  1499     // - Index (2 bytes),
       
  1500     // - Filler (1 bytes),
       
  1501     // - Filler (1 bytes),
       
  1502     // - Size of Data (4 bytes),
       
  1503     // - Data ( NITZ data: MCC, MNC, Long name and Short name (64 bytes) ).
       
  1504     TBuf8<KPmmDataLengthWriteReq> messageData;
       
  1505 
       
  1506     // Append Group ID.
       
  1507     messageData.Append( static_cast<TUint8>( KPmmGroupNokiaTsy >> 8 ) );
       
  1508     messageData.Append( static_cast<TUint8>( KPmmGroupNokiaTsy ) );
       
  1509     // Append Index. NITZ name use first index, value is "0".
       
  1510     messageData.Append( static_cast<TUint8>( KNitzNamePmmIndexValue >> 8 ) );
       
  1511     messageData.Append( static_cast<TUint8>( KNitzNamePmmIndexValue ) );
       
  1512     // Filler.
       
  1513     messageData.Append( KNetPadding );
       
  1514     // Filler.
       
  1515     messageData.Append( KNetPadding );
       
  1516     // Append Size of Data.
       
  1517     messageData.Append( static_cast<TUint8>( KNitzPmmDataLength >> 24 ) );
       
  1518     messageData.Append( static_cast<TUint8>( KNitzPmmDataLength >> 16 ) );
       
  1519     messageData.Append( static_cast<TUint8>( KNitzPmmDataLength >> 8 ) );
       
  1520     messageData.Append( static_cast<TUint8>( KNitzPmmDataLength ) );
       
  1521     // Append NITZ Data.
       
  1522     // - MCC (2 bytes).
       
  1523     messageData.Append( static_cast<TUint8>( iNitzNamePmm.iMCC >> 8 ) );
       
  1524     messageData.Append( static_cast<TUint8>( iNitzNamePmm.iMCC ) );
       
  1525     // - MNC (2 bytes).
       
  1526     messageData.Append( static_cast<TUint8>( iNitzNamePmm.iMNC >> 8 ) );
       
  1527     messageData.Append( static_cast<TUint8>( iNitzNamePmm.iMNC ) );
       
  1528     // - Long name (40 bytes).
       
  1529     //
       
  1530     // Copy long name to temp buffer.
       
  1531     tempLongName.Copy( iNitzNamePmm.iLongName );
       
  1532     // Check long name length and fill temp name until max length.
       
  1533     TUint16 zeroValue( 0 );
       
  1534     while ( tempLongName.MaxLength() > tempLongName.Length() )
       
  1535         {
       
  1536         // Fill with zero.
       
  1537         tempLongName.Append( zeroValue );
       
  1538         }
       
  1539     // Append long name.
       
  1540     for ( TInt i = 0; i < tempLongName.MaxLength(); i++ )
       
  1541         {
       
  1542         messageData.Append( static_cast<TUint8>( tempLongName[i] >> 8 ) );
       
  1543         messageData.Append( static_cast<TUint8>( tempLongName[i] ) );
       
  1544         }
       
  1545     // - Short name (20 Bytes).
       
  1546     //
       
  1547     // Copy short name to temp buffer.
       
  1548     tempShortName.Copy( iNitzNamePmm.iShortName );
       
  1549     // Check short name length and fill temp name until max length.
       
  1550     while ( tempShortName.MaxLength() > tempShortName.Length() )
       
  1551         {
       
  1552         // Fill with zero.
       
  1553         tempShortName.Append( zeroValue );
       
  1554         }
       
  1555     // Append short name.
       
  1556     for ( TInt i = 0; i < tempShortName.MaxLength(); i++ )
       
  1557         {
       
  1558         messageData.Append( static_cast<TUint8>( tempShortName[i] >> 8 ) );
       
  1559         messageData.Append( static_cast<TUint8>( tempShortName[i] ) );
       
  1560         }
       
  1561 
       
  1562     // Sending message to phonet.
       
  1563     /* To be done in CPS
       
  1564     iNetMessHandler->GetPhoNetSender()->Send(
       
  1565         PN_PERMANENT_DATA,
       
  1566         KNetTransId,
       
  1567         PERM_PM_RECORD_WRITE_REQ,
       
  1568         messageData );*/
       
  1569     }
       
  1570 
       
  1571 // -----------------------------------------------------------------------------
       
  1572 // CMmNetOperatorNameHandler::PermPmRecordWriteResp
       
  1573 // Breaks a PERM_PM_RECORD_WRITE_RESP ISI message.
       
  1574 // -----------------------------------------------------------------------------
       
  1575 //
       
  1576 /* To be done in CPS
       
  1577 void CMmNetOperatorNameHandler::PermPmRecordWriteResp
       
  1578         (
       
  1579         const TIsiReceiveC& aIsiMessage
       
  1580         )
       
  1581     {
       
  1582 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::PermPmRecordWriteResp");
       
  1583 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_PERMPMRECORDWRITERESP, "CMmNetOperatorNameHandler::PermPmRecordWriteResp" );
       
  1584 
       
  1585 
       
  1586     TUint8 status( aIsiMessage.Get8bit(
       
  1587         ISI_HEADER_SIZE + PERM_PM_RECORD_WRITE_RESP_OFFSET_PMMSTATUS ) );
       
  1588 
       
  1589     // Check status.
       
  1590     if ( PMM_OK == status )
       
  1591         {
       
  1592         // NITZ data is successfully stored to PMM.
       
  1593 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::PermPmRecordWriteResp - NITZ data successfully stored to PMM");
       
  1594 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_PERMPMRECORDWRITERESP, "CMmNetOperatorNameHandler::PermPmRecordWriteResp - NITZ data successfully stored to PMM" );
       
  1595         }
       
  1596     else
       
  1597         {
       
  1598         // Storing failed.
       
  1599 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::PermPmRecordWriteResp - NITZ data storing failed, error value: %d", status);
       
  1600 OstTraceExt1( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_PERMPMRECORDWRITERESP, "CMmNetOperatorNameHandler::PermPmRecordWriteResp - NITZ data storing failed, error value=%hhu", status );
       
  1601         }
       
  1602     } */
       
  1603 
       
  1604 // -----------------------------------------------------------------------------
       
  1605 // CMmNetOperatorNameHandler::PermPmRecordReadReq
       
  1606 // Creates PERM_PM_RECORD_READ_REQ ISI message and sends it through phonet.
       
  1607 // This request is used to read record for PMM.
       
  1608 // -----------------------------------------------------------------------------
       
  1609 //
       
  1610 void CMmNetOperatorNameHandler::PermPmRecordReadReq()
       
  1611     {
       
  1612 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::PermPmRecordReadReq");
       
  1613 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_PERMPMRECORDREADREQ, "CMmNetOperatorNameHandler::PermPmRecordReadReq" );
       
  1614 
       
  1615     // Create message data buffer (14 bytes) for
       
  1616     // - Group ID (2 bytes),
       
  1617     // - Index (2 bytes),
       
  1618     // - Filler (1 bytes),
       
  1619     // - Filler (1 bytes),
       
  1620     // - Offset (4 bytes),
       
  1621     // - Data amount to be read (4 bytes).
       
  1622     TBuf8<KPmmDataLengthReadReq> messageData;
       
  1623 
       
  1624     // Append Group ID.
       
  1625     messageData.Append( static_cast<TUint8>( KPmmGroupNokiaTsy >> 8 ) );
       
  1626     messageData.Append( static_cast<TUint8>( KPmmGroupNokiaTsy ) );
       
  1627     // Append Index. NITZ name use first index, value is "0".
       
  1628     messageData.Append( static_cast<TUint8>( KNitzNamePmmIndexValue >> 8 ) );
       
  1629     messageData.Append( static_cast<TUint8>( KNitzNamePmmIndexValue ) );
       
  1630     // Filler.
       
  1631     messageData.Append( KNetPadding );
       
  1632     // Filler.
       
  1633     messageData.Append( KNetPadding );
       
  1634     // Append Offset.
       
  1635     messageData.Append( static_cast<TUint8>( KNitzPmmDataOffset >> 24 ) );
       
  1636     messageData.Append( static_cast<TUint8>( KNitzPmmDataOffset >> 16 ) );
       
  1637     messageData.Append( static_cast<TUint8>( KNitzPmmDataOffset >> 8 ) );
       
  1638     messageData.Append( static_cast<TUint8>( KNitzPmmDataOffset ) );
       
  1639     // Append Data amount to be read.
       
  1640     messageData.Append( static_cast<TUint8>( KNitzPmmDataLength >> 24 ) );
       
  1641     messageData.Append( static_cast<TUint8>( KNitzPmmDataLength >> 16 ) );
       
  1642     messageData.Append( static_cast<TUint8>( KNitzPmmDataLength >> 8 ) );
       
  1643     messageData.Append( static_cast<TUint8>( KNitzPmmDataLength ) );
       
  1644 
       
  1645     // Sending message to phonet.
       
  1646     /* To be done in CPS
       
  1647     iNetMessHandler->GetPhoNetSender()->Send(
       
  1648         PN_PERMANENT_DATA,
       
  1649         KNetTransId,
       
  1650         PERM_PM_RECORD_READ_REQ,
       
  1651         messageData );*/
       
  1652     }
       
  1653 
       
  1654 // -----------------------------------------------------------------------------
       
  1655 // CMmNetOperatorNameHandler::PermPmRecordReadResp
       
  1656 // Breaks a PERM_PM_RECORD_READ_RESP ISI message.
       
  1657 // -----------------------------------------------------------------------------
       
  1658 //
       
  1659 /* To be done in CPS
       
  1660 void CMmNetOperatorNameHandler::PermPmRecordReadResp
       
  1661         (
       
  1662         const TIsiReceiveC& aIsiMessage
       
  1663         )
       
  1664     {
       
  1665 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::PermPmRecordReadResp");
       
  1666 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_PERMPMRECORDREADRESP, "CMmNetOperatorNameHandler::PermPmRecordReadResp" );
       
  1667 
       
  1668     TUint8 status( aIsiMessage.Get8bit(
       
  1669         ISI_HEADER_SIZE + PERM_PM_RECORD_READ_RESP_OFFSET_PMMSTATUS ) );
       
  1670 
       
  1671     // Check status.
       
  1672     if ( PMM_OK == status )
       
  1673         {
       
  1674         // NITZ data is successfully read from PMM.
       
  1675 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::PermPmRecordReadResp - NITZ data successfully read from PMM");
       
  1676 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_PERMPMRECORDREADRESP, "CMmNetOperatorNameHandler::PermPmRecordReadResp - NITZ data successfully read from PMM" );
       
  1677 
       
  1678         // NITZ data buffer has room for:
       
  1679         // - MCC, MNC, Long name and Short name ( 64 bytes ).
       
  1680         TBuf8<KNitzPmmDataLength> readNitzData;
       
  1681 
       
  1682         // Temp Buffers.
       
  1683         TBuf8<KNitzPmmLongNamelength8Bit> tempLongName8Bit;
       
  1684         TBuf8<KNitzPmmShortNameLength8Bit> tempShortName8Bit;
       
  1685 
       
  1686         TUint16 byte1( 0 );
       
  1687         TUint16 byte2( 0 );
       
  1688 
       
  1689         // Mobile Country Code.
       
  1690         TUint tempMCC( 0 );
       
  1691         // Mobile Network Code.
       
  1692         TUint tempMNC( 0 );
       
  1693         // Long Name.
       
  1694         RMobilePhone::TMobilePhoneNetworkLongName tempLongName;
       
  1695         // Short Name.
       
  1696         RMobilePhone::TMobilePhoneNetworkShortName tempShortName;
       
  1697 
       
  1698         TUint sbStartOffSet( 0 );
       
  1699 
       
  1700         // Check PERM_SB_PM_DATA subblock.
       
  1701         if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  1702             ISI_HEADER_SIZE + SIZE_PERM_PM_RECORD_READ_RESP,
       
  1703             PERM_SB_PM_DATA,
       
  1704             EIsiSubBlockTypeId8Len8,
       
  1705             sbStartOffSet ) )
       
  1706             {
       
  1707             // Get data size.
       
  1708             TUint32 nitzPmmDataLength( aIsiMessage.Get32bit(
       
  1709                 sbStartOffSet + PERM_SB_PM_DATA_OFFSET_SIZE ) );
       
  1710 
       
  1711             // Get read NITZ data to temp buffer.
       
  1712             readNitzData = aIsiMessage.GetData(
       
  1713                 sbStartOffSet + PERM_SB_PM_DATA_OFFSET_DATA,
       
  1714                 nitzPmmDataLength );
       
  1715 
       
  1716             // Get Mobile Country Code.
       
  1717             // - Buffer bytes 0-1 includes MCC value.
       
  1718             byte1 = readNitzData[0];
       
  1719             byte2 = readNitzData[1];
       
  1720             tempMCC = TUint16( ( byte1 << 8 ) | byte2 );
       
  1721 
       
  1722             // Get Mobile Network Code.
       
  1723             // - Buffer bytes 2-3 includes MNC value.
       
  1724             byte1 = readNitzData[2];
       
  1725             byte2 = readNitzData[3];
       
  1726             tempMNC = TUint16( ( byte1 << 8 ) | byte2 );
       
  1727 
       
  1728             // Get long name.
       
  1729             // - Buffer bytes 4-43 includes long name.
       
  1730             tempLongName8Bit.Copy( readNitzData.Mid(
       
  1731                 KNitzPmmLongNameOffset,
       
  1732                 KNitzPmmLongNamelength8Bit ) );
       
  1733             // Get short name.
       
  1734             // - Buffer bytes 44-63 includes short name.
       
  1735             tempShortName8Bit.Copy( readNitzData.Mid(
       
  1736                 KNitzPmmShortNameOffset,
       
  1737                 KNitzPmmShortNameLength8Bit ) );
       
  1738             // Convert.
       
  1739             TIsiUtility::CopyFromBigEndian(
       
  1740                 tempLongName8Bit,
       
  1741                 tempLongName );
       
  1742             TIsiUtility::CopyFromBigEndian(
       
  1743                 tempShortName8Bit,
       
  1744                 tempShortName );
       
  1745 
       
  1746             // Check names and strip NULL chars from end if exist.
       
  1747             TInt longNameNullPos( tempLongName.Locate( NULL ) );
       
  1748             if ( KErrNotFound != longNameNullPos )
       
  1749                 {
       
  1750                 tempLongName.SetLength( longNameNullPos );
       
  1751                 }
       
  1752 
       
  1753             TInt shortNameNullPos( tempShortName.Locate( NULL ) );
       
  1754             if ( KErrNotFound != shortNameNullPos )
       
  1755                 {
       
  1756                 tempShortName.SetLength( shortNameNullPos );
       
  1757                 }
       
  1758 
       
  1759             // Copy NITZ data got from PMM.
       
  1760             iNitzNamePmm.iMCC = tempMCC;
       
  1761             iNitzNamePmm.iMNC = tempMNC;
       
  1762             iNitzNamePmm.iLongName.Copy( tempLongName );
       
  1763             iNitzNamePmm.iShortName.Copy( tempShortName );
       
  1764 
       
  1765             // Copy name data to iNitzName struct to keep PMM data in handle.
       
  1766             iNitzName = iNitzNamePmm;
       
  1767             }
       
  1768         }
       
  1769     else
       
  1770         {
       
  1771         // Reading failed. No data stored or other error when reading.
       
  1772 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::PermPmRecordReadResp - NITZ data reading failed from PMM, error value: %d", status);
       
  1773 OstTraceExt1( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_PERMPMRECORDREADRESP, "CMmNetOperatorNameHandler::PermPmRecordReadResp - NITZ data reading failed from PMM, error value=%hhu", status );
       
  1774         }
       
  1775 
       
  1776 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::PermPmRecordReadResp - iNitzNamePmm.iMCC: %d", iNitzNamePmm.iMCC);
       
  1777 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::PermPmRecordReadResp - iNitzNamePmm.iMNC: %d", iNitzNamePmm.iMNC);
       
  1778 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::PermPmRecordReadResp - iNitzNamePmm.iLongName: %S", &iNitzNamePmm.iLongName);
       
  1779 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::PermPmRecordReadResp - iNitzNamePmm.iShortName: %S", &iNitzNamePmm.iShortName);
       
  1780 OstTrace1( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_PERMPMRECORDREADRESP, "CMmNetOperatorNameHandler::PermPmRecordReadResp - iNitzNamePmm.iMCC=%u", iNitzNamePmm.iMCC );
       
  1781 OstTrace1( TRACE_NORMAL, DUP4_CMMNETOPERATORNAMEHANDLER_PERMPMRECORDREADRESP, "CMmNetOperatorNameHandler::PermPmRecordReadResp - iNitzNamePmm.iMNC=%u", iNitzNamePmm.iMNC );
       
  1782 OstTraceExt1( TRACE_NORMAL, DUP5_CMMNETOPERATORNAMEHANDLER_PERMPMRECORDREADRESP, "CMmNetOperatorNameHandler::PermPmRecordReadResp - iNitzNamePmm.iLongName=%S", iNitzNamePmm.iLongName );
       
  1783 OstTraceExt1( TRACE_NORMAL, DUP6_CMMNETOPERATORNAMEHANDLER_PERMPMRECORDREADRESP, "CMmNetOperatorNameHandler::PermPmRecordReadResp - iNitzNamePmm.iShortName=%S", iNitzNamePmm.iShortName );
       
  1784     }*/
       
  1785 
       
  1786 // -----------------------------------------------------------------------------
       
  1787 // CMmNetOperatorNameHandler::HandleOnsAndHardCodedName
       
  1788 // Handles ONS and Hard coded names in priority.
       
  1789 // Add also Operator name info data ( RMmCustomAPI::TOperatorNameInfo ).
       
  1790 // -----------------------------------------------------------------------------
       
  1791 //
       
  1792 void CMmNetOperatorNameHandler::HandleOnsAndHardCodedName
       
  1793         (
       
  1794         TUint8 aNetworkType, // Network type.
       
  1795         TInt aHardCodedNameType, // Hard coded name type.
       
  1796         const TDes& aDisplayTag, // Hard coded operator name.
       
  1797         RMobilePhone::TMobilePhoneNetworkInfoV5& aNetworkName // Network name data.
       
  1798         )
       
  1799     {
       
  1800 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandleOnsAndHardCodedName");
       
  1801 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_HANDLEONSANDHARDCODEDNAME, "CMmNetOperatorNameHandler::HandleOnsAndHardCodedName" );
       
  1802 
       
  1803     // Check ONS name and hard coded names in priority and add then
       
  1804     // correct name to iDisplayTag.
       
  1805     // Add also Operator name info data.
       
  1806     if ( NET_GSM_HOME_PLMN == aNetworkType &&
       
  1807         0 < iOperatorNameString.Length() &&
       
  1808         ENetApacName != aHardCodedNameType )
       
  1809         {
       
  1810 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandleOnsAndHardCodedName - ONS Name added");
       
  1811 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_HANDLEONSANDHARDCODEDNAME, "CMmNetOperatorNameHandler::HandleOnsAndHardCodedName - ONS Name added" );
       
  1812         // ONS (Operator Name String) name is read from SIM when
       
  1813         // EMmTsyBootNotifySimStatusReadyIPC is completed and
       
  1814         // when refresh happens.
       
  1815         //
       
  1816         // ONS name is shown only for home operator.
       
  1817         // ONS name replaces the Latin name if exists.
       
  1818 
       
  1819         // Copy ONS name.
       
  1820         aNetworkName.iDisplayTag.Copy( iOperatorNameString );
       
  1821         // Add Operator name info data.
       
  1822         iOperNameInfo.iType = RMmCustomAPI::EOperatorNameHardcodedLatin;
       
  1823         iOperNameInfo.iName.Copy( iOperatorNameString );
       
  1824         }
       
  1825     else if ( ENetApacName == aHardCodedNameType )
       
  1826         {
       
  1827 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandleOnsAndHardCodedName - Hard coded APAC Name added");
       
  1828 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_HANDLEONSANDHARDCODEDNAME, "CMmNetOperatorNameHandler::HandleOnsAndHardCodedName - Hard coded APAC Name added" );
       
  1829         // Copy Hard coded APAC name.
       
  1830         aNetworkName.iDisplayTag.Copy( aDisplayTag );
       
  1831         // Add Operator name info data.
       
  1832         iOperNameInfo.iType = RMmCustomAPI::EOperatorNameHardcodedUcs2;
       
  1833         iOperNameInfo.iName.Copy( aDisplayTag );
       
  1834         }
       
  1835     else if ( ENetLatinName == aHardCodedNameType )
       
  1836         {
       
  1837 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandleOnsAndHardCodedName - Hard coded Latin Name added");
       
  1838 OstTrace0( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_HANDLEONSANDHARDCODEDNAME, "CMmNetOperatorNameHandler::HandleOnsAndHardCodedName - Hard coded Latin Name added" );
       
  1839         // Copy Hard coded Latin name.
       
  1840         aNetworkName.iDisplayTag.Copy( aDisplayTag );
       
  1841         // Add Operator name info data.
       
  1842         iOperNameInfo.iType = RMmCustomAPI::EOperatorNameHardcodedLatin;
       
  1843         iOperNameInfo.iName.Copy( aDisplayTag );
       
  1844         }
       
  1845     else if ( ENetCountryMncName == aHardCodedNameType )
       
  1846         {
       
  1847 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandleOnsAndHardCodedName - Hard coded CountryMnc Name added");
       
  1848 OstTrace0( TRACE_NORMAL, DUP4_CMMNETOPERATORNAMEHANDLER_HANDLEONSANDHARDCODEDNAME, "CMmNetOperatorNameHandler::HandleOnsAndHardCodedName - Hard coded CountryMnc Name added" );
       
  1849         // Copy Hard coded CountryMnc name.
       
  1850         aNetworkName.iDisplayTag.Copy( aDisplayTag );
       
  1851         // Add Operator name info data.
       
  1852         iOperNameInfo.iType = RMmCustomAPI::EOperatorNameCountryMcn;
       
  1853         iOperNameInfo.iName.Copy( aDisplayTag );
       
  1854         }
       
  1855     else if ( ENetMccMncName == aHardCodedNameType )
       
  1856         {
       
  1857 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandleOnsAndHardCodedName - Hard coded MccMnc Name added");
       
  1858 OstTrace0( TRACE_NORMAL, DUP5_CMMNETOPERATORNAMEHANDLER_HANDLEONSANDHARDCODEDNAME, "CMmNetOperatorNameHandler::HandleOnsAndHardCodedName - Hard coded MccMnc Name added" );
       
  1859         // Copy Hard coded MccMnc name.
       
  1860         aNetworkName.iDisplayTag.Copy( aDisplayTag );
       
  1861         // Add Operator name info data.
       
  1862         iOperNameInfo.iType = RMmCustomAPI::EOperatorNameMccMnc;
       
  1863         iOperNameInfo.iName.Copy( aDisplayTag );
       
  1864         }
       
  1865     // No else
       
  1866     }
       
  1867 
       
  1868 // -----------------------------------------------------------------------------
       
  1869 // CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn
       
  1870 // Handles PNN record number with PP bit INFO_PP_EONS_FEAT value when
       
  1871 // registered in HPLMN.
       
  1872 // -----------------------------------------------------------------------------
       
  1873 //
       
  1874 TInt CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn
       
  1875         (
       
  1876         const TDesC8& aOperatorCodeData, // Operator Code data in BCD format
       
  1877         const TUint& aLacData // Location Area Code data
       
  1878         )
       
  1879     {
       
  1880 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn");
       
  1881 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_HANDLEPNNRECORDWITHPPBITVALUEINHPLMN, "CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn" );
       
  1882 
       
  1883     // Temp PNN record identifier initialization.
       
  1884     TUint8 tempPnnIdentifier( 0 );
       
  1885     // PNN record identifier initialization.
       
  1886     TUint8 pnnHplmnIdentifier( KNetNoHplmnPnnRecordNumber );
       
  1887 
       
  1888     // Check PP bit value.
       
  1889     if ( INFO_PP_EONS_FEAT_0 == iInfoPpEonsFeatValue )
       
  1890         {
       
  1891 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn - PP bit INFO_PP_EONS_FEAT_0");
       
  1892 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_HANDLEPNNRECORDWITHPPBITVALUEINHPLMN, "CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn - PP bit INFO_PP_EONS_FEAT_0" );
       
  1893         // Phone will always assume that there is a name
       
  1894         // for HPLMN in PNN#1 (in PNN record number one),
       
  1895         // without checking rules from EF-OPL first.
       
  1896 
       
  1897         // PNN#1 is reserved for HPLMN.
       
  1898         pnnHplmnIdentifier = KNetHplmnPnnRecordNumber;
       
  1899         }
       
  1900     else
       
  1901         {
       
  1902         // OPL rules are read and list available.
       
  1903         if ( iOplRulesRead && iOplListAvailable )
       
  1904             {
       
  1905 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn - OPL Rules handling");
       
  1906 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_HANDLEPNNRECORDWITHPPBITVALUEINHPLMN, "CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn - OPL Rules handling" );
       
  1907             // EONS name consists of OPL rule and PNN record.
       
  1908             // One OPL rule consist of PLMN code, LAC range
       
  1909             // and PNN record number. OPL rules are read from
       
  1910             // SIM when EMmTsyBootNotifySimStatusReadyIPC is
       
  1911             // completed and when refresh happens.
       
  1912             //
       
  1913             // Note: BCD value of 'D' in any of the MCC and/or
       
  1914             // MNC digits shall be used to indicate a "wild"
       
  1915             // value for that corresponding MCC/MNC digit
       
  1916             // (spec 31.102/4.2.59).
       
  1917 
       
  1918             // Checking is there matching record in OPL list.
       
  1919             tempPnnIdentifier = OplRulesChecker(
       
  1920                 aOperatorCodeData,
       
  1921                 aLacData );
       
  1922             }
       
  1923 
       
  1924         // Check PP bit value.
       
  1925         if ( INFO_PP_EONS_FEAT_1 == iInfoPpEonsFeatValue )
       
  1926             {
       
  1927 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn - PP bit INFO_PP_EONS_FEAT_1");
       
  1928 OstTrace0( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_HANDLEPNNRECORDWITHPPBITVALUEINHPLMN, "CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn - PP bit INFO_PP_EONS_FEAT_1" );
       
  1929             // Phone will go through rules from OPL even when
       
  1930             // in service in HPLMN, if rule for HPLMN is not
       
  1931             // found from OPL, then it assumes that PNN#1
       
  1932             // is reserved to HPLMN.
       
  1933 
       
  1934             // OPL rules are read and list available.
       
  1935             if ( iOplRulesRead && iOplListAvailable )
       
  1936                 {
       
  1937                 // Matching OPL rules not found.
       
  1938                 if ( !iOplRuleMatch )
       
  1939                     {
       
  1940                     // PNN#1 is reserved for HPLMN.
       
  1941                     pnnHplmnIdentifier = KNetHplmnPnnRecordNumber;
       
  1942                     }
       
  1943                 else
       
  1944                     {
       
  1945                     // Matching OPL rule record is PNN record number.
       
  1946                     pnnHplmnIdentifier = tempPnnIdentifier;
       
  1947                     }
       
  1948                 }
       
  1949             else
       
  1950                 {
       
  1951                 // OPL list does not exist.
       
  1952                 // No EONS name in this case.
       
  1953                 pnnHplmnIdentifier = KNetNoHplmnPnnRecordNumber;
       
  1954                 }
       
  1955             }
       
  1956         else if ( INFO_PP_EONS_FEAT_2 == iInfoPpEonsFeatValue )
       
  1957             {
       
  1958 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn - PP bit INFO_PP_EONS_FEAT_2");
       
  1959 OstTrace0( TRACE_NORMAL, DUP4_CMMNETOPERATORNAMEHANDLER_HANDLEPNNRECORDWITHPPBITVALUEINHPLMN, "CMmNetOperatorNameHandler::HandlePnnRecordWithPPbitValueInHplmn - PP bit INFO_PP_EONS_FEAT_2" );
       
  1960             // Phone will never assume that there is a name
       
  1961             // for HPLMN in PNN#1. It will show EONS name for
       
  1962             // HPLMN only when it is found from EF-OPL, except
       
  1963             // when EF-OPL does not exist at all.
       
  1964 
       
  1965             // OPL rules are read and list available.
       
  1966             if ( iOplRulesRead && iOplListAvailable )
       
  1967                 {
       
  1968                 // Matching OPL rule found.
       
  1969                 if ( iOplRuleMatch )
       
  1970                     {
       
  1971                     // Matching OPL rule record is PNN record number.
       
  1972                     pnnHplmnIdentifier = tempPnnIdentifier;
       
  1973                     }
       
  1974                 else
       
  1975                     {
       
  1976                     // No EONS name in this case.
       
  1977                     pnnHplmnIdentifier = KNetNoHplmnPnnRecordNumber;
       
  1978                     }
       
  1979                 }
       
  1980             else
       
  1981                 {
       
  1982                 // OPL list does not exist. PNN#1 is reserved for HPLMN.
       
  1983                 pnnHplmnIdentifier = KNetHplmnPnnRecordNumber;
       
  1984                 }
       
  1985             }
       
  1986         // No else.
       
  1987         }
       
  1988 
       
  1989     return pnnHplmnIdentifier;
       
  1990     }
       
  1991 
       
  1992 // -----------------------------------------------------------------------------
       
  1993 // CMmNetOperatorNameHandler::OplRulesChecker
       
  1994 // Go through OPL rule records and find out matching record if exist.
       
  1995 // -----------------------------------------------------------------------------
       
  1996 //
       
  1997 TInt CMmNetOperatorNameHandler::OplRulesChecker
       
  1998         (
       
  1999         const TDesC8& aOperatorCode, // Operator Code in BCD format
       
  2000         TUint aLac // Location Area Code
       
  2001         )
       
  2002     {
       
  2003 TFLOGSTRING4("TSY: CMmNetOperatorNameHandler::OplRulesChecker - Operator Code BCD string: %02X %02X %02X", aOperatorCode[0], aOperatorCode[1], aOperatorCode[2]);
       
  2004 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::OplRulesChecker - LAC: %d", aLac);
       
  2005 OstTraceExt3( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_OPLRULESCHECKER, "CMmNetOperatorNameHandler::OplRulesChecker - Operator Code BCD string: %hhx %hhx %hhx", aOperatorCode[0], aOperatorCode[1], aOperatorCode[2] );
       
  2006 OstTrace1( TRACE_NORMAL, DUP5_CMMNETOPERATORNAMEHANDLER_OPLRULESCHECKER, "CMmNetOperatorNameHandler::OplRulesChecker - LAC: %u", aLac );
       
  2007 
       
  2008     // Initialize.
       
  2009     TUint8 index( 0 );
       
  2010     TUint8 tempPnnIdentifier( 0 );
       
  2011     iOplRuleMatch = EFalse;
       
  2012 
       
  2013     // Number of records to be checked.
       
  2014     TUint8 numberOfRecords( iOperatorPlmnListTable.Count() );
       
  2015 
       
  2016     // Go through records and find match if exist.
       
  2017     while ( index < numberOfRecords && !iOplRuleMatch )
       
  2018         {
       
  2019 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::OplRulesChecker - saved OPL list index: %d", index);
       
  2020 OstTraceExt1( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_OPLRULESCHECKER, "CMmNetOperatorNameHandler::OplRulesChecker - saved OPL list index=%hhu", index );
       
  2021         // Check OPL rule record.
       
  2022         OplRuleRecordChecker(
       
  2023             index,
       
  2024             aOperatorCode,
       
  2025             aLac );
       
  2026 
       
  2027         // If match, take PNN Identifier from matching record.
       
  2028         if ( iOplRuleMatch )
       
  2029             {
       
  2030 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::OplRulesChecker - OPL rule match");
       
  2031 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_OPLRULESCHECKER, "CMmNetOperatorNameHandler::OplRulesChecker - OPL rule match" );
       
  2032             tempPnnIdentifier = iOperatorPlmnListTable[index].iPNNIdentifier;
       
  2033             }
       
  2034         else
       
  2035             {
       
  2036 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::OplRulesChecker - OPL rule doesn't match");
       
  2037 OstTrace0( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_OPLRULESCHECKER, "CMmNetOperatorNameHandler::OplRulesChecker - OPL rule doesn't match" );
       
  2038             // No match.
       
  2039             // Increase index value.
       
  2040             index++;
       
  2041             }
       
  2042         }
       
  2043 
       
  2044 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::OplRulesChecker - PNN Identifier: %d", tempPnnIdentifier);
       
  2045 OstTraceExt1( TRACE_NORMAL, DUP4_CMMNETOPERATORNAMEHANDLER_OPLRULESCHECKER, "CMmNetOperatorNameHandler::OplRulesChecker - PNN Identifier=%hhu", tempPnnIdentifier );
       
  2046 
       
  2047     return tempPnnIdentifier;
       
  2048     }
       
  2049 
       
  2050 // -----------------------------------------------------------------------------
       
  2051 // CMmNetOperatorNameHandler::OplRuleRecordChecker
       
  2052 // Checks one OPL rule record against received Operator Code in BCD format
       
  2053 // and LAC value.
       
  2054 // -----------------------------------------------------------------------------
       
  2055 //
       
  2056 void CMmNetOperatorNameHandler::OplRuleRecordChecker
       
  2057         (
       
  2058         TUint8 aIndex, // Record index
       
  2059         const TDesC8& aOperCode, // Operator Code in BCD format
       
  2060         TUint aLac // Location Area Code
       
  2061         )
       
  2062     {
       
  2063 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::OplRuleRecordChecker");
       
  2064 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_OPLRULERECORDCHECKER, "CMmNetOperatorNameHandler::OplRuleRecordChecker" );
       
  2065 
       
  2066     // Temp data.
       
  2067     TUint8 operCodeChar( 0 );
       
  2068     TUint8 plmnListChar( 0 );
       
  2069 
       
  2070     // Setting ret value to KErrNone first to get compare working.
       
  2071     TInt ret( KErrNone );
       
  2072 
       
  2073     // Compare one BCD code byte at time.
       
  2074     for ( TUint8 i = 0; i < KBCDLength; i++ )
       
  2075         {
       
  2076         if ( KErrNone == ret )
       
  2077             {
       
  2078             // Check upper part of byte.
       
  2079             operCodeChar = ( aOperCode[i] >> 4 ) & KBCDOneCharMask;
       
  2080             plmnListChar =
       
  2081                 ( iOperatorPlmnListTable[aIndex].iOperCodeBCD[i] >> 4 ) &
       
  2082                 KBCDOneCharMask;
       
  2083 
       
  2084             ret = BCDCharChecker( operCodeChar, plmnListChar );
       
  2085 
       
  2086             // Continue checking lower part if previous matches.
       
  2087             if ( KErrNone == ret )
       
  2088                 {
       
  2089                 // Check lower part of byte.
       
  2090                 operCodeChar = aOperCode[i] & KBCDOneCharMask;
       
  2091                 plmnListChar =
       
  2092                     iOperatorPlmnListTable[aIndex].iOperCodeBCD[i] &
       
  2093                     KBCDOneCharMask;
       
  2094 
       
  2095                 ret = BCDCharChecker( operCodeChar, plmnListChar );
       
  2096                 }
       
  2097             }
       
  2098         }
       
  2099 
       
  2100     // Compare Location Area Value information.
       
  2101     // LAC should be in between upper and lower limit.
       
  2102     //
       
  2103     // If BCD code match then continue to check LAC values.
       
  2104     if ( KErrNone == ret )
       
  2105         {
       
  2106 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::OplRuleRecordChecker - BCD code match");
       
  2107 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_OPLRULERECORDCHECKER, "CMmNetOperatorNameHandler::OplRuleRecordChecker - BCD code match" );
       
  2108         if ( ( aLac <= iOperatorPlmnListTable[aIndex].iLACUpperLimit )
       
  2109             && ( aLac >= iOperatorPlmnListTable[aIndex].iLACLowerLimit ) )
       
  2110             {
       
  2111 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::OplRuleRecordChecker - LAC match => OPL Rule match");
       
  2112 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_OPLRULERECORDCHECKER, "CMmNetOperatorNameHandler::OplRuleRecordChecker - LAC match => OPL Rule match" );
       
  2113             // Both BCD code and LAC value match.
       
  2114             // Set iOplRuleMatch value to ETrue.
       
  2115             // This informs that OPL record match.
       
  2116             iOplRuleMatch = ETrue;
       
  2117             }
       
  2118         else
       
  2119             {
       
  2120 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::OplRuleRecordChecker - LAC doesn't match => OPL Rule doesn't match");
       
  2121 OstTrace0( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_OPLRULERECORDCHECKER, "CMmNetOperatorNameHandler::OplRuleRecordChecker - LAC doesn't match => OPL Rule doesn't match" );
       
  2122             // LAC value range doesn't match.
       
  2123             // Set iOplRuleMatch value to EFalse.
       
  2124             // This informs that OPL record didn't match.
       
  2125             iOplRuleMatch = EFalse;
       
  2126             }
       
  2127         }
       
  2128     else
       
  2129         {
       
  2130 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::OplRuleRecordChecker - BCD code didn't match => OPL Rule doesn't match");
       
  2131 OstTrace0( TRACE_NORMAL, DUP4_CMMNETOPERATORNAMEHANDLER_OPLRULERECORDCHECKER, "CMmNetOperatorNameHandler::OplRuleRecordChecker - BCD code didn't match => OPL Rule doesn't match" );
       
  2132         // Set iOplRuleMatch value to EFalse.
       
  2133         // This informs that OPL record didn't match.
       
  2134         iOplRuleMatch = EFalse;
       
  2135         }
       
  2136 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::OplRuleRecordChecker - OPL Rule Match value T/F: %d", iOplRuleMatch);
       
  2137 OstTraceExt1( TRACE_NORMAL, DUP5_CMMNETOPERATORNAMEHANDLER_OPLRULERECORDCHECKER, "CMmNetOperatorNameHandler::OplRuleRecordChecker - OPL Rule Match value T/F=%hhu", iOplRuleMatch );
       
  2138     }
       
  2139 
       
  2140 // -----------------------------------------------------------------------------
       
  2141 // CMmNetOperatorNameHandler::BCDCharChecker
       
  2142 // Check BCD char against rule to find out is that matching with OPL list.
       
  2143 // -----------------------------------------------------------------------------
       
  2144 //
       
  2145 TInt CMmNetOperatorNameHandler::BCDCharChecker
       
  2146         (
       
  2147         TUint8 aOperCodeChar,
       
  2148         TUint8 aPlmnListChar
       
  2149         )
       
  2150     {
       
  2151 TFLOGSTRING3("TSY: CMmNetOperatorNameHandler::BCDCharChecker - Operator code char : Plmn list char = %X : %X", aOperCodeChar, aPlmnListChar);
       
  2152 OstTraceExt2( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_BCDCHARCHECKER, "CMmNetOperatorNameHandler::BCDCharChecker - Operator code char : Plmn list char = %hhx : %hhx", aOperCodeChar, aPlmnListChar );
       
  2153 
       
  2154     TInt ret( KErrGeneral );
       
  2155 
       
  2156     // Check character.
       
  2157     // Operator code character needs to match OPL list Operator character
       
  2158     // or if OPL list character value is 'D' it indicates "wild" value what
       
  2159     // corresponding to all values.
       
  2160     if ( aOperCodeChar == aPlmnListChar || KBCDWildChar == aPlmnListChar )
       
  2161         {
       
  2162 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::BCDCharChecker - Character match");
       
  2163 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_BCDCHARCHECKER, "CMmNetOperatorNameHandler::BCDCharChecker - Character match" );
       
  2164         // Character match.
       
  2165         ret = KErrNone;
       
  2166         }
       
  2167     // No else, ret is already set to KErrGeneral.
       
  2168 
       
  2169     return ret;
       
  2170     }
       
  2171 
       
  2172 // -----------------------------------------------------------------------------
       
  2173 // CMmNetOperatorNameHandler::CopyEonsName
       
  2174 // Copy EONS Long and Short names if exist.
       
  2175 // -----------------------------------------------------------------------------
       
  2176 //
       
  2177 void CMmNetOperatorNameHandler::CopyEonsName
       
  2178         (
       
  2179         RMobilePhone::TMobilePhoneNetworkInfoV5& aNetworkData // Network data
       
  2180         )
       
  2181     {
       
  2182 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::CopyEonsName");
       
  2183 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_COPYEONSNAME, "CMmNetOperatorNameHandler::CopyEonsName" );
       
  2184 
       
  2185     // Copy Long EONS name if exist.
       
  2186     // If no Long EONS name there is no short EONS name either.
       
  2187     if ( 0 < iEonsName.iLongName.Length() )
       
  2188         {
       
  2189 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::CopyEonsName - EONS Long name");
       
  2190 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_COPYEONSNAME, "CMmNetOperatorNameHandler::CopyEonsName - EONS Long name" );
       
  2191 
       
  2192         // Copy EONS Long name.
       
  2193         aNetworkData.iLongName.Copy( iEonsName.iLongName );
       
  2194 
       
  2195         // Add Operator name info data.
       
  2196         iOperNameInfo.iType = RMmCustomAPI::EOperatorNameFlexiblePlmn;
       
  2197         iOperNameInfo.iName.Copy( iEonsName.iLongName );
       
  2198 
       
  2199         // Copy Short EONS name if exist.
       
  2200         if ( 0 < iEonsName.iShortName.Length() )
       
  2201             {
       
  2202 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::CopyEonsName - EONS Short name");
       
  2203 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_COPYEONSNAME, "CMmNetOperatorNameHandler::CopyEonsName - EONS Short name" );
       
  2204 
       
  2205             // Copy EONS Short name.
       
  2206             aNetworkData.iShortName.Copy( iEonsName.iShortName );
       
  2207             }
       
  2208         }
       
  2209     }
       
  2210 
       
  2211 // -----------------------------------------------------------------------------
       
  2212 // CMmNetOperatorNameHandler::NitzNameChecker
       
  2213 // Check NITZ name data to current MCC/MNC values and update name if match.
       
  2214 // -----------------------------------------------------------------------------
       
  2215 //
       
  2216 void CMmNetOperatorNameHandler::NitzNameChecker
       
  2217         (
       
  2218         TUint aMCC, // Current Mobile Country Code
       
  2219         TUint aMNC, // Current Mobile Network Code
       
  2220         RMobilePhone::TMobilePhoneNetworkInfoV5& aNetworkData // Network data
       
  2221         )
       
  2222     {
       
  2223 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::NitzNameChecker");
       
  2224 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_NITZNAMECHECKER, "CMmNetOperatorNameHandler::NitzNameChecker" );
       
  2225 
       
  2226     // Check if NITZ long/short name exist and will match for
       
  2227     // current Country and Network codes.
       
  2228     if ( ( iNitzName.iMCC == aMCC )
       
  2229         && ( iNitzName.iMNC == aMNC ) )
       
  2230         {
       
  2231 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::NitzNameChecker - NITZ MCC/MNC codes match");
       
  2232 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_NITZNAMECHECKER, "CMmNetOperatorNameHandler::NitzNameChecker - NITZ MCC/MNC codes match" );
       
  2233 
       
  2234         // Copy Long NITZ name if exist.
       
  2235         if ( 0 < iNitzName.iLongName.Length() )
       
  2236             {
       
  2237             // Copy NITZ Long name.
       
  2238             aNetworkData.iLongName.Copy( iNitzName.iLongName );
       
  2239 
       
  2240             // Add Operator name info data.
       
  2241             iOperNameInfo.iType = RMmCustomAPI::EOperatorNameNitzFull;
       
  2242             iOperNameInfo.iName.Copy( iNitzName.iLongName );
       
  2243             }
       
  2244 
       
  2245         // Copy Short NITZ name if exist.
       
  2246         if ( 0 < iNitzName.iShortName.Length() )
       
  2247             {
       
  2248             // Copy NITZ Short name.
       
  2249             aNetworkData.iShortName.Copy( iNitzName.iShortName );
       
  2250 
       
  2251             // If NITZ Long name not exist.
       
  2252             if ( 0 == iNitzName.iLongName.Length() )
       
  2253                 {
       
  2254                 // Add Operator name info data.
       
  2255                 iOperNameInfo.iType = RMmCustomAPI::EOperatorNameNitzShort;
       
  2256                 iOperNameInfo.iName.Copy( iNitzName.iShortName );
       
  2257                 }
       
  2258             }
       
  2259         }
       
  2260     }
       
  2261 
       
  2262 // -----------------------------------------------------------------------------
       
  2263 // CMmNetOperatorNameHandler::CompareNitzNameToPmmValues
       
  2264 // Compare NITZ name got in NET_NITZ_NAME_IND to stored values in PMM.
       
  2265 // If data doesn't match then new NITZ name data will stored to PMM.
       
  2266 // -----------------------------------------------------------------------------
       
  2267 //
       
  2268 void CMmNetOperatorNameHandler::CompareNitzNameToPmmValues()
       
  2269     {
       
  2270 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::CompareNitzNameToPmmValues");
       
  2271 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_COMPARENITZNAMETOPMMVALUES, "CMmNetOperatorNameHandler::CompareNitzNameToPmmValues" );
       
  2272 
       
  2273     // Initialize to ETrue.
       
  2274     TBool valuesMatch( ETrue );
       
  2275 
       
  2276     // Compare values.
       
  2277     if ( ( iNitzNamePmm.iMCC != iNitzName.iMCC )
       
  2278         || ( iNitzNamePmm.iMNC != iNitzName.iMNC )
       
  2279         || ( 0 != iNitzNamePmm.iLongName.Compare( iNitzName.iLongName ) )
       
  2280         || ( 0 != iNitzNamePmm.iShortName.Compare( iNitzName.iShortName ) ) )
       
  2281         {
       
  2282 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::CompareNitzNameToPmmValues - No match");
       
  2283 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_COMPARENITZNAMETOPMMVALUES, "CMmNetOperatorNameHandler::CompareNitzNameToPmmValues - No match" );
       
  2284         // No match.
       
  2285         valuesMatch = EFalse;
       
  2286         }
       
  2287 
       
  2288     // If values doesn't match, store new NITZ name to PMM.
       
  2289     if ( !valuesMatch )
       
  2290         {
       
  2291 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::CompareNitzNameToPmmValues - Update PMM with new NITZ name data");
       
  2292 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_COMPARENITZNAMETOPMMVALUES, "CMmNetOperatorNameHandler::CompareNitzNameToPmmValues - Update PMM with new NITZ name data" );
       
  2293         // Copy new values.
       
  2294         iNitzNamePmm = iNitzName;
       
  2295 
       
  2296         // We need to save current NITZ name data to PMM,
       
  2297         // then NITZ name data will be in save over power cycle.
       
  2298         PermPmRecordWriteReq();
       
  2299         }
       
  2300     }
       
  2301 
       
  2302 // -----------------------------------------------------------------------------
       
  2303 // CMmNetOperatorNameHandler::Packed7to8Format
       
  2304 // Converts packed GSM default alphabet format to 8-bit format.
       
  2305 // -----------------------------------------------------------------------------
       
  2306 //
       
  2307 void CMmNetOperatorNameHandler::Packed7to8Format
       
  2308         (
       
  2309         TUint8 aNumberOf7BitChars, // Number of 7-bit characters
       
  2310         const TDesC8& aString, // 7-bit packed string
       
  2311         TDes8& aOutput // 8-bit string
       
  2312         )
       
  2313     {
       
  2314 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::Packed7to8Format");
       
  2315 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_PACKED7TO8FORMAT, "CMmNetOperatorNameHandler::Packed7to8Format" );
       
  2316 
       
  2317     // The string is in packed GSM 7-bit Default Alphabet format.
       
  2318     // To be converted to 8-bit format.
       
  2319     TUint8 maskRightPartOfCurrentByte( 0x7F );
       
  2320     TUint8 shiftLeft( 0 );
       
  2321     TUint8 leftPartFromPreviousByte( 0 );
       
  2322     TInt stringLength( aString.Length() );
       
  2323 
       
  2324     aOutput.Zero();
       
  2325 
       
  2326     for ( TInt i = 0;
       
  2327         i < stringLength && aNumberOf7BitChars > aOutput.Length();
       
  2328         i++ )
       
  2329         {
       
  2330         TUint8 leftPartOfCurrentChar(
       
  2331             ( aString[i] & maskRightPartOfCurrentByte )
       
  2332             << shiftLeft );
       
  2333 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::Packed7to8Format - Buffer index: %d", i);
       
  2334 OstTrace1( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_PACKED7TO8FORMAT, "CMmNetOperatorNameHandler::Packed7to8Format - Buffer index=%u", i );
       
  2335 
       
  2336         TUint8 character( leftPartOfCurrentChar | leftPartFromPreviousByte );
       
  2337 
       
  2338 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::Packed7to8Format - Character: %X", character);
       
  2339 OstTraceExt1( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_PACKED7TO8FORMAT, "CMmNetOperatorNameHandler::Packed7to8Format - Character=%hhx", character );
       
  2340         // Append the character in the output text string.
       
  2341         aOutput.Append( character );
       
  2342 
       
  2343         // Check that possible spare bits doesn't append to output string.
       
  2344         if ( aNumberOf7BitChars > aOutput.Length() )
       
  2345             {
       
  2346             // Updates.
       
  2347             if ( KSiftedSixTimes == shiftLeft )
       
  2348                 {
       
  2349                 // After 6 shifts, the character is in bit7..bit1, therefore it has to
       
  2350                 // be shifted one bit to the right.
       
  2351                 character = aString[i] >> 1;
       
  2352 
       
  2353 TFLOGSTRING2("TSY: CMmNetOperatorNameHandler::Packed7to8Format - Character: %X", character);
       
  2354 OstTraceExt1( TRACE_NORMAL, DUP3_CMMNETOPERATORNAMEHANDLER_PACKED7TO8FORMAT, "CMmNetOperatorNameHandler::Packed7to8Format - Character=%hhx", character );
       
  2355                 // Continue.
       
  2356                 aOutput.Append( character );
       
  2357                 // Restart.
       
  2358                 leftPartFromPreviousByte = 0;
       
  2359                 shiftLeft = 0;
       
  2360                 maskRightPartOfCurrentByte = 0x7F;
       
  2361                 }
       
  2362             else
       
  2363                 {
       
  2364                 leftPartFromPreviousByte = ( aString[i] ) >> ( 7 - shiftLeft );
       
  2365                 maskRightPartOfCurrentByte = maskRightPartOfCurrentByte >> 1;
       
  2366                 shiftLeft++;
       
  2367                 }
       
  2368             }
       
  2369         }
       
  2370     }
       
  2371 
       
  2372 // -----------------------------------------------------------------------------
       
  2373 // CMmNetOperatorNameHandler::ConvertGsm7ToUnicode16
       
  2374 // Convert a text from GSM alphabet to Unicode format.
       
  2375 // -----------------------------------------------------------------------------
       
  2376 //
       
  2377 void CMmNetOperatorNameHandler::ConvertGsm7ToUnicode16
       
  2378         (
       
  2379         TDes16& aOutput, // Unicode 16-bit format string
       
  2380         const TDesC8& aInput // Input string
       
  2381         )
       
  2382     {
       
  2383 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::ConvertGsm7ToUnicode16");
       
  2384 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_CONVERTGSM7TOUNICODE16, "CMmNetOperatorNameHandler::ConvertGsm7ToUnicode16" );
       
  2385 
       
  2386     TInt i( 0 );
       
  2387     TInt outputMaxLength( aOutput.MaxLength() );
       
  2388     TInt inputLength( aInput.Length() );
       
  2389 
       
  2390     for ( i = 0; i < inputLength && outputMaxLength > aOutput.Length(); i++ )
       
  2391         {
       
  2392         TUint8 character( aInput[i] );
       
  2393 
       
  2394         // This code is an escape to an extension of the 7 bit default alphabet
       
  2395         // table.
       
  2396         if ( KExtendedTable == character && ( i + 1 != inputLength ) )
       
  2397             {
       
  2398             // extension table
       
  2399             switch ( aInput[i+1] )
       
  2400                 {
       
  2401                 case 0x28: // {
       
  2402                     {
       
  2403                     aOutput.Append( static_cast<TUint16>( 0x7B ) );
       
  2404                     break;
       
  2405                     }
       
  2406                 case 0x29: // }
       
  2407                     {
       
  2408                     aOutput.Append( static_cast<TUint16>( 0x7D ) );
       
  2409                     break;
       
  2410                     }
       
  2411                 case 0x3C: // [
       
  2412                     {
       
  2413                     aOutput.Append( static_cast<TUint16>( 0x5B ) );
       
  2414                     break;
       
  2415                     }
       
  2416                 case 0x3E: // ]
       
  2417                     {
       
  2418                     aOutput.Append( static_cast<TUint16>( 0x5D ) );
       
  2419                     break;
       
  2420                     }
       
  2421                 case 0x3D: // ~
       
  2422                     {
       
  2423                     aOutput.Append( static_cast<TUint16>( 0x7E ) );
       
  2424                     break;
       
  2425                     }
       
  2426                 case 0x2F: /* \ */
       
  2427                     {
       
  2428                     aOutput.Append( static_cast<TUint16>( 0x5C ) );
       
  2429                     break;
       
  2430                     }
       
  2431                 case 0x14: // ^
       
  2432                     {
       
  2433                     aOutput.Append( static_cast<TUint16>( 0x5E ) );
       
  2434                     break;
       
  2435                     }
       
  2436                 case 0x65: // euro 0x20AC
       
  2437                     {
       
  2438                     aOutput.Append( static_cast<TUint16>( 0x20AC ) );
       
  2439                     break;
       
  2440                     }
       
  2441                 case 0x40: // |
       
  2442                     {
       
  2443                     aOutput.Append( static_cast<TUint16>( 0x7C ) );
       
  2444                     break;
       
  2445                     }
       
  2446                 case 0x0A: // Form feed
       
  2447                     {
       
  2448                     aOutput.Append( static_cast<TUint16>( 0x0C ) );
       
  2449                     break;
       
  2450                     }
       
  2451                 case 0x1B: // Escape to yet another table.
       
  2452                     {
       
  2453                     // 3GPP TS 23.038 V6.1.0:
       
  2454                     // "space until another extension table is defined"
       
  2455                     aOutput.Append( static_cast<TUint16>( 0x20 ) );
       
  2456                     break;
       
  2457                     }
       
  2458                 default:
       
  2459                     {
       
  2460                     // 3GPP TS 23.038: "In the event that an MS receives
       
  2461                     // a code where a symbol is not represented in the above
       
  2462                     // table then the MS shall display the character shown in
       
  2463                     // the main GSM 7 bit default alphabet table in clause
       
  2464                     // 6.2.1"
       
  2465 
       
  2466                     // Check that bit 8 is set to '0'
       
  2467                     if ( 0x7F >= aInput[i+1] )
       
  2468                         {
       
  2469                         // Character is in normal 7-bit table.
       
  2470                         aOutput.Append( KUnicode[ aInput[i+1] ] );
       
  2471                         }
       
  2472                     else
       
  2473                         {
       
  2474                         // Unknown characters will be converted into a space.
       
  2475                         aOutput.Append( static_cast<TUint16>( 0x20 ) );
       
  2476 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::ConvertGsm7ToUnicode16, Unknown char is converted into a space.");
       
  2477 OstTrace0( TRACE_NORMAL, DUP1_CMMNETOPERATORNAMEHANDLER_CONVERTGSM7TOUNICODE16, "CMmNetOperatorNameHandler::ConvertGsm7ToUnicode16, Unknown char is converted into a space." );
       
  2478                         }
       
  2479                     break;
       
  2480                     }
       
  2481                 }
       
  2482             // Characters in extension table takes two bytes
       
  2483             i++;
       
  2484             }
       
  2485         // Check that bit 8 is set to '0'
       
  2486         else if ( 0x7F >= character )
       
  2487             {
       
  2488             // Character is in normal 7-bit table.
       
  2489             aOutput.Append( KUnicode[ character ] );
       
  2490             }
       
  2491         else
       
  2492             {
       
  2493             // Unknown characters will be converted into a space.
       
  2494             aOutput.Append( static_cast<TUint16>( 0x20 ) );
       
  2495 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::ConvertGsm7ToUnicode16, Unknown char is converted into a space.");
       
  2496 OstTrace0( TRACE_NORMAL, DUP2_CMMNETOPERATORNAMEHANDLER_CONVERTGSM7TOUNICODE16, "CMmNetOperatorNameHandler::ConvertGsm7ToUnicode16, Unknown char is converted into a space." );
       
  2497             }
       
  2498         }
       
  2499     }
       
  2500 
       
  2501 // -----------------------------------------------------------------------------
       
  2502 // CMmNetOperatorNameHandler::CompleteMobilePhoneGetDetectedNetworksV2Phase1L
       
  2503 // Creates a CMobilePhoneNetworkListV2 with the information of the networks and
       
  2504 // completes EMobilePhoneGetDetectedNetworksV2Phase1 to SOS layer.
       
  2505 // -----------------------------------------------------------------------------
       
  2506 //
       
  2507 void CMmNetOperatorNameHandler::CompleteMobilePhoneGetDetectedNetworksV2Phase1L()
       
  2508     {
       
  2509 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::CompleteMobilePhoneGetDetectedNetworksV2Phase1L");
       
  2510 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_COMPLETEMOBILEPHONEGETDETECTEDNETWORKSV2PHASE1L, "CMmNetOperatorNameHandler::CompleteMobilePhoneGetDetectedNetworksV2Phase1L" );
       
  2511 
       
  2512     // Completing EMobilePhoneGetDetectedNetworksV2Phase1 IPC with found
       
  2513     // operators in manual search need to use the CMobilePhoneNetworkListV2
       
  2514     // class which is read only.
       
  2515     //
       
  2516     // Pointer to the List of Operators in manual search.
       
  2517     CMobilePhoneNetworkListV2* list = CMobilePhoneNetworkListV2::NewL();
       
  2518     // Use the cleanup stack for the list.
       
  2519     CleanupStack::PushL( list );
       
  2520 
       
  2521     // Temporaly network data entry, because we need to use V2 version
       
  2522     // when completing network list.
       
  2523     RMobilePhone::TMobilePhoneNetworkInfoV2 networkEntry;
       
  2524 
       
  2525     // Amount of networks in Manual search network list.
       
  2526     TUint8 amountOfNetworks( iManualSearchNetworkList.Count() );
       
  2527     // Index value of network in manual search network list.
       
  2528     TUint8 indexValue( 0 );
       
  2529 
       
  2530     // Add all found operators to list.
       
  2531     while ( indexValue < amountOfNetworks )
       
  2532         {
       
  2533         // Copy Manual search data list entry first to V2 version.
       
  2534         networkEntry = ( RMobilePhone::TMobilePhoneNetworkInfoV2 )
       
  2535             iManualSearchNetworkList[indexValue];
       
  2536 
       
  2537         // Catch possible leave in AddEntryL.
       
  2538         TRAP_IGNORE(
       
  2539             // Add V2 version network entry to read only list.
       
  2540             list->AddEntryL( networkEntry ) );
       
  2541 
       
  2542         // Update indexValue.
       
  2543         indexValue++;
       
  2544         }
       
  2545 
       
  2546     // Assistant for packaging.
       
  2547     CMmDataPackage dataPackage;
       
  2548 
       
  2549     // Pack the data.
       
  2550     dataPackage.PackData( &list );
       
  2551 
       
  2552     // Complete client request
       
  2553     iNetMessHandler->GetMessageRouter()->Complete(
       
  2554         EMobilePhoneGetDetectedNetworksV2Phase1,
       
  2555         &dataPackage,
       
  2556         KErrNone );
       
  2557 
       
  2558     // List has been already used, destroy it.
       
  2559     CleanupStack::PopAndDestroy( list );
       
  2560 
       
  2561     // Reset manual network search list array.
       
  2562     iManualSearchNetworkList.Reset();
       
  2563     // Reset manual search data list array.
       
  2564     iManualSearchDataList.Reset();
       
  2565     }
       
  2566 
       
  2567 // -----------------------------------------------------------------------------
       
  2568 // CMmNetOperatorNameHandler::GetPnnRecordIdentifierValue
       
  2569 // Return PNN record identifier value.
       
  2570 // -----------------------------------------------------------------------------
       
  2571 //
       
  2572 TInt CMmNetOperatorNameHandler::GetPnnRecordIdentifierValue()
       
  2573     {
       
  2574 TFLOGSTRING("TSY: CMmNetOperatorNameHandler::GetPnnRecordIdentifierValue");
       
  2575 OstTrace0( TRACE_NORMAL, CMMNETOPERATORNAMEHANDLER_GETPNNRECORDIDENTIFIERVALUE, "CMmNetOperatorNameHandler::GetPnnRecordIdentifierValue" );
       
  2576     return iEonsName.iPNNIdentifier;
       
  2577     }
       
  2578 
       
  2579 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
  2580     //None
       
  2581 
       
  2582 //  End of File