|
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 store |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cvimpststoragevpbkstorehandler.h" |
|
21 |
|
22 #include "mvimpststoragevpbkstorehandler.h" |
|
23 |
|
24 //vpbk interfaces |
|
25 #include <MVPbkContactStoreObserver.h> |
|
26 #include <CVPbkContactManager.h> |
|
27 #include <MVPbkContactLink.h> |
|
28 #include <CVPbkContactStoreUriArray.h> |
|
29 #include <MVPbkContactOperationBase.h> |
|
30 #include <MVPbkContactStore.h> |
|
31 #include <MVPbkContactStoreProperties.h> |
|
32 #include <MVPbkContactView.h> |
|
33 #include <MVPbkContactStoreList.h> |
|
34 #include <MVPbkContactFieldTextData.h> |
|
35 #include <MVPbkContactFieldUriData.h> |
|
36 #include <MVPbkContactFieldBinaryData.h> |
|
37 #include <MVPbkContactFieldData.h> |
|
38 #include <CVPbkContactViewDefinition.h> |
|
39 |
|
40 #include <MVPbkViewContact.h> |
|
41 #include <MVPbkStoreContact.h> |
|
42 #include <TVPbkContactStoreUriPtr.h> |
|
43 #include <MVPbkStoreContactFieldCollection.h> |
|
44 #include <MVPbkStoreContactField.h> |
|
45 #include <MVPbkFieldType.h> |
|
46 #include <VPbkEng.rsg> |
|
47 #include <CVPbkContactLinkArray.h> |
|
48 #include <CVPbkFieldTypeSelector.h> |
|
49 #include <CPbk2SortOrderManager.h> |
|
50 #include <MVPbkContactFieldBinaryData.h> |
|
51 |
|
52 #include "vimpstdebugtrace.h" |
|
53 #include "tvimpstconsts.h" |
|
54 #include <cntdb.h> |
|
55 |
|
56 // ================= MEMBER FUNCTIONS ======================= |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CVIMPSTStorageVPbkStoreHandler:: |
|
60 // CVIMPSTStorageVPbkStoreHandler |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CVIMPSTStorageVPbkStoreHandler:: CVIMPSTStorageVPbkStoreHandler( MVIMPSTStorageVPbkStoreHandler& aStoreHandler,TBool aLocalStore ): |
|
64 CActive( CActive::EPriorityIdle ), |
|
65 iStoreHandler(aStoreHandler ), |
|
66 iStoreEventType( EVPbkUnknownEvent ), |
|
67 iFetcingIndex( 0 ), |
|
68 iLocalStore( aLocalStore ) |
|
69 { |
|
70 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CVIMPSTStorageVPbkStoreHandler()") ); |
|
71 CActiveScheduler::Add( this ); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CVIMPSTStorageVPbkStoreHandler::ConstructL |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 void CVIMPSTStorageVPbkStoreHandler::ConstructL(const TDesC& aStoreName,const TDesC& aServiceName ) |
|
79 { |
|
80 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ConstructL() begin") ); |
|
81 iAddIdInProgress = NULL; |
|
82 iStoreName = aStoreName.AllocL(); |
|
83 iServiceName = aServiceName.AllocL(); |
|
84 CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC(); |
|
85 uriArray->AppendL( TVPbkContactStoreUriPtr( aStoreName ) ); |
|
86 if( !uriArray->IsIncluded( TVPbkContactStoreUriPtr( KPhoneBookDbURI ) ) ) |
|
87 { |
|
88 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ConstructL() phonebook store apended") ); |
|
89 uriArray->AppendL( TVPbkContactStoreUriPtr( KPhoneBookDbURI ) ); |
|
90 } |
|
91 iContactManager = CVPbkContactManager::NewL( *uriArray, NULL ); |
|
92 CleanupStack::PopAndDestroy( uriArray ); |
|
93 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ConstructL() iContactManager created") ); |
|
94 iStores = &iContactManager->ContactStoresL(); |
|
95 iStores->OpenAllL( *this ); |
|
96 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ConstructL() OpenAllL called") ); |
|
97 iSortOrderManager = CPbk2SortOrderManager::NewL( iContactManager->FieldTypes(), NULL ); |
|
98 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ConstructL() end") ); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CVIMPSTStorageVPbkStoreHandler::NewL |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 CVIMPSTStorageVPbkStoreHandler* CVIMPSTStorageVPbkStoreHandler::NewL( const TDesC& aContactDb, |
|
106 const TDesC& aServiceName, |
|
107 MVIMPSTStorageVPbkStoreHandler& aStoreHandler, |
|
108 TBool aLocalStore ) |
|
109 { |
|
110 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::NewL begin") ); |
|
111 CVIMPSTStorageVPbkStoreHandler* self = NewLC( aContactDb ,aServiceName, aStoreHandler,aLocalStore ); |
|
112 CleanupStack::Pop( self ); |
|
113 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::NewL end") ); |
|
114 return self; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CVIMPSTStorageVPbkStoreHandler::NewLC |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 CVIMPSTStorageVPbkStoreHandler* CVIMPSTStorageVPbkStoreHandler::NewLC( const TDesC& aContactDb, |
|
122 const TDesC& aServiceName, |
|
123 MVIMPSTStorageVPbkStoreHandler& aStoreHandler, |
|
124 TBool aLocalStore ) |
|
125 { |
|
126 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::NewLC begin") ); |
|
127 CVIMPSTStorageVPbkStoreHandler* self = |
|
128 new (ELeave) CVIMPSTStorageVPbkStoreHandler( aStoreHandler ,aLocalStore ); |
|
129 CleanupStack::PushL( self ); |
|
130 self->ConstructL( aContactDb,aServiceName ); |
|
131 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::NewLC end") ); |
|
132 return self; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CVIMPSTStorageVPbkStoreHandler:: |
|
137 // ~CVIMPSTStorageVPbkStoreHandler |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 CVIMPSTStorageVPbkStoreHandler:: ~CVIMPSTStorageVPbkStoreHandler() |
|
141 { |
|
142 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::~CVIMPSTStorageVPbkStoreHandler begin") ); |
|
143 if( iWait.IsStarted() ) |
|
144 { |
|
145 iWait.AsyncStop(); |
|
146 } |
|
147 Cancel(); |
|
148 ResetAndDestroyRArray(); |
|
149 iUnCommittedVPbkContacts.ResetAndDestroy(); |
|
150 delete iAddIdInProgress; |
|
151 delete iContactOperation; |
|
152 delete iContactLink; |
|
153 delete iStoreContact; |
|
154 delete iContactView; |
|
155 if ( iContactManager ) |
|
156 { |
|
157 TRAP_IGNORE( iContactManager->ContactStoresL().CloseAll( *this ) ); |
|
158 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::~CVIMPSTStorageVPbkStoreHandler CloseAll called") ); |
|
159 delete iContactManager; |
|
160 } |
|
161 delete iStoreName; |
|
162 delete iSortOrderManager; |
|
163 delete iServiceName; |
|
164 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::~CVIMPSTStorageVPbkStoreHandler end") ); |
|
165 } |
|
166 // --------------------------------------------------------------------------- |
|
167 // CVIMPSTStorageVPbkStoreHandler::ContactViewReady |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 void CVIMPSTStorageVPbkStoreHandler::ContactViewReady( |
|
171 MVPbkContactViewBase& aView ) |
|
172 { |
|
173 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewReady() begin") ); |
|
174 if ( iContactView == &aView && ( iStoreEventType == EVPbkUnknownEvent ) ) |
|
175 { |
|
176 iStoreEventType = EVPbkContactReading ; |
|
177 TRAP_IGNORE( HandleContactViewReadyL( *iContactView ) ); |
|
178 } |
|
179 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewReady() end") ); |
|
180 } |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // CVIMPSTStorageVPbkStoreHandler::ContactViewUnavailable |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 void CVIMPSTStorageVPbkStoreHandler::ContactViewUnavailable( |
|
187 MVPbkContactViewBase& /*aView*/ ) |
|
188 { |
|
189 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewUnavailable begin") ); |
|
190 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewUnavailable end")); |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // CVIMPSTStorageVPbkStoreHandler::ContactAddedToView |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 void CVIMPSTStorageVPbkStoreHandler::ContactAddedToView( |
|
198 MVPbkContactViewBase& /*aView*/, |
|
199 TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ ) |
|
200 { |
|
201 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactAddedToView begin")); |
|
202 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactAddedToView End ")); |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CVIMPSTStorageVPbkStoreHandler::ContactRemovedFromView |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 void CVIMPSTStorageVPbkStoreHandler::ContactRemovedFromView( |
|
210 MVPbkContactViewBase& /*aView*/, |
|
211 TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ ) |
|
212 { |
|
213 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactRemovedFromView begin") ); |
|
214 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactRemovedFromView End")); |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // CVIMPSTStorageVPbkStoreHandler::ContactViewError |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 void CVIMPSTStorageVPbkStoreHandler::ContactViewError( |
|
222 MVPbkContactViewBase& /*aView*/, |
|
223 TInt /*aError*/, TBool /*aErrorNotified*/ ) |
|
224 { |
|
225 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewError() begin") ); |
|
226 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewError() end")); |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // CVIMPSTStorageVPbkStoreHandler::StoreReady |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 void CVIMPSTStorageVPbkStoreHandler::StoreReady( |
|
234 MVPbkContactStore& /*aContactStore*/ ) |
|
235 { |
|
236 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StoreReady() begin")); |
|
237 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StoreReady() end") ); |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // CVIMPSTStorageVPbkStoreHandler::StoreUnavailable |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 void CVIMPSTStorageVPbkStoreHandler::StoreUnavailable( |
|
245 MVPbkContactStore& /*aContactStore*/, |
|
246 TInt /*aReason*/ ) |
|
247 { |
|
248 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StoreUnavailable() begin") ); |
|
249 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StoreUnavailable() end")); |
|
250 } |
|
251 |
|
252 // --------------------------------------------------------------------------- |
|
253 // CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL |
|
254 // --------------------------------------------------------------------------- |
|
255 // |
|
256 MVPbkContactStore* CVIMPSTStorageVPbkStoreHandler::GetDefaultStoreL( const TDesC& aUri ) |
|
257 { |
|
258 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetDefaultStoreL() ")); |
|
259 return iStores->Find( TVPbkContactStoreUriPtr( aUri ) ); |
|
260 } |
|
261 |
|
262 // --------------------------------------------------------------------------- |
|
263 // CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL |
|
264 // --------------------------------------------------------------------------- |
|
265 // |
|
266 void CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL( |
|
267 MVPbkContactStore& aContactStore , |
|
268 TVPbkContactStoreEvent aStoreEvent ) |
|
269 { |
|
270 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() begin") ); |
|
271 if( iStore == &aContactStore ) |
|
272 { |
|
273 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() store event") ); |
|
274 switch( aStoreEvent.iEventType ) |
|
275 { |
|
276 case TVPbkContactStoreEvent::EContactAdded: |
|
277 { |
|
278 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactAdded event") ); |
|
279 delete iContactLink; |
|
280 iContactLink = NULL; |
|
281 MVPbkContactLink* contactLink = aStoreEvent.iContactLink->CloneLC(); |
|
282 iContactLink = contactLink; |
|
283 CleanupStack::Pop(); // contactLink |
|
284 IssueRequest(); // complete the request |
|
285 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactAdded done") ); |
|
286 break; |
|
287 } |
|
288 case TVPbkContactStoreEvent::EContactDeleted: |
|
289 { |
|
290 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactDeleted event") ); |
|
291 MVPbkContactLink* contactLink = aStoreEvent.iContactLink->CloneLC(); |
|
292 delete iContactLink; |
|
293 iContactLink = NULL; |
|
294 iContactLink = contactLink; |
|
295 CleanupStack::Pop(); // contactLink |
|
296 TVIMPSTVPbkStoreEvent storeEvent(EVPbkContactDeleted, iContactLink ); |
|
297 iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ; |
|
298 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactDeleted done") ); |
|
299 break; |
|
300 } |
|
301 case TVPbkContactStoreEvent::EContactChanged: |
|
302 { |
|
303 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactChanged event") ); |
|
304 delete iContactLink; |
|
305 iContactLink = NULL; |
|
306 MVPbkContactLink* contactLink = aStoreEvent.iContactLink->CloneLC(); |
|
307 iContactLink = contactLink; |
|
308 CleanupStack::Pop(); // contactLink |
|
309 iStoreEventType = EVPbkContactChanged; |
|
310 IssueRequest(); // complete the request which will begin retriving the iContactLink |
|
311 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactChanged done") ); |
|
312 break; |
|
313 } |
|
314 case TVPbkContactStoreEvent::EUnknownChanges: |
|
315 { |
|
316 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EUnknownChanges event") ); |
|
317 iStoreEventType = EVPbkUnknownChanges; |
|
318 TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType); |
|
319 iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ; |
|
320 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EUnknownChanges done") ); |
|
321 break; |
|
322 } |
|
323 default: |
|
324 break; |
|
325 } |
|
326 } |
|
327 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() end") ); |
|
328 } |
|
329 // --------------------------------------------------------------------------- |
|
330 // CVIMPSTStorageVPbkStoreHandler::OpenComplete |
|
331 // --------------------------------------------------------------------------- |
|
332 // |
|
333 void CVIMPSTStorageVPbkStoreHandler::OpenComplete() |
|
334 { |
|
335 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::OpenComplete() begin") ); |
|
336 // stores OpenAll completed |
|
337 TRAP_IGNORE( DoHnadleOpenCompleteL() ); |
|
338 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::OpenComplete() end")); |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------------------------- |
|
342 // CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL |
|
343 // --------------------------------------------------------------------------- |
|
344 // |
|
345 void CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL() |
|
346 { |
|
347 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL() begin") ); |
|
348 iStore = GetDefaultStoreL( *iStoreName ) ; |
|
349 CVPbkContactViewDefinition* viewDefinition = |
|
350 CVPbkContactViewDefinition::NewL(); |
|
351 CleanupStack::PushL( viewDefinition ); |
|
352 viewDefinition->SetType( EVPbkContactsView ); |
|
353 viewDefinition->SetUriL( *iStoreName ); |
|
354 if ( iStore ) |
|
355 { |
|
356 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL() store view creating")); |
|
357 MVPbkContactView* tmpView = iStore->CreateViewLC( |
|
358 *viewDefinition, |
|
359 *this, |
|
360 iSortOrderManager->SortOrder() ); |
|
361 CleanupStack::Pop(); // tmpView |
|
362 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL() store view created")); |
|
363 iContactView = tmpView; |
|
364 } |
|
365 CleanupStack::PopAndDestroy(); //viewDefinition, can not pop ny name |
|
366 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL() end")); |
|
367 } |
|
368 |
|
369 // --------------------------------------------------------------------------- |
|
370 // CVIMPSTStorageVPbkStoreHandler::ContactOperationCompleted |
|
371 // --------------------------------------------------------------------------- |
|
372 // |
|
373 void CVIMPSTStorageVPbkStoreHandler::ContactOperationCompleted( |
|
374 TContactOpResult /*aResult*/ ) |
|
375 { |
|
376 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactOperationCompleted() begin")); |
|
377 // called when contact commit is successful |
|
378 iOperationError = KErrNone; |
|
379 if( iWait.IsStarted() ) |
|
380 { |
|
381 iWait.AsyncStop(); |
|
382 } |
|
383 TRAP_IGNORE( CommitNextPendingContactsL() ); |
|
384 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactOperationCompleted() end")); |
|
385 } |
|
386 |
|
387 // --------------------------------------------------------------------------- |
|
388 // CVIMPSTStorageVPbkStoreHandler::ContactOperationFailed |
|
389 // --------------------------------------------------------------------------- |
|
390 // |
|
391 void CVIMPSTStorageVPbkStoreHandler::ContactOperationFailed( |
|
392 TContactOp /*aOpCode*/, TInt aErrorCode, TBool /*aErrorNotified*/ ) |
|
393 { |
|
394 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactOperationFailed() begin")); |
|
395 // called when contact commit is unsuccessful |
|
396 iOperationError = aErrorCode; |
|
397 if( iWait.IsStarted() ) |
|
398 { |
|
399 iWait.AsyncStop(); |
|
400 } |
|
401 TRAP_IGNORE( CommitNextPendingContactsL() ); |
|
402 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactOperationFailed() end")); |
|
403 } |
|
404 |
|
405 |
|
406 // -------------------------------------------------------------------------- |
|
407 // CVIMPSTStorageVPbkStoreHandler::StepComplete |
|
408 // -------------------------------------------------------------------------- |
|
409 // |
|
410 void CVIMPSTStorageVPbkStoreHandler::StepComplete( |
|
411 MVPbkContactOperationBase& /*aOperation*/, |
|
412 TInt /*aStepSize*/ ) |
|
413 { |
|
414 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StepComplete() begin")); |
|
415 // called when batch operation call |
|
416 iOperationError = KErrNone; |
|
417 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StepComplete() end")); |
|
418 } |
|
419 |
|
420 |
|
421 // -------------------------------------------------------------------------- |
|
422 // CVIMPSTStorageVPbkStoreHandler::StepFailed |
|
423 // -------------------------------------------------------------------------- |
|
424 // |
|
425 TBool CVIMPSTStorageVPbkStoreHandler::StepFailed( |
|
426 MVPbkContactOperationBase& /*aOperation*/, |
|
427 TInt /*aStepSize*/, |
|
428 TInt aError ) |
|
429 { |
|
430 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StepFailed() begin")); |
|
431 // called when batch operation call |
|
432 iOperationError = aError; |
|
433 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StepFailed() end")); |
|
434 return EFalse; |
|
435 } |
|
436 |
|
437 // -------------------------------------------------------------------------- |
|
438 // CVIMPSTStorageVPbkStoreHandler::OperationComplete |
|
439 // -------------------------------------------------------------------------- |
|
440 // |
|
441 void CVIMPSTStorageVPbkStoreHandler::OperationComplete( |
|
442 MVPbkContactOperationBase& aOperation ) |
|
443 { |
|
444 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::OperationComplete() begin")); |
|
445 // called when batch operation call for opening the multiple store |
|
446 if ( &aOperation == iContactOperation ) |
|
447 { |
|
448 delete iContactOperation; |
|
449 iContactOperation = NULL; |
|
450 } |
|
451 iOperationError = KErrNone; |
|
452 if( iWait.IsStarted() ) |
|
453 { |
|
454 iWait.AsyncStop(); |
|
455 } |
|
456 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::OperationComplete() end")); |
|
457 } |
|
458 |
|
459 //---------------------------------------------------------------------- |
|
460 //CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete() |
|
461 //---------------------------------------------------------------------- |
|
462 void CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete( MVPbkContactOperationBase& aOperation, |
|
463 MVPbkStoreContact* aContact ) |
|
464 { |
|
465 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete() begin")); |
|
466 // called when contact details is retrived |
|
467 TRAP_IGNORE( DoHnadleSingleContactOperationCompleteL( aOperation, aContact ) ); |
|
468 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete() end")); |
|
469 } |
|
470 |
|
471 //---------------------------------------------------------------------- |
|
472 //CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() |
|
473 //---------------------------------------------------------------------- |
|
474 void CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL( MVPbkContactOperationBase& aOperation, |
|
475 MVPbkStoreContact* aContact ) |
|
476 { |
|
477 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() begin")); |
|
478 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() StoreEventType: %d"),iStoreEventType); |
|
479 // called when contact details is retrived |
|
480 if( iStoreContact ) |
|
481 { |
|
482 delete iStoreContact; |
|
483 iStoreContact = NULL; |
|
484 } |
|
485 iStoreContact = aContact ; // iStoreContact owns thea Contact |
|
486 if( ( &aOperation == iContactOperation) && iStoreContact ) |
|
487 { |
|
488 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() inside if (operation) ")); |
|
489 if( iWait.IsStarted() ) |
|
490 { |
|
491 iWait.AsyncStop(); |
|
492 } |
|
493 delete iContactOperation; |
|
494 iContactOperation = NULL; |
|
495 TRACE( T_LIT("DoHnadleSingleContactOperationCompleteL() before iCommitOperationInProgress: %d"),iCommitOperationInProgress); |
|
496 iCommitOperationInProgress = EFalse; |
|
497 TRACE( T_LIT("DoHnadleSingleContactOperationCompleteL()After iCommitOperationInProgress: %d"),iCommitOperationInProgress); |
|
498 |
|
499 if( iStoreEventType != EVPbkUpdatingAvatar ) |
|
500 { |
|
501 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() inside if (iStoreEventType != EVPbkUpdatingAvatar ) ")); |
|
502 if( !iLocalStore && iStoreEventType == EVPbkContactRetriving ) |
|
503 { |
|
504 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() EVPbkContactRetriving")); |
|
505 RetriveFieldDataAndSendEventL( *iStoreContact ); |
|
506 } |
|
507 else |
|
508 { |
|
509 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() inside else start")); |
|
510 HBufC* userId = GetContactFieldDataLC( *iStoreContact, R_VPBK_FIELD_TYPE_IMPP ); |
|
511 HBufC* firstname = GetContactFieldDataLC( *iStoreContact,R_VPBK_FIELD_TYPE_FIRSTNAME ); |
|
512 HBufC* lastname = GetContactFieldDataLC( *iStoreContact,R_VPBK_FIELD_TYPE_LASTNAME ); |
|
513 |
|
514 HBufC* disname = NULL; |
|
515 /* |
|
516 * There are three scenarios where I can form the Display name. |
|
517 * 1. First and last name are present. |
|
518 * 2. First name is present but no last name is present. |
|
519 * 3. Lastname is there and no first name. |
|
520 * 4. if none, then assigning NULL |
|
521 */ |
|
522 if ( firstname && lastname ) |
|
523 { |
|
524 disname = HBufC::NewLC( firstname->Des().Length() + lastname->Des().Length()+ 1 ); |
|
525 TPtr disnamePtr( disname->Des() ); |
|
526 disnamePtr.Append(*firstname); |
|
527 if(firstname->Length() && lastname->Length() ) |
|
528 { |
|
529 disnamePtr.Append(KSpace); |
|
530 } |
|
531 disnamePtr.Append(*lastname); |
|
532 } |
|
533 else |
|
534 { |
|
535 disname = KNullDesC().AllocLC(); |
|
536 } |
|
537 HBufC8* avatarContent = GetContactBinaryFieldDataLC( *iStoreContact,R_VPBK_FIELD_TYPE_THUMBNAILPIC ); |
|
538 TRACE( T_LIT("DoHnadleSingleContactOperationCompleteL() iStoreHandler.HandleVPbkStoreEventL: %d"), iStoreEventType); |
|
539 TPtr useridPtr = userId->Des(); |
|
540 TRACE( T_LIT("DoHnadleSingleContactOperationCompleteL() inside else UserId : %S"), &useridPtr); |
|
541 TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType, |
|
542 iContactLink, |
|
543 NULL, |
|
544 *userId, |
|
545 *disname, |
|
546 *avatarContent); |
|
547 iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ; |
|
548 CleanupStack::PopAndDestroy(5); // disname,lastname,firstname,userId,avatarContent |
|
549 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() inside else end")); |
|
550 } |
|
551 delete iAddIdInProgress; |
|
552 iAddIdInProgress = NULL; |
|
553 } |
|
554 |
|
555 iOperationError = KErrNone; |
|
556 if( iStoreEventType == EVPbkContactReading && iContactView ) |
|
557 { |
|
558 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() if after iOperationError")); |
|
559 HandleContactViewReadyL( *iContactView ); |
|
560 } |
|
561 |
|
562 else if(!iCommitOperationInProgress ) |
|
563 { |
|
564 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() else if after if after iOperationError")); |
|
565 CommitNextPendingContactsL();// commit only if any pending contact |
|
566 } |
|
567 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() end")); |
|
568 } |
|
569 } |
|
570 //---------------------------------------------------------------------- |
|
571 //CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete() |
|
572 //---------------------------------------------------------------------- |
|
573 void CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationFailed( MVPbkContactOperationBase& aOperation, |
|
574 TInt aError) |
|
575 { |
|
576 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationFailed() begin")); |
|
577 if( &aOperation == iContactOperation ) |
|
578 { |
|
579 delete iContactOperation; |
|
580 iContactOperation = NULL; |
|
581 } |
|
582 iOperationError = aError; |
|
583 iCommitOperationInProgress = EFalse; |
|
584 if( iWait.IsStarted() ) |
|
585 { |
|
586 iWait.AsyncStop(); |
|
587 } |
|
588 TRAP_IGNORE( CommitNextPendingContactsL() );// commit only if any pending contact |
|
589 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationFailed() begin")); |
|
590 } |
|
591 // -------------------------------------------------------------------------- |
|
592 // CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL |
|
593 // -------------------------------------------------------------------------- |
|
594 // |
|
595 void CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL( MVPbkContactViewBase& aView ) |
|
596 { |
|
597 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL() begin")); |
|
598 TInt contactCount = aView.ContactCountL(); |
|
599 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL() begin")); |
|
600 if( contactCount == iFetcingIndex && iStoreEventType == EVPbkContactReading ) |
|
601 { |
|
602 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL() reading completed") ); |
|
603 iStoreEventType = EVPbkContactReadCompleted; |
|
604 TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType); |
|
605 iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ; |
|
606 } |
|
607 else if( iFetcingIndex < contactCount && iFetcingIndex>=0 ) |
|
608 { |
|
609 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL() reading")); |
|
610 const MVPbkViewContact& contact = aView.ContactAtL( iFetcingIndex ); |
|
611 MVPbkContactLink* contactLink = contact.CreateLinkLC(); |
|
612 delete iContactLink; |
|
613 iContactLink = NULL; |
|
614 iContactLink = contactLink; |
|
615 CleanupStack::Pop(); // contactLink |
|
616 IssueRequest(); |
|
617 iFetcingIndex++; |
|
618 } |
|
619 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL() end")); |
|
620 } |
|
621 // -------------------------------------------------------------------------- |
|
622 // CVIMPSTStorageVPbkStoreHandler::IssueRequest |
|
623 // -------------------------------------------------------------------------- |
|
624 // |
|
625 void CVIMPSTStorageVPbkStoreHandler::IssueRequest() |
|
626 { |
|
627 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::IssueRequest() begin")); |
|
628 if( !IsActive() ) |
|
629 { |
|
630 TRequestStatus* status = &iStatus; |
|
631 User::RequestComplete( status, KErrNone ); |
|
632 SetActive(); |
|
633 } |
|
634 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::IssueRequest() end")); |
|
635 } |
|
636 |
|
637 // -------------------------------------------------------------------------- |
|
638 // CVIMPSTStorageVPbkStoreHandler::RunL |
|
639 // -------------------------------------------------------------------------- |
|
640 // |
|
641 void CVIMPSTStorageVPbkStoreHandler::RunL() |
|
642 { |
|
643 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RunL() begin") ); |
|
644 if( iContactLink ) |
|
645 { |
|
646 delete iContactOperation; |
|
647 iContactOperation = NULL; |
|
648 iContactOperation = iContactManager->RetrieveContactL( *iContactLink, *this ); |
|
649 } |
|
650 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RunL() end")); |
|
651 } |
|
652 |
|
653 // -------------------------------------------------------------------------- |
|
654 // CVIMPSTStorageVPbkStoreHandler::DoCancel |
|
655 // -------------------------------------------------------------------------- |
|
656 // |
|
657 void CVIMPSTStorageVPbkStoreHandler::DoCancel() |
|
658 { |
|
659 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoCancel() begin") ); |
|
660 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoCancel() end") ); |
|
661 } |
|
662 |
|
663 // -------------------------------------------------------------------------- |
|
664 // CVIMPSTStorageVPbkStoreHandler::RunError |
|
665 // -------------------------------------------------------------------------- |
|
666 // |
|
667 TInt CVIMPSTStorageVPbkStoreHandler::RunError( TInt aError ) |
|
668 { |
|
669 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RunError()") ); |
|
670 return aError; |
|
671 } |
|
672 |
|
673 ////////////////////////////////////////////////////////// |
|
674 // --------------------------------------------------------------------------- |
|
675 // CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL |
|
676 // --------------------------------------------------------------------------- |
|
677 // |
|
678 TInt CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL(const TDesC& aUserId, |
|
679 const TDesC& aDisplayName ) |
|
680 { |
|
681 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() begin") ); |
|
682 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() aUserId = %S"), &aUserId ); |
|
683 |
|
684 if( iAddIdInProgress && iAddIdInProgress->Compare( aUserId ) == 0 ) |
|
685 { |
|
686 TPtr iAddIdInProgressPtr = iAddIdInProgress->Des(); |
|
687 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() iAddIdInProgressPtr = %S"), &iAddIdInProgressPtr ); |
|
688 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() already Adding") ); |
|
689 return KErrAlreadyExists; |
|
690 } |
|
691 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() After If") ); |
|
692 delete iAddIdInProgress; |
|
693 iAddIdInProgress = NULL; |
|
694 iAddIdInProgress = aUserId.AllocL(); |
|
695 |
|
696 if(iStore) |
|
697 { |
|
698 MVPbkStoreContact* storedContact = iStore->CreateNewContactLC(); //1 |
|
699 if( !storedContact ) |
|
700 { |
|
701 return NULL; |
|
702 } |
|
703 if(aUserId.Length()!= 0) |
|
704 { |
|
705 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() valid xsp Id") ); |
|
706 TInt prefixLocation = aUserId.Locate( ':' ); |
|
707 const MVPbkContactStoreProperties& storeProperties = storedContact->ParentStore().StoreProperties(); |
|
708 const MVPbkFieldTypeList& supportedFieldTypes = storeProperties.SupportedFields(); |
|
709 TInt fieldCount = supportedFieldTypes.FieldTypeCount(); |
|
710 |
|
711 for( TInt index = 0 ; index < fieldCount ; index++ ) |
|
712 { |
|
713 const MVPbkFieldType* fieldType = &(supportedFieldTypes.FieldTypeAt(index)); |
|
714 if ( fieldType && ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_IMPP )) |
|
715 { |
|
716 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() XSP Id-IMMP field creating") ); |
|
717 MVPbkStoreContactField* fielduri = storedContact->CreateFieldLC(*fieldType); //2 |
|
718 // Check for prefix and remove if found |
|
719 //append the internettelephoney field. |
|
720 HBufC* fieldData = NULL; |
|
721 TInt serFieldLength = aUserId.Length(); |
|
722 if( prefixLocation >=0 && ( prefixLocation < serFieldLength ) ) |
|
723 { |
|
724 fieldData = aUserId.Right(serFieldLength - prefixLocation - 1).AllocLC(); //3 |
|
725 } |
|
726 else |
|
727 { |
|
728 fieldData = aUserId.AllocLC(); // 3 |
|
729 } |
|
730 if (fieldData) |
|
731 { |
|
732 TPtr fieldDataPtr( fieldData->Des() ); |
|
733 MVPbkContactFieldUriData& address = MVPbkContactFieldUriData::Cast( fielduri->FieldData() ); |
|
734 // TODO check here about servicename:userId |
|
735 address.SetUriL(*iServiceName,*fieldData); |
|
736 // fielduri ownership is transfered to storedContact |
|
737 storedContact->AddFieldL(fielduri); |
|
738 CleanupStack::PopAndDestroy(fieldData); //3 |
|
739 CleanupStack::Pop(); //fielduri 2 |
|
740 }//End if (fieldData) |
|
741 else |
|
742 { |
|
743 CleanupStack::PopAndDestroy(); //2 fielduri |
|
744 } |
|
745 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() XSP Id-IMMP field created") ); |
|
746 }//end of if |
|
747 else if ( fieldType && |
|
748 ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_FIRSTNAME )) |
|
749 { |
|
750 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() first name field creating") ); |
|
751 HBufC* firstName = NULL; |
|
752 |
|
753 // if there is no display name then allocate hte user id as displayname. |
|
754 if(!(aDisplayName.Length())) |
|
755 { |
|
756 // if aServiceField is sip:user1@ouped111147.nmp.nokia.com, then |
|
757 // rippedaServiceField will be user1@ouped111147.nmp.nokia.com |
|
758 TPtrC rippedaServiceField = aUserId.Mid(prefixLocation+1); |
|
759 //append first name. |
|
760 TInt atLocation = rippedaServiceField.Locate( '@' ); |
|
761 if( atLocation > 0 && ( atLocation < rippedaServiceField.Length() ) ) |
|
762 { |
|
763 // atLocation must be greater that 0 |
|
764 firstName = rippedaServiceField.Left( atLocation ).AllocLC() ; //2 |
|
765 } |
|
766 else |
|
767 { |
|
768 firstName = rippedaServiceField.AllocLC(); //2 |
|
769 } |
|
770 } |
|
771 // there is a display name hence allocate it. |
|
772 else |
|
773 { |
|
774 firstName = aDisplayName.AllocLC();//2 |
|
775 } |
|
776 |
|
777 if (firstName) |
|
778 { |
|
779 MVPbkStoreContactField* firstNamefield = storedContact->CreateFieldLC(*fieldType); //2 |
|
780 MVPbkContactFieldTextData& firstNameText = MVPbkContactFieldTextData::Cast( firstNamefield->FieldData() ); |
|
781 firstNameText.SetTextL(*firstName); |
|
782 storedContact->AddFieldL(firstNamefield); // firstNamefield ownership transfered to storedContact |
|
783 CleanupStack::Pop(); //firstNamefield 2 |
|
784 CleanupStack::PopAndDestroy(firstName); // 3 |
|
785 }//End if (firstName) |
|
786 |
|
787 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() first name field created") ); |
|
788 }//end of if. |
|
789 }//end of for. |
|
790 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() iCommitOperationInProgress = %d"),iCommitOperationInProgress ); |
|
791 if( iCommitOperationInProgress ) |
|
792 { |
|
793 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() inside if") ); |
|
794 iUnCommittedVPbkContacts.AppendL( storedContact ); //takes ownership |
|
795 CleanupStack::Pop(); //storedContact |
|
796 } |
|
797 else |
|
798 { |
|
799 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() inside else") ); |
|
800 iCommitOperationInProgress = ETrue; |
|
801 if(iStoreContact) |
|
802 { |
|
803 delete iStoreContact; |
|
804 iStoreContact = NULL; |
|
805 } |
|
806 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() contact fields added") ); |
|
807 iStoreContact = storedContact; |
|
808 CleanupStack::Pop(); //storedContact |
|
809 iStoreContact->CommitL(*this); |
|
810 iStoreEventType = EVPbkContactAdded; |
|
811 } |
|
812 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() contact commited") ); |
|
813 //Start the wait untill adding of new contact is complete |
|
814 } |
|
815 } |
|
816 //return the added contact |
|
817 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() iOperationError =%d"),iOperationError ); |
|
818 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() end") ); |
|
819 return iOperationError; |
|
820 } |
|
821 |
|
822 // --------------------------------------------------------------------------- |
|
823 // CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL |
|
824 // --------------------------------------------------------------------------- |
|
825 // |
|
826 void CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() |
|
827 { |
|
828 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() Start") ); |
|
829 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() iStoreEventType = %d"),iStoreEventType ); |
|
830 if( !iCommitOperationInProgress && iUnCommittedVPbkContacts.Count() && iStoreEventType != EVPbkUpdatingAvatar) |
|
831 { |
|
832 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() Commit next") ); |
|
833 iCommitOperationInProgress = ETrue; |
|
834 if(iStoreContact) |
|
835 { |
|
836 delete iStoreContact; |
|
837 iStoreContact = NULL; |
|
838 } |
|
839 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() comming...") ); |
|
840 iStoreContact = iUnCommittedVPbkContacts[0]; |
|
841 iUnCommittedVPbkContacts.Remove(0); |
|
842 iUnCommittedVPbkContacts.Compress(); |
|
843 iStoreContact->CommitL(*this); |
|
844 iStoreEventType = EVPbkContactSynchronizing; |
|
845 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() Commit called") ); |
|
846 } |
|
847 else if(!iCommitOperationInProgress && iPendingAvatars.Count() && iStoreEventType != EVPbkUpdatingAvatar) |
|
848 { |
|
849 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() Commit next pending avatar") ); |
|
850 TVIMPSTAvatarData avatarData = iPendingAvatars[0]; |
|
851 UpdateAvatarFieldDataL( *avatarData.iContactLink, *avatarData.iAvatarContent ); |
|
852 iPendingAvatars.Remove( 0 ); |
|
853 delete avatarData.iContactLink; |
|
854 avatarData.iContactLink = NULL; |
|
855 delete avatarData.iAvatarContent; |
|
856 avatarData.iAvatarContent = NULL; |
|
857 iPendingAvatars.Compress(); |
|
858 } |
|
859 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() End") ); |
|
860 } |
|
861 |
|
862 // --------------------------------------------------------------------------- |
|
863 // CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL |
|
864 // --------------------------------------------------------------------------- |
|
865 // |
|
866 TInt CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL(const CVPbkContactLinkArray& aContactLinkArray ) |
|
867 { |
|
868 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL() begin") ); |
|
869 // text now holds the name (or first field of the contact) |
|
870 delete iContactOperation; |
|
871 iContactOperation = NULL; |
|
872 iContactOperation = iContactManager->DeleteContactsL(aContactLinkArray, *this ); |
|
873 if( !iWait.IsStarted() ) |
|
874 { |
|
875 iWait.Start(); |
|
876 } |
|
877 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL() iOperationError=%d"),iOperationError ); |
|
878 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL() end") ); |
|
879 return iOperationError; |
|
880 } |
|
881 |
|
882 // --------------------------------------------------------------------------- |
|
883 // CVIMPSTStorageVPbkStoreHandler::RetrieveVPbkContactL |
|
884 // --------------------------------------------------------------------------- |
|
885 // |
|
886 TInt CVIMPSTStorageVPbkStoreHandler::RetrieveVPbkContactL(const TDesC8& aPackedLinks) |
|
887 { |
|
888 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetrieveVPbkContactL() begin") ); |
|
889 iStoreEventType = EVPbkContactRetriving; |
|
890 CVPbkContactLinkArray* linkArray = CVPbkContactLinkArray::NewLC(aPackedLinks, *iStores ); |
|
891 // text now holds the name (or first field of the contact) |
|
892 TInt count = linkArray->Count(); |
|
893 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StoreReady() count=%d"),count ); |
|
894 for ( TInt i=0; i<count; i++ ) |
|
895 { |
|
896 delete iContactLink; |
|
897 iContactLink = NULL; |
|
898 // local variable caz cant push member variable to cleanup stack |
|
899 MVPbkContactLink* cloneLink = linkArray->At( i ).CloneLC(); |
|
900 iContactLink = cloneLink; |
|
901 CleanupStack::Pop(); // cloneLink |
|
902 |
|
903 delete iContactOperation; |
|
904 iContactOperation = NULL; |
|
905 |
|
906 iContactOperation = iContactManager->RetrieveContactL( *iContactLink, *this ); |
|
907 if( !iWait.IsStarted() ) |
|
908 { |
|
909 iWait.Start(); |
|
910 } |
|
911 } |
|
912 CleanupStack::PopAndDestroy();//linkArray |
|
913 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetrieveVPbkContactL() end") ); |
|
914 return iOperationError; |
|
915 } |
|
916 |
|
917 |
|
918 |
|
919 // --------------------------------------------------------------------------- |
|
920 // CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL() |
|
921 // --------------------------------------------------------------------------- |
|
922 // |
|
923 TInt CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL(const MVPbkContactLink& aContactLink, |
|
924 const TDesC8& aAvatartData ) |
|
925 { |
|
926 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL() begin") ); |
|
927 |
|
928 // local variable caz cant push member variable to cleanup stack |
|
929 MVPbkContactLink* cloneLink = aContactLink.CloneLC(); |
|
930 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL() iCommitOperationInProgress: %d"),iCommitOperationInProgress ); |
|
931 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL() iUnCommittedVPbkContacts: %d"),iUnCommittedVPbkContacts.Count() ); |
|
932 if(iCommitOperationInProgress || iUnCommittedVPbkContacts.Count() || iStoreEventType == EVPbkUpdatingAvatar ) |
|
933 { |
|
934 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL()Inside if") ); |
|
935 TVIMPSTAvatarData avatarData = { |
|
936 cloneLink, |
|
937 aAvatartData.AllocL() |
|
938 }; |
|
939 iPendingAvatars.Append( avatarData ); |
|
940 CleanupStack::Pop(); // cloneLink |
|
941 return KErrInUse; |
|
942 } |
|
943 iCommitOperationInProgress = ETrue; |
|
944 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL()Inside after if") ); |
|
945 delete iContactLink; |
|
946 iContactLink = NULL; |
|
947 iContactLink = cloneLink; |
|
948 CleanupStack::Pop(); // cloneLink |
|
949 |
|
950 //before updating the avatar, check if there are any pending operation already, if there are any, |
|
951 // then delete them and create the next one. |
|
952 if(iContactOperation) |
|
953 { |
|
954 delete iContactOperation; |
|
955 iContactOperation = NULL; |
|
956 } |
|
957 iStoreEventType = EVPbkUpdatingAvatar; |
|
958 iContactOperation = iContactManager->RetrieveContactL( *iContactLink, *this ); |
|
959 if( !iWait.IsStarted() ) |
|
960 { |
|
961 iWait.Start(); |
|
962 } |
|
963 // exception KErrInUse If another asynchronous operation is |
|
964 // already in progress. |
|
965 // exception KErrAccessDenied if the contact can not be modified. |
|
966 iStoreContact->LockL(*this); |
|
967 |
|
968 |
|
969 //wait till lock operation is succeded |
|
970 if(!iWait.IsStarted() ) |
|
971 { |
|
972 iWait.Start(); |
|
973 } |
|
974 TInt fieldcount = iStoreContact->Fields().FieldCount(); |
|
975 for( TInt j = 0 ; j < fieldcount ; j++ ) |
|
976 { |
|
977 const MVPbkFieldType* fieldType = iStoreContact->Fields().FieldAt(j).BestMatchingFieldType(); |
|
978 if( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_THUMBNAILPIC ) |
|
979 { |
|
980 iStoreContact->RemoveField(j); |
|
981 break; |
|
982 } |
|
983 } |
|
984 if( aAvatartData.Length() ) |
|
985 { |
|
986 const MVPbkContactStoreProperties& storeProperties = iStoreContact->ParentStore().StoreProperties(); |
|
987 const MVPbkFieldTypeList& supportedFieldTypes = storeProperties.SupportedFields(); |
|
988 TInt fieldCount = supportedFieldTypes.FieldTypeCount(); |
|
989 for( TInt index = 0 ; index < fieldCount ; index++ ) |
|
990 { |
|
991 const MVPbkFieldType* fieldType = &( supportedFieldTypes.FieldTypeAt(index) ); |
|
992 //find the relevant voip fields/email id fileds. |
|
993 if ( fieldType && ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_THUMBNAILPIC ) ) |
|
994 { |
|
995 //updating avatar field in the virtual phonebook |
|
996 //found the required fieldtype |
|
997 MVPbkStoreContactField* storeField = iStoreContact->CreateFieldLC(*fieldType); |
|
998 // The aField instance can not be used after AddFieldL |
|
999 //storeField ownership is transferred |
|
1000 TInt fieldIndex = iStoreContact->AddFieldL(storeField); |
|
1001 MVPbkContactFieldData& dataField = iStoreContact->Fields().FieldAt( fieldIndex ).FieldData(); |
|
1002 MVPbkContactFieldBinaryData& data = MVPbkContactFieldBinaryData::Cast(dataField); |
|
1003 data.SetBinaryDataL(aAvatartData); |
|
1004 CleanupStack::Pop(); // storeField |
|
1005 break; |
|
1006 } |
|
1007 } |
|
1008 } |
|
1009 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL()Inside after if(avatardata.length)") ); |
|
1010 iStoreEventType = EVPbkContactChanged; |
|
1011 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL()Inside after if(avatardata.length ): %d"),iStoreEventType ); |
|
1012 iStoreContact->CommitL(*this); |
|
1013 //wait for delete Avatar operation to complete. |
|
1014 if(!iWait.IsStarted() ) |
|
1015 { |
|
1016 iWait.Start(); |
|
1017 } |
|
1018 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL() end") ); |
|
1019 return iOperationError; |
|
1020 } |
|
1021 |
|
1022 // --------------------------------------------------------------------------- |
|
1023 // CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL() |
|
1024 // --------------------------------------------------------------------------- |
|
1025 // |
|
1026 TInt CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL(MVPbkStoreContact& aStoreContact) |
|
1027 { |
|
1028 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL() begin") ); |
|
1029 aStoreContact.LockL(*this); |
|
1030 //wait till lock operation is succeded |
|
1031 if(!iWait.IsStarted() ) |
|
1032 { |
|
1033 iWait.Start(); |
|
1034 } |
|
1035 TInt fieldcount = aStoreContact.Fields().FieldCount(); |
|
1036 for( TInt j = 0 ; j < fieldcount ; j++ ) |
|
1037 { |
|
1038 const MVPbkFieldType* fieldType = aStoreContact.Fields().FieldAt(j).BestMatchingFieldType(); |
|
1039 if( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_THUMBNAILPIC ) |
|
1040 { |
|
1041 aStoreContact.RemoveField(j); |
|
1042 break; |
|
1043 } |
|
1044 } |
|
1045 aStoreContact.CommitL(*this); |
|
1046 //wait for delete Avatar operation to complete. |
|
1047 if(!iWait.IsStarted() ) |
|
1048 { |
|
1049 iWait.Start(); |
|
1050 } |
|
1051 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL() iOperationError =%d"),iOperationError ); |
|
1052 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL() end") ); |
|
1053 return iOperationError; |
|
1054 } |
|
1055 |
|
1056 // --------------------------------------------------------------------------- |
|
1057 // CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() |
|
1058 // --------------------------------------------------------------------------- |
|
1059 // |
|
1060 HBufC* CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC(const MVPbkStoreContact& aContact, |
|
1061 TInt aFieldResId ) |
|
1062 { |
|
1063 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() begin") ); |
|
1064 HBufC* retValue = NULL; |
|
1065 const MVPbkStoreContactFieldCollection& fieldCollection = aContact.Fields(); |
|
1066 TInt fieldCount = fieldCollection.FieldCount(); |
|
1067 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() fieldCount%d"),fieldCount ); |
|
1068 for( TInt index = 0 ; index < fieldCount ; index++ ) |
|
1069 { |
|
1070 const MVPbkStoreContactField& field = fieldCollection.FieldAt( index ); |
|
1071 const MVPbkFieldType* fieldType = field.BestMatchingFieldType(); |
|
1072 //find the relevant xSP field |
|
1073 if ( fieldType && ( fieldType->FieldTypeResId() == aFieldResId ) ) |
|
1074 { |
|
1075 const MVPbkContactFieldData& fieldData = field.FieldData(); |
|
1076 switch( fieldData.DataType() ) |
|
1077 { |
|
1078 case EVPbkFieldStorageTypeText: |
|
1079 { |
|
1080 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() Text") ); |
|
1081 retValue = MVPbkContactFieldTextData::Cast(fieldData).Text().AllocLC(); |
|
1082 break; |
|
1083 } |
|
1084 case EVPbkFieldStorageTypeUri: |
|
1085 { |
|
1086 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() Uri ")); |
|
1087 retValue = MVPbkContactFieldUriData::Cast(fieldData).Text().AllocLC(); |
|
1088 break; |
|
1089 } |
|
1090 |
|
1091 }//End switch |
|
1092 if( aFieldResId == R_VPBK_FIELD_TYPE_IMPP && retValue ) |
|
1093 { |
|
1094 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() IMPP fild found")); |
|
1095 // TODO RAMC : Nikhil/Mukesh |
|
1096 // in case of srver contacts it also find the first valid xsp id |
|
1097 // not valid through NULL |
|
1098 // which can be clarified |
|
1099 // earlier it show selection query in UI which one to use |
|
1100 TPtrC scheme = MVPbkContactFieldUriData::Cast(fieldData).Scheme(); |
|
1101 if( scheme.Compare( *iServiceName ) == 0 ) |
|
1102 { |
|
1103 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() actual xsp Id found")); |
|
1104 // actual xsp id found break the loop and return |
|
1105 break; |
|
1106 } |
|
1107 else |
|
1108 { |
|
1109 // actual xsp not yet found continue looking |
|
1110 CleanupStack::PopAndDestroy(); // retValue; |
|
1111 retValue = NULL; |
|
1112 } |
|
1113 } |
|
1114 else if( retValue ) |
|
1115 { |
|
1116 // break this loop once the given aFieldResId is found |
|
1117 // with valid data |
|
1118 break; |
|
1119 } |
|
1120 } |
|
1121 } |
|
1122 if( !retValue ) |
|
1123 { |
|
1124 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() NULL value")); |
|
1125 // if NULL assign valid ptr |
|
1126 retValue = KNullDesC().AllocLC(); |
|
1127 } |
|
1128 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() end")); |
|
1129 return retValue;// ownership is return to caller |
|
1130 } |
|
1131 |
|
1132 // --------------------------------------------------------------------------- |
|
1133 // CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC() |
|
1134 // --------------------------------------------------------------------------- |
|
1135 // |
|
1136 HBufC8* CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC(const MVPbkStoreContact& aContact, |
|
1137 TInt aFieldResId ) |
|
1138 { |
|
1139 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC() begin") ); |
|
1140 HBufC8* retValue = NULL; |
|
1141 const MVPbkStoreContactFieldCollection& fieldCollection = aContact.Fields(); |
|
1142 TInt fieldCount = fieldCollection.FieldCount(); |
|
1143 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC() fieldCount%d"),fieldCount ); |
|
1144 for( TInt index = 0 ; index < fieldCount ; index++ ) |
|
1145 { |
|
1146 const MVPbkStoreContactField& field = fieldCollection.FieldAt( index ); |
|
1147 const MVPbkFieldType* fieldType = field.BestMatchingFieldType(); |
|
1148 //find the relevant xSP field |
|
1149 if ( fieldType && ( fieldType->FieldTypeResId() == aFieldResId ) ) |
|
1150 { |
|
1151 const MVPbkContactFieldData& fieldData = field.FieldData(); |
|
1152 switch( fieldData.DataType() ) |
|
1153 { |
|
1154 case EVPbkFieldStorageTypeBinary: |
|
1155 { |
|
1156 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC() Text") ); |
|
1157 retValue = MVPbkContactFieldBinaryData::Cast(fieldData).BinaryData().AllocLC(); |
|
1158 break; |
|
1159 } |
|
1160 }//End switch |
|
1161 if( retValue ) |
|
1162 { |
|
1163 // break this loop once the given aFieldResId is found |
|
1164 // with valid data |
|
1165 break; |
|
1166 } |
|
1167 } |
|
1168 } |
|
1169 if( !retValue ) |
|
1170 { |
|
1171 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC() NULL value")); |
|
1172 // if NULL assign valid ptr |
|
1173 retValue = KNullDesC8().AllocLC(); |
|
1174 } |
|
1175 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC() end")); |
|
1176 return retValue;// ownership is return to caller |
|
1177 } |
|
1178 |
|
1179 |
|
1180 // --------------------------------------------------------- |
|
1181 // CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL |
|
1182 // |
|
1183 // --------------------------------------------------------- |
|
1184 void CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL(const MVPbkStoreContact& aContact ) |
|
1185 { |
|
1186 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL() begin") ); |
|
1187 HBufC* retValue = NULL; |
|
1188 const MVPbkStoreContactFieldCollection& fieldCollection = aContact.Fields(); |
|
1189 TInt fieldCount = fieldCollection.FieldCount(); |
|
1190 for( TInt index = 0 ; index < fieldCount ; index++ ) |
|
1191 { |
|
1192 const MVPbkStoreContactField& field = fieldCollection.FieldAt( index ); |
|
1193 const MVPbkFieldType* fieldType = field.BestMatchingFieldType(); |
|
1194 //find the relevant xSP field |
|
1195 //if ( fieldType && ( fieldType->FieldTypeResId() == aFieldResId ) ) |
|
1196 if ( fieldType && (( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_IMPP ) |
|
1197 || (fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_LANDPHONEHOME ) |
|
1198 ||(fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_MOBILEPHONEHOME ) |
|
1199 ||(fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_LANDPHONEWORK ) |
|
1200 ||(fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_MOBILEPHONEWORK ) |
|
1201 ||(fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_VOIPWORK ) |
|
1202 ||(fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_VOIPHOME ) |
|
1203 ||(fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_LANDPHONEGEN ) |
|
1204 ||(fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) |
|
1205 ||(fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_VOIPGEN ) |
|
1206 ||(fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_SIP ) )) |
|
1207 { |
|
1208 const MVPbkContactFieldData& fieldData = field.FieldData(); |
|
1209 switch( fieldData.DataType() ) |
|
1210 { |
|
1211 case EVPbkFieldStorageTypeText: |
|
1212 { |
|
1213 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL() Text") ); |
|
1214 retValue = MVPbkContactFieldTextData::Cast(fieldData).Text().AllocLC(); |
|
1215 break; |
|
1216 } |
|
1217 case EVPbkFieldStorageTypeUri: |
|
1218 { |
|
1219 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL() begin") ) ; |
|
1220 retValue = MVPbkContactFieldUriData::Cast(fieldData).Text().AllocLC(); |
|
1221 break; |
|
1222 } |
|
1223 |
|
1224 }//End switch |
|
1225 if( retValue ) |
|
1226 { |
|
1227 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL() begin") ); |
|
1228 TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType, |
|
1229 NULL, |
|
1230 NULL, |
|
1231 *retValue, |
|
1232 KNullDesC ); |
|
1233 iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ; |
|
1234 CleanupStack::PopAndDestroy(); // retValue; |
|
1235 retValue = NULL; |
|
1236 } |
|
1237 } |
|
1238 } |
|
1239 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL() begin") ); |
|
1240 } |
|
1241 |
|
1242 // --------------------------------------------------------- |
|
1243 // CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL |
|
1244 // |
|
1245 // --------------------------------------------------------- |
|
1246 TInt CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() |
|
1247 { |
|
1248 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() begin") ); |
|
1249 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() before if") ); |
|
1250 if(iAddIdInProgress) |
|
1251 { |
|
1252 TPtr iAddIdInProgressPtr = iAddIdInProgress->Des(); |
|
1253 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() iAddIdInProgressPtr = %S"), &iAddIdInProgressPtr ); |
|
1254 delete iAddIdInProgress; |
|
1255 iAddIdInProgress = NULL; |
|
1256 } |
|
1257 // intialize it to efalse as, somewhere it would have missed. |
|
1258 iCommitOperationInProgress = EFalse; |
|
1259 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() After if") ); |
|
1260 TInt count = 0; |
|
1261 if( iContactView ) |
|
1262 { |
|
1263 count = iContactView->ContactCountL(); |
|
1264 } |
|
1265 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() count = %d"),count) ; |
|
1266 TPtr iStoreNamePtr(iStoreName->Des() ); |
|
1267 TInt index = iStoreNamePtr.Find(_L(":") ); |
|
1268 if( index >= 0 && count ) |
|
1269 { |
|
1270 TPtrC store = iStoreNamePtr.Right( iStoreNamePtr.Length() - index -3 ); |
|
1271 CContactIdArray* contactIds = CContactIdArray::NewLC(); |
|
1272 CContactDatabase* contactDb = NULL; |
|
1273 //Open the database |
|
1274 TRAPD(err, contactDb = CContactDatabase::OpenL( store ) ); |
|
1275 if(err == KErrNone ) |
|
1276 { |
|
1277 CleanupStack::PushL( contactDb ); |
|
1278 // rest if already old ids exist |
|
1279 contactIds->Reset(); |
|
1280 TContactIter iterator(*contactDb); |
|
1281 TContactItemId contactId = iterator.FirstL(); |
|
1282 while(contactId != KNullContactId) |
|
1283 { |
|
1284 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() in side while") ); |
|
1285 // store into iContactIds for later deletion of contacts |
|
1286 contactIds->AddL(contactId ); |
|
1287 // get the next contactids |
|
1288 contactId = iterator.NextL(); |
|
1289 } |
|
1290 contactDb->DeleteContactsL(*contactIds); |
|
1291 // reset old ids |
|
1292 contactIds->Reset(); |
|
1293 CleanupStack::PopAndDestroy( contactDb ); |
|
1294 } |
|
1295 CleanupStack::PopAndDestroy( contactIds ); |
|
1296 } |
|
1297 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() end") ); |
|
1298 return count; |
|
1299 } |
|
1300 |
|
1301 // --------------------------------------------------------------------------- |
|
1302 // CVIMPSTStorageVPbkStoreHandler::ResetAndDestroyRArray |
|
1303 // --------------------------------------------------------------------------- |
|
1304 // |
|
1305 void CVIMPSTStorageVPbkStoreHandler::ResetAndDestroyRArray() |
|
1306 { |
|
1307 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ResetAndDestroyRArrayL() begin") ); |
|
1308 TInt count = iPendingAvatars.Count(); |
|
1309 while( count ) |
|
1310 { |
|
1311 TVIMPSTAvatarData contactInf = iPendingAvatars[ 0 ]; |
|
1312 iPendingAvatars.Remove(0 ); |
|
1313 delete contactInf.iAvatarContent; |
|
1314 contactInf.iAvatarContent = NULL; |
|
1315 delete contactInf.iContactLink; |
|
1316 contactInf.iContactLink = NULL; |
|
1317 // not exist need to add |
|
1318 iPendingAvatars.Compress(); |
|
1319 count = iPendingAvatars.Count(); |
|
1320 } |
|
1321 iPendingAvatars.Reset(); |
|
1322 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ResetAndDestroyRArrayL() end") ); |
|
1323 } |
|
1324 // End of file |