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