# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1284491425 -10800 # Node ID 29d87345eaeb014093b4dca3f6692b5720a069b4 # Parent 85f623e1ef41a2b8388d75edf90215ef747effb7 Revision: 201033 Kit: 201035 diff -r 85f623e1ef41 -r 29d87345eaeb contextengine/plugins/locationplugin/src/locationcontextplugin.cpp --- a/contextengine/plugins/locationplugin/src/locationcontextplugin.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/contextengine/plugins/locationplugin/src/locationcontextplugin.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -138,17 +138,39 @@ return; } - if ( !iLocationTrailConnected ) // no trail, no snapshot - { - aHD.SetErrorCode( KErrDisconnected ); - aObserver.PluginSnapshotStatus( &aHD ); - return; + if ( !iLocationTrailConnected ) + { + WRITELOG( "CLocationContextPlugin::ContextSnapshot() - try to reconnect" ); + iManipulator.Close(); + iLocationTrail.Close(); + TInt err = iLocationTrail.Connect(); + if ( err == KErrNone ) + { + err = iManipulator.Connect(); + if( err == KErrNone ) + { + iLocationTrailConnected = ETrue; + } + } + + if (err != KErrNone ) + { + // no trail, no snapshot + aHD.SetErrorCode( KErrDisconnected ); + aObserver.PluginSnapshotStatus( &aHD ); + return; + } } TInt ret = KErrNone; ret = iManipulator.LocationSnapshot( aHD.MdeObject().Id() ); + if( ret == KErrServerTerminated ) + { + iLocationTrailConnected = EFalse; + } + if( ret != KErrNone ) { ret = KErrCompletion; diff -r 85f623e1ef41 -r 29d87345eaeb harvester/blacklistserver/src/blacklistsession.cpp --- a/harvester/blacklistserver/src/blacklistsession.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/blacklistserver/src/blacklistsession.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -118,7 +118,7 @@ aMessage.ReadL( 0, mediaIdPckg ); RBuf uri; - uri.Create( aMessage.GetDesLength( 1 ) ); + User::LeaveIfError( uri.Create( aMessage.GetDesLength( 1 ) ) ); CleanupClosePushL( uri ); aMessage.ReadL( 1, uri ); diff -r 85f623e1ef41 -r 29d87345eaeb harvester/client/inc/harvesterclientao.h --- a/harvester/client/inc/harvesterclientao.h Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/client/inc/harvesterclientao.h Tue Sep 14 22:10:25 2010 +0300 @@ -61,6 +61,8 @@ */ void Active(); + void CancelRequest(); + protected: /** @@ -111,6 +113,8 @@ * Harvester server assigned file name */ TFileName iURI; + + TBool iCancelled; }; #endif // __CHARVESTERCLIENTAO_H__ diff -r 85f623e1ef41 -r 29d87345eaeb harvester/client/src/harvesterclient.cpp --- a/harvester/client/src/harvesterclient.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/client/src/harvesterclient.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -183,20 +183,23 @@ delete iSessionWatcher; iSessionWatcher = NULL; - + + WRITELOG( "RHarvesterClient::Close() - cancelling pending harvesting requests" ); if( iRequestQueue && iRequestQueue->RequestsPending() ) { iRequestQueue->Cancel(); } - // cancels Harvest Complete request if it exist at server + WRITELOG( "RHarvesterClient::Close() - removing harvester client observer" ); if( iObserver ) { RemoveObserver( iObserver ); } + UnregisterHarvestComplete(); WRITELOG( "RHarvesterClient::Close() - UnregisterHarvest done" ); + WRITELOG( "RHarvesterClient::Close() - forcing remaining harvesting requests" ); if( iRequestQueue && iRequestQueue->RequestsPending() ) { WRITELOG( "RHarvesterClient::Close() - Pending harvesting requests detected -> ForceHarvest" ); @@ -211,6 +214,7 @@ delete iHEO; iHEO = NULL; + WRITELOG( "RHarvesterClient::Close() - deleting harvester client AO" ); delete iHarvesterClientAO; iHarvesterClientAO = NULL; @@ -250,6 +254,7 @@ if ( iHarvesterClientAO ) { + WRITELOG( "RHarvesterClient::RemoveObserver() - calling iHarvesterClientAO->RemoveObserver" ); iHarvesterClientAO->RemoveObserver( aObserver ); } diff -r 85f623e1ef41 -r 29d87345eaeb harvester/client/src/harvesterclientao.cpp --- a/harvester/client/src/harvesterclientao.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/client/src/harvesterclientao.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -51,7 +51,7 @@ OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_CHARVESTERCLIENTAO, "CHarvesterClientAO::~CHarvesterClientAO" ); WRITELOG( "CHarvesterClientAO::~CHarvesterClientAO()" ); - Cancel(); + CancelRequest(); } // --------------------------------------------------------------------------- @@ -60,9 +60,10 @@ // --------------------------------------------------------------------------- // CHarvesterClientAO::CHarvesterClientAO( RHarvesterClient& aHarvesterClient ) - : CActive( CActive::EPriorityStandard ), + : CActive( CActive::EPriorityUserInput ), iObserver( NULL ), - iHarvesterClient( aHarvesterClient ) + iHarvesterClient( aHarvesterClient ), + iCancelled( EFalse ) { OstTrace0( TRACE_NORMAL, DUP1_CHARVESTERCLIENTAO_CHARVESTERCLIENTAO, "CHarvesterClientAO::CHarvesterClientAO" ); @@ -100,13 +101,14 @@ void CHarvesterClientAO::RemoveObserver( MHarvestObserver* /*aObserver*/ ) { WRITELOG( "CHarvesterClientAO::RemoveObserver()" ); + OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_REMOVEOBSERVER, "CHarvesterClientAO::RemoveObserver" ); if ( iObserver ) { WRITELOG( "CHarvesterClientAO::RemoveObserver() - deleting observer" ); iObserver = NULL; } - Cancel(); + CancelRequest(); } // --------------------------------------------------------------------------- @@ -118,6 +120,7 @@ WRITELOG( "CHarvesterClientAO::DoCancel()" ); OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_DOCANCEL, "CHarvesterClientAO::DoCancel" ); iHarvesterClient.UnregisterHarvestComplete(); + WRITELOG( "CHarvesterClientAO::DoCancel() - end" ); } // --------------------------------------------------------------------------- @@ -126,9 +129,12 @@ // void CHarvesterClientAO::Active() { + WRITELOG( "CHarvesterClientAO::Active" ); if ( iObserver && !IsActive()) { + WRITELOG( "CHarvesterClientAO::Active - calling RegisterHarvestComplete" ); iHarvesterClient.RegisterHarvestComplete(iURI, iStatus); + iCancelled = EFalse; SetActive(); } } @@ -157,10 +163,12 @@ } // if the request was not canceled or server is not terminated, Activating AO again - if ( status != KErrCancel && status != KErrServerTerminated && iObserver ) + if ( status != KErrCancel && status != KErrServerTerminated && iObserver && !iCancelled ) { + WRITELOG( "CHarvesterClientAO::RunL() - not cancelled or terminated, calling Active" ); Active(); } + WRITELOG( "CHarvesterClientAO::RunL() - end" ); } // --------------------------------------------------------------------------- @@ -177,3 +185,24 @@ return KErrNone; } + +// --------------------------------------------------------------------------- +// Active +// --------------------------------------------------------------------------- +// +void CHarvesterClientAO::CancelRequest() + { + WRITELOG( "CHarvesterClientAO::CancelRequest" ); + if( !iCancelled ) + { + WRITELOG( "CHarvesterClientAO::CancelRequest - not cancelled, calling Cancel" ); + iCancelled = ETrue; + Cancel(); + } + if( !IsActive() ) + { + WRITELOG( "CHarvesterClientAO::CancelRequest - setting priority to High" ); + SetPriority( CActive::EPriorityHigh ); + } + } + diff -r 85f623e1ef41 -r 29d87345eaeb harvester/client/traces/fixed_id.definitions --- a/harvester/client/traces/fixed_id.definitions Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/client/traces/fixed_id.definitions Tue Sep 14 22:10:25 2010 +0300 @@ -4,6 +4,7 @@ [TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_CONSTRUCTL=0x10 [TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_DOCANCEL=0x13 [TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_NEWL=0xd +[TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_REMOVEOBSERVER=0x15 [TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_RUNL=0x14 [TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_SETOBSERVER=0x11 [TRACE]TRACE_NORMAL[0x3]_DUP1_CHARVESTERCLIENTAO_CHARVESTERCLIENTAO=0xf diff -r 85f623e1ef41 -r 29d87345eaeb harvester/client/traces/harvesterclientaoTraces.h --- a/harvester/client/traces/harvesterclientaoTraces.h Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/client/traces/harvesterclientaoTraces.h Tue Sep 14 22:10:25 2010 +0300 @@ -13,6 +13,7 @@ #define CHARVESTERCLIENTAO_SETOBSERVER 0x30011 #define CHARVESTERCLIENTAO_DOCANCEL 0x30013 #define CHARVESTERCLIENTAO_RUNL 0x30014 +#define CHARVESTERCLIENTAO_REMOVEOBSERVER 0x30015 #endif diff -r 85f623e1ef41 -r 29d87345eaeb harvester/common/bwincw/harvesterplugininterfacewinscw.def --- a/harvester/common/bwincw/harvesterplugininterfacewinscw.def Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/common/bwincw/harvesterplugininterfacewinscw.def Tue Sep 14 22:10:25 2010 +0300 @@ -13,4 +13,5 @@ ?GetMimeType@CHarvesterPlugin@@UAEXABVTDesC16@@AAVTDes16@@@Z @ 12 NONAME ; void CHarvesterPlugin::GetMimeType(class TDesC16 const &, class TDes16 &) ?SetHarvesterPluginFactory@CHarvesterPlugin@@QAEXAAVCHarvesterPluginFactory@@@Z @ 13 NONAME ; void CHarvesterPlugin::SetHarvesterPluginFactory(class CHarvesterPluginFactory &) ?PluginInIdleState@CHarvesterPlugin@@QAEHXZ @ 14 NONAME ; int CHarvesterPlugin::PluginInIdleState(void) + ?StopHarvest@CHarvesterPlugin@@UAEXXZ @ 15 NONAME ; void CHarvesterPlugin::StopHarvest(void) diff -r 85f623e1ef41 -r 29d87345eaeb harvester/common/eabi/harvesterplugininterfacearm.def --- a/harvester/common/eabi/harvesterplugininterfacearm.def Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/common/eabi/harvesterplugininterfacearm.def Tue Sep 14 22:10:25 2010 +0300 @@ -17,4 +17,5 @@ _ZN16CHarvesterPlugin11GetMimeTypeERK7TDesC16R6TDes16 @ 16 NONAME _ZN16CHarvesterPlugin25SetHarvesterPluginFactoryER23CHarvesterPluginFactory @ 17 NONAME _ZN16CHarvesterPlugin17PluginInIdleStateEv @ 18 NONAME + _ZN16CHarvesterPlugin11StopHarvestEv @ 19 NONAME diff -r 85f623e1ef41 -r 29d87345eaeb harvester/common/inc/harvestercommon.h --- a/harvester/common/inc/harvestercommon.h Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/common/inc/harvestercommon.h Tue Sep 14 22:10:25 2010 +0300 @@ -107,9 +107,8 @@ // Between Standard and UserInput to allow components to react to important events correctly const TInt KHarvesterCustomImportantPriority = 5; -// Higher than MonitorPlugin priority but lower than High to ensure server can answer to all -// connection requests as fast as possible -const TInt KHarvesterServerSessionPriority = 11; +// Higher than MonitorPlugin priority but lower than High. Highest priority within Harvester +const TInt KHarvesterServerHighPriority = 11; #endif diff -r 85f623e1ef41 -r 29d87345eaeb harvester/common/inc/harvesterpluginfactory.h --- a/harvester/common/inc/harvesterpluginfactory.h Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/common/inc/harvesterpluginfactory.h Tue Sep 14 22:10:25 2010 +0300 @@ -61,6 +61,9 @@ TBool iHarvesting; CHarvesterEventManager* iHarvesterEventManager; + + HBufC* iLastConfirmedContainerExt; + HBufC* iLastConfirmedSupportedExt; }; #endif diff -r 85f623e1ef41 -r 29d87345eaeb harvester/common/src/harvesterexifutil.cpp --- a/harvester/common/src/harvesterexifutil.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/common/src/harvesterexifutil.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -433,7 +433,7 @@ EXPORT_C TTime CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL( const TDesC8& aDateTime ) { - WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL()" ); + WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL()" ); OstTrace0( TRACE_NORMAL, CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL" ); TDateTime datetime( 0, EJanuary, 0, 0, 0, 0, 0 ); @@ -446,7 +446,7 @@ TInt error = lex.Val( number ); if ( error != KErrNone ) { - WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get year" ); + WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get year" ); OstTrace0( TRACE_NORMAL, DUP1_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get year" ); User::Leave( error ); @@ -459,7 +459,7 @@ error = lex.Val( number ); if ( error != KErrNone ) { - WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get month" ); + WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get month" ); OstTrace0( TRACE_NORMAL, DUP2_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get month" ); User::Leave( error ); @@ -474,7 +474,7 @@ error = lex.Val( number ); if ( error != KErrNone ) { - WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get date" ); + WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get date" ); OstTrace0( TRACE_NORMAL, DUP3_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get date" ); User::Leave( error ); @@ -487,7 +487,7 @@ error = lex.Val( number ); if ( error != KErrNone ) { - WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get hours" ); + WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get hours" ); OstTrace0( TRACE_NORMAL, DUP4_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get hours" ); User::Leave( error ); @@ -500,7 +500,7 @@ error = lex.Val( number ); if ( error != KErrNone ) { - WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get minutes" ); + WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get minutes" ); OstTrace0( TRACE_NORMAL, DUP5_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get minutes" ); User::Leave( error ); @@ -513,7 +513,7 @@ error = lex.Val( number ); if ( error != KErrNone ) { - WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get seconds" ); + WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get seconds" ); OstTrace0( TRACE_NORMAL, DUP6_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get seconds" ); User::Leave( error ); @@ -829,7 +829,9 @@ WRITELOG( "CHarvesterExifUtil::ComposeExifData() - Image doesn't contain EXIF data" ); modifyExif = CExifModify::NewL( aImagePtr, CExifModify::ECreate, CExifModify::ENoJpegParsing ); + CleanupStack::PushL( modifyExif ); SetExifDefaultsL( aMdeObject, *modifyExif ); + CleanupStack::Pop( modifyExif ); exifChanged = ETrue; } CleanupStack::PushL( modifyExif ); diff -r 85f623e1ef41 -r 29d87345eaeb harvester/common/src/harvesterplugin.cpp --- a/harvester/common/src/harvesterplugin.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/common/src/harvesterplugin.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -65,7 +65,8 @@ iDtor_ID_Key( KNullUid ), iOriginPropertyDef( NULL ), iTitlePropertyDef( NULL ), - iHarvesting( EFalse ) + iHarvesting( EFalse ), + iPaused( EFalse ) { } @@ -109,6 +110,7 @@ { if( iState == EHarvesterIdle ) { + iPaused = EFalse; SetNextRequest( EHarvesterGathering ); } } @@ -154,6 +156,7 @@ } else { + WRITELOG( "CHarvesterPlugin::RunL EHarvesterGathering - items in queue" ); if ( !iHarvesting ) { TRAP_IGNORE( iFactory->SendHarvestingStatusEventL( ETrue ) ); @@ -244,12 +247,28 @@ } // --------------------------------------------------------------------------- +// StartHarvest +// --------------------------------------------------------------------------- +// +EXPORT_C void CHarvesterPlugin::StopHarvest() + { + Cancel(); + iState = EHarvesterIdle; + if( iHarvesting ) + { + TRAP_IGNORE( iFactory->SendHarvestingStatusEventL( EFalse ) ); + iHarvesting = EFalse; + } + iPaused = ETrue; + } + +// --------------------------------------------------------------------------- // SetNextRequest // --------------------------------------------------------------------------- // void CHarvesterPlugin::SetNextRequest( THarvesterState aState ) { - if ( ! IsActive() ) + if ( !IsActive() && !iPaused ) { iState = aState; SetActive(); diff -r 85f623e1ef41 -r 29d87345eaeb harvester/common/src/harvesterpluginfactory.cpp --- a/harvester/common/src/harvesterpluginfactory.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/common/src/harvesterpluginfactory.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -68,6 +68,12 @@ { WRITELOG( "CHarvesterPluginFactory::~CHarvesterPluginFactory()" ); + delete iLastConfirmedContainerExt; + iLastConfirmedContainerExt = NULL; + + delete iLastConfirmedSupportedExt; + iLastConfirmedSupportedExt = NULL; + if (iHarvesterEventManager) { iHarvesterEventManager->ReleaseInstance(); @@ -330,6 +336,13 @@ TPtrC extPtr; if( MdsUtils::GetExt( aFileName, extPtr ) ) { + if( iLastConfirmedSupportedExt && + extPtr.CompareF( iLastConfirmedSupportedExt->Des() ) == 0 ) + { + // Extension has previously been confirmed to be + // supported file extension, no need to ask from plugins + return ETrue; + } TInt pluginInfoCount = iHarvesterPluginInfoArray.Count(); TInt extCount = 0; for ( TInt i = pluginInfoCount; --i >= 0; ) @@ -343,6 +356,9 @@ TInt result = MdsUtils::Compare( *ext, extPtr ); if ( result == 0 ) { + delete iLastConfirmedSupportedExt; + iLastConfirmedSupportedExt = NULL; + iLastConfirmedSupportedExt = extPtr.Alloc(); return ETrue; } } @@ -358,6 +374,14 @@ if( MdsUtils::GetExt( aURI, extPtr ) ) { + if( iLastConfirmedContainerExt && + extPtr.CompareF( iLastConfirmedContainerExt->Des() ) == 0 ) + { + // Extension has previously been confirmed to be + // container file extension, no need to ask from plugins + return ETrue; + } + RPointerArray supportedPlugins; CleanupClosePushL( supportedPlugins ); GetSupportedPluginsL( supportedPlugins, extPtr ); @@ -367,6 +391,9 @@ if( info->iObjectTypes.Count() > 1 ) { isContainerFile = ETrue; + delete iLastConfirmedContainerExt; + iLastConfirmedContainerExt = NULL; + iLastConfirmedContainerExt = extPtr.Alloc(); break; } } @@ -395,6 +422,7 @@ EXPORT_C void CHarvesterPluginFactory::SendHarvestingStatusEventL( TBool aStarted ) { + WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL" ); const TInt pluginInfoCount = iHarvesterPluginInfoArray.Count(); TBool itemsLeft( EFalse ); TBool allPluginsOnIdle( ETrue ); @@ -418,6 +446,7 @@ if( !iHarvesting && itemsLeft && aStarted ) { + WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL - overall started" ); iHarvesting = ETrue; iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateStarted ); // This next line is for caching the harvester started event for observers registering @@ -427,6 +456,7 @@ } else if( iHarvesting && (!itemsLeft || allPluginsOnIdle) && !aStarted ) { + WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL - overall finished" ); iHarvesting = EFalse; iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateFinished ); iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeOverall, KCacheItemCountForEventCaching ); @@ -440,7 +470,7 @@ { if( iHarvesterPluginInfoArray[i]->iPlugin && aPaused ) { - iHarvesterPluginInfoArray[i]->iPlugin->Cancel(); + iHarvesterPluginInfoArray[i]->iPlugin->StopHarvest(); } else if( iHarvesterPluginInfoArray[i]->iPlugin ) { @@ -481,6 +511,8 @@ info->iPlugin->SetBlacklist( *iBlacklist ); } info->iPlugin->GetObjectType( aHD->Uri(), aObjectDef ); + // It is possible for unmount to occure while we are waiting + // for GetObjectType to return, thus check aHD for validity if( aHD && aObjectDef.Length() > 0 ) { aHD->SetHarvesterPluginInfo( info ); diff -r 85f623e1ef41 -r 29d87345eaeb harvester/common/src/mdeobjectwrapper.cpp --- a/harvester/common/src/mdeobjectwrapper.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/common/src/mdeobjectwrapper.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -157,7 +157,7 @@ case EPropertyReal32: { TReal32* value = static_cast( aData ); - WRITELOG2("CMdeObjectWrapper::HandleObjectPropertyL - Edit property: %S with value %d", &aPropertyDef.Name(), *value ); + WRITELOG2("CMdeObjectWrapper::HandleObjectPropertyL - Edit property: %S with value %f", &aPropertyDef.Name(), *value ); property->SetReal32ValueL( *value ); } break; @@ -173,9 +173,7 @@ case EPropertyTime: { TTime* value = static_cast( aData ); -#ifdef _DEBUG - WRITELOG2("CMdeObjectWrapper::HandleObjectPropertyL - Edit property: %S with value %d", &aPropertyDef.Name(), value->Int64() ); -#endif + WRITELOG2("CMdeObjectWrapper::HandleObjectPropertyL - Edit property: %S with value %u", &aPropertyDef.Name(), value->Int64() ); property->SetTimeValueL( *value ); } break; diff -r 85f623e1ef41 -r 29d87345eaeb harvester/composerplugins/imagecomposer/src/imagecomposerao.cpp --- a/harvester/composerplugins/imagecomposer/src/imagecomposerao.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/composerplugins/imagecomposer/src/imagecomposerao.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -275,7 +275,7 @@ SetNextRequest( ERequestCompose ); } - // if object does not exists, find next + // if object does not exists, or data is not modified, find next else if ( err == KErrNotFound || err == KErrAbort ) { if ( err == KErrAbort && mdeObjectId != KNoId ) @@ -423,6 +423,7 @@ if( error != KErrNone || entry.iModified == time ) { + WRITELOG( "CImageComposerAO::GetObjectFromMdeL() - image data has not been modified - abort" ); User::Leave( KErrAbort ); } } diff -r 85f623e1ef41 -r 29d87345eaeb harvester/composerplugins/imagecomposer/src/imagepresentobserver.cpp --- a/harvester/composerplugins/imagecomposer/src/imagepresentobserver.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/composerplugins/imagecomposer/src/imagepresentobserver.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -87,8 +87,10 @@ void CImagePresentObserver::HandleObjectPresentNotification(CMdESession& /*aSession*/, TBool aPresent, const RArray& aObjectIdArray) { + WRITELOG( "CImagePresentObserver::HandleObjectPresentNotification" ); if ( aPresent ) { + WRITELOG( "CImagePresentObserver::HandleObjectPresentNotification - objects present" ); if ( !iStarted ) { CMdEObjectDef* imageObjDef = NULL; diff -r 85f623e1ef41 -r 29d87345eaeb harvester/harvesterplugins/OMADRMPlugin/src/harvesteromadrmplugin.cpp --- a/harvester/harvesterplugins/OMADRMPlugin/src/harvesteromadrmplugin.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/harvesterplugins/OMADRMPlugin/src/harvesteromadrmplugin.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -193,7 +193,7 @@ void CHarvesterOMADRMPlugin::HarvestL( CHarvesterData* aHarvesterData ) { - WRITELOG( "CHarvesterImagePlugin::HarvestL()" ); + WRITELOG( "CHarvesterOMADRMPlugin::HarvestL()" ); CMdEObject& mdeObject = aHarvesterData->MdeObject(); CDRMHarvestData* drmHarvestData = CDRMHarvestData::NewL(); CleanupStack::PushL( drmHarvestData ); @@ -330,31 +330,36 @@ WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting protection info failed %d", err ); } - CImageDecoder* decoder = NULL; - - TRAP( err, decoder = CImageDecoder::FileNewL( iFs, uri, ContentAccess::EPeek, - ( CImageDecoder::TOptions )( CImageDecoder::EPreferFastDecode ))); - - CleanupStack::PushL( decoder ); - - if(decoder && !err) + if( aMetadataObject.Def().Name() == MdeConstants::Image::KImageObject ) { - WRITELOG( "CHarvesterImagePlugin::GatherData() - Image decoder has opened the file." ); - // Get image width, frame count, height and bits per pixel from image decoder. - const TFrameInfo info = decoder->FrameInfo( 0 ); - const TSize imageSize = info.iOverallSizeInPixels; - const TInt framecount = decoder->FrameCount(); - aFileData.iFrameCount = framecount; - aFileData.iImageWidth = imageSize.iWidth; - aFileData.iImageHeight = imageSize.iHeight; - aFileData.iBitsPerPixel = info.iBitsPerPixel; - } - else - { - WRITELOG1( "CHarvesterImagePlugin::GatherData() - ERROR: decoder %d", err ); + CImageDecoder* decoder = NULL; + + TRAP( err, decoder = CImageDecoder::FileNewL( iFs, uri, ContentAccess::EPeek, + ( CImageDecoder::TOptions )( CImageDecoder::EPreferFastDecode ))); + + CleanupStack::PushL( decoder ); + + if(decoder && !err) + { + WRITELOG( "CHarvesterImagePlugin::GatherData() - Image decoder has opened the file." ); + // Get image width, frame count, height and bits per pixel from image decoder. + const TFrameInfo info = decoder->FrameInfo( 0 ); + const TSize imageSize = info.iOverallSizeInPixels; + const TInt framecount = decoder->FrameCount(); + aFileData.iFrameCount = framecount; + aFileData.iImageWidth = imageSize.iWidth; + aFileData.iImageHeight = imageSize.iHeight; + aFileData.iBitsPerPixel = info.iBitsPerPixel; + } + else + { + WRITELOG1( "CHarvesterImagePlugin::GatherData() - ERROR: decoder %d", err ); + } + CleanupStack::PopAndDestroy( decoder ); } - CleanupStack::PopAndDestroy( 4 ); // content, data, attrSet, imagedecoder + + CleanupStack::PopAndDestroy( 3 ); // content, data, attrSet return KErrNone; } diff -r 85f623e1ef41 -r 29d87345eaeb harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp --- a/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -339,7 +339,7 @@ if ( error != KErrNone ) { WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - File open error: %d", error ); - if( error == KErrInUse ) + if( error == KErrInUse || KErrLocked ) { #ifdef _DEBUG TPtrC fileName( aUri.Mid(2) ); @@ -627,6 +627,7 @@ TRAP( error, helixMetadata->OpenFileL( file ) ); // No need for the file handle anymore so closing it + WRITELOG( "CHarvesterVideoPlugin - Parsing done, file handle can be closed" ); file.Close(); if ( error == KErrNone ) @@ -981,7 +982,7 @@ } #endif } - WRITELOG( "CHarvesterVideoPlugin - Closing file" ); + WRITELOG( "CHarvesterVideoPlugin - Closing file, if still open" ); CleanupStack::PopAndDestroy( &file ); #ifdef _DEBUG @@ -1247,6 +1248,7 @@ CleanupStack::PushL( helixMetadata ); TRAPD( err, helixMetadata->OpenFileL( aFile ) ); + aFile.Close(); if( err == KErrNone ) { @@ -1273,10 +1275,10 @@ const TInt mimeCount = mimes.Count(); - // at least one MIME type must be found + // Set to Video, regardless how badly file is corrupted if( mimeCount == 0 ) { - User::Leave( KErrNotFound ); + aType.Copy( KVideo ); } for( TInt i = 0; i < mimeCount; i++ ) @@ -1336,8 +1338,7 @@ if( blackListError == KErrNone ) { RemoveFileFromBlackList( tempName, mediaId ); - } - + } } TInt CHarvesterVideoPlugin::AddFileToBlackList( const TFileName& aFullName, const TUint32& aMediaId ) diff -r 85f623e1ef41 -r 29d87345eaeb harvester/monitorplugins/fileplugin/src/processoriginmapper.cpp --- a/harvester/monitorplugins/fileplugin/src/processoriginmapper.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/monitorplugins/fileplugin/src/processoriginmapper.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -227,7 +227,7 @@ // TInt CProcessOriginMapper::ReadFileL() { - WRITELOG( "CProcessOriginMapper::ReadFileL - reading default file..." ); + WRITELOG( "CProcessOriginMapper::ReadFileL - reading default file" ); iDefaultFileRead = ETrue; const TInt count = ReadFileL( KDefaultMappingFile ); iDefaultFileRead = EFalse; diff -r 85f623e1ef41 -r 29d87345eaeb harvester/monitorplugins/mmcplugin/inc/mmcmounttaskao.h --- a/harvester/monitorplugins/mmcplugin/inc/mmcmounttaskao.h Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/monitorplugins/mmcplugin/inc/mmcmounttaskao.h Tue Sep 14 22:10:25 2010 +0300 @@ -53,9 +53,9 @@ void SetHarvesterPluginFactory( CHarvesterPluginFactory* aPluginFactory ); /** - * Returns internal hard drive's media id if the device has one. 0 if not or drive is not present + * Returns internal hard drive's media id if the device has one. */ - TUint32 GetInternalDriveMediaId(); + TUint32 GetInternalDriveMediaId( TBool& aPresent ); void SetCachingStatus( TBool aCachingStatus ); diff -r 85f623e1ef41 -r 29d87345eaeb harvester/monitorplugins/mmcplugin/src/mmcfilelist.cpp --- a/harvester/monitorplugins/mmcplugin/src/mmcfilelist.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/monitorplugins/mmcplugin/src/mmcfilelist.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -104,7 +104,7 @@ TUint32 mediaId( 0 ); iMediaIdUtil->GetMediaId( aDrivePath, mediaId ); - WRITELOG1( "CMmcFileList::BuildFileListL - mediaId: %d", mediaId ); + WRITELOG1( "CMmcFileList::BuildFileListL - mediaId: %u", mediaId ); CDir* directory = NULL; TFileName name; @@ -294,7 +294,6 @@ aEntryArray.Compress(); } - WRITELOG( "CMmcFileList::HandleFileEntryL -- cleanupstack" ); CleanupStack::PopAndDestroy( &results ); CleanupStack::PopAndDestroy( &fileInfos ); CleanupStack::PopAndDestroy( &uris ); diff -r 85f623e1ef41 -r 29d87345eaeb harvester/monitorplugins/mmcplugin/src/mmcmonitorao.cpp --- a/harvester/monitorplugins/mmcplugin/src/mmcmonitorao.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/monitorplugins/mmcplugin/src/mmcmonitorao.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -124,6 +124,8 @@ return; } + StartNotify(); + iPreviousDriveList.Zero(); iPreviousDriveList.Copy( iDriveList ); @@ -138,8 +140,6 @@ #ifdef _DEBUG PrintAllLists(); #endif - - StartNotify(); } #ifdef _DEBUG @@ -161,7 +161,7 @@ iFs.NotifyChangeCancel( iStatus ); } -CMMCMonitorAO::CMMCMonitorAO() : CActive( KHarvesterPriorityMonitorPlugin ), +CMMCMonitorAO::CMMCMonitorAO() : CActive( KHarvesterServerHighPriority ), iObserver( NULL ) { } @@ -283,7 +283,7 @@ { if ( iMediaIdList[i] != mediaId ) { - WRITELOG3( "CMMCMonitorAO::CompareDriveLists media changed %d, old=%d, new=%d", i, iMediaIdList[i], mediaId ); // DEBUG INFO + WRITELOG3( "CMMCMonitorAO::CompareDriveLists media changed %d, old=%u, new=%u", i, iMediaIdList[i], mediaId ); // DEBUG INFO // skip mount events if mediaId is 0 if ( iMediaIdList[i] != 0 ) { diff -r 85f623e1ef41 -r 29d87345eaeb harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp --- a/harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -116,7 +116,8 @@ TBool presentState( EFalse ); TUint32 hdMediaId( 0 ); - hdMediaId = iMountTask->GetInternalDriveMediaId(); + TBool hdPresent( EFalse ); + hdMediaId = iMountTask->GetInternalDriveMediaId( hdPresent ); for( TInt i = medias.Count() - 1; i >=0; i-- ) { @@ -137,10 +138,10 @@ } } - if( hdMediaId == 0 ) + if( hdMediaId == 0 || !hdPresent ) { // Try to fetch internall mass storage media id again if it was not mounted - hdMediaId = iMountTask->GetInternalDriveMediaId(); + hdMediaId = iMountTask->GetInternalDriveMediaId( hdPresent ); } // scan mass storage to catch all chances even if battery dies during operation that should be catched @@ -149,7 +150,7 @@ TBool exists( EFalse ); TRAP_IGNORE( exists= iMdEClient->GetMediaL( hdMediaId, driveLetter, presentState ) ); - if ( exists ) + if ( exists && hdPresent ) { WRITELOG("CMMCMonitorPlugin::StartMonitoring - start mass storage scan"); @@ -267,33 +268,39 @@ if( internalMassStorageError == KErrNone ) { const TUint32 massStorageMediaId( internalMassStorageVolumeInfo.iUniqueID ); - TUint32 mmcMediaId( 0 ); - TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive ) ); - if( mmcError == KErrNone ) + if( massStorageMediaId == aMediaID && + 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 && - massStorageMediaId == aMediaID ) + // If removable storage is not found, assume internal mass storage was mounted + if( mmcError ) + { + iMdEClient->CheckMassStorageMediaId( massStorageMediaId ); + } + else if( massStorageMediaId != mmcMediaId ) { iMdEClient->CheckMassStorageMediaId( massStorageMediaId ); - } - } - else if( massStorageMediaId != mmcMediaId && - massStorageMediaId != 0 && - massStorageMediaId == aMediaID ) - { - iMdEClient->CheckMassStorageMediaId( massStorageMediaId ); - } + } + } } } diff -r 85f623e1ef41 -r 29d87345eaeb harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp --- a/harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -114,6 +114,25 @@ { WRITELOG("CMMCMountTaskAO::StartMount"); + // Remove pending mount request for the same drive + // if for example USB cable is pluged and unpluged + // several times in a row + for( TInt i = iMountDataQueue.Count() - 1; i >=0; i-- ) + { + WRITELOG( "CMMCMountTaskAO::StartUnmountL - checking for pending mount notifications" ); + TMountData* tempData = iMountDataQueue[i]; + if( tempData->iMediaID == aMountData.iMediaID && + tempData->iMountType == TMountData::EMount && + aMountData.iMountType == TMountData::EMount && + tempData->iDrivePath == aMountData.iDrivePath ) + { + WRITELOG( "CMMCMountTaskAO::StartUnmountL - removing obsolite mount notifications" ); + iMountDataQueue.Remove(i); + delete tempData; + tempData = NULL; + } + } + User::LeaveIfError( iMountDataQueue.Append( &aMountData )); if ( iNextRequest == ERequestIdle ) @@ -135,7 +154,26 @@ Deinitialize(); } } - + + // Remove pending unmount request for the same drive + // if for example USB cable is pluged and unpluged + // several times in a row + for( TInt i = iMountDataQueue.Count() - 1; i >=0; i-- ) + { + WRITELOG( "CMMCMountTaskAO::StartUnmountL - checking for pending unmount notifications" ); + TMountData* tempData = iMountDataQueue[i]; + if( tempData->iMediaID == aMountData.iMediaID && + tempData->iMountType == TMountData::EUnmount && + aMountData.iMountType == TMountData::EUnmount && + tempData->iDrivePath == aMountData.iDrivePath ) + { + WRITELOG( "CMMCMountTaskAO::StartUnmountL - removing obsolite unmount notifications" ); + iMountDataQueue.Remove(i); + delete tempData; + tempData = NULL; + } + } + User::LeaveIfError( iMountDataQueue.Append( &aMountData )); SetNextRequest( ERequestStartTask ); @@ -181,7 +219,7 @@ WRITELOG1( "iMountData.iMountType: %d", iMountData->iMountType ); WRITELOG1( "iMountData.iDrivePath: %S", &iMountData->iDrivePath ); - WRITELOG1( "iMountData.iMediaID: %d", iMountData->iMediaID ); + WRITELOG1( "iMountData.iMediaID: %u", iMountData->iMediaID ); if ( iMountData->iMountType == TMountData::EMount ) { @@ -393,6 +431,7 @@ { WRITELOG1( "CMMCMountTaskAO::RunError with error code: %d", aError ); Deinitialize(); + SetNextRequest( ERequestStartTask ); return KErrNone; } @@ -415,7 +454,7 @@ void CMMCMountTaskAO::SetNotPresentToMDE() { - WRITELOG1("CMMCMountTaskAO::SetNotPresentToMDE - MediaID %d", iMountData->iMediaID); + WRITELOG1("CMMCMountTaskAO::SetNotPresentToMDE - MediaID %u", iMountData->iMediaID); if ( iMountData->iMediaID ) { iMdeSession->SetFilesToNotPresent( iMountData->iMediaID ); @@ -538,7 +577,7 @@ } } -TUint32 CMMCMountTaskAO::GetInternalDriveMediaId() +TUint32 CMMCMountTaskAO::GetInternalDriveMediaId( TBool& aPresent ) { WRITELOG( "CMMCMountTaskAO::GetInternalDriveMediaId" ); @@ -581,10 +620,15 @@ // check if disk is internal TUint driveStatus; const TInt err = DriveInfo::GetDriveStatus( iFs, i, driveStatus ); - if ( (err == KErrNone ) && ( driveStatus & DriveInfo::EDriveInternal ) ) + if ( ( err == KErrNone ) && + ( driveStatus & DriveInfo::EDriveInternal )) { // get media id hdMediaId = FSUtil::MediaID( iFs, i ); + if( driveStatus & DriveInfo::EDrivePresent ) + { + aPresent = ETrue; + } break; } } diff -r 85f623e1ef41 -r 29d87345eaeb harvester/monitorplugins/mmcplugin/src/mmcscannerao.cpp --- a/harvester/monitorplugins/mmcplugin/src/mmcscannerao.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/monitorplugins/mmcplugin/src/mmcscannerao.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -108,6 +108,14 @@ { case( EUninitialized ): { + WRITELOG("CMmcScannerAO::RunL - Starting processing"); + if( iMediaId == 0 ) + { + WRITELOG("CMmcScannerAO::RunL - MediaId == 0 -> end"); + SetState( EDone ); + break; + } + WRITELOG("CMmcScannerAO::RunL - Setting files to not present"); iMdEClient->SetFilesToNotPresent( iMediaId, ETrue ); SetState( EReadFiles ); diff -r 85f623e1ef41 -r 29d87345eaeb harvester/monitorplugins/mmcplugin/src/mmcusbao.cpp --- a/harvester/monitorplugins/mmcplugin/src/mmcusbao.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/monitorplugins/mmcplugin/src/mmcusbao.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -136,7 +136,7 @@ TFileName* fn = new (ELeave) TFileName( driveChar ); _LIT( KIndicator, ":" ); fn->Append( KIndicator ); - WRITELOG1( "CMMCUsbAO::RunL - drive letter: %S", fn ); + WRITELOG1( "CMMCUsbAO::RunL - drive letter: %S", &(*fn) ); PrintDriveStatus( driveStatus ); delete fn; fn = NULL; diff -r 85f623e1ef41 -r 29d87345eaeb harvester/server/inc/harvesterao.h --- a/harvester/server/inc/harvesterao.h Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/server/inc/harvesterao.h Tue Sep 14 22:10:25 2010 +0300 @@ -22,6 +22,8 @@ #include #include +#include + #include "contextengine.h" #include "mdeharvestersession.h" @@ -584,7 +586,11 @@ HBufC* iMmcSoundsPath; TBool iUnmountDetected; + TBool iUnmountHandlingOngoing; TBool iPriorityInterruptDetected; + + RLocationObjectManipulator iLocManipulator; + TBool iLocManipulatorConnected; }; #endif //__CHARVESTERAO_H__ diff -r 85f623e1ef41 -r 29d87345eaeb harvester/server/src/harvesterao.cpp --- 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 #include -#include #include #include #include @@ -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(); diff -r 85f623e1ef41 -r 29d87345eaeb harvester/server/src/harvesterqueue.cpp --- a/harvester/server/src/harvesterqueue.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/server/src/harvesterqueue.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -144,7 +144,7 @@ WRITELOG( "CHarvesterQueue::Append()" ); TInt err( KErrNone ); - if ( iBlacklist ) + if ( iBlacklist && aItem->Origin() != MdeConstants::Object::ECamera ) { TUint32 mediaId( 0 ); err = iMediaIdUtil->GetMediaId( aItem->Uri(), mediaId ); diff -r 85f623e1ef41 -r 29d87345eaeb harvester/server/src/harvesterserver.cpp --- a/harvester/server/src/harvesterserver.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/server/src/harvesterserver.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -162,7 +162,7 @@ WRITELOG( "CHarvesterServer::NewLC() - begin" ); CHarvesterServer* self = new (ELeave) CHarvesterServer( - KHarvesterServerSessionPriority, KHarvesterServerPolicy, + KHarvesterServerHighPriority, KHarvesterServerPolicy, ESharableSessions ); CleanupStack::PushL( self ); self->ConstructL(); diff -r 85f623e1ef41 -r 29d87345eaeb harvester/server/src/ondemandao.cpp --- a/harvester/server/src/ondemandao.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/server/src/ondemandao.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -72,7 +72,7 @@ void COnDemandAO::DoCancel() { WRITELOG("COnDemandAO::DoCancel"); - iMdEHarvesterSession->CancelHarvestingPrioritizationObserver (); + iMdEHarvesterSession->CancelHarvestingPrioritizationObserver(); } void COnDemandAO::StartL() @@ -80,7 +80,7 @@ WRITELOG("COnDemandAO::StartL"); // Cancel any request, just to be sure Cancel (); - iMdEHarvesterSession->SetHarvestingPrioritizationChunkL ( 16384 ); + iMdEHarvesterSession->SetHarvestingPrioritizationChunkL( 16384 ); WaitHarvestingRequest (); } diff -r 85f623e1ef41 -r 29d87345eaeb harvester/server/src/reharvesterao.cpp --- a/harvester/server/src/reharvesterao.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/harvester/server/src/reharvesterao.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -170,13 +170,7 @@ } } - CMdEObject* mdeObject = &aItem->MdeObject(); - if( mdeObject ) - { - delete mdeObject; - mdeObject = NULL; - aItem->SetMdeObject( NULL ); - } + aItem->SetMdeObject( NULL ); if(iItems.Append( aItem ) != KErrNone ) { diff -r 85f623e1ef41 -r 29d87345eaeb inc/mdcdef.h --- a/inc/mdcdef.h Wed Sep 01 12:24:24 2010 +0100 +++ b/inc/mdcdef.h Tue Sep 14 22:10:25 2010 +0300 @@ -25,7 +25,7 @@ NONSHARABLE_CLASS(TMdCDef) : protected TMdCSerializationType { protected: - TMdCDef(TMdCStructTypes aType) : TMdCSerializationType( aType ) + TMdCDef(TMdCStructTypes aType) : TMdCSerializationType( aType ), iDefId( 0 ) { } diff -r 85f623e1ef41 -r 29d87345eaeb inc/mdscommoninternal.h --- a/inc/mdscommoninternal.h Wed Sep 01 12:24:24 2010 +0100 +++ b/inc/mdscommoninternal.h Tue Sep 14 22:10:25 2010 +0300 @@ -45,6 +45,9 @@ const TItemId KSystemFavouritesAlbumId = 1; +_LIT( KSystemFavouritesAlbumUri, "defaultalbum_favourites" ); +_LIT( KSystemCapturedAlbumUri, "defaultalbum_captured" ); + const TInt KMaxUintValueLength = 10; const TInt KMaxUint64ValueLength = 20; @@ -69,7 +72,7 @@ const TUint32 KNokiaVendorId = 52487775; -const TInt64 KDiskFullThreshold = 1024*50; // 50 kB +const TInt64 KDiskFullThreshold = 1024*70; // 70 kB, SQLite default maximum journal size // P&S stuff static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); diff -r 85f623e1ef41 -r 29d87345eaeb locationmanager/ReverseGeocode/inc/internalreversegeocode.h --- a/locationmanager/ReverseGeocode/inc/internalreversegeocode.h Wed Sep 01 12:24:24 2010 +0100 +++ b/locationmanager/ReverseGeocode/inc/internalreversegeocode.h Tue Sep 14 22:10:25 2010 +0300 @@ -162,10 +162,8 @@ MReverseGeocodeObserver& iObserver; CConnectionTimerHandler* iTimer; - // Optimize the buffer len..?? + TBuf8 iQueryString; - TBuf8 iAuthCode; - TBuf8 iRefURL; TBuf8 iLang; TBool iStartTimerFlag; }; diff -r 85f623e1ef41 -r 29d87345eaeb locationmanager/ReverseGeocode/src/internalreversegeocode.cpp --- a/locationmanager/ReverseGeocode/src/internalreversegeocode.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/locationmanager/ReverseGeocode/src/internalreversegeocode.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -22,18 +22,13 @@ //Maximum length for the response buffer size const int KMaxResponseLength = 2048; -//Authentication token for the Maps server -//This authentication in specific to our photo-tagging feature -_LIT8( KAuthenticationToken, "eb0ae60051e27d3cfcae94e7b47e9eff" ); -//Static RefererURL which shows that request has been made from this app -_LIT8( KRefererURL, "s60_app_photos" ); //Language option for the REST request _LIT8( KDefaultLanguage, "eng" ); //Format of the HTTP request for the reverse geocode -_LIT8( KRequestFormat, "http://loc.mobile.maps.svc.ovi.com/geocoder/rgc/1.0?token=%S&referer=%S&n=10&lat=%f&long=%f&lg=%S&output=xml" ); +_LIT8( KRequestFormat, "http://loc.mobile.maps.svc.ovi.com/geocoder/rgc/1.0?n=10&lat=%f&long=%f&lg=%S&output=xml" ); // http://www.loc.gov/marc/languages/ @@ -216,15 +211,11 @@ LOG("CInternalReverseGeocode::GetAddressByCoordinateL ,begin"); TReal64 latitude = aLocality.Latitude(); TReal64 longitude = aLocality.Longitude(); - - iAuthCode.Copy( KAuthenticationToken ); - iRefURL.Copy( KRefererURL ); - GetLanguageForTheRequest( iLang ); //Form the request URI - iQueryString.Format( KRequestFormat, &iAuthCode, &iRefURL, latitude, longitude, &iLang ); + iQueryString.Format( KRequestFormat, latitude, longitude, &iLang ); TInt err = KErrNone; TRAP(err, iClientEngine->IssueHTTPGetL( iQueryString, aOption )); diff -r 85f623e1ef41 -r 29d87345eaeb locationmanager/locationtrail/src/clocationrecord.cpp --- a/locationmanager/locationtrail/src/clocationrecord.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/locationmanager/locationtrail/src/clocationrecord.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -509,7 +509,7 @@ if ( !iTrailStarted || iState == RLocationTrail::ETrailStopped) { - LOG("trail not started/stopped"); + LOG("CLocationRecord::Position(), trail not started/stopped"); iPositionInfo->Stop(); return; } @@ -533,24 +533,24 @@ case KPositionQualityLoss: { // Location is stored, even if it may not be valid. - LOG("Partial update"); + LOG("CLocationRecord::Position(), Partial update"); if ( iState != RLocationTrail::EWaitingGPSData && iState != RLocationTrail::ETrailStopping ) { SetCurrentState( RLocationTrail::EWaitingGPSData ); - LOG("Trail waiting for gps"); + LOG("CLocationRecord::Position(), Trail waiting for gps"); } break; } case KErrNone: { - LOG("Good GPS coordinates"); + LOG("CLocationRecord::Position(), Good GPS coordinates"); iGpsDataAvailableFlag = ETrue; if ( iState != RLocationTrail::ETrailStarted ) { if ( iRemapper ) { - LOG("Start remapping"); + LOG("CLocationRecord::Position(), Start remapping"); iRemapper->StartRemappingObjects( iNewItem.iLocationData ); if( iObserver->WaitForPositioningStopTimeout() && !RemappingNeeded() ) @@ -571,7 +571,7 @@ } default: { - LOG1("Searching GPS, aError %d", aError ); + LOG1("CLocationRecord::Position(), Searching GPS, aError %d", aError ); if ( iState != RLocationTrail::ESearchingGPS && iState != RLocationTrail::ETrailStopping ) { @@ -582,12 +582,12 @@ } } TBool fixState = CheckGPSFix( positionSatelliteInfo ); - LOG1( "fixState %d", fixState ); - LOG1( "iLastGPSFixState %d", iLastGPSFixState ); + LOG1( "CLocationRecord::Position(), fixState %d", fixState ); + LOG1( "CLocationRecord::Position(), iLastGPSFixState %d", iLastGPSFixState ); if ( iObserver && iLastGPSFixState != fixState ) { - LOG("Quality changed"); + LOG("CLocationRecord::Position(), Quality changed"); iObserver->GPSSignalQualityChanged( positionSatelliteInfo ); } @@ -968,7 +968,7 @@ { // no n/w info... put it into remap. // remove the last appended element. - LOG("No network info (offline mode + no GPS fix), keep for remapping"); + LOG("CLocationRecord::LocationSnapshotL(), No network info (offline mode + no GPS fix), keep for remapping"); TRemapItem remapItem; remapItem.iObjectId = aObjectId; remapItem.iTime = timestamp; @@ -977,7 +977,12 @@ TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1]; iMediaItems.Remove(iMediaItems.Count() - 1); iMediaItems.Compress(); - delete firstPtr; + if( firstPtr == newItem) + { + newItem = NULL; + } + delete firstPtr; + firstPtr = NULL; } else { @@ -988,6 +993,7 @@ else if ( Math::IsNaN( locationData.iPosition.Latitude() ) && Math::IsNaN( locationData.iPosition.Longitude() )) { + LOG("CLocationRecord::LocationSnapshotL(), coordinates empty with or without cellular info") // coordinates empty, with or without cellular info if ( net->iCellId == 0 && @@ -995,7 +1001,7 @@ net->iCountryCode.Length() == 0 && net->iNetworkId.Length() == 0 ) { - LOG("No network info (offline mode + no GPS fix), keep for remapping"); + LOG("CLocationRecord::LocationSnapshotL(), No network info (offline mode + no GPS fix), keep for remapping"); TRemapItem remapItem; remapItem.iObjectId = aObjectId; remapItem.iTime = timestamp; @@ -1004,7 +1010,12 @@ TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1]; iMediaItems.Remove(iMediaItems.Count() - 1); iMediaItems.Compress(); - delete firstPtr; + if( firstPtr == newItem) + { + newItem = NULL; + } + delete firstPtr; + firstPtr = NULL; } // check match for last created locationobject #ifdef LOC_REVERSEGEOCODE @@ -1014,6 +1025,7 @@ else if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0) #endif //LOC_REVERSEGEOCODE { + LOG("CLocationRecord::LocationSnapshotL(), last created locationobject match" ); TLocationData lastLocationData = iLastMediaItem.iLocationData; CTelephony::TNetworkInfoV1* lastnet = &lastLocationData.iNetworkInfo; @@ -1038,11 +1050,16 @@ TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1]; iMediaItems.Remove(iMediaItems.Count() - 1); iMediaItems.Compress(); - delete firstPtr; + if( firstPtr == newItem) + { + newItem = NULL; + } + delete firstPtr; + firstPtr = NULL; } } - if ( !previousMatch ) + if ( newItem && !previousMatch ) { // go for n/w based newItem->iFlag |= KNetQueryBit; @@ -1053,6 +1070,7 @@ else if ( lastLocationId != 0 && ((iLastMediaItem.iFlag & KSnapMediaFile) > 0)) { + LOG("CLocationRecord::LocationSnapshotL(), valid coordinates found"); TLocationData lastLocationData = iLastMediaItem.iLocationData; CTelephony::TNetworkInfoV1* lastnet = &lastLocationData.iNetworkInfo; @@ -1078,7 +1096,7 @@ if ( distance < iLocationDelta ) { - LOG("location close to the previous one"); + LOG("CLocationRecord::LocationSnapshotL(), location close to the previous one"); previousMatch = ETrue; CreateRelationL( aObjectId, lastLocationId ); @@ -1091,9 +1109,15 @@ TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1]; iMediaItems.Remove(iMediaItems.Count() - 1); iMediaItems.Compress(); - delete firstPtr; + if( firstPtr == newItem) + { + newItem = NULL; + } + delete firstPtr; + firstPtr = NULL; } - else + //check newItem for validity + else if (newItem) { // country tag not found.. go for reverse geocoding.. newItem->iLocationId = lastLocationId; @@ -1117,7 +1141,12 @@ TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1]; iMediaItems.Remove(iMediaItems.Count() - 1); iMediaItems.Compress(); - delete firstPtr; + if( firstPtr == newItem) + { + newItem = NULL; + } + delete firstPtr; + firstPtr = NULL; #endif //LOC_REVERSEGEOCODE } @@ -1193,7 +1222,7 @@ || (iMediaItems.Count() <= 0)) { // query is in progress or queue is empty - LOG1( "query is in progress or queue is empty. Count - %d", iMediaItems.Count() ); + LOG1( "CLocationRecord::FindLocationFromDBL(), Count - %d", iMediaItems.Count() ); return; } if ( (iMediaItems[0]->iFlag & KNetQueryBit) > 0 ) @@ -1236,10 +1265,10 @@ CMdELogicCondition& cond = iLocationQuery->Conditions(); cond.SetOperator( ELogicConditionOperatorAnd ); - LOG1( "latitude: %f", latitude); - LOG1( "latdelta: %f", latDelta); - LOG1( "longitude: %f", longitude); - LOG1( "londelta: %f", lonDelta); + LOG1( "CLocationRecord::FindLocationFromDBL(), latitude: %f", latitude); + LOG1( "CLocationRecord::FindLocationFromDBL(), latdelta: %f", latDelta); + LOG1( "CLocationRecord::FindLocationFromDBL(), longitude: %f", longitude); + LOG1( "CLocationRecord::FindLocationFromDBL(), londelta: %f", lonDelta); cond.AddPropertyConditionL( *iLatitudeDef, TMdERealBetween( latitude - latDelta, latitude + latDelta )); @@ -1329,14 +1358,14 @@ locationObject->AddTextPropertyL( itemTypeDef, Location::KLocationItemType ); locationObject->AddInt16PropertyL( offSetDef, timeOffset.Int() / 60 ); - LOG1( "Location created with stamp: %Ld", timestamp.Int64() ); + LOG1( "CLocationRecord::DoCreateLocationL(), Location created with stamp: %Ld", timestamp.Int64() ); // location related properties if ( !Math::IsNaN( aLocationData.iPosition.Latitude() ) && !Math::IsNaN( aLocationData.iPosition.Longitude() )) { - LOG1("Lan - %f", aLocationData.iPosition.Latitude()); - LOG1("Lon - %f", aLocationData.iPosition.Longitude()); + LOG1("CLocationRecord::DoCreateLocationL(), Lan - %f", aLocationData.iPosition.Latitude()); + LOG1("CLocationRecord::DoCreateLocationL(), Lon - %f", aLocationData.iPosition.Longitude()); locationObject->AddReal64PropertyL( *iLatitudeDef, aLocationData.iPosition.Latitude() ); locationObject->AddReal64PropertyL( *iLongitudeDef, aLocationData.iPosition.Longitude() ); @@ -1361,29 +1390,44 @@ // network related properties if ( aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown ) { - LOG1("Cell id - %d", aLocationData.iNetworkInfo.iCellId); + LOG1("CLocationRecord::DoCreateLocationL(), Cell id - %d", aLocationData.iNetworkInfo.iCellId); locationObject->AddUint32PropertyL( cellIdDef, aLocationData.iNetworkInfo.iCellId ); } if ( aLocationData.iNetworkInfo.iAreaKnown && aLocationData.iNetworkInfo.iLocationAreaCode != 0 && aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown ) { - LOG1("Areacode - %d", aLocationData.iNetworkInfo.iLocationAreaCode); + LOG1("CLocationRecord::DoCreateLocationL(), Areacode - %d", aLocationData.iNetworkInfo.iLocationAreaCode); locationObject->AddUint32PropertyL( locationCodeDef, aLocationData.iNetworkInfo.iLocationAreaCode ); } #ifdef _DEBUG - TLex lexer( aLocationData.iNetworkInfo.iCountryCode ); - TUint countryCode = 0; - - User::LeaveIfError( lexer.Val( countryCode, EDecimal) ); - LOG1("Country code - %d", countryCode); + + if ( aLocationData.iNetworkInfo.iCountryCode.Length() > 0 ) + { + TLex lexer( aLocationData.iNetworkInfo.iCountryCode ); + TUint countryCode = 0; + TRAP_IGNORE(lexer.Val( countryCode, EDecimal)); + LOG1("CLocationRecord::DoCreateLocationL(), Country code - %d", countryCode); + } + else + { + LOG("CLocationRecord::DoCreateLocationL(), No Country code"); + } //Set mobile network code - lexer = aLocationData.iNetworkInfo.iNetworkId; - TUint networkCode = 0; - User::LeaveIfError( lexer.Val( networkCode, EDecimal) ); - LOG1("Network id - %d", networkCode); + if ( aLocationData.iNetworkInfo.iNetworkId.Length() > 0 ) + { + TLex lexer = aLocationData.iNetworkInfo.iNetworkId; + TUint networkCode = 0; + TRAP_IGNORE(lexer.Val( networkCode, EDecimal)); + LOG1("CLocationRecord::DoCreateLocationL(), Network id - %d", networkCode); + } + else + { + LOG("CLocationRecord::DoCreateLocationL(), No network code"); + } + #endif if ( aLocationData.iNetworkInfo.iCountryCode.Length() > 0 ) { @@ -1398,7 +1442,7 @@ // Add the location object to the database. locationObjectId = iMdeSession->AddObjectL( *locationObject ); - LOG1("Location id - %d", locationObjectId); + LOG1("CLocationRecord::DoCreateLocationL(), Location id - %d", locationObjectId); CleanupStack::PopAndDestroy( locationObject ); LOG( "CLocationRecord::DoCreateLocationL(), end" ); @@ -2197,6 +2241,11 @@ CMdEProperty* property = NULL; object = iMdeSession->GetObjectL( aObjectId ); + if( !object ) + { + User::Leave( KErrNotFound ); + } + CleanupStack::PushL( object ); object->Property( timeDef, property, 0 ); if ( !property ) @@ -2206,7 +2255,10 @@ const TTime timeValue( property->TimeValueL() ); CleanupStack::PopAndDestroy( object ); + + LOG( "CLocationRecord::GetMdeObjectTimeL(), end" ); return timeValue; + } diff -r 85f623e1ef41 -r 29d87345eaeb mds_plat/harvester_framework_api/inc/harvesterplugin.h --- a/mds_plat/harvester_framework_api/inc/harvesterplugin.h Wed Sep 01 12:24:24 2010 +0100 +++ b/mds_plat/harvester_framework_api/inc/harvesterplugin.h Tue Sep 14 22:10:25 2010 +0300 @@ -160,6 +160,11 @@ * @param aBlacklist Reference to blacklisting component. */ IMPORT_C virtual void SetBlacklist( CHarvesterBlacklist& aBlacklist ); + + /** + * Method to stop harvester plugin if needed. + */ + IMPORT_C virtual void StopHarvest(); protected: @@ -265,6 +270,7 @@ CMdEPropertyDef* iTitlePropertyDef; TBool iHarvesting; + TBool iPaused; }; diff -r 85f623e1ef41 -r 29d87345eaeb metadataengine/client/src/mdeharvestersession.cpp --- a/metadataengine/client/src/mdeharvestersession.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/metadataengine/client/src/mdeharvestersession.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -138,8 +138,10 @@ WRITELOG( "CMdEHarvesterSession::SetFilesToPresentL -- Start" ); if( aUris.Count() != aFileInfos.Count() ) { +#ifdef _DEBUG WRITELOG2( "CMdEHarvesterSession::SetFilesToPresentL -- Leave (%d, %d)", aUris.Count(), aFileInfos.Count() ); +#endif User::Leave( KErrArgument ); } diff -r 85f623e1ef41 -r 29d87345eaeb metadataengine/server/inc/mdssqldbmaintenance.h --- a/metadataengine/server/inc/mdssqldbmaintenance.h Wed Sep 01 12:24:24 2010 +0100 +++ b/metadataengine/server/inc/mdssqldbmaintenance.h Tue Sep 14 22:10:25 2010 +0300 @@ -55,6 +55,11 @@ * Drops and re-creates tables */ void CreateDatabaseL(); + + /** + * Does quick check to the existing database to detect obvious corruption + */ + TBool CheckForCorruptionL(); }; #endif // __MDSSQLDBMAINTENANCE_H__ diff -r 85f623e1ef41 -r 29d87345eaeb metadataengine/server/src/mdsfindsequence.cpp --- a/metadataengine/server/src/mdsfindsequence.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/metadataengine/server/src/mdsfindsequence.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -15,6 +15,7 @@ */ #include +#include #include "mdsfindsequence.h" @@ -72,7 +73,7 @@ , iObserver( &aObserver ) , iUserLevel( EUserLevelNone ) { - iNotifyCount = KMaxTUint32; + iNotifyCount = KMdEQueryDefaultMaxCount; iFindOperation = NULL; } diff -r 85f623e1ef41 -r 29d87345eaeb metadataengine/server/src/mdsmaintenanceengine.cpp --- a/metadataengine/server/src/mdsmaintenanceengine.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/metadataengine/server/src/mdsmaintenanceengine.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -120,7 +120,7 @@ TBool isValid(EFalse); TRAPD(err, isValid = iMaintenance->ValidateL( )); - if(err == KErrCorrupt) + if( err == KErrCorrupt ) { DeleteDatabase(); User::Leave( err ); @@ -174,11 +174,6 @@ User::Leave( schemaError ); } } - - if ( FailedImports() != 0 ) - { - User::Leave( KErrBadName ); - } // try to read default import file from C drive TRAPD( err, ImportMetadataL( aManipulate, aSchema, KMdsDefaultImportFile ) ); @@ -188,6 +183,13 @@ // and ignore errors TRAP_IGNORE( ImportMetadataL( aManipulate, aSchema, KMdsDefaultRomImportFile ) ); } + +#ifdef _DEBUG + if ( FailedImports() != 0 ) + { + User::Leave( KErrBadName ); + } +#endif __LOG1( ELogAlways, "MDS DB tables created %d", 0 ); @@ -206,6 +208,12 @@ DeleteDatabase(); User::Leave( err ); } + + if( !iMaintenance->CheckForCorruptionL() ) + { + DeleteDatabase(); + User::Leave( KErrCorrupt ); + } } __LOG1( ELogAlways, "CMdSMaintenanceEngine::InstallL complete: %d", 0 ); } diff -r 85f623e1ef41 -r 29d87345eaeb metadataengine/server/src/mdsmanipulationengine.cpp --- a/metadataengine/server/src/mdsmanipulationengine.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/metadataengine/server/src/mdsmanipulationengine.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -852,11 +852,11 @@ #ifdef _DEBUG const TInt64 time = fileInfo.iModifiedTime; - RDebug::Print( _L("CMdSManipulationEngine::SetFilesToPresentL: (%d) iSize %u, iModified %Ld, uri %S"), + RDebug::Print( _L("CMdSManipulationEngine::SetFilesToPresentL: (%d) uri %S, iSize %u, iModified %Ld"), i, + &uri, fileInfo.iSize, - time, - &uri); + time ); #endif TFilePresentStates placeHolder; diff -r 85f623e1ef41 -r 29d87345eaeb metadataengine/server/src/mdsnotifycomparator.cpp --- a/metadataengine/server/src/mdsnotifycomparator.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/metadataengine/server/src/mdsnotifycomparator.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -1180,7 +1180,7 @@ { aSerializedCondition.PositionL( aRelationCondition.iRelationIds.iPtr.iOffset ); - for (TInt i = 0; i < aRelationCondition.iRelationIds.iPtr.iCount; ++i) + for (TUint i = 0; i < aRelationCondition.iRelationIds.iPtr.iCount; ++i) { TItemId relationId; aSerializedCondition.ReceiveL( relationId ); diff -r 85f623e1ef41 -r 29d87345eaeb metadataengine/server/src/mdssqldbmaintenance.cpp --- a/metadataengine/server/src/mdssqldbmaintenance.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/metadataengine/server/src/mdssqldbmaintenance.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -188,7 +188,6 @@ } } CleanupStack::PopAndDestroy( &col2propQuery ); - emptyRowData.Reset(); CleanupStack::PopAndDestroy( &emptyRowData ); @@ -227,3 +226,49 @@ CleanupStack::PopAndDestroy( &emptyRowData ); } +TBool CMdSSqlDbMaintenance::CheckForCorruptionL() + { + // Check the MDS default namespace main table for validity + // This table should always contain at least 1 default system folder object + _LIT( KValidateData, "SELECT COUNT(*) FROM Object%u;" ); + + RBuf commonClauseOne; + User::LeaveIfError( commonClauseOne.Create( KValidateData.iTypeLength + KMaxUintValueLength ) ); + CleanupClosePushL( commonClauseOne ); + commonClauseOne.Format( KValidateData, KDefaultNamespaceDefId ); + + RRowData emptyRowData; + CleanupClosePushL( emptyRowData ); + + RMdsStatement validationQuery; + CleanupClosePushL( validationQuery ); + + CMdSSqLiteConnection& connection = MMdSDbConnectionPool::GetDefaultDBL(); + + TInt test( KErrNone ); + TUint32 count( 0 ); + TRAP( test, connection.ExecuteQueryL( commonClauseOne, validationQuery, emptyRowData ) ); + if( test == KErrNone ) + { + emptyRowData.AppendL( TColumn( count ) ); + TRAP( test, connection.NextRowL(validationQuery, emptyRowData)); + if(test == KErrNone) + { + emptyRowData.Column(0).Get( count ); + + if(count <= 0) + { + test = KErrCorrupt; + } + } + } + + CleanupStack::PopAndDestroy( &validationQuery ); + + CleanupStack::PopAndDestroy( &emptyRowData ); + + CleanupStack::PopAndDestroy( &commonClauseOne ); + + return ( test == KErrNone ); + } + diff -r 85f623e1ef41 -r 29d87345eaeb metadataengine/server/src/mdssqlobjectmanipulate.cpp --- a/metadataengine/server/src/mdssqlobjectmanipulate.cpp Wed Sep 01 12:24:24 2010 +0100 +++ b/metadataengine/server/src/mdssqlobjectmanipulate.cpp Tue Sep 14 22:10:25 2010 +0300 @@ -2271,8 +2271,8 @@ TPtrC16 uri = aBuffer.ReceivePtr16L(); objectId = SearchObjectByUriL( uri, flags ); if ( objectId != KNoId && - objectId != KSystemFavouritesAlbumId && - objectId != KSystemCapturedAlbumId ) + uri != KSystemFavouritesAlbumUri && + uri != KSystemCapturedAlbumUri ) { // unlock object, so update is no possible anymore if ( iLockList.IsLocked( *iNamespaceDef, objectId ) ) diff -r 85f623e1ef41 -r 29d87345eaeb rom/mds_cellid_reverse_geocode_enabled.iby --- a/rom/mds_cellid_reverse_geocode_enabled.iby Wed Sep 01 12:24:24 2010 +0100 +++ b/rom/mds_cellid_reverse_geocode_enabled.iby Tue Sep 14 22:10:25 2010 +0300 @@ -121,16 +121,4 @@ data=ZSYSTEM\install\mds_stub.sis system\install\mds_stub.sis data=ZSYSTEM\install\mdswatchdog_stub.sis system\install\mdswatchdog_stub.sis -data=ZSYSTEM\install\locationmanagerclient_stub.sis system\install\locationmanagerclient_stub.sis -data=ZSYSTEM\install\locationtrail_stub.sis system\install\locationtrail_stub.sis -data=ZSYSTEM\install\locationmanagerserver_stub.sis system\install\locationmanagerserver_stub.sis - -data=ZSYSTEM\install\ReverseGeocode_stub.sis system\install\ReverseGeocode_stub.sis -data=ZSYSTEM\install\ReverseGeoCoderPlugin_stub.sis system\install\ReverseGeoCoderPlugin_stub.sis -data=ZSYSTEM\install\tagcreator_stub.sis system\install\tagcreator_stub.sis -data=ZSYSTEM\install\geotagger_stub.sis system\install\geotagger_stub.sis -data=ZSYSTEM\install\geoconverter_stub.sis system\install\geoconverter_stub.sis - - - #endif //__METADATA_IBY__ diff -r 85f623e1ef41 -r 29d87345eaeb rom/mds_reverse_geocode_enabled_only.iby --- a/rom/mds_reverse_geocode_enabled_only.iby Wed Sep 01 12:24:24 2010 +0100 +++ b/rom/mds_reverse_geocode_enabled_only.iby Tue Sep 14 22:10:25 2010 +0300 @@ -118,11 +118,4 @@ data=ZSYSTEM\install\mds_stub.sis system\install\mds_stub.sis data=ZSYSTEM\install\mdswatchdog_stub.sis system\install\mdswatchdog_stub.sis -data=ZSYSTEM\install\locationmanagerclient_stub.sis system\install\locationmanagerclient_stub.sis -data=ZSYSTEM\install\locationtrail_stub.sis system\install\locationtrail_stub.sis -data=ZSYSTEM\install\locationmanagerserver_stub.sis system\install\locationmanagerserver_stub.sis -data=ZSYSTEM\install\ReverseGeocode_stub.sis system\install\ReverseGeocode_stub.sis -data=ZSYSTEM\install\ReverseGeoCoderPlugin_stub.sis system\install\ReverseGeoCoderPlugin_stub.sis -data=ZSYSTEM\install\tagcreator_stub.sis system\install\tagcreator_stub.sis -data=ZSYSTEM\install\geotagger_stub.sis system\install\geotagger_stub.sis #endif //__METADATA_IBY__