--- a/harvester/server/src/harvesterao.cpp Wed Sep 01 12:24:24 2010 +0100
+++ b/harvester/server/src/harvesterao.cpp Tue Sep 14 22:10:25 2010 +0300
@@ -19,7 +19,6 @@
#include <caf/caf.h>
#include <driveinfo.h>
-#include <rlocationobjectmanipulator.h>
#include <placeholderdata.h>
#include <harvesterclientdata.h>
#include <pathinfo.h>
@@ -62,7 +61,7 @@
_LIT(KVideo, "Video");
_LIT(KInUse, "InUse");
-_LIT(KUndefinedMime, " ");
+_LIT(KUndefined, " ");
_LIT( KExtensionMp4, "mp4" );
_LIT( KExtensionMpg4, "mpg4" );
@@ -156,7 +155,9 @@
iHarvestingPlaceholders = EFalse;
iUnmountDetected = EFalse;
+ iUnmountHandlingOngoing = EFalse;
iPriorityInterruptDetected = EFalse;
+ iLocManipulatorConnected = EFalse;
}
// ---------------------------------------------------------------------------
@@ -172,6 +173,8 @@
iFs.Close();
+ iLocManipulator.Close();
+
if (iCtxEngine)
{
iCtxEngine->ReleaseInstance();
@@ -507,6 +510,7 @@
OstTrace1( TRACE_NORMAL, CHARVESTERAO_HANDLEUNMOUNT, "CHarvesterAO::HandleUnmount;aMediaId=%d", aMediaId );
iUnmountDetected = ETrue;
+ iUnmountHandlingOngoing = ETrue;
if( !iServerPaused )
{
@@ -731,12 +735,10 @@
iMediaIdUtil->RemoveMediaId( aMediaId );
// resume harvesting from last state
- if( !iRamFull && !iDiskFull )
- {
- // resume monitoring
- ResumeMonitoring();
- TRAP_IGNORE( ResumeHarvesterL() );
- }
+ iUnmountHandlingOngoing = EFalse;
+ // resume monitoring
+ ResumeMonitoring();
+ TRAP_IGNORE( ResumeHarvesterL() );
}
// ---------------------------------------------------------------------------
@@ -847,9 +849,9 @@
{
SetPriority( KHarvesterCustomImportantPriority );
}
- while( hd != NULL &&
- iPHArray.Count() < KPlaceholderQueueSize &&
- hd->ObjectType() == EPlaceholder )
+ while( hd &&
+ iPHArray.Count() < KPlaceholderQueueSize &&
+ hd->ObjectType() == EPlaceholder )
{
if(iPHArray.Append( hd ) != KErrNone)
{
@@ -985,7 +987,9 @@
{
CHarvesterData* hd = iPHArray[i];
- if( aCheck && iHarvesterPluginFactory->IsContainerFileL( hd->Uri() ) )
+ if( aCheck &&
+ hd->Origin() != MdeConstants::Object::ECamera &&
+ iHarvesterPluginFactory->IsContainerFileL( hd->Uri() ) )
{
if( iContainerPHArray.Append( hd ) != KErrNone )
{
@@ -1078,7 +1082,30 @@
if( objDefStr.Length() == 0 ||
( objDefStr == KInUse ) )
{
- WRITELOG( "CHarvesterAO::HandlePlaceholdersL() - no objectDef or in use, failing harvesting" );
+#ifdef _DEBUG
+ if( objDefStr.Length() == 0 )
+ {
+ WRITELOG( "CHarvesterAO::HandlePlaceholdersL() - no objectDef failing harvesting" );
+ }
+ else
+ {
+ WRITELOG( "CHarvesterAO::HandlePlaceholdersL() - in use, failing harvesting" );
+ }
+ WRITELOG1( "CHarvesterAO::HandlePlaceholdersL() - harvesting failed, uri: %S", &(hd->Uri()) );
+#endif
+ // If object has not been created in the device so that monitors would have
+ // picked up creation event, and the file is in use, subclose event will
+ // not trigger the file to be harvester when closed, thus it needs to be moved
+ // to reharvesting queue
+ if( objDefStr == KInUse &&
+ !hd->TakeSnapshot() )
+ {
+ iPHArray.Remove( i );
+ i--;
+ endindex--;
+ iReHarvester->AddItem( hd );
+ continue;
+ }
const TInt error( KErrUnknown );
// notify observer, notification is needed even if file is not supported
HarvestCompleted( hd->ClientId(), hd->Uri(), error );
@@ -1191,7 +1218,7 @@
}
else
{
- mdeObject->AddTextPropertyL( *iPropDefs->iItemTypePropertyDef, KUndefinedMime );
+ mdeObject->AddTextPropertyL( *iPropDefs->iItemTypePropertyDef, KUndefined );
}
if( hd->Origin() == MdeConstants::Object::ECamera )
@@ -1213,7 +1240,7 @@
}
else
{
- mdeObject->AddTextPropertyL( *iPropDefs->iTitlePropertyDef, KNullDesC );
+ mdeObject->AddTextPropertyL( *iPropDefs->iTitlePropertyDef, KUndefined );
}
CPlaceholderData* ph = NULL;
@@ -1566,18 +1593,25 @@
WRITELOG( "CHarvesterAO::HarvestingCompleted() - Creating location object. " );
OstTrace0( TRACE_NORMAL, DUP6_CHARVESTERAO_HARVESTINGCOMPLETED, "CHarvesterAO::HarvestingCompleted - Creating location object." );
- RLocationObjectManipulator lo;
-
- const TInt loError = lo.Connect();
+ TInt loError( KErrNone );
+ if( !iLocManipulatorConnected )
+ {
+ loError = iLocManipulator.Connect();
+ if( loError == KErrNone )
+ {
+ iLocManipulatorConnected = ETrue;
+ }
+ }
if (loError == KErrNone)
{
- TInt err = lo.CreateLocationObject( *locData, aHD->MdeObject().Id() );
+ TInt err = iLocManipulator.CreateLocationObject( *locData, aHD->MdeObject().Id() );
if( err != KErrNone )
{
WRITELOG( "CHarvesterAO::HarvestingCompleted() - Location object creation failed!!!" );
OstTrace0( TRACE_NORMAL, DUP7_CHARVESTERAO_HARVESTINGCOMPLETED, "CHarvesterAO::HarvestingCompleted - Location object creation failed!!!" );
-
+ iLocManipulator.Close();
+ iLocManipulatorConnected = EFalse;
}
}
else
@@ -1585,8 +1619,6 @@
WRITELOG( "CHarvesterAO::HarvestingCompleted() - LocationObjectManipulator connect failed!!!" );
OstTrace0( TRACE_NORMAL, DUP8_CHARVESTERAO_HARVESTINGCOMPLETED, "CHarvesterAO::HarvestingCompleted - LocationObjectManipulator connect failed!!" );
}
-
- lo.Close();
}
TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, 1 ) );
@@ -1793,31 +1825,38 @@
if( internalMassStorageError == KErrNone )
{
const TUint32 massStorageMediaId( internalMassStorageVolumeInfo.iUniqueID );
- TUint32 mmcMediaId( 0 );
- TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive ) );
- if( mmcError == KErrNone )
+ if( massStorageMediaId != 0 )
{
- TVolumeInfo mmcVolumeInfo;
- mmcError = iFs.Volume( mmcVolumeInfo, drive );
+ TUint32 mmcMediaId( 0 );
+ TInt mmcDrive( -1 );
+ TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, mmcDrive ) );
if( mmcError == KErrNone )
{
- mmcMediaId = mmcVolumeInfo.iUniqueID;
+ if( drive != mmcDrive )
+ {
+ TVolumeInfo mmcVolumeInfo;
+ mmcError = iFs.Volume( mmcVolumeInfo, mmcDrive );
+ if( mmcError == KErrNone )
+ {
+ mmcMediaId = mmcVolumeInfo.iUniqueID;
+ }
+ }
+ else
+ {
+ mmcMediaId = massStorageMediaId;
+ }
}
- }
- // If removable storage is not found, assume internal mass storage was mounted
- if( mmcError )
- {
- if( massStorageMediaId != 0 )
+ // If removable storage is not found, assume internal mass storage was mounted
+ if( mmcError )
+ {
+ iMdEHarvesterSession->CheckMassStorageMediaId( massStorageMediaId );
+ }
+ else if( massStorageMediaId != mmcMediaId )
{
iMdEHarvesterSession->CheckMassStorageMediaId( massStorageMediaId );
- }
- }
- else if( massStorageMediaId != mmcMediaId &&
- massStorageMediaId != 0 )
- {
- iMdEHarvesterSession->CheckMassStorageMediaId( massStorageMediaId );
- }
+ }
+ }
}
}
}
@@ -1882,11 +1921,6 @@
iHarvesterPluginFactory->PauseHarvester( ETrue );
iServerPaused = ETrue;
- if( !iRamFull && !iDiskFull && !iUnmountDetected )
- {
- iManualPauseEnabled = ETrue;
- }
-
// Everything is paused
WRITELOG( "CHarvesterAO::PauseHarvester() - Moving paused state paused" );
OstTrace0( TRACE_NORMAL, DUP1_CHARVESTERAO_PAUSEHARVESTER, "CHarvesterAO::PauseHarvester - Moving paused state paused" );
@@ -1902,17 +1936,19 @@
{
WRITELOG( "CHarvesterAO::ResumeHarvesterL()" );
OstTrace0( TRACE_NORMAL, CHARVESTERAO_RESUMEHARVESTERL, "CHarvesterAO::ResumeHarvesterL" );
+
+ if( iRamFull || iDiskFull || iUnmountHandlingOngoing || iManualPauseEnabled )
+ {
+ return;
+ }
iHarvesterPluginFactory->PauseHarvester( EFalse );
iServerPaused = EFalse;
- if( !iManualPauseEnabled &&
- iNextRequest == ERequestIdle )
+ if( iNextRequest == ERequestIdle )
{
SetNextRequest( ERequestHarvest );
- }
-
- iManualPauseEnabled = EFalse;
+ }
}
// ---------------------------------------------------------------------------
@@ -1948,6 +1984,12 @@
iContainerPHArray.Compress();
iPHArray.Compress();
iTempReadyPHArray.Compress();
+
+ if( iLocManipulatorConnected )
+ {
+ iLocManipulator.Close();
+ iLocManipulatorConnected = EFalse;
+ }
}
break;
@@ -2066,7 +2108,11 @@
while( i < count )
{
CHarvesterData* hd = iContainerPHArray[0];
- iPHArray.Append( hd );
+ if( iPHArray.Append( hd ) != KErrNone )
+ {
+ delete hd;
+ hd = NULL;
+ }
iContainerPHArray.Remove( 0 );
i++;
}
@@ -2093,6 +2139,7 @@
WRITELOG( "CHarvesterAO::RunL - ERequestPause" );
OstTrace0( TRACE_NORMAL, DUP6_CHARVESTERAO_RUNL, "CHarvesterAO::RunL - ERequestPause" );
User::LeaveIfError( PauseHarvester() );
+ iManualPauseEnabled = ETrue;
iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStatePaused );
if( iHarvesterStatusObserver )
{
@@ -2106,6 +2153,19 @@
{
WRITELOG( "CHarvesterAO::RunL - ERequestResume" );
OstTrace0( TRACE_NORMAL, DUP7_CHARVESTERAO_RUNL, "CHarvesterAO::RunL - ERequestResume" );
+ iManualPauseEnabled = EFalse;
+ // If for some reason, mds session is not (yet) ready, only inform that
+ // server state is no longer paused, but do not restart actual harvesting
+ // yet.
+ if( !iMdeSessionInitialized )
+ {
+ iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateResumed );
+ if( iHarvesterStatusObserver )
+ {
+ iHarvesterStatusObserver->ResumeReady( KErrNone );
+ }
+ break;
+ }
ResumeHarvesterL();
iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateResumed );
if( iHarvesterStatusObserver )
@@ -2303,7 +2363,7 @@
PauseMonitoring();
PauseHarvester();
}
- else if( !iRamFull && !iManualPauseEnabled && iServerPaused )
+ else if( iServerPaused )
{
// resume monitoring
ResumeMonitoring();
@@ -2874,7 +2934,6 @@
continue;
}
- //if (aMessage.Identity() == msg.Identity())
if( &req.iSession == &aSession )
{
err = KErrNone;
@@ -3395,9 +3454,10 @@
PauseMonitoring();
PauseHarvester();
- iPHArray.Compress();
- iReadyPHArray.Compress();
- iContainerPHArray.Compress();
+ iReadyPHArray.Compress();
+ iContainerPHArray.Compress();
+ iPHArray.Compress();
+ iTempReadyPHArray.Compress();
}
void CHarvesterAO::MemoryGood()
@@ -3407,7 +3467,7 @@
iRamFull = EFalse;
- if( !iDiskFull && !iManualPauseEnabled && iServerPaused )
+ if( iServerPaused )
{
// resume monitoring
ResumeMonitoring();