|
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: Thumbnail Composer plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 * @internal reviewed 12/07/2007 by Simon Brooks |
|
23 */ |
|
24 |
|
25 #include <e32base.h> |
|
26 |
|
27 #include <MdELogicCondition.h> |
|
28 #include <mdeconstants.h> |
|
29 |
|
30 #include <mpxcollectionutility.h> |
|
31 #include <mpxcollectionpath.h> |
|
32 #include <mpxcollectionmessage.h> |
|
33 #include <mpxmessagegeneraldefs.h> |
|
34 #include <mpxcollectionframeworkdefs.h> |
|
35 |
|
36 #include <glxassert.h> |
|
37 #include <glxcollectionpluginall.hrh> |
|
38 #include <glxthumbnailattributeinfo.h> |
|
39 #include <glxbackgroundtnmessagedefs.h> |
|
40 #include <glxmediaid.h> |
|
41 #include <glxthumbnailinfo.h> |
|
42 #include <glxfilterfactory.h> |
|
43 #include <glxcommandfactory.h> |
|
44 #include <glxtracer.h> |
|
45 #include <hal.h> |
|
46 |
|
47 #include "glxthumbnailcomposerplugin.h" |
|
48 |
|
49 // This can be any number other than zero |
|
50 const TUint KGlxBackgroundThumbnailAttributeId = 1; |
|
51 const TInt KGlxThumbnailComposerInactivityTimeout = 30; // seconds |
|
52 const TInt KGlxThumbnailComposerDelay = 10000; // microseconds |
|
53 const TInt KGlxThumbnailComposerHarvestDelay = 5000000; // microseconds |
|
54 const TInt KGlxThumbnailComposerLargeDelay = 30000000; // microseconds |
|
55 const TInt KGlxDisplayStatusTimeOutDelay = 5000000; // 5 secs |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // destructor |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CGlxThumbnailCompeserInactivityTimer::~CGlxThumbnailCompeserInactivityTimer() |
|
62 { |
|
63 // no implementation |
|
64 } |
|
65 |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // NewL |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CGlxThumbnailCompeserInactivityTimer* CGlxThumbnailCompeserInactivityTimer::NewL(TInt aPriority, CGlxThumbnailComposerPlugin& aCallback) |
|
72 { |
|
73 TRACER("CGlxThumbnailCompeserInactivityTimer::NewL"); |
|
74 CGlxThumbnailCompeserInactivityTimer* self = |
|
75 new (ELeave) CGlxThumbnailCompeserInactivityTimer(aPriority, aCallback); |
|
76 CleanupStack::PushL(self); |
|
77 self->ConstructL(); |
|
78 CleanupStack::Pop(self); |
|
79 CActiveScheduler::Add(self); |
|
80 return self; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // After |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CGlxThumbnailCompeserInactivityTimer::After( TTimeIntervalMicroSeconds32 aInterval ) |
|
88 { |
|
89 TRACER("CGlxThumbnailCompeserInactivityTimer::After"); |
|
90 |
|
91 // Fix for ELLZ-7DBBDZ and JPKN-7M2AYJ: to prevent a KERN EXEC 15 panic that occurs |
|
92 // if a timer request is made while one is already outstanding. |
|
93 Cancel(); |
|
94 // Forward the call on to the base class. |
|
95 CTimer::After( aInterval ); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // constructor |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 CGlxThumbnailCompeserInactivityTimer::CGlxThumbnailCompeserInactivityTimer(TInt aPriority, CGlxThumbnailComposerPlugin& aCallback) |
|
103 : CTimer(aPriority), iCallback(aCallback) |
|
104 { |
|
105 // no implementation |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // RunL |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 void CGlxThumbnailCompeserInactivityTimer::RunL() |
|
113 { |
|
114 TRACER("CGlxThumbnailCompeserInactivityTimer::RunL"); |
|
115 |
|
116 TInt dispState = KErrNotFound; |
|
117 TInt ret = HAL::Get(HALData::EDisplayState, dispState); |
|
118 GLX_DEBUG4("CGlxThumbnailCompeserInactivityTimer::RunL iCallback.iState = %d, ret=%d, dispState= %d", |
|
119 iCallback.iState, ret, dispState ); |
|
120 if (iCallback.iState && ret == KErrNone && dispState) |
|
121 { |
|
122 iCallback.DelayDisplayStateCheck(); |
|
123 GLX_LOG_INFO("GlxThumbnailCompeser - DISPLAY ON - DO NOT PROCESS" ); |
|
124 return; |
|
125 } |
|
126 |
|
127 GLX_LOG_INFO("GlxThumbnailCompeser - DISPLAY OFF - ALLOW TO PROCESS" ); |
|
128 |
|
129 switch (iCallback.iState) |
|
130 { |
|
131 case CGlxThumbnailComposerPlugin::EStateFirstOpening: |
|
132 case CGlxThumbnailComposerPlugin::EStateOpening: |
|
133 { |
|
134 iCallback.DoOpenCollectionL(); |
|
135 break; |
|
136 } |
|
137 case CGlxThumbnailComposerPlugin::EStateActiveSmall: |
|
138 case CGlxThumbnailComposerPlugin::EStateActiveLarge: |
|
139 { |
|
140 iCallback.DoRequestItemL(); |
|
141 break; |
|
142 } |
|
143 case CGlxThumbnailComposerPlugin::EStateClosing: |
|
144 { |
|
145 iCallback.CloseCollection(); |
|
146 break; |
|
147 } |
|
148 } |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // DoCancel |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CGlxThumbnailCompeserInactivityTimer::DoCancel() |
|
156 { |
|
157 // no implementation |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // RunError |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 TInt CGlxThumbnailCompeserInactivityTimer::RunError(TInt /*aError*/) |
|
165 { |
|
166 TRACER("CGlxThumbnailCompeserInactivityTimer::RunError"); |
|
167 iCallback.ReturnToIdle(); |
|
168 return KErrNone; |
|
169 } |
|
170 |
|
171 |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // NewL |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 CGlxThumbnailComposerPlugin* CGlxThumbnailComposerPlugin::NewL() |
|
178 { |
|
179 TRACER("CGlxThumbnailComposerPlugin::NewL"); |
|
180 CGlxThumbnailComposerPlugin* self = |
|
181 new (ELeave) CGlxThumbnailComposerPlugin(); |
|
182 CleanupStack::PushL(self); |
|
183 self->ConstructL(); |
|
184 CleanupStack::Pop(self); |
|
185 return self; |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // ~CGlxThumbnailComposerPlugin |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 CGlxThumbnailComposerPlugin::~CGlxThumbnailComposerPlugin() |
|
193 { |
|
194 delete iPath; |
|
195 if (iCollectionUtility) |
|
196 { |
|
197 iCollectionUtility->Close(); |
|
198 } |
|
199 |
|
200 if ( iInactivityTimer ) |
|
201 { |
|
202 iInactivityTimer->Cancel(); |
|
203 } |
|
204 delete iInactivityTimer; |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // CGlxThumbnailComposerPlugin |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 CGlxThumbnailComposerPlugin::CGlxThumbnailComposerPlugin() : iLastError(KErrNone) |
|
212 { |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // ConstructL |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 void CGlxThumbnailComposerPlugin::ConstructL() |
|
220 { |
|
221 TRACER("CGlxThumbnailComposerPlugin::ConstructL"); |
|
222 iInactivityTimer = CGlxThumbnailCompeserInactivityTimer::NewL(CActive::EPriorityIdle, *this); |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // SetObservers |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 void CGlxThumbnailComposerPlugin::SetObservers() |
|
230 { |
|
231 TRAPD(err, SetObserversL()); |
|
232 GLX_ASSERT_ALWAYS( KErrNone == err, Panic( EGlxPanicEnvironment ), |
|
233 "CGlxThumbnailComposerPlugin cannot set observers, reset Harvester server" ); |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // SetObserversL |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 void CGlxThumbnailComposerPlugin::SetObserversL() |
|
241 { |
|
242 TRACER("CGlxThumbnailComposerPlugin::SetObserversL"); |
|
243 if ( iSession ) |
|
244 { |
|
245 CMdELogicCondition* condition = |
|
246 CMdELogicCondition::NewLC( ELogicConditionOperatorOr ); |
|
247 |
|
248 #ifdef RD_MDS_2_0 |
|
249 |
|
250 CMdENamespaceDef* defaultNamespace = |
|
251 iSession->GetDefaultNamespaceDefL(); |
|
252 |
|
253 CMdEObjectDef* imageDef = defaultNamespace->GetObjectDefL( |
|
254 MdeConstants::Image::KImageObject ); |
|
255 condition->AddObjectConditionL( *imageDef ); |
|
256 |
|
257 CMdEObjectDef* videoDef = defaultNamespace->GetObjectDefL( |
|
258 MdeConstants::Video::KVideoObject ); |
|
259 condition->AddObjectConditionL( *videoDef ); |
|
260 |
|
261 #else |
|
262 |
|
263 CMdENamespaceDef& defaultNamespace = |
|
264 iSession->GetDefaultNamespaceDefL(); |
|
265 |
|
266 CMdEObjectDef& imageDef = defaultNamespace.GetObjectDefL( |
|
267 MdeConstants::Image::KImageObject ); |
|
268 condition->AddObjectConditionL( imageDef ); |
|
269 |
|
270 CMdEObjectDef& videoDef = defaultNamespace.GetObjectDefL( |
|
271 MdeConstants::Video::KVideoObject ); |
|
272 condition->AddObjectConditionL( videoDef ); |
|
273 |
|
274 #endif |
|
275 |
|
276 iSession->AddObjectObserverL( *this, condition ); |
|
277 CleanupStack::Pop( condition ); |
|
278 |
|
279 if ( iState == EStateIdle ) |
|
280 { |
|
281 iState = EStateFirstOpening; |
|
282 iInactivityTimer->After(KGlxThumbnailComposerLargeDelay); |
|
283 } |
|
284 } |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // RemoveObservers |
|
289 // --------------------------------------------------------------------------- |
|
290 // |
|
291 void CGlxThumbnailComposerPlugin::RemoveObservers() |
|
292 { |
|
293 if ( iSession ) |
|
294 { |
|
295 #ifdef RD_MDS_2_0 |
|
296 iSession->RemoveObjectObserver( *this ); |
|
297 #else |
|
298 TRAP_IGNORE(iSession->RemoveObjectObserverL( *this )); |
|
299 #endif |
|
300 } |
|
301 } |
|
302 |
|
303 // --------------------------------------------------------------------------- |
|
304 // IsComposingComplete |
|
305 // --------------------------------------------------------------------------- |
|
306 // |
|
307 TBool CGlxThumbnailComposerPlugin::IsComposingComplete() |
|
308 { |
|
309 TRACER("CGlxThumbnailComposerPlugin::IsComposingComplete"); |
|
310 // Need to stop background thumbnail generation activity |
|
311 // when harvester requests to pause. |
|
312 |
|
313 if (iState != EStateIdle) |
|
314 { |
|
315 iState = EStateClosing; |
|
316 |
|
317 if ( iInactivityTimer ) |
|
318 { |
|
319 iInactivityTimer->Cancel(); |
|
320 } |
|
321 |
|
322 if (iCollectionUtility) |
|
323 { |
|
324 iCollectionUtility->Close(); |
|
325 iCollectionUtility = NULL; |
|
326 } |
|
327 |
|
328 iState = EStateIdle; |
|
329 } |
|
330 |
|
331 return ETrue ; |
|
332 } |
|
333 |
|
334 #ifdef RD_MDS_2_0 |
|
335 |
|
336 // --------------------------------------------------------------------------- |
|
337 // HandleObjectAdded |
|
338 // --------------------------------------------------------------------------- |
|
339 // |
|
340 void CGlxThumbnailComposerPlugin::HandleObjectAdded( |
|
341 CMdESession& /*aSession*/, const RArray<TItemId>& /*aObjectIdArray*/ ) |
|
342 { |
|
343 TRACER("CGlxThumbnailComposerPlugin::HandleObjectAdded"); |
|
344 if ( ( iState == EStateIdle ) || ( iState == EStateFirstOpening ) || ( iState == EStateClosing ) ) |
|
345 { |
|
346 iInactivityTimer->Cancel(); |
|
347 iState = EStateOpening; |
|
348 iInactivityTimer->After(20000000); |
|
349 } |
|
350 else |
|
351 { |
|
352 iLastError = 1; |
|
353 iState = EStateActiveLarge; |
|
354 } |
|
355 } |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // HandleObjectModified |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 void CGlxThumbnailComposerPlugin::HandleObjectModified( |
|
362 CMdESession& /*aSession*/, |
|
363 const RArray<TItemId>& /*aObjectIdArray*/) |
|
364 { |
|
365 //no implemention needed |
|
366 } |
|
367 |
|
368 // --------------------------------------------------------------------------- |
|
369 // HandleObjectRemoved |
|
370 // --------------------------------------------------------------------------- |
|
371 // |
|
372 void CGlxThumbnailComposerPlugin::HandleObjectRemoved( |
|
373 CMdESession& /*aSession*/, |
|
374 const RArray<TItemId>& /*aObjectIdArray*/) |
|
375 { |
|
376 //no implemention needed |
|
377 } |
|
378 |
|
379 #else |
|
380 |
|
381 void CGlxThumbnailComposerPlugin::HandleObjectNotification(CMdESession& /*aSession*/, |
|
382 TObserverNotificationType aType, |
|
383 const RArray<TItemId>& /*aObjectIdArray*/) |
|
384 { |
|
385 TRACER("CGlxThumbnailComposerPlugin::HandleObjectNotification"); |
|
386 if (aType == ENotifyAdd) |
|
387 { |
|
388 if ( iState == EStateIdle ) |
|
389 { |
|
390 iState = EStateOpening; |
|
391 iInactivityTimer->After(KGlxThumbnailComposerLargeDelay); |
|
392 } |
|
393 else |
|
394 { |
|
395 iLastError = 1; |
|
396 iState = EStateActiveLarge; |
|
397 iInactivityTimer->After(KGlxThumbnailComposerLargeDelay); |
|
398 } |
|
399 } |
|
400 } |
|
401 |
|
402 #endif |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // HandleCollectionMediaL |
|
406 // --------------------------------------------------------------------------- |
|
407 // |
|
408 void CGlxThumbnailComposerPlugin::HandleCollectionMediaL( |
|
409 const CMPXMedia& /*aMedia*/, TInt aError ) |
|
410 { |
|
411 TRACER("CGlxThumbnailComposerPlugin::HandleCollectionMediaL"); |
|
412 if ( iPath && KErrNone != aError ) |
|
413 { |
|
414 GLX_LOG_WARNING1( "Error %d getting media", aError ); |
|
415 |
|
416 // Error generating thumbnails, try the next item |
|
417 iLastError = aError; |
|
418 iCurrentIndex++; |
|
419 RequestItemL(); |
|
420 } |
|
421 } |
|
422 |
|
423 // --------------------------------------------------------------------------- |
|
424 // HandleCollectionMessageL |
|
425 // --------------------------------------------------------------------------- |
|
426 // |
|
427 void CGlxThumbnailComposerPlugin::HandleCollectionMessage( |
|
428 CMPXMessage* aMsg, TInt /*aErr*/ ) |
|
429 { |
|
430 TRACER("CGlxThumbnailComposerPlugin::HandleCollectionMessage"); |
|
431 if ( iState != EStateIdle && aMsg ) |
|
432 { |
|
433 TRAPD( err, DoHandleCollectionMessageL( *aMsg ) ); |
|
434 if ( KErrNone != err ) |
|
435 { |
|
436 GLX_LOG_WARNING1( "Error %d handling message", err ); |
|
437 ReturnToIdle(); |
|
438 } |
|
439 } |
|
440 } |
|
441 |
|
442 // --------------------------------------------------------------------------- |
|
443 // HandleOpenL |
|
444 // --------------------------------------------------------------------------- |
|
445 // |
|
446 void CGlxThumbnailComposerPlugin::HandleOpenL( const CMPXMedia& /*aEntries*/, |
|
447 TInt /*aIndex*/, TBool /*aComplete*/, TInt aError ) |
|
448 { |
|
449 TRACER("CGlxThumbnailComposerPlugin::HandleOpenL"); |
|
450 if ( KErrNone != aError ) |
|
451 { |
|
452 GLX_LOG_WARNING1( "Error %d opening collection", aError ); |
|
453 ReturnToIdle(); |
|
454 } |
|
455 } |
|
456 |
|
457 // --------------------------------------------------------------------------- |
|
458 // HandleOpenL |
|
459 // --------------------------------------------------------------------------- |
|
460 // |
|
461 void CGlxThumbnailComposerPlugin::HandleOpenL( |
|
462 const CMPXCollectionPlaylist& /*aPlaylist*/, TInt /*aError*/ ) |
|
463 { |
|
464 // No implemention needed |
|
465 } |
|
466 |
|
467 // --------------------------------------------------------------------------- |
|
468 // HandleCommandComplete |
|
469 // --------------------------------------------------------------------------- |
|
470 // |
|
471 void CGlxThumbnailComposerPlugin::HandleCommandComplete( |
|
472 CMPXCommand* /*aCommandResult*/, TInt /*aError*/ ) |
|
473 { |
|
474 TRACER("CGlxThumbnailComposerPlugin::HandleCommandComplete"); |
|
475 if( EStateCleanup == iState ) |
|
476 { |
|
477 ReturnToIdle(); |
|
478 } |
|
479 else |
|
480 { |
|
481 iInactivityTimer->After(0); |
|
482 } |
|
483 } |
|
484 |
|
485 // --------------------------------------------------------------------------- |
|
486 // DoOpenCollectionL |
|
487 // --------------------------------------------------------------------------- |
|
488 // |
|
489 void CGlxThumbnailComposerPlugin::DoOpenCollectionL() |
|
490 { |
|
491 TRACER("CGlxThumbnailComposerPlugin::HandleCollectionMediaL"); |
|
492 if ( !iCollectionUtility ) |
|
493 { |
|
494 // Open isolated collection utility |
|
495 iCollectionUtility = MMPXCollectionUtility::NewL( |
|
496 this, KMcModeIsolated ); |
|
497 } |
|
498 |
|
499 CMPXFilter* filter = CMPXFilter::NewL(); |
|
500 CleanupStack::PushL(filter); |
|
501 filter->SetTObjectValueL<TGlxFilterSortDirection>(KGlxFilterGeneralSortDirection, EGlxFilterSortDirectionDescending); |
|
502 iCollectionUtility->Collection().SetFilterL(filter); |
|
503 CleanupStack::PopAndDestroy(filter); |
|
504 |
|
505 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
|
506 CleanupStack::PushL( path ); |
|
507 // argument path all collection id |
|
508 path->AppendL( KGlxCollectionPluginAllImplementationUid ); |
|
509 |
|
510 iCollectionUtility->Collection().OpenL( *path ); |
|
511 CleanupStack::PopAndDestroy( path ); |
|
512 |
|
513 iState = EStateActiveSmall; |
|
514 } |
|
515 |
|
516 // --------------------------------------------------------------------------- |
|
517 // DoHandleCollectionMessageL |
|
518 // --------------------------------------------------------------------------- |
|
519 // |
|
520 void CGlxThumbnailComposerPlugin::DoHandleCollectionMessageL( |
|
521 const CMPXMessage& aMsg ) |
|
522 { |
|
523 TRACER("CGlxThumbnailComposerPlugin::DoHandleCollectionMessageL"); |
|
524 if ( aMsg.IsSupported( KMPXMessageGeneralId ) ) |
|
525 { |
|
526 TInt messageId = aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralId ); |
|
527 |
|
528 // Is it a background thumbnail message |
|
529 if ( KGlxMessageIdBackgroundThumbnail == messageId ) |
|
530 { |
|
531 // Is it the item expected |
|
532 TGlxMediaId id( ( TUint32 ) |
|
533 aMsg.ValueTObjectL<TMPXItemId>( KGlxBackgroundThumbnailMediaId ) ); |
|
534 if ( iPath && id.Value() |
|
535 == ( TUint32 )iPath->IdOfIndex( iCurrentIndex ) ) |
|
536 { |
|
537 TInt error = aMsg.ValueTObjectL<TInt>( KGlxBackgroundThumbnailError ); |
|
538 if ( error == KErrCancel ) |
|
539 { |
|
540 iState = EStateActiveLarge; |
|
541 iLastError = error; |
|
542 } |
|
543 else if( KErrNone != error ) |
|
544 { |
|
545 GLX_LOG_WARNING1( "Error %d in command", error ); |
|
546 error = KErrNone; |
|
547 } |
|
548 // Yes, then request the next item |
|
549 iCurrentIndex++; |
|
550 RequestItemL(); |
|
551 } |
|
552 } |
|
553 else if ( KMPXMessageGeneral == messageId |
|
554 && aMsg.IsSupported( KMPXMessageGeneralEvent ) ) |
|
555 { |
|
556 TInt messageEvent = aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ); |
|
557 |
|
558 // Is it a path changed event |
|
559 if ( TMPXCollectionMessage::EPathChanged == messageEvent |
|
560 && aMsg.IsSupported( KMPXMessageGeneralType ) ) |
|
561 { |
|
562 TInt messageType = aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralType ); |
|
563 |
|
564 if ( EMcPathChangedByOpen == messageType |
|
565 && iCollectionUtility && !iPath ) |
|
566 { |
|
567 iPath = iCollectionUtility->Collection().PathL(); |
|
568 |
|
569 iCurrentIndex = 0; |
|
570 RequestItemL(); |
|
571 } |
|
572 } |
|
573 } |
|
574 } |
|
575 } |
|
576 |
|
577 // --------------------------------------------------------------------------- |
|
578 // RequestItemL |
|
579 // --------------------------------------------------------------------------- |
|
580 // |
|
581 void CGlxThumbnailComposerPlugin::RequestItemL() |
|
582 { |
|
583 TRACER("CGlxThumbnailComposerPlugin::RequestItemL"); |
|
584 if ( iLastError == KErrCancel ) |
|
585 { |
|
586 iInactivityTimer->Inactivity(KGlxThumbnailComposerInactivityTimeout); |
|
587 } |
|
588 else if ( iLastError == 1 ) |
|
589 { |
|
590 iInactivityTimer->After(KGlxThumbnailComposerHarvestDelay); |
|
591 } |
|
592 else |
|
593 { |
|
594 iInactivityTimer->After(KGlxThumbnailComposerDelay); |
|
595 } |
|
596 iLastError = KErrNone; |
|
597 } |
|
598 |
|
599 // --------------------------------------------------------------------------- |
|
600 // DoRequestItemL |
|
601 // --------------------------------------------------------------------------- |
|
602 // |
|
603 void CGlxThumbnailComposerPlugin::DoRequestItemL() |
|
604 { |
|
605 TRACER("CGlxThumbnailComposerPlugin::DoRequestItemL"); |
|
606 |
|
607 if ( iPath && iCurrentIndex < iPath->Count() ) |
|
608 { |
|
609 GLX_ASSERT_ALWAYS( iCollectionUtility, Panic( EGlxPanicNullPointer ), |
|
610 "No collection utility" ); |
|
611 // request next item |
|
612 iPath->Set( iCurrentIndex ); |
|
613 |
|
614 RArray<TMPXAttribute> attrs; |
|
615 CleanupClosePushL( attrs ); |
|
616 // Add thumbnail attribute |
|
617 attrs.AppendL( TMPXAttribute( |
|
618 KGlxMediaIdThumbnail, KGlxBackgroundThumbnailAttributeId ) ); |
|
619 |
|
620 // Don't add spec for bitmap handle, to request background thumbnail |
|
621 CMPXAttributeSpecs* attrSpecs = NULL; |
|
622 |
|
623 // Start first task |
|
624 iCollectionUtility->Collection().MediaL( |
|
625 *iPath, attrs.Array(), attrSpecs ); |
|
626 CleanupStack::PopAndDestroy( &attrs ); |
|
627 } |
|
628 else |
|
629 { |
|
630 delete iPath; |
|
631 iPath = NULL; |
|
632 |
|
633 if ( iState == EStateActiveLarge ) |
|
634 { |
|
635 // go on to do small thumbnails |
|
636 DoOpenCollectionL(); |
|
637 } |
|
638 else |
|
639 { |
|
640 CMPXCommand* command |
|
641 = TGlxCommandFactory::ThumbnailCleanupCommandLC(); |
|
642 iCollectionUtility->Collection().CommandL( *command ); |
|
643 CleanupStack::PopAndDestroy( command ); |
|
644 |
|
645 iState = EStateCleanup; |
|
646 } |
|
647 } |
|
648 } |
|
649 |
|
650 // --------------------------------------------------------------------------- |
|
651 // ReturnToIdle |
|
652 // --------------------------------------------------------------------------- |
|
653 // |
|
654 void CGlxThumbnailComposerPlugin::ReturnToIdle() |
|
655 { |
|
656 TRACER("CGlxThumbnailComposerPlugin::ReturnToIdle"); |
|
657 iState = EStateClosing; |
|
658 iInactivityTimer->After(KGlxThumbnailComposerLargeDelay); |
|
659 } |
|
660 |
|
661 // --------------------------------------------------------------------------- |
|
662 // DelayDisplayStateCheck |
|
663 // --------------------------------------------------------------------------- |
|
664 // |
|
665 void CGlxThumbnailComposerPlugin::DelayDisplayStateCheck() |
|
666 { |
|
667 TRACER("CGlxThumbnailComposerPlugin::DelayDisplayStateCheck"); |
|
668 iInactivityTimer->After(KGlxDisplayStatusTimeOutDelay); |
|
669 } |
|
670 |
|
671 // --------------------------------------------------------------------------- |
|
672 // CloseCollection |
|
673 // --------------------------------------------------------------------------- |
|
674 // |
|
675 void CGlxThumbnailComposerPlugin::CloseCollection() |
|
676 { |
|
677 TRACER("CGlxThumbnailComposerPlugin::CloseCollection"); |
|
678 if ( ( EStateClosing == iState ) && iCollectionUtility ) |
|
679 { |
|
680 iCollectionUtility->Close(); |
|
681 iCollectionUtility = NULL; |
|
682 iState = EStateIdle; |
|
683 } |
|
684 } |