|
1 /* |
|
2 * Copyright (c) 2006 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: Data Source MDE Class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 * @author Simon Brooks, Alex Birkett |
|
23 */ |
|
24 |
|
25 /** |
|
26 * @internal reviewed 10/07/2007 by M Byrne |
|
27 */ |
|
28 |
|
29 #ifndef _C_GLXDATASOURCEMDE_H_ |
|
30 #define _C_GLXDATASOURCEMDE_H_ |
|
31 |
|
32 // INCLUDES |
|
33 #include <e32cmn.h> |
|
34 #include <f32file.h> |
|
35 |
|
36 #include <mdesession.h> |
|
37 #include <mglxtnstorage.h> |
|
38 #include <mpxcollectionmessagedefs.h> |
|
39 |
|
40 #ifdef USE_S60_TNM |
|
41 #include <thumbnailmanager.h> |
|
42 #include <thumbnailmanagerobserver.h> |
|
43 #include <thumbnaildata.h> |
|
44 #include <thumbnailobjectsource.h> |
|
45 |
|
46 #include "mthumbnailfetchrequestobserver.h" |
|
47 #endif |
|
48 |
|
49 #include "glxdatasource.h" |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 class CGlxRequest; |
|
53 |
|
54 #ifndef USE_S60_TNM |
|
55 class CGlxtnThumbnailCreator; |
|
56 class CGlxtnThumbnailDatabase; |
|
57 #endif |
|
58 |
|
59 // CONSTANTS |
|
60 |
|
61 // CLASS DECLARATION |
|
62 |
|
63 /** |
|
64 * CGlxDataSourceMde class |
|
65 * |
|
66 * Data Source Mde is a Meta Data Data Source. |
|
67 * @lib GlxDataSourceMde.lib |
|
68 * @ingroup collection_component_design |
|
69 */ |
|
70 class CGlxDataSourceMde : public CGlxDataSource, |
|
71 public MMdESessionObserver, |
|
72 public MMdEObjectObserver, |
|
73 public MMdEObjectPresentObserver, |
|
74 public MMdERelationObserver, |
|
75 public MMdERelationPresentObserver |
|
76 #ifdef USE_S60_TNM |
|
77 , public MThumbnailManagerObserver |
|
78 #else |
|
79 , public MGlxtnThumbnailStorageObserver |
|
80 #endif |
|
81 { |
|
82 public: |
|
83 static CGlxDataSourceMde* NewL(); |
|
84 |
|
85 private: |
|
86 ~CGlxDataSourceMde(); |
|
87 |
|
88 CGlxDataSourceMde(); |
|
89 |
|
90 void ConstructL(); |
|
91 |
|
92 public: // from CGlxDataSource |
|
93 CGlxDataSourceTask* CreateTaskL(CGlxRequest* aRequest, MGlxDataSourceRequestObserver& aObserver); |
|
94 |
|
95 private: |
|
96 /** |
|
97 * from MMdESessionObserver |
|
98 */ |
|
99 void HandleSessionOpened(CMdESession& aSession, TInt aError); |
|
100 |
|
101 void HandleSessionError(CMdESession& aSession, TInt aError); |
|
102 |
|
103 #ifdef USE_S60_TNM |
|
104 public: |
|
105 void FetchThumbnailL(CGlxRequest* aRequest, MThumbnailFetchRequestObserver& aObserver); |
|
106 TInt CancelFetchThumbnail(); |
|
107 #else |
|
108 private: // from MGlxtnThumbnailStorageObserver |
|
109 /** |
|
110 * Notify that a given thumbnail is available in storage. |
|
111 * @param aId Media item ID. |
|
112 * @param aSize Requested thumbnail size. |
|
113 */ |
|
114 void ThumbnailAvailable(const TGlxMediaId& aId, const TSize& aSize); |
|
115 /** |
|
116 * Notify that a given thumbnail is available in storage. |
|
117 * @param aId Media item ID. |
|
118 * @param aSize Thumbnail size. |
|
119 */ |
|
120 void BackgroundThumbnailError(const TGlxMediaId& aId, TInt aError); |
|
121 #endif |
|
122 |
|
123 private: // MMdEObjectObserver |
|
124 /** |
|
125 * Called to notify the observer that new objects has been added to |
|
126 * the metadata engine database. |
|
127 * |
|
128 * @param aSession session |
|
129 * @param aObjectIdArray IDs of added object |
|
130 */ |
|
131 void HandleObjectAdded(CMdESession& aSession, const RArray<TItemId>& aObjectIdArray); |
|
132 |
|
133 /** |
|
134 * Called to notify the observer that objects has been modified in |
|
135 * the metadata engine database. |
|
136 * |
|
137 * @param aSession session |
|
138 * @param aObjectIdArray IDs of modified object |
|
139 */ |
|
140 void HandleObjectModified(CMdESession& aSession, const RArray<TItemId>& aObjectIdArray); |
|
141 |
|
142 /** |
|
143 * Called to notify the observer that objects has been removed from |
|
144 * the metadata engine database. |
|
145 * |
|
146 * @param aSession session |
|
147 * @param aObjectIdArray IDs of removed object |
|
148 */ |
|
149 void HandleObjectRemoved(CMdESession& aSession, const RArray<TItemId>& aObjectIdArray); |
|
150 |
|
151 private: // MMdEObjectPresentObserver |
|
152 /** |
|
153 * Called to notify the observer that objects has been set to present state in |
|
154 * the metadata engine database. |
|
155 * |
|
156 * @param aSession session |
|
157 * @param aObjectIdArray object IDs which are set to present state |
|
158 */ |
|
159 void HandleObjectPresent(CMdESession& aSession, const RArray<TItemId>& aObjectIdArray); |
|
160 |
|
161 /** |
|
162 * Called to notify the observer that objects has been set to not present state in |
|
163 * the metadata engine database. |
|
164 * |
|
165 * @param aSession session |
|
166 * @param aObjectIdArray object IDs which are set to not present state |
|
167 */ |
|
168 void HandleObjectNotPresent(CMdESession& aSession, const RArray<TItemId>& aObjectIdArray); |
|
169 |
|
170 private: // MMdERelationObserver |
|
171 /** |
|
172 * Called to notify the observer that new relations has been added to |
|
173 * the metadata engine database. |
|
174 * |
|
175 * @param aSession session |
|
176 * @param aRelationIdArray IDs of added relations |
|
177 */ |
|
178 void HandleRelationAdded(CMdESession& aSession, const RArray<TItemId>& aRelationIdArray); |
|
179 |
|
180 /** |
|
181 * Called to notify the observer that relations has been removed from |
|
182 * the metadata engine database. |
|
183 * |
|
184 * @param aSession session |
|
185 * @param aRelationIdArray IDs of removed relations |
|
186 */ |
|
187 void HandleRelationRemoved(CMdESession& aSession, const RArray<TItemId>& aRelationIdArray); |
|
188 |
|
189 /** |
|
190 * Called to notify the observer that relations has been modified from |
|
191 * the metadata engine database. |
|
192 * |
|
193 * @param aSession session |
|
194 * @param aRelationIdArray IDs of modified relations |
|
195 */ |
|
196 void HandleRelationModified(CMdESession& aSession, const RArray<TItemId>& aRelationIdArray); |
|
197 |
|
198 private: //MMdERelationPresentObserver |
|
199 /** |
|
200 * Called to notify the observer that objects has been set to present state in |
|
201 * the metadata engine database. |
|
202 * |
|
203 * @param aSession session |
|
204 * @param aObjectIdArray object IDs which are set to present state |
|
205 */ |
|
206 void HandleRelationPresent(CMdESession& aSession, const RArray<TItemId>& aRelationIdArray); |
|
207 |
|
208 /** |
|
209 * Called to notify the observer that objects has been set to not present state in |
|
210 * the metadata engine database. |
|
211 * |
|
212 * @param aSession session |
|
213 * @param aObjectIdArray object IDs which are set to not present state |
|
214 */ |
|
215 void HandleRelationNotPresent(CMdESession& aSession, const RArray<TItemId>& aRelationIdArray); |
|
216 |
|
217 #ifdef USE_S60_TNM |
|
218 // from MThumbnailManagerObserver |
|
219 void ThumbnailPreviewReady( MThumbnailData& aThumbnail, |
|
220 TThumbnailRequestId aId ); |
|
221 |
|
222 void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail, |
|
223 TThumbnailRequestId aId ); |
|
224 #endif |
|
225 |
|
226 private: |
|
227 |
|
228 void BackgroundThumbnailMessageL(const TGlxMediaId& aId, const TSize& aSize, TInt aError); |
|
229 |
|
230 void DoSessionInitL(); |
|
231 |
|
232 void AddMdEObserversL(); |
|
233 |
|
234 void ProcessUpdateArray(const RArray<TItemId>& aArray, TMPXChangeEventType aType, TBool aIsObject); |
|
235 |
|
236 void ProcessItemUpdateL(); |
|
237 |
|
238 static TInt ProcessItemUpdate(TAny* aPtr); |
|
239 |
|
240 void CreateSessionL(); |
|
241 |
|
242 static TInt CreateSession(TAny* aPtr); |
|
243 |
|
244 void PrepareMonthsL(); |
|
245 |
|
246 void TaskCompletedL(); |
|
247 |
|
248 void TaskStartedL(); |
|
249 #ifdef USE_S60_TNM |
|
250 /* |
|
251 * This function doesnt add up any value, added to reduce compiler warnings |
|
252 */ |
|
253 void ThumbnailReadyL( TInt aError, MThumbnailData& aThumbnail, |
|
254 TThumbnailRequestId aId ); |
|
255 #endif |
|
256 |
|
257 public: |
|
258 inline CMdESession& Session() const; |
|
259 |
|
260 #ifndef USE_S60_TNM |
|
261 inline CGlxtnThumbnailCreator& ThumbnailCreator() const; |
|
262 |
|
263 inline CGlxtnThumbnailDatabase& ThumbnailDatabase() const; |
|
264 #endif |
|
265 |
|
266 inline RFs& FileServerSession(); |
|
267 |
|
268 inline const TGlxMediaId& CameraAlbumId() const; |
|
269 |
|
270 inline const TGlxMediaId& FavoritesId() const; |
|
271 |
|
272 inline CMdENamespaceDef* NamespaceDef() const; |
|
273 |
|
274 inline CMdEObjectDef& ObjectDef() const; |
|
275 |
|
276 inline CMdEObjectDef& ImageDef() const; |
|
277 |
|
278 inline CMdEObjectDef& VideoDef() const; |
|
279 |
|
280 inline CMdEObjectDef& AlbumDef() const; |
|
281 |
|
282 inline CMdEObjectDef& MediaDef() const; |
|
283 inline CMdEObjectDef& TagDef() const; |
|
284 |
|
285 /** |
|
286 * Return object definition used to describe months. |
|
287 * @return object definition used to describe months. |
|
288 */ |
|
289 inline CMdEObjectDef& MonthDef() const; |
|
290 |
|
291 inline CMdERelationDef& ContainsDef() const; |
|
292 |
|
293 /** |
|
294 * Get the location definition. |
|
295 * @return location definition. |
|
296 */ |
|
297 inline CMdEObjectDef& LocationDef() const; |
|
298 |
|
299 TContainerType ContainerType(CMdEObject* aObject); |
|
300 |
|
301 TContainerType ContainerType(CMdEObjectDef* aObjectDef); |
|
302 |
|
303 TItemType ItemType(CMdEObject* aObject); |
|
304 |
|
305 const TGlxMediaId GetMonthIdL(const TTime& aMonth); |
|
306 |
|
307 TBool SameMonth(const TTime& aOldDate, const TTime& aNewDate); |
|
308 |
|
309 TBool ContainerIsLeft(CMdEObjectDef& aObjectDef); |
|
310 |
|
311 private: |
|
312 #ifdef USE_S60_TNM |
|
313 MThumbnailFetchRequestObserver* iTnFetchObserver; |
|
314 CThumbnailManager* iTnEngine; |
|
315 CFbsBitmap* iTnThumbnail; |
|
316 CFbsBitmap* iThumbnail; |
|
317 TThumbnailRequestId iTnThumbnailCbId; |
|
318 TBool iTnRequestInProgress; |
|
319 TInt iTnHandle; |
|
320 TGlxMediaId iMediaId; |
|
321 |
|
322 #else |
|
323 CGlxtnThumbnailCreator* iThumbnailCreator; |
|
324 |
|
325 CGlxtnThumbnailDatabase* iThumbnailDatabase; |
|
326 #endif |
|
327 |
|
328 CMdESession* iSession; |
|
329 |
|
330 RFs iFs; |
|
331 |
|
332 TBool iSessionOpen; |
|
333 |
|
334 TGlxMediaId iCameraAlbumId; |
|
335 |
|
336 TGlxMediaId iFavoritesId; |
|
337 |
|
338 |
|
339 CMdENamespaceDef* iNameSpaceDef; |
|
340 |
|
341 CMdEObjectDef* iObjectDef; |
|
342 |
|
343 CMdEObjectDef* iImageDef; |
|
344 |
|
345 CMdEObjectDef* iVideoDef; |
|
346 |
|
347 CMdEObjectDef* iAlbumDef; |
|
348 |
|
349 CMdEObjectDef* iMediaDef; |
|
350 CMdEObjectDef* iTagDef; |
|
351 |
|
352 CMdEObjectDef* iMonthDef; |
|
353 |
|
354 /** |
|
355 * Location object definition. |
|
356 */ |
|
357 CMdEObjectDef* iLocationDef; |
|
358 CMdERelationDef* iContainsDef; |
|
359 |
|
360 |
|
361 RArray<TTime> iMonthArray; |
|
362 |
|
363 RArray<TGlxMediaId> iMonthList; |
|
364 |
|
365 TTime iFirstMonth; |
|
366 |
|
367 TTime iLastMonth; |
|
368 |
|
369 CAsyncCallBack* iUpdateCallback; |
|
370 |
|
371 CAsyncCallBack* iCreateSessionCallback; |
|
372 |
|
373 struct TUpdateData |
|
374 { |
|
375 TItemId iId; |
|
376 TMPXChangeEventType iType; |
|
377 TBool iIsObject; |
|
378 }; |
|
379 |
|
380 RArray<TUpdateData> iUpdateData; |
|
381 TBool iPauseUpdate; |
|
382 }; |
|
383 |
|
384 #include "glxdatasourcemde.inl" |
|
385 |
|
386 #endif //_C_GLXDATASOURCEMDE_H_ |