Example #1
0
// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
void CSpsBackupHelperPerformer::ReadSettingsL()
    {
    XSPSLOGSTRING( "CSpsBackupHelperPerformer::ReadSettingsL IN" );
    RIdArray ids;
    CleanupClosePushL( ids );
    iServiceProviderSettings->FindServiceIdsL( ids );
    
    // Make sure that id's are in correct order!
    for( TInt i = 0; i < ids.Count(); i++ )
        {
        TRAP_IGNORE( 
            CSPEntry* entry = CSPEntry::NewLC();
            User::LeaveIfError( 
                iServiceProviderSettings->FindEntryL( ids[i], *entry ) );
            
            // Make sure that all properties are loaded
            entry->GetAllProperties(); 
            iEntries.AppendL( entry );
            CleanupStack::Pop( entry );
            )

        }
    
    XSPSLOGSTRING2( 
        "CSpsBackupHelperPerformer::ReadSettingsL Service count=%i", 
        iEntries.Count() );
    
    CleanupStack::PopAndDestroy( &ids );
    XSPSLOGSTRING( "CSpsBackupHelperPerformer::ReadSettingsL OUT" );
    }
// ---------------------------------------------------------------------------
// Search service names by given service IDs
// ---------------------------------------------------------------------------
//
void CSPSettingsEngine::FindServiceNamesL( RIdArray& aServiceIds,
    CDesCArray& aServiceNames )
    {
    XSPSLOGSTRING( "CSPSettingsEngine::FindServiceNamesL() - IN" );
    
    CCenRepDatabaseProperty* property = CCenRepDatabaseProperty::NewLC();
    TInt count = aServiceIds.Count();
    for( TInt i = 0; i < count; i++ )
        {
        TInt id = ( TInt )aServiceIds[i];
        
        TInt err = iCenRepUtils->FindPropertyL( id, EServiceName, *property );
        if( err == KErrNone )
            {
            aServiceNames.AppendL( property->GetDesValue() );
            }
        else
            {
            aServiceIds.Remove( i ); // Remove non-existent ID
            count--;
            i--; // Do not increment index
            }
        }

    CleanupStack::PopAndDestroy( property );
    
    XSPSLOGSTRING( "CSPSettingsEngine::FindServiceNamesL() - OUT" );
    }
void T_CSPSettingsEngine::T_CSPSettingsEngine_FindServiceIdsLL(  )
    {
    RIdArray serviceIds;
    CleanupClosePushL( serviceIds );
    
    EUNIT_ASSERT( KErrNone == iCSPSettingsEngine->FindServiceIdsL( serviceIds ) );
    EUNIT_ASSERT( serviceIds.Count() );
    
    CleanupStack::PopAndDestroy( &serviceIds );
    }
void T_CSPSettings::T_CSPSettings_FindServiceIdsLL(  )
    {
    RIdArray ids;
    CleanupClosePushL( ids );
    
    EUNIT_ASSERT( KErrNone == iCSPSettings->FindServiceIdsL( ids ) );
    TInt count( ids.Count() );
    EUNIT_ASSERT( count );
    
    CleanupStack::PopAndDestroy( &ids );
    }
void T_CSPSettingsEngine::T_CSPSettingsEngine_FindServiceIdsFromPropertiesLL(  )
    {
    RIdArray serviceIds;
    CleanupClosePushL( serviceIds );
    RPropertyArray properties;
    CleanupClosePushL( properties );
    
    iCSPSettingsEngine->FindServiceIdsFromPropertiesL( properties, serviceIds );
    EUNIT_ASSERT( serviceIds.Count() );
    
    CleanupStack::PopAndDestroy( &properties );
    CleanupStack::PopAndDestroy( &serviceIds );
    }
// -----------------------------------------------------------------------------
// IsPluginOnStandbyL
// -----------------------------------------------------------------------------
//
TBool CCCESPSettingsHandler::IsPluginOnStandbyL( TUid aImplementationUid )
    {
    CCELOGSTRING( "CCCESPSettingsHandler:: IsPluginOnStandbyL." );
    TBool ret( EFalse );
    
    RIdArray idArray;
    CleanupClosePushL( idArray );
    
    // Create property array
    RPropertyArray* propertyArray = new (ELeave) RPropertyArray( 1 );
    TCleanupItem cleanup( CCCESPSettingsHandler::CleanupPointerArray, propertyArray );
    CleanupStack::PushL( cleanup );
    
    // call provider property
    CSPProperty* callProviderPluginId  = CSPProperty::NewLC();
    callProviderPluginId->SetName( EPropertyCallProviderPluginId );
    callProviderPluginId->SetValue( aImplementationUid.iUid );
    propertyArray->AppendL( callProviderPluginId );
    CleanupStack::Pop( callProviderPluginId );
    
    // Get service's 
    User::LeaveIfError( iSettings->
            FindServiceIdsFromPropertiesL( *propertyArray, idArray ) );
        
    
    TInt count = idArray.Count();
    for ( TInt index( 0 ); index < count && !ret; index++ )
        {
        TInt tmpServiceId = idArray[ index ]; 
        // ETrue if VoIP atribute is enabled or Bootstrap is enabled
        ret = ( IsEnabledL( tmpServiceId ) || 
            ( CapabilitiesL( tmpServiceId ) & EBootstrapCallProvider ) );
        }
    CleanupStack::PopAndDestroy( propertyArray );
    CleanupStack::PopAndDestroy( &idArray );
    CCELOGSTRING2( "CCCESPSettingsHandler:: ret %i ", ret );
    //note: Lint doesn't understand the use of PopAndDestroy and thinks
    //that there is a memory leak for propertyArray, we disable that warning with
    //the following command
    //lint -e429

    return ret; 
    }
// -----------------------------------------------------------------------------
// Load EBootstrapCallProvider marked or enabled plugins
// -----------------------------------------------------------------------------
//
void CCCEPluginManager::LoadBootPluginsL()
    {
    //List implementations
#ifdef _DEBUG
    RImplInfoPtrArray implementations;
    CConvergedCallProvider::ListImplementationsL(implementations);
    CCELOGSTRING2("CCCEPluginManager::GetPluginL: %d Implementation(s) found", 
        implementations.Count() );
        
    for( TInt i=0; i<implementations.Count(); i++ )
        {
        CImplementationInformation *info = implementations[i];
        
        CCELOGSTRING3("CCCEPluginManager::GetPluginL: Uid = %d, Name = %S", 
            info->ImplementationUid().iUid, &info->DisplayName() );
        CCELOGSTRING3("CCCEPluginManager::GetPluginL: ->RomBased = %d, RomOnly = %d", 
            info->RomBased(), info->RomOnly() );
        }
  
    implementations.ResetAndDestroy();
    implementations.Close();
#endif // _DEBUG
    
    RIdArray serviceIDArray;
    CleanupClosePushL( serviceIDArray );
    iSPSettings->GetServicesL( serviceIDArray );
    const TInt serviceCount = serviceIDArray.Count();
    iPrimaryEmergencyCallPlugin = NULL;
    TInt err = KErrNone;
    
    CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: Service count: %d", serviceCount );
    for( TInt service = 0; service < serviceCount; service++ )
        {
        CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: Processing service: %d", service );
        CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: ServiceID: %d", serviceIDArray[service] );
        
        TRAP( err, LoadBootPluginL( serviceIDArray[service] ) )
        
        CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: Result %i", err );
        }

    CleanupStack::PopAndDestroy();
    }
// ---------------------------------------------------------------------------
// Check feature is supported or not
// ---------------------------------------------------------------------------
//
TBool CSPSettingsEngine::IsFeatureSupportedL( TSPServiceFeature aFeature,
                                              TBool aWriteAllowed )
    {
    XSPSLOGSTRING( "CSPSettingsEngine::IsFeatureSupportedL() - IN" );

    TBool ret = EFalse;
    
    // First check P&S key, if P&S key is defined, use the value from P&S key.
    // if not defined, then walk through all the sevices and check there is any service match
    TInt mask = 0;
    TInt value = 0;
    TInt psFlag = 0;
    TInt retProperty = 0;
    
    switch( aFeature )
        {
        case ESupportInternetCallFeature:
            {
            retProperty = RProperty::Get( KUidSystemCategory, KSPSupportInternetCallKey, psFlag );
            if( retProperty == KErrNone && psFlag != KSPInitFeatureValue )
                {
                ret = psFlag;
                }
            else
                {
                mask = ESupportsInternetCall | ESupportsAlphanumericAddressing | EIsVisibleInCallMenu;
                value = mask;
                ret = CheckFeatureL( mask, value );
                if ( aWriteAllowed )
                    {                   
                    User::LeaveIfError( RProperty::Set( KUidSystemCategory, 
                        KSPSupportInternetCallKey, ret ) );
                    }
                }
            
            break;
            }
        case ESupportCallOutFeature:
            {
            retProperty = RProperty::Get( KUidSystemCategory, KSPSupportCallOutKey, psFlag );
            if( retProperty == KErrNone && psFlag != KSPInitFeatureValue )
                {
                ret = psFlag;
                }
            else
                {
                mask = ESupportsInternetCall | ESupportsMSISDNAddressing | EIsVisibleInCallMenu;
                value = mask;
                ret = CheckFeatureL( mask, value );
                if ( aWriteAllowed )
                    {                   
                    User::LeaveIfError( RProperty::Set( 
                        KUidSystemCategory, 
                        KSPSupportCallOutKey, ret ) );
                    }
                }
            break;
            }
        
        case ESupportVoIPSSFeature:
            {
            retProperty = RProperty::Get( KUidSystemCategory, KSPSupportVoIPSSKey, psFlag );
            if( retProperty == KErrNone && psFlag != KSPInitFeatureValue )
                {
                ret = psFlag;
                }
            else
                {
                mask = ESupportVoIPSS;
                value = mask;
                ret = CheckFeatureL( mask, value );
                if ( aWriteAllowed )
                    {                   
                    User::LeaveIfError( RProperty::Set( 
                        KUidSystemCategory, 
                        KSPSupportVoIPSSKey, ret ) );
                    }
                }
            break;
            }
        
        case ESupportVoIPFeature:
            {
            TBool bFeatureMgr = EFalse;
            TBool bDynVoIP = EFalse;
            TBool bSubVoIP = EFalse;
            
            //check FeatureManager
            FeatureManager::InitializeLibL();
            bFeatureMgr = FeatureManager::FeatureSupported( KFeatureIdCommonVoip );
            FeatureManager::UnInitializeLib();
            
            //check dynamic voip flag
            CRepository* repository = CRepository::NewLC( KCRUidTelephonySettings );
            TInt value = 0;
            TInt err = repository->Get( KDynamicVoIP, value );
            if( value != 0 )
                {
                bDynVoIP = ETrue;
                }
            
            CleanupStack::PopAndDestroy( repository );
            
            //check subservice voip
            RIdArray serviceIds;
            CleanupClosePushL( serviceIds );
            FindServiceIdsL( serviceIds );
            CSPProperty* property = CSPProperty::NewLC();
            
            for( TInt i = 0; i < serviceIds.Count(); i++ )
                {
                TServiceId serviceId = serviceIds[i];
                TInt retProperty = FindPropertyL( serviceId, EPropertyVoIPSubServicePluginId, *property );
                if( retProperty == KErrNone )
                    {
                    bSubVoIP = ETrue;
                    break;
                    }
                }
            CleanupStack::PopAndDestroy( property );
            CleanupStack::PopAndDestroy( &serviceIds );
            
            ret = bFeatureMgr && bDynVoIP && bSubVoIP;
            
            break;
            }
        default:
            {
            User::Leave( KErrNotSupported );        
            }
        }
    
    XSPSLOGSTRING( "CSPSettingsEngine::IsFeatureSupportedL() - OUT" );

    return ret;
    }