imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp
branchRCL_3
changeset 10 ee674526fac5
parent 9 dea39715fc05
child 11 85a88bc05e45
equal deleted inserted replaced
9:dea39715fc05 10:ee674526fac5
   199 
   199 
   200 // -----------------------------------------------------------------------------
   200 // -----------------------------------------------------------------------------
   201 // CThumbAGProcessor::HandleQueryNewResults()
   201 // CThumbAGProcessor::HandleQueryNewResults()
   202 // -----------------------------------------------------------------------------
   202 // -----------------------------------------------------------------------------
   203 //
   203 //
   204 void CThumbAGProcessor::HandleQueryNewResults( CMdEQuery& /*aQuery*/,
   204 void CThumbAGProcessor::HandleQueryNewResults( CMdEQuery& aQuery,
   205                                                const TInt /*aFirstNewItemIndex*/,
   205                                                const TInt aFirstNewItemIndex,
   206                                                const TInt /*aNewItemCount*/ )
   206                                                const TInt aNewItemCount )
   207     {
   207     {
   208     // No implementation required
   208     // PH & AllItems query results are handled here
   209     }
   209     if (aNewItemCount > 0)
   210 
   210         {
   211 // -----------------------------------------------------------------------------
   211         if(&aQuery == iQueryPlaceholders)
   212 // CThumbAGProcessor::HandleQueryCompleted()
   212             {
   213 // -----------------------------------------------------------------------------
   213             TN_DEBUG2( "CThumbAGProcessor::HandleQueryNewResults - iQueryPlaceholders, %d new", aNewItemCount);
   214 //
   214             
   215 void CThumbAGProcessor::HandleQueryCompleted( CMdEQuery& aQuery, const TInt aError )
   215             for(TInt i = aFirstNewItemIndex; i < iQueryPlaceholders->Count(); i++)
   216     {
   216                 {    
   217     TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompleted, aError == %d Count== %d", aError, aQuery.Count());
   217                 const CMdEObject* object = &iQueryPlaceholders->Result(i);
   218     
       
   219     if(&aQuery == iQueryPlaceholders)
       
   220         {
       
   221         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - iQueryPlaceholders completed");
       
   222         
       
   223         iPlaceholderQueue.Reset();
       
   224         // if no errors in query
       
   225         if (aError == KErrNone )
       
   226             {
       
   227             for(TInt i = 0; i < iQueryPlaceholders->Count(); i++)
       
   228                {    
       
   229                const CMdEObject* object = &iQueryPlaceholders->Result(i);
       
   230               
   218               
   231                if(!object)
   219                 if(!object)
   232                    {
   220                     {
   233                    continue;
   221                     continue;
   234                    }
   222                     }
   235               
   223               
   236                if(!object->Placeholder())
   224                 if(!object->Placeholder())
   237                    {
   225                     {
   238                    TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted %d not placeholder", object->Id());
   226                     TN_DEBUG2( "CThumbAGProcessor::HandleQueryNewResults %d not placeholder", object->Id());
   239                    continue;
   227                     continue;
   240                    }
   228                     }
   241               
   229                
   242                /*if (iPlaceholderQueue.Find( object->Id() ) == KErrNotFound)
   230                 // ignore if fails
   243                    {
   231                 iPlaceholderQueue.InsertInOrder(object->Id(), Compare);               
   244                    TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted %d added to placeholder queue", object->Id());*/
   232                 }  
   245                    TRAP_IGNORE( iPlaceholderQueue.AppendL( object->Id() )); 
   233             }
   246                  //}
   234         else if(&aQuery == iQueryAllItems)
   247                }
   235             {
   248            }
   236             TN_DEBUG2( "CThumbAGProcessor::HandleQueryNewResults - QueryAllItems, %d new", aNewItemCount);
   249            delete iQueryPlaceholders;
   237     
   250            iQueryPlaceholders = NULL;
   238             for(TInt i = aFirstNewItemIndex; i < iQueryAllItems->Count(); i++)
   251            
       
   252            if(iDoQueryAllItems)
       
   253                {
       
   254                iDoQueryAllItems = EFalse;
       
   255                TRAP_IGNORE(QueryAllItemsL());
       
   256                }
       
   257         }
       
   258     else if(&aQuery == iQueryAllItems)
       
   259         {
       
   260         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - QueryAllItems completed");
       
   261         // if no errors in query
       
   262         if (aError == KErrNone )
       
   263             {
       
   264             for(TInt i = 0; i < iQueryAllItems->Count(); i++)
       
   265                 {    
   239                 {    
   266                 const CMdEObject* object = &iQueryAllItems->Result(i);
   240                 const CMdEObject* object = &iQueryAllItems->Result(i);
   267                
   241                
   268                 if(!object)
   242                 if(!object)
   269                     {
   243                     {
   270                     continue;
   244                     continue;
   271                     }
   245                     }
   272                
   246                
   273                 if (iAddQueue.Find( object->Id() ) == KErrNotFound && iModifyQueue.Find( object->Id()) == KErrNotFound  )
   247                 if (iAddQueue.FindInOrder(object->Id(), Compare) == KErrNotFound && 
       
   248                     iModifyQueue.FindInOrder(object->Id(), Compare) == KErrNotFound )
   274                     {
   249                     {
   275                     TRAP_IGNORE( iAddQueue.AppendL( object->Id() ));
   250                     // ignore if fails
       
   251                     iAddQueue.InsertInOrder(object->Id(), Compare);
   276                     }
   252                     }
   277                 }
   253                 }
       
   254             }    
       
   255         }
       
   256     else
       
   257         {
       
   258         TN_DEBUG1( "CThumbAGProcessor::HandleQueryNewResults - error, no new items");
       
   259         }
       
   260     }
       
   261 
       
   262 // -----------------------------------------------------------------------------
       
   263 // CThumbAGProcessor::HandleQueryCompleted()
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 void CThumbAGProcessor::HandleQueryCompleted( CMdEQuery& aQuery, const TInt aError )
       
   267     {
       
   268     TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompleted, aError == %d Count== %d", aError, aQuery.Count());
       
   269     
       
   270     if(&aQuery == iQueryPlaceholders)
       
   271         {
       
   272         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - iQueryPlaceholders completed");
       
   273         
       
   274         iPlaceholderQueue.Reset();
       
   275         
       
   276         //free query
       
   277         delete iQueryPlaceholders;
       
   278         iQueryPlaceholders = NULL;
       
   279        
       
   280         if(iDoQueryAllItems)
       
   281             {
       
   282             iDoQueryAllItems = EFalse;
       
   283             TRAP_IGNORE(QueryAllItemsL());
       
   284             }
       
   285         }
       
   286     else if(&aQuery == iQueryAllItems)
       
   287         {
       
   288         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - QueryAllItems completed");
       
   289 
   278 #ifdef _DEBUG
   290 #ifdef _DEBUG
   279 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted IN-COUNTERS---------- Amount: %d, Add",iQueryAllItems->Count());
   291 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted IN-COUNTERS---------- Amount: %d, Add",iQueryAllItems->Count());
   280 #endif
   292 #endif
   281             }
   293        
   282             //free query
   294         //free query
   283             delete iQueryAllItems;
   295         delete iQueryAllItems;
   284             iQueryAllItems = NULL;
   296         iQueryAllItems = NULL;
   285         }
   297         }
   286     else if(&aQuery == iQuery )
   298     else if(&aQuery == iQuery )
   287         {
   299         {
   288         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - Query completed");
   300         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - Query completed");
   289         
   301         
   300 			
   312 			
   301             if(iProcessingCount != iQueryQueue.Count())
   313             if(iProcessingCount != iQueryQueue.Count())
   302                 {
   314                 {
   303                 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() some result items missing");
   315                 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() some result items missing");
   304                 
   316                 
   305                 RArray<TItemId> iQueryQueueDelta;
   317                 RArray<TItemId> queryQueueDelta;
   306                 
   318                 
   307                 TInt itemIndex(KErrNotFound);
   319                 TInt itemIndex(KErrNotFound);
   308                 
   320                 
   309                 //search delta items
   321                 //search delta items
   310                  for(TInt queryItem =0; queryItem < iQueryQueue.Count();queryItem++)
   322                  for(TInt queryItem =0; queryItem < iQueryQueue.Count();queryItem++)
   322                         }
   334                         }
   323                          
   335                          
   324                      if(!found)
   336                      if(!found)
   325                          {
   337                          {
   326                          TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing from results item %d", iQueryQueue[queryItem] );
   338                          TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing from results item %d", iQueryQueue[queryItem] );
   327                          iQueryQueueDelta.Append( iQueryQueue[queryItem] );
   339                          
       
   340                          // ignore if fails
       
   341                          queryQueueDelta.InsertInOrder(iQueryQueue[queryItem], Compare);
   328                          }
   342                          }
   329                      }
   343                      }
   330                  
   344                  
   331                  TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing items total count %d", iQueryQueueDelta.Count()); 
   345                  TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing items total count %d", queryQueueDelta.Count()); 
   332                  //cleanup from previous queue it item is not found from MDS
   346                  //cleanup from previous queue it item is not found from MDS
   333                  while(iQueryQueueDelta.Count())
   347                  while(queryQueueDelta.Count())
   334                      {
   348                      {
   335                      itemIndex = iLastQueue->Find(iQueryQueueDelta[0]);
   349                      itemIndex = iLastQueue->FindInOrder(queryQueueDelta[0], Compare);
       
   350                      
   336                      if(itemIndex >= 0)
   351                      if(itemIndex >= 0)
   337                          {
   352                          {
   338                          TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove items %d", iQueryQueue[0]);
   353                          TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove items %d", iQueryQueue[0]);
   339                          iLastQueue->Remove( itemIndex );
   354                          iLastQueue->Remove( itemIndex );
   340                          }
   355                          }
   341                      iQueryQueueDelta.Remove(0);
   356                      queryQueueDelta.Remove(0);
   342                      }
   357                      }
   343                  iQueryQueueDelta.Close();
   358                  queryQueueDelta.Close();
   344                 }
   359                 }
   345             
   360             
   346             // no results, reset query
   361             // no results, reset query
   347             if( !iProcessingCount)
   362             if( !iProcessingCount)
   348                 {
   363                 {
   357             TInt itemIndex(KErrNotFound);
   372             TInt itemIndex(KErrNotFound);
   358             
   373             
   359             //cleanup current queue
   374             //cleanup current queue
   360             while(iQueryQueue.Count())
   375             while(iQueryQueue.Count())
   361                 {
   376                 {
   362                 itemIndex = iLastQueue->Find(iQueryQueue[0]);
   377                 itemIndex = iLastQueue->FindInOrder(iQueryQueue[0], Compare);
   363                 if(itemIndex >= 0)
   378                 if(itemIndex >= 0)
   364                     {
   379                     {
   365                     iLastQueue->Remove( itemIndex );
   380                     iLastQueue->Remove( itemIndex );
   366                     }
   381                     }
   367                 iQueryQueue.Remove(0);
   382                 iQueryQueue.Remove(0);
   477         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyAdd" );
   492         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyAdd" );
   478         
   493         
   479         for (int i=0; i<aIDArray.Count(); i++)
   494         for (int i=0; i<aIDArray.Count(); i++)
   480             {
   495             {
   481             // do not to append to Add queue if exist already in Add or 2nd Add queue (just processed)     
   496             // do not to append to Add queue if exist already in Add or 2nd Add queue (just processed)     
   482             if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound && i2ndRoundGenerateQueue.Find( aIDArray[i] ) == KErrNotFound)
   497             if (iAddQueue.FindInOrder(aIDArray[i], Compare) == KErrNotFound && 
   483                 {
   498                 i2ndRoundGenerateQueue.FindInOrder(aIDArray[i], Compare) == KErrNotFound)
   484                 iAddQueue.AppendL(aIDArray[i]);
   499                 {
       
   500                 User::LeaveIfError(iAddQueue.InsertInOrder(aIDArray[i], Compare));    
   485                 }
   501                 }
   486             }
   502             }
   487         }
   503         }
   488     else if (aType == ENotifyModify)
   504     else if (aType == ENotifyModify)
   489         {
   505         {
   490         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyModify" );
   506         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyModify" );
   491         
   507         
   492         if(iPHHarvesting)
   508         if(iPHHarvesting)
   493             {
   509             {        
   494         
       
   495             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH  harvesting active, treat like add" );
   510             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH  harvesting active, treat like add" );
   496             for (int i=0; i<aIDArray.Count(); i++)
   511             for (int i=0; i<aIDArray.Count(); i++)
   497                 {
   512                 {
   498                 TInt itemIndex = iPlaceholderQueue.Find( aIDArray[i] );
   513                 TInt itemIndex = iPlaceholderQueue.FindInOrder(aIDArray[i], Compare);
   499                                 
   514                                 
   500                 if (itemIndex >= 0)
   515                 if (itemIndex >= 0)
   501                     {
   516                     {
   502                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from placeholder queue");
   517                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from placeholder queue");
   503                     iPlaceholderQueue.Remove( itemIndex );
   518                     iPlaceholderQueue.Remove( itemIndex );
   504                     }
   519                     }
   505                 
   520                 
   506                 if(iAddQueue.Find( aIDArray[i]) == KErrNotFound && i2ndRoundGenerateQueue.Find( aIDArray[i]) == KErrNotFound )
   521                 if(iAddQueue.FindInOrder(aIDArray[i], Compare) == KErrNotFound && 
       
   522                    i2ndRoundGenerateQueue.FindInOrder(aIDArray[i], Compare) == KErrNotFound)
   507                     {
   523                     {
   508                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append to add queue");
   524                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append to add queue");
   509                     iAddQueue.Append( aIDArray[i]);
   525                     User::LeaveIfError(iAddQueue.InsertInOrder(aIDArray[i], Compare));
   510                     }
   526                     }
   511                 }
   527                 }
   512             }
   528             }
   513         else
   529         else
   514             {
   530             {
   516             
   532             
   517             TInt itemIndex(KErrNotFound);
   533             TInt itemIndex(KErrNotFound);
   518             
   534             
   519             for (int i=0; i<aIDArray.Count(); i++)
   535             for (int i=0; i<aIDArray.Count(); i++)
   520                 {
   536                 {
   521                 itemIndex = iPlaceholderQueue.Find( aIDArray[i] );
   537                 itemIndex = iPlaceholderQueue.FindInOrder(aIDArray[i], Compare);
   522                 
   538                 
   523                 if (itemIndex >= 0)
   539                 if (itemIndex >= 0)
   524                     {
   540                     {
   525                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - placeholder modify, remove from placeholder queue");
   541                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - placeholder modify, remove from placeholder queue");
   526                     iPlaceholderQueue.Remove( itemIndex );
   542                     iPlaceholderQueue.Remove( itemIndex );
   527                     }
   543                     }
   528                 else
   544                 else
   529                     {
   545                     {
   530                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - real modify");
   546                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - real modify");
   531                     itemIndex = iAddQueue.Find( aIDArray[i] );
   547                     itemIndex = iAddQueue.FindInOrder(aIDArray[i], Compare);
   532                                     
   548                                     
   533                     if (itemIndex >= 0)
   549                     if (itemIndex >= 0)
   534                         {
   550                         {
   535                         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from add queue");
   551                         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from add queue");
   536                         iAddQueue.Remove( itemIndex );
   552                         iAddQueue.Remove( itemIndex );
   537                         }
   553                         }
   538 					else
   554 					else
   539 						{
   555 						{						
   540 						
   556 						itemIndex = i2ndRoundGenerateQueue.FindInOrder(aIDArray[i], Compare);
   541 						itemIndex = i2ndRoundGenerateQueue.Find( aIDArray[i] );
       
   542                                     
   557                                     
   543 	                    if (itemIndex >= 0)
   558 	                    if (itemIndex >= 0)
   544 	                        {
   559 	                        {
   545 	                        TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from 2nd round add queue");
   560 	                        TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from 2nd round add queue");
   546 	                        i2ndRoundGenerateQueue.Remove( itemIndex );
   561 	                        i2ndRoundGenerateQueue.Remove( itemIndex );
   547 	                        }
   562 	                        }
   548 					}
   563 					}
   549                     
   564                     
   550                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append to modify queue");
   565                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append to modify queue");
   551                     iModifyQueue.AppendL(aIDArray[i]);
   566                     User::LeaveIfError(iModifyQueue.InsertInOrder(aIDArray[i], Compare));
   552                     
   567                     
   553                     SetForceRun( ETrue );
   568                     SetForceRun( ETrue );
   554                     } 
   569                     } 
   555                 }
   570                 }
   556             }
   571             }
   560             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove, remove IDs from all queues");
   575             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove, remove IDs from all queues");
   561             
   576             
   562             for (int i=0; i<aIDArray.Count(); i++)
   577             for (int i=0; i<aIDArray.Count(); i++)
   563                 {
   578                 {
   564                 // can be removed from Add queue
   579                 // can be removed from Add queue
   565                 TInt itemIndex = iAddQueue.Find( aIDArray[i] );
   580                 TInt itemIndex = iAddQueue.FindInOrder(aIDArray[i], Compare);
   566                 if(itemIndex >= 0)
   581                 if(itemIndex >= 0)
   567                     {
   582                     {
   568                     iAddQueue.Remove(itemIndex);
   583                     iAddQueue.Remove(itemIndex);
   569                     }
   584                     }
   570     
   585     
   571                 // ..and Modify Queue
   586                 // ..and Modify Queue
   572                 itemIndex = iModifyQueue.Find( aIDArray[i] );
   587                 itemIndex = iModifyQueue.FindInOrder(aIDArray[i], Compare);
   573                 if(itemIndex >= 0)
   588                 if(itemIndex >= 0)
   574                     {
   589                     {
   575                     iModifyQueue.Remove(itemIndex);
   590                     iModifyQueue.Remove(itemIndex);
   576                     }
   591                     }
   577                 }
   592                 }
   655             
   670             
   656             // add item to 2nd round queue 
   671             // add item to 2nd round queue 
   657             if(iLastQueue == &iAddQueue || iLastQueue == &iModifyQueue)
   672             if(iLastQueue == &iAddQueue || iLastQueue == &iModifyQueue)
   658                 {
   673                 {
   659                 TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL() - 1st round add/modify, append to 2nd round queue", aObject->Id() );
   674                 TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL() - 1st round add/modify, append to 2nd round queue", aObject->Id() );
   660                 if(i2ndRoundGenerateQueue.Find(aObject->Id()) == KErrNotFound)
   675                 if(i2ndRoundGenerateQueue.FindInOrder(aObject->Id(), Compare) == KErrNotFound)
   661                     {
   676                     {
   662                     i2ndRoundGenerateQueue.Append( aObject->Id() );
   677                     // ignore if fails
       
   678                     i2ndRoundGenerateQueue.InsertInOrder(aObject->Id(), Compare);
   663                     }
   679                     }
   664                 }
   680                 }
   665             
   681             
   666            if( !(imageObjectDef.Id() == aObject->Def().Id() || videoObjectDef.Id() == aObject->Def().Id()) )
   682            if( !(imageObjectDef.Id() == aObject->Def().Id() || videoObjectDef.Id() == aObject->Def().Id()) )
   667                 {
   683                 {
   728     
   744     
   729     //move ID from source queue to Query queue
   745     //move ID from source queue to Query queue
   730     TInt maxCount = aIDArray.Count();
   746     TInt maxCount = aIDArray.Count();
   731         
   747         
   732     TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() );
   748     TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() );
   733     
   749       
   734     for(TInt i=0;i < KMaxQueryItems && i < maxCount; i++)
   750     for(TInt i=0;i < KMaxQueryItems && i < maxCount; i++)
   735         {
   751         {
   736         TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", aIDArray[i] );
   752         TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", aIDArray[i] );
   737         iQueryQueue.Append( aIDArray[i] );
   753         iQueryQueue.InsertInOrder(aIDArray[i], Compare);
   738         }
   754         }
   739     
   755     
   740     TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() );
   756     TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() );
   741     
   757     
   742     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );
   758     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );
   834     
   850     
   835     CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
   851     CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
   836     audioPHObjectCondition.SetPlaceholderOnly( ETrue );
   852     audioPHObjectCondition.SetPlaceholderOnly( ETrue );
   837     audioPHObjectCondition.SetNotPresent( ETrue );
   853     audioPHObjectCondition.SetNotPresent( ETrue );
   838     
   854     
   839     iQueryPlaceholders->FindL();  
   855     iQueryPlaceholders->FindL(KMaxTInt, KMaxQueryItems2);   
   840    
   856    
   841     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL - end" );
   857     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL - end" );
   842     }
   858     }
   843 
   859 
   844 
   860 
  1007             TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" );
  1023             TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" );
  1008             
  1024             
  1009             const CMdEObject* object = &iQuery->Result( iProcessingCount-1 );
  1025             const CMdEObject* object = &iQuery->Result( iProcessingCount-1 );
  1010             iProcessingCount--;
  1026             iProcessingCount--;
  1011             
  1027             
  1012             TInt itemIndex = iLastQueue->Find( object->Id());
  1028             TInt itemIndex = iLastQueue->FindInOrder(object->Id(), Compare);
  1013             if(itemIndex >= 0)
  1029             if(itemIndex >= 0)
  1014                 {
  1030                 {
  1015                 iLastQueue->Remove(itemIndex);
  1031                 iLastQueue->Remove(itemIndex);
  1016                 }
  1032                 }
  1017 				
  1033 				
  1018             // process one item at once
  1034             // process one item at once
  1019             if ( object )
  1035             if ( object )
  1020                 {
  1036                 {
  1021                 //remove item from queryQueue when request is issued 
  1037                 //remove item from queryQueue when request is issued 
  1022                 itemIndex = iQueryQueue.Find( object->Id());
  1038                 itemIndex = iQueryQueue.FindInOrder(object->Id(), Compare);
  1023                 if(itemIndex >= 0)
  1039                 if(itemIndex >= 0)
  1024                     {
  1040                     {
  1025                     iQueryQueue.Remove(itemIndex);
  1041                     iQueryQueue.Remove(itemIndex);
  1026                     }
  1042                     }
  1027             
  1043             
  1042             //move remainig IDs in query queue back to original queue
  1058             //move remainig IDs in query queue back to original queue
  1043             while(iQueryQueue.Count())
  1059             while(iQueryQueue.Count())
  1044                 {
  1060                 {
  1045                 if(iLastQueue)
  1061                 if(iLastQueue)
  1046                     {
  1062                     {
  1047                     if(iLastQueue->Find( iQueryQueue[0]) == KErrNotFound)
  1063                     if(iLastQueue->FindInOrder(iQueryQueue[0], Compare) == KErrNotFound)
  1048                         {
  1064                         {
  1049                         iLastQueue->Append(iQueryQueue[0]);
  1065                         //ignore if fails
       
  1066                         iLastQueue->InsertInOrder(iQueryQueue[0], Compare);
  1050                         }
  1067                         }
  1051                     }
  1068                     }
  1052                 iQueryQueue.Remove(0);
  1069                 iQueryQueue.Remove(0);
  1053                 }
  1070                 }
  1054             iLastQueue = NULL;
  1071             iLastQueue = NULL;
  1085             //move remainig IDs in query queue back to original queue
  1102             //move remainig IDs in query queue back to original queue
  1086             while(iQueryQueue.Count())
  1103             while(iQueryQueue.Count())
  1087                 {
  1104                 {
  1088                 if(iLastQueue)
  1105                 if(iLastQueue)
  1089                     {
  1106                     {
  1090                     if(iLastQueue->Find( iQueryQueue[0]) == KErrNotFound)
  1107                     if(iLastQueue->FindInOrder(iQueryQueue[0], Compare) == KErrNotFound)
  1091                         {
  1108                         {
  1092                         iLastQueue->Append(iQueryQueue[0]);
  1109                         //ignore if fails
       
  1110                         iLastQueue->InsertInOrder(iQueryQueue[0], Compare);
  1093                         }
  1111                         }
  1094                     }
  1112                     }
  1095                 iQueryQueue.Remove(0);
  1113                 iQueryQueue.Remove(0);
  1096                 }
  1114                 }
  1097             iLastQueue = NULL;
  1115             iLastQueue = NULL;
  1347         {
  1365         {
  1348         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE");
  1366         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE");
  1349         return;
  1367         return;
  1350         }
  1368         }
  1351         
  1369         
  1352     if( !IsActive() )
  1370     //check if forced run needs to continue
  1353         {
  1371     if (iModifyQueue.Count())
       
  1372         {
       
  1373         SetForceRun( ETrue );
       
  1374         }
       
  1375     else
       
  1376         {
       
  1377         iModify = EFalse;
       
  1378         SetForceRun( EFalse );
       
  1379         }
       
  1380     
       
  1381     if( !IsActive() && ((!iActive && !iQueryActive) || iForceRun ))
       
  1382         {
       
  1383         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - Activated");
  1354         SetActive();
  1384         SetActive();
  1355         TRequestStatus* statusPtr = &iStatus;
  1385         TRequestStatus* statusPtr = &iStatus;
  1356         User::RequestComplete( statusPtr, KErrNone );
  1386         User::RequestComplete( statusPtr, KErrNone );
  1357         }
       
  1358     
       
  1359     //check if forced run needs to continue
       
  1360     if (iModifyQueue.Count())
       
  1361         {
       
  1362         SetForceRun( ETrue );
       
  1363         }
       
  1364     else
       
  1365         {
       
  1366         iModify = EFalse;
       
  1367         SetForceRun( EFalse );
       
  1368         }
  1387         }
  1369 
  1388 
  1370     UpdatePSValues();
  1389     UpdatePSValues();
  1371     }
  1390     }
  1372 
  1391 
  1460     
  1479     
  1461     for (int i=0; i< aIDArray.Count(); i++)
  1480     for (int i=0; i< aIDArray.Count(); i++)
  1462         {
  1481         {
  1463         TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]);
  1482         TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]);
  1464 
  1483 
  1465         itemIndex = iPlaceholderQueue.Find( aIDArray[i] );
  1484         itemIndex = iPlaceholderQueue.FindInOrder(aIDArray[i], Compare);                        
  1466                          
       
  1467         if(itemIndex >= 0)
  1485         if(itemIndex >= 0)
  1468             {
  1486             {
  1469             iPlaceholderQueue.Remove(itemIndex);
  1487             iPlaceholderQueue.Remove(itemIndex);
  1470             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPlaceholderQueue" );
  1488             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPlaceholderQueue" );
  1471             }
  1489             }
  1472                 
  1490                 
  1473         itemIndex = iAddQueue.Find( aIDArray[i] );
  1491         itemIndex = iAddQueue.FindInOrder(aIDArray[i], Compare);       
  1474         
       
  1475         if(itemIndex >= 0)
  1492         if(itemIndex >= 0)
  1476             {
  1493             {
  1477             iAddQueue.Remove(itemIndex);
  1494             iAddQueue.Remove(itemIndex);
  1478             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iAddQueue" );
  1495             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iAddQueue" );
  1479             }
  1496             }
  1480 
  1497 
  1481         itemIndex = i2ndRoundGenerateQueue.Find( aIDArray[i] );
  1498         itemIndex = i2ndRoundGenerateQueue.FindInOrder(aIDArray[i], Compare);               
  1482                 
       
  1483         if(itemIndex >= 0)
  1499         if(itemIndex >= 0)
  1484             {
  1500             {
  1485             i2ndRoundGenerateQueue.Remove(itemIndex);
  1501             i2ndRoundGenerateQueue.Remove(itemIndex);
  1486             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - i2ndRoundGenerateQueue" );
  1502             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - i2ndRoundGenerateQueue" );
  1487             }
  1503             }
  1488         
  1504         
  1489         itemIndex = iModifyQueue.Find( aIDArray[i] );
  1505         itemIndex = iModifyQueue.FindInOrder(aIDArray[i], Compare);       
  1490          
       
  1491         if(itemIndex >= 0)
  1506         if(itemIndex >= 0)
  1492             {
  1507             {
  1493             iModifyQueue.Remove(itemIndex);
  1508             iModifyQueue.Remove(itemIndex);
  1494             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iModifyQueue" );
  1509             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iModifyQueue" );
  1495 			 
  1510 			 
  1497 			    {
  1512 			    {
  1498 			    SetForceRun( EFalse );
  1513 			    SetForceRun( EFalse );
  1499 		        }
  1514 		        }
  1500             }
  1515             }
  1501             
  1516             
  1502         itemIndex = iQueryQueue.Find( aIDArray[i] );
  1517         itemIndex = iQueryQueue.FindInOrder(aIDArray[i], Compare);                    
  1503                      
       
  1504         if(itemIndex >= 0)
  1518         if(itemIndex >= 0)
  1505             {
  1519             {
  1506             iQueryQueue.Remove(itemIndex);
  1520             iQueryQueue.Remove(itemIndex);
  1507             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iQueryQueue" );
  1521             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iQueryQueue" );
  1508             }
  1522             }
  1509         
  1523          
  1510         itemIndex = iPlaceholderQueue.Find( aIDArray[i] );
  1524         itemIndex = iPlaceholderQueue.FindInOrder(aIDArray[i], Compare); 
  1511                       
       
  1512         if(itemIndex >= 0)
  1525         if(itemIndex >= 0)
  1513         	{
  1526         	{
  1514             iPlaceholderQueue.Remove(itemIndex);
  1527             iPlaceholderQueue.Remove(itemIndex);
  1515             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPlaceholderQueue" );
  1528             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPlaceholderQueue" );
  1516             }
  1529             }
  1517         
       
  1518         /*
       
  1519         if( aRemoveFromDelete )
       
  1520             {
       
  1521             itemIndex = iRemoveQueue.Find( aIDArray[i] );
       
  1522              
       
  1523             if(itemIndex >= 0)
       
  1524                 {
       
  1525                 iRemoveQueue.Remove(itemIndex);
       
  1526                 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iRemoveQueue" );
       
  1527                 continue;
       
  1528                 }
       
  1529             }*/
       
  1530         }
  1530         }
  1531     
  1531     
  1532     TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - end" );
  1532     TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - end" );
  1533     }
  1533     }
  1534 	
  1534 	
  1591     
  1591     
  1592     CMdEObjectCondition& videoPHObjectCondition = rootCondition.AddObjectConditionL(videoObjDef);
  1592     CMdEObjectCondition& videoPHObjectCondition = rootCondition.AddObjectConditionL(videoObjDef);
  1593     
  1593     
  1594     CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
  1594     CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
  1595     
  1595     
  1596     iQueryAllItems->FindL();  
  1596     iQueryAllItems->FindL(KMaxTInt, KMaxQueryItems2);  
  1597     
  1597     
  1598     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL - end" );
  1598     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL - end" );
  1599     }
  1599     }
  1600 
  1600 
  1601 // -----------------------------------------------------------------------------
  1601 // -----------------------------------------------------------------------------
  1809         iPreviousItemsLeft = itemsLeft;
  1809         iPreviousItemsLeft = itemsLeft;
  1810         RProperty::Set(KTAGDPSNotification, KItemsleft, itemsLeft );
  1810         RProperty::Set(KTAGDPSNotification, KItemsleft, itemsLeft );
  1811         }
  1811         }
  1812     }
  1812     }
  1813 
  1813 
       
  1814 // ---------------------------------------------------------------------------
       
  1815 // CThumbAGProcessor::Compare
       
  1816 // Comparison function for logaritmic use of queue arrays
       
  1817 // ---------------------------------------------------------------------------
       
  1818 //
       
  1819 TInt CThumbAGProcessor::Compare(const TItemId& aLeft, const TItemId& aRight)
       
  1820     {  
       
  1821     return (aLeft - aRight);
       
  1822     }
       
  1823 
       
  1824 
  1814 // End of file
  1825 // End of file