95 // Open resource file. |
103 // Open resource file. |
96 TRAP_IGNORE( iResourceLoader.OpenL( fileName ) ); |
104 TRAP_IGNORE( iResourceLoader.OpenL( fileName ) ); |
97 |
105 |
98 User::LeaveIfError( iSSSettings.Open() ); |
106 User::LeaveIfError( iSSSettings.Open() ); |
99 |
107 |
100 iProfileEngine = CreateProfileEngineL(); |
108 // Register to listen ALS activation, if ALS status changes, |
101 } |
109 // profile must be republished. |
102 |
110 TInt err( iSSSettings.Register( ESSSettingsAls, *this ) ); |
103 |
111 |
104 // --------------------------------------------------------- |
112 if( err == KErrNotSupported || err == KErrAlreadyExists ) |
105 // Destructor. |
113 { |
106 // --------------------------------------------------------- |
114 // ALS not supported or already registered, that's fine |
|
115 err = KErrNone; |
|
116 } |
|
117 |
|
118 User::LeaveIfError( err ); |
|
119 |
|
120 iProfileEngine = ProEngFactory::NewEngineL(); |
|
121 |
|
122 // Start to listen profile changes. |
|
123 iProfileNotifier = ProEngFactory::NewNotifyHandlerL(); |
|
124 |
|
125 iProfileNotifier->RequestActiveProfileNotificationsL( *this ); |
|
126 iProfileNotifier->RequestProfileNameArrayNotificationsL( *this ); |
|
127 iProfileNotifier->RequestProfileActivationNotificationsL( *this ); |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // CAiProfileEngine::~CAiProfileEngine |
|
132 // |
|
133 // ---------------------------------------------------------------------------- |
107 // |
134 // |
108 CAiProfileEngine::~CAiProfileEngine() |
135 CAiProfileEngine::~CAiProfileEngine() |
109 { |
136 { |
110 iSSSettings.CancelAll( *this ); |
137 iSSSettings.CancelAll( *this ); |
111 iSSSettings.Close(); |
138 iSSSettings.Close(); |
112 delete iProfileNotifier; |
139 |
113 delete iActiveProfileName; |
140 delete iActiveProfileName; |
114 delete iSwapProfileName; |
141 delete iSwapProfileName; |
115 |
142 |
116 if( iProfileNamePointerArray.Count() ) |
143 iProfileNamePointerArray.ResetAndDestroy(); |
117 { |
144 |
118 iProfileNamePointerArray.ResetAndDestroy(); |
145 if ( iProfileNotifier ) |
119 } |
146 { |
120 |
147 iProfileNotifier->CancelAll(); |
|
148 } |
|
149 |
|
150 delete iProfileNotifier; |
|
151 |
121 if( iProfileEngine ) |
152 if( iProfileEngine ) |
122 { |
153 { |
123 iProfileEngine->Release(); |
154 iProfileEngine->Release(); |
124 } |
155 } |
125 |
156 |
126 iResourceLoader.Close(); |
157 iResourceLoader.Close(); |
127 } |
158 } |
128 |
159 |
129 // --------------------------------------------------------- |
160 // ---------------------------------------------------------------------------- |
130 // Updates profiles |
161 // CAiProfileEngine::UpdateProfileNamesL() |
131 // --------------------------------------------------------- |
162 // |
|
163 // ---------------------------------------------------------------------------- |
132 // |
164 // |
133 void CAiProfileEngine::UpdateProfileNamesL() |
165 void CAiProfileEngine::UpdateProfileNamesL() |
134 { |
166 { |
135 //update active profile name |
167 // Update active profile name |
136 HBufC* activeProfileName = NULL; |
168 MProEngProfile* profile( iProfileEngine->ActiveProfileLC() ); |
137 |
169 |
138 MProfile* profile = iProfileEngine->ActiveProfileLC(); |
170 const MProEngProfileName& name( profile->ProfileName() ); |
139 const MProfileName& name = profile->ProfileName(); |
171 |
140 activeProfileName = name.Name().AllocLC(); |
172 HBufC* activeProfileName( name.Name().AllocLC() ); |
141 |
173 |
142 SetActiveProfileNameL( *activeProfileName ); |
174 SetActiveProfileNameL( *activeProfileName ); |
143 |
175 |
144 //update profile name list |
176 // Update profile name list |
145 MProfilesNamesArray* profileNamesArray = iProfileEngine->ProfilesNamesArrayLC(); |
177 MProEngProfileNameArray* profileNamesArray( |
|
178 iProfileEngine->ProfileNameArrayLC() ); |
146 |
179 |
147 SetProfileNameListL( *profileNamesArray ); |
180 SetProfileNameListL( *profileNamesArray ); |
148 |
181 |
149 //update swap profile name |
182 // Update swap profile name |
150 HBufC* swapProfileName = NULL; |
183 HBufC* swapProfileName( NULL ); |
151 |
184 |
152 TInt activeProfileId = iProfileEngine->ActiveProfileId(); |
185 TInt activeProfileId( iProfileEngine->ActiveProfileId() ); |
153 |
186 |
154 if( activeProfileId == KSilentProfileId ) |
187 if( activeProfileId == KSilentProfileId ) |
155 { |
188 { |
156 const MProfileName* generalProfileName = profileNamesArray->ProfileName( KGeneralProfileId ); |
189 TInt generalProfileIndex( |
157 swapProfileName = generalProfileName->Name().AllocLC(); |
190 profileNamesArray->FindById( KGeneralProfileId ) ); |
|
191 |
|
192 swapProfileName = |
|
193 profileNamesArray->MdcaPoint( generalProfileIndex ).AllocLC() ; |
158 } |
194 } |
159 else |
195 else |
160 { |
196 { |
161 const MProfileName* silentProfileName = profileNamesArray->ProfileName( KSilentProfileId ); |
197 TInt silentProfileIndex( |
162 swapProfileName = silentProfileName->Name().AllocLC(); |
198 profileNamesArray->FindById( KSilentProfileId ) ); |
|
199 |
|
200 swapProfileName = |
|
201 profileNamesArray->MdcaPoint( silentProfileIndex ).AllocLC() ; |
163 } |
202 } |
164 |
203 |
165 TPtrC swapProfileNamePtr( *swapProfileName ); |
204 TPtrC swapProfileNamePtr( *swapProfileName ); |
166 HBufC* activateProfileString = NULL; |
205 |
167 activateProfileString = StringLoader::LoadLC( R_AI_PERS_PROF_TOGGLE, swapProfileNamePtr ); |
206 HBufC* activateProfileString( StringLoader::LoadLC( |
|
207 R_AI_PERS_PROF_TOGGLE, swapProfileNamePtr ) ); |
168 |
208 |
169 SetSwapProfileNameL( *activateProfileString ); |
209 SetSwapProfileNameL( *activateProfileString ); |
170 |
210 |
171 CleanupStack::PopAndDestroy( 5 ); //profile, profileName, profileNamesArray, swapProfileName, activateProfileString |
211 CleanupStack::PopAndDestroy( 5 ); //profile, profileName, // profileNamesArray, swapProfileName, activateProfileString |
172 } |
212 } |
173 |
213 |
174 // --------------------------------------------------------- |
214 // ---------------------------------------------------------------------------- |
175 // Checks SIM card status |
215 // CAiProfileEngine::ShowOfflineMessageL |
176 // --------------------------------------------------------- |
216 // |
|
217 // ---------------------------------------------------------------------------- |
177 // |
218 // |
178 TBool CAiProfileEngine::ShowOfflineMessageL() |
219 TBool CAiProfileEngine::ShowOfflineMessageL() |
179 { |
220 { |
180 TInt result = ETrue; |
221 TInt result( ETrue ); |
181 |
222 |
182 TInt simCardStatus( ESimNotPresent ); |
223 TInt simCardStatus( ESimNotPresent ); |
183 |
224 |
184 RProperty simStatus; |
225 RProperty simStatus; |
185 User::LeaveIfError( simStatus.Attach( KPSUidStartup, KPSSimStatus ) ); |
226 User::LeaveIfError( simStatus.Attach( KPSUidStartup, KPSSimStatus ) ); |
186 User::LeaveIfError( simStatus.Get( simCardStatus ) ); |
227 User::LeaveIfError( simStatus.Get( simCardStatus ) ); |
187 simStatus.Close(); |
228 simStatus.Close(); |
188 |
229 |
189 if( simCardStatus == ESimNotPresent ) |
230 if ( simCardStatus == ESimNotPresent ) |
190 { |
231 { |
191 // SIM card does not exist. |
232 // SIM card does not exist. |
192 HBufC* infoNoteText = StringLoader::LoadLC( R_SU_NOTE_INSERT_SIM ); |
233 HBufC* infoNoteText = StringLoader::LoadLC( R_SU_NOTE_INSERT_SIM_AND_RESTART ); |
|
234 |
193 CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue ); |
235 CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue ); |
194 note->ExecuteLD( *infoNoteText ); |
236 note->ExecuteLD( *infoNoteText ); |
|
237 |
195 CleanupStack::PopAndDestroy( infoNoteText ); |
238 CleanupStack::PopAndDestroy( infoNoteText ); |
|
239 |
196 result = EFalse; |
240 result = EFalse; |
197 } |
241 } |
198 else |
242 else |
199 { |
243 { |
200 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
244 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
245 |
201 result = dlg->ExecuteLD( R_AI_LEAVE_OFFLINE_MODE_QUERY ); |
246 result = dlg->ExecuteLD( R_AI_LEAVE_OFFLINE_MODE_QUERY ); |
202 } |
247 } |
203 |
248 |
204 return result; |
249 return result; |
205 } |
250 } |
206 |
251 |
207 |
252 // ---------------------------------------------------------------------------- |
208 // --------------------------------------------------------- |
253 // CAiProfileEngine::SetActiveProfileNameL |
209 // |
254 // |
210 // --------------------------------------------------------- |
255 // ---------------------------------------------------------------------------- |
211 // |
256 // |
212 void CAiProfileEngine::SetActiveProfileNameL( const TDesC& aName ) |
257 void CAiProfileEngine::SetActiveProfileNameL( const TDesC& aName ) |
213 { |
258 { |
214 HBufC* temp = aName.AllocL(); |
259 HBufC* temp( aName.AllocL() ); |
|
260 |
|
261 TPtr profileNamePtr( temp->Des() ); |
|
262 |
|
263 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( profileNamePtr ); |
|
264 |
215 delete iActiveProfileName; |
265 delete iActiveProfileName; |
216 iActiveProfileName = NULL; |
266 iActiveProfileName = NULL; |
217 TPtr profileNamePtr = temp->Des(); |
267 |
|
268 iActiveProfileName = temp; |
|
269 } |
|
270 |
|
271 // ---------------------------------------------------------------------------- |
|
272 // CAiProfileEngine::ActiveProfileName |
|
273 // |
|
274 // ---------------------------------------------------------------------------- |
|
275 // |
|
276 const TDesC& CAiProfileEngine::ActiveProfileName() const |
|
277 { |
|
278 if( iActiveProfileName ) |
|
279 { |
|
280 return *iActiveProfileName; |
|
281 } |
|
282 |
|
283 return KNullDesC(); |
|
284 } |
|
285 |
|
286 // ---------------------------------------------------------------------------- |
|
287 // CAiProfileEngine::SetSwapProfileNameL |
|
288 // |
|
289 // ---------------------------------------------------------------------------- |
|
290 // |
|
291 void CAiProfileEngine::SetSwapProfileNameL( const TDesC& aName ) |
|
292 { |
|
293 HBufC* temp( aName.AllocL() ); |
|
294 |
|
295 TPtr profileNamePtr( temp->Des() ); |
|
296 |
218 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( profileNamePtr ); |
297 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( profileNamePtr ); |
219 iActiveProfileName = temp; |
298 |
220 } |
299 delete iSwapProfileName; |
221 |
300 iSwapProfileName = NULL; |
222 // --------------------------------------------------------- |
301 |
223 // |
302 iSwapProfileName = temp; |
224 // --------------------------------------------------------- |
303 } |
225 // |
304 |
226 const TDesC& CAiProfileEngine::ActiveProfileName() const |
305 // ---------------------------------------------------------------------------- |
227 { |
306 // CAiProfileEngine::SwapProfileName |
228 if( iActiveProfileName ) |
307 // |
229 { |
308 // ---------------------------------------------------------------------------- |
230 return *iActiveProfileName; |
309 // |
|
310 const TDesC& CAiProfileEngine::SwapProfileName() const |
|
311 { |
|
312 if( iSwapProfileName ) |
|
313 { |
|
314 return *iSwapProfileName; |
231 } |
315 } |
232 |
316 |
233 return KNullDesC(); |
317 return KNullDesC(); |
234 } |
318 } |
235 |
319 |
236 // --------------------------------------------------------- |
320 // ---------------------------------------------------------------------------- |
237 // |
321 // CAiProfileEngine::SetProfileNameListL |
238 // --------------------------------------------------------- |
322 // |
239 // |
323 // ---------------------------------------------------------------------------- |
240 void CAiProfileEngine::SetSwapProfileNameL( const TDesC& aName ) |
324 // |
241 { |
325 void CAiProfileEngine::SetProfileNameListL( |
242 HBufC* temp = aName.AllocL(); |
326 const MProEngProfileNameArray& aArray ) |
243 delete iSwapProfileName; |
327 { |
244 iSwapProfileName = NULL; |
328 iProfileNamePointerArray.ResetAndDestroy(); |
245 TPtr profileNamePtr = temp->Des(); |
329 |
246 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( profileNamePtr ); |
330 const TInt count( aArray.MdcaCount() ); |
247 iSwapProfileName = temp; |
331 |
248 } |
|
249 |
|
250 // --------------------------------------------------------- |
|
251 // |
|
252 // --------------------------------------------------------- |
|
253 // |
|
254 const TDesC& CAiProfileEngine::SwapProfileName() const |
|
255 { |
|
256 if( iSwapProfileName ) |
|
257 { |
|
258 return *iSwapProfileName; |
|
259 } |
|
260 |
|
261 return KNullDesC(); |
|
262 } |
|
263 |
|
264 |
|
265 // --------------------------------------------------------- |
|
266 // Set profile names |
|
267 // --------------------------------------------------------- |
|
268 // |
|
269 void CAiProfileEngine::SetProfileNameListL( const MProfilesNamesArray& aArray ) |
|
270 { |
|
271 if( iProfileNamePointerArray.Count() ) |
|
272 { |
|
273 iProfileNamePointerArray.ResetAndDestroy(); |
|
274 } |
|
275 |
|
276 const TInt count = aArray.MdcaCount(); |
|
277 TBufC<KMaxProfileNameLength> profileName; |
332 TBufC<KMaxProfileNameLength> profileName; |
278 |
333 |
279 for( TInt i = 0; i < count; i++ ) |
334 for ( TInt i = 0; i < count; i++ ) |
280 { |
335 { |
281 profileName = aArray.MdcaPoint( i ); |
336 profileName = aArray.MdcaPoint( i ); |
282 TPtr profileNamePtr = profileName.Des(); |
337 |
283 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( profileNamePtr ); |
338 TPtr profileNamePtr( profileName.Des() ); |
284 HBufC* profile = profileNamePtr.AllocLC(); |
339 |
285 User::LeaveIfError( iProfileNamePointerArray.Append( profile )); |
340 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( |
|
341 profileNamePtr ); |
|
342 |
|
343 HBufC* profile( profileNamePtr.AllocLC() ); |
|
344 |
|
345 iProfileNamePointerArray.AppendL( profile ); |
286 CleanupStack::Pop( profile ); |
346 CleanupStack::Pop( profile ); |
287 } |
347 } |
288 } |
348 } |
289 |
349 |
290 |
350 // ---------------------------------------------------------------------------- |
291 // --------------------------------------------------------- |
351 // CAiProfileEngine::ProfileNameByIndex |
292 // |
352 // |
293 // --------------------------------------------------------- |
353 // ---------------------------------------------------------------------------- |
294 // |
354 // |
295 const TDesC& CAiProfileEngine::ProfileNameByIndex( TInt aIndex ) const |
355 const TDesC& CAiProfileEngine::ProfileNameByIndex( TInt aIndex ) const |
296 { |
356 { |
297 if( iProfileNamePointerArray.Count() ) |
357 TInt count( iProfileNamePointerArray.Count() ); |
|
358 |
|
359 if( aIndex < count && aIndex >= 0 ) |
298 { |
360 { |
299 return *iProfileNamePointerArray[aIndex]; |
361 return *iProfileNamePointerArray[ aIndex ]; |
300 } |
362 } |
301 |
363 |
302 return KNullDesC(); |
364 return KNullDesC(); |
303 } |
365 } |
304 |
366 |
305 // --------------------------------------------------------- |
367 // ---------------------------------------------------------------------------- |
|
368 // CAiProfileEngine::IsActiveProfileSilentL |
|
369 // |
|
370 // ---------------------------------------------------------------------------- |
|
371 // |
|
372 TBool CAiProfileEngine::IsActiveProfileSilentL() const |
|
373 { |
|
374 MProEngProfile* profile( iProfileEngine->ActiveProfileLC() ); |
|
375 |
|
376 TBool silent( profile->IsSilent() ); |
|
377 |
|
378 CleanupStack::PopAndDestroy(); |
|
379 |
|
380 return silent; |
|
381 } |
|
382 |
|
383 // ---------------------------------------------------------------------------- |
|
384 // CAiProfileEngine::IsActiveProfileTimedL |
306 // |
385 // |
307 // --------------------------------------------------------- |
386 // ---------------------------------------------------------------------------- |
308 // |
387 // |
309 TBool CAiProfileEngine::IsActiveProfileSilentL() |
388 TBool CAiProfileEngine::IsActiveProfileTimedL() const |
310 { |
389 { |
311 TBool isSilent = EFalse; |
390 MProfileEngine* engine = CreateProfileEngineL(); |
312 MProfile* profile = iProfileEngine->ActiveProfileLC(); |
391 |
313 isSilent = profile->IsSilent(); |
392 TBool retval( EFalse ); |
314 CleanupStack::PopAndDestroy(); |
393 |
315 return isSilent; |
394 TRAP_IGNORE( retval = engine->IsActiveProfileTimedL() ); |
316 } |
395 |
317 |
396 engine->Release(); |
318 // --------------------------------------------------------- |
397 |
319 // |
398 return retval; |
320 // --------------------------------------------------------- |
399 } |
321 // |
400 |
322 TBool CAiProfileEngine::IsActiveProfileTimedL() |
401 // ---------------------------------------------------------------------------- |
323 { |
402 // CAiProfileEngine::NumberOfProfiles |
324 return iProfileEngine->IsActiveProfileTimedL(); |
403 // |
325 } |
404 // ---------------------------------------------------------------------------- |
326 |
405 // |
327 // --------------------------------------------------------- |
406 TInt CAiProfileEngine::NumberOfProfiles() const |
328 // Number of profiles |
|
329 // --------------------------------------------------------- |
|
330 // |
|
331 TInt CAiProfileEngine::NumberOfProfiles() |
|
332 { |
407 { |
333 return iProfileNamePointerArray.Count(); |
408 return iProfileNamePointerArray.Count(); |
334 } |
409 } |
335 |
410 |
336 |
411 // ---------------------------------------------------------------------------- |
337 // --------------------------------------------------------- |
412 // CAiProfileEngine::HandleAiEventL |
338 // |
413 // |
339 // --------------------------------------------------------- |
414 // ---------------------------------------------------------------------------- |
340 // |
415 // |
341 void CAiProfileEngine::HandleAiEventL( TInt aEvent, const TDesC& aParam ) |
416 void CAiProfileEngine::HandleAiEventL( TInt aEvent, const TDesC& aParam ) |
342 { |
417 { |
343 switch ( aEvent ) |
418 switch ( aEvent ) |
344 { |
419 { |
355 break; |
430 break; |
356 |
431 |
357 case EAiProfileEditActive: |
432 case EAiProfileEditActive: |
358 HandleEditActiveProfileL(); |
433 HandleEditActiveProfileL(); |
359 break; |
434 break; |
|
435 |
360 default: |
436 default: |
361 break; |
437 break; |
362 } |
438 } |
363 } |
439 } |
364 |
440 |
365 |
441 // ---------------------------------------------------------------------------- |
366 // ----------------------------------------------------------------------------- |
442 // CAiProfileEngine::HandleSwitchByIndexL |
367 // Handles profile switch by index event |
443 // |
368 // ----------------------------------------------------------------------------- |
444 // ---------------------------------------------------------------------------- |
369 // |
445 // |
370 void CAiProfileEngine::HandleSwitchByIndexL( const TDesC& aParam ) |
446 void CAiProfileEngine::HandleSwitchByIndexL( const TDesC& aParam ) |
371 { |
447 { |
372 if ( aParam.Length() > 0 ) |
448 if ( aParam.Length() > 0 ) |
373 { |
449 { |
374 TInt profileId = KErrNotFound; |
450 TInt index( KErrNotFound ); |
375 TPtrC ptr( aParam ); |
451 TPtrC ptr( aParam ); |
376 TLex lexer( ptr ); |
452 TLex lexer( ptr ); |
377 |
453 |
378 TInt err = lexer.Val( profileId ); |
454 TInt err( lexer.Val( index ) ); |
|
455 |
379 if ( err == KErrNone ) |
456 if ( err == KErrNone ) |
380 { |
457 { |
381 MProfilesNamesArray* profileNamesArray = iProfileEngine->ProfilesNamesArrayLC(); |
458 MProEngProfileNameArray* profileNamesArray( |
382 const MProfileName* profileName = profileNamesArray->ProfileName( profileId ); |
459 iProfileEngine->ProfileNameArrayLC() ); |
383 |
460 |
384 if( profileName ) |
461 TInt profileId( profileNamesArray->ProfileId( index ) ); |
385 { |
462 |
386 profileId = profileName->Id(); |
463 if ( profileId != KErrNotFound ) |
387 SetActiveProfileL( profileId ); |
464 { |
388 } |
465 SetActiveProfileL( profileId ); |
|
466 } |
389 |
467 |
390 CleanupStack::PopAndDestroy(); |
468 CleanupStack::PopAndDestroy(); |
391 } |
469 } |
392 } |
470 } |
393 } |
471 } |
394 |
472 |
395 // ----------------------------------------------------------------------------- |
473 // ---------------------------------------------------------------------------- |
396 // Handles profile switch by name event |
474 // CAiProfileEngine::HandleSwitchByNameL |
397 // ----------------------------------------------------------------------------- |
475 // |
|
476 // ---------------------------------------------------------------------------- |
398 // |
477 // |
399 void CAiProfileEngine::HandleSwitchByNameL( const TDesC& aParam ) |
478 void CAiProfileEngine::HandleSwitchByNameL( const TDesC& aParam ) |
400 { |
479 { |
401 if ( aParam.Length() > 0 ) |
480 if ( aParam.Length() > 0 ) |
402 { |
481 { |
403 TInt profileId = KErrNotFound; |
482 MProEngProfileNameArray* profileNamesArray( |
404 MProfilesNamesArray* profileNamesArray = iProfileEngine->ProfilesNamesArrayLC(); |
483 iProfileEngine->ProfileNameArrayLC() ); |
405 profileId = profileNamesArray->FindByName( aParam ); |
484 |
406 if( profileId != KErrNotFound ) |
485 TInt index( profileNamesArray->FindByName( aParam ) ); |
|
486 |
|
487 if( index != KErrNotFound ) |
407 { |
488 { |
408 SetActiveProfileL( profileId ); |
489 SetActiveProfileL( profileNamesArray->ProfileId( index ) ); |
409 } |
490 } |
410 |
491 |
411 CleanupStack::PopAndDestroy(); |
492 CleanupStack::PopAndDestroy(); |
412 } |
493 } |
413 } |
494 } |
414 |
495 |
415 // ----------------------------------------------------------------------------- |
496 // ---------------------------------------------------------------------------- |
416 // Handles profile swap event |
497 // CAiProfileEngine::HandleSwapL |
417 // ----------------------------------------------------------------------------- |
498 // |
|
499 // ---------------------------------------------------------------------------- |
418 // |
500 // |
419 void CAiProfileEngine::HandleSwapL( const TDesC& aParam ) |
501 void CAiProfileEngine::HandleSwapL( const TDesC& aParam ) |
420 { |
502 { |
421 if ( aParam.Length() > 0 ) |
503 if ( aParam.Length() > 0 ) |
422 { |
504 { |
423 TInt profileId = KErrNotFound; |
505 TInt profileId( KErrNotFound ); |
424 TPtrC ptr( aParam ); |
506 TPtrC ptr( aParam ); |
425 TLex lexer( ptr ); |
507 TLex lexer( ptr ); |
426 |
508 |
427 TInt err = lexer.Val( profileId ); |
509 TInt err( lexer.Val( profileId ) ); |
|
510 |
428 if ( err == KErrNone ) |
511 if ( err == KErrNone ) |
429 { |
512 { |
430 TInt activeProfile = iProfileEngine->ActiveProfileId(); |
513 TInt activeProfile( iProfileEngine->ActiveProfileId() ); |
431 |
514 |
432 if( activeProfile != profileId ) |
515 if( activeProfile != profileId ) |
433 { |
516 { |
434 MProfilesNamesArray* profileNamesArray = iProfileEngine->ProfilesNamesArrayLC(); |
517 MProEngProfileNameArray* profileNamesArray( |
|
518 iProfileEngine->ProfileNameArrayLC() ); |
|
519 |
435 profileId = profileNamesArray->FindById( profileId ); |
520 profileId = profileNamesArray->FindById( profileId ); |
436 |
521 |
437 if( profileId != KErrNotFound ) |
522 if( profileId != KErrNotFound ) |
438 { |
523 { |
439 TRAP_IGNORE( SetActiveProfileL( profileId ) ); |
524 SetActiveProfileL( profileId ); |
440 } |
525 } |
441 |
526 |
442 CleanupStack::PopAndDestroy(); |
527 CleanupStack::PopAndDestroy(); |
443 } |
528 } |
444 else |
529 else |
497 } |
588 } |
498 } |
589 } |
499 |
590 |
500 iProfileEngine->SetActiveProfileL( aProfileId ); |
591 iProfileEngine->SetActiveProfileL( aProfileId ); |
501 } |
592 } |
502 |
593 |
503 // --------------------------------------------------------------------------- |
594 // ---------------------------------------------------------------------------- |
504 // Resumes the engine |
595 // CAiProfileEngine::IsOffline |
505 // --------------------------------------------------------------------------- |
596 // |
506 // |
597 // ---------------------------------------------------------------------------- |
507 void CAiProfileEngine::ResumeL() |
598 // |
508 { |
599 TBool CAiProfileEngine::IsOffline() const |
509 User::LeaveIfError( iSSSettings.Open() ); |
600 { |
510 |
601 return iProfileEngine->ActiveProfileId() == KOfflineProfileId; |
511 //Register to listen ALS activation, if ALS status changes, |
602 } |
512 //profile must be republished. |
603 |
513 TInt err = iSSSettings.Register( ESSSettingsAls, *this ); |
604 // ---------------------------------------------------------------------------- |
514 |
605 // CAiProfileEngine::PhoneSettingChanged |
515 if( err == KErrNotSupported || err == KErrAlreadyExists ) |
606 // |
516 { |
607 // ---------------------------------------------------------------------------- |
517 //ALS not supported or already registered, that's fine |
608 // |
518 err = KErrNone; |
609 void CAiProfileEngine::PhoneSettingChanged( TSSSettingsSetting aSetting, |
519 } |
610 TInt /*aNewValue*/ ) |
520 |
|
521 User::LeaveIfError( err ); |
|
522 |
|
523 //Start to listen profile changes. |
|
524 delete iProfileNotifier; |
|
525 iProfileNotifier = NULL; |
|
526 |
|
527 iProfileNotifier = CProfileChangeNotifyHandler::NewL( this ); |
|
528 } |
|
529 |
|
530 // --------------------------------------------------------------------------- |
|
531 // Suspends the engine |
|
532 // --------------------------------------------------------------------------- |
|
533 // |
|
534 void CAiProfileEngine::Suspend() |
|
535 { |
|
536 iSSSettings.CancelAll( *this ); |
|
537 iSSSettings.Close(); |
|
538 delete iProfileNotifier; |
|
539 iProfileNotifier = NULL; |
|
540 } |
|
541 |
|
542 // --------------------------------------------------------------------------- |
|
543 // From class MProfileChangeObserver |
|
544 // --------------------------------------------------------------------------- |
|
545 // |
|
546 |
|
547 void CAiProfileEngine::HandleActiveProfileEventL( |
|
548 TProfileEvent aProfileEvent, |
|
549 TInt /*aProfileId*/ ) |
|
550 { |
|
551 //Profile activated or modified. |
|
552 if( ( aProfileEvent == EProfileNewActiveProfile ) || |
|
553 ( aProfileEvent == EProfileActiveProfileModified ) ) |
|
554 { |
|
555 UpdateProfileNamesL(); |
|
556 iProfilePluginNotifier->NotifyContentUpdate(); |
|
557 } |
|
558 } |
|
559 |
|
560 // --------------------------------------------------------------------------- |
|
561 // From class MSSSettingsObserver. |
|
562 // --------------------------------------------------------------------------- |
|
563 // |
|
564 void CAiProfileEngine::PhoneSettingChanged( |
|
565 TSSSettingsSetting aSetting, |
|
566 TInt /*aNewValue*/ ) |
|
567 { |
611 { |
568 if( aSetting == ESSSettingsAls ) |
612 if( aSetting == ESSSettingsAls ) |
569 { |
613 { |
570 TRAP_IGNORE( UpdateProfileNamesL() ); |
614 NotifyContentUpdate(); |
571 iProfilePluginNotifier->NotifyContentUpdate(); |
615 } |
572 } |
616 } |
573 } |
617 |
574 |
618 // ---------------------------------------------------------------------------- |
575 |
619 // CAiProfileEngine::HandleActiveProfileModifiedL |
576 TBool CAiProfileEngine::IsOffline() |
620 // |
577 { |
621 // ---------------------------------------------------------------------------- |
578 return iProfileEngine->ActiveProfileId() == KOfflineProfileId; |
622 // |
579 } |
623 void CAiProfileEngine::HandleActiveProfileModifiedL() |
580 |
624 { |
|
625 NotifyContentUpdate(); |
|
626 } |
|
627 |
|
628 // ---------------------------------------------------------------------------- |
|
629 // CAiProfileEngine::HandleProfileNameArrayModificationL |
|
630 // |
|
631 // ---------------------------------------------------------------------------- |
|
632 // |
|
633 void CAiProfileEngine::HandleProfileNameArrayModificationL() |
|
634 { |
|
635 NotifyContentUpdate(); |
|
636 } |
|
637 |
|
638 // ---------------------------------------------------------------------------- |
|
639 // CAiProfileEngine::HandleProfileActivatedL |
|
640 // |
|
641 // ---------------------------------------------------------------------------- |
|
642 // |
|
643 void CAiProfileEngine::HandleProfileActivatedL( TInt /*aProfileId*/ ) |
|
644 { |
|
645 NotifyContentUpdate(); |
|
646 } |
|
647 |
|
648 // ---------------------------------------------------------------------------- |
|
649 // CAiProfileEngine::NotifyContentUpdate |
|
650 // |
|
651 // ---------------------------------------------------------------------------- |
|
652 // |
|
653 void CAiProfileEngine::NotifyContentUpdate() |
|
654 { |
|
655 TRAP_IGNORE( UpdateProfileNamesL() ); |
|
656 |
|
657 iProfilePluginNotifier->NotifyContentUpdate(); |
|
658 } |
|
659 |
|
660 // End of file |