367 iModify = EFalse; |
367 iModify = EFalse; |
368 } |
368 } |
369 } |
369 } |
370 else |
370 else |
371 { |
371 { |
372 TInt itemIndex(KErrNotFound); |
372 DeleteAndCancelQuery(); |
373 |
373 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() Query FAILED!"); |
374 //cleanup current queue |
|
375 while(iQueryQueue.Count()) |
|
376 { |
|
377 itemIndex = iLastQueue->FindInOrder(iQueryQueue[0], Compare); |
|
378 if(itemIndex >= 0) |
|
379 { |
|
380 iLastQueue->Remove( itemIndex ); |
|
381 } |
|
382 iQueryQueue.Remove(0); |
|
383 } |
|
384 |
|
385 delete iQuery; |
|
386 iQuery = NULL; |
|
387 iProcessingCount = 0; |
|
388 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() Query FAILED!"); |
|
389 } |
374 } |
390 } |
375 } |
391 else |
376 else |
392 { |
377 { |
393 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() - NO QUERY ACTIVE"); |
378 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() - NO QUERY ACTIVE"); |
744 |
729 |
745 //move ID from source queue to Query queue |
730 //move ID from source queue to Query queue |
746 TInt maxCount = aIDArray.Count(); |
731 TInt maxCount = aIDArray.Count(); |
747 |
732 |
748 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
733 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
749 |
734 |
750 for(TInt i=0;i < KMaxQueryItems && i < maxCount; i++) |
735 for(TInt i=0; i < KMaxQueryItems && i < maxCount; i++) |
751 { |
736 { |
752 TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", aIDArray[i] ); |
737 TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", aIDArray[0] ); |
753 iQueryQueue.InsertInOrder(aIDArray[i], Compare); |
738 iQueryQueue.InsertInOrder(aIDArray[0], Compare); |
|
739 aIDArray.Remove(0); |
754 } |
740 } |
755 |
741 |
756 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
742 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
757 |
743 |
758 CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
744 CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
909 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err)); |
895 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err)); |
910 |
896 |
911 if( err == KErrNone ) |
897 if( err == KErrNone ) |
912 { |
898 { |
913 TN_DEBUG1( "CThumbAGProcessor::RunL() add iHarvesterClient observer"); |
899 TN_DEBUG1( "CThumbAGProcessor::RunL() add iHarvesterClient observer"); |
914 err = iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall | EHEObserverTypePlaceholder, KMaxTInt ); |
900 err = iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall | EHEObserverTypeMMC | EHEObserverTypePlaceholder, KMaxTInt ); |
915 TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient observer err = %d", err); |
901 TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient observer err = %d", err); |
916 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err)); |
902 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err)); |
917 } |
903 } |
918 #endif |
904 #endif |
919 |
905 |
981 |
967 |
982 if( iForceRun || iForegroundRun ) |
968 if( iForceRun || iForegroundRun ) |
983 { |
969 { |
984 TN_DEBUG1( "void CThumbAGProcessor::RunL() skip idle detection!"); |
970 TN_DEBUG1( "void CThumbAGProcessor::RunL() skip idle detection!"); |
985 CancelTimeout(); |
971 CancelTimeout(); |
986 } |
972 } |
987 else |
973 else |
988 { |
974 { |
989 if(iActivityManager) |
|
990 { |
|
991 iIdle = iActivityManager->IsInactive(); |
|
992 } |
|
993 |
|
994 if( !iIdle || iHarvesting || iMPXHarvesting || iPeriodicTimer->IsActive() ) |
975 if( !iIdle || iHarvesting || iMPXHarvesting || iPeriodicTimer->IsActive() ) |
995 { |
976 { |
996 TN_DEBUG1( "void CThumbAGProcessor::RunL() device not idle"); |
977 TN_DEBUG1( "void CThumbAGProcessor::RunL() device not idle"); |
997 return; |
978 return; |
998 } |
979 } |
1023 TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" ); |
1004 TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" ); |
1024 |
1005 |
1025 const CMdEObject* object = &iQuery->Result( iProcessingCount-1 ); |
1006 const CMdEObject* object = &iQuery->Result( iProcessingCount-1 ); |
1026 iProcessingCount--; |
1007 iProcessingCount--; |
1027 |
1008 |
1028 TInt itemIndex = iLastQueue->FindInOrder(object->Id(), Compare); |
1009 if ( object ) |
1029 if(itemIndex >= 0) |
1010 { |
1030 { |
1011 TInt itemIndex = iLastQueue->FindInOrder(object->Id(), Compare); |
1031 iLastQueue->Remove(itemIndex); |
1012 if(itemIndex >= 0) |
1032 } |
1013 { |
|
1014 iLastQueue->Remove(itemIndex); |
|
1015 } |
1033 |
1016 |
1034 // process one item at once |
1017 //process one item at once |
1035 if ( object ) |
|
1036 { |
|
1037 //remove item from queryQueue when request is issued |
1018 //remove item from queryQueue when request is issued |
1038 itemIndex = iQueryQueue.FindInOrder(object->Id(), Compare); |
1019 itemIndex = iQueryQueue.FindInOrder(object->Id(), Compare); |
1039 if(itemIndex >= 0) |
1020 if(itemIndex >= 0) |
1040 { |
1021 { |
1041 iQueryQueue.Remove(itemIndex); |
1022 iQueryQueue.Remove(itemIndex); |
1047 } |
1028 } |
1048 } |
1029 } |
1049 //force is coming, but executing non-forced query complete-> cancel old |
1030 //force is coming, but executing non-forced query complete-> cancel old |
1050 else |
1031 else |
1051 { |
1032 { |
1052 TN_DEBUG1( "CThumbAGProcessor::RunL() - deleting query 1" ); |
1033 DeleteAndCancelQuery(); |
1053 delete iQuery; |
1034 ActivateAO(); |
1054 iQuery = NULL; |
1035 return; |
1055 iQueryReady = EFalse; |
|
1056 iProcessingCount = 0; |
|
1057 |
|
1058 //move remainig IDs in query queue back to original queue |
|
1059 while(iQueryQueue.Count()) |
|
1060 { |
|
1061 if(iLastQueue) |
|
1062 { |
|
1063 if(iLastQueue->FindInOrder(iQueryQueue[0], Compare) == KErrNotFound) |
|
1064 { |
|
1065 //ignore if fails |
|
1066 iLastQueue->InsertInOrder(iQueryQueue[0], Compare); |
|
1067 } |
|
1068 } |
|
1069 iQueryQueue.Remove(0); |
|
1070 } |
|
1071 iLastQueue = NULL; |
|
1072 ActivateAO(); |
|
1073 return; |
|
1074 } |
1036 } |
1075 |
1037 |
1076 //is last query item |
1038 //is last query item |
1077 if( iProcessingCount <= 0 ) |
1039 if( iProcessingCount <= 0 ) |
1078 { |
1040 { |
1086 //waiting for MDS query to complete |
1048 //waiting for MDS query to complete |
1087 else if( iQueryActive ) |
1049 else if( iQueryActive ) |
1088 { |
1050 { |
1089 if(iForceRun && !iModify) |
1051 if(iForceRun && !iModify) |
1090 { |
1052 { |
1091 if(iQuery) |
1053 DeleteAndCancelQuery(); |
1092 { |
|
1093 TN_DEBUG1( "CThumbAGProcessor::RunL() - deleting query 2" ); |
|
1094 iQuery->Cancel(); |
|
1095 delete iQuery; |
|
1096 iQuery = NULL; |
|
1097 } |
|
1098 |
|
1099 iQueryReady = EFalse; |
|
1100 iQueryActive = EFalse; |
|
1101 |
|
1102 //move remainig IDs in query queue back to original queue |
|
1103 while(iQueryQueue.Count()) |
|
1104 { |
|
1105 if(iLastQueue) |
|
1106 { |
|
1107 if(iLastQueue->FindInOrder(iQueryQueue[0], Compare) == KErrNotFound) |
|
1108 { |
|
1109 //ignore if fails |
|
1110 iLastQueue->InsertInOrder(iQueryQueue[0], Compare); |
|
1111 } |
|
1112 } |
|
1113 iQueryQueue.Remove(0); |
|
1114 } |
|
1115 iLastQueue = NULL; |
|
1116 |
|
1117 ActivateAO(); |
1054 ActivateAO(); |
1118 } |
1055 } |
1119 else |
1056 else |
1120 { |
1057 { |
1121 TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for query to complete, abort..." ); |
1058 TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for query to complete, abort..." ); |
1184 |
1121 |
1185 TN_DEBUG1( "CThumbAGProcessor::RunL() - end" ); |
1122 TN_DEBUG1( "CThumbAGProcessor::RunL() - end" ); |
1186 } |
1123 } |
1187 |
1124 |
1188 // --------------------------------------------------------------------------- |
1125 // --------------------------------------------------------------------------- |
|
1126 // CThumbAGProcessor::DeleteAndCancelQuery() |
|
1127 // --------------------------------------------------------------------------- |
|
1128 // |
|
1129 void CThumbAGProcessor::DeleteAndCancelQuery() |
|
1130 { |
|
1131 TN_DEBUG1( "CThumbAGProcessor::DeleteAndCancelQuery() in" ); |
|
1132 |
|
1133 if(iQuery) |
|
1134 { |
|
1135 TN_DEBUG1( "CThumbAGProcessor::DeleteAndCancelQuery() - deleting query" ); |
|
1136 iQuery->Cancel(); |
|
1137 delete iQuery; |
|
1138 iQuery = NULL; |
|
1139 } |
|
1140 |
|
1141 iQueryReady = EFalse; |
|
1142 iQueryActive = EFalse; |
|
1143 iProcessingCount = 0; |
|
1144 |
|
1145 //move remainig IDs in query queue back to original queue |
|
1146 while(iQueryQueue.Count()) |
|
1147 { |
|
1148 if(iLastQueue) |
|
1149 { |
|
1150 if(iLastQueue->FindInOrder(iQueryQueue[0], Compare) == KErrNotFound) |
|
1151 { |
|
1152 //ignore if fails |
|
1153 iLastQueue->InsertInOrder(iQueryQueue[0], Compare); |
|
1154 } |
|
1155 } |
|
1156 iQueryQueue.Remove(0); |
|
1157 } |
|
1158 iLastQueue = NULL; |
|
1159 |
|
1160 TN_DEBUG1( "CThumbAGProcessor::DeleteAndCancelQuery() out" ); |
|
1161 } |
|
1162 |
|
1163 // --------------------------------------------------------------------------- |
1189 // CThumbAGProcessor::DoCancel() |
1164 // CThumbAGProcessor::DoCancel() |
1190 // --------------------------------------------------------------------------- |
1165 // --------------------------------------------------------------------------- |
1191 // |
1166 // |
1192 void CThumbAGProcessor::DoCancel() |
1167 void CThumbAGProcessor::DoCancel() |
1193 { |
1168 { |
1284 // continue processing if needed |
1259 // continue processing if needed |
1285 StartTimeout(); |
1260 StartTimeout(); |
1286 } |
1261 } |
1287 } |
1262 } |
1288 } |
1263 } |
|
1264 //MMC harvesting |
|
1265 else if( aHEObserverType == EHEObserverTypeMMC) |
|
1266 { |
|
1267 switch(aHarvesterEventState) |
|
1268 { |
|
1269 case EHEStateStarted: |
|
1270 case EHEStateHarvesting: |
|
1271 case EHEStatePaused: |
|
1272 case EHEStateResumed: |
|
1273 { |
|
1274 iMMCHarvestingTemp = ETrue; |
|
1275 break; |
|
1276 } |
|
1277 case EHEStateFinished: |
|
1278 case EHEStateUninitialized: |
|
1279 { |
|
1280 iMMCHarvestingTemp = EFalse; |
|
1281 break; |
|
1282 } |
|
1283 }; |
|
1284 |
|
1285 if(iMMCHarvestingTemp != iMMCHarvesting) |
|
1286 { |
|
1287 iMMCHarvesting = iMMCHarvestingTemp; |
|
1288 |
|
1289 if( iMMCHarvesting ) |
|
1290 { |
|
1291 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS MMC harvesterin started"); |
|
1292 if(iPreviousItemsLeft != KErrNotReady) |
|
1293 { |
|
1294 iPreviousItemsLeft = KErrNotReady; |
|
1295 RProperty::Set(KTAGDPSNotification, KDaemonProcessing, iPreviousItemsLeft); |
|
1296 } |
|
1297 } |
|
1298 else |
|
1299 { |
|
1300 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS MMC harvesting finished "); |
|
1301 } |
|
1302 } |
|
1303 } |
1289 |
1304 |
1290 TN_DEBUG3( "CThumbAGProcessor::HarvestingUpdated -- end() iHarvesting == %d, iPHHarvesting == %d ", iHarvesting, iPHHarvesting); |
1305 TN_DEBUG4( "CThumbAGProcessor::HarvestingUpdated -- end() iHarvesting == %d, iPHHarvesting == %d iMMCHarvesting == %d ", iHarvesting, iPHHarvesting, iMMCHarvesting); |
1291 } |
1306 } |
1292 |
1307 |
1293 // --------------------------------------------------------------------------- |
1308 // --------------------------------------------------------------------------- |
1294 // CThumbAGProcessor::StartTimeout() |
1309 // CThumbAGProcessor::StartTimeout() |
1295 // --------------------------------------------------------------------------- |
1310 // --------------------------------------------------------------------------- |
1768 if(itemsLeft + i2ndRoundGenerateQueue.Count() + iRemoveQueue.Count() > 0 ) |
1783 if(itemsLeft + i2ndRoundGenerateQueue.Count() + iRemoveQueue.Count() > 0 ) |
1769 { |
1784 { |
1770 daemonProcessing = ETrue; |
1785 daemonProcessing = ETrue; |
1771 } |
1786 } |
1772 |
1787 |
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 |
|
1780 //adjust items left to containing also items not yet processed but removed from queue under processing |
1788 //adjust items left to containing also items not yet processed but removed from queue under processing |
1781 if((iLastQueue == &iModifyQueue || iLastQueue == &iAddQueue) && !i2ndRound) |
1789 if((iLastQueue == &iModifyQueue || iLastQueue == &iAddQueue) && !i2ndRound) |
1782 { |
1790 { |
1783 itemsLeft +=iQueryQueue.Count(); |
1791 itemsLeft +=iQueryQueue.Count(); |
1784 } |
1792 } |
1785 |
1793 |
|
1794 //cancel 2nd round generarion when there is items in 1st round queues |
|
1795 if(itemsLeft && i2ndRound) |
|
1796 { |
|
1797 DeleteAndCancelQuery(); |
|
1798 i2ndRound = EFalse; |
|
1799 } |
|
1800 |
1786 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() KItemsleft == %d", itemsLeft); |
1801 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() KItemsleft == %d", itemsLeft); |
1787 |
1802 |
1788 if(aDefine) |
1803 if(aDefine) |
1789 { |
1804 { |
1790 TN_DEBUG1( "CThumbAGProcessor::UpdatePSValues() define"); |
1805 TN_DEBUG1( "CThumbAGProcessor::UpdatePSValues() define"); |