93 iActivityManager = CTMActivityManager::NewL( this, KBackgroundGenerationIdle); |
93 iActivityManager = CTMActivityManager::NewL( this, KBackgroundGenerationIdle); |
94 |
94 |
95 UpdatePSValues(ETrue); |
95 UpdatePSValues(ETrue); |
96 |
96 |
97 if(iForegroundGenerationObserver) |
97 if(iForegroundGenerationObserver) |
98 { |
98 { |
99 delete iForegroundGenerationObserver; |
99 delete iForegroundGenerationObserver; |
100 iForegroundGenerationObserver = NULL; |
100 iForegroundGenerationObserver = NULL; |
101 } |
101 } |
102 |
102 |
103 RProperty::Define(KTAGDPSNotification, KMPXHarvesting, RProperty::EInt); |
103 RProperty::Define(KTAGDPSNotification, KMPXHarvesting, RProperty::EInt); |
104 |
104 |
105 //start foreground generation observer |
105 //start foreground generation observer |
106 iForegroundGenerationObserver = CTMRPropertyObserver::NewL( *this, KTAGDPSNotification, KForceBackgroundGeneration, ETrue ); |
106 iForegroundGenerationObserver = CTMRPropertyObserver::NewL( *this, KTAGDPSNotification, KForceBackgroundGeneration, ETrue ); |
141 delete iPeriodicTimer; |
141 delete iPeriodicTimer; |
142 } |
142 } |
143 |
143 |
144 if (!iInit) |
144 if (!iInit) |
145 { |
145 { |
146 /* |
146 #ifdef MDS_MODIFY_OBSERVER |
147 iHarvesterClient.RemoveHarvesterEventObserver(*this); |
147 iHarvesterClient.RemoveHarvesterEventObserver(*this); |
148 iHarvesterClient.Close();*/ |
148 iHarvesterClient.Close(); |
|
149 #endif |
149 } |
150 } |
150 |
151 |
151 if ( iCollectionUtility ) |
152 if ( iCollectionUtility ) |
152 { |
153 { |
153 iCollectionUtility->Close(); |
154 iCollectionUtility->Close(); |
245 //} |
246 //} |
246 } |
247 } |
247 } |
248 } |
248 delete iQueryPlaceholders; |
249 delete iQueryPlaceholders; |
249 iQueryPlaceholders = NULL; |
250 iQueryPlaceholders = NULL; |
|
251 |
|
252 if(iDoQueryAllItems) |
|
253 { |
|
254 iDoQueryAllItems = EFalse; |
|
255 TRAP_IGNORE(QueryAllItemsL()); |
|
256 } |
250 } |
257 } |
251 else if(&aQuery == iQueryAllItems) |
258 else if(&aQuery == iQueryAllItems) |
252 { |
259 { |
253 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - QueryAllItems completed"); |
260 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - QueryAllItems completed"); |
254 // if no errors in query |
261 // if no errors in query |
289 // if no errors in query |
296 // if no errors in query |
290 if (aError == KErrNone && iQuery) |
297 if (aError == KErrNone && iQuery) |
291 { |
298 { |
292 iProcessingCount = iQuery->Count(); |
299 iProcessingCount = iQuery->Count(); |
293 |
300 |
|
301 if(iProcessingCount != iQueryQueue.Count()) |
|
302 { |
|
303 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() some result items missing"); |
|
304 |
|
305 RArray<TItemId> iQueryQueueDelta; |
|
306 |
|
307 TInt itemIndex(KErrNotFound); |
|
308 |
|
309 //search delta items |
|
310 for(TInt queryItem =0; queryItem < iQueryQueue.Count();queryItem++) |
|
311 { |
|
312 TBool found(EFalse); |
|
313 for(TInt queryResult = 0; queryResult < iQuery->Count(); queryResult++) |
|
314 { |
|
315 const CMdEObject* object = &iQuery->Result(queryResult); |
|
316 |
|
317 if( iQueryQueue[queryItem] == object->Id()) |
|
318 { |
|
319 found = ETrue; |
|
320 break; |
|
321 } |
|
322 } |
|
323 |
|
324 if(!found) |
|
325 { |
|
326 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing from results item %d", iQueryQueue[queryItem] ); |
|
327 iQueryQueueDelta.Append( iQueryQueue[queryItem] ); |
|
328 } |
|
329 } |
|
330 |
|
331 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing items total count %d", iQueryQueueDelta.Count()); |
|
332 //cleanup from previous queue it item is not found from MDS |
|
333 while(iQueryQueueDelta.Count()) |
|
334 { |
|
335 itemIndex = iLastQueue->Find(iQueryQueueDelta[0]); |
|
336 if(itemIndex >= 0) |
|
337 { |
|
338 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove items %d", iQueryQueue[0]); |
|
339 iLastQueue->Remove( itemIndex ); |
|
340 } |
|
341 iQueryQueueDelta.Remove(0); |
|
342 } |
|
343 iQueryQueueDelta.Close(); |
|
344 } |
|
345 |
|
346 // no results, reset query |
294 if( !iProcessingCount) |
347 if( !iProcessingCount) |
295 { |
348 { |
296 delete iQuery; |
349 delete iQuery; |
297 iQuery = NULL; |
350 iQuery = NULL; |
298 iProcessingCount = 0; |
351 iProcessingCount = 0; |
827 { |
882 { |
828 TN_DEBUG1( "CThumbAGProcessor::RunL() - Do Initialisation 2" ); |
883 TN_DEBUG1( "CThumbAGProcessor::RunL() - Do Initialisation 2" ); |
829 |
884 |
830 iInit2 = EFalse; |
885 iInit2 = EFalse; |
831 TInt err(KErrNone); |
886 TInt err(KErrNone); |
832 /* |
887 |
|
888 #ifdef MDS_MODIFY_OBSERVER |
833 TN_DEBUG1( "CThumbAGProcessor::RunL() do iHarvesterClient connect"); |
889 TN_DEBUG1( "CThumbAGProcessor::RunL() do iHarvesterClient connect"); |
834 TInt err = iHarvesterClient.Connect(); |
890 err = iHarvesterClient.Connect(); |
835 TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient connect err = %d", err); |
891 TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient connect err = %d", err); |
836 |
892 |
837 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err)); |
893 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err)); |
838 |
894 |
839 if( err == KErrNone ) |
895 if( err == KErrNone ) |
840 { |
896 { |
841 TN_DEBUG1( "CThumbAGProcessor::RunL() add iHarvesterClient observer"); |
897 TN_DEBUG1( "CThumbAGProcessor::RunL() add iHarvesterClient observer"); |
842 err = iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall | EHEObserverTypePlaceholder, KMaxTInt ); |
898 err = iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall | EHEObserverTypePlaceholder, KMaxTInt ); |
843 TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient observer err = %d", err); |
899 TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient observer err = %d", err); |
844 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err)); |
900 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err)); |
845 }*/ |
901 } |
|
902 #endif |
846 |
903 |
847 TN_DEBUG1( "CThumbAGProcessor::RunL() MMPXCollectionUtility"); |
904 TN_DEBUG1( "CThumbAGProcessor::RunL() MMPXCollectionUtility"); |
848 TRAP( err, iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated )); |
905 TRAP( err, iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated )); |
849 TN_DEBUG2( "CThumbAGProcessor::RunL() create MMPXCollectionUtility err = %d", err); |
906 TN_DEBUG2( "CThumbAGProcessor::RunL() create MMPXCollectionUtility err = %d", err); |
850 __ASSERT_DEBUG((iCollectionUtility), User::Panic(_L("CThumbAGProcessor::RunL(), !iCollectionUtility "), err)); |
907 __ASSERT_DEBUG((iCollectionUtility), User::Panic(_L("CThumbAGProcessor::RunL(), !iCollectionUtility "), err)); |
929 { |
984 { |
930 //check is server idle |
985 //check is server idle |
931 TInt serveIdle(KErrNotFound); |
986 TInt serveIdle(KErrNotFound); |
932 TInt ret = RProperty::Get(KServerIdle, KIdle, serveIdle); |
987 TInt ret = RProperty::Get(KServerIdle, KIdle, serveIdle); |
933 |
988 |
934 if(ret == KErrNone ) |
989 if(ret != KErrNone || !serveIdle ) |
935 { |
990 { |
936 if(!serveIdle) |
991 //start inactivity timer and retry on after callback |
937 { |
992 TN_DEBUG1( "void CThumbAGProcessor::RunL() server not idle"); |
938 //start inactivity timer and retry on after callback |
993 StartTimeout(); |
939 TN_DEBUG1( "void CThumbAGProcessor::RunL() server not idle"); |
994 return; |
940 StartTimeout(); |
|
941 return; |
|
942 } |
|
943 } |
995 } |
944 TN_DEBUG1( "void CThumbAGProcessor::RunL() device and server idle, process"); |
996 TN_DEBUG1( "void CThumbAGProcessor::RunL() device and server idle, process"); |
945 } |
997 } |
946 } |
998 } |
947 |
999 |
1008 if( iProcessingCount <= 0 ) |
1060 if( iProcessingCount <= 0 ) |
1009 { |
1061 { |
1010 TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady FINISH" ); |
1062 TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady FINISH" ); |
1011 iQueryReady = EFalse; |
1063 iQueryReady = EFalse; |
1012 iQueryActive = EFalse; |
1064 iQueryActive = EFalse; |
1013 iModify = EFalse; |
1065 } |
1014 |
1066 |
1015 //check if forced run needs to continue |
1067 ActivateAO(); |
1016 if (iModifyQueue.Count()) |
|
1017 { |
|
1018 SetForceRun( ETrue ); |
|
1019 } |
|
1020 else |
|
1021 { |
|
1022 SetForceRun( EFalse ); |
|
1023 } |
|
1024 } |
|
1025 //keep going if processing Remove items or if Add item fails |
|
1026 else if( iModify || err ) |
|
1027 { |
|
1028 ActivateAO(); |
|
1029 } |
|
1030 } |
1068 } |
1031 //waiting for MDS query to complete |
1069 //waiting for MDS query to complete |
1032 else if( iQueryActive ) |
1070 else if( iQueryActive ) |
1033 { |
1071 { |
1034 if(iForceRun && !iModify) |
1072 if(iForceRun && !iModify) |
1446 |
1495 |
1447 if( iModifyQueue.Count() == 0) |
1496 if( iModifyQueue.Count() == 0) |
1448 { |
1497 { |
1449 SetForceRun( EFalse ); |
1498 SetForceRun( EFalse ); |
1450 } |
1499 } |
1451 |
1500 } |
1452 continue; |
1501 |
1453 } |
1502 itemIndex = iQueryQueue.Find( aIDArray[i] ); |
1454 |
1503 |
1455 /*if( aRemoveFromDelete ) |
1504 if(itemIndex >= 0) |
|
1505 { |
|
1506 iQueryQueue.Remove(itemIndex); |
|
1507 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iQueryQueue" ); |
|
1508 } |
|
1509 |
|
1510 itemIndex = iPlaceholderQueue.Find( aIDArray[i] ); |
|
1511 |
|
1512 if(itemIndex >= 0) |
|
1513 { |
|
1514 iPlaceholderQueue.Remove(itemIndex); |
|
1515 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPlaceholderQueue" ); |
|
1516 } |
|
1517 |
|
1518 /* |
|
1519 if( aRemoveFromDelete ) |
1456 { |
1520 { |
1457 itemIndex = iRemoveQueue.Find( aIDArray[i] ); |
1521 itemIndex = iRemoveQueue.Find( aIDArray[i] ); |
1458 |
1522 |
1459 if(itemIndex >= 0) |
1523 if(itemIndex >= 0) |
1460 { |
1524 { |
1475 void CThumbAGProcessor::SetForceRun( const TBool aForceRun) |
1539 void CThumbAGProcessor::SetForceRun( const TBool aForceRun) |
1476 { |
1540 { |
1477 TN_DEBUG2( "CThumbAGProcessor::SetForceRun(%d) - end", aForceRun ); |
1541 TN_DEBUG2( "CThumbAGProcessor::SetForceRun(%d) - end", aForceRun ); |
1478 |
1542 |
1479 // enable forced run |
1543 // enable forced run |
1480 if (aForceRun) |
1544 iForceRun = aForceRun; |
1481 { |
|
1482 iForceRun = aForceRun; |
|
1483 } |
|
1484 } |
1545 } |
1485 |
1546 |
1486 // --------------------------------------------------------------------------- |
1547 // --------------------------------------------------------------------------- |
1487 // CThumbAGProcessor::QueryForPlaceholders() |
1548 // CThumbAGProcessor::QueryForPlaceholders() |
1488 // --------------------------------------------------------------------------- |
1549 // --------------------------------------------------------------------------- |
1548 if ( aError != KErrNone || !aMessage ) |
1609 if ( aError != KErrNone || !aMessage ) |
1549 { |
1610 { |
1550 return; |
1611 return; |
1551 } |
1612 } |
1552 |
1613 |
1553 TN_DEBUG1( "CThumbAGProcessor::HandleCollectionMessage" ); |
|
1554 |
|
1555 TMPXMessageId generalId( *aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ) ); |
1614 TMPXMessageId generalId( *aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ) ); |
|
1615 |
|
1616 TN_DEBUG2( "CThumbAGProcessor::HandleCollectionMessage KMPXMessageGeneralId=%d", generalId); |
1556 |
1617 |
1557 //we are interestead of only general system events |
1618 //we are interestead of only general system events |
1558 if ( generalId == KMPXMessageGeneral ) |
1619 if ( generalId == KMPXMessageGeneral ) |
1559 { |
1620 { |
1560 TInt event( *aMessage->Value<TInt>( KMPXMessageGeneralEvent ) ); |
1621 TInt event( *aMessage->Value<TInt>( KMPXMessageGeneralEvent ) ); |
|
1622 TInt op( *aMessage->Value<TInt>( KMPXMessageGeneralType ) ); |
|
1623 TN_DEBUG3( "CThumbAGProcessor::HandleCollectionMessage KMPXMessageGeneralEvent=%d", event, op); |
1561 if ( event == TMPXCollectionMessage::EBroadcastEvent ) |
1624 if ( event == TMPXCollectionMessage::EBroadcastEvent ) |
1562 { |
1625 { |
1563 TInt op( *aMessage->Value<TInt>( KMPXMessageGeneralType ) ); |
|
1564 |
|
1565 switch( op ) |
1626 switch( op ) |
1566 { |
1627 { |
1567 //when MTP sync or music collection is started then pause processing |
1628 //when MTP sync or music collection is started then pause processing |
1568 case EMcMsgRefreshStart: |
1629 case EMcMsgRefreshStart: |
1569 case EMcMsgUSBMTPStart: |
1630 case EMcMsgUSBMTPStart: |
1707 if(itemsLeft + i2ndRoundGenerateQueue.Count() + iRemoveQueue.Count() > 0 ) |
1768 if(itemsLeft + i2ndRoundGenerateQueue.Count() + iRemoveQueue.Count() > 0 ) |
1708 { |
1769 { |
1709 daemonProcessing = ETrue; |
1770 daemonProcessing = ETrue; |
1710 } |
1771 } |
1711 |
1772 |
|
1773 //disable 2nd round generarion when there is items in 1st round queues |
|
1774 //or 2nd queue is empty |
|
1775 if( !i2ndRoundGenerateQueue.Count() || itemsLeft ) |
|
1776 { |
|
1777 i2ndRound = EFalse; |
|
1778 } |
|
1779 |
1712 if(aDefine) |
1780 if(aDefine) |
1713 { |
1781 { |
1714 TN_DEBUG1( "CThumbAGProcessor::UpdatePSValues() define"); |
1782 TN_DEBUG1( "CThumbAGProcessor::UpdatePSValues() define"); |
1715 RProperty::Define(KTAGDPSNotification, KDaemonProcessing, RProperty::EInt); |
1783 RProperty::Define(KTAGDPSNotification, KDaemonProcessing, RProperty::EInt); |
1716 RProperty::Set(KTAGDPSNotification, KDaemonProcessing, 0); |
1784 RProperty::Set(KTAGDPSNotification, KDaemonProcessing, 0); |