|
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: Data Source Task MDS class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 * @internal reviewed 11/07/2007 by M Byrne |
|
23 * @internal reviewed 24/07/2007 by K Hoikka, SCO 403-8472 removal of all view |
|
24 */ |
|
25 |
|
26 #include "glxdatasourcetaskmds.h" |
|
27 |
|
28 #include <glxcollectionplugincamera.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 <glxlog.h> |
|
37 #include <glxmediacollectioninternaldefs.h> |
|
38 #include <glxmediageneraldefs.h> |
|
39 #include <glxrequest.h> |
|
40 #include <glxthumbnailattributeinfo.h> |
|
41 #include <glxthumbnailrequest.h> |
|
42 #include <glxtndatabase.h> |
|
43 #include <glxtnfileinfo.h> |
|
44 #include <glxtnthumbnailcreator.h> |
|
45 #include <glxtracer.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 "glxdatasourcemds.h" |
|
64 #include "glxdatasourcemds.hrh" |
|
65 #include "glxdatasourcemdsutility.h" |
|
66 |
|
67 // CONSTANTS |
|
68 _LIT(KPropertyDefNameCreationDate, "CreationDate"); |
|
69 _LIT(KPropertyDefNameLastModifiedDate, "LastModifiedDate"); |
|
70 _LIT(KPropertyDefNameTitle, "Title"); |
|
71 _LIT(KPropertyDefNameFrameCount, "FrameCount"); |
|
72 _LIT(KPropertyDefNameOrigin, "Origin"); |
|
73 |
|
74 // ---------------------------------------------------------------------------- |
|
75 // Constructor |
|
76 // ---------------------------------------------------------------------------- |
|
77 // |
|
78 CGlxDataSourceTaskMde:: CGlxDataSourceTaskMde(CGlxRequest* aRequest, |
|
79 MGlxDataSourceRequestObserver& aObserver, CGlxDataSource* aDataSource) |
|
80 : CGlxDataSourceTask(aRequest, aObserver, aDataSource) |
|
81 { |
|
82 TRACER("CGlxDataSourceTaskMde::CGlxDataSourceTaskMde()"); |
|
83 // No implementation required |
|
84 } |
|
85 |
|
86 // ---------------------------------------------------------------------------- |
|
87 // Destructor |
|
88 // ---------------------------------------------------------------------------- |
|
89 // |
|
90 CGlxDataSourceTaskMde::~CGlxDataSourceTaskMde() |
|
91 { |
|
92 TRACER("CGlxDataSourceTaskMde::~CGlxDataSourceTaskMde()"); |
|
93 DestroyQueries(); |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // Second stage constructor |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 void CGlxDataSourceTaskMde::ConstructL() |
|
101 { |
|
102 TRACER("CGlxDataSourceTaskMde::ConstructL()"); |
|
103 CreateResponseL(); |
|
104 #ifdef USE_S60_TNM |
|
105 DataSource()->CancelFetchThumbnail(); |
|
106 #else |
|
107 DataSource()->ThumbnailCreator().CancelRequest( TGlxMediaId(0) ); |
|
108 #endif |
|
109 } |
|
110 |
|
111 // ---------------------------------------------------------------------------- |
|
112 // CGlxDataSourceTaskMde::CancelRequest |
|
113 // ---------------------------------------------------------------------------- |
|
114 // |
|
115 void CGlxDataSourceTaskMde::CancelRequest() |
|
116 { |
|
117 TRACER("CGlxDataSourceTaskMde::CancelRequest()"); |
|
118 iCancelled = ETrue; |
|
119 DestroyQueries(); |
|
120 } |
|
121 |
|
122 // ---------------------------------------------------------------------------- |
|
123 // CGlxDataSourceTaskMde::HandleQueryNewResults |
|
124 // ---------------------------------------------------------------------------- |
|
125 // |
|
126 void CGlxDataSourceTaskMde::HandleQueryNewResults( CMdEQuery& /*aQuery*/, |
|
127 TInt /*aFirstNewItemIndex*/, |
|
128 TInt /*aNewItemCount*/ ) |
|
129 { |
|
130 TRACER("CGlxDataSourceTaskMde::HandleQueryNewResults()"); |
|
131 // Not used. |
|
132 } |
|
133 |
|
134 |
|
135 // ---------------------------------------------------------------------------- |
|
136 // CGlxDataSourceTaskMde::HandleQueryNewResults |
|
137 // ---------------------------------------------------------------------------- |
|
138 // |
|
139 void CGlxDataSourceTaskMde::HandleQueryNewResults( CMdEQuery& /*aQuery*/, |
|
140 TInt /*aNewObjectItemCount*/, |
|
141 TInt /*aNewRelationItemCount*/, |
|
142 TInt /*aNewEventItemCount*/) |
|
143 { |
|
144 TRACER("CGlxDataSourceTaskMde::HandleQueryNewResults()"); |
|
145 // Not used. |
|
146 } |
|
147 |
|
148 |
|
149 // ---------------------------------------------------------------------------- |
|
150 // CGlxDataSourceTaskMde::HandleQueryCompleted |
|
151 // ---------------------------------------------------------------------------- |
|
152 // |
|
153 void CGlxDataSourceTaskMde::HandleQueryCompleted(CMdEQuery& aQuery, TInt aError) |
|
154 { |
|
155 TRACER("CGlxDataSourceTaskMde::HandleQueryCompleted()"); |
|
156 __ASSERT_ALWAYS(&aQuery == iQueries[0], Panic(EGlxPanicQueryLogicError)); |
|
157 |
|
158 TInt err = aError; |
|
159 if (err == KErrNone) |
|
160 { |
|
161 TRAP(err, HandleQueryCompletedL(aQuery)); |
|
162 } |
|
163 |
|
164 if (err != KErrNone && !iCancelled) |
|
165 { |
|
166 HandleRequestComplete(err); |
|
167 } |
|
168 } |
|
169 |
|
170 // ---------------------------------------------------------------------------- |
|
171 // CGlxDataSourceTaskMde::DataSource |
|
172 // ---------------------------------------------------------------------------- |
|
173 // |
|
174 CGlxDataSourceMde* CGlxDataSourceTaskMde::DataSource() |
|
175 { |
|
176 TRACER("CGlxDataSourceTaskMde::DataSource()"); |
|
177 return static_cast<CGlxDataSourceMde*>(iDataSource); |
|
178 } |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // CGlxDataSourceTaskMde::SetQueryConditionsL |
|
182 // ---------------------------------------------------------------------------- |
|
183 // |
|
184 void CGlxDataSourceTaskMde::SetQueryConditionsL(CMdEQuery& aQuery, |
|
185 const TGlxFilterProperties& aFilterProperties, const TGlxMediaId aContainerId, |
|
186 CMdEObjectDef& aObjectDef) |
|
187 { |
|
188 TRACER("CGlxDataSourceTaskMde::SetQueryConditionsL()"); |
|
189 |
|
190 CMdELogicCondition& rootCondition = aQuery.Conditions(); |
|
191 CMdEObjectDef* objectDef = &aObjectDef; |
|
192 |
|
193 SetQueryFilterConditionsL(rootCondition, *objectDef, aFilterProperties); |
|
194 |
|
195 if (aQuery.ResultMode() != EQueryResultModeCount) |
|
196 { |
|
197 SetSortOrderL(aQuery, aObjectDef, aFilterProperties); |
|
198 } |
|
199 |
|
200 if( KGlxCollectionRootId != aContainerId.Value() ) |
|
201 { |
|
202 CMdELogicCondition* containerCondition = NULL; |
|
203 CMdERelationCondition* relationCondition = NULL; |
|
204 objectDef = &DataSource()->ObjectDef(); |
|
205 if( DataSource()->ContainerIsLeft(aObjectDef) ) |
|
206 { |
|
207 relationCondition = &rootCondition.AddRelationConditionL( |
|
208 DataSource()->ContainsDef(), ERelationConditionSideRight); |
|
209 containerCondition = &relationCondition->LeftL(); |
|
210 } |
|
211 else |
|
212 { |
|
213 relationCondition = &rootCondition.AddRelationConditionL( |
|
214 DataSource()->ContainsDef(), ERelationConditionSideLeft); |
|
215 containerCondition = &relationCondition->RightL(); |
|
216 } |
|
217 containerCondition->AddObjectConditionL(aContainerId.Value()); |
|
218 } |
|
219 |
|
220 } |
|
221 |
|
222 // ---------------------------------------------------------------------------- |
|
223 // CGlxDataSourceTaskMde::SetQueryFilterConditionsL |
|
224 // ---------------------------------------------------------------------------- |
|
225 // |
|
226 void CGlxDataSourceTaskMde::SetQueryFilterConditionsL(CMdELogicCondition& |
|
227 aLogicCondition, CMdEObjectDef& aObjectDef, |
|
228 const TGlxFilterProperties& aFilterProperties) |
|
229 { |
|
230 TRACER("CGlxDataSourceTaskMde::SetQueryFilterConditionsL()"); |
|
231 |
|
232 if( aFilterProperties.iUri ) |
|
233 { |
|
234 aLogicCondition.AddObjectConditionL(EObjectConditionCompareUri, |
|
235 *aFilterProperties.iUri); |
|
236 } |
|
237 |
|
238 if( 0 == aObjectDef.Compare(DataSource()->ObjectDef()) ) |
|
239 { |
|
240 // Filter on content type |
|
241 if ( EGlxFilterVideoAndImages == aFilterProperties.iItemType ) |
|
242 { |
|
243 CMdELogicCondition& logicCondition = |
|
244 aLogicCondition.AddLogicConditionL(ELogicConditionOperatorOr); |
|
245 logicCondition.AddObjectConditionL( DataSource()->ImageDef() ); |
|
246 logicCondition.AddObjectConditionL( DataSource()->VideoDef() ); |
|
247 } |
|
248 } |
|
249 |
|
250 if( ( aFilterProperties.iMinCount > 0 ) && ( |
|
251 CGlxDataSource::EContainerTypeNotAContainer != DataSource()->ContainerType( |
|
252 &aObjectDef) ) ) |
|
253 { |
|
254 TMdEUintRange range(aFilterProperties.iMinCount, |
|
255 aFilterProperties.iMinCount,EMdERangeTypeGreaterOrEqual); |
|
256 aLogicCondition.AddObjectConditionL(range); |
|
257 } |
|
258 |
|
259 if( 0 != aFilterProperties.iContainsItem.Value() ) |
|
260 { |
|
261 |
|
262 if( DataSource()->ContainerIsLeft(aObjectDef) ) |
|
263 { |
|
264 CMdERelationCondition& relationCondition = |
|
265 aLogicCondition.AddRelationConditionL( |
|
266 DataSource()->ContainsDef(), ERelationConditionSideLeft); |
|
267 relationCondition.RightL().AddObjectConditionL( |
|
268 aFilterProperties.iContainsItem.Value()); |
|
269 } |
|
270 else |
|
271 { |
|
272 CMdERelationCondition& relationCondition = aLogicCondition.AddRelationConditionL( |
|
273 DataSource()->ContainsDef(), ERelationConditionSideRight); |
|
274 relationCondition.LeftL().AddObjectConditionL(aFilterProperties.iContainsItem.Value()); |
|
275 } |
|
276 } |
|
277 |
|
278 if( EGlxFilterOriginNotUsed != aFilterProperties.iOrigin ) |
|
279 { |
|
280 CMdEPropertyDef& originProperty = aObjectDef.GetPropertyDefL(KPropertyDefNameOrigin); |
|
281 if( EGlxFilterOriginDownload == aFilterProperties.iOrigin ) |
|
282 { |
|
283 // The download collection shows all but captured items |
|
284 aLogicCondition.AddPropertyConditionL(originProperty, TMdEUintNotEqual( |
|
285 MdeConstants::Object::ECamera)); |
|
286 } |
|
287 else if(EGlxFilterOriginCamera == aFilterProperties.iOrigin ) |
|
288 { |
|
289 // The camera collection Shows the captured Items |
|
290 aLogicCondition.AddPropertyConditionL(originProperty, TMdEUintEqual( |
|
291 MdeConstants::Object::ECamera)); |
|
292 } |
|
293 else if(EGlxFilterOriginAll == aFilterProperties.iOrigin ) |
|
294 { |
|
295 // Filter for all Images and Videos |
|
296 CMdELogicCondition& logicCondition = |
|
297 aLogicCondition.AddLogicConditionL(ELogicConditionOperatorOr); |
|
298 logicCondition.AddObjectConditionL( DataSource()->ImageDef() ); |
|
299 logicCondition.AddObjectConditionL( DataSource()->VideoDef() ); |
|
300 } |
|
301 } |
|
302 |
|
303 if( aFilterProperties.iExcludeAnimation ) |
|
304 { |
|
305 // Exclude any image with a frame count > 1 |
|
306 const TInt excludeAllImagesAboveOrEqualToThisFrameCount = 2; |
|
307 CMdEPropertyDef& frameCountProperty = DataSource()->ImageDef().GetPropertyDefL( |
|
308 KPropertyDefNameFrameCount); |
|
309 aLogicCondition.AddPropertyConditionL(frameCountProperty, TMdEIntLess( |
|
310 excludeAllImagesAboveOrEqualToThisFrameCount)); |
|
311 } |
|
312 |
|
313 if( aFilterProperties.iNoDRM ) |
|
314 { |
|
315 __ASSERT_DEBUG((EGlxFilterImage == aFilterProperties.iItemType), Panic( |
|
316 EGlxPanicIllegalArgument)); |
|
317 } |
|
318 |
|
319 if( aFilterProperties.iPath ) // If this is set. Then we need to filter on the Ids it supplies |
|
320 { |
|
321 TArray<TInt> selection = aFilterProperties.iPath->Selection(); |
|
322 TInt selectionCount = selection.Count(); |
|
323 RArray<TItemId> itemList; |
|
324 CleanupClosePushL(itemList); |
|
325 GLX_DEBUG2("Reading Ids from Path, count = %d", selectionCount); |
|
326 if( selectionCount ) |
|
327 { |
|
328 for( TInt i = 0; i < selectionCount; i++ ) |
|
329 { |
|
330 const TMPXItemId& itemId = aFilterProperties.iPath->IdOfIndex(selection[i]); |
|
331 itemList.AppendL(itemId); |
|
332 } |
|
333 aLogicCondition.AddObjectConditionL(itemList); |
|
334 } |
|
335 CleanupStack::Pop(&itemList); |
|
336 } |
|
337 |
|
338 if( !aFilterProperties.iIncludeCameraAlbum ) |
|
339 { |
|
340 CMdEObjectCondition& objectCondition = aLogicCondition.AddObjectConditionL( |
|
341 DataSource()->CameraAlbumId().Value()); |
|
342 objectCondition.SetNegate(ETrue); |
|
343 } |
|
344 |
|
345 if( TTime(0) != aFilterProperties.iStartDate ) |
|
346 { |
|
347 CMdEPropertyDef& creationDateDef = aObjectDef.GetPropertyDefL( |
|
348 KPropertyDefNameCreationDate); |
|
349 if (creationDateDef.PropertyType() != EPropertyTime) |
|
350 { |
|
351 User::Leave(KErrCorrupt); |
|
352 } |
|
353 |
|
354 aLogicCondition.AddPropertyConditionL(creationDateDef, TMdETimeBetween( |
|
355 aFilterProperties.iStartDate, aFilterProperties.iEndDate)); |
|
356 } |
|
357 } |
|
358 |
|
359 // ---------------------------------------------------------------------------- |
|
360 // CGlxDataSourceTaskMde::SetSortOrderL |
|
361 // ---------------------------------------------------------------------------- |
|
362 // |
|
363 void CGlxDataSourceTaskMde::SetSortOrderL(CMdEQuery& aQuery, CMdEObjectDef& aObjectDef, |
|
364 const TGlxFilterProperties& aFilterProperties) |
|
365 { |
|
366 TRACER("CGlxDataSourceTaskMde::SetSortOrderL()"); |
|
367 switch(aFilterProperties.iSortOrder) |
|
368 { |
|
369 case EGlxFilterSortOrderAlphabetical: |
|
370 { |
|
371 CMdEPropertyDef& titleProperty = aObjectDef.GetPropertyDefL(KPropertyDefNameTitle); |
|
372 TMdEOrderRule orderRule(titleProperty, aFilterProperties.iSortDirection == |
|
373 EGlxFilterSortDirectionAscending); |
|
374 orderRule.SetType(EOrderRuleTypeProperty); |
|
375 orderRule.SetCaseSensitive(EFalse); |
|
376 aQuery.AppendOrderRuleL(orderRule); |
|
377 break; |
|
378 } |
|
379 case EGlxFilterSortOrderItemCount: |
|
380 { |
|
381 //Order rule is needed for tags popularity |
|
382 TMdEOrderRule orderRule(EOrderRuleTypeUsageCount, aFilterProperties.iSortDirection == |
|
383 EGlxFilterSortDirectionAscending); |
|
384 aQuery.AppendOrderRuleL(orderRule); |
|
385 break; |
|
386 } |
|
387 case EGlxFilterSortOrderCaptureDate: |
|
388 { |
|
389 CMdEPropertyDef& creationDateProperty = aObjectDef.GetPropertyDefL( |
|
390 KPropertyDefNameCreationDate); |
|
391 TMdEOrderRule orderRule(creationDateProperty, aFilterProperties.iSortDirection == |
|
392 EGlxFilterSortDirectionAscending); |
|
393 orderRule.SetType(EOrderRuleTypeProperty); |
|
394 aQuery.AppendOrderRuleL(orderRule); |
|
395 TMdEOrderRule orderRule2(EOrderRuleTypeItemID, aFilterProperties.iSortDirection == |
|
396 EGlxFilterSortDirectionAscending); |
|
397 aQuery.AppendOrderRuleL(orderRule2); |
|
398 break; |
|
399 } |
|
400 case EGlxFilterSortOrderModifiedDate: |
|
401 { |
|
402 CMdEPropertyDef& modifiedDateProperty = aObjectDef.GetPropertyDefL( |
|
403 KPropertyDefNameLastModifiedDate); |
|
404 TMdEOrderRule orderRule(modifiedDateProperty, aFilterProperties.iSortDirection == |
|
405 EGlxFilterSortDirectionAscending); |
|
406 orderRule.SetType(EOrderRuleTypeProperty); |
|
407 aQuery.AppendOrderRuleL(orderRule); |
|
408 TMdEOrderRule orderRule2(EOrderRuleTypeItemID, aFilterProperties.iSortDirection == |
|
409 EGlxFilterSortDirectionAscending); |
|
410 aQuery.AppendOrderRuleL(orderRule2); |
|
411 break; |
|
412 } |
|
413 case EGlxFilterSortOrderNotUsed: |
|
414 { |
|
415 break; |
|
416 } |
|
417 } |
|
418 } |
|
419 |
|
420 // ---------------------------------------------------------------------------- |
|
421 // CGlxDataSourceTaskMde::MaxQueryResultsCount |
|
422 // ---------------------------------------------------------------------------- |
|
423 // |
|
424 TInt CGlxDataSourceTaskMde::MaxQueryResultsCount(const TGlxFilterProperties& |
|
425 aFilterProperties) const |
|
426 { |
|
427 TRACER("CGlxDataSourceTaskMde::MaxQueryResultsCount()"); |
|
428 TInt ret = KMdEQueryDefaultMaxCount; |
|
429 if (aFilterProperties.iLastCaptureDate || aFilterProperties.iMaxCount == 1) |
|
430 { |
|
431 ret = 1; |
|
432 } |
|
433 GLX_DEBUG2("CGlxDataSourceTaskMde::MaxQueryResultsCount ret=%d", ret); |
|
434 return ret; |
|
435 } |
|
436 |
|
437 // ---------------------------------------------------------------------------- |
|
438 // CGlxDataSourceTaskMde::RemoveQuery |
|
439 // ---------------------------------------------------------------------------- |
|
440 // |
|
441 void CGlxDataSourceTaskMde::RemoveQuery() |
|
442 { |
|
443 TRACER("CGlxDataSourceTaskMde::RemoveQuery()"); |
|
444 CMdEQuery* query = iQueries[0]; |
|
445 iQueryTypes.Remove(0); |
|
446 iQueries.Remove(0); |
|
447 query->RemoveObserver(*this); |
|
448 delete query; |
|
449 } |
|
450 |
|
451 // ---------------------------------------------------------------------------- |
|
452 // CGlxDataSourceTaskMde::DoQueryL |
|
453 // ---------------------------------------------------------------------------- |
|
454 // |
|
455 void CGlxDataSourceTaskMde::DoQueryL(CMdEObjectDef& aObjectDef, |
|
456 TBool aIsContent, TGlxQueryType aQueryType, TQueryResultMode aResultMode, |
|
457 const TGlxMediaId& aContainerId) |
|
458 { |
|
459 TRACER("CGlxDataSourceTaskMde::DoQueryL()"); |
|
460 |
|
461 CMdEObjectDef* queryBaseObject = &aObjectDef; |
|
462 if( aIsContent ) |
|
463 { |
|
464 switch(iFilterProperties.iItemType) |
|
465 { |
|
466 case EGlxFilterImage: |
|
467 { |
|
468 queryBaseObject = &DataSource()->ImageDef(); |
|
469 break; |
|
470 } |
|
471 case EGlxFilterVideo: |
|
472 { |
|
473 queryBaseObject = &DataSource()->VideoDef(); |
|
474 break; |
|
475 } |
|
476 default: |
|
477 { |
|
478 queryBaseObject = &DataSource()->ObjectDef(); |
|
479 break; |
|
480 } |
|
481 } |
|
482 } |
|
483 |
|
484 CMdEQuery* query = DataSource()->Session().NewObjectQueryL(*DataSource()->NamespaceDef(), |
|
485 *queryBaseObject, this); |
|
486 CleanupStack::PushL(query); |
|
487 |
|
488 query->SetResultMode(aResultMode); |
|
489 SetQueryConditionsL(*query, iFilterProperties, aContainerId, aObjectDef); |
|
490 |
|
491 CleanupStack::Pop(query); |
|
492 |
|
493 AppendQueryL(query, aQueryType); |
|
494 |
|
495 query->FindL(MaxQueryResultsCount(iFilterProperties)); |
|
496 } |
|
497 |
|
498 // ---------------------------------------------------------------------------- |
|
499 // CGlxDataSourceTask::QueueImageVideoObjectQueriesL |
|
500 // ---------------------------------------------------------------------------- |
|
501 // |
|
502 void CGlxDataSourceTaskMde::QueueImageVideoObjectQueriesL(const RArray<TGlxMediaId>& aObjectIds, |
|
503 const TGlxFilterProperties& aFilterProperties) |
|
504 { |
|
505 TRACER("CGlxDataSourceTaskMde::QueueImageVideoObjectQueriesL()"); |
|
506 if (aFilterProperties.iItemType == EGlxFilterImage) |
|
507 { |
|
508 // Only perform the image query |
|
509 QueueObjectQueryL(DataSource()->ImageDef(), aObjectIds, EImageVideoQuery); |
|
510 } |
|
511 else if (aFilterProperties.iItemType == EGlxFilterVideo) |
|
512 { |
|
513 // Only perform the video query |
|
514 QueueObjectQueryL(DataSource()->VideoDef(), aObjectIds, EImageVideoQuery); |
|
515 } |
|
516 else |
|
517 { |
|
518 QueueObjectQueryL(DataSource()->ImageDef(), aObjectIds, EImageVideoQuery); |
|
519 QueueObjectQueryL(DataSource()->VideoDef(), aObjectIds, EImageVideoQuery); |
|
520 // Perform both the image and video queries |
|
521 } |
|
522 } |
|
523 |
|
524 // ---------------------------------------------------------------------------- |
|
525 // CGlxDataSourceTask::QueueTagObjectQueryL |
|
526 // ---------------------------------------------------------------------------- |
|
527 // |
|
528 void CGlxDataSourceTaskMde::QueueTagObjectQueryL(const RArray<TGlxMediaId>& aObjectIds) |
|
529 { |
|
530 TRACER("CGlxDataSourceTaskMde::QueueTagObjectQueryL()"); |
|
531 QueueObjectQueryL(DataSource()->TagDef(), aObjectIds, EImageVideoQuery); |
|
532 } |
|
533 |
|
534 // ---------------------------------------------------------------------------- |
|
535 // CGlxDataSourceTask::QueueAlbumObjectQueryL |
|
536 // ---------------------------------------------------------------------------- |
|
537 // |
|
538 void CGlxDataSourceTaskMde::QueueAlbumObjectQueryL(const RArray<TGlxMediaId>& aObjectIds) |
|
539 { |
|
540 TRACER("CGlxDataSourceTaskMde::QueueAlbumObjectQueryL()"); |
|
541 QueueObjectQueryL(DataSource()->AlbumDef(), aObjectIds, EImageVideoQuery); |
|
542 } |
|
543 |
|
544 // ---------------------------------------------------------------------------- |
|
545 // CGlxDataSourceTask::QueueObjectQueryL |
|
546 // ---------------------------------------------------------------------------- |
|
547 // |
|
548 void CGlxDataSourceTaskMde::QueueObjectQueryL(CMdEObjectDef& aObjectDef, |
|
549 const RArray<TGlxMediaId>& aObjectIds, const TGlxQueryType& aQueryType) |
|
550 { |
|
551 TRACER("CGlxDataSourceTaskMde::QueueObjectQueryL()"); |
|
552 CMdEQuery* query = DataSource()->Session().NewObjectQueryL(*DataSource()->NamespaceDef(), |
|
553 aObjectDef, this); |
|
554 CleanupStack::PushL(query); |
|
555 |
|
556 CMdELogicCondition& lc = query->Conditions(); |
|
557 NGlxDataSourceMdsUtility::AddObjectConditionL(lc,aObjectIds); |
|
558 |
|
559 query->SetResultMode(EQueryResultModeItem); |
|
560 |
|
561 CleanupStack::Pop(query); |
|
562 AppendQueryL(query, aQueryType); |
|
563 |
|
564 } |
|
565 |
|
566 // ---------------------------------------------------------------------------- |
|
567 // CGlxDataSourceTaskMde::AppendQueryL |
|
568 // ---------------------------------------------------------------------------- |
|
569 // |
|
570 void CGlxDataSourceTaskMde::AppendQueryL(CMdEQuery* aQuery, const TGlxQueryType& aQueryType) |
|
571 { |
|
572 TRACER("CGlxDataSourceTaskMde::AppendQueryL()"); |
|
573 CleanupStack::PushL(aQuery); |
|
574 |
|
575 TInt err = iQueryTypes.Append(aQueryType); |
|
576 |
|
577 if (KErrNone == err) |
|
578 { |
|
579 iQueries.AppendL(aQuery); |
|
580 CleanupStack::Pop(aQuery); |
|
581 } |
|
582 else |
|
583 { |
|
584 User::Leave(err); |
|
585 } |
|
586 } |
|
587 |
|
588 // ---------------------------------------------------------------------------- |
|
589 // CGlxDataSourceTaskMde::ExecuteQueryL |
|
590 // ---------------------------------------------------------------------------- |
|
591 // |
|
592 void CGlxDataSourceTaskMde::ExecuteQueryL() |
|
593 { |
|
594 TRACER("CGlxDataSourceTaskMde::ExecuteQueryL()"); |
|
595 __ASSERT_DEBUG(iQueries.Count(), Panic(EGlxPanicQueryLogicError)); |
|
596 iQueries[0]->FindL(); |
|
597 } |
|
598 |
|
599 // ---------------------------------------------------------------------------- |
|
600 // CGlxDataSourceTaskMde::HandleQueryCompletedL |
|
601 // ---------------------------------------------------------------------------- |
|
602 // |
|
603 void CGlxDataSourceTaskMde::HandleQueryCompletedL(CMdEQuery& aQuery) |
|
604 { |
|
605 TRACER("CGlxDataSourceTaskMde::HandleQueryCompletedL()"); |
|
606 DoHandleQueryCompletedL(aQuery); |
|
607 |
|
608 // Both the function calls should be executed if any |
|
609 // request is not cancelled before completion. |
|
610 // All the pending Queries are already destroyed in CancelRequest. |
|
611 // Hence we do not have to call RemoveQuery here. That will lead to |
|
612 // User 130 crash. |
|
613 // DoNextQuery tries to get iQueries.Count(). Since iQueries is destroyed |
|
614 // in CancelRequest |
|
615 if (iCancelled) |
|
616 { |
|
617 GLX_LOG_INFO("***Query already Removed. Hence Return***"); |
|
618 return; |
|
619 } |
|
620 RemoveQuery(); |
|
621 DoNextQueryL(); |
|
622 } |
|
623 |
|
624 // ---------------------------------------------------------------------------- |
|
625 // CGlxDataSourceTaskMde::DestroyQueries |
|
626 // ---------------------------------------------------------------------------- |
|
627 // |
|
628 void CGlxDataSourceTaskMde::DestroyQueries() |
|
629 { |
|
630 TRACER("CGlxDataSourceTaskMde::DestroyQueries()"); |
|
631 for (TInt i = 0; i < iQueries.Count(); i++) |
|
632 { |
|
633 // Ensure that there are not any running queries |
|
634 iQueries[i]->RemoveObserver(*this); |
|
635 iQueries[i]->Cancel(); |
|
636 } |
|
637 iQueries.ResetAndDestroy(); |
|
638 iQueryTypes.Close(); |
|
639 } |
|
640 |
|
641 |
|
642 |