src/hbcore/utils/hbfeaturemanager.cpp
changeset 34 ed14f46c0e55
parent 6 c3690ec91ef8
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    25 
    25 
    26 #include "hbfeaturemanager_r.h"
    26 #include "hbfeaturemanager_r.h"
    27 
    27 
    28 #include <QString>
    28 #include <QString>
    29 
    29 
    30 #if defined(Q_WS_S60)
    30 #if defined(Q_OS_SYMBIAN)
    31 #include <centralrepository.h>
    31 #include <centralrepository.h>
    32 #else
    32 #else
    33 #include <QSettings>
    33 #include <QSettings>
    34 #endif // Q_WS_S60
    34 #endif // Q_OS_SYMBIAN
    35 
    35 
    36 /*!
    36 /*!
    37     @alpha
    37     @alpha
    38     @hbcore
    38     @hbcore
    39     \class HbFeatureManager
    39     \class HbFeatureManager
    52     Runtime variation flag for text measurement feature.
    52     Runtime variation flag for text measurement feature.
    53 
    53 
    54     This needs to be enabled if you want to get the localization layout
    54     This needs to be enabled if you want to get the localization layout
    55     metrics from your application.
    55     metrics from your application.
    56 
    56 
       
    57     Zero means disabled, non-zero means enabled. Value 2 means that
       
    58     text measurement is done automatically when Hb applications are run.
       
    59 */
       
    60 
       
    61 /*!
       
    62     \var HbFeatureManager::TheTestUtility
       
    63 
       
    64     Runtime variation flag for "the test utility"
       
    65 
       
    66     This needs to be enabled if you want to utilize "the test utility"
       
    67     (the four floating buttons) in your application.
       
    68 
    57     Zero means disabled, non-zero means enabled.
    69     Zero means disabled, non-zero means enabled.
    58 */
    70 */
    59 
    71 
    60 /*!
    72 /*!
    61     \var HbFeatureManager::TheTestUtility
       
    62 
       
    63     Runtime variation flag for "the test utility"
       
    64 
       
    65     This needs to be enabled if you want to utilize "the test utility"
       
    66     (the four floating buttons) in your application. 
       
    67 
       
    68     Zero means disabled, non-zero means enabled.
       
    69 */
       
    70 
       
    71 /*!
       
    72     \var HbFeatureManager::LanguageSwitch
    73     \var HbFeatureManager::LanguageSwitch
    73 */
    74 */
    74 
    75 
    75 
    76 
    76 #if defined(Q_WS_S60)
    77 #if defined(Q_OS_SYMBIAN)
    77 const TUid HBFM_CREPO_ID  = {0x2002C304};
    78 const TUid HBFM_CREPO_ID  = {0x2002C304};
    78 #endif
    79 #endif
    79 
    80 
    80 
    81 
    81 class HbFeatureManagerPrivate
    82 class HbFeatureManagerPrivate
    84     HbFeatureManagerPrivate();
    85     HbFeatureManagerPrivate();
    85     virtual ~HbFeatureManagerPrivate();
    86     virtual ~HbFeatureManagerPrivate();
    86 
    87 
    87     QString toString( HbFeatureManager::Feature feature );
    88     QString toString( HbFeatureManager::Feature feature );
    88 
    89 
    89 #if defined(Q_WS_S60)
    90 #if defined(Q_OS_SYMBIAN)
    90     CRepository *mRepo;
    91     CRepository *mRepo;
    91 #else
    92 #else
    92     QSettings *mSettings;
    93     QSettings *mSettings;
    93 #endif // Q_WS_S60
    94 #endif // Q_OS_SYMBIAN
    94 };
    95 };
    95 
    96 
    96 /*!
    97 /*!
    97 \internal
    98 \internal
    98 */
    99 */
    99 HbFeatureManagerPrivate::HbFeatureManagerPrivate()
   100 HbFeatureManagerPrivate::HbFeatureManagerPrivate()
   100 {
   101 {
   101 #if defined(Q_WS_S60)
   102 #if defined(Q_OS_SYMBIAN)
   102     TRAPD( err, mRepo = CRepository::NewL( HBFM_CREPO_ID ) );
   103     TRAPD( err, mRepo = CRepository::NewL( HBFM_CREPO_ID ) );
   103     if( err ) {
   104     if( err ) {
   104         qWarning( "HbFeatureManager construction fails, error code = %d", err );
   105         qWarning( "HbFeatureManager construction fails, error code = %d", err );
   105     }
   106     }
   106     // Default values defined in cenrep file.
   107     // Default values defined in cenrep file.
   107 #else
   108 #else
   108     mSettings = new QSettings( "Nokia", "Hb feature manager" );
   109     mSettings = new QSettings( "Nokia", "Hb" );
       
   110     mSettings->beginGroup( "FeatureManager" );
   109     // Set default values:
   111     // Set default values:
   110     if( !mSettings->contains( toString( HbFeatureManager::TextMeasurement ) ) ) {
   112     if( !mSettings->contains( toString( HbFeatureManager::TextMeasurement ) ) ) {
   111         mSettings->setValue( toString( HbFeatureManager::TextMeasurement ), 0 );
   113         mSettings->setValue( toString( HbFeatureManager::TextMeasurement ), 0 );
   112     }
   114     }
   113     if( !mSettings->contains( toString( HbFeatureManager::TheTestUtility ) ) ) {
   115     if( !mSettings->contains( toString( HbFeatureManager::TheTestUtility ) ) ) {
   114         mSettings->setValue( toString( HbFeatureManager::TheTestUtility ), 0 );
   116         mSettings->setValue( toString( HbFeatureManager::TheTestUtility ), 0 );
   115     }
   117     }
   116 #endif // Q_WS_S60
   118 #endif // Q_OS_SYMBIAN
   117 }
   119 }
   118 
   120 
   119 /*!
   121 /*!
   120 \internal
   122 \internal
   121 */
   123 */
   122 HbFeatureManagerPrivate::~HbFeatureManagerPrivate()
   124 HbFeatureManagerPrivate::~HbFeatureManagerPrivate()
   123 {
   125 {
   124 #if defined(Q_WS_S60)
   126 #if defined(Q_OS_SYMBIAN)
   125     delete mRepo;
   127     delete mRepo;
   126 #else
   128 #else
   127     delete mSettings;
   129     delete mSettings;
   128 #endif // Q_WS_S60
   130 #endif // Q_OS_SYMBIAN
   129 }
   131 }
   130 
   132 
   131 /*!
   133 /*!
   132 \internal
   134 \internal
   133 */
   135 */
   164 /*!
   166 /*!
   165     Returns the status of requested feature.
   167     Returns the status of requested feature.
   166 */
   168 */
   167 int HbFeatureManager::featureStatus( Feature feature )
   169 int HbFeatureManager::featureStatus( Feature feature )
   168 {
   170 {
   169 #if defined(Q_WS_S60)
   171 #if defined(Q_OS_SYMBIAN)
   170     if (!d->mRepo) {
   172     if (!d->mRepo) {
   171         return 0;
   173         return 0;
   172     }
   174     }
   173     TUint32 key = (TUint32)feature;
   175     TUint32 key = (TUint32)feature;
   174     TInt value = 0;
   176     TInt value = 0;
   191 /*!
   193 /*!
   192     Sets the status of requested feature to given value.
   194     Sets the status of requested feature to given value.
   193 */
   195 */
   194 void HbFeatureManager::setFeatureStatus( Feature feature, int status )
   196 void HbFeatureManager::setFeatureStatus( Feature feature, int status )
   195 {
   197 {
   196 #if defined(Q_WS_S60)
   198 #if defined(Q_OS_SYMBIAN)
   197     if (!d->mRepo) {
   199     if (!d->mRepo) {
   198         return;
   200         return;
   199     }
   201     }
   200     TUint32 key = (TUint32)feature;
   202     TUint32 key = (TUint32)feature;
   201     TInt value = (TInt)status;
   203     TInt value = (TInt)status;