25
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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: Concrete interface for loading thumbail images.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CPHCNTTHUMBNAILLOADERIMPL_H
|
|
20 |
#define CPHCNTTHUMBNAILLOADERIMPL_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include "cphcntthumbnailloader.h"
|
|
24 |
#include "mphcntthumbnailloader.h"
|
|
25 |
|
|
26 |
// FORWARD DECLARATIONS
|
|
27 |
class MPhoneCntPbkOwner;
|
|
28 |
class MPhCntThumbnailLoaderObserver;
|
|
29 |
class CPbkContactItem;
|
|
30 |
class CPbkThumbnailManager;
|
|
31 |
class MPbkThumbnailOperation;
|
|
32 |
class CPhCntContactId;
|
|
33 |
|
|
34 |
// CLASS DECLARATION
|
|
35 |
|
|
36 |
/**
|
|
37 |
* It loads thumbail images.
|
|
38 |
*
|
|
39 |
* Note that it is considered that loading of thumbnail images is not critical.
|
|
40 |
* Thus, if something fails during loading procedure, then we ignore the whole
|
|
41 |
* thumbnail.
|
|
42 |
*
|
|
43 |
* However, observer will be informed of both success and failure.
|
|
44 |
*
|
|
45 |
* @lib PhoneCntFinder
|
|
46 |
* @since 1.0
|
|
47 |
*/
|
|
48 |
NONSHARABLE_CLASS( CPhCntThumbnailLoaderImpl )
|
|
49 |
: public CPhCntThumbnailLoader,
|
|
50 |
private MPhCntLoaderObserver
|
|
51 |
{
|
|
52 |
public: // Constructors and destructor
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Two-phased constructor.
|
|
56 |
*/
|
|
57 |
static CPhCntThumbnailLoaderImpl* NewL(
|
|
58 |
MPhCntThumbnailLoaderObserver& aObserver,
|
|
59 |
MPhoneCntPbkOwner& aPbkOwner,
|
|
60 |
MPhCntThumbnailLoader& aLoader );
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Destructor.
|
|
64 |
*/
|
|
65 |
~CPhCntThumbnailLoaderImpl();
|
|
66 |
|
|
67 |
public: // Functions from base classes
|
|
68 |
|
|
69 |
/**
|
|
70 |
* From CPhCntThumbnailLoader
|
|
71 |
*/
|
|
72 |
TInt Load( TThumbnailId& aId, const CPhCntContactId& aContactId );
|
|
73 |
|
|
74 |
/**
|
|
75 |
* From CPhCntThumbnailLoader
|
|
76 |
*/
|
|
77 |
void Cancel( TThumbnailId aId );
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Indication that loading has been made.
|
|
81 |
*
|
|
82 |
* @since S60 v3.0
|
|
83 |
* @param Pointer of bitmap loaded, ownership is given to caller.
|
|
84 |
* May be null if error occured during loading.
|
|
85 |
* @param aError Error code of loading.
|
|
86 |
*/
|
|
87 |
void LoadingCompleted( CFbsBitmap* aBitmap, TInt aError );
|
|
88 |
|
|
89 |
private:
|
|
90 |
|
|
91 |
/**
|
|
92 |
* It contains necessary information to load a thumbnail.
|
|
93 |
*/
|
|
94 |
struct TThumbnailInfo
|
|
95 |
{
|
|
96 |
// It contains index.
|
|
97 |
TThumbnailId iId;
|
|
98 |
|
|
99 |
// Identifies the contact, which thumbnail is going to be loaded.
|
|
100 |
CPhCntContactId* iContactId;
|
|
101 |
};
|
|
102 |
|
|
103 |
/**
|
|
104 |
* It enumerates all states.
|
|
105 |
*/
|
|
106 |
enum TState
|
|
107 |
{
|
|
108 |
ELoadFromContact,
|
|
109 |
EProcessResult
|
|
110 |
};
|
|
111 |
|
|
112 |
/**
|
|
113 |
* C++ constructor.
|
|
114 |
*/
|
|
115 |
CPhCntThumbnailLoaderImpl(
|
|
116 |
MPhCntThumbnailLoaderObserver& aObserver,
|
|
117 |
MPhoneCntPbkOwner& aPbkOwner,
|
|
118 |
MPhCntThumbnailLoader& aLoader );
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Symbian OS constructor.
|
|
122 |
*/
|
|
123 |
void ConstructL( MPhoneCntPbkOwner& aPbkOwner );
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Attempts to start loading of thumbnail.
|
|
127 |
*/
|
|
128 |
void AttemptLoadL(
|
|
129 |
TThumbnailId aId,
|
|
130 |
const CPhCntContactId& aContactId );
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Starts loading next thumbnail.
|
|
134 |
*/
|
|
135 |
void StartLoadL();
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Cancels loading.
|
|
139 |
*/
|
|
140 |
void CancelLoad();
|
|
141 |
|
|
142 |
/**
|
|
143 |
* Processes the result.
|
|
144 |
*/
|
|
145 |
void ProcessResultL();
|
|
146 |
|
|
147 |
/**
|
|
148 |
* Finds position in array by thumbnail id.
|
|
149 |
*
|
|
150 |
* @param aId id.
|
|
151 |
* @return position or KErrNotFound if not found.
|
|
152 |
*/
|
|
153 |
TInt FindById( TThumbnailId aId );
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Starts loading. If it failed, then simply inform
|
|
157 |
* observer about failure.
|
|
158 |
*/
|
|
159 |
void DoStartLoad();
|
|
160 |
|
|
161 |
/**
|
|
162 |
* Handles start.
|
|
163 |
*/
|
|
164 |
void HandleStartL();
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Handles start; calls HandleStartL in trap harnness.
|
|
168 |
*/
|
|
169 |
void HandleStart();
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Starts bridge.
|
|
173 |
*/
|
|
174 |
void Start( TState aState );
|
|
175 |
|
|
176 |
/**
|
|
177 |
* Idle callback.
|
|
178 |
*/
|
|
179 |
static TInt DoStart( TAny* aAny );
|
|
180 |
|
|
181 |
/**
|
|
182 |
* It gives thumbnail to the observer.
|
|
183 |
*
|
|
184 |
* Ownership of the bitmap is transferred to the client.
|
|
185 |
*
|
|
186 |
* @param aResult error code.
|
|
187 |
* @param aBitmap bitmap or NULL if no bitmap loaded.
|
|
188 |
*/
|
|
189 |
void Notify(
|
|
190 |
TThumbnailId aId,
|
|
191 |
TInt aResult,
|
|
192 |
CFbsBitmap* aBitmap );
|
|
193 |
|
|
194 |
/**
|
|
195 |
* Clears all pbk stuff.
|
|
196 |
*/
|
|
197 |
void ClearPbk( TBool aMore = ETrue );
|
|
198 |
|
|
199 |
/**
|
|
200 |
* Compares ids of two structure.
|
|
201 |
*
|
|
202 |
* @return ETrue iff aFirst.iId == aSecond.iId.
|
|
203 |
*/
|
|
204 |
static TBool CompareIds(
|
|
205 |
const TThumbnailInfo& aFirst,
|
|
206 |
const TThumbnailInfo& aSecond );
|
|
207 |
|
|
208 |
/**
|
|
209 |
* It is enumeration of all panic reasons.
|
|
210 |
*/
|
|
211 |
enum TPanicReason
|
|
212 |
{
|
|
213 |
EPanicInvariant,
|
|
214 |
EPanicInvalidState
|
|
215 |
};
|
|
216 |
|
|
217 |
/**
|
|
218 |
* Panics.
|
|
219 |
*
|
|
220 |
* @param aReason reason for panic.
|
|
221 |
*/
|
|
222 |
static void Panic( TPanicReason aReason );
|
|
223 |
|
|
224 |
void ClearThumbnailArray();
|
|
225 |
|
|
226 |
void RemoveThumbnailArrayEntry( TInt aIndex );
|
|
227 |
|
|
228 |
private: // Data
|
|
229 |
|
|
230 |
/**
|
|
231 |
* It is type for array of thumbnail info.
|
|
232 |
*/
|
|
233 |
typedef RArray< TThumbnailInfo > RThumbnailArray;
|
|
234 |
|
|
235 |
// Ref: Observer.
|
|
236 |
MPhCntThumbnailLoaderObserver& iObserver;
|
|
237 |
|
|
238 |
// Owned: array of thumbnails to load.
|
|
239 |
RThumbnailArray iArray;
|
|
240 |
|
|
241 |
// Owned: active bridge
|
|
242 |
CIdle* iBridge;
|
|
243 |
|
|
244 |
// INFORMATION OF LOADING..
|
|
245 |
|
|
246 |
// Current state.
|
|
247 |
TState iState;
|
|
248 |
|
|
249 |
// Currently loading. System is loading iff iCurrent != KNullId.
|
|
250 |
TThumbnailId iCurrent;
|
|
251 |
|
|
252 |
// Current bitmap.
|
|
253 |
CFbsBitmap* iBitmap;
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Thumbnail loader.
|
|
257 |
* Own.
|
|
258 |
*/
|
|
259 |
MPhCntThumbnailLoader* iLoader;
|
|
260 |
|
|
261 |
};
|
|
262 |
|
|
263 |
#endif // CPHCNTTHUMBNAILLOADERIMPL_H
|
|
264 |
|
|
265 |
// End of File
|