|
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 KGlxAlbumPromotionPosition = 0; |
|
72 |
|
73 _LIT(KPropertyDefNameCreationDate, "CreationDate"); |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // Constructor |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 CGlxDataSourceTaskMdeIdList::CGlxDataSourceTaskMdeIdList(CGlxIdListRequest* aRequest, MGlxDataSourceRequestObserver& aObserver, CGlxDataSource* aDataSource) |
|
80 : CGlxDataSourceTaskMde(aRequest, aObserver, aDataSource) |
|
81 { |
|
82 TRACER("CGlxDataSourceTaskMdeIdList::CGlxDataSourceTaskMdeIdList()") |
|
83 iFilterProperties = TGlxFilterFactory::ExtractAttributes(iRequest->Filter()); |
|
84 } |
|
85 |
|
86 // ---------------------------------------------------------------------------- |
|
87 // Destructor |
|
88 // ---------------------------------------------------------------------------- |
|
89 // |
|
90 CGlxDataSourceTaskMdeIdList::~CGlxDataSourceTaskMdeIdList() |
|
91 { |
|
92 TRACER("CGlxDataSourceTaskMdeIdList::~CGlxDataSourceTaskMdeIdList()") |
|
93 // No implementation required |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // CGlxDataSourceTaskMde::FilterAvailableComplete |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 void CGlxDataSourceTaskMdeIdList::FilterAvailableComplete( |
|
101 const RArray<TGlxMediaId>& aIdArray, TInt aErrorCode) |
|
102 { |
|
103 TRACER("CGlxDataSourceTaskMdeIdList::FilterAvailableComplete()") |
|
104 DoPostFilterComplete(aIdArray, aErrorCode); |
|
105 } |
|
106 |
|
107 // ---------------------------------------------------------------------------- |
|
108 // CGlxDataSourceTaskMdeIdList::ExecuteRequestL |
|
109 // ---------------------------------------------------------------------------- |
|
110 // |
|
111 void CGlxDataSourceTaskMdeIdList::ExecuteRequestL() |
|
112 { |
|
113 TRACER("CGlxDataSourceTaskMdeIdList::ExecuteRequestL()") |
|
114 CGlxIdListRequest* request = static_cast<CGlxIdListRequest*>(iRequest); |
|
115 TGlxMediaId container = request->ContainerId(); |
|
116 TGlxQueryType queryType = EIdListQuery; |
|
117 TQueryResultMode resultMode = EQueryResultModeId; |
|
118 CMdEObjectDef* objectDef = &DataSource()->ObjectDef(); |
|
119 TBool isContent = ETrue; |
|
120 |
|
121 if( KGlxCollectionRootId == container.Value() ) // The root. |
|
122 { |
|
123 switch(request->CollectionPluginUid().iUid) |
|
124 { |
|
125 |
|
126 case KGlxCollectionPluginAlbumsImplementationUid: |
|
127 { |
|
128 isContent = EFalse; |
|
129 objectDef = &DataSource()->AlbumDef(); |
|
130 break; |
|
131 } |
|
132 case KGlxCollectionPluginCameraImplementationUid: |
|
133 { |
|
134 iFilterProperties.iOrigin = EGlxFilterOriginCamera; |
|
135 break; |
|
136 } |
|
137 case KGlxTagCollectionPluginImplementationUid: |
|
138 { |
|
139 isContent = EFalse; |
|
140 objectDef = &DataSource()->TagDef(); |
|
141 break; |
|
142 } |
|
143 case KGlxCollectionPluginMonthsImplementationUid: |
|
144 { |
|
145 iFilterProperties.iOrigin = EGlxFilterOriginCamera; |
|
146 container = TGlxMediaId(KGlxCollectionRootId); |
|
147 resultMode = EQueryResultModeObjectWithFreetexts; |
|
148 break; |
|
149 } |
|
150 case KGlxCollectionPluginImageViewerImplementationUid: |
|
151 { |
|
152 RArray<TGlxMediaId> list; |
|
153 CleanupClosePushL(list); |
|
154 list.AppendL(TGlxMediaId(request->CollectionPluginUid().iUid)); |
|
155 DoPostFilterComplete(list, KErrNone); |
|
156 CleanupStack::PopAndDestroy(&list); |
|
157 return; |
|
158 } |
|
159 default: |
|
160 { |
|
161 // default gallery query returns all objects as per filter |
|
162 break; |
|
163 } |
|
164 } |
|
165 } |
|
166 else // return the content of a container |
|
167 { |
|
168 switch(request->CollectionPluginUid().iUid) |
|
169 { |
|
170 case KGlxCollectionPluginAlbumsImplementationUid: |
|
171 { |
|
172 objectDef = &DataSource()->AlbumDef(); |
|
173 break; |
|
174 } |
|
175 case KGlxTagCollectionPluginImplementationUid: |
|
176 { |
|
177 objectDef = &DataSource()->TagDef(); |
|
178 break; |
|
179 } |
|
180 case KGlxCollectionPluginMonthsImplementationUid: |
|
181 { |
|
182 iFilterProperties.iOrigin = EGlxFilterOriginCamera; |
|
183 AddMonthFilterL(container, iFilterProperties); |
|
184 container = TGlxMediaId(KGlxCollectionRootId); |
|
185 break; |
|
186 } |
|
187 default: |
|
188 { |
|
189 User::Leave(KErrNotSupported); |
|
190 break; |
|
191 } |
|
192 } |
|
193 } |
|
194 |
|
195 DoQueryL(*objectDef, isContent, queryType, resultMode, container); |
|
196 } |
|
197 |
|
198 // ---------------------------------------------------------------------------- |
|
199 // CGlxDataSourceTaskMde::DoHandleQueryCompletedL |
|
200 // ---------------------------------------------------------------------------- |
|
201 // |
|
202 void CGlxDataSourceTaskMdeIdList::DoHandleQueryCompletedL(CMdEQuery& /*aQuery*/) |
|
203 { |
|
204 TRACER("CGlxDataSourceTaskMdeIdList::DoHandleQueryCompletedL()") |
|
205 __ASSERT_DEBUG(iQueryTypes[0] == EIdListQuery, Panic(EGlxPanicLogicError)); |
|
206 DoHandleListQueryCompletedL(); |
|
207 } |
|
208 |
|
209 // ---------------------------------------------------------------------------- |
|
210 // CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL |
|
211 // ---------------------------------------------------------------------------- |
|
212 // |
|
213 void CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL() |
|
214 { |
|
215 TRACER("CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL()") |
|
216 if(iQueries[0]->ResultMode() == EQueryResultModeObjectWithFreetexts) |
|
217 { |
|
218 DoMonthListCreationL(*iQueries[0], iFilterProperties); |
|
219 } |
|
220 else // only id or item supported |
|
221 { |
|
222 |
|
223 RArray<TGlxMediaId> localList; |
|
224 CleanupClosePushL(localList); |
|
225 NGlxDataSourceMdsUtility::CopyItemIdArrayL(localList,iQueries[0]->ResultIds()); |
|
226 PostFilterL(localList, iFilterProperties); |
|
227 CleanupStack::PopAndDestroy(&localList); |
|
228 } |
|
229 } |
|
230 |
|
231 // ---------------------------------------------------------------------------- |
|
232 // CGlxDataSourceTaskMdeIdList::DoMonthListCreationL |
|
233 // ---------------------------------------------------------------------------- |
|
234 // |
|
235 void CGlxDataSourceTaskMdeIdList::DoMonthListCreationL(CMdEQuery& aQuery, |
|
236 const TGlxFilterProperties& aFilterProperties) |
|
237 { |
|
238 TRACER("CGlxDataSourceTaskMdeIdList::DoMonthListCreationL()") |
|
239 CMdEProperty* time; |
|
240 CMdEPropertyDef& creationDateDef = DataSource()->ObjectDef().GetPropertyDefL(KPropertyDefNameCreationDate); |
|
241 if (creationDateDef.PropertyType() != EPropertyTime) |
|
242 { |
|
243 User::Leave(KErrCorrupt); |
|
244 } |
|
245 RArray<TGlxMediaId> monthList; |
|
246 CleanupClosePushL(monthList); |
|
247 TTime lastMonth; |
|
248 TTime currentMonth; |
|
249 TInt count = aQuery.Count(); |
|
250 for( TInt i = 0 ; i < count ; i++ ) |
|
251 { |
|
252 CMdEObject& object = (CMdEObject&)aQuery.ResultItem(i); |
|
253 TInt timeIndex = object.Property(creationDateDef, time); |
|
254 if( KErrNotFound == timeIndex ) |
|
255 { |
|
256 User::Leave(KErrCorrupt); |
|
257 } |
|
258 currentMonth = static_cast<CMdETimeProperty*>(time)->Value(); |
|
259 if( !DataSource()->SameMonth(lastMonth, currentMonth) ) |
|
260 { |
|
261 const TGlxMediaId monthId = DataSource()->GetMonthIdL(currentMonth); |
|
262 monthList.AppendL(monthId); |
|
263 lastMonth = currentMonth; |
|
264 } |
|
265 } |
|
266 PostFilterL(monthList, aFilterProperties); |
|
267 CleanupStack::PopAndDestroy(&monthList); |
|
268 } |
|
269 |
|
270 // ---------------------------------------------------------------------------- |
|
271 // CGlxDataSourceTaskMdeIdList::DoPostFilterComplete |
|
272 // ---------------------------------------------------------------------------- |
|
273 // |
|
274 void CGlxDataSourceTaskMdeIdList::DoPostFilterComplete( |
|
275 const RArray<TGlxMediaId>& aIdArray, TInt aErrorCode) |
|
276 { |
|
277 TRACER("CGlxDataSourceTaskMdeIdList::DoPostFilterComplete()") |
|
278 if (aErrorCode == KErrNone) |
|
279 { |
|
280 TRAP(aErrorCode, ListToMediaL(aIdArray)); |
|
281 } |
|
282 |
|
283 HandleRequestComplete(aErrorCode); |
|
284 } |
|
285 |
|
286 // ---------------------------------------------------------------------------- |
|
287 // CGlxDataSourceTaskMde::PostFilterL |
|
288 // ---------------------------------------------------------------------------- |
|
289 // |
|
290 void CGlxDataSourceTaskMdeIdList::PostFilterL(const RArray<TGlxMediaId>& |
|
291 aFilteredList, const TGlxFilterProperties& aFilterProperties) |
|
292 { |
|
293 TRACER("CGlxDataSourceTaskMdeIdList::PostFilterL()") |
|
294 |
|
295 if( aFilterProperties.iPromoteSystemItems ) |
|
296 { |
|
297 RArray<TGlxMediaId> list = aFilteredList; |
|
298 /* |
|
299 TInt favoritesIndex = list.Find(DataSource()->FavoritesId()); |
|
300 if( KErrNotFound != favoritesIndex ) |
|
301 { |
|
302 list.Remove(favoritesIndex); |
|
303 list.Insert(DataSource()->FavoritesId(), KGlxAlbumPromotionPosition); |
|
304 } |
|
305 */ |
|
306 DoPostFilterComplete(list, KErrNone); |
|
307 } |
|
308 else |
|
309 { |
|
310 DoPostFilterComplete(aFilteredList, KErrNone); |
|
311 } |
|
312 } |