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 } |
|
195 iEngineHandler.Engine()->SetActiveProfileL( currentProfileId ); |
|
196 } |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // CProfileMainView::DoCmdCreateNewL |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 void CProfileMainView::DoCmdCreateNewL() |
|
203 { |
|
204 MProfileExtended* profile = iEngineHandler.Engine()->CreateProfileL(); // CSI: 35 # profile object deleted before leaving function calls |
|
205 if( profile ) |
|
206 { |
|
207 // Profile creation successful |
|
208 TInt id( profile->ProfileName().Id() ); |
|
209 profile->Release(); |
|
210 iEngineHandler.ReadIdArrayL(); |
|
211 // Focus the created profile: |
|
212 iIndexHandler.SetCurrentProfileIndex( |
|
213 iEngineHandler.IdArray()->FindById( id ) ); |
|
214 AppUi()->HandleCommandL( EProfileCmdPersonalise ); |
|
215 } |
|
216 else |
|
217 { |
|
218 // Maximum number of user created profiles reached, show error note |
|
219 HBufC* errorText = StringLoader::LoadLC( |
|
220 R_PROFILE_TEXT_ERROR_MAXIMUM ); |
|
221 CAknErrorNote* note = new( ELeave ) CAknErrorNote( ETrue ); |
|
222 note->ExecuteLD( *errorText ); |
|
223 CleanupStack::PopAndDestroy( errorText ); |
|
224 } |
|
225 } |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // CProfileMainView::DoCmdDeleteL |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 void CProfileMainView::DoCmdDeleteL() |
|
232 { |
|
233 // Ask user if he/she wants to delete profile |
|
234 if( !DisplayConfirmationQueryL( R_PROFILE_DELETE_CONFIRMATION_QUERY ) ) |
|
235 { |
|
236 // User didn't want to delete the profile, return |
|
237 return; |
|
238 } |
|
239 |
|
240 TInt currentProfileIndex( iIndexHandler.CurrentProfileIndex() ); |
|
241 |
|
242 // Try deleting the focused profile |
|
243 TInt errorCode( iEngineHandler.Engine()->DeleteProfileL( |
|
244 iEngineHandler.IdForIndex( currentProfileIndex ) ) ); |
|
245 |
|
246 if( errorCode == KErrNone ) |
|
247 { |
|
248 iEngineHandler.ReadIdArrayL(); |
|
249 TInt lastIndex = iEngineHandler.IdArray()->MdcaCount() - 1; |
|
250 if( currentProfileIndex > lastIndex ) |
|
251 { |
|
252 // The last profile in the list was deleted. change focus. |
|
253 iIndexHandler.SetCurrentProfileIndex( lastIndex ); |
|
254 } |
|
255 iContainer->PopulateListBoxL(); |
|
256 } |
|
257 else |
|
258 { |
|
259 // Show error note if cannot delete profile |
|
260 HBufC* errorText = StringLoader::LoadLC( |
|
261 R_PROFILE_TEXT_DELETE_ERROR ); |
|
262 CAknErrorNote* note = new( ELeave ) CAknErrorNote( ETrue ); |
|
263 note->ExecuteLD( *errorText ); |
|
264 CleanupStack::PopAndDestroy( errorText ); |
|
265 } |
|
266 } |
|
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // CProfileMainView::DoCmdContextSpecificOptionsMenuL |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 void CProfileMainView::DoCmdContextSpecificOptionsMenuL() |
|
273 { |
|
274 // Switch to Context specific options menu, |
|
275 // show it and switch back to main view options menu. |
|
276 CEikMenuBar* menuBar = MenuBar(); |
|
277 menuBar->SetMenuType( CEikMenuBar::EMenuContext ); |
|
278 menuBar->SetMenuTitleResourceId( |
|
279 R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUBAR ); |
|
280 |
|
281 // TRAP displaying of menu bar. |
|
282 // If it fails, the correct resource is set back before leave. |
|
283 TRAPD( error, menuBar->TryDisplayContextMenuBarL() ); |
|
284 |
|
285 menuBar->SetMenuType( CEikMenuBar::EMenuOptions ); |
|
286 menuBar->SetMenuTitleResourceId( R_PROFILE_MAIN_VIEW_OPTIONS_MENUBAR ); |
|
287 User::LeaveIfError( error ); |
|
288 |
|
289 } |
|
290 |
|
291 // ----------------------------------------------------------------------------- |
|
292 // CProfileMainView::DisplayTimedNote |
|
293 // ----------------------------------------------------------------------------- |
|
294 // |
|
295 void CProfileMainView::DisplayTimedInfoNoteL( TInt aMinutes, TInt aHours ) const |
|
296 { |
|
297 TInt resourceId = R_PROFILE_CONF_SINGULAR; |
|
298 TBool minutesSingular( EFalse ); |
|
299 TBool hoursSingular( EFalse ); |
|
300 |
|
301 if( aMinutes == 1) |
|
302 { |
|
303 minutesSingular = ETrue; |
|
304 } |
|
305 if( aHours == 1 ) |
|
306 { |
|
307 hoursSingular = ETrue; |
|
308 } |
|
309 |
|
310 if( ( !minutesSingular ) && ( hoursSingular ) ) |
|
311 { |
|
312 resourceId = R_PROFILE_CONF_HOUR_SEV_MIN; |
|
313 } |
|
314 else if( ( minutesSingular ) && ( !hoursSingular ) ) |
|
315 { |
|
316 resourceId = R_PROFILE_CONF_SEV_HOURS_MIN; |
|
317 } |
|
318 else if( ( !minutesSingular ) && ( !hoursSingular ) ) |
|
319 { |
|
320 resourceId = R_PROFILE_CONF_PLURAL; |
|
321 } |
|
322 |
|
323 CArrayFix<TInt>* array = new( ELeave ) CArrayFixFlat<TInt>(1); |
|
324 CleanupStack::PushL( array ); |
|
325 |
|
326 array->AppendL( aHours ); |
|
327 array->AppendL( aMinutes ); |
|
328 |
|
329 HBufC* expiryText = StringLoader::LoadLC( |
|
330 resourceId, *array ); |
|
331 |
|
332 CAknInformationNote* note = new( ELeave ) CAknInformationNote( EFalse ); |
|
333 |
|
334 note->ExecuteLD( *expiryText ); |
|
335 |
|
336 // expiryText |
|
337 CleanupStack::PopAndDestroy( expiryText ); |
|
338 |
|
339 // array |
|
340 CleanupStack::PopAndDestroy( array ); |
|
341 } |
|
342 |
|
343 // ----------------------------------------------------------------------------- |
|
344 // CProfileMainView::DisplayTimedQueryNote |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 void CProfileMainView::DisplayTimedQueryNoteL( TInt aMinutes, TInt aHours ) const |
|
348 { |
|
349 TInt resourceId = R_PROFILE_CONF_SINGULAR; |
|
350 TBool minutesSingular( EFalse ); |
|
351 TBool hoursSingular( EFalse ); |
|
352 |
|
353 if( aMinutes == 1) |
|
354 { |
|
355 minutesSingular = ETrue; |
|
356 } |
|
357 if( aHours == 1 ) |
|
358 { |
|
359 hoursSingular = ETrue; |
|
360 } |
|
361 |
|
362 if( ( !minutesSingular ) && ( hoursSingular ) ) |
|
363 { |
|
364 resourceId = R_PROFILE_CONF_HOUR_SEV_MIN; |
|
365 } |
|
366 else if( ( minutesSingular ) && ( !hoursSingular ) ) |
|
367 { |
|
368 resourceId = R_PROFILE_CONF_SEV_HOURS_MIN; |
|
369 } |
|
370 else if( ( !minutesSingular ) && ( !hoursSingular ) ) |
|
371 { |
|
372 resourceId = R_PROFILE_CONF_PLURAL; |
|
373 } |
|
374 |
|
375 CArrayFix<TInt>* array = new( ELeave ) CArrayFixFlat<TInt>(1); |
|
376 CleanupStack::PushL( array ); |
|
377 |
|
378 array->AppendL( aHours ); |
|
379 array->AppendL( aMinutes ); |
|
380 |
|
381 HBufC* expiryText = StringLoader::LoadLC( |
|
382 resourceId, *array ); |
|
383 |
|
384 CAknQueryDialog* query = CAknQueryDialog::NewL(); |
|
385 const TInt ret( |
|
386 query->ExecuteLD( R_PROFILE_CONFIRM_TIMED_QUERY, *expiryText ) ); |
|
387 |
|
388 // expiryText |
|
389 CleanupStack::PopAndDestroy( expiryText ); |
|
390 |
|
391 // array |
|
392 CleanupStack::PopAndDestroy( array ); |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // CProfileMainView::DoCmdTimedL |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 void CProfileMainView::DoCmdTimedL() |
|
400 { |
|
401 // ID of the currently focused profile |
|
402 // (the profile that user would like to activate) |
|
403 TInt currentProfileId( |
|
404 iEngineHandler.IdForIndex( iIndexHandler.CurrentProfileIndex() ) ); |
|
405 |
|
406 // If Off-line profile is supported |
|
407 if( ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) ) && |
|
408 // and active profile is Off-line |
|
409 ( iEngineHandler.Engine()->ActiveProfileId() == EProfileOffLineId ) && |
|
410 // and currently focused profile is not Off-line |
|
411 ( currentProfileId != EProfileOffLineId ) ) |
|
412 { |
|
413 // We are changing from Off-line to a normal profile. |
|
414 // Check if SIM card exists or not |
|
415 #ifndef RD_STARTUP_CHANGE |
|
416 TInt simCStatus( EPSCSimRemoved ); |
|
417 #else |
|
418 TInt simCStatus( ESimNotPresent ); |
|
419 #endif |
|
420 |
|
421 RProperty simStatus; |
|
422 #ifndef RD_STARTUP_CHANGE |
|
423 User::LeaveIfError( |
|
424 simStatus.Attach( KUidSystemCategory, KPSUidSimCStatusValue ) ); |
|
425 User::LeaveIfError( simStatus.Get( simCStatus ) ); |
|
426 #else |
|
427 User::LeaveIfError( |
|
428 simStatus.Attach( KPSUidStartup, KPSSimStatus ) ); |
|
429 User::LeaveIfError( simStatus.Get( simCStatus ) ); |
|
430 #endif |
|
431 simStatus.Close(); |
|
432 |
|
433 #ifndef RD_STARTUP_CHANGE |
|
434 if( simCStatus == EPSCSimRemoved ) |
|
435 #else |
|
436 if( simCStatus == ESimNotPresent ) |
|
437 #endif |
|
438 { |
|
439 // SIM card does not exist. |
|
440 // Show an information note and exit from method. |
|
441 HBufC* infoText = StringLoader::LoadLC( R_PROFILE_TEXT_INSERT_SIM ); |
|
442 CAknInformationNote* note = |
|
443 new( ELeave ) CAknInformationNote( ETrue ); |
|
444 note->ExecuteLD( *infoText ); |
|
445 CleanupStack::PopAndDestroy( infoText ); |
|
446 return; |
|
447 } |
|
448 } |
|
449 |
|
450 TTime expireTime; |
|
451 expireTime.HomeTime(); |
|
452 |
|
453 HBufC* expiryTime = |
|
454 StringLoader::LoadLC( R_PROFILE_SETTING_EXPIRY_TIME ); |
|
455 |
|
456 CAknTimeQueryDialog* dlg = new(ELeave) CAknTimeQueryDialog( expireTime ); |
|
457 if (dlg->ExecuteLD(R_PROFILE_TIME_QUERY, *expiryTime )) |
|
458 { |
|
459 // Timing currently active profile is not allowed. This can happen |
|
460 // if active profile is changed after the timing process begins. |
|
461 // Exception: re-timing a timed profile. |
|
462 MProfileEngine* profileEngine = CreateProfileEngineL(); |
|
463 CleanupReleasePushL( *profileEngine ); |
|
464 TBool isActiveProfileTimed = profileEngine->IsActiveProfileTimedL(); |
|
465 CleanupStack::PopAndDestroy( profileEngine ); |
|
466 |
|
467 if( currentProfileId == iEngineHandler.Engine()->ActiveProfileId() |
|
468 && !isActiveProfileTimed ) |
|
469 { |
|
470 HBufC* errorText = StringLoader::LoadLC( |
|
471 R_PROFILE_ERROR_TIMING_ACTIVE_PROFILE ); |
|
472 CAknErrorNote* note = new( ELeave ) CAknErrorNote( ETrue ); |
|
473 note->ExecuteLD( *errorText ); |
|
474 CleanupStack::PopAndDestroy( errorText ); |
|
475 return; |
|
476 } |
|
477 |
|
478 TTime originalTime; |
|
479 originalTime.HomeTime(); |
|
480 |
|
481 TDateTime expiredtime = expireTime.DateTime(); |
|
482 TDateTime originaltdtime = originalTime.DateTime(); |
|
483 expiredtime.SetDay(originaltdtime.Day()); |
|
484 expiredtime.SetMonth(originaltdtime.Month()); |
|
485 expiredtime.SetYear(originaltdtime.Year()); |
|
486 expireTime = expiredtime; |
|
487 |
|
488 if( expireTime < originalTime ) |
|
489 { |
|
490 expireTime += TTimeIntervalDays(1); |
|
491 } |
|
492 |
|
493 TTimeIntervalMicroSeconds remainTime( |
|
494 expireTime.MicroSecondsFrom( originalTime ) ); |
|
495 TInt64 tmp = ( remainTime.Int64() ) / KOneMinuteInMicrosecond; |
|
496 TInt minutes = I64INT(tmp); |
|
497 TInt hours(minutes / KOneHourInMinute); |
|
498 minutes -= hours * KOneHourInMinute; |
|
499 |
|
500 DisplayTimedQueryNoteL( minutes, hours ); |
|
501 |
|
502 MProfileEngineExtended* engine = iEngineHandler.Engine(); |
|
503 engine->SetActiveProfileTimedL( currentProfileId, expireTime ); |
|
504 } |
|
505 CleanupStack::PopAndDestroy( expiryTime ); |
|
506 } |
|
507 |
|
508 // ----------------------------------------------------------------------------- |
|
509 // CProfileMainView::Id |
|
510 // ----------------------------------------------------------------------------- |
|
511 // |
|
512 TUid CProfileMainView::Id() const |
|
513 { |
|
514 return KProfileAppMainViewId; |
|
515 } |
|
516 |
|
517 // ----------------------------------------------------------------------------- |
|
518 // CProfileMainView::HandleCommandL |
|
519 // ----------------------------------------------------------------------------- |
|
520 // |
|
521 void CProfileMainView::HandleCommandL( TInt aCommand ) |
|
522 { |
|
523 switch ( aCommand ) |
|
524 { |
|
525 case EProfileCmdActivate: |
|
526 { |
|
527 DoCmdActivateL(); |
|
528 break; |
|
529 } |
|
530 case EProfileCmdCreateNew: |
|
531 { |
|
532 DoCmdCreateNewL(); |
|
533 break; |
|
534 } |
|
535 case EProfileCmdDelete: |
|
536 { |
|
537 DoCmdDeleteL(); |
|
538 break; |
|
539 } |
|
540 case EProfileCmdContextSpecificOptionsMenu: |
|
541 case EAknSoftkeyContextOptions: |
|
542 { |
|
543 DoCmdContextSpecificOptionsMenuL(); |
|
544 break; |
|
545 } |
|
546 case EProfileCmdTimed: |
|
547 { |
|
548 DoCmdTimedL(); |
|
549 break; |
|
550 } |
|
551 default: |
|
552 { |
|
553 AppUi()->HandleCommandL( aCommand ); |
|
554 break; |
|
555 } |
|
556 } |
|
557 } |
|
558 |
|
559 // ----------------------------------------------------------------------------- |
|
560 // CProfileMainView::DoActivateL |
|
561 // ----------------------------------------------------------------------------- |
|
562 // |
|
563 void CProfileMainView::DoActivateL( |
|
564 const TVwsViewId& /* aPrevViewId */, |
|
565 TUid aCustomMessageId, |
|
566 const TDesC8& /* aCustomMessage */ ) |
|
567 { |
|
568 if( !iContainer ) |
|
569 { |
|
570 iContainer = CProfileMainContainer::NewL( |
|
571 iEngineHandler, iIndexHandler, *this ); |
|
572 iContainer->PopulateListBoxL( iTopItemIndex ); |
|
573 iNaviPaneContainer = |
|
574 CProfileNaviPaneContainer::NewL( *StatusPane(), iEngineHandler ); |
|
575 // Set the name of the active profile to navi pane |
|
576 iNaviPaneContainer->SetNaviPaneTextL(); |
|
577 AppUi()->AddToViewStackL( *this, iContainer ); |
|
578 iContainer->MakeVisible( ETrue ); |
|
579 } |
|
580 |
|
581 if( aCustomMessageId == KProfileAppMainViewId ) |
|
582 { |
|
583 DoCmdCreateNewL(); |
|
584 } |
|
585 |
|
586 CEikMenuBar* menuBar = MenuBar(); |
|
587 menuBar->SetContextMenuTitleResourceId( |
|
588 R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUBAR ); |
|
589 |
|
590 |
|
591 if ( iEikonEnv->StartedAsServerApp() ) |
|
592 { |
|
593 UpdateCbaL(R_PROFILE_MAIN_VIEW_CBA_2); |
|
594 } |
|
595 |
|
596 } |
|
597 |
|
598 // ----------------------------------------------------------------------------- |
|
599 // CProfileMainView::DoDeactivate |
|
600 // ----------------------------------------------------------------------------- |
|
601 // |
|
602 void CProfileMainView::DoDeactivate() |
|
603 { |
|
604 delete iNaviPaneContainer; |
|
605 iNaviPaneContainer = NULL; |
|
606 if( iContainer ) |
|
607 { |
|
608 iTopItemIndex = iContainer->TopItemIndex(); |
|
609 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
610 delete iContainer; |
|
611 iContainer = NULL; |
|
612 } |
|
613 } |
|
614 |
|
615 // ----------------------------------------------------------------------------- |
|
616 // CProfileMainView::DynInitMenuPaneL |
|
617 // ----------------------------------------------------------------------------- |
|
618 // |
|
619 void CProfileMainView::DynInitMenuPaneL( |
|
620 TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
621 { |
|
622 if( !iContainer || |
|
623 ( (aResourceId != R_PROFILE_MAIN_VIEW_OPTIONS_MENUPANE) && |
|
624 (aResourceId != R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUPANE) |
|
625 ) ) |
|
626 { |
|
627 return; |
|
628 } |
|
629 |
|
630 // ID of the currently focused profile |
|
631 TInt currentProfileId( |
|
632 iEngineHandler.IdForIndex( iIndexHandler.CurrentProfileIndex() ) ); |
|
633 TInt activeProfileId( iEngineHandler.Engine()->ActiveProfileId() ); |
|
634 |
|
635 // "Timed" item is in both menus: |
|
636 if( aResourceId == R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUPANE && (( !iLocalFeatures->IsFeatureSupported( KProEngFeatureIdTimedProfiles ) ) |
|
637 || ( currentProfileId == EProfileOffLineId ) || |
|
638 ( ( activeProfileId == currentProfileId ) && |
|
639 !iEngineHandler.Engine()->IsActiveProfileTimedL() ) )) |
|
640 { |
|
641 // Timed profiles is not supported. Hide Timed option from |
|
642 // Options menu |
|
643 aMenuPane->SetItemDimmed( EProfileCmdTimed, ETrue ); |
|
644 } |
|
645 if(aResourceId == R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUPANE && ( FeatureManager::FeatureSupported(KFeatureIdDynamicProfiles) ) && |
|
646 iEngineHandler.Engine()->IsDefaultProfile( currentProfileId ) ) |
|
647 { |
|
648 // A default profile is focused. Hide Delete from Options menu |
|
649 aMenuPane->SetItemDimmed( EProfileCmdDelete, ETrue ); |
|
650 } |
|
651 |
|
652 if( aResourceId == R_PROFILE_MAIN_VIEW_OPTIONS_MENUPANE ) |
|
653 { |
|
654 if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
655 { |
|
656 // Help is not supported. Hide Help from Options menu |
|
657 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
658 } |
|
659 // Check that dynamic profiles are supported |
|
660 // before trying to hide Delete from Options menu. |
|
661 /* if( ( 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 |
|
669 } |
|
670 |
|
671 // ----------------------------------------------------------------------------- |
|
672 // CProfileMainView::HandleActiveProfileEventL |
|
673 // ----------------------------------------------------------------------------- |
|
674 // |
|
675 void CProfileMainView::HandleActiveProfileEventL( |
|
676 TProfileEvent /* aProfileEvent */, TInt /* aProfileId */ ) |
|
677 { |
|
678 if( iNaviPaneContainer ) |
|
679 { |
|
680 // Active profile has changed. Change active profile name in navi pane. |
|
681 iNaviPaneContainer->SetNaviPaneTextL(); |
|
682 } |
|
683 } |
|
684 |
|
685 // ----------------------------------------------------------------------------- |
|
686 // CProfileMainView::UpdateClientRect |
|
687 // ----------------------------------------------------------------------------- |
|
688 // |
|
689 void CProfileMainView::UpdateClientRect() |
|
690 { |
|
691 iContainer->SetRect( ClientRect() ); |
|
692 } |
|
693 |
|
694 // ----------------------------------------------------------------------------- |
|
695 // CProfileMainView::View |
|
696 // ----------------------------------------------------------------------------- |
|
697 // |
|
698 CAknView& CProfileMainView::View() |
|
699 { |
|
700 return *this; |
|
701 } |
|
702 |
|
703 |
|
704 // ----------------------------------------------------------------------------- |
|
705 // CProfileMainView::UpdateCbaL |
|
706 // |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 void CProfileMainView::UpdateCbaL(TInt aResourceId) |
|
710 { |
|
711 CEikButtonGroupContainer* cba = Cba(); |
|
712 cba->SetCommandSetL(aResourceId); |
|
713 cba->DrawDeferred(); |
|
714 } |
|
715 |
|
716 |
|
717 // End of File |
|