|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Processor |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 #include <mdeconstants.h> |
|
22 #include <centralrepository.h> |
|
23 |
|
24 #include "thumbagprocessor.h" |
|
25 #include "thumbnaillog.h" |
|
26 #include "thumbnailmanagerconstants.h" |
|
27 #include "thumbnailmanagerprivatecrkeys.h" |
|
28 #include "thumbagformatobserver.h" |
|
29 #include <mpxcollectionutility.h> |
|
30 #include <mpxmessagegeneraldefs.h> |
|
31 #include <mpxcollectionmessage.h> |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CThumbAGProcessor::NewL() |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CThumbAGProcessor* CThumbAGProcessor::NewL() |
|
38 { |
|
39 TN_DEBUG1( "CThumbAGProcessor::NewL() - begin" ); |
|
40 |
|
41 CThumbAGProcessor* self = new( ELeave )CThumbAGProcessor(); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CThumbAGProcessor::CThumbAGProcessor() |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CThumbAGProcessor::CThumbAGProcessor(): CActive( CActive::EPriorityStandard ) |
|
53 { |
|
54 TN_DEBUG1( "CThumbAGProcessor::CThumbAGProcessor() - begin" ); |
|
55 |
|
56 CActiveScheduler::Add( this ); |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CThumbAGProcessor::ConstructL() |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 void CThumbAGProcessor::ConstructL() |
|
64 { |
|
65 TN_DEBUG1( "CThumbAGProcessor::ConstructL() - begin" ); |
|
66 |
|
67 #ifdef _DEBUG |
|
68 iAddCounter = 0; |
|
69 iModCounter = 0; |
|
70 iDelCounter = 0; |
|
71 #endif |
|
72 |
|
73 iTMSession = CThumbnailManager::NewL( *this ); |
|
74 |
|
75 iQuery = NULL; |
|
76 iQueryActive = EFalse; |
|
77 iModify = EFalse; |
|
78 iProcessingCount = 0; |
|
79 |
|
80 iActiveCount = 0; |
|
81 |
|
82 // set auto create values from cenrep |
|
83 CheckAutoCreateValuesL(); |
|
84 |
|
85 iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityIdle); |
|
86 |
|
87 //do some initializing async in RunL() |
|
88 iInit = ETrue; |
|
89 iForceRun = EFalse; |
|
90 iActive = EFalse; |
|
91 |
|
92 iFormatObserver = CThumbAGFormatObserver::NewL( this ); |
|
93 |
|
94 iFormatting = EFalse; |
|
95 iSessionDied = EFalse; |
|
96 |
|
97 iCollectionUtility = NULL; |
|
98 |
|
99 TN_DEBUG1( "CThumbAGProcessor::ConstructL() - end" ); |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // CThumbAGProcessor::~CThumbAGProcessor() |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 CThumbAGProcessor::~CThumbAGProcessor() |
|
107 { |
|
108 TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - begin" ); |
|
109 |
|
110 if(iPeriodicTimer) |
|
111 { |
|
112 iPeriodicTimer->Cancel(); |
|
113 delete iPeriodicTimer; |
|
114 } |
|
115 |
|
116 if (!iInit) |
|
117 { |
|
118 iHarvesterClient.RemoveHarvesterEventObserver(*this); |
|
119 iHarvesterClient.Close(); |
|
120 } |
|
121 |
|
122 if ( iCollectionUtility ) |
|
123 { |
|
124 iCollectionUtility->Close(); |
|
125 iCollectionUtility = NULL; |
|
126 } |
|
127 |
|
128 Cancel(); |
|
129 |
|
130 if (iQuery) |
|
131 { |
|
132 iQuery->Cancel(); |
|
133 delete iQuery; |
|
134 iQuery = NULL; |
|
135 } |
|
136 |
|
137 if (iQueryForPlaceholders) |
|
138 { |
|
139 iQueryForPlaceholders->Cancel(); |
|
140 delete iQueryForPlaceholders; |
|
141 iQueryForPlaceholders = NULL; |
|
142 } |
|
143 |
|
144 iAddQueue.Close(); |
|
145 iModifyQueue.Close(); |
|
146 iRemoveQueue.Close(); |
|
147 iQueryQueue.Close(); |
|
148 iPresentQueue.Close(); |
|
149 iTempModifyQueue.Close(); |
|
150 iTempAddQueue.Close(); |
|
151 iPlaceholderIDs.Close(); |
|
152 |
|
153 if (iTMSession) |
|
154 { |
|
155 delete iTMSession; |
|
156 iTMSession = NULL; |
|
157 } |
|
158 |
|
159 delete iFormatObserver; |
|
160 |
|
161 TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - end" ); |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CThumbAGProcessor::HandleQueryNewResults() |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void CThumbAGProcessor::HandleQueryNewResults( CMdEQuery& /*aQuery*/, |
|
169 const TInt /*aFirstNewItemIndex*/, |
|
170 const TInt /*aNewItemCount*/ ) |
|
171 { |
|
172 // No implementation required |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CThumbAGProcessor::HandleQueryCompleted() |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CThumbAGProcessor::HandleQueryCompleted( CMdEQuery& /*aQuery*/, const TInt aError ) |
|
180 { |
|
181 |
|
182 if( iQueryForPlaceholdersActive && iQueryForPlaceholders) |
|
183 { |
|
184 TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompletedv2, aError == %d Count== %d", aError, iQueryForPlaceholders->Count()); |
|
185 |
|
186 // if no errors in query |
|
187 if (aError == KErrNone ) |
|
188 { |
|
189 |
|
190 for(TInt i = 0; i < iQueryForPlaceholders->Count(); i++) |
|
191 { |
|
192 const CMdEObject* object = &iQueryForPlaceholders->Result(i); |
|
193 |
|
194 if(!object) |
|
195 continue; |
|
196 |
|
197 if(!object->Placeholder()) |
|
198 { |
|
199 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompletedv2 %d not placeholder",object->Id()); |
|
200 continue; |
|
201 } |
|
202 |
|
203 if (iPlaceholderIDs.Find( object->Id() ) == KErrNotFound) |
|
204 { |
|
205 TRAP_IGNORE( iPlaceholderIDs.AppendL( object->Id() )); |
|
206 } |
|
207 } |
|
208 |
|
209 } |
|
210 else |
|
211 { |
|
212 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() FAILED!"); |
|
213 } |
|
214 |
|
215 iQueryForPlaceholdersActive = EFalse; |
|
216 } |
|
217 |
|
218 else if(iQueryActive) |
|
219 { |
|
220 TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompleted, aError == %d Count== %d", aError, iQuery->Count()); |
|
221 iQueryReady = ETrue; |
|
222 iQueryActive = EFalse; |
|
223 |
|
224 // if no errors in query |
|
225 if (aError == KErrNone && iQuery) |
|
226 { |
|
227 iProcessingCount = iQuery->Count(); |
|
228 } |
|
229 else |
|
230 { |
|
231 iProcessingCount = 0; |
|
232 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() FAILED!"); |
|
233 } |
|
234 } |
|
235 else |
|
236 { |
|
237 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() - NO QUERY ACTIVE"); |
|
238 } |
|
239 |
|
240 ActivateAO(); |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CThumbAGProcessor::ThumbnailPreviewReady() |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 void CThumbAGProcessor::ThumbnailPreviewReady( MThumbnailData& /*aThumbnail*/, |
|
248 TThumbnailRequestId /*aId*/) |
|
249 { |
|
250 // No implementation required |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CThumbAGProcessor::ThumbnailReady() |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 void CThumbAGProcessor::ThumbnailReady( TInt aError, MThumbnailData& /*aThumbnail*/, |
|
258 TThumbnailRequestId /*aId*/ ) |
|
259 { |
|
260 TN_DEBUG2( "CThumbAGProcessor::ThumbnailReady() aError == %d", aError ); |
|
261 |
|
262 iActive = EFalse; |
|
263 |
|
264 // TNM server died, delete session |
|
265 if( aError == KErrServerTerminated ) |
|
266 { |
|
267 TN_DEBUG1( "CThumbAGProcessor::ThumbnailReady() - **** THUMBNAIL SERVER DIED ****" ); |
|
268 |
|
269 iSessionDied = ETrue; |
|
270 |
|
271 if( !iTimerActive) |
|
272 { |
|
273 StartTimeout(); |
|
274 } |
|
275 |
|
276 //reset PS idle so that RunL() can startup reopen TNM session and proceed |
|
277 TInt ret = RProperty::Set(KServerIdle, KIdle, ETrue); |
|
278 TN_DEBUG2( "CThumbAGProcessor::ThumbnailReady() set Idle ret = %d", ret ); |
|
279 |
|
280 return; |
|
281 } |
|
282 |
|
283 ActivateAO(); |
|
284 TN_DEBUG1( "CThumbAGProcessor::ThumbnailReady() - end" ); |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // CThumbAGProcessor::SetMdESession() |
|
289 // --------------------------------------------------------------------------- |
|
290 // |
|
291 void CThumbAGProcessor::SetMdESession( CMdESession* aMdESession ) |
|
292 { |
|
293 TN_DEBUG1( "CThumbAGProcessor::SetMdESession() - begin" ); |
|
294 |
|
295 iMdESession = aMdESession; |
|
296 |
|
297 TRAPD( err, iDefNamespace = &iMdESession->GetDefaultNamespaceDefL() ); |
|
298 if (err != KErrNone) |
|
299 { |
|
300 TN_DEBUG1( "CThumbAGProcessor::SetMdESession - Error: GetDefaultNamespaceDefL leave" ); |
|
301 } |
|
302 ActivateAO(); |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------------------------- |
|
306 // CThumbAGProcessor::AddToQueue() |
|
307 // --------------------------------------------------------------------------- |
|
308 // |
|
309 void CThumbAGProcessor::AddToQueueL( TObserverNotificationType aType, |
|
310 const RArray<TItemId>& aIDArray, TBool aPresent ) |
|
311 { |
|
312 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - begin" ); |
|
313 |
|
314 if(aPresent) |
|
315 { |
|
316 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - Add to SetPresentQueue" ); |
|
317 for (int i=0; i<aIDArray.Count(); i++) |
|
318 { |
|
319 // only add to Present queue if not already in Add or Present queue |
|
320 if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound) |
|
321 { |
|
322 if (iPresentQueue.Find( aIDArray[i] ) == KErrNotFound) |
|
323 { |
|
324 iPresentQueue.AppendL(aIDArray[i]); |
|
325 } |
|
326 } |
|
327 } |
|
328 } |
|
329 // update queues |
|
330 else if (aType == ENotifyAdd) |
|
331 { |
|
332 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyAdd" ); |
|
333 |
|
334 for (int i=0; i<aIDArray.Count(); i++) |
|
335 { |
|
336 // only add to Add queue if not already in Add queue |
|
337 if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound) |
|
338 { |
|
339 //if in Present Queue remove from there and and put to add queue |
|
340 TInt index = iPresentQueue.Find( aIDArray[i] ); |
|
341 if( index != KErrNotFound) |
|
342 { |
|
343 iPresentQueue.Remove( index ); |
|
344 } |
|
345 iAddQueue.AppendL(aIDArray[i]); |
|
346 iTempAddQueue.AppendL(aIDArray[i]); |
|
347 } |
|
348 } |
|
349 } |
|
350 else if (aType == ENotifyModify) |
|
351 { |
|
352 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyModify" ); |
|
353 |
|
354 for (int i=0; i<aIDArray.Count(); i++) |
|
355 { |
|
356 TInt itemIndex = iPlaceholderIDs.Find( aIDArray[i] ); |
|
357 if(itemIndex >= 0 ) |
|
358 { |
|
359 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - harvesting now ended for this placeholder - not Real ENotifyModify" ); |
|
360 iPlaceholderIDs.Remove(itemIndex); |
|
361 TN_DEBUG2( "CThumbAGProcessor::AddToQueueL() - placeholders left %d", iPlaceholderIDs.Count() ); |
|
362 if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound) |
|
363 { |
|
364 iAddQueue.AppendL(aIDArray[i]); |
|
365 } |
|
366 if (iTempModifyQueue.Find( aIDArray[i] ) == KErrNotFound) |
|
367 { |
|
368 iTempModifyQueue.AppendL( aIDArray[i] ); |
|
369 } |
|
370 } |
|
371 else if ( iTempAddQueue.Find( aIDArray[i] ) == KErrNotFound) |
|
372 { |
|
373 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - Real ENotifyModify, force run" ); |
|
374 iModifyQueue.InsertL( aIDArray[i], 0 ); |
|
375 |
|
376 TInt itemIndex = iAddQueue.Find( aIDArray[i] ); |
|
377 if(itemIndex >= 0) |
|
378 { |
|
379 iAddQueue.Remove(itemIndex); |
|
380 } |
|
381 itemIndex = iPresentQueue.Find( aIDArray[i] ); |
|
382 if(itemIndex >= 0) |
|
383 { |
|
384 iPresentQueue.Remove(itemIndex); |
|
385 } |
|
386 SetForceRun( ETrue ); |
|
387 } |
|
388 else |
|
389 { |
|
390 if (iTempModifyQueue.Find( aIDArray[i] ) == KErrNotFound) |
|
391 { |
|
392 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - harvesting now ended for this file - not Real ENotifyModify" ); |
|
393 iTempModifyQueue.AppendL( aIDArray[i] ); |
|
394 } |
|
395 else |
|
396 { |
|
397 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - harvesting ended allready for this file - Real ENotifyModify, force run" ); |
|
398 iModifyQueue.InsertL( aIDArray[i], 0 ); |
|
399 TInt itemIndex = iAddQueue.Find( aIDArray[i] ); |
|
400 if(itemIndex >= 0) |
|
401 { |
|
402 iAddQueue.Remove(itemIndex); |
|
403 } |
|
404 itemIndex = iPresentQueue.Find( aIDArray[i] ); |
|
405 if(itemIndex >= 0) |
|
406 { |
|
407 iPresentQueue.Remove(itemIndex); |
|
408 } |
|
409 SetForceRun( ETrue ); |
|
410 } |
|
411 } |
|
412 } |
|
413 } |
|
414 else if (aType == ENotifyRemove) |
|
415 { |
|
416 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove" ); |
|
417 |
|
418 for (int i=0; i<aIDArray.Count(); i++) |
|
419 { |
|
420 // only add to Remove queue if not already in Remove queue |
|
421 if (iRemoveQueue.Find( aIDArray[i] ) == KErrNotFound) |
|
422 { |
|
423 iRemoveQueue.AppendL(aIDArray[i]); |
|
424 } |
|
425 |
|
426 // can be removed from Add queue |
|
427 TInt itemIndex = iAddQueue.Find( aIDArray[i] ); |
|
428 if(itemIndex >= 0) |
|
429 { |
|
430 iAddQueue.Remove(itemIndex); |
|
431 } |
|
432 // ..and Present Queue |
|
433 itemIndex = iPresentQueue.Find( aIDArray[i] ); |
|
434 if(itemIndex >= 0) |
|
435 { |
|
436 iPresentQueue.Remove(itemIndex); |
|
437 } |
|
438 // ..and Modify Queue |
|
439 itemIndex = iModifyQueue.Find( aIDArray[i] ); |
|
440 if(itemIndex >= 0) |
|
441 { |
|
442 iModifyQueue.Remove(itemIndex); |
|
443 } |
|
444 } |
|
445 } |
|
446 else |
|
447 { |
|
448 // should not come here |
|
449 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - should not come here" ); |
|
450 return; |
|
451 } |
|
452 |
|
453 ActivateAO(); |
|
454 |
|
455 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - end" ); |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // CThumbAGProcessor::CreateThumbnailsL() |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 void CThumbAGProcessor::CreateThumbnailsL( const CMdEObject* aObject ) |
|
463 { |
|
464 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - begin" ); |
|
465 |
|
466 if( iModify ) |
|
467 { |
|
468 TInt orientationVal = 0; |
|
469 TInt64 modifiedVal = 0; |
|
470 |
|
471 CMdEProperty* orientation = NULL; |
|
472 CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject ); |
|
473 TInt orientErr = aObject->Property( objDef.GetPropertyDefL( MdeConstants::Image::KOrientationProperty ), orientation, 0 ); |
|
474 |
|
475 if (orientErr == KErrNone) |
|
476 { |
|
477 orientationVal = orientation->Uint16ValueL(); |
|
478 } |
|
479 |
|
480 CMdEProperty* modified = NULL; |
|
481 CMdEObjectDef& objDef2 = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
|
482 TInt modifyErr = aObject->Property( objDef2.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ), modified, 0 ); |
|
483 |
|
484 if (modifyErr >= 0) |
|
485 { |
|
486 modifiedVal = modified->TimeValueL().Int64(); |
|
487 } |
|
488 |
|
489 // modify existing thumbs |
|
490 if (iTMSession) |
|
491 { |
|
492 // run as lower priority than getting but higher that creating thumbnails |
|
493 TRAPD(err, iTMSession->UpdateThumbnailsL(aObject->Id(), aObject->Uri(), orientationVal, modifiedVal, CActive::EPriorityIdle )); |
|
494 |
|
495 if ( err != KErrNone ) |
|
496 { |
|
497 TN_DEBUG2( "CThumbAGProcessor::UpdateThumbnailsL, iTMSession error == %d", err ); |
|
498 |
|
499 iSessionDied = ETrue; |
|
500 iActive = EFalse; |
|
501 ActivateAO(); |
|
502 } |
|
503 else |
|
504 { |
|
505 iActive = ETrue; |
|
506 } |
|
507 } |
|
508 else |
|
509 { |
|
510 ActivateAO(); |
|
511 } |
|
512 |
|
513 #ifdef _DEBUG |
|
514 iModCounter++; |
|
515 #endif |
|
516 } |
|
517 else |
|
518 { |
|
519 CThumbnailObjectSource* source = NULL; |
|
520 CMdEProperty* mimeType = NULL; |
|
521 CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
|
522 TInt mime = aObject->Property( objDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty ), mimeType, 0 ); |
|
523 |
|
524 // create new thumbs |
|
525 if (mime != KErrNotFound) |
|
526 { |
|
527 source = CThumbnailObjectSource::NewLC(aObject->Uri(), aObject->Id(), mimeType->TextValueL()); |
|
528 } |
|
529 else |
|
530 { |
|
531 source = CThumbnailObjectSource::NewLC(aObject->Uri(), aObject->Id()); |
|
532 } |
|
533 |
|
534 if (iTMSession) |
|
535 { |
|
536 // run as very low priority task |
|
537 TInt id = iTMSession->CreateThumbnails(*source, CActive::EPriorityIdle ); |
|
538 if ( id < 0 ) |
|
539 { |
|
540 TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL, iTMSession error == %d", id ); |
|
541 |
|
542 iSessionDied = ETrue; |
|
543 iActive = EFalse; |
|
544 CleanupStack::PopAndDestroy( source ); |
|
545 ActivateAO(); |
|
546 } |
|
547 else |
|
548 { |
|
549 iActive = ETrue; |
|
550 CleanupStack::PopAndDestroy( source ); |
|
551 } |
|
552 |
|
553 } |
|
554 else |
|
555 { |
|
556 ActivateAO(); |
|
557 } |
|
558 |
|
559 #ifdef _DEBUG |
|
560 iAddCounter++; |
|
561 #endif |
|
562 } |
|
563 |
|
564 #ifdef _DEBUG |
|
565 TN_DEBUG3( "CThumbAGProcessor::OUT-COUNTERS----------, Add = %d Modify = %d", |
|
566 iAddCounter, iModCounter ); |
|
567 #endif |
|
568 |
|
569 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - end" ); |
|
570 } |
|
571 |
|
572 // --------------------------------------------------------------------------- |
|
573 // CThumbAGProcessor::QueryL() |
|
574 // --------------------------------------------------------------------------- |
|
575 // |
|
576 void CThumbAGProcessor::QueryL( RArray<TItemId>& aIDArray ) |
|
577 { |
|
578 TN_DEBUG1( "CThumbAGProcessor::QueryL() - begin" ); |
|
579 |
|
580 iQueryReady = EFalse; |
|
581 |
|
582 // delete old query |
|
583 if (iQuery) |
|
584 { |
|
585 delete iQuery; |
|
586 iQuery = NULL; |
|
587 } |
|
588 |
|
589 //move ID from source queue to Query queue |
|
590 TInt maxCount = aIDArray.Count(); |
|
591 |
|
592 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
|
593 |
|
594 for(TInt i=0;i < KMaxQueryItems && i < maxCount; i++) |
|
595 { |
|
596 TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", aIDArray[0] ); |
|
597 iQueryQueue.Append( aIDArray[0] ); |
|
598 aIDArray.Remove( 0 ); |
|
599 } |
|
600 |
|
601 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
|
602 |
|
603 CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
|
604 iQuery = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this ); |
|
605 iQuery->SetResultMode( EQueryResultModeItem ); |
|
606 |
|
607 CMdELogicCondition& rootCondition = iQuery->Conditions(); |
|
608 rootCondition.SetOperator( ELogicConditionOperatorAnd ); |
|
609 |
|
610 // add IDs |
|
611 CleanupClosePushL( iQueryQueue ); |
|
612 rootCondition.AddObjectConditionL( iQueryQueue ); |
|
613 CleanupStack::Pop( &iQueryQueue ); |
|
614 |
|
615 // add object type conditions |
|
616 if (!iModify) |
|
617 { |
|
618 CMdELogicCondition& objDefCondition = rootCondition.AddLogicConditionL( ELogicConditionOperatorOr ); |
|
619 |
|
620 if (iAutoImage) |
|
621 { |
|
622 CMdEObjectDef& imageDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject ); |
|
623 objDefCondition.AddObjectConditionL( imageDef ); |
|
624 } |
|
625 if (iAutoVideo) |
|
626 { |
|
627 CMdEObjectDef& videoDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject ); |
|
628 objDefCondition.AddObjectConditionL( videoDef ); |
|
629 } |
|
630 if (iAutoAudio) |
|
631 { |
|
632 CMdEObjectDef& audioDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
633 objDefCondition.AddObjectConditionL( audioDef ); |
|
634 } |
|
635 } |
|
636 |
|
637 iQuery->FindL(); |
|
638 |
|
639 iQueryQueue.Reset(); |
|
640 |
|
641 TN_DEBUG1( "CThumbAGProcessor::QueryL() - end" ); |
|
642 } |
|
643 |
|
644 // --------------------------------------------------------------------------- |
|
645 // CThumbAGProcessor::RunL() |
|
646 // --------------------------------------------------------------------------- |
|
647 // |
|
648 void CThumbAGProcessor::RunL() |
|
649 { |
|
650 TN_DEBUG1( "CThumbAGProcessor::RunL() - begin" ); |
|
651 |
|
652 if (iSessionDied) |
|
653 { |
|
654 delete iTMSession; |
|
655 iTMSession = NULL; |
|
656 } |
|
657 |
|
658 if (iInit) |
|
659 { |
|
660 TN_DEBUG1( "CThumbAGProcessor::RunL() - Do Initialisation" ); |
|
661 iInit = EFalse; |
|
662 TN_DEBUG1( "iHarvesterClient"); |
|
663 if( iHarvesterClient.Connect() == KErrNone ) |
|
664 { |
|
665 TN_DEBUG1( "iHarvesterClient connected"); |
|
666 iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall, KMaxTInt ); |
|
667 iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypePlaceholder, KMaxTInt ); |
|
668 TN_DEBUG1( "iHarvesterClient AddHarvesterEventObserver added"); |
|
669 } |
|
670 |
|
671 TN_DEBUG1( "create MMPXCollectionUtility"); |
|
672 iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated ); |
|
673 TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation done" ); |
|
674 return; |
|
675 } |
|
676 |
|
677 // restart session if died |
|
678 if (!iTMSession) |
|
679 { |
|
680 TN_DEBUG1( "CThumbAGProcessor::RunL() - open TNM session"); |
|
681 iActive = EFalse; |
|
682 TRAPD( err, iTMSession = CThumbnailManager::NewL( *this ) ); |
|
683 |
|
684 if (err != KErrNone) |
|
685 { |
|
686 iTMSession = NULL; |
|
687 TN_DEBUG2( "CThumbAGProcessor::RunL() - Session restart failed, error == %d", err ); |
|
688 } |
|
689 else { |
|
690 iSessionDied = EFalse; |
|
691 } |
|
692 } |
|
693 |
|
694 // do not run if request is already issued to TNM server even if forced |
|
695 if( iActive) |
|
696 { |
|
697 if(iActiveCount <= KMaxDaemonRequests) |
|
698 { |
|
699 iActiveCount++; |
|
700 TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for previous to complete, abort..." ); |
|
701 return; |
|
702 } |
|
703 else |
|
704 { |
|
705 TN_DEBUG1( "CThumbAGProcessor::RunL() - iActive jammed - resetted" ); |
|
706 iActive = EFalse; |
|
707 iActiveCount = 0; |
|
708 } |
|
709 } |
|
710 else |
|
711 { |
|
712 iActiveCount = 0; |
|
713 } |
|
714 |
|
715 //Iforce run can proceed from this point |
|
716 if( !iForceRun ) |
|
717 { |
|
718 //check if harvesting or waiting timeout |
|
719 if( iHarvesting || iTimerActive || iMPXHarvesting ) |
|
720 { |
|
721 TN_DEBUG1( "void CThumbAGProcessor::RunL() Harvester or timer active, abort"); |
|
722 return; |
|
723 } |
|
724 else |
|
725 { |
|
726 //check is server idle |
|
727 TInt idle(-1); |
|
728 |
|
729 TInt ret = RProperty::Get(KServerIdle, KIdle, idle); |
|
730 |
|
731 if(ret == KErrNone ) |
|
732 { |
|
733 if(!idle) |
|
734 { |
|
735 //start wait timer and retry on after callback |
|
736 TN_DEBUG1( "CThumbAGProcessor::RunL() server not idle, wait... " ); |
|
737 if( !iTimerActive) |
|
738 { |
|
739 StartTimeout(); |
|
740 } |
|
741 return; |
|
742 } |
|
743 } |
|
744 else |
|
745 { |
|
746 TN_DEBUG2( "CThumbAGProcessor::RunL() get KServerIdle failed %d, continue...", ret ); |
|
747 } |
|
748 } |
|
749 } |
|
750 else |
|
751 { |
|
752 TN_DEBUG1( "void CThumbAGProcessor::RunL() forced run"); |
|
753 } |
|
754 |
|
755 |
|
756 //Handle completed MDS Query |
|
757 if( iQueryReady && iProcessingCount) |
|
758 { |
|
759 TInt err(KErrNone); |
|
760 if((iForceRun && iModify) || (!iForceRun && !iModify)) |
|
761 { |
|
762 TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" ); |
|
763 |
|
764 |
|
765 const CMdEObject* object = &iQuery->Result( iProcessingCount-1 ); |
|
766 iProcessingCount--; |
|
767 |
|
768 // process one item at once |
|
769 if ( object ) |
|
770 { |
|
771 TRAP( err, CreateThumbnailsL(object) ); |
|
772 |
|
773 if ( err != KErrNone ) |
|
774 { |
|
775 TN_DEBUG2( "CThumbAGProcessor::RunL(), CreateThumbnailsL error == %d", err ); |
|
776 } |
|
777 } |
|
778 } |
|
779 else |
|
780 { |
|
781 TN_DEBUG1( "CThumbAGProcessor::RunL() - deleting query" ); |
|
782 delete iQuery; |
|
783 iQuery = NULL; |
|
784 iQueryReady = EFalse; |
|
785 iProcessingCount = 0; |
|
786 ActivateAO(); |
|
787 return; |
|
788 } |
|
789 |
|
790 //is last query item |
|
791 if( iProcessingCount <= 0 ) |
|
792 { |
|
793 TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady FINISH" ); |
|
794 iQueryReady = EFalse; |
|
795 iQueryActive = EFalse; |
|
796 iModify = EFalse; |
|
797 |
|
798 //check if forced run needs to continue |
|
799 if (iModifyQueue.Count()) |
|
800 { |
|
801 iForceRun = ETrue; |
|
802 } |
|
803 else |
|
804 { |
|
805 iForceRun = EFalse; |
|
806 } |
|
807 |
|
808 } |
|
809 //keep going if processing Remove items or if Add item fails |
|
810 else if( iModify || err ) |
|
811 { |
|
812 ActivateAO(); |
|
813 } |
|
814 } |
|
815 //waiting for MDS query to complete |
|
816 else if( iQueryActive || iQueryForPlaceholdersActive ) |
|
817 { |
|
818 if(iForceRun && !iModify && iQueryActive) |
|
819 { |
|
820 iQuery->Cancel(); |
|
821 delete iQuery; |
|
822 iQuery = NULL; |
|
823 TN_DEBUG1( "CThumbAGProcessor::RunL() - canceling query..." ); |
|
824 iQueryReady = EFalse; |
|
825 iQueryActive = EFalse; |
|
826 ActivateAO(); |
|
827 } |
|
828 else |
|
829 { |
|
830 TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for query to complete, abort..." ); |
|
831 } |
|
832 } |
|
833 |
|
834 // select queue to process, priority by type. Process modify events before new images |
|
835 else if ( iModifyQueue.Count() > 0 ) |
|
836 { |
|
837 TN_DEBUG1( "void CThumbAGProcessor::RunL() update thumbnails"); |
|
838 |
|
839 // query for object info |
|
840 iQueryActive = ETrue; |
|
841 iModify = ETrue; |
|
842 QueryL( iModifyQueue ); |
|
843 } |
|
844 else if ( iRemoveQueue.Count() > 0 ) |
|
845 { |
|
846 TN_DEBUG1( "void CThumbAGProcessor::RunL() delete thumbnails"); |
|
847 |
|
848 // delete thumbs by ID |
|
849 if (iTMSession) |
|
850 { |
|
851 iTMSession->DeleteThumbnails( iRemoveQueue[0] ); |
|
852 } |
|
853 iRemoveQueue.Remove( 0 ); |
|
854 |
|
855 #ifdef _DEBUG |
|
856 iDelCounter++; |
|
857 TN_DEBUG2( "CThumbAGProcessor::OUT-COUNTERS----------, Delete = %d", iDelCounter ); |
|
858 #endif |
|
859 ActivateAO(); |
|
860 } |
|
861 else if ( iAddQueue.Count() > 0 ) |
|
862 { |
|
863 TN_DEBUG1( "void CThumbAGProcessor::RunL() add thumbnails"); |
|
864 |
|
865 // query for object info |
|
866 iQueryActive = ETrue; |
|
867 |
|
868 QueryL( iAddQueue ); |
|
869 } |
|
870 else if ( iPresentQueue.Count() > 0 ) |
|
871 { |
|
872 TN_DEBUG1( "void CThumbAGProcessor::RunL() add thumbnails for present thumbnails" ); |
|
873 |
|
874 // query for object info |
|
875 iQueryActive = ETrue; |
|
876 |
|
877 QueryL( iPresentQueue ); |
|
878 } |
|
879 |
|
880 TN_DEBUG1( "CThumbAGProcessor::RunL() - end" ); |
|
881 } |
|
882 |
|
883 // --------------------------------------------------------------------------- |
|
884 // CThumbAGProcessor::DoCancel() |
|
885 // --------------------------------------------------------------------------- |
|
886 // |
|
887 void CThumbAGProcessor::DoCancel() |
|
888 { |
|
889 // No implementation required |
|
890 } |
|
891 |
|
892 void CThumbAGProcessor::HarvestingUpdated( |
|
893 HarvesterEventObserverType aHEObserverType, |
|
894 HarvesterEventState aHarvesterEventState, |
|
895 TInt /*aItemsLeft*/ ) |
|
896 { |
|
897 TN_DEBUG3( "CThumbAGProcessor::HarvestingUpdated -- start() aHEObserverType = %d, aHarvesterEventState = %d", aHEObserverType, aHarvesterEventState ); |
|
898 |
|
899 if( aHEObserverType == EHEObserverTypePlaceholder) |
|
900 { |
|
901 TRAP_IGNORE( QueryForPlaceholdersL() ); |
|
902 return; |
|
903 } |
|
904 |
|
905 if( aHEObserverType != EHEObserverTypeOverall) |
|
906 { |
|
907 return; |
|
908 } |
|
909 |
|
910 switch(aHarvesterEventState) |
|
911 { |
|
912 case EHEStateStarted: |
|
913 case EHEStateHarvesting: |
|
914 case EHEStatePaused: |
|
915 case EHEStateResumed: |
|
916 { |
|
917 iHarvestingTemp = ETrue; |
|
918 break; |
|
919 } |
|
920 case EHEStateFinished: |
|
921 case EHEStateUninitialized: |
|
922 { |
|
923 iHarvestingTemp = EFalse; |
|
924 break; |
|
925 } |
|
926 }; |
|
927 |
|
928 if(iHarvestingTemp == iHarvesting) |
|
929 { |
|
930 TN_DEBUG2( "CThumbAGProcessor::HarvestingUpdated -- no change %d", iHarvesting); |
|
931 } |
|
932 else |
|
933 { |
|
934 iHarvesting = iHarvestingTemp; |
|
935 |
|
936 if( iHarvesting ) |
|
937 { |
|
938 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesterin started"); |
|
939 CancelTimeout(); |
|
940 } |
|
941 else |
|
942 { |
|
943 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesting finished "); |
|
944 // continue processing if needed |
|
945 StartTimeout(); |
|
946 |
|
947 iTempModifyQueue.Reset(); |
|
948 iTempAddQueue.Reset(); |
|
949 iPlaceholderIDs.Reset(); |
|
950 } |
|
951 } |
|
952 |
|
953 TN_DEBUG3( "CThumbAGProcessor::HarvestingUpdated -- end() iHarvesting == %d, iMPXHarvesting == %d", iHarvesting, iMPXHarvesting); |
|
954 } |
|
955 |
|
956 // --------------------------------------------------------------------------- |
|
957 // CThumbAGProcessor::StartTimeout() |
|
958 // --------------------------------------------------------------------------- |
|
959 // |
|
960 void CThumbAGProcessor::StartTimeout() |
|
961 { |
|
962 CancelTimeout(); |
|
963 |
|
964 if(!iHarvesting && !iMPXHarvesting && !iPeriodicTimer->IsActive()) |
|
965 { |
|
966 iPeriodicTimer->Start( KHarvestingCompleteTimeout, KHarvestingCompleteTimeout, |
|
967 TCallBack(PeriodicTimerCallBack, this)); |
|
968 iTimerActive = ETrue; |
|
969 } |
|
970 else |
|
971 { |
|
972 iTimerActive = EFalse; |
|
973 } |
|
974 } |
|
975 |
|
976 // --------------------------------------------------------------------------- |
|
977 // CThumbAGProcessor::StopTimeout() |
|
978 // --------------------------------------------------------------------------- |
|
979 // |
|
980 void CThumbAGProcessor::CancelTimeout() |
|
981 { |
|
982 if(iTimerActive) |
|
983 { |
|
984 iPeriodicTimer->Cancel(); |
|
985 } |
|
986 iTimerActive = EFalse; |
|
987 } |
|
988 |
|
989 // --------------------------------------------------------------------------- |
|
990 // CThumbAGProcessor::RunError() |
|
991 // --------------------------------------------------------------------------- |
|
992 // |
|
993 TInt CThumbAGProcessor::RunError(TInt aError) |
|
994 { |
|
995 if (aError != KErrNone) |
|
996 { |
|
997 TN_DEBUG2( "CThumbAGProcessor::RunError = %d", aError ); |
|
998 } |
|
999 |
|
1000 iActive = EFalse; |
|
1001 |
|
1002 // nothing to do |
|
1003 return KErrNone; |
|
1004 } |
|
1005 |
|
1006 // --------------------------------------------------------------------------- |
|
1007 // CThumbAGProcessor::ActivateAO() |
|
1008 // --------------------------------------------------------------------------- |
|
1009 // |
|
1010 void CThumbAGProcessor::ActivateAO() |
|
1011 { |
|
1012 if(iFormatting) |
|
1013 { |
|
1014 TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE"); |
|
1015 return; |
|
1016 } |
|
1017 |
|
1018 if( !IsActive() && (!iHarvesting || iForceRun )) |
|
1019 { |
|
1020 #ifdef _DEBUG |
|
1021 if( iForceRun ) |
|
1022 { |
|
1023 TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - *** FORCED RUN ***"); |
|
1024 } |
|
1025 #endif |
|
1026 SetActive(); |
|
1027 TRequestStatus* statusPtr = &iStatus; |
|
1028 User::RequestComplete( statusPtr, KErrNone ); |
|
1029 } |
|
1030 } |
|
1031 |
|
1032 // --------------------------------------------------------------------------- |
|
1033 // CThumbAGProcessor::PeriodicTimerCallBack() |
|
1034 // --------------------------------------------------------------------------- |
|
1035 // |
|
1036 TInt CThumbAGProcessor::PeriodicTimerCallBack(TAny* aAny) |
|
1037 { |
|
1038 TN_DEBUG1( "CThumbAGProcessor::PeriodicTimerCallBack()"); |
|
1039 CThumbAGProcessor* self = static_cast<CThumbAGProcessor*>( aAny ); |
|
1040 |
|
1041 self->CancelTimeout(); |
|
1042 self->ActivateAO(); |
|
1043 |
|
1044 return KErrNone; // Return value ignored by CPeriodic |
|
1045 } |
|
1046 |
|
1047 // --------------------------------------------------------------------------- |
|
1048 // CThumbAGProcessor::CheckAutoCreateValuesL() |
|
1049 // --------------------------------------------------------------------------- |
|
1050 // |
|
1051 void CThumbAGProcessor::CheckAutoCreateValuesL() |
|
1052 { |
|
1053 CRepository* rep = CRepository::NewL( TUid::Uid( THUMBNAIL_CENREP_UID )); |
|
1054 |
|
1055 TBool imageGrid( EFalse ); |
|
1056 TBool imageList( EFalse ); |
|
1057 TBool imageFull( EFalse ); |
|
1058 TBool videoGrid( EFalse ); |
|
1059 TBool videoList( EFalse ); |
|
1060 TBool videoFull( EFalse ); |
|
1061 TBool audioGrid( EFalse ); |
|
1062 TBool audioList( EFalse ); |
|
1063 TBool audioFull( EFalse ); |
|
1064 |
|
1065 // get cenrep values |
|
1066 rep->Get( KAutoCreateImageGrid, imageGrid ); |
|
1067 rep->Get( KAutoCreateImageList, imageList ); |
|
1068 rep->Get( KAutoCreateImageFullscreen, imageFull ); |
|
1069 rep->Get( KAutoCreateVideoGrid, videoGrid ); |
|
1070 rep->Get( KAutoCreateVideoList, videoList ); |
|
1071 rep->Get( KAutoCreateVideoFullscreen, videoFull ); |
|
1072 rep->Get( KAutoCreateAudioGrid, audioGrid ); |
|
1073 rep->Get( KAutoCreateAudioList, audioList ); |
|
1074 rep->Get( KAutoCreateAudioFullscreen, audioFull ); |
|
1075 |
|
1076 iAutoImage = EFalse; |
|
1077 iAutoVideo = EFalse; |
|
1078 iAutoAudio = EFalse; |
|
1079 |
|
1080 // set processing values |
|
1081 if (imageGrid || imageList || imageFull) |
|
1082 { |
|
1083 iAutoImage = ETrue; |
|
1084 } |
|
1085 if (videoGrid || videoList || videoFull) |
|
1086 { |
|
1087 iAutoVideo = ETrue; |
|
1088 } |
|
1089 if (audioGrid || audioList || audioFull) |
|
1090 { |
|
1091 iAutoAudio = ETrue; |
|
1092 } |
|
1093 |
|
1094 delete rep; |
|
1095 } |
|
1096 |
|
1097 // --------------------------------------------------------------------------- |
|
1098 // CThumbAGProcessor::RemoveFromQueues() |
|
1099 // --------------------------------------------------------------------------- |
|
1100 // |
|
1101 void CThumbAGProcessor::RemoveFromQueues( const RArray<TItemId>& aIDArray, const TBool aRemoveFromDelete ) |
|
1102 { |
|
1103 TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() aRemoveFromDelete == %d - begin", aRemoveFromDelete ); |
|
1104 |
|
1105 TInt itemIndex = KErrNotFound; |
|
1106 |
|
1107 for (int i=0; i< aIDArray.Count(); i++) |
|
1108 { |
|
1109 TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]); |
|
1110 |
|
1111 itemIndex = iAddQueue.Find( aIDArray[i] ); |
|
1112 |
|
1113 if(itemIndex >= 0) |
|
1114 { |
|
1115 iAddQueue.Remove(itemIndex); |
|
1116 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iAddQueue" ); |
|
1117 continue; |
|
1118 } |
|
1119 |
|
1120 itemIndex = iPresentQueue.Find( aIDArray[i] ); |
|
1121 |
|
1122 if(itemIndex >= 0) |
|
1123 { |
|
1124 iPresentQueue.Remove(itemIndex); |
|
1125 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPresentQueue" ); |
|
1126 continue; |
|
1127 } |
|
1128 |
|
1129 itemIndex = iModifyQueue.Find( aIDArray[i] ); |
|
1130 |
|
1131 if(itemIndex >= 0) |
|
1132 { |
|
1133 iModifyQueue.Remove(itemIndex); |
|
1134 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iModifyQueue" ); |
|
1135 |
|
1136 if( iModifyQueue.Count() == 0) |
|
1137 { |
|
1138 iForceRun = EFalse; |
|
1139 } |
|
1140 |
|
1141 continue; |
|
1142 } |
|
1143 |
|
1144 if( aRemoveFromDelete ) |
|
1145 { |
|
1146 itemIndex = iRemoveQueue.Find( aIDArray[i] ); |
|
1147 |
|
1148 if(itemIndex >= 0) |
|
1149 { |
|
1150 iRemoveQueue.Remove(itemIndex); |
|
1151 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iRemoveQueue" ); |
|
1152 continue; |
|
1153 } |
|
1154 } |
|
1155 } |
|
1156 |
|
1157 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - end" ); |
|
1158 } |
|
1159 |
|
1160 // --------------------------------------------------------------------------- |
|
1161 // CThumbAGProcessor::SetForceRun() |
|
1162 // --------------------------------------------------------------------------- |
|
1163 // |
|
1164 void CThumbAGProcessor::SetForceRun( const TBool aForceRun) |
|
1165 { |
|
1166 TN_DEBUG2( "CThumbAGProcessor::SetForceRun(%d) - end", aForceRun ); |
|
1167 |
|
1168 // enable forced run |
|
1169 if (aForceRun) |
|
1170 { |
|
1171 iForceRun = aForceRun; |
|
1172 } |
|
1173 } |
|
1174 |
|
1175 // --------------------------------------------------------------------------- |
|
1176 // CThumbAGProcessor::SetFormat() |
|
1177 // --------------------------------------------------------------------------- |
|
1178 // |
|
1179 |
|
1180 void CThumbAGProcessor::SetFormat(TBool aStatus) |
|
1181 { |
|
1182 TN_DEBUG2( "CThumbAGProcessor::SetFormat(%d) - end", aStatus ); |
|
1183 |
|
1184 iFormatting = aStatus; |
|
1185 if(!aStatus) |
|
1186 { |
|
1187 ActivateAO(); |
|
1188 } |
|
1189 } |
|
1190 |
|
1191 // --------------------------------------------------------------------------- |
|
1192 // CThumbAGProcessor::QueryForPlaceholders() |
|
1193 // --------------------------------------------------------------------------- |
|
1194 // |
|
1195 |
|
1196 void CThumbAGProcessor::QueryForPlaceholdersL() |
|
1197 { |
|
1198 TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders" ); |
|
1199 if(iQueryForPlaceholdersActive) |
|
1200 { |
|
1201 TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders - skip" ); |
|
1202 return; |
|
1203 } |
|
1204 |
|
1205 TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders - start" ); |
|
1206 |
|
1207 // delete old query |
|
1208 if (iQueryForPlaceholders) |
|
1209 { |
|
1210 iQueryForPlaceholdersActive = EFalse; |
|
1211 iQueryForPlaceholders->Cancel(); |
|
1212 delete iQueryForPlaceholders; |
|
1213 iQueryForPlaceholders = NULL; |
|
1214 } |
|
1215 |
|
1216 CMdEObjectDef& imageObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject ); |
|
1217 CMdEObjectDef& videoObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject ); |
|
1218 CMdEObjectDef& audioObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
1219 |
|
1220 CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject); |
|
1221 iQueryForPlaceholders = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this ); |
|
1222 |
|
1223 iQueryForPlaceholders->SetResultMode( EQueryResultModeItem ); |
|
1224 |
|
1225 CMdELogicCondition& rootCondition = iQueryForPlaceholders->Conditions(); |
|
1226 rootCondition.SetOperator( ELogicConditionOperatorOr ); |
|
1227 |
|
1228 CMdEObjectCondition& imagePHObjectCondition = rootCondition.AddObjectConditionL(imageObjDef); |
|
1229 imagePHObjectCondition.SetPlaceholderOnly( ETrue ); |
|
1230 imagePHObjectCondition.SetNotPresent( ETrue ); |
|
1231 |
|
1232 CMdEObjectCondition& videoPHObjectCondition = rootCondition.AddObjectConditionL(videoObjDef); |
|
1233 videoPHObjectCondition.SetPlaceholderOnly( ETrue ); |
|
1234 videoPHObjectCondition.SetNotPresent( ETrue ); |
|
1235 |
|
1236 CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef); |
|
1237 audioPHObjectCondition.SetPlaceholderOnly( ETrue ); |
|
1238 audioPHObjectCondition.SetNotPresent( ETrue ); |
|
1239 |
|
1240 iQueryForPlaceholders->FindL(); |
|
1241 |
|
1242 iQueryForPlaceholdersActive = ETrue; |
|
1243 |
|
1244 TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders - end" ); |
|
1245 } |
|
1246 |
|
1247 // ----------------------------------------------------------------------------- |
|
1248 // CThumbAGProcessor::HandleCollectionMessage |
|
1249 // From MMPXCollectionObserver |
|
1250 // Handle collection message. |
|
1251 // ----------------------------------------------------------------------------- |
|
1252 // |
|
1253 |
|
1254 void CThumbAGProcessor::HandleCollectionMessage( CMPXMessage* aMessage, |
|
1255 TInt aError ) |
|
1256 { |
|
1257 if ( aError != KErrNone || !aMessage ) |
|
1258 { |
|
1259 return; |
|
1260 } |
|
1261 |
|
1262 TN_DEBUG1( "CThumbAGProcessor::HandleCollectionMessage" ); |
|
1263 |
|
1264 TMPXMessageId generalId( *aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ) ); |
|
1265 |
|
1266 //we are interestead of only general system events |
|
1267 if ( generalId == KMPXMessageGeneral ) |
|
1268 { |
|
1269 TInt event( *aMessage->Value<TInt>( KMPXMessageGeneralEvent ) ); |
|
1270 if ( event == TMPXCollectionMessage::EBroadcastEvent ) |
|
1271 { |
|
1272 TInt op( *aMessage->Value<TInt>( KMPXMessageGeneralType ) ); |
|
1273 |
|
1274 switch( op ) |
|
1275 { |
|
1276 //when MTP sync or music collection is started then pause processing |
|
1277 case EMcMsgRefreshStart: |
|
1278 case EMcMsgUSBMTPStart: |
|
1279 TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh started" ); |
|
1280 iMPXHarvesting = ETrue; |
|
1281 CancelTimeout(); |
|
1282 break; |
|
1283 //when MTP sync or music collection refresh is complete then resume processing |
|
1284 case EMcMsgRefreshEnd: |
|
1285 case EMcMsgUSBMTPEnd: |
|
1286 case EMcMsgUSBMTPNotActive: |
|
1287 TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh finished/not active" ); |
|
1288 iMPXHarvesting = EFalse; |
|
1289 StartTimeout(); |
|
1290 break; |
|
1291 default: |
|
1292 break; |
|
1293 } |
|
1294 TN_DEBUG3( "CThumbAGProcessor::HandleCollectionMessage -- end() iHarvesting == %d, iMPXHarvesting == %d", iHarvesting, iMPXHarvesting); |
|
1295 } |
|
1296 } |
|
1297 } |
|
1298 // ----------------------------------------------------------------------------- |
|
1299 // CThumbAGProcessor::HandleOpenL |
|
1300 // From MMPXCollectionObserver |
|
1301 // Handles the collection entries being opened. |
|
1302 // ----------------------------------------------------------------------------- |
|
1303 // |
|
1304 void CThumbAGProcessor::HandleOpenL( const CMPXMedia& /*aEntries*/, |
|
1305 TInt /*aIndex*/, |
|
1306 TBool /*aComplete*/, |
|
1307 TInt /*aError*/ ) |
|
1308 { |
|
1309 // not needed here |
|
1310 } |
|
1311 |
|
1312 // ----------------------------------------------------------------------------- |
|
1313 // CThumbAGProcessor::HandleOpenL |
|
1314 // From MMPXCollectionObserver |
|
1315 // Handles an item being opened. |
|
1316 // ----------------------------------------------------------------------------- |
|
1317 void CThumbAGProcessor::HandleOpenL( const CMPXCollectionPlaylist& /*aPlaylist*/, TInt /*aError*/ ) |
|
1318 { |
|
1319 // not needed here |
|
1320 } |
|
1321 |
|
1322 // ----------------------------------------------------------------------------- |
|
1323 // CThumbAGProcessor::HandleCollectionMediaL |
|
1324 // From MMPXCollectionObserver |
|
1325 // Handle media properties. |
|
1326 // ----------------------------------------------------------------------------- |
|
1327 // |
|
1328 void CThumbAGProcessor::HandleCollectionMediaL( const CMPXMedia& /*aMedia*/, |
|
1329 TInt /*aError*/ ) |
|
1330 { |
|
1331 // not needed here |
|
1332 } |
|
1333 |
|
1334 // End of file |