|
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: Implementation of the CProfileEngineImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CProfileEngineImpl.h" |
|
22 #include <bautils.h> |
|
23 #include <barsc.h> |
|
24 #include <featmgr.h> |
|
25 #include <settingsinternalcrkeys.h> |
|
26 #include <sysutil.h> |
|
27 #include <accessoriescrkeys.h> |
|
28 |
|
29 #include <ProfileEng.rsg> |
|
30 #include <TProfileToneSettings.h> |
|
31 #include <MProfileTones.h> |
|
32 #include "CProfilesNamesArrayImpl.h" |
|
33 #include "CProfileImpl.h" |
|
34 #include "CProfileNameImpl.h" |
|
35 #include "ProfileEngUtils.h" |
|
36 #include "MProfileSetName.h" |
|
37 #include "ProfileEng.hrh" |
|
38 #include "ProfileEngPanic.h" |
|
39 #include "ProfileEngineConstants.h" |
|
40 #include "ProfileEnginePrivateCRKeys.h" |
|
41 |
|
42 namespace |
|
43 { |
|
44 const TInt KProfileGeneratedNameTailLength( 4 ); |
|
45 _LIT( KFirstParenthesis, "(" ); |
|
46 } |
|
47 |
|
48 // ============================= LOCAL FUNCTIONS =============================== |
|
49 |
|
50 void GenerateProfileName( TDes& aProfileName, const MProfilesNamesArray& aProfileNames ) |
|
51 { |
|
52 _LIT( KEndParenthesis, ")" ); |
|
53 _LIT( KZero, "0" ); |
|
54 TInt counter( 1 ); |
|
55 TBuf<KProfileMaxNameLength> rootName( aProfileName ); |
|
56 while( aProfileNames.FindByName( aProfileName ) != KErrNotFound && |
|
57 counter <= KProfilesMaxNumberOfDynamicProfiles ) |
|
58 { |
|
59 aProfileName.Copy( rootName ); |
|
60 aProfileName.Append( KFirstParenthesis ); |
|
61 if( counter < 10 ) |
|
62 { |
|
63 aProfileName.Append( KZero ); |
|
64 } |
|
65 TBuf<KProfilesMaxTIntLength> number; |
|
66 number.Num( counter ); |
|
67 aProfileName.Append( number ); |
|
68 aProfileName.Append( KEndParenthesis ); |
|
69 ++counter; |
|
70 } |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // HandleProfileRemoved |
|
75 // |
|
76 // Updates the given central repository value from the given file, when a |
|
77 // profile is removed. This is used for those central repository keys that |
|
78 // contain a profile id as a value, and if a deleted profile is |
|
79 // currently assigned to the central repository value, it is resetted to the |
|
80 // given default value. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void HandleProfileRemoved( const TInt aRemovedProfileId, |
|
84 const TInt aValuePlusDelta, |
|
85 CRepository& aCenRep, |
|
86 const TUint aKey, |
|
87 const TInt aDefaultValue ) |
|
88 { |
|
89 if ( ( aValuePlusDelta ) == aRemovedProfileId ) |
|
90 { |
|
91 aCenRep.Set( aKey, aDefaultValue ); |
|
92 } |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CreateIntSettingForNewProfileL |
|
97 // |
|
98 // Creates a new integer Central Repository key for the new profile and |
|
99 // initialises it by copying the default value to it. |
|
100 // |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CreateIntSettingForNewProfileL( CRepository& aRepository, TInt aSettingId, |
|
104 TInt aProfileId ) |
|
105 { |
|
106 TInt val; |
|
107 User::LeaveIfError( |
|
108 aRepository.Get( |
|
109 ProfileEngUtils::ResolveKey( aSettingId, |
|
110 KProEngDefaultProfileId ), val ) ); |
|
111 TInt err( |
|
112 aRepository.Create( |
|
113 ProfileEngUtils::ResolveKey( aSettingId, aProfileId ), |
|
114 val ) ); |
|
115 if( ( err != KErrNone ) && ( err != KErrAlreadyExists ) ) |
|
116 { |
|
117 User::Leave( err ); |
|
118 } |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CreateStringSettingForNewProfileL |
|
123 // |
|
124 // Creates a new string Central Repository key for the new profile and |
|
125 // initialises it by copying the default value to it. |
|
126 // |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void CreateStringSettingForNewProfileL( CRepository& aRepository, |
|
130 TInt aSettingId, TInt aProfileId, |
|
131 const TDesC& aNewProfileName, |
|
132 TPtr& aStringPtr ) |
|
133 { |
|
134 if( aSettingId != KProEngProfileName ) |
|
135 { |
|
136 User::LeaveIfError( |
|
137 aRepository.Get( |
|
138 ProfileEngUtils::ResolveKey( aSettingId, |
|
139 KProEngDefaultProfileId ), aStringPtr ) ); |
|
140 } |
|
141 else |
|
142 { |
|
143 aStringPtr = aNewProfileName; |
|
144 } |
|
145 TInt err( |
|
146 aRepository.Create( |
|
147 ProfileEngUtils::ResolveKey( aSettingId, aProfileId ), |
|
148 aStringPtr ) ); |
|
149 if( ( err != KErrNone ) && ( err != KErrAlreadyExists ) ) |
|
150 { |
|
151 User::Leave( err ); |
|
152 } |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CreateBinSettingForNewProfileL |
|
157 // |
|
158 // Creates a new binary Central Repository key for the new profile and |
|
159 // initialises it by copying the default value to it. |
|
160 // |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 void CreateBinSettingForNewProfileL( CRepository& aRepository, TInt aSettingId, |
|
164 TInt aProfileId, TPtr8& aBinPtr ) |
|
165 { |
|
166 User::LeaveIfError( |
|
167 aRepository.Get( |
|
168 ProfileEngUtils::ResolveKey( aSettingId, |
|
169 KProEngDefaultProfileId ), aBinPtr ) ); |
|
170 TInt err( |
|
171 aRepository.Create( |
|
172 ProfileEngUtils::ResolveKey( aSettingId, aProfileId ), |
|
173 aBinPtr ) ); |
|
174 if( ( err != KErrNone ) && ( err != KErrAlreadyExists ) ) |
|
175 { |
|
176 User::Leave( err ); |
|
177 } |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // GetSettingsForProfile |
|
182 // |
|
183 // Gets all the settings of the profile with given id from Central Repository. |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 TInt GetSettingsForProfile( CRepository& aRepository, |
|
187 RArray<TUint32>& aSettings, |
|
188 TInt aId ) |
|
189 { |
|
190 const TUint32 KId( aId << 24 ); |
|
191 const TUint32 KMask( 0xFF000000 ); |
|
192 TInt error( 0 ); |
|
193 TRAP( error, error = aRepository.FindL( KId, KMask, aSettings ) ); |
|
194 return error; |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // DeleteSettingsForProfile |
|
199 // |
|
200 // Deletes all the settings of the profile with given id from Central Repository |
|
201 // Tries to delete all without checking if a deletion fails. |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 void DeleteSettingsForProfile( CRepository& aRepository, |
|
205 RArray<TUint32>& aSettings ) |
|
206 { |
|
207 for( TInt i( aSettings.Count() - 1 ); i >= 0; --i ) |
|
208 { |
|
209 aRepository.Delete( aSettings[i] ); // ignore errors |
|
210 } |
|
211 } |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CreateSettingsForNewProfileL |
|
215 // |
|
216 // Creates new Central Repository keys for the new profile and initialises them |
|
217 // by copying the default values to them. |
|
218 // |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CreateSettingsForNewProfileL( CRepository& aRepository, TInt aProfileId, |
|
222 const TDesC& aNewProfileName, |
|
223 TResourceReader& aReader ) |
|
224 { |
|
225 User::LeaveIfError( aRepository.StartTransaction( |
|
226 CRepository::EReadWriteTransaction ) ); |
|
227 |
|
228 // This only be used after normal RFS(restore factory settings), If there was |
|
229 // user created profile before normal RFS, and the normal RFS only restore |
|
230 // KProEngUsedIds, the settings of user created profile are in CenRep still. |
|
231 // So we should delete the remain settings and create new one. |
|
232 RArray<TUint32> settings; |
|
233 if ( !GetSettingsForProfile( aRepository, settings, aProfileId ) ) |
|
234 { |
|
235 DeleteSettingsForProfile( aRepository, settings ); |
|
236 } |
|
237 settings.Close(); |
|
238 |
|
239 HBufC* stringVal = HBufC::NewL( |
|
240 NCentralRepositoryConstants::KMaxUnicodeStringLength ); |
|
241 CleanupStack::PushL( stringVal ); |
|
242 TPtr stringValPtr = stringVal->Des(); |
|
243 HBufC8* binVal = HBufC8::NewL( |
|
244 NCentralRepositoryConstants::KMaxBinaryLength ); |
|
245 CleanupStack::PushL( binVal ); |
|
246 TPtr8 binValPtr = binVal->Des(); |
|
247 |
|
248 TInt numOfElements( aReader.ReadInt16() ); |
|
249 |
|
250 for( TInt i( 0 ) ; i < numOfElements ; ++i ) |
|
251 { |
|
252 TInt settingId( aReader.ReadInt32() ); |
|
253 TInt keyType( aReader.ReadInt32() ); |
|
254 switch( keyType ) |
|
255 { |
|
256 case EProfileSettingKeyTypeInt: |
|
257 { |
|
258 CreateIntSettingForNewProfileL( aRepository, settingId, |
|
259 aProfileId ); |
|
260 break; |
|
261 } |
|
262 case EProfileSettingKeyTypeString: |
|
263 { |
|
264 CreateStringSettingForNewProfileL( aRepository, settingId, |
|
265 aProfileId, |
|
266 aNewProfileName, |
|
267 stringValPtr ); |
|
268 break; |
|
269 } |
|
270 case EProfileSettingKeyTypeBin: |
|
271 { |
|
272 CreateBinSettingForNewProfileL( aRepository, settingId, |
|
273 aProfileId, binValPtr ); |
|
274 |
|
275 break; |
|
276 } |
|
277 case EProfileSettingKeyTypeReal: // no settings of this type |
|
278 default: |
|
279 { |
|
280 break; |
|
281 } |
|
282 } |
|
283 } |
|
284 |
|
285 CleanupStack::PopAndDestroy( 2 ); // stringVal, binVal |
|
286 |
|
287 // Update the used ids value (this is done last so that we can get the |
|
288 // repository back in a legal state (by deleting the settings just |
|
289 // created)). |
|
290 TBuf8< KProfilesMaxNumberOfDynamicProfiles > idBuf; |
|
291 ProfileEngUtils::GetBinarySettingL( aRepository, KProEngUsedIds, idBuf ); |
|
292 idBuf.Append( aProfileId ); |
|
293 User::LeaveIfError( aRepository.Set( KProEngUsedIds, idBuf ) ); |
|
294 |
|
295 TUint32 ignore( 0 ); |
|
296 User::LeaveIfError( aRepository.CommitTransaction( ignore ) ); |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // DeleteProfileIdFromList |
|
301 // |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 void DeleteProfileIdFromList( CRepository& aRepository, TInt aId, TDes8& aIdBuf ) |
|
305 { |
|
306 TInt numOfIds = aIdBuf.Length(); |
|
307 for( TInt idx( 0 ); idx < numOfIds; ++idx ) |
|
308 { |
|
309 if( aIdBuf[ idx ] == aId ) |
|
310 { |
|
311 aIdBuf.Delete( idx, 1 ); |
|
312 aRepository.Set( KProEngUsedIds, aIdBuf ); |
|
313 break; |
|
314 } |
|
315 } |
|
316 } |
|
317 |
|
318 void DoDeleteProfileL( CRepository& aCenRep, TInt aId ) |
|
319 { |
|
320 RArray<TUint32> settings; |
|
321 User::LeaveIfError( GetSettingsForProfile( aCenRep, settings, aId ) ); |
|
322 |
|
323 TBuf8< 4 * KProfilesMaxNumberOfDynamicProfiles > idBuf; // One id is 4-bytes long |
|
324 ProfileEngUtils::GetBinarySettingL( aCenRep, KProEngUsedIds, idBuf ); |
|
325 |
|
326 User::LeaveIfError( aCenRep.StartTransaction( |
|
327 CRepository::EReadWriteTransaction ) ); |
|
328 DeleteSettingsForProfile( aCenRep, settings ); |
|
329 settings.Reset(); |
|
330 DeleteProfileIdFromList( aCenRep, aId, idBuf ); |
|
331 |
|
332 TInt headsetVal( 0 ); |
|
333 TInt loopsetVal( 0 ); |
|
334 TInt ttyVal( 0 ); |
|
335 TInt btVal( 0 ); |
|
336 TUint32 ignore( 0 ); |
|
337 TRAPD( error, |
|
338 CRepository* cr = CRepository::NewL( KCRUidProfileSettings ); |
|
339 CleanupStack::PushL( cr ); |
|
340 User::LeaveIfError( cr->Get( KSettingsHeadsetDefaultProfile, headsetVal ) ); |
|
341 User::LeaveIfError( cr->Get( KSettingsLoopsetDefaultProfile, loopsetVal ) ); |
|
342 User::LeaveIfError( cr->Get( KSettingsTTYDefaultProfile, ttyVal ) ); |
|
343 User::LeaveIfError( cr->Get( KSettingsBTDefaultProfile, btVal ) ); |
|
344 User::LeaveIfError( cr->StartTransaction( |
|
345 CRepository::EReadWriteTransaction ) ); |
|
346 // -1 is a mystery, consult general settings team: |
|
347 // 0 ( = general profile ) is the default profile used with all the |
|
348 // accessories: |
|
349 HandleProfileRemoved( aId, headsetVal-1, *cr, |
|
350 KSettingsHeadsetDefaultProfile, 0 ); |
|
351 HandleProfileRemoved( aId, loopsetVal-1, *cr, |
|
352 KSettingsLoopsetDefaultProfile, 0 ); |
|
353 HandleProfileRemoved( aId, ttyVal-1, *cr, |
|
354 KSettingsTTYDefaultProfile, 0 ); |
|
355 HandleProfileRemoved( aId, btVal-1, *cr, |
|
356 KSettingsBTDefaultProfile, 0 ); |
|
357 User::LeaveIfError( cr->CommitTransaction( ignore ) ); |
|
358 |
|
359 CleanupStack::PopAndDestroy(); // delete cr: |
|
360 ); |
|
361 |
|
362 if( error ) |
|
363 { |
|
364 aCenRep.RollbackTransaction(); // ignore error |
|
365 User::Leave( error ); |
|
366 } |
|
367 |
|
368 User::LeaveIfError( aCenRep.CommitTransaction( ignore ) ); |
|
369 } |
|
370 |
|
371 // ============================ MEMBER FUNCTIONS =============================== |
|
372 |
|
373 // ----------------------------------------------------------------------------- |
|
374 // CProfileEngineImpl::DeleteProfileL |
|
375 // |
|
376 // (other items were commented in a header). |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 TInt CProfileEngineImpl::DeleteProfileL( TInt aId ) |
|
380 { |
|
381 iMutex.Wait(); |
|
382 TInt activeProfileId( ActiveProfileId() ); |
|
383 |
|
384 if( activeProfileId < 0 ) |
|
385 { |
|
386 iMutex.Signal(); |
|
387 User::Leave( activeProfileId ); |
|
388 } |
|
389 |
|
390 // Do not allow delete active profile |
|
391 if( aId == activeProfileId ) |
|
392 { |
|
393 iMutex.Signal(); |
|
394 return KErrAbort; |
|
395 } |
|
396 // Do not allow delete default profile |
|
397 if( IsDefaultProfile( aId ) ) |
|
398 { |
|
399 iMutex.Signal(); |
|
400 return KErrAbort; |
|
401 } |
|
402 |
|
403 TRAPD( error, DoDeleteProfileL( *iCenRep, aId ) ); |
|
404 iMutex.Signal(); |
|
405 User::LeaveIfError( error ); |
|
406 return KErrNone; |
|
407 } |
|
408 |
|
409 // ----------------------------------------------------------------------------- |
|
410 // CProfileEngineImpl::CreateProfileL |
|
411 // |
|
412 // (other items were commented in a header). |
|
413 // ----------------------------------------------------------------------------- |
|
414 // |
|
415 MProfileExtended* CProfileEngineImpl::CreateProfileL() |
|
416 { |
|
417 if( SysUtil::FFSSpaceBelowCriticalLevelL( iFs ) ) |
|
418 { |
|
419 User::Leave( KErrDiskFull ); |
|
420 } |
|
421 |
|
422 // Create profile ID |
|
423 CProfilesNamesArrayImpl* profileNameArray = CProfilesNamesArrayImpl::NewLC(); |
|
424 |
|
425 iMutex.Wait(); |
|
426 TRAPD( error, ReadProfilesNamesL( profileNameArray ) ); |
|
427 if( error ) |
|
428 { |
|
429 iMutex.Signal(); |
|
430 User::Leave( error ); |
|
431 } |
|
432 |
|
433 if( profileNameArray->MdcaCount() - // current profile count |
|
434 iProfileLocalisedNames->MdcaCount() >= // default profile count |
|
435 KProfilesMaxNumberOfDynamicProfiles ) // max dynamic profiles |
|
436 { |
|
437 // Max number of dynamic profiles |
|
438 CleanupStack::PopAndDestroy(); // profileNameArray |
|
439 iMutex.Signal(); |
|
440 return NULL; |
|
441 } |
|
442 |
|
443 TInt profileId( KErrNotFound ); |
|
444 // Find first free id |
|
445 TInt lastDynamicProfileId( KProfileBaseDynamicProfileId + |
|
446 KProfilesMaxNumberOfDynamicProfiles ); |
|
447 |
|
448 for( TInt i( KProfileBaseDynamicProfileId ); i < lastDynamicProfileId; ++i ) |
|
449 { |
|
450 TInt index( profileNameArray->FindById( i ) ); |
|
451 if( index == KErrNotFound ) |
|
452 { |
|
453 profileId = i; |
|
454 break; |
|
455 } |
|
456 } |
|
457 |
|
458 if( profileId == KErrNotFound ) |
|
459 { |
|
460 CleanupStack::PopAndDestroy(); // profileNameArray |
|
461 iMutex.Signal(); |
|
462 return NULL; |
|
463 } |
|
464 |
|
465 TBuf<KProfileMaxNameLength> profileName; |
|
466 TRAP( error, |
|
467 ReadNewProfileNameFromResourceL( R_NEW_PROFILE, profileName ) ); |
|
468 if( error ) |
|
469 { |
|
470 iMutex.Signal(); |
|
471 User::Leave( error ); |
|
472 } |
|
473 |
|
474 GenerateProfileName( profileName, *profileNameArray ); |
|
475 CleanupStack::PopAndDestroy(); // profileNameArray |
|
476 |
|
477 TResourceReader rsReader; |
|
478 CProfileImpl* newProfile = NULL; |
|
479 TRAP( error, |
|
480 ReadResourceInBufferLC( R_PROFILE_SETTINGS, rsReader ); |
|
481 CreateSettingsForNewProfileL( *iCenRep, profileId, |
|
482 profileName, rsReader ); |
|
483 CleanupStack::PopAndDestroy(); // ReadResourceInBufferLC |
|
484 |
|
485 // Create and store new profile |
|
486 newProfile = CProfileImpl::NewLC( *iFs ); |
|
487 newProfile->InternalizeL( *iCenRep, profileId ); |
|
488 |
|
489 CleanupStack::Pop(); // newProfile |
|
490 ); |
|
491 |
|
492 iMutex.Signal(); |
|
493 User::LeaveIfError( error ); |
|
494 |
|
495 return newProfile; |
|
496 } |
|
497 |
|
498 // ----------------------------------------------------------------------------- |
|
499 // CProfileEngineImpl::ReadNewProfileNameFromResourceL |
|
500 // |
|
501 // (other items were commented in a header). |
|
502 // ----------------------------------------------------------------------------- |
|
503 // |
|
504 void CProfileEngineImpl::ReadNewProfileNameFromResourceL( TInt aResourceId, |
|
505 TDes& aProfileName ) |
|
506 { |
|
507 TResourceReader rsReader; |
|
508 ReadResourceInBufferLC( aResourceId, rsReader ); |
|
509 |
|
510 TPtrC profileName( rsReader.ReadTPtrC() ); |
|
511 aProfileName.Copy( profileName ); |
|
512 |
|
513 CleanupStack::PopAndDestroy(); // ReadResourceInBufferLC |
|
514 } |
|
515 |
|
516 // ----------------------------------------------------------------------------- |
|
517 // CProfileEngineImpl::ReadNewProfileNameFromResourceL |
|
518 // |
|
519 // (other items were commented in a header). |
|
520 // ----------------------------------------------------------------------------- |
|
521 // |
|
522 CProfileNameImpl* CProfileEngineImpl::ReadNewProfileNameFromResourceLC() |
|
523 { |
|
524 TBuf<KProfileMaxNameLength> profileName; |
|
525 ReadNewProfileNameFromResourceL( R_NEW_PROFILE, profileName ); |
|
526 |
|
527 TBuf<KProfileMaxNameLength> shortName; |
|
528 ReadNewProfileNameFromResourceL( R_NEW_PROFILE_SHORT, shortName ); |
|
529 |
|
530 TBuf<KProfileMaxNameLength> naviName; |
|
531 ReadNewProfileNameFromResourceL( R_NEW_PROFILE_NAVI, naviName ); |
|
532 |
|
533 TBuf<KProfileMaxNameLength> titleName; |
|
534 ReadNewProfileNameFromResourceL( R_NEW_PROFILE_TITLE, titleName ); |
|
535 |
|
536 CProfileNameImpl* localizedName = |
|
537 CProfileNameImpl::NewLC( 0, profileName, shortName, |
|
538 naviName, titleName ); |
|
539 |
|
540 return localizedName; |
|
541 } |
|
542 |
|
543 // ----------------------------------------------------------------------------- |
|
544 // CProfileEngineImpl::ReadDynamicProfilesNamesL |
|
545 // |
|
546 // (other items were commented in a header). |
|
547 // ----------------------------------------------------------------------------- |
|
548 // |
|
549 void CProfileEngineImpl::ReadDynamicProfilesNamesL( |
|
550 CProfilesNamesArrayImpl* aProfilesNames, |
|
551 CProfileNameImpl& aNameTemplate ) |
|
552 { |
|
553 TBuf8< NCentralRepositoryConstants::KMaxBinaryLength > idBuf; |
|
554 ProfileEngUtils::GetBinarySettingL( *iCenRep, KProEngUsedIds, idBuf ); |
|
555 TInt len = idBuf.Length(); |
|
556 |
|
557 if( len == 0 ) |
|
558 { |
|
559 return; // No user-created profiles, just return |
|
560 } |
|
561 |
|
562 CProfileNameImpl* localizedName = ReadNewProfileNameFromResourceLC(); |
|
563 |
|
564 for( TInt i( 0 ); i < len; ++i ) |
|
565 { |
|
566 aNameTemplate.InternalizeL( *iCenRep, idBuf[i] ); |
|
567 if( !aNameTemplate.IsProfileNameChanged() ) |
|
568 { |
|
569 TInt idxOfParenthesis( |
|
570 aNameTemplate.Name().Find( KFirstParenthesis ) ); |
|
571 if( idxOfParenthesis != KErrNotFound ) |
|
572 { |
|
573 TBuf<KProfileGeneratedNameTailLength> uniquePart = |
|
574 aNameTemplate.Name().Mid( idxOfParenthesis, |
|
575 KProfileGeneratedNameTailLength ); |
|
576 aNameTemplate.SetLocalizedProfileNameL( *localizedName, |
|
577 uniquePart ); |
|
578 } |
|
579 else |
|
580 { |
|
581 aNameTemplate.SetLocalizedProfileNameL( *localizedName, |
|
582 KNullDesC() ); |
|
583 } |
|
584 } |
|
585 |
|
586 CProfileNameImpl* nameImpl = |
|
587 CProfileNameImpl::NewLC( aNameTemplate ); |
|
588 |
|
589 User::LeaveIfError( aProfilesNames->InsertInOrder( nameImpl ) ); |
|
590 CleanupStack::Pop(); // nameImpl |
|
591 } |
|
592 |
|
593 CleanupStack::PopAndDestroy( localizedName ); |
|
594 } |
|
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // CProfileEngineImpl::SetLocalizedNameForDynamicProfileL |
|
598 // |
|
599 // (other items were commented in a header). |
|
600 // ----------------------------------------------------------------------------- |
|
601 // |
|
602 void CProfileEngineImpl::SetLocalizedNameForDynamicProfileL( |
|
603 CProfileImpl& aProfile ) |
|
604 { |
|
605 CProfileNameImpl* localizedName = ReadNewProfileNameFromResourceLC(); |
|
606 |
|
607 TInt idxOfParenthesis( |
|
608 aProfile.ProfileName().Name().Find( KFirstParenthesis ) ); |
|
609 if( idxOfParenthesis != KErrNotFound ) |
|
610 { |
|
611 TBuf<KProfileGeneratedNameTailLength> uniquePart = |
|
612 aProfile.ProfileName().Name().Mid( idxOfParenthesis, |
|
613 KProfileGeneratedNameTailLength ); |
|
614 aProfile.SetLocalizedProfileNameL( *localizedName, uniquePart ); |
|
615 } |
|
616 else |
|
617 { |
|
618 aProfile.SetLocalizedProfileNameL( *localizedName, |
|
619 KNullDesC() ); |
|
620 } |
|
621 |
|
622 CleanupStack::PopAndDestroy( localizedName ); |
|
623 } |
|
624 |
|
625 // End of File |
|
626 |