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 68 | 9da50d567e3c |
permissions | -rw-r--r-- |
63 | 1 |
/* |
2 |
* Copyright (c) 2009 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: Thumbnail manager for the social phonebook. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// class header |
|
20 |
#include "CPbk2ThumbnailManager.h" |
|
21 |
||
22 |
// external includes |
|
23 |
#include <CPbk2ImageManager.h> |
|
24 |
#include <CVPbkContactManager.h> |
|
25 |
#include <MVPbkStoreContact.h> |
|
26 |
#include <MVPbkContactOperationBase.h> |
|
27 |
#include <TPbk2ImageManagerParams.h> |
|
28 |
#include <CVPbkContactLinkArray.h> |
|
29 |
#include <MVPbkContactLink.h> |
|
30 |
#include <MVPbkFieldType.h> |
|
31 |
#include <barsread.h> //tresource reader |
|
32 |
#include <gulicon.h> |
|
33 |
||
34 |
//INTERNAL |
|
35 |
#include "CPbk2ContactViewListBox.h" |
|
36 |
#include "CPbk2IconArray.h" |
|
37 |
||
38 |
||
39 |
// Virtual Phonebook |
|
40 |
#include <MVPbkBaseContact.h> |
|
41 |
#include <MVPbkFieldType.h> |
|
42 |
#include <CVPbkContactManager.h> |
|
43 |
#include <TVPbkFieldTypeMapping.h> |
|
44 |
#include <MVPbkContactViewBase.h> |
|
45 |
||
46 |
//Pbk2 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
47 |
#include <Pbk2UIControls.rsg> |
63 | 48 |
#include <Pbk2UID.h> |
49 |
||
50 |
namespace { |
|
51 |
||
52 |
// Default size for thumbnail images |
|
53 |
#define KDefaultThumbnailSize TSize(36,36) |
|
54 |
// icon offset. Thumbnail indexing starts from 10000 in CPbk2IconArray, so that there is 0 - 9999 indexes free for |
|
55 |
// phonebook's own icons |
|
56 |
const TInt KIconIndexOffset = 10000; |
|
57 |
// loading limit for thumbnails |
|
58 |
const TInt KLoadingLimit = 100; |
|
59 |
// loading queue limit |
|
60 |
const TInt KQueueLimit = 25; |
|
61 |
// Denotes Start Index for an item in the any Queue |
|
62 |
const TInt KStartIndex = 0; |
|
63 |
// Granularity of the thumbnail array |
|
64 |
const TInt KThumbnailArrayGranularity = 200; |
|
65 |
||
66 |
} |
|
67 |
||
68 |
/* |
|
69 |
* Helper class for mapping between contact link + image + index on listbox |
|
70 |
*/ |
|
71 |
NONSHARABLE_CLASS( CPbk2TmItem ) : public CBase |
|
72 |
{ |
|
73 |
public: // constructor & destructor |
|
74 |
||
75 |
// Takes ownership of items |
|
76 |
static CPbk2TmItem* NewL( MVPbkContactLink* aLink, |
|
77 |
TInt aListboxIndex ); |
|
78 |
~CPbk2TmItem(); |
|
79 |
||
80 |
public: //new functions |
|
81 |
||
82 |
/* |
|
83 |
* Returns contact link |
|
84 |
*/ |
|
85 |
inline MVPbkContactLink* GetLink(); |
|
86 |
||
87 |
||
88 |
/* |
|
89 |
* Returns corresponding bitmap |
|
90 |
*/ |
|
91 |
inline CFbsBitmap* GetBitmap(); |
|
92 |
||
93 |
/* |
|
94 |
* Returns index on listbox |
|
95 |
*/ |
|
96 |
inline TInt GetListboxIndex() const; |
|
97 |
||
98 |
||
99 |
/* |
|
100 |
* Returns index on Pbk2IconArray |
|
101 |
*/ |
|
102 |
inline TInt GetIconArrayIndex() const; |
|
103 |
||
104 |
||
105 |
/* |
|
106 |
* Returns icon id |
|
107 |
*/ |
|
108 |
inline const TPbk2IconId& GetIconId() const; |
|
109 |
||
110 |
/* |
|
111 |
* Getter for has thumbnail flag |
|
112 |
*/ |
|
113 |
inline TBool HasThumbnail(); |
|
114 |
||
115 |
/* |
|
116 |
* deletes link and bitmap |
|
117 |
*/ |
|
118 |
inline void DeleteBitmap(); |
|
119 |
||
120 |
/* |
|
121 |
* Setter for bitmap, deletes old one if set |
|
122 |
*/ |
|
123 |
inline void SetBitmap( CFbsBitmap* aBitmap ); |
|
124 |
||
125 |
||
126 |
/* |
|
127 |
* Setter for listbox index |
|
128 |
*/ |
|
129 |
inline void SetListboxIndex( TInt aIndex ); |
|
130 |
||
131 |
/* |
|
132 |
* Setter for Pbk2IconArray index |
|
133 |
*/ |
|
134 |
inline void SetIconArrayIndexAndId( TInt aIndex, TPbk2IconId aId ); |
|
135 |
||
136 |
/* |
|
137 |
* Setter for has thumbnail flag |
|
138 |
*/ |
|
139 |
inline void SetHasThumbnail( TBool aValue ); |
|
140 |
||
141 |
/* |
|
142 |
* Compare function for sorting |
|
143 |
*/ |
|
144 |
static TInt CompareByListboxIndex( |
|
145 |
const CPbk2TmItem& aItem1, const CPbk2TmItem& aItem2 ); |
|
146 |
||
147 |
private: // constructor |
|
148 |
||
149 |
CPbk2TmItem( MVPbkContactLink* aLink, |
|
150 |
TInt aListboxIndex ); |
|
151 |
||
152 |
private: //data |
|
153 |
// OWN: contact link |
|
154 |
MVPbkContactLink* iLink; |
|
155 |
// OWN: thumbnail |
|
156 |
CFbsBitmap* iBitmap; |
|
157 |
// index to listbox |
|
158 |
TInt iIndexOnListbox; |
|
159 |
// index to icon array |
|
160 |
TInt iPbkIconArrayIndex; |
|
161 |
// icon id |
|
162 |
TPbk2IconId iIconId; |
|
163 |
// informs whether the item has thumbnail image on contact database |
|
164 |
TBool iHasThumbnail; |
|
165 |
}; |
|
166 |
||
167 |
||
168 |
// -------------------------------------------------------------------------- |
|
169 |
// CPbk2TmItem::NewL |
|
170 |
// -------------------------------------------------------------------------- |
|
171 |
// |
|
172 |
CPbk2TmItem* CPbk2TmItem::NewL( MVPbkContactLink* aLink, |
|
173 |
TInt aListboxIndex ) |
|
174 |
{ |
|
175 |
CPbk2TmItem* self = new( ELeave )CPbk2TmItem( aLink, |
|
176 |
aListboxIndex ); |
|
177 |
return self; |
|
178 |
} |
|
179 |
||
180 |
// -------------------------------------------------------------------------- |
|
181 |
// CPbk2TmItem::CPbk2TmItem |
|
182 |
// -------------------------------------------------------------------------- |
|
183 |
// |
|
184 |
CPbk2TmItem::CPbk2TmItem( MVPbkContactLink* aLink, |
|
185 |
TInt aListboxIndex ): |
|
186 |
iLink( aLink ), |
|
187 |
iIndexOnListbox( aListboxIndex ), |
|
188 |
iHasThumbnail( EFalse ) |
|
189 |
{ |
|
190 |
} |
|
191 |
||
192 |
// -------------------------------------------------------------------------- |
|
193 |
// CPbk2TmItem::~CPbk2TmItem |
|
194 |
// -------------------------------------------------------------------------- |
|
195 |
// |
|
196 |
CPbk2TmItem::~CPbk2TmItem() |
|
197 |
{ |
|
198 |
delete iLink; |
|
199 |
delete iBitmap; |
|
200 |
} |
|
201 |
||
202 |
// -------------------------------------------------------------------------- |
|
203 |
// CPbk2TmItem::CompareByListboxIndex |
|
204 |
// -------------------------------------------------------------------------- |
|
205 |
// |
|
206 |
TInt CPbk2TmItem::CompareByListboxIndex( |
|
207 |
const CPbk2TmItem& aItem1, const CPbk2TmItem& aItem2 ) |
|
208 |
{ |
|
209 |
TInt i = aItem1.GetListboxIndex(); |
|
210 |
TInt j = aItem2.GetListboxIndex(); |
|
211 |
return i-j; |
|
212 |
} |
|
213 |
||
214 |
// -------------------------------------------------------------------------- |
|
215 |
// CPbk2TmItem::GetLink |
|
216 |
// -------------------------------------------------------------------------- |
|
217 |
// |
|
218 |
inline MVPbkContactLink* CPbk2TmItem::GetLink() |
|
219 |
{ |
|
220 |
return iLink; |
|
221 |
} |
|
222 |
||
223 |
// -------------------------------------------------------------------------- |
|
224 |
// CPbk2TmItem::GetBitmap |
|
225 |
// -------------------------------------------------------------------------- |
|
226 |
// |
|
227 |
inline CFbsBitmap* CPbk2TmItem::GetBitmap() |
|
228 |
{ |
|
229 |
return iBitmap; |
|
230 |
} |
|
231 |
||
232 |
||
233 |
// -------------------------------------------------------------------------- |
|
234 |
// CPbk2TmItem::GetListboxIndex |
|
235 |
// -------------------------------------------------------------------------- |
|
236 |
// |
|
237 |
inline TInt CPbk2TmItem::GetListboxIndex() const |
|
238 |
{ |
|
239 |
return iIndexOnListbox; |
|
240 |
} |
|
241 |
||
242 |
||
243 |
// -------------------------------------------------------------------------- |
|
244 |
// CPbk2TmItem::GetIconArrayIndex |
|
245 |
// -------------------------------------------------------------------------- |
|
246 |
// |
|
247 |
inline TInt CPbk2TmItem::GetIconArrayIndex() const |
|
248 |
{ |
|
249 |
return iPbkIconArrayIndex; |
|
250 |
} |
|
251 |
||
252 |
||
253 |
// -------------------------------------------------------------------------- |
|
254 |
// CPbk2TmItem::HasThumbnail |
|
255 |
// -------------------------------------------------------------------------- |
|
256 |
// |
|
257 |
inline TBool CPbk2TmItem::HasThumbnail() |
|
258 |
{ |
|
259 |
return iHasThumbnail; |
|
260 |
} |
|
261 |
||
262 |
// -------------------------------------------------------------------------- |
|
263 |
// CPbk2TmItem::GetIconId |
|
264 |
// -------------------------------------------------------------------------- |
|
265 |
// |
|
266 |
inline const TPbk2IconId& CPbk2TmItem::GetIconId() const |
|
267 |
{ |
|
268 |
return iIconId; |
|
269 |
} |
|
270 |
||
271 |
// -------------------------------------------------------------------------- |
|
272 |
// CPbk2TmItem::ClearValues |
|
273 |
// -------------------------------------------------------------------------- |
|
274 |
// |
|
275 |
inline void CPbk2TmItem::DeleteBitmap( ) |
|
276 |
{ |
|
277 |
delete iBitmap; |
|
278 |
iBitmap = NULL; |
|
279 |
} |
|
280 |
||
281 |
||
282 |
// -------------------------------------------------------------------------- |
|
283 |
// CPbk2TmItem::SetBitmap |
|
284 |
// -------------------------------------------------------------------------- |
|
285 |
// |
|
286 |
inline void CPbk2TmItem::SetBitmap( CFbsBitmap* aBitmap ) |
|
287 |
{ |
|
288 |
delete iBitmap; |
|
289 |
iBitmap = aBitmap; |
|
290 |
} |
|
291 |
||
292 |
||
293 |
// -------------------------------------------------------------------------- |
|
294 |
// CPbk2TmItem::SetListboxIndex |
|
295 |
// -------------------------------------------------------------------------- |
|
296 |
// |
|
297 |
inline void CPbk2TmItem::SetListboxIndex( TInt aIndex ) |
|
298 |
{ |
|
299 |
iIndexOnListbox = aIndex; |
|
300 |
} |
|
301 |
||
302 |
||
303 |
// -------------------------------------------------------------------------- |
|
304 |
// CPbk2TmItem::SetIconArrayIndexAndId |
|
305 |
// -------------------------------------------------------------------------- |
|
306 |
// |
|
307 |
inline void CPbk2TmItem::SetIconArrayIndexAndId( TInt aIndex, TPbk2IconId aId ) |
|
308 |
{ |
|
309 |
iPbkIconArrayIndex = aIndex; |
|
310 |
iIconId = aId; |
|
311 |
} |
|
312 |
||
313 |
// -------------------------------------------------------------------------- |
|
314 |
// CPbk2TmItem::SetHasThumbnail |
|
315 |
// -------------------------------------------------------------------------- |
|
316 |
// |
|
317 |
inline void CPbk2TmItem::SetHasThumbnail( TBool aValue ) |
|
318 |
{ |
|
319 |
iHasThumbnail = aValue; |
|
320 |
} |
|
321 |
||
322 |
||
323 |
/*********************************** THUMBNAIL MANAGER ************************************/ |
|
324 |
||
325 |
||
326 |
// -------------------------------------------------------------------------- |
|
327 |
// CPbk2ThumbnailManager* CPbk2ThumbnailManager::NewL |
|
328 |
// -------------------------------------------------------------------------- |
|
329 |
// |
|
330 |
EXPORT_C CPbk2ThumbnailManager* CPbk2ThumbnailManager::NewL( CVPbkContactManager& aContactManager ) |
|
331 |
{ |
|
332 |
CPbk2ThumbnailManager* self = new (ELeave) CPbk2ThumbnailManager( aContactManager ); |
|
333 |
CleanupStack::PushL(self); |
|
334 |
self->ConstructL(); |
|
335 |
CleanupStack::Pop(); |
|
336 |
return self; |
|
337 |
} |
|
338 |
||
339 |
// -------------------------------------------------------------------------- |
|
340 |
// CPbk2ThumbnailManager::CPbk2ThumbnailManager |
|
341 |
// -------------------------------------------------------------------------- |
|
342 |
// |
|
343 |
CPbk2ThumbnailManager::CPbk2ThumbnailManager( |
|
344 |
CVPbkContactManager& aContactManager ) : |
|
345 |
iState( EIdle ), |
|
346 |
iContactThumbnails( KThumbnailArrayGranularity ), |
|
347 |
iContactManager( aContactManager ), |
|
348 |
iDefaultIconIndex( KErrNotFound ) |
|
349 |
{ |
|
350 |
} |
|
351 |
||
352 |
// -------------------------------------------------------------------------- |
|
353 |
// CPbk2ThumbnailManager::~CPbk2ThumbnailManager() |
|
354 |
// -------------------------------------------------------------------------- |
|
355 |
// |
|
356 |
CPbk2ThumbnailManager::~CPbk2ThumbnailManager() |
|
357 |
{ |
|
358 |
if( iView ) |
|
359 |
{ |
|
360 |
iView->RemoveObserver(*this ); |
|
361 |
iView->RemoveStackObserver( *this ); |
|
362 |
} |
|
363 |
||
364 |
delete iInProgressItemToBeRemoved; |
|
365 |
delete iThumbOperation; |
|
366 |
delete iManager; |
|
367 |
delete iRetrieveOperation; |
|
368 |
delete iStoreContact; |
|
369 |
iContactThumbnails.ResetAndDestroy(); |
|
370 |
iLoadingQueue.Reset(); |
|
371 |
iPriorityArray.Reset(); |
|
372 |
} |
|
373 |
||
374 |
// -------------------------------------------------------------------------- |
|
375 |
// CPbk2ThumbnailManager::ConstructL() |
|
376 |
// -------------------------------------------------------------------------- |
|
377 |
// |
|
378 |
void CPbk2ThumbnailManager::ConstructL() |
|
379 |
{ |
|
380 |
// image manager |
|
381 |
iManager = CPbk2ImageManager::NewL( iContactManager ); |
|
382 |
// read file type for thumbnail field |
|
383 |
ReadFieldTypeL(); |
|
384 |
} |
|
385 |
||
386 |
// -------------------------------------------------------------------------- |
|
387 |
// CPbk2ThumbnailManager::SetObserver() |
|
388 |
// -------------------------------------------------------------------------- |
|
389 |
// |
|
390 |
void CPbk2ThumbnailManager::SetObserver( MPbk2ThumbnailManagerObserver& aObserver ) |
|
391 |
{ |
|
392 |
iObserver = &aObserver; |
|
393 |
} |
|
394 |
||
395 |
// -------------------------------------------------------------------------- |
|
396 |
// CPbk2ThumbnailManager::RemoveObserver() |
|
397 |
// -------------------------------------------------------------------------- |
|
398 |
// |
|
399 |
void CPbk2ThumbnailManager::RemoveObserver() |
|
400 |
{ |
|
401 |
iObserver = NULL; |
|
402 |
} |
|
403 |
||
404 |
// -------------------------------------------------------------------------- |
|
405 |
// CPbk2ThumbnailManager::ThumbnailCount() |
|
406 |
// -------------------------------------------------------------------------- |
|
407 |
// |
|
408 |
TInt CPbk2ThumbnailManager::ThumbnailCount() |
|
409 |
{ |
|
410 |
return iContactThumbnails.Count(); |
|
411 |
} |
|
412 |
||
413 |
// -------------------------------------------------------------------------- |
|
414 |
// CPbk2ThumbnailManager::GetPbkIconIndexL() |
|
415 |
// -------------------------------------------------------------------------- |
|
416 |
// |
|
417 |
TInt CPbk2ThumbnailManager::GetPbkIconIndexL( |
|
418 |
TInt aListboxIndex, |
|
419 |
const MVPbkContactLink& aContactLink ) |
|
420 |
{ |
|
421 |
TInt arrIndex = iDefaultIconIndex; |
|
422 |
||
423 |
// check that requested thumbnail is allready added to thumbnail array |
|
424 |
if( Rng( 0, aListboxIndex, iContactThumbnails.Count() - 1 ) ) |
|
425 |
{ |
|
426 |
CPbk2TmItem* item = iContactThumbnails[ aListboxIndex ]; |
|
427 |
if( !item ) |
|
428 |
{ |
|
429 |
item = CPbk2TmItem::NewL( aContactLink.CloneLC(), aListboxIndex ); |
|
430 |
CleanupStack::Pop(); // link |
|
431 |
// set default icon index |
|
432 |
item->SetIconArrayIndexAndId( iDefaultIconIndex,iDefaultIconId ); |
|
433 |
item->SetHasThumbnail( ETrue ); |
|
434 |
iContactThumbnails[ aListboxIndex ] = item; |
|
435 |
iIsCacheClean = EFalse; |
|
436 |
} |
|
437 |
||
438 |
// if item has a thumbnail image, but it is not loaded yet ( queue ) |
|
439 |
if( item->HasThumbnail() && !item->GetBitmap() ) |
|
440 |
{ |
|
441 |
TBool reOrderItem = ETrue; |
|
442 |
TInt res = iLoadingQueue.Find( item ); |
|
443 |
//remove from array if duplicate |
|
444 |
if( res != KErrNotFound ) |
|
445 |
{ |
|
446 |
// if item's position is 0 or 1, dont reorder |
|
447 |
if( res <= 1 ) |
|
448 |
{ |
|
449 |
reOrderItem = EFalse; |
|
450 |
} |
|
451 |
// else remove item from the array for reordering |
|
452 |
else |
|
453 |
{ |
|
454 |
iLoadingQueue.Remove( res ); |
|
455 |
} |
|
456 |
} |
|
457 |
||
458 |
// if item is to be reordered |
|
459 |
if( reOrderItem ) |
|
460 |
{ |
|
461 |
// if there are more than 2 items |
|
462 |
if( iLoadingQueue.Count() > 2 && iState == ELoading ) |
|
463 |
{ |
|
464 |
// insert to second position, first one is under loading |
|
465 |
iLoadingQueue.Insert( item, 1 ); |
|
466 |
} |
|
467 |
// else append to first or second |
|
468 |
else |
|
469 |
{ |
|
470 |
iLoadingQueue.Append( item ); |
|
471 |
} |
|
472 |
} |
|
473 |
||
474 |
//if idle, start loading |
|
475 |
if( iState == EIdle ) |
|
476 |
{ |
|
477 |
StartLoading(); |
|
478 |
} |
|
479 |
} |
|
480 |
else |
|
481 |
{ |
|
482 |
arrIndex = item->GetIconArrayIndex(); |
|
483 |
} |
|
484 |
} |
|
485 |
return arrIndex; |
|
486 |
} |
|
487 |
||
488 |
// -------------------------------------------------------------------------- |
|
489 |
// CPbk2ThumbnailManager::SetDefaultIconId() |
|
490 |
// -------------------------------------------------------------------------- |
|
491 |
// |
|
492 |
void CPbk2ThumbnailManager::SetDefaultIconId( TPbk2IconId aDefaultIconId ) |
|
493 |
{ |
|
494 |
if( iIconArray ) |
|
495 |
{ |
|
496 |
iDefaultIconIndex = iIconArray->FindIcon( aDefaultIconId ); |
|
497 |
} |
|
498 |
iDefaultIconId = aDefaultIconId; |
|
499 |
} |
|
500 |
||
501 |
// -------------------------------------------------------------------------- |
|
502 |
// CPbk2ThumbnailManager::GetDefaultIconIndex() |
|
503 |
// -------------------------------------------------------------------------- |
|
504 |
// |
|
505 |
const TPbk2IconId& CPbk2ThumbnailManager::GetDefaultIconId() |
|
506 |
{ |
|
507 |
return iDefaultIconId; |
|
508 |
} |
|
509 |
||
510 |
// -------------------------------------------------------------------------- |
|
511 |
// CPbk2ThumbnailManager::SetPbkIconArray() |
|
512 |
// -------------------------------------------------------------------------- |
|
513 |
// |
|
514 |
void CPbk2ThumbnailManager::SetPbkIconArray( CPbk2IconArray* aIconArray ) |
|
515 |
{ |
|
516 |
iIconArray = aIconArray; |
|
517 |
} |
|
518 |
||
519 |
// -------------------------------------------------------------------------- |
|
520 |
// CPbk2ThumbnailManager::RemoveIconArray() |
|
521 |
// -------------------------------------------------------------------------- |
|
522 |
// |
|
523 |
void CPbk2ThumbnailManager::RemoveIconArray() |
|
524 |
{ |
|
525 |
// no more icon array |
|
526 |
iIconArray = NULL; |
|
527 |
const TInt count = iContactThumbnails.Count(); |
|
528 |
||
529 |
// set all the indexes to default because there is no items in icon array to refer to |
|
530 |
for( TInt i = 0; i < count; ++i ) |
|
531 |
{ |
|
532 |
CPbk2TmItem* item = iContactThumbnails[i]; |
|
533 |
if( item ) |
|
534 |
{ |
|
535 |
item->SetIconArrayIndexAndId( iDefaultIconIndex, iDefaultIconId ); |
|
536 |
} |
|
537 |
} |
|
538 |
iIconIdCounter = 0; |
|
539 |
} |
|
540 |
||
541 |
// -------------------------------------------------------------------------- |
|
542 |
// CPbk2ThumbnailManager::DecreaseIndexes() |
|
543 |
// -------------------------------------------------------------------------- |
|
544 |
// |
|
545 |
void CPbk2ThumbnailManager::ResetIndexes() |
|
546 |
{ |
|
547 |
// go through items |
|
548 |
const TInt count = iContactThumbnails.Count(); |
|
549 |
for( TInt i = 0; i < count; ++i ) |
|
550 |
{ |
|
551 |
CPbk2TmItem* item = iContactThumbnails[i]; |
|
552 |
if( item ) |
|
553 |
{ |
|
554 |
item->SetListboxIndex( i ); |
|
555 |
} |
|
556 |
} |
|
557 |
} |
|
558 |
||
559 |
// -------------------------------------------------------------------------- |
|
560 |
// CPbk2ThumbnailManager::Reset() |
|
561 |
// -------------------------------------------------------------------------- |
|
562 |
// |
|
563 |
void CPbk2ThumbnailManager::Reset() |
|
564 |
{ |
|
565 |
// clear cache |
|
566 |
iContactThumbnails.ResetAndDestroy(); |
|
567 |
iPriorityArray.Reset(); |
|
568 |
||
569 |
// reset operations and queue |
|
570 |
delete iRetrieveOperation; |
|
571 |
iRetrieveOperation = NULL; |
|
572 |
delete iThumbOperation; |
|
573 |
iThumbOperation = NULL; |
|
574 |
iState = EIdle; |
|
575 |
iLoadingQueue.Reset(); |
|
576 |
} |
|
577 |
||
578 |
// -------------------------------------------------------------------------- |
|
579 |
// CPbk2ThumbnailManager::SetThumbnailIconSize() |
|
580 |
// -------------------------------------------------------------------------- |
|
581 |
// |
|
582 |
void CPbk2ThumbnailManager::SetThumbnailIconSize( TSize aSize ) |
|
583 |
{ |
|
584 |
iIconSize = aSize; |
|
585 |
} |
|
586 |
||
587 |
// -------------------------------------------------------------------------- |
|
588 |
// CPbk2ThumbnailManager::GetThumbnailIconSize() |
|
589 |
// -------------------------------------------------------------------------- |
|
590 |
// |
|
591 |
const TSize& CPbk2ThumbnailManager::GetThumbnailIconSize() |
|
592 |
{ |
|
593 |
return iIconSize; |
|
594 |
} |
|
595 |
||
596 |
// -------------------------------------------------------------------------- |
|
597 |
// CPbk2ThumbnailManager::SetContactViewL() |
|
598 |
// -------------------------------------------------------------------------- |
|
599 |
// |
|
600 |
void CPbk2ThumbnailManager::SetContactViewL( MPbk2FilteredViewStack* aView ) |
|
601 |
{ |
|
602 |
if( iView ) |
|
603 |
{ |
|
604 |
iView->RemoveObserver(*this ); |
|
605 |
iView->RemoveStackObserver( *this ); |
|
606 |
} |
|
607 |
||
608 |
iView = aView; |
|
609 |
if( iView ) |
|
610 |
{ |
|
611 |
iView->AddObserverL( *this ); |
|
612 |
iView->AddStackObserverL( *this ); |
|
613 |
} |
|
614 |
FlushCache(); |
|
615 |
} |
|
616 |
||
617 |
// -------------------------------------------------------------------------- |
|
618 |
// CPbk2ThumbnailManager::RemoveThumbnail() |
|
619 |
// -------------------------------------------------------------------------- |
|
620 |
// |
|
621 |
void CPbk2ThumbnailManager::RemoveThumbnail( |
|
622 |
const MVPbkContactLink& /*aContactLink*/, TInt aListboxIndex ) |
|
623 |
{ |
|
624 |
const TInt count = iContactThumbnails.Count(); |
|
625 |
if( count > aListboxIndex ) |
|
626 |
{ |
|
627 |
CPbk2TmItem* item = iContactThumbnails[aListboxIndex]; |
|
628 |
iContactThumbnails.Remove( aListboxIndex ); |
|
629 |
ResetIndexes(); |
|
630 |
if( item ) |
|
631 |
{ |
|
632 |
// check that the icon is not a default icon |
|
633 |
if( item->GetIconArrayIndex() != iDefaultIconIndex ) |
|
634 |
{ |
|
635 |
if( iIconArray ) |
|
636 |
{ |
|
637 |
//inform icon array to remove the icon |
|
638 |
iIconArray->RemoveIcon( item->GetIconId() ); |
|
639 |
} |
|
640 |
//update indexes after that |
|
641 |
UpdateIconIndexes(); |
|
642 |
} |
|
643 |
||
644 |
// remove from priority list |
|
645 |
const TInt priIndex = iPriorityArray.Find( item->GetLink() ); |
|
646 |
if( priIndex != KErrNotFound ) |
|
647 |
{ |
|
648 |
iPriorityArray.Remove( priIndex ); |
|
649 |
} |
|
650 |
||
651 |
// remove from loading queue |
|
652 |
const TInt loadIndex = iLoadingQueue.Find( item ); |
|
653 |
if( loadIndex != KErrNotFound ) |
|
654 |
{ |
|
655 |
iLoadingQueue.Remove( loadIndex ); |
|
656 |
} |
|
657 |
||
658 |
// inform observer |
|
659 |
if( iObserver ) |
|
660 |
{ |
|
661 |
iObserver->ThumbnailRemoved( *item->GetLink(), aListboxIndex ); |
|
662 |
} |
|
663 |
||
664 |
//The item at 0th position, denotes the current item |
|
665 |
//whose thumbnail load is in progress. |
|
666 |
if ( KStartIndex == loadIndex && !iInProgressItemToBeRemoved ) |
|
667 |
{ |
|
668 |
//Remove it when its safe |
|
669 |
iInProgressItemToBeRemoved = item; |
|
670 |
} |
|
671 |
else |
|
672 |
{ |
|
673 |
//can be safely deleted immediately |
|
674 |
delete item; |
|
675 |
} |
|
676 |
} |
|
677 |
} |
|
678 |
} |
|
679 |
||
680 |
// -------------------------------------------------------------------------- |
|
681 |
// CPbk2ThumbnailManager::UpdateIconIndexes() |
|
682 |
// -------------------------------------------------------------------------- |
|
683 |
// |
|
684 |
void CPbk2ThumbnailManager::UpdateIconIndexes( ) |
|
685 |
{ |
|
686 |
// if icon array exists |
|
687 |
if( iIconArray ) |
|
688 |
{ |
|
689 |
const TInt count = iContactThumbnails.Count(); |
|
690 |
for( TInt i = 0; i < count; ++i ) |
|
691 |
{ |
|
692 |
CPbk2TmItem* item = iContactThumbnails[ i ]; |
|
693 |
if( item && !( iDefaultIconId == item->GetIconId() ) ) |
|
694 |
{ |
|
695 |
// icon is removed from the CPbk2IconArray, update indexes |
|
696 |
TPbk2IconId id = item->GetIconId(); |
|
697 |
item->SetIconArrayIndexAndId( iIconArray->FindIcon( id ), id ); |
|
698 |
} |
|
699 |
} |
|
700 |
} |
|
701 |
} |
|
702 |
||
703 |
// -------------------------------------------------------------------------- |
|
704 |
// CPbk2ThumbnailManager::DuplicateBitmapL() |
|
705 |
// -------------------------------------------------------------------------- |
|
706 |
// |
|
707 |
CFbsBitmap* CPbk2ThumbnailManager::DuplicateBitmapL( CFbsBitmap* aSourceBitmap ) |
|
708 |
{ |
|
709 |
//Target bitmap. |
|
710 |
CFbsBitmap* dstbitmap = new (ELeave) CFbsBitmap; |
|
711 |
CleanupStack::PushL( dstbitmap ); |
|
712 |
||
713 |
//Get the handle to source bitmap |
|
714 |
TInt srchandle = aSourceBitmap->Handle(); |
|
715 |
||
716 |
//Duplicate the bitmap handle. Increases the RefCount of bitmap |
|
717 |
//managed but Fbs Server |
|
718 |
User::LeaveIfError( dstbitmap->Duplicate( srchandle ) ); |
|
719 |
CleanupStack::Pop( dstbitmap ); |
|
720 |
return dstbitmap; |
|
721 |
} |
|
722 |
||
723 |
// -------------------------------------------------------------------------- |
|
724 |
// CPbk2ThumbnailManager::StartLoading() |
|
725 |
// -------------------------------------------------------------------------- |
|
726 |
// |
|
727 |
void CPbk2ThumbnailManager::StartLoading() |
|
728 |
{ |
|
729 |
//its safe to delete the item here |
|
730 |
if ( iInProgressItemToBeRemoved ) |
|
731 |
{ |
|
732 |
delete iInProgressItemToBeRemoved; |
|
733 |
iInProgressItemToBeRemoved = NULL; |
|
734 |
} |
|
735 |
||
736 |
TInt count = iLoadingQueue.Count(); |
|
737 |
||
738 |
// limit loading queue |
|
739 |
while( count > KQueueLimit ) |
|
740 |
{ |
|
741 |
iLoadingQueue.Remove( --count ); |
|
742 |
} |
|
743 |
||
744 |
if( count ) |
|
745 |
{ |
|
746 |
// manager is loading |
|
747 |
iState = ELoading; |
|
748 |
// take first item from the queue |
|
749 |
CPbk2TmItem* item = iLoadingQueue[KStartIndex]; |
|
750 |
// take first item from the loading queue |
|
751 |
TRAPD( err, iRetrieveOperation = |
|
752 |
iContactManager.RetrieveContactL( *item->GetLink(), *this ) ); |
|
753 |
if( err ) |
|
754 |
{ |
|
755 |
// error occured -> remove item from the queue and continue |
|
756 |
iLoadingQueue.Remove( KStartIndex ); |
|
757 |
//load next one |
|
758 |
StartLoading(); |
|
759 |
} |
|
760 |
} |
|
761 |
// no more items |
|
762 |
else |
|
763 |
{ |
|
764 |
// loading queue is empty, inform observer |
|
765 |
if( iObserver ) |
|
766 |
{ |
|
767 |
iObserver->LoadingFinished(); |
|
768 |
} |
|
769 |
// default state |
|
770 |
iState = EIdle; |
|
771 |
} |
|
772 |
} |
|
773 |
||
774 |
// -------------------------------------------------------------------------- |
|
775 |
// CPbk2ThumbnailManager::VPbkSingleContactOperationComplete |
|
776 |
// -------------------------------------------------------------------------- |
|
777 |
// |
|
778 |
void CPbk2ThumbnailManager::VPbkSingleContactOperationComplete |
|
779 |
( MVPbkContactOperationBase& /*aOperation*/ , MVPbkStoreContact* aContact ) |
|
780 |
{ |
|
781 |
delete iRetrieveOperation; |
|
782 |
iRetrieveOperation = NULL; |
|
783 |
||
784 |
delete iStoreContact; |
|
785 |
iStoreContact = aContact; |
|
786 |
||
787 |
// store contact found, fetch thumbnail for it |
|
788 |
DoLoadThumbnail( *iStoreContact ); |
|
789 |
} |
|
790 |
||
791 |
// -------------------------------------------------------------------------- |
|
792 |
// CPbk2ThumbnailManager::VPbkSingleContactOperationFailed |
|
793 |
// -------------------------------------------------------------------------- |
|
794 |
// |
|
795 |
void CPbk2ThumbnailManager::VPbkSingleContactOperationFailed |
|
796 |
( MVPbkContactOperationBase& /*aOperation*/ ,TInt /*aError*/ ) |
|
797 |
{ |
|
798 |
if( iObserver && !iInProgressItemToBeRemoved && iLoadingQueue.Count() ) |
|
799 |
{ |
|
800 |
//inform observer |
|
801 |
//We should not inform the observer with wrong index, |
|
802 |
//hence check for iInProgressItemToBeRemoved |
|
803 |
iObserver->ThumbnailLoadingComplete( KErrNotFound, iLoadingQueue[ KStartIndex ]->GetListboxIndex() ); |
|
804 |
||
805 |
//remove item from the queue |
|
806 |
iLoadingQueue.Remove( KStartIndex ); |
|
807 |
} |
|
808 |
//next |
|
809 |
StartLoading(); |
|
810 |
} |
|
811 |
||
812 |
// -------------------------------------------------------------------------- |
|
813 |
// CPbk2ThumbnailManager::DoLoadThumbnail() |
|
814 |
// -------------------------------------------------------------------------- |
|
815 |
// |
|
816 |
void CPbk2ThumbnailManager::DoLoadThumbnail( |
|
817 |
MVPbkBaseContact& aContact ) |
|
818 |
{ |
|
819 |
TInt err = KErrNotFound; |
|
820 |
||
821 |
//if the item in progress has been removed then it will be filled in iInProgressItemToBeRemoved |
|
822 |
//If such condition arises then we need not load the thumbnail at all |
|
823 |
||
824 |
// check if the contact has an image |
|
825 |
if( !iInProgressItemToBeRemoved && iManager->HasImage( aContact, *iFieldType ) && iLoadingQueue.Count() ) |
|
826 |
{ |
|
827 |
// contact has a thumbnail |
|
828 |
iLoadingQueue[ KStartIndex ]->SetHasThumbnail( ETrue ); |
|
829 |
||
830 |
/* |
|
831 |
* If priority array is full, this function removes first item from the array and |
|
832 |
* frees all the allocations related. |
|
833 |
*/ |
|
834 |
MakeRoomForNextThumbnail(); |
|
835 |
||
836 |
// if there is room, load thumbnail |
|
837 |
if( iPriorityArray.Count() <= KLoadingLimit ) |
|
838 |
{ |
|
839 |
//add current item to priority array |
|
840 |
iPriorityArray.Append( iLoadingQueue[ KStartIndex ]->GetLink() ); |
|
841 |
||
842 |
// start loading picture for the current item |
|
843 |
delete iThumbOperation; |
|
844 |
iThumbOperation = NULL; |
|
845 |
// Define parameters for thumbnail |
|
846 |
TPbk2ImageManagerParams params; |
|
847 |
// if iconsize is not set |
|
848 |
if( iIconSize.iHeight == 0 && iIconSize.iWidth == 0 ) |
|
849 |
{ |
|
850 |
iIconSize = KDefaultThumbnailSize; |
|
851 |
} |
|
852 |
// set params |
|
853 |
params.iSize = iIconSize; |
|
854 |
params.iFlags = TPbk2ImageManagerParams::EScaleImage | |
|
855 |
TPbk2ImageManagerParams::EUseSpeedOptimizedScaling | |
|
856 |
TPbk2ImageManagerParams::ECropImage ; |
|
857 |
params.iDisplayMode = EColor16MU; |
|
858 |
// fetch the image |
|
859 |
TRAP( err, iThumbOperation = |
|
860 |
iManager->GetImageAsyncL( ¶ms, aContact, *iFieldType, *this ) ); |
|
861 |
} |
|
862 |
// no room at this moment |
|
863 |
else |
|
864 |
{ |
|
865 |
//has image, but cannot load it |
|
866 |
err = KErrNone; |
|
867 |
//remove item from the queue |
|
868 |
iLoadingQueue.Remove( KStartIndex ); |
|
869 |
// start loading next one |
|
870 |
StartLoading(); |
|
871 |
} |
|
872 |
} |
|
873 |
||
874 |
// contact has no image or error occured, move to next contact |
|
875 |
if( err ) |
|
876 |
{ |
|
877 |
if ( !iInProgressItemToBeRemoved && iLoadingQueue.Count() ) |
|
878 |
{ |
|
879 |
if( iObserver ) |
|
880 |
{ |
|
881 |
//inform observer |
|
882 |
iObserver->ThumbnailLoadingComplete( KErrNotFound, iLoadingQueue[ KStartIndex ]->GetListboxIndex() ); |
|
883 |
} |
|
884 |
//no thumbnail |
|
885 |
iLoadingQueue[ KStartIndex ]->SetHasThumbnail( EFalse ); |
|
886 |
// set default icon index and id |
|
887 |
iLoadingQueue[ KStartIndex ]->SetIconArrayIndexAndId( iDefaultIconIndex, iDefaultIconId ); |
|
888 |
//remove item from the queue |
|
889 |
iLoadingQueue.Remove( KStartIndex ); |
|
890 |
} |
|
891 |
// start loading next one |
|
892 |
StartLoading(); |
|
893 |
} |
|
894 |
} |
|
895 |
||
896 |
// -------------------------------------------------------------------------- |
|
897 |
// CPbk2ThumbnailManager::MakeRoomForNextThumbnail |
|
898 |
// -------------------------------------------------------------------------- |
|
899 |
// |
|
900 |
void CPbk2ThumbnailManager::MakeRoomForNextThumbnail() |
|
901 |
{ |
|
902 |
// if the loading limit for thumbnails is reached and optimizing is on, make room for next thumbnail |
|
903 |
if( iPriorityArray.Count() >= KLoadingLimit ) |
|
904 |
{ |
|
905 |
// remove first one from the queue |
|
906 |
CPbk2TmItem* rem = NULL; |
|
907 |
const TInt count = iContactThumbnails.Count(); |
|
908 |
for( TInt i = 0; i < count; ++i ) |
|
909 |
{ |
|
910 |
CPbk2TmItem* item = iContactThumbnails[ i ]; |
|
911 |
if( item && item->GetLink()->IsSame( *iPriorityArray[ KStartIndex ] ) ) |
|
912 |
{ |
|
913 |
rem = item; |
|
914 |
break; |
|
915 |
} |
|
916 |
} |
|
917 |
// if item was found |
|
918 |
if( rem ) |
|
919 |
{ |
|
920 |
// remove from priority array |
|
921 |
iPriorityArray.Remove( 0 ); |
|
922 |
||
923 |
//remove icon from Pbk2IconArray |
|
924 |
if( iIconArray && rem->GetIconArrayIndex() != iDefaultIconIndex ) |
|
925 |
{ |
|
926 |
iIconArray->RemoveIcon( rem->GetIconId() ); |
|
927 |
} |
|
928 |
// remove memory allocations from heap |
|
929 |
rem->DeleteBitmap(); |
|
930 |
//set default icon id and index |
|
931 |
rem->SetIconArrayIndexAndId( iDefaultIconIndex,iDefaultIconId ); |
|
932 |
//update indexes for other items |
|
933 |
UpdateIconIndexes(); |
|
934 |
} |
|
935 |
} |
|
936 |
} |
|
937 |
||
938 |
// -------------------------------------------------------------------------- |
|
939 |
// CPbk2ThumbnailManager::Pbk2ImageGetComplete |
|
940 |
// -------------------------------------------------------------------------- |
|
941 |
// |
|
942 |
void CPbk2ThumbnailManager::Pbk2ImageGetComplete |
|
943 |
( MPbk2ImageOperation& /*aOperation*/, CFbsBitmap* aBitmap ) |
|
944 |
{ |
|
945 |
//if the item in progress has been removed then it will be filled in iInProgressItemToBeRemoved |
|
946 |
//If such condition arises then we need not load the thumbnail at all |
|
947 |
||
948 |
// store loaded bitmap |
|
949 |
if ( !iInProgressItemToBeRemoved && iLoadingQueue.Count() ) |
|
950 |
{ |
|
951 |
iLoadingQueue[ KStartIndex ]->SetBitmap( aBitmap ); |
|
952 |
||
953 |
// inform the observer |
|
954 |
if( iObserver ) |
|
955 |
{ |
|
956 |
// if icon array exists |
|
957 |
if( iIconArray ) |
|
958 |
{ |
|
959 |
//create icon and pass it to the array |
|
960 |
TPbk2IconId iconID( TUid::Uid( KPbk2UID3 ), iIconIdCounter + KIconIndexOffset ); |
|
961 |
iIconIdCounter++; |
|
962 |
||
963 |
TRAPD( err, AppendIconL( iconID, aBitmap ) ); |
|
964 |
if( err == KErrNone ) |
|
965 |
{ |
|
966 |
// set icond index and id |
|
967 |
iLoadingQueue[ KStartIndex ]->SetIconArrayIndexAndId( iIconArray->FindIcon( iconID ), iconID ); |
|
968 |
// inform observer |
|
969 |
iObserver->ThumbnailLoadingComplete( KErrNone, iLoadingQueue[ KStartIndex ]->GetListboxIndex() ); |
|
970 |
} |
|
971 |
} |
|
972 |
} |
|
973 |
||
974 |
//remove item from the queue |
|
975 |
iLoadingQueue.Remove( KStartIndex ); |
|
976 |
} |
|
977 |
else |
|
978 |
{ |
|
979 |
//None to take ownership. so delete here |
|
980 |
delete aBitmap; |
|
981 |
} |
|
982 |
||
983 |
// delete operation |
|
984 |
delete iThumbOperation; |
|
985 |
iThumbOperation = NULL; |
|
986 |
// next |
|
987 |
StartLoading(); |
|
988 |
} |
|
989 |
||
990 |
// -------------------------------------------------------------------------- |
|
991 |
// CPbk2ThumbnailManager::Pbk2ImageGetFailed |
|
992 |
// -------------------------------------------------------------------------- |
|
993 |
// |
|
994 |
void CPbk2ThumbnailManager::Pbk2ImageGetFailed |
|
995 |
( MPbk2ImageOperation& /*aOperation*/, TInt /*aError*/ ) |
|
996 |
{ |
|
997 |
delete iThumbOperation; |
|
998 |
iThumbOperation = NULL; |
|
999 |
||
1000 |
if( iObserver && !iInProgressItemToBeRemoved && iLoadingQueue.Count() ) |
|
1001 |
{ |
|
1002 |
//inform observer |
|
1003 |
//We should not inform the observer with wrong index, |
|
1004 |
//hence check for iInProgressItemToBeRemoved |
|
1005 |
iObserver->ThumbnailLoadingComplete( KErrNotFound, iLoadingQueue[ KStartIndex ]->GetListboxIndex() ); |
|
1006 |
||
1007 |
//remove item from the queue |
|
1008 |
iLoadingQueue.Remove( KStartIndex ); |
|
1009 |
} |
|
1010 |
||
1011 |
// next |
|
1012 |
StartLoading(); |
|
1013 |
} |
|
1014 |
||
1015 |
// -------------------------------------------------------------------------- |
|
1016 |
// CPbk2ThumbnailManager::ContactViewReady |
|
1017 |
// -------------------------------------------------------------------------- |
|
1018 |
// |
|
1019 |
void CPbk2ThumbnailManager::ContactViewReady( MVPbkContactViewBase& aView ) |
|
1020 |
{ |
|
1021 |
TRAP_IGNORE( DoContactViewReadyL( aView ) ); |
|
1022 |
} |
|
1023 |
||
1024 |
// -------------------------------------------------------------------------- |
|
1025 |
// CPbk2ThumbnailManager::DoContactViewReadyL |
|
1026 |
// -------------------------------------------------------------------------- |
|
1027 |
// |
|
1028 |
void CPbk2ThumbnailManager::DoContactViewReadyL( MVPbkContactViewBase& aView ) |
|
1029 |
{ |
|
1030 |
FlushCache(); |
|
1031 |
PreCreateThumbnailArrayL( aView ); |
|
1032 |
} |
|
1033 |
||
1034 |
// -------------------------------------------------------------------------- |
|
1035 |
// CPbk2ThumbnailManager::PreCreateThumbnailArrayL |
|
1036 |
// -------------------------------------------------------------------------- |
|
1037 |
// |
|
1038 |
void CPbk2ThumbnailManager::PreCreateThumbnailArrayL( MVPbkContactViewBase& aView ) |
|
1039 |
{ |
|
1040 |
iContactThumbnails.ResetAndDestroy(); |
|
1041 |
const TInt contactCount = aView.ContactCountL(); |
|
1042 |
for( TInt i = 0; i < contactCount; ++i ) |
|
1043 |
{ |
|
1044 |
iContactThumbnails.AppendL( NULL ); |
|
1045 |
} |
|
1046 |
} |
|
1047 |
||
1048 |
// -------------------------------------------------------------------------- |
|
1049 |
// CPbk2ThumbnailManager::FlushCache |
|
1050 |
// -------------------------------------------------------------------------- |
|
1051 |
// |
|
1052 |
void CPbk2ThumbnailManager::FlushCache() |
|
1053 |
{ |
|
1054 |
// reset operations |
|
1055 |
delete iRetrieveOperation; |
|
1056 |
iRetrieveOperation = NULL; |
|
1057 |
delete iThumbOperation; |
|
1058 |
iThumbOperation = NULL; |
|
1059 |
iState = EIdle; |
|
1060 |
||
1061 |
if( !iIsCacheClean ) // prevent unnecessary work if cache is already cleaned |
|
1062 |
{ |
|
1063 |
iIsCacheClean = ETrue; |
|
1064 |
const TInt count = iContactThumbnails.Count(); |
|
1065 |
for ( TInt i = count - 1; i >= 0; --i ) |
|
1066 |
{ |
|
1067 |
CPbk2TmItem* item = iContactThumbnails[i]; |
|
1068 |
if ( item ) |
|
1069 |
{ |
|
1070 |
// check that the icon is not a default icon |
|
1071 |
if( iIconArray && item->GetIconArrayIndex() != iDefaultIconIndex ) |
|
1072 |
{ |
|
1073 |
iIconArray->RemoveIcon( item->GetIconId() ); |
|
1074 |
} |
|
1075 |
||
1076 |
delete item; |
|
1077 |
iContactThumbnails[i] = NULL; |
|
1078 |
} |
|
1079 |
} |
|
1080 |
} |
|
1081 |
||
1082 |
// reset loading queue and cache priority |
|
1083 |
iLoadingQueue.Reset(); |
|
1084 |
iPriorityArray.Reset(); |
|
1085 |
} |
|
1086 |
||
1087 |
// -------------------------------------------------------------------------- |
|
1088 |
// CPbk2ThumbnailManager::ContactViewUnavailable |
|
1089 |
// -------------------------------------------------------------------------- |
|
1090 |
// |
|
1091 |
void CPbk2ThumbnailManager::ContactViewUnavailable( |
|
1092 |
MVPbkContactViewBase& /*aView*/ ) |
|
1093 |
{ |
|
1094 |
// ignored |
|
1095 |
} |
|
1096 |
||
1097 |
// -------------------------------------------------------------------------- |
|
1098 |
// CPbk2ThumbnailManager::ContactAddedToView |
|
1099 |
// -------------------------------------------------------------------------- |
|
1100 |
// |
|
1101 |
void CPbk2ThumbnailManager::ContactAddedToView( |
|
1102 |
MVPbkContactViewBase& /*aView*/, |
|
1103 |
TInt aIndex, |
|
1104 |
const MVPbkContactLink& /*aContactLink*/ ) |
|
1105 |
{ |
|
1106 |
// Because contact events and contact view are not always in sync we need to |
|
1107 |
// flush the whole cache. |
|
1108 |
FlushCache(); |
|
1109 |
iContactThumbnails.Insert( NULL, aIndex ); |
|
1110 |
} |
|
1111 |
||
1112 |
// -------------------------------------------------------------------------- |
|
1113 |
// CPbk2ThumbnailManager::ContactRemovedFromView |
|
1114 |
// -------------------------------------------------------------------------- |
|
1115 |
// |
|
1116 |
void CPbk2ThumbnailManager::ContactRemovedFromView( |
|
1117 |
MVPbkContactViewBase& /*aView*/, |
|
1118 |
TInt aIndex, |
|
1119 |
const MVPbkContactLink& /*aContactLink*/ ) |
|
1120 |
{ |
|
1121 |
// Because contact events and contact view are not always in sync we need to |
|
1122 |
// flush the whole cache. |
|
1123 |
FlushCache(); |
|
1124 |
iContactThumbnails.Remove( aIndex ); |
|
1125 |
} |
|
1126 |
||
1127 |
// -------------------------------------------------------------------------- |
|
1128 |
// CPbk2ThumbnailManager::ContactViewError |
|
1129 |
// -------------------------------------------------------------------------- |
|
1130 |
// |
|
1131 |
void CPbk2ThumbnailManager::ContactViewError( |
|
1132 |
MVPbkContactViewBase& /*aView*/, |
|
1133 |
TInt /*aError*/, |
|
1134 |
TBool /*aErrorNotified*/ ) |
|
1135 |
{ |
|
1136 |
// ignored |
|
1137 |
} |
|
1138 |
||
1139 |
// -------------------------------------------------------------------------- |
|
1140 |
// CPbk2ThumbnailManager::TopViewChangedL |
|
1141 |
// -------------------------------------------------------------------------- |
|
1142 |
// |
|
1143 |
void CPbk2ThumbnailManager::TopViewChangedL( MVPbkContactViewBase& /*aOldView*/ ) |
|
1144 |
{ |
|
1145 |
FlushCache(); |
|
1146 |
if( iView ) |
|
1147 |
{ |
|
1148 |
PreCreateThumbnailArrayL( *iView ); |
|
1149 |
} |
|
1150 |
} |
|
1151 |
||
1152 |
// -------------------------------------------------------------------------- |
|
1153 |
// CPbk2ThumbnailManager::TopViewUpdatedL |
|
1154 |
// -------------------------------------------------------------------------- |
|
1155 |
// |
|
1156 |
void CPbk2ThumbnailManager::TopViewUpdatedL() |
|
1157 |
{ |
|
1158 |
} |
|
1159 |
||
1160 |
// -------------------------------------------------------------------------- |
|
1161 |
// CPbk2ThumbnailManager::BaseViewChangedL |
|
1162 |
// -------------------------------------------------------------------------- |
|
1163 |
// |
|
1164 |
void CPbk2ThumbnailManager::BaseViewChangedL() |
|
1165 |
{ |
|
1166 |
} |
|
1167 |
||
1168 |
// -------------------------------------------------------------------------- |
|
1169 |
// CPbk2ThumbnailManager::ViewStackError |
|
1170 |
// -------------------------------------------------------------------------- |
|
1171 |
// |
|
1172 |
void CPbk2ThumbnailManager::ViewStackError( TInt /*aError*/ ) |
|
1173 |
{ |
|
1174 |
} |
|
1175 |
||
1176 |
// -------------------------------------------------------------------------- |
|
1177 |
// CPbk2ThumbnailManager::ContactAddedToBaseView |
|
1178 |
// -------------------------------------------------------------------------- |
|
1179 |
// |
|
1180 |
void CPbk2ThumbnailManager::ContactAddedToBaseView( |
|
1181 |
MVPbkContactViewBase& /*aBaseView*/, |
|
1182 |
TInt /*aIndex*/, |
|
1183 |
const MVPbkContactLink& /*aContactLink*/ ) |
|
1184 |
{ |
|
1185 |
} |
|
1186 |
||
1187 |
// -------------------------------------------------------------------------- |
|
1188 |
// CPbk2ThumbnailManager::ReadFieldTypeL |
|
1189 |
// -------------------------------------------------------------------------- |
|
1190 |
// |
|
1191 |
void CPbk2ThumbnailManager::ReadFieldTypeL() |
|
1192 |
{ |
|
1193 |
TResourceReader reader; |
|
1194 |
CCoeEnv::Static()->CreateResourceReaderLC |
|
1195 |
( reader, R_PBK2_THUMBNAIL_FIELD_TYPE ); |
|
1196 |
const TInt count = reader.ReadInt16(); |
|
1197 |
||
1198 |
TVPbkFieldTypeMapping mapping( reader ); |
|
1199 |
iFieldType = mapping.FindMatch( iContactManager.FieldTypes() ); |
|
1200 |
if( !iFieldType ) |
|
1201 |
{ |
|
1202 |
User::Leave( KErrNotFound ); |
|
1203 |
} |
|
1204 |
CleanupStack::PopAndDestroy(); // CreateResourceReaderLC |
|
1205 |
} |
|
1206 |
||
1207 |
||
1208 |
// -------------------------------------------------------------------------- |
|
1209 |
// CPbk2ThumbnailManager::AppendIconL |
|
1210 |
// -------------------------------------------------------------------------- |
|
1211 |
// |
|
1212 |
void CPbk2ThumbnailManager::AppendIconL( |
|
1213 |
TPbk2IconId& aIcon, CFbsBitmap* aBitmap ) |
|
1214 |
{ |
|
1215 |
// create icon |
|
1216 |
CGulIcon* icon = CGulIcon::NewLC(); |
|
1217 |
icon->SetBitmap( DuplicateBitmapL( aBitmap ) ); |
|
1218 |
iIconArray->AppendIconL( icon, aIcon ); |
|
1219 |
CleanupStack::Pop( icon ); |
|
1220 |
} |
|
1221 |
||
1222 |
// end of file |