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