|
1 /* |
|
2 * Copyright (c) 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: Database (content) specific fata and functionality |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <nsmlconstants.h> |
|
21 #include <nsmldebug.h> |
|
22 #include "nsmldbcaps.h" |
|
23 #include <nsmlchangefinder.h> |
|
24 #include "nsmldserror.h" |
|
25 #include "nsmlcliagconstants.h" |
|
26 #include "nsmldscontent.h" |
|
27 #include "NSmlDSCmds.h" |
|
28 #include "nsmldsluidbuffer.h" |
|
29 #include "nsmldsmapcontainer.h" |
|
30 #include "nsmlagentlog.h" |
|
31 #include "NSmlURI.h" |
|
32 #include "nsmldshostclient.h" |
|
33 #include "NsmlDSContentItem.h" |
|
34 #include "nsmldssettings.h" |
|
35 #include <centralrepository.h> |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS =============================== |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CNSmlDSContent::CNSmlDSContent() |
|
41 // C++ default constructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CNSmlDSContent::CNSmlDSContent() |
|
45 { |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CNSmlDSContent::ConstructL |
|
50 // Symbian 2nd phase constructor. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 void CNSmlDSContent::ConstructL() |
|
54 { |
|
55 // <MAPINFO_RESEND_MOD_BEGIN> |
|
56 SetMapStreamUID(); |
|
57 iOldMapExists=EFalse; |
|
58 |
|
59 TInt keyVal; |
|
60 TRAPD (err ,ReadRepositoryL(KNsmlDsSuspendResume, keyVal)); |
|
61 if(err==KErrNone && keyVal==1) |
|
62 { |
|
63 SetResendUsed(ETrue); |
|
64 } |
|
65 else |
|
66 { |
|
67 SetResendUsed(EFalse); |
|
68 } |
|
69 // <MAPINFO_RESEND_MOD_END> |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CNSmlDSContent::NewL |
|
74 // Symbian two-phased constructor. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CNSmlDSContent* CNSmlDSContent::NewL() |
|
78 { |
|
79 CNSmlDSContent* self = new ( ELeave ) CNSmlDSContent(); |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop(); // self |
|
83 return( self ); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CNSmlDSContent::~CNSmlDSContent |
|
88 // Destructor. |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CNSmlDSContent::~CNSmlDSContent() |
|
92 { |
|
93 iStores.ResetAndDestroy(); |
|
94 iStores.Close(); |
|
95 delete iOldServerId; |
|
96 delete iHostClient; |
|
97 iHierarchicalSupportTable.ResetAndDestroy(); |
|
98 iHierarchicalSupportTable.Close(); |
|
99 } |
|
100 |
|
101 void CNSmlDSContent::InitContentDataL() |
|
102 { |
|
103 iHostClient = CNSmlDSHostClient::NewL(); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CNSmlDSContent::CurrentIndex |
|
108 // Returns the index of the current content (datastore). |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 TInt CNSmlDSContent::CurrentIndex() const |
|
112 { |
|
113 return iIndex; |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CNSmlDSContent::ContentIndexIsSet |
|
118 // Checks whether some content is selected. |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 TBool CNSmlDSContent::ContentIndexIsSet() const |
|
122 { |
|
123 if ( iIndex == -1 ) |
|
124 { |
|
125 return EFalse; |
|
126 } |
|
127 |
|
128 return ETrue; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CNSmlDSContent::Count |
|
133 // Returns the number of contents in the content array. |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 TInt CNSmlDSContent::Count() const |
|
137 { |
|
138 return iStores.Count(); |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CNSmlDSContent::ImplementationUID |
|
143 // Returns current content's unique identifier. |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 TInt CNSmlDSContent::ImplementationUID() const |
|
147 { |
|
148 return iStores[iIndex]->iImplementationUID; |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------- |
|
152 // CNSmlDSContent::LocalDatabase() |
|
153 // |
|
154 // --------------------------------------------------------- |
|
155 CNSmlURI* CNSmlDSContent::LocalDatabase() const |
|
156 { |
|
157 return iStores[iIndex]->iLocalDatabase; |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------- |
|
161 // CNSmlDSContent::RemoteDatabase() |
|
162 // |
|
163 // --------------------------------------------------------- |
|
164 CNSmlURI* CNSmlDSContent::RemoteDatabase() const |
|
165 { |
|
166 return iStores[iIndex]->iRemoteDatabase; |
|
167 } |
|
168 |
|
169 //RD_SUSPEND_RESUME |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CNSmlDSContent::SyncType |
|
172 // Returns the datastore's currently selected synchronisation type. |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 TPtrC8 CNSmlDSContent::SyncType() const |
|
176 { |
|
177 if ( iStores[iIndex]->iSyncType ) |
|
178 { |
|
179 return iStores[iIndex]->iSyncType->Des(); |
|
180 } |
|
181 |
|
182 return TPtrC8( KNullDesC8 ); |
|
183 } |
|
184 |
|
185 //RD_SUSPEND_RESUME |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CNSmlDSContent::ClientSyncType |
|
188 // Returns the Sync Type proposed by the Client in the Sync session |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TPtrC8 CNSmlDSContent::ClientSyncType() |
|
192 { |
|
193 |
|
194 if ( iStores[iIndex]->iClientSyncType ) |
|
195 { |
|
196 return iStores[iIndex]->iClientSyncType->Des(); |
|
197 } |
|
198 |
|
199 |
|
200 return TPtrC8( KNullDesC8 ); |
|
201 } |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CNSmlDSContent::SupportsOperationL |
|
204 // Checks if an operation is supported by the data provider. |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 TBool CNSmlDSContent::SupportsOperationL( TUid aOperation ) |
|
208 { |
|
209 TInt resultCode; |
|
210 |
|
211 // <MAPINFO_RESEND_MOD_BEGIN> |
|
212 if( aOperation == KUidSmlSupportBatch && ResendUsed() ) |
|
213 { |
|
214 return EFalse; |
|
215 } |
|
216 // <MAPINFO_RESEND_MOD_END> |
|
217 |
|
218 return iHostClient->SupportsOperationL( aOperation, iStores[iIndex]->iImplementationUID, resultCode ); |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CNSmlDSContent::BeginTransActionL |
|
223 // Sets the current datastore to the transaction mode. |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CNSmlDSContent::BeginTransActionL() |
|
227 { |
|
228 TInt resultCode; |
|
229 iStores[iIndex]->iAtomicModeOn = ETrue; |
|
230 iHostClient->BeginTransactionL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, resultCode ); |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CNSmlDSContent::CommitTransactionL |
|
235 // Orders the current datastore to apply pending atomic operations. |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 void CNSmlDSContent::CommitTransactionL( TInt& aResultCode ) |
|
239 { |
|
240 iStores[iIndex]->iAtomicModeOn = EFalse; |
|
241 iHostClient->CommitTransactionL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, aResultCode ); |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CNSmlDSContent::RevertTransactionL |
|
246 // Aborts the ongoing transaction. |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 void CNSmlDSContent::RevertTransactionL( TInt& aResultCode ) |
|
250 { |
|
251 iStores[iIndex]->iAtomicModeOn = EFalse; |
|
252 iHostClient->RevertTransactionL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, aResultCode ); |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CNSmlDSContent::AtomicModeOn |
|
257 // Checks if the current datastore is in the batch mode. |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 TBool CNSmlDSContent::AtomicModeOn() const |
|
261 { |
|
262 return iStores[iIndex]->iAtomicModeOn; |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CNSmlDSContent::OpenNextItemL |
|
267 // Opens the next item in the LUID buffer. |
|
268 // ----------------------------------------------------------------------------- |
|
269 // |
|
270 TInt CNSmlDSContent::OpenNextItemL( TSmlDbItemUid& aLocalUid, TSmlDbItemUid& aParentUid, TDes8& aCmdName, TInt& aSize, CNSmlDbMeta& aMeta ) const |
|
271 { |
|
272 TInt ret( iStores[iIndex]->iLUIDBuffer->NextUIDL( aLocalUid, aCmdName ) ); |
|
273 |
|
274 if ( ( ret == KErrNone ) && ( aCmdName != KNSmlAgentDelete ) ) |
|
275 { |
|
276 TBool fieldChange; |
|
277 HBufC8* mimeType; |
|
278 HBufC8* mimeVersion; |
|
279 |
|
280 iHostClient->OpenItemL( aLocalUid, |
|
281 fieldChange, |
|
282 aSize, |
|
283 aParentUid, |
|
284 mimeType, |
|
285 mimeVersion, |
|
286 iStores[iIndex]->iImplementationUID, |
|
287 *iStores[iIndex]->iStoreName, |
|
288 ret ); |
|
289 |
|
290 if ( ret == KErrNone ) |
|
291 { |
|
292 CleanupStack::PushL( mimeType ); |
|
293 CleanupStack::PushL( mimeVersion ); |
|
294 |
|
295 if ( fieldChange ) |
|
296 { |
|
297 aCmdName = KNSmlAgentPartialReplace; |
|
298 } |
|
299 |
|
300 aMeta.SetTypeL( *mimeType ); |
|
301 aMeta.SetVersionL( *mimeVersion ); |
|
302 |
|
303 CleanupStack::PopAndDestroy( 2 ); // mimeVersion, mimeType |
|
304 } |
|
305 } |
|
306 |
|
307 return ret; |
|
308 } |
|
309 |
|
310 // ----------------------------------------------------------------------------- |
|
311 // CNSmlDSContent::ReadItemL |
|
312 // Reads data from the currently open item. |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 void CNSmlDSContent::ReadItemL( TDes8& aBuffer ) |
|
316 { |
|
317 TInt resultCode; |
|
318 iHostClient->ReadItemL( aBuffer, iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, resultCode ); |
|
319 } |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // CNSmlDSContent::CloseItemL |
|
323 // Closes the currently open item. |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 void CNSmlDSContent::CloseItemL() |
|
327 { |
|
328 TInt resultCode; |
|
329 iHostClient->CloseItemL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, resultCode ); |
|
330 } |
|
331 |
|
332 // ----------------------------------------------------------------------------- |
|
333 // CNSmlDSContent::CurrentUID |
|
334 // Returns the UID of the current item. |
|
335 // ----------------------------------------------------------------------------- |
|
336 // |
|
337 void CNSmlDSContent::CurrentUID( TSmlDbItemUid& aLocalUID ) const |
|
338 { |
|
339 iStores[iIndex]->iLUIDBuffer->CurrentUID( aLocalUID ); |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------- |
|
343 // CNSmlDSContent::DbCapabilitiesL() |
|
344 // |
|
345 // --------------------------------------------------------- |
|
346 TInt CNSmlDSContent::DbCapabilitiesL( CNSmlDbCaps*& aDbCaps ) const |
|
347 { |
|
348 TInt resultCode( KErrNone ); |
|
349 aDbCaps = iHostClient->StoreFormatL( iStores[iIndex]->iImplementationUID, resultCode ); |
|
350 |
|
351 return resultCode; |
|
352 } |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // CNSmlDSContent::HasSyncHistoryL |
|
356 // Checks if the current datastore has been synced previously. |
|
357 // ----------------------------------------------------------------------------- |
|
358 // |
|
359 TBool CNSmlDSContent::HasSyncHistoryL() const |
|
360 { |
|
361 TInt resultCode; |
|
362 return iHostClient->HasSyncHistoryL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, resultCode ); |
|
363 } |
|
364 |
|
365 // ----------------------------------------------------------------------------- |
|
366 // CNSmlDSContent::IsSupportedRxL |
|
367 // Checks if the given RxType is supported by the datastore. |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 TBool CNSmlDSContent::IsSupportedRxL( const TDesC8& aType ) const |
|
371 { |
|
372 TBool ret( EFalse ); |
|
373 CNSmlDbCaps* dbCaps; |
|
374 |
|
375 TInt result = DbCapabilitiesL( dbCaps ); |
|
376 User::LeaveIfError( result ); |
|
377 |
|
378 CleanupStack::PushL( dbCaps ); |
|
379 |
|
380 // dbCaps ownership is moved to a caller |
|
381 SmlDevInfDatastore_t* datastore = dbCaps->DatastoreL(); |
|
382 |
|
383 if ( !datastore ) |
|
384 { |
|
385 CleanupStack::PopAndDestroy(); // dbCaps |
|
386 return ret; |
|
387 } |
|
388 |
|
389 // datastore ownership is moved to a caller |
|
390 CleanupStack::PushL( datastore ); |
|
391 |
|
392 if ( aType == datastore->rxpref->cttype->Data() ) |
|
393 { |
|
394 ret = ETrue; |
|
395 } |
|
396 else |
|
397 { |
|
398 SmlDevInfXmitList_t* rxList = datastore->rx; |
|
399 |
|
400 while ( rxList ) |
|
401 { |
|
402 if ( aType == rxList->data->cttype->Data() ) |
|
403 { |
|
404 ret = ETrue; |
|
405 break; |
|
406 } |
|
407 |
|
408 rxList = rxList->next; |
|
409 } |
|
410 } |
|
411 |
|
412 CleanupStack::PopAndDestroy( 2 ); // datastore, dbCaps |
|
413 |
|
414 return ret; |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // CNSmlDSContent::IsSupportedTxL |
|
419 // Checks if the given TxType is supported by the datastore. |
|
420 // ----------------------------------------------------------------------------- |
|
421 // |
|
422 TBool CNSmlDSContent::IsSupportedTxL( const TDesC8& aType ) const |
|
423 { |
|
424 TBool ret = EFalse; |
|
425 CNSmlDbCaps* dbCaps; |
|
426 |
|
427 TInt result = DbCapabilitiesL( dbCaps ); |
|
428 User::LeaveIfError( result ); |
|
429 |
|
430 CleanupStack::PushL( dbCaps ); |
|
431 |
|
432 // dbCaps ownership is moved to a caller |
|
433 SmlDevInfDatastore_t* datastore = dbCaps->DatastoreL(); |
|
434 |
|
435 if ( !datastore ) |
|
436 { |
|
437 CleanupStack::PopAndDestroy(); // dbCaps |
|
438 return ret; |
|
439 } |
|
440 |
|
441 // datastore ownership is moved to a caller |
|
442 CleanupStack::PushL( datastore ); |
|
443 if ( aType == datastore->txpref->cttype->Data() ) |
|
444 { |
|
445 ret = ETrue; |
|
446 } |
|
447 else |
|
448 { |
|
449 SmlDevInfXmitList_t* txList = datastore->tx; |
|
450 |
|
451 while ( txList ) |
|
452 { |
|
453 if ( aType == txList->data->cttype->Data() ) |
|
454 { |
|
455 ret = ETrue; |
|
456 break; |
|
457 } |
|
458 |
|
459 txList = txList->next; |
|
460 } |
|
461 } |
|
462 |
|
463 CleanupStack::PopAndDestroy( 2 ); // datastore, dbCaps |
|
464 |
|
465 return ret; |
|
466 } |
|
467 |
|
468 // --------------------------------------------------------- |
|
469 // CNSmlDSContent::IsSupportedSyncTypeL() |
|
470 // |
|
471 // --------------------------------------------------------- |
|
472 TBool CNSmlDSContent::IsSupportedSyncTypeL( CNSmlDbCaps::ENSmlSyncTypes aSyncType ) const |
|
473 { |
|
474 CNSmlDbCaps* dbCaps( NULL ); |
|
475 |
|
476 TInt result = DbCapabilitiesL( dbCaps ); |
|
477 User::LeaveIfError( result ); |
|
478 |
|
479 TBool ret( dbCaps->SupportsSyncType( aSyncType ) ); |
|
480 delete dbCaps; |
|
481 |
|
482 return ret; |
|
483 } |
|
484 |
|
485 // --------------------------------------------------------- |
|
486 // CNSmlDSContent::IsSupportedSyncTypeL() |
|
487 // |
|
488 // --------------------------------------------------------- |
|
489 TBool CNSmlDSContent::IsSupportedSyncTypeL( const TDesC8& aSyncType ) const |
|
490 { |
|
491 CNSmlDbCaps::ENSmlSyncTypes syncType; |
|
492 |
|
493 if ( SyncTypeConv ( aSyncType, syncType ) ) |
|
494 { |
|
495 return IsSupportedSyncTypeL( syncType ); |
|
496 } |
|
497 |
|
498 return EFalse; |
|
499 } |
|
500 |
|
501 // --------------------------------------------------------- |
|
502 // CNSmlDSContent::IsHierarchicalSyncSupportedL() |
|
503 // |
|
504 // --------------------------------------------------------- |
|
505 TBool CNSmlDSContent::IsHierarchicalSyncSupportedL( const TPtr8 aMediaType ) |
|
506 { |
|
507 TBool* doesExist = iHierarchicalSupportTable.Find(aMediaType); |
|
508 if(doesExist) |
|
509 { |
|
510 return *doesExist; |
|
511 } |
|
512 TBool ret( EFalse ); |
|
513 CNSmlDbCaps* dbCaps( NULL ); |
|
514 |
|
515 TInt result = DbCapabilitiesL( dbCaps ); |
|
516 User::LeaveIfError( result ); |
|
517 |
|
518 CleanupStack::PushL( dbCaps ); |
|
519 |
|
520 SmlDevInfDatastorePtr_t datastore = dbCaps->DatastoreL(); |
|
521 CleanupStack::PushL( datastore ); |
|
522 |
|
523 if ( datastore->rxpref->cttype->Data().Compare( aMediaType ) == 0 ) |
|
524 { |
|
525 if ( datastore->supportHierarchicalSync ) |
|
526 { |
|
527 ret = ETrue; |
|
528 } |
|
529 } |
|
530 else if ( datastore->rx ) |
|
531 { |
|
532 SmlDevInfXmitListPtr_t rx = datastore->rx; |
|
533 |
|
534 while ( rx ) |
|
535 { |
|
536 if ( rx->data && rx->data->Data().Compare( aMediaType ) == 0 ) |
|
537 { |
|
538 if ( datastore->supportHierarchicalSync ) |
|
539 { |
|
540 ret = ETrue; |
|
541 } |
|
542 |
|
543 break; |
|
544 } |
|
545 |
|
546 rx = rx->next; |
|
547 } |
|
548 } |
|
549 |
|
550 CleanupStack::PopAndDestroy( 2 ); // datastore, dbCaps |
|
551 HBufC8* targetType = aMediaType.AllocLC(); |
|
552 doesExist = new (ELeave) TBool(ret); |
|
553 CleanupStack::PushL(doesExist); |
|
554 if(iHierarchicalSupportTable.Insert(targetType,doesExist)!=KErrNone) |
|
555 { |
|
556 // Insertion failed, ignore but free memory |
|
557 CleanupStack::PopAndDestroy(2); // doesExist, targetType |
|
558 } |
|
559 else |
|
560 { |
|
561 CleanupStack::Pop(2); // doesExist and targetType are owned by the hash table now |
|
562 } |
|
563 |
|
564 return ret; |
|
565 } |
|
566 |
|
567 // --------------------------------------------------------- |
|
568 // CNSmlDSContent::IsSupportedSyncTypeByServerL() |
|
569 // |
|
570 // --------------------------------------------------------- |
|
571 TBool CNSmlDSContent::IsSupportedSyncTypeByServerL() const |
|
572 { |
|
573 TUint flag; |
|
574 |
|
575 if ( SyncType() == KNSmlDSOneWayFromClient ) |
|
576 { |
|
577 flag = KNSmlOneWayFromClientFlag; |
|
578 } |
|
579 else if ( SyncType() == KNSmlDSRefreshFromClient ) |
|
580 { |
|
581 flag = KNSmlRefreshFromClientFlag; |
|
582 } |
|
583 else if ( SyncType() == KNSmlDSOneWayFromServer ) |
|
584 { |
|
585 flag = KNSmlOneWayFromServerFlag; |
|
586 } |
|
587 else if ( SyncType() == KNSmlDSRefreshFromServer ) |
|
588 { |
|
589 flag = KNSmlRefreshFromServerFlag; |
|
590 } |
|
591 else |
|
592 { |
|
593 return ETrue; |
|
594 } |
|
595 |
|
596 TUint syncTypeFlags( iStores[iIndex]->iAgentLog->IntValueL( EAgentLogServerSyncTypes ) ); |
|
597 |
|
598 if ( syncTypeFlags != 0 ) |
|
599 { |
|
600 if ( !IsFlagSet( syncTypeFlags, flag ) ) |
|
601 { |
|
602 return EFalse; |
|
603 } |
|
604 } |
|
605 |
|
606 return ETrue; |
|
607 } |
|
608 |
|
609 // ----------------------------------------------------------------------------- |
|
610 // CNSmlDSContent::Interrupted |
|
611 // Checks if the synchronisation of the current datastore has been interrupted. |
|
612 // ----------------------------------------------------------------------------- |
|
613 // |
|
614 TBool CNSmlDSContent::Interrupted() const |
|
615 { |
|
616 return iStores[iIndex]->iInterrupted; |
|
617 } |
|
618 |
|
619 // ----------------------------------------------------------------------------- |
|
620 // CNSmlDSContent::ServerStatusError |
|
621 // Checks if there is a server error in the synchronisation log. |
|
622 // ----------------------------------------------------------------------------- |
|
623 // |
|
624 TBool CNSmlDSContent::ServerStatusError() const |
|
625 { |
|
626 return iStores[iIndex]->iStatusErrorInSyncLog; |
|
627 } |
|
628 |
|
629 // ----------------------------------------------------------------------------- |
|
630 // CNSmlDSContent::WaitingInitAlert |
|
631 // Checks if the current datastore is waiting for the initial alert. |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 TBool CNSmlDSContent::WaitingInitAlert() const |
|
635 { |
|
636 return iStores[iIndex]->iWaitingInitAlert; |
|
637 } |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CNSmlDSContent::SlowSyncRequestL |
|
641 // Checks if slow synchronisation has been requested for the current datastore. |
|
642 // ----------------------------------------------------------------------------- |
|
643 // |
|
644 TBool CNSmlDSContent::SlowSyncRequestL() const |
|
645 { |
|
646 return iStores[iIndex]->iAgentLog->IntValueL( EAgentLogSlowSyncRequest ); |
|
647 } |
|
648 |
|
649 // ----------------------------------------------------------------------------- |
|
650 // CNSmlDSContent::AnyDatabaseIsInterrupted |
|
651 // Checks if the sychronisation of any datastore has been interrupted. |
|
652 // ----------------------------------------------------------------------------- |
|
653 // |
|
654 TBool CNSmlDSContent::AnyDatabaseIsInterrupted() const |
|
655 { |
|
656 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
657 { |
|
658 if ( iStores[i]->iInterrupted ) |
|
659 { |
|
660 return ETrue; |
|
661 } |
|
662 } |
|
663 |
|
664 return EFalse; |
|
665 } |
|
666 |
|
667 // ----------------------------------------------------------------------------- |
|
668 // CNSmlDSContent::AllDatabasesAreInterrupted |
|
669 // Checks if all synchronisations are interrupted. |
|
670 // ----------------------------------------------------------------------------- |
|
671 // |
|
672 TBool CNSmlDSContent::AllDatabasesAreInterrupted() const |
|
673 { |
|
674 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
675 { |
|
676 if ( !iStores[i]->iInterrupted ) |
|
677 { |
|
678 return EFalse; |
|
679 } |
|
680 } |
|
681 |
|
682 return ETrue; |
|
683 } |
|
684 |
|
685 // ----------------------------------------------------------------------------- |
|
686 // CNSmlDSContent::AllDatabasesAreInterruptedImmediately |
|
687 // Checks if all synchronisations are interrupted immediately. |
|
688 // ----------------------------------------------------------------------------- |
|
689 // |
|
690 TBool CNSmlDSContent::AllDatabasesAreInterruptedImmediately() const |
|
691 { |
|
692 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
693 { |
|
694 if ( !iStores[i]->iImmediatelyInterruption ) |
|
695 { |
|
696 return EFalse; |
|
697 } |
|
698 } |
|
699 |
|
700 return ETrue; |
|
701 } |
|
702 |
|
703 // ----------------------------------------------------------------------------- |
|
704 // CNSmlDSContent::AllDatabasesOneWayFromClient |
|
705 // Checks if synchronisation type is client-initiated one-way synchronisation |
|
706 // for all datastores. |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 TBool CNSmlDSContent::AllDatabasesOneWayFromClient() const |
|
710 { |
|
711 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
712 { |
|
713 if ( *iStores[i]->iSyncType != KNSmlDSOneWayFromClient && |
|
714 *iStores[i]->iSyncType != KNSmlDSOneWayFromClientByServer && |
|
715 *iStores[i]->iSyncType != KNSmlDSRefreshFromClient && |
|
716 *iStores[i]->iSyncType != KNSmlDSRefreshFromClientByServer ) |
|
717 { |
|
718 return EFalse; |
|
719 } |
|
720 } |
|
721 |
|
722 return ETrue; |
|
723 } |
|
724 |
|
725 // ----------------------------------------------------------------------------- |
|
726 // CNSmlDSContent::MapExists |
|
727 // Checks if the mapped items buffer exists for the current datastore. |
|
728 // ----------------------------------------------------------------------------- |
|
729 // |
|
730 TBool CNSmlDSContent::MapExists() const |
|
731 { |
|
732 if ( !iStores[iIndex]->iMapContainer ) |
|
733 { |
|
734 return EFalse; |
|
735 } |
|
736 |
|
737 return iStores[iIndex]->iMapContainer->MapListExists(); |
|
738 } |
|
739 |
|
740 // --------------------------------------------------------- |
|
741 // CNSmlDSContent::ClientItemCountAsked() |
|
742 // |
|
743 // --------------------------------------------------------- |
|
744 TBool CNSmlDSContent::ClientItemCountAsked() const |
|
745 { |
|
746 return iStores[iIndex]->iClientItemCountAsked; |
|
747 } |
|
748 |
|
749 // --------------------------------------------------------- |
|
750 // CNSmlDSContent::ServerItemCountAsked() |
|
751 // |
|
752 // --------------------------------------------------------- |
|
753 TBool CNSmlDSContent::ServerItemCountAsked() const |
|
754 { |
|
755 return iStores[iIndex]->iServerItemCountAsked; |
|
756 } |
|
757 |
|
758 // --------------------------------------------------------- |
|
759 // CNSmlDSContent::ClientItemCount() |
|
760 // |
|
761 // --------------------------------------------------------- |
|
762 TInt CNSmlDSContent::ClientItemCount() const |
|
763 { |
|
764 return iStores[iIndex]->iLUIDBuffer->ClientItemCount(); |
|
765 } |
|
766 |
|
767 // --------------------------------------------------------- |
|
768 // CNSmlDSContent::ServerItemCount() |
|
769 // |
|
770 // --------------------------------------------------------- |
|
771 TInt CNSmlDSContent::ServerItemCount() const |
|
772 { |
|
773 iStores[iIndex]->iServerItemCountAsked = ETrue; |
|
774 |
|
775 return iStores[iIndex]->iServerItemCount; |
|
776 } |
|
777 |
|
778 // --------------------------------------------------------- |
|
779 // CNSmlDSContent::MapItemList() |
|
780 // |
|
781 // --------------------------------------------------------- |
|
782 SmlMapItemList_t* CNSmlDSContent::MapItemListL() const |
|
783 { |
|
784 return iStores[iIndex]->iMapContainer->MapItemListL(); |
|
785 } |
|
786 |
|
787 // --------------------------------------------------------- |
|
788 // CNSmlDSContent::MaxObjSizeInServer() |
|
789 // |
|
790 // --------------------------------------------------------- |
|
791 TInt CNSmlDSContent::MaxObjSizeInServer() const |
|
792 { |
|
793 return iStores[iIndex]->iMaxObjSizeInServer; |
|
794 } |
|
795 |
|
796 // --------------------------------------------------------- |
|
797 // CNSmlDSContent::LastSyncAnchorL() |
|
798 // |
|
799 // --------------------------------------------------------- |
|
800 TTime CNSmlDSContent::LastSyncAnchorL() const |
|
801 { |
|
802 return iStores[iIndex]->iAgentLog->TimeValueL( EAgentLogLastSyncAnchor ); |
|
803 } |
|
804 |
|
805 // --------------------------------------------------------- |
|
806 // CNSmlDSContent::GetSavedFilterCapsL() |
|
807 // |
|
808 // --------------------------------------------------------- |
|
809 void CNSmlDSContent::GetSavedFilterCapsL( CArrayFix<TNSmlFilterCapData>* aFilterCaps ) const |
|
810 { |
|
811 iStores[iIndex]->iAgentLog->GetServerFilterInfoL( aFilterCaps ); |
|
812 } |
|
813 |
|
814 // --------------------------------------------------------- |
|
815 // CNSmlDSContent::InitInterruptionFlags() |
|
816 // |
|
817 // --------------------------------------------------------- |
|
818 void CNSmlDSContent::InitInterruptionFlags() const |
|
819 { |
|
820 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
821 { |
|
822 if ( !iStores[i]->iInterruptedBeforeSync ) |
|
823 { |
|
824 iStores[i]->iInterrupted = EFalse; |
|
825 iStores[i]->iImmediatelyInterruption = EFalse; |
|
826 iStores[i]->iStatusErrorInSyncLog = EFalse; |
|
827 } |
|
828 } |
|
829 } |
|
830 |
|
831 // --------------------------------------------------------- |
|
832 // CNSmlDSContent::CreateNewMapItemL() |
|
833 // |
|
834 // --------------------------------------------------------- |
|
835 void CNSmlDSContent::CreateNewMapItemL( const TSmlDbItemUid aLUID, const TDesC8& aGUID, const TInt aAtomicId ) const |
|
836 { |
|
837 if ( !iStores[iIndex]->iMapContainer ) |
|
838 { |
|
839 iStores[iIndex]->iMapContainer = CNSmlDSMapContainer::NewL(); |
|
840 } |
|
841 |
|
842 iStores[iIndex]->iMapContainer->CreateNewMapItemL( aLUID, aGUID, aAtomicId ); |
|
843 } |
|
844 |
|
845 // --------------------------------------------------------- |
|
846 // CNSmlDSContent::SetMapItemList() |
|
847 // |
|
848 // --------------------------------------------------------- |
|
849 void CNSmlDSContent::SetMapItemList( SmlMapItemList_t* aMapItemList ) const |
|
850 { |
|
851 iStores[iIndex]->iMapContainer->SetMapItemList( aMapItemList ); |
|
852 } |
|
853 |
|
854 // --------------------------------------------------------- |
|
855 // CNSmlDSContent::RemoveMap() |
|
856 // |
|
857 // --------------------------------------------------------- |
|
858 void CNSmlDSContent::RemoveMap() const |
|
859 { |
|
860 iStores[iIndex]->iMapContainer->MarkAllItemsSent(); |
|
861 } |
|
862 |
|
863 //RD_SUSPEND_RESUME |
|
864 // --------------------------------------------------------- |
|
865 // CNSmlDSContent::SetSyncTypeL() |
|
866 // |
|
867 // --------------------------------------------------------- |
|
868 void CNSmlDSContent::SetSyncTypeL( const TDesC8& aSyncType ) const |
|
869 { |
|
870 delete iStores[iIndex]->iSyncType; |
|
871 iStores[iIndex]->iSyncType = NULL; |
|
872 iStores[iIndex]->iSyncType = aSyncType.AllocL(); |
|
873 } |
|
874 |
|
875 //RD_SUSPEND_RESUME |
|
876 // --------------------------------------------------------- |
|
877 // CNSmlDSContent::SetClientSyncTypeL() |
|
878 // |
|
879 // --------------------------------------------------------- |
|
880 void CNSmlDSContent::SetClientSyncTypeL( const TDesC8& aSyncType ) const |
|
881 { |
|
882 delete iStores[iIndex]->iClientSyncType; |
|
883 iStores[iIndex]->iClientSyncType = NULL; |
|
884 iStores[iIndex]->iClientSyncType = aSyncType.AllocL(); |
|
885 } |
|
886 // CNSmlDSContent::SetSyncTypeL() |
|
887 // |
|
888 // --------------------------------------------------------- |
|
889 void CNSmlDSContent::SetSyncTypeL( CNSmlDbCaps::ENSmlSyncTypes aSyncType ) const |
|
890 { |
|
891 TBuf8<3> syncType; |
|
892 |
|
893 switch ( aSyncType ) |
|
894 { |
|
895 case CNSmlDbCaps::ETwoWaySync: |
|
896 syncType = KNSmlDSTwoWay; |
|
897 break; |
|
898 |
|
899 case CNSmlDbCaps::ESlowTwoWaySync: |
|
900 syncType = KNSmlDSSlowSync; |
|
901 break; |
|
902 |
|
903 case CNSmlDbCaps::EOneWaySyncFromClient: |
|
904 syncType = KNSmlDSOneWayFromClient; |
|
905 break; |
|
906 |
|
907 case CNSmlDbCaps::ERefreshSyncFromClient: |
|
908 syncType = KNSmlDSRefreshFromClient; |
|
909 break; |
|
910 |
|
911 case CNSmlDbCaps::EOneWaySyncFromServer: |
|
912 syncType = KNSmlDSOneWayFromServer; |
|
913 break; |
|
914 |
|
915 case CNSmlDbCaps::ERefreshSyncFromServer: |
|
916 syncType = KNSmlDSRefreshFromServer; |
|
917 break; |
|
918 |
|
919 default: |
|
920 break; |
|
921 } |
|
922 |
|
923 SetSyncTypeL( syncType ); |
|
924 SetClientSyncTypeL( syncType );//RD_SUSPEND_RESUME |
|
925 } |
|
926 |
|
927 // --------------------------------------------------------- |
|
928 // CNSmlDSContent::SetDbAndTimeInitsL() |
|
929 // |
|
930 // --------------------------------------------------------- |
|
931 void CNSmlDSContent::SetDbAndTimeInitsL( TBool& aEndOfInits, TInt& aResultCode, TBool aStartOfInits ) |
|
932 { |
|
933 DBG_FILE(_S8("CNSmlDSContent:::SetDbAndTimeInitsL begins")); |
|
934 |
|
935 if ( !aStartOfInits ) |
|
936 { |
|
937 aEndOfInits = !SetToFirst(); |
|
938 } |
|
939 else |
|
940 { |
|
941 aEndOfInits = !SetToNext(); |
|
942 } |
|
943 |
|
944 if ( !aEndOfInits ) |
|
945 { |
|
946 if ( !Interrupted() ) |
|
947 { |
|
948 if ( *iStores[iIndex]->iSyncType == KNSmlDSSlowSync || |
|
949 *iStores[iIndex]->iSyncType == KNSmlDSRefreshFromClient || |
|
950 *iStores[iIndex]->iSyncType == KNSmlDSRefreshFromClientByServer ) |
|
951 { |
|
952 iHostClient->ResetChangeInfoL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, aResultCode ); |
|
953 // <MAPINFO_RESEND_MOD_BEGIN> |
|
954 // CleanMapInfo(); |
|
955 // <MAPINFO_RESEND_MOD_END> |
|
956 iStores[iIndex]->iLUIDBuffer->FetchModificationsL( aResultCode ); |
|
957 } |
|
958 if ( *iStores[iIndex]->iSyncType == KNSmlDSOneWayFromServer || |
|
959 *iStores[iIndex]->iSyncType == KNSmlDSOneWayFromServerByServer || |
|
960 *iStores[iIndex]->iSyncType == KNSmlDSRefreshFromServer || |
|
961 *iStores[iIndex]->iSyncType == KNSmlDSRefreshFromServerByServer ) |
|
962 { |
|
963 iStores[iIndex]->iLUIDBuffer->FetchModificationsL( aResultCode ); |
|
964 } |
|
965 if ( *iStores[iIndex]->iSyncType == KNSmlDSRefreshFromServer || |
|
966 *iStores[iIndex]->iSyncType == KNSmlDSRefreshFromServerByServer ) |
|
967 { |
|
968 iHostClient->DeleteAllItemsL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, aResultCode ); |
|
969 User::LeaveIfError(aResultCode); |
|
970 iHostClient->ResetChangeInfoL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, aResultCode ); |
|
971 // <MAPINFO_RESEND_MOD_BEGIN> |
|
972 |
|
973 DBG_FILE(_S8("CNSmlDSContent:::SetDbAndTimeInitsL - SyncType was KNSmlDSRefreshFromServer || KNSmlDSRefreshFromServerByServer")); |
|
974 // CleanMapInfo(); |
|
975 // <MAPINFO_RESEND_MOD_END> |
|
976 } |
|
977 if ( *iStores[iIndex]->iSyncType == KNSmlDSTwoWay || |
|
978 *iStores[iIndex]->iSyncType == KNSmlDSTwoWayByServer || |
|
979 *iStores[iIndex]->iSyncType == KNSmlDSOneWayFromClient || |
|
980 *iStores[iIndex]->iSyncType == KNSmlDSOneWayFromClientByServer ) |
|
981 { |
|
982 iStores[iIndex]->iLUIDBuffer->FetchModificationsL( aResultCode ); |
|
983 } |
|
984 } |
|
985 } |
|
986 |
|
987 DBG_FILE(_S8("CNSmlDSContent:::SetDbAndTimeInitsL ends")); |
|
988 } |
|
989 |
|
990 // --------------------------------------------------------- |
|
991 // CNSmlDSContent::InitSyncLogEventL() |
|
992 // |
|
993 // --------------------------------------------------------- |
|
994 void CNSmlDSContent::InitSyncLogEventL( CSyncMLHistoryJob& aSyncLog ) |
|
995 { |
|
996 InitEventL( aSyncLog, iIndex ); |
|
997 } |
|
998 |
|
999 // --------------------------------------------------------- |
|
1000 // CNSmlDSContent::InitAllSyncLogEventsL() |
|
1001 // |
|
1002 // --------------------------------------------------------- |
|
1003 void CNSmlDSContent::InitAllSyncLogEventsL( CSyncMLHistoryJob& aSyncLog ) |
|
1004 { |
|
1005 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
1006 { |
|
1007 InitEventL( aSyncLog, i ); |
|
1008 } |
|
1009 } |
|
1010 |
|
1011 // --------------------------------------------------------- |
|
1012 // CNSmlDSContent::FinalizeSyncLogEvents() |
|
1013 // |
|
1014 // --------------------------------------------------------- |
|
1015 void CNSmlDSContent::FinalizeSyncLogEvents() const |
|
1016 { |
|
1017 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
1018 { |
|
1019 if ( iStores[i]->iTaskInfo ) |
|
1020 { |
|
1021 if ( iStores[i]->iSyncStatus == CNSmlDSAgent::ECompletedOK && iStores[i]->iWarnings > 0 ) |
|
1022 { |
|
1023 iStores[i]->iSyncStatus = CNSmlDSAgent::ECompletedWithInfo; |
|
1024 } |
|
1025 |
|
1026 |
|
1027 iStores[i]->iTaskInfo->iError = iStores[i]->iSyncStatus; |
|
1028 |
|
1029 TSmlSyncType syncType = ESmlTwoWay; // set a value to avoid compiler warning |
|
1030 TPtr8 dsSyncType = iStores[i]->iSyncType->Des(); |
|
1031 |
|
1032 if ( dsSyncType == KNSmlDSTwoWay || dsSyncType == KNSmlDSTwoWayByServer ) |
|
1033 { |
|
1034 syncType = ESmlTwoWay; |
|
1035 } |
|
1036 else |
|
1037 if ( dsSyncType == KNSmlDSSlowSync ) |
|
1038 { |
|
1039 syncType = ESmlSlowSync; |
|
1040 } |
|
1041 else |
|
1042 if ( dsSyncType == KNSmlDSOneWayFromClient || dsSyncType == KNSmlDSOneWayFromClientByServer ) |
|
1043 { |
|
1044 syncType = ESmlOneWayFromClient; |
|
1045 } |
|
1046 else |
|
1047 if ( dsSyncType == KNSmlDSRefreshFromClient || dsSyncType == KNSmlDSRefreshFromClientByServer ) |
|
1048 { |
|
1049 syncType = ESmlRefreshFromClient; |
|
1050 } |
|
1051 else |
|
1052 if ( dsSyncType == KNSmlDSOneWayFromServer || dsSyncType == KNSmlDSOneWayFromServerByServer ) |
|
1053 { |
|
1054 syncType = ESmlOneWayFromServer; |
|
1055 } |
|
1056 else |
|
1057 if ( dsSyncType == KNSmlDSRefreshFromServer || dsSyncType == KNSmlDSRefreshFromServerByServer ) |
|
1058 { |
|
1059 syncType = ESmlRefreshFromServer; |
|
1060 } |
|
1061 |
|
1062 iStores[i]->iTaskInfo->iSyncType = syncType; |
|
1063 } |
|
1064 } |
|
1065 } |
|
1066 |
|
1067 // ----------------------------------------------------------------------------- |
|
1068 // CNSmlDSContent::AddNewContentL |
|
1069 // Adds a new datastore to the datastore list. |
|
1070 // ----------------------------------------------------------------------------- |
|
1071 // |
|
1072 void CNSmlDSContent::AddNewContentL() |
|
1073 { |
|
1074 CNSmlDSContentItem* contentItem = new ( ELeave ) CNSmlDSContentItem; |
|
1075 |
|
1076 CleanupStack::PushL( contentItem ); |
|
1077 User::LeaveIfError( iStores.Append( contentItem ) ); |
|
1078 CleanupStack::Pop(); // contentItem |
|
1079 |
|
1080 iIndex = iStores.Count() - 1; |
|
1081 iStores[iIndex]->iSyncStatus = CNSmlDSAgent::ENothingIsSent; |
|
1082 } |
|
1083 |
|
1084 // ----------------------------------------------------------------------------- |
|
1085 // CNSmlDSContent::SetImplementationUID |
|
1086 // Sets the current datastore's implementation UID. |
|
1087 // ----------------------------------------------------------------------------- |
|
1088 // |
|
1089 void CNSmlDSContent::SetImplementationUID( TInt aImplUID ) const |
|
1090 { |
|
1091 iStores[iIndex]->iImplementationUID = aImplUID; |
|
1092 } |
|
1093 |
|
1094 // --------------------------------------------------------- |
|
1095 // CNSmlDSContent::SetLocalDatabaseL() |
|
1096 // |
|
1097 // --------------------------------------------------------- |
|
1098 void CNSmlDSContent::SetLocalDatabaseL( CNSmlURI& aLocalDatabase ) const |
|
1099 { |
|
1100 |
|
1101 if ( aLocalDatabase.Database() == KNullDesC() |
|
1102 || ImplementationUID() == KUidNSmlAdapterEMail.iUid) |
|
1103 { |
|
1104 CNSmlDSHostClient* dsClient = CNSmlDSHostClient::NewL(); |
|
1105 CleanupStack::PushL(dsClient); |
|
1106 |
|
1107 RArray<TInt> idArray; |
|
1108 RArray<TInt> resultArray; |
|
1109 CleanupClosePushL(resultArray); |
|
1110 CleanupClosePushL(idArray); |
|
1111 idArray.AppendL(ImplementationUID() ); |
|
1112 |
|
1113 dsClient->CreateDataProvidersL( idArray, resultArray ); |
|
1114 |
|
1115 TInt res = resultArray[0]; |
|
1116 User::LeaveIfError( res ); |
|
1117 |
|
1118 CleanupStack::PopAndDestroy(2); |
|
1119 TInt result(KErrNone); |
|
1120 |
|
1121 HBufC* localDatabase = dsClient->DefaultStoreL( ImplementationUID(), result ); |
|
1122 User::LeaveIfNull( localDatabase ); |
|
1123 |
|
1124 CleanupStack::PushL( localDatabase ); |
|
1125 |
|
1126 if ( localDatabase->Des() == KNullDesC() ) |
|
1127 { |
|
1128 User::Leave( KErrNotFound ); |
|
1129 } |
|
1130 |
|
1131 aLocalDatabase.SetDatabaseL( localDatabase->Des() ); |
|
1132 CleanupStack::PopAndDestroy(); //localDatabase; |
|
1133 |
|
1134 CleanupStack::PopAndDestroy(); //dsClient |
|
1135 } |
|
1136 |
|
1137 iStores[iIndex]->iLocalDatabase = CNSmlURI::NewL(); |
|
1138 *iStores[iIndex]->iLocalDatabase = aLocalDatabase; |
|
1139 iStores[iIndex]->iStoreName = aLocalDatabase.DataBaseWithoutRelativePrefix().AllocL(); |
|
1140 } |
|
1141 |
|
1142 // --------------------------------------------------------- |
|
1143 // CNSmlDSContent::SetRemoteDatabaseL() |
|
1144 // |
|
1145 // --------------------------------------------------------- |
|
1146 void CNSmlDSContent::SetRemoteDatabaseL( const CNSmlURI& aRemoteDatabase ) const |
|
1147 { |
|
1148 iStores[iIndex]->iRemoteDatabase = CNSmlURI::NewL(); |
|
1149 *iStores[iIndex]->iRemoteDatabase = aRemoteDatabase; |
|
1150 } |
|
1151 |
|
1152 // ----------------------------------------------------------------------------- |
|
1153 // CNSmlDSContent::InitContentInstanceL |
|
1154 // Initialises the current datastore. |
|
1155 // ----------------------------------------------------------------------------- |
|
1156 // |
|
1157 TBool CNSmlDSContent::InitContentInstanceL( TDesC& aServerId ) |
|
1158 { |
|
1159 TBool retval( ETrue ); |
|
1160 |
|
1161 iStores[iIndex]->iAgentLog = CNSmlDSAgentLog::NewL(); |
|
1162 iStores[iIndex]->iAgentLog->SetAgentLogKeyL( iStores[iIndex]->iImplementationUID, |
|
1163 iStores[iIndex]->iLocalDatabase->Database(), |
|
1164 aServerId, |
|
1165 iStores[iIndex]->iRemoteDatabase->Database() ); |
|
1166 |
|
1167 // old Server Id needs to be examined, if the server has sent a new id in the device info |
|
1168 delete iOldServerId; |
|
1169 iOldServerId = NULL; |
|
1170 iOldServerId = aServerId.AllocL(); |
|
1171 iStores[iIndex]->iServerId = aServerId.AllocL(); |
|
1172 |
|
1173 RArray<TSmlDataProviderId> dataProvider; |
|
1174 RArray<TInt> result; |
|
1175 |
|
1176 dataProvider.Append( iStores[iIndex]->iImplementationUID ); |
|
1177 |
|
1178 iHostClient->CreateDataProvidersL( dataProvider, result ); |
|
1179 |
|
1180 if ( result[0] != KErrNone ) |
|
1181 { |
|
1182 retval = EFalse; |
|
1183 } |
|
1184 |
|
1185 dataProvider.Close(); |
|
1186 result.Close(); |
|
1187 |
|
1188 return retval; |
|
1189 } |
|
1190 |
|
1191 // --------------------------------------------------------- |
|
1192 // CNSmlDSContent::OpenContentInstanceL() |
|
1193 // |
|
1194 // --------------------------------------------------------- |
|
1195 void CNSmlDSContent::OpenContentInstanceL( TInt& aResultCode ) const |
|
1196 { |
|
1197 DBG_FILE(_S8("CNSmlDSContent::OpenContentInstanceL begins")); |
|
1198 |
|
1199 iStores[iIndex]->iStoreOpened = ETrue; |
|
1200 iHostClient->OpenL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, *iStores[iIndex]->iServerId, iStores[iIndex]->iRemoteDatabase->DataBaseWithoutRelativePrefix(), aResultCode ); |
|
1201 |
|
1202 DBG_FILE(_S8("CNSmlDSContent::OpenContentInstanceL ends")); |
|
1203 } |
|
1204 |
|
1205 // ----------------------------------------------------------------------------- |
|
1206 // CNSmlDSContent::CreateLUIDBufferL |
|
1207 // Creates a LUID buffer for the current datastore. |
|
1208 // ----------------------------------------------------------------------------- |
|
1209 // |
|
1210 void CNSmlDSContent::CreateLUIDBufferL( TInt& aResultCode ) const |
|
1211 { |
|
1212 DBG_FILE(_S8("CNSmlDSContent::CreateLUIDBufferL begins")); |
|
1213 |
|
1214 iStores[iIndex]->iLUIDBuffer = new ( ELeave ) CNSmlDSLUIDBuffer( *iHostClient, *iStores[iIndex] ); |
|
1215 iStores[iIndex]->iLUIDBuffer->FetchModificationsL( aResultCode ); |
|
1216 |
|
1217 DBG_FILE(_S8("CNSmlDSContent::CreateLUIDBufferL ends")); |
|
1218 } |
|
1219 |
|
1220 // ----------------------------------------------------------------------------- |
|
1221 // CNSmlDSContent::CancelRequestL |
|
1222 // Cancels all ongoing asynchronous operations. |
|
1223 // ----------------------------------------------------------------------------- |
|
1224 // |
|
1225 void CNSmlDSContent::CancelRequestL() const |
|
1226 { |
|
1227 TInt resultCode; |
|
1228 |
|
1229 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
1230 { |
|
1231 if ( iStores[i]->iStoreOpened ) |
|
1232 { |
|
1233 iHostClient->CancelRequestL( iStores[i]->iImplementationUID, *iStores[i]->iStoreName, resultCode ); |
|
1234 } |
|
1235 } |
|
1236 } |
|
1237 |
|
1238 // --------------------------------------------------------- |
|
1239 // CNSmlDSContent::SetInitAlertWaiting() |
|
1240 // |
|
1241 // --------------------------------------------------------- |
|
1242 void CNSmlDSContent::SetInitAlertWaiting() const |
|
1243 { |
|
1244 iStores[iIndex]->iWaitingInitAlert = ETrue; |
|
1245 } |
|
1246 |
|
1247 // --------------------------------------------------------- |
|
1248 // CNSmlDSContent::SetInitAlertReceived() |
|
1249 // |
|
1250 // --------------------------------------------------------- |
|
1251 void CNSmlDSContent::SetInitAlertReceived() const |
|
1252 { |
|
1253 iStores[iIndex]->iWaitingInitAlert = EFalse; |
|
1254 } |
|
1255 |
|
1256 // ----------------------------------------------------------------------------- |
|
1257 // CNSmlDSContent::SetSlowSyncReqForNextSyncL |
|
1258 // Sets the next synchronisation type to slow sync. |
|
1259 // ----------------------------------------------------------------------------- |
|
1260 // |
|
1261 void CNSmlDSContent::SetSlowSyncReqForNextSyncL( TBool aRequest ) const |
|
1262 { |
|
1263 if ( aRequest ) |
|
1264 { |
|
1265 iStores[iIndex]->iAgentLog->SetIntValueL( EAgentLogSlowSyncRequest, 1 ); |
|
1266 } |
|
1267 else |
|
1268 { |
|
1269 iStores[iIndex]->iAgentLog->SetIntValueL( EAgentLogSlowSyncRequest, 0 ); |
|
1270 } |
|
1271 } |
|
1272 |
|
1273 // ----------------------------------------------------------------------------- |
|
1274 // CNSmlDSContent::SetRefreshRequiredL |
|
1275 // Sets if the Resume command is Rejected by the Server |
|
1276 // ----------------------------------------------------------------------------- |
|
1277 // |
|
1278 void CNSmlDSContent::SetRefreshRequiredL(TBool aRefreshRequired) |
|
1279 { |
|
1280 iStores[iIndex]->iRefreshRequired=aRefreshRequired; |
|
1281 } |
|
1282 // ----------------------------------------------------------------------------- |
|
1283 // CNSmlDSContent::GetRefreshRequired |
|
1284 // Gets if the Resume command is Rejected by the Server or not |
|
1285 // ----------------------------------------------------------------------------- |
|
1286 // |
|
1287 TBool CNSmlDSContent::GetRefreshRequired() |
|
1288 { |
|
1289 return(iStores[iIndex]->iRefreshRequired); |
|
1290 } |
|
1291 |
|
1292 //RD_SUSPEND_RESUME |
|
1293 // ----------------------------------------------------------------------------- |
|
1294 // CNSmlDSContent::SetSessionResumedL |
|
1295 // Sets if the Resume command is sent by the client |
|
1296 // ----------------------------------------------------------------------------- |
|
1297 // |
|
1298 void CNSmlDSContent::SetSessionResumedL(TBool aSessionResumed) |
|
1299 { |
|
1300 iStores[iIndex]->iSessionResumed=aSessionResumed; |
|
1301 } |
|
1302 |
|
1303 //RD_SUSPEND_RESUME |
|
1304 // ------------------------------------------------------------------------------------------------ |
|
1305 // CNSmlDSContent::GetRefreshRequired |
|
1306 // Gets if the Resume command is sent by the client or not, ETrue is returned if session is resumed |
|
1307 // ------------------------------------------------------------------------------------------------ |
|
1308 // |
|
1309 TBool CNSmlDSContent::GetSessionResumed() |
|
1310 { |
|
1311 return(iStores[iIndex]->iSessionResumed); |
|
1312 } |
|
1313 |
|
1314 // --------------------------------------------------------- |
|
1315 // CNSmlDSContent::SetIndexByLocalDatabaseL() |
|
1316 // |
|
1317 // --------------------------------------------------------- |
|
1318 TBool CNSmlDSContent::SetIndexByLocalDatabaseL( CNSmlURI& aDatabase ) |
|
1319 { |
|
1320 iIndex = -1; |
|
1321 |
|
1322 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
1323 { |
|
1324 if ( aDatabase.IsEqualL( *iStores[i]->iLocalDatabase ) ) |
|
1325 { |
|
1326 // Sync was bound to a database |
|
1327 iIndex = i; |
|
1328 return ETrue; |
|
1329 } |
|
1330 } |
|
1331 |
|
1332 return EFalse; |
|
1333 } |
|
1334 |
|
1335 // --------------------------------------------------------- |
|
1336 // CNSmlDSContent::SetIndexByRemoteDatabaseL() |
|
1337 // |
|
1338 // --------------------------------------------------------- |
|
1339 |
|
1340 TBool CNSmlDSContent::SetIndexByRemoteDatabaseL( CNSmlURI& aDatabase, TBool aRespURIExists ) |
|
1341 { |
|
1342 iIndex = -1; |
|
1343 |
|
1344 for ( TInt i = 0; i < iStores.Count() ; i++ ) |
|
1345 { |
|
1346 if ( aDatabase.IsEqualL( *iStores[i]->iRemoteDatabase , !aRespURIExists) ) |
|
1347 { |
|
1348 // Sync was bound to a database |
|
1349 iIndex = i; |
|
1350 return ETrue; |
|
1351 } |
|
1352 else |
|
1353 { |
|
1354 if ( aRespURIExists ) |
|
1355 { |
|
1356 if ( aDatabase.DatabaseMatchesL( iStores[i]->iRemoteDatabase->Database() ) ) |
|
1357 { |
|
1358 // Sync was bound to a database |
|
1359 iIndex = i; |
|
1360 return ETrue; |
|
1361 } |
|
1362 } |
|
1363 } |
|
1364 } |
|
1365 |
|
1366 return EFalse; |
|
1367 } |
|
1368 |
|
1369 // --------------------------------------------------------- |
|
1370 // CNSmlDSContent::SetIndexByDatabasesAndTypeL() |
|
1371 // |
|
1372 // --------------------------------------------------------- |
|
1373 TBool CNSmlDSContent::SetIndexByDatabasesAndTypeL( CNSmlURI& aRemoteDatabase, CNSmlURI& aLocalDatabase, const TDesC8& aType ) |
|
1374 { |
|
1375 iIndex = -1; |
|
1376 |
|
1377 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
1378 { |
|
1379 if ( ( aLocalDatabase.Database().Length() > 0 ) && ( aLocalDatabase.Database() != _L("/") ) ) |
|
1380 { |
|
1381 if ( !aLocalDatabase.IsEqualL( *iStores[i]->iLocalDatabase ) ) |
|
1382 { |
|
1383 continue; |
|
1384 } |
|
1385 } |
|
1386 |
|
1387 if ( !aRemoteDatabase.IsEqualL( *iStores[i]->iRemoteDatabase ) ) |
|
1388 { |
|
1389 continue; |
|
1390 } |
|
1391 |
|
1392 iIndex = i; |
|
1393 |
|
1394 if ( IsSupportedRxL( aType ) && IsSupportedTxL( aType ) ) |
|
1395 { |
|
1396 return ETrue; |
|
1397 } |
|
1398 else |
|
1399 { |
|
1400 iIndex = -1; |
|
1401 } |
|
1402 } |
|
1403 |
|
1404 return EFalse; |
|
1405 } |
|
1406 |
|
1407 // ----------------------------------------------------------------------------- |
|
1408 // CNSmlDSContent::SetAsServerAlerted |
|
1409 // Raises the server alert flag. |
|
1410 // ----------------------------------------------------------------------------- |
|
1411 // |
|
1412 void CNSmlDSContent::SetAsServerAlerted() const |
|
1413 { |
|
1414 iStores[iIndex]->iServerAlerted = ETrue; |
|
1415 } |
|
1416 |
|
1417 // ----------------------------------------------------------------------------- |
|
1418 // CNSmlDSContent::SetToFirst |
|
1419 // Sets the index to the first datastore. |
|
1420 // ----------------------------------------------------------------------------- |
|
1421 TBool CNSmlDSContent::SetToFirst() |
|
1422 { |
|
1423 iIndex = 0; |
|
1424 |
|
1425 if ( iIndex < iStores.Count() ) |
|
1426 { |
|
1427 return ETrue; |
|
1428 } |
|
1429 |
|
1430 iIndex = -1; |
|
1431 |
|
1432 return EFalse; |
|
1433 } |
|
1434 |
|
1435 // ----------------------------------------------------------------------------- |
|
1436 // CNSmlDSContent::SetToNext |
|
1437 // Advances the index to the next datastore. |
|
1438 // ----------------------------------------------------------------------------- |
|
1439 // |
|
1440 TBool CNSmlDSContent::SetToNext() |
|
1441 { |
|
1442 if ( ++iIndex < iStores.Count() ) |
|
1443 { |
|
1444 return ETrue; |
|
1445 } |
|
1446 |
|
1447 iIndex = -1; |
|
1448 |
|
1449 return EFalse; |
|
1450 } |
|
1451 |
|
1452 // ----------------------------------------------------------------------------- |
|
1453 // CNSmlDSContent::SetIndex |
|
1454 // Sets the index to the given datastore. |
|
1455 // ----------------------------------------------------------------------------- |
|
1456 // |
|
1457 TBool CNSmlDSContent::SetIndex( TInt aInd ) |
|
1458 { |
|
1459 iIndex = aInd; |
|
1460 |
|
1461 if ( iIndex >= 0 && iIndex < iStores.Count() ) |
|
1462 { |
|
1463 return ETrue; |
|
1464 } |
|
1465 |
|
1466 iIndex = -1; |
|
1467 |
|
1468 return EFalse; |
|
1469 } |
|
1470 |
|
1471 // ----------------------------------------------------------------------------- |
|
1472 // CNSmlDSContent::SaveCurrentIndex |
|
1473 // Saves the current index. |
|
1474 // ----------------------------------------------------------------------------- |
|
1475 // |
|
1476 void CNSmlDSContent::SaveCurrentIndex() |
|
1477 { |
|
1478 iSavedIndex = iIndex; |
|
1479 } |
|
1480 |
|
1481 // ----------------------------------------------------------------------------- |
|
1482 // CNSmlDSContent::SetIndexToSaved |
|
1483 // Sets the index to the previously saved index. |
|
1484 // ----------------------------------------------------------------------------- |
|
1485 // |
|
1486 void CNSmlDSContent::SetIndexToSaved() |
|
1487 { |
|
1488 iIndex = iSavedIndex; |
|
1489 } |
|
1490 |
|
1491 // ----------------------------------------------------------------------------- |
|
1492 // CNSmlDSContent::SetCurrentItemWritten |
|
1493 // Sets the current item's state in the LUID buffer processed. |
|
1494 // ----------------------------------------------------------------------------- |
|
1495 // |
|
1496 void CNSmlDSContent::SetCurrentItemWritten() const |
|
1497 { |
|
1498 iStores[iIndex]->iLUIDBuffer->SetCurrentItemWritten(); |
|
1499 } |
|
1500 |
|
1501 // --------------------------------------------------------- |
|
1502 // CNSmlDSContent::SetInterrupted() |
|
1503 // |
|
1504 // --------------------------------------------------------- |
|
1505 void CNSmlDSContent::SetInterrupted() |
|
1506 { |
|
1507 iStores[iIndex]->iInterrupted = ETrue; |
|
1508 } |
|
1509 |
|
1510 // --------------------------------------------------------- |
|
1511 // CNSmlDSContent::SetImmediatelyInterrupted() |
|
1512 // |
|
1513 // --------------------------------------------------------- |
|
1514 void CNSmlDSContent::SetImmediatelyInterrupted() |
|
1515 { |
|
1516 iStores[iIndex]->iImmediatelyInterruption = ETrue; |
|
1517 } |
|
1518 |
|
1519 // --------------------------------------------------------- |
|
1520 // CNSmlDSContent::SetServerStatusError() |
|
1521 // |
|
1522 // --------------------------------------------------------- |
|
1523 void CNSmlDSContent::SetServerStatusError() |
|
1524 { |
|
1525 iStores[iIndex]->iStatusErrorInSyncLog = ETrue; |
|
1526 } |
|
1527 |
|
1528 // --------------------------------------------------------- |
|
1529 // CNSmlDSContent::SetInterruptedBeforeSync() |
|
1530 // |
|
1531 // --------------------------------------------------------- |
|
1532 void CNSmlDSContent::SetInterruptedBeforeSync() const |
|
1533 { |
|
1534 iStores[iIndex]->iInterruptedBeforeSync = ETrue; |
|
1535 } |
|
1536 |
|
1537 // --------------------------------------------------------- |
|
1538 // CNSmlDSContent::UpdateInterruptedFlags() |
|
1539 // |
|
1540 // --------------------------------------------------------- |
|
1541 void CNSmlDSContent::UpdateInterruptedFlags() |
|
1542 { |
|
1543 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
1544 { |
|
1545 if ( !iStores[i]->iInterrupted ) |
|
1546 { |
|
1547 iStores[i]->iImmediatelyInterruption = EFalse; |
|
1548 } |
|
1549 } |
|
1550 } |
|
1551 |
|
1552 // --------------------------------------------------------- |
|
1553 // CNSmlDSContent::SetSyncStatus() |
|
1554 // |
|
1555 // --------------------------------------------------------- |
|
1556 void CNSmlDSContent::SetSyncStatus( CNSmlDSAgent::TNSmlAgentSyncStatus aSyncStatus ) const |
|
1557 { |
|
1558 iStores[iIndex]->iSyncStatus = aSyncStatus; |
|
1559 } |
|
1560 |
|
1561 // --------------------------------------------------------- |
|
1562 // CNSmlDSContent::SetSyncStatusAll() |
|
1563 // |
|
1564 // --------------------------------------------------------- |
|
1565 void CNSmlDSContent::SetSyncStatusToAll( CNSmlDSAgent::TNSmlAgentSyncStatus aSyncStatus ) const |
|
1566 { |
|
1567 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
1568 { |
|
1569 if( !( iStores[i]->iSyncStatus == CNSmlDSAgent::EServerDataPartiallyUpdated && aSyncStatus == CNSmlDSAgent::ENoServerDataUpdated ) ) |
|
1570 { |
|
1571 iStores[i]->iSyncStatus = aSyncStatus; |
|
1572 } |
|
1573 } |
|
1574 } |
|
1575 |
|
1576 // --------------------------------------------------------- |
|
1577 // CNSmlDSContent::SetTypeAndDevCapsL() |
|
1578 // |
|
1579 // --------------------------------------------------------- |
|
1580 TInt CNSmlDSContent::SetTypeAndDevCapsL() const |
|
1581 { |
|
1582 TInt resultCode( KErrNotFound ); |
|
1583 |
|
1584 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
1585 { |
|
1586 if ( iStores[i]->iStoreOpened ) |
|
1587 { |
|
1588 CNSmlDbCaps* dbCaps( NULL ); |
|
1589 GetDevCapsFromAgentLogL( i, dbCaps ); |
|
1590 if ( dbCaps ) |
|
1591 { |
|
1592 CleanupStack::PushL( dbCaps ); |
|
1593 iHostClient->SetRemoteDataStoreFormatL( *dbCaps, iStores[i]->iImplementationUID, *iStores[i]->iStoreName, resultCode ); |
|
1594 CleanupStack::PopAndDestroy(); // dbCaps |
|
1595 } |
|
1596 } |
|
1597 } |
|
1598 |
|
1599 return resultCode; |
|
1600 } |
|
1601 |
|
1602 // --------------------------------------------------------- |
|
1603 // CNSmlDSContent::CheckValidRemoteDb() |
|
1604 // Checks if the remote database is same as source ref |
|
1605 // --------------------------------------------------------- |
|
1606 TBool CNSmlDSContent::CheckValidRemoteDbL(RPointerArray<CNSmlURI>& aSourceRefArr, TBool aResp) const |
|
1607 { |
|
1608 TBool dbFound; |
|
1609 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
1610 { |
|
1611 dbFound = EFalse; |
|
1612 for ( TInt j = 0; j < aSourceRefArr.Count(); j++ ) |
|
1613 { |
|
1614 if ( (aSourceRefArr[j])->IsEqualL( *iStores[i]->iRemoteDatabase,!aResp) ) |
|
1615 { |
|
1616 dbFound = ETrue; |
|
1617 continue; |
|
1618 } |
|
1619 else |
|
1620 { |
|
1621 if ( aResp ) |
|
1622 { |
|
1623 if ( (aSourceRefArr[j])->DatabaseMatchesL( iStores[i]->iRemoteDatabase->Database() ) ) |
|
1624 { |
|
1625 dbFound = ETrue; |
|
1626 continue; |
|
1627 } |
|
1628 } |
|
1629 } |
|
1630 } |
|
1631 |
|
1632 if( !dbFound ) |
|
1633 { |
|
1634 return EFalse; |
|
1635 } |
|
1636 } |
|
1637 return ETrue; |
|
1638 } |
|
1639 // --------------------------------------------------------- |
|
1640 // CNSmlDSContent::SetSavedPartnerDevCapsL() |
|
1641 // |
|
1642 // --------------------------------------------------------- |
|
1643 TInt CNSmlDSContent::SetSavedPartnerDevCapsL() |
|
1644 { |
|
1645 TInt resultCode( KErrNone ); |
|
1646 |
|
1647 CNSmlDbCaps* dbCaps; |
|
1648 GetDevCapsFromAgentLogL( iIndex, dbCaps ); |
|
1649 if ( dbCaps ) |
|
1650 { |
|
1651 CleanupStack::PushL( dbCaps ); |
|
1652 iHostClient->SetRemoteDataStoreFormatL( *dbCaps, iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, resultCode ); |
|
1653 CleanupStack::PopAndDestroy(); // dbCaps |
|
1654 } |
|
1655 |
|
1656 return resultCode; |
|
1657 } |
|
1658 |
|
1659 // --------------------------------------------------------- |
|
1660 // CNSmlDSContent::SetClientItemCountAsked() |
|
1661 // |
|
1662 // --------------------------------------------------------- |
|
1663 void CNSmlDSContent::SetClientItemCountAsked() const |
|
1664 { |
|
1665 iStores[iIndex]->iClientItemCountAsked = ETrue; |
|
1666 } |
|
1667 |
|
1668 // --------------------------------------------------------- |
|
1669 // CNSmlDSContent::SetServerItemCount() |
|
1670 // |
|
1671 // --------------------------------------------------------- |
|
1672 void CNSmlDSContent::SetServerItemCount( TInt aCount ) const |
|
1673 { |
|
1674 iStores[iIndex]->iServerItemCount = aCount; |
|
1675 } |
|
1676 |
|
1677 // --------------------------------------------------------- |
|
1678 // CNSmlDSContent::SetMaxObjSizeInServer() |
|
1679 // |
|
1680 // --------------------------------------------------------- |
|
1681 void CNSmlDSContent::SetMaxObjSizeInServer( TInt aSize ) const |
|
1682 { |
|
1683 iStores[iIndex]->iMaxObjSizeInServer = aSize; |
|
1684 } |
|
1685 |
|
1686 // --------------------------------------------------------- |
|
1687 // CNSmlDSContent::MaxObjSizeL() |
|
1688 // |
|
1689 // --------------------------------------------------------- |
|
1690 TInt CNSmlDSContent::MaxObjSizeL() const |
|
1691 { |
|
1692 TInt resultCode( KErrNone ); |
|
1693 TInt value( KNSmlMaxObjSize ); |
|
1694 value = iHostClient->MaxObjectSizeL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, resultCode ); |
|
1695 if ( value == 0 ) |
|
1696 { |
|
1697 value = KNSmlMaxObjSize; |
|
1698 } |
|
1699 return value; |
|
1700 } |
|
1701 |
|
1702 // ----------------------------------------------------------------------------- |
|
1703 // CNSmlDSContent::SetAsReceivedL |
|
1704 // Signals the current datastore that the given item has been received by the |
|
1705 // server. |
|
1706 // ----------------------------------------------------------------------------- |
|
1707 // |
|
1708 void CNSmlDSContent::SetAsReceivedL( TSmlDbItemUid aLUID ) const |
|
1709 { |
|
1710 TInt resultCode; |
|
1711 CNSmlDataItemUidSet* uidSet = new ( ELeave ) CNSmlDataItemUidSet; |
|
1712 CleanupStack::PushL( uidSet ); |
|
1713 uidSet->AddItem( aLUID ); |
|
1714 iHostClient->CommitChangeInfoL( *uidSet, iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, resultCode ); |
|
1715 CleanupStack::PopAndDestroy( uidSet ); |
|
1716 } |
|
1717 |
|
1718 // ----------------------------------------------------------------------------- |
|
1719 // CNSmlDSContent::BeginBatchL |
|
1720 // Sets the current datastore to batch mode. |
|
1721 // ----------------------------------------------------------------------------- |
|
1722 // |
|
1723 void CNSmlDSContent::BeginBatchL() |
|
1724 { |
|
1725 TInt resultCode; |
|
1726 iStores[iIndex]->iBatchModeOn = ETrue; |
|
1727 iHostClient->BeginBatchL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, resultCode ); |
|
1728 } |
|
1729 |
|
1730 // ----------------------------------------------------------------------------- |
|
1731 // CNSmlDSContent::CancelBatchL |
|
1732 // Cancels the ongoing batch mode. |
|
1733 // ----------------------------------------------------------------------------- |
|
1734 // |
|
1735 void CNSmlDSContent::CancelBatchL() |
|
1736 { |
|
1737 TInt resultCode; |
|
1738 iStores[iIndex]->iBatchModeOn = EFalse; |
|
1739 iHostClient->CancelBatchL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, resultCode ); |
|
1740 } |
|
1741 |
|
1742 // ----------------------------------------------------------------------------- |
|
1743 // CNSmlDSContent::CommitBatchL |
|
1744 // Commits all operations done during the batch mode. Batch mode ends after this |
|
1745 // call is completed. |
|
1746 // ----------------------------------------------------------------------------- |
|
1747 // |
|
1748 void CNSmlDSContent::CommitBatchL( RArray<TInt>& aResultArray, TInt& aResultCode ) |
|
1749 { |
|
1750 iStores[iIndex]->iBatchModeOn = EFalse; |
|
1751 iHostClient->CommitBatchL( aResultArray, iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, aResultCode ); |
|
1752 } |
|
1753 |
|
1754 // ----------------------------------------------------------------------------- |
|
1755 // CNSmlDSContent::BatchModeOn |
|
1756 // Checks if the current datastore is in the batch mode. |
|
1757 // ----------------------------------------------------------------------------- |
|
1758 // |
|
1759 TBool CNSmlDSContent::BatchModeOn() const |
|
1760 { |
|
1761 return iStores[iIndex]->iBatchModeOn; |
|
1762 } |
|
1763 |
|
1764 // ----------------------------------------------------------------------------- |
|
1765 // CNSmlDSContent::CreateItemL |
|
1766 // Creates new item to the current datastore. |
|
1767 // ----------------------------------------------------------------------------- |
|
1768 // |
|
1769 TInt CNSmlDSContent::CreateItemL( TSmlDbItemUid& aUid, TInt aSize, const TPtrC8 aMimeType, const TPtrC8 aMimeVersion, TSmlDbItemUid aParent ) const |
|
1770 { |
|
1771 TInt resultCode; |
|
1772 |
|
1773 iHostClient->CreateItemL( aUid, |
|
1774 aSize, |
|
1775 aParent, |
|
1776 aMimeType, |
|
1777 aMimeVersion, |
|
1778 iStores[iIndex]->iImplementationUID, |
|
1779 *iStores[iIndex]->iStoreName, |
|
1780 resultCode ); |
|
1781 |
|
1782 return resultCode; |
|
1783 } |
|
1784 |
|
1785 // ----------------------------------------------------------------------------- |
|
1786 // CNSmlDSContent::DeleteItemL |
|
1787 // Deletes an item from the current datastore. |
|
1788 // ----------------------------------------------------------------------------- |
|
1789 // |
|
1790 TInt CNSmlDSContent::DeleteItemL( const TSmlDbItemUid aUid, TBool aSoftDelete ) const |
|
1791 { |
|
1792 TInt resultCode; |
|
1793 |
|
1794 if ( aSoftDelete ) |
|
1795 { |
|
1796 iHostClient->SoftDeleteItemL( aUid, |
|
1797 iStores[iIndex]->iImplementationUID, |
|
1798 *iStores[iIndex]->iStoreName, |
|
1799 resultCode ); |
|
1800 } |
|
1801 else |
|
1802 { |
|
1803 iHostClient->DeleteItemL( aUid, |
|
1804 iStores[iIndex]->iImplementationUID, |
|
1805 *iStores[iIndex]->iStoreName, |
|
1806 resultCode ); |
|
1807 } |
|
1808 |
|
1809 return resultCode; |
|
1810 } |
|
1811 |
|
1812 // ----------------------------------------------------------------------------- |
|
1813 // CNSmlDSContent::MoveItemL |
|
1814 // Moves an item in the current datastore. |
|
1815 // ----------------------------------------------------------------------------- |
|
1816 // |
|
1817 TInt CNSmlDSContent::MoveItemL( const TSmlDbItemUid aUid, const TSmlDbItemUid aParent ) const |
|
1818 { |
|
1819 TInt resultCode; |
|
1820 |
|
1821 iHostClient->MoveItemL( aUid, |
|
1822 aParent, |
|
1823 iStores[iIndex]->iImplementationUID, |
|
1824 *iStores[iIndex]->iStoreName, |
|
1825 resultCode ); |
|
1826 |
|
1827 return resultCode; |
|
1828 } |
|
1829 |
|
1830 // ----------------------------------------------------------------------------- |
|
1831 // CNSmlDSContent::CommitItemL |
|
1832 // Commits the currently opened item. |
|
1833 // ----------------------------------------------------------------------------- |
|
1834 // |
|
1835 TInt CNSmlDSContent::CommitItemL() |
|
1836 { |
|
1837 TInt resultCode; |
|
1838 |
|
1839 iHostClient->CommitItemL( iStores[iIndex]->iImplementationUID, |
|
1840 *iStores[iIndex]->iStoreName, |
|
1841 resultCode ); |
|
1842 |
|
1843 return resultCode; |
|
1844 } |
|
1845 |
|
1846 // ----------------------------------------------------------------------------- |
|
1847 // CNSmlDSContent::WriteItemL |
|
1848 // Writes data to the currently opened item. |
|
1849 // ----------------------------------------------------------------------------- |
|
1850 // |
|
1851 void CNSmlDSContent::WriteItemL( const TDesC8& aData ) |
|
1852 { |
|
1853 TInt resultCode; |
|
1854 |
|
1855 iHostClient->WriteItemL( aData, |
|
1856 iStores[iIndex]->iImplementationUID, |
|
1857 *iStores[iIndex]->iStoreName, resultCode ); |
|
1858 } |
|
1859 |
|
1860 // ----------------------------------------------------------------------------- |
|
1861 // CNSmlDSContent::ReplaceItemL |
|
1862 // Replaces an item in the current datastore with a new one. |
|
1863 // ----------------------------------------------------------------------------- |
|
1864 // |
|
1865 TInt CNSmlDSContent::ReplaceItemL( const TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent, TBool aPartialUpdate ) const |
|
1866 { |
|
1867 TInt resultCode; |
|
1868 |
|
1869 iHostClient->ReplaceItemL( aUid, aSize, aParent, aPartialUpdate, iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, resultCode ); |
|
1870 |
|
1871 return resultCode; |
|
1872 } |
|
1873 |
|
1874 // ----------------------------------------------------------------------------- |
|
1875 // CNSmlDSContent::GetFilterL |
|
1876 // Gets filters from adapter. |
|
1877 // ----------------------------------------------------------------------------- |
|
1878 // |
|
1879 TInt CNSmlDSContent::GetFilterL( CNSmlFilter*& aFilter ) |
|
1880 { |
|
1881 TInt resultCode( KErrNone ); |
|
1882 |
|
1883 iHostClient->GetFilterL( iStores[iIndex]->iImplementationUID, *iStores[iIndex]->iStoreName, iStores[iIndex]->iFilters, aFilter, iStores[iIndex]->iFilterMatchType, resultCode ); |
|
1884 |
|
1885 return resultCode; |
|
1886 } |
|
1887 |
|
1888 // ----------------------------------------------------------------------------- |
|
1889 // CNSmlDSContent::IncreaseWarnings |
|
1890 // |
|
1891 // ----------------------------------------------------------------------------- |
|
1892 // |
|
1893 void CNSmlDSContent::IncreaseWarnings() const |
|
1894 { |
|
1895 ++iStores[iIndex]->iWarnings; |
|
1896 } |
|
1897 |
|
1898 // ----------------------------------------------------------------------------- |
|
1899 // CNSmlDSContent::UpdateSyncTypeL |
|
1900 // |
|
1901 // ----------------------------------------------------------------------------- |
|
1902 // |
|
1903 void CNSmlDSContent::UpdateSyncTypeL( const CArrayFix<HBufC8*>& aSyncTypeArray ) const |
|
1904 { |
|
1905 TInt syncTypeFlags( 0 ); |
|
1906 |
|
1907 for ( TInt i = 0; i < aSyncTypeArray.Count() ; i++ ) |
|
1908 { |
|
1909 TLex8 lexicalValue( *aSyncTypeArray[i] ); |
|
1910 TInt syncTypeInt; |
|
1911 |
|
1912 if ( lexicalValue.Val( syncTypeInt ) == KErrNone ) |
|
1913 { |
|
1914 switch ( syncTypeInt ) |
|
1915 { |
|
1916 case CNSmlDbCaps::ETwoWaySync: |
|
1917 syncTypeFlags += KNSmlTwoWayFlag; |
|
1918 break; |
|
1919 |
|
1920 case CNSmlDbCaps::ESlowTwoWaySync: |
|
1921 syncTypeFlags += KNSmlSlowTwoWayFlag; |
|
1922 break; |
|
1923 |
|
1924 case CNSmlDbCaps::EOneWaySyncFromClient: |
|
1925 syncTypeFlags += KNSmlOneWayFromClientFlag; |
|
1926 break; |
|
1927 |
|
1928 case CNSmlDbCaps::ERefreshSyncFromClient: |
|
1929 syncTypeFlags += KNSmlRefreshFromClientFlag; |
|
1930 break; |
|
1931 |
|
1932 case CNSmlDbCaps::EOneWaySyncFromServer: |
|
1933 syncTypeFlags += KNSmlOneWayFromServerFlag; |
|
1934 break; |
|
1935 |
|
1936 case CNSmlDbCaps::ERefreshSyncFromServer: |
|
1937 syncTypeFlags += KNSmlRefreshFromServerFlag; |
|
1938 break; |
|
1939 |
|
1940 case CNSmlDbCaps::EServerAlertedSync: |
|
1941 syncTypeFlags += KNSmlServerAlertedFlag; |
|
1942 break; |
|
1943 |
|
1944 default: |
|
1945 User::Leave( KErrGeneral ); |
|
1946 } |
|
1947 } |
|
1948 } |
|
1949 |
|
1950 iStores[iIndex]->iAgentLog->SetIntValueL( EAgentLogServerSyncTypes, syncTypeFlags ); |
|
1951 } |
|
1952 |
|
1953 // --------------------------------------------------------- |
|
1954 // CNSmlDSContent::UpdateSupportHierarchicalSyncL() |
|
1955 // |
|
1956 // --------------------------------------------------------- |
|
1957 void CNSmlDSContent::UpdateSupportHierarchicalSyncL( TInt aSupport ) const |
|
1958 { |
|
1959 iStores[iIndex]->iAgentLog->SetIntValueL( EAgentLogServerSupportsHierarchicalSync, aSupport ); |
|
1960 } |
|
1961 |
|
1962 // --------------------------------------------------------- |
|
1963 // CNSmlDSContent::UpdateCtCapsL() |
|
1964 // |
|
1965 // --------------------------------------------------------- |
|
1966 void CNSmlDSContent::UpdateCtCapsL( const RPointerArray<CNSmlDbCaps>& aDbCaps ) const |
|
1967 { |
|
1968 RPointerArray<CNSmlDbCaps> dbCapArray; |
|
1969 CleanupStack::PushL( TCleanupItem( DeleteRPointerArray, &dbCapArray ) ); |
|
1970 |
|
1971 dbCapArray.AppendL( aDbCaps[aDbCaps.Count() - 1] ); |
|
1972 |
|
1973 iStores[iIndex]->iAgentLog->SetServerDeviceInfoL( dbCapArray ); |
|
1974 |
|
1975 dbCapArray.Reset(); |
|
1976 |
|
1977 CleanupStack::Pop(); // dbCapArray |
|
1978 } |
|
1979 |
|
1980 // --------------------------------------------------------- |
|
1981 // CNSmlDSContent::UpdateFilterCapsL() |
|
1982 // |
|
1983 // --------------------------------------------------------- |
|
1984 void CNSmlDSContent::UpdateFilterCapsL( const CArrayFix<TNSmlFilterCapData>* aFilterCaps ) const |
|
1985 { |
|
1986 iStores[iIndex]->iAgentLog->SetServerFilterInfoL( aFilterCaps ); |
|
1987 } |
|
1988 |
|
1989 // --------------------------------------------------------- |
|
1990 // CNSmlDSContent::RemoveCtCapsL |
|
1991 // Empty CTCaps for initialising in Agent log |
|
1992 // --------------------------------------------------------- |
|
1993 void CNSmlDSContent::RemoveCtCapsL() const |
|
1994 { |
|
1995 RPointerArray<CNSmlDbCaps> emptyArray; |
|
1996 |
|
1997 iStores[iIndex]->iAgentLog->SetServerDeviceInfoL( emptyArray ); |
|
1998 emptyArray.ResetAndDestroy(); |
|
1999 emptyArray.Close(); |
|
2000 } |
|
2001 |
|
2002 // --------------------------------------------------------- |
|
2003 // CNSmlDSContent::RemoveFilterCapsL |
|
2004 // Empty FilterCaps for initialising in Agent log |
|
2005 // --------------------------------------------------------- |
|
2006 void CNSmlDSContent::RemoveFilterCapsL() const |
|
2007 { |
|
2008 CArrayFix<TNSmlFilterCapData>* emptyArray = new( ELeave ) CArrayFixFlat<TNSmlFilterCapData>( 1 ); |
|
2009 CleanupStack::PushL( emptyArray ); |
|
2010 iStores[iIndex]->iAgentLog->SetServerFilterInfoL( emptyArray ); |
|
2011 CleanupStack::PopAndDestroy(); // emptyArray |
|
2012 } |
|
2013 |
|
2014 // ----------------------------------------------------------------------------- |
|
2015 // CNSmlDSContent::FinalizeDatabasesL |
|
2016 // Makes final modifications to all opened datastores. |
|
2017 // ----------------------------------------------------------------------------- |
|
2018 // |
|
2019 void CNSmlDSContent::FinalizeDatabasesL() const |
|
2020 { |
|
2021 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
2022 { |
|
2023 if ( iStores[i]->iStoreOpened ) |
|
2024 { |
|
2025 if ( iStores[i]->iAgentLog->IntValueL( EAgentLogSlowSyncRequest ) == 1 ) |
|
2026 { |
|
2027 iStores[i]->iAgentLog->SetIntValueL( EAgentLogSlowSyncRequest, 0 ); |
|
2028 } |
|
2029 } |
|
2030 |
|
2031 iStores[i]->iStoreOpened = EFalse; |
|
2032 } |
|
2033 } |
|
2034 |
|
2035 // --------------------------------------------------------- |
|
2036 // CNSmlDSContent::UpdateSyncAnchorsL() |
|
2037 // Updates Client's Sync Anchors in Agent Log |
|
2038 // --------------------------------------------------------- |
|
2039 void CNSmlDSContent::UpdateSyncAnchorsL( const TTime& aAnchor ) const |
|
2040 { |
|
2041 for ( TInt i = 0; i < iStores.Count(); i++ ) |
|
2042 { |
|
2043 if ( !iStores[i]->iInterrupted ) |
|
2044 { |
|
2045 iStores[i]->iAgentLog->SetTimeValueL( EAgentLogLastSyncAnchor, aAnchor ); |
|
2046 } |
|
2047 } |
|
2048 } |
|
2049 |
|
2050 // ----------------------------------------------------------------------------- |
|
2051 // CNSmlDSContent::RemoveContent |
|
2052 // Removes the current content (datastore) from the content array. |
|
2053 // ----------------------------------------------------------------------------- |
|
2054 // |
|
2055 void CNSmlDSContent::RemoveContent() |
|
2056 { |
|
2057 delete iStores[iIndex]; |
|
2058 iStores.Remove( iIndex ); |
|
2059 iStores.Compress(); |
|
2060 } |
|
2061 |
|
2062 // ----------------------------------------------------------------------------- |
|
2063 // CNSmlDSContent::RemoveNotServerAlertedContents |
|
2064 // Removes non-server alerted contents from the content array. |
|
2065 // ----------------------------------------------------------------------------- |
|
2066 // |
|
2067 void CNSmlDSContent::RemoveNotServerAlertedContents() |
|
2068 { |
|
2069 TInt i( 0 ) ; |
|
2070 |
|
2071 while ( i < iStores.Count() ) |
|
2072 { |
|
2073 if ( !iStores[i]->iServerAlerted ) |
|
2074 { |
|
2075 delete iStores[i]; |
|
2076 iStores.Remove( i ); |
|
2077 iStores.Compress(); |
|
2078 } |
|
2079 else |
|
2080 { |
|
2081 ++i; |
|
2082 } |
|
2083 } |
|
2084 } |
|
2085 |
|
2086 // --------------------------------------------------------- |
|
2087 // CNSmlDSContent::GetDevCapsFromAgentLogL() |
|
2088 // Supported fields by the server are read from Agent Log |
|
2089 // --------------------------------------------------------- |
|
2090 void CNSmlDSContent::GetDevCapsFromAgentLogL( TInt aInd, CNSmlDbCaps*& aDbCaps ) const |
|
2091 { |
|
2092 RPointerArray<CNSmlDbCaps> dbCaps; |
|
2093 aDbCaps = NULL; |
|
2094 |
|
2095 iStores[aInd]->iAgentLog->GetServerDeviceInfoL( dbCaps ); |
|
2096 |
|
2097 if ( dbCaps.Count() == 1 ) |
|
2098 { |
|
2099 aDbCaps = dbCaps[0]; |
|
2100 dbCaps.Remove( 0 ); |
|
2101 TInt syncTypeFlags = iStores[aInd]->iAgentLog->IntValueL( EAgentLogServerSyncTypes ); |
|
2102 if ( syncTypeFlags & KNSmlTwoWayFlag) |
|
2103 { |
|
2104 aDbCaps->SetSyncType( CNSmlDbCaps::ETwoWaySync ); |
|
2105 } |
|
2106 if ( syncTypeFlags & KNSmlSlowTwoWayFlag) |
|
2107 { |
|
2108 aDbCaps->SetSyncType( CNSmlDbCaps::ESlowTwoWaySync ); |
|
2109 } |
|
2110 if ( syncTypeFlags & KNSmlOneWayFromClientFlag) |
|
2111 { |
|
2112 aDbCaps->SetSyncType( CNSmlDbCaps::EOneWaySyncFromClient ); |
|
2113 } |
|
2114 if ( syncTypeFlags & KNSmlRefreshFromClientFlag) |
|
2115 { |
|
2116 aDbCaps->SetSyncType( CNSmlDbCaps::ERefreshSyncFromClient ); |
|
2117 } |
|
2118 if ( syncTypeFlags & KNSmlOneWayFromServerFlag) |
|
2119 { |
|
2120 aDbCaps->SetSyncType( CNSmlDbCaps::EOneWaySyncFromServer ); |
|
2121 } |
|
2122 if ( syncTypeFlags & KNSmlRefreshFromServerFlag) |
|
2123 { |
|
2124 aDbCaps->SetSyncType( CNSmlDbCaps::ERefreshSyncFromServer ); |
|
2125 } |
|
2126 if ( syncTypeFlags & KNSmlServerAlertedFlag) |
|
2127 { |
|
2128 aDbCaps->SetSyncType( CNSmlDbCaps::EServerAlertedSync ); |
|
2129 } |
|
2130 } |
|
2131 dbCaps.ResetAndDestroy(); |
|
2132 } |
|
2133 |
|
2134 // --------------------------------------------------------- |
|
2135 // CNSmlDSContent::SyncTypeConv |
|
2136 // |
|
2137 // --------------------------------------------------------- |
|
2138 TBool CNSmlDSContent::SyncTypeConv( const TDesC8& aSyncType, CNSmlDbCaps::ENSmlSyncTypes& aDbCapsSyncType ) const |
|
2139 { |
|
2140 if ( aSyncType == KNSmlDSTwoWay || aSyncType == KNSmlDSTwoWayByServer ) |
|
2141 { |
|
2142 aDbCapsSyncType = CNSmlDbCaps::ETwoWaySync; |
|
2143 } |
|
2144 else |
|
2145 if ( aSyncType == KNSmlDSSlowSync ) |
|
2146 { |
|
2147 aDbCapsSyncType = CNSmlDbCaps::ESlowTwoWaySync; |
|
2148 } |
|
2149 else |
|
2150 if ( aSyncType == KNSmlDSOneWayFromClient || aSyncType == KNSmlDSOneWayFromClientByServer ) |
|
2151 { |
|
2152 aDbCapsSyncType = CNSmlDbCaps::EOneWaySyncFromClient; |
|
2153 } |
|
2154 else |
|
2155 if ( aSyncType == KNSmlDSRefreshFromClient || aSyncType == KNSmlDSRefreshFromClientByServer ) |
|
2156 { |
|
2157 aDbCapsSyncType = CNSmlDbCaps::ERefreshSyncFromClient; |
|
2158 } |
|
2159 else |
|
2160 if ( aSyncType == KNSmlDSOneWayFromServer || aSyncType == KNSmlDSOneWayFromServerByServer ) |
|
2161 { |
|
2162 aDbCapsSyncType = CNSmlDbCaps::EOneWaySyncFromServer; |
|
2163 } |
|
2164 else |
|
2165 if ( aSyncType == KNSmlDSRefreshFromServer || aSyncType == KNSmlDSRefreshFromServerByServer ) |
|
2166 { |
|
2167 aDbCapsSyncType = CNSmlDbCaps::ERefreshSyncFromServer; |
|
2168 } |
|
2169 else |
|
2170 { |
|
2171 return EFalse; |
|
2172 } |
|
2173 |
|
2174 return ETrue; |
|
2175 } |
|
2176 |
|
2177 // ----------------------------------------------------------------------------- |
|
2178 // CNSmlDSContent::IsFlagSet |
|
2179 // Checks if a bit is set in the given TUint. |
|
2180 // ----------------------------------------------------------------------------- |
|
2181 // |
|
2182 TBool CNSmlDSContent::IsFlagSet( const TUint& aValue, const TUint& aBit ) const |
|
2183 { |
|
2184 return( ( aValue & aBit ) == aBit ); |
|
2185 } |
|
2186 |
|
2187 // ----------------------------------------------------------------------------- |
|
2188 // CNSmlDSContent::InitEventL |
|
2189 // Inits the history log task info. |
|
2190 // ----------------------------------------------------------------------------- |
|
2191 // |
|
2192 void CNSmlDSContent::InitEventL( CSyncMLHistoryJob& aSyncLog, TInt aInd ) |
|
2193 { |
|
2194 iStores[aInd]->iTaskInfo = &aSyncLog.TaskById( iStores[aInd]->iTaskId ); |
|
2195 iStores[aInd]->iTaskInfo->iItemsAdded = 0; |
|
2196 iStores[aInd]->iTaskInfo->iItemsChanged = 0; |
|
2197 iStores[aInd]->iTaskInfo->iItemsDeleted = 0; |
|
2198 iStores[aInd]->iTaskInfo->iItemsMoved = 0; |
|
2199 iStores[aInd]->iTaskInfo->iItemsFailed = 0; |
|
2200 iStores[aInd]->iTaskInfo->iServerItemsAdded = 0; |
|
2201 iStores[aInd]->iTaskInfo->iServerItemsChanged = 0; |
|
2202 iStores[aInd]->iTaskInfo->iServerItemsDeleted = 0; |
|
2203 iStores[aInd]->iTaskInfo->iServerItemsMoved = 0; |
|
2204 iStores[aInd]->iTaskInfo->iServerItemsFailed = 0; |
|
2205 } |
|
2206 |
|
2207 // ----------------------------------------------------------------------------- |
|
2208 // CNSmlDSContent::UpdateServerId |
|
2209 // Updates current synchronisation profile's server ID. |
|
2210 // ----------------------------------------------------------------------------- |
|
2211 // |
|
2212 TInt CNSmlDSContent::UpdateServerIdL( TDesC& aServerId ) const |
|
2213 { |
|
2214 TInt status = KErrNone; |
|
2215 |
|
2216 if (iOldServerId->Size() == 0 ) |
|
2217 { |
|
2218 if ( *iOldServerId != aServerId ) |
|
2219 { |
|
2220 TInt resultCode; |
|
2221 iStores[0]->iAgentLog->SetServerIdL( *iOldServerId, aServerId ); |
|
2222 iHostClient->UpdateServerIdL( *iOldServerId, aServerId, resultCode ); |
|
2223 } |
|
2224 } |
|
2225 else if ( *iOldServerId != aServerId ) |
|
2226 { |
|
2227 status = TNSmlDSError::ESmlDSServerIdNotMatching; |
|
2228 } |
|
2229 |
|
2230 return status; |
|
2231 } |
|
2232 |
|
2233 // ----------------------------------------------------------------------------- |
|
2234 // CNSmlDSContent::RemoveFailedMappingsL |
|
2235 // Removes those mappings that were created under a failed atomic command. |
|
2236 // ----------------------------------------------------------------------------- |
|
2237 // |
|
2238 void CNSmlDSContent::RemoveFailedMappingsL( const TInt aAtomicId ) |
|
2239 { |
|
2240 if ( iStores[iIndex]->iMapContainer ) |
|
2241 { |
|
2242 iStores[iIndex]->iMapContainer->RemoveFailedAtomics( aAtomicId ); |
|
2243 } |
|
2244 } |
|
2245 |
|
2246 // ----------------------------------------------------------------------------- |
|
2247 // CNSmlDSContent::TaskId |
|
2248 // Returns current content's task id. |
|
2249 // ----------------------------------------------------------------------------- |
|
2250 // |
|
2251 TSmlTaskId CNSmlDSContent::TaskId() const |
|
2252 { |
|
2253 if ( !ContentIndexIsSet() ) |
|
2254 { |
|
2255 return 0; |
|
2256 } |
|
2257 |
|
2258 return iStores[iIndex]->iTaskId; |
|
2259 } |
|
2260 |
|
2261 // ----------------------------------------------------------------------------- |
|
2262 // CNSmlDSContent::TaskId |
|
2263 // Sets current content's task id. |
|
2264 // ----------------------------------------------------------------------------- |
|
2265 // |
|
2266 void CNSmlDSContent::TaskId( const TSmlTaskId aId ) |
|
2267 { |
|
2268 iStores[iIndex]->iTaskId = aId; |
|
2269 } |
|
2270 |
|
2271 // ----------------------------------------------------------------------------- |
|
2272 // CNSmlDSContent::IncreaseItemsAdded |
|
2273 // Increases the counter of added items. |
|
2274 // ----------------------------------------------------------------------------- |
|
2275 // |
|
2276 void CNSmlDSContent::IncreaseItemsAdded() const |
|
2277 { |
|
2278 ++iStores[iIndex]->iTaskInfo->iItemsAdded; |
|
2279 } |
|
2280 |
|
2281 // ----------------------------------------------------------------------------- |
|
2282 // CNSmlDSContent::IncreaseItemsChanged |
|
2283 // Increases the counter of changed items. |
|
2284 // ----------------------------------------------------------------------------- |
|
2285 // |
|
2286 void CNSmlDSContent::IncreaseItemsChanged() const |
|
2287 { |
|
2288 ++iStores[iIndex]->iTaskInfo->iItemsChanged; |
|
2289 } |
|
2290 |
|
2291 // ----------------------------------------------------------------------------- |
|
2292 // CNSmlDSContent::IncreaseItemsDeleted |
|
2293 // Increases the counter of deleted items. |
|
2294 // ----------------------------------------------------------------------------- |
|
2295 // |
|
2296 void CNSmlDSContent::IncreaseItemsDeleted() const |
|
2297 { |
|
2298 ++iStores[iIndex]->iTaskInfo->iItemsDeleted; |
|
2299 } |
|
2300 |
|
2301 // ----------------------------------------------------------------------------- |
|
2302 // CNSmlDSContent::IncreaseItemsMoved |
|
2303 // Increases the counter of moved items. |
|
2304 // ----------------------------------------------------------------------------- |
|
2305 // |
|
2306 void CNSmlDSContent::IncreaseItemsMoved() const |
|
2307 { |
|
2308 ++iStores[iIndex]->iTaskInfo->iItemsMoved; |
|
2309 } |
|
2310 |
|
2311 // ----------------------------------------------------------------------------- |
|
2312 // CNSmlDSContent::IncreaseItemsFailed |
|
2313 // Increases the counter of failed items. |
|
2314 // ----------------------------------------------------------------------------- |
|
2315 // |
|
2316 void CNSmlDSContent::IncreaseItemsFailed() const |
|
2317 { |
|
2318 ++iStores[iIndex]->iTaskInfo->iItemsFailed; |
|
2319 } |
|
2320 |
|
2321 // ----------------------------------------------------------------------------- |
|
2322 // CNSmlDSContent::IncreaseServerItemsAdded |
|
2323 // Increases the counter of items added on the server. |
|
2324 // ----------------------------------------------------------------------------- |
|
2325 // |
|
2326 void CNSmlDSContent::IncreaseServerItemsAdded() const |
|
2327 { |
|
2328 ++iStores[iIndex]->iTaskInfo->iServerItemsAdded; |
|
2329 } |
|
2330 |
|
2331 // ----------------------------------------------------------------------------- |
|
2332 // CNSmlDSContent::IncreaseServerItemsChanged |
|
2333 // Increases the counter of items changed on the server. |
|
2334 // ----------------------------------------------------------------------------- |
|
2335 // |
|
2336 void CNSmlDSContent::IncreaseServerItemsChanged() const |
|
2337 { |
|
2338 ++iStores[iIndex]->iTaskInfo->iServerItemsChanged; |
|
2339 } |
|
2340 |
|
2341 // ----------------------------------------------------------------------------- |
|
2342 // CNSmlDSContent::IncreaseServerItemsDeleted |
|
2343 // Increases the counter of items deleted on the server. |
|
2344 // ----------------------------------------------------------------------------- |
|
2345 // |
|
2346 void CNSmlDSContent::IncreaseServerItemsDeleted() const |
|
2347 { |
|
2348 ++iStores[iIndex]->iTaskInfo->iServerItemsDeleted; |
|
2349 } |
|
2350 |
|
2351 // ----------------------------------------------------------------------------- |
|
2352 // CNSmlDSContent::IncreaseServerItemsMoved |
|
2353 // Increases the counter of items moved on the server. |
|
2354 // ----------------------------------------------------------------------------- |
|
2355 // |
|
2356 void CNSmlDSContent::IncreaseServerItemsMoved() const |
|
2357 { |
|
2358 ++iStores[iIndex]->iTaskInfo->iServerItemsMoved; |
|
2359 } |
|
2360 |
|
2361 // ----------------------------------------------------------------------------- |
|
2362 // CNSmlDSContent::IncreaseServerItemsFailed |
|
2363 // Increases the counter of items failed on the server. |
|
2364 // ----------------------------------------------------------------------------- |
|
2365 // |
|
2366 void CNSmlDSContent::IncreaseServerItemsFailed() const |
|
2367 { |
|
2368 ++iStores[iIndex]->iTaskInfo->iServerItemsFailed; |
|
2369 } |
|
2370 |
|
2371 // ----------------------------------------------------------------------------- |
|
2372 // CNSmlDSContent::PartiallyUpdated |
|
2373 // Checks if at least one change is applied to the local datastore. |
|
2374 // ----------------------------------------------------------------------------- |
|
2375 // |
|
2376 TBool CNSmlDSContent::PartiallyUpdated() const |
|
2377 { |
|
2378 return ( iStores[iIndex]->iTaskInfo->iItemsAdded | |
|
2379 iStores[iIndex]->iTaskInfo->iItemsChanged | |
|
2380 iStores[iIndex]->iTaskInfo->iItemsDeleted | |
|
2381 iStores[iIndex]->iTaskInfo->iItemsMoved ); |
|
2382 } |
|
2383 |
|
2384 // ----------------------------------------------------------------------------- |
|
2385 // CNSmlDSContent::MapSourceParent |
|
2386 // Maps a SourceParent to an existing LUID. |
|
2387 // ----------------------------------------------------------------------------- |
|
2388 // |
|
2389 TBool CNSmlDSContent::MapSourceParent( const TDesC8& aSourceParent, TSmlDbItemUid& aUid ) |
|
2390 { |
|
2391 if ( aUid == KDbItemUidRoot ) |
|
2392 { |
|
2393 return ETrue; |
|
2394 } |
|
2395 |
|
2396 if ( !iStores[iIndex]->iMapContainer ) |
|
2397 { |
|
2398 return EFalse; |
|
2399 } |
|
2400 |
|
2401 return iStores[iIndex]->iMapContainer->MapSourceParent( aSourceParent, aUid ); |
|
2402 } |
|
2403 |
|
2404 // ----------------------------------------------------------------------------- |
|
2405 // CNSmlDSContent::StoreNamesL |
|
2406 // Gets a list of current content's store names. |
|
2407 // ----------------------------------------------------------------------------- |
|
2408 // |
|
2409 CDesCArray* CNSmlDSContent::StoreNamesL() const |
|
2410 { |
|
2411 TInt result( KErrNone ); |
|
2412 CDesCArrayFlat* storeNames = new ( ELeave ) CDesCArrayFlat( 1 ); |
|
2413 |
|
2414 iHostClient->ListStoresL( storeNames, iStores[iIndex]->iImplementationUID, result ); |
|
2415 |
|
2416 return storeNames; |
|
2417 } |
|
2418 |
|
2419 // ----------------------------------------------------------------------------- |
|
2420 // CNSmlDSContent::SetUsedFiltersL |
|
2421 // Stores the set of filters used with the current content. |
|
2422 // ----------------------------------------------------------------------------- |
|
2423 // |
|
2424 void CNSmlDSContent::SetUsedFiltersL( RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterMatchType aFilterMatchType ) |
|
2425 { |
|
2426 iStores[iIndex]->iFilterMatchType = aFilterMatchType; |
|
2427 |
|
2428 for ( TInt i = 0; i < aFilters.Count(); i++ ) |
|
2429 { |
|
2430 iStores[iIndex]->iFilters.AppendL( aFilters[i] ); |
|
2431 } |
|
2432 } |
|
2433 |
|
2434 // ----------------------------------------------------------------------------- |
|
2435 // CNSmlDSContent::HasFilters |
|
2436 // Checks if filters are used. |
|
2437 // ----------------------------------------------------------------------------- |
|
2438 // |
|
2439 TBool CNSmlDSContent::HasFilters() const |
|
2440 { |
|
2441 return ( iStores[iIndex]->iFilters.Count() > 0 ); |
|
2442 } |
|
2443 |
|
2444 // <MAPINFO_RESEND_MOD_BEGIN> |
|
2445 |
|
2446 // --------------------------------------------------------- |
|
2447 // CNSmlDSContent::ScanMapContentL() |
|
2448 // Calls map loader function |
|
2449 // --------------------------------------------------------- |
|
2450 TInt CNSmlDSContent::ScanMapContentL( TRequestStatus &aStatus ) |
|
2451 { |
|
2452 DBG_FILE(_S8("CNSmlDSContent::ScanMapContentL begins")); |
|
2453 iCallerStatus = &aStatus; |
|
2454 *iCallerStatus = KRequestPending; |
|
2455 TRAPD( err, LoadMapInfoL()); |
|
2456 if( err != KErrNone) |
|
2457 { |
|
2458 iOldMapExists = EFalse; |
|
2459 if ( iStores[iIndex]->iMapContainer ) |
|
2460 { |
|
2461 delete iStores[iIndex]->iMapContainer; |
|
2462 iStores[iIndex]->iMapContainer = NULL; |
|
2463 } |
|
2464 } |
|
2465 User::RequestComplete(iCallerStatus, err); |
|
2466 DBG_FILE(_S8("CNSmlDSContent::ScanMapContentL ends")); |
|
2467 return err; |
|
2468 } |
|
2469 |
|
2470 // --------------------------------------------------------- |
|
2471 // CNSmlDSContent::PackupRequestL() |
|
2472 // To save the map information to the physical storage |
|
2473 // --------------------------------------------------------- |
|
2474 void CNSmlDSContent::PackupRequestL( const TTime& aAnchor ) |
|
2475 { |
|
2476 DBG_FILE(_S8("CNSmlDSContent::PackupRequestL begins")); |
|
2477 RMutex mutex; |
|
2478 if(mutex.OpenGlobal( KNSmlDSContentAtomicOperationName ) != KErrNone ) |
|
2479 mutex.CreateGlobal( KNSmlDSContentAtomicOperationName ); |
|
2480 mutex.Wait(); |
|
2481 SaveMapInfoL( aAnchor ); |
|
2482 mutex.Signal(); |
|
2483 mutex.Close(); |
|
2484 DBG_FILE(_S8("CNSmlDSContent::PackupRequestL ends")); |
|
2485 } |
|
2486 |
|
2487 // ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
2488 // CNSmlDSContent::SaveMapInfoL() |
|
2489 // Saves the map information to the physical storage and update the sync flags required for next sync to continue properly but not the last sync anchor |
|
2490 // ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
2491 void CNSmlDSContent::SaveMapInfoL( const TTime& aAnchor ) |
|
2492 { |
|
2493 DBG_FILE(_S8("CNSmlDSContent::SaveMapInfoL() begins")); |
|
2494 TBool found=EFalse; |
|
2495 SaveCurrentIndex(); |
|
2496 if(SetToFirst()) |
|
2497 { |
|
2498 do |
|
2499 { |
|
2500 if( iStores[iIndex]->iMapContainer ) |
|
2501 { |
|
2502 if( iStores[iIndex]->iAgentLog ) |
|
2503 { |
|
2504 if( iStores[iIndex]->iAgentLog->IsPresentL( iMapStreamUid ) ) |
|
2505 { |
|
2506 iStores[iIndex]->iAgentLog->DeleteStreamL( iMapStreamUid ); |
|
2507 } |
|
2508 MStreamBuf* sb = iStores[iIndex]->iAgentLog->OpenWriteStreamL( iMapStreamUid ); |
|
2509 RWriteStream ws( sb ); |
|
2510 DBG_FILE_CODE( iStores[iIndex]->iMapContainer->MapItemListSize(), _S8("CNSmlDSAgent::SaveMapInfoL(): MapItemListSize!")); |
|
2511 if( iStores[iIndex]->iMapContainer->MapItemListSize() > 0 ) |
|
2512 { |
|
2513 found = ETrue; |
|
2514 TTime now; |
|
2515 now.UniversalTime(); |
|
2516 iStores[iIndex]->iMapContainer->setMapAnchor( now ); |
|
2517 iStores[iIndex]->iMapContainer->setAppendToStore( EFalse ); |
|
2518 ws << *iStores[iIndex]->iMapContainer; |
|
2519 } |
|
2520 iStores[iIndex]->iAgentLog->CloseWriteStreamL( ETrue ); |
|
2521 } |
|
2522 } |
|
2523 } while(SetToNext()); |
|
2524 } |
|
2525 SetIndexToSaved(); |
|
2526 if( found ) |
|
2527 { |
|
2528 //UpdateSyncAnchorsL( aAnchor ); |
|
2529 } |
|
2530 DBG_FILE(_S8("CNSmlDSContent::SaveMapInfoL() ends")); |
|
2531 } |
|
2532 |
|
2533 // --------------------------------------------------------------------------------------------- |
|
2534 // CNSmlDSContent::CleanAllMapInfo() |
|
2535 // Cleans up the map information in the cash and physical storage for all the databases |
|
2536 // // ------------------------------------------------------------------------------------------ |
|
2537 void CNSmlDSContent::CleanAllMapInfo() |
|
2538 { |
|
2539 DBG_FILE(_S8("CNSmlDSAgent:: CleanAllMapInfo() begins")); |
|
2540 //Generally we will have map informaiton for only one type of database to be deleted in any sync |
|
2541 //In any case if more than one database has map information this will be useful |
|
2542 SaveCurrentIndex(); |
|
2543 if(SetToFirst()) |
|
2544 { |
|
2545 do |
|
2546 { |
|
2547 delete iStores[iIndex]->iMapContainer; |
|
2548 iStores[iIndex]->iMapContainer = NULL; |
|
2549 if( iStores[iIndex]->iAgentLog ) |
|
2550 { |
|
2551 TInt err; |
|
2552 TRAP(err, |
|
2553 { |
|
2554 if( iStores[iIndex]->iAgentLog->IsPresentL( iMapStreamUid ) ) |
|
2555 iStores[iIndex]->iAgentLog->DeleteStreamL( iMapStreamUid ); |
|
2556 } |
|
2557 ); |
|
2558 DBG_FILE_CODE( err, _S8("CNSmlDSContent::CleanAllMapInfo(): IsPresentL and DeleteStream executed!") ); |
|
2559 } |
|
2560 }while(SetToNext()); |
|
2561 } |
|
2562 SetIndexToSaved(); |
|
2563 DBG_FILE(_S8("CNSmlDSAgent:: CleanAllMapInfo() ends")); |
|
2564 } |
|
2565 |
|
2566 // ------------------------------------------------------------------ |
|
2567 // CNSmlDSContent::CheckDbIndex() |
|
2568 // Checks if a given index is a valid index of a database in a sync |
|
2569 // ------------------------------------------------------------------ |
|
2570 TBool CNSmlDSContent::CheckDbIndex(TInt aIndex){ |
|
2571 DBG_FILE(_S8("CNSmlDSContent::CheckDbIndex() starts")); |
|
2572 TBool ret =EFalse; |
|
2573 for ( TInt i = 0; i < iStores.Count(); i++){ |
|
2574 if ( i==aIndex ) |
|
2575 { |
|
2576 ret = ETrue; |
|
2577 break; |
|
2578 } |
|
2579 } |
|
2580 DBG_FILE(_S8("CNSmlDSContent::CheckDbIndex() ends")); |
|
2581 return ret; |
|
2582 } |
|
2583 |
|
2584 // -------------------------------------------------------------------------------------------------- |
|
2585 // CNSmlDSContent::CleanMapInfo() |
|
2586 // To clean up the map information in the cache as well as from physical storage for current database |
|
2587 // -------------------------------------------------------------------------------------------------- |
|
2588 void CNSmlDSContent::CleanMapInfo() |
|
2589 { |
|
2590 DBG_FILE(_S8("CNSmlDSContent::CleanMapInfo() starts")); |
|
2591 if( CheckDbIndex(iIndex) ) |
|
2592 { |
|
2593 delete iStores[iIndex]->iMapContainer; |
|
2594 iStores[iIndex]->iMapContainer = NULL; |
|
2595 if( iStores[iIndex]->iAgentLog ) |
|
2596 { |
|
2597 DBG_FILE(_S8("CNSmlDSContent::CleanMapInfo() - Trying to delete the present stream!")); |
|
2598 TInt err; |
|
2599 TRAP(err, |
|
2600 { |
|
2601 if( iStores[iIndex]->iAgentLog->IsPresentL(iMapStreamUid)) |
|
2602 { |
|
2603 DBG_FILE(_S8("CNSmlDSContent::CleanMapInfo(): iMapStreamUid is present!")); |
|
2604 iStores[iIndex]->iAgentLog->DeleteStreamL( iMapStreamUid ); |
|
2605 } |
|
2606 } |
|
2607 ); |
|
2608 DBG_FILE_CODE( err, _S8("CNSmlDSContent::CleanMapInfo(): IsPresentL and DeleteStream executed!") ); |
|
2609 } |
|
2610 } |
|
2611 else |
|
2612 { |
|
2613 DBG_FILE(_S8("CNSmlDSContent::CleanMapInfo() - Cleaning all mapinfo!")); |
|
2614 CleanAllMapInfo(); |
|
2615 } |
|
2616 DBG_FILE(_S8("CNSmlDSContent::CleanMapInfo() ends")); |
|
2617 } |
|
2618 |
|
2619 // ------------------------------------------------------------------- |
|
2620 // CNSmlDSContent::SetMapStreamUID() |
|
2621 // To Set the stream uid to be used for the map information streaming |
|
2622 // ------------------------------------------------------------------- |
|
2623 void CNSmlDSContent::SetMapStreamUID(TInt aMapStreamUid) |
|
2624 { |
|
2625 iMapStreamUid.iUid = aMapStreamUid; |
|
2626 } |
|
2627 |
|
2628 // ------------------------------------------------------------------ |
|
2629 // CNSmlDSContent::LoadMapInfoL() |
|
2630 // To Load the map information form the physical storage to the cache |
|
2631 // ------------------------------------------------------------------ |
|
2632 void CNSmlDSContent::LoadMapInfoL() |
|
2633 { |
|
2634 DBG_FILE(_S8("CNSmlDSContent::LoadMapInfoL() starts")); |
|
2635 if( iStores[iIndex]->iAgentLog && iStores[iIndex]->iAgentLog->IsPresentL(iMapStreamUid) ) |
|
2636 { |
|
2637 if ( iStores[iIndex]->iMapContainer ) |
|
2638 { |
|
2639 DBG_FILE(_S8("CNSmlDSContent::LoadMapInfoL(): deleting mapcontainer")); |
|
2640 delete iStores[iIndex]->iMapContainer; |
|
2641 iStores[iIndex]->iMapContainer = NULL; |
|
2642 } |
|
2643 DBG_FILE(_S8("CNSmlDSContent::LoadMapInfoL(): Creating new map container!")); |
|
2644 iStores[iIndex]->iMapContainer = CNSmlDSMapContainer::NewL(); |
|
2645 MStreamBuf* sb = iStores[iIndex]->iAgentLog->OpenReadStreamL( iMapStreamUid ); |
|
2646 RReadStream rs(sb); |
|
2647 TInt sz = rs.Source()->SizeL(); |
|
2648 if( sz > 0 ) |
|
2649 { |
|
2650 TRAPD( err1,rs >> *iStores[iIndex]->iMapContainer); |
|
2651 DBG_FILE_CODE( err1, _S8("CNSmlDSContent::LoadMapInfoL(): Tried to load mapcontainer!") ); |
|
2652 if( err1 != KErrNone ) |
|
2653 { |
|
2654 DBG_FILE(_S8("CNSmlDSContent::LoadMapInfoL() - Reading mapcontainer from stream successful!")); |
|
2655 iOldMapExists = ETrue; |
|
2656 } |
|
2657 } |
|
2658 iStores[iIndex]->iAgentLog->CloseReadStreamL(); |
|
2659 } |
|
2660 DBG_FILE(_S8("CNSmlDSContent::LoadMapInfoL() ends")); |
|
2661 } |
|
2662 |
|
2663 |
|
2664 // -------------------------------------------------------------------------------------- |
|
2665 // CNSmlDSContent::SetRemoveMap() |
|
2666 // To Delay the removal of map information from the cache to be removed at a later stage |
|
2667 // -------------------------------------------------------------------------------------- |
|
2668 void CNSmlDSContent::SetRemoveMap(TBool aRemoveMap) |
|
2669 { |
|
2670 if(iStores[iIndex]->iMapContainer) |
|
2671 { |
|
2672 iStores[iIndex]->iMapContainer->setRemoveMap(aRemoveMap); |
|
2673 } |
|
2674 } |
|
2675 // --------------------------------------------------------- |
|
2676 // CNSmlDSContent::SetRemoveMap() |
|
2677 // To Delay the removal of map information from the cache |
|
2678 // --------------------------------------------------------- |
|
2679 |
|
2680 TBool CNSmlDSContent::isMapRemovable() |
|
2681 { |
|
2682 if(iStores[iIndex]->iMapContainer) |
|
2683 { |
|
2684 return iStores[iIndex]->iMapContainer->isMapRemovable(); |
|
2685 } |
|
2686 return EFalse; |
|
2687 } |
|
2688 // ----------------------------------------------------------------------------------------------------------------------------------- |
|
2689 // CNSmlDSContent::RemoveRemovableMap() |
|
2690 // Removes the map information form the cache for only set removable map and corresponding to the current database under consideration |
|
2691 // ----------------------------------------------------------------------------------------------------------------------------------- |
|
2692 void CNSmlDSContent::RemoveRemovableMap() const |
|
2693 { |
|
2694 if ( iStores[iIndex]->iMapContainer && iStores[iIndex]->iMapContainer->isMapRemovable()) |
|
2695 { |
|
2696 delete iStores[iIndex]->iMapContainer; |
|
2697 iStores[iIndex]->iMapContainer = NULL; |
|
2698 } |
|
2699 } |
|
2700 |
|
2701 // ------------------------------------------------------------------------------------------- |
|
2702 // CNSmlDSContent::RemoveAllRemovableMap() |
|
2703 // Removes the map information form the cache for only set removable map for all the databases |
|
2704 // ------------------------------------------------------------------------------------------- |
|
2705 void CNSmlDSContent::RemoveAllRemovableMap() const |
|
2706 { |
|
2707 for ( TInt i = 0; i < iStores.Count() ; i++ ) |
|
2708 { |
|
2709 if ( iStores[i]->iMapContainer && iStores[i]->iMapContainer->isMapRemovable()) |
|
2710 { |
|
2711 delete iStores[i]->iMapContainer; |
|
2712 iStores[i]->iMapContainer = NULL; |
|
2713 } |
|
2714 } |
|
2715 } |
|
2716 |
|
2717 void CNSmlDSContent::SetResendUsed( TBool aResendUsed ) |
|
2718 { |
|
2719 iResendUsed = aResendUsed; |
|
2720 } |
|
2721 |
|
2722 TBool CNSmlDSContent::ResendUsed() const |
|
2723 { |
|
2724 return iResendUsed; |
|
2725 } |
|
2726 // <MAPINFO_RESEND_MOD_END> |
|
2727 |
|
2728 //RD_SUSPEND_RESUME |
|
2729 // --------------------------------------------------------- |
|
2730 // CNSmlDSContent::SetMapRemovable() |
|
2731 // |
|
2732 // --------------------------------------------------------- |
|
2733 |
|
2734 void CNSmlDSContent::SetMapRemovable() |
|
2735 { |
|
2736 for ( TInt i = 0; i < iStores.Count() ; i++ ) |
|
2737 { |
|
2738 if (iStores[i]->iMapContainer) |
|
2739 { |
|
2740 iStores[i]->iMapContainer->setRemoveMap(ETrue); |
|
2741 } |
|
2742 } |
|
2743 } |
|
2744 |
|
2745 //RD_SUSPEND_RESUME |
|
2746 // --------------------------------------------------------- |
|
2747 // CNSmlDSContent::SetSuspendedStateL() |
|
2748 // |
|
2749 // --------------------------------------------------------- |
|
2750 |
|
2751 void CNSmlDSContent::SetSuspendedStateL(TNSmlSyncSuspendedState aState) |
|
2752 { |
|
2753 iStores[iIndex]->iAgentLog->SetIntValueL( EAgentLogSyncSuspendedState, aState); |
|
2754 } |
|
2755 |
|
2756 //RD_SUSPEND_RESUME |
|
2757 // --------------------------------------------------------- |
|
2758 // CNSmlDSContent::SuspendedStateL() |
|
2759 // |
|
2760 // --------------------------------------------------------- |
|
2761 TNSmlSyncSuspendedState CNSmlDSContent::SuspendedStateL() |
|
2762 { |
|
2763 return (TNSmlSyncSuspendedState)iStores[iIndex]->iAgentLog->IntValueL( EAgentLogSyncSuspendedState ); |
|
2764 } |
|
2765 //RD_SUSPEND_RESUME |
|
2766 // --------------------------------------------------------- |
|
2767 // CNSmlDSContent::SetPreviousSyncType() |
|
2768 // |
|
2769 // --------------------------------------------------------- |
|
2770 |
|
2771 void CNSmlDSContent::SetPreviousSyncTypeL(TNSmlPreviousSyncType aPrevSyncType) |
|
2772 { |
|
2773 iStores[iIndex]->iAgentLog->SetIntValueL( EAgentLogPreviousSyncType, aPrevSyncType); |
|
2774 } |
|
2775 //RD_SUSPEND_RESUME |
|
2776 // --------------------------------------------------------- |
|
2777 // CNSmlDSContent::PreviousSyncType() |
|
2778 // |
|
2779 // --------------------------------------------------------- |
|
2780 |
|
2781 TNSmlPreviousSyncType CNSmlDSContent::PreviousSyncTypeL() |
|
2782 { |
|
2783 return(TNSmlPreviousSyncType)iStores[iIndex]->iAgentLog->IntValueL(EAgentLogPreviousSyncType); |
|
2784 |
|
2785 } |
|
2786 |
|
2787 //RD_SUSPEND_RESUME |
|
2788 // --------------------------------------------------------- |
|
2789 // CNSmlDSContent::SetPreviousClientSyncType() |
|
2790 // |
|
2791 // --------------------------------------------------------- |
|
2792 void CNSmlDSContent::SetPreviousClientSyncTypeL(TNSmlPreviousSyncType aPrevSyncType) |
|
2793 { |
|
2794 iStores[iIndex]->iAgentLog->SetIntValueL( EAgentLogPreviousClientSyncType, aPrevSyncType); |
|
2795 } |
|
2796 |
|
2797 //RD_SUSPEND_RESUME |
|
2798 // --------------------------------------------------------- |
|
2799 // CNSmlDSContent::PreviousClientSyncType() |
|
2800 // |
|
2801 // --------------------------------------------------------- |
|
2802 TNSmlPreviousSyncType CNSmlDSContent::PreviousClientSyncTypeL() |
|
2803 { |
|
2804 return(TNSmlPreviousSyncType)iStores[iIndex]->iAgentLog->IntValueL(EAgentLogPreviousClientSyncType); |
|
2805 } |
|
2806 // --------------------------------------------------------- |
|
2807 // CNSmlDSContent::ReadRepositoryL() |
|
2808 // |
|
2809 // --------------------------------------------------------- |
|
2810 |
|
2811 void CNSmlDSContent::ReadRepositoryL(TInt aKey, TInt& aValue) |
|
2812 { |
|
2813 const TUid KRepositoryId = KCRUidDataSyncInternalKeys; |
|
2814 |
|
2815 CRepository* rep = CRepository::NewLC(KRepositoryId); |
|
2816 TInt err = rep->Get(aKey, aValue); |
|
2817 User::LeaveIfError(err); |
|
2818 CleanupStack::PopAndDestroy(rep); |
|
2819 } |
|
2820 // End of File |