vmbx/vmbxengine/src/vmbxpbkstore.cpp
changeset 19 e44a8c097b15
parent 12 ae8abd0db65c
child 27 7eb70891911c
equal deleted inserted replaced
15:d7fc66ccd6fb 19:e44a8c097b15
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    22 #include <cvoicemailboxentry.h>
    22 #include <cvoicemailboxentry.h>
    23 
    23 
    24 #include "vmbxutilities.h"
    24 #include "vmbxutilities.h"
    25 #include "vmbxetelconnection.h"
    25 #include "vmbxetelconnection.h"
    26 #include "vmbxlogger.h"
    26 #include "vmbxlogger.h"
    27 
       
    28 #include "vmbxpbkstore.h"
    27 #include "vmbxpbkstore.h"
    29 
    28 
       
    29 #include <e32property.h>
       
    30 #include <simutils.h>
       
    31 #include <startupdomainpskeys.h>
    30 //CONSTANTS
    32 //CONSTANTS
    31 // Amount of retries to be performed.
    33 // Amount of retries to be performed.
    32 const TInt KVmbxPhonebookBufferSize( 150 );
    34 const TInt KVmbxPhonebookBufferSize( 150 );
    33 
    35 
    34 // ============================ MEMBER FUNCTIONS =============================
    36 // ============================ MEMBER FUNCTIONS =============================
    85 // ---------------------------------------------------------------------------
    87 // ---------------------------------------------------------------------------
    86 //
    88 //
    87 void CVmbxPbkStore::ConstructL()
    89 void CVmbxPbkStore::ConstructL()
    88     {
    90     {
    89     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ConstructL =>" );
    91     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ConstructL =>" );
       
    92     TInt value( 0 );
       
    93     TInt res = RProperty::Get( KPSUidStartup, KPSSimStatus, value );
       
    94     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::ConstructL res = %d", res );
       
    95     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::ConstructL value = %d", value );
       
    96     if ( (ESimUsable != value && ESimReadable != value ) || KErrNone != res )
       
    97         {
       
    98         // Sim card not ready to use
       
    99         User::Leave( KErrNotReady );
       
   100         }
    90     // Open tel server and phone
   101     // Open tel server and phone
    91     iETelConnection = CVmbxETelConnection::NewL();
   102     iETelConnection = CVmbxETelConnection::NewL();
    92 
   103 
    93     iWait = new( ELeave ) CActiveSchedulerWait; 
   104     iWait = new( ELeave ) CActiveSchedulerWait; 
    94     TVmbxAlsLineType alsLine = VmbxUtilities::AlsLine();
   105     TVmbxAlsLineType alsLine = VmbxUtilities::AlsLine();
    95 
   106 
    96     // Supported ALS line
   107     // Supported ALS line,ALS line on
    97     if ( EVmbxAlsLineDefault != alsLine )
   108     if ( EVmbxAlsLineDefault != alsLine )
    98         {
   109         {
    99         // open 6f17 file
   110         // open 6f17 file ,if not found the file, leave
   100         User::LeaveIfError( OpenVmbxPhonebook() );
   111         User::LeaveIfError( OpenVmbxPhonebook() );
   101         }
   112         }
   102     // Not supported ALS line
   113     // Not supported ALS line,ALS line off
   103     else
   114     else
   104         {
   115         {
   105         // USIM exist
   116         // Open 6fc7 file, if not found, open 6f17 file
   106         if ( SimFileExistsAndReadAccess() )
   117         TInt result = OpenMbdnPhonebook();
   107             {
   118         if ( KErrPathNotFound == result )
   108             // Open 6fc7 file
   119             {
   109             User::LeaveIfError( OpenMbdnPhonebook() );
   120             //close 6fc7 and open 6f17 file
   110             }
   121             iPhoneBook.Close();
   111         // USIM not exist, open 6f17 file
   122             // open 6f17 file ,if not found the file, leave
       
   123             User::LeaveIfError( OpenVmbxPhonebook() );
       
   124             }
   112         else
   125         else
   113             {
   126             {
   114             VMBLOGSTRING( "VMBX: CVmbxPbkStore::ConstructL: no mbdn file\
   127             User::LeaveIfError( result );
   115                 then open 6f17 file" );
       
   116             User::LeaveIfError( OpenVmbxPhonebook() );
       
   117             }
   128             }
   118         }
   129         }
   119     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ConstructL <=" );
   130     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ConstructL <=" );
   120     }
   131     }
   121 
   132 
   140 
   151 
   141         result = iStatus.Int();
   152         result = iStatus.Int();
   142         VMBLOGSTRING2( "VMBX: CVmbxPbkStore::PhonebookInfo: \
   153         VMBLOGSTRING2( "VMBX: CVmbxPbkStore::PhonebookInfo: \
   143                 SIM Phonebook info read, status: %I", result );
   154                 SIM Phonebook info read, status: %I", result );
   144         }
   155         }
   145 
       
   146     VMBLOGSTRING( "VMBX: CVmbxPbkStore::GetVmbxInfo <=" );
   156     VMBLOGSTRING( "VMBX: CVmbxPbkStore::GetVmbxInfo <=" );
   147     return result;
   157     return result;
   148     }
   158     }
   149 
   159 
   150 // ---------------------------------------------------------------------------
   160 // ---------------------------------------------------------------------------
   154 //
   164 //
   155 TBool CVmbxPbkStore::IsWritable()
   165 TBool CVmbxPbkStore::IsWritable()
   156     {
   166     {
   157     VMBLOGSTRING( "VMBX: CVmbxPbkStore::IsWritable =>" );
   167     VMBLOGSTRING( "VMBX: CVmbxPbkStore::IsWritable =>" );
   158     TBool result( EFalse );
   168     TBool result( EFalse );
   159     RMobilePhoneBookStore::TMobilePhoneBookInfoV1 info;
   169     if ( IsWriteAccess() )
   160     TInt temp = GetVmbxInfo( info );
   170         {
   161     if( KErrNone == temp )
   171         // Get current sim entry, then write the same entry 
   162         {
   172         // to sim if read successufully
   163         result = ( info.iCaps &
   173         CVoiceMailboxEntry* simEntry(NULL);
   164                 RMobilePhoneBookStore::KCapsWriteAccess ? 1 : 0 );
   174         TRAPD( newErr, simEntry = CVoiceMailboxEntry::NewL() );
   165         
   175         VMBLOGSTRING2( "VMBX: CVmbxPbkStore::IsWritable newErr = %d ",
   166         }
   176             newErr );
   167     VMBLOGSTRING2( "VMBX: CVmbxPbkStore:: IsWritable: info.iCaps %I",
   177         if ( KErrNone == newErr )
   168                      info.iCaps );
   178             {
       
   179             // get als line info
       
   180             simEntry->SetVmbxAlsLineType( VmbxUtilities::AlsLine() );
       
   181             simEntry->SetVoiceMailboxType( EVmbxVoice );
       
   182             simEntry->SetServiceId( KVmbxServiceVoice );
       
   183             TRAPD( err, SimReadL( *simEntry ) );
       
   184             VMBLOGSTRING2( "VMBX: CVmbxPbkStore:: IsWritable read %I <=", err );
       
   185             if ( KErrNotFound == err )
       
   186                 {
       
   187                 simEntry->SetVmbxNumber( KNullDesC );
       
   188                 }
       
   189             if ( KErrNone == err || KErrNotFound == err )
       
   190                 {
       
   191                 err = Write( *simEntry );
       
   192                 VMBLOGSTRING2( "VMBX: CVmbxPbkStore:: IsWritable write %I <=",
       
   193                     err );
       
   194                 // If write successfully, means writable
       
   195                 if ( KErrNone == err )
       
   196                     {
       
   197                     result = ETrue;
       
   198                     }
       
   199                  }
       
   200            }
       
   201         delete simEntry;
       
   202         simEntry = NULL;
       
   203         }
   169     VMBLOGSTRING2( "VMBX: CVmbxPbkStore:: IsWritable result %I <=", result );
   204     VMBLOGSTRING2( "VMBX: CVmbxPbkStore:: IsWritable result %I <=", result );
   170     return result;
   205     return result;
   171     }
   206     }
   172 
   207 
   173 // ---------------------------------------------------------------------------
   208 // ---------------------------------------------------------------------------
   203         }
   238         }
   204     else
   239     else
   205         {
   240         {
   206         pbkBuffer->Set( &pbData );
   241         pbkBuffer->Set( &pbData );
   207         TInt activeAlsLine = aEntry.VmbxAlsLineType();
   242         TInt activeAlsLine = aEntry.VmbxAlsLineType();
       
   243         // Add index, const value for vmbx write.
       
   244         int entryIndex = 1;
   208         // New entry
   245         // New entry
   209         result = pbkBuffer->AddNewEntryTag();
   246         result = pbkBuffer->AddNewEntryTag();
   210         if ( KErrNone == result )
   247         if ( KErrNone == result )
   211             {
   248             {
   212             // Add index
       
   213             // Type of index is TUint16 in Multimode ETel and TInt in old ETel.
   249             // Type of index is TUint16 in Multimode ETel and TInt in old ETel.
   214             result = pbkBuffer->PutTagAndValue( 
   250             result = pbkBuffer->PutTagAndValue( 
   215             RMobilePhoneBookStore::ETagPBAdnIndex, (TUint16)activeAlsLine );
   251             RMobilePhoneBookStore::ETagPBAdnIndex, (TUint16)entryIndex );
   216             }
   252             VMBLOGSTRING2( "VMBX: CVmbxPbkStore::Write: ETagPBAdnIndex \
   217         // Add name if it existed on SIM card
   253                     result=%I",  result );
   218         // Type of ETagPBText is TDes16
   254             // Add name if it existed on SIM card,Type of ETagPBText is TDes16
   219         if ( KErrNone == result && iAlphaStringFromSIM )
   255             if ( iAlphaStringFromSIM )
   220             {
   256                 {
   221             result = pbkBuffer->PutTagAndValue( 
   257                 result = pbkBuffer->PutTagAndValue( 
   222             RMobilePhoneBookStore::ETagPBText, *iAlphaStringFromSIM );
   258                 RMobilePhoneBookStore::ETagPBText, *iAlphaStringFromSIM );
   223             // Add number,Type of ETagPBNumber is TDes16
   259                 VMBLOGSTRING2( "VMBX: CVmbxPbkStore::Write: ETagPBText\
       
   260                         result=%I",  result );
       
   261                 }
       
   262             TPtrC vmbxNumber( KNullDesC );
       
   263             result = aEntry.GetVmbxNumber( vmbxNumber );
   224             if ( KErrNone == result )
   264             if ( KErrNone == result )
   225                 {
   265                 {
   226                 TPtrC vmbxNumber( KNullDesC );
   266                 // Add number,Type of ETagPBNumber is TDes16
   227                 result = aEntry.GetVmbxNumber( vmbxNumber );
   267                 result = pbkBuffer->PutTagAndValue( 
   228                 if ( KErrNone == result )
   268                 RMobilePhoneBookStore::ETagPBNumber, vmbxNumber );
   229                     {
   269                 VMBLOGSTRING2( "VMBX: CVmbxPbkStore::Write: ETagPBNumber\
   230                     result = pbkBuffer->PutTagAndValue( 
   270                         result=%I",  result );
   231                     RMobilePhoneBookStore::ETagPBNumber, vmbxNumber );
       
   232                     }
       
   233                 }
   271                 }
   234             }
   272             }
       
   273 
   235         if ( KErrNone == result )
   274         if ( KErrNone == result )
   236             {
   275             {
   237             if ( iPhoneBookType == EMBDNPhoneBook )
   276             if ( iPhoneBookType == EMBDNPhoneBook )
   238                 {
   277                 {
   239                 RMobilePhone::TMobilePhoneVoicemailIdsV3 mbdnInfo;
   278                 RMobilePhone::TMobilePhoneVoicemailIdsV3 mbdnInfo;
   240                 result = GetMbdnInfo( EVmbxAlsLine1, mbdnInfo );
   279                 result = GetMbdnInfo( VmbxUtilities::AlsLine(), mbdnInfo );
   241 
   280 
   242                 if ( KErrNone == result )
   281                 if ( KErrNone == result )
   243                     {
   282                     {
   244                     TInt index = mbdnInfo.iVoice;
   283                     TInt index = mbdnInfo.iVoice;
   245                     if( !IsActive() && !iWait->IsStarted() )
   284                     if( !IsActive() && !iWait->IsStarted() )
   258             else
   297             else
   259                 {
   298                 {
   260                 if( !IsActive() && !iWait->IsStarted() )
   299                 if( !IsActive() && !iWait->IsStarted() )
   261                     {
   300                     {
   262                     // write vmbx number to 6f17 file
   301                     // write vmbx number to 6f17 file
   263                     iPhoneBook.Write( iStatus, pbData, activeAlsLine );
   302                     iPhoneBook.Write( iStatus, pbData, entryIndex );
   264                     iAsynType = EVmbxSimEntryWrite;
   303                     iAsynType = EVmbxSimEntryWrite;
   265                     // Wait for asynchronous call to finish
   304                     // Wait for asynchronous call to finish
   266                     SetActive();
   305                     SetActive();
   267                     iWait->Start();
   306                     iWait->Start();
   268                     result = iStatus.Int();
   307                     result = iStatus.Int();
   276     return result;
   315     return result;
   277     }
   316     }
   278 
   317 
   279 // ---------------------------------------------------------------------------
   318 // ---------------------------------------------------------------------------
   280 // CVmbxPbkStore::PhonebookStore
   319 // CVmbxPbkStore::PhonebookStore
   281 // Return Phonebook
   320 // Return RMobilePhoneBookStore
   282 // ---------------------------------------------------------------------------
   321 // ---------------------------------------------------------------------------
   283 RMobilePhoneBookStore& CVmbxPbkStore::PhonebookStore()
   322 RMobilePhoneBookStore& CVmbxPbkStore::PhonebookStore()
   284     {
   323     {
   285     VMBLOGSTRING( "VMBX: CVmbxPbkStore::PhonebookStore <=>" );
   324     VMBLOGSTRING( "VMBX: CVmbxPbkStore::PhonebookStore <=>" );
   286     return iPhoneBook;
   325     return iPhoneBook;
   321         else
   360         else
   322             {
   361             {
   323             result = iStatus.Int();
   362             result = iStatus.Int();
   324             }
   363             }
   325 
   364 
   326         if ( EVmbxAlsLineDefault == aAlsLine && KErrNone == result )
   365         if ( EVmbxAlsLineDefault == aAlsLine )
   327             {
   366             {
   328             aInfo.iVoice =  EVmbxAlsLine1;
   367             aInfo.iVoice =  EVmbxAlsLine1;
   329             }
   368             }
       
   369         VMBLOGSTRING2( "VMBX: CVmbxPbkStore::GetMbdnInfo: aInfo.iVoice %I",
       
   370             aInfo.iVoice );
   330         }
   371         }
   331     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::GetMbdnInfo: result %I<=",
   372     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::GetMbdnInfo: result %I<=",
   332          result );
   373          result );
   333     return result;
   374     return result;
   334     }
   375     }
   339 // ---------------------------------------------------------------------------
   380 // ---------------------------------------------------------------------------
   340 //   
   381 //   
   341 TInt CVmbxPbkStore::OpenMbdnPhonebook()
   382 TInt CVmbxPbkStore::OpenMbdnPhonebook()
   342     {
   383     {
   343     VMBLOGSTRING( "VMBX: CVmbxPbkStore::OpenMbdnPhonebook =>" );
   384     VMBLOGSTRING( "VMBX: CVmbxPbkStore::OpenMbdnPhonebook =>" );
   344     // try to open mbdn-type phonebook
   385     //Open mbdn-type phonebook , Currently the file not exist, thr return
       
   386     // value also KErrNone
   345     TInt result = iPhoneBook.Open( iETelConnection->Phone(),
   387     TInt result = iPhoneBook.Open( iETelConnection->Phone(),
   346                                          KETelIccMbdnPhoneBook );
   388                                          KETelIccMbdnPhoneBook );
   347     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::OpenMbdnPhonebook :\
   389     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::OpenMbdnPhonebook :\
   348         MBDN opening result = %I", result );
   390         MBDN opening result = %d", result );
   349     if ( KErrNone == result )
   391 
   350         {
   392     TBool res = IsSimFileExisting( EMBDNPhoneBook );
   351         iPhoneBookType = EMBDNPhoneBook;
   393     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::OpenMbdnPhonebook :\
   352         }
   394         MBDN reading res = %d", res );
   353     VMBLOGSTRING( "VMBX: CVmbxPbkStore::OpenMbdnPhonebook <=" );
   395     if ( !res )
       
   396         {
       
   397         result = KErrPathNotFound;
       
   398         }
       
   399     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::OpenMbdnPhonebook res = %d<=", result );
   354     return result;
   400     return result;
   355     }
   401     }
   356 
   402 
   357 // ---------------------------------------------------------------------------
   403 // ---------------------------------------------------------------------------
   358 // CVmbxPbkStore::OpenVmbxPhonebook
   404 // CVmbxPbkStore::OpenVmbxPhonebook
   360 // ---------------------------------------------------------------------------
   406 // ---------------------------------------------------------------------------
   361 //
   407 //
   362 TInt CVmbxPbkStore::OpenVmbxPhonebook()
   408 TInt CVmbxPbkStore::OpenVmbxPhonebook()
   363     {
   409     {
   364     VMBLOGSTRING( "VMBX: CVmbxPbkStore::OpenVmbxPhonebook =>" );
   410     VMBLOGSTRING( "VMBX: CVmbxPbkStore::OpenVmbxPhonebook =>" );
   365     // try to open vmbx-type phonebook
   411     //Open vmbx-type phonebook , Currently the file not exist, thr return
       
   412     // value also KErrNone
   366     TInt result = iPhoneBook.Open( iETelConnection->Phone(),
   413     TInt result = iPhoneBook.Open( iETelConnection->Phone(),
   367                                                  KETelIccVoiceMailBox );
   414                                                  KETelIccVoiceMailBox );
   368     if ( KErrNone == result )
   415     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::OpenVmbxPhonebook :\
   369         {
   416         Vmbx opening result = %d", result );
   370         iPhoneBookType = EVMBXPhoneBook;
   417     TBool res = IsSimFileExisting( EVMBXPhoneBook );
   371         }
   418     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::OpenVmbxPhonebook :\
   372     VMBLOGSTRING2( "Vmbx phonebook opening result = %I ", result );
   419         Vmbx reading res = %d", res );
   373     VMBLOGSTRING( "VMBX: CVmbxPbkStore::OpenVmbxPhonebook <=" );
   420     if ( !res )
       
   421         {
       
   422         result = KErrPathNotFound;
       
   423         }
       
   424     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::OpenVmbxPhonebook result=%d <=", result );
   374     return result;
   425     return result;
   375     }
   426     }
   376 
   427 
   377 // ---------------------------------------------------------------------------
   428 // ---------------------------------------------------------------------------
   378 // CVmbxPbkStore::GetL
   429 // CVmbxPbkStore::GetL
   402             // close 6fc7 and open 6f17 file
   453             // close 6fc7 and open 6f17 file
   403             iPhoneBook.Close();
   454             iPhoneBook.Close();
   404             User::LeaveIfError( OpenVmbxPhonebook() );
   455             User::LeaveIfError( OpenVmbxPhonebook() );
   405             // read vmbx number from 6f17 file
   456             // read vmbx number from 6f17 file
   406             SimReadL( aEntry );
   457             SimReadL( aEntry );
   407             } 
   458             }
   408         }
   459         }
   409     else
   460     else
   410         {
   461         {
   411         SimReadL( aEntry );
   462         SimReadL( aEntry );
   412         }
   463         }
   443                 iStatus, mbdnInfo.iVoice, numEntries, pbData );
   494                 iStatus, mbdnInfo.iVoice, numEntries, pbData );
   444                 iAsynType = EVmbxSimEntryRead;
   495                 iAsynType = EVmbxSimEntryRead;
   445                 // Wait for asynchronous call to finish
   496                 // Wait for asynchronous call to finish
   446                 SetActive();
   497                 SetActive();
   447                 iWait->Start();
   498                 iWait->Start();
   448                 }         
   499                 }
   449             }
   500             }
   450         }
   501         }
   451     else
   502     else
   452         {
   503         {
   453         // Record#1 in sim is for line1 number and Record#2 in sim is for
   504         // Record#1 in sim is for line1 number and Record#2 in sim is for
   454         // line2 number so line is used to fetch
   505         // line2 number so line is used to fetch
   455         VMBLOGSTRING( "start VMBX PhoneBook read" );
   506         VMBLOGSTRING( "start VMBX PhoneBook read" );
   456         TInt activeAlsLine = aEntry.VmbxAlsLineType();
   507         TInt activeAlsLine = aEntry.VmbxAlsLineType();
       
   508         if ( EVmbxAlsLineDefault == activeAlsLine )
       
   509             {
       
   510             activeAlsLine = EVmbxAlsLine1;
       
   511             }
   457          if( !IsActive() && !iWait->IsStarted() )
   512          if( !IsActive() && !iWait->IsStarted() )
   458             {
   513             {
   459             result = KErrNone;
   514             result = KErrNone;
   460             // read vmbx number from 6f17 file
   515             // read vmbx number from 6f17 file
       
   516             VMBLOGSTRING2( "VMBX: CVmbxPbkStore::SimReadLactiveAlsLine = %I",
       
   517                  activeAlsLine );
   461             iPhoneBook.Read( iStatus, activeAlsLine, numEntries, pbData );
   518             iPhoneBook.Read( iStatus, activeAlsLine, numEntries, pbData );
   462             iAsynType = EVmbxSimEntryRead;
   519             iAsynType = EVmbxSimEntryRead;
   463             // Wait for asynchronous call to finish
   520             // Wait for asynchronous call to finish
   464             SetActive();
   521             SetActive();
   465             iWait->Start();
   522             iWait->Start();
   482     VMBLOGSTRING( "VMBX: CVmbxPbkStore::SimReadL <=" );
   539     VMBLOGSTRING( "VMBX: CVmbxPbkStore::SimReadL <=" );
   483     }
   540     }
   484 
   541 
   485 // ---------------------------------------------------------------------------
   542 // ---------------------------------------------------------------------------
   486 // CVmbxPbkStore::ParseDataL
   543 // CVmbxPbkStore::ParseDataL
   487 // read vmbx number from sim
   544 // 
   488 // ---------------------------------------------------------------------------
   545 // ---------------------------------------------------------------------------
   489 //
   546 //
   490 void CVmbxPbkStore::ParseDataL( CVoiceMailboxEntry& aEntry, TDes8& aPbData )
   547 void CVmbxPbkStore::ParseDataL( CVoiceMailboxEntry& aEntry, TDes8& aPbData )
   491     {
   548     {
   492     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ParseDataL =>" );
   549     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ParseDataL =>" );
   639     User::LeaveIfError( result );
   696     User::LeaveIfError( result );
   640     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ReadPbkDataL <=" );
   697     VMBLOGSTRING( "VMBX: CVmbxPbkStore::ReadPbkDataL <=" );
   641     }
   698     }
   642 
   699 
   643 // ---------------------------------------------------------------------------
   700 // ---------------------------------------------------------------------------
   644 // CVmbxPbkStore::IsUsimSupport
       
   645 // Checks if USim card in the phone
       
   646 // ---------------------------------------------------------------------------
       
   647 TBool CVmbxPbkStore::SimFileExistsAndReadAccess()
       
   648     {
       
   649     VMBLOGSTRING( "VMBX: CVmbxPbkStore::SimFileExistsAndReadAccess =>" );
       
   650     TBool result( EFalse );
       
   651 
       
   652     TUint32 capability;
       
   653     TInt err = iETelConnection->Phone().GetIccAccessCaps( capability );
       
   654     VMBLOGSTRING2( "VMBX: CVmbxSimHandler::SimFileExistsAndReadAccess:\
       
   655         Err = %I", err);
       
   656 
       
   657     if ( err == KErrNone &&
       
   658         // Phone has a USIM and it currently supports USIM access by clients.
       
   659         // the current sim card is 3G
       
   660          capability & RMobilePhone::KCapsUSimAccessSupported )
       
   661         {
       
   662         result = ETrue;
       
   663         }
       
   664     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::SimFileExistsAndReadAccess \
       
   665         return = %d <=", result );
       
   666     return result;
       
   667     }
       
   668 
       
   669 // ---------------------------------------------------------------------------
       
   670 // CVmbxPbkStore::RunL
   701 // CVmbxPbkStore::RunL
   671 // read vmbx number from sim
   702 // 
   672 // ---------------------------------------------------------------------------
   703 // ---------------------------------------------------------------------------
   673 //
   704 //
   674 void CVmbxPbkStore::RunL()
   705 void CVmbxPbkStore::RunL()
   675     {
   706     {
   676     VMBLOGSTRING( "VMBX: CVmbxPbkStore::RunL =>" );
   707     VMBLOGSTRING( "VMBX: CVmbxPbkStore::RunL =>" );
   684     VMBLOGSTRING( "VMBX: CVmbxPbkStore::RunL <=" );
   715     VMBLOGSTRING( "VMBX: CVmbxPbkStore::RunL <=" );
   685     }
   716     }
   686 
   717 
   687 // ---------------------------------------------------------------------------
   718 // ---------------------------------------------------------------------------
   688 // CVmbxPbkStore::DoCancel
   719 // CVmbxPbkStore::DoCancel
   689 // read vmbx number from sim
   720 // 
   690 // ---------------------------------------------------------------------------
   721 // ---------------------------------------------------------------------------
   691 //
   722 //
   692 void CVmbxPbkStore::DoCancel()
   723 void CVmbxPbkStore::DoCancel()
   693     {
   724     {
   694     VMBLOGSTRING( "VMBX: CVmbxPbkStore::DoCancel =>" );
   725     VMBLOGSTRING( "VMBX: CVmbxPbkStore::DoCancel =>" );
   722             {
   753             {
   723             VMBLOGSTRING( "VMBX: CVmbxPbkStore::DoCancel : EVmbxSimEntryRead" );
   754             VMBLOGSTRING( "VMBX: CVmbxPbkStore::DoCancel : EVmbxSimEntryRead" );
   724             iETelConnection->Phone().CancelAsyncRequest( 
   755             iETelConnection->Phone().CancelAsyncRequest( 
   725                                                EMobilePhoneStoreRead );
   756                                                EMobilePhoneStoreRead );
   726             break;
   757             break;
   727             }                                        
   758             }
   728         case EVmbxSimEntryWrite:
   759         case EVmbxSimEntryWrite:
   729             {
   760             {
   730             VMBLOGSTRING( "VMBX: CVmbxPbkStore::DoCancel : EVmbxSimEntryWrite" );
   761             VMBLOGSTRING( "VMBX: CVmbxPbkStore::DoCancel : EVmbxSimEntryWrite" );
   731             iETelConnection->Phone().CancelAsyncRequest( 
   762             iETelConnection->Phone().CancelAsyncRequest( 
   732                                                EMobilePhoneStoreWrite );
   763                                                EMobilePhoneStoreWrite );
   733             break;
   764             break;
   734             }                                        
   765             }
   735         default:
   766         default:
   736             break;   
   767             break;
   737         }
   768         }
   738     
   769     
   739     VMBLOGSTRING( "VMBX: CVmbxPbkStore::DoCancel <=" );
   770     VMBLOGSTRING( "VMBX: CVmbxPbkStore::DoCancel <=" );
   740     }
   771     }
   741 
   772 
   742 // ---------------------------------------------------------------------------
   773 // ---------------------------------------------------------------------------
   743 // CVmbxPbkStore::RunError
   774 // CVmbxPbkStore::RunError
   744 // read vmbx number from sim
   775 // 
   745 // ---------------------------------------------------------------------------
   776 // ---------------------------------------------------------------------------
   746 //
   777 //
   747 TInt CVmbxPbkStore::RunError(TInt aError)
   778 TInt CVmbxPbkStore::RunError(TInt aError)
   748     {
   779     {
       
   780     // Avoid warning
       
   781     aError = aError;
   749     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::RunError: %I", aError );
   782     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::RunError: %I", aError );
   750     return KErrNone;
   783     return KErrNone;
   751     }
   784     }
   752 
   785 
       
   786 // ---------------------------------------------------------------------------
       
   787 // CVmbxPbkStore::IsSimFileExisting
       
   788 // check sim file existing or not
       
   789 // ---------------------------------------------------------------------------
       
   790 //
       
   791 TBool CVmbxPbkStore::IsSimFileExisting( const TVmbxSimPhonebookType aType )
       
   792     {
       
   793     VMBLOGSTRING( "VMBX: CVmbxPbkStore::IsSimFileExisting =>" );
       
   794     iPhoneBookType = aType;
       
   795     TBool result( ETrue );
       
   796     CVoiceMailboxEntry* entry(NULL);
       
   797     TRAPD( err, entry = CVoiceMailboxEntry::NewL() );
       
   798     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::IsSimFileExisting err = %d ",
       
   799      err );
       
   800     if ( KErrNone != err )
       
   801         {
       
   802         result = EFalse;
       
   803         }
       
   804     else
       
   805         {
       
   806         entry->SetVoiceMailboxType( EVmbxVoice );
       
   807         TRAPD( err, SimReadL( *entry ) );
       
   808         // KErrPathNotFound means when current file path not found.
       
   809         if ( KErrPathNotFound == err )
       
   810             {
       
   811             result = EFalse;
       
   812             }
       
   813         }
       
   814     delete entry;
       
   815     entry = NULL;
       
   816     VMBLOGSTRING2( "VMBX: CVmbxPbkStore::IsSimFileExisting result = %d <= ",
       
   817          result );
       
   818     return result;
       
   819     }
       
   820 
       
   821 // ---------------------------------------------------------------------------
       
   822 // CVmbxPbkStore::IsWriteAccess
       
   823 // Sim write access support
       
   824 // ---------------------------------------------------------------------------
       
   825 //
       
   826 TBool CVmbxPbkStore::IsWriteAccess()
       
   827     {
       
   828     VMBLOGSTRING( "VMBX: CVmbxPbkStore::IsWriteAccess =>" );
       
   829     TBool result( EFalse );
       
   830     RMobilePhoneBookStore::TMobilePhoneBookInfoV1 info;
       
   831     TInt temp = GetVmbxInfo( info );
       
   832     if( KErrNone == temp )
       
   833         {
       
   834         result = ( info.iCaps &
       
   835                 RMobilePhoneBookStore::KCapsWriteAccess ? ETrue : EFalse );
       
   836         
       
   837         }
       
   838     VMBLOGSTRING2( "VMBX: CVmbxPbkStore:: IsWriteAccess: info.iCaps %X",
       
   839                      info.iCaps );
       
   840     VMBLOGSTRING2( "VMBX: CVmbxPbkStore:: IsWriteAccess result %I <=", result );
       
   841     return result;
       
   842     }
       
   843 
   753 //End of file
   844 //End of file