harvester/common/src/harvesterplugin.cpp
changeset 54 a3cc46f37772
parent 36 aa5a574040a4
equal deleted inserted replaced
36:aa5a574040a4 54:a3cc46f37772
    63 	iQueue( NULL ),
    63 	iQueue( NULL ),
    64 	iBlacklist( NULL ),
    64 	iBlacklist( NULL ),
    65     iDtor_ID_Key( KNullUid ),
    65     iDtor_ID_Key( KNullUid ),
    66     iOriginPropertyDef( NULL ),
    66     iOriginPropertyDef( NULL ),
    67     iTitlePropertyDef( NULL ),
    67     iTitlePropertyDef( NULL ),
    68     iHarvesting( EFalse )
    68     iHarvesting( EFalse ),
       
    69     iPaused( EFalse )
    69 	{
    70 	{
    70 	}
    71 	}
    71 
    72 
    72 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
    73 // ListImplementationsL
    74 // ListImplementationsL
   107 //
   108 //
   108 EXPORT_C void CHarvesterPlugin::StartHarvest()
   109 EXPORT_C void CHarvesterPlugin::StartHarvest()
   109 	{
   110 	{
   110 	if( iState == EHarvesterIdle )
   111 	if( iState == EHarvesterIdle )
   111 		{
   112 		{
       
   113 		iPaused = EFalse;
   112 		SetNextRequest( EHarvesterGathering );
   114 		SetNextRequest( EHarvesterGathering );
   113 		}
   115 		}
   114 	}
   116 	}
   115 
   117 
   116 // ---------------------------------------------------------------------------
   118 // ---------------------------------------------------------------------------
   142             
   144             
   143         case EHarvesterGathering:
   145         case EHarvesterGathering:
   144             {
   146             {
   145             if( iQueue->Count() == 0 )
   147             if( iQueue->Count() == 0 )
   146                 {
   148                 {
   147                 SetNextRequest( EHarvesterIdle );
       
   148                 if( iHarvesting )
   149                 if( iHarvesting )
   149                     {
   150                     {
   150                     TRAP_IGNORE( iFactory->SendHarvestingStatusEventL( EFalse ) );
   151                     TRAP_IGNORE( iFactory->SendHarvestingStatusEventL( EFalse ) );
   151                     iHarvesting = EFalse;     
   152                     iHarvesting = EFalse;     
   152                     }
   153                     }
   153                 iQueue->Compress();
   154                 iQueue->Compress();
       
   155                 SetNextRequest( EHarvesterIdle );
   154                 }
   156                 }
   155             else
   157             else
   156             	{
   158             	{
       
   159                 WRITELOG( "CHarvesterPlugin::RunL EHarvesterGathering - items in queue" );
   157                 if ( !iHarvesting )
   160                 if ( !iHarvesting )
   158                     {
   161                     {
   159                     TRAP_IGNORE( iFactory->SendHarvestingStatusEventL( ETrue ) );
   162                     TRAP_IGNORE( iFactory->SendHarvestingStatusEventL( ETrue ) );
   160                     iHarvesting = ETrue;
   163                     iHarvesting = ETrue;
   161                     }
   164                     }
   162             
   165             
   163             	CHarvesterData* hd = (*iQueue)[0];
   166             	CHarvesterData* hd = (*iQueue)[0];
   164             	iQueue->Remove( 0 );
   167             	iQueue->Remove( 0 );
       
   168             	if( !hd )
       
   169             	    {
       
   170             	    SetNextRequest( EHarvesterGathering );
       
   171             	    break;
       
   172             	    }
   165             	const TDesC& uri = hd->Uri();
   173             	const TDesC& uri = hd->Uri();
   166             	TUint32 mediaId = hd->MdeObject().MediaId();
   174             	TUint32 mediaId = hd->MdeObject().MediaId();
   167             	
   175             	
   168             	if( hd->ObjectType() == EFastHarvest || hd->Origin() == MdeConstants::Object::ECamera )
   176             	if( hd->ObjectType() == EFastHarvest || hd->Origin() == MdeConstants::Object::ECamera )
   169             	    {
   177             	    {
   192 					}
   200 					}
   193 				
   201 				
   194 				TRAP_IGNORE( SetDefaultPropertiesL( *hd ) );
   202 				TRAP_IGNORE( SetDefaultPropertiesL( *hd ) );
   195 				
   203 				
   196 				WRITELOG1("CHarvesterPlugin::RunL - Calling HarvestL for file: %S", &uri);  
   204 				WRITELOG1("CHarvesterPlugin::RunL - Calling HarvestL for file: %S", &uri);  
   197                 TRAPD(err, HarvestL( hd ) );
   205                 TRAPD( err, HarvestL( hd ) );
   198                 
   206                 
   199                 if ( iBlacklist )
   207                 if ( iBlacklist )
   200                     {
   208                     {
   201                     WRITELOG( "CHarvesterPlugin::RunL - Removing URI from blacklist" );
   209                     WRITELOG( "CHarvesterPlugin::RunL - Removing URI from blacklist" );
   202                     iBlacklist->RemoveFile( uri, mediaId );
   210                     iBlacklist->RemoveFile( uri, mediaId );
   237 	SetNextRequest( EHarvesterGathering );
   245 	SetNextRequest( EHarvesterGathering );
   238 	return KErrNone;
   246 	return KErrNone;
   239 	}
   247 	}
   240 
   248 
   241 // ---------------------------------------------------------------------------
   249 // ---------------------------------------------------------------------------
       
   250 // StartHarvest
       
   251 // ---------------------------------------------------------------------------
       
   252 //
       
   253 EXPORT_C void CHarvesterPlugin::StopHarvest()
       
   254     {
       
   255     Cancel();
       
   256     iState = EHarvesterIdle;
       
   257     if( iHarvesting )
       
   258         {
       
   259         TRAP_IGNORE( iFactory->SendHarvestingStatusEventL( EFalse ) );
       
   260         iHarvesting = EFalse;     
       
   261         }
       
   262     iPaused = ETrue;
       
   263     }
       
   264 
       
   265 // ---------------------------------------------------------------------------
   242 // SetNextRequest
   266 // SetNextRequest
   243 // ---------------------------------------------------------------------------
   267 // ---------------------------------------------------------------------------
   244 //
   268 //
   245 void CHarvesterPlugin::SetNextRequest( THarvesterState aState )
   269 void CHarvesterPlugin::SetNextRequest( THarvesterState aState )
   246     {
   270     {
   247     if ( ! IsActive() )
   271     if ( !IsActive() && !iPaused )
   248         {
   272         {
   249         iState = aState;
   273         iState = aState;
   250         SetActive();
   274         SetActive();
   251         TRequestStatus* status = &iStatus;
   275         TRequestStatus* status = &iStatus;
   252         User::RequestComplete( status, KErrNone );
   276         User::RequestComplete( status, KErrNone );