imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp
branchRCL_3
changeset 28 ff2fb7658ff7
parent 24 f0aa341a25bf
child 37 f759b6186ab5
equal deleted inserted replaced
24:f0aa341a25bf 28:ff2fb7658ff7
    63 //
    63 //
    64 void CThumbAGProcessor::ConstructL()
    64 void CThumbAGProcessor::ConstructL()
    65     {
    65     {
    66     TN_DEBUG1( "CThumbAGProcessor::ConstructL() - begin" );
    66     TN_DEBUG1( "CThumbAGProcessor::ConstructL() - begin" );
    67     
    67     
       
    68     iShutdown = EFalse;
       
    69     
    68     iTMSession = CThumbnailManager::NewL( *this );
    70     iTMSession = CThumbnailManager::NewL( *this );
    69     iTMSession->SetRequestObserver(*this);
    71     iTMSession->SetRequestObserver(*this);
    70     
    72     
    71     iQueryAllItems = NULL;
    73     iQueryAllItems = NULL;
    72     iQueryPlaceholders = NULL;
    74     iQueryPlaceholders = NULL;
   110 //
   112 //
   111 CThumbAGProcessor::~CThumbAGProcessor()
   113 CThumbAGProcessor::~CThumbAGProcessor()
   112     {
   114     {
   113     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - begin" );
   115     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - begin" );
   114     
   116     
       
   117     Shutdown();
       
   118     
   115     Cancel();
   119     Cancel();
   116     
   120     
   117     if(iPeriodicTimer)
   121     if(iPeriodicTimer)
   118         {
   122         {
   119         iPeriodicTimer->Cancel();
   123         iPeriodicTimer->Cancel();
   120         delete iPeriodicTimer;
   124         delete iPeriodicTimer;
       
   125         iPeriodicTimer = NULL;
   121         }
   126         }
   122     
   127     
   123     if(iActivityManager)
   128     if(iActivityManager)
   124         {
   129         {
   125         delete iActivityManager;
   130         delete iActivityManager;
   189         }
   194         }
   190     
   195     
   191     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - end" );
   196     TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - end" );
   192     }
   197     }
   193 
   198 
       
   199 // ---------------------------------------------------------------------------
       
   200 // CThumbAGProcessor::Shutdown()
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 void CThumbAGProcessor::Shutdown()
       
   204     {
       
   205     TN_DEBUG1( "CThumbAGProcessor::Shutdown()" );
       
   206     iShutdown = ETrue;
       
   207     UpdatePSValues();
       
   208     }
       
   209 
   194 // -----------------------------------------------------------------------------
   210 // -----------------------------------------------------------------------------
   195 // CThumbAGProcessor::HandleQueryNewResults()
   211 // CThumbAGProcessor::HandleQueryNewResults()
   196 // -----------------------------------------------------------------------------
   212 // -----------------------------------------------------------------------------
   197 //
   213 //
   198 void CThumbAGProcessor::HandleQueryNewResults( CMdEQuery& aQuery,
   214 void CThumbAGProcessor::HandleQueryNewResults( CMdEQuery& aQuery,
   199                                                const TInt aFirstNewItemIndex,
   215                                                const TInt aFirstNewItemIndex,
   200                                                const TInt aNewItemCount )
   216                                                const TInt aNewItemCount )
   201     {
   217     {
   202     // PH & AllItems query results are handled here
   218     // PH & AllItems query results are handled here
       
   219     
       
   220     if(iShutdown)
       
   221         {
       
   222         return;
       
   223         }
       
   224     
   203     if (aNewItemCount > 0)
   225     if (aNewItemCount > 0)
   204         {
   226         {
   205         if(&aQuery == iQueryPlaceholders)
   227         if(&aQuery == iQueryPlaceholders)
   206             {
   228             {
   207             TN_DEBUG2( "CThumbAGProcessor::HandleQueryNewResults - iQueryPlaceholders, %d new", aNewItemCount);
   229             TN_DEBUG2( "CThumbAGProcessor::HandleQueryNewResults - iQueryPlaceholders, %d new", aNewItemCount);
   258 // -----------------------------------------------------------------------------
   280 // -----------------------------------------------------------------------------
   259 //
   281 //
   260 void CThumbAGProcessor::HandleQueryCompleted( CMdEQuery& aQuery, const TInt aError )
   282 void CThumbAGProcessor::HandleQueryCompleted( CMdEQuery& aQuery, const TInt aError )
   261     {
   283     {
   262     TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompleted, aError == %d Count== %d", aError, aQuery.Count());
   284     TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompleted, aError == %d Count== %d", aError, aQuery.Count());
       
   285     
       
   286     if(iShutdown)
       
   287         {
       
   288         return;
       
   289         }
   263     
   290     
   264     if(&aQuery == iQueryPlaceholders)
   291     if(&aQuery == iQueryPlaceholders)
   265         {
   292         {
   266         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - iQueryPlaceholders completed");
   293         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - iQueryPlaceholders completed");
   267         
   294         
   735     TN_DEBUG1( "CThumbAGProcessor::QueryL() - begin" );
   762     TN_DEBUG1( "CThumbAGProcessor::QueryL() - begin" );
   736     
   763     
   737     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryL() !iMdeSession "), KErrBadHandle));
   764     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryL() !iMdeSession "), KErrBadHandle));
   738     __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::QueryL() !iDefNamespace "), KErrBadHandle));
   765     __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::QueryL() !iDefNamespace "), KErrBadHandle));
   739     
   766     
   740     if(!iMdESession  || !iDefNamespace)
   767     if(!iMdESession  || !iDefNamespace || iShutdown)
   741         {
   768         {
   742         return;
   769         return;
   743         }
   770         }
   744     
   771     
   745 	//reset query queue
   772 	//reset query queue
   820     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL" );
   847     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL" );
   821     
   848     
   822     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryPlaceholdersL() !iMdeSession "), KErrBadHandle));
   849     __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryPlaceholdersL() !iMdeSession "), KErrBadHandle));
   823     __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::QueryPlaceholdersL() !iDefNamespace "), KErrBadHandle));
   850     __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::QueryPlaceholdersL() !iDefNamespace "), KErrBadHandle));
   824     
   851     
   825     if(!iMdESession  || !iDefNamespace)
   852     if(!iMdESession  || !iDefNamespace || iShutdown)
   826          {
   853          {
   827          return;
   854          return;
   828          }
   855          }
   829     
   856     
   830     if( iQueryPlaceholders )
   857     if( iQueryPlaceholders )
   878 // ---------------------------------------------------------------------------
   905 // ---------------------------------------------------------------------------
   879 //
   906 //
   880 void CThumbAGProcessor::RunL()
   907 void CThumbAGProcessor::RunL()
   881     {
   908     {
   882     TN_DEBUG1( "CThumbAGProcessor::RunL() - begin" );
   909     TN_DEBUG1( "CThumbAGProcessor::RunL() - begin" );
       
   910 	
       
   911 	if(iShutdown)
       
   912 		{
       
   913         TN_DEBUG1( "CThumbAGProcessor::RunL() - shutdown" );
       
   914 		return;
       
   915 		}
   883     
   916     
   884     if (iSessionDied)
   917     if (iSessionDied)
   885         {
   918         {
   886         TN_DEBUG1( "CThumbAGProcessor::RunL() - iSessionDied" );
   919         TN_DEBUG1( "CThumbAGProcessor::RunL() - iSessionDied" );
   887         delete iTMSession;
   920         delete iTMSession;
  1207          HarvesterEventObserverType aHEObserverType, 
  1240          HarvesterEventObserverType aHEObserverType, 
  1208          HarvesterEventState aHarvesterEventState,
  1241          HarvesterEventState aHarvesterEventState,
  1209          TInt /*aItemsLeft*/ )
  1242          TInt /*aItemsLeft*/ )
  1210     {
  1243     {
  1211     TN_DEBUG3( "CThumbAGProcessor::HarvestingUpdated -- start() aHEObserverType = %d, aHarvesterEventState = %d", aHEObserverType, aHarvesterEventState );
  1244     TN_DEBUG3( "CThumbAGProcessor::HarvestingUpdated -- start() aHEObserverType = %d, aHarvesterEventState = %d", aHEObserverType, aHarvesterEventState );
       
  1245     
       
  1246     if(iShutdown)
       
  1247         {
       
  1248         return;
       
  1249         }
  1212 
  1250 
  1213     #ifdef _DEBUG
  1251     #ifdef _DEBUG
  1214     if( aHEObserverType == EHEObserverTypePlaceholder)
  1252     if( aHEObserverType == EHEObserverTypePlaceholder)
  1215         {
  1253         {
  1216         TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypePlaceholder");
  1254         TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- type EHEObserverTypePlaceholder");
  1346 void CThumbAGProcessor::StartTimeout()
  1384 void CThumbAGProcessor::StartTimeout()
  1347     {
  1385     {
  1348     TN_DEBUG1( "CThumbAGProcessor::StartTimeout()");
  1386     TN_DEBUG1( "CThumbAGProcessor::StartTimeout()");
  1349     CancelTimeout();
  1387     CancelTimeout();
  1350     
  1388     
  1351     if(!iHarvesting && !iMPXHarvesting && !iPeriodicTimer->IsActive())
  1389     if(!iHarvesting && !iMPXHarvesting && !iPeriodicTimer->IsActive() && !iShutdown)
  1352         {
  1390         {
  1353         iPeriodicTimer->Start( KHarvestingCompleteTimeout, KHarvestingCompleteTimeout,
  1391         iPeriodicTimer->Start( KHarvestingCompleteTimeout, KHarvestingCompleteTimeout,
  1354                 TCallBack(PeriodicTimerCallBack, this));
  1392                 TCallBack(PeriodicTimerCallBack, this));
  1355         }
  1393         }
  1356     }
  1394     }
  1425         {
  1463         {
  1426         iModify = EFalse;
  1464         iModify = EFalse;
  1427         SetForceRun( EFalse );
  1465         SetForceRun( EFalse );
  1428         }
  1466         }
  1429     
  1467     
  1430     if( !IsActive() && ((!iActive && !iQueryActive) || iForceRun ))
  1468     if( !IsActive() && !iShutdown && ((!iActive && !iQueryActive) || iForceRun ))
  1431         {
  1469         {
  1432         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - Activated");
  1470         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - Activated");
  1433         SetActive();
  1471         SetActive();
  1434         TRequestStatus* statusPtr = &iStatus;
  1472         TRequestStatus* statusPtr = &iStatus;
  1435         User::RequestComplete( statusPtr, KErrNone );
  1473         User::RequestComplete( statusPtr, KErrNone );
  1653 // Handle collection message.
  1691 // Handle collection message.
  1654 // -----------------------------------------------------------------------------
  1692 // -----------------------------------------------------------------------------
  1655 //
  1693 //
  1656 void CThumbAGProcessor::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError )
  1694 void CThumbAGProcessor::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError )
  1657     {
  1695     {
  1658     if ( aError != KErrNone || !aMessage )
  1696     if ( aError != KErrNone || !aMessage || iShutdown )
  1659         {
  1697         {
  1660         return;
  1698         return;
  1661         }
  1699         }
  1662     
  1700     
  1663     TMPXMessageId generalId( *aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ) );
  1701     TMPXMessageId generalId( *aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ) );
  1813 void CThumbAGProcessor::UpdatePSValues(const TBool aDefine)
  1851 void CThumbAGProcessor::UpdatePSValues(const TBool aDefine)
  1814     {
  1852     {
  1815     TInt itemsLeft = iModifyQueue.Count() + iAddQueue.Count();
  1853     TInt itemsLeft = iModifyQueue.Count() + iAddQueue.Count();
  1816     TBool daemonProcessing = EFalse;
  1854     TBool daemonProcessing = EFalse;
  1817     
  1855     
       
  1856     if(iShutdown)
       
  1857         {
       
  1858         RProperty::Set(KTAGDPSNotification, KDaemonProcessing, EFalse);
       
  1859         RProperty::Set(KTAGDPSNotification, KItemsleft, 0 );
       
  1860         return;
       
  1861         }
       
  1862     
  1818     if(itemsLeft + i2ndRoundGenerateQueue.Count() + iRemoveQueue.Count() > 0 )
  1863     if(itemsLeft + i2ndRoundGenerateQueue.Count() + iRemoveQueue.Count() > 0 )
  1819         {
  1864         {
  1820         daemonProcessing = ETrue;
  1865         daemonProcessing = ETrue;
  1821         }
  1866         }
  1822     
  1867