author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:19:36 +0300 | |
branch | RCL_3 |
changeset 24 | ea11b8c1e6a4 |
parent 23 | cd54903d48da |
child 27 | d0e1a4b40897 |
permissions | -rw-r--r-- |
23 | 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 ); |
|
24
ea11b8c1e6a4
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
475 |
CleanupStack::PopAndDestroy( expiryTime ); |
23 | 476 |
return; |
477 |
} |
|
478 |
||
479 |
TTime originalTime; |
|
480 |
originalTime.HomeTime(); |
|
481 |
||
482 |
TDateTime expiredtime = expireTime.DateTime(); |
|
483 |
TDateTime originaltdtime = originalTime.DateTime(); |
|
484 |
expiredtime.SetDay(originaltdtime.Day()); |
|
485 |
expiredtime.SetMonth(originaltdtime.Month()); |
|
486 |
expiredtime.SetYear(originaltdtime.Year()); |
|
487 |
expireTime = expiredtime; |
|
488 |
||
489 |
if( expireTime < originalTime ) |
|
490 |
{ |
|
491 |
expireTime += TTimeIntervalDays(1); |
|
492 |
} |
|
493 |
||
494 |
TTimeIntervalMicroSeconds remainTime( |
|
495 |
expireTime.MicroSecondsFrom( originalTime ) ); |
|
496 |
TInt64 tmp = ( remainTime.Int64() ) / KOneMinuteInMicrosecond; |
|
497 |
TInt minutes = I64INT(tmp); |
|
498 |
TInt hours(minutes / KOneHourInMinute); |
|
499 |
minutes -= hours * KOneHourInMinute; |
|
500 |
||
501 |
DisplayTimedQueryNoteL( minutes, hours ); |
|
502 |
||
503 |
MProfileEngineExtended* engine = iEngineHandler.Engine(); |
|
504 |
engine->SetActiveProfileTimedL( currentProfileId, expireTime ); |
|
505 |
} |
|
506 |
CleanupStack::PopAndDestroy( expiryTime ); |
|
507 |
} |
|
508 |
||
509 |
// ----------------------------------------------------------------------------- |
|
510 |
// CProfileMainView::Id |
|
511 |
// ----------------------------------------------------------------------------- |
|
512 |
// |
|
513 |
TUid CProfileMainView::Id() const |
|
514 |
{ |
|
515 |
return KProfileAppMainViewId; |
|
516 |
} |
|
517 |
||
518 |
// ----------------------------------------------------------------------------- |
|
519 |
// CProfileMainView::HandleCommandL |
|
520 |
// ----------------------------------------------------------------------------- |
|
521 |
// |
|
522 |
void CProfileMainView::HandleCommandL( TInt aCommand ) |
|
523 |
{ |
|
524 |
switch ( aCommand ) |
|
525 |
{ |
|
526 |
case EProfileCmdActivate: |
|
527 |
{ |
|
528 |
DoCmdActivateL(); |
|
529 |
break; |
|
530 |
} |
|
531 |
case EProfileCmdCreateNew: |
|
532 |
{ |
|
533 |
DoCmdCreateNewL(); |
|
534 |
break; |
|
535 |
} |
|
536 |
case EProfileCmdDelete: |
|
537 |
{ |
|
538 |
DoCmdDeleteL(); |
|
539 |
break; |
|
540 |
} |
|
541 |
case EProfileCmdContextSpecificOptionsMenu: |
|
542 |
case EAknSoftkeyContextOptions: |
|
543 |
{ |
|
544 |
DoCmdContextSpecificOptionsMenuL(); |
|
545 |
break; |
|
546 |
} |
|
547 |
case EProfileCmdTimed: |
|
548 |
{ |
|
549 |
DoCmdTimedL(); |
|
550 |
break; |
|
551 |
} |
|
552 |
default: |
|
553 |
{ |
|
554 |
AppUi()->HandleCommandL( aCommand ); |
|
555 |
break; |
|
556 |
} |
|
557 |
} |
|
558 |
} |
|
559 |
||
560 |
// ----------------------------------------------------------------------------- |
|
561 |
// CProfileMainView::DoActivateL |
|
562 |
// ----------------------------------------------------------------------------- |
|
563 |
// |
|
564 |
void CProfileMainView::DoActivateL( |
|
565 |
const TVwsViewId& /* aPrevViewId */, |
|
566 |
TUid aCustomMessageId, |
|
567 |
const TDesC8& /* aCustomMessage */ ) |
|
568 |
{ |
|
569 |
if( !iContainer ) |
|
570 |
{ |
|
571 |
iContainer = CProfileMainContainer::NewL( |
|
572 |
iEngineHandler, iIndexHandler, *this ); |
|
573 |
iContainer->PopulateListBoxL( iTopItemIndex ); |
|
574 |
iNaviPaneContainer = |
|
575 |
CProfileNaviPaneContainer::NewL( *StatusPane(), iEngineHandler ); |
|
576 |
// Set the name of the active profile to navi pane |
|
577 |
iNaviPaneContainer->SetNaviPaneTextL(); |
|
578 |
AppUi()->AddToViewStackL( *this, iContainer ); |
|
579 |
iContainer->MakeVisible( ETrue ); |
|
580 |
} |
|
581 |
||
582 |
if( aCustomMessageId == KProfileAppMainViewId ) |
|
583 |
{ |
|
584 |
DoCmdCreateNewL(); |
|
585 |
} |
|
586 |
||
587 |
CEikMenuBar* menuBar = MenuBar(); |
|
588 |
menuBar->SetContextMenuTitleResourceId( |
|
589 |
R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUBAR ); |
|
590 |
||
591 |
||
592 |
if ( iEikonEnv->StartedAsServerApp() ) |
|
593 |
{ |
|
594 |
UpdateCbaL(R_PROFILE_MAIN_VIEW_CBA_2); |
|
595 |
} |
|
596 |
||
597 |
} |
|
598 |
||
599 |
// ----------------------------------------------------------------------------- |
|
600 |
// CProfileMainView::DoDeactivate |
|
601 |
// ----------------------------------------------------------------------------- |
|
602 |
// |
|
603 |
void CProfileMainView::DoDeactivate() |
|
604 |
{ |
|
605 |
delete iNaviPaneContainer; |
|
606 |
iNaviPaneContainer = NULL; |
|
607 |
if( iContainer ) |
|
608 |
{ |
|
609 |
iTopItemIndex = iContainer->TopItemIndex(); |
|
610 |
AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
611 |
delete iContainer; |
|
612 |
iContainer = NULL; |
|
613 |
} |
|
614 |
} |
|
615 |
||
616 |
// ----------------------------------------------------------------------------- |
|
617 |
// CProfileMainView::DynInitMenuPaneL |
|
618 |
// ----------------------------------------------------------------------------- |
|
619 |
// |
|
620 |
void CProfileMainView::DynInitMenuPaneL( |
|
621 |
TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
622 |
{ |
|
623 |
if( !iContainer || |
|
624 |
( (aResourceId != R_PROFILE_MAIN_VIEW_OPTIONS_MENUPANE) && |
|
625 |
(aResourceId != R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUPANE) |
|
626 |
) ) |
|
627 |
{ |
|
628 |
return; |
|
629 |
} |
|
630 |
||
631 |
// ID of the currently focused profile |
|
632 |
TInt currentProfileId( |
|
633 |
iEngineHandler.IdForIndex( iIndexHandler.CurrentProfileIndex() ) ); |
|
634 |
TInt activeProfileId( iEngineHandler.Engine()->ActiveProfileId() ); |
|
635 |
||
636 |
// "Timed" item is in both menus: |
|
637 |
if( aResourceId == R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUPANE && (( !iLocalFeatures->IsFeatureSupported( KProEngFeatureIdTimedProfiles ) ) |
|
638 |
|| ( currentProfileId == EProfileOffLineId ) || |
|
639 |
( ( activeProfileId == currentProfileId ) && |
|
640 |
!iEngineHandler.Engine()->IsActiveProfileTimedL() ) )) |
|
641 |
{ |
|
642 |
// Timed profiles is not supported. Hide Timed option from |
|
643 |
// Options menu |
|
644 |
aMenuPane->SetItemDimmed( EProfileCmdTimed, ETrue ); |
|
645 |
} |
|
646 |
if(aResourceId == R_PROFILE_MAIN_VIEW_CONTEXT_SPECIFIC_OPTIONS_MENUPANE && ( FeatureManager::FeatureSupported(KFeatureIdDynamicProfiles) ) && |
|
647 |
iEngineHandler.Engine()->IsDefaultProfile( currentProfileId ) ) |
|
648 |
{ |
|
649 |
// A default profile is focused. Hide Delete from Options menu |
|
650 |
aMenuPane->SetItemDimmed( EProfileCmdDelete, ETrue ); |
|
651 |
} |
|
652 |
||
653 |
if( aResourceId == R_PROFILE_MAIN_VIEW_OPTIONS_MENUPANE ) |
|
654 |
{ |
|
655 |
if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
656 |
{ |
|
657 |
// Help is not supported. Hide Help from Options menu |
|
658 |
aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
659 |
} |
|
660 |
// Check that dynamic profiles are supported |
|
661 |
// before trying to hide Delete from Options menu. |
|
662 |
/* if( ( FeatureManager::FeatureSupported(KFeatureIdDynamicProfiles) ) && |
|
663 |
iEngineHandler.Engine()->IsDefaultProfile( currentProfileId ) ) |
|
664 |
{ |
|
665 |
// A default profile is focused. Hide Delete from Options menu |
|
666 |
aMenuPane->SetItemDimmed( EProfileCmdDelete, ETrue ); |
|
667 |
}*/ |
|
668 |
} |
|
669 |
||
670 |
} |
|
671 |
||
672 |
// ----------------------------------------------------------------------------- |
|
673 |
// CProfileMainView::HandleActiveProfileEventL |
|
674 |
// ----------------------------------------------------------------------------- |
|
675 |
// |
|
676 |
void CProfileMainView::HandleActiveProfileEventL( |
|
677 |
TProfileEvent /* aProfileEvent */, TInt /* aProfileId */ ) |
|
678 |
{ |
|
679 |
if( iNaviPaneContainer ) |
|
680 |
{ |
|
681 |
// Active profile has changed. Change active profile name in navi pane. |
|
682 |
iNaviPaneContainer->SetNaviPaneTextL(); |
|
683 |
} |
|
684 |
} |
|
685 |
||
686 |
// ----------------------------------------------------------------------------- |
|
687 |
// CProfileMainView::UpdateClientRect |
|
688 |
// ----------------------------------------------------------------------------- |
|
689 |
// |
|
690 |
void CProfileMainView::UpdateClientRect() |
|
691 |
{ |
|
692 |
iContainer->SetRect( ClientRect() ); |
|
693 |
} |
|
694 |
||
695 |
// ----------------------------------------------------------------------------- |
|
696 |
// CProfileMainView::View |
|
697 |
// ----------------------------------------------------------------------------- |
|
698 |
// |
|
699 |
CAknView& CProfileMainView::View() |
|
700 |
{ |
|
701 |
return *this; |
|
702 |
} |
|
703 |
||
704 |
||
705 |
// ----------------------------------------------------------------------------- |
|
706 |
// CProfileMainView::UpdateCbaL |
|
707 |
// |
|
708 |
// ----------------------------------------------------------------------------- |
|
709 |
// |
|
710 |
void CProfileMainView::UpdateCbaL(TInt aResourceId) |
|
711 |
{ |
|
712 |
CEikButtonGroupContainer* cba = Cba(); |
|
713 |
cba->SetCommandSetL(aResourceId); |
|
714 |
cba->DrawDeferred(); |
|
715 |
} |
|
716 |
||
717 |
||
718 |
// End of File |