|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 fetch results. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2FetchResults.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include "MPbk2FetchDlg.h" |
|
23 #include "MPbk2FetchDlgPage.h" |
|
24 #include "MPbk2FetchDlgPages.h" |
|
25 #include "MPbk2FetchResultsObserver.h" |
|
26 #include <MPbk2FetchDlgObserver.h> |
|
27 #include <MPbk2ContactUiControl.h> |
|
28 |
|
29 // Virtual Phonebook |
|
30 #include <CVPbkContactLinkArray.h> |
|
31 #include <MVPbkContactLink.h> |
|
32 #include <CVPbkContactManager.h> |
|
33 #include <MVPbkContactGroup.h> |
|
34 #include <MVPbkContactStoreList.h> |
|
35 #include <MVPbkContactStore.h> |
|
36 #include <MVPbkContactOperationBase.h> |
|
37 #include <MVPbkContactViewBase.h> |
|
38 |
|
39 // System includes |
|
40 #include <coemain.h> |
|
41 #include <akninputblock.h> |
|
42 |
|
43 // Debugging headers |
|
44 #include <Pbk2Debug.h> |
|
45 |
|
46 // -------------------------------------------------------------------------- |
|
47 // CPbk2FetchResults::CPbk2FetchResults |
|
48 // -------------------------------------------------------------------------- |
|
49 // |
|
50 CPbk2FetchResults::CPbk2FetchResults |
|
51 ( CVPbkContactManager& aContactManager, |
|
52 MPbk2FetchDlg& aFetchDlg, |
|
53 MPbk2FetchDlgPages& aPages, |
|
54 MPbk2FetchDlgObserver& aObserver, |
|
55 MPbk2FetchResultsObserver& aResultsObserver ) : |
|
56 iContactManager( aContactManager ), |
|
57 iFetchDlg( aFetchDlg ), |
|
58 iPages( aPages ), |
|
59 iObserver( aObserver ), |
|
60 iResultsObserver( aResultsObserver ), |
|
61 iWaitingForDelayedAppend( EFalse ), |
|
62 iInputBlock( NULL ) |
|
63 { |
|
64 } |
|
65 |
|
66 // -------------------------------------------------------------------------- |
|
67 // CPbk2FetchResults::~CPbk2FetchResults |
|
68 // -------------------------------------------------------------------------- |
|
69 // |
|
70 CPbk2FetchResults::~CPbk2FetchResults() |
|
71 { |
|
72 if ( iStoreList ) |
|
73 { |
|
74 for ( TInt i = 0; i < iStoreList->Count(); ++i ) |
|
75 { |
|
76 MVPbkContactStore& store = iStoreList->At( i ); |
|
77 store.Close( *this ); |
|
78 } |
|
79 } |
|
80 |
|
81 delete iSelectedContacts; |
|
82 |
|
83 delete iRetrieveOperation; |
|
84 |
|
85 if( iOperationQueue ) |
|
86 { |
|
87 for ( TInt k = 0; k < iOperationQueue->Count(); k++ ) |
|
88 delete iOperationQueue->At(k); |
|
89 |
|
90 delete iOperationQueue; |
|
91 } |
|
92 |
|
93 delete iWaitForAllOperationComplete; |
|
94 } |
|
95 |
|
96 // -------------------------------------------------------------------------- |
|
97 // CPbk2FetchResults::ConstructL |
|
98 // -------------------------------------------------------------------------- |
|
99 // |
|
100 inline void CPbk2FetchResults::ConstructL |
|
101 ( CVPbkContactManager& aContactManager ) |
|
102 { |
|
103 iSelectedContacts = CVPbkContactLinkArray::NewL(); |
|
104 |
|
105 iStoreList = &aContactManager.ContactStoresL(); |
|
106 |
|
107 const TInt storeCount = iStoreList->Count(); |
|
108 for (TInt i = 0; i < storeCount; ++i) |
|
109 { |
|
110 MVPbkContactStore& store = iStoreList->At( i ); |
|
111 store.OpenL( *this ); |
|
112 } |
|
113 |
|
114 iOperationQueue = new (ELeave) CArrayFixFlat<CFRConatactOperation*>(4); |
|
115 |
|
116 iWaitForAllOperationComplete = new (ELeave) CActiveSchedulerWait(); |
|
117 } |
|
118 |
|
119 // -------------------------------------------------------------------------- |
|
120 // CPbk2FetchResults::NewL |
|
121 // -------------------------------------------------------------------------- |
|
122 // |
|
123 CPbk2FetchResults* CPbk2FetchResults::NewL |
|
124 ( CVPbkContactManager& aContactManager, |
|
125 MPbk2FetchDlg& aFetchDlg, MPbk2FetchDlgPages& aPages, |
|
126 MPbk2FetchDlgObserver& aObserver, |
|
127 MPbk2FetchResultsObserver& aResultsObserver ) |
|
128 { |
|
129 CPbk2FetchResults* self = new ( ELeave ) CPbk2FetchResults |
|
130 ( aContactManager, aFetchDlg, aPages, aObserver, |
|
131 aResultsObserver ); |
|
132 CleanupStack::PushL( self ); |
|
133 self->ConstructL( aContactManager ); |
|
134 CleanupStack::Pop( self ); |
|
135 return self; |
|
136 } |
|
137 |
|
138 // -------------------------------------------------------------------------- |
|
139 // CPbk2FetchResults::AppendL |
|
140 // -------------------------------------------------------------------------- |
|
141 // |
|
142 void CPbk2FetchResults::AppendL( const MVPbkContactLink& aLink ) |
|
143 { |
|
144 if ( iFetchDlg.IsSelectPermitted() ) |
|
145 { |
|
146 CFRConatactOperation* newAppendOperation = CFRConatactOperation::NewL( aLink, CFRConatactOperation::EAppendContact ); |
|
147 AppendContactOperationL(newAppendOperation); |
|
148 ProcessNextContactOperationL(); |
|
149 } |
|
150 else |
|
151 { |
|
152 iPages.SelectContactL( aLink, EFalse ); |
|
153 } |
|
154 } |
|
155 |
|
156 // -------------------------------------------------------------------------- |
|
157 // CPbk2FetchResults::AppendDelayedL |
|
158 // -------------------------------------------------------------------------- |
|
159 // |
|
160 void CPbk2FetchResults::AppendDelayedL( const MVPbkContactLink& aLink ) |
|
161 { |
|
162 // Add the feedback contact's operation to the head of the queue |
|
163 // in order to ensure that the checked contact's operation to be |
|
164 // handled firstly when phonebook receives the client feedback. |
|
165 CFRConatactOperation* newAppendOperation = CFRConatactOperation::NewL( aLink, CFRConatactOperation::EAppendContactDelayed ); |
|
166 iOperationQueue->InsertL( 0, newAppendOperation ); |
|
167 // Waiting is over. |
|
168 iWaitingForDelayedAppend = EFalse; |
|
169 ProcessNextContactOperationL(); |
|
170 } |
|
171 |
|
172 // -------------------------------------------------------------------------- |
|
173 // CPbk2FetchResults::DenyAppendDelayedL |
|
174 // -------------------------------------------------------------------------- |
|
175 // |
|
176 void CPbk2FetchResults::DenyAppendDelayedL( const MVPbkContactLink& aLink ) |
|
177 { |
|
178 // Waiting is over, process next contact operation |
|
179 iWaitingForDelayedAppend = EFalse; |
|
180 ProcessNextContactOperationL(); |
|
181 } |
|
182 |
|
183 // -------------------------------------------------------------------------- |
|
184 // CPbk2FetchResults::RemoveL |
|
185 // -------------------------------------------------------------------------- |
|
186 // |
|
187 void CPbk2FetchResults::RemoveL( const MVPbkContactLink& aLink ) |
|
188 { |
|
189 CFRConatactOperation* newRemoveOperation = CFRConatactOperation::NewL( aLink, CFRConatactOperation::ERemoveContact ); |
|
190 AppendContactOperationL(newRemoveOperation); |
|
191 ProcessNextContactOperationL(); |
|
192 } |
|
193 |
|
194 // -------------------------------------------------------------------------- |
|
195 // CPbk2FetchResults::ResetAndDestroy |
|
196 // -------------------------------------------------------------------------- |
|
197 // |
|
198 void CPbk2FetchResults::ResetAndDestroy() |
|
199 { |
|
200 delete iRetrieveOperation; |
|
201 iRetrieveOperation = NULL; |
|
202 |
|
203 RemoveCurrentContactOperation(); |
|
204 |
|
205 iSelectedContacts->ResetAndDestroy(); |
|
206 } |
|
207 |
|
208 // -------------------------------------------------------------------------- |
|
209 // CPbk2FetchResults::WaitOperationsCompleteL |
|
210 // -------------------------------------------------------------------------- |
|
211 // |
|
212 void CPbk2FetchResults::WaitOperationsCompleteL() |
|
213 { |
|
214 if ( iWaitingForDelayedAppend || iOperationQueue->Count()>0 ) |
|
215 { |
|
216 iInputBlock = CAknInputBlock::NewLC(); |
|
217 CleanupStack::Pop( iInputBlock ); |
|
218 |
|
219 iWaitForAllOperationComplete->Start(); |
|
220 } |
|
221 } |
|
222 |
|
223 // -------------------------------------------------------------------------- |
|
224 // CPbk2FetchResults::Count |
|
225 // -------------------------------------------------------------------------- |
|
226 // |
|
227 TInt CPbk2FetchResults::Count() const |
|
228 { |
|
229 return iSelectedContacts->Count(); |
|
230 } |
|
231 |
|
232 // -------------------------------------------------------------------------- |
|
233 // CPbk2FetchResults::At |
|
234 // -------------------------------------------------------------------------- |
|
235 // |
|
236 const MVPbkContactLink& CPbk2FetchResults::At( TInt aIndex ) const |
|
237 { |
|
238 return iSelectedContacts->At( aIndex ); |
|
239 } |
|
240 |
|
241 // -------------------------------------------------------------------------- |
|
242 // CPbk2FetchResults::Find |
|
243 // -------------------------------------------------------------------------- |
|
244 // |
|
245 TInt CPbk2FetchResults::Find( const MVPbkContactLink& aLink ) const |
|
246 { |
|
247 return iSelectedContacts->Find( aLink ); |
|
248 } |
|
249 |
|
250 // -------------------------------------------------------------------------- |
|
251 // CPbk2FetchResults::PackLC |
|
252 // -------------------------------------------------------------------------- |
|
253 // |
|
254 HBufC8* CPbk2FetchResults::PackLC() const |
|
255 { |
|
256 return iSelectedContacts->PackLC(); |
|
257 } |
|
258 |
|
259 // -------------------------------------------------------------------------- |
|
260 // CPbk2FetchResults::Streamable |
|
261 // -------------------------------------------------------------------------- |
|
262 // |
|
263 const MVPbkStreamable* CPbk2FetchResults::Streamable() const |
|
264 { |
|
265 return iSelectedContacts->Streamable(); |
|
266 } |
|
267 |
|
268 // -------------------------------------------------------------------------- |
|
269 // CPbk2FetchResults::VPbkSingleContactOperationComplete |
|
270 // -------------------------------------------------------------------------- |
|
271 // |
|
272 void CPbk2FetchResults::VPbkSingleContactOperationComplete |
|
273 ( MVPbkContactOperationBase& aOperation, |
|
274 MVPbkStoreContact* aContact ) |
|
275 { |
|
276 TRAPD( err, HandleContactOperationCompleteL( aOperation, aContact ) ); |
|
277 |
|
278 if ( err != KErrNone ) |
|
279 { |
|
280 iResultsObserver.ContactSelectionFailed(); |
|
281 CCoeEnv::Static()->HandleError( err ); |
|
282 } |
|
283 } |
|
284 |
|
285 // -------------------------------------------------------------------------- |
|
286 // CPbk2FetchResults::VPbkSingleContactOperationFailed |
|
287 // -------------------------------------------------------------------------- |
|
288 // |
|
289 void CPbk2FetchResults::VPbkSingleContactOperationFailed |
|
290 ( MVPbkContactOperationBase& /*aOperation*/, TInt aError ) |
|
291 { |
|
292 iResultsObserver.ContactSelectionFailed(); |
|
293 |
|
294 CCoeEnv::Static()->HandleError( aError ); |
|
295 } |
|
296 |
|
297 // -------------------------------------------------------------------------- |
|
298 // CPbk2FetchResults::StoreReady |
|
299 // -------------------------------------------------------------------------- |
|
300 // |
|
301 void CPbk2FetchResults::StoreReady |
|
302 ( MVPbkContactStore& /*aContactStore*/ ) |
|
303 { |
|
304 // Do nothing |
|
305 } |
|
306 |
|
307 // -------------------------------------------------------------------------- |
|
308 // CPbk2FetchResults::StoreUnavailable |
|
309 // -------------------------------------------------------------------------- |
|
310 // |
|
311 void CPbk2FetchResults::StoreUnavailable |
|
312 ( MVPbkContactStore& /*aContactStore*/, TInt /*aReason*/ ) |
|
313 { |
|
314 // Do nothing |
|
315 } |
|
316 |
|
317 // -------------------------------------------------------------------------- |
|
318 // CPbk2FetchResults::HandleStoreEventL |
|
319 // -------------------------------------------------------------------------- |
|
320 // |
|
321 void CPbk2FetchResults::HandleStoreEventL |
|
322 ( MVPbkContactStore& /*aContactStore*/, |
|
323 TVPbkContactStoreEvent aStoreEvent ) |
|
324 { |
|
325 switch ( aStoreEvent.iEventType ) |
|
326 { |
|
327 case TVPbkContactStoreEvent::EContactDeleted: |
|
328 { |
|
329 // Do not update UI selections - just remove the link |
|
330 // from results. The view event, listened by the control, |
|
331 // takes care of updating the UI selections. |
|
332 TInt findResult = iSelectedContacts->Find( *aStoreEvent.iContactLink ); |
|
333 if ( findResult != KErrNotFound ) |
|
334 { |
|
335 User::LeaveIfError( findResult ); |
|
336 iSelectedContacts->Delete( findResult ); |
|
337 } |
|
338 break; |
|
339 } |
|
340 |
|
341 case TVPbkContactStoreEvent::EGroupDeleted: |
|
342 { |
|
343 // Do nothing. |
|
344 // This means that we keep the selection of the contacts |
|
345 // which belonged to a group when the group is deleted. |
|
346 break; |
|
347 } |
|
348 |
|
349 default: |
|
350 { |
|
351 // Do nothing |
|
352 break; |
|
353 } |
|
354 } |
|
355 } |
|
356 |
|
357 // -------------------------------------------------------------------------- |
|
358 // CPbk2FetchResults::DoAppendContactL |
|
359 // -------------------------------------------------------------------------- |
|
360 // |
|
361 void CPbk2FetchResults::DoAppendContactL |
|
362 ( MVPbkStoreContact& aContact, TBool aDelayed ) |
|
363 { |
|
364 MVPbkContactLink* link = aContact.CreateLinkLC(); |
|
365 |
|
366 TInt count = CountContactsL( aContact, *link ); |
|
367 |
|
368 // Ask observer for acceptance |
|
369 MPbk2FetchDlgObserver::TPbk2FetchAcceptSelection accept = |
|
370 MPbk2FetchDlgObserver::EFetchYes; |
|
371 |
|
372 if ( !aDelayed ) |
|
373 { |
|
374 // Observer needs to asked |
|
375 accept = iObserver.AcceptFetchSelectionL( count, *link ); |
|
376 // Determine whether accept query is needed |
|
377 if ( MPbk2FetchDlgObserver::EFetchDelayed == accept ) |
|
378 { |
|
379 // Start to wait client feedback, block the operation queue, |
|
380 // process next operation until receive client feedback. |
|
381 iWaitingForDelayedAppend = ETrue; |
|
382 } |
|
383 } |
|
384 |
|
385 if ( accept == MPbk2FetchDlgObserver::EFetchNo ) |
|
386 { |
|
387 // Observer did not accept or delayed the selection |
|
388 MVPbkContactViewBase& view = iFetchDlg.FetchDlgViewL |
|
389 ( iPages.CurrentPage().FetchDlgPageId() ); |
|
390 TInt index = view.IndexOfLinkL( *link ); |
|
391 iPages.CurrentPage().Control().SetSelectedContactL |
|
392 ( index, EFalse ); |
|
393 } |
|
394 else if( accept == MPbk2FetchDlgObserver::EFetchYes ) |
|
395 { |
|
396 MVPbkContactGroup* group = aContact.Group(); |
|
397 if ( group ) |
|
398 { |
|
399 // Contact was a group, insert group members into append queue |
|
400 MVPbkContactLinkArray* groupMembers = group->ItemsContainedLC(); |
|
401 |
|
402 for ( TInt i = 0; i < groupMembers->Count(); ++i ) |
|
403 { |
|
404 AppendToResultsL( groupMembers->At( i ) ); |
|
405 } |
|
406 |
|
407 CleanupStack::PopAndDestroy(); // groupMembers |
|
408 } |
|
409 else |
|
410 { |
|
411 AppendToResultsL( *link ); |
|
412 } |
|
413 |
|
414 iResultsObserver.ContactSelected( *link, ETrue ); |
|
415 } |
|
416 |
|
417 CleanupStack::PopAndDestroy(); // link |
|
418 } |
|
419 |
|
420 // -------------------------------------------------------------------------- |
|
421 // CPbk2FetchResults::DoRemoveContactL |
|
422 // -------------------------------------------------------------------------- |
|
423 // |
|
424 void CPbk2FetchResults::DoRemoveContactL( MVPbkStoreContact& aContact ) |
|
425 { |
|
426 MVPbkContactLink* link = aContact.CreateLinkLC(); |
|
427 |
|
428 MVPbkContactGroup* group = aContact.Group(); |
|
429 if ( group ) |
|
430 { |
|
431 MVPbkContactLinkArray* groupMembers = group->ItemsContainedLC(); |
|
432 |
|
433 for ( TInt i = 0; i < groupMembers->Count(); ++i ) |
|
434 { |
|
435 RemoveFromResultsL( groupMembers->At( i ) ); |
|
436 } |
|
437 |
|
438 CleanupStack::PopAndDestroy(); // groupMembers |
|
439 } |
|
440 else |
|
441 { |
|
442 RemoveFromResultsL( *link ); |
|
443 } |
|
444 |
|
445 iResultsObserver.ContactSelected( *link, EFalse ); |
|
446 |
|
447 CleanupStack::PopAndDestroy(); // link |
|
448 } |
|
449 |
|
450 // -------------------------------------------------------------------------- |
|
451 // CPbk2FetchResults::AppendToResultsL |
|
452 // -------------------------------------------------------------------------- |
|
453 // |
|
454 void CPbk2FetchResults::AppendToResultsL( const MVPbkContactLink& aLink ) |
|
455 { |
|
456 TInt findResult = iSelectedContacts->Find( aLink ); |
|
457 |
|
458 if ( findResult == KErrNotFound ) |
|
459 { |
|
460 iPages.SelectContactL( aLink, ETrue ); |
|
461 MVPbkContactLink* clone = aLink.CloneLC(); |
|
462 CleanupStack::Pop(); // clone |
|
463 iSelectedContacts->AppendL( clone ); |
|
464 } |
|
465 else |
|
466 { |
|
467 User::LeaveIfError( findResult ); |
|
468 } |
|
469 } |
|
470 |
|
471 // -------------------------------------------------------------------------- |
|
472 // CPbk2FetchResults::RemoveFromResultsL |
|
473 // -------------------------------------------------------------------------- |
|
474 // |
|
475 void CPbk2FetchResults::RemoveFromResultsL( const MVPbkContactLink& aLink ) |
|
476 { |
|
477 TInt findResult = iSelectedContacts->Find( aLink ); |
|
478 if ( findResult != KErrNotFound ) |
|
479 { |
|
480 User::LeaveIfError( findResult ); |
|
481 iPages.SelectContactL( aLink, EFalse ); |
|
482 iSelectedContacts->Delete( findResult ); |
|
483 } |
|
484 } |
|
485 |
|
486 // -------------------------------------------------------------------------- |
|
487 // CPbk2FetchResults::CountContactsL |
|
488 // -------------------------------------------------------------------------- |
|
489 // |
|
490 TInt CPbk2FetchResults::CountContactsL |
|
491 ( MVPbkStoreContact& aContact, MVPbkContactLink& aLink ) |
|
492 { |
|
493 TInt count = iSelectedContacts->Count(); |
|
494 |
|
495 MVPbkContactGroup* group = aContact.Group(); |
|
496 |
|
497 if ( group ) |
|
498 { |
|
499 // Contact was a group, insert group members into append queue |
|
500 MVPbkContactLinkArray* groupMembers = group->ItemsContainedLC(); |
|
501 |
|
502 for ( TInt i = 0; i < groupMembers->Count(); ++i ) |
|
503 { |
|
504 if ( iSelectedContacts->Find( groupMembers->At( i ) ) |
|
505 == KErrNotFound ) |
|
506 { |
|
507 ++count; |
|
508 } |
|
509 } |
|
510 CleanupStack::PopAndDestroy(); // groupMembers |
|
511 } |
|
512 else |
|
513 { |
|
514 if ( iSelectedContacts->Find( aLink ) == KErrNotFound ) |
|
515 { |
|
516 ++count; |
|
517 } |
|
518 } |
|
519 |
|
520 return count; |
|
521 } |
|
522 |
|
523 // -------------------------------------------------------------------------- |
|
524 // CPbk2FetchResults::HandleContactOperationCompleteL |
|
525 // -------------------------------------------------------------------------- |
|
526 // |
|
527 void CPbk2FetchResults::HandleContactOperationCompleteL( |
|
528 MVPbkContactOperationBase& /*aOperation*/, |
|
529 MVPbkStoreContact* aContact ) |
|
530 { |
|
531 /*************** Do class member operations here *****************/ |
|
532 |
|
533 // Delete retrieve contact operation ptr |
|
534 delete iRetrieveOperation; |
|
535 iRetrieveOperation = NULL; |
|
536 |
|
537 // Copy current operation type before deleting |
|
538 CFRConatactOperation::EOperationType operationType = |
|
539 GetCurrentContactOperation()->GetOperationType(); |
|
540 |
|
541 // Remove executed operation from queue |
|
542 RemoveCurrentContactOperation(); |
|
543 |
|
544 |
|
545 /**********************************************************************/ |
|
546 /**************! Dont use class members after SWITCH !*****************/ |
|
547 /*** DoAppendContactL, DoRemoveContactL are able to call destructor ***/ |
|
548 /**********************************************************************/ |
|
549 |
|
550 // Finish contact operation |
|
551 CleanupDeletePushL( aContact ); |
|
552 |
|
553 switch( operationType ) |
|
554 { |
|
555 case CFRConatactOperation::EAppendContact: |
|
556 { |
|
557 DoAppendContactL( *aContact, EFalse ); |
|
558 // Check whether next operation can be processed |
|
559 // after sending check request to client. |
|
560 ProcessNextContactOperationL(); |
|
561 break; |
|
562 } |
|
563 |
|
564 case CFRConatactOperation::EAppendContactDelayed: |
|
565 { |
|
566 // Process new contact opretation before appending |
|
567 // the delayed contact to results. It can save time. |
|
568 ProcessNextContactOperationL(); |
|
569 DoAppendContactL( *aContact, ETrue ); |
|
570 break; |
|
571 } |
|
572 |
|
573 case CFRConatactOperation::ERemoveContact: |
|
574 { |
|
575 // Process new contact opretation before removing contact |
|
576 // from results. It can save time. |
|
577 ProcessNextContactOperationL(); |
|
578 DoRemoveContactL( *aContact ); |
|
579 break; |
|
580 } |
|
581 } |
|
582 |
|
583 CleanupStack::PopAndDestroy(); // aContact |
|
584 } |
|
585 |
|
586 // -------------------------------------------------------------------------- |
|
587 // CPbk2FetchResults::ProcessNextContactOperationL |
|
588 // -------------------------------------------------------------------------- |
|
589 // |
|
590 void CPbk2FetchResults::ProcessNextContactOperationL() |
|
591 { |
|
592 if( !iRetrieveOperation && !iWaitingForDelayedAppend ) |
|
593 { |
|
594 // No operation is executing -> process next one |
|
595 |
|
596 if( GetCurrentContactOperation() ) |
|
597 { |
|
598 // Start asynchronous contact retrieve operation, which completes |
|
599 // in CPbk2FetchResults::HandleContactOperationCompleteL. |
|
600 iRetrieveOperation = iContactManager.RetrieveContactL( |
|
601 *( GetCurrentContactOperation()->GetContactLink() ), |
|
602 *this ); |
|
603 } |
|
604 else |
|
605 { |
|
606 if ( !iWaitingForDelayedAppend ) |
|
607 { |
|
608 // Every seleced contacts' operation finishes, |
|
609 // stop the scheduler waiting for every operation. |
|
610 if (iWaitForAllOperationComplete->IsStarted()) |
|
611 iWaitForAllOperationComplete->AsyncStop(); |
|
612 |
|
613 // Stop blocking input |
|
614 delete iInputBlock; |
|
615 iInputBlock = NULL; |
|
616 } |
|
617 } |
|
618 } |
|
619 else |
|
620 { |
|
621 // Ongoing operation -> do nothing |
|
622 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING( "CPbk2FetchResults::ProcessNextContactOperationL busy" )); |
|
623 } |
|
624 } |
|
625 |
|
626 // -------------------------------------------------------------------------- |
|
627 // CPbk2FetchResults::AppendContactOperationL |
|
628 // -------------------------------------------------------------------------- |
|
629 // |
|
630 void CPbk2FetchResults::AppendContactOperationL( CFRConatactOperation* aOperation ) |
|
631 { |
|
632 iOperationQueue->AppendL( aOperation ); // Append to the end |
|
633 } |
|
634 |
|
635 // -------------------------------------------------------------------------- |
|
636 // CPbk2FetchResults::GetCurrentContactOperation |
|
637 // -------------------------------------------------------------------------- |
|
638 // |
|
639 CPbk2FetchResults::CFRConatactOperation* CPbk2FetchResults::GetCurrentContactOperation() |
|
640 { |
|
641 if( iOperationQueue->Count() ) |
|
642 return iOperationQueue->At(0); // Return first element |
|
643 else |
|
644 return NULL; // If empty, return NULL |
|
645 } |
|
646 |
|
647 // -------------------------------------------------------------------------- |
|
648 // CPbk2FetchResults::RemoveCurrentContactOperation |
|
649 // -------------------------------------------------------------------------- |
|
650 // |
|
651 void CPbk2FetchResults::RemoveCurrentContactOperation( ) |
|
652 { |
|
653 if( iOperationQueue->Count() ) |
|
654 { |
|
655 // Remove and delete first operation |
|
656 delete ( iOperationQueue->At( 0 ) ); |
|
657 iOperationQueue->Delete( 0 ); |
|
658 } |
|
659 } |
|
660 |
|
661 // -------------------------------------------------------------------------- |
|
662 // CPbk2FetchResults::CFRConatactOperation::NewL |
|
663 // -------------------------------------------------------------------------- |
|
664 // |
|
665 CPbk2FetchResults::CFRConatactOperation* CPbk2FetchResults::CFRConatactOperation::NewL( |
|
666 const MVPbkContactLink& aContactLink, const EOperationType aType ) |
|
667 { |
|
668 CFRConatactOperation* self = new ( ELeave ) CFRConatactOperation( aType ); |
|
669 CleanupStack::PushL( self ); |
|
670 self->ConstructL( aContactLink ); |
|
671 CleanupStack::Pop( self ); |
|
672 return self; |
|
673 } |
|
674 |
|
675 // -------------------------------------------------------------------------- |
|
676 // CPbk2FetchResults::CFRConatactOperation::CFRConatactOperation |
|
677 // -------------------------------------------------------------------------- |
|
678 // |
|
679 CPbk2FetchResults::CFRConatactOperation::CFRConatactOperation( |
|
680 const EOperationType aType ): |
|
681 iType( aType ) |
|
682 { |
|
683 // Nothing |
|
684 } |
|
685 |
|
686 // -------------------------------------------------------------------------- |
|
687 // CPbk2FetchResults::CFRConatactOperation::~CFRConatactOperation |
|
688 // -------------------------------------------------------------------------- |
|
689 // |
|
690 CPbk2FetchResults::CFRConatactOperation::~CFRConatactOperation( ) |
|
691 { |
|
692 delete iContactLink; |
|
693 } |
|
694 |
|
695 // -------------------------------------------------------------------------- |
|
696 // CPbk2FetchResults::CFRConatactOperation::ConstructL |
|
697 // -------------------------------------------------------------------------- |
|
698 // |
|
699 void CPbk2FetchResults::CFRConatactOperation::ConstructL( |
|
700 const MVPbkContactLink& aContactLink ) |
|
701 { |
|
702 // Copy ContactLink |
|
703 iContactLink = aContactLink.CloneLC(); |
|
704 CleanupStack::Pop(); |
|
705 } |
|
706 |
|
707 // End of File |