// --------------------------------------------------------------------------- // Find service IDs with same properties // --------------------------------------------------------------------------- // void CSPSettingsEngine::FindServiceIdsFromPropertiesL( const RPropertyArray& aPropertyArray, RIdArray& aServiceIds ) { XSPSLOGSTRING( "CSPSettingsEngine::FindServiceIdsFromPropertiesL() - IN" ); RArray<TInt> entryIds; CleanupClosePushL( entryIds ); RIpAppPropArray array; TCleanupItem cleanup( CSPSettingsEngine::CleanupPointerArray, &array ); CleanupStack::PushL( cleanup ); // todo custom cleanup stack ConvertSpArrayToCenRepArrayL( aPropertyArray, array ); TInt err = iCenRepUtils->FindEntryIdsFromPropertiesL( array, entryIds ); if( err == KErrNone ) { TInt count = entryIds.Count(); for( TInt i = 0; i < count; i++ ) { TServiceId id = (TServiceId)entryIds[i]; if( id != KSPDefaultVoIPServiceId ) { User::LeaveIfError( aServiceIds.Append( id ) ); } } } CleanupStack::PopAndDestroy( &array ); CleanupStack::PopAndDestroy( &entryIds ); XSPSLOGSTRING( "CSPSettingsEngine::FindServiceIdsFromPropertiesL() - OUT" ); }
// --------------------------------------------------------------------------- // Update existing service provider settings entry // --------------------------------------------------------------------------- // TInt CSPSettingsEngine::UpdateEntryL( const CSPEntry& aEntry ) { XSPSLOGSTRING( "CSPSettingsEngine::UpdateEntry() - IN" ); TServiceId serviceId( aEntry.GetServiceId() ); // Leave if there is no service ID if ( KSPNoId == serviceId || aEntry.GetServiceName().Length() == 0 ) { User::Leave( KErrArgument ); } // construct RIpAppPropArray RIpAppPropArray array; TCleanupItem cleanup( CSPSettingsEngine::CleanupPointerArray, &array ); CleanupStack::PushL( cleanup ); ConvertSpEntryToCenRepArrayL( aEntry, array ); TInt err = iCenRepUtils->UpdateEntryL( (TInt) serviceId, array ); CleanupStack::PopAndDestroy( &array ); XSPSLOGSTRING( "CSPSettingsEngine::UpdateEntry() - OUT" ); return err; }
// --------------------------------------------------------------------------- // Stores new service provider settings entry // --------------------------------------------------------------------------- // void CSPSettingsEngine::AddEntryL( CSPEntry& aEntry ) { XSPSLOGSTRING( "CSPSettingsEngine::AddEntryL() - IN" ); // check the service name is not empty if( aEntry.GetServiceName().Length() == 0 ) { User::LeaveIfError( KErrArgument ); } // construct RIpAppPropArray RIpAppPropArray array; TCleanupItem cleanup( CSPSettingsEngine::CleanupPointerArray, &array ); CleanupStack::PushL( cleanup ); ConvertSpEntryToCenRepArrayL( aEntry, array ); // Create new unique service ID TInt newId = 0; iCenRepUtils->AddEntryL( newId, array ); aEntry.SetServiceId( newId ); CleanupStack::PopAndDestroy( &array ); XSPSLOGSTRING( "CSPSettingsEngine::AddEntryL() - OUT" ); }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // void CSpsBackupHelperPerformer::ConstructL() { XSPSLOGSTRING( "CSpsBackupHelperPerformer::ConstructL IN" ); iServiceProviderSettings = CSPSettings::NewL(); XSPSLOGSTRING( "CSpsBackupHelperPerformer::ConstructL 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 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" ); }
// --------------------------------------------------------------------------- // Destructor // --------------------------------------------------------------------------- // CSPSettingsEngine::~CSPSettingsEngine() { XSPSLOGSTRING( "CSPSettingsEngine::~CSPSettingsEngine() - IN" ); delete iCenRepUtils; XSPSLOGSTRING( "CSPSettingsEngine::~CSPSettingsEngine() - OUT" ); }
// --------------------------------------------------------------------------- // Destructor // --------------------------------------------------------------------------- // EXPORT_C CSPSettingsVoIPUtils::~CSPSettingsVoIPUtils() { XSPSLOGSTRING( "CSPSettingsVoIPUtils::~CSPSettingsVoIPUtils() - IN" ); delete iSettingsEngine; XSPSLOGSTRING( "CSPSettingsVoIPUtils::~CSPSettingsVoIPUtils() - OUT" ); }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // void CSpsBackupHelperPerformer::ResetToFactorySettingsL() { XSPSLOGSTRING( "CSpsBackupHelperPerformer::ResetToFactorySettingsL IN" ); // Ok if leave ( No service provider settings ) CRepository* cenrep = CRepository::NewLC( KCRUidSPSettings ); User::LeaveIfError( cenrep->Reset() ); CleanupStack::PopAndDestroy( cenrep ); XSPSLOGSTRING( "CSpsBackupHelperPerformer::ResetToFactorySettingsL OUT" ); }
// --------------------------------------------------------------------------- // Rollback changes in repository. // --------------------------------------------------------------------------- // void CSPSettingsEngine::RollbackTransaction() { XSPSLOGSTRING( "CSPSettingsEngine::RollbackTransaction() - IN" ); iCenRepUtils->RollbackTransaction(); XSPSLOGSTRING( "CSPSettingsEngine::RollbackTransaction() - OUT" ); }
// --------------------------------------------------------------------------- // Commits changes in repository. // --------------------------------------------------------------------------- // TInt CSPSettingsEngine::CommitTransaction() { XSPSLOGSTRING( "CSPSettingsEngine::CommitTransaction() - IN" ); iCenRepUtils->CommitTransaction(); XSPSLOGSTRING( "CSPSettingsEngine::CommitTransaction() - OUT" ); return KErrNone; }
// --------------------------------------------------------------------------- // Begins transaction in repository. // --------------------------------------------------------------------------- // TInt CSPSettingsEngine::BeginTransactionLC() { XSPSLOGSTRING( "CSPSettingsEngine::BeginTransaction() - IN" ); iCenRepUtils->BeginTransactionL(); XSPSLOGSTRING( "CSPSettingsEngine::BeginTransaction() - OUT" ); return KErrNone; }
// --------------------------------------------------------------------------- // Constructor // --------------------------------------------------------------------------- // void CSPSettingsEngine::ConstructL() { XSPSLOGSTRING( "CSPSettingsEngine::ConstructL() - IN" ); iCenRepUtils = CCenRepDatabaseUtil::NewL( KCRUidSPSettings, KSPStartKey, KSPColIncrement, KSPColMask, KServiceIdCounter, KSPColCount ); XSPSLOGSTRING( "CSPSettingsEngine::ConstructL() - OUT" ); }
// --------------------------------------------------------------------------- // IsVoIPSupported - API method // Returns ETrue if following items are ON: // Common Voip (Feature Manager) // Dynamic VoIP (Telephony settings) // --------------------------------------------------------------------------- // EXPORT_C TBool CSPSettingsVoIPUtils::IsVoIPSupported( ) const { XSPSLOGSTRING( "CSPSettingsVoIPUtils::IsVoIPSupported( ) - IN" ); TBool voipSupport( EFalse ); TRAPD( err, voipSupport = IsVoIPSupportedL() ); if ( err != KErrNone ) { voipSupport = EFalse; } XSPSLOGSTRING( "CSPSettingsVoIPUtils::IsVoIPSupported( ) - OUT" ); return voipSupport; }
// --------------------------------------------------------------------------- // Get Preferred Service - Actual implementation // --------------------------------------------------------------------------- // void CSPSettingsVoIPUtils::DoGetPreferredServiceL( TUint& aServiceId ) const { XSPSLOGSTRING( "CSPSettingsVoIPUtils::DoGetPreferredServiceL() - IN" ); if ( !IsVoIPSupportedL() ) { // Voip not supported User::Leave( KErrNotSupported ); } // Get the preferred service id CRepository* repository = CRepository::NewLC( KCRUidRichCallSettings ); TInt value(0); User::LeaveIfError( repository->Get( KRCSPSPreferredService, value ) ); CleanupStack::PopAndDestroy( repository ); XSPSLOGSTRING2( "CSPSettingsVoIPUtils::DoGetPreferredServiceL() service:%d",value ); if ( 0 == value ) { // Preferred service not setted. User::Leave( KErrNotFound ); } aServiceId = value; }
// --------------------------------------------------------------------------- // Returns count of stored service provider settings entries // --------------------------------------------------------------------------- // TInt CSPSettingsEngine::SettingsCountL() { XSPSLOGSTRING( "CSPSettingsEngine::SettingsCount() - IN" ); TInt result( 0 ); TInt err = iCenRepUtils->EntryCountL( result ); if( err == KErrNone ) { if( result >= KSPPredefinedCount ) { result--; } err = result; } else { err = 0; } XSPSLOGSTRING2( "CSPSettingsEngine::SettingsCount(%d) - OUT", result ); return err; }
// --------------------------------------------------------------------------- // Deletes service properties // --------------------------------------------------------------------------- // TInt CSPSettingsEngine::DeleteServicePropertiesL( TServiceId aServiceId, const RPropertyNameArray& aNameArray ) { XSPSLOGSTRING2( "CSPSettingsEngine::FindSubServicePropertyL( %d ) - IN", aServiceId ); RArray<TUint32> nameArray; CleanupClosePushL( nameArray ); TInt count = aNameArray.Count(); for( TInt i = 0; i < count; i++ ) { TUint32 name = (TUint32)( aNameArray[i] ); User::LeaveIfError( nameArray.Append( name ) ); } TInt id = (TInt)aServiceId; TInt err = iCenRepUtils->DeletePropertiesL( id, nameArray ); CleanupStack::PopAndDestroy( &nameArray ); XSPSLOGSTRING( "CSPSettingsEngine::FindSubServicePropertyL() - OUT" ); return err; }
// --------------------------------------------------------------------------- // Get id of the preferred service // --------------------------------------------------------------------------- // EXPORT_C TInt CSPSettingsVoIPUtils::GetPreferredService( TUint& aServiceId ) const { XSPSLOGSTRING( "CSPSettingsVoIPUtils::GetPreferredService() - IN" ); TRAPD( error, DoGetPreferredServiceL( aServiceId ) ); return error; }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // void CSpsBackupHelperPerformer::SetNextFreeServiceIdL( TInt aServiceId ) { XSPSLOGSTRING2( "CSpsBackupHelperPerformer::SetNextFreeServiceIdL IN, %i", aServiceId ); CRepository* cenrep = CRepository::NewLC( KCRUidSPSettings ); User::LeaveIfError( cenrep->Set( KServiceIdCounter, aServiceId ) ); CleanupStack::PopAndDestroy( cenrep ); XSPSLOGSTRING( "CSpsBackupHelperPerformer::SetNextFreeServiceIdL OUT" ); }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // TInt CSpsBackupHelperPerformer::NextFreeServiceIdL() { XSPSLOGSTRING( "CSpsBackupHelperPerformer::NextFreeServiceIdL IN" ); TInt ret(0); CRepository* cenrep = CRepository::NewLC( KCRUidSPSettings ); User::LeaveIfError( cenrep->Get( KServiceIdCounter, ret ) ); CleanupStack::PopAndDestroy( cenrep ); XSPSLOGSTRING2( "CSpsBackupHelperPerformer::NextFreeServiceIdL OUT, %i", ret ); return ret; }
// --------------------------------------------------------------------------- // VoIPProfilesExistL - API method // Returns ETrue if VoIP sub service plugin ID have been set for some service. // --------------------------------------------------------------------------- // EXPORT_C TBool CSPSettingsVoIPUtils::VoIPProfilesExistL() const { XSPSLOGSTRING( "CSPSettingsVoIPUtils::VoIPProfilesExistL() - IN" ); TBool profileExists( EFalse ); // Get all service IDs RArray<TServiceId> services; CleanupClosePushL( services ); iSettingsEngine->FindServiceIdsL( services ); const TInt count( services.Count() ); // Check if some service has VoIP sub service plug-in ID TInt err( 0 ); CSPProperty* property = CSPProperty::NewLC(); for( TInt i = 0; i < count && !profileExists; ++i ) { TServiceId id = services[ i ]; if( id == KSPDefaultVoIPServiceId ) { continue; } err = iSettingsEngine->FindPropertyL( id, EPropertyVoIPSubServicePluginId, *property ); profileExists = ( KErrNone == err ? ETrue : EFalse ); } CleanupStack::PopAndDestroy( property ); CleanupStack::PopAndDestroy( &services ); XSPSLOGSTRING( "CSPSettingsVoIPUtils::VoIPProfilesExistL() - OUT" ); return profileExists; }
// --------------------------------------------------------------------------- // IsPreferredTelephonyVoIP - API method // Returns ETrue if following items are ON: // Common Voip (Feature Manager) // Dynamic VoIP (Telephony settings) // Preferred telephony (Rich call settings) // + there is at least one SIP-VoIP profile stored // --------------------------------------------------------------------------- // EXPORT_C TBool CSPSettingsVoIPUtils::IsPreferredTelephonyVoIP() const { XSPSLOGSTRING( "CSPSettingsVoIPUtils::IsPreferredTelephonyVoIP() - IN" ); // Check that VoIP is supported TBool voipSupported( IsVoIPSupported() ); XSPSLOGSTRING2( "CSPSettingsVoIPUtils::VoipSupported: %d",voipSupported ); // Check the preferred telephony TBool voipPreferred( EFalse ); TRAP_IGNORE( voipPreferred = IsPreferredTelephonyVoIPL() ); XSPSLOGSTRING2( "CSPSettingsVoIPUtils::VoipPreferred: %d", voipPreferred ); XSPSLOGSTRING( "CSPSettingsVoIPUtils::IsPreferredTelephonyVoIP() - OUT" ); return voipPreferred && voipSupported; }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // void CSpsBackupHelperPerformer::FinalizeRestoreL() { XSPSLOGSTRING( "CSpsBackupHelperPerformer::FinalizeRestoreL IN" ); // Determine how many settings exists after factory settings TUint nextFreeServiceId = NextFreeServiceIdL(); // Restore old settings // Make sure that id's are in correct order! for( TInt i = 0; i < iEntries.Count(); i++ ) { // Start inputting restored settings from next free serviceid if( iEntries[i]->GetServiceId() == nextFreeServiceId ) { // Service id to be inserver is same as next free serviceid nextFreeServiceId = iEntries[i]->GetServiceId(); iServiceProviderSettings->AddEntryL( *iEntries[i] ); nextFreeServiceId++; // Entry added } else if( iEntries[i]->GetServiceId() > nextFreeServiceId ) { // Change inserted service id when service id is larger // than current service count. // This is done since backed up settings can be non linear SetNextFreeServiceIdL( iEntries[i]->GetServiceId() ); nextFreeServiceId = iEntries[i]->GetServiceId(); iServiceProviderSettings->AddEntryL( *iEntries[i] ); nextFreeServiceId++; // Entry added } } XSPSLOGSTRING2( "CSpsBackupHelperPerformer::FinalizeRestoreL Next free serviceid=%i", nextFreeServiceId ); XSPSLOGSTRING( "CSpsBackupHelperPerformer::FinalizeRestoreL OUT" ); }
// --------------------------------------------------------------------------- // Search stored service IDs of service provider settings entries // --------------------------------------------------------------------------- // TInt CSPSettingsEngine::FindServiceIdsL( RIdArray& aServiceIds ) { XSPSLOGSTRING( "CSPSettingsEngine::FindServiceIdsL() - IN" ); RArray<TInt> cenrepArray; CleanupClosePushL( cenrepArray ); TInt err = iCenRepUtils->FindEntryIdsL( cenrepArray ); for( TInt i = 0; i < cenrepArray.Count(); i++ ) { TServiceId id = (TServiceId)cenrepArray[i]; if( id != KSPDefaultVoIPServiceId ) { User::LeaveIfError( aServiceIds.Append( id )); } } CleanupStack::PopAndDestroy( &cenrepArray ); XSPSLOGSTRING( "CSPSettingsEngine::FindServiceIdsL() - OUT" ); return err; }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // TInt CSPSettingsEngine::FindSubServicePropertiesL( TServiceId aServiceId, TSPItemType aPropertyType, RPropertyArray& aPropertyArray ) { XSPSLOGSTRING2( "CSPSettingsEngine::FindSubServicePropertiesL( %d ) - IN", aServiceId ); RPropertyNameArray nameArray; CleanupClosePushL( nameArray ); PropertyNameArrayFromItemTypeL( aPropertyType, nameArray ); TInt count = nameArray.Count(); TInt id = (TInt) aServiceId; CCenRepDatabaseProperty* property = CCenRepDatabaseProperty::NewLC(); for( TInt i = 0; i < count; i++ ) { TUint32 name = nameArray[i]; TInt err = iCenRepUtils->FindPropertyL( id, name, *property ); if( err == KErrNone ) { CSPProperty* spProperty = CSPProperty::NewLC(); User::LeaveIfError( spProperty->SetName( (TServicePropertyName)(property->GetName())) ); User::LeaveIfError( spProperty->SetValue( property->GetDesValue() )); User::LeaveIfError( aPropertyArray.Append( spProperty )); CleanupStack::Pop( spProperty ); } } CleanupStack::PopAndDestroy( property ); CleanupStack::PopAndDestroy( &nameArray ); XSPSLOGSTRING( "CSPSettingsEngine::FindSubServicePropertiesL() - OUT" ); return KErrNone; }
// --------------------------------------------------------------------------- // 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; }
// --------------------------------------------------------------------------- // Constructor // --------------------------------------------------------------------------- // void CSPSettingsVoIPUtils::ConstructL() { XSPSLOGSTRING( "CSPSettingsVoIPUtils::ConstructL() - IN" ); iSettingsEngine = CSPSettingsEngine::NewL(); XSPSLOGSTRING( "CSPSettingsVoIPUtils::ConstructL() - OUT" ); }