|
1 /* |
|
2 * Copyright (c) 2002-2005 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 CNSmlDMSyncDocument |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <StringLoader.h> |
|
21 #include <eikenv.h> |
|
22 #include <centralrepository.h> |
|
23 #include <SyncMLNotifierDomainCRKeys.h> |
|
24 |
|
25 #include <e32const.h> |
|
26 #include <DevManInternalCRKeys.h> |
|
27 #include <e32property.h> |
|
28 #include "nsmldmsyncinternalpskeys.h" |
|
29 #include "NSmlDMSyncApp.h" |
|
30 #include "NSmlDMSyncAppEngine.h" |
|
31 #include "NSmlDMSyncDocument.h" |
|
32 #include "NSmlDMSyncAppUi.h" |
|
33 #include "NSmlDMSyncProfileList.h" |
|
34 #include "NSmlDMSyncProfile.h" |
|
35 #include "NSmlDMSyncDebug.h" |
|
36 #include <nsmldmsync.rsg> |
|
37 #include <SyncService.h> |
|
38 #include <SyncServiceParams.h> |
|
39 #include <coreapplicationuisdomainpskeys.h> |
|
40 |
|
41 |
|
42 // ================= MEMBER FUNCTIONS ======================= |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // Desctructor |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CNSmlDMSyncDocument::~CNSmlDMSyncDocument() |
|
49 { |
|
50 FLOG( "[OMADM] CNSmlDMSyncDocument::~CNSmlDMSyncDocument" ); |
|
51 |
|
52 TInt err = RProperty::Delete(KPSUidNSmlDMSyncApp,KServerAlertType); |
|
53 FTRACE( FPrint( |
|
54 _L("CNSmlDMSyncDocument::~CNSmlDMSyncDocument KServerAlertType key deletion with error err = %d"),err ) ); |
|
55 //IAD**** |
|
56 |
|
57 err = RProperty::Delete(KPSUidNSmlDMSyncApp, KDMIdle); |
|
58 |
|
59 err = RProperty::Delete(KPSUidNSmlDMSyncApp, KFotaDLRefresh); |
|
60 FTRACE( FPrint( |
|
61 _L("CNSmlDMSyncDocument::~CNSmlDMSyncDocumentKFotaDLRefresh key deletion with error err = %d"),err ) ); |
|
62 err = RProperty::Delete(KPSUidNSmlDMSyncApp, KDmJobCancel); |
|
63 |
|
64 err = RProperty::Delete(KPSUidNSmlDMSyncApp, KSilentSession); |
|
65 |
|
66 FTRACE( FPrint( |
|
67 _L("CNSmlDMSyncDocument::~CNSmlDMSyncDocument KDmJobCancel key deletion with error err = %d"),err ) ); |
|
68 delete iDbNotifier; |
|
69 delete iSyncProfileList; |
|
70 delete iAppEngine; |
|
71 if ( iProfileList ) |
|
72 { |
|
73 iProfileList->Reset(); |
|
74 delete iProfileList; |
|
75 } |
|
76 delete iServer; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CNSmlDMSyncDocument::ConstructL |
|
81 // Symbian 2nd phase constructor can leave. |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void CNSmlDMSyncDocument::ConstructL() |
|
85 { |
|
86 FLOG( "[OMADM] CNSmlDMSyncDocument::ConstructL" ); |
|
87 |
|
88 iAppEngine = CNSmlDMSyncAppEngine::NewL( this ); |
|
89 iSyncProfileList = CNSmlDMSyncProfileList::NewL( iAppEngine ); |
|
90 iSilent = EFalse; |
|
91 iDbEventsBlocked = EFalse; |
|
92 iDbNotifier = CNSmlDMDbNotifier::NewL( iAppEngine->Session(), this ); |
|
93 iDbNotifier->RequestL(); |
|
94 |
|
95 iProfileList = new (ELeave) CArrayFixFlat< TNSmlDMProfileItem >(1); |
|
96 iCurrentIndex = 0; |
|
97 iEikEnv = CEikonEnv::Static(); |
|
98 iOldProfileId = KErrNotFound; |
|
99 //SAN Spport |
|
100 TInt SanSupport( KErrNone ); |
|
101 CRepository* centrep = NULL; |
|
102 TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys) ); |
|
103 if( err == KErrNone ) |
|
104 { |
|
105 centrep->Get( KDevManSANUIBitVariation, SanSupport ); |
|
106 } |
|
107 delete centrep; |
|
108 iSanSupport = SanSupport; |
|
109 |
|
110 _LIT_SECURITY_POLICY_S0( KWritePolicy, KUidSmlSyncApp.iUid ); |
|
111 _LIT_SECURITY_POLICY_C1( KReadPolicy, ECapabilityReadDeviceData ); |
|
112 _LIT_SECURITY_POLICY_C1( KWritePolicy1, ECapabilityWriteDeviceData ); |
|
113 RProperty::Define( KPSUidNSmlDMSyncApp, |
|
114 KServerAlertType, |
|
115 RProperty::EInt, |
|
116 KReadPolicy, |
|
117 KWritePolicy ); |
|
118 |
|
119 RProperty::Set( KPSUidNSmlDMSyncApp, |
|
120 KServerAlertType, |
|
121 KErrNotFound ); |
|
122 err = RProperty::Define( KPSUidNSmlDMSyncApp, |
|
123 KFotaDLRefresh, |
|
124 RProperty::EInt,KReadPolicy,KWritePolicy1); |
|
125 TInt err1 = KErrNotFound; |
|
126 //if key defined then only set from DMUI, other wise fota sets it |
|
127 if( err == KErrNone ) |
|
128 { |
|
129 iDMDefinesFotaDLKey = ETrue; |
|
130 err1 = RProperty::Set( KPSUidNSmlDMSyncApp, |
|
131 KFotaDLRefresh,KErrNone ); |
|
132 } |
|
133 FTRACE( FPrint( |
|
134 _L("KFotaDLRefresh setting err = %d, err1 = %d"),err, err1 ) ); |
|
135 //IAD ******// |
|
136 err = RProperty::Define( KPSUidNSmlDMSyncApp, |
|
137 KDMIdle, |
|
138 RProperty::EInt); |
|
139 err1 = RProperty::Set( KPSUidNSmlDMSyncApp, |
|
140 KDMIdle,KErrNone ); |
|
141 if (err1) |
|
142 { |
|
143 FTRACE( FPrint( |
|
144 _L("error in setting = %d, err1 = %d"),err, err1 ) ); |
|
145 |
|
146 } |
|
147 FTRACE( FPrint( |
|
148 _L("KDMIdle setting err = %d, err1 = %d"),err, err1 ) ); |
|
149 |
|
150 |
|
151 /*err = RProperty::Define( KPSUidNSmlDMSyncApp, |
|
152 KFotaDLStatus, |
|
153 RProperty::EInt,KReadPolicy,KWritePolicy2); |
|
154 err1 = RProperty::Set( KPSUidNSmlDMSyncApp, |
|
155 KFotaDLStatus,KErrNotFound ); */ |
|
156 |
|
157 FLOG( "[OMADM] CNSmlDMSyncDocument::ConstructL() completed" ); |
|
158 //FTRACE( FPrint( |
|
159 // _L("KFotaDLStatus setting err = %d, err1 = %d"),err, err1 ) ); |
|
160 err = RProperty::Define( KPSUidNSmlDMSyncApp, |
|
161 KDmJobCancel, |
|
162 RProperty::EInt,KReadPolicy,KWritePolicy1); |
|
163 err1 = RProperty::Set( KPSUidNSmlDMSyncApp, |
|
164 KDmJobCancel, KErrNone ); |
|
165 |
|
166 // Define new P&S key to know whether these DM session started in Silent or |
|
167 // User Interactive mode |
|
168 |
|
169 RProperty::Define( KPSUidNSmlDMSyncApp, |
|
170 KSilentSession, |
|
171 RProperty::EInt); |
|
172 FTRACE( FPrint( |
|
173 _L("KDmJobCancel setting err = %d, err1 = %d"),err, err1 ) ); |
|
174 FLOG( "[OMADM] CNSmlDMSyncDocument::ConstructL() completed" ); |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CNSmlDMSyncDocument::NewL |
|
179 // Two-phased constructor. |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 CNSmlDMSyncDocument* CNSmlDMSyncDocument::NewL( CAknApplication& aApp ) |
|
183 { |
|
184 FLOG( "[OMADM] CNSmlDMSyncDocument::NewL:" ); |
|
185 |
|
186 CNSmlDMSyncDocument* self = new (ELeave) CNSmlDMSyncDocument( aApp ); |
|
187 CleanupStack::PushL( self ); |
|
188 self->ConstructL(); |
|
189 CleanupStack::Pop(); //self |
|
190 |
|
191 FLOG( "[OMADM] CNSmlDMSyncDocument::NewL() completed" ); |
|
192 return self; |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CNSmlDMSyncDocument::CreateAppUiL |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 CEikAppUi* CNSmlDMSyncDocument::CreateAppUiL() |
|
200 { |
|
201 FLOG( "[OMADM] CNSmlDMSyncDocument::CreateAppUiL:" ); |
|
202 |
|
203 return new (ELeave) CNSmlDMSyncAppUi; |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CNSmlDMSyncDocument::DeleteProfile |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 TInt CNSmlDMSyncDocument::DeleteProfile( TInt& aIndex ) |
|
211 { |
|
212 FTRACE( FPrint( |
|
213 _L("[OMADM] CNSmlDMSyncDocument::DeleteProfile(), index = %d"), |
|
214 aIndex ) ); |
|
215 |
|
216 TInt retVal = KErrNotFound; |
|
217 if ( iProfileList->Count() <= 0 ) |
|
218 { |
|
219 return retVal; |
|
220 } |
|
221 TRAP( retVal, iAppEngine->DeleteProfileL( |
|
222 (*iProfileList)[iCurrentIndex].iProfileId ) ); |
|
223 if ( retVal == KErrNone ) |
|
224 { |
|
225 TRAP( retVal, ReadProfileListL() ); |
|
226 if ( retVal == KErrNone ) |
|
227 { |
|
228 if ( iCurrentIndex > iProfileList->Count() - 1 ) |
|
229 { |
|
230 iCurrentIndex--; |
|
231 } |
|
232 aIndex = iCurrentIndex; |
|
233 } |
|
234 } |
|
235 |
|
236 FTRACE( FPrint( |
|
237 _L("[OMADM] CNSmlDMSyncDocument::DeleteProfile() completed, retval = %d, index = %d"), |
|
238 retVal, iCurrentIndex ) ); |
|
239 return retVal; |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // CNSmlDMSyncDocument::ReadProfileListL |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 void CNSmlDMSyncDocument::ReadProfileListL() |
|
247 { |
|
248 ReadProfileListL( EFalse ); |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // CNSmlDMSyncDocument::ReadProfileListL |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 void CNSmlDMSyncDocument::ReadProfileListL( TBool aIncludeHidden ) |
|
256 { |
|
257 FLOG( "[OMADM] CNSmlDMSyncDocument::ReadProfileListL:" ); |
|
258 |
|
259 iProfileList->Reset(); |
|
260 |
|
261 TKeyArrayFix key(_FOFF( TNSmlDMProfileItem, iProfileName ), ECmpFolded16 ); |
|
262 iProfileList->Sort(key); |
|
263 |
|
264 iSyncProfileList->Reset(); |
|
265 |
|
266 TRAPD( error, iSyncProfileList->ReadProfileItemsL( aIncludeHidden ) ); |
|
267 if ( error != KErrNone ) |
|
268 { |
|
269 iSyncProfileList->Reset(); |
|
270 } |
|
271 |
|
272 //read profile values |
|
273 for ( TInt index = 0; index < iSyncProfileList->Count(); index++ ) |
|
274 { |
|
275 TNSmlDMProfileItem profile; |
|
276 profile.iProfileName = iSyncProfileList->Item( index ).iProfileName; |
|
277 if ( profile.iProfileName.Length() == 0 ) |
|
278 { |
|
279 StringLoader::Load( profile.iProfileName, R_QTN_APPS_EMPTYPROFILE ); |
|
280 } |
|
281 profile.iProfileId = iSyncProfileList->Item( index ).iProfileId; |
|
282 profile.iBearer = iSyncProfileList->Item( index ).iBearer; |
|
283 profile.iSynced = iSyncProfileList->Item( index ).iSynced; |
|
284 profile.iLastSync = iSyncProfileList->Item( index ).iLastSync; |
|
285 profile.iLastSuccessSync = iSyncProfileList->Item( index ).iLastSuccessSync; |
|
286 profile.iActive = iSyncProfileList->Item( index ).iActive; |
|
287 profile.iDeleteAllowed = iSyncProfileList->Item( index ).iDeleteAllowed; |
|
288 profile.iProfileLocked = iSyncProfileList->Item( index ).iProfileLocked; |
|
289 |
|
290 TInt start = 0; |
|
291 TBool found( EFalse ); |
|
292 |
|
293 if ( iProfileList->Count() == 0 ) |
|
294 { |
|
295 iProfileList->AppendL ( profile ); |
|
296 } |
|
297 else |
|
298 { |
|
299 while ( ( start < iProfileList->Count() ) && ( !found ) ) |
|
300 { |
|
301 if ( iAppEngine->Compare( profile.iProfileName, |
|
302 iProfileList->At( start ).iProfileName ) < 1 ) |
|
303 { |
|
304 iProfileList->InsertL( start, profile ); |
|
305 found = ETrue; |
|
306 } |
|
307 start++; |
|
308 } |
|
309 if ( !found ) //insert to the end of the list |
|
310 { |
|
311 iProfileList->AppendL( profile ); |
|
312 } |
|
313 } |
|
314 } |
|
315 FLOG( "[OMADM] CNSmlDMSyncDocument::ReadProfileListL() completed" ); |
|
316 } |
|
317 |
|
318 // ----------------------------------------------------------------------------- |
|
319 // CNSmlDMSyncDocument::ProfileItem |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 TNSmlDMProfileItem* CNSmlDMSyncDocument::ProfileItem() const |
|
323 { |
|
324 FTRACE( FPrint( |
|
325 _L("[OMADM] CNSmlDMSyncDocument::ProfileItem() iProfileList = 0x%x"), |
|
326 iProfileList ) ); |
|
327 |
|
328 if ( iProfileList->Count() > 0 ) |
|
329 { |
|
330 return &( *iProfileList )[ iCurrentIndex ]; |
|
331 } |
|
332 return 0; |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // CNSmlDMSyncDocument::ProfileItemAt |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 TNSmlDMProfileItem* CNSmlDMSyncDocument::ProfileItemAt( TInt aIndex ) const |
|
340 { |
|
341 FLOG( "[OMADM] CNSmlDMSyncDocument::ProfileItemAt:" ); |
|
342 |
|
343 if ( ( iProfileList->Count() > 0 ) && |
|
344 ( ( aIndex >= 0 ) && |
|
345 ( aIndex < iProfileList->Count() ) ) ) |
|
346 { |
|
347 return &( *iProfileList )[aIndex]; |
|
348 } |
|
349 return 0; |
|
350 } |
|
351 |
|
352 // ----------------------------------------------------------------------------- |
|
353 // CNSmlDMSyncDocument::FotaModel |
|
354 // ----------------------------------------------------------------------------- |
|
355 // |
|
356 CNSmlDMFotaModel* CNSmlDMSyncDocument::FotaModel() const |
|
357 { |
|
358 return ((CNSmlDMSyncAppUi*) iAppUi)->FotaModel(); |
|
359 } |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // CNSmlDMSyncDocument::MarkFwUpdChangesStartL |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 void CNSmlDMSyncDocument::MarkFwUpdChangesStartL() |
|
366 { |
|
367 ((CNSmlDMSyncAppUi*) iAppUi)->MarkFwUpdChangesStartL(); |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // CNSmlDMSyncDocument::FwUpdStatesChangedL |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 TBool CNSmlDMSyncDocument::FwUpdStatesChangedL() |
|
375 { |
|
376 return ((CNSmlDMSyncAppUi*) iAppUi)->FwUpdStatesChangedL(); |
|
377 } |
|
378 |
|
379 // ----------------------------------------------------------------------------- |
|
380 // CNSmlDMSyncDocument::ProfileList |
|
381 // ----------------------------------------------------------------------------- |
|
382 // |
|
383 CArrayFixFlat< TNSmlDMProfileItem >* CNSmlDMSyncDocument::ProfileList( |
|
384 TInt& aIndex ) |
|
385 { |
|
386 FLOG( "[OMADM] CNSmlDMSyncDocument::ProfileList:" ); |
|
387 |
|
388 if ( iCurrentIndex < 0 ) |
|
389 { |
|
390 iCurrentIndex = 0; |
|
391 } |
|
392 aIndex = iCurrentIndex; |
|
393 |
|
394 FLOG( "[OMADM] CNSmlDMSyncDocument::ProfileList() completed" ); |
|
395 return iProfileList; |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // CNSmlDMSyncDocument::SetCurrentIndex |
|
400 // ----------------------------------------------------------------------------- |
|
401 // |
|
402 void CNSmlDMSyncDocument::SetCurrentIndex( TInt aIndex ) |
|
403 { |
|
404 FLOG( "[OMADM] CNSmlDMSyncDocument::SetCurrentIndex:" ); |
|
405 |
|
406 if ( ( aIndex > -1 ) && ( aIndex < iProfileList->Count() ) ) |
|
407 { |
|
408 iCurrentIndex = aIndex; |
|
409 } |
|
410 FTRACE( FPrint( |
|
411 _L("[OMADM] CNSmlDMSyncDocument::SetCurrentIndex() completed, index = %d"), |
|
412 iCurrentIndex ) ); |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // CNSmlDMSyncDocument::MoveIndexToProfile |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 void CNSmlDMSyncDocument::MoveIndexToProfile( TInt aProfileId ) |
|
420 { |
|
421 FTRACE( FPrint( |
|
422 _L("[OMADM] CNSmlDMSyncDocument::MoveIndexToProfile(), aProfileId = %d"), |
|
423 aProfileId ) ); |
|
424 |
|
425 TInt index = 0; |
|
426 TRAP_IGNORE( ReadProfileListL() );//new fix for the error ELGO-6ZK8BD |
|
427 TInt profileCount = iProfileList->Count(); |
|
428 |
|
429 while ( ( index < profileCount ) && |
|
430 ( (*iProfileList)[index].iProfileId != aProfileId ) ) |
|
431 { |
|
432 index++; |
|
433 } |
|
434 if ( index < profileCount ) |
|
435 { |
|
436 SetCurrentIndex( index ); |
|
437 } |
|
438 else //Fix for SMAN-73XGBM |
|
439 { |
|
440 SetCurrentIndex( 0 ); |
|
441 } |
|
442 FTRACE( FPrint( |
|
443 _L("[OMADM] CNSmlDMSyncDocument::MoveIndexToProfile() completed, index = %d"), |
|
444 index ) ); |
|
445 } |
|
446 |
|
447 // ----------------------------------------------------------------------------- |
|
448 // CNSmlDMSyncDocument::GetCopyProfileL |
|
449 // ----------------------------------------------------------------------------- |
|
450 // |
|
451 void CNSmlDMSyncDocument::GetCopyProfileL( TInt& aProfileId ) |
|
452 { |
|
453 FLOG( "[OMADM] CNSmlDMSyncDocument::GetCopyProfileL:" ); |
|
454 |
|
455 if ( iProfileList->Count() <= 0 ) |
|
456 { |
|
457 return; |
|
458 } |
|
459 // save the original profileid, if it's not saved it can be deleted |
|
460 iOldProfileId = ( *iProfileList )[iCurrentIndex].iProfileId; |
|
461 |
|
462 CNSmlDMSyncProfile* profile = |
|
463 iAppEngine->CreateCopyProfileL( (*iProfileList )[iCurrentIndex].iProfileId ); |
|
464 |
|
465 profile->SetNameL( GetNextProfileNameLC()->Des() ); |
|
466 aProfileId = profile->ProfileId(); |
|
467 profile->SaveL(); |
|
468 iAppEngine->CloseProfile(); |
|
469 |
|
470 CleanupStack::PopAndDestroy(); //name |
|
471 |
|
472 FLOG( "[OMADM] CNSmlDMSyncDocument::GetCopyProfileL() completed" ); |
|
473 } |
|
474 |
|
475 // ----------------------------------------------------------------------------- |
|
476 // CNSmlDMSyncDocument::GetNextProfileNameLC |
|
477 // ----------------------------------------------------------------------------- |
|
478 HBufC* CNSmlDMSyncDocument::GetNextProfileNameLC() |
|
479 { |
|
480 FLOG( "[OMADM] CNSmlDMSyncDocument::GetNextProfileNameLC:" ); |
|
481 |
|
482 TBool newNameFound = EFalse; |
|
483 HBufC* profileName = NULL; |
|
484 TInt nameIndex = 1; |
|
485 |
|
486 while ( !newNameFound ) |
|
487 { |
|
488 profileName = StringLoader::LoadLC( R_QTN_APPS_NEWPROFILE, nameIndex ); |
|
489 TNSmlDMProfileItem profileItem; |
|
490 profileItem.iProfileName = *profileName; |
|
491 TKeyArrayFix key(_FOFF(TNSmlDMProfileItem, iProfileName), ECmpFolded16 ); |
|
492 |
|
493 TInt foundIndex; |
|
494 if ( iProfileList->Find( profileItem, key, foundIndex ) ) |
|
495 { |
|
496 newNameFound = ETrue; |
|
497 } |
|
498 else |
|
499 { |
|
500 nameIndex++; |
|
501 CleanupStack::PopAndDestroy( profileName ); |
|
502 } |
|
503 } |
|
504 |
|
505 FTRACE( FPrint( |
|
506 _L("[OMADM] CNSmlDMSyncDocument::GetNextProfileNameLC() completed, name = \"%S\""), |
|
507 profileName ) ); |
|
508 return profileName; |
|
509 } |
|
510 |
|
511 // ----------------------------------------------------------------------------- |
|
512 // DisableDbNotifications |
|
513 // ----------------------------------------------------------------------------- |
|
514 // |
|
515 void CNSmlDMSyncDocument::DisableDbNotifications( TBool aEvent ) |
|
516 { |
|
517 iDbEventsBlocked = aEvent; |
|
518 } |
|
519 |
|
520 // ----------------------------------------------------------------------------- |
|
521 // HandleDbEventL |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 void CNSmlDMSyncDocument::HandleDbEventL( TNSmlDMDbEvent aEvent ) |
|
525 { |
|
526 FLOG( "[OMADM] CNSmlDMSyncDocument::HandleDbEventL:" ); |
|
527 |
|
528 if( !iDbEventsBlocked ) |
|
529 { |
|
530 switch ( aEvent.iType ) |
|
531 { |
|
532 case CNSmlDMDbNotifier::EClose: |
|
533 iAppEngine->SyncCompleted( ENSmlRefreshMainView ); |
|
534 break; |
|
535 |
|
536 case CNSmlDMDbNotifier::EUpdate: |
|
537 iSyncProfileList->ReadProfileItemL( aEvent.iProfileId ); |
|
538 iAppEngine->SyncCompleted( ENSmlRefreshMainView ); |
|
539 break; |
|
540 |
|
541 case CNSmlDMDbNotifier::EDelete: |
|
542 iSyncProfileList->Remove( aEvent.iProfileId ); |
|
543 iAppEngine->SyncCompleted( ENSmlRefreshMainView ); |
|
544 break; |
|
545 |
|
546 case CNSmlDMDbNotifier::EUpdateAll: |
|
547 iSyncProfileList->ReadProfileItemsL(); |
|
548 iAppEngine->SyncCompleted( ENSmlRefreshMainView ); |
|
549 break; |
|
550 |
|
551 default: |
|
552 break; |
|
553 } |
|
554 } |
|
555 FLOG( "[OMADM] CNSmlDMSyncDocument::HandleDbEventL() completed" ); |
|
556 } |
|
557 |
|
558 // ----------------------------------------------------------------------------- |
|
559 // CNSmlDMSyncDocument::RestoreL |
|
560 // |
|
561 // Called (by the environment) when app is opened embedded. |
|
562 // ----------------------------------------------------------------------------- |
|
563 // |
|
564 void CNSmlDMSyncDocument::RestoreL( const CStreamStore& aStore, |
|
565 const CStreamDictionary& aStreamDic ) |
|
566 { |
|
567 FLOG( "[OMADM] CNSmlDMSyncDocument::RestoreL:" ); |
|
568 |
|
569 TSyncParameters params; |
|
570 RStoreReadStream stream; |
|
571 stream.OpenLC( aStore, aStreamDic.At( KUidSyncParameterValue ) ); |
|
572 params.InternalizeL( stream ); |
|
573 CleanupStack::PopAndDestroy(); // stream |
|
574 switch ( params.iCommand ) |
|
575 { |
|
576 case KSyncServCmdStartSync: |
|
577 { |
|
578 FLOG( "[OMADM] CNSmlDMSyncDocument::KSyncServCmdStartSync" ); |
|
579 static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); |
|
580 static _LIT_SECURITY_POLICY_C1(KAllowWriteDeviceDataPolicy, ECapabilityWriteDeviceData); |
|
581 TInt value = 1; |
|
582 TInt r=RProperty::Define(KUidSmlSyncApp,KNSmlDMSyncUiLaunchKey,RProperty::EInt,KAllowAllPolicy,KAllowWriteDeviceDataPolicy); |
|
583 if ( r!=KErrNone && r!=KErrAlreadyExists ) |
|
584 { |
|
585 User::LeaveIfError(r); |
|
586 } |
|
587 if( r==KErrAlreadyExists || r==KErrNone ) |
|
588 { |
|
589 TInt Value; |
|
590 TInt r=RProperty::Get(KUidSmlSyncApp,KNSmlDMSyncUiLaunchKey,Value); |
|
591 if( Value == 2 ) //DM UI launched from CP |
|
592 { |
|
593 FLOG( "[OMADM] CNSmlDMSyncDocument::RestoreL P& S value = 3:" ); |
|
594 value = 3; //DM UI launched from CP and now from server alert |
|
595 } |
|
596 else |
|
597 {FLOG( "[OMADM] CNSmlDMSyncDocument::RestoreL P& S value = 1:" ); |
|
598 value = 1; //DM UI launched as server alert |
|
599 } |
|
600 } |
|
601 TInt r1=RProperty::Set(KUidSmlSyncApp,KNSmlDMSyncUiLaunchKey,value); |
|
602 |
|
603 AppEngine()->OpenProfileL( params.iProfileId ); |
|
604 TInt bearer = AppEngine()->Profile()->BearerType(); |
|
605 TBuf<KNSmlMaxProfileNameLength> serverName; |
|
606 AppEngine()->Profile()->GetName( serverName ); |
|
607 |
|
608 // Server alerted sync should be checked to prevent the sending |
|
609 // the application to background in case the user has opened it. |
|
610 if ( iSanSupport == EOn ) |
|
611 { |
|
612 RProperty::Set( KPSUidNSmlDMSyncApp, |
|
613 KServerAlertType, |
|
614 params.iSilent ); |
|
615 if ( params.iSilent == 1 ) |
|
616 { |
|
617 iSilent = ETrue; // For already DM app open case also |
|
618 } |
|
619 if ( IsServerAlertSync() |
|
620 && params.iSilent == 1 |
|
621 ) |
|
622 { |
|
623 TApaTaskList taskList( iEikEnv->WsSession() ); |
|
624 TApaTask task(taskList.FindApp( KUidSmlSyncApp ) ); |
|
625 task.SetWgId( iEikEnv->RootWin().Identifier() ); |
|
626 task.SendToBackground(); |
|
627 } |
|
628 } |
|
629 else if ( IsServerAlertSync()) |
|
630 { |
|
631 if(AppEngine()->Profile()->SASyncState() == ESASyncStateEnable ) |
|
632 { |
|
633 //new fix for DD and DL not shown for Accepted "yes" |
|
634 RProperty::Set( KPSUidNSmlDMSyncApp, |
|
635 KServerAlertType, 1 ); |
|
636 TApaTaskList taskList( iEikEnv->WsSession() ); |
|
637 TApaTask task(taskList.FindApp( KUidSmlSyncApp ) ); |
|
638 task.SetWgId( iEikEnv->RootWin().Identifier() ); |
|
639 task.SendToBackground(); |
|
640 } |
|
641 else |
|
642 { |
|
643 RProperty::Set( KPSUidNSmlDMSyncApp, |
|
644 KServerAlertType, 0 ); |
|
645 } |
|
646 } |
|
647 AppEngine()->CloseProfile(); |
|
648 |
|
649 // Simpler FOTA progress note is not used in server initiated |
|
650 // management sessions and EFalse can be given as parameter. |
|
651 AppEngine()->SynchronizeL( serverName, |
|
652 params.iProfileId, |
|
653 params.iJobId, |
|
654 bearer, |
|
655 EFalse, |
|
656 iSilent); |
|
657 break; |
|
658 } |
|
659 case KSyncServCmdShowProgress: |
|
660 { |
|
661 FLOG( "[OMADM] CNSmlDMSyncDocument::KSyncServCmdShowProgress" ); |
|
662 if ( iSanSupport == EOn ) |
|
663 { |
|
664 RProperty::Set( KPSUidNSmlDMSyncApp, |
|
665 KServerAlertType, |
|
666 params.iSilent ); |
|
667 if ( params.iSilent == 1 ) |
|
668 { |
|
669 iSilent = ETrue; |
|
670 } |
|
671 } |
|
672 |
|
673 if ( params.iJobId == KSyncServEnabled) |
|
674 { |
|
675 AppEngine()->ShowProgressDialogL( ETrue ); |
|
676 } |
|
677 else |
|
678 { |
|
679 AppEngine()->ShowProgressDialogL( EFalse ); |
|
680 } |
|
681 break; |
|
682 } |
|
683 default: |
|
684 { |
|
685 break; |
|
686 } |
|
687 } |
|
688 FLOG( "[OMADM] CNSmlDMSyncDocument::RestoreL() completed" ); |
|
689 } |
|
690 |
|
691 // ----------------------------------------------------------------------------- |
|
692 // CNSmlDMSyncDocument::IsServerAlertSync |
|
693 // ----------------------------------------------------------------------------- |
|
694 // |
|
695 TBool CNSmlDMSyncDocument::IsServerAlertSync() |
|
696 { |
|
697 FLOG( "CNSmlDMSyncDocument::IsServerAlertSync" ); |
|
698 |
|
699 return iEikEnv->StartedAsServerApp(); |
|
700 } |
|
701 |
|
702 // ----------------------------------------------------------------------------- |
|
703 // CNSmlDMSyncDocument::StartServerL |
|
704 // ----------------------------------------------------------------------------- |
|
705 // |
|
706 void CNSmlDMSyncDocument::StartServerL() |
|
707 { |
|
708 FLOG( "CNSmlDMSyncDocument::StartServerL" ); |
|
709 |
|
710 CApaApplication* app = Application(); |
|
711 app->NewAppServerL( iServer ); |
|
712 TBuf<KMaxFullName> DmAppName; |
|
713 CRepository* centrep = NULL; |
|
714 centrep = CRepository::NewL( KCRUidNSmlNotifierDomainKeys ); |
|
715 centrep->Get( KNSmlDMAppName, DmAppName ); |
|
716 delete centrep; |
|
717 iServer->ConstructL( DmAppName ); |
|
718 |
|
719 FLOG( "CNSmlDMSyncDocument::StartServerL Done" ); |
|
720 } |
|
721 |
|
722 // ----------------------------------------------------------------------------- |
|
723 // CNSmlDMSyncDocument::SANSupport() |
|
724 // ----------------------------------------------------------------------------- |
|
725 // |
|
726 TBool CNSmlDMSyncDocument::SANSupport() |
|
727 { |
|
728 FLOG( "CNSmlDMSyncDocument::SANSupport" ); |
|
729 if ( iSanSupport == EOn ) |
|
730 { |
|
731 return ETrue; |
|
732 } |
|
733 FLOG( "CNSmlDMSyncDocument::SANSupportDone" ); |
|
734 return EFalse; |
|
735 |
|
736 } |
|
737 |
|
738 // ----------------------------------------------------------------------------- |
|
739 // CNSmlDMSyncDocument::SilentSession() |
|
740 // ----------------------------------------------------------------------------- |
|
741 // |
|
742 TBool CNSmlDMSyncDocument::SilentSession() |
|
743 { |
|
744 FLOG( "CNSmlDMSyncDocument::SilentSession" ); |
|
745 TBool silent = ETrue; |
|
746 TInt silentenabled = 0; |
|
747 TInt silentdisabled = 1; |
|
748 if(iSilent == silent) |
|
749 { |
|
750 |
|
751 RProperty::Set( KPSUidNSmlDMSyncApp, |
|
752 KSilentSession, |
|
753 silentenabled ); |
|
754 } |
|
755 else |
|
756 { |
|
757 RProperty::Set( KPSUidNSmlDMSyncApp, |
|
758 KSilentSession, |
|
759 silentdisabled ); |
|
760 } |
|
761 |
|
762 // If trust is establish then default make application management silent |
|
763 |
|
764 TInt tarmtrustenabled = KErrNone; |
|
765 RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsTarmIndicator, tarmtrustenabled); |
|
766 |
|
767 |
|
768 if(tarmtrustenabled == ECoreAppUIsTarmTerminalSecurityOnIndicatorOn || |
|
769 tarmtrustenabled ==ECoreAppUIsTarmMngActiveIndicatorOn ) |
|
770 { |
|
771 |
|
772 RProperty::Set( KPSUidNSmlDMSyncApp, |
|
773 KSilentSession, |
|
774 silentenabled ); |
|
775 |
|
776 } |
|
777 |
|
778 return iSilent; |
|
779 } |
|
780 |
|
781 // ----------------------------------------------------------------------------- |
|
782 // CNSmlDMSyncDocument::ResetSession() |
|
783 // ----------------------------------------------------------------------------- |
|
784 // |
|
785 void CNSmlDMSyncDocument::ResetSession() |
|
786 { |
|
787 FLOG( "CNSmlDMSyncDocument::ResetSession" ); |
|
788 iSilent = EFalse; |
|
789 FLOG( "CNSmlDMSyncDocument::ResetSession" ); |
|
790 } |
|
791 |
|
792 // ----------------------------------------------------------------------------- |
|
793 // CNSmlDMSyncDocument::CurrentIndex() |
|
794 // ----------------------------------------------------------------------------- |
|
795 // |
|
796 TInt CNSmlDMSyncDocument::CurrentIndex() |
|
797 { |
|
798 return iCurrentIndex; |
|
799 } |
|
800 |
|
801 // ----------------------------------------------------------------------------- |
|
802 // CNSmlDMSyncDocument::DMDefinesFotaDLKey() |
|
803 // ----------------------------------------------------------------------------- |
|
804 // |
|
805 TBool CNSmlDMSyncDocument::DMDefinesFotaDLKey() |
|
806 { |
|
807 return iDMDefinesFotaDLKey; |
|
808 } |
|
809 // End of File |