|
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: The Data Source Task MDS IDlist class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 * @internal reviewed 11/07/2007 by M Byrne |
|
23 */ |
|
24 |
|
25 #include "glxdatasourcetaskmdsidlist.h" |
|
26 |
|
27 #include <glxcollectionplugincamera.hrh> |
|
28 #include <glxcollectionplugindownloads.hrh> |
|
29 #include <glxcollectionpluginmonths.hrh> |
|
30 #include <glxcollectionpluginalbums.hrh> |
|
31 #include <glxcollectionpluginall.hrh> |
|
32 #include <glxcollectionplugintags.hrh> |
|
33 #include <glxcollectionpluginimageviewer.hrh> |
|
34 |
|
35 #include <glxerrors.h> |
|
36 #include <glxfilterfactory.h> |
|
37 #include <glxgetrequest.h> |
|
38 #include <glxidlistrequest.h> |
|
39 #include <glxidlistrequest.h> |
|
40 #include <glxlog.h> |
|
41 #include <glxmediacollectioninternaldefs.h> |
|
42 #include <glxmediageneraldefs.h> |
|
43 #include <glxrequest.h> |
|
44 #include <glxthumbnailattributeinfo.h> |
|
45 #include <glxthumbnailrequest.h> |
|
46 #include <glxtndatabase.h> |
|
47 #include <glxtnfileinfo.h> |
|
48 #include <glxtnthumbnailcreator.h> |
|
49 #include <glxtracer.h> |
|
50 #include <lbsposition.h> |
|
51 #include <mdeconstants.h> |
|
52 #include <mdelogiccondition.h> |
|
53 #include <mdeobject.h> |
|
54 #include <mdeobjectdef.h> |
|
55 #include <mdeobjectquery.h> |
|
56 #include <mdepropertydef.h> |
|
57 #include <mderelationdef.h> |
|
58 #include <mdesession.h> |
|
59 #include <mdetextproperty.h> |
|
60 #include <mpxmedia.h> |
|
61 #include <mpxmediaarray.h> |
|
62 #include <mpxmediacollectiondetaildefs.h> |
|
63 #include <mpxmediacontainerdefs.h> |
|
64 #include <mpxmediadrmdefs.h> |
|
65 #include <mpxmediageneraldefs.h> |
|
66 |
|
67 #include "glxdatasourcemds.h" |
|
68 #include "glxdatasourcemds.hrh" |
|
69 #include "glxdatasourcemdsutility.h" |
|
70 |
|
71 // CONSTANTS |
|
72 //const TInt KGlxAlbumPromotionPosition = 0; |
|
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 CGlxIdListRequest* request = static_cast<CGlxIdListRequest*>(iRequest); |
|
117 TGlxMediaId container = request->ContainerId(); |
|
118 TGlxQueryType queryType = EIdListQuery; |
|
119 TQueryResultMode resultMode = EQueryResultModeId; |
|
120 CMdEObjectDef* objectDef = &DataSource()->ObjectDef(); |
|
121 TBool isContent = ETrue; |
|
122 |
|
123 if( KGlxCollectionRootId == container.Value() ) // The root. |
|
124 { |
|
125 switch(request->CollectionPluginUid().iUid) |
|
126 { |
|
127 |
|
128 case KGlxCollectionPluginAlbumsImplementationUid: |
|
129 { |
|
130 isContent = EFalse; |
|
131 objectDef = &DataSource()->AlbumDef(); |
|
132 break; |
|
133 } |
|
134 case KGlxCollectionPluginCameraImplementationUid: |
|
135 { |
|
136 iFilterProperties.iOrigin = EGlxFilterOriginCamera; |
|
137 break; |
|
138 } |
|
139 case KGlxTagCollectionPluginImplementationUid: |
|
140 { |
|
141 isContent = EFalse; |
|
142 objectDef = &DataSource()->TagDef(); |
|
143 break; |
|
144 } |
|
145 case KGlxCollectionPluginMonthsImplementationUid: |
|
146 { |
|
147 iFilterProperties.iOrigin = EGlxFilterOriginAll; |
|
148 container = TGlxMediaId(KGlxCollectionRootId); |
|
149 resultMode = EQueryResultModeItem; |
|
150 break; |
|
151 } |
|
152 case KGlxCollectionPluginImageViewerImplementationUid: |
|
153 { |
|
154 RArray<TGlxMediaId> list; |
|
155 CleanupClosePushL(list); |
|
156 list.AppendL(TGlxMediaId(request->CollectionPluginUid().iUid)); |
|
157 DoPostFilterComplete(list, KErrNone); |
|
158 CleanupStack::PopAndDestroy(&list); |
|
159 return; |
|
160 } |
|
161 default: |
|
162 { |
|
163 // default gallery query returns all objects as per filter |
|
164 break; |
|
165 } |
|
166 } |
|
167 } |
|
168 else // return the content of a container |
|
169 { |
|
170 switch(request->CollectionPluginUid().iUid) |
|
171 { |
|
172 case KGlxCollectionPluginAlbumsImplementationUid: |
|
173 { |
|
174 objectDef = &DataSource()->AlbumDef(); |
|
175 break; |
|
176 } |
|
177 case KGlxTagCollectionPluginImplementationUid: |
|
178 { |
|
179 objectDef = &DataSource()->TagDef(); |
|
180 break; |
|
181 } |
|
182 case KGlxCollectionPluginMonthsImplementationUid: |
|
183 { |
|
184 iFilterProperties.iOrigin = EGlxFilterOriginAll; |
|
185 AddMonthFilterL(container, iFilterProperties); |
|
186 container = TGlxMediaId(KGlxCollectionRootId); |
|
187 break; |
|
188 } |
|
189 default: |
|
190 { |
|
191 User::Leave(KErrNotSupported); |
|
192 break; |
|
193 } |
|
194 } |
|
195 } |
|
196 |
|
197 DoQueryL(*objectDef, isContent, queryType, resultMode, container); |
|
198 } |
|
199 |
|
200 // ---------------------------------------------------------------------------- |
|
201 // CGlxDataSourceTaskMde::DoHandleQueryCompletedL |
|
202 // ---------------------------------------------------------------------------- |
|
203 // |
|
204 void CGlxDataSourceTaskMdeIdList::DoHandleQueryCompletedL(CMdEQuery& /*aQuery*/) |
|
205 { |
|
206 TRACER("CGlxDataSourceTaskMdeIdList::DoHandleQueryCompletedL()") |
|
207 __ASSERT_DEBUG(iQueryTypes[0] == EIdListQuery, Panic(EGlxPanicLogicError)); |
|
208 DoHandleListQueryCompletedL(); |
|
209 } |
|
210 |
|
211 // ---------------------------------------------------------------------------- |
|
212 // CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL |
|
213 // ---------------------------------------------------------------------------- |
|
214 // |
|
215 void CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL() |
|
216 { |
|
217 TRACER("CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL()") |
|
218 if(iQueries[0]->ResultMode() == EQueryResultModeItem) |
|
219 { |
|
220 DoMonthListCreationL(*iQueries[0], iFilterProperties); |
|
221 } |
|
222 else // only id or item supported |
|
223 { |
|
224 |
|
225 RArray<TGlxMediaId> localList; |
|
226 CleanupClosePushL(localList); |
|
227 NGlxDataSourceMdsUtility::CopyItemIdArrayL(localList,iQueries[0]->ResultIds()); |
|
228 PostFilterL(localList, iFilterProperties); |
|
229 CleanupStack::PopAndDestroy(&localList); |
|
230 } |
|
231 } |
|
232 |
|
233 // ---------------------------------------------------------------------------- |
|
234 // CGlxDataSourceTaskMdeIdList::DoMonthListCreationL |
|
235 // ---------------------------------------------------------------------------- |
|
236 // |
|
237 void CGlxDataSourceTaskMdeIdList::DoMonthListCreationL(CMdEQuery& aQuery, |
|
238 const TGlxFilterProperties& aFilterProperties) |
|
239 { |
|
240 TRACER("CGlxDataSourceTaskMdeIdList::DoMonthListCreationL()") |
|
241 CMdEProperty* time; |
|
242 CMdEPropertyDef& creationDateDef = DataSource()->ObjectDef().GetPropertyDefL(KPropertyDefNameCreationDate); |
|
243 if (creationDateDef.PropertyType() != EPropertyTime) |
|
244 { |
|
245 User::Leave(KErrCorrupt); |
|
246 } |
|
247 RArray<TGlxMediaId> monthList; |
|
248 CleanupClosePushL(monthList); |
|
249 TTime lastMonth; |
|
250 TTime currentMonth; |
|
251 TInt count = aQuery.Count(); |
|
252 for( TInt i = 0 ; i < count ; i++ ) |
|
253 { |
|
254 CMdEObject& object = (CMdEObject&)aQuery.ResultItem(i); |
|
255 TInt timeIndex = object.Property(creationDateDef, time); |
|
256 if( KErrNotFound == timeIndex ) |
|
257 { |
|
258 User::Leave(KErrCorrupt); |
|
259 } |
|
260 currentMonth = static_cast<CMdETimeProperty*>(time)->Value(); |
|
261 if( !DataSource()->SameMonth(lastMonth, currentMonth) ) |
|
262 { |
|
263 const TGlxMediaId monthId = DataSource()->GetMonthIdL(currentMonth); |
|
264 monthList.AppendL(monthId); |
|
265 lastMonth = currentMonth; |
|
266 } |
|
267 } |
|
268 PostFilterL(monthList, aFilterProperties); |
|
269 CleanupStack::PopAndDestroy(&monthList); |
|
270 } |
|
271 |
|
272 // ---------------------------------------------------------------------------- |
|
273 // CGlxDataSourceTaskMdeIdList::DoPostFilterComplete |
|
274 // ---------------------------------------------------------------------------- |
|
275 // |
|
276 void CGlxDataSourceTaskMdeIdList::DoPostFilterComplete( |
|
277 const RArray<TGlxMediaId>& aIdArray, TInt aErrorCode) |
|
278 { |
|
279 TRACER("CGlxDataSourceTaskMdeIdList::DoPostFilterComplete()") |
|
280 if (aErrorCode == KErrNone) |
|
281 { |
|
282 TRAP(aErrorCode, ListToMediaL(aIdArray)); |
|
283 } |
|
284 |
|
285 HandleRequestComplete(aErrorCode); |
|
286 } |
|
287 |
|
288 // ---------------------------------------------------------------------------- |
|
289 // CGlxDataSourceTaskMde::PostFilterL |
|
290 // ---------------------------------------------------------------------------- |
|
291 // |
|
292 void CGlxDataSourceTaskMdeIdList::PostFilterL(const RArray<TGlxMediaId>& |
|
293 aFilteredList, const TGlxFilterProperties& aFilterProperties) |
|
294 { |
|
295 TRACER("CGlxDataSourceTaskMdeIdList::PostFilterL()") |
|
296 |
|
297 if( aFilterProperties.iPromoteSystemItems ) |
|
298 { |
|
299 RArray<TGlxMediaId> list = aFilteredList; |
|
300 /* |
|
301 TInt favoritesIndex = list.Find(DataSource()->FavoritesId()); |
|
302 if( KErrNotFound != favoritesIndex ) |
|
303 { |
|
304 list.Remove(favoritesIndex); |
|
305 list.Insert(DataSource()->FavoritesId(), KGlxAlbumPromotionPosition); |
|
306 } |
|
307 */ |
|
308 DoPostFilterComplete(list, KErrNone); |
|
309 } |
|
310 else |
|
311 { |
|
312 DoPostFilterComplete(aFilteredList, KErrNone); |
|
313 } |
|
314 } |