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