|
1 /* |
|
2 * Copyright (c) 2005-2010 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: Methods for Device Manager Application UI |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <apgwgnam.h> |
|
19 #include <gsfwviewuids.h> |
|
20 #include <aknnotewrappers.h> |
|
21 #include <aknnavide.h> |
|
22 #include <StringLoader.h> |
|
23 #include <textresolver.h> |
|
24 #include <DevManInternalCRKeys.h> //SAN support |
|
25 #include <centralrepository.h> |
|
26 #include <barsread.h> |
|
27 #include <e32property.h> |
|
28 #include <nsmldmsync.rsg> |
|
29 #include "nsmldmsyncinternalpskeys.h" |
|
30 #include "NSmlDMSyncAppUi.h" |
|
31 #include "NSmlDMSyncApp.h" |
|
32 #include "NSmlDMSyncAppEngine.h" |
|
33 #include "NSmlDMFotaModel.h" |
|
34 #include "NSmlDMFotaView.h" |
|
35 #include "NSmlDMProfilesView.h" |
|
36 #include "NSmlDMSyncDocument.h" |
|
37 #include "NSmlDMDlgProfileView.h" |
|
38 #include "NSmlDMSyncDebug.h" |
|
39 #include "NSmlDMSyncDialog.h" |
|
40 #include "NSmlDMSyncProfile.h" |
|
41 #include "NSmlDMSyncPrivateCRKeys.h" |
|
42 #include <featmgr.h> |
|
43 |
|
44 #include <hlplch.h> |
|
45 #include <csxhelp/dm.hlp.hrh> |
|
46 |
|
47 #include <aknmessagequerydialog.h> // For CAknMessageQueryDialog |
|
48 // For KCalenHoursInDay = 24 and other time-related constants. |
|
49 #include <calenconstants.h> |
|
50 |
|
51 // Array granuality for displaying R_QTN_FOTA_NOTE_TIME_RESTRICTION note. |
|
52 const TInt KNSmlDMFotaNoteArrayGranuality = 3; |
|
53 |
|
54 |
|
55 // ============================ MEMBER FUNCTIONS ============================== |
|
56 // |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CNSmlDMSyncAppUi::ConstructL |
|
60 // Symbian 2nd phase constructor can leave. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CNSmlDMSyncAppUi::ConstructL() |
|
64 { |
|
65 FLOG( "[OMADM] CNSmlDMSyncAppUi::ConstructL()" ); |
|
66 |
|
67 BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible); |
|
68 iSyncDocument = (CNSmlDMSyncDocument*) iDocument; |
|
69 iSyncAppEngine = iSyncDocument->AppEngine(); |
|
70 iSyncAppEngine->RequestSyncStatus( this ); |
|
71 iFotaModel = CNSmlDMFotaModel::NewL( iSyncDocument ); |
|
72 iProfilesView = new (ELeave) CNSmlDMProfilesView(); |
|
73 |
|
74 iViewTitle = 0; |
|
75 |
|
76 iProfilesView->ConstructL(); // this ); |
|
77 AddViewL( iProfilesView ); // Transfer ownership to CAknViewAppUi |
|
78 |
|
79 TInt configFlags( 0 ); |
|
80 CRepository* centrep = NULL; |
|
81 centrep = CRepository::NewL( KCRUidNSmlDMSyncApp ); |
|
82 centrep->Get( KNSmlDMFotaConfigurationKey, configFlags ); |
|
83 delete centrep; |
|
84 |
|
85 if ( configFlags & KNSmlDMFotaEnableFotaViewFlag ) |
|
86 { |
|
87 iNaviDecorator = 0; |
|
88 // Show tabs for main views from resources |
|
89 CEikStatusPane* sp = StatusPane(); |
|
90 |
|
91 // Fetch pointer to the default navi pane control |
|
92 iNaviPane = ( CAknNavigationControlContainer* ) |
|
93 sp->ControlL( TUid::Uid(EEikStatusPaneUidNavi) ); |
|
94 |
|
95 |
|
96 CNSmlDMFotaView* fotaView = new (ELeave) CNSmlDMFotaView; |
|
97 iMainView = fotaView; |
|
98 CleanupStack::PushL( fotaView ); |
|
99 fotaView->ConstructL(); |
|
100 AddViewL( fotaView ); // Transfer ownership to CAknViewAppUi |
|
101 CleanupStack::Pop( fotaView ); |
|
102 |
|
103 ActivateLocalViewL( fotaView->Id() ); |
|
104 } |
|
105 else |
|
106 { |
|
107 ActivateLocalViewL( iProfilesView->Id() ); |
|
108 } |
|
109 |
|
110 |
|
111 iDialogUp = 0; |
|
112 iDestroyed = 1; |
|
113 |
|
114 FLOG( "[OMADM] CNSmlDMSyncAppUi::ConstructL() completed" ); |
|
115 } |
|
116 |
|
117 // ------------------------------------------------------------------------------ |
|
118 // Destructor |
|
119 // ------------------------------------------------------------------------------ |
|
120 |
|
121 CNSmlDMSyncAppUi::~CNSmlDMSyncAppUi() |
|
122 { |
|
123 FLOG( "[OMADM] ~CNSmlDMSyncAppUi()" ); |
|
124 |
|
125 delete iFotaModel; |
|
126 delete iNaviDecorator; |
|
127 if ( iDestroyed == 0 ) |
|
128 { |
|
129 delete iAppView; |
|
130 } |
|
131 } |
|
132 |
|
133 // ------------------------------------------------------------------------------ |
|
134 // CNSmlDMSyncAppUi::TabChangedL |
|
135 // ------------------------------------------------------------------------------ |
|
136 // |
|
137 |
|
138 // ------------------------------------------------------------------------------ |
|
139 // CNSmlDMSyncAppUi::DynInitMenuPaneL |
|
140 // ------------------------------------------------------------------------------ |
|
141 // |
|
142 void CNSmlDMSyncAppUi::DynInitMenuPaneL( TInt /*aResourceId*/, |
|
143 CEikMenuPane* /*aMenuPane*/ ) |
|
144 { |
|
145 FLOG( "[OMADM] CNSmlDMSyncAppUi::DynInitMenuPaneL:" ); |
|
146 } |
|
147 |
|
148 // ------------------------------------------------------------------------------ |
|
149 // CNSmlDMSyncAppUi::HandleKeyEventL |
|
150 // ------------------------------------------------------------------------------ |
|
151 // |
|
152 TKeyResponse CNSmlDMSyncAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent, |
|
153 TEventCode aType ) |
|
154 { |
|
155 FTRACE( FPrint( |
|
156 _L("[OMADM] CNSmlDMSyncAppUi::HandleKeyEventL: = 0x%x"),aKeyEvent.iCode ) ); |
|
157 //EEventKeyDown ends settdialog |
|
158 if ( iDialogUp != 0 ) |
|
159 { |
|
160 return EKeyWasConsumed; |
|
161 } |
|
162 if ( aType == EEventKey ) |
|
163 { |
|
164 switch ( aKeyEvent.iCode ) |
|
165 { |
|
166 case EKeyUpArrow: |
|
167 { |
|
168 if ( !Synchronise() ) |
|
169 { |
|
170 HandleUpScrollL(); |
|
171 } |
|
172 } |
|
173 break; |
|
174 |
|
175 case EKeyDownArrow: |
|
176 { |
|
177 if ( !Synchronise() ) |
|
178 { |
|
179 HandleDownScrollL(); |
|
180 } |
|
181 } |
|
182 break; |
|
183 |
|
184 case EKeyPhoneEnd: |
|
185 { |
|
186 FLOG( "End key pressed" ); |
|
187 if ( iMainView ) |
|
188 { |
|
189 ExitCallL(); |
|
190 } |
|
191 } |
|
192 case EKeyEscape: |
|
193 { |
|
194 if ( Synchronise() ) |
|
195 { |
|
196 iSyncAppEngine->CancelSyncL(); |
|
197 } |
|
198 } |
|
199 break; |
|
200 default: |
|
201 |
|
202 return EKeyWasNotConsumed; |
|
203 } |
|
204 } |
|
205 FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleKeyEventL() completed" ); |
|
206 return EKeyWasNotConsumed; |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CNSmlDMSyncAppUi::HandleCommandL |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void CNSmlDMSyncAppUi::HandleCommandL( TInt aCommand ) |
|
214 { |
|
215 FTRACE( FPrint( |
|
216 _L("[OMADM] CNSmlDMSyncAppUi::HandleCommandL() command = 0x%x"), |
|
217 aCommand ) ); |
|
218 |
|
219 iSyncDocument->DisableDbNotifications( ETrue ); |
|
220 iBusy = ETrue; |
|
221 |
|
222 switch ( aCommand ) |
|
223 { |
|
224 case EAknCmdHelp: |
|
225 { |
|
226 |
|
227 if (FeatureManager::FeatureSupported( KFeatureIdHelp )) |
|
228 { |
|
229 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), AppHelpContextL()); |
|
230 iBusy = EFalse; |
|
231 } |
|
232 |
|
233 } |
|
234 break; |
|
235 |
|
236 case EAknSoftkeyExit: //For independent .exe app launch from file browser |
|
237 case EAknCmdExit: |
|
238 case EEikCmdExit: // quit application |
|
239 { |
|
240 TInt value=-1; |
|
241 TInt r1=RProperty::Set(KPSUidNSmlDMSyncApp,KNSmlDMSyncUiLaunchKey,value); |
|
242 |
|
243 TBool val (EFalse); |
|
244 TInt err = RProperty::Get(KFotaServerAppUid, KFotaDLStatus, val ); |
|
245 if(val == 1) |
|
246 { |
|
247 TApaTaskList taskList(CEikonEnv::Static()->WsSession()); |
|
248 TApaTask task1(taskList.FindApp( KFotaServerAppUid)); |
|
249 if(task1.Exists()) |
|
250 task1.EndTask(); |
|
251 } |
|
252 Exit(); |
|
253 } |
|
254 break; |
|
255 |
|
256 case ENSmlMenuCmdNewProfile: // create new profile |
|
257 { |
|
258 if (TUtil::SettingEnforcementState()) |
|
259 { |
|
260 ShowResourceErrorNoteL( R_QTN_DM_INFO_NOTE_LOCKED_SETTING ); |
|
261 break; |
|
262 } |
|
263 HandleCommandNewProfileL(); |
|
264 } |
|
265 break; |
|
266 |
|
267 case ENSmlMenuCmdEraseProfile: // delete profile |
|
268 { |
|
269 if (TUtil::SettingEnforcementState()|| iSyncDocument->ProfileItem()->iProfileLocked) |
|
270 { |
|
271 ShowResourceErrorNoteL( R_QTN_DM_INFO_NOTE_LOCKED_SETTING ); |
|
272 break; |
|
273 } |
|
274 HandleCommandEraseProfileL(); |
|
275 } |
|
276 break; |
|
277 |
|
278 case ENSmlMenuCmdOpenLog: // open syncronisation log view |
|
279 { |
|
280 CNSmlDMSyncDialog::ShowDialogL( |
|
281 iSyncDocument->ProfileItem()->iProfileId, |
|
282 iSyncAppEngine->Session() ); |
|
283 iBusy = EFalse; |
|
284 } |
|
285 break; |
|
286 |
|
287 case ENSmlMenuCmdOpenSettings: // open profile for editing |
|
288 { |
|
289 if (TUtil::SettingEnforcementState()) |
|
290 { |
|
291 ShowResourceErrorNoteL( R_QTN_DM_INFO_NOTE_LOCKED_SETTING ); |
|
292 break; |
|
293 } |
|
294 ShowEditProfileDialogL( ESmlEditProfile ); |
|
295 } |
|
296 break; |
|
297 |
|
298 case ENSmlMenuCmdStartSync: // start synchronisation |
|
299 { |
|
300 if(TUtil::ShowNativeDialogL(EPrivacyPolicy)==KErrNone) |
|
301 { |
|
302 if ( ShowConfirmationNoteL( R_QTN_SML_CONF_STARTQUERY ) ) |
|
303 { |
|
304 StartSyncL(); |
|
305 } |
|
306 } |
|
307 } |
|
308 break; |
|
309 |
|
310 default: |
|
311 break; |
|
312 } |
|
313 iSyncDocument->DisableDbNotifications( EFalse ); |
|
314 FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleCommandL() completed" ); |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CNSmlDMSyncAppUi::HandleUpScrollL |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 void CNSmlDMSyncAppUi::HandleUpScrollL() |
|
322 { |
|
323 FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleUpScrollL:" ); |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CNSmlDMSyncAppUi::HandleDownScrollL |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void CNSmlDMSyncAppUi::HandleDownScrollL() |
|
331 { |
|
332 FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleDownScrollL:" ); |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // CNSmlDMSyncAppUi::ShowEditProfileDialogL |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 void CNSmlDMSyncAppUi::ShowEditProfileDialogL( TNSmlEditMode aMode, |
|
340 TInt /*aStartUp*/) |
|
341 { |
|
342 FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowEditProfileDialogL:" ); |
|
343 |
|
344 TInt profileId( KErrNotFound ); |
|
345 if ( aMode != ESmlNewProfile ) |
|
346 { |
|
347 profileId = iSyncDocument->ProfileItem()->iProfileId; |
|
348 } |
|
349 |
|
350 iAppView = CNSmlDMDlgProfileView::NewL( |
|
351 iSyncDocument, |
|
352 aMode, |
|
353 profileId ); |
|
354 |
|
355 TRAPD( error, iAppView->ExecuteLD( R_NSML_SETTING_DIALOG ) ); |
|
356 if ( error != KErrNone ) |
|
357 { |
|
358 ShowErrorNoteL( error ); |
|
359 } |
|
360 else |
|
361 { |
|
362 iBusy = ETrue; |
|
363 iActiveView = CNSmlDMSyncAppUi::SettingsView; |
|
364 AddToStackL( iAppView ); |
|
365 } |
|
366 } |
|
367 |
|
368 // ----------------------------------------------------------------------------- |
|
369 // CNSmlDMSyncAppUi::ProcessCommandParametersL |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 TBool CNSmlDMSyncAppUi::ProcessCommandParametersL( TApaCommand /*aCommand*/, |
|
373 TFileName& aDocumentName, |
|
374 const TDesC8& /*aTail*/ ) |
|
375 { |
|
376 FLOG( "[OMADM] CNSmlDMSyncAppUi::ProcessCommandParametersL:" ); |
|
377 |
|
378 // This is to prevent dummy document creation |
|
379 aDocumentName.Zero(); |
|
380 return EFalse; |
|
381 } |
|
382 |
|
383 // ----------------------------------------------------------------------------- |
|
384 // CNSmlDMSyncAppUi::StartSyncL |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 void CNSmlDMSyncAppUi::StartSyncL( |
|
388 const TInt aProfileId, // = KErrNotFound |
|
389 const TBool aUseFotaProgressNote ) // = EFalse |
|
390 { |
|
391 FTRACE( FPrint( |
|
392 _L("[OMADM] CNSmlDMSyncAppUi::StartSyncL() aProfileId = %d"), |
|
393 aProfileId ) ); |
|
394 |
|
395 if ( aProfileId == KErrNotFound ) |
|
396 { |
|
397 iConfedProfileId = iSyncDocument->ProfileItem()->iProfileId; |
|
398 } |
|
399 else |
|
400 { |
|
401 iConfedProfileId = aProfileId; |
|
402 } |
|
403 |
|
404 FTRACE( FPrint( |
|
405 _L("[OMADM] CNSmlDMSyncAppUi::StartSyncL() used profileId = %d"), |
|
406 iConfedProfileId ) ); |
|
407 |
|
408 CNSmlDMSyncProfile* profile = |
|
409 iSyncAppEngine->OpenProfileL( iConfedProfileId, ESmlOpenReadWrite ); |
|
410 |
|
411 TInt connectionBearer = profile->BearerType(); |
|
412 |
|
413 TBuf<KNSmlMaxProfileNameLength> serverName; |
|
414 profile->GetName( serverName ); |
|
415 |
|
416 if ( profile->SASyncState() == ESASyncStateDisable ) |
|
417 { |
|
418 if ( ShowConfirmationNoteL( R_QTN_SML_CONF_ACTIVEQUERY ) ) |
|
419 { |
|
420 profile->SetSASyncStateL( ESASyncStateEnable ); |
|
421 profile->SaveL(); |
|
422 } |
|
423 else |
|
424 { |
|
425 iSyncAppEngine->CloseProfile(); |
|
426 return; |
|
427 } |
|
428 } |
|
429 |
|
430 // If Fota check limitation feature is enabled, users are allowed to check |
|
431 // updates only once within the limitation set in the CenRep |
|
432 // (24 hours by default). |
|
433 if ( FeatureManager::FeatureSupported( KFeatureIdFfFotaCheckLimitation ) |
|
434 && !IsUpdateAllowedL( *profile ) ) |
|
435 { |
|
436 FLOG( "[OMADM] CNSmlDMSyncAppUi::StartSyncL Checking update is limited.\ |
|
437 Can not proceed sync." ); |
|
438 iSyncAppEngine->CloseProfile(); |
|
439 return; |
|
440 } |
|
441 |
|
442 iSyncAppEngine->CloseProfile(); |
|
443 TRAPD( error, iSyncAppEngine->SynchronizeL( serverName, |
|
444 iConfedProfileId, |
|
445 connectionBearer, |
|
446 aUseFotaProgressNote ) ); |
|
447 |
|
448 if (error == KErrNone) |
|
449 { |
|
450 iActiveView = CNSmlDMSyncAppUi::ProgressView; |
|
451 } |
|
452 else |
|
453 { |
|
454 ShowErrorNoteL( error ); |
|
455 iActiveView = CNSmlDMSyncAppUi::MainView; |
|
456 } |
|
457 |
|
458 FTRACE( FPrint( |
|
459 _L("[OMADM] CNSmlDMSyncAppUi::StartSyncL() completed, error = %d"), |
|
460 error ) ); |
|
461 } |
|
462 |
|
463 // ----------------------------------------------------------------------------- |
|
464 // CNSmlDMSyncAppUi::ChangeViewL |
|
465 // ----------------------------------------------------------------------------- |
|
466 // |
|
467 void CNSmlDMSyncAppUi::ChangeViewL(TBool aRefresh) |
|
468 { |
|
469 FLOG( "[OMADM] CNSmlDMSyncAppUi::ChangeViewL:" ); |
|
470 |
|
471 iActiveView = CNSmlDMSyncAppUi::MainView; |
|
472 if ( aRefresh != EFalse ) |
|
473 { |
|
474 iSyncDocument->RefreshProfileListL(); |
|
475 iProfilesView->RefreshL(); |
|
476 } |
|
477 CAknTitlePane* titlePane = |
|
478 (CAknTitlePane*) StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ); |
|
479 HBufC* titleText = NULL; |
|
480 |
|
481 if ( iViewTitle ) |
|
482 { |
|
483 titleText = iEikonEnv->AllocReadResourceLC( R_SML_APP_TITLE ); |
|
484 iViewTitle = 0; |
|
485 } |
|
486 else |
|
487 { |
|
488 titleText = iEikonEnv->AllocReadResourceLC( R_SML_PROFILES_TITLE ); |
|
489 } |
|
490 |
|
491 titlePane->SetTextL( titleText->Des() ); |
|
492 CleanupStack::PopAndDestroy(titleText); |
|
493 iBusy = EFalse; |
|
494 |
|
495 FLOG( "[OMADM] CNSmlDMSyncAppUi::ChangeViewL() completed" ); |
|
496 } |
|
497 |
|
498 // ----------------------------------------------------------------------------- |
|
499 // CNSmlDMSyncAppUi::ShowErrorNoteL |
|
500 // ----------------------------------------------------------------------------- |
|
501 // |
|
502 void CNSmlDMSyncAppUi::ShowErrorNoteL( TInt aError ) const |
|
503 { |
|
504 FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowErrorNoteL:" ); |
|
505 |
|
506 TBuf<KNSmlMaxTextLength256> errMsg; |
|
507 SetErrorMessageL( aError, errMsg ); |
|
508 CAknInformationNote* queryDialog = new (ELeave) CAknInformationNote; |
|
509 queryDialog->ExecuteLD( errMsg ); |
|
510 FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowErrorNoteL() completed" ); |
|
511 } |
|
512 |
|
513 // ----------------------------------------------------------------------------- |
|
514 // CNSmlDMSyncAppUi::SetErrorMessageL |
|
515 // ----------------------------------------------------------------------------- |
|
516 // |
|
517 void CNSmlDMSyncAppUi::SetErrorMessageL( TInt aError, TDes& aMsg ) const |
|
518 { |
|
519 FLOG( "[OMADM] CNSmlDMSyncAppUi::SetErrorMessageL:" ); |
|
520 CTextResolver* textResolver = CTextResolver::NewLC(); |
|
521 |
|
522 aMsg.Append( textResolver->ResolveErrorString( aError, |
|
523 CTextResolver::ECtxNoCtx ) ); |
|
524 |
|
525 CleanupStack::PopAndDestroy( textResolver ); |
|
526 |
|
527 HBufC* appTitle = iEikonEnv->AllocReadResourceLC( R_SML_APP_TITLE ); |
|
528 aMsg.Insert( 0, appTitle->Des() ); |
|
529 CleanupStack::PopAndDestroy( appTitle ); |
|
530 FTRACE( FPrint( |
|
531 _L("[OMADM] CNSmlDMSyncAppUi::SetErrorMessageL() completed, aError = %d, aMsg ="), |
|
532 aError ) ); |
|
533 FTRACE( FPrint( |
|
534 _L("[OMADM] \"%S\""), |
|
535 &aMsg ) ); |
|
536 } |
|
537 |
|
538 // ----------------------------------------------------------------------------- |
|
539 // CNSmlDMSyncAppUi::HelpContextL |
|
540 // ----------------------------------------------------------------------------- |
|
541 // |
|
542 |
|
543 CArrayFix<TCoeHelpContext>* CNSmlDMSyncAppUi::HelpContextL() const |
|
544 { |
|
545 CArrayFixFlat<TCoeHelpContext>* array = |
|
546 new (ELeave) CArrayFixFlat<TCoeHelpContext>(1); |
|
547 array->AppendL( TCoeHelpContext( KUidSmlSyncApp, KDM_HLP_MAIN_VIEW ) ); |
|
548 array->AppendL( TCoeHelpContext( KUidSmlSyncApp, KFOTA_HLP_SETTINGS ) ); |
|
549 array->AppendL( TCoeHelpContext( KUidSmlSyncApp, KDM_HLP_SERVERS_VIEW ) ); |
|
550 array->AppendL( TCoeHelpContext( KUidSmlSyncApp, KDM_HLP_SETTINGS ) ); |
|
551 return array; |
|
552 } |
|
553 |
|
554 |
|
555 // ----------------------------------------------------------------------------- |
|
556 // CNSmlDMSyncAppUi::ShowResourceErrorNoteL |
|
557 // ----------------------------------------------------------------------------- |
|
558 // |
|
559 void CNSmlDMSyncAppUi::ShowResourceErrorNoteL(TInt aResource) const |
|
560 { |
|
561 FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowResourceErrorNoteL:" ); |
|
562 |
|
563 HBufC* errorText = iEikonEnv->AllocReadResourceLC( aResource ); |
|
564 CAknInformationNote* queryDialog = new (ELeave) CAknInformationNote; |
|
565 queryDialog->ExecuteLD( errorText->Des() ); |
|
566 CleanupStack::PopAndDestroy( errorText ); |
|
567 |
|
568 FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowResourceErrorNoteL() completed" ); |
|
569 } |
|
570 |
|
571 // ----------------------------------------------------------------------------- |
|
572 // CNSmlDMSyncAppUi::FotaModel |
|
573 // ----------------------------------------------------------------------------- |
|
574 // |
|
575 CNSmlDMFotaModel* CNSmlDMSyncAppUi::FotaModel() const |
|
576 { |
|
577 return iFotaModel; |
|
578 } |
|
579 |
|
580 // ----------------------------------------------------------------------------- |
|
581 // CNSmlDMSyncAppUi::MarkFwUpdChangesStartL |
|
582 // ----------------------------------------------------------------------------- |
|
583 // |
|
584 void CNSmlDMSyncAppUi::MarkFwUpdChangesStartL() |
|
585 { |
|
586 __ASSERT_ALWAYS( iFotaModel, TUtil::Panic( KErrGeneral ) ); |
|
587 iFotaModel->MarkFwUpdChangesStartL(); |
|
588 } |
|
589 |
|
590 // ----------------------------------------------------------------------------- |
|
591 // CNSmlDMSyncAppUi::FwUpdStatesChangedL |
|
592 // ----------------------------------------------------------------------------- |
|
593 // |
|
594 TBool CNSmlDMSyncAppUi::FwUpdStatesChangedL() |
|
595 { |
|
596 __ASSERT_ALWAYS( iFotaModel, TUtil::Panic( KErrGeneral ) ); |
|
597 return iFotaModel->FwUpdStatesChangedL(); |
|
598 } |
|
599 |
|
600 // ----------------------------------------------------------------------------- |
|
601 // CNSmlDMSyncAppUi::ShowConfirmationNoteL |
|
602 // ----------------------------------------------------------------------------- |
|
603 // |
|
604 TBool CNSmlDMSyncAppUi::ShowConfirmationNoteL( TInt aResource ) const |
|
605 { |
|
606 FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowConfirmationNoteL:" ); |
|
607 |
|
608 HBufC* queryText = iEikonEnv->AllocReadResourceLC( aResource ); |
|
609 CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog(); |
|
610 |
|
611 TBool retValue = queryDialog->ExecuteLD( R_STARTQUERY_NOTE, |
|
612 queryText->Des() ); |
|
613 CleanupStack::PopAndDestroy( queryText ); |
|
614 FTRACE( FPrint( |
|
615 _L("[OMADM] CNSmlDMSyncAppUi::ShowConfirmationNoteL() completed, retval = %d"), |
|
616 retValue ) ); |
|
617 return retValue; |
|
618 } |
|
619 |
|
620 // ----------------------------------------------------------------------------- |
|
621 // CNSmlDMSyncAppUi::HandleCommandNewProfileL |
|
622 // ----------------------------------------------------------------------------- |
|
623 // |
|
624 void CNSmlDMSyncAppUi::HandleCommandNewProfileL() |
|
625 { |
|
626 FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleCommandNewProfileL:" ); |
|
627 |
|
628 if ( iSyncDocument->ProfileCount() != 0 ) |
|
629 { |
|
630 //This if loop check required whether keypad or touch (via stylus) being used incase of single click enabled |
|
631 if(iProfilesView->MenuBar()->ItemSpecificCommandsEnabled()) |
|
632 { |
|
633 HBufC* delQuery = StringLoader::LoadL( |
|
634 R_QTN_SML_APPUI_COPY, |
|
635 iSyncDocument->ProfileItem()->iProfileName ); |
|
636 CleanupStack::PushL( delQuery ); |
|
637 |
|
638 CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog(); |
|
639 iDialogUp = 1; |
|
640 |
|
641 if ( queryDialog->ExecuteLD( R_STARTQUERY_NOTE, delQuery->Des() ) ) |
|
642 { |
|
643 iDialogUp = 0; |
|
644 ShowEditProfileDialogL( ESmlCopyProfile ); |
|
645 } |
|
646 else |
|
647 { |
|
648 iDialogUp = 0; |
|
649 ShowEditProfileDialogL( ESmlNewProfile ); |
|
650 } |
|
651 CleanupStack::PopAndDestroy( delQuery ); |
|
652 } |
|
653 else |
|
654 { |
|
655 iDialogUp = 0; |
|
656 ShowEditProfileDialogL( ESmlNewProfile ); |
|
657 } |
|
658 } |
|
659 else |
|
660 { |
|
661 iDialogUp = 0; |
|
662 ShowEditProfileDialogL( ESmlNewProfile ); |
|
663 } |
|
664 |
|
665 FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleCommandNewProfileL() completed" ); |
|
666 } |
|
667 |
|
668 // ----------------------------------------------------------------------------- |
|
669 // CNSmlDMSyncAppUi::HandleCommandEraseProfileL |
|
670 // ----------------------------------------------------------------------------- |
|
671 // |
|
672 void CNSmlDMSyncAppUi::HandleCommandEraseProfileL() |
|
673 { |
|
674 FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleCommandEraseProfileL:" ); |
|
675 |
|
676 HBufC* delQuery = StringLoader::LoadL( |
|
677 R_SML_APPUI_NOTE_TEXT_DEL, |
|
678 iSyncDocument->ProfileItem()->iProfileName ); |
|
679 CleanupStack::PushL( delQuery ); |
|
680 |
|
681 CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog( ); |
|
682 iDialogUp = 1; |
|
683 |
|
684 if ( queryDialog->ExecuteLD( R_STARTQUERY_NOTE, delQuery->Des() ) ) |
|
685 { |
|
686 TInt index = 0; |
|
687 TInt result = iSyncDocument->DeleteProfile( index ); |
|
688 if ( result == KErrNone ) |
|
689 { |
|
690 iProfilesView->RefreshL(); |
|
691 } |
|
692 else |
|
693 { |
|
694 ShowErrorNoteL( result ); |
|
695 } |
|
696 } |
|
697 iDialogUp = 0; |
|
698 iBusy = EFalse; |
|
699 CleanupStack::PopAndDestroy( delQuery ); |
|
700 FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleCommandEraseProfileL() completed" ); |
|
701 } |
|
702 |
|
703 // ----------------------------------------------------------------------------- |
|
704 // CNSmlDMSyncAppUi::Synchronise |
|
705 // ----------------------------------------------------------------------------- |
|
706 // |
|
707 TBool CNSmlDMSyncAppUi::Synchronise() |
|
708 { |
|
709 FLOG( "[OMADM] CNSmlDMSyncAppUi::Synchronise:" ); |
|
710 return iSyncAppEngine->SyncRunning(); |
|
711 } |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // CNSmlDMSyncAppUi::SyncComplete |
|
715 // ----------------------------------------------------------------------------- |
|
716 // |
|
717 void CNSmlDMSyncAppUi::SyncComplete( TNSmlStatus /* aStatus */ ) |
|
718 |
|
719 { |
|
720 FLOG( "[OMADM] CNSmlDMSyncAppUi::SyncComplete()" ); |
|
721 |
|
722 TRAP_IGNORE( iSyncDocument->RefreshProfileListL() ); |
|
723 // The listbox should get at least an empty array in any case, so |
|
724 // the result checking is not needed. |
|
725 TRAP_IGNORE( iProfilesView->RefreshL() ); |
|
726 RProperty::Set( KPSUidNSmlDMSyncApp, |
|
727 KServerAlertType, |
|
728 KErrNotFound ); |
|
729 iSyncDocument->ResetSession(); |
|
730 TRAP_IGNORE( iMainView->RefreshL(ETrue) ); |
|
731 TInt Value; |
|
732 TInt r=RProperty::Get(KPSUidNSmlDMSyncApp,KNSmlDMSyncUiLaunchKey,Value); |
|
733 if ( iSyncDocument->IsServerAlertSync() && Value == 1) //for Server alert launch case |
|
734 { |
|
735 FLOG( "[OMADM] CNSmlDMSyncAppUi::SyncComplete: RunAppShutter" ); |
|
736 // TRAP_IGNORE( ExitCallL() ); |
|
737 FLOG( "CNSmlDMSyncAppUi::SyncComplete--SANSupport existed" ); |
|
738 //new for fota case SAN Support |
|
739 TInt configFlags( EGenericSession ); |
|
740 CRepository* centrep = NULL; |
|
741 TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ) ); |
|
742 if ( centrep ) |
|
743 { |
|
744 if( err == KErrNone ) |
|
745 { |
|
746 centrep->Get( KDevManSessionType, configFlags ); |
|
747 centrep->Set( KDevManSessionType, EGenericSession ); |
|
748 } |
|
749 delete centrep; |
|
750 } |
|
751 // Check P&S Key set by Application Management. |
|
752 // If P&S Key is set then indicates that DM UI should not be closed. Application Mgmt |
|
753 // Server will take care of closing DM UI |
|
754 const TUid KMyPropertyCat = {0x1020781C}; |
|
755 |
|
756 const TUint KDMUINotClosed = 0x00005; |
|
757 //enum TMyPropertyKeys {EMyPropertyInteger, EMyPropertyArray}; |
|
758 |
|
759 |
|
760 TInt valuekey = 0; |
|
761 RProperty::Get(KMyPropertyCat, KDMUINotClosed, valuekey); |
|
762 |
|
763 |
|
764 //new for fota case SAN Support |
|
765 if( configFlags != EFotaPkgFound && !valuekey) //no update found |
|
766 { |
|
767 FLOG( "[OMADM] CNSmlDMSyncAppUi::SyncComplete: RunAppShutter::Sansupport" ); |
|
768 TRAP_IGNORE( ExitCallL() ); |
|
769 CAknEnv::Static()->RunAppShutter(); |
|
770 } |
|
771 } |
|
772 if ( Value == 3 ) |
|
773 { |
|
774 Value = 2; |
|
775 RProperty::Set(KPSUidNSmlDMSyncApp,KNSmlDMSyncUiLaunchKey,Value); |
|
776 } |
|
777 |
|
778 } |
|
779 // ----------------------------------------------------------------------------- |
|
780 // CNSmlDMSyncAppUi::RefreshMainViewL |
|
781 // ----------------------------------------------------------------------------- |
|
782 // |
|
783 void CNSmlDMSyncAppUi::RefreshMainViewL( ) |
|
784 { |
|
785 iMainView->RefreshL(ETrue); |
|
786 } |
|
787 |
|
788 |
|
789 // ----------------------------------------------------------------------------- |
|
790 // CNSmlDMSyncAppUi::CloseGs |
|
791 // ----------------------------------------------------------------------------- |
|
792 // |
|
793 |
|
794 void CNSmlDMSyncAppUi::CloseGs() |
|
795 { |
|
796 TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); |
|
797 TApaTask task(taskList.FindApp( KUidSmlSyncApp ) ); |
|
798 task.SetWgId( CEikonEnv::Static()->RootWin().Identifier() ); |
|
799 task.SendToBackground(); |
|
800 CAknEnv::Static()->RunAppShutter(); |
|
801 } |
|
802 |
|
803 |
|
804 // ----------------------------------------------------------------------------- |
|
805 // CNSmlDMSyncAppUi::ExitCallL |
|
806 // ----------------------------------------------------------------------------- |
|
807 // |
|
808 void CNSmlDMSyncAppUi::ExitCallL( ) |
|
809 { |
|
810 iMainView->UpdateExitL(); |
|
811 } |
|
812 |
|
813 // ----------------------------------------------------------------------------- |
|
814 // CNSmlDMSyncAppUi::CheckFotaDlL |
|
815 // ----------------------------------------------------------------------------- |
|
816 // |
|
817 void CNSmlDMSyncAppUi::CheckFotaDlL() |
|
818 { |
|
819 FLOG( "CNSmlDMSyncAppUi::CheckFotaDlL : Begin" ); |
|
820 if( FeatureManager::FeatureSupported( KFeatureIdSyncMlDmFota ) ) |
|
821 { |
|
822 //When Download is going on |
|
823 TInt value = KErrNotFound, err = KErrNotFound; |
|
824 err = RProperty::Get(KFotaServerAppUid,KFotaDLStatus,value); |
|
825 FTRACE( FPrint( _L("[OMADM]\t CNSmlDMSyncAppUi::CheckFotaDl() \ |
|
826 KFotaDLStatus val = %d & err = %d"), |
|
827 value,err ) ); |
|
828 if(!err && value == 1) |
|
829 { |
|
830 FLOG( "CNSmlDMSyncAppUi::CheckFotaDl Ongoing Fota operation\ |
|
831 identified." ); |
|
832 |
|
833 TApaTaskList taskList(CEikonEnv::Static()->WsSession()); |
|
834 TApaTask task=taskList.FindApp(TUid::Uid(0x102072c4)); |
|
835 if(task.Exists()) |
|
836 { |
|
837 FLOG( "CNSmlDMSyncAppUi::CheckFotaDl Switching to FS \ |
|
838 Download" ); |
|
839 task.BringToForeground(); |
|
840 } |
|
841 else |
|
842 FLOG( "CNSmlDMSyncAppUi::CheckFotaDl Inconsistency problem\ |
|
843 need to debug" ); |
|
844 } |
|
845 |
|
846 else |
|
847 { |
|
848 FLOG("CNSmlDMSyncAppUi::CheckFotaDl No ongoing Fota\ |
|
849 operation identified!"); |
|
850 } |
|
851 } |
|
852 FLOG( "CNSmlDMSyncAppUi::CheckFotaDlL : End" ); |
|
853 } |
|
854 |
|
855 void CNSmlDMSyncAppUi::CheckAMDlL() |
|
856 { |
|
857 |
|
858 FLOG( "CNSmlDMSyncAppUi::CheckAMDlL : Start" ); |
|
859 const TUid KAppMgmtServerUid = {0x1020781C}; |
|
860 |
|
861 |
|
862 TInt silentoperation = 1; |
|
863 RProperty::Get( KPSUidNSmlDMSyncApp, |
|
864 KServerAlertType, |
|
865 silentoperation); |
|
866 |
|
867 |
|
868 const TUint KAMServerUIEnabled = 0x00001; |
|
869 TInt newValue; |
|
870 TInt err = RProperty::Get(KAppMgmtServerUid, KAMServerUIEnabled, newValue); |
|
871 |
|
872 if(!err && newValue && (silentoperation==KErrNotFound || silentoperation==1)) |
|
873 { |
|
874 FLOG( "CNSmlDMSyncAppUi::CheckAMDlL : Entered:" ); |
|
875 |
|
876 if(silentoperation ==0) |
|
877 { |
|
878 FLOG( "CNSmlDMSyncAppUi::CheckAMDlL :silentoperation ==0" ); |
|
879 } |
|
880 else |
|
881 { |
|
882 FLOG( "CNSmlDMSyncAppUi::CheckAMDlL :silentoperation not equal to 0" ); |
|
883 } |
|
884 |
|
885 TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); |
|
886 TApaTask task = taskList.FindApp(KAppMgmtServerUid ); |
|
887 const TInt id = task.WgId(); |
|
888 task.SetWgId(id); |
|
889 |
|
890 FTRACE( FPrint( _L("[OMADM]\t CNSmlDMSyncAppUi::CheckAMDlL() \ |
|
891 WGID val = %d"), |
|
892 id ) ); |
|
893 |
|
894 if(task.Exists()) |
|
895 { |
|
896 FLOG( "CNSmlDMSyncAppUi::CheckAMDlL :task.Exists() : BringToForeground" ); |
|
897 task.BringToForeground(); |
|
898 } |
|
899 } |
|
900 |
|
901 } |
|
902 |
|
903 TBool CNSmlDMSyncAppUi::IsUpdateAllowedL( CNSmlDMSyncProfile& aProfile ) |
|
904 { |
|
905 FLOG( "CNSmlDMSyncAppUi::IsUpdateAllowedL : Start" ); |
|
906 |
|
907 // Get the last successful sync time. It's a UTC time. |
|
908 // Note: LastSuccessSync() returns the time when the last successful check |
|
909 // for Fota update. |
|
910 TTime utcLastSuccessSync = aProfile.LastSuccessSync(); |
|
911 |
|
912 // If utcLastSuccessSync is 0, there is no log available. Continue |
|
913 // sync. |
|
914 // Note: CNSmlDMSyncProfile::LastSuccessSync() returns 0 not Time::NullTTime(). |
|
915 if ( utcLastSuccessSync.Int64() == 0 ) |
|
916 { |
|
917 FLOG( "[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() LastSuccessSync is 0." ); |
|
918 return ETrue; |
|
919 } |
|
920 |
|
921 #ifdef _DEBUG |
|
922 TDateTime dt = utcLastSuccessSync.DateTime(); |
|
923 FTRACE( FPrint( |
|
924 _L("[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() utcLastSuccessSync \ |
|
925 %04d-%02d-%02d %02d:%02d:%02d"), |
|
926 dt.Year(), dt.Month(), dt.Day(), dt.Hour(), dt.Minute(), dt.Second() ) ); |
|
927 #endif |
|
928 |
|
929 // Read Fota check limitation value in hours from CenRep. |
|
930 // If failed to get the value, the default value is 24 hours. |
|
931 TInt fotaCheckLimitation( KCalenHoursInDay ); |
|
932 CRepository* cenrep = CRepository::NewL( KCRUidNSmlDMSyncApp ); |
|
933 cenrep->Get( KNsmlDmFotaCheckLimitation, fotaCheckLimitation ); |
|
934 delete cenrep; |
|
935 FTRACE( FPrint( |
|
936 _L("[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() Fota check limitation = %d"), |
|
937 fotaCheckLimitation ) ); |
|
938 |
|
939 // Check the get value. |
|
940 if ( fotaCheckLimitation <= 0 ) |
|
941 { |
|
942 // Something wrong with the value. Set it to the default value. |
|
943 fotaCheckLimitation = KCalenHoursInDay; |
|
944 } |
|
945 |
|
946 // Read the current time for comparison. Also universal time. |
|
947 TTime utcCurrentTime; |
|
948 utcCurrentTime.UniversalTime(); |
|
949 |
|
950 #ifdef _DEBUG |
|
951 dt = utcCurrentTime.DateTime(); |
|
952 FTRACE( FPrint( |
|
953 _L("[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() utcCurrentTime \ |
|
954 %04d-%02d-%02d %02d:%02d:%02d"), |
|
955 dt.Year(), dt.Month(), dt.Day(), dt.Hour(), dt.Minute(), dt.Second() ) ); |
|
956 #endif |
|
957 |
|
958 // Calculate the remainig time for the next available update check. |
|
959 TTimeIntervalMinutes passedMinutes; |
|
960 utcCurrentTime.MinutesFrom( utcLastSuccessSync, passedMinutes ); |
|
961 FTRACE( FPrint( |
|
962 _L("[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() passedMinutes.Int() = %d"), |
|
963 passedMinutes.Int() ) ); |
|
964 |
|
965 // If Fota check limit is passed or passedMinutes is invalid, return EFalse |
|
966 // to proceed sync process. |
|
967 if ( passedMinutes.Int() > fotaCheckLimitation * KCalenMinutesInHour |
|
968 || passedMinutes.Int() < 0 ) |
|
969 { |
|
970 FLOG( "[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() Proceed sync process." ); |
|
971 return ETrue; |
|
972 } |
|
973 |
|
974 // Calculate the next available update check time. |
|
975 TInt remainingMinutes ( ( fotaCheckLimitation * KCalenMinutesInHour ) |
|
976 - passedMinutes.Int() ); |
|
977 TInt remainingHours( remainingMinutes / KCalenMinutesInHour ); |
|
978 remainingMinutes -= remainingHours * KCalenMinutesInHour; |
|
979 FTRACE( FPrint( |
|
980 _L("[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() \ |
|
981 remainingHours = %d, remainingMinutes = %d"), |
|
982 remainingHours, remainingMinutes ) ); |
|
983 __ASSERT_DEBUG( ( remainingHours >= 0 ) && ( remainingMinutes >= 0 ), |
|
984 _L("CNSmlDMSyncAppUi::IsUpdateAllowedL - Problem with Remaining \ |
|
985 time calculation.") ); |
|
986 |
|
987 // If calculated remaining time is valid, show the sorry note with |
|
988 // remaining time until next available time for checking update then |
|
989 // return ETrue to stop sync process. |
|
990 if ( remainingHours > 0 || remainingMinutes > 0 ) |
|
991 { |
|
992 CArrayFix< TInt >* timeArray = |
|
993 new( ELeave ) CArrayFixFlat< TInt >( KNSmlDMFotaNoteArrayGranuality ); |
|
994 CleanupStack::PushL( timeArray ); |
|
995 |
|
996 timeArray->AppendL( fotaCheckLimitation ); |
|
997 timeArray->AppendL( remainingHours ); |
|
998 timeArray->AppendL( remainingMinutes ); |
|
999 |
|
1000 HBufC* stringHolder = |
|
1001 StringLoader::LoadLC( R_QTN_FOTA_NOTE_TIME_RESTRICTION, |
|
1002 *timeArray, iEikonEnv ); |
|
1003 |
|
1004 CAknMessageQueryDialog* infoDialog = |
|
1005 CAknMessageQueryDialog::NewL( *stringHolder ); |
|
1006 |
|
1007 // infoDialog is added to the cleanup stack in PrepareLC(). |
|
1008 // And the dialog is popped and destroyed in RunLD(). |
|
1009 infoDialog->PrepareLC( R_AVKON_MESSAGE_QUERY_DIALOG ); |
|
1010 |
|
1011 // Only OK button should be shown since this is just a note. |
|
1012 infoDialog->ButtonGroupContainer().MakeCommandVisible( |
|
1013 EAknSoftkeyCancel, EFalse ); |
|
1014 |
|
1015 // Return value of RunLD() is ignored. |
|
1016 infoDialog->RunLD(); |
|
1017 |
|
1018 CleanupStack::PopAndDestroy( stringHolder ); |
|
1019 CleanupStack::PopAndDestroy( timeArray ); |
|
1020 |
|
1021 // Return EFalse to stop sync process. |
|
1022 FLOG( "CNSmlDMSyncAppUi::IsUpdateAllowedL : End - EFalse" ); |
|
1023 return EFalse; |
|
1024 } |
|
1025 |
|
1026 // No remaining time left (or invalid calculation). |
|
1027 // Proceed checking update process. |
|
1028 FLOG( "CNSmlDMSyncAppUi::IsUpdateAllowedL : End - ETrue" ); |
|
1029 return ETrue; |
|
1030 } |
|
1031 |
|
1032 // End of File |