imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp
branchRCL_3
changeset 5 82749d516180
parent 0 2014ca87e772
child 9 2eb74cf6572e
equal deleted inserted replaced
1:235a7fc86938 5:82749d516180
    19 #include <e32base.h>
    19 #include <e32base.h>
    20 
    20 
    21 #include <mdeconstants.h>
    21 #include <mdeconstants.h>
    22 #include <centralrepository.h>
    22 #include <centralrepository.h>
    23 
    23 
       
    24 #include <mpxcollectionutility.h>
       
    25 #include <mpxmessagegeneraldefs.h>
       
    26 #include <mpxcollectionmessage.h>
       
    27 #include <CoreApplicationUIsDomainPSKeys.h> 
       
    28 
    24 #include "thumbagprocessor.h"
    29 #include "thumbagprocessor.h"
    25 #include "thumbnaillog.h"
    30 #include "thumbnaillog.h"
    26 #include "thumbnailmanagerconstants.h"
    31 #include "thumbnailmanagerconstants.h"
    27 #include "thumbnailmanagerprivatecrkeys.h"
    32 #include "thumbnailmanagerprivatecrkeys.h"
    28 #include "thumbagformatobserver.h"
       
    29 #include <mpxcollectionutility.h>
       
    30 #include <mpxmessagegeneraldefs.h>
       
    31 #include <mpxcollectionmessage.h>
       
    32 
    33 
    33 // ---------------------------------------------------------------------------
    34 // ---------------------------------------------------------------------------
    34 // CThumbAGProcessor::NewL()
    35 // CThumbAGProcessor::NewL()
    35 // ---------------------------------------------------------------------------
    36 // ---------------------------------------------------------------------------
    36 //
    37 //
    69     iModCounter = 0;
    70     iModCounter = 0;
    70     iDelCounter = 0;
    71     iDelCounter = 0;
    71 #endif
    72 #endif
    72     
    73     
    73     iTMSession = CThumbnailManager::NewL( *this );
    74     iTMSession = CThumbnailManager::NewL( *this );
    74     
    75     iQueryAllItems = NULL;
       
    76     iQueryPlaceholders = NULL;
    75     iQuery = NULL;
    77     iQuery = NULL;
    76     iQueryActive = EFalse;
    78     iQueryActive = EFalse;
    77     iModify = EFalse;
    79     iModify = EFalse;
    78     iProcessingCount = 0;
    80     iProcessingCount = 0;
    79     
    81     
    87     //do some initializing async in RunL()
    89     //do some initializing async in RunL()
    88     iInit = ETrue;
    90     iInit = ETrue;
    89     iForceRun = EFalse;    
    91     iForceRun = EFalse;    
    90     iActive = EFalse;
    92     iActive = EFalse;
    91     
    93     
    92     iFormatObserver = CThumbAGFormatObserver::NewL( this );
    94     iFormatObserver = CTMFormatObserver::NewL( *this );
    93        
    95        
    94     iFormatting = EFalse;     
    96     iFormatting = EFalse;     
    95     iSessionDied = EFalse;
    97     iSessionDied = EFalse;
    96     
    98     
    97     iCollectionUtility = NULL;
    99     iCollectionUtility = NULL;
    98         
   100     
       
   101     iLight = CHWRMLight::NewL(this);
       
   102 
       
   103 #ifdef _DEBUG 
       
   104     if(iLight)
       
   105         {
       
   106         iLightMask = iLight->SupportedTargets();
       
   107         TN_DEBUG2( "CThumbAGProcessor::ConstructL() - iLightMask == %d", iLightMask );
       
   108         }
       
   109 #endif
       
   110         
       
   111     iActivityManager = CTMActivityManager::NewL( this, KBackgroundGenerationIdle);
       
   112     
       
   113     ActivateAO();
       
   114     
    99     TN_DEBUG1( "CThumbAGProcessor::ConstructL() - end" );
   115     TN_DEBUG1( "CThumbAGProcessor::ConstructL() - end" );
   100     }
   116     }
   101 
   117 
   102 // ---------------------------------------------------------------------------
   118 // ---------------------------------------------------------------------------
   103 // CThumbAGProcessor::~CThumbAGProcessor()
   119 // CThumbAGProcessor::~CThumbAGProcessor()
   104 // ---------------------------------------------------------------------------
   120 // ---------------------------------------------------------------------------
   105 //
   121 //
   106 CThumbAGProcessor::~CThumbAGProcessor()
   122 CThumbAGProcessor::~CThumbAGProcessor()
   107     {
   123     {
   108     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - begin" );
   124     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - begin" );
       
   125     
       
   126     if(iActivityManager)
       
   127         {
       
   128         delete iActivityManager;
       
   129         iActivityManager = NULL;
       
   130         }
       
   131     
       
   132     if (iInactivityTimer)
       
   133         {
       
   134         iInactivityTimer->Cancel();
       
   135         delete iInactivityTimer;
       
   136         iInactivityTimer = NULL;
       
   137         }
   109     
   138     
   110     if(iPeriodicTimer)
   139     if(iPeriodicTimer)
   111         {
   140         {
   112         iPeriodicTimer->Cancel();
   141         iPeriodicTimer->Cancel();
   113         delete iPeriodicTimer;
   142         delete iPeriodicTimer;
   124         iCollectionUtility->Close();
   153         iCollectionUtility->Close();
   125         iCollectionUtility = NULL;
   154         iCollectionUtility = NULL;
   126         }
   155         }
   127 
   156 
   128     Cancel();
   157     Cancel();
       
   158     
       
   159     if(iQueryPlaceholders)
       
   160         {
       
   161         iQueryPlaceholders->Cancel();
       
   162         delete iQueryPlaceholders;
       
   163         iQueryPlaceholders = NULL;
       
   164         }
   129     
   165     
   130     if (iQuery)
   166     if (iQuery)
   131         {
   167         {
   132         iQuery->Cancel();
   168         iQuery->Cancel();
   133         delete iQuery;
   169         delete iQuery;
   134         iQuery = NULL;
   170         iQuery = NULL;
   135         }
   171         }
   136     
   172     
   137     if (iQueryForPlaceholders)
   173     if (iQueryAllItems)
   138        {
   174        {
   139        iQueryForPlaceholders->Cancel();
   175        iQueryAllItems->Cancel();
   140        delete iQueryForPlaceholders;
   176        delete iQueryAllItems;
   141        iQueryForPlaceholders = NULL;
   177        iQueryAllItems = NULL;
   142        }
   178        }
   143     
   179     
   144     iAddQueue.Close();
   180     iAddQueue.Close();
   145     iModifyQueue.Close();
   181     iModifyQueue.Close();
   146     iRemoveQueue.Close();
   182     iRemoveQueue.Close();
   147     iQueryQueue.Close();
   183     iQueryQueue.Close();
   148     iPresentQueue.Close();
   184     iPlaceholderQueue.Close();
   149     iTempModifyQueue.Close();
       
   150     iTempAddQueue.Close();
       
   151     iPlaceholderIDs.Close();
       
   152     
   185     
   153     if (iTMSession)
   186     if (iTMSession)
   154         {
   187         {
   155         delete iTMSession;
   188         delete iTMSession;
   156         iTMSession = NULL;
   189         iTMSession = NULL;
   157         }
   190         }
   158     
   191     
   159     delete iFormatObserver;
   192     delete iFormatObserver;
       
   193     
       
   194     delete iLight;
       
   195     iLight = NULL;
   160     
   196     
   161     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - end" );
   197     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - end" );
   162     }
   198     }
   163 
   199 
   164 // -----------------------------------------------------------------------------
   200 // -----------------------------------------------------------------------------
   174 
   210 
   175 // -----------------------------------------------------------------------------
   211 // -----------------------------------------------------------------------------
   176 // CThumbAGProcessor::HandleQueryCompleted()
   212 // CThumbAGProcessor::HandleQueryCompleted()
   177 // -----------------------------------------------------------------------------
   213 // -----------------------------------------------------------------------------
   178 //
   214 //
   179 void CThumbAGProcessor::HandleQueryCompleted( CMdEQuery& /*aQuery*/, const TInt aError )
   215 void CThumbAGProcessor::HandleQueryCompleted( CMdEQuery& aQuery, const TInt aError )
   180     {
   216     {
   181 
   217     TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompleted, aError == %d Count== %d", aError, aQuery.Count());
   182     if( iQueryForPlaceholdersActive && iQueryForPlaceholders)
   218     
   183         {
   219     if(&aQuery == iQueryPlaceholders)
   184         TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompletedv2, aError == %d Count== %d", aError, iQueryForPlaceholders->Count());
   220         {
   185         
   221         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - iQueryPlaceholders completed");
       
   222         
       
   223         iPlaceholderQueue.Reset();
   186         // if no errors in query
   224         // if no errors in query
   187         if (aError == KErrNone )
   225         if (aError == KErrNone )
   188             {
   226             {
   189             
   227             for(TInt i = 0; i < iQueryPlaceholders->Count(); i++)
   190             for(TInt i = 0; i < iQueryForPlaceholders->Count(); i++)
   228                {    
       
   229                const CMdEObject* object = &iQueryPlaceholders->Result(i);
       
   230               
       
   231                if(!object)
       
   232                    {
       
   233                    continue;
       
   234                    }
       
   235               
       
   236                if(!object->Placeholder())
       
   237                    {
       
   238                    TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted %d not placeholder", object->Id());
       
   239                    continue;
       
   240                    }
       
   241               
       
   242                /*if (iPlaceholderQueue.Find( object->Id() ) == KErrNotFound)
       
   243                    {
       
   244                    TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted %d added to placeholder queue", object->Id());*/
       
   245                    TRAP_IGNORE( iPlaceholderQueue.AppendL( object->Id() )); 
       
   246                  //}
       
   247                }
       
   248            }
       
   249            delete iQueryPlaceholders;
       
   250            iQueryPlaceholders = NULL;
       
   251         }
       
   252     else if(&aQuery == iQueryAllItems)
       
   253         {
       
   254         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - QueryAllItems completed");
       
   255         // if no errors in query
       
   256         if (aError == KErrNone )
       
   257             {
       
   258             for(TInt i = 0; i < iQueryAllItems->Count(); i++)
   191                 {    
   259                 {    
   192                 const CMdEObject* object = &iQueryForPlaceholders->Result(i);
   260                 const CMdEObject* object = &iQueryAllItems->Result(i);
   193                 
   261                
   194                 if(!object)
   262                 if(!object)
   195                     continue;
       
   196                 
       
   197                 if(!object->Placeholder())
       
   198                     {
   263                     {
   199                     TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompletedv2 %d not placeholder",object->Id());
       
   200                     continue;
   264                     continue;
   201                     }
   265                     }
   202                 
   266                
   203                 if (iPlaceholderIDs.Find( object->Id() ) == KErrNotFound)
   267                 if (iAddQueue.Find( object->Id() ) == KErrNotFound)
   204                    {
   268                     {
   205                    TRAP_IGNORE( iPlaceholderIDs.AppendL( object->Id() )); 
   269                     TRAP_IGNORE( iAddQueue.AppendL( object->Id() ));
   206                    }
   270                     }
   207                 }
   271                 }
   208                 
   272 #ifdef _DEBUG
   209             }
   273 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted IN-COUNTERS---------- Amount: %d, Add",iQueryAllItems->Count());
   210         else
   274 #endif
   211             {
   275             }
   212             TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() FAILED!");   
   276             //free query
   213             }
   277             delete iQueryAllItems;
   214         
   278             iQueryAllItems = NULL;
   215         iQueryForPlaceholdersActive = EFalse;
   279         }
   216         }
   280     else if(&aQuery == iQuery )
   217     
   281         {
   218     else if(iQueryActive)
   282         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - Query completed");
   219         {
   283         if(iQueryActive)
   220         TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompleted, aError == %d Count== %d", aError, iQuery->Count());
   284             {
   221         iQueryReady = ETrue;
   285             iQueryReady = ETrue;
   222         iQueryActive = EFalse;
   286             iQueryActive = EFalse;
       
   287             }
   223     
   288     
   224         // if no errors in query
   289         // if no errors in query
   225         if (aError == KErrNone && iQuery)
   290         if (aError == KErrNone && iQuery)
   226             {
   291             {
   227             iProcessingCount = iQuery->Count();
   292             iProcessingCount = iQuery->Count();
   228             }
   293             }
   229         else
   294         else
   230             {
   295             {
       
   296             delete iQuery;
       
   297             iQuery = NULL;
   231             iProcessingCount = 0;
   298             iProcessingCount = 0;
   232             TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() FAILED!");   
   299             TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() Query FAILED!");   
   233             }
   300             }
   234         }
   301         }
   235     else
   302     else
   236         {
   303         {
   237         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() - NO QUERY ACTIVE"); 
   304         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() - NO QUERY ACTIVE"); 
       
   305         __ASSERT_DEBUG((EFalse), User::Panic(_L("CThumbAGProcessor::HandleQueryCompleted()"), -1));
   238         }
   306         }
   239     
   307     
   240     ActivateAO();
   308     ActivateAO();
   241     }
   309     }
   242 
   310 
   266         {
   334         {
   267         TN_DEBUG1( "CThumbAGProcessor::ThumbnailReady() - **** THUMBNAIL SERVER DIED ****" );
   335         TN_DEBUG1( "CThumbAGProcessor::ThumbnailReady() - **** THUMBNAIL SERVER DIED ****" );
   268 		
   336 		
   269         iSessionDied = ETrue;
   337         iSessionDied = ETrue;
   270         
   338         
   271         if( !iTimerActive)
   339         if( !iPeriodicTimer->IsActive())
   272             {
   340             {
   273             StartTimeout();
   341             StartTimeout();
   274 			}
   342 			}
   275 			
   343 			
   276         //reset PS idle so that RunL() can startup reopen TNM session and proceed
   344         //reset PS idle so that RunL() can startup reopen TNM session and proceed
   297     TRAPD( err, iDefNamespace = &iMdESession->GetDefaultNamespaceDefL() );
   365     TRAPD( err, iDefNamespace = &iMdESession->GetDefaultNamespaceDefL() );
   298     if (err != KErrNone)
   366     if (err != KErrNone)
   299         {
   367         {
   300         TN_DEBUG1( "CThumbAGProcessor::SetMdESession - Error: GetDefaultNamespaceDefL leave" );
   368         TN_DEBUG1( "CThumbAGProcessor::SetMdESession - Error: GetDefaultNamespaceDefL leave" );
   301         }
   369         }
       
   370     
       
   371     TRAP_IGNORE(QueryPlaceholdersL());
       
   372     TRAP_IGNORE(QueryAllItemsL());
       
   373     
   302 	ActivateAO();
   374 	ActivateAO();
   303     }
   375     }
   304 
   376 
   305 // ---------------------------------------------------------------------------
   377 // ---------------------------------------------------------------------------
   306 // CThumbAGProcessor::AddToQueue()
   378 // CThumbAGProcessor::AddToQueue()
   307 // ---------------------------------------------------------------------------
   379 // ---------------------------------------------------------------------------
   308 //
   380 //
   309 void CThumbAGProcessor::AddToQueueL( TObserverNotificationType aType, 
   381 void CThumbAGProcessor::AddToQueueL( TObserverNotificationType aType, 
   310                                     const RArray<TItemId>& aIDArray, TBool aPresent )
   382                                     const RArray<TItemId>& aIDArray, TBool /*aPresent*/ )
   311     {
   383     {
   312     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - begin" );
   384     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - begin" );
   313     
   385 
   314     if(aPresent)
       
   315         {
       
   316         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - Add to SetPresentQueue" );
       
   317         for (int i=0; i<aIDArray.Count(); i++)
       
   318              {
       
   319              // only add to Present queue if not already in Add or Present queue        
       
   320               if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound)
       
   321                   {
       
   322                   if (iPresentQueue.Find( aIDArray[i] ) == KErrNotFound)
       
   323                       {
       
   324                       iPresentQueue.AppendL(aIDArray[i]);
       
   325                       }
       
   326                   }
       
   327              }     
       
   328         }
       
   329     // update queues
   386     // update queues
   330     else if (aType == ENotifyAdd)
   387     if (aType == ENotifyAdd)
   331         {
   388         {
   332         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyAdd" );
   389         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyAdd" );
   333         
   390         
   334         for (int i=0; i<aIDArray.Count(); i++)
   391         for (int i=0; i<aIDArray.Count(); i++)
   335             {
   392             {
   336             // only add to Add queue if not already in Add queue        
   393             // only add to Add queue if not already in Add queue        
   337             if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound)
   394             if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound)
   338                 {
   395                 {
   339                 //if in Present Queue remove from there and and put to add queue
   396                 iAddQueue.AppendL(aIDArray[i]); 
   340                 TInt index = iPresentQueue.Find( aIDArray[i] );
   397                 }
   341                 if( index != KErrNotFound)
   398             }
       
   399         }
       
   400     else if (aType == ENotifyModify)
       
   401         {
       
   402         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyModify" );
       
   403         
       
   404         if(iPHHarvesting)
       
   405             {
       
   406             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH  harvesting active, treat like add" );
       
   407             for (int i=0; i<aIDArray.Count(); i++)
       
   408                 {
       
   409                 // only add to Add queue if not already in Add queue        
       
   410                 if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound)
   342                     {
   411                     {
   343                     iPresentQueue.Remove( index );
   412                     iAddQueue.AppendL(aIDArray[i]); 
   344                     }
   413                     }
   345                 iAddQueue.AppendL(aIDArray[i]); 
   414                 
   346                 iTempAddQueue.AppendL(aIDArray[i]);
   415                 TInt itemIndex = iPlaceholderQueue.Find( aIDArray[i] );
   347                 }
   416                                 
   348             }
   417                 if (itemIndex >= 0)
   349         }
   418                     {
   350     else if (aType == ENotifyModify)
   419                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from placeholder queue");
   351         {
   420                     iPlaceholderQueue.Remove( itemIndex );
   352         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyModify" );
   421                     }
       
   422                 }
       
   423             }
       
   424         else
       
   425             {
       
   426             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH  harvesting finished, check is real modify!" );
   353             
   427             
   354         for (int i=0; i<aIDArray.Count(); i++)
   428             TInt itemIndex(KErrNotFound);
   355              {
   429             
   356              TInt itemIndex = iPlaceholderIDs.Find( aIDArray[i] );
   430             for (int i=0; i<aIDArray.Count(); i++)
   357              if(itemIndex >= 0 )
   431                 {
   358                  {
   432                 itemIndex = iPlaceholderQueue.Find( aIDArray[i] );
   359                  TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - harvesting now ended for this placeholder - not Real ENotifyModify" );
   433                 
   360                  iPlaceholderIDs.Remove(itemIndex);
   434                 if (itemIndex >= 0)
   361                  TN_DEBUG2( "CThumbAGProcessor::AddToQueueL() - placeholders left %d", iPlaceholderIDs.Count() );
   435                     {
   362                  if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound)
   436                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - placeholder modify, remove from placeholder queue");
   363                      {
   437                     iPlaceholderQueue.Remove( itemIndex );
   364                      iAddQueue.AppendL(aIDArray[i]);
   438                     iAddQueue.Append( aIDArray[i] );
   365                      }
   439                     }
   366                  if (iTempModifyQueue.Find( aIDArray[i] ) == KErrNotFound)
   440                 else
   367                      {
   441                     {
   368                      iTempModifyQueue.AppendL( aIDArray[i] );
   442                     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - real modify");
   369                      }
   443                     itemIndex = iAddQueue.Find( aIDArray[i] );
   370                  }
   444                                     
   371              else if ( iTempAddQueue.Find( aIDArray[i] ) == KErrNotFound)
   445                     if (itemIndex >= 0)
   372                  {
   446                         {
   373                  TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - Real ENotifyModify, force run" );
   447                         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from add queue");
   374                  iModifyQueue.InsertL( aIDArray[i], 0 );
   448                         iAddQueue.Remove( itemIndex );
   375                   
   449                         }
   376                  TInt itemIndex = iAddQueue.Find( aIDArray[i] );
   450                     
   377                  if(itemIndex >= 0)
   451                     if( iPlaceholderQueue.Find( aIDArray[i] ) == KErrNotFound )
       
   452                         {
       
   453                         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append to modify queue");
       
   454                         iModifyQueue.AppendL(aIDArray[i]);
       
   455                         }
       
   456                     
       
   457                     SetForceRun( ETrue );
       
   458                     } 
       
   459                 }
       
   460             }
       
   461         }
       
   462         else if (aType == ENotifyRemove)
       
   463             {
       
   464             TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove, remove IDs from all queues, append to Delete" );
       
   465             
       
   466             for (int i=0; i<aIDArray.Count(); i++)
       
   467                 {
       
   468                 // can be removed from Add queue
       
   469                 TInt itemIndex = iAddQueue.Find( aIDArray[i] );
       
   470                 if(itemIndex >= 0)
   378                     {
   471                     {
   379                     iAddQueue.Remove(itemIndex);
   472                     iAddQueue.Remove(itemIndex);
   380                     }
   473                     }
   381                  itemIndex = iPresentQueue.Find( aIDArray[i] );
   474     
   382                  if(itemIndex >= 0)
   475                 // ..and Modify Queue
       
   476                 itemIndex = iModifyQueue.Find( aIDArray[i] );
       
   477                 if(itemIndex >= 0)
   383                     {
   478                     {
   384                     iPresentQueue.Remove(itemIndex);
   479                     iModifyQueue.Remove(itemIndex);
   385                     }
   480                     }
   386                  SetForceRun( ETrue );
   481                 
   387                  }
   482                 //add to remove queue
   388              else
   483                 if (iRemoveQueue.Find( aIDArray[i] ) == KErrNotFound)
   389                  {
   484                     {
   390                  if (iTempModifyQueue.Find( aIDArray[i] ) == KErrNotFound)
   485                     iRemoveQueue.AppendL(aIDArray[i]);
   391                      {
   486                     }
   392                      TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - harvesting now ended for this file - not Real ENotifyModify" );
   487                 }
   393                      iTempModifyQueue.AppendL( aIDArray[i] );
   488             }
   394                      }
   489 #ifdef _DEBUG
   395                 else
   490         else
   396                      {
   491             {
   397                      TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - harvesting ended allready for this file - Real ENotifyModify, force run" );
   492 	        TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() -  should not come here" );
   398                      iModifyQueue.InsertL( aIDArray[i], 0 );
   493             __ASSERT_DEBUG((EFalse), User::Panic(_L("CThumbAGProcessor::AddToQueueL()"), -2));
   399                      TInt itemIndex = iAddQueue.Find( aIDArray[i] );
   494 			return;
   400                      if(itemIndex >= 0)
   495             }
   401                         {
   496 #endif
   402                         iAddQueue.Remove(itemIndex);
   497     
   403                         }
   498     ActivateAO(); 
   404                      itemIndex = iPresentQueue.Find( aIDArray[i] );
   499     
   405                      if(itemIndex >= 0)
   500     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - end" );
   406                         {
   501     }
   407                         iPresentQueue.Remove(itemIndex);
   502 
   408                         }
   503 // ---------------------------------------------------------------------------
   409                      SetForceRun( ETrue );
   504 // CThumbAGProcessor::CreateThumbnailsL()
   410                      }
   505 // ---------------------------------------------------------------------------
   411                  } 
   506 //
   412              }        
   507 void CThumbAGProcessor::CreateThumbnailsL( const CMdEObject* aObject )
   413         }
   508     {
   414     else if (aType == ENotifyRemove)
   509     TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - begin" );
   415         {
   510     
   416         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove" );
   511     TInt orientationVal = 0;
   417         
   512     TInt64 modifiedVal = 0;
   418         for (int i=0; i<aIDArray.Count(); i++)
   513     
   419             {
   514     CMdEProperty* orientation = NULL;
   420             // only add to Remove queue if not already in Remove queue        
   515     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );       
   421             if (iRemoveQueue.Find( aIDArray[i] ) == KErrNotFound)
   516     TInt orientErr = aObject->Property( objDef.GetPropertyDefL( MdeConstants::Image::KOrientationProperty ), orientation, 0 );
   422                 {
   517     
   423                 iRemoveQueue.AppendL(aIDArray[i]);
   518     if (orientErr == KErrNone)
   424                 }
   519         {
   425 
   520         orientationVal = orientation->Uint16ValueL();
   426             // can be removed from Add queue
   521         }
   427             TInt itemIndex = iAddQueue.Find( aIDArray[i] );
   522         
   428             if(itemIndex >= 0)
   523     CMdEProperty* modified = NULL;
   429                 {
   524     CMdEObjectDef& objDef2 = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );       
   430                 iAddQueue.Remove(itemIndex);
   525     TInt modifyErr = aObject->Property( objDef2.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ), modified, 0 );
   431                 }
   526     
   432             // ..and Present Queue
   527     if (modifyErr >= 0)
   433             itemIndex = iPresentQueue.Find( aIDArray[i] );
   528         {
   434             if(itemIndex >= 0)
   529         modifiedVal = modified->TimeValueL().Int64();
   435                 {
   530         }
   436                 iPresentQueue.Remove(itemIndex);
   531     
   437                 }
   532     // modify existing thumbs
   438             // ..and Modify Queue
   533     if (iTMSession)
   439             itemIndex = iModifyQueue.Find( aIDArray[i] );
   534         {
   440             if(itemIndex >= 0)
   535         // run as lower priority than getting but higher that creating thumbnails
   441                 {
   536         TRAPD(err, iTMSession->UpdateThumbnailsL(aObject->Id(), aObject->Uri(), orientationVal, modifiedVal, CActive::EPriorityIdle ));
   442                 iModifyQueue.Remove(itemIndex);
   537         
   443                 }
   538         if ( err != KErrNone )
   444             }  
   539             {
       
   540             TN_DEBUG2( "CThumbAGProcessor::UpdateThumbnailsL, iTMSession error == %d", err );
       
   541             
       
   542             iSessionDied = ETrue;
       
   543             iActive = EFalse;
       
   544             ActivateAO();
       
   545             } 
       
   546         else
       
   547             {
       
   548             iActive = ETrue;
       
   549             }
   445         }
   550         }
   446     else
   551     else
   447         {
   552         {
   448         // should not come here
   553         ActivateAO();
   449         TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() -  should not come here" );
   554         }
   450         return;
       
   451         }
       
   452 
       
   453     ActivateAO(); 
       
   454     
       
   455     TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - end" );
       
   456     }
       
   457 
       
   458 // ---------------------------------------------------------------------------
       
   459 // CThumbAGProcessor::CreateThumbnailsL()
       
   460 // ---------------------------------------------------------------------------
       
   461 //
       
   462 void CThumbAGProcessor::CreateThumbnailsL( const CMdEObject* aObject )
       
   463     {
       
   464     TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - begin" );
       
   465     
       
   466     if( iModify )
       
   467         {
       
   468         TInt orientationVal = 0;
       
   469         TInt64 modifiedVal = 0;
       
   470         
       
   471         CMdEProperty* orientation = NULL;
       
   472         CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );       
       
   473         TInt orientErr = aObject->Property( objDef.GetPropertyDefL( MdeConstants::Image::KOrientationProperty ), orientation, 0 );
       
   474         
       
   475         if (orientErr == KErrNone)
       
   476             {
       
   477             orientationVal = orientation->Uint16ValueL();
       
   478             }
       
   479         
       
   480         CMdEProperty* modified = NULL;
       
   481         CMdEObjectDef& objDef2 = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );       
       
   482         TInt modifyErr = aObject->Property( objDef2.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ), modified, 0 );
       
   483         
       
   484         if (modifyErr >= 0)
       
   485             {
       
   486             modifiedVal = modified->TimeValueL().Int64();
       
   487             }
       
   488         
       
   489         // modify existing thumbs
       
   490         if (iTMSession)
       
   491             {
       
   492 			// run as lower priority than getting but higher that creating thumbnails
       
   493             TRAPD(err, iTMSession->UpdateThumbnailsL(aObject->Id(), aObject->Uri(), orientationVal, modifiedVal, CActive::EPriorityIdle ));
       
   494             
       
   495             if ( err != KErrNone )
       
   496                 {
       
   497                 TN_DEBUG2( "CThumbAGProcessor::UpdateThumbnailsL, iTMSession error == %d", err );
       
   498                 
       
   499                 iSessionDied = ETrue;
       
   500                 iActive = EFalse;
       
   501                 ActivateAO();
       
   502                 } 
       
   503             else
       
   504                 {
       
   505                 iActive = ETrue;
       
   506                 }
       
   507             }
       
   508         else
       
   509             {
       
   510             ActivateAO();
       
   511             }
       
   512         
   555         
   513 #ifdef _DEBUG
   556 #ifdef _DEBUG
       
   557     if(iModify)
       
   558         {
   514         iModCounter++;
   559         iModCounter++;
       
   560         }
       
   561     else
       
   562         {
       
   563         iAddCounter++;
       
   564         }
   515 #endif     
   565 #endif     
   516         }
   566         
   517     else
       
   518         {
       
   519         CThumbnailObjectSource* source = NULL;
       
   520         CMdEProperty* mimeType = NULL;
       
   521         CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );       
       
   522         TInt mime = aObject->Property( objDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty ), mimeType, 0 );
       
   523         
       
   524         // create new thumbs
       
   525         if (mime != KErrNotFound)
       
   526             {
       
   527             source = CThumbnailObjectSource::NewLC(aObject->Uri(), aObject->Id(), mimeType->TextValueL());
       
   528             }
       
   529         else
       
   530             {
       
   531             source = CThumbnailObjectSource::NewLC(aObject->Uri(), aObject->Id());
       
   532             }
       
   533         
       
   534         if (iTMSession)
       
   535             {
       
   536             // run as very low priority task
       
   537             TInt id = iTMSession->CreateThumbnails(*source, CActive::EPriorityIdle );
       
   538             if ( id < 0 )
       
   539                 {
       
   540                 TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL, iTMSession error == %d", id );
       
   541                            
       
   542                 iSessionDied = ETrue;
       
   543                 iActive = EFalse;
       
   544                 CleanupStack::PopAndDestroy( source );
       
   545                 ActivateAO();
       
   546                 } 
       
   547            else
       
   548                 {
       
   549                 iActive = ETrue;
       
   550                 CleanupStack::PopAndDestroy( source );
       
   551                 }
       
   552             
       
   553             }
       
   554         else
       
   555             {
       
   556             ActivateAO();
       
   557             }
       
   558         
       
   559 #ifdef _DEBUG
       
   560         iAddCounter++;
       
   561 #endif
       
   562         }
       
   563     
       
   564 #ifdef _DEBUG
   567 #ifdef _DEBUG
   565     TN_DEBUG3( "CThumbAGProcessor::OUT-COUNTERS----------, Add = %d Modify = %d", 
   568     TN_DEBUG3( "CThumbAGProcessor::OUT-COUNTERS----------, Add = %d Modify = %d", 
   566                iAddCounter, iModCounter );
   569                iAddCounter, iModCounter );
   567 #endif
   570 #endif
   568    
   571    
   639     iQueryQueue.Reset();
   642     iQueryQueue.Reset();
   640     
   643     
   641     TN_DEBUG1( "CThumbAGProcessor::QueryL() - end" );
   644     TN_DEBUG1( "CThumbAGProcessor::QueryL() - end" );
   642     }
   645     }
   643 
   646 
       
   647 
       
   648 // ---------------------------------------------------------------------------
       
   649 // CThumbAGProcessor::QueryForPlaceholders()
       
   650 // ---------------------------------------------------------------------------
       
   651 //
       
   652 
       
   653 void CThumbAGProcessor::QueryPlaceholdersL()
       
   654     {
       
   655     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL" );
       
   656     
       
   657     CMdEObjectQuery::TState state(CMdEObjectQuery::EStateFirst);
       
   658     
       
   659     if( iQueryPlaceholders )
       
   660         {
       
   661         state = iQueryPlaceholders->State();
       
   662     
       
   663         if(state == CMdEObjectQuery::EStateSearching )
       
   664             {
       
   665             TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL active- skip" );
       
   666             return;
       
   667             }
       
   668         
       
   669         // delete old query
       
   670         iQueryPlaceholders->Cancel();
       
   671         delete iQueryPlaceholders;
       
   672         iQueryPlaceholders = NULL;
       
   673         }
       
   674    
       
   675     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL - start" );
       
   676 
       
   677     CMdEObjectDef& imageObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );
       
   678     CMdEObjectDef& videoObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject );
       
   679     CMdEObjectDef& audioObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject );
       
   680     
       
   681     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject);
       
   682     iQueryPlaceholders = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this );
       
   683         
       
   684     iQueryPlaceholders->SetResultMode( EQueryResultModeItem );
       
   685     
       
   686     CMdELogicCondition& rootCondition = iQueryPlaceholders->Conditions();
       
   687     rootCondition.SetOperator( ELogicConditionOperatorOr );
       
   688     
       
   689     CMdEObjectCondition& imagePHObjectCondition = rootCondition.AddObjectConditionL(imageObjDef);
       
   690     imagePHObjectCondition.SetPlaceholderOnly( ETrue );
       
   691     imagePHObjectCondition.SetNotPresent( ETrue );
       
   692     
       
   693     CMdEObjectCondition& videoPHObjectCondition = rootCondition.AddObjectConditionL(videoObjDef);
       
   694     videoPHObjectCondition.SetPlaceholderOnly( ETrue );
       
   695     videoPHObjectCondition.SetNotPresent( ETrue );
       
   696     
       
   697     CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
       
   698     audioPHObjectCondition.SetPlaceholderOnly( ETrue );
       
   699     audioPHObjectCondition.SetNotPresent( ETrue );
       
   700     
       
   701     iQueryPlaceholders->FindL();  
       
   702    
       
   703     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL - end" );
       
   704     }
       
   705 
       
   706 
   644 // ---------------------------------------------------------------------------
   707 // ---------------------------------------------------------------------------
   645 // CThumbAGProcessor::RunL()
   708 // CThumbAGProcessor::RunL()
   646 // ---------------------------------------------------------------------------
   709 // ---------------------------------------------------------------------------
   647 //
   710 //
   648 void CThumbAGProcessor::RunL()
   711 void CThumbAGProcessor::RunL()
   663         if( iHarvesterClient.Connect() == KErrNone )
   726         if( iHarvesterClient.Connect() == KErrNone )
   664             {
   727             {
   665             TN_DEBUG1( "iHarvesterClient connected");
   728             TN_DEBUG1( "iHarvesterClient connected");
   666             iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall, KMaxTInt );
   729             iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall, KMaxTInt );
   667             iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypePlaceholder, KMaxTInt );
   730             iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypePlaceholder, KMaxTInt );
       
   731             iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeMMC, KMaxTInt );
   668             TN_DEBUG1( "iHarvesterClient AddHarvesterEventObserver added");
   732             TN_DEBUG1( "iHarvesterClient AddHarvesterEventObserver added");
   669             }
   733             }
   670         
   734         
   671         TN_DEBUG1( "create MMPXCollectionUtility");
   735         TN_DEBUG1( "create MMPXCollectionUtility");
   672         iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated );
   736         iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated );
   673         TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation done" );
   737         TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation done" );
       
   738         
       
   739         iActivityManager->Start();
       
   740         
   674         return;
   741         return;
   675         }
   742         }
   676     
   743     
   677     // restart session if died
   744     // restart session if died
   678     if (!iTMSession)
   745     if (!iTMSession)
   682         TRAPD( err, iTMSession = CThumbnailManager::NewL( *this ) );
   749         TRAPD( err, iTMSession = CThumbnailManager::NewL( *this ) );
   683 		
   750 		
   684         if (err != KErrNone)
   751         if (err != KErrNone)
   685             {
   752             {
   686             iTMSession = NULL;
   753             iTMSession = NULL;
       
   754             ActivateAO();
   687             TN_DEBUG2( "CThumbAGProcessor::RunL() - Session restart failed, error == %d", err );
   755             TN_DEBUG2( "CThumbAGProcessor::RunL() - Session restart failed, error == %d", err );
   688             }        
   756             }        
   689         else {
   757         else 
       
   758             {
   690             iSessionDied = EFalse;
   759             iSessionDied = EFalse;
   691             }
   760             }
   692         }    
   761         }    
   693    
   762    
   694     // do not run if request is already issued to TNM server even if forced
   763     // do not run if request is already issued to TNM server even if forced
   710     else
   779     else
   711         {
   780         {
   712         iActiveCount = 0;   
   781         iActiveCount = 0;   
   713         }
   782         }
   714     
   783     
   715     //Iforce run can proceed from this point
   784     //force run can proceed from this point
   716     if( !iForceRun )
   785 	if( iForceRun )
   717         {
   786 	    {
   718         //check if harvesting or waiting timeout
   787 	    CancelTimeout();
   719         if( iHarvesting || iTimerActive || iMPXHarvesting )
   788 	    TN_DEBUG1( "void CThumbAGProcessor::RunL() forced run, continue!");
   720             {
   789 	    }
   721             TN_DEBUG1( "void CThumbAGProcessor::RunL() Harvester or timer active, abort");
   790 	else
       
   791 	    {
       
   792 	    if( !iLights)
       
   793 	        {
       
   794             iIdle = ETrue;
       
   795             }
       
   796         else
       
   797             {
       
   798             iIdle = IsInactive();
       
   799             }
       
   800         
       
   801         if( !iIdle || iHarvesting || iMPXHarvesting || iPeriodicTimer->IsActive() )
       
   802             {
       
   803             #ifdef _DEBUG
       
   804             TN_DEBUG5( "iIdle = %d, iHarvesting = %d, iMPXHarvesting = %d, iPeriodicTimer->IsActive() = %d", 
       
   805                     iIdle, iHarvesting, iMPXHarvesting, iPeriodicTimer->IsActive());
       
   806             #endif
       
   807             TN_DEBUG1( "void CThumbAGProcessor::RunL() device not idle");
   722             return;
   808             return;
   723             }
   809             }
   724         else
   810         else
   725             {
   811             {
   726             //check is server idle
   812             //check is server idle
   727 	        TInt idle(-1);
   813             TInt serveIdle(KErrNotFound);
   728 
   814             TInt ret = RProperty::Get(KServerIdle, KIdle, serveIdle);
   729             TInt ret = RProperty::Get(KServerIdle, KIdle, idle);
   815             
   730 	        
   816             if(ret == KErrNone )
   731 	        if(ret == KErrNone )
   817                 {
   732 	            {
   818                 if(!serveIdle)
   733 	            if(!idle)
   819                     {
   734 	                {
   820                     //start inactivity timer and retry on after callback
   735 					//start wait timer and retry on after callback
   821                     TN_DEBUG1( "void CThumbAGProcessor::RunL() server not idle");
   736 	                TN_DEBUG1( "CThumbAGProcessor::RunL() server not idle, wait... " );
   822                     StartTimeout();
   737 	                if( !iTimerActive)
   823                     return;
   738 	                    {
   824                     }
   739 	                    StartTimeout();
   825                 }
   740 	                    }
   826             TN_DEBUG1( "void CThumbAGProcessor::RunL() device and server idle, process");
   741 	                return;
   827             }
   742 	                }
   828 	    }
   743 	            }
       
   744 	        else
       
   745 	            {
       
   746 	            TN_DEBUG2( "CThumbAGProcessor::RunL() get KServerIdle failed %d, continue...", ret );
       
   747 	            }
       
   748             }
       
   749         }
       
   750     else
       
   751         {
       
   752         TN_DEBUG1( "void CThumbAGProcessor::RunL() forced run");
       
   753         }
       
   754     
       
   755     
   829     
   756     //Handle completed MDS Query
   830     //Handle completed MDS Query
   757     if( iQueryReady && iProcessingCount)
   831     if( iQueryReady && iProcessingCount)
   758         {
   832         {
   759         TInt err(KErrNone);
   833         TInt err(KErrNone);
       
   834         //if force or non forced
   760         if((iForceRun && iModify) || (!iForceRun && !iModify))
   835         if((iForceRun && iModify) || (!iForceRun && !iModify))
   761             {
   836             {
   762             TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" );
   837             TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" );
   763             
   838             
   764         
       
   765             const CMdEObject* object = &iQuery->Result( iProcessingCount-1 );
   839             const CMdEObject* object = &iQuery->Result( iProcessingCount-1 );
   766             iProcessingCount--;
   840             iProcessingCount--;
   767         
   841         
   768             // process one item at once
   842             // process one item at once
   769             if ( object )
   843             if ( object )
   770                 {
   844                 {
   771                 TRAP( err, CreateThumbnailsL(object) );
   845                 TRAP( err, CreateThumbnailsL(object) );
   772             
   846             
   773                 if ( err != KErrNone )
   847                 if ( err != KErrNone )
   774                    { 
   848                     { 
   775                    TN_DEBUG2( "CThumbAGProcessor::RunL(), CreateThumbnailsL error == %d", err );
   849                     TN_DEBUG2( "CThumbAGProcessor::RunL(), CreateThumbnailsL error == %d", err );
   776                    }
   850                     }
   777                 }
   851                 }
   778             }
   852             }
       
   853         //force is coming, but executing non-forced query complete-> cancel old
   779         else
   854         else
   780             {
   855             {
   781             TN_DEBUG1( "CThumbAGProcessor::RunL() - deleting query" );
   856             TN_DEBUG1( "CThumbAGProcessor::RunL() - deleting query" );
   782             delete iQuery;
   857             delete iQuery;
   783             iQuery = NULL;
   858             iQuery = NULL;
   801                 iForceRun = ETrue;
   876                 iForceRun = ETrue;
   802                 }
   877                 }
   803             else
   878             else
   804                 {
   879                 {
   805                 iForceRun = EFalse;
   880                 iForceRun = EFalse;
   806                 }
   881                 }   
   807                 
       
   808             }
   882             }
   809         //keep going if processing Remove items or if Add item fails
   883         //keep going if processing Remove items or if Add item fails
   810         else if( iModify || err )
   884         else if( iModify || err )
   811             {
   885             {
   812             ActivateAO();
   886             ActivateAO();
   813             }
   887             }
   814         }
   888         }
   815     //waiting for MDS query to complete
   889     //waiting for MDS query to complete
   816     else if( iQueryActive || iQueryForPlaceholdersActive )
   890     else if( iQueryActive )
   817         {
   891         {
   818         if(iForceRun && !iModify && iQueryActive)
   892         if(iForceRun && !iModify)
   819             {
   893             {
   820             iQuery->Cancel();
   894             iQuery->Cancel();
   821             delete iQuery;
   895             delete iQuery;
   822             iQuery = NULL;
   896             iQuery = NULL;
   823             TN_DEBUG1( "CThumbAGProcessor::RunL() - canceling query..." );
   897             TN_DEBUG1( "CThumbAGProcessor::RunL() - canceling query..." );
   858 #endif
   932 #endif
   859         ActivateAO();
   933         ActivateAO();
   860         }
   934         }
   861     else if ( iAddQueue.Count() > 0 )
   935     else if ( iAddQueue.Count() > 0 )
   862         {
   936         {
   863         TN_DEBUG1( "void CThumbAGProcessor::RunL() add thumbnails");
   937         TN_DEBUG1( "void CThumbAGProcessor::RunL() create thumbnails");
   864         
   938         
   865         // query for object info
   939         // query for object info
   866         iQueryActive = ETrue;
   940         iQueryActive = ETrue;
   867         
   941         
   868         QueryL( iAddQueue );     
   942         QueryL( iAddQueue );     
   869         }
   943         }
   870     else if ( iPresentQueue.Count() > 0 )
   944         
   871         {
       
   872         TN_DEBUG1( "void CThumbAGProcessor::RunL() add thumbnails for present thumbnails" );
       
   873                 
       
   874         // query for object info
       
   875         iQueryActive = ETrue;
       
   876                 
       
   877         QueryL( iPresentQueue );  
       
   878         }
       
   879     
       
   880     TN_DEBUG1( "CThumbAGProcessor::RunL() - end" );
   945     TN_DEBUG1( "CThumbAGProcessor::RunL() - end" );
   881     }
   946     }
   882 
   947 
   883 // ---------------------------------------------------------------------------
   948 // ---------------------------------------------------------------------------
   884 // CThumbAGProcessor::DoCancel()
   949 // CThumbAGProcessor::DoCancel()
   893          HarvesterEventObserverType aHEObserverType, 
   958          HarvesterEventObserverType aHEObserverType, 
   894          HarvesterEventState aHarvesterEventState,
   959          HarvesterEventState aHarvesterEventState,
   895          TInt /*aItemsLeft*/ )
   960          TInt /*aItemsLeft*/ )
   896     {
   961     {
   897     TN_DEBUG3( "CThumbAGProcessor::HarvestingUpdated -- start() aHEObserverType = %d, aHarvesterEventState = %d", aHEObserverType, aHarvesterEventState );
   962     TN_DEBUG3( "CThumbAGProcessor::HarvestingUpdated -- start() aHEObserverType = %d, aHarvesterEventState = %d", aHEObserverType, aHarvesterEventState );
   898   
   963 
       
   964     #ifdef _DEBUG
   899     if( aHEObserverType == EHEObserverTypePlaceholder)
   965     if( aHEObserverType == EHEObserverTypePlaceholder)
   900         {
   966         {
   901         TRAP_IGNORE( QueryForPlaceholdersL() );
   967         TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypePlaceholder");
   902         return;
   968         }
   903         }    
   969     else if( aHEObserverType == EHEObserverTypeOverall)
   904     
   970         {
   905     if( aHEObserverType != EHEObserverTypeOverall)
   971         TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypeOverall");
   906         {
       
   907         return;
       
   908         }
       
   909     
       
   910     switch(aHarvesterEventState)
       
   911         {
       
   912         case EHEStateStarted:
       
   913         case EHEStateHarvesting:
       
   914         case EHEStatePaused:
       
   915         case EHEStateResumed:
       
   916            {
       
   917            iHarvestingTemp = ETrue;
       
   918            break;
       
   919            }
       
   920         case EHEStateFinished:
       
   921         case EHEStateUninitialized:
       
   922            {
       
   923            iHarvestingTemp = EFalse;
       
   924            break;
       
   925            }
       
   926         };
       
   927     
       
   928     if(iHarvestingTemp == iHarvesting)
       
   929         {
       
   930         TN_DEBUG2( "CThumbAGProcessor::HarvestingUpdated -- no change %d", iHarvesting);
       
   931         }
   972         }
   932     else
   973     else
   933         {
   974         {
   934         iHarvesting = iHarvestingTemp;
   975         TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypeMMC");
   935         
   976         }
   936         if( iHarvesting )
   977     #endif
   937             {
   978     
   938             TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesterin started");
   979     //placeholder harvesting
   939             CancelTimeout();
   980     if( aHEObserverType == EHEObserverTypePlaceholder)
   940             }
   981         {
   941         else
   982         switch(aHarvesterEventState)
   942             {
   983             {
   943              TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesting finished ");
   984             case EHEStateStarted:
   944              // continue processing if needed
   985             case EHEStateHarvesting:
   945             StartTimeout();
   986             case EHEStateResumed:
   946                  
   987                 {
   947              iTempModifyQueue.Reset();
   988                 iPHHarvestingTemp = ETrue;
   948              iTempAddQueue.Reset();
   989                 break;
   949              iPlaceholderIDs.Reset();
   990                 }
   950             }
   991             case EHEStatePaused:
   951         }
   992             case EHEStateFinished:
   952 
   993             case EHEStateUninitialized:
   953     TN_DEBUG3( "CThumbAGProcessor::HarvestingUpdated -- end() iHarvesting == %d, iMPXHarvesting == %d", iHarvesting, iMPXHarvesting);
   994                 {
       
   995                 iPHHarvestingTemp = EFalse;
       
   996                 break;
       
   997                 }
       
   998             };
       
   999     
       
  1000         if(iPHHarvestingTemp != iPHHarvesting)
       
  1001             {
       
  1002             iPHHarvesting = iPHHarvestingTemp;
       
  1003            
       
  1004             if( iPHHarvesting )
       
  1005                 {
       
  1006                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS placeholder harvesterin started");
       
  1007                 }
       
  1008             else
       
  1009                 {
       
  1010                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS placeholder harvesting finished");
       
  1011                 TRAP_IGNORE(QueryPlaceholdersL());
       
  1012                 }
       
  1013             }
       
  1014         }
       
  1015     //overall harvesting
       
  1016     else if ( aHEObserverType == EHEObserverTypeOverall)
       
  1017         {
       
  1018         switch(aHarvesterEventState)
       
  1019             {
       
  1020             case EHEStateStarted:
       
  1021             case EHEStateHarvesting:
       
  1022             case EHEStatePaused:
       
  1023             case EHEStateResumed:
       
  1024                 {
       
  1025                 iHarvestingTemp = ETrue;
       
  1026                 break;
       
  1027                 }
       
  1028             case EHEStateFinished:
       
  1029             case EHEStateUninitialized:
       
  1030                 {
       
  1031                 iHarvestingTemp = EFalse;
       
  1032                 break;
       
  1033                 }
       
  1034             };
       
  1035         
       
  1036         if(iHarvestingTemp != iHarvesting)
       
  1037             {
       
  1038             iHarvesting = iHarvestingTemp;
       
  1039             
       
  1040             if( iHarvesting )
       
  1041                 {
       
  1042                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesterin started");
       
  1043                 CancelTimeout();
       
  1044                 }
       
  1045             else
       
  1046                 {
       
  1047                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesting finished ");
       
  1048                 // continue processing if needed
       
  1049                 StartTimeout();
       
  1050                 }
       
  1051             }
       
  1052         }
       
  1053     else if( aHEObserverType == EHEObserverTypeMMC)
       
  1054         {
       
  1055         switch(aHarvesterEventState)
       
  1056             {
       
  1057             case EHEStateStarted:
       
  1058             case EHEStateHarvesting:
       
  1059             case EHEStateResumed:
       
  1060                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MMC harvesting started ");
       
  1061                 break;
       
  1062             case EHEStateFinished:
       
  1063                 TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MMC harvesting finished ");
       
  1064                 TRAP_IGNORE(QueryAllItemsL());
       
  1065             break;
       
  1066             };
       
  1067         }
       
  1068 
       
  1069     TN_DEBUG3( "CThumbAGProcessor::HarvestingUpdated -- end() iHarvesting == %d, iPHHarvesting == %d ", iHarvesting, iPHHarvesting);
   954     }
  1070     }
   955 
  1071 
   956 // ---------------------------------------------------------------------------
  1072 // ---------------------------------------------------------------------------
   957 // CThumbAGProcessor::StartTimeout()
  1073 // CThumbAGProcessor::StartTimeout()
   958 // ---------------------------------------------------------------------------
  1074 // ---------------------------------------------------------------------------
   959 //
  1075 //
   960 void CThumbAGProcessor::StartTimeout()
  1076 void CThumbAGProcessor::StartTimeout()
   961     {
  1077     {
       
  1078     TN_DEBUG1( "CThumbAGProcessor::StartTimeout()");
   962     CancelTimeout();
  1079     CancelTimeout();
   963     
  1080     
   964     if(!iHarvesting && !iMPXHarvesting && !iPeriodicTimer->IsActive())
  1081     if(!iHarvesting && !iMPXHarvesting && !iPeriodicTimer->IsActive())
   965         {
  1082         {
   966         iPeriodicTimer->Start( KHarvestingCompleteTimeout, KHarvestingCompleteTimeout, 
  1083         iPeriodicTimer->Start( KHarvestingCompleteTimeout, KHarvestingCompleteTimeout,
   967                 TCallBack(PeriodicTimerCallBack, this));
  1084                 TCallBack(PeriodicTimerCallBack, this));
   968         iTimerActive = ETrue;
       
   969         }
       
   970     else
       
   971         {
       
   972         iTimerActive = EFalse;
       
   973         }
  1085         }
   974     }
  1086     }
   975 
  1087 
   976 // ---------------------------------------------------------------------------
  1088 // ---------------------------------------------------------------------------
   977 // CThumbAGProcessor::StopTimeout()
  1089 // CThumbAGProcessor::StopTimeout()
   978 // ---------------------------------------------------------------------------
  1090 // ---------------------------------------------------------------------------
   979 //
  1091 //
   980 void CThumbAGProcessor::CancelTimeout()
  1092 void CThumbAGProcessor::CancelTimeout()
   981     {
  1093     {
   982     if(iTimerActive)
  1094     if(iPeriodicTimer->IsActive())
   983        {
  1095         {
   984        iPeriodicTimer->Cancel();
  1096         iPeriodicTimer->Cancel();
   985        }
  1097         }
   986     iTimerActive = EFalse;
       
   987     }
  1098     }
   988 
  1099 
   989 // ---------------------------------------------------------------------------
  1100 // ---------------------------------------------------------------------------
   990 // CThumbAGProcessor::RunError()
  1101 // CThumbAGProcessor::RunError()
   991 // ---------------------------------------------------------------------------
  1102 // ---------------------------------------------------------------------------
   992 //
  1103 //
   993 TInt CThumbAGProcessor::RunError(TInt aError)
  1104 TInt CThumbAGProcessor::RunError(TInt aError)
   994     {
  1105     {
       
  1106     TN_DEBUG1( "CThumbAGProcessor::RunError()");
   995     if (aError != KErrNone)
  1107     if (aError != KErrNone)
   996         {
  1108         {
   997         TN_DEBUG2( "CThumbAGProcessor::RunError = %d", aError );
  1109         TN_DEBUG2( "CThumbAGProcessor::RunError = %d", aError );
   998         }
  1110         }
   999     
  1111     
  1007 // CThumbAGProcessor::ActivateAO()
  1119 // CThumbAGProcessor::ActivateAO()
  1008 // ---------------------------------------------------------------------------
  1120 // ---------------------------------------------------------------------------
  1009 //
  1121 //
  1010 void CThumbAGProcessor::ActivateAO()
  1122 void CThumbAGProcessor::ActivateAO()
  1011     {
  1123     {
       
  1124 #ifdef _DEBUG
       
  1125     TN_DEBUG6( "CThumbAGProcessor::Items in queue Add = %d, Mod = %d, Del = %d, Query = %d, iPlaceholder = %d", iAddQueue.Count(),  iModifyQueue.Count(), iRemoveQueue.Count(), iQueryQueue.Count(), iPlaceholderQueue.Count());
       
  1126 #endif
       
  1127     
  1012     if(iFormatting)
  1128     if(iFormatting)
  1013         {
  1129         {
  1014         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE");
  1130         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE");
  1015         return;
  1131         return;
  1016         }
  1132         }
  1017         
  1133         
  1018     if( !IsActive() && (!iHarvesting || iForceRun ))
  1134     if( !IsActive() )
  1019         {
  1135         {
  1020 #ifdef _DEBUG
  1136 #ifdef _DEBUG
  1021         if( iForceRun )
  1137         if( iForceRun )
  1022             {
  1138             {
  1023             TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - *** FORCED RUN ***");
  1139             TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - *** FORCED RUN ***");
  1061     TBool audioGrid( EFalse );
  1177     TBool audioGrid( EFalse );
  1062     TBool audioList( EFalse );
  1178     TBool audioList( EFalse );
  1063     TBool audioFull( EFalse );
  1179     TBool audioFull( EFalse );
  1064 
  1180 
  1065     // get cenrep values
  1181     // get cenrep values
  1066     rep->Get( KAutoCreateImageGrid, imageGrid );
  1182     TInt ret = rep->Get( KAutoCreateImageGrid, imageGrid );
  1067     rep->Get( KAutoCreateImageList, imageList );
  1183     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateImageGrid %d", ret);
  1068     rep->Get( KAutoCreateImageFullscreen, imageFull );
  1184     ret = rep->Get( KAutoCreateImageList, imageList );
  1069     rep->Get( KAutoCreateVideoGrid, videoGrid );
  1185     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateImageList %d", ret);
  1070     rep->Get( KAutoCreateVideoList, videoList );
  1186     ret = rep->Get( KAutoCreateImageFullscreen, imageFull );
  1071     rep->Get( KAutoCreateVideoFullscreen, videoFull );
  1187     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateImageFullscreen %d", ret);
  1072     rep->Get( KAutoCreateAudioGrid, audioGrid );
  1188     ret = rep->Get( KAutoCreateVideoGrid, videoGrid );
  1073     rep->Get( KAutoCreateAudioList, audioList );
  1189     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateVideoGrid %d", ret);
  1074     rep->Get( KAutoCreateAudioFullscreen, audioFull );
  1190     ret = rep->Get( KAutoCreateVideoList, videoList );
       
  1191     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateVideoList %d", ret);
       
  1192     ret = rep->Get( KAutoCreateVideoFullscreen, videoFull );
       
  1193     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateVideoFullscreen %d", ret);
       
  1194     ret = rep->Get( KAutoCreateAudioGrid, audioGrid );
       
  1195     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateAudioGrid %d", ret);
       
  1196     ret = rep->Get( KAutoCreateAudioList, audioList );
       
  1197     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateAudioList %d", ret);
       
  1198     ret = rep->Get( KAutoCreateAudioFullscreen, audioFull );
       
  1199     TN_DEBUG2( "CThumbAGProcessor::CheckAutoCreateValuesL() KAutoCreateAudioFullscreen %d", ret);
  1075     
  1200     
  1076     iAutoImage = EFalse;
  1201     iAutoImage = EFalse;
  1077     iAutoVideo = EFalse;
  1202     iAutoVideo = EFalse;
  1078     iAutoAudio = EFalse;
  1203     iAutoAudio = EFalse;
  1079     
  1204     
  1105     TInt itemIndex = KErrNotFound;
  1230     TInt itemIndex = KErrNotFound;
  1106     
  1231     
  1107     for (int i=0; i< aIDArray.Count(); i++)
  1232     for (int i=0; i< aIDArray.Count(); i++)
  1108         {
  1233         {
  1109         TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]);
  1234         TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]);
       
  1235         
       
  1236         itemIndex = iPlaceholderQueue.Find( aIDArray[i] );
       
  1237                          
       
  1238         if(itemIndex >= 0)
       
  1239             {
       
  1240             iPlaceholderQueue.Remove(itemIndex);
       
  1241             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPlaceholderQueue" );
       
  1242             }
  1110                 
  1243                 
  1111         itemIndex = iAddQueue.Find( aIDArray[i] );
  1244         itemIndex = iAddQueue.Find( aIDArray[i] );
  1112         
  1245         
  1113         if(itemIndex >= 0)
  1246         if(itemIndex >= 0)
  1114             {
  1247             {
  1115             iAddQueue.Remove(itemIndex);
  1248             iAddQueue.Remove(itemIndex);
  1116             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iAddQueue" );
  1249             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iAddQueue" );
  1117             continue;
  1250             continue;
  1118             }
  1251             }
  1119         
  1252         
  1120         itemIndex = iPresentQueue.Find( aIDArray[i] );
       
  1121                 
       
  1122         if(itemIndex >= 0)
       
  1123             {
       
  1124             iPresentQueue.Remove(itemIndex);
       
  1125             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPresentQueue" );
       
  1126             continue;
       
  1127             }
       
  1128    
       
  1129         itemIndex = iModifyQueue.Find( aIDArray[i] );
  1253         itemIndex = iModifyQueue.Find( aIDArray[i] );
  1130          
  1254          
  1131         if(itemIndex >= 0)
  1255         if(itemIndex >= 0)
  1132            {
  1256             {
  1133            iModifyQueue.Remove(itemIndex);
  1257             iModifyQueue.Remove(itemIndex);
  1134            TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iModifyQueue" );
  1258             TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iModifyQueue" );
  1135 			 
  1259 			 
  1136            if( iModifyQueue.Count() == 0)
  1260             if( iModifyQueue.Count() == 0)
  1137 			  {
  1261 			    {
  1138 			  iForceRun = EFalse;
  1262 			    iForceRun = EFalse;
  1139 		      }
  1263 		        }
  1140 			 
  1264 			 
  1141            continue;
  1265             continue;
  1142            }
  1266             }
  1143     
  1267     
  1144         if( aRemoveFromDelete )
  1268         if( aRemoveFromDelete )
  1145            {
  1269             {
  1146            itemIndex = iRemoveQueue.Find( aIDArray[i] );
  1270             itemIndex = iRemoveQueue.Find( aIDArray[i] );
  1147              
  1271              
  1148            if(itemIndex >= 0)
  1272             if(itemIndex >= 0)
  1149               {
  1273                 {
  1150               iRemoveQueue.Remove(itemIndex);
  1274                 iRemoveQueue.Remove(itemIndex);
  1151               TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iRemoveQueue" );
  1275                 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iRemoveQueue" );
  1152               continue;
  1276                 continue;
  1153               }
  1277                 }
  1154            }
  1278             }
  1155         }
  1279         }
  1156     
  1280     
  1157     TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - end" );
  1281     TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - end" );
  1158     }
  1282     }
  1159 	
  1283 	
  1171         iForceRun = aForceRun;
  1295         iForceRun = aForceRun;
  1172         }
  1296         }
  1173     }
  1297     }
  1174 
  1298 
  1175 // ---------------------------------------------------------------------------
  1299 // ---------------------------------------------------------------------------
  1176 // CThumbAGProcessor::SetFormat()
       
  1177 // ---------------------------------------------------------------------------
       
  1178 //
       
  1179 
       
  1180 void CThumbAGProcessor::SetFormat(TBool aStatus)
       
  1181     {
       
  1182     TN_DEBUG2( "CThumbAGProcessor::SetFormat(%d) - end", aStatus );
       
  1183     
       
  1184     iFormatting = aStatus;
       
  1185     if(!aStatus)
       
  1186         {
       
  1187         ActivateAO();
       
  1188         }
       
  1189     }
       
  1190 
       
  1191 // ---------------------------------------------------------------------------
       
  1192 // CThumbAGProcessor::QueryForPlaceholders()
  1300 // CThumbAGProcessor::QueryForPlaceholders()
  1193 // ---------------------------------------------------------------------------
  1301 // ---------------------------------------------------------------------------
  1194 //
  1302 //
  1195 
  1303 void CThumbAGProcessor::QueryAllItemsL()
  1196 void CThumbAGProcessor::QueryForPlaceholdersL()
  1304     {
  1197     {
  1305     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL" );
  1198     TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders" );
  1306     
  1199     if(iQueryForPlaceholdersActive)
  1307     CMdEObjectQuery::TState state(CMdEObjectQuery::EStateFirst);
  1200         {
  1308     
  1201         TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders - skip" );
  1309     if( iQueryAllItems )
  1202         return;
  1310         {
  1203         }
  1311         state = iQueryAllItems->State();
  1204     
  1312     
  1205     TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders - start" );
  1313         if(state == CMdEObjectQuery::EStateSearching )
  1206 
  1314             {
  1207     // delete old query
  1315             TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL active- skip" );
  1208     if (iQueryForPlaceholders)
  1316             return;
  1209        {
  1317             }
  1210        iQueryForPlaceholdersActive = EFalse;
  1318         
  1211        iQueryForPlaceholders->Cancel();
  1319         // delete old query
  1212        delete iQueryForPlaceholders;
  1320         iQueryAllItems->Cancel();
  1213        iQueryForPlaceholders = NULL;
  1321         delete iQueryAllItems;
  1214        }
  1322         iQueryAllItems = NULL;
       
  1323         }
       
  1324     
       
  1325     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL - start" );
  1215     
  1326     
  1216     CMdEObjectDef& imageObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );
  1327     CMdEObjectDef& imageObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );
  1217     CMdEObjectDef& videoObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject );
  1328     CMdEObjectDef& videoObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject );
  1218     CMdEObjectDef& audioObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject );
  1329     CMdEObjectDef& audioObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject );
  1219     
  1330     
  1220     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject);
  1331     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject);
  1221     iQueryForPlaceholders = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this );
  1332     iQueryAllItems = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this );
  1222         
  1333         
  1223     iQueryForPlaceholders->SetResultMode( EQueryResultModeItem );
  1334     iQueryAllItems->SetResultMode( EQueryResultModeItem );
  1224     
  1335     
  1225     CMdELogicCondition& rootCondition = iQueryForPlaceholders->Conditions();
  1336     CMdELogicCondition& rootCondition = iQueryAllItems->Conditions();
  1226     rootCondition.SetOperator( ELogicConditionOperatorOr );
  1337     rootCondition.SetOperator( ELogicConditionOperatorOr );
  1227     
  1338     
  1228     CMdEObjectCondition& imagePHObjectCondition = rootCondition.AddObjectConditionL(imageObjDef);
  1339     CMdEObjectCondition& imagePHObjectCondition = rootCondition.AddObjectConditionL(imageObjDef);
  1229     imagePHObjectCondition.SetPlaceholderOnly( ETrue );
       
  1230     imagePHObjectCondition.SetNotPresent( ETrue );
       
  1231     
  1340     
  1232     CMdEObjectCondition& videoPHObjectCondition = rootCondition.AddObjectConditionL(videoObjDef);
  1341     CMdEObjectCondition& videoPHObjectCondition = rootCondition.AddObjectConditionL(videoObjDef);
  1233     videoPHObjectCondition.SetPlaceholderOnly( ETrue );
       
  1234     videoPHObjectCondition.SetNotPresent( ETrue );
       
  1235     
  1342     
  1236     CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
  1343     CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
  1237     audioPHObjectCondition.SetPlaceholderOnly( ETrue );
  1344     
  1238     audioPHObjectCondition.SetNotPresent( ETrue );
  1345     iQueryAllItems->FindL();  
  1239     
  1346     
  1240     iQueryForPlaceholders->FindL();  
  1347     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL - end" );
  1241     
       
  1242     iQueryForPlaceholdersActive = ETrue;
       
  1243     
       
  1244     TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders - end" );
       
  1245     }
  1348     }
  1246 
  1349 
  1247 // -----------------------------------------------------------------------------
  1350 // -----------------------------------------------------------------------------
  1248 // CThumbAGProcessor::HandleCollectionMessage
  1351 // CThumbAGProcessor::HandleCollectionMessage
  1249 // From MMPXCollectionObserver
  1352 // From MMPXCollectionObserver
  1250 // Handle collection message.
  1353 // Handle collection message.
  1251 // -----------------------------------------------------------------------------
  1354 // -----------------------------------------------------------------------------
  1252 //
  1355 //
  1253 
  1356 void CThumbAGProcessor::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError )
  1254 void CThumbAGProcessor::HandleCollectionMessage( CMPXMessage* aMessage,
       
  1255                                                         TInt aError )
       
  1256     {
  1357     {
  1257     if ( aError != KErrNone || !aMessage )
  1358     if ( aError != KErrNone || !aMessage )
  1258         {
  1359         {
  1259         return;
  1360         return;
  1260         }
  1361         }
  1269         TInt event( *aMessage->Value<TInt>( KMPXMessageGeneralEvent ) );
  1370         TInt event( *aMessage->Value<TInt>( KMPXMessageGeneralEvent ) );
  1270         if ( event == TMPXCollectionMessage::EBroadcastEvent )
  1371         if ( event == TMPXCollectionMessage::EBroadcastEvent )
  1271             {
  1372             {
  1272             TInt op( *aMessage->Value<TInt>( KMPXMessageGeneralType ) );
  1373             TInt op( *aMessage->Value<TInt>( KMPXMessageGeneralType ) );
  1273                
  1374                
  1274            switch( op )
  1375             switch( op )
  1275                {
  1376                 {
  1276 			   //when MTP sync or music collection is started then pause processing
  1377 			    //when MTP sync or music collection is started then pause processing
  1277                case EMcMsgRefreshStart:
  1378                 case EMcMsgRefreshStart:
  1278                case EMcMsgUSBMTPStart:
  1379                 case EMcMsgUSBMTPStart:
  1279                    TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh started" );
  1380                     TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh started" );
  1280                    iMPXHarvesting = ETrue;
  1381                     iMPXHarvesting = ETrue;
  1281                    CancelTimeout();
  1382                     CancelTimeout();
  1282                    break;
  1383                     break;
  1283 			   //when MTP sync or music collection refresh is complete then resume processing
  1384 			    //when MTP sync or music collection refresh is complete then resume processing
  1284                case EMcMsgRefreshEnd:
  1385                 case EMcMsgRefreshEnd:
  1285                case EMcMsgUSBMTPEnd:
  1386                 case EMcMsgUSBMTPEnd:
  1286                case EMcMsgUSBMTPNotActive:
  1387                 case EMcMsgUSBMTPNotActive:
  1287                    TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh finished/not active" );
  1388                     TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh finished/not active" );
  1288                    iMPXHarvesting = EFalse;
  1389                     iMPXHarvesting = EFalse;
  1289                    StartTimeout();
  1390                     StartTimeout();
  1290                    break;
  1391                     break;
  1291                default:
  1392                 default:
  1292                    break;
  1393                     break;
  1293                }
  1394                 }
  1294            TN_DEBUG3( "CThumbAGProcessor::HandleCollectionMessage -- end() iHarvesting == %d, iMPXHarvesting == %d", iHarvesting, iMPXHarvesting);
  1395             TN_DEBUG3( "CThumbAGProcessor::HandleCollectionMessage -- end() iHarvesting == %d, iMPXHarvesting == %d", iHarvesting, iMPXHarvesting);
  1295             }
  1396             }
  1296         }
  1397         }
  1297     }
  1398     }
       
  1399 
  1298 // -----------------------------------------------------------------------------
  1400 // -----------------------------------------------------------------------------
  1299 // CThumbAGProcessor::HandleOpenL
  1401 // CThumbAGProcessor::HandleOpenL
  1300 // From MMPXCollectionObserver
  1402 // From MMPXCollectionObserver
  1301 // Handles the collection entries being opened.
  1403 // Handles the collection entries being opened.
  1302 // -----------------------------------------------------------------------------
  1404 // -----------------------------------------------------------------------------
  1303 //
  1405 //
  1304 void CThumbAGProcessor::HandleOpenL( const CMPXMedia& /*aEntries*/,
  1406 void CThumbAGProcessor::HandleOpenL( const CMPXMedia& /*aEntries*/, TInt /*aIndex*/,
  1305                                             TInt /*aIndex*/,
  1407                                                TBool /*aComplete*/, TInt /*aError*/ )
  1306                                             TBool /*aComplete*/,
       
  1307                                             TInt /*aError*/ )
       
  1308      {
  1408      {
  1309      // not needed here
  1409      // not needed here
  1310      }
  1410      }
  1311 
  1411 
  1312 // -----------------------------------------------------------------------------
  1412 // -----------------------------------------------------------------------------
  1328 void CThumbAGProcessor::HandleCollectionMediaL( const CMPXMedia& /*aMedia*/,
  1428 void CThumbAGProcessor::HandleCollectionMediaL( const CMPXMedia& /*aMedia*/,
  1329                                                        TInt /*aError*/ )
  1429                                                        TInt /*aError*/ )
  1330     {
  1430     {
  1331     // not needed here
  1431     // not needed here
  1332     }
  1432     }
       
  1433 	
       
  1434 // -----------------------------------------------------------------------------
       
  1435 // LightStatusChanged()
       
  1436 // -----------------------------------------------------------------------------
       
  1437 //
       
  1438 void CThumbAGProcessor::LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus)
       
  1439     {
       
  1440     TN_DEBUG3( "void CThumbAGProcessor::LightStatusChanged() aTarget == %d, aStatus == %d", aTarget, aStatus);
       
  1441     
       
  1442      if( aStatus == CHWRMLight::ELightOff)
       
  1443         {
       
  1444         TN_DEBUG1( "void CThumbAGProcessor::LightStatusChanged() -- OFF");
       
  1445         iLights = EFalse;
       
  1446 		
       
  1447         if(iAddQueue.Count() + iModifyQueue.Count() + iRemoveQueue.Count() > 0 )
       
  1448             {
       
  1449             ActivateAO();
       
  1450             }
       
  1451         }
       
  1452     else
       
  1453         {
       
  1454         TN_DEBUG1( "void CThumbAGProcessor::LightStatusChanged() -- ON");
       
  1455         iLights = ETrue;
       
  1456         }
       
  1457     }
       
  1458 
       
  1459 // -----------------------------------------------------------------------------
       
  1460 // IsInactive()
       
  1461 // -----------------------------------------------------------------------------
       
  1462 //
       
  1463 TBool CThumbAGProcessor::IsInactive()
       
  1464     {
       
  1465 #ifdef _DEBUG
       
  1466 TN_DEBUG2( "CThumbAGProcessor::IsInactive()= %d", User::InactivityTime().Int());
       
  1467 #endif
       
  1468 
       
  1469     if( User::InactivityTime() < TTimeIntervalSeconds(KBackgroundGenerationIdle) )
       
  1470       {
       
  1471       return EFalse;
       
  1472       }
       
  1473     return ETrue;
       
  1474     }
       
  1475 
       
  1476 // -----------------------------------------------------------------------------
       
  1477 // ActivityDetected()
       
  1478 // -----------------------------------------------------------------------------
       
  1479 //
       
  1480 void CThumbAGProcessor::ActivityDetected()
       
  1481     {
       
  1482     iIdle = EFalse;
       
  1483     }
       
  1484 
       
  1485 // -----------------------------------------------------------------------------
       
  1486 // InactivityDetected()
       
  1487 // -----------------------------------------------------------------------------
       
  1488 //
       
  1489 void CThumbAGProcessor::InactivityDetected()
       
  1490     {
       
  1491     iIdle = ETrue; 
       
  1492     
       
  1493     if(iAddQueue.Count() + iModifyQueue.Count() + iRemoveQueue.Count() > 0 )
       
  1494         {
       
  1495         ActivateAO();
       
  1496         }
       
  1497     }
       
  1498 
       
  1499 // ---------------------------------------------------------------------------
       
  1500 // CThumbAGProcessor::FormatNotification
       
  1501 // Handles a format operation
       
  1502 // ---------------------------------------------------------------------------
       
  1503 //
       
  1504 void CThumbAGProcessor::FormatNotification( TBool aFormat )
       
  1505     {
       
  1506     TN_DEBUG2( "CThumbAGProcessor::FormatNotification(%d)", aFormat );
       
  1507     
       
  1508     iFormatting = aFormat;
       
  1509     if(!aFormat)
       
  1510         {
       
  1511         ActivateAO();
       
  1512         }
       
  1513     }
       
  1514 
  1333 
  1515 
  1334 // End of file
  1516 // End of file