75 CVIMPSTStorageVPbkLocalStore* |
74 CVIMPSTStorageVPbkLocalStore* |
76 CVIMPSTStorageVPbkLocalStore::NewLC( const TDesC& aContactDb, |
75 CVIMPSTStorageVPbkLocalStore::NewLC( const TDesC& aContactDb, |
77 const TDesC& aServiceName, |
76 const TDesC& aServiceName, |
78 MVIMPSTStorageServiceCacheWriter& aServiceCacheWriter ) |
77 MVIMPSTStorageServiceCacheWriter& aServiceCacheWriter ) |
79 { |
78 { |
80 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::NewLC() begin") ); |
79 TRACER_AUTO; |
|
80 |
81 CVIMPSTStorageVPbkLocalStore* self = |
81 CVIMPSTStorageVPbkLocalStore* self = |
82 new (ELeave) CVIMPSTStorageVPbkLocalStore(aServiceCacheWriter); |
82 new (ELeave) CVIMPSTStorageVPbkLocalStore(aServiceCacheWriter); |
83 CleanupStack::PushL( self ); |
83 CleanupStack::PushL( self ); |
84 self->ConstructL( aContactDb, aServiceName ); |
84 self->ConstructL( aContactDb, aServiceName ); |
85 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::NewLC() end") ); |
85 |
86 return self; |
86 return self; |
87 } |
87 } |
88 // --------------------------------------------------------------------------- |
88 // --------------------------------------------------------------------------- |
89 // CVIMPSTStorageVPbkLocalStore::ConstructL |
89 // CVIMPSTStorageVPbkLocalStore::ConstructL |
90 // --------------------------------------------------------------------------- |
90 // --------------------------------------------------------------------------- |
91 // |
91 // |
92 void CVIMPSTStorageVPbkLocalStore::ConstructL( const TDesC& aContactDb, const TDesC& aServiceName ) |
92 void CVIMPSTStorageVPbkLocalStore::ConstructL( const TDesC& aContactDb, const TDesC& aServiceName ) |
93 { |
93 { |
94 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() begin") ); |
94 TRACER_AUTO; |
|
95 |
95 iVPbkStoreHandler = CVIMPSTStorageVPbkStoreHandler::NewL( aContactDb ,aServiceName, *this,ETrue ); |
96 iVPbkStoreHandler = CVIMPSTStorageVPbkStoreHandler::NewL( aContactDb ,aServiceName, *this,ETrue ); |
96 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() iVPbkStoreHandler created") ); |
97 TRACE( "iVPbkStoreHandler created" ); |
97 //construct the persistent store name |
98 //construct the persistent store name |
98 iLocalDBName = HBufC::NewL( aServiceName.Length()+ KStorageExtn().Length()); |
99 iLocalDBName = HBufC::NewL( aServiceName.Length()+ KStorageExtn().Length()); |
99 TPtr iLocalDBNamePtr = iLocalDBName->Des(); |
100 TPtr iLocalDBNamePtr = iLocalDBName->Des(); |
100 iLocalDBNamePtr.Append(aServiceName); |
101 iLocalDBNamePtr.Append(aServiceName); |
101 _LIT(KSpecialChar ,"/\\:*?<>\""); |
102 _LIT(KSpecialChar ,"/\\:*?<>\""); |
102 AknTextUtils :: StripCharacters(iLocalDBNamePtr,KSpecialChar); |
103 AknTextUtils :: StripCharacters(iLocalDBNamePtr,KSpecialChar); |
103 iLocalDBNamePtr.Append(KStorageExtn()); |
104 iLocalDBNamePtr.Append(KStorageExtn()); |
104 TRACE( T_LIT("iLocalDBNamePtr: %S"), &iLocalDBNamePtr ); |
105 TRACE( "iLocalDBNamePtr: %S", &iLocalDBNamePtr ); |
105 MVPbkContactStore* defaultStore = iVPbkStoreHandler->GetDefaultStoreL( aContactDb ); |
106 MVPbkContactStore* defaultStore = iVPbkStoreHandler->GetDefaultStoreL( aContactDb ); |
106 User::LeaveIfNull(defaultStore); |
107 User::LeaveIfNull(defaultStore); |
107 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() defaultStore retrived") ); |
108 TRACE("defaultStore retrived" ); |
108 iIdConverter = CVPbkContactIdConverter::NewL(*defaultStore); |
109 iIdConverter = CVPbkContactIdConverter::NewL(*defaultStore); |
109 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() iIdConverter created") ); |
110 TRACE( "iIdConverter created" ); |
110 User::LeaveIfError( iFs.Connect() ); |
111 User::LeaveIfError( iFs.Connect() ); |
111 // Open existing or create new database. |
112 // Open existing or create new database. |
112 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() connected to file server") ); |
113 TRACE( "connected to file server" ); |
113 if ( DbExists() ) |
114 if ( DbExists() ) |
114 { |
115 { |
115 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() local db exist") ); |
116 TRACE( "local db exist" ); |
116 OpenDbL(); |
117 OpenDbL(); |
117 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() open success") ); |
118 TRACE( "open success" ); |
118 } |
119 } |
119 else |
120 else |
120 { |
121 { |
121 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() local db not exist") ); |
122 TRACE("local db not exist" ); |
122 DoFreespaceLevelCheckL( KEmptyDbSize ); |
123 DoFreespaceLevelCheckL( KEmptyDbSize ); |
123 CreateDbL(); |
124 CreateDbL(); |
124 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() local db created") ); |
125 TRACE("local db created"); |
125 } |
126 } |
126 OpenTableL(); |
127 OpenTableL(); |
127 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() OpenTableL success ") ); |
128 TRACE("OpenTableL success " ); |
128 iColset = iDb.ColSetL( KContactTable ); |
129 iColset = iDb.ColSetL( KContactTable ); |
129 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() iColset is set") ); |
130 TRACE( " iColset is set" ); |
130 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ConstructL() end") ); |
131 |
131 } |
132 } |
132 |
133 |
133 // --------------------------------------------------------------------------- |
134 // --------------------------------------------------------------------------- |
134 // CVIMPSTStorageVPbkLocalStore:: |
135 // CVIMPSTStorageVPbkLocalStore:: |
135 // ~CVIMPSTStorageVPbkLocalStore |
136 // ~CVIMPSTStorageVPbkLocalStore |
136 // --------------------------------------------------------------------------- |
137 // --------------------------------------------------------------------------- |
137 // |
138 // |
138 CVIMPSTStorageVPbkLocalStore::~CVIMPSTStorageVPbkLocalStore() |
139 CVIMPSTStorageVPbkLocalStore::~CVIMPSTStorageVPbkLocalStore() |
139 { |
140 { |
140 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::~CVIMPSTStorageVPbkLocalStore() begin") ); |
141 TRACER_AUTO; |
|
142 |
141 iRetrivedContactArray.ResetAndDestroy(); |
143 iRetrivedContactArray.ResetAndDestroy(); |
142 TRAP_IGNORE( ResetAndDestroyLocalArrayL() ); |
144 TRAP_IGNORE( ResetAndDestroyLocalArrayL() ); |
143 |
145 |
144 CloseTable(); |
146 CloseTable(); |
145 delete iColset; |
147 delete iColset; |
173 // not exist need to add |
175 // not exist need to add |
174 iFetchContactsToBeAdded.Compress(); |
176 iFetchContactsToBeAdded.Compress(); |
175 count = iFetchContactsToBeAdded.Count(); |
177 count = iFetchContactsToBeAdded.Count(); |
176 } |
178 } |
177 iFetchContactsToBeAdded.Reset(); |
179 iFetchContactsToBeAdded.Reset(); |
178 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ResetAndDestroyLocalArrayL() end") ); |
180 |
179 } |
181 } |
180 |
182 |
181 // ---------------------------------------------------------- |
183 // ---------------------------------------------------------- |
182 // CVIMPSTStorageVPbkLocalStore::LocalStore |
184 // CVIMPSTStorageVPbkLocalStore::LocalStore |
183 // ---------------------------------------------------------- |
185 // ---------------------------------------------------------- |
184 // |
186 // |
185 TBool CVIMPSTStorageVPbkLocalStore::LocalStore() const |
187 TBool CVIMPSTStorageVPbkLocalStore::LocalStore() const |
186 { |
188 { |
187 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::LocalStore() local store") ); |
189 TRACER_AUTO; |
188 return ETrue; |
190 return ETrue; |
189 } |
191 } |
190 // --------------------------------------------------------------------------- |
192 // --------------------------------------------------------------------------- |
191 // CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL |
193 // CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL |
192 // --------------------------------------------------------------------------- |
194 // --------------------------------------------------------------------------- |
193 // |
195 // |
194 void CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL(TVIMPSTVPbkStoreEvent aVPbkStoreEvent) |
196 void CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL(TVIMPSTVPbkStoreEvent aVPbkStoreEvent) |
195 { |
197 { |
196 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() begin") ); |
198 TRACER_AUTO; |
197 switch( aVPbkStoreEvent.iEventType ) |
199 switch( aVPbkStoreEvent.iEventType ) |
198 { |
200 { |
199 case EVPbkContactReadCompleted: |
201 case EVPbkContactReadCompleted: |
200 { |
202 { |
201 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactReadCompleted started") ); |
203 TRACE( " EVPbkContactReadCompleted started" ); |
202 iServiceCacheWriter.NotifyServiceViewL(TVIMPSTEnums::EStorageContactReadComplete); |
204 iServiceCacheWriter.NotifyServiceViewL(TVIMPSTEnums::EStorageContactReadComplete); |
203 if( iFetchStep == EFetchingCalled ) |
205 if( iFetchStep == EFetchingCalled ) |
204 { |
206 { |
205 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactReadCompleted EFetchingCalled ") ); |
207 TRACE( " EVPbkContactReadCompleted EFetchingCalled " ); |
206 IssueRequest(); |
208 IssueRequest(); |
207 } |
209 } |
208 iFetchStep = EContactReadComplete; |
210 iFetchStep = EContactReadComplete; |
209 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EContactReadComplete completed ") ); |
211 TRACE( "EContactReadComplete completed " ); |
210 break; |
212 break; |
211 } |
213 } |
212 case EVPbkContactReading: |
214 case EVPbkContactReading: |
213 { |
215 { |
214 // a contact entry has been created in virtual database store |
216 // a contact entry has been created in virtual database store |
215 // create the cache contact |
217 // create the cache contact |
216 TInt32 linkId = iIdConverter->LinkToIdentifier(*aVPbkStoreEvent.iContactLink ); |
218 TInt32 linkId = iIdConverter->LinkToIdentifier(*aVPbkStoreEvent.iContactLink ); |
217 TDbColNo colNo = iColset->ColNo( KContactId ); |
219 TDbColNo colNo = iColset->ColNo( KContactId ); |
218 if ( SeekRowL( colNo, linkId ) ) |
220 if ( SeekRowL( colNo, linkId ) ) |
219 { |
221 { |
220 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactReading contact") ); |
222 TRACE( "EVPbkContactReading contact" ); |
221 /* |
223 /* |
222 * This is local store, that is phone book and service tab shares only one cdb file. |
224 * This is local store, that is phone book and service tab shares only one cdb file. |
223 * in that case, if somebody edits the cdb file from contacts tab, then also we get the |
225 * in that case, if somebody edits the cdb file from contacts tab, then also we get the |
224 * callback, then checking for entry in db table makes sens.. |
226 * callback, then checking for entry in db table makes sens.. |
225 */ |
227 */ |
336 aVPbkStoreEvent.iAvatarContent, |
338 aVPbkStoreEvent.iAvatarContent, |
337 TVIMPSTEnums::EStorageContactFetching ); |
339 TVIMPSTEnums::EStorageContactFetching ); |
338 } |
340 } |
339 if(iFetchStep == EFetchingOn) |
341 if(iFetchStep == EFetchingOn) |
340 { |
342 { |
341 TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactSynchronizing fetchin on" ) ); |
343 TRACE( "EVPbkContactSynchronizing fetchin on" ); |
342 IssueRequest(); |
344 IssueRequest(); |
343 } |
345 } |
344 TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactSynchronizing completed" ) ); |
346 TRACE(" EVPbkContactSynchronizing completed" ); |
345 break; |
347 break; |
346 } |
348 } |
347 case EVPbkContactDeleted: |
349 case EVPbkContactDeleted: |
348 { |
350 { |
349 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactDeleted") ); |
351 TRACE( "EVPbkContactDeleted" ); |
350 TInt32 linkId = iIdConverter->LinkToIdentifier(*aVPbkStoreEvent.iContactLink ); |
352 TInt32 linkId = iIdConverter->LinkToIdentifier(*aVPbkStoreEvent.iContactLink ); |
351 // a contact entry has been deleted from virtual database store |
353 // a contact entry has been deleted from virtual database store |
352 TDbColNo colNo = iColset->ColNo( KContactId ); |
354 TDbColNo colNo = iColset->ColNo( KContactId ); |
353 if ( SeekRowL( colNo, linkId ) ) |
355 if ( SeekRowL( colNo, linkId ) ) |
354 { |
356 { |
355 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactDeleted found in db") ); |
357 TRACE( "EVPbkContactDeleted found in db" ); |
356 // contatc found in local database ,delete from local database |
358 // contatc found in local database ,delete from local database |
357 DeleteContactFromInternalStoreL( linkId ); |
359 DeleteContactFromInternalStoreL( linkId ); |
358 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactDeleted deleted from db") ); |
360 TRACE( "EVPbkContactDeleted deleted from db" ); |
359 // delete from cache contact |
361 // delete from cache contact |
360 iServiceCacheWriter.RemoveContactFromCacheL(*aVPbkStoreEvent.iContactLink, |
362 iServiceCacheWriter.RemoveContactFromCacheL(*aVPbkStoreEvent.iContactLink, |
361 TVIMPSTEnums::EStorageEventDeleteFromPbk ); |
363 TVIMPSTEnums::EStorageEventDeleteFromPbk ); |
362 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactDeleted deleted from cache") ); |
364 TRACE( "EVPbkContactDeleted deleted from cache" ); |
363 } |
365 } |
364 break; |
366 break; |
365 } |
367 } |
366 case EVPbkContactChanged: |
368 case EVPbkContactChanged: |
367 { |
369 { |
368 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactChanged ") ); |
370 TRACE( "EVPbkContactChanged "); |
369 TInt32 linkId = iIdConverter->LinkToIdentifier(*aVPbkStoreEvent.iContactLink ); |
371 TInt32 linkId = iIdConverter->LinkToIdentifier(*aVPbkStoreEvent.iContactLink ); |
370 TDbColNo colNo = iColset->ColNo( KContactId ); |
372 TDbColNo colNo = iColset->ColNo( KContactId ); |
371 if ( SeekRowL( colNo, linkId ) ) |
373 if ( SeekRowL( colNo, linkId ) ) |
372 { |
374 { |
373 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactChanged found in local db") ); |
375 TRACE( "EVPbkContactChanged found in local db" ); |
374 // found in the list update it |
376 // found in the list update it |
375 iServiceCacheWriter.UpdateCacheContactL(*aVPbkStoreEvent.iContactLink , |
377 iServiceCacheWriter.UpdateCacheContactL(*aVPbkStoreEvent.iContactLink , |
376 aVPbkStoreEvent.iUserId , |
378 aVPbkStoreEvent.iUserId , |
377 aVPbkStoreEvent.iDisplayName, |
379 aVPbkStoreEvent.iDisplayName, |
378 aVPbkStoreEvent.iAvatarContent ); |
380 aVPbkStoreEvent.iAvatarContent ); |
379 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactChanged changed in cache") ); |
381 TRACE( "EVPbkContactChanged changed in cache"); |
380 } |
382 } |
381 break; |
383 break; |
382 } |
384 } |
383 case EVPbkContactRetriving: |
385 case EVPbkContactRetriving: |
384 { |
386 { |
385 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactRetriving") ); |
387 TRACE( "EVPbkContactRetriving"); |
386 // in case of local we allow all |
388 // in case of local we allow all |
387 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactRetriving valid Id") ); |
389 TRACE( "EVPbkContactRetriving valid Id"); |
388 CVIMPSTStorageContact* retrivedContact = CVIMPSTStorageContact::NewL( aVPbkStoreEvent.iUserId , |
390 CVIMPSTStorageContact* retrivedContact = CVIMPSTStorageContact::NewL( aVPbkStoreEvent.iUserId , |
389 aVPbkStoreEvent.iDisplayName, |
391 aVPbkStoreEvent.iDisplayName, |
390 *aVPbkStoreEvent.iContactLink, |
392 *aVPbkStoreEvent.iContactLink, |
391 aVPbkStoreEvent.iAvatarContent); |
393 aVPbkStoreEvent.iAvatarContent); |
392 iRetrivedContactArray.Append( retrivedContact ); // takes the ownership of retrivedContact |
394 iRetrivedContactArray.Append( retrivedContact ); // takes the ownership of retrivedContact |
393 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkContactRetriving valid Id added") ); |
395 TRACE( "EVPbkContactRetriving valid Id added" ); |
394 // keep the backup of retrieved contacts |
396 // keep the backup of retrieved contacts |
395 // user can add later once it sent to server |
397 // user can add later once it sent to server |
396 break; |
398 break; |
397 } |
399 } |
398 case EVPbkUnknownChanges: |
400 case EVPbkUnknownChanges: |
399 { |
401 { |
400 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkUnknownChanges start") ); |
402 TRACE("EVPbkUnknownChanges start" ); |
401 DeleteAllContactFromInternalStoreL(); |
403 DeleteAllContactFromInternalStoreL(); |
402 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkUnknownChanges all delete from db") ); |
404 TRACE( " EVPbkUnknownChanges all delete from db" ); |
403 // unknow mean all contact deleted from store |
405 // unknow mean all contact deleted from store |
404 iServiceCacheWriter.RemoveAllCacheContactsL(); |
406 iServiceCacheWriter.RemoveAllCacheContactsL(); |
405 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() EVPbkUnknownChanges all delete from cache") ); |
407 TRACE( " EVPbkUnknownChanges all delete from cache" ); |
406 break; |
408 break; |
407 } |
409 } |
408 default: |
410 default: |
409 break; |
411 break; |
410 } |
412 } |
411 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL() end") ); |
413 |
412 } |
414 } |
413 |
415 |
414 |
416 |
415 // -------------------------------------------------------------------------- |
417 // -------------------------------------------------------------------------- |
416 // CVIMPSTStorageVPbkLocalStore::IssueRequest |
418 // CVIMPSTStorageVPbkLocalStore::IssueRequest |
417 // -------------------------------------------------------------------------- |
419 // -------------------------------------------------------------------------- |
418 // |
420 // |
419 void CVIMPSTStorageVPbkLocalStore::IssueRequest() |
421 void CVIMPSTStorageVPbkLocalStore::IssueRequest() |
420 { |
422 { |
421 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::IssueRequest() begin") ); |
423 TRACER_AUTO; |
422 if( !IsActive() ) |
424 if( !IsActive() ) |
423 { |
425 { |
424 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::IssueRequest() SetActive") ); |
426 TRACE( "SetActive" ); |
425 TRequestStatus* status = &iStatus; |
427 TRequestStatus* status = &iStatus; |
426 User::RequestComplete( status, KErrNone ); |
428 User::RequestComplete( status, KErrNone ); |
427 SetActive(); |
429 SetActive(); |
428 } |
430 } |
429 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::IssueRequest() begin") ); |
431 |
430 } |
432 } |
431 |
433 |
432 // -------------------------------------------------------------------------- |
434 // -------------------------------------------------------------------------- |
433 // CVIMPSTStorageVPbkLocalStore::RunL |
435 // CVIMPSTStorageVPbkLocalStore::RunL |
434 // -------------------------------------------------------------------------- |
436 // -------------------------------------------------------------------------- |
435 // |
437 // |
436 void CVIMPSTStorageVPbkLocalStore::RunL() |
438 void CVIMPSTStorageVPbkLocalStore::RunL() |
437 { |
439 { |
438 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RunL() begin") ); |
440 TRACER_AUTO; |
439 TInt count = iFetchContactsToBeAdded.Count(); |
441 TInt count = iFetchContactsToBeAdded.Count(); |
440 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RunL() count to be added = %d "),count ); |
442 TRACE( "count to be added = %d ",count ); |
441 if( !count ) |
443 if( !count ) |
442 { |
444 { |
443 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RunL() fetch completed " ) ); |
445 TRACE(" fetch completed " ); |
444 iFetchStep = EContactReadComplete; |
446 iFetchStep = EContactReadComplete; |
445 iServiceCacheWriter.NotifyServiceViewL( TVIMPSTEnums::EStorageContactFetchComplete ); |
447 iServiceCacheWriter.NotifyServiceViewL( TVIMPSTEnums::EStorageContactFetchComplete ); |
446 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RunL() fetch completed notification sent" ) ); |
448 TRACE( "fetch completed notification sent" ); |
447 } |
449 } |
448 else |
450 else |
449 { |
451 { |
450 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RunL() fetch in progress" ) ); |
452 TRACE( "fetch in progress" ); |
451 iFetchStep = EFetchingOn; |
453 iFetchStep = EFetchingOn; |
452 TVIMPSTContactInfo contactInfoToAdd = iFetchContactsToBeAdded[0]; |
454 TVIMPSTContactInfo contactInfoToAdd = iFetchContactsToBeAdded[0]; |
453 MVIMPSTStorageContact* exist = iServiceCacheWriter.FindCacheContactByUserId( *contactInfoToAdd.iUserId ); |
455 MVIMPSTStorageContact* exist = iServiceCacheWriter.FindCacheContactByUserId( *contactInfoToAdd.iUserId ); |
454 if( exist ) |
456 if( exist ) |
455 { |
457 { |
456 // contact is already exist ,send the notification about this |
458 // contact is already exist ,send the notification about this |
457 iServiceCacheWriter.NotifyServiceViewL(TVIMPSTEnums::EStorageContactFetchExistInStore, exist ); |
459 iServiceCacheWriter.NotifyServiceViewL(TVIMPSTEnums::EStorageContactFetchExistInStore, exist ); |
458 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RunL() fetch in progress id exist" ) ); |
460 TRACE( " fetch in progress id exist" ); |
459 // process next |
461 // process next |
460 IssueRequest(); |
462 IssueRequest(); |
461 } |
463 } |
462 else |
464 else |
463 { |
465 { |
464 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RunL() fetch in progress create id in store called" ) ); |
466 TRACE( "fetch in progress create id in store called" ); |
465 // pass the display NAme in place of NULL |
467 // pass the display NAme in place of NULL |
466 iVPbkStoreHandler->CreateVPbkContactL( *contactInfoToAdd.iUserId, *contactInfoToAdd.iDisplayName ); // process always 0th item |
468 iVPbkStoreHandler->CreateVPbkContactL( *contactInfoToAdd.iUserId, *contactInfoToAdd.iDisplayName ); // process always 0th item |
467 } |
469 } |
468 iFetchContactsToBeAdded.Remove( 0 ); |
470 iFetchContactsToBeAdded.Remove( 0 ); |
469 delete contactInfoToAdd.iUserId; |
471 delete contactInfoToAdd.iUserId; |
470 contactInfoToAdd.iUserId = NULL; |
472 contactInfoToAdd.iUserId = NULL; |
471 delete contactInfoToAdd.iDisplayName; |
473 delete contactInfoToAdd.iDisplayName; |
472 contactInfoToAdd.iDisplayName = NULL ; |
474 contactInfoToAdd.iDisplayName = NULL ; |
473 iFetchContactsToBeAdded.Compress(); |
475 iFetchContactsToBeAdded.Compress(); |
474 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RunL() fetch in progress iFetchContactsToBeAdded ,one entry removed" ) ); |
476 TRACE( "fetch in progress iFetchContactsToBeAdded ,one entry removed" ); |
475 } |
477 } |
476 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RunL() end") ); |
478 |
477 } |
479 } |
478 |
480 |
479 // -------------------------------------------------------------------------- |
481 // -------------------------------------------------------------------------- |
480 // CVIMPSTStorageVPbkLocalStore::DoCancel |
482 // CVIMPSTStorageVPbkLocalStore::DoCancel |
481 // -------------------------------------------------------------------------- |
483 // -------------------------------------------------------------------------- |
482 // |
484 // |
483 void CVIMPSTStorageVPbkLocalStore::DoCancel() |
485 void CVIMPSTStorageVPbkLocalStore::DoCancel() |
484 { |
486 { |
485 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::DoCancel()") ); |
487 TRACER_AUTO; |
486 } |
488 } |
487 |
489 |
488 // -------------------------------------------------------------------------- |
490 // -------------------------------------------------------------------------- |
489 // CVIMPSTStorageVPbkLocalStore::RunError |
491 // CVIMPSTStorageVPbkLocalStore::RunError |
490 // -------------------------------------------------------------------------- |
492 // -------------------------------------------------------------------------- |
491 // |
493 // |
492 TInt CVIMPSTStorageVPbkLocalStore::RunError( TInt aError ) |
494 TInt CVIMPSTStorageVPbkLocalStore::RunError( TInt aError ) |
493 { |
495 { |
494 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RunError()") ); |
496 TRACER_AUTO; |
495 return aError; |
497 return aError; |
496 } |
498 } |
497 |
499 |
498 ////////////////////////////////////////////////////////// |
500 ////////////////////////////////////////////////////////// |
499 // --------------------------------------------------------------------------- |
501 // --------------------------------------------------------------------------- |
502 // |
504 // |
503 TInt CVIMPSTStorageVPbkLocalStore::CreateVPbkContactL(const TDesC& aUserId, |
505 TInt CVIMPSTStorageVPbkLocalStore::CreateVPbkContactL(const TDesC& aUserId, |
504 const TDesC& aDisplayName , |
506 const TDesC& aDisplayName , |
505 TBool aInvitationAutoAccept /* = EFalse */ ) |
507 TBool aInvitationAutoAccept /* = EFalse */ ) |
506 { |
508 { |
507 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateVPbkContactL() begin") ); |
509 TRACER_AUTO; |
508 TInt error = KErrGeneral; |
510 TInt error = KErrGeneral; |
509 if( aInvitationAutoAccept) |
511 if( aInvitationAutoAccept) |
510 { |
512 { |
511 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateVPbkContactL() autoaccept add contact") ); |
513 TRACE("autoaccept add contact" ); |
512 delete iInviteId; |
514 delete iInviteId; |
513 iInviteId = NULL; |
515 iInviteId = NULL; |
514 iInviteId = aUserId.AllocL(); |
516 iInviteId = aUserId.AllocL(); |
515 error = iVPbkStoreHandler->CreateVPbkContactL( *iInviteId,aDisplayName ); |
517 error = iVPbkStoreHandler->CreateVPbkContactL( *iInviteId,aDisplayName ); |
516 } |
518 } |
517 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateVPbkContactL() error = %d"),error ); |
519 TRACE( "error = %d",error ); |
518 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateVPbkContactL() begin") ); |
520 |
519 return error; |
521 return error; |
520 } |
522 } |
521 |
523 |
522 // --------------------------------------------------------------------------- |
524 // --------------------------------------------------------------------------- |
523 // CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL |
525 // CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL |
524 // --------------------------------------------------------------------------- |
526 // --------------------------------------------------------------------------- |
525 // |
527 // |
526 TInt CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL(const MVPbkContactLink& aContactLink) |
528 TInt CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL(const MVPbkContactLink& aContactLink) |
527 { |
529 { |
528 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL() begin") ); |
530 TRACER_AUTO;; |
529 TInt error = KErrNotFound; |
531 TInt error = KErrNotFound; |
530 // text now holds the name (or first field of the contact) |
532 // text now holds the name (or first field of the contact) |
531 TInt32 linkId = iIdConverter->LinkToIdentifier(aContactLink); |
533 TInt32 linkId = iIdConverter->LinkToIdentifier(aContactLink); |
532 // a contact entry has been deleted from virtual database store |
534 // a contact entry has been deleted from virtual database store |
533 TDbColNo colNo = iColset->ColNo( KContactId ); |
535 TDbColNo colNo = iColset->ColNo( KContactId ); |
534 if ( SeekRowL( colNo, linkId ) ) |
536 if ( SeekRowL( colNo, linkId ) ) |
535 { |
537 { |
536 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL() link exist in db") ); |
538 TRACE( "link exist in db" ); |
537 // contatc found in local database ,delete from local database |
539 // contatc found in local database ,delete from local database |
538 DeleteContactFromInternalStoreL( linkId ); |
540 DeleteContactFromInternalStoreL( linkId ); |
539 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL() link deleted from db") ); |
541 TRACE( "link deleted from db" ); |
540 // delete from cache contact |
542 // delete from cache contact |
541 error = iServiceCacheWriter.RemoveContactFromCacheL(aContactLink, |
543 error = iServiceCacheWriter.RemoveContactFromCacheL(aContactLink, |
542 TVIMPSTEnums::EStorageEventContactDelete ); |
544 TVIMPSTEnums::EStorageEventContactDelete ); |
543 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL() link deleted from cache") ); |
545 TRACE( "link deleted from cache" ); |
544 } |
546 } |
545 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL() error %d"),error ); |
547 TRACE("error %d",error ); |
546 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL() end") ); |
548 |
547 return error; |
549 return error; |
548 } |
550 } |
549 |
551 |
550 // --------------------------------------------------------------------------- |
552 // --------------------------------------------------------------------------- |
551 // CVIMPSTStorageVPbkLocalStore::RemoveAllVPbkContactsL |
553 // CVIMPSTStorageVPbkLocalStore::RemoveAllVPbkContactsL |
552 // --------------------------------------------------------------------------- |
554 // --------------------------------------------------------------------------- |
553 // |
555 // |
554 TInt CVIMPSTStorageVPbkLocalStore::RemoveAllVPbkContactsL() |
556 TInt CVIMPSTStorageVPbkLocalStore::RemoveAllVPbkContactsL() |
555 { |
557 { |
556 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RemoveAllVPbkContactsL() begin" ) ); |
558 TRACER_AUTO; |
557 iRetrivedContactArray.ResetAndDestroy(); |
559 iRetrivedContactArray.ResetAndDestroy(); |
558 DeleteAllContactFromInternalStoreL(); |
560 DeleteAllContactFromInternalStoreL(); |
559 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RemoveAllVPbkContactsL() all contacts deleted from db") ); |
561 TRACE( "all contacts deleted from db" ); |
560 iServiceCacheWriter.RemoveAllCacheContactsL(); |
562 iServiceCacheWriter.RemoveAllCacheContactsL(); |
561 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RemoveAllVPbkContactsL() all contacts deleted from cache") ); |
563 TRACE( "all contacts deleted from cache" ); |
562 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RemoveAllVPbkContactsL() end" ) ); |
564 |
563 return KErrNone;// local store : delete from local store ,own user has changed |
565 return KErrNone;// local store : delete from local store ,own user has changed |
564 } |
566 } |
565 // --------------------------------------------------------------------------- |
567 // --------------------------------------------------------------------------- |
566 // CVIMPSTStorageVPbkLocalStore::RetrieveVPbkXSPIdL |
568 // CVIMPSTStorageVPbkLocalStore::RetrieveVPbkXSPIdL |
567 // --------------------------------------------------------------------------- |
569 // --------------------------------------------------------------------------- |
568 // |
570 // |
569 TInt CVIMPSTStorageVPbkLocalStore::RetrieveVPbkXSPIdL(const TDesC8& aPackedLinks ) |
571 TInt CVIMPSTStorageVPbkLocalStore::RetrieveVPbkXSPIdL(const TDesC8& aPackedLinks ) |
570 { |
572 { |
571 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RetrieveVPbkXSPIdL() begin" ) ); |
573 TRACER_AUTO; |
572 iRetrivedContactArray.ResetAndDestroy(); |
574 iRetrivedContactArray.ResetAndDestroy(); |
573 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RetrieveVPbkXSPIdL() iRetrivedContactArray Reset" ) ); |
575 TRACE( " iRetrivedContactArray Reset" ); |
574 iVPbkStoreHandler->RetrieveVPbkContactL( aPackedLinks ); |
576 iVPbkStoreHandler->RetrieveVPbkContactL( aPackedLinks ); |
575 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RetrieveVPbkXSPIdL() iRetrivedContactArray count= %d " ),iRetrivedContactArray.Count() ); |
577 TRACE( "iRetrivedContactArray count= %d " ,iRetrivedContactArray.Count() ); |
576 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RetrieveVPbkXSPIdL() end " ) ); |
578 |
577 return iRetrivedContactArray.Count(); |
579 return iRetrivedContactArray.Count(); |
578 } |
580 } |
579 |
581 |
580 // --------------------------------------------------------------------------- |
582 // --------------------------------------------------------------------------- |
581 // CVIMPSTStorageVPbkLocalStore::GetRetrieveVPbkXSPIdL |
583 // CVIMPSTStorageVPbkLocalStore::GetRetrieveVPbkXSPIdL |
582 // --------------------------------------------------------------------------- |
584 // --------------------------------------------------------------------------- |
583 // |
585 // |
584 const TDesC& CVIMPSTStorageVPbkLocalStore::GetRetrieveVPbkXSPIdL(TInt aIndex ) |
586 const TDesC& CVIMPSTStorageVPbkLocalStore::GetRetrieveVPbkXSPIdL(TInt aIndex ) |
585 { |
587 { |
586 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::GetRetrieveVPbkXSPIdL() begin" ) ); |
588 TRACER_AUTO; |
587 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::GetRetrieveVPbkXSPIdL() aIndex = %d" ),aIndex ); |
589 TRACE( "aIndex = %d" ,aIndex ); |
588 MVIMPSTStorageContact* contact = NULL; |
590 MVIMPSTStorageContact* contact = NULL; |
589 if( aIndex >= 0 && aIndex < iRetrivedContactArray.Count() ) |
591 if( aIndex >= 0 && aIndex < iRetrivedContactArray.Count() ) |
590 { |
592 { |
591 contact = iRetrivedContactArray[ aIndex ]; |
593 contact = iRetrivedContactArray[ aIndex ]; |
592 } |
594 } |
593 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::GetRetrieveVPbkXSPIdL() end" ) ); |
595 |
594 return contact ? contact->UserId() : KNullDesC ; |
596 return contact ? contact->UserId() : KNullDesC ; |
595 } |
597 } |
596 // --------------------------------------------------------------------------- |
598 // --------------------------------------------------------------------------- |
597 // CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL |
599 // CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL |
598 // --------------------------------------------------------------------------- |
600 // --------------------------------------------------------------------------- |
599 // |
601 // |
600 TInt CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL( TInt aIndexToUse ) |
602 TInt CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL( TInt aIndexToUse ) |
601 { |
603 { |
602 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL() begin" ) ); |
604 TRACER_AUTO; |
603 if( aIndexToUse < 0 && aIndexToUse >= iRetrivedContactArray.Count() ) |
605 if( aIndexToUse < 0 && aIndexToUse >= iRetrivedContactArray.Count() ) |
604 { |
606 { |
605 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL() argument error" ) ); |
607 TRACE( " argument error" ); |
606 return KErrArgument; |
608 return KErrArgument; |
607 } |
609 } |
608 TInt error = KErrAlreadyExists; |
610 TInt error = KErrAlreadyExists; |
609 MVIMPSTStorageContact* retrivedContact = iRetrivedContactArray[ aIndexToUse ]; |
611 MVIMPSTStorageContact* retrivedContact = iRetrivedContactArray[ aIndexToUse ]; |
610 |
612 |
626 retrivedContact->AvatarContent() |
628 retrivedContact->AvatarContent() |
627 ); |
629 ); |
628 CleanupStack::PushL( contactToAdd ); |
630 CleanupStack::PushL( contactToAdd ); |
629 TInt32 linkId = iIdConverter->LinkToIdentifier( *link ); |
631 TInt32 linkId = iIdConverter->LinkToIdentifier( *link ); |
630 error = iServiceCacheWriter.AddStorageContactToCacheL( contactToAdd ); // contactToAdd ownership is transfered |
632 error = iServiceCacheWriter.AddStorageContactToCacheL( contactToAdd ); // contactToAdd ownership is transfered |
631 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL() adding to cache done" ) ); |
633 TRACE( " adding to cache done" ); |
632 if( error == KErrNone ) |
634 if( error == KErrNone ) |
633 { |
635 { |
634 CleanupStack::Pop(); // contactToAdd , Ownership is transfered to AddStorageContactToCacheL |
636 CleanupStack::Pop(); // contactToAdd , Ownership is transfered to AddStorageContactToCacheL |
635 WriteToStoreDbL( linkId ); |
637 WriteToStoreDbL( linkId ); |
636 } |
638 } |
637 else |
639 else |
638 { |
640 { |
639 CleanupStack::PopAndDestroy(); // contactToAdd |
641 CleanupStack::PopAndDestroy(); // contactToAdd |
640 } |
642 } |
641 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL() adding to db done" ) ); |
643 TRACE( " adding to db done" ); |
642 } |
644 } |
643 } |
645 } |
644 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL() error =%d" ),error ); |
646 TRACE( "error =%d" ,error ); |
645 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL() end" ) ); |
647 |
646 return error; |
648 return error; |
647 } |
649 } |
648 |
650 |
649 // --------------------------------------------------------------------------- |
651 // --------------------------------------------------------------------------- |
650 // CVIMPSTStorageVPbkLocalStore::deleteRetriveVPbkContactL |
652 // CVIMPSTStorageVPbkLocalStore::deleteRetriveVPbkContactL |
651 // --------------------------------------------------------------------------- |
653 // --------------------------------------------------------------------------- |
652 // |
654 // |
653 TInt CVIMPSTStorageVPbkLocalStore::deleteRetriveVPbkContactL( TInt aIndexToUse ) |
655 TInt CVIMPSTStorageVPbkLocalStore::deleteRetriveVPbkContactL( TInt aIndexToUse ) |
654 { |
656 { |
655 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::deleteRetriveVPbkContactL() begin" ) ); |
657 TRACER_AUTO; |
656 if( aIndexToUse < 0 && aIndexToUse >= iRetrivedContactArray.Count() ) |
658 if( aIndexToUse < 0 && aIndexToUse >= iRetrivedContactArray.Count() ) |
657 { |
659 { |
658 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::deleteRetriveVPbkContactL() argument error" ) ); |
660 TRACE( "argument error" ); |
659 return KErrArgument; |
661 return KErrArgument; |
660 } |
662 } |
661 MVIMPSTStorageContact* retrivedContact = iRetrivedContactArray[ aIndexToUse ]; |
663 MVIMPSTStorageContact* retrivedContact = iRetrivedContactArray[ aIndexToUse ]; |
662 MVPbkContactLink* contactLink = retrivedContact->ContactLink(); |
664 MVPbkContactLink* contactLink = retrivedContact->ContactLink(); |
663 // delete from cache contact |
665 // delete from cache contact |
665 MVPbkContactLink* link = contactLink->CloneLC(); |
667 MVPbkContactLink* link = contactLink->CloneLC(); |
666 contactsToDelete->AppendL( link ); // takes ownership |
668 contactsToDelete->AppendL( link ); // takes ownership |
667 CleanupStack::Pop(); // link |
669 CleanupStack::Pop(); // link |
668 TInt error = iVPbkStoreHandler->RemoveVPbkContactL( *contactsToDelete ); |
670 TInt error = iVPbkStoreHandler->RemoveVPbkContactL( *contactsToDelete ); |
669 CleanupStack::PopAndDestroy(); // contactsToDelete |
671 CleanupStack::PopAndDestroy(); // contactsToDelete |
670 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::deleteRetriveVPbkContactL() begin" ) ); |
672 |
671 return error; |
673 return error; |
672 } |
674 } |
673 // CVIMPSTStorageVPbkLocalStore::UpdateAvatarFieldDataL() |
675 // CVIMPSTStorageVPbkLocalStore::UpdateAvatarFieldDataL() |
674 // --------------------------------------------------------------------------- |
676 // --------------------------------------------------------------------------- |
675 // |
677 // |
676 TInt CVIMPSTStorageVPbkLocalStore::UpdateAvatarFieldDataL(const MVPbkContactLink& aContactLink, |
678 TInt CVIMPSTStorageVPbkLocalStore::UpdateAvatarFieldDataL(const MVPbkContactLink& aContactLink, |
677 const TDesC8& aAvatartData ) |
679 const TDesC8& aAvatartData ) |
678 { |
680 { |
679 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::UpdateAvatarFieldDataL()" ) ); |
681 TRACER_AUTO; |
680 return iVPbkStoreHandler->UpdateAvatarFieldDataL( aContactLink, aAvatartData ); |
682 return iVPbkStoreHandler->UpdateAvatarFieldDataL( aContactLink, aAvatartData ); |
681 } |
683 } |
682 |
684 |
683 // --------------------------------------------------------------------------- |
685 // --------------------------------------------------------------------------- |
684 // CVIMPSTStorageVPbkLocalStore::RemoveAvatarFieldL() |
686 // CVIMPSTStorageVPbkLocalStore::RemoveAvatarFieldL() |
685 // --------------------------------------------------------------------------- |
687 // --------------------------------------------------------------------------- |
686 // |
688 // |
687 TInt CVIMPSTStorageVPbkLocalStore::RemoveAvatarFieldL(MVPbkStoreContact& aStoreContact) |
689 TInt CVIMPSTStorageVPbkLocalStore::RemoveAvatarFieldL(MVPbkStoreContact& aStoreContact) |
688 { |
690 { |
689 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RemoveAvatarFieldL()" ) ); |
691 TRACER_AUTO; |
690 return iVPbkStoreHandler->RemoveAvatarFieldL( aStoreContact ); |
692 return iVPbkStoreHandler->RemoveAvatarFieldL( aStoreContact ); |
691 } |
693 } |
692 |
694 |
693 // --------------------------------------------------------------------------- |
695 // --------------------------------------------------------------------------- |
694 // CVIMPSTStorageVPbkLocalStore::AddVPbkFetchContactsL() |
696 // CVIMPSTStorageVPbkLocalStore::AddVPbkFetchContactsL() |
695 // --------------------------------------------------------------------------- |
697 // --------------------------------------------------------------------------- |
696 // |
698 // |
697 void CVIMPSTStorageVPbkLocalStore::AddVPbkFetchContactsL( RArray <TPtrC>& aFirstNameList, |
699 void CVIMPSTStorageVPbkLocalStore::AddVPbkFetchContactsL( RArray <TPtrC>& aFirstNameList, |
698 RArray <TPtrC> &aServiceField ) |
700 RArray <TPtrC> &aServiceField ) |
699 { |
701 { |
700 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::AddVPbkFetchContactsL() begin" ) ); |
702 TRACER_AUTO; |
701 // in case of server contacts delete all contacts |
703 // in case of server contacts delete all contacts |
702 ResetAndDestroyLocalArrayL(); |
704 ResetAndDestroyLocalArrayL(); |
703 TInt count = aServiceField.Count(); |
705 TInt count = aServiceField.Count(); |
704 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::AddVPbkFetchContactsL() count=%d" ),count ); |
706 TRACE( " count=%d" ,count ); |
705 for( TInt i = 0; i<count; i++ ) |
707 for( TInt i = 0; i<count; i++ ) |
706 { |
708 { |
707 TVIMPSTContactInfo contactInf = |
709 TVIMPSTContactInfo contactInf = |
708 { |
710 { |
709 aServiceField[i].AllocL() , |
711 aServiceField[i].AllocL() , |
797 iFileStore = NULL; |
799 iFileStore = NULL; |
798 iDb.Close(); |
800 iDb.Close(); |
799 iFs.Delete( storagePath ); |
801 iFs.Delete( storagePath ); |
800 User::Leave( err3 ); |
802 User::Leave( err3 ); |
801 } |
803 } |
802 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateDbL() end" ) ); |
804 |
803 } |
805 } |
804 |
806 |
805 // ----------------------------------------------------------- |
807 // ----------------------------------------------------------- |
806 // CVIMPSTStorageVPbkLocalStore::OpenDbL |
808 // CVIMPSTStorageVPbkLocalStore::OpenDbL |
807 // ----------------------------------------------------------- |
809 // ----------------------------------------------------------- |
808 // |
810 // |
809 void CVIMPSTStorageVPbkLocalStore::OpenDbL() |
811 void CVIMPSTStorageVPbkLocalStore::OpenDbL() |
810 { |
812 { |
811 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::OpenDbL() begin" ) ); |
813 TRACER_AUTO; |
812 TBuf< KMaxPath > storagePath; |
814 TBuf< KMaxPath > storagePath; |
813 storagePath.Append( KDbPath ); |
815 storagePath.Append( KDbPath ); |
814 storagePath.Append( *iLocalDBName ); |
816 storagePath.Append( *iLocalDBName ); |
815 iFileStore = CPermanentFileStore::OpenL( iFs, storagePath, EFileShareReadersOrWriters|EFileWrite ); |
817 iFileStore = CPermanentFileStore::OpenL( iFs, storagePath, EFileShareReadersOrWriters|EFileWrite ); |
816 iFileStore->SetTypeL( iFileStore->Layout() ); |
818 iFileStore->SetTypeL( iFileStore->Layout() ); |
817 iDb.OpenL( iFileStore, iFileStore->Root() ); |
819 iDb.OpenL( iFileStore, iFileStore->Root() ); |
818 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::OpenDbL() begin" ) ); |
820 |
819 } |
821 } |
820 |
822 |
821 // ----------------------------------------------------------- |
823 // ----------------------------------------------------------- |
822 // CVIMPSTStorageVPbkLocalStore::CloseDb |
824 // CVIMPSTStorageVPbkLocalStore::CloseDb |
823 // ----------------------------------------------------------- |
825 // ----------------------------------------------------------- |
824 // |
826 // |
825 void CVIMPSTStorageVPbkLocalStore::CloseDb() |
827 void CVIMPSTStorageVPbkLocalStore::CloseDb() |
826 { |
828 { |
827 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CloseDb() begin" ) ); |
829 TRACER_AUTO; |
828 delete iFileStore; |
830 delete iFileStore; |
829 iFileStore = NULL; |
831 iFileStore = NULL; |
830 iDb.Close(); |
832 iDb.Close(); |
831 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CloseDb() end" ) ); |
833 |
832 } |
834 } |
833 |
835 |
834 // ----------------------------------------------------------- |
836 // ----------------------------------------------------------- |
835 // CVIMPSTStorageVPbkLocalStore::CreateTablesL |
837 // CVIMPSTStorageVPbkLocalStore::CreateTablesL |
836 // ----------------------------------------------------------- |
838 // ----------------------------------------------------------- |
837 // |
839 // |
838 void CVIMPSTStorageVPbkLocalStore::CreateTablesL() |
840 void CVIMPSTStorageVPbkLocalStore::CreateTablesL() |
839 { |
841 { |
840 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateTablesL() begin" ) ); |
842 TRACER_AUTO; |
841 CDbColSet* contactId = CDbColSet::NewLC(); |
843 CDbColSet* contactId = CDbColSet::NewLC(); |
842 |
844 |
843 AddColumnL( KContactId, EDbColInt32, contactId ); |
845 AddColumnL( KContactId, EDbColInt32, contactId ); |
844 |
846 |
845 TInt err = iDb.CreateTable( KContactTable, *contactId ); |
847 TInt err = iDb.CreateTable( KContactTable, *contactId ); |
846 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateTablesL() err = %d" ),err ); |
848 TRACE( "err = %d" ,err ); |
847 User::LeaveIfError( err ); |
849 User::LeaveIfError( err ); |
848 |
850 |
849 CleanupStack::PopAndDestroy( contactId ); |
851 CleanupStack::PopAndDestroy( contactId ); |
850 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CreateTablesL() end" ) ); |
852 |
851 } |
853 } |
852 |
854 |
853 // ----------------------------------------------------------- |
855 // ----------------------------------------------------------- |
854 // CVIMPSTStorageVPbkLocalStore::AddColumnL |
856 // CVIMPSTStorageVPbkLocalStore::AddColumnL |
855 // ----------------------------------------------------------- |
857 // ----------------------------------------------------------- |
856 // |
858 // |
857 void CVIMPSTStorageVPbkLocalStore::AddColumnL( const TDesC& aName, TDbColType aType, CDbColSet* aColset ) |
859 void CVIMPSTStorageVPbkLocalStore::AddColumnL( const TDesC& aName, TDbColType aType, CDbColSet* aColset ) |
858 { |
860 { |
859 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::AddColumnL() begin" ) ); |
861 TRACER_AUTO; |
860 TDbCol column( aName, aType ); |
862 TDbCol column( aName, aType ); |
861 aColset->AddL( column ); |
863 aColset->AddL( column ); |
862 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::AddColumnL() end" ) ); |
864 |
863 } |
865 } |
864 |
866 |
865 // ----------------------------------------------------------- |
867 // ----------------------------------------------------------- |
866 // CVIMPSTStorageVPbkLocalStore::DoFreespaceLevelCheckL |
868 // CVIMPSTStorageVPbkLocalStore::DoFreespaceLevelCheckL |
867 // ----------------------------------------------------------- |
869 // ----------------------------------------------------------- |
868 // |
870 // |
869 void CVIMPSTStorageVPbkLocalStore::DoFreespaceLevelCheckL( TInt aSize ) |
871 void CVIMPSTStorageVPbkLocalStore::DoFreespaceLevelCheckL( TInt aSize ) |
870 { |
872 { |
871 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::DoFreespaceLevelCheckL() begin" ) ); |
873 TRACER_AUTO; |
872 if ( SysUtil::FFSSpaceBelowCriticalLevelL( &iFs, aSize ) ) |
874 if ( SysUtil::FFSSpaceBelowCriticalLevelL( &iFs, aSize ) ) |
873 { |
875 { |
874 User::Leave( KErrDiskFull ); |
876 User::Leave( KErrDiskFull ); |
875 } |
877 } |
876 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::DoFreespaceLevelCheckL() end" ) ); |
878 |
877 } |
879 } |
878 |
880 |
879 // ----------------------------------------------------------------------------- |
881 // ----------------------------------------------------------------------------- |
880 // CVIMPSTStorageVPbkLocalStore::DeleteAllContactFromInternalStoreL |
882 // CVIMPSTStorageVPbkLocalStore::DeleteAllContactFromInternalStoreL |
881 // ----------------------------------------------------------------------------- |
883 // ----------------------------------------------------------------------------- |
882 // |
884 // |
883 void CVIMPSTStorageVPbkLocalStore::DeleteAllContactFromInternalStoreL() |
885 void CVIMPSTStorageVPbkLocalStore::DeleteAllContactFromInternalStoreL() |
884 { |
886 { |
885 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::DeleteAllContactFromInternalStoreL() begin" ) ); |
887 TRACER_AUTO; |
886 iColset->ColNo( KContactId ); |
888 iColset->ColNo( KContactId ); |
887 iTable.LastL(); |
889 iTable.LastL(); |
888 while( !iTable.IsEmptyL() ) |
890 while( !iTable.IsEmptyL() ) |
889 { |
891 { |
890 iTable.GetL(); |
892 iTable.GetL(); |
891 iTable.DeleteL(); |
893 iTable.DeleteL(); |
892 iDb.Compact(); |
894 iDb.Compact(); |
893 // delete alwasy first item untill table is empty |
895 // delete alwasy first item untill table is empty |
894 iTable.LastL(); |
896 iTable.LastL(); |
895 } |
897 } |
896 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::DeleteAllContactFromInternalStoreL() end" ) ); |
898 |
897 } |
899 } |
898 // ---------------------------------------------------------- |
900 // ---------------------------------------------------------- |
899 // CVIMPSTStorageVPbkLocalStore::DeleteContactFromInternalStoreL |
901 // CVIMPSTStorageVPbkLocalStore::DeleteContactFromInternalStoreL |
900 // ---------------------------------------------------------- |
902 // ---------------------------------------------------------- |
901 // |
903 // |
902 void CVIMPSTStorageVPbkLocalStore::DeleteContactFromInternalStoreL( TInt32& aIdentifier ) |
904 void CVIMPSTStorageVPbkLocalStore::DeleteContactFromInternalStoreL( TInt32& aIdentifier ) |
903 { |
905 { |
904 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::DeleteContactFromInternalStoreL() begin" ) ); |
906 TRACER_AUTO; |
905 TDbColNo colNo = iColset->ColNo( KContactId ); |
907 TDbColNo colNo = iColset->ColNo( KContactId ); |
906 if ( SeekRowL( colNo, aIdentifier ) ) |
908 if ( SeekRowL( colNo, aIdentifier ) ) |
907 { |
909 { |
908 iTable.DeleteL(); |
910 iTable.DeleteL(); |
909 iDb.Compact(); |
911 iDb.Compact(); |
910 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::DeleteContactFromInternalStoreL() found deleted" ) ); |
912 TRACE( "found deleted" ); |
911 } |
913 } |
912 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::DeleteContactFromInternalStoreL() end" ) ); |
914 |
913 } |
915 } |
914 |
916 |
915 // ---------------------------------------------------------- |
917 // ---------------------------------------------------------- |
916 // CVIMPSTStorageVPbkLocalStore::WriteToStoreDbL |
918 // CVIMPSTStorageVPbkLocalStore::WriteToStoreDbL |
917 // ---------------------------------------------------------- |
919 // ---------------------------------------------------------- |
918 // |
920 // |
919 void CVIMPSTStorageVPbkLocalStore::WriteToStoreDbL( TInt32& aIdentifier ) |
921 void CVIMPSTStorageVPbkLocalStore::WriteToStoreDbL( TInt32& aIdentifier ) |
920 { |
922 { |
921 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::WriteToStoreDbL() begin" ) ); |
923 TRACER_AUTO; |
922 TDbColNo colNo = iColset->ColNo( KContactId ); |
924 TDbColNo colNo = iColset->ColNo( KContactId ); |
923 if (!SeekRowL( colNo, aIdentifier ) ) |
925 if (!SeekRowL( colNo, aIdentifier ) ) |
924 { |
926 { |
925 iTable.InsertL(); |
927 iTable.InsertL(); |
926 |
928 |
934 // recover |
936 // recover |
935 iTable.Cancel(); |
937 iTable.Cancel(); |
936 iTable.Reset(); |
938 iTable.Reset(); |
937 } |
939 } |
938 } |
940 } |
939 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::WriteToStoreDbL() end" ) ); |
941 |
940 } |
942 } |
941 // ---------------------------------------------------------- |
943 // ---------------------------------------------------------- |
942 // CVIMPSTStorageVPbkLocalStore::OpenTableL |
944 // CVIMPSTStorageVPbkLocalStore::OpenTableL |
943 // ---------------------------------------------------------- |
945 // ---------------------------------------------------------- |
944 // |
946 // |
945 void CVIMPSTStorageVPbkLocalStore::OpenTableL() |
947 void CVIMPSTStorageVPbkLocalStore::OpenTableL() |
946 { |
948 { |
947 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::OpenTableL() begin" ) ); |
949 TRACER_AUTO; |
948 TInt err( iTable.Open( iDb, KContactTable ) ); |
950 TInt err( iTable.Open( iDb, KContactTable ) ); |
949 if ( err != KErrNone ) |
951 if ( err != KErrNone ) |
950 { |
952 { |
951 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::OpenTableL() err =%d" ),err ); |
953 TRACE( " err =%d" ,err ); |
952 iTable.Close(); |
954 iTable.Close(); |
953 User::Leave( err ); |
955 User::Leave( err ); |
954 } |
956 } |
955 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::OpenTableL() end" ) ); |
957 |
956 } |
958 } |
957 |
959 |
958 // ---------------------------------------------------------- |
960 // ---------------------------------------------------------- |
959 // CVIMPSTStorageVPbkLocalStore::CloseTable |
961 // CVIMPSTStorageVPbkLocalStore::CloseTable |
960 // ---------------------------------------------------------- |
962 // ---------------------------------------------------------- |
961 // |
963 // |
962 void CVIMPSTStorageVPbkLocalStore::CloseTable() |
964 void CVIMPSTStorageVPbkLocalStore::CloseTable() |
963 { |
965 { |
964 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CloseTable() begin" ) ); |
966 TRACER_AUTO; |
965 iTable.Close(); |
967 iTable.Close(); |
966 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::CloseTable() end" ) ); |
968 |
967 } |
969 } |
968 |
970 |
969 // ---------------------------------------------------------- |
971 // ---------------------------------------------------------- |
970 // CVIMPSTStorageVPbkLocalStore::ReadFirstL |
972 // CVIMPSTStorageVPbkLocalStore::ReadFirstL |
971 // ---------------------------------------------------------- |
973 // ---------------------------------------------------------- |
972 // |
974 // |
973 TInt CVIMPSTStorageVPbkLocalStore::ReadFirstL( TInt32& aIdentifier ) |
975 TInt CVIMPSTStorageVPbkLocalStore::ReadFirstL( TInt32& aIdentifier ) |
974 { |
976 { |
975 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ReadFirstL() begin" ) ); |
977 TRACER_AUTO; |
976 iTable.BeginningL(); |
978 iTable.BeginningL(); |
977 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ReadFirstL() end" ) ); |
979 |
978 return ReadNextL( aIdentifier ); |
980 return ReadNextL( aIdentifier ); |
979 } |
981 } |
980 |
982 |
981 // ---------------------------------------------------------- |
983 // ---------------------------------------------------------- |
982 // CVIMPSTStorageVPbkLocalStore::ReadNextL |
984 // CVIMPSTStorageVPbkLocalStore::ReadNextL |
983 // ---------------------------------------------------------- |
985 // ---------------------------------------------------------- |
984 // |
986 // |
985 TInt CVIMPSTStorageVPbkLocalStore::ReadNextL( TInt32& aIdentifier ) |
987 TInt CVIMPSTStorageVPbkLocalStore::ReadNextL( TInt32& aIdentifier ) |
986 { |
988 { |
987 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ReadNextL() begin" ) ); |
989 TRACER_AUTO; |
988 TInt err = KErrNotFound; |
990 TInt err = KErrNotFound; |
989 if ( iTable.NextL() ) |
991 if ( iTable.NextL() ) |
990 { |
992 { |
991 TRAP( err, ReadCurrentL( aIdentifier ) ); |
993 TRAP( err, ReadCurrentL( aIdentifier ) ); |
992 // For some reason ReadCurrentL leaves with KErrEof, |
994 // For some reason ReadCurrentL leaves with KErrEof, |
993 // even if the contact was read succesfully. |
995 // even if the contact was read succesfully. |
994 } |
996 } |
995 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ReadNextL() err = %d" ),err ); |
997 TRACE( " err = %d" ,err ); |
996 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ReadNextL() end" ) ); |
998 |
997 return err; |
999 return err; |
998 } |
1000 } |
999 |
1001 |
1000 |
1002 |
1001 // ---------------------------------------------------------- |
1003 // ---------------------------------------------------------- |
1002 // CVIMPSTStorageVPbkLocalStore::ReadCurrentL |
1004 // CVIMPSTStorageVPbkLocalStore::ReadCurrentL |
1003 // ---------------------------------------------------------- |
1005 // ---------------------------------------------------------- |
1004 // |
1006 // |
1005 void CVIMPSTStorageVPbkLocalStore::ReadCurrentL( TInt32& aIdentifier ) |
1007 void CVIMPSTStorageVPbkLocalStore::ReadCurrentL( TInt32& aIdentifier ) |
1006 { |
1008 { |
1007 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ReadCurrentL() begin" ) ); |
1009 TRACER_AUTO; |
1008 iTable.GetL(); |
1010 iTable.GetL(); |
1009 // Get Column number for contact data size |
1011 // Get Column number for contact data size |
1010 TDbColNo colNo = iColset->ColNo( KContactId ); |
1012 TDbColNo colNo = iColset->ColNo( KContactId ); |
1011 aIdentifier = iTable.ColInt32(colNo); |
1013 aIdentifier = iTable.ColInt32(colNo); |
1012 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::ReadCurrentL() end" ) ); |
1014 |
1013 } |
1015 } |
1014 |
1016 |
1015 // ---------------------------------------------------------- |
1017 // ---------------------------------------------------------- |
1016 // CVIMPSTStorageVPbkLocalStore::SeekRowL |
1018 // CVIMPSTStorageVPbkLocalStore::SeekRowL |
1017 // ---------------------------------------------------------- |
1019 // ---------------------------------------------------------- |
1018 // |
1020 // |
1019 TBool CVIMPSTStorageVPbkLocalStore::SeekRowL( TDbColNo aColNo, TInt32& aIdentifier ) |
1021 TBool CVIMPSTStorageVPbkLocalStore::SeekRowL( TDbColNo aColNo, TInt32& aIdentifier ) |
1020 { |
1022 { |
1021 TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::SeekRowL() begin" ) ); |
1023 TRACER_AUTO; |
1022 TBool ret = EFalse; |
1024 TBool ret = EFalse; |
1023 iTable.BeginningL(); |
1025 iTable.BeginningL(); |
1024 while ( iTable.NextL() ) |
1026 while ( iTable.NextL() ) |
1025 { |
1027 { |
1026 iTable.GetL(); |
1028 iTable.GetL(); |