imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp
branchRCL_3
changeset 58 9e8b0cc88842
parent 50 60bb012f1157
equal deleted inserted replaced
50:60bb012f1157 58:9e8b0cc88842
   103     RProperty::Define(KTAGDPSNotification, KMPXHarvesting, RProperty::EInt);
   103     RProperty::Define(KTAGDPSNotification, KMPXHarvesting, RProperty::EInt);
   104     
   104     
   105 	//start foreground generation observer
   105 	//start foreground generation observer
   106     iForegroundGenerationObserver = CTMRPropertyObserver::NewL( *this, KTAGDPSNotification, KForceBackgroundGeneration, ETrue );  
   106     iForegroundGenerationObserver = CTMRPropertyObserver::NewL( *this, KTAGDPSNotification, KForceBackgroundGeneration, ETrue );  
   107     
   107     
       
   108     //itemsLeft observer
       
   109     iItemsLeftObserver = CTMRPropertyObserver::NewL( *this, KTAGDPSNotification, KItemsleft, EFalse ); 
       
   110     
   108     TN_DEBUG1( "CThumbAGProcessor::ConstructL() - end" );
   111     TN_DEBUG1( "CThumbAGProcessor::ConstructL() - end" );
   109     }
   112     }
   110 
   113 
   111 // ---------------------------------------------------------------------------
   114 // ---------------------------------------------------------------------------
   112 // CThumbAGProcessor::~CThumbAGProcessor()
   115 // CThumbAGProcessor::~CThumbAGProcessor()
   178     
   181     
   179     if(iForegroundGenerationObserver)
   182     if(iForegroundGenerationObserver)
   180         {
   183         {
   181         delete iForegroundGenerationObserver;
   184         delete iForegroundGenerationObserver;
   182         iForegroundGenerationObserver = NULL;
   185         iForegroundGenerationObserver = NULL;
       
   186         }
       
   187     
       
   188     if(iItemsLeftObserver)
       
   189         {
       
   190         delete iItemsLeftObserver;
       
   191         iItemsLeftObserver = NULL;
   183         }
   192         }
   184     
   193     
   185     if(iFormatObserver)
   194     if(iFormatObserver)
   186         {
   195         {
   187         delete iFormatObserver;
   196         delete iFormatObserver;
   956     
   965     
   957     TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end iGenerationQueue == %d, iQueryQueue == %d", iGenerationQueue.Count(), iQueryQueue.Count() );
   966     TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end iGenerationQueue == %d, iQueryQueue == %d", iGenerationQueue.Count(), iQueryQueue.Count() );
   958     
   967     
   959     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );
   968     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );
   960     iQuery = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this );
   969     iQuery = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this );
   961 	
   970     iQuery->SetResultMode( EQueryResultModeItem );
   962 	if(iQuery)
   971 
   963 		{
   972     CMdELogicCondition& rootCondition = iQuery->Conditions();
   964 	    iQuery->SetResultMode( EQueryResultModeItem );
   973     rootCondition.SetOperator( ELogicConditionOperatorAnd );
   965 
   974     
   966 	    CMdELogicCondition& rootCondition = iQuery->Conditions();
   975     // add IDs
   967 	    rootCondition.SetOperator( ELogicConditionOperatorAnd );
   976     CleanupClosePushL( iQueryQueue );
   968     
   977     rootCondition.AddObjectConditionL( iQueryQueue );
   969 	    // add IDs
   978     CleanupStack::Pop( &iQueryQueue );
   970 	    CleanupClosePushL( iQueryQueue );
   979     
   971 	    rootCondition.AddObjectConditionL( iQueryQueue );
   980     // add object type conditions 
   972 	    CleanupStack::Pop( &iQueryQueue );
   981     if (!(iModify || iUnknown))
   973     
   982         {
   974 	    // add object type conditions 
   983         CMdELogicCondition& objDefCondition = rootCondition.AddLogicConditionL( ELogicConditionOperatorOr );
   975 	    if (!(iModify || iUnknown))
   984         
   976 	        {
   985         if (iAutoImage)
   977 	        CMdELogicCondition& objDefCondition = rootCondition.AddLogicConditionL( ELogicConditionOperatorOr );
   986             {
   978         
   987             CMdEObjectDef& imageDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );
   979 	        if (iAutoImage)
   988             objDefCondition.AddObjectConditionL( imageDef );
   980 	            {
   989             }
   981 	            CMdEObjectDef& imageDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject );
   990         if (iAutoVideo)
   982 	            objDefCondition.AddObjectConditionL( imageDef );
   991             {
   983 	            }
   992             CMdEObjectDef& videoDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject );
   984 	        if (iAutoVideo)
   993             objDefCondition.AddObjectConditionL( videoDef );
   985 	            {
   994             }
   986 	            CMdEObjectDef& videoDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject );
   995         if (iAutoAudio)
   987 	            objDefCondition.AddObjectConditionL( videoDef );
   996             {
   988 	            }
   997             CMdEObjectDef& audioDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject );
   989 	        if (iAutoAudio)
   998             objDefCondition.AddObjectConditionL( audioDef );
   990 	            {
   999             }    
   991 	            CMdEObjectDef& audioDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject );
  1000         }
   992 	            objDefCondition.AddObjectConditionL( audioDef );
  1001     
   993 	            }    
  1002     iQuery->FindL();
   994 	        }
       
   995     
       
   996 	    iQuery->FindL();
       
   997 		}
       
   998     
  1003     
   999     TN_DEBUG1( "CThumbAGProcessor::QueryL() - end" );
  1004     TN_DEBUG1( "CThumbAGProcessor::QueryL() - end" );
  1000     }
  1005     }
  1001 
  1006 
  1002 
  1007 
  1038     CMdEObjectDef& audioObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject );
  1043     CMdEObjectDef& audioObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject );
  1039     
  1044     
  1040     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject);
  1045     CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject);
  1041     iQueryPlaceholders = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this );
  1046     iQueryPlaceholders = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this );
  1042         
  1047         
  1043     if(iQueryPlaceholders)
  1048     iQueryPlaceholders->SetResultMode( EQueryResultModeItem );
  1044         {
  1049     
  1045         iQueryPlaceholders->SetResultMode( EQueryResultModeItem );
  1050     CMdELogicCondition& rootCondition = iQueryPlaceholders->Conditions();
  1046         
  1051     rootCondition.SetOperator( ELogicConditionOperatorOr );
  1047         CMdELogicCondition& rootCondition = iQueryPlaceholders->Conditions();
  1052     
  1048         rootCondition.SetOperator( ELogicConditionOperatorOr );
  1053     CMdEObjectCondition& imagePHObjectCondition = rootCondition.AddObjectConditionL(imageObjDef);
  1049         
  1054     imagePHObjectCondition.SetPlaceholderOnly( ETrue );
  1050         CMdEObjectCondition& imagePHObjectCondition = rootCondition.AddObjectConditionL(imageObjDef);
  1055     imagePHObjectCondition.SetNotPresent( aPresent );
  1051         imagePHObjectCondition.SetPlaceholderOnly( ETrue );
  1056     
  1052         imagePHObjectCondition.SetNotPresent( aPresent );
  1057     CMdEObjectCondition& videoPHObjectCondition = rootCondition.AddObjectConditionL(videoObjDef);
  1053         
  1058     videoPHObjectCondition.SetPlaceholderOnly( ETrue );
  1054         CMdEObjectCondition& videoPHObjectCondition = rootCondition.AddObjectConditionL(videoObjDef);
  1059     videoPHObjectCondition.SetNotPresent( aPresent );
  1055         videoPHObjectCondition.SetPlaceholderOnly( ETrue );
  1060     
  1056         videoPHObjectCondition.SetNotPresent( aPresent );
  1061     CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
  1057         
  1062     audioPHObjectCondition.SetPlaceholderOnly( ETrue );
  1058         CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
  1063     audioPHObjectCondition.SetNotPresent( aPresent );
  1059         audioPHObjectCondition.SetPlaceholderOnly( ETrue );
  1064     
  1060         audioPHObjectCondition.SetNotPresent( aPresent );
  1065     iQueryPlaceholders->FindL(KMaxTInt, KMaxQueryBatchSize);   
  1061         
  1066    
  1062         iQueryPlaceholders->FindL(KMaxTInt, KMaxQueryBatchSize);   
       
  1063         }
       
  1064 	
       
  1065     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL - end" );
  1067     TN_DEBUG1( "CThumbAGProcessor::QueryPlaceholdersL - end" );
  1066     }
  1068     }
  1067 
  1069 
  1068 
  1070 
  1069 // ---------------------------------------------------------------------------
  1071 // ---------------------------------------------------------------------------
  1293         iUnknown = ETrue;
  1295         iUnknown = ETrue;
  1294         iQueryActive = ETrue;
  1296         iQueryActive = ETrue;
  1295 
  1297 
  1296         QueryL( EGenerationItemActionResolveType );
  1298         QueryL( EGenerationItemActionResolveType );
  1297        }
  1299        }
  1298     else if ( iDeleteItemCount > 0 )
       
  1299        {
       
  1300        TN_DEBUG1( "void CThumbAGProcessor::RunL() delete thumbnails");
       
  1301        // delete thumbs by URI
       
  1302        __ASSERT_DEBUG((iTMSession), User::Panic(_L("CThumbAGProcessor::RunL() !iTMSession "), KErrBadHandle));
       
  1303        if(iTMSession)
       
  1304            {
       
  1305            TInt itemIndex(KErrNotFound);
       
  1306                                
       
  1307            for(TInt i=0;i<iGenerationQueue.Count() || itemIndex == KErrNotFound;i++)
       
  1308                {
       
  1309                if(iGenerationQueue[i].iItemAction == EGenerationItemActionDelete)
       
  1310                    {
       
  1311                    itemIndex = i;
       
  1312                    }
       
  1313                }
       
  1314        
       
  1315            if(itemIndex >= 0)
       
  1316                {
       
  1317                if(!iGenerationQueue[itemIndex].iUri)
       
  1318                    {
       
  1319                    //URI is invalid
       
  1320                    TN_DEBUG1( "void CThumbAGProcessor::RunL() unable to delete URI inbalid");
       
  1321                    iGenerationQueue.Remove( itemIndex );
       
  1322                    ActivateAO();
       
  1323                    return;
       
  1324                    }
       
  1325 
       
  1326                TN_DEBUG2( "void CThumbAGProcessor::RunL() delete %S",  iGenerationQueue[itemIndex].iUri);
       
  1327                CThumbnailObjectSource* source = NULL;                
       
  1328                TRAPD(err,  source = CThumbnailObjectSource::NewL( *iGenerationQueue[itemIndex].iUri, KNullDesC));
       
  1329                   
       
  1330                if(err == KErrNone)
       
  1331                    {
       
  1332                    iTMSession->DeleteThumbnails( *source );
       
  1333                    }
       
  1334                delete source;
       
  1335                
       
  1336                delete iGenerationQueue[itemIndex].iUri;
       
  1337                iGenerationQueue[itemIndex].iUri = NULL;
       
  1338                iGenerationQueue.Remove( itemIndex );
       
  1339                
       
  1340                iActiveCount++;
       
  1341                }
       
  1342            }
       
  1343        }
       
  1344     // no items in query queue, start new
  1300     // no items in query queue, start new
  1345     // select queue to process, priority by type
  1301     // select queue to process, priority by type
  1346     else if ( iModifyItemCount > 0 )
  1302     else if ( iModifyItemCount > 0 )
  1347         {
  1303         {
  1348         TN_DEBUG1( "void CThumbAGProcessor::RunL() update thumbnails");
  1304         TN_DEBUG1( "void CThumbAGProcessor::RunL() update thumbnails");
  1364         // query for object info
  1320         // query for object info
  1365         iQueryActive = ETrue;
  1321         iQueryActive = ETrue;
  1366         
  1322         
  1367         QueryL( EGenerationItemActionAdd );     
  1323         QueryL( EGenerationItemActionAdd );     
  1368         }
  1324         }
       
  1325     else if ( iDeleteItemCount > 0 )
       
  1326         {
       
  1327         TN_DEBUG1( "void CThumbAGProcessor::RunL() delete thumbnails");
       
  1328         i2ndRound = EFalse;
       
  1329         iUnknown = EFalse;
       
  1330         // delete thumbs by URI
       
  1331         __ASSERT_DEBUG((iTMSession), User::Panic(_L("CThumbAGProcessor::RunL() !iTMSession "), KErrBadHandle));
       
  1332         if(iTMSession)
       
  1333             {
       
  1334             TInt itemIndex(KErrNotFound);
       
  1335                                 
       
  1336             for(TInt i=0;i<iGenerationQueue.Count() || itemIndex == KErrNotFound;i++)
       
  1337                 {
       
  1338                 if(iGenerationQueue[i].iItemAction == EGenerationItemActionDelete)
       
  1339                     {
       
  1340                     itemIndex = i;
       
  1341                     }
       
  1342                 }
       
  1343         
       
  1344             if(itemIndex >= 0)
       
  1345                 {
       
  1346                 if(!iGenerationQueue[itemIndex].iUri)
       
  1347                     {
       
  1348                     //URI is invalid
       
  1349                     TN_DEBUG1( "void CThumbAGProcessor::RunL() unable to delete URI inbalid");
       
  1350                     iGenerationQueue.Remove( itemIndex );
       
  1351                     ActivateAO();
       
  1352                     return;
       
  1353                     }
       
  1354 
       
  1355                 TN_DEBUG2( "void CThumbAGProcessor::RunL() delete %S",  iGenerationQueue[itemIndex].iUri);
       
  1356                 CThumbnailObjectSource* source = NULL;                
       
  1357                 TRAPD(err,  source = CThumbnailObjectSource::NewL( *iGenerationQueue[itemIndex].iUri, KNullDesC));
       
  1358                    
       
  1359                 if(err == KErrNone)
       
  1360                     {
       
  1361                     iTMSession->DeleteThumbnails( *source );
       
  1362                     }
       
  1363                 delete source;
       
  1364                 
       
  1365                 delete iGenerationQueue[itemIndex].iUri;
       
  1366                 iGenerationQueue[itemIndex].iUri = NULL;
       
  1367                 iGenerationQueue.Remove( itemIndex );
       
  1368                 
       
  1369                 iActiveCount++;
       
  1370                 }
       
  1371             }
       
  1372         }
  1369     else if( i2ndAddItemCount > 0)
  1373     else if( i2ndAddItemCount > 0)
  1370         {
  1374         {
  1371         TN_DEBUG1( "void CThumbAGProcessor::RunL() update 2nd round thumbnails");
  1375         TN_DEBUG1( "void CThumbAGProcessor::RunL() update 2nd round thumbnails");
  1372             
  1376             
  1373         // query for object info
  1377         // query for object info
  1690         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE");
  1694         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE");
  1691         return;
  1695         return;
  1692         }
  1696         }
  1693     
  1697     
  1694     //check if forced run needs to continue
  1698     //check if forced run needs to continue
  1695     if ( (iModifyItemCount > 0 || iDeleteItemCount > 0 ||  iUnknownItemCount > 0) && !iMountTimer->IsActive())
  1699     if ( ( iModifyItemCount || iUnknownItemCount > 0 )  && !iMountTimer->IsActive())
  1696         {
  1700         {
  1697         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() -  forced run");
  1701         TN_DEBUG1( "CThumbAGProcessor::ActivateAO() -  forced run");
  1698         SetForceRun( ETrue );
  1702         SetForceRun( ETrue );
  1699         }
  1703         }
  1700     else
  1704     else
  1883     iQueryAllItems->SetResultMode( EQueryResultModeItem );
  1887     iQueryAllItems->SetResultMode( EQueryResultModeItem );
  1884     
  1888     
  1885     CMdELogicCondition& rootCondition = iQueryAllItems->Conditions();
  1889     CMdELogicCondition& rootCondition = iQueryAllItems->Conditions();
  1886     rootCondition.SetOperator( ELogicConditionOperatorOr );
  1890     rootCondition.SetOperator( ELogicConditionOperatorOr );
  1887     
  1891     
  1888     rootCondition.AddObjectConditionL(imageObjDef);   
  1892     CMdEObjectCondition& imageObjectCondition = rootCondition.AddObjectConditionL(imageObjDef);
  1889     rootCondition.AddObjectConditionL(videoObjDef);   
  1893     
  1890     rootCondition.AddObjectConditionL(audioObjDef);
  1894     CMdEObjectCondition& videoObjectCondition = rootCondition.AddObjectConditionL(videoObjDef);
       
  1895     
       
  1896     CMdEObjectCondition& audioObjectCondition = rootCondition.AddObjectConditionL(audioObjDef);
  1891     
  1897     
  1892     iQueryAllItems->FindL(KMaxTInt, KMaxQueryBatchSize);  
  1898     iQueryAllItems->FindL(KMaxTInt, KMaxQueryBatchSize);  
  1893     
  1899     
  1894     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL - end" );
  1900     TN_DEBUG1( "CThumbAGProcessor::QueryAllItemsL - end" );
  1895     }
  1901     }
  2048             ActivateAO();
  2054             ActivateAO();
  2049             }
  2055             }
  2050         else
  2056         else
  2051             {
  2057             {
  2052             iForegroundRun = EFalse;
  2058             iForegroundRun = EFalse;
       
  2059             }
       
  2060         }
       
  2061     else if(aPropertyKey == KItemsleft && aKeyCategory == KTAGDPSNotification )
       
  2062         {
       
  2063         if( aError == KErrNone && aValue != iPreviousItemsLeft)
       
  2064             {
       
  2065             TN_DEBUG1( "CThumbAGProcessor::RPropertyNotification() - itemsLeft changed outside Daemon" );
       
  2066             iPreviousItemsLeft = aValue;
       
  2067             ActivateAO();
  2053             }
  2068             }
  2054         }
  2069         }
  2055     }
  2070     }
  2056 
  2071 
  2057 // ---------------------------------------------------------------------------
  2072 // ---------------------------------------------------------------------------