|
1 /* |
|
2 * Copyright (c) 2002 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: Profile engine implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CPROFILEENGINEIMPL_H__ |
|
21 #define __CPROFILEENGINEIMPL_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32property.h> |
|
25 #include <f32file.h> // RFs |
|
26 #include <Profile.hrh> // TProfileRingingVolume |
|
27 #include "MProfileEngineExtended.h" // MProfileEngineExtended |
|
28 #include "MProfileExtended.h" // MProfileExtended |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CProfileNameImpl; |
|
32 class CProfileImpl; |
|
33 class CProfilesNamesArrayImpl; |
|
34 class DRMCommon; |
|
35 class MProfilesLocalFeatures; |
|
36 class CRepository; |
|
37 class TResourceReader; |
|
38 class CProfileTiming; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 /** |
|
43 * Profile engine implementation. |
|
44 * |
|
45 * @lib ProfileEng |
|
46 * @since 2.0 |
|
47 */ |
|
48 NONSHARABLE_CLASS(CProfileEngineImpl) : public CBase, |
|
49 public MProfileEngineExtended |
|
50 { |
|
51 public: // Constructors and destructor |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 */ |
|
56 static CProfileEngineImpl* NewL(); |
|
57 |
|
58 /** |
|
59 * Two-phased constructor. |
|
60 */ |
|
61 static CProfileEngineImpl* NewLC(); |
|
62 |
|
63 /** |
|
64 * Two-phased constructor. |
|
65 * @param aFs An open file server session. Ownership is NOT transferred. |
|
66 */ |
|
67 static CProfileEngineImpl* NewL( RFs* aFs ); |
|
68 |
|
69 /** |
|
70 * Two-phased constructor. |
|
71 * @param aFs An open file server session. Ownership is NOT transferred. |
|
72 */ |
|
73 static CProfileEngineImpl* NewLC( RFs* aFs ); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 virtual ~CProfileEngineImpl(); |
|
79 |
|
80 public: // Functions from base classes |
|
81 |
|
82 /** |
|
83 * From MProfileEngine. |
|
84 */ |
|
85 virtual void Release(); |
|
86 |
|
87 /** |
|
88 * From MProfileEngine. |
|
89 */ |
|
90 virtual MProfile* ActiveProfileLC(); |
|
91 |
|
92 /** |
|
93 * From MProfileEngine. |
|
94 */ |
|
95 virtual MProfile* ActiveProfileL(); |
|
96 |
|
97 /** |
|
98 * From MProfileEngine. |
|
99 */ |
|
100 virtual TInt ActiveProfileId(); |
|
101 |
|
102 /** |
|
103 * From MProfileEngine. |
|
104 */ |
|
105 virtual void SetActiveProfileL( TInt aId ); |
|
106 |
|
107 /** |
|
108 * From MProfileEngine. |
|
109 */ |
|
110 virtual MProfilesNamesArray* ProfilesNamesArrayLC(); |
|
111 |
|
112 /** |
|
113 * From MProfileEngineExtended. |
|
114 */ |
|
115 virtual MProfileExtended* ProfileLC( TInt aId ); |
|
116 |
|
117 /** |
|
118 * From MProfileEngineExtended. |
|
119 */ |
|
120 virtual MProfileExtended* ProfileL( TInt aId ); |
|
121 |
|
122 /** |
|
123 * From MProfileEngineExtended. |
|
124 */ |
|
125 virtual void CommitChangeL( MProfileExtended& aProfile ); |
|
126 |
|
127 /** |
|
128 * From MProfileEngineExtended. |
|
129 */ |
|
130 virtual void SendPresenceSettingsL( |
|
131 const MProfilePresence& aPresence ); |
|
132 |
|
133 /** |
|
134 * From MProfileEngineExtended. |
|
135 */ |
|
136 virtual TInt DeleteProfileL( TInt aId ); |
|
137 |
|
138 /** |
|
139 * From MProfileEngineExtended. |
|
140 */ |
|
141 virtual MProfileExtended* CreateProfileL(); |
|
142 |
|
143 /** |
|
144 * From MProfileEngineExtended. |
|
145 */ |
|
146 virtual TBool IsDefaultProfile( TInt aId ); |
|
147 |
|
148 /** |
|
149 * From MProfileEngine. |
|
150 */ |
|
151 void SetTempRingingVolumeL( TProfileRingingVolume aVolume ); |
|
152 |
|
153 /** |
|
154 * From MProfileEngine. |
|
155 */ |
|
156 TProfileRingingVolume TempRingingVolumeL() const; |
|
157 |
|
158 /** |
|
159 * From MProfileEngine. |
|
160 */ |
|
161 void SetTempMediaVolumeL( TProfileRingingVolume aVolume ); |
|
162 |
|
163 /** |
|
164 * From MProfileEngine. |
|
165 */ |
|
166 TProfileRingingVolume TempMediaVolumeL() const; |
|
167 |
|
168 /** |
|
169 * From MProfileEngineExtended. |
|
170 */ |
|
171 MProfilesLocalFeatures& LocalFeatures(); |
|
172 |
|
173 /** |
|
174 * From MProfileEngine. |
|
175 */ |
|
176 TBool IsFeatureSupported( TProfileFeatureId aFeatureId ) const; |
|
177 |
|
178 /** |
|
179 * From MProfileEngineExtended. |
|
180 */ |
|
181 void GetProfileUtilityObject( TProfileUtilityObjectType aType, TAny*& aImpl ); |
|
182 |
|
183 /** |
|
184 * From MProfileEngine. |
|
185 */ |
|
186 TBool IsActiveProfileTimedL(); |
|
187 |
|
188 /** |
|
189 * From MProfileEngineExtended. |
|
190 */ |
|
191 void SetActiveProfileTimedL( TInt aId, TTime aTime ); |
|
192 |
|
193 protected: // New functions |
|
194 |
|
195 /** |
|
196 * Reads the resource with the given id from Profiles Engine resource |
|
197 * file. |
|
198 * @param aResourceId the id of the resource to be read |
|
199 * @param aReader the resource reader object in which the buffer |
|
200 * containing the resource is set |
|
201 */ |
|
202 void ReadResourceInBufferLC( TInt aResourceId, |
|
203 TResourceReader& aReader ); |
|
204 |
|
205 /** |
|
206 * Read default profiles names from resource. |
|
207 */ |
|
208 void ReadProfilesNamesFromResourceL(); |
|
209 |
|
210 /** |
|
211 * Write profile settings to Central Repository. |
|
212 * @since 2.8 |
|
213 * @param aProfile Profile |
|
214 */ |
|
215 void WriteProfileL( MProfileExtended& aProfile ); |
|
216 |
|
217 /** |
|
218 * Send an event indicating that a setting in the active profile was |
|
219 * modified through Publish & Subscribe. |
|
220 * @param aPSKey the P&S key which value should be changed |
|
221 * @since 3.0 |
|
222 */ |
|
223 void PublishChangeL( TUint32 aPSKey ); |
|
224 |
|
225 /** |
|
226 * Update Active Profile settings in Central Repository. |
|
227 * @since 2.8 |
|
228 * @param aProfile Profile |
|
229 * @param aSetId sets the id of the active profile to Central Repository |
|
230 * only if this is ETrue |
|
231 */ |
|
232 void UpdateActiveProfileSettingsL( MProfile& aProfile, |
|
233 TBool aSetId = EFalse ); |
|
234 |
|
235 /** |
|
236 * Updates the alert for groups shared data value. |
|
237 * @since 2.6 |
|
238 * @param aProfile settings containing the new alert for groups. |
|
239 */ |
|
240 void UpdateContactGroupsValueL( MProfile& aProfile ); |
|
241 |
|
242 /** |
|
243 * Get profile settings. |
|
244 * @since 2.0 |
|
245 * @param aId Profile ID |
|
246 * @return Profile instance |
|
247 */ |
|
248 CProfileImpl* GetProfileL( TInt aId ); |
|
249 |
|
250 /** |
|
251 * Read profiles names. |
|
252 * @since 2.0 |
|
253 * @param aProfilePath Profile path where profiles readed |
|
254 * @param aProfilesNames Profile names array |
|
255 */ |
|
256 void ReadProfilesNamesL( CProfilesNamesArrayImpl* aProfilesNames ); |
|
257 |
|
258 /** |
|
259 * Read new profile default name from resource. |
|
260 * @param aResourceId resource id containing the profile name or |
|
261 * short name. |
|
262 * @param aProfileName Buffer for default profile name. |
|
263 * @since 2.1 |
|
264 */ |
|
265 void ReadNewProfileNameFromResourceL( TInt aResourceId, |
|
266 TDes& aProfileName ); |
|
267 |
|
268 /** |
|
269 * Helper function for setting the active profile. Wraps several |
|
270 * leaving calls inside. |
|
271 * @since 2.5 |
|
272 * @param aId the id of the profile to be set as active profile. |
|
273 * @param aTime the time when the new profile should be deactivated |
|
274 */ |
|
275 void DoSetActiveProfileL( TInt aId, TTime* aTime = NULL ); |
|
276 |
|
277 /** |
|
278 * Helper method for SetTempRingingVolumeL() and SetTempMediaVolumeL() |
|
279 * to set the needed volume value to Central Repository. |
|
280 * @since 2.8 |
|
281 * @param aCenRep the central repository object to write the new |
|
282 * temporary volume |
|
283 * @param aCenRepKey the key to the volume value in CentralRepository |
|
284 * @param aVolume the new value to be set for the volume |
|
285 */ |
|
286 void SetTempVolumeL( CRepository& aCenRep, TUint32 aCenRepKey, |
|
287 TProfileRingingVolume aVolume ); |
|
288 |
|
289 /** |
|
290 * Helper method for TempRingingVolumeL() and TempMediaVolumeL() to |
|
291 * get the needed volume value from Central Repository. |
|
292 * @since 2.6 |
|
293 * @param aCenRep reference to the CenRep instance containing the data |
|
294 * @param aCenRepKey the key to the volume value in Central Repository |
|
295 */ |
|
296 TProfileRingingVolume TempVolumeL( CRepository& aCenRep, |
|
297 TUint32 aCenRepKey ) const; |
|
298 |
|
299 /** |
|
300 * Helper method for SetTempMediaVolumeL() and SetTempRingingVolumeL() |
|
301 * to check and leave with KErrAccessDenied if the corresponding |
|
302 * setting item is read-only. |
|
303 * @since 2.8 |
|
304 * @param aFlag the flag corresponding to the setting item to be |
|
305 * checked for modifiability. |
|
306 */ |
|
307 void LeaveIfReadOnlyL( TProfileFlags aFlag ); |
|
308 |
|
309 /** |
|
310 * Helper method to check whether a client-given profile ID belongs to |
|
311 * an existing profile. |
|
312 * @since 3.0 |
|
313 * @param aId profile ID to check |
|
314 * @return KErrNotFound if a profile with the given ID is not found, |
|
315 * KErrNone otherwise. |
|
316 */ |
|
317 |
|
318 TInt CheckProfileIdL( TInt aId ); |
|
319 |
|
320 /** |
|
321 * Creates the Publish & Subscribe keys needed for notifying about |
|
322 * active profile changes if the keys aren't already created. |
|
323 * @since 3.1 |
|
324 */ |
|
325 void CreatePubSubKeysIfNeededL(); |
|
326 |
|
327 /** |
|
328 * Reads names of user-created profiles. |
|
329 * @param aProfilesNames Profiles Names Array to be updated with the |
|
330 * user-created Profile Names. |
|
331 * @param aNameTemplate CProfileNameImpl to be reused when reading name |
|
332 * data from Profiles Central Repository. |
|
333 * @since 3.1 |
|
334 */ |
|
335 void ReadDynamicProfilesNamesL( CProfilesNamesArrayImpl* aProfilesNames, |
|
336 CProfileNameImpl& aNameTemplate ); |
|
337 |
|
338 /** |
|
339 * Reads both the normal and short versions of the name of a new profile |
|
340 * from the resources. |
|
341 * @return Pointer to CProfileNameImpl wrapping the normal and short |
|
342 * names of a new profile. |
|
343 * @since 3.1 |
|
344 */ |
|
345 CProfileNameImpl* ReadNewProfileNameFromResourceLC(); |
|
346 |
|
347 /** |
|
348 * Sets the localized name for a dynamic (= user-created) profile. |
|
349 * @param aProfile the profile object into which the localized name |
|
350 * should be set. |
|
351 * @since 3.1 |
|
352 */ |
|
353 void SetLocalizedNameForDynamicProfileL( CProfileImpl& aProfile ); |
|
354 |
|
355 private: |
|
356 TBool PowerSaveMode(); |
|
357 TBool PowerSaveModeL(); |
|
358 |
|
359 private: |
|
360 |
|
361 /** |
|
362 * By default Symbian 2nd phase constructor is private. |
|
363 */ |
|
364 void ConstructL(); |
|
365 |
|
366 /** |
|
367 * By default Symbian 2nd phase constructor is private. |
|
368 */ |
|
369 void ConstructL( RFs* aFs ); |
|
370 |
|
371 /** |
|
372 * Common part used by both ConstructL() methods above. |
|
373 */ |
|
374 void CommonConstructL(); |
|
375 |
|
376 private: // Data |
|
377 // Own: resource file name is stored here (to avoid stack overflow) |
|
378 TFileName iFileName; |
|
379 |
|
380 // Own or Ref: File server session |
|
381 RFs* iFs; |
|
382 |
|
383 // Indicates whether the file server session is owned or not |
|
384 TBool iFsOwned; |
|
385 |
|
386 // Own: Central Repository handle for Profiles repository |
|
387 CRepository* iCenRep; |
|
388 |
|
389 // Own: Central Repository handle for VibraCntrl repository |
|
390 CRepository* iVibraCenRep; |
|
391 |
|
392 // Own: Publish & Subscribe client: |
|
393 RProperty iProperty; |
|
394 |
|
395 // Own: Localised profile names |
|
396 CProfilesNamesArrayImpl* iProfileLocalisedNames; |
|
397 |
|
398 // Own: Handle to a mutex |
|
399 RMutex iMutex; |
|
400 |
|
401 // Not owned: Locally variated features of Profiles: |
|
402 MProfilesLocalFeatures* iFeatures; |
|
403 |
|
404 // Indicates whether the Publish & Subscribe keys has been created: |
|
405 TBool iPubSubKeysCreated; |
|
406 |
|
407 // Own: functionality for timing of profiles |
|
408 CProfileTiming* iProfileTiming; |
|
409 |
|
410 // Supported features |
|
411 TBool iSideVolumeKeys; |
|
412 }; |
|
413 |
|
414 #endif // __CPROFILEENGINEIMPL_H__ |
|
415 |
|
416 // End of File |