harvester/common/src/harvesterplugin.cpp
changeset 1 acef663c1218
parent 0 c53acadfccc6
child 3 6752808b2036
equal deleted inserted replaced
0:c53acadfccc6 1:acef663c1218
    22 #include <mdeobjectdef.h>
    22 #include <mdeobjectdef.h>
    23 #include <mdeobject.h>
    23 #include <mdeobject.h>
    24 #include "harvesterlog.h"
    24 #include "harvesterlog.h"
    25 #include "harvestercommon.h"
    25 #include "harvestercommon.h"
    26 #include "harvesterblacklist.h"
    26 #include "harvesterblacklist.h"
       
    27 #include "harvestereventmanager.h"
    27 #include "mdsutils.h"
    28 #include "mdsutils.h"
       
    29 
       
    30 const TInt KCacheItemCountForEventCaching = 1;
    28 
    31 
    29 // ---------------------------------------------------------------------------
    32 // ---------------------------------------------------------------------------
    30 // NewL
    33 // NewL
    31 // ---------------------------------------------------------------------------
    34 // ---------------------------------------------------------------------------
    32 //
    35 //
    47 //
    50 //
    48 void CHarvesterPlugin::ConstructL()
    51 void CHarvesterPlugin::ConstructL()
    49 	{
    52 	{
    50 	User::LeaveIfError( iFs.Connect() );
    53 	User::LeaveIfError( iFs.Connect() );
    51 	iState = EHarvesterIdle;
    54 	iState = EHarvesterIdle;
       
    55 	iHarvesterEventManager = CHarvesterEventManager::GetInstanceL();
    52 	CActiveScheduler::Add( this );
    56 	CActiveScheduler::Add( this );
    53 	}
    57 	}
    54 
    58 
    55 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
    56 // Constructor
    60 // Constructor
    84 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
    85 //
    89 //
    86 EXPORT_C CHarvesterPlugin::~CHarvesterPlugin() // destruct - virtual
    90 EXPORT_C CHarvesterPlugin::~CHarvesterPlugin() // destruct - virtual
    87 	{
    91 	{
    88 	Cancel();
    92 	Cancel();
       
    93 
       
    94     if (iHarvesterEventManager)
       
    95         {
       
    96         iHarvesterEventManager->ReleaseInstance();
       
    97         }
    89 	
    98 	
    90 	iFs.Close();
    99 	iFs.Close();
    91 	REComSession::DestroyedImplementation( iDtor_ID_Key );
   100 	REComSession::DestroyedImplementation( iDtor_ID_Key );
    92 	}
   101 	}
    93 
   102 
   137         case EHarvesterGathering:
   146         case EHarvesterGathering:
   138             {
   147             {
   139             if( iQueue->Count() == 0 )
   148             if( iQueue->Count() == 0 )
   140                 {
   149                 {
   141                 SetNextRequest( EHarvesterIdle );
   150                 SetNextRequest( EHarvesterIdle );
       
   151                 iHarvesting = EFalse;                       
       
   152                 iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateFinished );
       
   153                 iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
   142                 iQueue->Compress();
   154                 iQueue->Compress();
   143                 }
   155                 }
   144             else
   156             else
   145             	{
   157             	{
       
   158                 if ( !iHarvesting )
       
   159                     {
       
   160                     iHarvesting = ETrue;
       
   161                     iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateStarted );
       
   162                     // This next line is for caching the harvester started event for observers registering
       
   163                     // after harvesting has already started
       
   164                     iHarvesterEventManager->IncreaseItemCount( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
       
   165                     }
       
   166             
   146             	CHarvesterData* hd = (*iQueue)[0];
   167             	CHarvesterData* hd = (*iQueue)[0];
   147             	iQueue->Remove( 0 );
   168             	iQueue->Remove( 0 );
   148             	const TDesC& uri = hd->Uri();
   169             	const TDesC& uri = hd->Uri();
   149             	TUint32 mediaId = hd->MdeObject().MediaId();
   170             	TUint32 mediaId = hd->MdeObject().MediaId();
   150             	
   171