How to get preferences of active profile using CRepository
Reviewer Approved
Note!
This API is not part of the public SDK. It can be found in the SDK API Plug-in.
The following code snippet explains how to read settings of currently active profile using CRepository. Create() and Set() methods are not documented in SDK.
There are potentially 2^32 repositories, each identified by a UID. Within each repository up to 2^32 settings can be stored. Settings within a repository are identified by a 32-bit key and may be of the types integer, real or descriptor.
Get() method of CRepository class will be used to read active profile settings. UID of profile repository is KCRUidProfileEngine.
Code
Includes:
// for CRepository
#include <centralrepository.h>
// for active profile settings
#include <ProfileEngineSDKCRKeys.h>
Libraries:
centralrepository.lib
void GetSettingsOfActiveProfileL()
{
CRepository *repository = CRepository::NewLC( KCRUidProfileEngine );
TInt value;
// Get the ID of the active profile:
User::LeaveIfError( repository->Get( KProEngActiveProfile, value ) );
// Get the keypad tone volume of active profile
User::LeaveIfError( repository->Get( KProEngActiveKeypadVolume, value ) );
// Get the ringtone of the cactive profile
User::LeaveIfError( repository->Get( KProEngActiveRingingType, value ) );
// Get the ringing volume of the active profile
User::LeaveIfError( repository->Get( KProEngActiveRingingVolume, value ) );
// Get the warning tone setting of the active profile
User::LeaveIfError( repository->Get( KProEngActiveWarningTones, value ) );
// Get the message alert setting of the active profile:
User::LeaveIfError( repository->Get( KProEngActiveMessageAlert, value ) );
CleanupStack::PopAndDestroy( repository );
}