imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp
branchRCL_3
changeset 22 9d4d3445ce6e
parent 21 6257223ede8a
equal deleted inserted replaced
21:6257223ede8a 22:9d4d3445ce6e
    28 
    28 
    29 #include "thumbagprocessor.h"
    29 #include "thumbagprocessor.h"
    30 #include "thumbnaillog.h"
    30 #include "thumbnaillog.h"
    31 #include "thumbnailmanagerconstants.h"
    31 #include "thumbnailmanagerconstants.h"
    32 #include "thumbnailmanagerprivatecrkeys.h"
    32 #include "thumbnailmanagerprivatecrkeys.h"
    33 #include "OstTraceDefinitions.h"
       
    34 #ifdef OST_TRACE_COMPILER_IN_USE
       
    35 #include "thumbagprocessorTraces.h"
       
    36 #endif
       
    37 
    33 
    38 // ---------------------------------------------------------------------------
    34 // ---------------------------------------------------------------------------
    39 // CThumbAGProcessor::NewL()
    35 // CThumbAGProcessor::NewL()
    40 // ---------------------------------------------------------------------------
    36 // ---------------------------------------------------------------------------
    41 //
    37 //
    42 CThumbAGProcessor* CThumbAGProcessor::NewL()
    38 CThumbAGProcessor* CThumbAGProcessor::NewL()
    43     {
    39     {
    44     TN_DEBUG1( "CThumbAGProcessor::NewL() - begin" );
    40     TN_DEBUG1( "CThumbAGProcessor::NewL() - begin" );
    45     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_NEWL, "CThumbAGProcessor::NewL - begin" );
       
    46     
    41     
    47     CThumbAGProcessor* self = new( ELeave )CThumbAGProcessor();
    42     CThumbAGProcessor* self = new( ELeave )CThumbAGProcessor();
    48     CleanupStack::PushL( self );
    43     CleanupStack::PushL( self );
    49     self->ConstructL();
    44     self->ConstructL();
    50     CleanupStack::Pop( self );
    45     CleanupStack::Pop( self );
    57 //
    52 //
    58 CThumbAGProcessor::CThumbAGProcessor(): CActive( CActive::EPriorityStandard ), iMMCHarvestingItemsLeftTemp(0), 
    53 CThumbAGProcessor::CThumbAGProcessor(): CActive( CActive::EPriorityStandard ), iMMCHarvestingItemsLeftTemp(0), 
    59         iPHHarvestingItemsLeftTemp(0)
    54         iPHHarvestingItemsLeftTemp(0)
    60     {
    55     {
    61     TN_DEBUG1( "CThumbAGProcessor::CThumbAGProcessor() - begin" );
    56     TN_DEBUG1( "CThumbAGProcessor::CThumbAGProcessor() - begin" );
    62     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_CTHUMBAGPROCESSOR, "CThumbAGProcessor::CThumbAGProcessor- begin" );
       
    63     
    57     
    64     CActiveScheduler::Add( this );
    58     CActiveScheduler::Add( this );
    65     }
    59     }
    66 
    60 
    67 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    69 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    70 //
    64 //
    71 void CThumbAGProcessor::ConstructL()
    65 void CThumbAGProcessor::ConstructL()
    72     {
    66     {
    73     TN_DEBUG1( "CThumbAGProcessor::ConstructL() - begin" );
    67     TN_DEBUG1( "CThumbAGProcessor::ConstructL() - begin" );
    74     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_CONSTRUCTL, "CThumbAGProcessor::ConstructL - begin" );
       
    75     
    68     
    76     iShutdown = EFalse;
    69     iShutdown = EFalse;
    77     
    70     
    78     iTMSession = CThumbnailManager::NewL( *this );
    71     iTMSession = CThumbnailManager::NewL( *this );
    79     iTMSession->SetRequestObserver(*this);
    72     iTMSession->SetRequestObserver(*this);
   111     
   104     
   112 	//start foreground generation observer
   105 	//start foreground generation observer
   113     iForegroundGenerationObserver = CTMRPropertyObserver::NewL( *this, KTAGDPSNotification, KForceBackgroundGeneration, ETrue );  
   106     iForegroundGenerationObserver = CTMRPropertyObserver::NewL( *this, KTAGDPSNotification, KForceBackgroundGeneration, ETrue );  
   114     
   107     
   115     TN_DEBUG1( "CThumbAGProcessor::ConstructL() - end" );
   108     TN_DEBUG1( "CThumbAGProcessor::ConstructL() - end" );
   116     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_CONSTRUCTL, "CThumbAGProcessor::ConstructL - end" );
       
   117     }
   109     }
   118 
   110 
   119 // ---------------------------------------------------------------------------
   111 // ---------------------------------------------------------------------------
   120 // CThumbAGProcessor::~CThumbAGProcessor()
   112 // CThumbAGProcessor::~CThumbAGProcessor()
   121 // ---------------------------------------------------------------------------
   113 // ---------------------------------------------------------------------------
   122 //
   114 //
   123 CThumbAGProcessor::~CThumbAGProcessor()
   115 CThumbAGProcessor::~CThumbAGProcessor()
   124     {
   116     {
   125     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - begin" );
   117     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - begin" );
   126     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_CTHUMBAGPROCESSOR, "CThumbAGProcessor::~CThumbAGProcessor - begin" );
       
   127     
   118     
   128     Shutdown();
   119     Shutdown();
   129     
   120     
   130     Cancel();
   121     Cancel();
   131     
   122     
   213     iGenerationQueue.Close();
   204     iGenerationQueue.Close();
   214     
   205     
   215     iQueryQueue.Close();
   206     iQueryQueue.Close();
   216     
   207     
   217     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - end" );
   208     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - end" );
   218     OstTrace0( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_CTHUMBAGPROCESSOR, "CThumbAGProcessor::~CThumbAGProcessor - end" );
       
   219     }
   209     }
   220 
   210 
   221 // ---------------------------------------------------------------------------
   211 // ---------------------------------------------------------------------------
   222 // CThumbAGProcessor::Shutdown()
   212 // CThumbAGProcessor::Shutdown()
   223 // ---------------------------------------------------------------------------
   213 // ---------------------------------------------------------------------------
   224 //
   214 //
   225 void CThumbAGProcessor::Shutdown()
   215 void CThumbAGProcessor::Shutdown()
   226     {
   216     {
   227     TN_DEBUG1( "CThumbAGProcessor::Shutdown()" );
   217     TN_DEBUG1( "CThumbAGProcessor::Shutdown()" );
   228     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_SHUTDOWN, "CThumbAGProcessor::Shutdown" );
       
   229     iShutdown = ETrue;
   218     iShutdown = ETrue;
   230     UpdatePSValues(EFalse, EFalse);
   219     UpdatePSValues(EFalse, EFalse);
   231     }
   220     }
   232 
   221 
   233 // -----------------------------------------------------------------------------
   222 // -----------------------------------------------------------------------------
   248     if (aNewItemCount > 0)
   237     if (aNewItemCount > 0)
   249         {
   238         {
   250         if(&aQuery == iQueryPlaceholders)
   239         if(&aQuery == iQueryPlaceholders)
   251             {
   240             {
   252             TN_DEBUG2( "CThumbAGProcessor::HandleQueryNewResults - iQueryPlaceholders, %d new", aNewItemCount);
   241             TN_DEBUG2( "CThumbAGProcessor::HandleQueryNewResults - iQueryPlaceholders, %d new", aNewItemCount);
   253             OstTrace1( TRACE_NORMAL, CTHUMBAGPROCESSOR_HANDLEQUERYNEWRESULTS, "CThumbAGProcessor::HandleQueryNewResults - iQueryPlaceholders;aNewItemCount=%d", aNewItemCount );
       
   254             
   242             
   255             for(TInt i = aFirstNewItemIndex; i < iQueryPlaceholders->Count(); i++)
   243             for(TInt i = aFirstNewItemIndex; i < iQueryPlaceholders->Count(); i++)
   256                 {    
   244                 {    
   257                 const CMdEObject* object = &iQueryPlaceholders->Result(i);
   245                 const CMdEObject* object = &iQueryPlaceholders->Result(i);
   258               
   246               
   262                     }
   250                     }
   263               
   251               
   264                 if(!object->Placeholder())
   252                 if(!object->Placeholder())
   265                     {
   253                     {
   266                     TN_DEBUG2( "CThumbAGProcessor::HandleQueryNewResults %d not placeholder", object->Id());
   254                     TN_DEBUG2( "CThumbAGProcessor::HandleQueryNewResults %d not placeholder", object->Id());
   267                     OstTrace1( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_HANDLEQUERYNEWRESULTS, "CThumbAGProcessor::HandleQueryNewResults - not placeholder;object->Id()=%u", object->Id() );
       
   268                     continue;
   255                     continue;
   269                     }
   256                     }
   270                
   257                
   271                 // ignore if fails
   258                 // ignore if fails
   272                 TThumbnailGenerationItem item;
   259                 TThumbnailGenerationItem item;
   279                 }  
   266                 }  
   280             }
   267             }
   281         else if(&aQuery == iQueryAllItems)
   268         else if(&aQuery == iQueryAllItems)
   282             {
   269             {
   283             TN_DEBUG2( "CThumbAGProcessor::HandleQueryNewResults - QueryAllItems, %d new", aNewItemCount);
   270             TN_DEBUG2( "CThumbAGProcessor::HandleQueryNewResults - QueryAllItems, %d new", aNewItemCount);
   284             OstTrace1( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_HANDLEQUERYNEWRESULTS, "CThumbAGProcessor::HandleQueryNewResults - QueryAllItems;aNewItemCount=%d", aNewItemCount );
       
   285             
   271             
   286             for(TInt i = aFirstNewItemIndex; i < iQueryAllItems->Count(); i++)
   272             for(TInt i = aFirstNewItemIndex; i < iQueryAllItems->Count(); i++)
   287                 {    
   273                 {    
   288                 const CMdEObject* object = &iQueryAllItems->Result(i);
   274                 const CMdEObject* object = &iQueryAllItems->Result(i);
   289                
   275                
   306             }    
   292             }    
   307         }
   293         }
   308     else
   294     else
   309         {
   295         {
   310         TN_DEBUG1( "CThumbAGProcessor::HandleQueryNewResults - error, no new items");
   296         TN_DEBUG1( "CThumbAGProcessor::HandleQueryNewResults - error, no new items");
   311         OstTrace0( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_HANDLEQUERYNEWRESULTS, "CThumbAGProcessor::HandleQueryNewResults - error, no new items" );
       
   312         }
   297         }
   313     }
   298     }
   314 
   299 
   315 // -----------------------------------------------------------------------------
   300 // -----------------------------------------------------------------------------
   316 // CThumbAGProcessor::HandleQueryCompleted()
   301 // CThumbAGProcessor::HandleQueryCompleted()
   317 // -----------------------------------------------------------------------------
   302 // -----------------------------------------------------------------------------
   318 //
   303 //
   319 void CThumbAGProcessor::HandleQueryCompleted( CMdEQuery& aQuery, const TInt aError )
   304 void CThumbAGProcessor::HandleQueryCompleted( CMdEQuery& aQuery, const TInt aError )
   320     {
   305     {
   321     TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompleted, aError == %d Count== %d", aError, aQuery.Count());
   306     TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompleted, aError == %d Count== %d", aError, aQuery.Count());
   322     OstTraceExt2( TRACE_NORMAL, CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted;aError=%d;aQuery.Count()=%d", aError, aQuery.Count() );
       
   323     
   307     
   324     if(iShutdown)
   308     if(iShutdown)
   325         {
   309         {
   326         return;
   310         return;
   327         }
   311         }
   328     
   312     
   329     if(&aQuery == iQueryPlaceholders)
   313     if(&aQuery == iQueryPlaceholders)
   330         {
   314         {
   331         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - iQueryPlaceholders completed");
   315         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - iQueryPlaceholders completed");
   332         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - iQueryPlaceholders completed" );
       
   333         
   316         
   334         //free query
   317         //free query
   335         delete iQueryPlaceholders;
   318         delete iQueryPlaceholders;
   336         iQueryPlaceholders = NULL;
   319         iQueryPlaceholders = NULL;
   337        
   320        
   342             }
   325             }
   343         }
   326         }
   344     else if(&aQuery == iQueryAllItems)
   327     else if(&aQuery == iQueryAllItems)
   345         {
   328         {
   346         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - QueryAllItems completed");
   329         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - QueryAllItems completed");
   347         OstTrace0( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - QueryAllItems completed" );
       
   348 
   330 
   349 #ifdef _DEBUG
   331 #ifdef _DEBUG
   350 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted IN-COUNTERS---------- Amount: %d, Add",iQueryAllItems->Count());
   332 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted IN-COUNTERS---------- Amount: %d, Add",iQueryAllItems->Count());
   351 OstTrace1( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted IN-COUNTERS---------- Amount;iQueryAllItems->Count()=%d", iQueryAllItems->Count() );
       
   352 #endif
   333 #endif
   353        
   334        
   354         //free query
   335         //free query
   355         delete iQueryAllItems;
   336         delete iQueryAllItems;
   356         iQueryAllItems = NULL;
   337         iQueryAllItems = NULL;
   357         }
   338         }
   358     else if(&aQuery == iQuery ) 
   339     else if(&aQuery == iQuery ) 
   359         {
   340         {
   360         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - Query completed");
   341         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - Query completed");
   361         OstTrace0( TRACE_NORMAL, DUP4_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - Query completed" );
       
   362         
   342         
   363         if(iQueryActive)
   343         if(iQueryActive)
   364             {
   344             {
   365             iQueryReady = ETrue;
   345             iQueryReady = ETrue;
   366             iQueryActive = EFalse;
   346             iQueryActive = EFalse;
   372             iProcessingCount = iQuery->Count();
   352             iProcessingCount = iQuery->Count();
   373 			
   353 			
   374             if(iProcessingCount != iQueryQueue.Count() )
   354             if(iProcessingCount != iQueryQueue.Count() )
   375                 {
   355                 {
   376                 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() some result items missing");
   356                 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() some result items missing");
   377                 OstTrace0( TRACE_NORMAL, DUP5_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - some result items missing" );
       
   378                 
   357                 
   379                 RArray<TItemId> queryQueueDelta;
   358                 RArray<TItemId> queryQueueDelta;
   380                 
   359                 
   381                     //search delta items which were queried, but not found
   360                     //search delta items which were queried, but not found
   382                      for(TInt queryItem =0; queryItem < iQueryQueue.Count();queryItem++)
   361                      for(TInt queryItem =0; queryItem < iQueryQueue.Count();queryItem++)
   394                             }
   373                             }
   395                              
   374                              
   396                          if(!found)
   375                          if(!found)
   397                              {
   376                              {
   398                              TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() %d missing from query results", iQueryQueue[queryItem] );
   377                              TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() %d missing from query results", iQueryQueue[queryItem] );
   399                              OstTrace1( TRACE_NORMAL, DUP6_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted;iQueryQueue[queryItem]=%d", iQueryQueue[queryItem] );
       
   400                              
   378                              
   401                              // ignore if fails
   379                              // ignore if fails
   402                              queryQueueDelta.InsertInOrder(iQueryQueue[queryItem], CompareId);
   380                              queryQueueDelta.InsertInOrder(iQueryQueue[queryItem], CompareId);
   403                              }
   381                              }
   404                          }
   382                          }
   405                      
   383                      
   406                      TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing items found %d", queryQueueDelta.Count()); 
   384                      TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing items found %d", queryQueueDelta.Count()); 
   407                      OstTrace1( TRACE_NORMAL, DUP7_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - missing items found;queryQueueDelta.Count()=%d", queryQueueDelta.Count() );
       
   408                      //cleanup from previous queue it item is not found from MDS
   385                      //cleanup from previous queue it item is not found from MDS
   409                      while(queryQueueDelta.Count())
   386                      while(queryQueueDelta.Count())
   410                          {
   387                          {
   411                          TThumbnailGenerationItem item;
   388                          TThumbnailGenerationItem item;
   412                          item.iItemId = queryQueueDelta[0];
   389                          item.iItemId = queryQueueDelta[0];
   413                          TInt itemIndex = iQueryQueue.FindInOrder(item.iItemId, CompareId);
   390                          TInt itemIndex = iQueryQueue.FindInOrder(item.iItemId, CompareId);
   414                          
   391                          
   415                          if(itemIndex >= 0)
   392                          if(itemIndex >= 0)
   416                              {
   393                              {
   417                              TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove %d from iQueryQueue", queryQueueDelta[0]);
   394                              TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove %d from iQueryQueue", queryQueueDelta[0]);
   418                              OstTrace1( TRACE_NORMAL, DUP8_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - remove from iQueryQueue;queryQueueDelta[0]=%d", queryQueueDelta[0] );
       
   419                              iQueryQueue.Remove( itemIndex );
   395                              iQueryQueue.Remove( itemIndex );
   420                              
   396                              
   421                              //remove from procesing queue
   397                              //remove from procesing queue
   422                              itemIndex = iGenerationQueue.FindInOrder(item, Compare);
   398                              itemIndex = iGenerationQueue.FindInOrder(item, Compare);
   423                              
   399                              
   425                                  {
   401                                  {
   426                                  
   402                                  
   427                                  if( iUnknown )
   403                                  if( iUnknown )
   428                                      {
   404                                      {
   429                                      TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() mark %d as EGenerationItemTypeNotFound in iGenerationQueue", queryQueueDelta[0]);
   405                                      TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() mark %d as EGenerationItemTypeNotFound in iGenerationQueue", queryQueueDelta[0]);
   430                                      OstTrace1( TRACE_NORMAL, DUP9_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - mark as EGenerationItemTypeNotFound in iGenerationQueue;queryQueueDelta[0]=%d", queryQueueDelta[0] );
       
   431                                      //mark to be removed, cleanup is done below
   406                                      //mark to be removed, cleanup is done below
   432                                      iGenerationQueue[itemIndex].iItemType = EGenerationItemTypeNotFound;
   407                                      iGenerationQueue[itemIndex].iItemType = EGenerationItemTypeNotFound;
   433                                      }
   408                                      }
   434                                  else
   409                                  else
   435                                      {
   410                                      {
   436                                      TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove %d from iGenerationQueue", queryQueueDelta[0]);
   411                                      TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove %d from iGenerationQueue", queryQueueDelta[0]);
   437                                      OstTrace1( TRACE_NORMAL, DUP10_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - remove from iGenerationQueue;queryQueueDelta[0]=%d", queryQueueDelta[0] );
       
   438                                      iGenerationQueue.Remove( itemIndex );
   412                                      iGenerationQueue.Remove( itemIndex );
   439                                      }
   413                                      }
   440                                  }
   414                                  }
   441                              }
   415                              }
   442                          queryQueueDelta.Remove(0);
   416                          queryQueueDelta.Remove(0);
   464                             TThumbnailGenerationItem& item = iGenerationQueue[itemIndex]; 
   438                             TThumbnailGenerationItem& item = iGenerationQueue[itemIndex]; 
   465                             
   439                             
   466                             if(iGenerationQueue[itemIndex].iItemType == EGenerationItemTypeNotFound)
   440                             if(iGenerationQueue[itemIndex].iItemType == EGenerationItemTypeNotFound)
   467                                 {
   441                                 {
   468                                 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove EGenerationItemTypeNotFound %d item from iGenerationQueue", item.iItemId);
   442                                 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove EGenerationItemTypeNotFound %d item from iGenerationQueue", item.iItemId);
   469                                 OstTrace1( TRACE_NORMAL, DUP11_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - remove EGenerationItemTypeNotFound item from iGenerationQueue;item.iItemId=%u", item.iItemId );
       
   470                                 iGenerationQueue.Remove(itemIndex);
   443                                 iGenerationQueue.Remove(itemIndex);
   471                                 continue;
   444                                 continue;
   472                                 }
   445                                 }
   473                             
   446                             
   474                                 SetGenerationItemType(item, object->Def().Id());
   447                                 SetGenerationItemType(item, object->Def().Id());
   475                                     
   448                                     
   476                                 if(item.iItemType == EGenerationItemTypeUnknown )
   449                                 if(item.iItemType == EGenerationItemTypeUnknown )
   477                                   {
   450                                   {
   478                                   TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove unknown item %d", item.iItemId);
   451                                   TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove unknown item %d", item.iItemId);
   479                                   OstTrace1( TRACE_NORMAL, DUP12_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - remove unknown item;item.iItemId=%u", item.iItemId );
       
   480                                   iGenerationQueue.Remove(itemIndex);
   452                                   iGenerationQueue.Remove(itemIndex);
   481                                   continue;
   453                                   continue;
   482                                   }
   454                                   }
   483                               
   455                               
   484                               item.iPlaceholder = object->Placeholder(); 
   456                               item.iPlaceholder = object->Placeholder(); 
   502         else
   474         else
   503             {
   475             {
   504             //Delete and cancel query, do not return items back to original queue
   476             //Delete and cancel query, do not return items back to original queue
   505             DeleteAndCancelQuery( EFalse );
   477             DeleteAndCancelQuery( EFalse );
   506             TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() Query FAILED!"); 
   478             TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() Query FAILED!"); 
   507             OstTrace0( TRACE_NORMAL, DUP13_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - Query FAILED!" );
       
   508             }
   479             }
   509         }
   480         }
   510     else
   481     else
   511         {
   482         {
   512         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() - NO QUERY ACTIVE"); 
   483         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() - NO QUERY ACTIVE"); 
   513         OstTrace0( TRACE_NORMAL, DUP14_CTHUMBAGPROCESSOR_HANDLEQUERYCOMPLETED, "CThumbAGProcessor::HandleQueryCompleted - NO QUERY ACTIVE" );
       
   514         __ASSERT_DEBUG((EFalse), User::Panic(_L("CThumbAGProcessor::HandleQueryCompleted()"), -1));
   484         __ASSERT_DEBUG((EFalse), User::Panic(_L("CThumbAGProcessor::HandleQueryCompleted()"), -1));
   515         }
   485         }
   516     
   486     
   517     ActivateAO();
   487     ActivateAO();
   518     }
   488     }
   523 //
   493 //
   524 void CThumbAGProcessor::ThumbnailPreviewReady( MThumbnailData& /*aThumbnail*/, 
   494 void CThumbAGProcessor::ThumbnailPreviewReady( MThumbnailData& /*aThumbnail*/, 
   525                                                TThumbnailRequestId /*aId*/)
   495                                                TThumbnailRequestId /*aId*/)
   526     {
   496     {
   527     TN_DEBUG1( "CThumbAGProcessor::ThumbnailPreviewReady()");
   497     TN_DEBUG1( "CThumbAGProcessor::ThumbnailPreviewReady()");
   528     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_THUMBNAILPREVIEWREADY, "CThumbAGProcessor::ThumbnailPreviewReady" );
       
   529     // No implementation required
   498     // No implementation required
   530     }
   499     }
   531 
   500 
   532 // -----------------------------------------------------------------------------
   501 // -----------------------------------------------------------------------------
   533 // CThumbAGProcessor::ThumbnailReady()d
   502 // CThumbAGProcessor::ThumbnailReady()d
   535 //
   504 //
   536 void CThumbAGProcessor::ThumbnailReady( TInt aError, MThumbnailData& /*aThumbnail*/,
   505 void CThumbAGProcessor::ThumbnailReady( TInt aError, MThumbnailData& /*aThumbnail*/,
   537                                         TThumbnailRequestId /*aId*/ )
   506                                         TThumbnailRequestId /*aId*/ )
   538     {
   507     {
   539     TN_DEBUG2( "CThumbAGProcessor::ThumbnailReady() aError == %d", aError );
   508     TN_DEBUG2( "CThumbAGProcessor::ThumbnailReady() aError == %d", aError );
   540     OstTrace1( TRACE_NORMAL, CTHUMBAGPROCESSOR_THUMBNAILREADY, "CThumbAGProcessor::ThumbnailReady;aError=%d", aError );
       
   541     
   509     
   542     iActiveCount--;
   510     iActiveCount--;
   543     
   511     
   544     // TNM server died, delete session
   512     // TNM server died, delete session
   545     if( aError == KErrServerTerminated )
   513     if( aError == KErrServerTerminated )
   546         {
   514         {
   547         TN_DEBUG1( "CThumbAGProcessor::ThumbnailReady() - **** THUMBNAIL SERVER DIED ****" );
   515         TN_DEBUG1( "CThumbAGProcessor::ThumbnailReady() - **** THUMBNAIL SERVER DIED ****" );
   548 		OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_THUMBNAILREADY, "CThumbAGProcessor::ThumbnailReady - **** THUMBNAIL SERVER DIED ****" );
       
   549 		
   516 		
   550         iSessionDied = ETrue;
   517         iSessionDied = ETrue;
   551         
   518         
   552         if( !iPeriodicTimer->IsActive())
   519         if( !iPeriodicTimer->IsActive())
   553             {
   520             {
   555 			}
   522 			}
   556 			
   523 			
   557         //reset PS idle so that RunL() can startup reopen TNM session and proceed
   524         //reset PS idle so that RunL() can startup reopen TNM session and proceed
   558         TInt ret = RProperty::Set(KServerIdle, KIdle, ETrue);
   525         TInt ret = RProperty::Set(KServerIdle, KIdle, ETrue);
   559         TN_DEBUG2( "CThumbAGProcessor::ThumbnailReady() set Idle ret = %d", ret );
   526         TN_DEBUG2( "CThumbAGProcessor::ThumbnailReady() set Idle ret = %d", ret );
   560         OstTrace1( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_THUMBNAILREADY, "CThumbAGProcessor::ThumbnailReady - set Idle ret;ret=%d", ret );
   527         
   561         return;
   528         return;
   562         }
   529         }
   563     
   530     
   564     ActivateAO();
   531     ActivateAO();
   565 	
   532 	
   566     TN_DEBUG1( "CThumbAGProcessor::ThumbnailReady() - end" );
   533     TN_DEBUG1( "CThumbAGProcessor::ThumbnailReady() - end" );
   567     OstTrace0( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_THUMBNAILREADY, "CThumbAGProcessor::ThumbnailReady - end" );
       
   568     }
   534     }
   569 
   535 
   570 // -----------------------------------------------------------------------------
   536 // -----------------------------------------------------------------------------
   571 // CThumbAGProcessor::ThumbnailRequestReady()
   537 // CThumbAGProcessor::ThumbnailRequestReady()
   572 // -----------------------------------------------------------------------------
   538 // -----------------------------------------------------------------------------
   575                                                TThumbnailRequestId /*aId*/ )
   541                                                TThumbnailRequestId /*aId*/ )
   576     {	
   542     {	
   577     if (aRequestType == ERequestDeleteThumbnails)
   543     if (aRequestType == ERequestDeleteThumbnails)
   578         {
   544         {
   579         TN_DEBUG1( "CThumbAGProcessor::ThumbnailRequestReady() - delete" );
   545         TN_DEBUG1( "CThumbAGProcessor::ThumbnailRequestReady() - delete" );
   580         OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_THUMBNAILREQUESTREADY, "CThumbAGProcessor::ThumbnailRequestReady - delete" );
       
   581     
   546     
   582         iActiveCount--;
   547         iActiveCount--;
   583         
   548         
   584         ActivateAO();
   549         ActivateAO();
   585         }
   550         }
   590 // ---------------------------------------------------------------------------
   555 // ---------------------------------------------------------------------------
   591 //
   556 //
   592 void CThumbAGProcessor::SetMdESessionL( CMdESession* aMdESession )
   557 void CThumbAGProcessor::SetMdESessionL( CMdESession* aMdESession )
   593     {
   558     {
   594     TN_DEBUG1( "CThumbAGProcessor::SetMdESession() - begin" );
   559     TN_DEBUG1( "CThumbAGProcessor::SetMdESession() - begin" );
   595     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_SETMDESESSIONL, "CThumbAGProcessor::SetMdESessionL - begin" );
       
   596     
   560     
   597     iMdESession = aMdESession;
   561     iMdESession = aMdESession;
   598     
   562     
   599     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::SetMdESession() !iMdESession "), KErrBadHandle));
   563     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::SetMdESession() !iMdESession "), KErrBadHandle));
   600     
   564     
   601     TRAPD( err, iDefNamespace = &iMdESession->GetDefaultNamespaceDefL() );
   565     TRAPD( err, iDefNamespace = &iMdESession->GetDefaultNamespaceDefL() );
   602     if (err != KErrNone)
   566     if (err != KErrNone)
   603         {
   567         {
   604         TN_DEBUG2( "CThumbAGProcessor::SetMdESession() GetDefaultNamespaceDefL() err = %d", err );
   568         TN_DEBUG2( "CThumbAGProcessor::SetMdESession() GetDefaultNamespaceDefL() err = %d", err );
   605         OstTrace1( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_SETMDESESSIONL, "CThumbAGProcessor::SetMdESessionL;err=%d", err );
       
   606         __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::SetMdESession() !iDefNamespace "), KErrBadHandle));
   569         __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::SetMdESession() !iDefNamespace "), KErrBadHandle));
   607         }
   570         }
   608     else
   571     else
   609         {
   572         {
   610         iImageObjectDef = &iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );
   573         iImageObjectDef = &iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );
   630                                     const RArray<TItemId>& aIDArray, 
   593                                     const RArray<TItemId>& aIDArray, 
   631                                     const RPointerArray<HBufC>& aObjectUriArray,
   594                                     const RPointerArray<HBufC>& aObjectUriArray,
   632                                     TBool /*aPresent*/ )
   595                                     TBool /*aPresent*/ )
   633     {
   596     {
   634     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - begin" );
   597     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - begin" );
   635     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - begin" );
   598     
   636 
   599 
   637     // update queues
   600     // update queues
   638     if (aType == ENotifyAdd)
   601     if (aType == ENotifyAdd)
   639         {
   602         {
   640         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyAdd" );
   603         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyAdd" );
   656             }
   619             }
   657         }
   620         }
   658     else if (aType == ENotifyModify)
   621     else if (aType == ENotifyModify)
   659         {
   622         {
   660         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyModify" );
   623         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyModify" );
   661         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - ENotifyModify" );
       
   662         
   624         
   663         if(iPHHarvesting)
   625         if(iPHHarvesting)
   664             {        
   626             {        
   665             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH  harvesting active, treat like add" );
   627             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH  harvesting active, treat like add" );
   666             OstTrace0( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - PH  harvesting active, treat like add" );
       
   667             for (int i=0; i<aIDArray.Count(); i++)
   628             for (int i=0; i<aIDArray.Count(); i++)
   668                 {
   629                 {
   669                 TThumbnailGenerationItem item;
   630                 TThumbnailGenerationItem item;
   670                 item.iItemId = aIDArray[i];
   631                 item.iItemId = aIDArray[i];
   671                 item.iItemType = aItemType;
   632                 item.iItemType = aItemType;
   673                 TInt itemIndex = iGenerationQueue.FindInOrder(item, Compare);
   634                 TInt itemIndex = iGenerationQueue.FindInOrder(item, Compare);
   674                                 
   635                                 
   675                 if (itemIndex >= 0)
   636                 if (itemIndex >= 0)
   676                     {
   637                     {
   677                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - set as non-placeholder");
   638                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - set as non-placeholder");
   678                     OstTrace0( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - set as non-placeholder" );
       
   679                     iGenerationQueue[itemIndex].iPlaceholder = EFalse;
   639                     iGenerationQueue[itemIndex].iPlaceholder = EFalse;
   680                     }
   640                     }
   681                 else
   641                 else
   682                     {
   642                     {
   683                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append");
   643                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append");
   684                     OstTrace0( TRACE_NORMAL, DUP4_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - append" );
   644 
   685                      item.iPlaceholder = EFalse;
   645                      item.iPlaceholder = EFalse;
   686                      SetGenerationItemAction( item, aItemType );
   646                      SetGenerationItemAction( item, aItemType );
   687                      AppendProcessingQueue( item );
   647                      AppendProcessingQueue( item );
   688                     }
   648                     }
   689                 }
   649                 }
   690             }
   650             }
   691         else
   651         else
   692             {
   652             {
   693             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH  harvesting finished, check is real modify!" );
   653             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH  harvesting finished, check is real modify!" );
   694             OstTrace0( TRACE_NORMAL, DUP5_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - PH  harvesting finished, check is real modify!" );
       
   695             
   654             
   696             TInt itemIndex(KErrNotFound);
   655             TInt itemIndex(KErrNotFound);
   697             
   656             
   698             for (int i=0; i<aIDArray.Count(); i++)
   657             for (int i=0; i<aIDArray.Count(); i++)
   699                 {
   658                 {
   706                 if (itemIndex >= 0)
   665                 if (itemIndex >= 0)
   707                     {
   666                     {
   708                     if( iGenerationQueue[itemIndex].iPlaceholder )
   667                     if( iGenerationQueue[itemIndex].iPlaceholder )
   709                         {
   668                         {
   710                         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - placeholder modify");
   669                         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - placeholder modify");
   711                         OstTrace0( TRACE_NORMAL, DUP6_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - placeholder modify" );
       
   712                         iGenerationQueue[itemIndex].iPlaceholder = EFalse;
   670                         iGenerationQueue[itemIndex].iPlaceholder = EFalse;
   713                         }
   671                         }
   714                     else
   672                     else
   715                         {
   673                         {
   716                         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - real modify");
   674                         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - real modify");
   717                         OstTrace0( TRACE_NORMAL, DUP7_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - real modify" );
       
   718                         iGenerationQueue[itemIndex].iItemAction = EGenerationItemActionModify;
   675                         iGenerationQueue[itemIndex].iItemAction = EGenerationItemActionModify;
   719                         SetForceRun( ETrue );
   676                         SetForceRun( ETrue );
   720                         }
   677                         }
   721                     }
   678                     }
   722                 else
   679                 else
   723                     {
   680                     {
   724                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append");
   681                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append");
   725                     OstTrace0( TRACE_NORMAL, DUP8_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - append" );
       
   726                     SetGenerationItemAction( item, aItemType);
   682                     SetGenerationItemAction( item, aItemType);
   727                     item.iPlaceholder = EFalse;
   683                     item.iPlaceholder = EFalse;
   728                     AppendProcessingQueue( item );
   684                     AppendProcessingQueue( item );
   729                     }
   685                     }
   730                 }
   686                 }
   731             }
   687             }
   732         }
   688         }
   733         else if (aType == ENotifyRemove && aItemType == EGenerationItemTypeAny)
   689         else if (aType == ENotifyRemove && aItemType == EGenerationItemTypeAny)
   734             {
   690             {
   735             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove, remove IDs from all queues");
   691             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove, remove IDs from all queues");
   736             OstTrace0( TRACE_NORMAL, DUP9_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - ENotifyRemove, remove IDs from all queues" );
       
   737             
   692             
   738             for (int i=0; i<aIDArray.Count(); i++)
   693             for (int i=0; i<aIDArray.Count(); i++)
   739                 {
   694                 {
   740                 TThumbnailGenerationItem item;
   695                 TThumbnailGenerationItem item;
   741                 item.iItemId = aIDArray[i];
   696                 item.iItemId = aIDArray[i];
   760                         }
   715                         }
   761                     }
   716                     }
   762                 else
   717                 else
   763                     {
   718                     {
   764                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append");
   719                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append");
   765                     OstTrace0( TRACE_NORMAL, DUP10_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - append" );
       
   766                     item.iItemAction = EGenerationItemActionDelete;
   720                     item.iItemAction = EGenerationItemActionDelete;
   767                     delete item.iUri;
   721                     delete item.iUri;
   768                     item.iUri = NULL;
   722                     item.iUri = NULL;
   769                     
   723                     
   770                     if( aObjectUriArray[i])
   724                     if( aObjectUriArray[i])
   778                     //owned by item
   732                     //owned by item
   779                     item.iUri = NULL;
   733                     item.iUri = NULL;
   780                     }
   734                     }
   781                 
   735                 
   782                 TN_DEBUG2( "CThumbAGProcessor::AddToQueueL() - %S", aObjectUriArray[i]); 
   736                 TN_DEBUG2( "CThumbAGProcessor::AddToQueueL() - %S", aObjectUriArray[i]); 
   783                 OstTraceExt1( TRACE_NORMAL, DUP11_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL;aObjectUriArray[i]=%S", *aObjectUriArray[i] );
       
   784                 }
   737                 }
   785             }
   738             }
   786 #ifdef _DEBUG
   739 #ifdef _DEBUG
   787         else
   740         else
   788             {
   741             {
   789 	        TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() -  should not come here" );
   742 	        TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() -  should not come here" );
   790 	        OstTrace0( TRACE_NORMAL, DUP12_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL -  should not come here" );
       
   791 	        __ASSERT_DEBUG((EFalse), User::Panic(_L("CThumbAGProcessor::AddToQueueL()"), KErrArgument));
   743 	        __ASSERT_DEBUG((EFalse), User::Panic(_L("CThumbAGProcessor::AddToQueueL()"), KErrArgument));
   792 	        User::Leave( KErrArgument );
   744 	        User::Leave( KErrArgument );
   793             }
   745             }
   794 #endif
   746 #endif
   795     
   747     
   796     ActivateAO(); 
   748     ActivateAO(); 
   797     
   749     
   798     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - end" );
   750     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - end" );
   799     OstTrace0( TRACE_NORMAL, DUP13_CTHUMBAGPROCESSOR_ADDTOQUEUEL, "CThumbAGProcessor::AddToQueueL - end" );
       
   800     }
   751     }
   801 
   752 
   802 // ---------------------------------------------------------------------------
   753 // ---------------------------------------------------------------------------
   803 // CThumbAGProcessor::CreateThumbnailsL()
   754 // CThumbAGProcessor::CreateThumbnailsL()
   804 // ---------------------------------------------------------------------------
   755 // ---------------------------------------------------------------------------
   805 //
   756 //
   806 void CThumbAGProcessor::CreateThumbnailsL( const CMdEObject* aObject )
   757 void CThumbAGProcessor::CreateThumbnailsL( const CMdEObject* aObject )
   807     {
   758     {
   808     TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - begin" );
   759     TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - begin" );
   809     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_CREATETHUMBNAILSL, "CThumbAGProcessor::CreateThumbnailsL - begin" );
       
   810     
   760     
   811     __ASSERT_DEBUG((iTMSession), User::Panic(_L("CThumbAGProcessor::CreateThumbnailsL() !iTMSession "), KErrBadHandle));
   761     __ASSERT_DEBUG((iTMSession), User::Panic(_L("CThumbAGProcessor::CreateThumbnailsL() !iTMSession "), KErrBadHandle));
   812     __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::CreateThumbnailsL() !iDefNamespace "), KErrBadHandle));
   762     __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::CreateThumbnailsL() !iDefNamespace "), KErrBadHandle));
   813     
   763     
   814     if(!iTMSession || !iDefNamespace)
   764     if(!iTMSession || !iDefNamespace)
   843 		// 2nd round and modify updates both sizes if needed
   793 		// 2nd round and modify updates both sizes if needed
   844         if( i2ndRound )
   794         if( i2ndRound )
   845             {
   795             {
   846             //generate both if needed
   796             //generate both if needed
   847             TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() EOptimizeForQuality ");
   797             TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() EOptimizeForQuality ");
   848             OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_CREATETHUMBNAILSL, "CThumbAGProcessor::CreateThumbnailsL - EOptimizeForQuality" );
       
   849             iTMSession->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQuality );
   798             iTMSession->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQuality );
   850             
   799             
   851             TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL() - 2nd round add remove from queue", aObject->Id() );
   800             TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL() - 2nd round add remove from queue", aObject->Id() );
   852             OstTrace1( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_CREATETHUMBNAILSL, "CThumbAGProcessor::CreateThumbnailsL - 2nd round add remove from queue;aObject->Id()=%u", aObject->Id() );
       
   853                         
   801                         
   854             TThumbnailGenerationItem item;
   802             TThumbnailGenerationItem item;
   855             item.iItemId = aObject->Id();
   803             item.iItemId = aObject->Id();
   856             TInt itemIndex = iGenerationQueue.FindInOrder(item, Compare);
   804             TInt itemIndex = iGenerationQueue.FindInOrder(item, Compare);
   857             
   805             
   866 		// 1st roung generation
   814 		// 1st roung generation
   867         else
   815         else
   868             {
   816             {
   869             //1st round
   817             //1st round
   870             TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() EOptimizeForQualityWithPreview");
   818             TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() EOptimizeForQualityWithPreview");
   871             OstTrace0( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_CREATETHUMBNAILSL, "CThumbAGProcessor::CreateThumbnailsL - EOptimizeForQualityWithPreview" );
       
   872             iTMSession->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQualityWithPreview );
   819             iTMSession->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQualityWithPreview );
   873             
   820             
   874             // add item to 2nd round queue 
   821             // add item to 2nd round queue 
   875             TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL() - 1st round add/modify, append to 2nd round queue", aObject->Id() );
   822             TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL() - 1st round add/modify, append to 2nd round queue", aObject->Id() );
   876             OstTrace1( TRACE_NORMAL, DUP4_CTHUMBAGPROCESSOR_CREATETHUMBNAILSL, "CThumbAGProcessor::CreateThumbnailsL - 1st round add/modify, append to 2nd round queue;aObject->Id()=%u", aObject->Id() );
       
   877             
   823             
   878             TThumbnailGenerationItem item;
   824             TThumbnailGenerationItem item;
   879             item.iItemId = aObject->Id();
   825             item.iItemId = aObject->Id();
   880             TInt itemIndex = iGenerationQueue.FindInOrder(item, Compare);
   826             TInt itemIndex = iGenerationQueue.FindInOrder(item, Compare);
   881             
   827             
   902         TRAPD(err, iTMSession->UpdateThumbnailsL(KNoId, aObject->Uri(), orientationVal, modifiedVal, CActive::EPriorityIdle ));
   848         TRAPD(err, iTMSession->UpdateThumbnailsL(KNoId, aObject->Uri(), orientationVal, modifiedVal, CActive::EPriorityIdle ));
   903       
   849       
   904         if ( err != KErrNone )
   850         if ( err != KErrNone )
   905             {
   851             {
   906             TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL, iTMSession error == %d", err );
   852             TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL, iTMSession error == %d", err );
   907             OstTrace0( TRACE_NORMAL, DUP5_CTHUMBAGPROCESSOR_CREATETHUMBNAILSL, "CThumbAGProcessor::CreateThumbnailsL" );
       
   908             
   853             
   909             iSessionDied = ETrue;
   854             iSessionDied = ETrue;
   910             ActivateAO();
   855             ActivateAO();
   911             } 
   856             } 
   912         else
   857         else
   918         {
   863         {
   919         ActivateAO();
   864         ActivateAO();
   920         }
   865         }
   921         
   866         
   922     TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - end" );
   867     TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - end" );
   923     OstTrace0( TRACE_NORMAL, DUP6_CTHUMBAGPROCESSOR_CREATETHUMBNAILSL, "CThumbAGProcessor::CreateThumbnailsL - end" );
       
   924     }
   868     }
   925 
   869 
   926 // ---------------------------------------------------------------------------
   870 // ---------------------------------------------------------------------------
   927 // CThumbAGProcessor::QueryL()
   871 // CThumbAGProcessor::QueryL()
   928 // ---------------------------------------------------------------------------
   872 // ---------------------------------------------------------------------------
   929 //
   873 //
   930 void CThumbAGProcessor::QueryL(/*RArray<TItemId>& aIDArray*/TThumbnailGenerationItemAction aAction  )
   874 void CThumbAGProcessor::QueryL(/*RArray<TItemId>& aIDArray*/TThumbnailGenerationItemAction aAction  )
   931     {
   875     {
   932     TN_DEBUG1( "CThumbAGProcessor::QueryL() - begin" );
   876     TN_DEBUG1( "CThumbAGProcessor::QueryL() - begin" );
   933     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_QUERYL, "CThumbAGProcessor::QueryL - begin" );
       
   934     
   877     
   935     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryL() !iMdeSession "), KErrBadHandle));
   878     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryL() !iMdeSession "), KErrBadHandle));
   936     __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::QueryL() !iDefNamespace "), KErrBadHandle));
   879     __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::QueryL() !iDefNamespace "), KErrBadHandle));
   937     
   880     
   938     if(!iMdESession  || !iDefNamespace || iShutdown)
   881     if(!iMdESession  || !iDefNamespace || iShutdown)
   955     
   898     
   956     //move ID from source queue to Query queue
   899     //move ID from source queue to Query queue
   957     TInt maxCount = iGenerationQueue.Count();
   900     TInt maxCount = iGenerationQueue.Count();
   958         
   901         
   959     TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin iGenerationQueue == %d, iQueryQueue == %d", iGenerationQueue.Count(), iQueryQueue.Count() );
   902     TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin iGenerationQueue == %d, iQueryQueue == %d", iGenerationQueue.Count(), iQueryQueue.Count() );
   960     OstTraceExt2( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_QUERYL, "CThumbAGProcessor::QueryL -  - fill begin iGenerationQueue, iQueryQueue;iGenerationQueue.Count()=%d;iQueryQueue.Count()=%d", iGenerationQueue.Count(), iQueryQueue.Count() );
   903     
   961     
   904     
   962     TInt itemCount(0);
   905     TInt itemCount(0);
   963     for(TInt i=0; itemCount < KMaxQueryItems && i < maxCount; i++)
   906     for(TInt i=0; itemCount < KMaxQueryItems && i < maxCount; i++)
   964         {
   907         {
   965         TInt itemIndex(KErrNotFound);
   908         TInt itemIndex(KErrNotFound);
   996             };
   939             };
   997         
   940         
   998         if( itemIndex >= 0 )
   941         if( itemIndex >= 0 )
   999             {
   942             {
  1000             TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", iGenerationQueue[itemIndex].iItemId );        
   943             TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", iGenerationQueue[itemIndex].iItemId );        
  1001             OstTrace1( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_QUERYL, "CThumbAGProcessor::QueryL - fill;iGenerationQueue[itemIndex].iItemId=%u", iGenerationQueue[itemIndex].iItemId );
       
  1002             iQueryQueue.InsertInOrder(iGenerationQueue[itemIndex].iItemId, CompareId);
   944             iQueryQueue.InsertInOrder(iGenerationQueue[itemIndex].iItemId, CompareId);
  1003             itemCount++;
   945             itemCount++;
  1004             }
   946             }
  1005         }
   947         }
  1006     
   948     
  1007     if(!itemCount)
   949     if(!itemCount)
  1008         {
   950         {
  1009         TN_DEBUG1( "CThumbAGProcessor::QueryL() - empty query, cancel?!");
   951         TN_DEBUG1( "CThumbAGProcessor::QueryL() - empty query, cancel?!");
  1010         OstTrace0( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_QUERYL, "CThumbAGProcessor::QueryL - empty query, cancel?!" );
       
  1011         iQueryActive = EFalse;
   952         iQueryActive = EFalse;
  1012         __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryL() empty! "), KErrNotFound));
   953         __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryL() empty! "), KErrNotFound));
  1013         return;
   954         return;
  1014         }
   955         }
  1015     
   956     
  1016     TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end iGenerationQueue == %d, iQueryQueue == %d", iGenerationQueue.Count(), iQueryQueue.Count() );
   957     TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end iGenerationQueue == %d, iQueryQueue == %d", iGenerationQueue.Count(), iQueryQueue.Count() );
  1017     OstTraceExt2( TRACE_NORMAL, DUP4_CTHUMBAGPROCESSOR_QUERYL, "CThumbAGProcessor::QueryL;iGenerationQueue.Count()=%d;iQueryQueue.Count()=%d", iGenerationQueue.Count(), iQueryQueue.Count() );
       
  1018     
   958     
  1019     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );
   959     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );
  1020     iQuery = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this );
   960     iQuery = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this );
  1021 	
   961 	
  1022 	if(iQuery)
   962 	if(iQuery)
  1053 	            }    
   993 	            }    
  1054 	        }
   994 	        }
  1055     
   995     
  1056 	    iQuery->FindL();
   996 	    iQuery->FindL();
  1057 		}
   997 		}
  1058 	else
       
  1059 	    {
       
  1060         iQueryActive = EFalse;
       
  1061 	    }
       
  1062     
   998     
  1063     TN_DEBUG1( "CThumbAGProcessor::QueryL() - end" );
   999     TN_DEBUG1( "CThumbAGProcessor::QueryL() - end" );
  1064     OstTrace0( TRACE_NORMAL, DUP5_CTHUMBAGPROCESSOR_QUERYL, "CThumbAGProcessor::QueryL - end" );
       
  1065     }
  1000     }
  1066 
  1001 
  1067 
  1002 
  1068 // ---------------------------------------------------------------------------
  1003 // ---------------------------------------------------------------------------
  1069 // CThumbAGProcessor::QueryForPlaceholders()
  1004 // CThumbAGProcessor::QueryForPlaceholders()
  1071 //
  1006 //
  1072 
  1007 
  1073 void CThumbAGProcessor::QueryPlaceholdersL(TBool aPresent)
  1008 void CThumbAGProcessor::QueryPlaceholdersL(TBool aPresent)
  1074     {
  1009     {
  1075     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL" );
  1010     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL" );
  1076     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_QUERYPLACEHOLDERSL, "CThumbAGProcessor::QueryPlaceholdersL" );
       
  1077     
  1011     
  1078     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryPlaceholdersL() !iMdeSession "), KErrBadHandle));
  1012     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryPlaceholdersL() !iMdeSession "), KErrBadHandle));
  1079     __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::QueryPlaceholdersL() !iDefNamespace "), KErrBadHandle));
  1013     __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::QueryPlaceholdersL() !iDefNamespace "), KErrBadHandle));
  1080     
  1014     
  1081     if(!iMdESession  || !iDefNamespace || iShutdown)
  1015     if(!iMdESession  || !iDefNamespace || iShutdown)
  1086     if( iQueryPlaceholders )
  1020     if( iQueryPlaceholders )
  1087         {
  1021         {
  1088         if( !iQueryPlaceholders->IsComplete() )
  1022         if( !iQueryPlaceholders->IsComplete() )
  1089             {
  1023             {
  1090             TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL active- skip" );
  1024             TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL active- skip" );
  1091             OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_QUERYPLACEHOLDERSL, "CThumbAGProcessor::QueryPlaceholdersL - skip" );
       
  1092             return;
  1025             return;
  1093             }
  1026             }
  1094         
  1027         
  1095         // delete old query
  1028         // delete old query
  1096         iQueryPlaceholders->Cancel();
  1029         iQueryPlaceholders->Cancel();
  1097         delete iQueryPlaceholders;
  1030         delete iQueryPlaceholders;
  1098         iQueryPlaceholders = NULL;
  1031         iQueryPlaceholders = NULL;
  1099         }
  1032         }
  1100    
  1033    
  1101     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL - start" );
  1034     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL - start" );
  1102     OstTrace0( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_QUERYPLACEHOLDERSL, "CThumbAGProcessor::QueryPlaceholdersL - start" );
       
  1103 
  1035 
  1104     CMdEObjectDef& imageObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );
  1036     CMdEObjectDef& imageObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );
  1105     CMdEObjectDef& videoObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject );
  1037     CMdEObjectDef& videoObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject );
  1106     CMdEObjectDef& audioObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject );
  1038     CMdEObjectDef& audioObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject );
  1107     
  1039     
  1128         CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
  1060         CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
  1129         CleanupStack::PushL( &audioPHObjectCondition );
  1061         CleanupStack::PushL( &audioPHObjectCondition );
  1130         audioPHObjectCondition.SetPlaceholderOnly( ETrue );
  1062         audioPHObjectCondition.SetPlaceholderOnly( ETrue );
  1131         audioPHObjectCondition.SetNotPresent( aPresent );
  1063         audioPHObjectCondition.SetNotPresent( aPresent );
  1132         
  1064         
  1133         iQueryPlaceholders->FindL(KMdEQueryDefaultMaxCount, KMaxQueryBatchSize);   
  1065         iQueryPlaceholders->FindL(KMaxTInt, KMaxQueryBatchSize);   
  1134        
  1066        
  1135         CleanupStack::Pop(3, &imagePHObjectCondition );
  1067         CleanupStack::Pop(3, &imagePHObjectCondition );
  1136         }
  1068         }
  1137 	
  1069 	
  1138     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL - end" );
  1070     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL - end" );
  1139     OstTrace0( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_QUERYPLACEHOLDERSL, "CThumbAGProcessor::QueryPlaceholdersL - end" );
       
  1140     }
  1071     }
  1141 
  1072 
  1142 
  1073 
  1143 // ---------------------------------------------------------------------------
  1074 // ---------------------------------------------------------------------------
  1144 // CThumbAGProcessor::RunL()
  1075 // CThumbAGProcessor::RunL()
  1145 // ---------------------------------------------------------------------------
  1076 // ---------------------------------------------------------------------------
  1146 //
  1077 //
  1147 void CThumbAGProcessor::RunL()
  1078 void CThumbAGProcessor::RunL()
  1148     {
  1079     {
  1149     TN_DEBUG1( "CThumbAGProcessor::RunL() - begin" );
  1080     TN_DEBUG1( "CThumbAGProcessor::RunL() - begin" );
  1150 	OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - begin" );
       
  1151 	
  1081 	
  1152 	if(iShutdown)
  1082 	if(iShutdown)
  1153 		{
  1083 		{
  1154         TN_DEBUG1( "CThumbAGProcessor::RunL() - shutdown" );
  1084         TN_DEBUG1( "CThumbAGProcessor::RunL() - shutdown" );
  1155 		OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - shutdown" );
       
  1156 		return;
  1085 		return;
  1157 		}
  1086 		}
  1158     
  1087     
  1159     if (iSessionDied)
  1088     if (iSessionDied)
  1160         {
  1089         {
  1161         TN_DEBUG1( "CThumbAGProcessor::RunL() - iSessionDied" );
  1090         TN_DEBUG1( "CThumbAGProcessor::RunL() - iSessionDied" );
  1162         OstTrace0( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - iSessionDied" );
       
  1163         delete iTMSession;
  1091         delete iTMSession;
  1164         iTMSession = NULL;
  1092         iTMSession = NULL;
  1165         }
  1093         }
  1166     
  1094     
  1167     if (iInit)
  1095     if (iInit)
  1168         {
  1096         {
  1169         TN_DEBUG1( "CThumbAGProcessor::RunL() - Do Initialisation 1" );
  1097         TN_DEBUG1( "CThumbAGProcessor::RunL() - Do Initialisation 1" );
  1170         OstTrace0( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - Do Initialisation 1" );
       
  1171         
  1098         
  1172         iInit = EFalse;
  1099         iInit = EFalse;
  1173         iInit2 = ETrue;
  1100         iInit2 = ETrue;
  1174 
  1101 
  1175         iGenerationQueue.Reset();
  1102         iGenerationQueue.Reset();
  1178 		//query all not present placeholders
  1105 		//query all not present placeholders
  1179         TRAP_IGNORE(QueryPlaceholdersL( ETrue ));
  1106         TRAP_IGNORE(QueryPlaceholdersL( ETrue ));
  1180 		//query all items after PH query
  1107 		//query all items after PH query
  1181         iDoQueryAllItems = ETrue;
  1108         iDoQueryAllItems = ETrue;
  1182         TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation 1 done" );
  1109         TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation 1 done" );
  1183         OstTrace0( TRACE_NORMAL, DUP4_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - Initialisation 1 done" );
       
  1184         ActivateAO();
  1110         ActivateAO();
  1185         return;
  1111         return;
  1186         }
  1112         }
  1187     
  1113     
  1188     if(iInit2)
  1114     if(iInit2)
  1189         {
  1115         {
  1190         TN_DEBUG1( "CThumbAGProcessor::RunL() - Do Initialisation 2" );
  1116         TN_DEBUG1( "CThumbAGProcessor::RunL() - Do Initialisation 2" );
  1191 		OstTrace0( TRACE_NORMAL, DUP5_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - Do Initialisation 2" );
       
  1192 		
  1117 		
  1193         iInit2 = EFalse;
  1118         iInit2 = EFalse;
  1194         TInt err(KErrNone);
  1119         TInt err(KErrNone);
  1195         
  1120         
  1196 #ifdef  MDS_MODIFY_OBSERVER        
  1121 #ifdef  MDS_MODIFY_OBSERVER        
  1197         TN_DEBUG1( "CThumbAGProcessor::RunL() do iHarvesterClient connect");
  1122         TN_DEBUG1( "CThumbAGProcessor::RunL() do iHarvesterClient connect");
  1198         OstTrace0( TRACE_NORMAL, DUP6_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - do iHarvesterClient connect" );
       
  1199         err = iHarvesterClient.Connect();
  1123         err = iHarvesterClient.Connect();
  1200         TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient connect err = %d", err);
  1124         TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient connect err = %d", err);
  1201         OstTrace1( TRACE_NORMAL, DUP7_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - iHarvesterClient connect;err=%d", err );
       
  1202         
  1125         
  1203         __ASSERT_DEBUG((err == KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err));
  1126         __ASSERT_DEBUG((err == KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err));
  1204         
  1127         
  1205         if(  err == KErrNone )
  1128         if(  err == KErrNone )
  1206             {
  1129             {
  1207             TN_DEBUG1( "CThumbAGProcessor::RunL() add iHarvesterClient observer");
  1130             TN_DEBUG1( "CThumbAGProcessor::RunL() add iHarvesterClient observer");
  1208             OstTrace0( TRACE_NORMAL, DUP8_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - add iHarvesterClient observer" );
       
  1209             err = iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall | EHEObserverTypeMMC | EHEObserverTypePlaceholder, 20 );
  1131             err = iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall | EHEObserverTypeMMC | EHEObserverTypePlaceholder, 20 );
  1210             TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient observer err = %d", err);
  1132             TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient observer err = %d", err);
  1211             OstTrace1( TRACE_NORMAL, DUP9_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - iHarvesterClient observer;err=%d", err );
       
  1212             
  1133             
  1213             if( !err )
  1134             if( !err )
  1214                 {
  1135                 {
  1215                 TN_DEBUG1( "CThumbAGProcessor::RunL() add iHarvesterClient observer failed");
  1136                 TN_DEBUG1( "CThumbAGProcessor::RunL() add iHarvesterClient observer failed");
  1216                 OstTrace0( TRACE_NORMAL, DUP10_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - add iHarvesterClient observer failed" );
       
  1217                 // if we fail observer harvester, fake it
  1137                 // if we fail observer harvester, fake it
  1218                 iHarvesterActivated = ETrue;
  1138                 iHarvesterActivated = ETrue;
  1219                 }
  1139                 }
  1220             __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err));
  1140             __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err));
  1221             }
  1141             }
  1222 #endif
  1142 #endif
  1223  
  1143  
  1224         TN_DEBUG1( "CThumbAGProcessor::RunL() MMPXCollectionUtility");
  1144         TN_DEBUG1( "CThumbAGProcessor::RunL() MMPXCollectionUtility");
  1225         OstTrace0( TRACE_NORMAL, DUP11_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - MMPXCollectionUtility");
       
  1226         TRAP( err, iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated ));
  1145         TRAP( err, iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated ));
  1227         TN_DEBUG2( "CThumbAGProcessor::RunL() create MMPXCollectionUtility err = %d", err);
  1146         TN_DEBUG2( "CThumbAGProcessor::RunL() create MMPXCollectionUtility err = %d", err);
  1228         OstTrace1( TRACE_NORMAL, DUP12_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - create MMPXCollectionUtility err;err=%d", err );
       
  1229         __ASSERT_DEBUG((iCollectionUtility), User::Panic(_L("CThumbAGProcessor::RunL(), !iCollectionUtility "), err));
  1147         __ASSERT_DEBUG((iCollectionUtility), User::Panic(_L("CThumbAGProcessor::RunL(), !iCollectionUtility "), err));
  1230         
  1148         
  1231         __ASSERT_DEBUG((iActivityManager), User::Panic(_L("CThumbAGProcessor::RunL(), !iActivityManager "), KErrBadHandle));
  1149         __ASSERT_DEBUG((iActivityManager), User::Panic(_L("CThumbAGProcessor::RunL(), !iActivityManager "), KErrBadHandle));
  1232         if(iActivityManager)
  1150         if(iActivityManager)
  1233             {
  1151             {
  1234             iActivityManager->Start();
  1152             iActivityManager->Start();
  1235             }
  1153             }
  1236         
  1154         
  1237         TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation 2 done" );
  1155         TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation 2 done" );
  1238         OstTrace0( TRACE_NORMAL, DUP13_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - Initialisation 2 done" );
       
  1239         return;
  1156         return;
  1240         }
  1157         }
  1241     
  1158     
  1242     // restart session if died
  1159     // restart session if died
  1243     if (!iTMSession)
  1160     if (!iTMSession)
  1244         {
  1161         {
  1245         TN_DEBUG1( "CThumbAGProcessor::RunL() - open TNM session");
  1162         TN_DEBUG1( "CThumbAGProcessor::RunL() - open TNM session");
  1246         OstTrace0( TRACE_NORMAL, DUP14_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL" );
       
  1247         TRAPD( err, iTMSession = CThumbnailManager::NewL( *this ) );
  1163         TRAPD( err, iTMSession = CThumbnailManager::NewL( *this ) );
  1248 		
  1164 		
  1249         if (err != KErrNone)
  1165         if (err != KErrNone)
  1250             {
  1166             {
  1251             iTMSession = NULL;
  1167             iTMSession = NULL;
  1252             ActivateAO();
  1168             ActivateAO();
  1253             TN_DEBUG2( "CThumbAGProcessor::RunL() - Session restart failed, error == %d", err );
  1169             TN_DEBUG2( "CThumbAGProcessor::RunL() - Session restart failed, error == %d", err );
  1254             OstTrace1( TRACE_NORMAL, DUP15_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - Session restart failed, error;err=%d", err );
       
  1255             }        
  1170             }        
  1256         else 
  1171         else 
  1257             {
  1172             {
  1258             iTMSession->SetRequestObserver(*this);
  1173             iTMSession->SetRequestObserver(*this);
  1259             iSessionDied = EFalse;
  1174             iSessionDied = EFalse;
  1262    
  1177    
  1263     // do not run if request is already issued to TNM server even if forced
  1178     // do not run if request is already issued to TNM server even if forced
  1264     if(iActiveCount >= KMaxDaemonRequests)
  1179     if(iActiveCount >= KMaxDaemonRequests)
  1265         {
  1180         {
  1266         TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for previous to complete, abort..." );
  1181         TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for previous to complete, abort..." );
  1267         OstTrace0( TRACE_NORMAL, DUP16_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - waiting for previous to complete, abort..." );
       
  1268         return;
  1182         return;
  1269         }
  1183         }
  1270     
  1184     
  1271     //force run can proceed from this point
  1185     //force run can proceed from this point
  1272 #ifdef _DEBUG
  1186 #ifdef _DEBUG
  1273 	if( iForegroundRun )
  1187 	if( iForegroundRun )
  1274 		{
  1188 		{
  1275       	TN_DEBUG1( "void CThumbAGProcessor::RunL() KForceBackgroundGeneration enabled");
  1189       	TN_DEBUG1( "void CThumbAGProcessor::RunL() KForceBackgroundGeneration enabled");
  1276 	  	OstTrace0( TRACE_NORMAL, DUP17_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - KForceBackgroundGeneration enabled" );
       
  1277 	  	}
  1190 	  	}
  1278 	
  1191 	
  1279     if( iForceRun )
  1192     if( iForceRun )
  1280         {
  1193         {
  1281         TN_DEBUG1( "CThumbAGProcessor::RunL() - *** FORCED RUN ***");
  1194         TN_DEBUG1( "CThumbAGProcessor::RunL() - *** FORCED RUN ***");
  1282         OstTrace0( TRACE_NORMAL, DUP18_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - *** FORCED RUN ***" );
       
  1283         }
  1195         }
  1284 #endif
  1196 #endif
  1285 	
  1197 	
  1286   	if( (iForceRun || iForegroundRun ) && !iMountTimer->IsActive() )
  1198   	if( (iForceRun || iForegroundRun ) && !iMountTimer->IsActive() )
  1287       	{
  1199       	{
  1288         TN_DEBUG1( "void CThumbAGProcessor::RunL() skip idle detection!");
  1200         TN_DEBUG1( "void CThumbAGProcessor::RunL() skip idle detection!");
  1289       	OstTrace0( TRACE_NORMAL, DUP19_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - skip idle detection!" );
       
  1290       	CancelTimeout();
  1201       	CancelTimeout();
  1291      	}
  1202      	}
  1292   	else
  1203   	else
  1293 	    {
  1204 	    {
  1294         if( !iIdle || iHarvesting || iMPXHarvesting || iPeriodicTimer->IsActive() )
  1205         if( !iIdle || iHarvesting || iMPXHarvesting || iPeriodicTimer->IsActive() )
  1295             {
  1206             {
  1296             TN_DEBUG1( "void CThumbAGProcessor::RunL() device not idle");
  1207             TN_DEBUG1( "void CThumbAGProcessor::RunL() device not idle");
  1297             OstTrace0( TRACE_NORMAL, DUP20_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - device not idle" );
       
  1298             return;
  1208             return;
  1299             }
  1209             }
  1300         else
  1210         else
  1301             {
  1211             {
  1302             //check is server idle
  1212             //check is server idle
  1305             
  1215             
  1306             if(ret != KErrNone || !serveIdle )
  1216             if(ret != KErrNone || !serveIdle )
  1307                 {
  1217                 {
  1308             	//start inactivity timer and retry on after callback
  1218             	//start inactivity timer and retry on after callback
  1309             	TN_DEBUG1( "void CThumbAGProcessor::RunL() server not idle");
  1219             	TN_DEBUG1( "void CThumbAGProcessor::RunL() server not idle");
  1310                 OstTrace0( TRACE_NORMAL, DUP21_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - server not idle" );
       
  1311                 StartTimeout();
  1220                 StartTimeout();
  1312                 return;
  1221                 return;
  1313                 }
  1222                 }
  1314             TN_DEBUG1( "void CThumbAGProcessor::RunL() device and server idle, process");
  1223             TN_DEBUG1( "void CThumbAGProcessor::RunL() device and server idle, process");
  1315             OstTrace0( TRACE_NORMAL, DUP22_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - device and server idle, process" );
       
  1316             }
  1224             }
  1317 	    }
  1225 	    }
  1318     
  1226     
  1319     //Handle completed MDS Query
  1227     //Handle completed MDS Query
  1320     if( iQueryReady && iProcessingCount)
  1228     if( iQueryReady && iProcessingCount)
  1324 		//if unknown items or mount timer is active, abort processing
  1232 		//if unknown items or mount timer is active, abort processing
  1325 
  1233 
  1326         if(((iForceRun && iModify ) || (!iForceRun && !iModify )) && !iUnknownItemCount && !iMountTimer->IsActive())
  1234         if(((iForceRun && iModify ) || (!iForceRun && !iModify )) && !iUnknownItemCount && !iMountTimer->IsActive())
  1327             {
  1235             {
  1328             TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" );
  1236             TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" );
  1329             OstTrace0( TRACE_NORMAL, DUP23_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - iQueryReady START" );
       
  1330             
  1237             
  1331             const CMdEObject* object = &iQuery->Result( iProcessingCount-1 );
  1238             const CMdEObject* object = &iQuery->Result( iProcessingCount-1 );
  1332             iProcessingCount--;
  1239             iProcessingCount--;
  1333             
  1240             
  1334             if ( object )
  1241             if ( object )
  1342                     iQueryQueue.Remove(itemIndex);
  1249                     iQueryQueue.Remove(itemIndex);
  1343                     }
  1250                     }
  1344             
  1251             
  1345                 TRAP( err, CreateThumbnailsL( object ) );
  1252                 TRAP( err, CreateThumbnailsL( object ) );
  1346                 TN_DEBUG2( "CThumbAGProcessor::RunL(), CreateThumbnailsL error == %d", err );
  1253                 TN_DEBUG2( "CThumbAGProcessor::RunL(), CreateThumbnailsL error == %d", err );
  1347                 OstTrace1( TRACE_NORMAL, DUP24_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - CreateThumbnailsL error;err=%d", err );
       
  1348                 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), CreateThumbnailsL() "), err));
  1254                 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), CreateThumbnailsL() "), err));
  1349                 }
  1255                 }
  1350             }
  1256             }
  1351         //force is coming, but executing non-forced query complete-> cancel old
  1257         //force is coming, but executing non-forced query complete-> cancel old
  1352         else
  1258         else
  1353             {
  1259             {
  1354 			//cancel query
  1260 			//cancel query
  1355             TN_DEBUG1( "CThumbAGProcessor::RunL() - cancel processing query" );
  1261             TN_DEBUG1( "CThumbAGProcessor::RunL() - cancel processing query" );
  1356             OstTrace0( TRACE_NORMAL, DUP25_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - cancel processing query" );
       
  1357             DeleteAndCancelQuery( ETrue );
  1262             DeleteAndCancelQuery( ETrue );
  1358 	        ActivateAO();
  1263 	        ActivateAO();
  1359             return;  
  1264             return;  
  1360             }
  1265             }
  1361         
  1266         
  1362         //is last query item
  1267         //is last query item
  1363         if( iProcessingCount <= 0 )
  1268         if( iProcessingCount <= 0 )
  1364             {
  1269             {
  1365             TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady FINISH" );
  1270             TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady FINISH" );
  1366             OstTrace0( TRACE_NORMAL, DUP26_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - iQueryReady FINISH" );
       
  1367             iQueryReady = EFalse;
  1271             iQueryReady = EFalse;
  1368             iQueryActive = EFalse;
  1272             iQueryActive = EFalse;
  1369             }
  1273             }
  1370             
  1274             
  1371         ActivateAO();
  1275         ActivateAO();
  1381             ActivateAO();
  1285             ActivateAO();
  1382             }
  1286             }
  1383         else  
  1287         else  
  1384             {
  1288             {
  1385             TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for query to complete, abort..." );
  1289             TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for query to complete, abort..." );
  1386             OstTrace0( TRACE_NORMAL, DUP27_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - waiting for query to complete, abort..." );
       
  1387             }    
  1290             }    
  1388         }
  1291         }
  1389     else if ( iUnknownItemCount > 0 )
  1292     else if ( iUnknownItemCount > 0 )
  1390         {
  1293         {
  1391         TN_DEBUG1( "void CThumbAGProcessor::RunL() unknown items in queue");
  1294         TN_DEBUG1( "void CThumbAGProcessor::RunL() unknown items in queue");
  1392         OstTrace0( TRACE_NORMAL, DUP28_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - unknown items in queue" );
       
  1393         
  1295         
  1394         i2ndRound = EFalse;
  1296         i2ndRound = EFalse;
  1395         iModify = EFalse;
  1297         iModify = EFalse;
  1396         iUnknown = ETrue;
  1298         iUnknown = ETrue;
  1397         iQueryActive = ETrue;
  1299         iQueryActive = ETrue;
  1399         QueryL( EGenerationItemActionResolveType );
  1301         QueryL( EGenerationItemActionResolveType );
  1400        }
  1302        }
  1401     else if ( iDeleteItemCount > 0 )
  1303     else if ( iDeleteItemCount > 0 )
  1402        {
  1304        {
  1403        TN_DEBUG1( "void CThumbAGProcessor::RunL() delete thumbnails");
  1305        TN_DEBUG1( "void CThumbAGProcessor::RunL() delete thumbnails");
  1404        OstTrace0( TRACE_NORMAL, DUP29_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - delete thumbnails" );
       
  1405        // delete thumbs by URI
  1306        // delete thumbs by URI
  1406        __ASSERT_DEBUG((iTMSession), User::Panic(_L("CThumbAGProcessor::RunL() !iTMSession "), KErrBadHandle));
  1307        __ASSERT_DEBUG((iTMSession), User::Panic(_L("CThumbAGProcessor::RunL() !iTMSession "), KErrBadHandle));
  1407        if(iTMSession)
  1308        if(iTMSession)
  1408            {
  1309            {
  1409            TInt itemIndex(KErrNotFound);
  1310            TInt itemIndex(KErrNotFound);
  1420                {
  1321                {
  1421                if(!iGenerationQueue[itemIndex].iUri)
  1322                if(!iGenerationQueue[itemIndex].iUri)
  1422                    {
  1323                    {
  1423                    //URI is invalid
  1324                    //URI is invalid
  1424                    TN_DEBUG1( "void CThumbAGProcessor::RunL() unable to delete URI inbalid");
  1325                    TN_DEBUG1( "void CThumbAGProcessor::RunL() unable to delete URI inbalid");
  1425                    OstTrace0( TRACE_NORMAL, DUP30_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - unable to delete URI inbalid" );
       
  1426                    iGenerationQueue.Remove( itemIndex );
  1326                    iGenerationQueue.Remove( itemIndex );
  1427                    ActivateAO();
  1327                    ActivateAO();
  1428                    return;
  1328                    return;
  1429                    }
  1329                    }
  1430 
  1330 
  1431                TN_DEBUG2( "void CThumbAGProcessor::RunL() delete %S",  iGenerationQueue[itemIndex].iUri);
  1331                TN_DEBUG2( "void CThumbAGProcessor::RunL() delete %S",  iGenerationQueue[itemIndex].iUri);
  1432                OstTraceExt1( TRACE_NORMAL, DUP31_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL;iGenerationQueue[itemIndex].iUri=%S", *iGenerationQueue[itemIndex].iUri );
       
  1433                CThumbnailObjectSource* source = NULL;                
  1332                CThumbnailObjectSource* source = NULL;                
  1434                TRAPD(err,  source = CThumbnailObjectSource::NewL( *iGenerationQueue[itemIndex].iUri, KNullDesC));
  1333                TRAPD(err,  source = CThumbnailObjectSource::NewL( *iGenerationQueue[itemIndex].iUri, KNullDesC));
  1435                   
  1334                   
  1436                if(err == KErrNone)
  1335                if(err == KErrNone)
  1437                    {
  1336                    {
  1450     // no items in query queue, start new
  1349     // no items in query queue, start new
  1451     // select queue to process, priority by type
  1350     // select queue to process, priority by type
  1452     else if ( iModifyItemCount > 0 )
  1351     else if ( iModifyItemCount > 0 )
  1453         {
  1352         {
  1454         TN_DEBUG1( "void CThumbAGProcessor::RunL() update thumbnails");
  1353         TN_DEBUG1( "void CThumbAGProcessor::RunL() update thumbnails");
  1455         OstTrace0( TRACE_NORMAL, DUP32_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - update thumbnails" );
       
  1456         
  1354         
  1457         i2ndRound = EFalse;
  1355         i2ndRound = EFalse;
  1458         
  1356         
  1459         // query for object info
  1357         // query for object info
  1460         iQueryActive = ETrue;
  1358         iQueryActive = ETrue;
  1463         QueryL( EGenerationItemActionModify );
  1361         QueryL( EGenerationItemActionModify );
  1464        }
  1362        }
  1465     else if ( iAddItemCount > 0 )
  1363     else if ( iAddItemCount > 0 )
  1466         {
  1364         {
  1467         TN_DEBUG1( "void CThumbAGProcessor::RunL() update 1st round thumbnails");
  1365         TN_DEBUG1( "void CThumbAGProcessor::RunL() update 1st round thumbnails");
  1468         OstTrace0( TRACE_NORMAL, DUP33_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - update 1st round thumbnails" );
       
  1469         
  1366         
  1470         i2ndRound = EFalse;
  1367         i2ndRound = EFalse;
  1471         iUnknown = EFalse;
  1368         iUnknown = EFalse;
  1472         // query for object info
  1369         // query for object info
  1473         iQueryActive = ETrue;
  1370         iQueryActive = ETrue;
  1475         QueryL( EGenerationItemActionAdd );     
  1372         QueryL( EGenerationItemActionAdd );     
  1476         }
  1373         }
  1477     else if( i2ndAddItemCount > 0)
  1374     else if( i2ndAddItemCount > 0)
  1478         {
  1375         {
  1479         TN_DEBUG1( "void CThumbAGProcessor::RunL() update 2nd round thumbnails");
  1376         TN_DEBUG1( "void CThumbAGProcessor::RunL() update 2nd round thumbnails");
  1480             OstTrace0( TRACE_NORMAL, DUP34_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - update 2nd round thumbnails" );
       
  1481             
  1377             
  1482         // query for object info
  1378         // query for object info
  1483         iQueryActive = ETrue;
  1379         iQueryActive = ETrue;
  1484         i2ndRound = ETrue;
  1380         i2ndRound = ETrue;
  1485         iUnknown = EFalse;
  1381         iUnknown = EFalse;
  1486         QueryL( EGenerationItemAction2ndAdd );     
  1382         QueryL( EGenerationItemAction2ndAdd );     
  1487         }
  1383         }
  1488         
  1384         
  1489     TN_DEBUG1( "CThumbAGProcessor::RunL() - end" );
  1385     TN_DEBUG1( "CThumbAGProcessor::RunL() - end" );
  1490     OstTrace0( TRACE_NORMAL, DUP35_CTHUMBAGPROCESSOR_RUNL, "CThumbAGProcessor::RunL - end" );
       
  1491     }
  1386     }
  1492 
  1387 
  1493 // ---------------------------------------------------------------------------
  1388 // ---------------------------------------------------------------------------
  1494 // CThumbAGProcessor::DeleteAndCancelQuery()
  1389 // CThumbAGProcessor::DeleteAndCancelQuery()
  1495 // ---------------------------------------------------------------------------
  1390 // ---------------------------------------------------------------------------
  1496 //
  1391 //
  1497 void CThumbAGProcessor::DeleteAndCancelQuery(TBool aRestoreItems)
  1392 void CThumbAGProcessor::DeleteAndCancelQuery(TBool aRestoreItems)
  1498     {
  1393     {
  1499     TN_DEBUG2( "CThumbAGProcessor::DeleteAndCancelQuery(aRestoreItems = %d) in", aRestoreItems );
  1394     TN_DEBUG2( "CThumbAGProcessor::DeleteAndCancelQuery(aRestoreItems = %d) in", aRestoreItems );
  1500     OstTrace1( TRACE_NORMAL, CTHUMBAGPROCESSOR_DELETEANDCANCELQUERY, "CThumbAGProcessor::DeleteAndCancelQuery;aRestoreItems=%d", aRestoreItems );
       
  1501     
  1395     
  1502     if(iQuery)
  1396     if(iQuery)
  1503         {
  1397         {
  1504         TN_DEBUG1( "CThumbAGProcessor::DeleteAndCancelQuery() - deleting query" );
  1398         TN_DEBUG1( "CThumbAGProcessor::DeleteAndCancelQuery() - deleting query" );
  1505         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_DELETEANDCANCELQUERY, "CThumbAGProcessor::DeleteAndCancelQuery - deleting query" );
       
  1506         iQuery->Cancel();
  1399         iQuery->Cancel();
  1507         delete iQuery;
  1400         delete iQuery;
  1508         iQuery = NULL;
  1401         iQuery = NULL;
  1509         }
  1402         }
  1510     
  1403     
  1530             }
  1423             }
  1531         iQueryQueue.Remove(0);
  1424         iQueryQueue.Remove(0);
  1532         }
  1425         }
  1533 
  1426 
  1534     TN_DEBUG1( "CThumbAGProcessor::DeleteAndCancelQuery() out" );
  1427     TN_DEBUG1( "CThumbAGProcessor::DeleteAndCancelQuery() out" );
  1535     OstTrace0( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_DELETEANDCANCELQUERY, "CThumbAGProcessor::DeleteAndCancelQuery - out" );
       
  1536     }
  1428     }
  1537 
  1429 
  1538 // ---------------------------------------------------------------------------
  1430 // ---------------------------------------------------------------------------
  1539 // CThumbAGProcessor::DoCancel()
  1431 // CThumbAGProcessor::DoCancel()
  1540 // ---------------------------------------------------------------------------
  1432 // ---------------------------------------------------------------------------
  1548          HarvesterEventObserverType aHEObserverType, 
  1440          HarvesterEventObserverType aHEObserverType, 
  1549          HarvesterEventState aHarvesterEventState,
  1441          HarvesterEventState aHarvesterEventState,
  1550          TInt aItemsLeft )
  1442          TInt aItemsLeft )
  1551     {
  1443     {
  1552     TN_DEBUG4( "CThumbAGProcessor::HarvestingUpdated -- start() aHEObserverType = %d, aHarvesterEventState = %d, aItemsLeft = %d", aHEObserverType, aHarvesterEventState, aItemsLeft );
  1444     TN_DEBUG4( "CThumbAGProcessor::HarvestingUpdated -- start() aHEObserverType = %d, aHarvesterEventState = %d, aItemsLeft = %d", aHEObserverType, aHarvesterEventState, aItemsLeft );
  1553     OstTraceExt3( TRACE_NORMAL, CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated;aHEObserverType=%u;aHarvesterEventState=%u;aItemsLeft=%d", aHEObserverType, aHarvesterEventState, aItemsLeft );
       
  1554     
  1445     
  1555 	if(iShutdown)
  1446 	if(iShutdown)
  1556         {
  1447         {
  1557         return;
  1448         return;
  1558         }
  1449         }
  1564     
  1455     
  1565     #ifdef _DEBUG
  1456     #ifdef _DEBUG
  1566     if( aHEObserverType == EHEObserverTypePlaceholder)
  1457     if( aHEObserverType == EHEObserverTypePlaceholder)
  1567         {
  1458         {
  1568         TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypePlaceholder");
  1459         TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypePlaceholder");
  1569         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypePlaceholder" );
       
  1570         }
  1460         }
  1571     else if( aHEObserverType == EHEObserverTypeOverall)
  1461     else if( aHEObserverType == EHEObserverTypeOverall)
  1572         {
  1462         {
  1573         TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypeOverall");
  1463         TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypeOverall");
  1574         OstTrace0( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypeOverall" );
       
  1575         }
  1464         }
  1576     else if( aHEObserverType == EHEObserverTypeMMC)
  1465     else if( aHEObserverType == EHEObserverTypeMMC)
  1577         {
  1466         {
  1578         TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypeMMC");
  1467         TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypeMMC");
  1579         OstTrace0( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypeMMC" );
       
  1580         }
  1468         }
  1581     #endif
  1469     #endif
  1582     
  1470     
  1583     //placeholder harvesting
  1471     //placeholder harvesting
  1584     if( aHEObserverType == EHEObserverTypePlaceholder)
  1472     if( aHEObserverType == EHEObserverTypePlaceholder)
  1606             iPHHarvesting = iPHHarvestingTemp;
  1494             iPHHarvesting = iPHHarvestingTemp;
  1607            
  1495            
  1608             if( iPHHarvesting )
  1496             if( iPHHarvesting )
  1609                 {
  1497                 {
  1610                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS placeholder harvesterin started");
  1498                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS placeholder harvesterin started");
  1611                 OstTrace0( TRACE_NORMAL, DUP4_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated -- MDS placeholder harvesterin starteds" );
       
  1612                 }
  1499                 }
  1613             else
  1500             else
  1614                 {
  1501                 {
  1615                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS placeholder harvesting finished");
  1502                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS placeholder harvesting finished");
  1616                 OstTrace0( TRACE_NORMAL, DUP5_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated -- MDS placeholder harvesting finished" );
       
  1617                 //query present placeholders
  1503                 //query present placeholders
  1618                 TRAP_IGNORE(QueryPlaceholdersL( EFalse ));
  1504                 TRAP_IGNORE(QueryPlaceholdersL( EFalse ));
  1619                 iDoQueryAllItems = EFalse;
  1505                 iDoQueryAllItems = EFalse;
  1620                 iPHHarvestingItemsLeftTemp = 0;
  1506                 iPHHarvestingItemsLeftTemp = 0;
  1621                 }
  1507                 }
  1624         //restart mount timout if PH item count is increasing durin MMC harvesting 
  1510         //restart mount timout if PH item count is increasing durin MMC harvesting 
  1625         if(iMMCHarvesting && iPHHarvesting && aItemsLeft > iPHHarvestingItemsLeftTemp)
  1511         if(iMMCHarvesting && iPHHarvesting && aItemsLeft > iPHHarvestingItemsLeftTemp)
  1626           {
  1512           {
  1627           //if items count increasing, restart mount timeout 
  1513           //if items count increasing, restart mount timeout 
  1628             TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- PH count increasing, restart mount timeout");
  1514             TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- PH count increasing, restart mount timeout");
  1629             OstTrace0( TRACE_NORMAL, DUP6_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated -- PH count increasing, restart mount timeout" );
       
  1630             
  1515             
  1631            if(iMountTimer->IsActive())
  1516            if(iMountTimer->IsActive())
  1632               {
  1517               {
  1633               iMountTimer->Cancel();
  1518               iMountTimer->Cancel();
  1634               }
  1519               }
  1668             iHarvesting = iHarvestingTemp;
  1553             iHarvesting = iHarvestingTemp;
  1669             
  1554             
  1670             if( iHarvesting )
  1555             if( iHarvesting )
  1671                 {
  1556                 {
  1672                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesting started");
  1557                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesting started");
  1673                 OstTrace0( TRACE_NORMAL, DUP7_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated -- MDS harvesting started" );
       
  1674                 CancelTimeout();
  1558                 CancelTimeout();
  1675                 }
  1559                 }
  1676             else
  1560             else
  1677                 {
  1561                 {
  1678                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesting finished ");
  1562                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesting finished ");
  1679                 OstTrace0( TRACE_NORMAL, DUP8_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated -- MDS harvesting finished" );
       
  1680                 // continue processing if needed
  1563                 // continue processing if needed
  1681                 StartTimeout();
  1564                 StartTimeout();
  1682                 
  1565                 
  1683                 if(iMountTimer->IsActive())
  1566                 if(iMountTimer->IsActive())
  1684                     {
  1567                     {
  1713             iMMCHarvesting = iMMCHarvestingTemp;
  1596             iMMCHarvesting = iMMCHarvestingTemp;
  1714             
  1597             
  1715             if( iMMCHarvesting )
  1598             if( iMMCHarvesting )
  1716                 {
  1599                 {
  1717                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS MMC harvesterin started");
  1600                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS MMC harvesterin started");
  1718                 OstTrace0( TRACE_NORMAL, DUP9_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated -- MDS MMC harvesterin started" );
       
  1719                 UpdatePSValues(EFalse, ETrue);
  1601                 UpdatePSValues(EFalse, ETrue);
  1720                 iMMCHarvestingItemsLeftTemp = 0;
  1602                 iMMCHarvestingItemsLeftTemp = 0;
  1721                 }
  1603                 }
  1722             else
  1604             else
  1723                 {
  1605                 {
  1725                 if(!iHarvesting)
  1607                 if(!iHarvesting)
  1726                     {
  1608                     {
  1727                     StartTimeout();
  1609                     StartTimeout();
  1728                     }
  1610                     }
  1729                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS MMC harvesting finished ");
  1611                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS MMC harvesting finished ");
  1730                 OstTrace0( TRACE_NORMAL, DUP10_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated -- MDS MMC harvesting finished" );
       
  1731                 }
  1612                 }
  1732             }
  1613             }
  1733         
  1614         
  1734         //restart mount timout if MMC item count is still increasing 
  1615         //restart mount timout if MMC item count is still increasing 
  1735         if(iMMCHarvesting && aItemsLeft > iMMCHarvestingItemsLeftTemp)
  1616         if(iMMCHarvesting && aItemsLeft > iMMCHarvestingItemsLeftTemp)
  1736             {
  1617             {
  1737               TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MMC count increasing, restart mount timeout");
  1618               TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MMC count increasing, restart mount timeout");
  1738               OstTrace0( TRACE_NORMAL, DUP11_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated -- MMC count increasing, restart mount timeout" );
       
  1739               
  1619               
  1740              if(iMountTimer->IsActive())
  1620              if(iMountTimer->IsActive())
  1741                 {
  1621                 {
  1742                 iMountTimer->Cancel();
  1622                 iMountTimer->Cancel();
  1743                 }
  1623                 }
  1747         
  1627         
  1748             iMMCHarvestingItemsLeftTemp = aItemsLeft;
  1628             iMMCHarvestingItemsLeftTemp = aItemsLeft;
  1749         }
  1629         }
  1750    
  1630    
  1751     TN_DEBUG4( "CThumbAGProcessor::HarvestingUpdated -- end() iHarvesting == %d, iPHHarvesting == %d iMMCHarvesting == %d ", iHarvesting, iPHHarvesting, iMMCHarvesting);
  1631     TN_DEBUG4( "CThumbAGProcessor::HarvestingUpdated -- end() iHarvesting == %d, iPHHarvesting == %d iMMCHarvesting == %d ", iHarvesting, iPHHarvesting, iMMCHarvesting);
  1752     OstTraceExt3( TRACE_NORMAL, DUP12_CTHUMBAGPROCESSOR_HARVESTINGUPDATED, "CThumbAGProcessor::HarvestingUpdated;iHarvesting=%u;iPHHarvesting=%u;iMMCHarvesting=%u", iHarvesting, iPHHarvesting, iMMCHarvesting );
       
  1753     }
  1632     }
  1754 
  1633 
  1755 // ---------------------------------------------------------------------------
  1634 // ---------------------------------------------------------------------------
  1756 // CThumbAGProcessor::StartTimeout()
  1635 // CThumbAGProcessor::StartTimeout()
  1757 // ---------------------------------------------------------------------------
  1636 // ---------------------------------------------------------------------------
  1758 //
  1637 //
  1759 void CThumbAGProcessor::StartTimeout()
  1638 void CThumbAGProcessor::StartTimeout()
  1760     {
  1639     {
  1761     TN_DEBUG1( "CThumbAGProcessor::StartTimeout()");
  1640     TN_DEBUG1( "CThumbAGProcessor::StartTimeout()");
  1762     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_STARTTIMEOUT, "CThumbAGProcessor::StartTimeout" );
       
  1763     CancelTimeout();
  1641     CancelTimeout();
  1764     
  1642     
  1765     if(!iHarvesting && !iMPXHarvesting && !iPeriodicTimer->IsActive() && !iShutdown)
  1643     if(!iHarvesting && !iMPXHarvesting && !iPeriodicTimer->IsActive() && !iShutdown)
  1766         {
  1644         {
  1767         iPeriodicTimer->Start( KHarvestingCompleteTimeout, KHarvestingCompleteTimeout,
  1645         iPeriodicTimer->Start( KHarvestingCompleteTimeout, KHarvestingCompleteTimeout,
  1774 // ---------------------------------------------------------------------------
  1652 // ---------------------------------------------------------------------------
  1775 //
  1653 //
  1776 void CThumbAGProcessor::CancelTimeout()
  1654 void CThumbAGProcessor::CancelTimeout()
  1777     {
  1655     {
  1778     TN_DEBUG1( "CThumbAGProcessor::CancelTimeout()");
  1656     TN_DEBUG1( "CThumbAGProcessor::CancelTimeout()");
  1779     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_CANCELTIMEOUT, "CThumbAGProcessor::CancelTimeout" );
       
  1780     if(iPeriodicTimer->IsActive())
  1657     if(iPeriodicTimer->IsActive())
  1781         {
  1658         {
  1782         iPeriodicTimer->Cancel();
  1659         iPeriodicTimer->Cancel();
  1783         }
  1660         }
  1784     }
  1661     }
  1792 #else
  1669 #else
  1793 TInt CThumbAGProcessor::RunError(TInt /*aError*/)
  1670 TInt CThumbAGProcessor::RunError(TInt /*aError*/)
  1794 #endif
  1671 #endif
  1795     {
  1672     {
  1796     TN_DEBUG2( "CThumbAGrocessor::RunError() %d", aError);
  1673     TN_DEBUG2( "CThumbAGrocessor::RunError() %d", aError);
  1797 #ifdef _DEBUG
  1674     
  1798     OstTrace1( TRACE_NORMAL, CTHUMBAGPROCESSOR_RUNERROR, "CThumbAGProcessor::RunError;aError=%d", aError );
       
  1799 #else
       
  1800     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_RUNERROR, "CThumbAGProcessor::RunError");
       
  1801 #endif    
       
  1802     UpdatePSValues(EFalse, EFalse);
  1675     UpdatePSValues(EFalse, EFalse);
  1803         
  1676         
  1804     iActiveCount--;
  1677     iActiveCount--;
  1805     
  1678     
  1806 	ActivateAO();
  1679 	ActivateAO();
  1818     UpdateItemCounts();
  1691     UpdateItemCounts();
  1819     
  1692     
  1820     if(iFormatting)
  1693     if(iFormatting)
  1821         {
  1694         {
  1822         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE");
  1695         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE");
  1823         OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_ACTIVATEAO, "CThumbAGProcessor::ActivateAO - FORMATTING - DAEMON ON PAUSE" );
       
  1824         return;
  1696         return;
  1825         }
  1697         }
  1826     
  1698     
  1827     //check if forced run needs to continue
  1699     //check if forced run needs to continue
  1828     if ( (iModifyItemCount > 0 || iDeleteItemCount > 0 ||  iUnknownItemCount > 0) && !iMountTimer->IsActive())
  1700     if ( (iModifyItemCount > 0 || iDeleteItemCount > 0 ||  iUnknownItemCount > 0) && !iMountTimer->IsActive())
  1829         {
  1701         {
  1830         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() -  forced run");
  1702         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() -  forced run");
  1831         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_ACTIVATEAO, "CThumbAGProcessor::ActivateAO - iModifyItemCount > 0 || iUnknownItemCount > 0 || iDeleteItemCount > 0" );
       
  1832         SetForceRun( ETrue );
  1703         SetForceRun( ETrue );
  1833         }
  1704         }
  1834     else
  1705     else
  1835         {
  1706         {
  1836         iModify = EFalse;
  1707         iModify = EFalse;
  1838         }
  1709         }
  1839     
  1710     
  1840     if( !IsActive() && !iShutdown && ((iActiveCount < KMaxDaemonRequests && !iQueryActive) || iForceRun ))
  1711     if( !IsActive() && !iShutdown && ((iActiveCount < KMaxDaemonRequests && !iQueryActive) || iForceRun ))
  1841         {
  1712         {
  1842         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - Activated");
  1713         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - Activated");
  1843         OstTrace0( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_ACTIVATEAO, "CThumbAGProcessor::ActivateAO - Activated" );
       
  1844         SetActive();
  1714         SetActive();
  1845         TRequestStatus* statusPtr = &iStatus;
  1715         TRequestStatus* statusPtr = &iStatus;
  1846         User::RequestComplete( statusPtr, KErrNone );
  1716         User::RequestComplete( statusPtr, KErrNone );
  1847         }
  1717         }
  1848 
  1718 
  1854 // ---------------------------------------------------------------------------
  1724 // ---------------------------------------------------------------------------
  1855 //
  1725 //
  1856 TInt CThumbAGProcessor::PeriodicTimerCallBack(TAny* aAny)
  1726 TInt CThumbAGProcessor::PeriodicTimerCallBack(TAny* aAny)
  1857     {
  1727     {
  1858     TN_DEBUG1( "CThumbAGProcessor::PeriodicTimerCallBack()");
  1728     TN_DEBUG1( "CThumbAGProcessor::PeriodicTimerCallBack()");
  1859     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_PERIODICTIMERCALLBACK, "CThumbAGProcessor::PeriodicTimerCallBack" );
       
  1860     CThumbAGProcessor* self = static_cast<CThumbAGProcessor*>( aAny );
  1729     CThumbAGProcessor* self = static_cast<CThumbAGProcessor*>( aAny );
  1861     
  1730     
  1862     self->CancelTimeout();
  1731     self->CancelTimeout();
  1863     self->ActivateAO();
  1732     self->ActivateAO();
  1864 
  1733 
  1884     TBool audioFull( EFalse );
  1753     TBool audioFull( EFalse );
  1885 
  1754 
  1886     // get cenrep values
  1755     // get cenrep values
  1887     TInt ret = rep->Get( KAutoCreateImageGrid, imageGrid );
  1756     TInt ret = rep->Get( KAutoCreateImageGrid, imageGrid );
  1888     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateImageGrid %d", ret);
  1757     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateImageGrid %d", ret);
  1889     OstTrace1( TRACE_NORMAL, CTHUMBAGPROCESSOR_CHECKAUTOCREATEVALUESL, "CThumbAGProcessor::CheckAutoCreateValuesL - KAutoCreateImageGrid;ret=%d", ret );
       
  1890     ret = rep->Get( KAutoCreateImageList, imageList );
  1758     ret = rep->Get( KAutoCreateImageList, imageList );
  1891     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateImageList %d", ret);
  1759     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateImageList %d", ret);
  1892     OstTrace1( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_CHECKAUTOCREATEVALUESL, "CThumbAGProcessor::CheckAutoCreateValuesL - KAutoCreateImageList;ret=%d", ret );
       
  1893     ret = rep->Get( KAutoCreateImageFullscreen, imageFull );
  1760     ret = rep->Get( KAutoCreateImageFullscreen, imageFull );
  1894     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateImageFullscreen %d", ret);
  1761     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateImageFullscreen %d", ret);
  1895     OstTrace1( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_CHECKAUTOCREATEVALUESL, "CThumbAGProcessor::CheckAutoCreateValuesL;ret=%d", ret );
       
  1896     ret = rep->Get( KAutoCreateVideoGrid, videoGrid );
  1762     ret = rep->Get( KAutoCreateVideoGrid, videoGrid );
  1897     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateVideoGrid %d", ret);
  1763     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateVideoGrid %d", ret);
  1898     OstTrace1( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_CHECKAUTOCREATEVALUESL, "CThumbAGProcessor::CheckAutoCreateValuesL - KAutoCreateVideoGrid;ret=%d", ret );
       
  1899     ret = rep->Get( KAutoCreateVideoList, videoList );
  1764     ret = rep->Get( KAutoCreateVideoList, videoList );
  1900     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateVideoList %d", ret);
  1765     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateVideoList %d", ret);
  1901     OstTrace1( TRACE_NORMAL, DUP4_CTHUMBAGPROCESSOR_CHECKAUTOCREATEVALUESL, "CThumbAGProcessor::CheckAutoCreateValuesL - KAutoCreateVideoList;ret=%d", ret );
       
  1902     ret = rep->Get( KAutoCreateVideoFullscreen, videoFull );
  1766     ret = rep->Get( KAutoCreateVideoFullscreen, videoFull );
  1903     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateVideoFullscreen %d", ret);
  1767     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateVideoFullscreen %d", ret);
  1904     OstTrace1( TRACE_NORMAL, DUP5_CTHUMBAGPROCESSOR_CHECKAUTOCREATEVALUESL, "CThumbAGProcessor::CheckAutoCreateValuesL - KAutoCreateVideoFullscreen;ret=%d", ret );
       
  1905     ret = rep->Get( KAutoCreateAudioGrid, audioGrid );
  1768     ret = rep->Get( KAutoCreateAudioGrid, audioGrid );
  1906     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateAudioGrid %d", ret);
  1769     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateAudioGrid %d", ret);
  1907     OstTrace1( TRACE_NORMAL, DUP6_CTHUMBAGPROCESSOR_CHECKAUTOCREATEVALUESL, "CThumbAGProcessor::CheckAutoCreateValuesL - KAutoCreateAudioGrid;ret=%d", ret );
       
  1908     ret = rep->Get( KAutoCreateAudioList, audioList );
  1770     ret = rep->Get( KAutoCreateAudioList, audioList );
  1909     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateAudioList %d", ret);
  1771     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateAudioList %d", ret);
  1910     OstTrace1( TRACE_NORMAL, DUP7_CTHUMBAGPROCESSOR_CHECKAUTOCREATEVALUESL, "CThumbAGProcessor::CheckAutoCreateValuesL - KAutoCreateAudioList;ret=%d", ret );
       
  1911     ret = rep->Get( KAutoCreateAudioFullscreen, audioFull );
  1772     ret = rep->Get( KAutoCreateAudioFullscreen, audioFull );
  1912     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateAudioFullscreen %d", ret);
  1773     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateAudioFullscreen %d", ret);
  1913     OstTrace1( TRACE_NORMAL, DUP8_CTHUMBAGPROCESSOR_CHECKAUTOCREATEVALUESL, "CThumbAGProcessor::CheckAutoCreateValuesL - KAutoCreateAudioFullscreen;ret=%d", ret );
       
  1914     
  1774     
  1915     iAutoImage = EFalse;
  1775     iAutoImage = EFalse;
  1916     iAutoVideo = EFalse;
  1776     iAutoVideo = EFalse;
  1917     iAutoAudio = EFalse;
  1777     iAutoAudio = EFalse;
  1918     
  1778     
  1942 #else
  1802 #else
  1943 void CThumbAGProcessor::RemoveFromQueues( const RArray<TItemId>& aIDArray, const TBool /*aRemoveFromDelete*/ )
  1803 void CThumbAGProcessor::RemoveFromQueues( const RArray<TItemId>& aIDArray, const TBool /*aRemoveFromDelete*/ )
  1944 #endif
  1804 #endif
  1945     {
  1805     {
  1946     TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() aRemoveFromDelete == %d - begin", aRemoveFromDelete );
  1806     TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() aRemoveFromDelete == %d - begin", aRemoveFromDelete );
  1947 #ifdef _DEBUG
       
  1948     OstTrace1( TRACE_NORMAL, CTHUMBAGPROCESSOR_REMOVEFROMQUEUES, "CThumbAGProcessor::RemoveFromQueues - aRemoveFromDelete;aRemoveFromDelete=%d", aRemoveFromDelete );
       
  1949 #else
       
  1950     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_REMOVEFROMQUEUES, "CThumbAGProcessor::RemoveFromQueues - aRemoveFromDelete" );
       
  1951 #endif
       
  1952     
  1807     
  1953     TInt itemIndex(KErrNotFound);
  1808     TInt itemIndex(KErrNotFound);
  1954     
  1809     
  1955     for (int i=0; i< aIDArray.Count(); i++)
  1810     for (int i=0; i< aIDArray.Count(); i++)
  1956         {
  1811         {
  1957         TThumbnailGenerationItem item;
  1812         TThumbnailGenerationItem item;
  1958         item.iItemId = aIDArray[i];
  1813         item.iItemId = aIDArray[i];
  1959         TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]);
  1814         TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]);
  1960         OstTrace1( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_REMOVEFROMQUEUES, "CThumbAGProcessor::RemoveFromQueues;aIDArray[i]=%u", aIDArray[i] );
       
  1961 
  1815 
  1962         itemIndex = iGenerationQueue.FindInOrder(item, Compare);                        
  1816         itemIndex = iGenerationQueue.FindInOrder(item, Compare);                        
  1963         if(itemIndex >= 0)
  1817         if(itemIndex >= 0)
  1964             {
  1818             {
  1965             delete iGenerationQueue[itemIndex].iUri;
  1819             delete iGenerationQueue[itemIndex].iUri;
  1966             iGenerationQueue[itemIndex].iUri = NULL;
  1820             iGenerationQueue[itemIndex].iUri = NULL;
  1967             iGenerationQueue.Remove(itemIndex);
  1821             iGenerationQueue.Remove(itemIndex);
  1968             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iGenerationQueue" );
  1822             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iGenerationQueue" );
  1969             OstTrace0( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_REMOVEFROMQUEUES, "CThumbAGProcessor::RemoveFromQueues - iGenerationQueue" );
       
  1970             }
  1823             }
  1971                 
  1824                 
  1972         itemIndex = iQueryQueue.FindInOrder(aIDArray[i], CompareId);                    
  1825         itemIndex = iQueryQueue.FindInOrder(aIDArray[i], CompareId);                    
  1973         if(itemIndex >= 0)
  1826         if(itemIndex >= 0)
  1974             {
  1827             {
  1975             iQueryQueue.Remove(itemIndex);
  1828             iQueryQueue.Remove(itemIndex);
  1976             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iQueryQueue" );
  1829             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iQueryQueue" );
  1977             OstTrace0( TRACE_NORMAL, DUP4_CTHUMBAGPROCESSOR_REMOVEFROMQUEUES, "CThumbAGProcessor::RemoveFromQueues - iQueryQueue" );
       
  1978             }
  1830             }
  1979         }
  1831         }
  1980     
  1832     
  1981     ActivateAO();
  1833     ActivateAO();
  1982     
  1834     
  1983     TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - end" );
  1835     TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - end" );
  1984     OstTrace0( TRACE_NORMAL, DUP5_CTHUMBAGPROCESSOR_REMOVEFROMQUEUES, "CThumbAGProcessor::RemoveFromQueues - end" );
       
  1985     }
  1836     }
  1986 	
  1837 	
  1987 // ---------------------------------------------------------------------------
  1838 // ---------------------------------------------------------------------------
  1988 // CThumbAGProcessor::SetForceRun()
  1839 // CThumbAGProcessor::SetForceRun()
  1989 // ---------------------------------------------------------------------------
  1840 // ---------------------------------------------------------------------------
  1990 //
  1841 //
  1991 void CThumbAGProcessor::SetForceRun( const TBool aForceRun)
  1842 void CThumbAGProcessor::SetForceRun( const TBool aForceRun)
  1992     {
  1843     {
  1993     TN_DEBUG2( "CThumbAGProcessor::SetForceRun(%d) - end", aForceRun ); 
  1844     TN_DEBUG2( "CThumbAGProcessor::SetForceRun(%d) - end", aForceRun ); 
  1994     OstTrace1( TRACE_NORMAL, CTHUMBAGPROCESSOR_SETFORCERUN, "CThumbAGProcessor::SetForceRun - end;aForceRun=%u", aForceRun );
       
  1995 
  1845 
  1996     // enable forced run
  1846     // enable forced run
  1997     iForceRun = aForceRun;
  1847     iForceRun = aForceRun;
  1998     }
  1848     }
  1999 
  1849 
  2002 // ---------------------------------------------------------------------------
  1852 // ---------------------------------------------------------------------------
  2003 //
  1853 //
  2004 void CThumbAGProcessor::QueryAllItemsL()
  1854 void CThumbAGProcessor::QueryAllItemsL()
  2005     {
  1855     {
  2006     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL" );
  1856     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL" );
  2007     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_QUERYALLITEMSL, "CThumbAGProcessor::QueryAllItemsL" );
       
  2008     
  1857     
  2009     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryAllItemsL() !iMdeSession "), KErrBadHandle));
  1858     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryAllItemsL() !iMdeSession "), KErrBadHandle));
  2010     
  1859     
  2011     if(!iMdESession)
  1860     if(!iMdESession)
  2012          {
  1861          {
  2016     if( iQueryAllItems )
  1865     if( iQueryAllItems )
  2017         {
  1866         {
  2018         if( !iQueryAllItems->IsComplete() )
  1867         if( !iQueryAllItems->IsComplete() )
  2019             {
  1868             {
  2020             TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL active- skip" );
  1869             TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL active- skip" );
  2021             OstTrace0( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_QUERYALLITEMSL, "CThumbAGProcessor::QueryAllItemsL - active- skip" );
       
  2022             return;
  1870             return;
  2023             }
  1871             }
  2024         
  1872         
  2025         // delete old query
  1873         // delete old query
  2026         iQueryAllItems->Cancel();
  1874         iQueryAllItems->Cancel();
  2027         delete iQueryAllItems;
  1875         delete iQueryAllItems;
  2028         iQueryAllItems = NULL;
  1876         iQueryAllItems = NULL;
  2029         }
  1877         }
  2030     
  1878     
  2031     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL - start" );
  1879     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL - start" );
  2032     OstTrace0( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_QUERYALLITEMSL, "CThumbAGProcessor::QueryAllItemsL -start" );
       
  2033     
  1880     
  2034     CMdEObjectDef& imageObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );
  1881     CMdEObjectDef& imageObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );
  2035     CMdEObjectDef& videoObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject );
  1882     CMdEObjectDef& videoObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject );
  2036     CMdEObjectDef& audioObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject );
  1883     CMdEObjectDef& audioObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject );
  2037     
  1884     
  2050 	CleanupStack::PushL( &videoObjectCondition );
  1897 	CleanupStack::PushL( &videoObjectCondition );
  2051     
  1898     
  2052     CMdEObjectCondition& audioObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
  1899     CMdEObjectCondition& audioObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
  2053 	CleanupStack::PushL( &audioObjectCondition );
  1900 	CleanupStack::PushL( &audioObjectCondition );
  2054     
  1901     
  2055     iQueryAllItems->FindL(KMdEQueryDefaultMaxCount, KMaxQueryBatchSize);  
  1902     iQueryAllItems->FindL(KMaxTInt, KMaxQueryBatchSize);  
  2056 	
  1903 	
  2057 	CleanupStack::Pop(3, &imageObjectCondition);
  1904 	CleanupStack::Pop(3, &imageObjectCondition);
  2058     
  1905     
  2059     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL - end" );
  1906     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL - end" );
  2060     OstTrace0( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_QUERYALLITEMSL, "CThumbAGProcessor::QueryAllItemsL" );
       
  2061     }
  1907     }
  2062 
  1908 
  2063 // -----------------------------------------------------------------------------
  1909 // -----------------------------------------------------------------------------
  2064 // CThumbAGProcessor::HandleCollectionMessage
  1910 // CThumbAGProcessor::HandleCollectionMessage
  2065 // From MMPXCollectionObserver
  1911 // From MMPXCollectionObserver
  2074         }
  1920         }
  2075     
  1921     
  2076     TMPXMessageId generalId( *aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ) );
  1922     TMPXMessageId generalId( *aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ) );
  2077     
  1923     
  2078     TN_DEBUG2( "CThumbAGProcessor::HandleCollectionMessage KMPXMessageGeneralId=%d", generalId);
  1924     TN_DEBUG2( "CThumbAGProcessor::HandleCollectionMessage KMPXMessageGeneralId=%d", generalId);
  2079     OstTrace1( TRACE_NORMAL, CTHUMBAGPROCESSOR_HANDLECOLLECTIONMESSAGE, "CThumbAGProcessor::HandleCollectionMessage - KMPXMessageGeneralId;generalId=%u", generalId );
       
  2080 
  1925 
  2081 	//we are interestead of only general system events
  1926 	//we are interestead of only general system events
  2082     if ( generalId == KMPXMessageGeneral )
  1927     if ( generalId == KMPXMessageGeneral )
  2083         {
  1928         {
  2084         TInt event( *aMessage->Value<TInt>( KMPXMessageGeneralEvent ) );
  1929         TInt event( *aMessage->Value<TInt>( KMPXMessageGeneralEvent ) );
  2085         TInt op( *aMessage->Value<TInt>( KMPXMessageGeneralType ) );
  1930         TInt op( *aMessage->Value<TInt>( KMPXMessageGeneralType ) );
  2086         TN_DEBUG3( "CThumbAGProcessor::HandleCollectionMessage KMPXMessageGeneralEvent=%d", event, op);
  1931         TN_DEBUG3( "CThumbAGProcessor::HandleCollectionMessage KMPXMessageGeneralEvent=%d", event, op);
  2087         OstTraceExt2( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_HANDLECOLLECTIONMESSAGE, "CThumbAGProcessor::HandleCollectionMessage - KMPXMessageGeneralEvent;event=%d;op=%d", event, op );
       
  2088         if ( event == TMPXCollectionMessage::EBroadcastEvent )
  1932         if ( event == TMPXCollectionMessage::EBroadcastEvent )
  2089             {
  1933             {
  2090             switch( op )
  1934             switch( op )
  2091                 {
  1935                 {
  2092 			    //when MTP sync or music collection is started then pause processing
  1936 			    //when MTP sync or music collection is started then pause processing
  2093                 case EMcMsgRefreshStart:
  1937                 case EMcMsgRefreshStart:
  2094                 case EMcMsgUSBMTPStart:
  1938                 case EMcMsgUSBMTPStart:
  2095                     TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh started" );
  1939                     TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh started" );
  2096                     OstTrace0( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_HANDLECOLLECTIONMESSAGE, "CThumbAGProcessor::HandleCollectionMessage - MPX refresh started" );
       
  2097                     iMPXHarvesting = ETrue;
  1940                     iMPXHarvesting = ETrue;
  2098                     CancelTimeout();
  1941                     CancelTimeout();
  2099                     break;
  1942                     break;
  2100 			    //when MTP sync or music collection refresh is complete then resume processing
  1943 			    //when MTP sync or music collection refresh is complete then resume processing
  2101                 case EMcMsgRefreshEnd:
  1944                 case EMcMsgRefreshEnd:
  2102                 case EMcMsgUSBMTPEnd:
  1945                 case EMcMsgUSBMTPEnd:
  2103                 case EMcMsgUSBMTPNotActive:
  1946                 case EMcMsgUSBMTPNotActive:
  2104                     TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh finished/not active" );
  1947                     TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh finished/not active" );
  2105                     OstTrace0( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_HANDLECOLLECTIONMESSAGE, "CThumbAGProcessor::HandleCollectionMessage - MPX refresh finished/not active" );
       
  2106                     iMPXHarvesting = EFalse;
  1948                     iMPXHarvesting = EFalse;
  2107                     StartTimeout();
  1949                     StartTimeout();
  2108                     break;
  1950                     break;
  2109                 default:
  1951                 default:
  2110                     break;
  1952                     break;
  2119                 {
  1961                 {
  2120                 RProperty::Set(KTAGDPSNotification, KMPXHarvesting, EFalse);
  1962                 RProperty::Set(KTAGDPSNotification, KMPXHarvesting, EFalse);
  2121                 }
  1963                 }
  2122                 
  1964                 
  2123             TN_DEBUG3( "CThumbAGProcessor::HandleCollectionMessage -- end() iHarvesting == %d, iMPXHarvesting == %d", iHarvesting, iMPXHarvesting);
  1965             TN_DEBUG3( "CThumbAGProcessor::HandleCollectionMessage -- end() iHarvesting == %d, iMPXHarvesting == %d", iHarvesting, iMPXHarvesting);
  2124             OstTraceExt2( TRACE_NORMAL, DUP4_CTHUMBAGPROCESSOR_HANDLECOLLECTIONMESSAGE, "CThumbAGProcessor::HandleCollectionMessage - end;iHarvesting=%u;iMPXHarvesting=%u", iHarvesting, iMPXHarvesting );
       
  2125             }
  1966             }
  2126         }
  1967         }
  2127     }
  1968     }
  2128 
  1969 
  2129 // -----------------------------------------------------------------------------
  1970 // -----------------------------------------------------------------------------
  2165 // -----------------------------------------------------------------------------
  2006 // -----------------------------------------------------------------------------
  2166 //
  2007 //
  2167 void CThumbAGProcessor::ActivityChanged(const TBool aActive)
  2008 void CThumbAGProcessor::ActivityChanged(const TBool aActive)
  2168     {
  2009     {
  2169     TN_DEBUG2( "void CThumbAGProcessor::ActivityChanged() aActive == %d", aActive);
  2010     TN_DEBUG2( "void CThumbAGProcessor::ActivityChanged() aActive == %d", aActive);
  2170     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_ACTIVITYCHANGED, "CThumbAGProcessor::ActivityChanged" );
       
  2171     if(aActive)
  2011     if(aActive)
  2172         {
  2012         {
  2173         iIdle = EFalse;
  2013         iIdle = EFalse;
  2174         }
  2014         }
  2175     else
  2015     else
  2190 // ---------------------------------------------------------------------------
  2030 // ---------------------------------------------------------------------------
  2191 //
  2031 //
  2192 void CThumbAGProcessor::FormatNotification( TBool aFormat )
  2032 void CThumbAGProcessor::FormatNotification( TBool aFormat )
  2193     {
  2033     {
  2194     TN_DEBUG2( "CThumbAGProcessor::FormatNotification(%d)", aFormat );
  2034     TN_DEBUG2( "CThumbAGProcessor::FormatNotification(%d)", aFormat );
  2195     OstTrace1( TRACE_NORMAL, CTHUMBAGPROCESSOR_FORMATNOTIFICATION, "CThumbAGProcessor::FormatNotification;aFormat=%u", aFormat );
       
  2196     
  2035     
  2197     iFormatting = aFormat;
  2036     iFormatting = aFormat;
  2198     
  2037     
  2199     if(!aFormat)
  2038     if(!aFormat)
  2200         {
  2039         {
  2210 // ---------------------------------------------------------------------------
  2049 // ---------------------------------------------------------------------------
  2211 //
  2050 //
  2212 void CThumbAGProcessor::RPropertyNotification(const TInt aError, const TUid aKeyCategory, const TUint aPropertyKey, const TInt aValue)
  2051 void CThumbAGProcessor::RPropertyNotification(const TInt aError, const TUid aKeyCategory, const TUint aPropertyKey, const TInt aValue)
  2213     {
  2052     {
  2214     TN_DEBUG5( "CThumbAGProcessor::RPropertyNotification() aError = %d, aPropertyKey = %d, aKeyCategory = %d, aValue = %d", aError, aPropertyKey, aKeyCategory, aValue );
  2053     TN_DEBUG5( "CThumbAGProcessor::RPropertyNotification() aError = %d, aPropertyKey = %d, aKeyCategory = %d, aValue = %d", aError, aPropertyKey, aKeyCategory, aValue );
  2215     OstTraceExt2( TRACE_NORMAL, CTHUMBAGPROCESSOR_RPROPERTYNOTIFICATION, "CThumbAGProcessor::RPropertyNotification;aPropertyKey=%u;aValue=%d", aPropertyKey, aValue );
       
  2216     
  2054     
  2217     if(aPropertyKey == KForceBackgroundGeneration && aKeyCategory == KTAGDPSNotification )
  2055     if(aPropertyKey == KForceBackgroundGeneration && aKeyCategory == KTAGDPSNotification )
  2218         {
  2056         {
  2219         if( aValue == 1 && aError == KErrNone )
  2057         if( aValue == 1 && aError == KErrNone )
  2220             {
  2058             {
  2250         TInt ret = RProperty::Define(KTAGDPSNotification, KDaemonProcessing, RProperty::EInt);
  2088         TInt ret = RProperty::Define(KTAGDPSNotification, KDaemonProcessing, RProperty::EInt);
  2251         
  2089         
  2252         if( ret != KErrNone )
  2090         if( ret != KErrNone )
  2253             {
  2091             {
  2254             TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() define KDaemonProcessing ret = %d", ret);
  2092             TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() define KDaemonProcessing ret = %d", ret);
  2255             OstTrace1( TRACE_NORMAL, CTHUMBAGPROCESSOR_UPDATEPSVALUES, "CThumbAGProcessor::UpdatePSValues - define KDaemonProcessing;ret=%d", ret );
       
  2256             }
  2093             }
  2257 
  2094 
  2258         ret = RProperty::Define(KTAGDPSNotification, KItemsleft, RProperty::EInt);
  2095         ret = RProperty::Define(KTAGDPSNotification, KItemsleft, RProperty::EInt);
  2259         
  2096         
  2260         if( ret != KErrNone )
  2097         if( ret != KErrNone )
  2261             {
  2098             {
  2262             TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() define KItemsleft ret = %d", ret);
  2099             TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() define KItemsleft ret = %d", ret);
  2263             OstTrace1( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_UPDATEPSVALUES, "CThumbAGProcessor::UpdatePSValues - define KItemsleft;ret=%d", ret );
       
  2264             }
  2100             }
  2265         }
  2101         }
  2266     
  2102     
  2267         // set itemsleft = KErrNotReady (-18) and daemonProcessing = ETrue if
  2103         // set itemsleft = KErrNotReady (-18) and daemonProcessing = ETrue if
  2268         // - key is initalized
  2104         // - key is initalized
  2280            {
  2116            {
  2281            itemsLeft = iAddItemCount + iModifyItemCount;
  2117            itemsLeft = iAddItemCount + iModifyItemCount;
  2282            }
  2118            }
  2283        
  2119        
  2284        TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() KItemsleft == %d", itemsLeft);
  2120        TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() KItemsleft == %d", itemsLeft);
  2285        OstTrace1( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_UPDATEPSVALUES, "CThumbAGProcessor::UpdatePSValues;itemsLeft=%d", itemsLeft );
       
  2286            
  2121            
  2287        //cancel 2nd round generarion when there is items in 1st round queues
  2122        //cancel 2nd round generarion when there is items in 1st round queues
  2288        if(iAddItemCount && i2ndRound)
  2123        if(iAddItemCount && i2ndRound)
  2289            {
  2124            {
  2290            DeleteAndCancelQuery(ETrue);
  2125            DeleteAndCancelQuery(ETrue);
  2301             }
  2136             }
  2302         
  2137         
  2303         if( daemonProcessing != iPreviousDaemonProcessing)
  2138         if( daemonProcessing != iPreviousDaemonProcessing)
  2304             {
  2139             {
  2305             TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() update KDaemonProcessing == %d", daemonProcessing);
  2140             TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() update KDaemonProcessing == %d", daemonProcessing);
  2306             OstTrace1( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_UPDATEPSVALUES, "CThumbAGProcessor::UpdatePSValues - update KDaemonProcessing;daemonProcessing=%u", daemonProcessing );
       
  2307             iPreviousDaemonProcessing = daemonProcessing;
  2141             iPreviousDaemonProcessing = daemonProcessing;
  2308             TInt ret = RProperty::Set(KTAGDPSNotification, KDaemonProcessing, daemonProcessing);
  2142             TInt ret = RProperty::Set(KTAGDPSNotification, KDaemonProcessing, daemonProcessing);
  2309             
  2143             
  2310             if(ret != KErrNone )
  2144             if(ret != KErrNone )
  2311                 {
  2145                 {
  2312                 TN_DEBUG3( "CThumbAGProcessor::UpdatePSValues() set KDaemonProcessing %d failed %d", daemonProcessing, ret);
  2146                 TN_DEBUG3( "CThumbAGProcessor::UpdatePSValues() set KDaemonProcessing %d failed %d", daemonProcessing, ret);
  2313                 OstTraceExt2( TRACE_NORMAL, DUP4_CTHUMBAGPROCESSOR_UPDATEPSVALUES, "CThumbAGProcessor::UpdatePSValues - set KDaemonProcessing;daemonProcessing=%u;ret=%d", daemonProcessing, ret );
  2147                 }
  2314                 }
  2148             }
  2315             }
  2149         
  2316         
       
  2317         TInt ret = RProperty::Get(KTAGDPSNotification, KItemsleft, iPreviousItemsLeft );
       
  2318         TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() iPreviousItemsLeft == %d", iPreviousItemsLeft);
  2150         TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() iPreviousItemsLeft == %d", iPreviousItemsLeft);
  2319         OstTrace1( TRACE_NORMAL, DUP5_CTHUMBAGPROCESSOR_UPDATEPSVALUES, "CThumbAGProcessor::UpdatePSValues;iPreviousItemsLeft=%d", iPreviousItemsLeft );
       
  2320         
  2151         
  2321         if( itemsLeft != iPreviousItemsLeft)
  2152         if( itemsLeft != iPreviousItemsLeft)
  2322             {
  2153             {
  2323             TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() Set KItemsleft == %d", itemsLeft);
  2154             TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() Set KItemsleft == %d", itemsLeft);
  2324             OstTrace1( TRACE_NORMAL, DUP6_CTHUMBAGPROCESSOR_UPDATEPSVALUES, "CThumbAGProcessor::UpdatePSValues - Set KItemsleft;itemsLeft=%d", itemsLeft );
       
  2325             iPreviousItemsLeft = itemsLeft;
  2155             iPreviousItemsLeft = itemsLeft;
  2326             TInt ret = RProperty::Set(KTAGDPSNotification, KItemsleft, itemsLeft );
  2156             TInt ret = RProperty::Set(KTAGDPSNotification, KItemsleft, itemsLeft );
  2327             
  2157             
  2328             if(ret != KErrNone )
  2158             if(ret != KErrNone )
  2329                 {
  2159                 {
  2330                 TN_DEBUG3( "CThumbAGProcessor::UpdatePSValues() set KItemsleft %d failed %d", itemsLeft, ret);
  2160                 TN_DEBUG3( "CThumbAGProcessor::UpdatePSValues() set KItemsleft %d failed %d", itemsLeft, ret);
  2331                 OstTraceExt2( TRACE_NORMAL, DUP7_CTHUMBAGPROCESSOR_UPDATEPSVALUES, "CThumbAGProcessor::UpdatePSValues - set KItemsleft failed;itemsLeft=%d;ret=%d", itemsLeft, ret );
       
  2332                 }
  2161                 }
  2333             }
  2162             }
  2334         
  2163         
  2335     }
  2164     }
  2336 
  2165 
  2351     }
  2180     }
  2352 
  2181 
  2353 void CThumbAGProcessor::UpdateItemCounts()
  2182 void CThumbAGProcessor::UpdateItemCounts()
  2354     {
  2183     {
  2355     TN_DEBUG1( "CThumbAGProcessor::UpdateItemCounts()");
  2184     TN_DEBUG1( "CThumbAGProcessor::UpdateItemCounts()");
  2356     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts" );
       
  2357     iModifyItemCount = 0;
  2185     iModifyItemCount = 0;
  2358     iDeleteItemCount = 0;
  2186     iDeleteItemCount = 0;
  2359     iAddItemCount = 0;
  2187     iAddItemCount = 0;
  2360     iUnknownItemCount = 0;
  2188     iUnknownItemCount = 0;
  2361     i2ndAddItemCount = 0;
  2189     i2ndAddItemCount = 0;
  2413             }
  2241             }
  2414     }
  2242     }
  2415     
  2243     
  2416     TN_DEBUG2( "CThumbAGProcessor::UpdateItemCounts() iActiveCount = %d", 
  2244     TN_DEBUG2( "CThumbAGProcessor::UpdateItemCounts() iActiveCount = %d", 
  2417             iActiveCount);
  2245             iActiveCount);
  2418     OstTrace1( TRACE_NORMAL, DUP1_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts - iActiveCount;iActiveCount=%u", iActiveCount );
       
  2419     TN_DEBUG2( "CThumbAGProcessor::UpdateItemCounts() iPreviousItemsLeft = %d", 
  2246     TN_DEBUG2( "CThumbAGProcessor::UpdateItemCounts() iPreviousItemsLeft = %d", 
  2420             iPreviousItemsLeft);
  2247             iPreviousItemsLeft);
  2421     OstTrace1( TRACE_NORMAL, DUP2_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts;iPreviousItemsLeft=%d", iPreviousItemsLeft );
       
  2422     TN_DEBUG5( "CThumbAGProcessor::UpdateItemCounts() iHarvesting == %d, iMMCHarvesting == %d, iPHHarvesting == %d, iMPXHarvesting == %d", 
  2248     TN_DEBUG5( "CThumbAGProcessor::UpdateItemCounts() iHarvesting == %d, iMMCHarvesting == %d, iPHHarvesting == %d, iMPXHarvesting == %d", 
  2423             iHarvesting, iMMCHarvesting, iPHHarvesting, iMPXHarvesting);
  2249             iHarvesting, iMMCHarvesting, iPHHarvesting, iMPXHarvesting);
  2424     OstTraceExt4( TRACE_NORMAL, DUP3_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts;iHarvesting=%d;iMMCHarvesting=%d;iPHHarvesting=%d;iMPXHarvesting=%d", 
       
  2425             iHarvesting, iMMCHarvesting, iPHHarvesting, iMPXHarvesting );
       
  2426 
       
  2427     TN_DEBUG5( "CThumbAGProcessor::UpdateItemCounts() iIdle = %d, iForegroundRun = %d, timer = %d, iForceRun = %d", 
  2250     TN_DEBUG5( "CThumbAGProcessor::UpdateItemCounts() iIdle = %d, iForegroundRun = %d, timer = %d, iForceRun = %d", 
  2428             iIdle, iForegroundRun, iPeriodicTimer->IsActive(), iForceRun);
  2251             iIdle, iForegroundRun, iPeriodicTimer->IsActive(), iForceRun);
  2429     OstTraceExt4( TRACE_NORMAL, DUP4_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts;iIdle=%d;iForegroundRun=%d;iPeriodicTimer->IsActive()=%d;iForceRun=%d", 
       
  2430             iIdle, iForegroundRun, iPeriodicTimer->IsActive(), iForceRun );
       
  2431 			
       
  2432     TN_DEBUG4( "CThumbAGProcessor::UpdateItemCounts() iModify = %d, iQueryReady = %d, iProcessingCount = %d", 
  2252     TN_DEBUG4( "CThumbAGProcessor::UpdateItemCounts() iModify = %d, iQueryReady = %d, iProcessingCount = %d", 
  2433             iModify, iQueryReady, iProcessingCount);
  2253             iModify, iQueryReady, iProcessingCount);
  2434     OstTraceExt2( TRACE_NORMAL, DUP5_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts;iModify=%u;iQueryReady=%u", 
       
  2435             iModify, iQueryReady );
       
  2436     OstTrace1( TRACE_NORMAL, DUP12_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts;iProcessingCount=%u", iProcessingCount );
       
  2437     TN_DEBUG2( "CThumbAGProcessor::UpdateItemCounts() iMountTimer = %d", iMountTimer->IsActive());
  2254     TN_DEBUG2( "CThumbAGProcessor::UpdateItemCounts() iMountTimer = %d", iMountTimer->IsActive());
  2438     OstTrace1( TRACE_NORMAL, DUP6_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts;iMountTimer->IsActive()=%u", iMountTimer->IsActive() );
       
  2439     TN_DEBUG3( "CThumbAGProcessor::UpdateItemCounts() iGenerationQueue = %d, iQueryQueue = %d", 
  2255     TN_DEBUG3( "CThumbAGProcessor::UpdateItemCounts() iGenerationQueue = %d, iQueryQueue = %d", 
  2440             iGenerationQueue.Count(), iQueryQueue.Count());
  2256             iGenerationQueue.Count(), iQueryQueue.Count());
  2441     OstTraceExt2( TRACE_NORMAL, DUP7_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts;iGenerationQueue.Count()=%d;iQueryQueue.Count()=%d", iGenerationQueue.Count(), iQueryQueue.Count() );
       
  2442     TN_DEBUG5( "CThumbAGProcessor::UpdateItemCounts() iAddItemCount=%d, i2ndAddItemCount=%d, iModifyItemCount=%d, iDeleteItemCount=%d",
  2257     TN_DEBUG5( "CThumbAGProcessor::UpdateItemCounts() iAddItemCount=%d, i2ndAddItemCount=%d, iModifyItemCount=%d, iDeleteItemCount=%d",
  2443             iAddItemCount, i2ndAddItemCount, iModifyItemCount, iDeleteItemCount );
  2258             iAddItemCount, i2ndAddItemCount, iModifyItemCount, iDeleteItemCount );
  2444     OstTrace0( TRACE_NORMAL, DUP8_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts" );
       
  2445     TN_DEBUG3( "CThumbAGProcessor::UpdateItemCounts() iUnknownItemCount=%d, iPlaceholderItemCount=%d",
  2259     TN_DEBUG3( "CThumbAGProcessor::UpdateItemCounts() iUnknownItemCount=%d, iPlaceholderItemCount=%d",
  2446             iUnknownItemCount, iPlaceholderItemCount);
  2260             iUnknownItemCount, iPlaceholderItemCount);
  2447     OstTraceExt2( TRACE_NORMAL, DUP9_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts;iUnknownItemCount=%d;iPlaceholderItemCount=%d", iUnknownItemCount, iPlaceholderItemCount );
       
  2448     TN_DEBUG4( "CThumbAGProcessor::UpdateItemCounts() iAudioItemCount=%d, iVideoItemCount=%d, iImageItemCount=%d",
  2261     TN_DEBUG4( "CThumbAGProcessor::UpdateItemCounts() iAudioItemCount=%d, iVideoItemCount=%d, iImageItemCount=%d",
  2449             iAudioItemCount, iVideoItemCount, iImageItemCount);
  2262             iAudioItemCount, iVideoItemCount, iImageItemCount);
  2450     OstTraceExt3( TRACE_NORMAL, DUP10_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts;iAudioItemCount=%u;iVideoItemCount=%d;iImageItemCount=%d", 
       
  2451             iAudioItemCount, iVideoItemCount, iImageItemCount );
       
  2452 			
       
  2453     TN_DEBUG2( "CThumbAGProcessor::UpdateItemCounts() iCameraItemCount=%d", iCameraItemCount);
  2263     TN_DEBUG2( "CThumbAGProcessor::UpdateItemCounts() iCameraItemCount=%d", iCameraItemCount);
  2454     OstTrace1( TRACE_NORMAL, DUP11_CTHUMBAGPROCESSOR_UPDATEITEMCOUNTS, "CThumbAGProcessor::UpdateItemCounts;iCameraItemCount=%d", iCameraItemCount );
       
  2455     
  2264     
  2456     //compress queues when empty
  2265     //compress queues when empty
  2457     if(!iGenerationQueue.Count())
  2266     if(!iGenerationQueue.Count())
  2458         {
  2267         {
  2459         iGenerationQueue.Compress();
  2268         iGenerationQueue.Compress();
  2471 // ---------------------------------------------------------------------------
  2280 // ---------------------------------------------------------------------------
  2472 //
  2281 //
  2473 TInt CThumbAGProcessor::MountTimerCallBack(TAny* aAny)
  2282 TInt CThumbAGProcessor::MountTimerCallBack(TAny* aAny)
  2474     {
  2283     {
  2475     TN_DEBUG1( "CThumbAGProcessor::MountTimerCallBack()");
  2284     TN_DEBUG1( "CThumbAGProcessor::MountTimerCallBack()");
  2476     OstTrace0( TRACE_NORMAL, CTHUMBAGPROCESSOR_MOUNTTIMERCALLBACK, "CThumbAGProcessor::MountTimerCallBack" );
       
  2477     CThumbAGProcessor* self = static_cast<CThumbAGProcessor*>( aAny );
  2285     CThumbAGProcessor* self = static_cast<CThumbAGProcessor*>( aAny );
  2478     
  2286     
  2479     self->iMountTimer->Cancel();
  2287     self->iMountTimer->Cancel();
  2480     
  2288     
  2481     //activate timeout if overall or mmc harvestig is not active
  2289     //activate timeout if overall or mmc harvestig is not active
  2506             aGenerationItem.iItemAction = EGenerationItemActionAdd;
  2314             aGenerationItem.iItemAction = EGenerationItemActionAdd;
  2507             break;
  2315             break;
  2508         case EGenerationItemTypeVideo:
  2316         case EGenerationItemTypeVideo:
  2509             //S^3 EGenerationItemActionAdd
  2317             //S^3 EGenerationItemActionAdd
  2510             //S^4 EGenerationItemAction2ndAdd
  2318             //S^4 EGenerationItemAction2ndAdd
  2511             aGenerationItem.iItemAction = EGenerationItemAction2ndAdd;    
  2319             aGenerationItem.iItemAction = EGenerationItemActionAdd;    
  2512             break;
  2320             break;
  2513         default:
  2321         default:
  2514             aGenerationItem.iItemAction = EGenerationItemActionResolveType;
  2322             aGenerationItem.iItemAction = EGenerationItemActionResolveType;
  2515         }
  2323         }
  2516     }
  2324     }