phonebookengines/VirtualPhonebook/VPbkSimStoreImpl/src/CServiceTableCmd.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  A command that queries (U)SIM service table and checks
       
    15 *                if the store is supported. Updates the data in CVPbkPhone
       
    16 *                so this command is needs to run only once.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "CServiceTableCmd.h"
       
    24 
       
    25 #include <VPbkDebug.h>
       
    26 #include <etelmm.h>
       
    27 #include "CPhone.h"
       
    28 #include "VPbkSimStoreImplError.h"
       
    29 
       
    30 namespace VPbkSimStoreImpl {
       
    31 
       
    32 // ============================= LOCAL FUNCTIONS ===============================
       
    33 
       
    34 namespace {
       
    35 
       
    36 #ifdef VPBK_ENABLE_DEBUG_PRINT
       
    37 
       
    38 void PrintETelServiceTable( RMobilePhone::TMobilePhoneServiceTableV1& aTable )
       
    39     {
       
    40     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    41         "VPbkSimStoreImpl: ETel iServices1To8: %b"), 
       
    42         aTable.iServices1To8 );
       
    43     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    44         "VPbkSimStoreImpl: ETel iServices9To16: %b"), 
       
    45         aTable.iServices9To16 );
       
    46     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    47         "VPbkSimStoreImpl: ETel iServices17To24: %b"), 
       
    48         aTable.iServices17To24 );
       
    49     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    50         "VPbkSimStoreImpl: ETel iServices25To32: %b"), 
       
    51         aTable.iServices25To32 );
       
    52     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    53         "VPbkSimStoreImpl: ETel iServices33To40: %b"), 
       
    54         aTable.iServices33To40 );
       
    55     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    56         "VPbkSimStoreImpl: ETel iServices41To48: %b"), 
       
    57         aTable.iServices41To48 );
       
    58     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    59         "VPbkSimStoreImpl: ETel iServices49To56: %b"), 
       
    60         aTable.iServices49To56 );
       
    61     }
       
    62 
       
    63 #endif // VPBK_ENABLE_DEBUG_PRINT
       
    64 
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // ConvertUST. 
       
    68 // Converts USIM service table
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 inline void ConvertUST( RMobilePhone::TMobilePhoneServiceTableV1& aTable,
       
    72     TUint32& aServiceTable )
       
    73     {
       
    74     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    75         "VPbkSimStoreImpl: CServiceTableCmd::ConvertUST"));
       
    76 
       
    77 #ifdef VPBK_ENABLE_DEBUG_PRINT  
       
    78     PrintETelServiceTable( aTable );
       
    79 #endif // VPBK_ENABLE_DEBUG_PRINT
       
    80     
       
    81     aServiceTable = 0;
       
    82     // ADN is always supported
       
    83     aServiceTable |= MVPbkSimPhone::KVPbkCapsADNSupported;
       
    84 
       
    85     if (  aTable.iServices1To8 & RMobilePhone::KUstLocalPhBk )
       
    86         {
       
    87         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    88         "VPbkSimStoreImpl: CServiceTableCmd::ConvertUST, local Pbk supported"));
       
    89         }
       
    90         
       
    91     if ( aTable.iServices1To8 & RMobilePhone::KUstSDN )
       
    92         {
       
    93         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    94         "VPbkSimStoreImpl: CServiceTableCmd::ConvertUST, SDN supported"));
       
    95         aServiceTable |= MVPbkSimPhone::KVPbkCapsSDNSupported;
       
    96         }
       
    97     else
       
    98         {
       
    99         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   100         "VPbkSimStoreImpl: CServiceTableCmd::ConvertUST, SDN not supported"));
       
   101         aServiceTable &= ~MVPbkSimPhone::KVPbkCapsSDNSupported;
       
   102         }
       
   103         
       
   104     if ( aTable.iServices1To8 & RMobilePhone::KUstFDN )    
       
   105         {
       
   106         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   107         "VPbkSimStoreImpl: CServiceTableCmd::ConvertUST, FDN supported"));
       
   108         aServiceTable |= MVPbkSimPhone::KVPbkCapsFDNSupported;
       
   109         }
       
   110     else
       
   111         {
       
   112         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   113         "VPbkSimStoreImpl: CServiceTableCmd::ConvertUST, FDN not supported"));
       
   114         aServiceTable &= ~MVPbkSimPhone::KVPbkCapsFDNSupported;
       
   115         }
       
   116         
       
   117     if( aTable.iServices17To24 & RMobilePhone::KUstMSISDN )    
       
   118         {
       
   119         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   120         "VPbkSimStoreImpl: CServiceTableCmd::ConvertUST, ON supported"));
       
   121         aServiceTable |= MVPbkSimPhone::KVPbkCapsONSupported;
       
   122         }
       
   123     else
       
   124         {
       
   125         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   126         "VPbkSimStoreImpl: CServiceTableCmd::ConvertUST, ON not supported"));
       
   127         aServiceTable &= ~MVPbkSimPhone::KVPbkCapsONSupported;
       
   128         }
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // ConvertSST. 
       
   133 // Converts SIM service table
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 inline void ConvertSST( RMobilePhone::TMobilePhoneServiceTableV1& aTable,
       
   137     TUint32& aServiceTable )
       
   138     {
       
   139     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   140         "VPbkSimStoreImpl: CServiceTableCmd::ConvertSST"));
       
   141     
       
   142     // ADN is always supported
       
   143     aServiceTable |= MVPbkSimPhone::KVPbkCapsADNSupported;
       
   144 
       
   145     if ( aTable.iServices17To24 & RMobilePhone::KSstSDN )
       
   146         {
       
   147         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   148         "VPbkSimStoreImpl: CServiceTableCmd::ConvertSST, SDN supported"));
       
   149         aServiceTable |= MVPbkSimPhone::KVPbkCapsSDNSupported;
       
   150         }
       
   151     else
       
   152         {
       
   153         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   154         "VPbkSimStoreImpl: CServiceTableCmd::ConvertSST, SDN not supported"));
       
   155         aServiceTable &= ~MVPbkSimPhone::KVPbkCapsSDNSupported;
       
   156         }
       
   157         
       
   158     if ( aTable.iServices1To8 & RMobilePhone::KSstFDN )    
       
   159         {
       
   160         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   161         "VPbkSimStoreImpl: CServiceTableCmd::ConvertSST, FDN supported"));
       
   162         aServiceTable |= MVPbkSimPhone::KVPbkCapsFDNSupported;
       
   163         }
       
   164     else
       
   165         {
       
   166         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   167         "VPbkSimStoreImpl: CServiceTableCmd::ConvertSST, FDN not supported"));
       
   168         aServiceTable &= ~MVPbkSimPhone::KVPbkCapsFDNSupported;
       
   169         }
       
   170         
       
   171     if( aTable.iServices9To16 & RMobilePhone::KSstMSISDN )    
       
   172         {
       
   173         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   174         "VPbkSimStoreImpl: CServiceTableCmd::ConvertSST, ON supported"));
       
   175         aServiceTable |= MVPbkSimPhone::KVPbkCapsONSupported;
       
   176         }
       
   177     else
       
   178         {
       
   179         VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   180         "VPbkSimStoreImpl: CServiceTableCmd::ConvertSST, ON not supported"));
       
   181         aServiceTable &= ~MVPbkSimPhone::KVPbkCapsONSupported;
       
   182         }
       
   183 
       
   184     }
       
   185 } // unnamed
       
   186 
       
   187 // ============================ MEMBER FUNCTIONS ===============================
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // CServiceTableCmd::CServiceTableCmd
       
   191 // C++ default constructor can NOT contain any code, that
       
   192 // might leave.
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 CServiceTableCmd::CServiceTableCmd( CPhone& aPhone, TUint32& aServiceTable )
       
   196     : CActive( EPriorityStandard ),
       
   197       iPhone( aPhone ),
       
   198       iVPbkServiceTable( aServiceTable ),
       
   199       iServiceTablePckg( iServiceTable )
       
   200     {
       
   201     CActiveScheduler::Add( this );
       
   202     }
       
   203     
       
   204 // Destructor
       
   205 CServiceTableCmd::~CServiceTableCmd()
       
   206     {
       
   207     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   208         "VPbkSimStoreImpl: CServiceTableCmd::~CServiceTableCmd"));
       
   209     
       
   210     CancelCmd();
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CServiceTableCmd::NewLC
       
   215 // Two-phased constructor.
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 CServiceTableCmd* CServiceTableCmd::NewLC( CPhone& aPhone, 
       
   219         TUint32& aServiceTable )
       
   220     {
       
   221     CServiceTableCmd* self = 
       
   222         new( ELeave ) CServiceTableCmd( aPhone, aServiceTable );
       
   223     CleanupStack::PushL( self );
       
   224     return self;
       
   225     }
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CServiceTableCmd::Execute
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 void CServiceTableCmd::Execute()
       
   232     {
       
   233     __ASSERT_DEBUG( iObserver,
       
   234         VPbkSimStoreImpl::Panic( EPreCondCServiceTableCmdExecute ) );
       
   235         
       
   236     RMobilePhone::TMobilePhoneServiceTable tableType = 
       
   237         RMobilePhone::ESIMServiceTable;
       
   238     iUSimSupported = iPhone.USimAccessSupported();
       
   239     if ( iUSimSupported )
       
   240         {
       
   241         tableType = RMobilePhone::EUSIMServiceTable;
       
   242         }
       
   243 
       
   244     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   245         "VPbkSimStoreImpl: RMobilePhone::GetServiceTable h%d request,type=%d"), 
       
   246         iPhone.ETelPhone().SubSessionHandle(),tableType);
       
   247     iPhone.ETelPhone().GetServiceTable( iStatus, tableType, 
       
   248         iServiceTablePckg );
       
   249     SetActive();
       
   250     }
       
   251 
       
   252 // -----------------------------------------------------------------------------
       
   253 // CServiceTableCmd::AddObserverL
       
   254 // -----------------------------------------------------------------------------
       
   255 //
       
   256 void CServiceTableCmd::AddObserverL( MVPbkSimCommandObserver& aObserver )
       
   257     {
       
   258     __ASSERT_DEBUG( !iObserver,
       
   259         VPbkSimStoreImpl::Panic( EPreCondCServiceTableCmdAddObserverL ) );
       
   260     iObserver = &aObserver;
       
   261     }
       
   262 
       
   263 // -----------------------------------------------------------------------------
       
   264 // CServiceTableCmd::CancelCmd
       
   265 // -----------------------------------------------------------------------------
       
   266 //
       
   267 void CServiceTableCmd::CancelCmd()
       
   268     {
       
   269     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   270         "VPbkSimStoreImpl: CServiceTableCmd::CancelCmd"));
       
   271     
       
   272     Cancel();
       
   273     }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // CServiceTableCmd::RunL
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 void CServiceTableCmd::RunL()
       
   280     {
       
   281     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   282         "VPbkSimStoreImpl: RMobilePhone::GetServiceTable h%d complete %d"),
       
   283         iPhone.ETelPhone().SubSessionHandle(),iStatus.Int());
       
   284 
       
   285     if ( iStatus == KErrNone )
       
   286         {
       
   287         if ( iUSimSupported )
       
   288             {
       
   289             ConvertUST( iServiceTable, iVPbkServiceTable );
       
   290             }
       
   291         else
       
   292             {
       
   293             ConvertSST( iServiceTable, iVPbkServiceTable );
       
   294             }
       
   295 
       
   296         iObserver->CommandDone( *this );
       
   297         }
       
   298     else
       
   299         {
       
   300         iObserver->CommandError( *this, iStatus.Int() );
       
   301         }       
       
   302     }
       
   303 
       
   304 // -----------------------------------------------------------------------------
       
   305 // CServiceTableCmd::DoCancel
       
   306 // -----------------------------------------------------------------------------
       
   307 //
       
   308 void CServiceTableCmd::DoCancel()
       
   309     {
       
   310     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   311         "VPbkSimStoreImpl: RMobilePhone::GetServiceTable h%d Cancel"),
       
   312         iPhone.ETelPhone().SubSessionHandle());
       
   313     iPhone.ETelPhone().CancelAsyncRequest( EMobilePhoneGetServiceTable );
       
   314     }
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CServiceTableCmd::RunError
       
   318 // -----------------------------------------------------------------------------
       
   319 //    
       
   320 TInt CServiceTableCmd::RunError( TInt aError )
       
   321     {
       
   322     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   323         "VPbkSimStoreImpl: CServiceTableCmd::RunError"));
       
   324         
       
   325     iObserver->CommandError( *this, aError );    
       
   326     
       
   327     return KErrNone;    
       
   328     }
       
   329 
       
   330 } // namespace VPbkSimStoreImpl
       
   331 //  End of File