25
|
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 |
const TInt KNumLocationFeatures = 4;
|
|
42 |
|
|
43 |
} // namespace
|
|
44 |
|
|
45 |
// ======== MEMBER FUNCTIONS ========
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
// CESMRFeatureSettings::CESMRFeatureSettings
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
CESMRFeatureSettings::CESMRFeatureSettings()
|
|
52 |
{
|
|
53 |
FUNC_LOG;
|
|
54 |
// Do nothing
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
// CESMRFeatureSettings::ConstructL
|
|
60 |
// Reads settings from CenRep
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
void CESMRFeatureSettings::ConstructL()
|
|
64 |
{
|
|
65 |
FUNC_LOG;
|
|
66 |
|
|
67 |
// Read settings from central repository. These are read-only settings,
|
|
68 |
// so these must be read only once at this object lifetime.
|
|
69 |
CRepository* settings = NULL;
|
|
70 |
TRAPD( err, settings = CRepository::NewL( KCRUidESMRUIFeatures ) );
|
|
71 |
|
|
72 |
if ( err == KErrNone )
|
|
73 |
{
|
|
74 |
settings->Get( KESMRUIFeatureMnFwIntegration,
|
|
75 |
iFeatures[ EESMRUIMnFwIntegrationIndex ] );
|
|
76 |
|
|
77 |
settings->Get( KESMRUIFeatureContactsIntegration,
|
|
78 |
iFeatures[ EESMRUIContactsIntegrationIndex ] );
|
|
79 |
|
|
80 |
settings->Get( KESMRUIFeatureLandmarksIntegration,
|
|
81 |
iFeatures[ EESMRUILandmarksIntegrationIndex ] );
|
|
82 |
|
|
83 |
settings->Get( KESMRUIFeaturePreviousLocationsList,
|
|
84 |
iFeatures[ EESMRUIPreviousLocationsListIndex ] );
|
|
85 |
|
|
86 |
settings->Get( KMRUIFeatureMeetingRequestViewerCmailOnly,
|
|
87 |
iFeatures[ EMRUIMeetingRequestViewerCmailIndex ] );
|
|
88 |
|
|
89 |
delete settings;
|
|
90 |
}
|
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
// CESMRFeatureSettings* CESMRFeatureSettings::NewL
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
EXPORT_C CESMRFeatureSettings* CESMRFeatureSettings::NewL()
|
|
99 |
{
|
|
100 |
FUNC_LOG;
|
|
101 |
CESMRFeatureSettings* self = CESMRFeatureSettings::NewLC();
|
|
102 |
CleanupStack::Pop( self );
|
|
103 |
return self;
|
|
104 |
}
|
|
105 |
|
|
106 |
|
|
107 |
// ---------------------------------------------------------------------------
|
|
108 |
// CESMRFeatureSettings* CESMRFeatureSettings::NewLC
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
EXPORT_C CESMRFeatureSettings* CESMRFeatureSettings::NewLC()
|
|
112 |
{
|
|
113 |
FUNC_LOG;
|
|
114 |
CESMRFeatureSettings* self = new( ELeave ) CESMRFeatureSettings;
|
|
115 |
CleanupStack::PushL( self );
|
|
116 |
self->ConstructL();
|
|
117 |
return self;
|
|
118 |
}
|
|
119 |
|
|
120 |
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
// CESMRFeatureSettings::~CESMRFeatureSettings
|
|
123 |
// ---------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
CESMRFeatureSettings::~CESMRFeatureSettings()
|
|
126 |
{
|
|
127 |
FUNC_LOG;
|
|
128 |
}
|
|
129 |
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
// CESMRFeatureSettings::FeatureSupported
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
EXPORT_C TBool CESMRFeatureSettings::FeatureSupported( TUint aFeatures ) const
|
|
135 |
{
|
|
136 |
FUNC_LOG;
|
|
137 |
TBool featureSupported( EFalse );
|
|
138 |
switch ( aFeatures )
|
|
139 |
{
|
|
140 |
// Single flags
|
|
141 |
case EESMRUIMnFwIntegration:
|
|
142 |
case EESMRUIContactsIntegration:
|
|
143 |
case EESMRUILandmarksIntegration:
|
|
144 |
case EESMRUIPreviousLocationsList:
|
|
145 |
case EMRUIMeetingRequestViewerCmailOnly:
|
|
146 |
{
|
|
147 |
TInt index = MapFeature( aFeatures );
|
|
148 |
if ( index > KErrNotFound
|
|
149 |
&& iFeatures[ index ] ) // codescanner::accessArrayElementWithoutCheck2
|
|
150 |
{
|
|
151 |
featureSupported = ETrue;
|
|
152 |
}
|
|
153 |
break;
|
|
154 |
}
|
|
155 |
|
|
156 |
// All flag
|
|
157 |
case EESMRUILocationFeatures:
|
|
158 |
{
|
|
159 |
for ( TInt i = 0; i < KNumLocationFeatures; ++i )
|
|
160 |
{
|
|
161 |
if ( iFeatures[ i ] ) // codescanner::accessArrayElementWithoutCheck2
|
|
162 |
{
|
|
163 |
featureSupported = ETrue;
|
|
164 |
break; // for-loop
|
|
165 |
}
|
|
166 |
}
|
|
167 |
break;
|
|
168 |
}
|
|
169 |
|
|
170 |
// Combined flags
|
|
171 |
default:
|
|
172 |
{
|
|
173 |
TUint mask = 0x1;
|
|
174 |
for ( TInt i = 0; i < EESMRUINumFeatures; ++i )
|
|
175 |
{
|
|
176 |
TUint feature = aFeatures & mask;
|
|
177 |
TInt index = MapFeature( feature );
|
|
178 |
if ( ( index > KErrNotFound )
|
|
179 |
&& ( feature < EMRUIAllFeatures )
|
|
180 |
&& iFeatures[ index ] ) // codescanner::accessArrayElementWithoutCheck2
|
|
181 |
{
|
|
182 |
featureSupported = ETrue;
|
|
183 |
break;
|
|
184 |
}
|
|
185 |
else if ( feature > EMRUIAllFeatures )
|
|
186 |
{
|
|
187 |
__ASSERT_DEBUG( EFalse, User::Panic( KPanicCategory, EUnknownFeature) );
|
|
188 |
}
|
|
189 |
|
|
190 |
// Test next feature
|
|
191 |
mask = mask << 1;
|
|
192 |
}
|
|
193 |
|
|
194 |
break;
|
|
195 |
}
|
|
196 |
}
|
|
197 |
return featureSupported;
|
|
198 |
}
|
|
199 |
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
// CESMRFeatureSettings::MapFeature
|
|
202 |
// Converts single feature bitmask to feature array index
|
|
203 |
// ---------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
TInt CESMRFeatureSettings::MapFeature( TUint aFeature ) const
|
|
206 |
{
|
|
207 |
FUNC_LOG;
|
|
208 |
TInt index = KErrNotFound;
|
|
209 |
switch ( aFeature )
|
|
210 |
{
|
|
211 |
case 0: // None feature
|
|
212 |
{
|
|
213 |
break;
|
|
214 |
}
|
|
215 |
case EESMRUIMnFwIntegration:
|
|
216 |
{
|
|
217 |
index = EESMRUIMnFwIntegrationIndex;
|
|
218 |
break;
|
|
219 |
}
|
|
220 |
case EESMRUIContactsIntegration:
|
|
221 |
{
|
|
222 |
index = EESMRUIContactsIntegrationIndex;
|
|
223 |
break;
|
|
224 |
}
|
|
225 |
case EESMRUILandmarksIntegration:
|
|
226 |
{
|
|
227 |
index = EESMRUILandmarksIntegrationIndex;
|
|
228 |
break;
|
|
229 |
}
|
|
230 |
case EESMRUIPreviousLocationsList:
|
|
231 |
{
|
|
232 |
index = EESMRUIPreviousLocationsListIndex;
|
|
233 |
break;
|
|
234 |
}
|
|
235 |
case EMRUIMeetingRequestViewerCmailOnly:
|
|
236 |
{
|
|
237 |
index = EMRUIMeetingRequestViewerCmailIndex;
|
|
238 |
break;
|
|
239 |
}
|
|
240 |
default: // Illegal flags
|
|
241 |
{
|
|
242 |
__ASSERT_DEBUG( EFalse, User::Panic( KPanicCategory, EUnknownFeature) );
|
|
243 |
break;
|
|
244 |
}
|
|
245 |
}
|
|
246 |
|
|
247 |
return index;
|
|
248 |
}
|
|
249 |
|