1 /* |
|
2 * Copyright (c) 2008 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: Class that provides handling of vpbk local store |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <AknUtils.h> |
|
20 #include "cvimpststoragevpbklocalstore.h" |
|
21 |
|
22 #include "cvimpststoragevpbkstorehandler.h" |
|
23 |
|
24 #include <MVPbkContactView.h> |
|
25 #include <CVPbkContactIdConverter.h> |
|
26 #include "mvimpststorageserviceview.h" |
|
27 #include "uiservicetabtracer.h" |
|
28 #include "tvimpstconsts.h" |
|
29 #include <CVPbkContactLinkArray.h> |
|
30 #include <MVPbkContactLink.h> |
|
31 #include "cvimpststoragecontact.h" |
|
32 #include "vimpststorageutils.h" |
|
33 |
|
34 #include <f32file.h> |
|
35 #include <sysutil.h> |
|
36 |
|
37 |
|
38 // ================= MEMBER FUNCTIONS ======================= |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CVIMPSTStorageVPbkLocalStore:: |
|
42 // CVIMPSTStorageVPbkLocalStore |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CVIMPSTStorageVPbkLocalStore:: CVIMPSTStorageVPbkLocalStore( MVIMPSTStorageServiceCacheWriter& aServiceCacheWriter ): |
|
46 CActive( CActive::EPriorityIdle ), |
|
47 iServiceCacheWriter( aServiceCacheWriter ), |
|
48 iFetchStep( EFetchingUnknown ) |
|
49 { |
|
50 TRACER_AUTO; |
|
51 CActiveScheduler::Add( this ); |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CVIMPSTStorageVPbkLocalStore::NewL |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CVIMPSTStorageVPbkLocalStore* CVIMPSTStorageVPbkLocalStore::NewL( const TDesC& aContactDb, |
|
59 const TDesC& aServiceName, |
|
60 MVIMPSTStorageServiceCacheWriter& aServiceCacheWriter ) |
|
61 { |
|
62 TRACER_AUTO; |
|
63 CVIMPSTStorageVPbkLocalStore* self = NewLC( aContactDb, |
|
64 aServiceName, |
|
65 aServiceCacheWriter); |
|
66 CleanupStack::Pop( self ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CVIMPSTStorageVPbkLocalStore::NewLC |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CVIMPSTStorageVPbkLocalStore* |
|
75 CVIMPSTStorageVPbkLocalStore::NewLC( const TDesC& aContactDb, |
|
76 const TDesC& aServiceName, |
|
77 MVIMPSTStorageServiceCacheWriter& aServiceCacheWriter ) |
|
78 { |
|
79 TRACER_AUTO; |
|
80 |
|
81 CVIMPSTStorageVPbkLocalStore* self = |
|
82 new (ELeave) CVIMPSTStorageVPbkLocalStore(aServiceCacheWriter); |
|
83 CleanupStack::PushL( self ); |
|
84 self->ConstructL( aContactDb, aServiceName ); |
|
85 |
|
86 return self; |
|
87 } |
|
88 // --------------------------------------------------------------------------- |
|
89 // CVIMPSTStorageVPbkLocalStore::ConstructL |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CVIMPSTStorageVPbkLocalStore::ConstructL( const TDesC& aContactDb, const TDesC& aServiceName ) |
|
93 { |
|
94 TRACER_AUTO; |
|
95 |
|
96 iVPbkStoreHandler = CVIMPSTStorageVPbkStoreHandler::NewL( aContactDb ,aServiceName, *this,ETrue ); |
|
97 TRACE( "iVPbkStoreHandler created" ); |
|
98 //construct the persistent store name |
|
99 iLocalDBName = HBufC::NewL( aServiceName.Length()+ KStorageExtn().Length()); |
|
100 TPtr iLocalDBNamePtr = iLocalDBName->Des(); |
|
101 iLocalDBNamePtr.Append(aServiceName); |
|
102 _LIT(KSpecialChar ,"/\\:*?<>\""); |
|
103 AknTextUtils :: StripCharacters(iLocalDBNamePtr,KSpecialChar); |
|
104 iLocalDBNamePtr.Append(KStorageExtn()); |
|
105 TRACE( "iLocalDBNamePtr: %S", &iLocalDBNamePtr ); |
|
106 MVPbkContactStore* defaultStore = iVPbkStoreHandler->GetDefaultStoreL( aContactDb ); |
|
107 User::LeaveIfNull(defaultStore); |
|
108 TRACE("defaultStore retrived" ); |
|
109 iIdConverter = CVPbkContactIdConverter::NewL(*defaultStore); |
|
110 TRACE( "iIdConverter created" ); |
|
111 User::LeaveIfError( iFs.Connect() ); |
|
112 // Open existing or create new database. |
|
113 TRACE( "connected to file server" ); |
|
114 if ( DbExists() ) |
|
115 { |
|
116 TRACE( "local db exist" ); |
|
117 OpenDbL(); |
|
118 TRACE( "open success" ); |
|
119 } |
|
120 else |
|
121 { |
|
122 TRACE("local db not exist" ); |
|
123 DoFreespaceLevelCheckL( KEmptyDbSize ); |
|
124 CreateDbL(); |
|
125 TRACE("local db created"); |
|
126 } |
|
127 OpenTableL(); |
|
128 TRACE("OpenTableL success " ); |
|
129 iColset = iDb.ColSetL( KContactTable ); |
|
130 TRACE( " iColset is set" ); |
|
131 |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CVIMPSTStorageVPbkLocalStore:: |
|
136 // ~CVIMPSTStorageVPbkLocalStore |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 CVIMPSTStorageVPbkLocalStore::~CVIMPSTStorageVPbkLocalStore() |
|
140 { |
|
141 TRACER_AUTO; |
|
142 |
|
143 iRetrivedContactArray.ResetAndDestroy(); |
|
144 TRAP_IGNORE( ResetAndDestroyLocalArrayL() ); |
|
145 |
|
146 CloseTable(); |
|
147 delete iColset; |
|
148 CloseDb(); |
|
149 iFs.Close(); |
|
150 |
|
151 delete iLocalDBName; |
|
152 delete iIdConverter; |
|
153 delete iInviteId; |
|
154 delete iVPbkStoreHandler; |
|
155 |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // CVIMPSTStorageVPbkLocalStore:: |
|
160 // ResetAndDestroyLocalArrayL |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CVIMPSTStorageVPbkLocalStore::ResetAndDestroyLocalArrayL() |
|
164 { |
|
165 TRACER_AUTO; |
|
166 TInt count = iFetchContactsToBeAdded.Count(); |
|
167 while( count ) |
|
168 { |
|
169 TVIMPSTContactInfo contactInf = iFetchContactsToBeAdded[ count-1 ]; |
|
170 iFetchContactsToBeAdded.Remove( count-1 ); |
|
171 delete contactInf.iUserId; |
|
172 contactInf.iUserId = NULL; |
|
173 delete contactInf.iDisplayName; |
|
174 contactInf.iDisplayName = NULL; |
|
175 // not exist need to add |
|
176 iFetchContactsToBeAdded.Compress(); |
|
177 count = iFetchContactsToBeAdded.Count(); |
|
178 } |
|
179 iFetchContactsToBeAdded.Reset(); |
|
180 |
|
181 } |
|
182 |
|
183 // ---------------------------------------------------------- |
|
184 // CVIMPSTStorageVPbkLocalStore::LocalStore |
|
185 // ---------------------------------------------------------- |
|
186 // |
|
187 TBool CVIMPSTStorageVPbkLocalStore::LocalStore() const |
|
188 { |
|
189 TRACER_AUTO; |
|
190 return ETrue; |
|
191 } |
|
192 // --------------------------------------------------------------------------- |
|
193 // CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void CVIMPSTStorageVPbkLocalStore::HandleVPbkStoreEventL(TVIMPSTVPbkStoreEvent aVPbkStoreEvent) |
|
197 { |
|
198 TRACER_AUTO; |
|
199 switch( aVPbkStoreEvent.iEventType ) |
|
200 { |
|
201 case EVPbkContactReadCompleted: |
|
202 { |
|
203 TRACE( " EVPbkContactReadCompleted started" ); |
|
204 iServiceCacheWriter.NotifyServiceViewL(TVIMPSTEnums::EStorageContactReadComplete); |
|
205 if( iFetchStep == EFetchingCalled ) |
|
206 { |
|
207 TRACE( " EVPbkContactReadCompleted EFetchingCalled " ); |
|
208 IssueRequest(); |
|
209 } |
|
210 iFetchStep = EContactReadComplete; |
|
211 TRACE( "EContactReadComplete completed " ); |
|
212 break; |
|
213 } |
|
214 case EVPbkContactReading: |
|
215 { |
|
216 // a contact entry has been created in virtual database store |
|
217 // create the cache contact |
|
218 TInt32 linkId = iIdConverter->LinkToIdentifier(*aVPbkStoreEvent.iContactLink ); |
|
219 TDbColNo colNo = iColset->ColNo( KContactId ); |
|
220 if ( SeekRowL( colNo, linkId ) ) |
|
221 { |
|
222 TRACE( "EVPbkContactReading contact" ); |
|
223 /* |
|
224 * This is local store, that is phone book and service tab shares only one cdb file. |
|
225 * in that case, if somebody edits the cdb file from contacts tab, then also we get the |
|
226 * callback, then checking for entry in db table makes sens.. |
|
227 */ |
|
228 /* |
|
229 * in case when the user adds a contact from the service tab, then it first tries to add it in the |
|
230 * cdb file, after that we get this callback, then , there is no way that it will be present in the |
|
231 * db table, in that case, we will not add it in the cache - which is wrong.. |
|
232 * so we need to make a differentiation, on how the contact was added.. whether from cotnacts tab |
|
233 * or from the service tab. --- to solve this issue.. we can store the userid in memberVariable.. |
|
234 * before making a add request to the VPBK (cdb file).. then in this function, we check if |
|
235 * the contactid is same as the member variable. aVPbkStoreEvent contains the userid that was added. |
|
236 * then if it matches, then we know that it was added from our service tab.. and then we can add it in our DB. |
|
237 */ |
|
238 // contatc found in local database ,add to storage |
|
239 iServiceCacheWriter.AddContactToCacheL (*aVPbkStoreEvent.iContactLink , |
|
240 aVPbkStoreEvent.iUserId , |
|
241 aVPbkStoreEvent.iDisplayName, |
|
242 aVPbkStoreEvent.iAvatarContent, |
|
243 TVIMPSTEnums::EStorageContactReading ); |
|
244 } |
|
245 |
|
246 break; |
|
247 } |
|
248 case EVPbkContactFetching: |
|
249 case EVPbkContactAdded: |
|
250 { |
|
251 // a contact entry has been created in virtual database store |
|
252 // create the cache contact |
|
253 TInt32 linkId = iIdConverter->LinkToIdentifier(*aVPbkStoreEvent.iContactLink ); |
|
254 TDbColNo colNo = iColset->ColNo( KContactId ); |
|
255 if( iFetchStep == EFetchingOn ) |
|
256 { |
|
257 TRACE( "EVPbkContactFetching contact" ); |
|
258 WriteToStoreDbL( linkId ); |
|
259 iServiceCacheWriter.AddContactToCacheL (*aVPbkStoreEvent.iContactLink , |
|
260 aVPbkStoreEvent.iUserId , |
|
261 aVPbkStoreEvent.iDisplayName , |
|
262 aVPbkStoreEvent.iAvatarContent, |
|
263 TVIMPSTEnums::EStorageContactFetching ); |
|
264 IssueRequest(); |
|
265 } |
|
266 else if ( SeekRowL( colNo, linkId ) ) |
|
267 { |
|
268 TRACE( " EVPbkContactAdded start" ); |
|
269 /* |
|
270 * This is local store, that is phone book and service tab shares only one cdb file. |
|
271 * in that case, if somebody edits the cdb file from contacts tab, then also we get the |
|
272 * callback, then checking for entry in db table makes sens.. |
|
273 */ |
|
274 /* |
|
275 * in case when the user adds a contact from the service tab, then it first tries to add it in the |
|
276 * cdb file, after that we get this callback, then , there is no way that it will be present in the |
|
277 * db table, in that case, we will not add it in the cache - which is wrong.. |
|
278 * so we need to make a differentiation, on how the contact was added.. whether from cotnacts tab |
|
279 * or from the service tab. --- to solve this issue.. we can store the userid in memberVariable.. |
|
280 * before making a add request to the VPBK (cdb file).. then in this function, we check if |
|
281 * the contactid is same as the member variable. aVPbkStoreEvent contains the userid that was added. |
|
282 * then if it matches, then we know that it was added from our service tab.. and then we can add it in our DB. |
|
283 */ |
|
284 // contatc found in local database ,add to storage |
|
285 iServiceCacheWriter.AddContactToCacheL (*aVPbkStoreEvent.iContactLink , |
|
286 aVPbkStoreEvent.iUserId , |
|
287 aVPbkStoreEvent.iDisplayName, |
|
288 aVPbkStoreEvent.iAvatarContent, |
|
289 TVIMPSTEnums::EStorageEventContactAddition ); |
|
290 TRACE( "EVPbkContactAdded completed" ); |
|
291 } |
|
292 else if( iInviteId ) |
|
293 { |
|
294 TRACE( "iInviteId accepted" ); |
|
295 if( IsSameContactIdL( *iInviteId, aVPbkStoreEvent.iUserId ) ) |
|
296 { |
|
297 WriteToStoreDbL( linkId ); |
|
298 iServiceCacheWriter.AddContactToCacheL (*aVPbkStoreEvent.iContactLink , |
|
299 aVPbkStoreEvent.iUserId , |
|
300 aVPbkStoreEvent.iDisplayName, |
|
301 aVPbkStoreEvent.iAvatarContent, |
|
302 TVIMPSTEnums::EStorageEventContactAddition ); |
|
303 delete iInviteId; |
|
304 iInviteId = NULL; |
|
305 } |
|
306 TRACE( "iInviteId accepted sucess" ); |
|
307 } |
|
308 break; |
|
309 } |
|
310 case EVPbkContactSynchronizing: |
|
311 { |
|
312 TRACE( "EVPbkContactSynchronizing " ); |
|
313 // a contact entry has been created in virtual database store |
|
314 // create the cache contact |
|
315 TInt32 linkId = iIdConverter->LinkToIdentifier(*aVPbkStoreEvent.iContactLink ); |
|
316 TDbColNo colNo = iColset->ColNo( KContactId ); |
|
317 if ( SeekRowL( colNo, linkId ) ) |
|
318 { |
|
319 /* |
|
320 * This is local store, that is phone book and service tab shares only one cdb file. |
|
321 * in that case, if somebody edits the cdb file from contacts tab, then also we get the |
|
322 * callback, then checking for entry in db table makes sens.. |
|
323 */ |
|
324 /* |
|
325 * in case when the user adds a contact from the service tab, then it first tries to add it in the |
|
326 * cdb file, after that we get this callback, then , there is no way that it will be present in the |
|
327 * db table, in that case, we will not add it in the cache - which is wrong.. |
|
328 * so we need to make a differentiation, on how the contact was added.. whether from cotnacts tab |
|
329 * or from the service tab. --- to solve this issue.. we can store the userid in memberVariable.. |
|
330 * before making a add request to the VPBK (cdb file).. then in this function, we check if |
|
331 * the contactid is same as the member variable. aVPbkStoreEvent contains the userid that was added. |
|
332 * then if it matches, then we know that it was added from our service tab.. and then we can add it in our DB. |
|
333 */ |
|
334 // contatc found in local database ,add to storage |
|
335 iServiceCacheWriter.AddContactToCacheL (*aVPbkStoreEvent.iContactLink , |
|
336 aVPbkStoreEvent.iUserId , |
|
337 aVPbkStoreEvent.iDisplayName, |
|
338 aVPbkStoreEvent.iAvatarContent, |
|
339 TVIMPSTEnums::EStorageContactFetching ); |
|
340 } |
|
341 if(iFetchStep == EFetchingOn) |
|
342 { |
|
343 TRACE( "EVPbkContactSynchronizing fetchin on" ); |
|
344 IssueRequest(); |
|
345 } |
|
346 TRACE(" EVPbkContactSynchronizing completed" ); |
|
347 break; |
|
348 } |
|
349 case EVPbkContactDeleted: |
|
350 { |
|
351 TRACE( "EVPbkContactDeleted" ); |
|
352 TInt32 linkId = iIdConverter->LinkToIdentifier(*aVPbkStoreEvent.iContactLink ); |
|
353 // a contact entry has been deleted from virtual database store |
|
354 TDbColNo colNo = iColset->ColNo( KContactId ); |
|
355 if ( SeekRowL( colNo, linkId ) ) |
|
356 { |
|
357 TRACE( "EVPbkContactDeleted found in db" ); |
|
358 // contatc found in local database ,delete from local database |
|
359 DeleteContactFromInternalStoreL( linkId ); |
|
360 TRACE( "EVPbkContactDeleted deleted from db" ); |
|
361 // delete from cache contact |
|
362 iServiceCacheWriter.RemoveContactFromCacheL(*aVPbkStoreEvent.iContactLink, |
|
363 TVIMPSTEnums::EStorageEventDeleteFromPbk ); |
|
364 TRACE( "EVPbkContactDeleted deleted from cache" ); |
|
365 } |
|
366 break; |
|
367 } |
|
368 case EVPbkContactChanged: |
|
369 { |
|
370 TRACE( "EVPbkContactChanged "); |
|
371 TInt32 linkId = iIdConverter->LinkToIdentifier(*aVPbkStoreEvent.iContactLink ); |
|
372 TDbColNo colNo = iColset->ColNo( KContactId ); |
|
373 if ( SeekRowL( colNo, linkId ) ) |
|
374 { |
|
375 TRACE( "EVPbkContactChanged found in local db" ); |
|
376 // found in the list update it |
|
377 iServiceCacheWriter.UpdateCacheContactL(*aVPbkStoreEvent.iContactLink , |
|
378 aVPbkStoreEvent.iUserId , |
|
379 aVPbkStoreEvent.iDisplayName, |
|
380 aVPbkStoreEvent.iAvatarContent ); |
|
381 TRACE( "EVPbkContactChanged changed in cache"); |
|
382 } |
|
383 break; |
|
384 } |
|
385 case EVPbkContactRetriving: |
|
386 { |
|
387 TRACE( "EVPbkContactRetriving"); |
|
388 // in case of local we allow all |
|
389 TRACE( "EVPbkContactRetriving valid Id"); |
|
390 CVIMPSTStorageContact* retrivedContact = CVIMPSTStorageContact::NewL( aVPbkStoreEvent.iUserId , |
|
391 aVPbkStoreEvent.iDisplayName, |
|
392 *aVPbkStoreEvent.iContactLink, |
|
393 aVPbkStoreEvent.iAvatarContent); |
|
394 iRetrivedContactArray.Append( retrivedContact ); // takes the ownership of retrivedContact |
|
395 TRACE( "EVPbkContactRetriving valid Id added" ); |
|
396 // keep the backup of retrieved contacts |
|
397 // user can add later once it sent to server |
|
398 break; |
|
399 } |
|
400 case EVPbkUnknownChanges: |
|
401 { |
|
402 TRACE("EVPbkUnknownChanges start" ); |
|
403 DeleteAllContactFromInternalStoreL(); |
|
404 TRACE( " EVPbkUnknownChanges all delete from db" ); |
|
405 // unknow mean all contact deleted from store |
|
406 iServiceCacheWriter.RemoveAllCacheContactsL(); |
|
407 TRACE( " EVPbkUnknownChanges all delete from cache" ); |
|
408 break; |
|
409 } |
|
410 default: |
|
411 break; |
|
412 } |
|
413 |
|
414 } |
|
415 |
|
416 |
|
417 // -------------------------------------------------------------------------- |
|
418 // CVIMPSTStorageVPbkLocalStore::IssueRequest |
|
419 // -------------------------------------------------------------------------- |
|
420 // |
|
421 void CVIMPSTStorageVPbkLocalStore::IssueRequest() |
|
422 { |
|
423 TRACER_AUTO; |
|
424 if( !IsActive() ) |
|
425 { |
|
426 TRACE( "SetActive" ); |
|
427 TRequestStatus* status = &iStatus; |
|
428 User::RequestComplete( status, KErrNone ); |
|
429 SetActive(); |
|
430 } |
|
431 |
|
432 } |
|
433 |
|
434 // -------------------------------------------------------------------------- |
|
435 // CVIMPSTStorageVPbkLocalStore::RunL |
|
436 // -------------------------------------------------------------------------- |
|
437 // |
|
438 void CVIMPSTStorageVPbkLocalStore::RunL() |
|
439 { |
|
440 TRACER_AUTO; |
|
441 TInt count = iFetchContactsToBeAdded.Count(); |
|
442 TRACE( "count to be added = %d ",count ); |
|
443 if( !count ) |
|
444 { |
|
445 TRACE(" fetch completed " ); |
|
446 iFetchStep = EContactReadComplete; |
|
447 iServiceCacheWriter.NotifyServiceViewL( TVIMPSTEnums::EStorageContactFetchComplete ); |
|
448 TRACE( "fetch completed notification sent" ); |
|
449 } |
|
450 else |
|
451 { |
|
452 TRACE( "fetch in progress" ); |
|
453 iFetchStep = EFetchingOn; |
|
454 TVIMPSTContactInfo contactInfoToAdd = iFetchContactsToBeAdded[0]; |
|
455 MVIMPSTStorageContact* exist = iServiceCacheWriter.FindCacheContactByUserId( *contactInfoToAdd.iUserId ); |
|
456 if( exist ) |
|
457 { |
|
458 // contact is already exist ,send the notification about this |
|
459 iServiceCacheWriter.NotifyServiceViewL(TVIMPSTEnums::EStorageContactFetchExistInStore, exist ); |
|
460 TRACE( " fetch in progress id exist" ); |
|
461 // process next |
|
462 IssueRequest(); |
|
463 } |
|
464 else |
|
465 { |
|
466 TRACE( "fetch in progress create id in store called" ); |
|
467 // pass the display NAme in place of NULL |
|
468 iVPbkStoreHandler->CreateVPbkContactL( *contactInfoToAdd.iUserId, *contactInfoToAdd.iDisplayName ); // process always 0th item |
|
469 } |
|
470 iFetchContactsToBeAdded.Remove( 0 ); |
|
471 delete contactInfoToAdd.iUserId; |
|
472 contactInfoToAdd.iUserId = NULL; |
|
473 delete contactInfoToAdd.iDisplayName; |
|
474 contactInfoToAdd.iDisplayName = NULL ; |
|
475 iFetchContactsToBeAdded.Compress(); |
|
476 TRACE( "fetch in progress iFetchContactsToBeAdded ,one entry removed" ); |
|
477 } |
|
478 |
|
479 } |
|
480 |
|
481 // -------------------------------------------------------------------------- |
|
482 // CVIMPSTStorageVPbkLocalStore::DoCancel |
|
483 // -------------------------------------------------------------------------- |
|
484 // |
|
485 void CVIMPSTStorageVPbkLocalStore::DoCancel() |
|
486 { |
|
487 TRACER_AUTO; |
|
488 } |
|
489 |
|
490 // -------------------------------------------------------------------------- |
|
491 // CVIMPSTStorageVPbkLocalStore::RunError |
|
492 // -------------------------------------------------------------------------- |
|
493 // |
|
494 TInt CVIMPSTStorageVPbkLocalStore::RunError( TInt aError ) |
|
495 { |
|
496 TRACER_AUTO; |
|
497 return aError; |
|
498 } |
|
499 |
|
500 ////////////////////////////////////////////////////////// |
|
501 // --------------------------------------------------------------------------- |
|
502 // CVIMPSTStorageVPbkLocalStore::CreateVPbkContactL |
|
503 // --------------------------------------------------------------------------- |
|
504 // |
|
505 TInt CVIMPSTStorageVPbkLocalStore::CreateVPbkContactL(const TDesC& aUserId, |
|
506 const TDesC& aDisplayName , |
|
507 TBool aInvitationAutoAccept /* = EFalse */ ) |
|
508 { |
|
509 TRACER_AUTO; |
|
510 TInt error = KErrGeneral; |
|
511 if( aInvitationAutoAccept) |
|
512 { |
|
513 TRACE("autoaccept add contact" ); |
|
514 delete iInviteId; |
|
515 iInviteId = NULL; |
|
516 iInviteId = aUserId.AllocL(); |
|
517 error = iVPbkStoreHandler->CreateVPbkContactL( *iInviteId,aDisplayName ); |
|
518 } |
|
519 TRACE( "error = %d",error ); |
|
520 |
|
521 return error; |
|
522 } |
|
523 |
|
524 // --------------------------------------------------------------------------- |
|
525 // CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL |
|
526 // --------------------------------------------------------------------------- |
|
527 // |
|
528 TInt CVIMPSTStorageVPbkLocalStore::RemoveVPbkContactL(const MVPbkContactLink& aContactLink) |
|
529 { |
|
530 TRACER_AUTO;; |
|
531 TInt error = KErrNotFound; |
|
532 // text now holds the name (or first field of the contact) |
|
533 TInt32 linkId = iIdConverter->LinkToIdentifier(aContactLink); |
|
534 // a contact entry has been deleted from virtual database store |
|
535 TDbColNo colNo = iColset->ColNo( KContactId ); |
|
536 if ( SeekRowL( colNo, linkId ) ) |
|
537 { |
|
538 TRACE( "link exist in db" ); |
|
539 // contatc found in local database ,delete from local database |
|
540 DeleteContactFromInternalStoreL( linkId ); |
|
541 TRACE( "link deleted from db" ); |
|
542 // delete from cache contact |
|
543 error = iServiceCacheWriter.RemoveContactFromCacheL(aContactLink, |
|
544 TVIMPSTEnums::EStorageEventContactDelete ); |
|
545 TRACE( "link deleted from cache" ); |
|
546 } |
|
547 TRACE("error %d",error ); |
|
548 |
|
549 return error; |
|
550 } |
|
551 |
|
552 // --------------------------------------------------------------------------- |
|
553 // CVIMPSTStorageVPbkLocalStore::RemoveAllVPbkContactsL |
|
554 // --------------------------------------------------------------------------- |
|
555 // |
|
556 TInt CVIMPSTStorageVPbkLocalStore::RemoveAllVPbkContactsL() |
|
557 { |
|
558 TRACER_AUTO; |
|
559 iRetrivedContactArray.ResetAndDestroy(); |
|
560 DeleteAllContactFromInternalStoreL(); |
|
561 TRACE( "all contacts deleted from db" ); |
|
562 iServiceCacheWriter.RemoveAllCacheContactsL(); |
|
563 TRACE( "all contacts deleted from cache" ); |
|
564 |
|
565 return KErrNone;// local store : delete from local store ,own user has changed |
|
566 } |
|
567 // --------------------------------------------------------------------------- |
|
568 // CVIMPSTStorageVPbkLocalStore::RetrieveVPbkXSPIdL |
|
569 // --------------------------------------------------------------------------- |
|
570 // |
|
571 TInt CVIMPSTStorageVPbkLocalStore::RetrieveVPbkXSPIdL(const TDesC8& aPackedLinks ) |
|
572 { |
|
573 TRACER_AUTO; |
|
574 iRetrivedContactArray.ResetAndDestroy(); |
|
575 TRACE( " iRetrivedContactArray Reset" ); |
|
576 iVPbkStoreHandler->RetrieveVPbkContactL( aPackedLinks ); |
|
577 TRACE( "iRetrivedContactArray count= %d " ,iRetrivedContactArray.Count() ); |
|
578 |
|
579 return iRetrivedContactArray.Count(); |
|
580 } |
|
581 |
|
582 // --------------------------------------------------------------------------- |
|
583 // CVIMPSTStorageVPbkLocalStore::GetRetrieveVPbkXSPIdL |
|
584 // --------------------------------------------------------------------------- |
|
585 // |
|
586 const TDesC& CVIMPSTStorageVPbkLocalStore::GetRetrieveVPbkXSPIdL(TInt aIndex ) |
|
587 { |
|
588 TRACER_AUTO; |
|
589 TRACE( "aIndex = %d" ,aIndex ); |
|
590 MVIMPSTStorageContact* contact = NULL; |
|
591 if( aIndex >= 0 && aIndex < iRetrivedContactArray.Count() ) |
|
592 { |
|
593 contact = iRetrivedContactArray[ aIndex ]; |
|
594 } |
|
595 |
|
596 return contact ? contact->UserId() : KNullDesC ; |
|
597 } |
|
598 // --------------------------------------------------------------------------- |
|
599 // CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL |
|
600 // --------------------------------------------------------------------------- |
|
601 // |
|
602 TInt CVIMPSTStorageVPbkLocalStore::CreateRetriveVPbkContactL( TInt aIndexToUse ) |
|
603 { |
|
604 TRACER_AUTO; |
|
605 if( aIndexToUse < 0 && aIndexToUse >= iRetrivedContactArray.Count() ) |
|
606 { |
|
607 TRACE( " argument error" ); |
|
608 return KErrArgument; |
|
609 } |
|
610 TInt error = KErrAlreadyExists; |
|
611 MVIMPSTStorageContact* retrivedContact = iRetrivedContactArray[ aIndexToUse ]; |
|
612 |
|
613 MVPbkContactLink* contactLink = retrivedContact->ContactLink(); |
|
614 MVIMPSTStorageContact* exist = NULL; |
|
615 if( contactLink ) |
|
616 { |
|
617 exist = iServiceCacheWriter.FindCacheContactByLink( *contactLink ); |
|
618 } |
|
619 if( !exist ) |
|
620 { |
|
621 TRACE( "adding to cache" ); |
|
622 MVPbkContactLink* link = retrivedContact->ContactLink(); |
|
623 if( link ) |
|
624 { |
|
625 CVIMPSTStorageContact* contactToAdd = CVIMPSTStorageContact::NewL( retrivedContact->UserId() , |
|
626 retrivedContact->Name(), |
|
627 *link, |
|
628 retrivedContact->AvatarContent() |
|
629 ); |
|
630 CleanupStack::PushL( contactToAdd ); |
|
631 TInt32 linkId = iIdConverter->LinkToIdentifier( *link ); |
|
632 error = iServiceCacheWriter.AddStorageContactToCacheL( contactToAdd ); // contactToAdd ownership is transfered |
|
633 TRACE( " adding to cache done" ); |
|
634 if( error == KErrNone ) |
|
635 { |
|
636 CleanupStack::Pop(); // contactToAdd , Ownership is transfered to AddStorageContactToCacheL |
|
637 WriteToStoreDbL( linkId ); |
|
638 } |
|
639 else |
|
640 { |
|
641 CleanupStack::PopAndDestroy(); // contactToAdd |
|
642 } |
|
643 TRACE( " adding to db done" ); |
|
644 } |
|
645 } |
|
646 TRACE( "error =%d" ,error ); |
|
647 |
|
648 return error; |
|
649 } |
|
650 |
|
651 // --------------------------------------------------------------------------- |
|
652 // CVIMPSTStorageVPbkLocalStore::deleteRetriveVPbkContactL |
|
653 // --------------------------------------------------------------------------- |
|
654 // |
|
655 TInt CVIMPSTStorageVPbkLocalStore::deleteRetriveVPbkContactL( TInt aIndexToUse ) |
|
656 { |
|
657 TRACER_AUTO; |
|
658 if( aIndexToUse < 0 && aIndexToUse >= iRetrivedContactArray.Count() ) |
|
659 { |
|
660 TRACE( "argument error" ); |
|
661 return KErrArgument; |
|
662 } |
|
663 MVIMPSTStorageContact* retrivedContact = iRetrivedContactArray[ aIndexToUse ]; |
|
664 MVPbkContactLink* contactLink = retrivedContact->ContactLink(); |
|
665 // delete from cache contact |
|
666 CVPbkContactLinkArray* contactsToDelete = CVPbkContactLinkArray::NewLC(); |
|
667 MVPbkContactLink* link = contactLink->CloneLC(); |
|
668 contactsToDelete->AppendL( link ); // takes ownership |
|
669 CleanupStack::Pop(); // link |
|
670 TInt error = iVPbkStoreHandler->RemoveVPbkContactL( *contactsToDelete ); |
|
671 CleanupStack::PopAndDestroy(); // contactsToDelete |
|
672 |
|
673 return error; |
|
674 } |
|
675 // CVIMPSTStorageVPbkLocalStore::UpdateAvatarFieldDataL() |
|
676 // --------------------------------------------------------------------------- |
|
677 // |
|
678 TInt CVIMPSTStorageVPbkLocalStore::UpdateAvatarFieldDataL(const MVPbkContactLink& aContactLink, |
|
679 const TDesC8& aAvatartData ) |
|
680 { |
|
681 TRACER_AUTO; |
|
682 return iVPbkStoreHandler->UpdateAvatarFieldDataL( aContactLink, aAvatartData ); |
|
683 } |
|
684 |
|
685 // --------------------------------------------------------------------------- |
|
686 // CVIMPSTStorageVPbkLocalStore::RemoveAvatarFieldL() |
|
687 // --------------------------------------------------------------------------- |
|
688 // |
|
689 TInt CVIMPSTStorageVPbkLocalStore::RemoveAvatarFieldL(MVPbkStoreContact& aStoreContact) |
|
690 { |
|
691 TRACER_AUTO; |
|
692 return iVPbkStoreHandler->RemoveAvatarFieldL( aStoreContact ); |
|
693 } |
|
694 |
|
695 // --------------------------------------------------------------------------- |
|
696 // CVIMPSTStorageVPbkLocalStore::AddVPbkFetchContactsL() |
|
697 // --------------------------------------------------------------------------- |
|
698 // |
|
699 void CVIMPSTStorageVPbkLocalStore::AddVPbkFetchContactsL( RArray <TPtrC>& aFirstNameList, |
|
700 RArray <TPtrC> &aServiceField ) |
|
701 { |
|
702 TRACER_AUTO; |
|
703 // in case of server contacts delete all contacts |
|
704 ResetAndDestroyLocalArrayL(); |
|
705 TInt count = aServiceField.Count(); |
|
706 TRACE( " count=%d" ,count ); |
|
707 for( TInt i = 0; i<count; i++ ) |
|
708 { |
|
709 TVIMPSTContactInfo contactInf = |
|
710 { |
|
711 aServiceField[i].AllocL() , |
|
712 aFirstNameList[i].AllocL() |
|
713 }; |
|
714 // not exist need to add |
|
715 iFetchContactsToBeAdded.Append( contactInf ); |
|
716 } |
|
717 if( iFetchStep == EContactReadComplete ) |
|
718 { |
|
719 TRACE( "start fetcing" ); |
|
720 IssueRequest(); |
|
721 } |
|
722 else |
|
723 { |
|
724 TRACE( " EFetchingCalled" ); |
|
725 iFetchStep = EFetchingCalled; |
|
726 } |
|
727 |
|
728 } |
|
729 |
|
730 //******************* Database Operations *********************************// |
|
731 // ----------------------------------------------------------- |
|
732 // CVIMPSTStorageVPbkLocalStore::DbExists |
|
733 // ----------------------------------------------------------- |
|
734 // |
|
735 TBool CVIMPSTStorageVPbkLocalStore::DbExists() |
|
736 { |
|
737 TRACER_AUTO; |
|
738 RFile temp; |
|
739 |
|
740 TBuf< KMaxPath > storagePath; |
|
741 |
|
742 storagePath.Append( KDbPath ); |
|
743 storagePath.Append( *iLocalDBName ); |
|
744 TBool ret = ETrue; |
|
745 TInt err( temp.Open( iFs, *(&storagePath), EFileShareReadersOrWriters|EFileRead ) ); |
|
746 TInt size( 0 ); |
|
747 if ( err == KErrNone ) |
|
748 { |
|
749 temp.Size( size ); |
|
750 } |
|
751 temp.Close(); |
|
752 if ( (size == 0) || ( err != KErrNone ) ) |
|
753 { |
|
754 ret = EFalse; |
|
755 } |
|
756 |
|
757 return ret; |
|
758 } |
|
759 |
|
760 |
|
761 // ----------------------------------------------------------- |
|
762 // CVIMPSTStorageVPbkLocalStore::CreateDbL |
|
763 // ----------------------------------------------------------- |
|
764 // |
|
765 void CVIMPSTStorageVPbkLocalStore::CreateDbL() |
|
766 { |
|
767 TRACER_AUTO; |
|
768 TBuf< KMaxPath > storagePath; |
|
769 storagePath.Append( KDbPath ); |
|
770 iFs.MkDirAll( storagePath ); // make sure the directory exists |
|
771 storagePath.Append( *iLocalDBName ); |
|
772 iFs.SetAtt( *iLocalDBName ,KEntryAttHidden|KEntryAttSystem , KEntryAttNormal); |
|
773 iFileStore = CPermanentFileStore::ReplaceL( iFs, storagePath, EFileShareReadersOrWriters|EFileWrite ); |
|
774 |
|
775 iFileStore->SetTypeL( iFileStore->Layout() ); |
|
776 |
|
777 TStreamId streamId( 0 ); |
|
778 TRAPD( err, streamId = iDb.CreateL( iFileStore ) ); |
|
779 |
|
780 if( err ) |
|
781 { |
|
782 TRACE( " err = %d" ,err ); |
|
783 delete iFileStore; |
|
784 iFileStore = NULL; |
|
785 |
|
786 // remember to keep this updated |
|
787 iFs.Delete( storagePath ); |
|
788 User::Leave( err ); |
|
789 } |
|
790 |
|
791 iFileStore->SetRootL( streamId ); |
|
792 TInt err2( iFileStore->Commit() ); |
|
793 User::LeaveIfError( err2 ); |
|
794 |
|
795 TRAPD( err3, CreateTablesL() ); |
|
796 if( err3 ) |
|
797 { |
|
798 delete iFileStore; |
|
799 iFileStore = NULL; |
|
800 iDb.Close(); |
|
801 iFs.Delete( storagePath ); |
|
802 User::Leave( err3 ); |
|
803 } |
|
804 |
|
805 } |
|
806 |
|
807 // ----------------------------------------------------------- |
|
808 // CVIMPSTStorageVPbkLocalStore::OpenDbL |
|
809 // ----------------------------------------------------------- |
|
810 // |
|
811 void CVIMPSTStorageVPbkLocalStore::OpenDbL() |
|
812 { |
|
813 TRACER_AUTO; |
|
814 TBuf< KMaxPath > storagePath; |
|
815 storagePath.Append( KDbPath ); |
|
816 storagePath.Append( *iLocalDBName ); |
|
817 iFileStore = CPermanentFileStore::OpenL( iFs, storagePath, EFileShareReadersOrWriters|EFileWrite ); |
|
818 iFileStore->SetTypeL( iFileStore->Layout() ); |
|
819 iDb.OpenL( iFileStore, iFileStore->Root() ); |
|
820 |
|
821 } |
|
822 |
|
823 // ----------------------------------------------------------- |
|
824 // CVIMPSTStorageVPbkLocalStore::CloseDb |
|
825 // ----------------------------------------------------------- |
|
826 // |
|
827 void CVIMPSTStorageVPbkLocalStore::CloseDb() |
|
828 { |
|
829 TRACER_AUTO; |
|
830 delete iFileStore; |
|
831 iFileStore = NULL; |
|
832 iDb.Close(); |
|
833 |
|
834 } |
|
835 |
|
836 // ----------------------------------------------------------- |
|
837 // CVIMPSTStorageVPbkLocalStore::CreateTablesL |
|
838 // ----------------------------------------------------------- |
|
839 // |
|
840 void CVIMPSTStorageVPbkLocalStore::CreateTablesL() |
|
841 { |
|
842 TRACER_AUTO; |
|
843 CDbColSet* contactId = CDbColSet::NewLC(); |
|
844 |
|
845 AddColumnL( KContactId, EDbColInt32, contactId ); |
|
846 |
|
847 TInt err = iDb.CreateTable( KContactTable, *contactId ); |
|
848 TRACE( "err = %d" ,err ); |
|
849 User::LeaveIfError( err ); |
|
850 |
|
851 CleanupStack::PopAndDestroy( contactId ); |
|
852 |
|
853 } |
|
854 |
|
855 // ----------------------------------------------------------- |
|
856 // CVIMPSTStorageVPbkLocalStore::AddColumnL |
|
857 // ----------------------------------------------------------- |
|
858 // |
|
859 void CVIMPSTStorageVPbkLocalStore::AddColumnL( const TDesC& aName, TDbColType aType, CDbColSet* aColset ) |
|
860 { |
|
861 TRACER_AUTO; |
|
862 TDbCol column( aName, aType ); |
|
863 aColset->AddL( column ); |
|
864 |
|
865 } |
|
866 |
|
867 // ----------------------------------------------------------- |
|
868 // CVIMPSTStorageVPbkLocalStore::DoFreespaceLevelCheckL |
|
869 // ----------------------------------------------------------- |
|
870 // |
|
871 void CVIMPSTStorageVPbkLocalStore::DoFreespaceLevelCheckL( TInt aSize ) |
|
872 { |
|
873 TRACER_AUTO; |
|
874 if ( SysUtil::FFSSpaceBelowCriticalLevelL( &iFs, aSize ) ) |
|
875 { |
|
876 User::Leave( KErrDiskFull ); |
|
877 } |
|
878 |
|
879 } |
|
880 |
|
881 // ----------------------------------------------------------------------------- |
|
882 // CVIMPSTStorageVPbkLocalStore::DeleteAllContactFromInternalStoreL |
|
883 // ----------------------------------------------------------------------------- |
|
884 // |
|
885 void CVIMPSTStorageVPbkLocalStore::DeleteAllContactFromInternalStoreL() |
|
886 { |
|
887 TRACER_AUTO; |
|
888 iColset->ColNo( KContactId ); |
|
889 iTable.LastL(); |
|
890 while( !iTable.IsEmptyL() ) |
|
891 { |
|
892 iTable.GetL(); |
|
893 iTable.DeleteL(); |
|
894 iDb.Compact(); |
|
895 // delete alwasy first item untill table is empty |
|
896 iTable.LastL(); |
|
897 } |
|
898 |
|
899 } |
|
900 // ---------------------------------------------------------- |
|
901 // CVIMPSTStorageVPbkLocalStore::DeleteContactFromInternalStoreL |
|
902 // ---------------------------------------------------------- |
|
903 // |
|
904 void CVIMPSTStorageVPbkLocalStore::DeleteContactFromInternalStoreL( TInt32& aIdentifier ) |
|
905 { |
|
906 TRACER_AUTO; |
|
907 TDbColNo colNo = iColset->ColNo( KContactId ); |
|
908 if ( SeekRowL( colNo, aIdentifier ) ) |
|
909 { |
|
910 iTable.DeleteL(); |
|
911 iDb.Compact(); |
|
912 TRACE( "found deleted" ); |
|
913 } |
|
914 |
|
915 } |
|
916 |
|
917 // ---------------------------------------------------------- |
|
918 // CVIMPSTStorageVPbkLocalStore::WriteToStoreDbL |
|
919 // ---------------------------------------------------------- |
|
920 // |
|
921 void CVIMPSTStorageVPbkLocalStore::WriteToStoreDbL( TInt32& aIdentifier ) |
|
922 { |
|
923 TRACER_AUTO; |
|
924 TDbColNo colNo = iColset->ColNo( KContactId ); |
|
925 if (!SeekRowL( colNo, aIdentifier ) ) |
|
926 { |
|
927 iTable.InsertL(); |
|
928 |
|
929 colNo = iColset->ColNo( KContactId ); |
|
930 iTable.SetColL( colNo, aIdentifier ); |
|
931 |
|
932 // Write row to table |
|
933 TRAPD( err, iTable.PutL() ); |
|
934 if( err != KErrNone ) |
|
935 { |
|
936 // recover |
|
937 iTable.Cancel(); |
|
938 iTable.Reset(); |
|
939 } |
|
940 } |
|
941 |
|
942 } |
|
943 // ---------------------------------------------------------- |
|
944 // CVIMPSTStorageVPbkLocalStore::OpenTableL |
|
945 // ---------------------------------------------------------- |
|
946 // |
|
947 void CVIMPSTStorageVPbkLocalStore::OpenTableL() |
|
948 { |
|
949 TRACER_AUTO; |
|
950 TInt err( iTable.Open( iDb, KContactTable ) ); |
|
951 if ( err != KErrNone ) |
|
952 { |
|
953 TRACE( " err =%d" ,err ); |
|
954 iTable.Close(); |
|
955 User::Leave( err ); |
|
956 } |
|
957 |
|
958 } |
|
959 |
|
960 // ---------------------------------------------------------- |
|
961 // CVIMPSTStorageVPbkLocalStore::CloseTable |
|
962 // ---------------------------------------------------------- |
|
963 // |
|
964 void CVIMPSTStorageVPbkLocalStore::CloseTable() |
|
965 { |
|
966 TRACER_AUTO; |
|
967 iTable.Close(); |
|
968 |
|
969 } |
|
970 |
|
971 // ---------------------------------------------------------- |
|
972 // CVIMPSTStorageVPbkLocalStore::ReadFirstL |
|
973 // ---------------------------------------------------------- |
|
974 // |
|
975 TInt CVIMPSTStorageVPbkLocalStore::ReadFirstL( TInt32& aIdentifier ) |
|
976 { |
|
977 TRACER_AUTO; |
|
978 iTable.BeginningL(); |
|
979 |
|
980 return ReadNextL( aIdentifier ); |
|
981 } |
|
982 |
|
983 // ---------------------------------------------------------- |
|
984 // CVIMPSTStorageVPbkLocalStore::ReadNextL |
|
985 // ---------------------------------------------------------- |
|
986 // |
|
987 TInt CVIMPSTStorageVPbkLocalStore::ReadNextL( TInt32& aIdentifier ) |
|
988 { |
|
989 TRACER_AUTO; |
|
990 TInt err = KErrNotFound; |
|
991 if ( iTable.NextL() ) |
|
992 { |
|
993 TRAP( err, ReadCurrentL( aIdentifier ) ); |
|
994 // For some reason ReadCurrentL leaves with KErrEof, |
|
995 // even if the contact was read succesfully. |
|
996 } |
|
997 TRACE( " err = %d" ,err ); |
|
998 |
|
999 return err; |
|
1000 } |
|
1001 |
|
1002 |
|
1003 // ---------------------------------------------------------- |
|
1004 // CVIMPSTStorageVPbkLocalStore::ReadCurrentL |
|
1005 // ---------------------------------------------------------- |
|
1006 // |
|
1007 void CVIMPSTStorageVPbkLocalStore::ReadCurrentL( TInt32& aIdentifier ) |
|
1008 { |
|
1009 TRACER_AUTO; |
|
1010 iTable.GetL(); |
|
1011 // Get Column number for contact data size |
|
1012 TDbColNo colNo = iColset->ColNo( KContactId ); |
|
1013 aIdentifier = iTable.ColInt32(colNo); |
|
1014 |
|
1015 } |
|
1016 |
|
1017 // ---------------------------------------------------------- |
|
1018 // CVIMPSTStorageVPbkLocalStore::SeekRowL |
|
1019 // ---------------------------------------------------------- |
|
1020 // |
|
1021 TBool CVIMPSTStorageVPbkLocalStore::SeekRowL( TDbColNo aColNo, TInt32& aIdentifier ) |
|
1022 { |
|
1023 TRACER_AUTO; |
|
1024 TBool ret = EFalse; |
|
1025 iTable.BeginningL(); |
|
1026 while ( iTable.NextL() ) |
|
1027 { |
|
1028 iTable.GetL(); |
|
1029 if ( iTable.ColInt32( aColNo ) == aIdentifier ) |
|
1030 { |
|
1031 ret = ETrue; |
|
1032 break; |
|
1033 } |
|
1034 } |
|
1035 |
|
1036 return ret; |
|
1037 } |
|
1038 // ---------------------------------------------------------- |
|
1039 // CVIMPSTStorageVPbkLocalStore::DeleteDatabaseL |
|
1040 // ---------------------------------------------------------- |
|
1041 void CVIMPSTStorageVPbkLocalStore::DeleteDatabaseL() |
|
1042 { |
|
1043 TRACER_AUTO; |
|
1044 TBuf< KMaxPath > storagePath; |
|
1045 storagePath.Append( KDbPath ); |
|
1046 iFs.MkDirAll( storagePath ); |
|
1047 storagePath.Append( *iLocalDBName ); |
|
1048 //close db before deleting it. |
|
1049 CloseDb(); |
|
1050 iFs.Delete( storagePath ); |
|
1051 |
|
1052 } |
|
1053 // ---------------------------------------------------------- |
|
1054 // CVIMPSTStorageVPbkLocalStore::IsSameContactIdL |
|
1055 // ---------------------------------------------------------- |
|
1056 TBool CVIMPSTStorageVPbkLocalStore::IsSameContactIdL(const TDesC& aFirstId, const TDesC& aSecondId ) |
|
1057 { |
|
1058 TRACER_AUTO; |
|
1059 TInt colIndex = aFirstId.Find(_L(":")); |
|
1060 TPtrC firstId = aFirstId.Right( aFirstId.Length() - colIndex -1); |
|
1061 colIndex = aSecondId.Find(_L(":")); |
|
1062 TPtrC secondId = aSecondId.Right( aSecondId.Length() - colIndex -1); |
|
1063 //if( Compare( firstId,secondId ) == 0 ) |
|
1064 if(firstId.Compare(aSecondId) ==0 ) |
|
1065 { |
|
1066 return ETrue; |
|
1067 } |
|
1068 return EFalse; |
|
1069 } |
|
1070 // End of file |
|
1071 |
|