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