meetingrequest/mrcommon/src/cesmrfeaturesettings.cpp
changeset 0 8466d47a6819
child 16 4ce476e64c59
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  MRUI Feature settings utility implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "emailtrace.h"
       
    19 #include "cesmrfeaturesettings.h"
       
    20 
       
    21 #include <featmgr.h>
       
    22 #include <centralrepository.h>
       
    23 #include <bldvariant.hrh>
       
    24 
       
    25 #include "esmrconfig.hrh"
       
    26 #include "mruiprivatecrkeys.h"
       
    27 
       
    28 namespace { // codescanner::namespace
       
    29 
       
    30 #ifdef _DEBUG
       
    31 
       
    32 _LIT( KPanicCategory, "CESMRFeatureSettings" );
       
    33 
       
    34 enum TPanicCode
       
    35     {
       
    36     EUnknownFeature = 0
       
    37     };
       
    38 
       
    39 #endif  // _DEBUG
       
    40 
       
    41 // <cmail> Removed unneeded cleanup function.
       
    42 // </cmail>
       
    43 
       
    44 } // namespace
       
    45 
       
    46 // ======== MEMBER FUNCTIONS ========
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // CESMRFeatureSettings::CESMRFeatureSettings
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CESMRFeatureSettings::CESMRFeatureSettings()
       
    53     {
       
    54     FUNC_LOG;
       
    55     // Do nothing
       
    56     }
       
    57 
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CESMRFeatureSettings::ConstructL
       
    61 // Reads settings from CenRep
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 void CESMRFeatureSettings::ConstructL()
       
    65     {
       
    66     FUNC_LOG;
       
    67     // <cmail> Removed unneeded cleanup function.
       
    68     FeatureManager::InitializeLibL();
       
    69     
       
    70     TBool locationIntegrationSupported = FeatureManager::FeatureSupported(
       
    71         KFeatureIdFfFsCalendarLocation );
       
    72 
       
    73     FeatureManager::UnInitializeLib();
       
    74 
       
    75     if ( locationIntegrationSupported )
       
    76         {
       
    77         // Read settings from central repository. These are read-only settings,
       
    78         // so these must be read only once at this object lifetime.
       
    79         CRepository* settings = NULL;
       
    80         TRAPD( err, settings = CRepository::NewL( KCRUidESMRUIFeatures ) );
       
    81         
       
    82         if ( err == KErrNone )
       
    83 			{
       
    84 	        settings->Get( KESMRUIFeatureMnFwIntegration,
       
    85     	                   iLocationFeatures[ EESMRUIMnFwIntegrationIndex ] );
       
    86                 
       
    87         	settings->Get( KESMRUIFeatureContactsIntegration,
       
    88             	           iLocationFeatures[ EESMRUIContactsIntegrationIndex ] );
       
    89         
       
    90 	        settings->Get( KESMRUIFeatureLandmarksIntegration,
       
    91     	                   iLocationFeatures[ EESMRUILandmarksIntegrationIndex ] );
       
    92         
       
    93         	settings->Get( KESMRUIFeaturePreviousLocationsList,
       
    94             	           iLocationFeatures[ EESMRUIPreviousLocationsListIndex ] );
       
    95         	
       
    96 	        delete settings;
       
    97 			}		
       
    98         }
       
    99     // </cmail>
       
   100     }
       
   101 
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CESMRFeatureSettings* CESMRFeatureSettings::NewL
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C CESMRFeatureSettings* CESMRFeatureSettings::NewL()
       
   108     {
       
   109     FUNC_LOG;
       
   110     CESMRFeatureSettings* self = CESMRFeatureSettings::NewLC();
       
   111     CleanupStack::Pop( self );
       
   112     return self;
       
   113     }
       
   114 
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // CESMRFeatureSettings* CESMRFeatureSettings::NewLC
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 EXPORT_C CESMRFeatureSettings* CESMRFeatureSettings::NewLC()
       
   121     {
       
   122     FUNC_LOG;
       
   123     CESMRFeatureSettings* self = new( ELeave ) CESMRFeatureSettings;
       
   124     CleanupStack::PushL( self );
       
   125     self->ConstructL();
       
   126     return self;
       
   127     }
       
   128 
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // CESMRFeatureSettings::~CESMRFeatureSettings
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 CESMRFeatureSettings::~CESMRFeatureSettings()
       
   135     {
       
   136     FUNC_LOG;
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // CESMRFeatureSettings::FeatureSupported
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 EXPORT_C TBool CESMRFeatureSettings::FeatureSupported( TUint aFeatures ) const
       
   144     {
       
   145     FUNC_LOG;
       
   146     TBool featureSupported( EFalse );
       
   147     switch ( aFeatures )
       
   148         {
       
   149         // Single flags
       
   150         case EESMRUIMnFwIntegration:
       
   151         case EESMRUIContactsIntegration:
       
   152         case EESMRUILandmarksIntegration:
       
   153         case EESMRUIPreviousLocationsList:
       
   154             {
       
   155             TInt index = MapFeature( aFeatures );
       
   156             if ( index > KErrNotFound
       
   157                  && iLocationFeatures[ index ] ) // codescanner::accessArrayElementWithoutCheck2
       
   158                 {
       
   159                 featureSupported = ETrue;
       
   160                 }
       
   161             break;
       
   162             }
       
   163         
       
   164         // All flag
       
   165         case EESMRUILocationFeatures:
       
   166             {
       
   167             for ( TInt i = 0; i < EESMRUINumLocationFeatures; ++i )
       
   168                 {
       
   169                 if ( iLocationFeatures[ i ] ) // codescanner::accessArrayElementWithoutCheck2
       
   170                     {
       
   171                     featureSupported = ETrue;
       
   172                     break; // for-loop
       
   173                     }
       
   174                 }
       
   175             break;
       
   176             }
       
   177             
       
   178         // Combined flags
       
   179         default:
       
   180             {
       
   181             TUint mask = 0x1;
       
   182             for ( TInt i = 0; i < EESMRUINumLocationFeatures; ++i )
       
   183                 {
       
   184                 TUint feature = aFeatures & mask;
       
   185                 TInt index = MapFeature( feature );
       
   186                 if ( ( index > KErrNotFound )
       
   187                      && ( feature < EESMRUILocationFeatures )
       
   188                      && iLocationFeatures[ index ] ) // codescanner::accessArrayElementWithoutCheck2
       
   189                     {
       
   190                     featureSupported = ETrue;
       
   191                     break;
       
   192                     }
       
   193                 else if ( feature > EESMRUILocationFeatures )
       
   194                     {
       
   195                     __ASSERT_DEBUG( EFalse, User::Panic( KPanicCategory, EUnknownFeature) );
       
   196                     }
       
   197                 
       
   198                 // Test next feature
       
   199                 mask = mask << 1;
       
   200                 }
       
   201             
       
   202             break;
       
   203             }
       
   204         }
       
   205     return featureSupported;
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // CESMRFeatureSettings::MapFeature
       
   210 // Converts single feature bitmask to feature array index
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 TInt CESMRFeatureSettings::MapFeature( TUint aFeature ) const
       
   214     {
       
   215     FUNC_LOG;
       
   216     TInt index = KErrNotFound;
       
   217     switch ( aFeature )
       
   218         {
       
   219         case 0: // None feature
       
   220             {
       
   221             break;
       
   222             }
       
   223         case EESMRUIMnFwIntegration:
       
   224             {
       
   225             index = EESMRUIMnFwIntegrationIndex;
       
   226             break;
       
   227             }
       
   228         case EESMRUIContactsIntegration:
       
   229             {
       
   230             index = EESMRUIContactsIntegrationIndex;
       
   231             break;
       
   232             }
       
   233         case EESMRUILandmarksIntegration:
       
   234             {
       
   235             index = EESMRUILandmarksIntegrationIndex;
       
   236             break;
       
   237             }
       
   238         case EESMRUIPreviousLocationsList:
       
   239             {
       
   240             index = EESMRUIPreviousLocationsListIndex;
       
   241             break;
       
   242             }
       
   243         default: // Illegal flags
       
   244             {
       
   245             __ASSERT_DEBUG( EFalse, User::Panic( KPanicCategory, EUnknownFeature) );
       
   246             break;
       
   247             }
       
   248         }
       
   249     
       
   250     return index;
       
   251     }
       
   252