|
1 /* |
|
2 * Copyright (c) 2008-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 * @internal reviewed 11/07/2007 by M Byrne |
|
22 */ |
|
23 |
|
24 #include "glxdatasourcetaskmdsidlist.h" |
|
25 |
|
26 #include <glxcollectionplugincamera.hrh> |
|
27 #include <glxcollectionplugindownloads.hrh> |
|
28 #include <glxcollectionpluginmonths.hrh> |
|
29 #include <glxcollectionpluginalbums.hrh> |
|
30 #include <glxcollectionpluginall.hrh> |
|
31 #include <glxcollectionplugintags.hrh> |
|
32 #include <glxcollectionpluginimageviewer.hrh> |
|
33 |
|
34 #include <glxerrors.h> |
|
35 #include <glxfilterfactory.h> |
|
36 #include <glxgetrequest.h> |
|
37 #include <glxidlistrequest.h> |
|
38 #include <glxidlistrequest.h> |
|
39 #include <glxlog.h> |
|
40 #include <glxmediacollectioninternaldefs.h> |
|
41 #include <glxmediageneraldefs.h> |
|
42 #include <glxrequest.h> |
|
43 #include <glxthumbnailattributeinfo.h> |
|
44 #include <glxthumbnailrequest.h> |
|
45 #include <glxtndatabase.h> |
|
46 #include <glxtnfileinfo.h> |
|
47 #include <glxtnthumbnailcreator.h> |
|
48 #include <glxtracer.h> |
|
49 #include <lbsposition.h> |
|
50 #include <mdeconstants.h> |
|
51 #include <mdelogiccondition.h> |
|
52 #include <mdeobject.h> |
|
53 #include <mdeobjectdef.h> |
|
54 #include <mdeobjectquery.h> |
|
55 #include <mdepropertydef.h> |
|
56 #include <mderelationdef.h> |
|
57 #include <mdesession.h> |
|
58 #include <mdetextproperty.h> |
|
59 #include <mpxmedia.h> |
|
60 #include <mpxmediaarray.h> |
|
61 #include <mpxmediacollectiondetaildefs.h> |
|
62 #include <mpxmediacontainerdefs.h> |
|
63 #include <mpxmediadrmdefs.h> |
|
64 #include <mpxmediageneraldefs.h> |
|
65 |
|
66 #include "glxdatasourcemds.h" |
|
67 #include "glxdatasourcemds.hrh" |
|
68 #include "glxdatasourcemdsutility.h" |
|
69 |
|
70 // CONSTANTS |
|
71 const TInt KGlxCameraAlbumPromotionPosition = 0; |
|
72 const TInt KGlxfavoritesAlbumPromotionPosition = 1; |
|
73 |
|
74 _LIT(KPropertyDefNameCreationDate, "CreationDate"); |
|
75 |
|
76 // ---------------------------------------------------------------------------- |
|
77 // Constructor |
|
78 // ---------------------------------------------------------------------------- |
|
79 // |
|
80 CGlxDataSourceTaskMdeIdList::CGlxDataSourceTaskMdeIdList(CGlxIdListRequest* aRequest, |
|
81 MGlxDataSourceRequestObserver& aObserver, CGlxDataSource* aDataSource) |
|
82 : CGlxDataSourceTaskMde(aRequest, aObserver, aDataSource) |
|
83 { |
|
84 TRACER("CGlxDataSourceTaskMdeIdList::CGlxDataSourceTaskMdeIdList()") |
|
85 iFilterProperties = TGlxFilterFactory::ExtractAttributes(iRequest->Filter()); |
|
86 } |
|
87 |
|
88 // ---------------------------------------------------------------------------- |
|
89 // Destructor |
|
90 // ---------------------------------------------------------------------------- |
|
91 // |
|
92 CGlxDataSourceTaskMdeIdList::~CGlxDataSourceTaskMdeIdList() |
|
93 { |
|
94 TRACER("CGlxDataSourceTaskMdeIdList::~CGlxDataSourceTaskMdeIdList()") |
|
95 // No implementation required |
|
96 } |
|
97 |
|
98 // ---------------------------------------------------------------------------- |
|
99 // CGlxDataSourceTaskMde::FilterAvailableComplete |
|
100 // ---------------------------------------------------------------------------- |
|
101 // |
|
102 void CGlxDataSourceTaskMdeIdList::FilterAvailableComplete( |
|
103 const RArray<TGlxMediaId>& aIdArray, TInt aErrorCode) |
|
104 { |
|
105 TRACER("CGlxDataSourceTaskMdeIdList::FilterAvailableComplete()") |
|
106 DoPostFilterComplete(aIdArray, aErrorCode); |
|
107 } |
|
108 |
|
109 // ---------------------------------------------------------------------------- |
|
110 // CGlxDataSourceTaskMdeIdList::ExecuteRequestL |
|
111 // ---------------------------------------------------------------------------- |
|
112 // |
|
113 void CGlxDataSourceTaskMdeIdList::ExecuteRequestL() |
|
114 { |
|
115 TRACER("CGlxDataSourceTaskMdeIdList::ExecuteRequestL()") |
|
116 #ifdef _DEBUG |
|
117 iStartTime.HomeTime(); |
|
118 #endif |
|
119 CGlxIdListRequest* request = static_cast<CGlxIdListRequest*>(iRequest); |
|
120 TGlxMediaId container = request->ContainerId(); |
|
121 TGlxQueryType queryType = EIdListQuery; |
|
122 TQueryResultMode resultMode = EQueryResultModeId; |
|
123 CMdEObjectDef* objectDef = &DataSource()->ObjectDef(); |
|
124 TBool isContent = ETrue; |
|
125 |
|
126 if( KGlxCollectionRootId == container.Value() ) // The root. |
|
127 { |
|
128 switch(request->CollectionPluginUid().iUid) |
|
129 { |
|
130 |
|
131 case KGlxCollectionPluginAlbumsImplementationUid: |
|
132 { |
|
133 isContent = EFalse; |
|
134 objectDef = &DataSource()->AlbumDef(); |
|
135 break; |
|
136 } |
|
137 case KGlxCollectionPluginCameraImplementationUid: |
|
138 { |
|
139 iFilterProperties.iOrigin = EGlxFilterOriginCamera; |
|
140 break; |
|
141 } |
|
142 case KGlxTagCollectionPluginImplementationUid: |
|
143 { |
|
144 isContent = EFalse; |
|
145 objectDef = &DataSource()->TagDef(); |
|
146 break; |
|
147 } |
|
148 case KGlxCollectionPluginMonthsImplementationUid: |
|
149 { |
|
150 iFilterProperties.iOrigin = EGlxFilterOriginAll; |
|
151 container = TGlxMediaId(KGlxCollectionRootId); |
|
152 resultMode = EQueryResultModeItem; |
|
153 break; |
|
154 } |
|
155 case KGlxCollectionPluginImageViewerImplementationUid: |
|
156 { |
|
157 RArray<TGlxMediaId> list; |
|
158 CleanupClosePushL(list); |
|
159 list.AppendL(TGlxMediaId(request->CollectionPluginUid().iUid)); |
|
160 DoPostFilterComplete(list, KErrNone); |
|
161 CleanupStack::PopAndDestroy(&list); |
|
162 return; |
|
163 } |
|
164 default: |
|
165 { |
|
166 // default gallery query returns all objects as per filter |
|
167 break; |
|
168 } |
|
169 } |
|
170 } |
|
171 else // return the content of a container |
|
172 { |
|
173 switch(request->CollectionPluginUid().iUid) |
|
174 { |
|
175 case KGlxCollectionPluginAlbumsImplementationUid: |
|
176 { |
|
177 objectDef = &DataSource()->AlbumDef(); |
|
178 break; |
|
179 } |
|
180 case KGlxTagCollectionPluginImplementationUid: |
|
181 { |
|
182 objectDef = &DataSource()->TagDef(); |
|
183 break; |
|
184 } |
|
185 case KGlxCollectionPluginMonthsImplementationUid: |
|
186 { |
|
187 iFilterProperties.iOrigin = EGlxFilterOriginAll; |
|
188 AddMonthFilterL(container, iFilterProperties); |
|
189 container = TGlxMediaId(KGlxCollectionRootId); |
|
190 break; |
|
191 } |
|
192 default: |
|
193 { |
|
194 User::Leave(KErrNotSupported); |
|
195 break; |
|
196 } |
|
197 } |
|
198 } |
|
199 |
|
200 DoQueryL(*objectDef, isContent, queryType, resultMode, container); |
|
201 } |
|
202 |
|
203 // ---------------------------------------------------------------------------- |
|
204 // CGlxDataSourceTaskMde::DoHandleQueryCompletedL |
|
205 // ---------------------------------------------------------------------------- |
|
206 // |
|
207 void CGlxDataSourceTaskMdeIdList::DoHandleQueryCompletedL(CMdEQuery& /*aQuery*/) |
|
208 { |
|
209 TRACER("CGlxDataSourceTaskMdeIdList::DoHandleQueryCompletedL()") |
|
210 __ASSERT_DEBUG(iQueryTypes[0] == EIdListQuery, Panic(EGlxPanicLogicError)); |
|
211 DoHandleListQueryCompletedL(); |
|
212 #ifdef _DEBUG |
|
213 iStopTime.HomeTime(); |
|
214 GLX_DEBUG2("GlxDataSrcTaskMdeIdList:DoHandleQueryCompletedL() took %d us", |
|
215 (TInt)iStopTime.MicroSecondsFrom(iStartTime).Int64()); |
|
216 #endif |
|
217 } |
|
218 |
|
219 // ---------------------------------------------------------------------------- |
|
220 // CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL |
|
221 // ---------------------------------------------------------------------------- |
|
222 // |
|
223 void CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL() |
|
224 { |
|
225 TRACER("CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL()") |
|
226 if(iQueries[0]->ResultMode() == EQueryResultModeItem) |
|
227 { |
|
228 DoMonthListCreationL(*iQueries[0], iFilterProperties); |
|
229 } |
|
230 else // only id or item supported |
|
231 { |
|
232 |
|
233 RArray<TGlxMediaId> localList; |
|
234 CleanupClosePushL(localList); |
|
235 NGlxDataSourceMdsUtility::CopyItemIdArrayL(localList,iQueries[0]->ResultIds()); |
|
236 PostFilterL(localList, iFilterProperties); |
|
237 CleanupStack::PopAndDestroy(&localList); |
|
238 } |
|
239 } |
|
240 |
|
241 // ---------------------------------------------------------------------------- |
|
242 // CGlxDataSourceTaskMdeIdList::DoMonthListCreationL |
|
243 // ---------------------------------------------------------------------------- |
|
244 // |
|
245 void CGlxDataSourceTaskMdeIdList::DoMonthListCreationL(CMdEQuery& aQuery, |
|
246 const TGlxFilterProperties& aFilterProperties) |
|
247 { |
|
248 TRACER("CGlxDataSourceTaskMdeIdList::DoMonthListCreationL()") |
|
249 CMdEProperty* time; |
|
250 CMdEPropertyDef& creationDateDef = DataSource()->ObjectDef().GetPropertyDefL(KPropertyDefNameCreationDate); |
|
251 if (creationDateDef.PropertyType() != EPropertyTime) |
|
252 { |
|
253 User::Leave(KErrCorrupt); |
|
254 } |
|
255 RArray<TGlxMediaId> monthList; |
|
256 CleanupClosePushL(monthList); |
|
257 TTime lastMonth; |
|
258 TTime currentMonth; |
|
259 TInt count = aQuery.Count(); |
|
260 GLX_DEBUG2("CGlxDataSourceTaskMdeIdList::DoMonthListCreationL count=%d", count); |
|
261 for( TInt i = 0 ; i < count ; i++ ) |
|
262 { |
|
263 CMdEObject& object = (CMdEObject&)aQuery.ResultItem(i); |
|
264 TInt timeIndex = object.Property(creationDateDef, time); |
|
265 if( KErrNotFound == timeIndex ) |
|
266 { |
|
267 User::Leave(KErrCorrupt); |
|
268 } |
|
269 currentMonth = static_cast<CMdETimeProperty*>(time)->Value(); |
|
270 |
|
271 // Also Checking for a Valid Month Entry Based on a Year Greater than 0000. |
|
272 if( !DataSource()->SameMonth(lastMonth, currentMonth) && (currentMonth.DateTime().Year() > 0) ) |
|
273 { |
|
274 const TGlxMediaId monthId = DataSource()->GetMonthIdL(currentMonth); |
|
275 monthList.AppendL(monthId); |
|
276 GLX_DEBUG2("CGlxDataSourceTaskMdeIdList::DoMonthListCreationL monthId=%d", monthId.Value()); |
|
277 lastMonth = currentMonth; |
|
278 } |
|
279 } |
|
280 GLX_DEBUG2("CGlxDataSourceTaskMdeIdList::DoMonthListCreationL monthList.Count=%d", monthList.Count()); |
|
281 PostFilterL(monthList, aFilterProperties); |
|
282 CleanupStack::PopAndDestroy(&monthList); |
|
283 } |
|
284 |
|
285 // ---------------------------------------------------------------------------- |
|
286 // CGlxDataSourceTaskMdeIdList::DoPostFilterComplete |
|
287 // ---------------------------------------------------------------------------- |
|
288 // |
|
289 void CGlxDataSourceTaskMdeIdList::DoPostFilterComplete( |
|
290 const RArray<TGlxMediaId>& aIdArray, TInt aErrorCode) |
|
291 { |
|
292 TRACER("CGlxDataSourceTaskMdeIdList::DoPostFilterComplete()") |
|
293 if (aErrorCode == KErrNone) |
|
294 { |
|
295 TRAP(aErrorCode, ListToMediaL(aIdArray)); |
|
296 } |
|
297 |
|
298 HandleRequestComplete(aErrorCode); |
|
299 } |
|
300 |
|
301 // ---------------------------------------------------------------------------- |
|
302 // CGlxDataSourceTaskMde::PostFilterL |
|
303 // ---------------------------------------------------------------------------- |
|
304 // |
|
305 void CGlxDataSourceTaskMdeIdList::PostFilterL(const RArray<TGlxMediaId>& |
|
306 aFilteredList, const TGlxFilterProperties& aFilterProperties) |
|
307 { |
|
308 TRACER("CGlxDataSourceTaskMdeIdList::PostFilterL()") |
|
309 |
|
310 if( aFilterProperties.iPromoteSystemItems ) |
|
311 { |
|
312 RArray<TGlxMediaId> list = aFilteredList; |
|
313 // Here we don't have to push list in cleanup stack as caller function, |
|
314 // CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL is already |
|
315 // doing that. |
|
316 TInt cameraAlbumIndex = list.Find(DataSource()->CameraAlbumId()); |
|
317 |
|
318 // If Camera Index is not KErrNotFound, 1st Album should be Captured and |
|
319 // 2nd should be Favourites(In Albums List View) |
|
320 |
|
321 if( KErrNotFound != cameraAlbumIndex ) |
|
322 { |
|
323 list.Remove(cameraAlbumIndex); |
|
324 list.InsertL(DataSource()->CameraAlbumId(), KGlxCameraAlbumPromotionPosition); |
|
325 |
|
326 TInt favoritesIndex = list.Find(DataSource()->FavoritesId()); |
|
327 if( KErrNotFound != favoritesIndex ) |
|
328 { |
|
329 list.Remove(favoritesIndex); |
|
330 list.InsertL(DataSource()->FavoritesId(),KGlxfavoritesAlbumPromotionPosition); |
|
331 } |
|
332 } |
|
333 else |
|
334 { |
|
335 // In Selection popup, 1st item should be Favourites(from grid view/fullscreen view |
|
336 // and Camera post captured mode) |
|
337 |
|
338 TInt favoritesIndex = list.Find(DataSource()->FavoritesId()); |
|
339 if( KErrNotFound != favoritesIndex ) |
|
340 { |
|
341 list.Remove(favoritesIndex); |
|
342 list.InsertL(DataSource()->FavoritesId(),KGlxfavoritesAlbumPromotionPosition - 1); |
|
343 } |
|
344 } |
|
345 |
|
346 DoPostFilterComplete(list, KErrNone); |
|
347 } |
|
348 else |
|
349 { |
|
350 DoPostFilterComplete(aFilteredList, KErrNone); |
|
351 } |
|
352 } |