vmbx/vmbxengine/src/vmbxpbkstore.cpp
changeset 27 7eb70891911c
parent 19 e44a8c097b15
child 31 a2467631ae02
equal deleted inserted replaced
23:427125ac6cb8 27:7eb70891911c
    57 CVmbxPbkStore:: ~CVmbxPbkStore()
    57 CVmbxPbkStore:: ~CVmbxPbkStore()
    58     {
    58     {
    59     VMBLOGSTRING( "VMBX: CVmbxPbkStore::~CVmbxPbkStore =>" );
    59     VMBLOGSTRING( "VMBX: CVmbxPbkStore::~CVmbxPbkStore =>" );
    60     Cancel();
    60     Cancel();
    61     iPhoneBook.Close();
    61     iPhoneBook.Close();
    62     delete iAlphaStringFromSIM;
       
    63     delete iWait;
    62     delete iWait;
    64     delete iETelConnection;
    63     delete iETelConnection;
    65     VMBLOGSTRING( "VMBX: CVmbxPbkStore::~CVmbxPbkStore <=" );
    64     VMBLOGSTRING( "VMBX: CVmbxPbkStore::~CVmbxPbkStore <=" );
    66     }
    65     }
    67 
    66 
   249             // Type of index is TUint16 in Multimode ETel and TInt in old ETel.
   248             // Type of index is TUint16 in Multimode ETel and TInt in old ETel.
   250             result = pbkBuffer->PutTagAndValue( 
   249             result = pbkBuffer->PutTagAndValue( 
   251             RMobilePhoneBookStore::ETagPBAdnIndex, (TUint16)entryIndex );
   250             RMobilePhoneBookStore::ETagPBAdnIndex, (TUint16)entryIndex );
   252             VMBLOGSTRING2( "VMBX: CVmbxPbkStore::Write: ETagPBAdnIndex \
   251             VMBLOGSTRING2( "VMBX: CVmbxPbkStore::Write: ETagPBAdnIndex \
   253                     result=%I",  result );
   252                     result=%I",  result );
   254             // Add name if it existed on SIM card,Type of ETagPBText is TDes16
   253             // Add name, Type of ETagPBText is TDes16
   255             if ( iAlphaStringFromSIM )
   254             TPtrC vmbxName( KNullDesC );
   256                 {
   255             aEntry.GetVmbxName( vmbxName );
   257                 result = pbkBuffer->PutTagAndValue( 
   256             result = pbkBuffer->PutTagAndValue( 
   258                 RMobilePhoneBookStore::ETagPBText, *iAlphaStringFromSIM );
   257             RMobilePhoneBookStore::ETagPBText, vmbxName );
   259                 VMBLOGSTRING2( "VMBX: CVmbxPbkStore::Write: ETagPBText\
   258             VMBLOGSTRING2( "VMBX: CVmbxPbkStore::Write: ETagPBText\
   260                         result=%I",  result );
   259                     result=%I",  result );
   261                 }
   260             // Add number, Type of ETagPBNumber is TDes16
   262             TPtrC vmbxNumber( KNullDesC );
   261             TPtrC vmbxNumber( KNullDesC );
   263             result = aEntry.GetVmbxNumber( vmbxNumber );
   262             aEntry.GetVmbxNumber( vmbxNumber );
   264             if ( KErrNone == result )
   263             result = pbkBuffer->PutTagAndValue( 
   265                 {
   264             RMobilePhoneBookStore::ETagPBNumber, vmbxNumber );
   266                 // Add number,Type of ETagPBNumber is TDes16
   265             VMBLOGSTRING2( "VMBX: CVmbxPbkStore::Write: ETagPBNumber\
   267                 result = pbkBuffer->PutTagAndValue( 
   266                     result=%I",  result );
   268                 RMobilePhoneBookStore::ETagPBNumber, vmbxNumber );
       
   269                 VMBLOGSTRING2( "VMBX: CVmbxPbkStore::Write: ETagPBNumber\
       
   270                         result=%I",  result );
       
   271                 }
       
   272             }
   267             }
   273 
   268 
   274         if ( KErrNone == result )
   269         if ( KErrNone == result )
   275             {
   270             {
   276             if ( iPhoneBookType == EMBDNPhoneBook )
   271             if ( iPhoneBookType == EMBDNPhoneBook )
   475     VMBLOGSTRING( "VMBX: CVmbxPbkStore::SimReadL =>" );
   470     VMBLOGSTRING( "VMBX: CVmbxPbkStore::SimReadL =>" );
   476 
   471 
   477     TInt numEntries( 1 );
   472     TInt numEntries( 1 );
   478     TBuf8<KVmbxPhonebookBufferSize> pbData;
   473     TBuf8<KVmbxPhonebookBufferSize> pbData;
   479 
   474 
   480     delete iAlphaStringFromSIM;
       
   481     iAlphaStringFromSIM = NULL;
       
   482     TInt result( KErrInUse );
   475     TInt result( KErrInUse );
   483     if ( iPhoneBookType == EMBDNPhoneBook )
   476     if ( iPhoneBookType == EMBDNPhoneBook )
   484         {
   477         {
   485         RMobilePhone::TMobilePhoneVoicemailIdsV3 mbdnInfo;
   478         RMobilePhone::TMobilePhoneVoicemailIdsV3 mbdnInfo;
   486         result = GetMbdnInfo( EVmbxAlsLine1, mbdnInfo );
   479         result = GetMbdnInfo( EVmbxAlsLine1, mbdnInfo );
   546 //
   539 //
   547 void CVmbxPbkStore::ParseDataL( CVoiceMailboxEntry& aEntry, TDes8& aPbData )
   540 void CVmbxPbkStore::ParseDataL( CVoiceMailboxEntry& aEntry, TDes8& aPbData )
   548     {
   541     {
   549     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ParseDataL =>" );
   542     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ParseDataL =>" );
   550     TInt result( KErrNotFound );
   543     TInt result( KErrNotFound );
   551     delete iAlphaStringFromSIM;
       
   552     iAlphaStringFromSIM = NULL;
       
   553 
   544 
   554     VMBLOGSTRING2( "CVmbxPbkStore::ParseDataL Lengh = %d", aPbData.Length() );
   545     VMBLOGSTRING2( "CVmbxPbkStore::ParseDataL Lengh = %d", aPbData.Length() );
   555 
   546 
   556     if ( aPbData.Length() )
   547     if ( aPbData.Length() )
   557         {
   548         {
   616                                          CVoiceMailboxEntry& aEntry )
   607                                          CVoiceMailboxEntry& aEntry )
   617     {
   608     {
   618     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ReadPbkDataL =>" );
   609     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ReadPbkDataL =>" );
   619 
   610 
   620     TInt result( KErrNone );
   611     TInt result( KErrNone );
       
   612     TInt next( KErrNone );
       
   613     TBool found( EFalse );
   621     TUint8 tagValue( 0 );
   614     TUint8 tagValue( 0 );
   622     CPhoneBookBuffer::TPhBkTagType dataType(
   615     CPhoneBookBuffer::TPhBkTagType dataType(
   623                                           CPhoneBookBuffer::EPhBkTypeNoData );
   616                                           CPhoneBookBuffer::EPhBkTypeNoData );
   624 
   617 
   625     result = aPbkBuffer->GetTagAndType( tagValue, dataType );
   618     result = aPbkBuffer->GetTagAndType( tagValue, dataType );
   626 
   619 
   627     // loop through data to find a number and an possible alpha string
   620     // loop through data to find a number and an possible alpha string
   628     while ( result == KErrNone && aPbkBuffer->RemainingReadLength() > 0 )
   621     while ( next == KErrNone && result == KErrNone )
   629         {
   622         {
   630         VMBLOGSTRING2("VMBX: CVmbxPbkStore::ReadPbkDataL: tagValue: %d",
   623         VMBLOGSTRING2("VMBX: CVmbxPbkStore::ReadPbkDataL: tagValue: %d",
   631          tagValue );
   624          tagValue );
   632         VMBLOGSTRING2("VMBX: CVmbxPbkStore::ReadPbkDataL: dataType: %d",
   625         VMBLOGSTRING2("VMBX: CVmbxPbkStore::ReadPbkDataL: dataType: %d",
   633          dataType );
   626          dataType );
   634 
   627 
   635         // Check for text field
   628         // Check for text field
   636         if ( tagValue == RMobilePhoneBookStore::ETagPBText )
   629         if ( tagValue == RMobilePhoneBookStore::ETagPBText )
   637             {
   630             {
       
   631             VMBLOGSTRING("VMBX: CVmbxPbkStore::ReadPbkDataL: \
       
   632                           ETagPBText found Alpha ID" );
       
   633             found = ETrue;
   638             // Alpha string field found from TLV entry,
   634             // Alpha string field found from TLV entry,
   639             // assuming 16bit data
   635             // assuming 16bit data
   640             TPtrC16 alphaPtrC;
   636             TPtrC16 alphaPtrC;
   641             result = aPbkBuffer->GetValue( alphaPtrC );
   637             result = aPbkBuffer->GetValue( alphaPtrC );
       
   638             
   642             if ( KErrNone == result )
   639             if ( KErrNone == result )
   643                 {
   640                 {
   644                 iAlphaStringFromSIM = alphaPtrC.AllocL();
   641                 // set name to vmbx entry
   645                 VMBLOGSTRING2("VMBX: CVmbxPbkStore::ReadPbkDataL: \
   642                 result = aEntry.SetVmbxName( alphaPtrC );
   646                 iAlphaStringFromSIM: %S", iAlphaStringFromSIM );
       
   647                 }
   643                 }
   648             }
   644             }
   649 
   645 
   650          // Check for number field
   646         // Check for number field
   651          else if ( tagValue == RMobilePhoneBookStore::ETagPBNumber )
   647         else if ( tagValue == RMobilePhoneBookStore::ETagPBNumber )
   652             {
   648             {
       
   649             VMBLOGSTRING("VMBX: CVmbxPbkStore::ReadPbkDataL: \
       
   650                           ETagPBNumber found Number" );
       
   651             found = ETrue;
   653             // Number field found from TLV entry, assuming 16bit data
   652             // Number field found from TLV entry, assuming 16bit data
   654             TPtrC16 numberPtrC;
   653             TPtrC16 numberPtrC;
   655             result = aPbkBuffer->GetValue( numberPtrC );
   654             result = aPbkBuffer->GetValue( numberPtrC );
   656 
   655 
   657             VMBLOGSTRING( "VMBX: CVmbxPbkStore::ReadPbkDataL:\
       
   658                                             ETagPBNumber found" );
       
   659 
       
   660             if ( KErrNone == result )
   656             if ( KErrNone == result )
   661                 {
   657                 {
   662                 // Error code is returned if number not fit to
   658                 // set number to vmbx entry
   663                 // local buffer.
   659                 result = aEntry.SetVmbxNumber( numberPtrC );
   664                 if ( numberPtrC.Length() > KVmbxMaxNumberLength )
       
   665                     {
       
   666                     result = KErrOverflow;
       
   667                     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ReadPbkDataL: \
       
   668                                             Overflow error" );
       
   669                     }
       
   670                 else
       
   671                     {
       
   672                     result = aEntry.SetVmbxNumber( numberPtrC );
       
   673                     VMBLOGSTRING("VMBX: CVmbxPbkStore::ReadPbkDataL: \
       
   674                                     ETagPBNumber found Number" );
       
   675                     break;
       
   676                     }
       
   677                 }
   660                 }
   678             }
   661             }
   679          else
   662         else
   680             {
   663             {
   681             // skip field
   664             // skip field
   682             aPbkBuffer->SkipValue( dataType );
   665             aPbkBuffer->SkipValue( dataType );
   683             VMBLOGSTRING( "VMBX: CVmbxPbkStore::ReadPbkDataL: SkipValue" );
   666             VMBLOGSTRING( "VMBX: CVmbxPbkStore::ReadPbkDataL: SkipValue" );
   684             }
   667             }
   685         // read next if no errors
   668         // read next if no errors
   686         if ( KErrNone == result )
   669         if ( KErrNone == result )
   687             {
   670             {
   688             // Read next field type
   671             // Read next field type
   689             result = aPbkBuffer->GetTagAndType( tagValue, dataType );
   672             next = aPbkBuffer->GetTagAndType( tagValue, dataType );
   690             VMBLOGSTRING2( "VMBX: CVmbxPbkStore::ReadPbkDataL: \
   673             VMBLOGSTRING2( "VMBX: CVmbxPbkStore::ReadPbkDataL: \
   691                                     next GetTagAndType = %I", result );
   674                                     next GetTagAndType = %I", result );
   692             }
   675             }
   693         }
   676         }
   694 
   677 
       
   678     // Neither alpha string Nor number is found
       
   679     if( KErrNone == result && !found )
       
   680         {
       
   681         result = KErrNotFound;
       
   682         }
       
   683     
   695     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::ReadPbkDataL result=%I", result );
   684     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::ReadPbkDataL result=%I", result );
   696     User::LeaveIfError( result );
   685     User::LeaveIfError( result );
   697     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ReadPbkDataL <=" );
   686     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ReadPbkDataL <=" );
   698     }
   687     }
   699 
   688