|
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 <glxcollectionpluginalbums.hrh> |
|
29 #include <glxcollectionpluginall.hrh> |
|
30 #include <glxcollectionplugintags.hrh> |
|
31 #include <glxcollectionpluginimageviewer.hrh> |
|
32 |
|
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 <glxtracer.h> |
|
48 #include <lbsposition.h> |
|
49 #include <mdeconstants.h> |
|
50 #include <mdelogiccondition.h> |
|
51 #include <mdeobject.h> |
|
52 #include <mdeobjectdef.h> |
|
53 #include <mdeobjectquery.h> |
|
54 #include <mdepropertydef.h> |
|
55 #include <mderelationdef.h> |
|
56 #include <mdesession.h> |
|
57 #include <mdetextproperty.h> |
|
58 #include <mpxmedia.h> |
|
59 #include <mpxmediaarray.h> |
|
60 #include <mpxmediacollectiondetaildefs.h> |
|
61 #include <mpxmediacontainerdefs.h> |
|
62 #include <mpxmediadrmdefs.h> |
|
63 #include <mpxmediageneraldefs.h> |
|
64 |
|
65 #include "glxdatasourcemds.h" |
|
66 #include "glxdatasourcemds.hrh" |
|
67 #include "glxdatasourcemdsutility.h" |
|
68 |
|
69 // CONSTANTS |
|
70 const TInt KGlxCameraAlbumPromotionPosition = 0; |
|
71 const TInt KGlxfavoritesAlbumPromotionPosition = 1; |
|
72 |
|
73 |
|
74 // ---------------------------------------------------------------------------- |
|
75 // Constructor |
|
76 // ---------------------------------------------------------------------------- |
|
77 // |
|
78 CGlxDataSourceTaskMdeIdList::CGlxDataSourceTaskMdeIdList(CGlxIdListRequest* aRequest, |
|
79 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 #ifdef _DEBUG |
|
115 iStartTime.HomeTime(); |
|
116 #endif |
|
117 CGlxIdListRequest* request = static_cast<CGlxIdListRequest*>(iRequest); |
|
118 TGlxMediaId container = request->ContainerId(); |
|
119 TGlxQueryType queryType = EIdListQuery; |
|
120 TQueryResultMode resultMode = EQueryResultModeId; |
|
121 CMdEObjectDef* objectDef = &DataSource()->ObjectDef(); |
|
122 TBool isContent = ETrue; |
|
123 |
|
124 if( KGlxCollectionRootId == container.Value() ) // The root. |
|
125 { |
|
126 switch(request->CollectionPluginUid().iUid) |
|
127 { |
|
128 |
|
129 case KGlxCollectionPluginAlbumsImplementationUid: |
|
130 { |
|
131 isContent = EFalse; |
|
132 objectDef = &DataSource()->AlbumDef(); |
|
133 break; |
|
134 } |
|
135 case KGlxCollectionPluginCameraImplementationUid: |
|
136 { |
|
137 iFilterProperties.iOrigin = EGlxFilterOriginCamera; |
|
138 break; |
|
139 } |
|
140 case KGlxTagCollectionPluginImplementationUid: |
|
141 { |
|
142 isContent = EFalse; |
|
143 objectDef = &DataSource()->TagDef(); |
|
144 break; |
|
145 } |
|
146 case KGlxCollectionPluginImageViewerImplementationUid: |
|
147 { |
|
148 RArray<TGlxMediaId> list; |
|
149 CleanupClosePushL(list); |
|
150 list.AppendL(TGlxMediaId(request->CollectionPluginUid().iUid)); |
|
151 DoPostFilterComplete(list, KErrNone); |
|
152 CleanupStack::PopAndDestroy(&list); |
|
153 return; |
|
154 } |
|
155 default: |
|
156 { |
|
157 // default gallery query returns all objects as per filter |
|
158 break; |
|
159 } |
|
160 } |
|
161 } |
|
162 else // return the content of a container |
|
163 { |
|
164 switch(request->CollectionPluginUid().iUid) |
|
165 { |
|
166 case KGlxCollectionPluginAlbumsImplementationUid: |
|
167 { |
|
168 objectDef = &DataSource()->AlbumDef(); |
|
169 break; |
|
170 } |
|
171 case KGlxTagCollectionPluginImplementationUid: |
|
172 { |
|
173 objectDef = &DataSource()->TagDef(); |
|
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 TRACER("CGlxDataSourceTaskMdeIdList::DoHandleQueryCompletedL()") |
|
194 __ASSERT_DEBUG(iQueryTypes[0] == EIdListQuery, Panic(EGlxPanicLogicError)); |
|
195 DoHandleListQueryCompletedL(); |
|
196 #ifdef _DEBUG |
|
197 iStopTime.HomeTime(); |
|
198 GLX_DEBUG2("GlxDataSrcTaskMdeIdList:DoHandleQueryCompletedL() took %d us", |
|
199 (TInt)iStopTime.MicroSecondsFrom(iStartTime).Int64()); |
|
200 #endif |
|
201 } |
|
202 |
|
203 // ---------------------------------------------------------------------------- |
|
204 // CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL |
|
205 // ---------------------------------------------------------------------------- |
|
206 // |
|
207 void CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL() |
|
208 { |
|
209 TRACER("CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL()") |
|
210 RArray<TGlxMediaId> localList; |
|
211 CleanupClosePushL(localList); |
|
212 NGlxDataSourceMdsUtility::CopyItemIdArrayL(localList, |
|
213 iQueries[0]->ResultIds()); |
|
214 PostFilterL(localList, iFilterProperties); |
|
215 CleanupStack::PopAndDestroy(&localList); |
|
216 } |
|
217 |
|
218 // ---------------------------------------------------------------------------- |
|
219 // CGlxDataSourceTaskMdeIdList::DoPostFilterComplete |
|
220 // ---------------------------------------------------------------------------- |
|
221 // |
|
222 void CGlxDataSourceTaskMdeIdList::DoPostFilterComplete( |
|
223 const RArray<TGlxMediaId>& aIdArray, TInt aErrorCode) |
|
224 { |
|
225 TRACER("CGlxDataSourceTaskMdeIdList::DoPostFilterComplete()") |
|
226 if (aErrorCode == KErrNone) |
|
227 { |
|
228 TRAP(aErrorCode, ListToMediaL(aIdArray)); |
|
229 } |
|
230 |
|
231 HandleRequestComplete(aErrorCode); |
|
232 } |
|
233 |
|
234 // ---------------------------------------------------------------------------- |
|
235 // CGlxDataSourceTaskMde::PostFilterL |
|
236 // ---------------------------------------------------------------------------- |
|
237 // |
|
238 void CGlxDataSourceTaskMdeIdList::PostFilterL(const RArray<TGlxMediaId>& |
|
239 aFilteredList, const TGlxFilterProperties& aFilterProperties) |
|
240 { |
|
241 TRACER("CGlxDataSourceTaskMdeIdList::PostFilterL()") |
|
242 |
|
243 if( aFilterProperties.iPromoteSystemItems ) |
|
244 { |
|
245 RArray<TGlxMediaId> list = aFilteredList; |
|
246 // Here we don't have to push list in cleanup stack as caller function, |
|
247 // CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL is already |
|
248 // doing that. |
|
249 TInt cameraAlbumIndex = list.Find(DataSource()->CameraAlbumId()); |
|
250 |
|
251 // If Camera Index is not KErrNotFound, 1st Album should be Captured and |
|
252 // 2nd should be Favourites(In Albums List View) |
|
253 |
|
254 if( KErrNotFound != cameraAlbumIndex ) |
|
255 { |
|
256 list.Remove(cameraAlbumIndex); |
|
257 list.InsertL(DataSource()->CameraAlbumId(), KGlxCameraAlbumPromotionPosition); |
|
258 |
|
259 TInt favoritesIndex = list.Find(DataSource()->FavoritesId()); |
|
260 if( KErrNotFound != favoritesIndex ) |
|
261 { |
|
262 list.Remove(favoritesIndex); |
|
263 list.InsertL(DataSource()->FavoritesId(),KGlxfavoritesAlbumPromotionPosition); |
|
264 } |
|
265 } |
|
266 else |
|
267 { |
|
268 // In Selection popup, 1st item should be Favourites(from grid view/fullscreen view |
|
269 // and Camera post captured mode) |
|
270 |
|
271 TInt favoritesIndex = list.Find(DataSource()->FavoritesId()); |
|
272 if( KErrNotFound != favoritesIndex ) |
|
273 { |
|
274 list.Remove(favoritesIndex); |
|
275 list.InsertL(DataSource()->FavoritesId(),KGlxfavoritesAlbumPromotionPosition - 1); |
|
276 } |
|
277 } |
|
278 |
|
279 DoPostFilterComplete(list, KErrNone); |
|
280 } |
|
281 else |
|
282 { |
|
283 DoPostFilterComplete(aFilteredList, KErrNone); |
|
284 } |
|
285 } |