|
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: Main view class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CProfileMainView.h" |
|
20 |
|
21 #include <aknViewAppUi.h> |
|
22 #include <aknnotewrappers.h> |
|
23 #include <eikmenub.h> |
|
24 #include <featmgr.h> |
|
25 #include <AknQueryDialog.h> |
|
26 |
|
27 #ifndef RD_STARTUP_CHANGE |
|
28 #include <PSVariables.h> |
|
29 #include <e32property.h> |
|
30 #else |
|
31 #include <startupdomainpskeys.h> |
|
32 #endif |
|
33 |
|
34 #include <akntitle.h> |
|
35 #include <StringLoader.h> |
|
36 #include <cprofilechangenotifyhandler.h> |
|
37 #include <CProfileEngineHandler.h> |
|
38 #include <CProfileIndexHandler.h> |
|
39 #include <mprofileengine.h> |
|
40 #include <mprofileengineextended.h> |
|
41 #include <mprofile.h> |
|
42 #include <mprofilename.h> |
|
43 #include <mprofileextended.h> |
|
44 #include <mprofilesnamesarray.h> |
|
45 #include <profile.hrh> |
|
46 #include <ProfileApp.rsg> |
|
47 #include <AknQueryDialog.h> |
|
48 |
|
49 #include "CProfileMainContainer.h" |
|
50 #include "CProfileDocument.h" |
|
51 #include "ProfileApp.hrh" |
|
52 #include "CProfileNaviPaneContainer.h" |
|
53 #include "mprofileslocalfeatures.h" |
|
54 #include "profilesvariant.hrh" // KProEngFeatureIdTimedProfiles |
|
55 |
|
56 |
|
57 // CONSTANTS |
|
58 namespace |
|
59 { |
|
60 //const TInt KNumberOfVisibleProfilesInMainView( 6 ); |
|
61 const TInt KOneMinuteInMicrosecond = 1000000 * 60; |
|
62 const TInt KOneHourInMinute = 60; |
|
63 } |
|
64 |
|
65 |
|
66 // ============================ MEMBER FUNCTIONS =============================== |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CProfileMainView::CProfileMainView |
|
70 // C++ constructor can NOT contain any code, that might leave. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CProfileMainView::CProfileMainView( |
|
74 CProfileEngineHandler& aEngineHandler, |
|
75 CProfileIndexHandler& aIndexHandler ) |
|
76 : iEngineHandler( aEngineHandler ), |
|
77 iIndexHandler( aIndexHandler ), |
|
78 iTopItemIndex( KErrNotFound ) |
|
79 { |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CProfileMainView::ConstructL |
|
84 // Symbian 2nd phase constructor can leave. |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CProfileMainView::ConstructL() |
|
88 { |
|
89 BaseConstructL( R_PROFILE_MAIN_VIEW ); |
|
90 |
|
91 CAknTitlePane* titlePane = static_cast< CAknTitlePane* >( |
|
92 StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
93 |
|
94 HBufC* titleText = StringLoader::LoadLC( R_PROFILE_TEXT_TITLE ); |
|
95 titlePane->SetText( titleText ); // takes ownership |
|
96 CleanupStack::Pop( titleText ); |
|
97 |
|
98 iNotifier = CProfileChangeNotifyHandler::NewL( this ); |
|
99 |
|
100 iLocalFeatures = &( iEngineHandler.Engine()->LocalFeatures() ); |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CProfileMainView::NewLC |
|
105 // Two-phased constructor. |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 CProfileMainView* CProfileMainView::NewLC( |
|
109 CProfileEngineHandler& aEngineHandler, |
|
110 CProfileIndexHandler& aIndexHandler ) |
|
111 { |
|
112 CProfileMainView* self = |
|
113 new( ELeave ) CProfileMainView( aEngineHandler, aIndexHandler ); |
|
114 CleanupStack::PushL( self ); |
|
115 self->ConstructL(); |
|
116 return self; |
|
117 } |
|
118 |
|
119 // Destructor |
|
120 CProfileMainView::~CProfileMainView() |
|
121 { |
|
122 delete iNotifier; |
|
123 delete iNaviPaneContainer; |
|
124 if( iContainer ) |
|
125 { |
|
126 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
127 delete iContainer; |
|
128 } |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CProfileMainView::DisplayConfirmationQueryL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 TBool CProfileMainView::DisplayConfirmationQueryL( TInt aResourceId ) const |
|
136 { |
|
137 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
138 return dlg->ExecuteLD( aResourceId ); |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CProfileMainView::DoCmdActivateL |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void CProfileMainView::DoCmdActivateL() |
|
146 { |
|
147 // ID of the currently focused profile |
|
148 // (the profile that user would like to activate) |
|
149 TInt currentProfileId( |
|
150 iEngineHandler.IdForIndex( iIndexHandler.CurrentProfileIndex() ) ); |
|
151 |
|
152 // If Off-line profile is supported |
|
153 if( ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) ) && |
|
154 // and active profile is Off-line |
|
155 ( iEngineHandler.Engine()->ActiveProfileId() == EProfileOffLineId ) && |
|
156 // and currently focused profile is not Off-line |
|
157 ( currentProfileId != EProfileOffLineId ) ) |
|
158 { |
|
159 // We are changing from Off-line to a normal profile. |
|
160 // Check if SIM card exists or not |
|
161 #ifndef RD_STARTUP_CHANGE |
|
162 TInt simCStatus( EPSCSimRemoved ); |
|
163 #else |
|
164 TInt simCStatus( ESimNotPresent ); |
|
165 #endif |
|
166 |
|
167 RProperty simStatus; |
|
168 #ifndef RD_STARTUP_CHANGE |
|
169 User::LeaveIfError( |
|
170 simStatus.Attach( KUidSystemCategory, KPSUidSimCStatusValue ) ); |
|
171 User::LeaveIfError( simStatus.Get( simCStatus ) ); |
|
172 #else |
|
173 User::LeaveIfError( |
|
174 simStatus.Attach( KPSUidStartup, KPSSimStatus ) ); |
|
175 User::LeaveIfError( simStatus.Get( simCStatus ) ); |
|
176 #endif |
|
177 simStatus.Close(); |
|
178 |
|
179 #ifndef RD_STARTUP_CHANGE |
|
180 if( simCStatus == EPSCSimRemoved ) |
|
181 #else |
|
182 if( simCStatus == ESimNotPresent ) |
|
183 #endif |
|
184 { |
|
185 // SIM card does not exist. |
|
186 // Show an information note and exit from method. |
|
187 HBufC* infoText = StringLoader::LoadLC( R_PROFILE_TEXT_INSERT_SIM ); |
|
188 CAknInformationNote* note = |
|
189 new( ELeave ) CAknInformationNote( ETrue ); |
|
190 note->ExecuteLD( *infoText ); |
|
191 CleanupStack::PopAndDestroy( infoText ); |
|
192 return; |
|
193 } |
|
194 else if( !DisplayConfirmationQueryL( |
|
195 R_PROFILE_LEAVE_OFFLINE_CONFIRMATION_QUERY ) ) |
|
196 { |
|
197 // SIM card exists. |
|
198 // User replied that he/she doesn't want to activate RF. |
|
199 // Exit from method, do not activate the focused profile. |
|
200 return; |
|
201 } |
|
202 } |
|
203 iEngineHandler.Engine()->SetActiveProfileL( currentProfileId ); |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CProfileMainView::DoCmdCreateNewL |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 void CProfileMainView::DoCmdCreateNewL() |
|
211 { |
|
212 MProfileExtended* profile = iEngineHandler.Engine()->CreateProfileL(); // CSI: 35 # profile object deleted before leaving function calls |
|
213 if( profile ) |
|
214 { |
|
215 // Profile creation successful |
|
216 TInt id( profile->ProfileName().Id() ); |
|
217 profile->Release(); |
|
218 iEngineHandler.ReadIdArrayL(); |
|
219 // Focus the created profile: |
|
220 iIndexHandler.SetCurrentProfileIndex( |
|
221 iEngineHandler.IdArray()->FindById( id ) ); |
|
222 AppUi()->HandleCommandL( EProfileCmdPersonalise ); |
|
223 } |
|
224 else |
|
225 { |
|
226 // Maximum number of user created profiles reached, show error note |
|
227 HBufC* errorText = StringLoader::LoadLC( |
|
228 R_PROFILE_TEXT_ERROR_MAXIMUM ); |
|
229 CAknErrorNote* note = new( ELeave ) CAknErrorNote( ETrue ); |
|
230 note->ExecuteLD( *errorText ); |
|
231 CleanupStack::PopAndDestroy( errorText ); |
|
232 } |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CProfileMainView::DoCmdDeleteL |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 void CProfileMainView::DoCmdDeleteL() |
|
240 { |
|
241 // Ask user if he/she wants to delete profile |
|
242 if( !DisplayConfirmationQueryL( R_PROFILE_DELETE_CONFIRMATION_QUERY ) ) |
|
243 { |
|
244 // User didn't want to delete the profile, return |
|
245 return; |
|
246 } |
|
247 |
|
248 TInt currentProfileIndex( iIndexHandler.CurrentProfileIndex() ); |
|
249 |
|
250 // Try deleting the focused profile |
|
251 TInt errorCode( iEngineHandler.Engine()->DeleteProfileL( |
|
252 iEngineHandler.IdForIndex( currentProfileIndex ) ) ); |
|
253 |
|
254 if( errorCode == KErrNone ) |
|
255 { |
|
256 iEngineHandler.ReadIdArrayL(); |
|
257 TInt lastIndex = iEngineHandler.IdArray()->MdcaCount() - 1; |
|
258 if( currentProfileIndex > lastIndex ) |
|
259 { |
|
260 // The last profile in the list was deleted. change focus. |
|
261 iIndexHandler.SetCurrentProfileIndex( lastIndex ); |
|
262 } |
|
263 iContainer->PopulateListBoxL(); |
|
264 } |
|
265 else |
|
266 { |
|
267 // Show error note if cannot delete profile |
|
268 HBufC* errorText = StringLoader::LoadLC( |
|
269 R_PROFILE_TEXT_DELETE_ERROR ); |
|
270 CAknErrorNote* note = new( ELeave ) CAknErrorNote( ETrue ); |
|
271 note->ExecuteLD( *errorText ); |
|
272 CleanupStack::PopAndDestroy( errorText ); |
|
273 } |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CProfileMainView::DoCmdContextSpecificOptionsMenuL |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 void CProfileMainView::DoCmdContextSpecificOptionsMenuL() |
|
281 { |
|
282 // Switch to Context specific options menu, |
|
283 // show it and switch back to main view options menu. |
|
284 CEikMenuBar* menuBar = MenuBar(); |
|
285 menuBar->SetMenuType( CEikMenuBar::EMenuContext ); |
|
286 menuBar->SetMenuTitleResourceId( |
|
287 R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUBAR ); |
|
288 |
|
289 // TRAP displaying of menu bar. |
|
290 // If it fails, the correct resource is set back before leave. |
|
291 TRAPD( error, menuBar->TryDisplayContextMenuBarL() ); |
|
292 |
|
293 menuBar->SetMenuType( CEikMenuBar::EMenuOptions ); |
|
294 menuBar->SetMenuTitleResourceId( R_PROFILE_MAIN_VIEW_OPTIONS_MENUBAR ); |
|
295 User::LeaveIfError( error ); |
|
296 |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // CProfileMainView::DisplayTimedNote |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 void CProfileMainView::DisplayTimedInfoNoteL( TInt aMinutes, TInt aHours ) const |
|
304 { |
|
305 TInt resourceId = R_PROFILE_CONF_SINGULAR; |
|
306 TBool minutesSingular( EFalse ); |
|
307 TBool hoursSingular( EFalse ); |
|
308 |
|
309 if( aMinutes == 1) |
|
310 { |
|
311 minutesSingular = ETrue; |
|
312 } |
|
313 if( aHours == 1 ) |
|
314 { |
|
315 hoursSingular = ETrue; |
|
316 } |
|
317 |
|
318 if( ( !minutesSingular ) && ( hoursSingular ) ) |
|
319 { |
|
320 resourceId = R_PROFILE_CONF_HOUR_SEV_MIN; |
|
321 } |
|
322 else if( ( minutesSingular ) && ( !hoursSingular ) ) |
|
323 { |
|
324 resourceId = R_PROFILE_CONF_SEV_HOURS_MIN; |
|
325 } |
|
326 else if( ( !minutesSingular ) && ( !hoursSingular ) ) |
|
327 { |
|
328 resourceId = R_PROFILE_CONF_PLURAL; |
|
329 } |
|
330 |
|
331 CArrayFix<TInt>* array = new( ELeave ) CArrayFixFlat<TInt>(1); |
|
332 CleanupStack::PushL( array ); |
|
333 |
|
334 array->AppendL( aHours ); |
|
335 array->AppendL( aMinutes ); |
|
336 |
|
337 HBufC* expiryText = StringLoader::LoadLC( |
|
338 resourceId, *array ); |
|
339 |
|
340 CAknInformationNote* note = new( ELeave ) CAknInformationNote( EFalse ); |
|
341 |
|
342 note->ExecuteLD( *expiryText ); |
|
343 |
|
344 // expiryText |
|
345 CleanupStack::PopAndDestroy( expiryText ); |
|
346 |
|
347 // array |
|
348 CleanupStack::PopAndDestroy( array ); |
|
349 } |
|
350 |
|
351 // ----------------------------------------------------------------------------- |
|
352 // CProfileMainView::DisplayTimedQueryNote |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 void CProfileMainView::DisplayTimedQueryNoteL( TInt aMinutes, TInt aHours ) const |
|
356 { |
|
357 TInt resourceId = R_PROFILE_CONF_SINGULAR; |
|
358 TBool minutesSingular( EFalse ); |
|
359 TBool hoursSingular( EFalse ); |
|
360 |
|
361 if( aMinutes == 1) |
|
362 { |
|
363 minutesSingular = ETrue; |
|
364 } |
|
365 if( aHours == 1 ) |
|
366 { |
|
367 hoursSingular = ETrue; |
|
368 } |
|
369 |
|
370 if( ( !minutesSingular ) && ( hoursSingular ) ) |
|
371 { |
|
372 resourceId = R_PROFILE_CONF_HOUR_SEV_MIN; |
|
373 } |
|
374 else if( ( minutesSingular ) && ( !hoursSingular ) ) |
|
375 { |
|
376 resourceId = R_PROFILE_CONF_SEV_HOURS_MIN; |
|
377 } |
|
378 else if( ( !minutesSingular ) && ( !hoursSingular ) ) |
|
379 { |
|
380 resourceId = R_PROFILE_CONF_PLURAL; |
|
381 } |
|
382 |
|
383 CArrayFix<TInt>* array = new( ELeave ) CArrayFixFlat<TInt>(1); |
|
384 CleanupStack::PushL( array ); |
|
385 |
|
386 array->AppendL( aHours ); |
|
387 array->AppendL( aMinutes ); |
|
388 |
|
389 HBufC* expiryText = StringLoader::LoadLC( |
|
390 resourceId, *array ); |
|
391 |
|
392 CAknQueryDialog* query = CAknQueryDialog::NewL(); |
|
393 const TInt ret( |
|
394 query->ExecuteLD( R_PROFILE_CONFIRM_TIMED_QUERY, *expiryText ) ); |
|
395 |
|
396 // expiryText |
|
397 CleanupStack::PopAndDestroy( expiryText ); |
|
398 |
|
399 // array |
|
400 CleanupStack::PopAndDestroy( array ); |
|
401 } |
|
402 |
|
403 // ----------------------------------------------------------------------------- |
|
404 // CProfileMainView::DoCmdTimedL |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 void CProfileMainView::DoCmdTimedL() |
|
408 { |
|
409 // ID of the currently focused profile |
|
410 // (the profile that user would like to activate) |
|
411 TInt currentProfileId( |
|
412 iEngineHandler.IdForIndex( iIndexHandler.CurrentProfileIndex() ) ); |
|
413 |
|
414 // If Off-line profile is supported |
|
415 if( ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) ) && |
|
416 // and active profile is Off-line |
|
417 ( iEngineHandler.Engine()->ActiveProfileId() == EProfileOffLineId ) && |
|
418 // and currently focused profile is not Off-line |
|
419 ( currentProfileId != EProfileOffLineId ) ) |
|
420 { |
|
421 // We are changing from Off-line to a normal profile. |
|
422 // Check if SIM card exists or not |
|
423 #ifndef RD_STARTUP_CHANGE |
|
424 TInt simCStatus( EPSCSimRemoved ); |
|
425 #else |
|
426 TInt simCStatus( ESimNotPresent ); |
|
427 #endif |
|
428 |
|
429 RProperty simStatus; |
|
430 #ifndef RD_STARTUP_CHANGE |
|
431 User::LeaveIfError( |
|
432 simStatus.Attach( KUidSystemCategory, KPSUidSimCStatusValue ) ); |
|
433 User::LeaveIfError( simStatus.Get( simCStatus ) ); |
|
434 #else |
|
435 User::LeaveIfError( |
|
436 simStatus.Attach( KPSUidStartup, KPSSimStatus ) ); |
|
437 User::LeaveIfError( simStatus.Get( simCStatus ) ); |
|
438 #endif |
|
439 simStatus.Close(); |
|
440 |
|
441 #ifndef RD_STARTUP_CHANGE |
|
442 if( simCStatus == EPSCSimRemoved ) |
|
443 #else |
|
444 if( simCStatus == ESimNotPresent ) |
|
445 #endif |
|
446 { |
|
447 // SIM card does not exist. |
|
448 // Show an information note and exit from method. |
|
449 HBufC* infoText = StringLoader::LoadLC( R_PROFILE_TEXT_INSERT_SIM ); |
|
450 CAknInformationNote* note = |
|
451 new( ELeave ) CAknInformationNote( ETrue ); |
|
452 note->ExecuteLD( *infoText ); |
|
453 CleanupStack::PopAndDestroy( infoText ); |
|
454 return; |
|
455 } |
|
456 else if( !DisplayConfirmationQueryL( |
|
457 R_PROFILE_LEAVE_OFFLINE_CONFIRMATION_QUERY ) ) |
|
458 { |
|
459 // SIM card exists. |
|
460 // User replied that he/she doesn't want to activate RF. |
|
461 // Exit from method, do not activate the focused profile. |
|
462 return; |
|
463 } |
|
464 } |
|
465 |
|
466 TTime expireTime; |
|
467 expireTime.HomeTime(); |
|
468 |
|
469 HBufC* expiryTime = |
|
470 StringLoader::LoadLC( R_PROFILE_SETTING_EXPIRY_TIME ); |
|
471 |
|
472 CAknTimeQueryDialog* dlg = new(ELeave) CAknTimeQueryDialog( expireTime ); |
|
473 if (dlg->ExecuteLD(R_PROFILE_TIME_QUERY, *expiryTime )) |
|
474 { |
|
475 // Timing currently active profile is not allowed. This can happen |
|
476 // if active profile is changed after the timing process begins. |
|
477 // Exception: re-timing a timed profile. |
|
478 MProfileEngine* profileEngine = CreateProfileEngineL(); |
|
479 CleanupReleasePushL( *profileEngine ); |
|
480 TBool isActiveProfileTimed = profileEngine->IsActiveProfileTimedL(); |
|
481 CleanupStack::PopAndDestroy( profileEngine ); |
|
482 |
|
483 if( currentProfileId == iEngineHandler.Engine()->ActiveProfileId() |
|
484 && !isActiveProfileTimed ) |
|
485 { |
|
486 HBufC* errorText = StringLoader::LoadLC( |
|
487 R_PROFILE_ERROR_TIMING_ACTIVE_PROFILE ); |
|
488 CAknErrorNote* note = new( ELeave ) CAknErrorNote( ETrue ); |
|
489 note->ExecuteLD( *errorText ); |
|
490 CleanupStack::PopAndDestroy( errorText ); |
|
491 return; |
|
492 } |
|
493 |
|
494 TTime originalTime; |
|
495 originalTime.HomeTime(); |
|
496 |
|
497 TDateTime expiredtime = expireTime.DateTime(); |
|
498 TDateTime originaltdtime = originalTime.DateTime(); |
|
499 expiredtime.SetDay(originaltdtime.Day()); |
|
500 expiredtime.SetMonth(originaltdtime.Month()); |
|
501 expiredtime.SetYear(originaltdtime.Year()); |
|
502 expireTime = expiredtime; |
|
503 |
|
504 if( expireTime < originalTime ) |
|
505 { |
|
506 expireTime += TTimeIntervalDays(1); |
|
507 } |
|
508 |
|
509 TTimeIntervalMicroSeconds remainTime( |
|
510 expireTime.MicroSecondsFrom( originalTime ) ); |
|
511 TInt64 tmp = ( remainTime.Int64() ) / KOneMinuteInMicrosecond; |
|
512 TInt minutes = I64INT(tmp); |
|
513 TInt hours(minutes / KOneHourInMinute); |
|
514 minutes -= hours * KOneHourInMinute; |
|
515 |
|
516 DisplayTimedQueryNoteL( minutes, hours ); |
|
517 |
|
518 MProfileEngineExtended* engine = iEngineHandler.Engine(); |
|
519 engine->SetActiveProfileTimedL( currentProfileId, expireTime ); |
|
520 } |
|
521 CleanupStack::PopAndDestroy( expiryTime ); |
|
522 } |
|
523 |
|
524 // ----------------------------------------------------------------------------- |
|
525 // CProfileMainView::Id |
|
526 // ----------------------------------------------------------------------------- |
|
527 // |
|
528 TUid CProfileMainView::Id() const |
|
529 { |
|
530 return KProfileAppMainViewId; |
|
531 } |
|
532 |
|
533 // ----------------------------------------------------------------------------- |
|
534 // CProfileMainView::HandleCommandL |
|
535 // ----------------------------------------------------------------------------- |
|
536 // |
|
537 void CProfileMainView::HandleCommandL( TInt aCommand ) |
|
538 { |
|
539 switch ( aCommand ) |
|
540 { |
|
541 case EProfileCmdActivate: |
|
542 { |
|
543 DoCmdActivateL(); |
|
544 break; |
|
545 } |
|
546 case EProfileCmdCreateNew: |
|
547 { |
|
548 DoCmdCreateNewL(); |
|
549 break; |
|
550 } |
|
551 case EProfileCmdDelete: |
|
552 { |
|
553 DoCmdDeleteL(); |
|
554 break; |
|
555 } |
|
556 case EProfileCmdContextSpecificOptionsMenu: |
|
557 case EAknSoftkeyContextOptions: |
|
558 { |
|
559 DoCmdContextSpecificOptionsMenuL(); |
|
560 break; |
|
561 } |
|
562 case EProfileCmdTimed: |
|
563 { |
|
564 DoCmdTimedL(); |
|
565 break; |
|
566 } |
|
567 default: |
|
568 { |
|
569 AppUi()->HandleCommandL( aCommand ); |
|
570 break; |
|
571 } |
|
572 } |
|
573 } |
|
574 |
|
575 // ----------------------------------------------------------------------------- |
|
576 // CProfileMainView::DoActivateL |
|
577 // ----------------------------------------------------------------------------- |
|
578 // |
|
579 void CProfileMainView::DoActivateL( |
|
580 const TVwsViewId& /* aPrevViewId */, |
|
581 TUid aCustomMessageId, |
|
582 const TDesC8& /* aCustomMessage */ ) |
|
583 { |
|
584 if( !iContainer ) |
|
585 { |
|
586 iContainer = CProfileMainContainer::NewL( |
|
587 iEngineHandler, iIndexHandler, *this ); |
|
588 iContainer->PopulateListBoxL( iTopItemIndex ); |
|
589 iNaviPaneContainer = |
|
590 CProfileNaviPaneContainer::NewL( *StatusPane(), iEngineHandler ); |
|
591 // Set the name of the active profile to navi pane |
|
592 iNaviPaneContainer->SetNaviPaneTextL(); |
|
593 AppUi()->AddToViewStackL( *this, iContainer ); |
|
594 iContainer->MakeVisible( ETrue ); |
|
595 } |
|
596 |
|
597 if( aCustomMessageId == KProfileAppMainViewId ) |
|
598 { |
|
599 DoCmdCreateNewL(); |
|
600 } |
|
601 |
|
602 CEikMenuBar* menuBar = MenuBar(); |
|
603 menuBar->SetContextMenuTitleResourceId( |
|
604 R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUBAR ); |
|
605 |
|
606 |
|
607 if ( iEikonEnv->StartedAsServerApp() ) |
|
608 { |
|
609 UpdateCbaL(R_PROFILE_MAIN_VIEW_CBA_2); |
|
610 } |
|
611 |
|
612 } |
|
613 |
|
614 // ----------------------------------------------------------------------------- |
|
615 // CProfileMainView::DoDeactivate |
|
616 // ----------------------------------------------------------------------------- |
|
617 // |
|
618 void CProfileMainView::DoDeactivate() |
|
619 { |
|
620 delete iNaviPaneContainer; |
|
621 iNaviPaneContainer = NULL; |
|
622 if( iContainer ) |
|
623 { |
|
624 iTopItemIndex = iContainer->TopItemIndex(); |
|
625 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
626 delete iContainer; |
|
627 iContainer = NULL; |
|
628 } |
|
629 } |
|
630 |
|
631 // ----------------------------------------------------------------------------- |
|
632 // CProfileMainView::DynInitMenuPaneL |
|
633 // ----------------------------------------------------------------------------- |
|
634 // |
|
635 void CProfileMainView::DynInitMenuPaneL( |
|
636 TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
637 { |
|
638 if( !iContainer || |
|
639 ( (aResourceId != R_PROFILE_MAIN_VIEW_OPTIONS_MENUPANE) && |
|
640 (aResourceId != R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUPANE) |
|
641 ) ) |
|
642 { |
|
643 return; |
|
644 } |
|
645 |
|
646 // ID of the currently focused profile |
|
647 TInt currentProfileId( |
|
648 iEngineHandler.IdForIndex( iIndexHandler.CurrentProfileIndex() ) ); |
|
649 TInt activeProfileId( iEngineHandler.Engine()->ActiveProfileId() ); |
|
650 |
|
651 // "Timed" item is in both menus: |
|
652 if( aResourceId == R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUPANE && (( !iLocalFeatures->IsFeatureSupported( KProEngFeatureIdTimedProfiles ) ) |
|
653 || ( currentProfileId == EProfileOffLineId ) || |
|
654 ( ( activeProfileId == currentProfileId ) && |
|
655 !iEngineHandler.Engine()->IsActiveProfileTimedL() ) )) |
|
656 { |
|
657 // Timed profiles is not supported. Hide Timed option from |
|
658 // Options menu |
|
659 aMenuPane->SetItemDimmed( EProfileCmdTimed, ETrue ); |
|
660 } |
|
661 if(aResourceId == R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUPANE && ( FeatureManager::FeatureSupported(KFeatureIdDynamicProfiles) ) && |
|
662 iEngineHandler.Engine()->IsDefaultProfile( currentProfileId ) ) |
|
663 { |
|
664 // A default profile is focused. Hide Delete from Options menu |
|
665 aMenuPane->SetItemDimmed( EProfileCmdDelete, ETrue ); |
|
666 } |
|
667 |
|
668 if( aResourceId == R_PROFILE_MAIN_VIEW_OPTIONS_MENUPANE ) |
|
669 { |
|
670 if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
671 { |
|
672 // Help is not supported. Hide Help from Options menu |
|
673 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
674 } |
|
675 // Check that dynamic profiles are supported |
|
676 // before trying to hide Delete from Options menu. |
|
677 /* if( ( FeatureManager::FeatureSupported(KFeatureIdDynamicProfiles) ) && |
|
678 iEngineHandler.Engine()->IsDefaultProfile( currentProfileId ) ) |
|
679 { |
|
680 // A default profile is focused. Hide Delete from Options menu |
|
681 aMenuPane->SetItemDimmed( EProfileCmdDelete, ETrue ); |
|
682 }*/ |
|
683 } |
|
684 |
|
685 } |
|
686 |
|
687 // ----------------------------------------------------------------------------- |
|
688 // CProfileMainView::HandleActiveProfileEventL |
|
689 // ----------------------------------------------------------------------------- |
|
690 // |
|
691 void CProfileMainView::HandleActiveProfileEventL( |
|
692 TProfileEvent /* aProfileEvent */, TInt /* aProfileId */ ) |
|
693 { |
|
694 if( iNaviPaneContainer ) |
|
695 { |
|
696 // Active profile has changed. Change active profile name in navi pane. |
|
697 iNaviPaneContainer->SetNaviPaneTextL(); |
|
698 } |
|
699 } |
|
700 |
|
701 // ----------------------------------------------------------------------------- |
|
702 // CProfileMainView::UpdateClientRect |
|
703 // ----------------------------------------------------------------------------- |
|
704 // |
|
705 void CProfileMainView::UpdateClientRect() |
|
706 { |
|
707 iContainer->SetRect( ClientRect() ); |
|
708 } |
|
709 |
|
710 // ----------------------------------------------------------------------------- |
|
711 // CProfileMainView::View |
|
712 // ----------------------------------------------------------------------------- |
|
713 // |
|
714 CAknView& CProfileMainView::View() |
|
715 { |
|
716 return *this; |
|
717 } |
|
718 |
|
719 |
|
720 // ----------------------------------------------------------------------------- |
|
721 // CProfileMainView::UpdateCbaL |
|
722 // |
|
723 // ----------------------------------------------------------------------------- |
|
724 // |
|
725 void CProfileMainView::UpdateCbaL(TInt aResourceId) |
|
726 { |
|
727 CEikButtonGroupContainer* cba = Cba(); |
|
728 cba->SetCommandSetL(aResourceId); |
|
729 cba->DrawDeferred(); |
|
730 } |
|
731 |
|
732 |
|
733 // End of File |