// ---------------------------------------------------------------------------
// CSsmLangSelCmd::SetIndividualSettingsToCentRep
//
// ---------------------------------------------------------------------------
//
TInt CSsmLangSelCmd::SetIndividualSettingsToCentRep( const TInt aRegion, const TInt aCollation )
    {
    FUNC_LOG;
    CRepository* cenrep = NULL;
    TRAPD( errorCode, cenrep = CRepository::NewL( KCRUidCommonEngineKeys ) );
  
    if ( KErrNone == errorCode )
        {
        //Set the Region CR with the given value
        errorCode = cenrep->Set( KGSRegion, aRegion );
        ERROR( errorCode, "Failed to Set Region code to CentRep, %d"  );                
        }
    else
        {
        INFO_1( "Failed to initialize cen rep %d", errorCode );        
        }

    if ( KErrNone == errorCode )
        {
        //Set the Collation CR with the given value
        errorCode = cenrep->Set( KGSCollation, aCollation );
        ERROR( errorCode, "Failed to Set Collation code to CentRep, %d"  );               
        }
    delete cenrep;
    return errorCode;
    }
TVerdict CDeleteLastConnectedDevice::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Our implementation only gets called if the base class doTestStepPreambleL() did
 * not leave. That being the case, the current test result value will be EPass.
 */
	{
	if (TestStepResult()==EPass)
		{
#ifdef SYMBIAN_LOCATION_BTGPSCONFIG
		// Bluetooth GPS PSY is using the new configuration API to store HW information
		// simply clear the list
		
		SetTestStepResult(EPass);

		CLbsBtGpsConfig* config = CLbsBtGpsConfig::NewL();
		CleanupStack::PushL(config);
		
		User::LeaveIfError(config->EmptyDeviceList());
		
		CleanupStack::PopAndDestroy(config);
		
	    _LIT(KDeviceRemoved, "Cleared Bluetooth GPS PSY device list" );
		INFO_PRINTF1(KDeviceRemoved); 
#else
		// Bluetooth GPS PSY is using cenrep to store HW information  
		
		// This step removes any last known device information from the BT GPS PSY
		TUid KCRUidBtGpsPsy = { 0x101FE999 };
		SetTestStepResult(EPass);
		CRepository* settings = CRepository::NewL(KCRUidBtGpsPsy);
		
	    TInt err = settings->Set(KBluetoothGpsPsyDeviceAddressValidity, 0);
		
	    TInt isValid;
	    err |= settings->Get(KBluetoothGpsPsyDeviceAddressValidity, isValid);
	   
	    TBTSockAddr dummyAddr;
       
		TBuf<KMaxSockAddrSize> addressBuffer;
		addressBuffer.Copy(dummyAddr);
		err |= settings->Set(KBluetoothGpsPsyDeviceAddress , addressBuffer);
		err |= settings->Set(KDevNotifCenrepHwKey,addressBuffer);
	  
		if(isValid==0)
	    	{
		    _LIT(KDeviceInvalidated, "Device is invalidated" );
			INFO_PRINTF1(KDeviceInvalidated); 
	    	}
	    if((err!=KErrNone)||(isValid))
	    	{
		    _LIT(KErrorOccurred, "Error or device is still valid. Error is %d and isValid is %d");
			INFO_PRINTF3(KErrorOccurred,err,isValid);
	    	SetTestStepResult(EFail); 
	    	}
#endif
		}
	  return TestStepResult();
 	}
// -----------------------------------------------------------------------------
// CProfileExtraTonesImpl::ExternalizeL
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CProfileExtraTonesImpl::ExternalizeL( CRepository& aCenRep,
        TInt aProfileId ) const
{
    // IM Message Alert Tone
    User::LeaveIfError(
        aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngImTone,
                     aProfileId ), *iIMMessageAlertTone ) );

    // E-mail Alert Tone
    User::LeaveIfError(
        aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngEmailTone,
                     aProfileId ), *iEmailAlertTone ) );

    // Video call ringing tone
    User::LeaveIfError(
        aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngVideoCallTone,
                     aProfileId ), *iVideoCallRingingTone ) );

    // Reminder Tone
    User::LeaveIfError(
        aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngReminderTone,
                     aProfileId ), *iReminderTone ) );

    // Clock Alarm Tone
    User::LeaveIfError(
        aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngClockAlarmTone,
                     aProfileId ), *iClockAlarmTone ) );
}
void CSysApSimChanged::ClearRepositoriesL()
    {
    const TUid KCRUidLogs = {0x101F874E};
    /**
    * Informs the Logs application about the amount of new missed calls.
    * Integer type
    **/
    const TUint32 KLogsNewMissedCalls = 0x00000006;
    TRACES( RDebug::Print( _L("CSysApSimChanged::ClearRepositoriesL(): opening KCRUidCallForwarding") ) );
    
    CRepository* repository = CRepository::NewL( KCRUidCallForwarding );
    
    repository->Set( KSettingsCFDefaultNumber1, KNullDesC );
    repository->Set( KSettingsCFDefaultNumber2, KNullDesC );
    repository->Set( KSettingsCFDefaultNumber3, KNullDesC );
    repository->Set( KSettingsCFDefaultNumberAls1, KNullDesC );
    repository->Set( KSettingsCFDefaultNumberAls2, KNullDesC );
    repository->Set( KSettingsCFDefaultNumberAls3, KNullDesC );
    repository->Set( KSettingsCFUsedFaxNumber, KNullDesC );
    repository->Set( KSettingsCFUsedDataNumber, KNullDesC );
    repository->Set( KSettingsCFTimerValue, KPSetDefaultCFTimer );
    repository->Set( KSettingsCFTimerValueAls, KPSetDefaultCFTimer );
    
    delete repository;
    
    TRACES( RDebug::Print( _L("CSysApSimChanged::ClearRepositoriesL(): opening KCRUidLogs") ) );
    repository = CRepository::NewL( KCRUidLogs );
    
    repository->Set( KLogsNewMissedCalls, 0 );

    delete repository;
    }
/**
@SYMTestCaseID BA-CTSY-ALLS-MGAL-0005
@SYMComponent  telephony_ctsy
@SYMTestCaseDesc Test support in CTSY for RMobilePhone::GetALSLine with timeout
@SYMTestPriority High
@SYMTestActions Invokes RMobilePhone::GetALSLine and tests for timeout
@SYMTestExpectedResults Pass
@SYMTestType CT
*/
void CCTsyAlternateLineServiceFU::TestGetALSLine0005L()
	{

	OpenEtelServerL(EUseExtendedError);
	CleanupStack::PushL(TCleanupItem(Cleanup,this));
	OpenPhoneL();

	RBuf8 data;
	CleanupClosePushL(data);

	TRequestStatus requestStatus;
	TInt ret(-1);

	//-------------------------------------------------------------------------
	// Test A: Test timeout of RMobilePhone::GetALSLine
 	//-------------------------------------------------------------------------

	// create centRep to change repository 
	CRepository* centRep = CRepository::NewL( KCRUidCtsyMEAlsLine );
	CleanupStack::PushL(centRep);
    
	// setting environment (set KCtsyMEAlsSupported in repository to ETrue)
	ret = centRep->Set( KCtsyMEAlsSupported, ETrue );
	ASSERT_EQUALS(KErrNone, ret);

	// setting environment (set alsLine to EAlternateLinePrimary)
	iMockLTSY.NotifyTerminated(requestStatus);
	RMobilePhone::TMobilePhoneALSLine alsLine(RMobilePhone::EAlternateLineUnknown);
	TMockLtsyData1<RMobilePhone::TMobilePhoneALSLine> alsLineData(alsLine);
	alsLineData.SerialiseL(data);
	iMockLTSY.CompleteL(EMobilePhoneGetALSLine, KErrNone, data);
	User::WaitForRequest(requestStatus);
	ASSERT_EQUALS(KErrNone, requestStatus.Int());
	AssertMockLtsyStatusL();
	
	// test setting and execute
	iMockLTSY.ExpectL(EMobilePhoneGetALSLine, KErrNone);
	ret = iPhone.GetALSLine(alsLine);
	ASSERT_EQUALS(KErrTimedOut, ret);
	ASSERT_EQUALS(alsLine, RMobilePhone::EAlternateLineNotAvailable);
	AssertMockLtsyStatusL();

	// Done !
	// return repository KCtsyMEAlsSupported to EFalse (initial state)
	ret = centRep->Set( KCtsyMEAlsSupported, EFalse );
	ASSERT_EQUALS(KErrNone, ret);

	AssertMockLtsyStatusL();
	CleanupStack::PopAndDestroy(1); // iCentRep
	CleanupStack::PopAndDestroy(2, this); // data, this

	}
// -----------------------------------------------------------------------------
// CProfilePttSettingsImpl::ExternalizeL
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CProfilePttSettingsImpl::ExternalizeL( CRepository& aCenRep,
                                            TInt aProfileId ) const
    {
    // PTT Ringing tone
    User::LeaveIfError(
            aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngPttTone,
            aProfileId ), *iPttRingingTone ) );

    // PTT status
    User::LeaveIfError(
            aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngPttStatus,
            aProfileId ), iPttStatus ) );

    }
EXPORT_C TMTPResponseCode MMTPServiceHandler::SaveServicePropValue(
	CRepository& aRepository, TUint aColumnNum, TMTPTypeGuid& aNewData)
	{
	TInt ret;
	TMTPResponseCode responseCode = EMTPRespCodeOK;
	TBuf8<KMTPTypeINT128Size>  data;
	data.FillZ(data.MaxLength());
	TUint64 upperValue = aNewData.UpperValue();
	TUint64 lowerValue = aNewData.LowerValue();

	/**
	Least significant 64-bit buffer offset.
	*/
	const TInt           KMTPTypeUint128OffsetLS = 0;
	/**
	Most significant 64-bit buffer offset.
	*/
	const TInt           KMTPTypeUint128OffsetMS = 8;

	memcpy(&data[KMTPTypeUint128OffsetMS], &upperValue, sizeof(upperValue));
	memcpy(&data[KMTPTypeUint128OffsetLS], &lowerValue, sizeof(lowerValue));

	ret = aRepository.Set(aColumnNum, data);
	if (KErrNone != ret)
		{
		responseCode = EMTPRespCodeGeneralError;
		}
	return responseCode;
	}
// ---------------------------------------------------------------------------
// CSsmPolicyBase::ResetLimitReachedL
// ---------------------------------------------------------------------------
//
TBool CSsmPolicyBase::ResetLimitReachedL()
    {
    FUNC_LOG;

    CRepository* repository = CRepository::NewL( iUtil->CrUid( KCRUidSsmStartupPolicy ) );
    CleanupStack::PushL( repository );

    TInt count;
    User::LeaveIfError( repository->Get( KSsmStartupErrorResetCounter, count ) );

    INFO_1( "Reset count is %d", count );

    TInt limit;
    User::LeaveIfError( repository->Get( KSsmStartupErrorResetLimit, limit ) );

    INFO_1( "Reset limit is %d", limit );

    const TBool retVal = ( count >= limit );

    if ( count < limit )
        {
        count++;
        User::LeaveIfError( repository->Set( KSsmStartupErrorResetCounter, count ) );
        }

    CleanupStack::PopAndDestroy( repository );
    return retVal;
    }
/**
Static initializer. 
Defines the properties for each of the types of assistance data
Leaves if any error (except KErrAlreadyExists)
*/
EXPORT_C void RAssistanceDataCache::InitializeL()
    {
	_LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
    TInt err;
    
    for (TInt i = 0; i < KAssistanceDataListCount; i++)
    	{
	    err = RProperty::Define(KLbsAssistDataApiBase + i,
								RProperty::ELargeByteArray,
								KAllowAllPolicy,
								KAllowAllPolicy, 
								GetDataSize(KAssistanceDataList[i]));
		if (err != KErrNone && err != KErrAlreadyExists)
			{
			User::Leave(err);
			}
		}
				
	// Save the Uid of the process which called InitializeL()
	// in the cenrep file owned by LbsRoot.
	CRepository* rep = CRepository::NewLC(KLbsCenRepUid);
	TInt categoryUid(RProcess().SecureId());
	User::LeaveIfError(rep->Set(KNgAssistanceDataUpdatesCategoryKey, categoryUid));
	CleanupStack::PopAndDestroy(rep);
    }
/*
 * This method sets Common Data Set in Central Repository.
 * @param aNewValue new value for Common Data Set.
 */
void CT_LbsSimulationPsyPosTp400::SetTrpModeL(TInt aNewValue)
	{
	// Set Time Related Playback behaviour in the Central Repository.
	CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY);
	User::LeaveIfError(repository->Set(KCRKeySimPSYCommonDataSet, aNewValue));
	CleanupStack::PopAndDestroy(repository);
	}
void CdmcertapiSession::DispatchMessageL(const RMessage2& aMessage)
	{
	RDEBUG("CdmcertapiSession::DispatchMessageL");
	TInt ret = KErrNone;
	switch(aMessage.Function())
		{
		case EGetCertificate:
		{
			TInt err = KErrNone;
	
			TCertInfo info ;
			CreateCertificate( info ); 	

			CRepository *re = NULL;
			TRAPD( erx, re = CRepository::NewL ( 
		            KCRUidPolicyManagementUtilInternalKeys ) );
			if (erx == KErrNone )
			{
				TPckg<TCertInfo> pcert( info );
				err = re->Create( KSyncMLSessionCertificate, pcert ) ;
				if ( err == KErrNone )
				{
					//DBG_ARGS8(_S8("Wrote reposotry key %S"), &pcert );
				}
				else
				{
					if ( err == KErrAlreadyExists )
					{
						err = re->Set( KSyncMLSessionCertificate, pcert ) ;
						if ( err != KErrNone )
							{
							//
							}
					}
					else
					{
						//
					}
				}	
				delete re ;
				re = NULL;
			}
			else
			{
				//	DBG_ARGS8(_S8("ERROR Failed to open reposiritry %d"), erx );	
			}
		
		TCertInfo info1 ;
		RDMCert rdm;
		rdm.Get(info1);
		ret = KErrNone;
		}
		break;
		default:
			break;
		}
		TPckgBuf<TInt> retPackage(ret);
		aMessage.WriteL(0,retPackage);
	}
// ---------------------------------------------------------------------------
// CSsmShutdownPolicy::StoreStartupReasonL
// ---------------------------------------------------------------------------
//
void CSsmShutdownPolicy::StoreStartupReasonL( const TInt aReasonCode )
    {
    FUNC_LOG;
    INFO_1( "Storing startup reason %d", aReasonCode );

    CRepository* repository =
        CRepository::NewLC( iUtil->CrUid( KCRUidStartup ) );
    TInt errorCode = repository->Set( KStartupReason, aReasonCode );
    ERROR( errorCode, "Failed to set KStartupReason CenRep key" );

	// In case of disk full, we will not try to set the device lock query status cenrep key here.
	// Rather it is set after disk space is recovered.
	if ((EUnknownReset !=  aReasonCode) && (KErrDiskFull != errorCode))
		{
		// Set the lock code query success as EStartupDevLockNotSucess in case the shutdown is not due to the the unknown reset.  
		// This is because if the device crashes before resetting the key during boot time.
		errorCode = repository->Set(KStartupDevLockStatus, EStartupDevLockNotSucess);
		INFO_1("Setting KStartupDevLockStatus CenRep key with EStartupDevLockNotSucess completed with %d", errorCode);
		}

	if( KErrDiskFull == errorCode )
		{
		//Need not to put on CleanupStack, it's not calling any leaving function and
		//it's handled by reference count
		CSsmUiSpecific* ssmUiSpecific = CSsmUiSpecific::InstanceL();
		//Free complete reserve space
		errorCode = ssmUiSpecific->FreeReservedPhoneMemorySpace( 0 );
		if( KErrNone == errorCode )
			{
			errorCode = repository->Set( KStartupReason, aReasonCode );
			ERROR( errorCode, "Failed to set KStartupReason CenRep key after freeing the memory" );

			if (EUnknownReset !=  aReasonCode)
				{
				// Set the lock code query success as EStartupDevLockNotSucess in case the shutdown is not due to the the unknown reset.  
				// This is because if the device crashes before resetting the key during boot time.
				errorCode = repository->Set(KStartupDevLockStatus, EStartupDevLockNotSucess);
				ERROR( errorCode, "Failed to set KStartupDevLockStatus CenRep key after freeing the memory" );
				}
			}
		CSsmUiSpecific::Release();
		}
    
    CleanupStack::PopAndDestroy( repository );
    User::LeaveIfError( errorCode );
    }
// Allow writing value zero, so that STUN client's behaviour can be tested also
// in such case. If aKeyValue is KErrNotFound, then application didn't provide
// it, and it is not written.
void TCmdUNSAFTimers::WriteL( CRepository& aRepository,
						      const TUint32& aKey,
						      TInt aKeyValue ) const
    {
    if ( aKeyValue != KErrNotFound )
    	{
    	User::LeaveIfError( aRepository.Set( aKey, aKeyValue ) );
    	}    
    }
void TCmdUNSAFTimers::WriteL( CRepository& aRepository,
						      const TUint32& aKey,
						      const TDesC8& aKeyValue ) const
    {
    if ( aKeyValue != KNullDesC8 )
    	{
    	User::LeaveIfError( aRepository.Set( aKey, aKeyValue ) );
    	}    
    }
示例#15
0
// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
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" );
    }
示例#16
0
// -----------------------------------------------------------------------------
// CNSmlDSSettings::WriteRepositoryL
//
// -----------------------------------------------------------------------------
//
void CNSmlDSSettings::WriteRepositoryL(TUid aUid, TInt aKey, TInt aValue)
    {
    const TUid KRepositoryId = aUid;
    
    CRepository* rep = CRepository::NewLC(KRepositoryId);
    TInt err = rep->Set(aKey, aValue);
    User::LeaveIfError(err);
    CleanupStack::PopAndDestroy(rep);
    
    }
示例#17
0
/**
@SYMTestCaseID 	 SYSLIB-CENTRALREPOSITORY-CT-3343
@SYMTestCaseDesc Restore factory Settings from Install file.
@SYMTestPriority High
@SYMTestActions  Ensure that the repository file only exists in the Install directory.
				 Open the repository and modify a setting.  Force RFS
				 and check that the repository is restored against the Install file
@SYMTestExpectedResults The test repository should be reset against the Install file
@SYMDEF 		 PDEF099108
*/
LOCAL_C void RFSInstallOnlyL()
	{

	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-3343 ResetAllRepositoriesTestL "));
	TInt r;
	TReal realVal;
	TBuf<20> strVal;

	//restore all test files - this ensures we have a repository file
	//only on the c:
	RestoreRFSTestFilesL(EInstallOnly);

	TheTest.Next(_L("Open repository to ensure server is running"));
	CRepository* repository = CRepository::NewLC(KUidRfsRepositoryInstallOnlyDefaultFile);

	TheTest.Next(_L("Modify a Setting"));
	r = repository->Set(KReal1, KReal1_UpdatedValue);
	TEST2(r, KErrNone);

	//verify the update
	r = repository->Get(KReal1, realVal);
	TEST2(r, KErrNone);
	TEST(realVal == KReal1_UpdatedValue);

	// Close repository
	CleanupStack::PopAndDestroy(repository);

	//Kill the server
	TheTest.Next(_L("Kill the server process"));
	_LIT( KCentralRepositoryServerName, "Centralrepositorysrv");
	r = KillProcess(KCentralRepositoryServerName);
	TEST2(r,KErrNone);

	User::After(KGeneralDelay);

	//Restart the server in soft reset mode to force a
	//repository reset
	TheTest.Next(_L("Manually start central respository"));
	ReStartServerInSoftResetMode();

	//Open the repository
	repository = CRepository::NewLC(KUidRfsRepositoryInstallOnlyDefaultFile);

	//verify that the Real value has been reset against the value in the install
	//repository file
	TheTest.Next(_L("Get 'Modified' value"));
	r = repository->Get(KReal1, realVal);
	TEST2(r, KErrNone);
	TEST(realVal == KReal1_InstallValue);

	// Close repository
	CleanupStack::PopAndDestroy(repository);

	TheTest.End();
	}
示例#18
0
EXPORT_C TInt CDevEncSession::SetDevEncControlL(TInt aValue)
    {
    DFLOG2("CDevEncSession SetDevEncControl, value = %d >>", aValue);
    
    CRepository* rep = CRepository::NewLC(TUid::Uid(KCRDevEncUiSettings));
    TInt err = rep->Set(KDevEncUiDmControl, aValue);
    CleanupStack::PopAndDestroy(rep);
    
    DFLOG2("CDevEncSession SetDevEncControl, err = %d <<", err);
    return err;
    }
// -----------------------------------------------------------------------------
// CDRMHelperServer::SetKeyValueL().
// This function set CenRep key value
// -----------------------------------------------------------------------------
//
void CDRMHelperServer::SetKeyValueL( const TDesC8& aKeyValue , const TUint8& aRegType )
    {
#ifdef _DRM_TESTING
    WriteL(_L8("SetKeyValueL"));
    WriteL( aKeyValue );
#endif

    // Connecting and initialization:
    CRepository* repository = CRepository::NewL(KCRUidDRMHelperServer);
    CleanupStack::PushL( repository );
    if ( aRegType == CDRMHelperServer::EActive )
        {
        User::LeaveIfError(repository->Set(KDRMHelperServerNotification, aKeyValue));
        }
    else if ( aRegType == CDRMHelperServer::EPassive )
        {
        User::LeaveIfError(repository->Set(KDRMHelperServerNotificationPassive, aKeyValue));
        }
    CleanupStack::PopAndDestroy(repository); // repository
    }
//-----------------------------------------------------------------------------
// CNSmlDsProvisioningAdapter::StoreOperatorUrlL
// 
//-----------------------------------------------------------------------------
//
void CNSmlDsProvisioningAdapter::StoreOperatorUrlL( const TDesC& aUrl )
	{
	CRepository* rep = NULL;
	TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncInternalKeys ) );
	if ( err == KErrNone )
		{
		CleanupStack::PushL( rep );
		User::LeaveIfError( rep->Set( KNsmlOpDsOperatorSyncServerURL, aUrl ));
		CleanupStack::PopAndDestroy( rep );
		}
	}
EXPORT_C TMTPResponseCode MMTPServiceHandler::SaveServicePropValue(
	CRepository& aRepository, TUint aColumnNum, TInt aNewData)
	{
	TInt ret;
	TMTPResponseCode responseCode = EMTPRespCodeOK;
	ret = aRepository.Set(aColumnNum, aNewData);
	if (KErrNone != ret)
		{
		responseCode = EMTPRespCodeGeneralError;
		}
	return responseCode;
	}
示例#22
0
// ---------------------------------------------------------
// TXdmSettingsApi::UpdatePropertyL
//
// ---------------------------------------------------------
//
EXPORT_C void TXdmSettingsApi::UpdatePropertyL( TInt aSettingsId,
        const TDesC& aPropertyValue,
        TXdmSettingsProperty aPropertyName )

{
#ifdef _DEBUG
    HBufC8* value = HBufC8::NewLC( aPropertyValue.Length() );
    TPtr8 prop( value->Des() );
    prop.Copy( aPropertyValue );
    WriteToLog( _L8( "TXdmSettingsApi::UpdatePropertyL()" ) );
    WriteToLog( _L8( "  Settings ID:      %d" ), aSettingsId );
    WriteToLog( _L8( "  Property name:    %d" ), aPropertyName );
    WriteToLog( _L8( "  Property value:   %S" ), &prop );
    CleanupStack::PopAndDestroy();  //value
#endif
    TInt error = KErrAlreadyExists;
    CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
    CleanupStack::PushL( repository );
    RArray<TUint32> keys = FindByIdL( aSettingsId, repository );
    CleanupClosePushL( keys );
    TInt count = keys.Count();
    if( count == 1 )
    {
        TInt32 row = ( keys[0] & 0xFFFFFF00 ) / 0x100;
        TInt32 key = ( row * 0x100 ) | aPropertyName;
#ifdef _DEBUG
        WriteToLog( _L8( "  Key to update:    0x%08x" ), key );
#endif
        error = repository->Set( key, aPropertyValue );
        if( error != KErrNone )
        {
#ifdef _DEBUG
            WriteToLog( _L8( "  Set() failed with %d, try Create()" ), error );
#endif
            error = repository->Create( key, aPropertyValue );
#ifdef _DEBUG
            WriteToLog( _L8( "  Create() completed with %d" ), error );
#endif
        }
    }
    else                            //No keys or too many
    {
#ifdef _DEBUG
        TBuf<32> errBuf;
        count > 0 ? errBuf.Append( _L( "Too many results" ) ) :
        errBuf.Append( _L( "No results found" ) );
        WriteToLog( _L8( "  * Error - %S: %d" ), &errBuf, count );
#endif
        TInt error = count > 0 ? KErrGeneral : KErrNotFound;
        User::Leave( error );
    }
    CleanupStack::PopAndDestroy( 2 );  //keys, repository
}
示例#23
0
// ---------------------------------------------------------------------------
// CSsmLangSelCmd::StoreLanguageToCentRep
//
// ---------------------------------------------------------------------------
//
void CSsmLangSelCmd::StoreLanguageToCentRep( const TInt aLanguage )
    {
    FUNC_LOG;
    TUid mappedUid = iMapperUtility->CrUid( KCRUidSysLangUtil );
    CRepository* cenrep = NULL;
    TRAPD( errorCode, cenrep = CRepository::NewL( mappedUid ) );
    ERROR_1( errorCode, "Failed to initialize cen rep %d", errorCode );
    
    if ( KErrNone == errorCode )
        {
        errorCode = cenrep->Set( KSysLangUtilSimLanguage, aLanguage );
        ERROR_1( errorCode, "Failed to store language code to CentRep, %d", 
                                                                  errorCode );
        delete cenrep;
        }
    }
示例#24
0
TInt CProfilerPowerListener::Stop() 
    {
    LOGTEXT(_L("CProfilerPowerListener::Stop() - entry"));

    if (iPowerAPI)
        {
        TRAPD(err, iPowerAPI->StopAveragePowerReportingL());
        if(err != KErrNone)
            {
            LOGSTRING2("CProfilerPowerListener::Stop() - Failed to stop power reporting: %d", err);
            }
        else
            {
            LOGTEXT(_L("CProfilerPowerListener::Stop() - Stopped power monitoring"));
            }
        delete iPowerAPI;
        iPowerAPI = 0;

        // Restore original value to max sampling period
        CRepository* centRep = 0;
        TRAP(err, centRep = CRepository::NewL(KCRUidPowerSettings));
        if (err != KErrNone)
            {
            LOGSTRING2("CProfilerPowerListener::Stop() - Failed to open Central Repository: %d", err);
            }
        else
            {
            err = centRep->Set(KPowerMaxReportingPeriod, iOriginalReportingPeriod);
            if(err != KErrNone)
                {
                LOGSTRING2("CProfilerPowerListener::Stop() - Failed to restore max sampling period: %d", err);
                }
            }
        }
#ifdef PWR_SAMPLER_BACKLIGHT
    if (iLightAPI)
        {
        delete iLightAPI;
        iLightAPI = 0;
        }
#endif

    LOGTEXT(_L("CProfilerPowerListener::Stop() - exit"));
    return KErrNone;
    }
示例#25
0
void Util::SetAppropriateTimezoneL()
	{
	TUid repUid = {0x1020e4d3};
	CRepository* rep = CRepository::NewLC(repUid);
	
	// Set the date format to European
	User::LeaveIfError(rep->StartTransaction(CRepository::EConcurrentReadWriteTransaction));
	User::LeaveIfError(rep->Set(101, EDateEuropean)); // 101 is the date format reg entry
	TUint32 keys(0);
	User::LeaveIfError(rep->CommitTransaction(keys));
	
	CleanupStack::PopAndDestroy(rep);
	
	TExtendedLocale locale;
	locale.LoadSystemSettings();
	locale.GetLocale()->SetDateFormat(EDateEuropean);
	User::LeaveIfError(locale.SaveSystemSettings());
	}
// ---------------------------------------------------------
// CPosTp4723::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp4723::StartL()
    {
    ConnectL();
    SetupProxyPSYsL();
	
	TPositionModuleId modId = iUidSatInfoPsy;
    CRepository* repos = CRepository::NewL( KCRUidDefaultProxyConfiguration );    
    TBuf<40> idBuf;
    idBuf.AppendNumFixedWidth( modId.iUid, EHex, 8);
    TInt error = repos->Set(KDefaultProxyLastWorkingGpsPsy, idBuf);
    delete repos;
    User::LeaveIfError(error);
	
    TInt err = OpenPositioner();
    _LIT(KOpenErr, "Error when opening positioner, %d");
    AssertTrueL(err == KErrNone, KOpenErr, err);
    
    _LIT(KServiceName, "TP4723");
    iPositioner.SetRequestor(CRequestor::ERequestorService, 
		CRequestor::EFormatApplication, KServiceName);

    TPositionSatelliteInfo posInfo;
    // Request value should be 4722, even for TP4723...
    TInt request = 4722;
    
    // Default PSY won't pre-load Multi PSY since it is Internal
    VerifyPsyUnloadedL(iUidMultiPsy);
    // Default PSY should pre-load SetInfo PSY since it is External and supports GPS
    VerifyPsyLoadedL(iUidSatInfoPsy);
    
	//
	// Request 1
	//
    RequestL(posInfo, request, KEspectedErrorCodePSY1);    
      
    VerifyPositionFromL(posInfo, iUidSatInfoPsy);    
    VerifyRequestTimeLessThanL(1200000);
    
    VerifyPsyLoadedL(iUidSatInfoPsy);
    
    VerifyPositionL(posInfo, 40, 50, 60);
    }
// ---------------------------------------------------------------------------
// CheckForUpdateL
// Requests service list update if SendUI Ecom service count has changed.
// ---------------------------------------------------------------------------
//
void CSendUiEcomObserver::CheckForUpdateL()
{
    RImplInfoPtrArray implInfoArray ;
    REComSession::ListImplementationsL(
        TUid::Uid( KSendUiSendingServiceInterface ),implInfoArray );
    TInt newEcomCount = implInfoArray.Count();
    implInfoArray.ResetAndDestroy();

    CRepository* repository = CRepository::NewLC( KCRUidSendUi );
    TInt oldEcomCount = -1;
    // request service list update if sendui ecom service count has change.
    if ( repository->Get( KKeySendUiServiceEcomCount, oldEcomCount ) != KErrNone
            || oldEcomCount != newEcomCount )
    {
        repository->Set( KKeySendUiServiceEcomCount, newEcomCount );
        User::LeaveIfError(
            RProperty::Set(KPSUidSendUiProperty, KSendUiUpdateRequest, KSendUiUpdateRequested ) );
    }
    CleanupStack::PopAndDestroy( repository );
}
void CSysApCenRepController::SetInt( const TUid aRepository, const TUint32 aKey, const TInt aNewValue )
    {
    TInt err( KErrNone );
    if ( aRepository == KCRUidCoreApplicationUIsSysAp )
        {
        err = iSysApRepository->Set( aKey, aNewValue );
        }
    else
        {
        CRepository* repository = NULL;
        TRAP( err, repository= CRepository::NewL( aRepository ) );
        if ( !err )
            {
            err = repository->Set( aKey, aNewValue );
            }
        delete repository;
        }
    if ( err )
        {
        TRACES( RDebug::Print( _L("CSysApCenRepController::SetInt: err=%d" ), err ) );
        }
    }
示例#29
0
/*!
    \brief Changes the device system language.  
     
    \attention Symbian specific API
     
    \deprecated HbLanguageUtil::changeLanguage( int language )
        is deprecated. Please use HbLocaleUtil::changeLanguage( const QString &language ) instead.

    \param language identifier of language to set active
    \return true for Symbian if succesfull and false for other platforms
*/ 
bool HbLanguageUtil::changeLanguage( int language )
{
#if defined(Q_OS_SYMBIAN)
    if ( !HbFeatureManager::instance()->featureStatus(HbFeatureManager::LanguageSwitch) ) {
        return false;
    }
    
    CRepository* commonEngineRepository = 0;
    TRAPD( err1, commonEngineRepository = CRepository::NewL( KCRUidCommonEngineKeys ) );    
    if ( err1 != KErrNone ) { 
        return false;
    }
    
    if (!setLocale(language)) {
    		delete commonEngineRepository;
        return false;
    }
        
    // Never set Language code 0 to HAL
    if ( language !=0 ) {
        if ( HAL::Set( HAL::ELanguageIndex, language ) != KErrNone ) {
            delete commonEngineRepository;
            return false;
        }
    }
    if ( commonEngineRepository->Set( KGSDisplayTxtLang, language ) != KErrNone ) {
        delete commonEngineRepository;
        return false;
    }
    delete commonEngineRepository;
    return true;

#else
    Q_UNUSED(language);
    return false;
#endif
}
/**
@SYMTestCaseID PDS-CENTRALREPOSITORY-CT-4053
@SYMTestCaseDesc Test that settings information can be selectively overridden in a ROFS layer
@SYMTestPriority High
@SYMTestActions Open keyspace 0x10286550.  This keyspace is represented by two txt files.  The
keyspace file names in the source have been mangled in a similar way to that which would be
expected on the device (eg. abcd1234.txt, abcd1234.txt[01-00], abcd1234.txt[02-00] etc.
@SYMTestExpectedResults Ensure that the value of each setting specified in ROFS 1 has been
modified to the values specified in ROFS 1 and that each value not specified in ROFS 1 remains
as it was defined in the CORE layer.
@SYMREQ REQ11283
*/
LOCAL_C void REQ11283L()
{
    TheTest.Next(_L( " @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4053 " ));

    CRepository* rep;
    User::LeaveIfNull(rep = CRepository::NewLC(KUidKeyspace1));

    TInt settingValueInt = 0;
    TReal settingValueReal = 0.0;
    TBuf<20> settingValueStr;
    TUint32 settingMeta = 0;
    TInt rtn = 0;

    //check every single setting and meta and access policy
    User::LeaveIfError(rep->Get(1,settingValueInt));
    TEST(settingValueInt==1);
    User::LeaveIfError(rep->GetMeta(1,settingMeta));
    TEST(settingMeta==0);
    User::LeaveIfError(rep->Get(2,settingValueInt));
    TEST(settingValueInt==3);
    User::LeaveIfError(rep->GetMeta(2,settingMeta));
    TEST(settingMeta==0);
    User::LeaveIfError(rep->Get(3,settingValueReal));
    TEST(settingValueReal==3.1);
    User::LeaveIfError(rep->GetMeta(3,settingMeta));
    TEST(settingMeta==0);
    User::LeaveIfError(rep->Get(4,settingValueReal));
    TEST(settingValueReal==4.2);
    User::LeaveIfError(rep->GetMeta(4,settingMeta));
    TEST(settingMeta==0);
    User::LeaveIfError(rep->Get(5,settingValueStr));
    TEST(settingValueStr.Compare(_L("test 1"))==0);
    User::LeaveIfError(rep->GetMeta(5,settingMeta));
    TEST(settingMeta==0);
    User::LeaveIfError(rep->Get(6,settingValueStr));
    TEST(settingValueStr.Compare(_L("test 3"))==0);
    User::LeaveIfError(rep->GetMeta(6,settingMeta));
    TEST(settingMeta==0);

    //check value and meta combination
    User::LeaveIfError(rep->Get(7,settingValueInt));
    TEST(settingValueInt==8);
    User::LeaveIfError(rep->GetMeta(7,settingMeta));
    TEST(settingMeta==88);
    User::LeaveIfError(rep->Get(8,settingValueReal));
    TEST(settingValueReal==8.2);
    User::LeaveIfError(rep->GetMeta(8,settingMeta));
    TEST(settingMeta==888);
    User::LeaveIfError(rep->Get(9,settingValueStr));
    TEST(settingValueStr.Compare(_L("test 4"))==0);
    User::LeaveIfError(rep->GetMeta(9,settingMeta));
    TEST(settingMeta==888);

    //check value and platsec combination
    rtn=rep->Get(10,settingValueInt);
    TEST(rtn==KErrPermissionDenied);
    rtn=rep->Get(11,settingValueReal);
    TEST(rtn==KErrPermissionDenied);
    rtn=rep->Get(12,settingValueStr);
    TEST(rtn==KErrPermissionDenied);
    User::LeaveIfError(rep->Get(13,settingValueInt));
    TEST(settingValueInt==14);
    User::LeaveIfError(rep->GetMeta(13,settingMeta));
    TEST(settingMeta==0);
    User::LeaveIfError(rep->Get(14,settingValueInt));
    TEST(settingValueInt==15);
    User::LeaveIfError(rep->GetMeta(14,settingMeta));
    TEST(settingMeta==0);
    User::LeaveIfError(rep->Get(15,settingValueInt));
    TEST(settingValueInt==16);
    User::LeaveIfError(rep->GetMeta(15,settingMeta));
    TEST(settingMeta==0);
    User::LeaveIfError(rep->Set(15,150));
    User::LeaveIfError(rep->Get(16,settingValueInt));
    TEST(settingValueInt==16);
    User::LeaveIfError(rep->GetMeta(16,settingMeta));
    TEST(settingMeta==0);
    rtn=rep->Set(16,160);
    TEST(rtn==KErrPermissionDenied);


    //range meta
    User::LeaveIfError(rep->Get(0x20,settingValueInt));
    TEST(settingValueInt==16);
    User::LeaveIfError(rep->GetMeta(0x20,settingMeta));
    TEST(settingMeta==100);
    User::LeaveIfError(rep->Get(0x21,settingValueInt));
    TEST(settingValueInt==17);
    User::LeaveIfError(rep->GetMeta(0x21,settingMeta));
    TEST(settingMeta==101);

    //range platsec
    User::LeaveIfError(rep->Get(0x30,settingValueInt));
    TEST(settingValueInt==18);
    User::LeaveIfError(rep->GetMeta(0x30,settingMeta));
    TEST(settingMeta==0);
    rtn=rep->Set(0x30,0x31);
    TEST(rtn==KErrPermissionDenied);
    User::LeaveIfError(rep->Get(0x31,settingValueInt));
    TEST(settingValueInt==19);
    User::LeaveIfError(rep->GetMeta(0x31,settingMeta));
    TEST(settingMeta==0);
    User::LeaveIfError(rep->Set(0x31,0x32));

    //new settings
    User::LeaveIfError(rep->Get(0x50,settingValueInt));
    TEST(settingValueInt==50);
    User::LeaveIfError(rep->GetMeta(0x50,settingMeta));
    TEST(settingMeta==505);

    User::LeaveIfError(rep->Get(0x51,settingValueReal));
    TEST(settingValueReal==51.51);
    rtn=rep->Set(0x51,1.234);
    TEST(rtn==KErrPermissionDenied);

    User::LeaveIfError(rep->Get(0x52,settingValueStr));
    TEST(settingValueStr.Compare(_L("test 6"))==0);

    CleanupStack::PopAndDestroy(rep);
}