adaptationlayer/tsy/nokiatsy_dll/src/cmmphonebookstoremesshandler.cpp
changeset 5 8ccc39f9d787
parent 0 63b37f68c1ce
child 7 fa67e03b87df
equal deleted inserted replaced
4:510c70acdbf6 5:8ccc39f9d787
    28 #include "cmmphonemesshandler.h"
    28 #include "cmmphonemesshandler.h"
    29 #include "cmmstaticutility.h"
    29 #include "cmmstaticutility.h"
    30 #include "cmmphonebookalphastring.h"
    30 #include "cmmphonebookalphastring.h"
    31 #include "cmmphonebookoperationinit.h"
    31 #include "cmmphonebookoperationinit.h"
    32 #include "cmmphonebookoperationinit3g_adn.h"
    32 #include "cmmphonebookoperationinit3g_adn.h"
       
    33 #include "cmmphonebookoperationread.h"
       
    34 #include "cmmphonebookoperationread3g_adn.h"
       
    35 #include "cmmphonebookoperationcache.h"
       
    36 #include "cmmphonebookoperationwrite.h"
       
    37 #include "cmmphonebookoperationdelete.h"
    33 #include "cmmphonebookstoreoperationlist.h"
    38 #include "cmmphonebookstoreoperationlist.h"
    34 #include "cmmphonebookstoreoperationbase.h"
    39 #include "cmmphonebookstoreoperationbase.h"
    35 #include "cmmmessagerouter.h"
    40 #include "cmmmessagerouter.h"
    36 #include "osttracedefinitions.h"
    41 #include "OstTraceDefinitions.h"
    37 #ifdef OST_TRACE_COMPILER_IN_USE
    42 #ifdef OST_TRACE_COMPILER_IN_USE
    38 #include "cmmphonebookstoremesshandlertraces.h"
    43 #include "cmmphonebookstoremesshandlerTraces.h"
    39 #endif
    44 #endif
    40 
    45 
    41 
    46 
    42 // EXTERNAL DATA STRUCTURES
    47 // EXTERNAL DATA STRUCTURES
    43     // None
    48     // None
    64 // ==================== LOCAL FUNCTIONS ======================================
    69 // ==================== LOCAL FUNCTIONS ======================================
    65     // None
    70     // None
    66 
    71 
    67 
    72 
    68 // ================= MEMBER FUNCTIONS ========================================
    73 // ================= MEMBER FUNCTIONS ========================================
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // TPrimitiveInitInfo::TPrimitiveInitInfo
       
    77 // C++ default constructor can NOT contain any code, that
       
    78 // might leave.
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 TPrimitiveInitInfo::TPrimitiveInitInfo()
       
    82     {
       
    83 TFLOGSTRING("TSY: TPrimitiveInitInfo::TPrimitiveInitInfo");
       
    84 OstTrace0( TRACE_NORMAL, TPRIMITIVEINITINFO_TPRIMITIVEINITINFO, "TPrimitiveInitInfo::TPrimitiveInitInfo" );
       
    85 
       
    86 
       
    87     iNoOfRecords = 0;          // 2 byte long
       
    88     iAlphaStringlength = 0;    // 2 byte long
       
    89     iNumlength = 0;          // 2 byte long
       
    90     iExtNoOfRec = 0;
       
    91     iExtension = EFalse;
       
    92 
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // TPrimitiveInitInfo::GetPBEntryFromUICCData
       
    97 // Separate phonebook entry from ISI message
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 
       
   101 void TPrimitiveInitInfo::GetPBEntryFromUICCData(
       
   102      const TDesC8& aFileData,
       
   103      TDes8& aNumber,
       
   104      TDes8& aName)
       
   105     {
       
   106     TUint8 nameLength (0);
       
   107     TUint8 numLength(0);
       
   108 
       
   109     // Maximum record length will be RecordLength -14
       
   110     // Actual string length can be find the first FF , which indicates that after
       
   111     // that its empty
       
   112     nameLength = aFileData.Find(&KTagUnusedbyte,1);
       
   113     // Check if MAX length is smaller than the MAX alpha string length
       
   114     if( iAlphaStringlength < nameLength)
       
   115         {
       
   116         // Max lenght wil be the valid alpha string Length
       
   117         nameLength = iAlphaStringlength;
       
   118         }
       
   119 
       
   120     numLength = aFileData[iAlphaStringlength];
       
   121 
       
   122     // Chekc for number Length also
       
   123     if( iNumlength < numLength)
       
   124         {
       
   125         numLength = iNumlength;
       
   126         }
       
   127 
       
   128     // Save name
       
   129     if ( KMinLength < nameLength )
       
   130         {
       
   131 TFLOGSTRING("TSY: TPrimitiveInitInfo::GetPBEntryFromUICCData. Saving name.");
       
   132 OstTrace0( TRACE_NORMAL, TPRIMITIVEINITINFO_GETPBENTRYFROMUICCDATA, "TPrimitiveInitInfo::GetPBEntryFromUICCData. Saving Name" );
       
   133 
       
   134         aName.Copy(aFileData.Mid(0,nameLength));
       
   135         }
       
   136     //no else
       
   137     // Save number
       
   138     if ( KMinLength < numLength )
       
   139         {
       
   140 TFLOGSTRING("TSY: TPrimitiveInitInfo::GetPBEntryFromUICCData. Saving number.");
       
   141 OstTrace0( TRACE_NORMAL, DUP1_TPRIMITIVEINITINFO_GETPBENTRYFROMUICCDATA, "TPrimitiveInitInfo::GetPBEntryFromUICCData. Save Number" );
       
   142 
       
   143         // Store number in buffer4
       
   144         // Start for number
       
   145         TInt offset = iAlphaStringlength + 1;
       
   146         aNumber.Append(aFileData.Mid(offset,numLength));
       
   147         }
       
   148     }
       
   149 
    69 
   150 
    70 // ---------------------------------------------------------------------------
   151 // ---------------------------------------------------------------------------
    71 // CMmPhoneBookStoreMessHandler::CMmPhoneBookStoreMessHandler
   152 // CMmPhoneBookStoreMessHandler::CMmPhoneBookStoreMessHandler
    72 // C++ default constructor can NOT contain any code, that
   153 // C++ default constructor can NOT contain any code, that
    73 // might leave.
   154 // might leave.
    74 // ---------------------------------------------------------------------------
   155 // ---------------------------------------------------------------------------
    75 //
   156 //
    76 CMmPhoneBookStoreMessHandler::CMmPhoneBookStoreMessHandler()
   157 CMmPhoneBookStoreMessHandler::CMmPhoneBookStoreMessHandler()
    77     {
   158     {
    78     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::\
   159 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::CMmPhoneBookStoreMessHandler.");
    79         CMmPhoneBookStoreMessHandler.");
       
    80 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_CMMPHONEBOOKSTOREMESSHANDLER, "CMmPhoneBookStoreMessHandler::CMmPhoneBookStoreMessHandler" );
   160 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_CMMPHONEBOOKSTOREMESSHANDLER, "CMmPhoneBookStoreMessHandler::CMmPhoneBookStoreMessHandler" );
    81     }
   161     }
    82 
   162 
    83 // ---------------------------------------------------------------------------
   163 // ---------------------------------------------------------------------------
    84 // CMmPhoneBookStoreMessHandler::~CMmPhoneBookStoreMessHandler
   164 // CMmPhoneBookStoreMessHandler::~CMmPhoneBookStoreMessHandler
    85 // C++ destructor.
   165 // C++ destructor.
    86 // ---------------------------------------------------------------------------
   166 // ---------------------------------------------------------------------------
    87 //
   167 //
    88 CMmPhoneBookStoreMessHandler::~CMmPhoneBookStoreMessHandler()
   168 CMmPhoneBookStoreMessHandler::~CMmPhoneBookStoreMessHandler()
    89     {
   169     {
    90     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::\
   170 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::~CMmPhoneBookStoreMessHandler.");
    91         ~CMmPhoneBookStoreMessHandler.");
       
    92 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKSTOREMESSHANDLER_CMMPHONEBOOKSTOREMESSHANDLER, "CMmPhoneBookStoreMessHandler::~CMmPhoneBookStoreMessHandler" );
   171 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKSTOREMESSHANDLER_CMMPHONEBOOKSTOREMESSHANDLER, "CMmPhoneBookStoreMessHandler::~CMmPhoneBookStoreMessHandler" );
       
   172 
       
   173 // Delete all the entries
       
   174     for( TInt pbCount = 0; pbCount < iPBEntryList.Count(); pbCount++ )
       
   175         {
       
   176         for( TInt count = 0; count < iPBEntryList[pbCount].iEntryList.Count(); count++)
       
   177             {
       
   178             delete iPBEntryList[pbCount].iEntryList[count];
       
   179             }
       
   180         iPBEntryList[pbCount].iEntryList.Close();
       
   181         }
       
   182 
    93     delete iOperationlist;
   183     delete iOperationlist;
    94 
   184 
    95 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
   185 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
    96     if ( iAas )
   186     if ( iAas )
    97       {
   187       {
   114 //
   204 //
   115 CMmPhoneBookStoreMessHandler* CMmPhoneBookStoreMessHandler::NewL(
   205 CMmPhoneBookStoreMessHandler* CMmPhoneBookStoreMessHandler::NewL(
   116     CMmMessageRouter* aMessageRouter,  // Pointer to message router
   206     CMmMessageRouter* aMessageRouter,  // Pointer to message router
   117     CMmUiccMessHandler* aUiccMessHandler) //Pointer to the Uicc Message handler
   207     CMmUiccMessHandler* aUiccMessHandler) //Pointer to the Uicc Message handler
   118     {
   208     {
   119     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::NewL.");
   209 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::NewL.");
   120 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_NEWL, "CMmPhoneBookStoreMessHandler::NewL" );
   210 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_NEWL, "CMmPhoneBookStoreMessHandler::NewL" );
   121 
   211 
   122     // Create PhoneBookStore messagehandler
   212     // Create PhoneBookStore messagehandler
   123     CMmPhoneBookStoreMessHandler* mmPhoneBookStoreMessHandler =
   213     CMmPhoneBookStoreMessHandler* mmPhoneBookStoreMessHandler =
   124         new( ELeave ) CMmPhoneBookStoreMessHandler();
   214         new( ELeave ) CMmPhoneBookStoreMessHandler();
   145 //
   235 //
   146 void CMmPhoneBookStoreMessHandler::ConstructL(
   236 void CMmPhoneBookStoreMessHandler::ConstructL(
   147     CMmPhoneBookStoreMessHandler* /*mmPhoneBookStoreMessHandler*/,
   237     CMmPhoneBookStoreMessHandler* /*mmPhoneBookStoreMessHandler*/,
   148     CMmUiccMessHandler* aUiccMessHandler)
   238     CMmUiccMessHandler* aUiccMessHandler)
   149     {
   239     {
   150     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ConstructL");
   240 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ConstructL");
   151 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_CONSTRUCTL, "CMmPhoneBookStoreMessHandler::ConstructL" );
   241 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_CONSTRUCTL, "CMmPhoneBookStoreMessHandler::ConstructL" );
   152 
   242 
   153     iOperationlist = CMmPhoneBookStoreOperationList::NewL( this , aUiccMessHandler );
   243     iOperationlist = CMmPhoneBookStoreOperationList::NewL( this , aUiccMessHandler );
   154     iNumberOfFdnInfoResps = 0;
   244     iNumberOfFdnInfoResps = 0;
   155     }
   245     }
   161 //
   251 //
   162 TInt CMmPhoneBookStoreMessHandler::ExtFuncL(
   252 TInt CMmPhoneBookStoreMessHandler::ExtFuncL(
   163     TInt aIpc,
   253     TInt aIpc,
   164     const CMmDataPackage* aDataPackage )
   254     const CMmDataPackage* aDataPackage )
   165     {
   255     {
   166     TFLOGSTRING2("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - arrived. \
   256 TFLOGSTRING2("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - arrived. IPC: %d", aIpc);
   167         IPC: %d", aIpc);
       
   168 OstTrace1( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL;aIpc=%d", aIpc );
   257 OstTrace1( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL;aIpc=%d", aIpc );
   169 
   258 
   170     TInt ret( KErrNotSupported );
   259     TInt ret( KErrNone );
   171     CMmPhoneBookStoreOperationBase* operation( NULL );
   260     CMmPhoneBookStoreOperationBase* operation( NULL );
   172 
   261 
       
   262 
   173     if ( EMmTsyPhoneBookStoreCacheCancelIPC == aIpc )
   263     if ( EMmTsyPhoneBookStoreCacheCancelIPC == aIpc )
   174         {
   264         {
       
   265         // get the phonebook name
       
   266         TName phonebookTypeName;
       
   267         const CPhoneBookDataPackage* phoneBookData =
       
   268             static_cast<const CPhoneBookDataPackage*>( aDataPackage );
       
   269         phoneBookData->GetPhoneBookName( phonebookTypeName );
       
   270 
   175         // processing cache cancel IPC
   271         // processing cache cancel IPC
   176         TUint8 trans( 0 );
   272         iOperationlist->CancelOperation( phonebookTypeName ); // seek from the beginning
   177         ret = CMmPhoneBookStoreOperationList::CalculateTransactionId(
   273         }  // end of EMmTsyPhoneBookStoreCacheCancelIPC
   178                   EMmTsyPhoneBookStoreCacheIPC, aDataPackage, trans );
       
   179         if ( KErrNone == ret )
       
   180             {
       
   181             operation = iOperationlist->Find( trans ); // seek from the beginning
       
   182             if ( NULL != operation )
       
   183                 {
       
   184                 if ( operation->IsPrepared() )
       
   185                     { // found running operation - cancel it
       
   186                     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - cancel running cache operation");
       
   187                     OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL - cancel running cache operation" );
       
   188                     operation->CancelReq();
       
   189                     ret = KErrNone;
       
   190                     }
       
   191                 else
       
   192                     { // look for pending operation
       
   193                     operation = iOperationlist->Find( trans, operation );
       
   194                     if ( NULL != operation && operation->IsPrepared() )
       
   195                         { // pending operation is found - cancel it
       
   196                         TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - cancel pending cacheing");
       
   197                         OstTrace0( TRACE_NORMAL, DUP3_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL - cancel pending cacheing" );
       
   198                         operation->CancelReq();
       
   199                         ret = KErrNone;
       
   200                         }
       
   201                     else
       
   202                         { // pending operation is either not found or already canceled
       
   203                           // this is error situation: multiple cancel requests
       
   204                         TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - error: nothing to cancel");
       
   205                         OstTrace0( TRACE_NORMAL, DUP2_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL - error: nothing to cancel" );
       
   206                         ret = KErrServerBusy;
       
   207                         }
       
   208                     }
       
   209                 }
       
   210             else
       
   211                 {
       
   212                 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - already canceled");
       
   213                 OstTrace0( TRACE_NORMAL, DUP10_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL - already canceled" );
       
   214                 }
       
   215             }
       
   216         }
       
   217     else if ( EMmTsyPhoneBookStoreCacheIPC == aIpc )
       
   218         {
       
   219         // processing cache IPC
       
   220         TUint8 trans( 0 );
       
   221         ret = CMmPhoneBookStoreOperationList::CalculateTransactionId(
       
   222                   aIpc, aDataPackage, trans );
       
   223         if ( KErrNone == ret )
       
   224             {
       
   225             operation = iOperationlist->Find( trans );
       
   226             if ( NULL != operation )
       
   227                 { // found running cacheing operation - look for pending
       
   228                   // we can not reactivate this one, because even if it is canceled
       
   229                   // it is waiting for the response from CellMo
       
   230                 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - cacheing already running");
       
   231                 OstTrace0( TRACE_NORMAL, DUP4_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL - cacheing already running" );
       
   232                 if ( !operation->IsPrepared() )
       
   233                     { // pending operation creation/reactivation is allowed
       
   234                       // only if running one is canceled
       
   235                     operation = iOperationlist->Find( trans, operation );
       
   236                     if ( NULL != operation )
       
   237                         {
       
   238                         TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - pending cacheing is found");
       
   239                         OstTrace0( TRACE_NORMAL, DUP5_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL - pending cacheing is found" );
       
   240                         ret = operation->PrepareReq( aIpc, aDataPackage );
       
   241 
       
   242                         if ( KErrArgument == ret )
       
   243                             {
       
   244                             // request preparation fails - needs to be removed
       
   245 TFLOGSTRING2("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL;PrepareReq returns %d", ret);
       
   246 OstTrace1( TRACE_NORMAL, DUP14_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL;PrepareReq returns %d", ret );
       
   247                             iOperationlist->RemoveLastOperationFromList();
       
   248                             }
       
   249                         else if ( KErrNone != ret )
       
   250                             { // this happens when there are 2 consequent
       
   251                               // cache requests without cancellation:
       
   252                               // cache-cancel-cache-cache
       
   253                             TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - error: pending operation is active");
       
   254                             OstTrace0( TRACE_NORMAL, DUP6_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL - error: pending operation is active" );
       
   255                             ret = KErrServerBusy;
       
   256                             }
       
   257                         else
       
   258                             {
       
   259                             TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - pending operation reactivated");
       
   260                             OstTrace0( TRACE_NORMAL, DUP7_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL - pending operation reactivated" );
       
   261                             }
       
   262                         }
       
   263                     else
       
   264                         { // no pending operation - create and prepare
       
   265                         TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - preparing pending cacheing");
       
   266                         OstTrace0( TRACE_NORMAL, DUP8_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL - preparing pending cacheing" );
       
   267                         operation = iOperationlist->BuildL( aDataPackage, aIpc );
       
   268                         ret = operation->PrepareReq( aIpc, aDataPackage );
       
   269 
       
   270                         if ( KErrArgument == ret )
       
   271                             {
       
   272 TFLOGSTRING2("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL;PrepareReq returns %d", ret);
       
   273 OstTrace1( TRACE_NORMAL, DUP13_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL;PrepareReq returns %d", ret );
       
   274                             // here we remove the newly created operation
       
   275                             // we could turn it back into non-prepared state,
       
   276                             // but this breaks the concept
       
   277                             iOperationlist->RemoveLastOperationFromList();
       
   278                             }
       
   279                         }
       
   280                     }
       
   281                 else
       
   282                     { // operation was not canceled:
       
   283                       // cache-cache
       
   284                     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL; running operation was not canceled");
       
   285                     OstTrace0( TRACE_NORMAL, DUP9_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL; running operation was not canceled" );
       
   286                     ret = KErrServerBusy;
       
   287                     }
       
   288                 }
       
   289             else
       
   290                 { // no cacheing is running - create, prepare & launch
       
   291                 operation = iOperationlist->BuildL( aDataPackage, aIpc );
       
   292                 ret = operation->PrepareReq( aIpc, aDataPackage );
       
   293 
       
   294                 if ( KErrNone == ret )
       
   295                     {
       
   296                     ret = operation->LaunchReq();
       
   297                     }
       
   298 
       
   299                 if ( KErrNone != ret )
       
   300                     {
       
   301                     // in case request preparation or phonetsender fail
       
   302 TFLOGSTRING2("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL;PrepareReq returns  %d", ret);
       
   303 OstTrace1( TRACE_NORMAL, DUP12_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL;PrepareReq returns  %d", ret );
       
   304                     // it is safe to ignore return value here
       
   305                     iOperationlist->RemoveLastOperationFromList();
       
   306                     }
       
   307                 }
       
   308             }
       
   309         }
       
   310     else
   274     else
   311         { // all other IPC's
   275         { // all other IPC's
   312         
   276         // Check for Empty Index
   313         operation = iOperationlist->BuildL( aDataPackage, aIpc );
   277          TInt transId = iOperationlist->FindEmptyIndexTransId();
   314             ret = operation->UICCCreateReq(aIpc,aDataPackage );
   278 
   315 
   279         if( 0 <= transId )
   316         if ( KErrNone != ret)
   280             {
   317             {
   281             // create operation on the basis of IPC
       
   282             operation = CreateNewOperationL( aDataPackage, aIpc );
       
   283 
       
   284             // Add operation to the operation list
       
   285             iOperationlist->AddOperation( transId, operation );
       
   286 
       
   287             // Start operation request
       
   288             ret = operation->UICCCreateReq(aIpc,aDataPackage, transId );
       
   289 
       
   290             if ( KErrNone != ret)
       
   291                 {
   318 TFLOGSTRING2("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL;CreateReq returns %d", ret);
   292 TFLOGSTRING2("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL;CreateReq returns %d", ret);
   319 OstTrace1( TRACE_NORMAL, DUP11_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL;CreateReq returns %d", ret );
   293 OstTrace1( TRACE_NORMAL, DUP11_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL;CreateReq returns %d", ret );
   320             // it is safe to ignore return value here
   294 
   321             iOperationlist->RemoveLastOperationFromList();
   295                 iOperationlist->RemoveOperationFromList( transId );
       
   296                 }
       
   297             }
       
   298         else
       
   299             {
       
   300 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - Server Busy ");
       
   301 OstTrace0( TRACE_NORMAL, DUP3_CMMPHONEBOOKSTOREMESSHANDLER_EXTFUNCL, "CMmPhoneBookStoreMessHandler::ExtFuncL - Server Busy " );
       
   302 
       
   303             ret = KErrServerBusy;
   322             }
   304             }
   323         }
   305         }
   324 
   306 
   325     return ret;
   307     return ret;
   326     }
   308     }
   327 
   309 
   328 
   310 
   329 
   311 
   330 // ---------------------------------------------------------------------------
   312 // ---------------------------------------------------------------------------
   331 // CMmPhoneBookStoreMessHandler::ReceiveMessageL
   313 // CMmPhoneBookStoreMessHandler::ProcessUiccMsg
   332 // Called when an ISI message has been received.
   314 // Called when an ISI message has been received.
   333 // ---------------------------------------------------------------------------
   315 // ---------------------------------------------------------------------------
   334 //
   316 //
   335 TInt CMmPhoneBookStoreMessHandler::ProcessUiccMsg(
   317 TInt CMmPhoneBookStoreMessHandler::ProcessUiccMsg(
   336     TInt aTraId,
   318     TInt aTraId,
   337     TInt aStatus,
   319     TInt aStatus,
       
   320     TUint8 aDetails,
   338     const TDesC8 &aFileData  ) // received data in UICC Server Message
   321     const TDesC8 &aFileData  ) // received data in UICC Server Message
   339     {
   322     {
   340     TInt ret(KErrNone);
   323     TInt ret(KErrNone);
   341    
   324 
   342     TBool complete( EFalse );
   325 
   343     
   326 TFLOGSTRING2("TSY: CMmPhoneBookStoreMessHandler::ProcessUiccMsg. transactId:%d", aTraId);
   344     TFLOGSTRING2("TSY: CMmPhoneBookStoreMessHandler::ProcessUiccMsg. transactId:%d", aTraId);
   327 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_PROCESSUICCMSG, "CMmPhoneBookStoreMessHandler::ProcessUiccMsg" );
   345     OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_PROCESSUICCMSG, "CMmPhoneBookStoreMessHandler::ProcessUiccMsg" );
   328 
   346     
   329 
   347 
   330     // Check for operation with transaction id
   348     switch(aTraId)
   331     CMmPhoneBookStoreOperationBase* operation;
   349         {
   332     operation = iOperationlist->Find( aTraId );
   350         case ETrIdPbInit:
   333     if( operation )
   351             // Check for operation with transaction id
   334         {
   352             CMmPhoneBookStoreOperationBase* operation;
   335         if( operation->HandleUICCPbRespL( aStatus, aDetails, aFileData, aTraId ))
   353             operation = iOperationlist->Find( aTraId );
   336             {
   354             if( operation )
   337 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ProcessUiccMsg. Remove Operation from the list ");
   355                 {
   338 OstTrace0( TRACE_NORMAL, DUP2_CMMPHONEBOOKSTOREMESSHANDLER_PROCESSUICCMSG, "CMmPhoneBookStoreMessHandler::ProcessUiccMsg. Remove operation from the list " );
   356                 ret = operation->HandleUICCPbRespL(complete, aStatus, aFileData, aTraId);
   339 
   357                 }
   340             // remove operation From the list
   358 
   341             iOperationlist->RemoveOperationFromList( aTraId );
       
   342             } // End of operation remove from thelist
       
   343         }
       
   344     else
       
   345         {
       
   346 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ProcessUiccMsg. Operation not Found ");
       
   347 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKSTOREMESSHANDLER_PROCESSUICCMSG, "CMmPhoneBookStoreMessHandler::ProcessUiccMsg. Operation not found " );
       
   348         }
       
   349 
       
   350     return(ret);
       
   351     }
       
   352 
       
   353 
       
   354 // ---------------------------------------------------------------------------
       
   355 // CMmPhoneBookStoreOperationList::CreateNewOperation
       
   356 // Separate request and create correct object
       
   357 // ---------------------------------------------------------------------------
       
   358 //
       
   359 CMmPhoneBookStoreOperationBase* CMmPhoneBookStoreMessHandler::CreateNewOperationL(
       
   360     const CMmDataPackage* aDataPackage,
       
   361     TInt aIpc
       
   362     )
       
   363     {
       
   364 TFLOGSTRING("TSY: CMmPhoneBookStoreOperationList::CreateNewOperation");
       
   365 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREOPERATIONLIST_CREATENEWOPERATION, "CMmPhoneBookStoreOperationList::CreateNewOperation" );
       
   366 
       
   367     CMmPhoneBookStoreOperationBase* pointer( NULL );
       
   368 
       
   369     switch( aIpc )
       
   370         {
       
   371         case EMmTsyPhoneBookStoreInitIPC:
       
   372             {
       
   373 
       
   374             // Get Card type from uiccmesshandler
       
   375             // if SIM, phonebook is 2G and located under DFtelecom and ADN pb contains only name/number entries
       
   376             // if USIM, phonebook can be 3G local or 3G private. ADN pb entry can contain additional entries
       
   377             // 3G local is located under DFtelecom and 3G private under ADFusim, both have same structure however
       
   378             // only the path is different? 7F10 vs. 7FFF
       
   379             // Here in UICCCreateReq only 3G local has been handled
       
   380             // So for both SIM and USIM Phonebook will be under DFtelecom (whose address is 7F10)
       
   381 
       
   382 
       
   383             // Chekc for Card type to Create Class for Phonebook Init
       
   384             if(UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType())
       
   385                 {
       
   386                 //call CmmPhonebookOperatorInit3G_ADN Phonebook
       
   387                 pointer = CMmPhoneBookOperationInit3G_adn::NewL(
       
   388                         this,
       
   389                         iMmUiccMessHandler,
       
   390                         aDataPackage
       
   391                         );
       
   392                 }
       
   393             else if(UICC_CARD_TYPE_ICC ==  iMmUiccMessHandler->GetCardType())
       
   394                 {
       
   395                 //call CmmPhonebookOperatorInit
       
   396                 pointer = CMmPhoneBookOperationInit::NewL(
       
   397                     this,
       
   398                     iMmUiccMessHandler,
       
   399                     aDataPackage
       
   400                     );
       
   401                 }
   359             break;
   402             break;
   360         case ETrIdPbRead:
   403             }
       
   404 
       
   405         case EMmTsyPhoneBookStoreGetInfoIPC:
       
   406         case EMmTsyPhoneBookStoreCacheIPC:
       
   407             {
       
   408 
       
   409             if(UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType())
       
   410                 {
       
   411                 //call CmmPhonebookOperationCache Phonebook
       
   412                 pointer = CMmPhoneBookOperationCache::NewL(
       
   413                         this,
       
   414                         iMmUiccMessHandler,
       
   415                         aIpc,
       
   416                         aDataPackage );
       
   417                 }
       
   418             else if(UICC_CARD_TYPE_ICC ==  iMmUiccMessHandler->GetCardType())
       
   419                 {
       
   420                 //call CmmPhonebookOperatorInit
       
   421                 pointer = CMmPhoneBookOperationCache::NewL(
       
   422                     this,
       
   423                     iMmUiccMessHandler,
       
   424                     aIpc,
       
   425                     aDataPackage );
       
   426                 }
   361             break;
   427             break;
   362         case ETrIdPbUpdate:
   428             }
       
   429         case EMmTsyPhoneBookStoreReadIPC:
       
   430         case EMmTsyONStoreReadIPC:
       
   431         case EMmTsyONStoreReadEntryIPC:
       
   432 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   433         case ECustomReadAlphaStringIPC:
       
   434 #endif // INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   435             {
       
   436             //call CmmPhonebookOperatorRead
       
   437             if( UICC_CARD_TYPE_ICC == iMmUiccMessHandler->GetCardType())
       
   438                 {
       
   439                 pointer = CMmPhoneBookOperationRead::NewL(
       
   440                     this,
       
   441                     iMmUiccMessHandler,
       
   442                     aDataPackage );
       
   443                 }
       
   444             else if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType())
       
   445                 {
       
   446                 pointer = CMmPhoneBookOperationRead3g_adn::NewL(
       
   447                         this,
       
   448                         iMmUiccMessHandler,
       
   449                         aDataPackage );
       
   450                 }
   363             break;
   451             break;
   364         case ETrIdPbDelete:
   452             }
   365             
   453         case EMmTsyPhoneBookStoreWriteIPC:
       
   454             {
       
   455             if( UICC_CARD_TYPE_ICC == iMmUiccMessHandler->GetCardType())
       
   456                 {
       
   457                 //call CmmPhonebookOperationWrite
       
   458                 pointer = CMmPhoneBookOperationWrite::NewL(
       
   459                     this,
       
   460                     aDataPackage );
       
   461                 }
       
   462             else if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
       
   463                 {
       
   464                 //call CmmPhonebookOperationWrite
       
   465                 pointer = CMmPhoneBookOperationWrite::NewL(
       
   466                     this,
       
   467                     aDataPackage );
       
   468                 }
   366             break;
   469             break;
       
   470             }
       
   471         case EMmTsyPhoneBookStoreDeleteIPC:
       
   472         case EMmTsyPhoneBookStoreDeleteAllIPC:
       
   473 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   474         case ECustomDeleteAlphaStringIPC:
       
   475 #endif // INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   476             {
       
   477             if( UICC_CARD_TYPE_ICC == iMmUiccMessHandler->GetCardType() )
       
   478                 {
       
   479                 // Create CmmPhoneBookOperationDelete
       
   480                 pointer = CMmPhoneBookOperationDelete::NewL(
       
   481                     this,
       
   482                     iMmUiccMessHandler,
       
   483                     aDataPackage );
       
   484                 }
       
   485             else if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
       
   486                 {
       
   487                 // To be implemented for 3G
       
   488                 }
       
   489             break;
       
   490             }
       
   491         /*
       
   492         case EMobilePhoneGetMailboxNumbers:
       
   493             {
       
   494             pointer =  new ( ELeave )CMmPhonebookOperationCustom(
       
   495                 iMmPhoneBookStoreMessHandler );
       
   496             CleanupStack::PushL( pointer );
       
   497             // Add pointer to array
       
   498             iPtrOperationArray.AppendL( pointer );
       
   499             CleanupStack::Pop( pointer );
       
   500             break;
       
   501             }
       
   502             */
   367         default:
   503         default:
   368             TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::\
   504             {
   369                 ProcessUiccMsg. switch case -> default");
   505             // Nothing to do here
   370             OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKSTOREMESSHANDLER_PROCESSUICCMSG, "CMmPhoneBookStoreMessHandler::ProcessUiccMsg. switch case -> default" );
   506 TFLOGSTRING2("TSY: CMmPhoneBookStoreMessHandler::ExtFuncL - Unknown IPC: %d", aIpc);
       
   507 OstTrace1( TRACE_NORMAL, DUP2_CMMPHONEBOOKSTOREOPERATIONLIST_BUILDL, "CMmPhoneBookStoreOperationList::BuildL;Unknown aIpc=%d", aIpc );
   371             break;
   508             break;
   372         }
   509             }
   373     return(ret);
   510         }
   374     }
   511 
   375 
   512     //return pointer to right operation
   376 
   513     return pointer;
       
   514     }
       
   515 
       
   516 
       
   517 
       
   518 
       
   519 // ---------------------------------------------------------------------------
       
   520 // CMmPhoneBookStoreMessHandler::StorePhonebookEntryL
       
   521 // Store phonebook entry to Array received from commonTSY
       
   522 // ---------------------------------------------------------------------------
       
   523 //
       
   524 
       
   525 void CMmPhoneBookStoreMessHandler::StorePhonebookEntryL(
       
   526         TDes8& aName,
       
   527         TDes8& aNumber,
       
   528         CPhoneBookStoreEntry& aEntry,
       
   529         const TUint16 aFileId,
       
   530         const TInt aIndexToRead,
       
   531         const TBool aMailboxIdExist )
       
   532     {
       
   533     // Save Name
       
   534 
       
   535 TFLOGSTRING("TSY: CMmPhoneBookStoreOperationBase::SeparatePhoneBookEntryFromIsiMsgL. Saving name in commonTSY Array.");
       
   536 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREOPERATIONBASE_STOREPHONEBOOKENTRY, "CMmPhoneBookStoreOperationBase::StorePhonebookEntry. Save name to commonTSY Array" );
       
   537 
       
   538 
       
   539     aEntry.iText = HBufC::NewL( aName.Length() );
       
   540     TPtr ptrToName = aEntry.iText->Des();
       
   541 
       
   542     TBuf8<UICC_EF_MAX_NAME_LEN> aNameString;
       
   543     TUint16 nameLength = aName.Length();
       
   544     if(KMinLength < nameLength)
       
   545         {
       
   546         // Convert String to 8 bit format
       
   547         CMmStaticUtility::ConvertGsmDataToUcs2(aName, nameLength , aNameString );
       
   548         TIsiUtility::CopyFromBigEndian(
       
   549                 aNameString,
       
   550                 ptrToName );
       
   551         }
       
   552 
       
   553     // Store Number
       
   554 
       
   555 TFLOGSTRING("TSY: CMmPhoneBookStoreOperationBase::SeparatePhoneBookEntryFromIsiMsgL. Saving number in commonTSY Array.");
       
   556 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKSTOREOPERATIONBASE_STOREPHONEBOOKENTRY, "CMmPhoneBookStoreOperationBase::StorePhonebookEntry. Save number to commonTSY Array" );
       
   557 
       
   558     TInt numLength = aNumber.Length();
       
   559     if(KMinLength < numLength)
       
   560         {
       
   561         // Check for last lower nibble if " F " then terminate it
       
   562             if( 0x0F == ( aNumber[numLength-1]& 0x0F ))
       
   563                 {
       
   564                 // Decrement the memory allocated by 1
       
   565                 aEntry.iNumber = HBufC::NewL( ( 2*numLength ) - 1 );
       
   566                 }
       
   567             else
       
   568                 {
       
   569                 // Allocate memory for double the number Length
       
   570                 aEntry.iNumber = HBufC::NewL( 2*numLength );
       
   571                 }
       
   572             TPtr ptrToNumber = aEntry.iNumber->Des();
       
   573 
       
   574             // Convert Number to Ascii Code
       
   575             ConvertToUcs2FromBCD(aNumber, ptrToNumber,aFileId);
       
   576 
       
   577         }
       
   578 
       
   579 
       
   580     // If mailbox exists set 1 into higher 8 bits (iLocation is TUint16)
       
   581     if ( aMailboxIdExist )
       
   582         {
       
   583         aEntry.iLocation = 0x0100;
       
   584         }
       
   585 
       
   586     // Set record index
       
   587     aEntry.iLocation = aEntry.iLocation | aIndexToRead;
       
   588 
       
   589     // reset both buffers after storing data to commonTSY buffer
       
   590     aName.Zero();
       
   591     aNumber.Zero();
       
   592     }
       
   593 
       
   594 
       
   595 
       
   596 
       
   597 // -----------------------------------------------------------------------------
       
   598 // CMmPhoneBookStoreMessHandler::CopyToUcs2FromBCD
       
   599 // Copies unsigned BCD coded digits to Ascii code
       
   600 // by index
       
   601 // -----------------------------------------------------------------------------
       
   602 //
       
   603 void CMmPhoneBookStoreMessHandler::ConvertToUcs2FromBCD
       
   604        (
       
   605         const TDesC8 &aSource,
       
   606         TDes16 &aTarget,
       
   607         const TUint16 aFileId
       
   608         )
       
   609     {
       
   610 TFLOGSTRING("TSY: CMmPhoneBookStoreOperationBase::ConvertToUcs2FromBCD");
       
   611 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_CONVERTTOUCS2FROMBCD, "CMmPhoneBookStoreMessHandler::ConvertToUcs2FromBCD" );
       
   612 
       
   613     TInt maxLength(0);
       
   614     TUint8 data;
       
   615     TBool plus_in_middle = EFalse;
       
   616     TBool first_occurance = ETrue;
       
   617     TUint8 nibble = 0;
       
   618 
       
   619     // Check for the Valid Length for Target
       
   620     if( aTarget.MaxSize() < (aSource.Length()* 2))
       
   621         {
       
   622         // Assign Target length to Max Length
       
   623         maxLength = ( aTarget.MaxSize()/2 );
       
   624 
       
   625         // Chekc for if target Max length is Odd number
       
   626         if( 1 == ( aTarget.MaxLength()% 2 ))
       
   627             {
       
   628             maxLength++;
       
   629             }
       
   630         }
       
   631     else
       
   632         {
       
   633         maxLength = aSource.Length();
       
   634         }
       
   635 
       
   636     // Check for first Byte which is TON/NPI nit equal to 0xFF, which is unused
       
   637     if(aSource[0] != TON_NPI_NO_TEL_NBR)
       
   638         {
       
   639         // Check for International number
       
   640         if( MASK_TON_FROM_TON_NPI_BYTE(aSource[0]) == TON_INTERNATIONAL)
       
   641             {
       
   642             data = MASK_LOWER_NIBBLE_OF_BCD(aSource[1]);
       
   643 
       
   644             // Check for first lower nibble if first byte is '*' and '#'
       
   645             if(( 0xA != data) && ( 0xB != data))
       
   646                 {
       
   647                 // if not then Append + in Start
       
   648                 aTarget.Append('+');
       
   649                 }
       
   650             else
       
   651                 {
       
   652                 // Stiore the informtion that '+' could be in between
       
   653                 plus_in_middle = ETrue;
       
   654                 }
       
   655             }
       
   656         }
       
   657 
       
   658 
       
   659     // Read lower nibble
       
   660         nibble = 0;
       
   661     // Store rest of the digits
       
   662     for( TInt count = 1; count < maxLength ; )
       
   663         {
       
   664         // Check if it's higher nibble
       
   665         if(1 == nibble)
       
   666             {
       
   667             // Shift higher nibble dayta to lower nibble
       
   668             data = aSource[count]>>4;
       
   669             count++;
       
   670             }
       
   671         else
       
   672             {
       
   673             data = aSource[count];
       
   674             }
       
   675         data = data & 0x0f;
       
   676         // Check for higher nibble to End Mark for odd numbers
       
   677         if(0x0F != data)
       
   678             {
       
   679             // Check for the phonebook type to decide which
       
   680             //lookup table should be checked
       
   681             if( PB_ADN_FID == aFileId )
       
   682                 {
       
   683                 // Chek for lookup table LookUptable ADN
       
   684                 aTarget.Append(LookupArrayAdn[data]);
       
   685                 }
       
   686             else
       
   687                 {
       
   688                 // for all other phonebooks
       
   689                 aTarget.Append(LookupArray[data]);
       
   690                 }
       
   691             }
       
   692         // Change the nibble to read next digit
       
   693         if(0 == nibble)
       
   694             {
       
   695             nibble = 1;
       
   696             }
       
   697         else
       
   698             {
       
   699             nibble = 0;
       
   700             }
       
   701         }
       
   702 
       
   703     TInt offset = 0;
       
   704     // start from higher nibble
       
   705     nibble = 1;
       
   706     // Check if its a international number and plus in middle is present
       
   707     if( plus_in_middle )
       
   708         {
       
   709         for(TInt count = 1; count < maxLength; )
       
   710             {
       
   711             // Check if it's higher nibble
       
   712             if(1 == nibble)
       
   713                 {
       
   714                 // Shift higher nibble dayta to lower nibble
       
   715                 data = aSource[count]>>4;
       
   716                 count++;
       
   717                 }
       
   718             else
       
   719                 {
       
   720                 data = aSource[count];
       
   721                 }
       
   722             data = data & 0x0f;
       
   723             // Check for higher nibble to End Mark for odd numbers
       
   724             if((0xA == data) || (0xB == data))
       
   725                 {
       
   726                 first_occurance = EFalse;
       
   727                 }
       
   728             if(!first_occurance)
       
   729                 {
       
   730                 // Check for if data is some digit or cahracter
       
   731                 if((data!=0xA) && ( data!=0xB))
       
   732                     {
       
   733                     offset = 2 * (count - 1);
       
   734                     if(1 == nibble)
       
   735                         {
       
   736                         offset = offset -1;
       
   737                         }
       
   738                     break;
       
   739                     }
       
   740                 }
       
   741 
       
   742             // Change the nibble to read next digit
       
   743             if(0 == nibble)
       
   744                 {
       
   745                 nibble = 1;
       
   746                 }
       
   747             else
       
   748                 {
       
   749                 nibble = 0;
       
   750                 }
       
   751             }// End of checking offset for insert '+'
       
   752         }
       
   753     // To insert '+' in between the number
       
   754     TBuf16<1> insertBuffer;
       
   755     insertBuffer.Append('+');
       
   756     if(plus_in_middle)
       
   757         {
       
   758         // Insert '+'
       
   759         aTarget.Insert(offset,insertBuffer);
       
   760         }
       
   761  }
       
   762 
       
   763 
       
   764 
       
   765 // -----------------------------------------------------------------------------
       
   766 // CMmPhoneBookStoreMessHandler::CopyToUcs2FromBCD
       
   767 // Copies unsigned BCD coded digits to Ascii code
       
   768 // by index
       
   769 // -----------------------------------------------------------------------------
       
   770 //
       
   771 TInt CMmPhoneBookStoreMessHandler::ConvertToBCDFromUCS2
       
   772        (
       
   773         TDes16 &aSource,
       
   774         TDes8 &aTarget,
       
   775         TUint16 aFileId )
       
   776     {
       
   777 TFLOGSTRING("TSY: CMmPhoneBookStoreOperationBase::ConvertToBCDFromUCS2");
       
   778 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_CONVERTTOBCDFROMUCS2, "CMmPhoneBookStoreMessHandler::ConvertToBCDFromUCS2" );
       
   779 
       
   780     TInt ret ( KErrNone );
       
   781     TInt count( 0 );
       
   782     TUint8 plusCount( 0 );
       
   783     TBool internationalNumber ( EFalse );
       
   784 
       
   785         // Search if more than 1 '+' is present then its a illegal number
       
   786     for( TInt i=0; i<aSource.Length(); i++ )
       
   787         {
       
   788         if( '+' == aSource[i] )
       
   789             {
       
   790             plusCount++;
       
   791             }
       
   792         }
       
   793 
       
   794 
       
   795     if( plusCount <= 1 )
       
   796         {
       
   797         if( UICC_INTERNATIONAL_NUM == aSource[count] )
       
   798             {
       
   799             aTarget.Append( TON_NPI_INTERNATIONAL );
       
   800             internationalNumber = ETrue;
       
   801             }
       
   802         if( ( '*' == aSource[count] ) || ( '#' == aSource[count] ))
       
   803             {
       
   804             if( plusCount == 1)
       
   805                 {
       
   806                 aTarget.Append( TON_NPI_INTERNATIONAL );
       
   807                 internationalNumber = ETrue;
       
   808                 }
       
   809             }
       
   810         if( ! internationalNumber )
       
   811             {
       
   812             aTarget.Append( TON_NPI_UNKNOWN );
       
   813             }
       
   814         }
       
   815     else
       
   816         {
       
   817         // its a Illegal number
       
   818         ret = KErrGeneral;
       
   819         aTarget.Append( TON_NPI_NO_TEL_NBR );
       
   820         }
       
   821 
       
   822     count = 0;
       
   823     while ( count < aSource.Length() )
       
   824     {
       
   825     if( 0 <= GetBCDCodeforUCS( aSource[count], aFileId ) )
       
   826         {
       
   827         TInt lo = GetBCDCodeforUCS( aSource[count++], aFileId ); // low nibble
       
   828         TInt hi = ( count < aSource.Length() ) ? aSource[count++] : 0xf; // high nibble
       
   829         aTarget.Append( (hi<<4)|lo );
       
   830         }
       
   831     }
       
   832 
       
   833     return ret;
       
   834     }
       
   835 
       
   836 
       
   837 
       
   838 // ---------------------------------------------------------------------------
       
   839 // CMmPhoneBookStoreMessHandler::GetBCDCodeforUCS
       
   840 // Convert UCS String to BCD coding
       
   841 // ---------------------------------------------------------------------------
       
   842 //
       
   843 TInt CMmPhoneBookStoreMessHandler::GetBCDCodeforUCS(
       
   844          TUint16 aUCSCharacter,
       
   845          TUint16 aFileId )
       
   846     {
       
   847 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::GetBCDCodeforUCS");
       
   848 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_GETBCDCODEFORUCS, "CMmPhoneBookStoreMessHandler::GetBCDCodeforUCS" );
       
   849     TInt bcdNumber( -1 );
       
   850 
       
   851     if ( aUCSCharacter >= '0' && aUCSCharacter <='9')
       
   852         bcdNumber = aUCSCharacter - '0';
       
   853      else if (aUCSCharacter == 'w' && aFileId == PB_ADN_FID)
       
   854          bcdNumber = 0xd;
       
   855      else if (aUCSCharacter == '?')
       
   856          bcdNumber = 0xd;
       
   857      else
       
   858          bcdNumber = -1;
       
   859     return bcdNumber;
       
   860     }
       
   861 
       
   862 // ---------------------------------------------------------------------------
       
   863 // CMmPhoneBookStoreMessHandler::StoreEntryToPhoenBookList
       
   864 // Stores PhoneBook Entry in PhoneBook list
       
   865 // ---------------------------------------------------------------------------
       
   866 //
       
   867 
       
   868 void CMmPhoneBookStoreMessHandler::StoreEntryToPhoneBookList( TPBEntry* aStoreEntry, TUint8 aPBIndex )
       
   869     {
       
   870 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::StoreEntryToPhoenBookList");
       
   871 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_STOREENTRYTOPHOENBOOKLIST, "CMmPhoneBookStoreMessHandler::StoreEntryToPhoenBookList" );
       
   872 
       
   873     iPBEntryList[aPBIndex].iEntryList.Append( aStoreEntry );
       
   874     }
       
   875 
       
   876 // ---------------------------------------------------------------------------
       
   877 // CMmPhoneBookStoreMessHandler::ResetEntryInPhoneBookList
       
   878 // Resets a phonebook entry in phonebook list
       
   879 // ---------------------------------------------------------------------------
       
   880 //
       
   881 void CMmPhoneBookStoreMessHandler::ResetEntryInPhoneBookList(
       
   882     TUint8 aPbIndex,
       
   883     TInt aEntryIndex )
       
   884     {
       
   885 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::ResetEntryInPhoneBookList");
       
   886 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_RESETENTRYINPHONEBOOKLIST, "CMmPhoneBookStoreMessHandler::ResetEntryInPhoneBookList" );
       
   887     TInt numOfEntries( iPBEntryList[aPbIndex].iEntryList.Count() );
       
   888     for( TInt i( 0 ); i < numOfEntries; i++)
       
   889         {
       
   890         if ( aEntryIndex == iPBEntryList[aPbIndex].iEntryList[i]->iEntryIndex )
       
   891             {
       
   892             // Reset values
       
   893             iPBEntryList[aPbIndex].iEntryList[i]->iEntryPresent = EFalse;
       
   894             iPBEntryList[aPbIndex].iEntryList[i]->PBEntryExtRecord.Reset();
       
   895             // Exit loop
       
   896             i = numOfEntries;
       
   897             }
       
   898         }
       
   899     }
       
   900 
       
   901 // ---------------------------------------------------------------------------
       
   902 // CMmPhoneBookStoreMessHandler::IndexCheckInPBList
       
   903 // Gets pointer to CMmMessageRouter object.
       
   904 // ---------------------------------------------------------------------------
       
   905 //
       
   906 
       
   907 TBool CMmPhoneBookStoreMessHandler::IndexCheckInPBList( TUint8 aIndex, TUint8 aPBIndex, TPBEntry& aEntry )
       
   908     {
       
   909 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::IndexCheckInPBList");
       
   910 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_INDEXCHECKINPBLIST, "CMmPhoneBookStoreMessHandler::IndexCheckInPBList" );
       
   911 
       
   912     TBool entryFound( EFalse );
       
   913 
       
   914     for( TInt count = 0; count < iPBEntryList[aPBIndex].iEntryList.Count(); count++)
       
   915         {
       
   916         if( aIndex == iPBEntryList[aPBIndex].iEntryList[count]->iEntryIndex )
       
   917             {
       
   918             entryFound = ETrue;
       
   919             aEntry = *( iPBEntryList[aPBIndex].iEntryList[count] );
       
   920             }
       
   921         }
       
   922     return entryFound;
       
   923     }
       
   924 
       
   925 // ---------------------------------------------------------------------------
       
   926 // CMmPhoneBookStoreMessHandler::GetIndexForPresentEntry
       
   927 // Gets the index for present entry in the Stored list
       
   928 // ---------------------------------------------------------------------------
       
   929 //
       
   930 
       
   931 TInt CMmPhoneBookStoreMessHandler::GetIndexForPresentEntry( TUint8 aIndex, TUint8 aPBIndex )
       
   932     {
       
   933 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::GetIndexForPresentEntry");
       
   934 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_GETINDEXFORPRESENTENTRY, "CMmPhoneBookStoreMessHandler::GetIndexForPresentEntry" );
       
   935 
       
   936     TInt count( -1 );
       
   937     for( ;( count+1 ) < iPBEntryList[aPBIndex].iEntryList.Count(); count++)
       
   938         {
       
   939         if( aIndex == iPBEntryList[aPBIndex].iEntryList[count+1]->iEntryIndex )
       
   940             {
       
   941             return (count+1);
       
   942             }
       
   943         }
       
   944     return count;
       
   945     }
       
   946 
       
   947 // ---------------------------------------------------------------------------
       
   948 // CMmPhoneBookStoreMessHandler::EmptyEntryCheckInPBList
       
   949 // Checks for Empty entry in the stored list
       
   950 // ---------------------------------------------------------------------------
       
   951 //
       
   952 
       
   953 TInt CMmPhoneBookStoreMessHandler::EmptyEntryCheckInPBList( TUint8 aPBIndex )
       
   954     {
       
   955 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::EmptyEntryCheckInPBList");
       
   956 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_EMPTYENTRYCHECKINPBLIST, "CMmPhoneBookStoreMessHandler::EmptyEntryCheckInPBList" );
       
   957 
       
   958     TInt entryNumber( 0 );
       
   959 
       
   960     for( TInt count = 0; count < iPBEntryList[aPBIndex].iEntryList.Count(); count++)
       
   961         {
       
   962         if( !iPBEntryList[aPBIndex].iEntryList[count]->iEntryPresent )
       
   963             {
       
   964             entryNumber = iPBEntryList[aPBIndex].iEntryList[count]->iEntryIndex;
       
   965             break;
       
   966             }
       
   967         }
       
   968     return entryNumber;
       
   969     }
       
   970 
       
   971 
       
   972 // ---------------------------------------------------------------------------
       
   973 // CMmPhoneBookStoreMessHandler::EmptyEntryCheckInPBList
       
   974 // Gets pointer to CMmMessageRouter object.
       
   975 // ---------------------------------------------------------------------------
       
   976 //
       
   977 
       
   978 void CMmPhoneBookStoreMessHandler::UpdateEntryFromList( TPBEntry* aEntry, TUint8 aIndex , TUint8 aPBIndex)
       
   979     {
       
   980 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::RemoveEntryFromList");
       
   981 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_REMOVEENTRYFROMLIST, "CMmPhoneBookStoreMessHandler::RemoveEntryFromList" );
       
   982 
       
   983     iPBEntryList[aPBIndex].iEntryList[aIndex] = aEntry;
       
   984 
       
   985     }
       
   986 
       
   987 // ---------------------------------------------------------------------------
       
   988 // CMmPhoneBookStoreMessHandler::RemoveExtEntryFromList
       
   989 // REmove the EXt record form the stored list
       
   990 // ---------------------------------------------------------------------------
       
   991 //
       
   992 
       
   993 void CMmPhoneBookStoreMessHandler::RemoveExtEntryFromList( TUint8 aIndex , TUint8 aPBIndex)
       
   994     {
       
   995 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::RemoveExtEntryFromList");
       
   996 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_REMOVEEXTENTRYFROMLIST, "CMmPhoneBookStoreMessHandler::RemoveExtEntryFromList" );
       
   997 
       
   998     TInt count = iPBEntryList[aPBIndex].iEntryList[aIndex]->PBEntryExtRecord.Count();
       
   999     if( 0 < count )
       
  1000         {
       
  1001         iPBEntryList[aPBIndex].iEntryList[aIndex]->PBEntryExtRecord.Remove( count-1 );
       
  1002         iPBEntryList[aPBIndex].iEntryList[aIndex]->PBEntryExtRecord.Compress();
       
  1003         }
       
  1004     }
   377 
  1005 
   378 
  1006 
   379 // ---------------------------------------------------------------------------
  1007 // ---------------------------------------------------------------------------
   380 // CMmPhoneBookStoreMessHandler::MessageRouter
  1008 // CMmPhoneBookStoreMessHandler::MessageRouter
   381 // Gets pointer to CMmMessageRouter object.
  1009 // Gets pointer to CMmMessageRouter object.
   382 // ---------------------------------------------------------------------------
  1010 // ---------------------------------------------------------------------------
   383 //
  1011 //
   384 CMmMessageRouter* CMmPhoneBookStoreMessHandler::MessageRouter()
  1012 CMmMessageRouter* CMmPhoneBookStoreMessHandler::MessageRouter()
   385     {
  1013     {
   386     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::MessageRouter");
  1014 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::MessageRouter");
   387 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_MESSAGEROUTER, "CMmPhoneBookStoreMessHandler::MessageRouter" );
  1015 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_MESSAGEROUTER, "CMmPhoneBookStoreMessHandler::MessageRouter" );
   388 
  1016 
   389     return iMessageRouter;
  1017     return iMessageRouter;
   390     }
  1018     }
   391 
  1019 
   396 // Gets pointer to CMmMessageRouter object.
  1024 // Gets pointer to CMmMessageRouter object.
   397 // ---------------------------------------------------------------------------
  1025 // ---------------------------------------------------------------------------
   398 //
  1026 //
   399 CMmUiccMessHandler* CMmPhoneBookStoreMessHandler::UiccMessHandler()
  1027 CMmUiccMessHandler* CMmPhoneBookStoreMessHandler::UiccMessHandler()
   400     {
  1028     {
   401     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::UiccMessHandler");
  1029 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::UiccMessHandler");
   402 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_UICCMESSHANDLER, "CMmPhoneBookStoreMessHandler::UiccMessHandler" );
  1030 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_UICCMESSHANDLER, "CMmPhoneBookStoreMessHandler::UiccMessHandler" );
   403 
  1031 
   404     return iMmUiccMessHandler;
  1032     return iMmUiccMessHandler;
   405     }
  1033     }
   406 
  1034 
   410 // Gets pointer to PhoNetSender object.
  1038 // Gets pointer to PhoNetSender object.
   411 // ---------------------------------------------------------------------------
  1039 // ---------------------------------------------------------------------------
   412 //
  1040 //
   413 CMmPhoNetSender* CMmPhoneBookStoreMessHandler::PhoNetSender()
  1041 CMmPhoNetSender* CMmPhoneBookStoreMessHandler::PhoNetSender()
   414     {
  1042     {
   415     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::PhoNetSender");
  1043 TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::PhoNetSender");
   416 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_PHONETSENDER, "CMmPhoneBookStoreMessHandler::PhoNetSender" );
  1044 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_PHONETSENDER, "CMmPhoneBookStoreMessHandler::PhoNetSender" );
   417 
  1045 
   418     return iPhoNetSender;
  1046     return iPhoNetSender;
   419     }
  1047     }
   420 
  1048 
   421 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   422 // ---------------------------------------------------------------------------
       
   423 // CMmPhoneBookStoreMessHandler::Gas
       
   424 // Gets pointer to list of Group Alpha String
       
   425 // ---------------------------------------------------------------------------
       
   426 //
       
   427 CArrayPtrSeg<CMmPhonebookAlphaString>* CMmPhoneBookStoreMessHandler::Gas()
       
   428     {
       
   429     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::Gas");
       
   430 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_GAS, "CMmPhoneBookStoreMessHandler::Gas" );
       
   431 
       
   432     return iGas;
       
   433     }
       
   434 
       
   435 // ---------------------------------------------------------------------------
       
   436 // CMmPhoneBookStoreMessHandler::SetGas
       
   437 // Sets pointer to list of Group Alpha String
       
   438 // ---------------------------------------------------------------------------
       
   439 //
       
   440 void CMmPhoneBookStoreMessHandler::SetGas(
       
   441     CArrayPtrSeg<CMmPhonebookAlphaString>* aGas )
       
   442     {
       
   443     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::SetGas");
       
   444 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_SETGAS, "CMmPhoneBookStoreMessHandler::SetGas" );
       
   445     iGas = aGas;
       
   446     }
       
   447 
       
   448 // ---------------------------------------------------------------------------
       
   449 // CMmPhoneBookStoreMessHandler::Aas
       
   450 // Gets pointer to list of Additional Alpha String
       
   451 // ---------------------------------------------------------------------------
       
   452 //
       
   453 CArrayPtrSeg<CMmPhonebookAlphaString>* CMmPhoneBookStoreMessHandler::Aas()
       
   454     {
       
   455     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::Aas");
       
   456 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_AAS, "CMmPhoneBookStoreMessHandler::Aas" );
       
   457 
       
   458     return iAas;
       
   459     }
       
   460 
       
   461 // ---------------------------------------------------------------------------
       
   462 // CMmPhoneBookStoreMessHandler::SetGas
       
   463 // Sets pointer to list of Additional Alpha String
       
   464 // ---------------------------------------------------------------------------
       
   465 //
       
   466 void CMmPhoneBookStoreMessHandler::SetAas(
       
   467     CArrayPtrSeg<CMmPhonebookAlphaString>* aAas )
       
   468     {
       
   469     TFLOGSTRING("TSY: CMmPhoneBookStoreMessHandler::SetAas");
       
   470 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKSTOREMESSHANDLER_SETAAS, "CMmPhoneBookStoreMessHandler::SetAas" );
       
   471     iAas = aAas;
       
   472     }
       
   473 #endif // INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   474 
  1049 
   475 // End of File
  1050 // End of File