Revision: 201007 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 12 Mar 2010 15:44:28 +0200
branchRCL_3
changeset 6 646a02f170b9
parent 3 6752808b2036
child 7 3cebc1a84278
Revision: 201007 Kit: 201008
clfwrapper/ClientSrc/CCLFDbItemProvider.cpp
clfwrapper/ClientSrc/CCLFDefaultOperation.cpp
clfwrapper/ClientSrc/CCLFItemImpl.cpp
clfwrapper/ClientSrc/CCLFItemListModelImpl.cpp
clfwrapper/ClientSrc/CCLFServerProxy.cpp
clfwrapper/ClientSrc/CLFUtils.cpp
clfwrapper/group/mediacollectionmanager.mmp
contextengine/plugins/contextplugininterface/group/contextplugininterface.mmp
contextengine/plugins/locationplugin/src/locationcontextplugin.cpp
group/bld.inf
harvester/blacklistclient/group/blacklistclient.mmp
harvester/blacklistserver/group/blacklistserver.mmp
harvester/client/inc/harvesterrequestactive.h
harvester/client/src/harvesterrequestactive.cpp
harvester/common/eabi/harvestercommonarm.def
harvester/common/group/harvesterplugininterface.mmp
harvester/common/src/harvesterexifutil.cpp
harvester/composerplugins/composerplugininterface/group/composerplugininterface.mmp
harvester/composerplugins/imagecomposer/inc/imagepresentobserver.h
harvester/composerplugins/imagecomposer/src/imagepresentobserver.cpp
harvester/composerplugins/imagecomposer/src/locationrelationobserver.cpp
harvester/harvesterplugins/AudioPlugin/src/harvesteraudiopluginutils.cpp
harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp
harvester/harvesterplugins/RTPPlugin/group/harvesterrtpplugin.mmp
harvester/harvesterplugins/VideoPlugin/group/harvestervideoplugin.mmp
harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp
harvester/monitorplugins/fileplugin/src/FolderRenamer.cpp
harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp
harvester/monitorplugins/fileplugin/src/filemonitorao.cpp
harvester/monitorplugins/mdsfileserverplugin/src/mdsfileserverplugin.cpp
harvester/monitorplugins/mdsoomplugin/group/bld.inf
harvester/monitorplugins/mdsoomplugin/group/mdsoomplugin.mmp
harvester/monitorplugins/messageplugin/group/messagemonitorplugin.mmp
harvester/monitorplugins/messageplugin/src/messagemonitorplugin.cpp
harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp
harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp
harvester/monitorplugins/monitorplugininterface/group/monitorplugininterface.mmp
harvester/server/src/harvesterao.cpp
inc/mdssqliteconnection.h
locationmanager/locationtrail/eabi/locationtrailarm.def
locationmanager/locationtrail/group/locationtrail.mmp
locationmanager/locationtrail/inc/clocationrecord.h
locationmanager/locationtrail/inc/clocationwrite.h
locationmanager/locationtrail/inc/cnetworkinfo.h
locationmanager/locationtrail/inc/cpositioninfo.h
locationmanager/locationtrail/inc/ctracklog.h
locationmanager/locationtrail/inc/locationtraildefs.h
locationmanager/locationtrail/src/clocationrecord.cpp
locationmanager/locationtrail/src/cnetworkinfo.cpp
locationmanager/locationtrail/src/cpositioninfo.cpp
locationmanager/locationtrail/src/ctracklog.cpp
locationmanager/server/group/locationmanagerserver.mmp
locationmanager/server/inc/clocationmanagerserver.h
locationmanager/server/src/clocationmanagerserver.cpp
mds_plat/metadata_engine_api/inc/mdeobjectcondition.h
mds_plat/metadata_engine_api/inc/mdeproperty.h
mds_plat/metadata_engine_api/inc/mdequery.h
metadataengine/client/bwincw/mdeclientu.def
metadataengine/client/eabi/mdeclientu.def
metadataengine/client/group/mdeclient.mmp
metadataengine/client/inc/mdeenginesession.h
metadataengine/client/inc/mdesessionimpl.h
metadataengine/client/src/mdeasynchronousfindao.cpp
metadataengine/client/src/mdelogiccondition.cpp
metadataengine/client/src/mdenotifierao.cpp
metadataengine/client/src/mdeobjectdef.cpp
metadataengine/client/src/mdequery.cpp
metadataengine/client/src/mdesessionimpl.cpp
metadataengine/server/inc/mdsfindengine.h
metadataengine/server/src/mdsclausebuffer.cpp
metadataengine/server/src/mdsdiskspacenotifier.cpp
metadataengine/server/src/mdseventdef.cpp
metadataengine/server/src/mdsfindengine.cpp
metadataengine/server/src/mdsfindsequence.cpp
metadataengine/server/src/mdsfindsqlclause.cpp
metadataengine/server/src/mdsimportexport.cpp
metadataengine/server/src/mdsindexer.cpp
metadataengine/server/src/mdslogger.cpp
metadataengine/server/src/mdsmaintenanceengine.cpp
metadataengine/server/src/mdsmanipulationengine.cpp
metadataengine/server/src/mdsnotifier.cpp
metadataengine/server/src/mdsobjectdef.cpp
metadataengine/server/src/mdspropertydef.cpp
metadataengine/server/src/mdsrelationdef.cpp
metadataengine/server/src/mdsschema.cpp
metadataengine/server/src/mdsserver.cpp
metadataengine/server/src/mdsserversession.cpp
metadataengine/server/src/mdssqliteconnection.cpp
metadataengine/server/src/mdssqlobjectmanipulate.cpp
sis/mds/mds_stub.sis
sis/mds/package.pkg
sis/mds/package_separate.pkg
sis/mds/stub.pkg
watchdog/group/bld.inf
--- a/clfwrapper/ClientSrc/CCLFDbItemProvider.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/clfwrapper/ClientSrc/CCLFDbItemProvider.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -93,8 +93,6 @@
 //
 void CCLFDbItemProvider::DoCancel()
     {
-    MG_DEBUG1( dr1, "[CLF]\t CCLFDbItemProvider::DoCancel" ); 
-
     if ( iObjectQuery )
         {
         iObjectQuery->Cancel();
--- a/clfwrapper/ClientSrc/CCLFDefaultOperation.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/clfwrapper/ClientSrc/CCLFDefaultOperation.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -173,8 +173,6 @@
                         const TArray<TCLFFieldId> aSortFields,
                         TCLFItemDataType aSortingDataType )
     {
-    MG_DEBUG1( MSI1, "MakeSortingItemsL start" );
-
     const TInt sortingFieldsCount( aSortFields.Count() );
     const TInt count( aItemArray.Count() );
     for( TInt i = 0 ; i < count ; ++i )
@@ -218,8 +216,6 @@
             aUndefinedItemArray.AppendL( seItem );
             }
         }
-
-    MG_DEBUG1( MSI2, "MakeSortingItemsL end" );
     }
 
 // -----------------------------------------------------------------------------
@@ -390,8 +386,6 @@
 void CCLFDefaultOperation::GroupItemsL( const TArray<MCLFItem*>& aSourceList,
                                         RPointerArray<MCLFItem>& aGroupedList )
     {
-    MG_DEBUG1( GI1, "CCLFDefaultOperation::GroupItemsL start" );
-
     iGroupedItemList.ResetAndDestroy();
     switch ( iGrouping )
         {
@@ -407,8 +401,6 @@
             break;
             }
         }
-
-    MG_DEBUG1( GI2, "CCLFDefaultOperation::GroupItemsL end" );
     }
 
 // -----------------------------------------------------------------------------
@@ -484,8 +476,6 @@
                                     const TArray<MCLFItem*>& aSourceList,
                                     RPointerArray<MCLFItem>& aGroupedList )
     {
-    MG_DEBUG1( DMAG1, "CCLFDefaultOperation::DoMusicAlbumGroupingL start" );
-
     CDesCArray* tempAlbumNameArray =
                 new (ELeave) CDesCArraySeg( KCLFGroupedItemArrayGranularity );
     CleanupStack::PushL( tempAlbumNameArray );
@@ -498,10 +488,10 @@
         if( item->GetField( ECLFFieldIdAlbum, albumName ) == KErrNone )
             {
             TInt pos( 0 );
-            if( tempAlbumNameArray->Find( albumName, pos ) )
+            if( tempAlbumNameArray->FindIsq( albumName, pos ) )
                 {
                 // not found
-                tempAlbumNameArray->AppendL( albumName );
+                tempAlbumNameArray->InsertIsqL( albumName );
 
                 // make new item
                 MCLFModifiableItem* newItem =
@@ -522,8 +512,6 @@
             }
         }
     CleanupStack::PopAndDestroy( tempAlbumNameArray );
-
-    MG_DEBUG1( DMAG2, "CCLFDefaultOperation::DoMusicAlbumGroupingL end" );
     }
 
 //  End of File
--- a/clfwrapper/ClientSrc/CCLFItemImpl.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/clfwrapper/ClientSrc/CCLFItemImpl.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -209,7 +209,7 @@
     TInt32 error = KErrNotFound;
 
     aValue = ECLFMediaTypeUnknown; // Default to this.
-    for ( TInt i = 0; i < sizeof( clfmediatypes ) / sizeof( TInt ); ++i )
+    for ( TUint i = 0; i < sizeof( clfmediatypes ) / sizeof( TInt ); ++i )
         {
         if ( name.Compare( *mdemediatypes[ i ] ) == 0 )
             {
@@ -258,7 +258,7 @@
         {
         // Get the actual data
         CMdEProperty* prop = NULL;
-        const TInt index = iMdEObject.Property( *propertyDef, prop );
+        iMdEObject.Property( *propertyDef, prop );
         if ( prop )
             {
             const TInt num = sizeof ( clfwrappermusictypes ) / sizeof( TDesC* );
--- a/clfwrapper/ClientSrc/CCLFItemListModelImpl.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/clfwrapper/ClientSrc/CCLFItemListModelImpl.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -443,17 +443,11 @@
 void CCLFItemListModelImpl::CopyArrayL( const TArray<MCLFItem*>& aSource,
                                         RPointerArray<MCLFItem>& aDest )
     {
-    MG_DEBUG3( AI1, "CCLFItemListModelImpl::CopyArrayL start, aSource: 0x%08x, aDest: 0x%08x",
-               &aSource, &aDest );
-
     const TInt count( aSource.Count() );
     for( TInt i = 0 ; i < count ; ++i )
         {
-        MG_DEBUG3( AI2, "aSource[ %d ]: 0x%08x", i, aSource[ i ] );
         aDest.AppendL( aSource[i] );
         }
-
-    MG_DEBUG1( AI3, "CCLFItemListModelImpl::CopyArrayL end" );
     }
 
 // -----------------------------------------------------------------------------
--- a/clfwrapper/ClientSrc/CCLFServerProxy.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/clfwrapper/ClientSrc/CCLFServerProxy.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -842,9 +842,8 @@
     {
     CUpdateItemsHandler* handler = CUpdateIDsHandler::NewL( aItemIDArray );
 
-    CleanupStack::PushL( handler );
+    // Ownership tranferred
     StartHandlingL( handler );
-    CleanupStack::Pop( handler );
 
     return KErrNone;
     }
@@ -879,9 +878,8 @@
             return KErrNone;
             }
 
-        CleanupStack::PushL( handler );
+        // Ownership tranferred
         StartHandlingL( handler );
-        CleanupStack::Pop( handler );
         }
     CleanupStack::PopAndDestroy( uriArray );
 
@@ -896,9 +894,8 @@
     {
     CUpdateItemsHandler* handler = CUpdateFoldersHandler::NewL( iMdESession, 
                                                          *iUriArray, this, this, iFs, iHC, iExtensionArray );
-    CleanupStack::PushL( handler );
+    // Ownership tranferred
     StartHandlingL( handler );
-    CleanupStack::Pop( handler );
     
     return KErrNone;
     }
@@ -1002,6 +999,7 @@
     {
     if ( aHandler )
         {
+        CleanupStack::PushL( aHandler );
         // Notify pending active objects about the event.
         NotifyUpdateEvent( ECLFProcessStartEvent );
 
@@ -1012,16 +1010,17 @@
             {
             // Remove aHandler, because it is in clean up stack.
             iUpdateItemsHandlerArray.Remove( iUpdateItemsHandlerArray.Count() - 1 );
+            CleanupStack::PopAndDestroy( aHandler );
             User::LeaveIfError( err );
             }
         if ( aHandler->AllDone() )
             {
-            delete aHandler;
-            aHandler = NULL;
+            CleanupStack::PopAndDestroy( aHandler );
             iUpdateItemsHandlerArray.Remove( iUpdateItemsHandlerArray.Count() - 1 );
             }
         else
             {
+            CleanupStack::Pop( aHandler );
             aHandler->StartScheduler();
             }
         }
--- a/clfwrapper/ClientSrc/CLFUtils.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/clfwrapper/ClientSrc/CLFUtils.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -30,7 +30,6 @@
 //
 const TDesC& CLFUtils::MapClfType( const TInt aType )
     {
-    MG_DEBUG2( MCT, "[CLF]\t CCLFQueryAdapter::MapClfType %d", aType );
     const TDesC* ret = &KNullDesC;
 
     switch ( aType )
@@ -67,7 +66,6 @@
         case ECLFMediaTypePresentations:
         default:
             {
-            MG_DEBUG1( MCT3, "[CLF]\t MapClfType reached default, returning KBaseObject" );   
             ret = &MdeConstants::Object::KBaseObject;
             break;
             }
--- a/clfwrapper/group/mediacollectionmanager.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/clfwrapper/group/mediacollectionmanager.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -44,6 +44,7 @@
 
 BYTEPAIRCOMPRESSTARGET
 PAGED
+OPTION ARMCC -O3 -OSpace
 
 // End of File
 
--- a/contextengine/plugins/contextplugininterface/group/contextplugininterface.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/contextengine/plugins/contextplugininterface/group/contextplugininterface.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -46,4 +46,5 @@
 
 PAGED
 BYTEPAIRCOMPRESSTARGET
+OPTION ARMCC -O3 -OSpace
 
--- a/contextengine/plugins/locationplugin/src/locationcontextplugin.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/contextengine/plugins/locationplugin/src/locationcontextplugin.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -149,6 +149,11 @@
     
     ret = iManipulator.LocationSnapshot( aHD.MdeObject().Id() );
     
+    if( ret != KErrNone )
+        {
+        ret = KErrCompletion;
+        }
+    
     aHD.SetErrorCode( ret );
     aObserver.PluginSnapshotStatus( &aHD );
     }
--- a/group/bld.inf	Fri Feb 19 23:14:48 2010 +0200
+++ b/group/bld.inf	Fri Mar 12 15:44:28 2010 +0200
@@ -47,3 +47,4 @@
 
 PRJ_TESTEXPORTS
 ../rom/mds_testers.iby	CORE_MW_LAYER_IBY_EXPORT_PATH(mds_testers.iby)
+
--- a/harvester/blacklistclient/group/blacklistclient.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/blacklistclient/group/blacklistclient.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -51,4 +51,5 @@
 
 BYTEPAIRCOMPRESSTARGET
 PAGED
+OPTION ARMCC -O2 -OTime
 
--- a/harvester/blacklistserver/group/blacklistserver.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/blacklistserver/group/blacklistserver.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -49,5 +49,6 @@
 
 PAGED
 BYTEPAIRCOMPRESSTARGET
+OPTION ARMCC -O2 -OTime
 
 EPOCPROCESSPRIORITY background
--- a/harvester/client/inc/harvesterrequestactive.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/client/inc/harvesterrequestactive.h	Fri Mar 12 15:44:28 2010 +0200
@@ -60,7 +60,7 @@
     static CHarvesterRequestActive* NewL( 
             RHarvesterClient& aClient, MHarvestObserver* aObserver,
             TInt aService, const TDesC& aUri, 
-            HBufC8* aAlbumIds, TBool& aAddLocation,
+            HBufC8* aAlbumIds, TBool aAddLocation,
             CHarvesterRequestQueue* aQueue );
 
     /**
@@ -104,7 +104,7 @@
      */
     CHarvesterRequestActive( RHarvesterClient& aClient,
             MHarvestObserver* aObserver, TInt aService, const TDesC& aUri, 
-            HBufC8* aAlbumIds, TBool& aAddLocation,
+            HBufC8* aAlbumIds, TBool aAddLocation,
             CHarvesterRequestQueue* aQueue );
 
     /**
--- a/harvester/client/src/harvesterrequestactive.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/client/src/harvesterrequestactive.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -50,7 +50,7 @@
 CHarvesterRequestActive* CHarvesterRequestActive::NewL(
         RHarvesterClient& aClient, MHarvestObserver* aObserver,
         TInt aService, const TDesC& aUri, 
-        HBufC8* aAlbumIds, TBool& aAddLocation,
+        HBufC8* aAlbumIds, TBool aAddLocation,
         CHarvesterRequestQueue* aQueue )
     {
     CHarvesterRequestActive* self = new( ELeave )CHarvesterRequestActive( aClient, aObserver,
@@ -65,7 +65,7 @@
 //
 CHarvesterRequestActive::CHarvesterRequestActive( RHarvesterClient& aClient,
     MHarvestObserver* aObserver, TInt aService, const TDesC& aUri, 
-    HBufC8* aAlbumIds, TBool& aAddLocation, CHarvesterRequestQueue* aQueue )
+    HBufC8* aAlbumIds, TBool aAddLocation, CHarvesterRequestQueue* aQueue )
     : CActive( CActive::EPriorityStandard ), iClient( aClient ), iObserver( aObserver ), 
     iService( aService ), iUri( aUri ), iAlbumIds( aAlbumIds ), iAddLocation( aAddLocation ),
     iRequestQueue( aQueue ), iLocation( EFalse ), iCancelled( EFalse )
--- a/harvester/common/eabi/harvestercommonarm.def	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/common/eabi/harvestercommonarm.def	Fri Mar 12 15:44:28 2010 +0200
@@ -82,4 +82,7 @@
 	_ZN22CHarvesterEventManager23UnregisterEventObserverERK9RMessage2 @ 81 NONAME
 	_ZN17CMdeObjectWrapper21HandleObjectPropertyLER10CMdEObjectR15CMdEPropertyDefPvi @ 82 NONAME
 	_ZN23CHarvesterPluginFactory26SendHarvestingStatusEventLEi @ 83 NONAME
+	_ZN18CHarvesterExifUtilD0Ev @ 84 NONAME
+	_ZN18CHarvesterExifUtilD1Ev @ 85 NONAME
+	_ZN18CHarvesterExifUtilD2Ev @ 86 NONAME
 
--- a/harvester/common/group/harvesterplugininterface.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/common/group/harvesterplugininterface.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -53,4 +53,5 @@
 
 BYTEPAIRCOMPRESSTARGET
 PAGED
+OPTION ARMCC -O3 -OSpace
 
--- a/harvester/common/src/harvesterexifutil.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/common/src/harvesterexifutil.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -100,7 +100,7 @@
 }
 
 
-CHarvesterExifUtil::~CHarvesterExifUtil()
+EXPORT_C CHarvesterExifUtil::~CHarvesterExifUtil()
 {
 }
 
--- a/harvester/composerplugins/composerplugininterface/group/composerplugininterface.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/composerplugins/composerplugininterface/group/composerplugininterface.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -46,4 +46,5 @@
 
 PAGED
 BYTEPAIRCOMPRESSTARGET
+OPTION ARMCC -O3 -OSpace
 
--- a/harvester/composerplugins/imagecomposer/inc/imagepresentobserver.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/composerplugins/imagecomposer/inc/imagepresentobserver.h	Fri Mar 12 15:44:28 2010 +0200
@@ -125,8 +125,6 @@
 	 */
 	CComposerImagePlugin* iComposer;	
 	
-	TGetPendingPgckWrapper* iPendingPckWrapper;
-	
 	RArray<TItemId> iPresentObjectIds;
 	RArray<TItemId> iPendingObjectIds;
 	RArray<TItemId> iComposeObjectIds;
--- a/harvester/composerplugins/imagecomposer/src/imagepresentobserver.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/composerplugins/imagecomposer/src/imagepresentobserver.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -34,7 +34,6 @@
 		iSession( NULL ),
 		iMdEHarvesterSession( NULL ),
 		iComposer( NULL ),
-		iPendingPckWrapper( NULL ),
 		iNextRequest( ERequestIdle ),
 		iPendingCount( 0 ),
 		iPendingBuffer( NULL ),
--- a/harvester/composerplugins/imagecomposer/src/locationrelationobserver.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/composerplugins/imagecomposer/src/locationrelationobserver.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -42,6 +42,12 @@
 		{
 		TRAP_IGNORE( iSession->RemoveRelationObserverL( *this ) );
 		}
+	
+	if( iQuery )
+	    {
+	    iQuery->Cancel();
+	    delete iQuery;
+	    }
 	}
 
 CLocationRelationObserver* CLocationRelationObserver::NewL( CMdESession* aSession, CComposerImagePlugin* aComposer )
--- a/harvester/harvesterplugins/AudioPlugin/src/harvesteraudiopluginutils.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/harvesterplugins/AudioPlugin/src/harvesteraudiopluginutils.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -77,6 +77,7 @@
     {
     delete iMetaDataUtility;
     
+    iMimeTypeMappings.Close();
     iWantedMetadataFields.Close();
     }
 
--- a/harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -192,6 +192,7 @@
    	
     delete iPropDefs;
     
+    iMimeTypeMappings.Close();
     iFbs.Disconnect();
 	}
 
--- a/harvester/harvesterplugins/RTPPlugin/group/harvesterrtpplugin.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/harvesterplugins/RTPPlugin/group/harvesterrtpplugin.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -56,4 +56,5 @@
 
 PAGED
 BYTEPAIRCOMPRESSTARGET
+OPTION ARMCC -O2 -OTime
 
--- a/harvester/harvesterplugins/VideoPlugin/group/harvestervideoplugin.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/harvesterplugins/VideoPlugin/group/harvestervideoplugin.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -34,7 +34,6 @@
 SYSTEMINCLUDE /epoc32/include/ecom
 SYSTEMINCLUDE /epoc32/include/libc
 SYSTEMINCLUDE /epoc32/include/connect
-SYSTEMINCLUDE /epoc32/include/3gplibrary
 
 USERINCLUDE   ../inc
 USERINCLUDE   ../../../common/inc
--- a/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -159,6 +159,7 @@
 CHarvesterVideoPlugin::~CHarvesterVideoPlugin()
 	{
 	delete iPropDefs;
+	iMimeTypeMappings.Close();
 
 	WRITELOG("CHarvesterVideoPlugin::CHarvesterVideoPlugin()");
 	}
@@ -658,7 +659,10 @@
 	        	// Match MIME type for audio object with "audio" substring
 	        	else if( MdsUtils::Find( mime, KAudio() ) != KErrNotFound )
 	        		{
-	        		break;
+	        	    if( !aVHD.iVideoObject )
+	        	        {
+	        	        break;
+	        	        }
 	        		}
 	        	}
 	        }
@@ -668,6 +672,7 @@
         	aVHD.iMimeBuf = mime.Alloc();
         	}
         
+        helixMetadata->ResetL();
         CleanupStack::PopAndDestroy( helixMetadata );
         
         // don't destory mime type pointers just clean array
@@ -1055,6 +1060,7 @@
 		aType.Copy( KVideo );
 		}
     
+	helixMetadata->ResetL();
     CleanupStack::PopAndDestroy( helixMetadata );
 	}
 
--- a/harvester/monitorplugins/fileplugin/src/FolderRenamer.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/monitorplugins/fileplugin/src/FolderRenamer.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -112,6 +112,7 @@
 CFolderRenamer::~CFolderRenamer()
 	{
 	Cancel();
+	iRenamedFolders.ResetAndDestroy();
 	}
 
 void CFolderRenamer::ConstructL()
--- a/harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -108,6 +108,8 @@
     delete iFolderRenamer;
     
     delete iEventArray;
+    
+    iQueue.ResetAndDestroy();
     iUriArray.Close();
     }
 
--- a/harvester/monitorplugins/fileplugin/src/filemonitorao.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/monitorplugins/fileplugin/src/filemonitorao.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -157,6 +157,9 @@
     	}
     
     Cancel();
+
+    delete iFileEventHandler;
+    iFileEventHandler = NULL;
     
     // remove mds fileserver plugin
     iEngine.Disable();
--- a/harvester/monitorplugins/mdsfileserverplugin/src/mdsfileserverplugin.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/monitorplugins/mdsfileserverplugin/src/mdsfileserverplugin.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -784,6 +784,10 @@
             {
             iPaths.Append( fn );
             }
+        else
+            {
+            err = KErrNoMemory;
+            }
         }
     else
         {
@@ -872,6 +876,10 @@
             {
             iIgnorePaths.Append( fn ); // ownership is transferred
             }
+        else
+            {
+            err = KErrNoMemory;
+            }
         }
     else
         {
--- a/harvester/monitorplugins/mdsoomplugin/group/bld.inf	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/monitorplugins/mdsoomplugin/group/bld.inf	Fri Mar 12 15:44:28 2010 +0200
@@ -26,4 +26,5 @@
 
 PRJ_TESTMMPFILES
 
-PRJ_TESTEXPORTS
\ No newline at end of file
+PRJ_TESTEXPORTS
+
--- a/harvester/monitorplugins/mdsoomplugin/group/mdsoomplugin.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/monitorplugins/mdsoomplugin/group/mdsoomplugin.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -49,5 +49,6 @@
 
 PAGED
 BYTEPAIRCOMPRESSTARGET
+OPTION ARMCC -O2 -OTime
 
 
--- a/harvester/monitorplugins/messageplugin/group/messagemonitorplugin.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/monitorplugins/messageplugin/group/messagemonitorplugin.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -59,4 +59,5 @@
 
 PAGED
 BYTEPAIRCOMPRESSTARGET
+OPTION ARMCC -O2 -OTime
 
--- a/harvester/monitorplugins/messageplugin/src/messagemonitorplugin.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/monitorplugins/messageplugin/src/messagemonitorplugin.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -64,6 +64,7 @@
 	{
 	WRITELOG("ENTER ~CMessageMonitorPlugin");
     delete iMsvSession;
+    delete iMessageScannerAO;
 	WRITELOG("END ~CMessageMonitorPlugin");	
 	}
 
--- a/harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -122,6 +122,13 @@
     	if ( presentState && medias[i].iMediaId != hdMediaId )
     		{
     		// scan MMC if card was in phone
+    	
+    	    if( iMmcScanner )
+    	        {
+    	        iMmcScanner->Cancel();
+    	        delete iMmcScanner;
+    	        iMmcScanner = NULL;
+    	        }
     		TRAP_IGNORE( iMmcScanner = CMmcScannerAO::NewL( medias[i].iMediaId, iMdEClient, iObserver,
     		    				aHarvesterPluginFactory, CActive::EPriorityHigh, alreadyWaited ) );
     		alreadyWaited = ETrue;
--- a/harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -72,6 +72,8 @@
 	iFs.Close();
 	
 	iMountDataQueue.ResetAndDestroy();
+	iEntryArray.ResetAndDestroy();
+	iHarvestEntryArray.ResetAndDestroy();
 	
 	delete iMdeSession;
   
--- a/harvester/monitorplugins/monitorplugininterface/group/monitorplugininterface.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/monitorplugins/monitorplugininterface/group/monitorplugininterface.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -50,4 +50,5 @@
 
 PAGED
 BYTEPAIRCOMPRESSTARGET
+OPTION ARMCC -O3 -OSpace
 
--- a/harvester/server/src/harvesterao.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/harvester/server/src/harvesterao.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -54,6 +54,8 @@
 _LIT(KVideo, "Video");
 _LIT(KInUse, "InUse");
 
+_LIT(KUndefinedMime, " ");
+
 _LIT( KExtensionMp4,   "mp4" );
 _LIT( KExtensionMpg4,  "mpg4" );
 _LIT( KExtensionMpeg4, "mpeg4" );
@@ -836,7 +838,7 @@
             }
         else
             {
-            mdeObject->AddTextPropertyL( *iPropDefs->iItemTypePropertyDef, KNullDesC );
+            mdeObject->AddTextPropertyL( *iPropDefs->iItemTypePropertyDef, KUndefinedMime );
             }
 		
 	    TPtrC name;
@@ -1767,7 +1769,7 @@
     
     CHarvesterData* hd = NULL;
     TRAP( err, hd = CHarvesterData::NewL( uri ) );
-    if ( err != KErrNone )
+    if ( err != KErrNone || !hd )
         {
         WRITELOG( "CHarvesterAO::HarvestFile - creating harvUri failed" );
         albumIds.Close();
@@ -1798,7 +1800,7 @@
         WRITELOG( "CHarvesterAO::HarvestFile - creating clientData failed" );
         }
 
-    if( iQueue && hd )
+    if( iQueue )
         {
         iQueue->Append( hd );
         
@@ -1810,6 +1812,7 @@
         }
     else
         {
+        delete hd;
         err = KErrUnknown;
         }
     
@@ -1943,7 +1946,7 @@
     
     CHarvesterData* hd = NULL;
     TRAP( err, hd = CHarvesterData::NewL( uri ) );
-    if ( err != KErrNone )
+    if ( err != KErrNone || !hd )
         {
         WRITELOG( "CHarvesterAO::HarvestFileWithUID - creating harvUri failed" );
         albumIds.Close();
@@ -1974,7 +1977,7 @@
         WRITELOG( "CHarvesterAO::HarvestFileWithUID - creating clientData failed" );
         }
 
-    if( iQueue && hd )
+    if( iQueue )
     	{
     	iQueue->Append( hd );
 
@@ -1986,6 +1989,7 @@
     	}
     else
         {
+        delete hd;
         err = KErrUnknown;
         }
 
@@ -2204,13 +2208,21 @@
     HarvestCompleted( aHD->ClientId(), aHD->Uri(), aHD->ErrorCode() );
 
     const TInt errorCode = aHD->ErrorCode();
-    if( errorCode != KErrNone )
+    if( errorCode != KErrNone && errorCode != KErrCompletion )
     	{
         WRITELOG1( "CHarvesterAO::ContextSnapshotStatus() - error occurred: %d", errorCode );    	
     	}
     else
     	{
-        WRITELOG( "CHarvesterAO::ContextSnapshotStatus() - successfully completed" );
+        if( errorCode == KErrCompletion )
+            {
+            WRITELOG( "CHarvesterAO::ContextSnapshotStatus() - snapshot could not be completed" );
+            WRITELOG( "CHarvesterAO::ContextSnapshotStatus() - processing non-context data anyway" );   
+            }
+        else
+            {
+            WRITELOG( "CHarvesterAO::ContextSnapshotStatus() - successfully completed" );
+            }
         if( aHD->Origin() == MdeConstants::Object::ECamera )
         	{
             aHD->MdeObject().SetPlaceholder( EFalse );
@@ -2298,7 +2310,11 @@
 	{
 	// check if partial restore was done before last boot
 	TBool partialRestore = iRestoreWatcher->Register();
-		
+	
+#ifdef __WINSCW__
+	partialRestore = ETrue;
+#endif
+	
 	if ( !partialRestore )
 		{
 		return;
--- a/inc/mdssqliteconnection.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/inc/mdssqliteconnection.h	Fri Mar 12 15:44:28 2010 +0200
@@ -76,6 +76,16 @@
         */        
         void ConstructL();
 
+        /**
+        * Delete and re-create database.
+        * @param aDbFileName Database filename and path
+        * @param asqlSecurityPolicy sql policy
+        * @param aKMdsSqlDbaConfig database connection configure
+        */    
+        TInt DeleteAndReCreateDB( const HBufC* aDbFileName,
+                                  const RSqlSecurityPolicy& asqlSecurityPolicy,
+                                  const TDesC8* aKMdsSqlDbaConfig );
+        
     public: // Methods from CMdSSqLiteConnection
 
 		/**
@@ -130,6 +140,11 @@
         void CurrentRowL( const RMdsStatement& aQuery, RRowData& aRow );
 
         /**
+         * Returns id of the last inserted row
+         */
+        TItemId LastInsertedRowId();
+
+        /**
          * terminates a running query or execution loop
          * @param aStatement ID of the statement
          */
--- a/locationmanager/locationtrail/eabi/locationtrailarm.def	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/eabi/locationtrailarm.def	Fri Mar 12 15:44:28 2010 +0200
@@ -41,4 +41,16 @@
 	_ZN15CLocationRecord18SetStateToStoppingEv @ 40 NONAME
 	_ZN15CLocationRecord17LocationSnapshotLERKj @ 41 NONAME
 	_ZN15CLocationRecord15RemappingNeededEv @ 42 NONAME
+	_ZN12CNetworkInfoD0Ev @ 43 NONAME
+	_ZN12CNetworkInfoD1Ev @ 44 NONAME
+	_ZN12CNetworkInfoD2Ev @ 45 NONAME
+	_ZN13CPositionInfoD0Ev @ 46 NONAME
+	_ZN13CPositionInfoD1Ev @ 47 NONAME
+	_ZN13CPositionInfoD2Ev @ 48 NONAME
+	_ZN15CLocationRecordD0Ev @ 49 NONAME
+	_ZN15CLocationRecordD1Ev @ 50 NONAME
+	_ZN15CLocationRecordD2Ev @ 51 NONAME
+	_ZN9CTrackLogD0Ev @ 52 NONAME
+	_ZN9CTrackLogD1Ev @ 53 NONAME
+	_ZN9CTrackLogD2Ev @ 54 NONAME
 
--- a/locationmanager/locationtrail/group/locationtrail.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/group/locationtrail.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -60,4 +60,7 @@
 BYTEPAIRCOMPRESSTARGET
 OPTION ARMCC -O3 -OTime
 
+#ifdef __VFP_HW_SUPPORT
+OPTION ARMCC --fpu vfpv2 --fpmode fast
+#endif
 
--- a/locationmanager/locationtrail/inc/clocationrecord.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/inc/clocationrecord.h	Fri Mar 12 15:44:28 2010 +0200
@@ -54,13 +54,13 @@
     /**
      * This method is used to notify about location trail state changes.
      */
-    virtual void LocationTrailStateChange() = 0;
+    virtual void LocationTrailStateChange() __SOFTFP = 0;
     
     virtual void CurrentLocation( const TPositionSatelliteInfo& aSatelliteInfo, 
     							  const CTelephony::TNetworkInfoV1& aNetworkInfo,
-                                  const TInt aError ) = 0;
+                                  const TInt aError ) __SOFTFP = 0;
     
-    virtual void GPSSignalQualityChanged( const TPositionSatelliteInfo& aSatelliteInfo ) = 0;
+    virtual void GPSSignalQualityChanged( const TPositionSatelliteInfo& aSatelliteInfo ) __SOFTFP = 0;
     };
 
 /**
@@ -81,7 +81,7 @@
 	 * This method is used to notify about new locations added to location trail
 	 */
 	virtual void LocationAdded( const TLocationTrailItem& aTrailItem, 
-								const TPositionSatelliteInfo& aSatellites ) = 0;
+								const TPositionSatelliteInfo& aSatellites ) __SOFTFP = 0;
 	};    
 
 /**
@@ -147,7 +147,7 @@
     								  TLocationData& aLocationData,
                                       /*TLocality& aPosition,
                                       CTelephony::TNetworkInfoV1& aNetworkInfo,*/
-                                      TLocTrailState& aState );
+                                      TLocTrailState& aState ) __SOFTFP;
 
     /**
      * Request location info. The result is returned by calllback method.
@@ -171,7 +171,7 @@
      * @param aCellId, Network cell is written into this param.
      * @return None.
      */
-    IMPORT_C void GetNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo );
+    IMPORT_C void GetNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo ) __SOFTFP;
     
     /**
      * Set observer for notifying state changes.
@@ -189,11 +189,11 @@
     static TInt UpdateNetworkInfo( TAny* aAny );
     
     IMPORT_C void CreateLocationObjectL( const TLocationData& aLocationData,
-    		const TUint& aObjectId );
+    		const TUint& aObjectId ) __SOFTFP;
     
     IMPORT_C void LocationSnapshotL( const TUint& aObjectId );
     
-    TItemId DoCreateLocationL( const TLocationData& aLocationData );
+    TItemId DoCreateLocationL( const TLocationData& aLocationData ) __SOFTFP;
     
     TItemId CreateRelationL( const TUint& aObjectId, const TUint& aLocationId );
     
@@ -212,7 +212,7 @@
      * @param 
      * @return 
      */
-    void NetworkInfo( const CTelephony::TNetworkInfoV1 &aNetworkInfo, TInt aError );
+    void NetworkInfo( const CTelephony::TNetworkInfoV1 &aNetworkInfo, TInt aError ) __SOFTFP;
     
 public: // from MPositionInfoObserver    
     /**
@@ -221,7 +221,7 @@
      * @param 
      * @return  
      */
-    void Position( const TPositionInfo& aPositionInfo, const TInt aError );
+    void Position( const TPositionInfo& aPositionInfo, const TInt aError ) __SOFTFP;
     
     
 public: // From MMdEQueryObserver
--- a/locationmanager/locationtrail/inc/clocationwrite.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/inc/clocationwrite.h	Fri Mar 12 15:44:28 2010 +0200
@@ -34,7 +34,7 @@
     /**
      * 2-phased constructor.
      */
-    IMPORT_C static CLocationWrite* NewL( CLocationRecord& aLocRecord );
+    IMPORT_C static CLocationWrite* NewL( CLocationRecord& aLocRecord ) __SOFTFP;
     
     /**
      * C++ destructor.
--- a/locationmanager/locationtrail/inc/cnetworkinfo.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/inc/cnetworkinfo.h	Fri Mar 12 15:44:28 2010 +0200
@@ -33,7 +33,7 @@
      * This method is used for setting the network cell id to the 
      * location trail.
      */
-    virtual void NetworkInfo( const CTelephony::TNetworkInfoV1 &aNetworkInfo, const TInt aError ) = 0;
+    virtual void NetworkInfo( const CTelephony::TNetworkInfoV1 &aNetworkInfo, const TInt aError ) __SOFTFP  = 0;
     };
 
 /**
--- a/locationmanager/locationtrail/inc/cpositioninfo.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/inc/cpositioninfo.h	Fri Mar 12 15:44:28 2010 +0200
@@ -36,7 +36,7 @@
      * location trail.
      */
     virtual void Position( const TPositionInfo& aPositionInfo, 
-                           const TInt aError ) = 0;
+                           const TInt aError ) __SOFTFP = 0;
     };
 
 /**
--- a/locationmanager/locationtrail/inc/ctracklog.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/inc/ctracklog.h	Fri Mar 12 15:44:28 2010 +0200
@@ -22,7 +22,7 @@
 #include <f32file.h>
 #include <lbs.h>
 #include "clocationrecord.h"
-#include <lbsSatellite.h>
+#include <lbssatellite.h>
 
 class MTrackLogObserver;
 class CGpxConverterAO;
@@ -66,7 +66,7 @@
 	 * This method is used to notify about converted GPX files
 	 */
 	virtual void GpxFileCreated( const TDesC& aFileName, TItemId aTagId, TReal32 aLength,
-			TTime aStart, TTime aEnd ) = 0;
+			TTime aStart, TTime aEnd ) __SOFTFP = 0;
 	};    
 
 class CTrackLog : public CBase, public MLocationAddObserver
@@ -111,7 +111,7 @@
 	/*
 	 * from MLocationAddObserver
 	 */
-	void LocationAdded( const TLocationTrailItem& aTrailItem, const TPositionSatelliteInfo& aSatellites );
+	void LocationAdded( const TLocationTrailItem& aTrailItem, const TPositionSatelliteInfo& aSatellites ) __SOFTFP;
 		
 	IMPORT_C void AddGpxObserver( MGpxConversionObserver* aObserver );
 	
--- a/locationmanager/locationtrail/inc/locationtraildefs.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/inc/locationtraildefs.h	Fri Mar 12 15:44:28 2010 +0200
@@ -28,7 +28,7 @@
 
 const TInt KMaxTrailLength = 480000000; // 8 min.
 
-const TInt KIntervalSeconds = KUpdateInterval / 1000000; // 10 seconds
+const TInt KMaximumIntervalSeconds = KUpdateTimeOut / 1000000; // 20 seconds
 
 const TInt KCurrentLocTimeoutCount = 48; // 48 * 10 sec -> 8 min timeout.
 
@@ -46,6 +46,8 @@
 
 const TInt KFirstInterval = 1000000; // 1 second
 
+const TInt KFirstTimeOut = 1500000; // 1.5 second
+
 //The name of the requestor
 _LIT( KRequestor,         "Location Trail" );
 
--- a/locationmanager/locationtrail/src/clocationrecord.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/src/clocationrecord.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -110,7 +110,7 @@
 // CLocationRecord::~CLocationRecord
 // --------------------------------------------------------------------------
 //    
-CLocationRecord::~CLocationRecord()
+EXPORT_C CLocationRecord::~CLocationRecord()
     {
     Stop();
     iProperty.Delete( KPSUidLocationTrail, KLocationTrailState );
@@ -212,7 +212,7 @@
 //
 EXPORT_C void CLocationRecord::GetLocationByTimeL( const TTime aTime, 
 												   TLocationData& aLocationData,
-                                                   TLocTrailState& aState )
+                                                   TLocTrailState& aState ) __SOFTFP 
     {
     LOG( "CLocationRecord::GetLocationByTimeL(), begin" );
     TInt posFound( EFalse );
@@ -242,7 +242,7 @@
         LOG1( "CLocationRecord::GetLocationByTimeL - timeDiff: %d", timeDiff );
 #endif
 
-        if ( err == KErrNone && timeDiff <= KIntervalSeconds )
+        if ( err == KErrNone && timeDiff <= KMaximumIntervalSeconds )
             {
             // The nearest time is in iTrail[i] or in iTrail[i-1].
             if ( i > 0 )
@@ -317,7 +317,7 @@
 // CLocationRecord::GetNetworkInfo
 // --------------------------------------------------------------------------
 //
-EXPORT_C void CLocationRecord::GetNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo )
+EXPORT_C void CLocationRecord::GetNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo ) __SOFTFP 
     {
     LOG("CLocationRecord::GetNetworkInfo");
 
@@ -328,7 +328,7 @@
 // CLocationRecord::SetObserver
 // --------------------------------------------------------------------------
 //
-EXPORT_C void CLocationRecord::SetObserver( MLocationTrailObserver* aObserver)
+EXPORT_C void CLocationRecord::SetObserver( MLocationTrailObserver* aObserver) 
     {
     iObserver = aObserver;
     }
@@ -348,7 +348,7 @@
 // --------------------------------------------------------------------------
 //    
 void CLocationRecord::Position( const TPositionInfo& aPositionInfo,
-                                const TInt aError  )
+                                const TInt aError  ) __SOFTFP
     {    
     const TPositionSatelliteInfo& positionSatelliteInfo = 
     	static_cast<const TPositionSatelliteInfo&>(aPositionInfo);
@@ -457,7 +457,7 @@
 // --------------------------------------------------------------------------
 //    
 void CLocationRecord::NetworkInfo( const CTelephony::TNetworkInfoV1 &aNetworkInfo, 
-		const TInt aError )
+		const TInt aError ) __SOFTFP
     {
     LOG("CLocationRecord::NetworkInfo");
     if ( aError == KErrNone )
@@ -585,7 +585,7 @@
 
 
 EXPORT_C void CLocationRecord::CreateLocationObjectL( const TLocationData& aLocationData,
-		const TUint& aObjectId )
+		const TUint& aObjectId ) __SOFTFP
 	{
 	TItemId locationId = DoCreateLocationL( aLocationData );
 	CreateRelationL( aObjectId, locationId );
@@ -792,7 +792,7 @@
 	}
 
 	
-TItemId CLocationRecord::DoCreateLocationL( const TLocationData& aLocationData )
+TItemId CLocationRecord::DoCreateLocationL( const TLocationData& aLocationData ) __SOFTFP 
 	{
 	LOG("CLocationRecord::DoCreateLocationL - start");
 	TItemId locationObjectId;
--- a/locationmanager/locationtrail/src/cnetworkinfo.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/src/cnetworkinfo.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -74,7 +74,7 @@
 // CNetworkInfo::~CNetworkInfo
 // --------------------------------------------------------------------------
 //    
-CNetworkInfo::~CNetworkInfo()
+EXPORT_C CNetworkInfo::~CNetworkInfo()
     {
     Cancel();
     delete iTelephony;
--- a/locationmanager/locationtrail/src/cpositioninfo.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/src/cpositioninfo.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -52,7 +52,7 @@
     // Set update interval.
     iUpdateOptions.SetUpdateInterval( TTimeIntervalMicroSeconds(KFirstInterval) );
     // Set time out level. 
-    iUpdateOptions.SetUpdateTimeOut( TTimeIntervalMicroSeconds(KUpdateTimeOut) );
+    iUpdateOptions.SetUpdateTimeOut( TTimeIntervalMicroSeconds(KFirstTimeOut) );
     // Positions which have time stamp below KMaxAge can be reused
     iUpdateOptions.SetMaxUpdateAge( TTimeIntervalMicroSeconds(KMaxAge) );
     // Disables location framework to send partial position data
@@ -72,7 +72,7 @@
 // CPositionInfo::~CPositionInfo
 // --------------------------------------------------------------------------
 //    
-CPositionInfo::~CPositionInfo()
+EXPORT_C CPositionInfo::~CPositionInfo()
     {
     Cancel();
     iPositioner.Close();
@@ -98,6 +98,8 @@
 
     iTrailCaptureSetting = aCaptureSetting;
     iUpdateInterval = aUpdateInterval;
+    iFirstInterval = ETrue;
+    iPositionInfo = TPositionSatelliteInfo();
     
     if ( aCaptureSetting == RLocationTrail::ECaptureAll ) 
     	{
@@ -150,7 +152,7 @@
     Cancel();
     
     iFirstInterval = ETrue;
-    iUpdateOptions.SetUpdateInterval( TTimeIntervalMicroSeconds(KFirstInterval) );
+    iUpdateOptions.SetUpdateInterval( TTimeIntervalMicroSeconds( KFirstInterval ) );
     
     iPositioner.Close();
     iPosServer.Close();
@@ -166,6 +168,7 @@
     if ( iFirstInterval && iTrailCaptureSetting == RLocationTrail::ECaptureAll )
     	{
     	iUpdateOptions.SetUpdateInterval( TTimeIntervalMicroSeconds( iUpdateInterval ) );
+    	iUpdateOptions.SetUpdateTimeOut( TTimeIntervalMicroSeconds( KUpdateTimeOut ) );
     	User::LeaveIfError( iPositioner.SetUpdateOptions( iUpdateOptions ) );
     	iFirstInterval = EFalse;
     	}
--- a/locationmanager/locationtrail/src/ctracklog.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/locationtrail/src/ctracklog.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -65,7 +65,7 @@
 	{
 	}
 
-CTrackLog::~CTrackLog()
+EXPORT_C CTrackLog::~CTrackLog()
 	{
 	delete iGpxConverter;
 	iFs.Close();
@@ -137,7 +137,7 @@
 	}
 
 void CTrackLog::LocationAdded( const TLocationTrailItem& aTrailItem, 
-							   const TPositionSatelliteInfo& aSatellites )
+							   const TPositionSatelliteInfo& aSatellites ) __SOFTFP
 	{
 	LOG("CTrackLog::LocationAdded start");
 
@@ -231,7 +231,7 @@
 			User::Leave( err );
 			}
 		writer << I64LOW( iTagId );
-		writer << I64HIGH( iTagId );
+		writer << I64HIGH( iTagId ); // Causes compiler warning due to misinterpretation by compiler parser
 		}
 	else 
 		{
--- a/locationmanager/server/group/locationmanagerserver.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/server/group/locationmanagerserver.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -57,4 +57,8 @@
 BYTEPAIRCOMPRESSTARGET
 OPTION ARMCC -O3 -OTime
 
+#ifdef __VFP_HW_SUPPORT
+OPTION ARMCC --fpu vfpv2 --fpmode fast
+#endif
+
 EPOCPROCESSPRIORITY background
--- a/locationmanager/server/inc/clocationmanagerserver.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/server/inc/clocationmanagerserver.h	Fri Mar 12 15:44:28 2010 +0200
@@ -201,7 +201,7 @@
     						 TLocationData& aLocationData,
                              /*TLocality& aPosition, 
                              CTelephony::TNetworkInfoV1& aNetworkInfo,*/
-                             TLocTrailState& aState );
+                             TLocTrailState& aState ) __SOFTFP;
 
     /**
      * Get current location.
@@ -232,7 +232,7 @@
      * @param aCurrLocReq 
      * @return None.
      */     
-    void GetCurrentNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo );
+    void GetCurrentNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo ) __SOFTFP;
     
     /**
      * Create a location context object in DB and create relationships to objects
@@ -241,7 +241,7 @@
      * @param aObjectId
      */
 	void CreateLocationObjectL( const TLocationData& aLocationData, 
-    						   	   const TUint& aObjectId );
+    						   	   const TUint& aObjectId ) __SOFTFP;
 	
     /**
      * Create a location context object in DB and create relationships to objects
@@ -270,7 +270,7 @@
 	
 	void IsTrackLogRecording( TBool &aRec );
 	
-	TInt GetTrackLogStatus( TBool& aRecording, TPositionSatelliteInfo& aFixQuality);
+	TInt GetTrackLogStatus( TBool& aRecording, TPositionSatelliteInfo& aFixQuality) __SOFTFP;
 	
 	TInt DeleteTrackLogL(const TDesC& aUri);
 	
@@ -290,7 +290,7 @@
      * @param None.
      * @return None.
      */
-    void LocationTrailStateChange();
+    void LocationTrailStateChange() __SOFTFP;
     
     /**
      * Callback method to return current location.
@@ -301,14 +301,14 @@
      * @return None.
      */
     void CurrentLocation( const TPositionSatelliteInfo& aSatelliteInfo,
-    		const CTelephony::TNetworkInfoV1& aNetworkInfo, const TInt aError );
+    		const CTelephony::TNetworkInfoV1& aNetworkInfo, const TInt aError ) __SOFTFP;
     
     /**
      * Callback method to notify observer of changes in GPS signal quality.
      * @param aSatelliteInfo, includes position and satellite info
      * @return None.
      */
-    void GPSSignalQualityChanged( const TPositionSatelliteInfo& aSatelliteInfo );
+    void GPSSignalQualityChanged( const TPositionSatelliteInfo& aSatelliteInfo ) __SOFTFP;
     
 public: // from MMdeObjectObserver
 	/**
@@ -326,7 +326,7 @@
 public: // from MGpxConversionObserver
 
 	void GpxFileCreated( const TDesC& aFileName, TItemId aTagId, TReal32 aLength,
-			TTime aStart, TTime aEnd );
+			TTime aStart, TTime aEnd ) __SOFTFP;
 
 private:    
     /**
--- a/locationmanager/server/src/clocationmanagerserver.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/locationmanager/server/src/clocationmanagerserver.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -306,6 +306,7 @@
 //
 void CLocationManagerServer::StartGPSPositioningL( RLocationTrail::TTrailCaptureSetting aCaptureSetting )
     {
+    LOG( "CLocationManagerServer::StartGPSPositioningL" );
     if ( aCaptureSetting == RLocationTrail::EOff )
     	{
     	return;
@@ -335,42 +336,28 @@
 //    
 void CLocationManagerServer::StopGPSPositioningL()
     {
+    LOG( "CLocationManagerServer::StopGPSPositioningL()" );
     iCaptureSetting = RLocationTrail::EOff;
     
     RLocationTrail::TTrailState state;
     GetLocationTrailState( state );
-    if( state == RLocationTrail::ETrailStarted || state == RLocationTrail::ETrailStarting )
-    	{
-        TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityStandard ) );
+    
+    
+    if( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping )
+        {
+        TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityHigh ) );
+        
         if ( error != KErrNone )
             {
             // If timer can't be created we stop the location trail immediately.
             iLocationRecord->Stop();
             StopTrackLogL();
             return;
-            }
-        iLocationRecord->SetStateToStopping();
-        iTimer->Start( KLocationTrailRemappingCheckDelay * 1000000, 0, TCallBack( CheckForRemappingCallback, this ) );
-    	}
-    else if ( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping )
-        {
-        TInt delay( iLocManStopDelay );
-        if ( iLocationRecord->RemappingNeeded() )
-        	{
-            delay = iLocManStopRemapDelay;
-        	}
+            }   
         
-        TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityStandard ) );
-        if ( error != KErrNone )
-        	{
-        	// If timer can't be created we stop the location trail immediately.
-        	iLocationRecord->Stop();
-        	StopTrackLogL();
-        	return;
-        	}
         iLocationRecord->SetStateToStopping();
-        iTimer->Start( delay * 1000000, 0, TCallBack( PositioningStopTimeout, this ) );
-        }
+        iTimer->Start( iLocManStopDelay * 1000000, 0, TCallBack( CheckForRemappingCallback, this ) );
+    	}
     
     // Always stop tracklog.
     StopTrackLogL();
@@ -382,6 +369,7 @@
 //
 void CLocationManagerServer::StopRecording()
 	{
+    LOG( "CLocationManagerServer::StopRecording()" );
 	iLocationRecord->Stop();
 	delete iTimer;
 	iTimer = NULL;
@@ -393,6 +381,7 @@
 //
 TInt CLocationManagerServer::PositioningStopTimeout( TAny* aAny )
 	{
+    LOG( "CLocationManagerServer::PositioningStopTimeout" );
 	CLocationManagerServer* self = STATIC_CAST( CLocationManagerServer*, aAny );
 	self->StopRecording();
 	
@@ -405,21 +394,18 @@
 //
 TInt CLocationManagerServer::CheckForRemappingCallback( TAny* aAny )
     {
+    LOG( "CLocationManagerServer::CheckForRemappingCallback" );
     CLocationManagerServer* self = STATIC_CAST( CLocationManagerServer*, aAny );
 
-    self->iTimer->Cancel();
+    self->iTimer->Cancel();    
     
-    TInt delay( self->iLocManStopDelay );
     if ( self->iLocationRecord->RemappingNeeded() )
-        {
-        delay = self->iLocManStopRemapDelay;
-        self->iTimer->Start( delay * 1000000, 0, TCallBack( PositioningStopTimeout, self ) );
+        {     
+        self->iTimer->Start( self->iLocManStopRemapDelay * 1000000, 0, TCallBack( PositioningStopTimeout, self ) );
         }
     else
-        {
-        delete self->iTimer;
-        self->iTimer = NULL;
-        self->iLocationRecord->Stop();
+        {        
+        self->StopRecording();
         }
     
     return KErrNone;
@@ -489,7 +475,7 @@
 //   
 void CLocationManagerServer::GetLocationByTimeL( const TTime& aTimeStamp, 
 												 TLocationData& aLocationData,
-                                                 TLocTrailState& aState )
+                                                 TLocTrailState& aState ) __SOFTFP
     {
     iLocationRecord->GetLocationByTimeL( aTimeStamp,
     									 aLocationData,
@@ -543,7 +529,7 @@
 // CLocationManagerServer::GetCurrentCellId
 // --------------------------------------------------------------------------
 //    
-void CLocationManagerServer::GetCurrentNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo )
+void CLocationManagerServer::GetCurrentNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo ) __SOFTFP
     {
     iLocationRecord->GetNetworkInfo( aNetworkInfo );
     }    
@@ -552,7 +538,7 @@
 // CLocationManagerServer::LocationTrailStateChange
 // --------------------------------------------------------------------------
 //    
-void CLocationManagerServer::LocationTrailStateChange()
+void CLocationManagerServer::LocationTrailStateChange() __SOFTFP
     {
     LOG( "CLocationManagerServer::LocationTrailStateChange(), begin" );
 
@@ -575,7 +561,7 @@
 //
 void CLocationManagerServer::CurrentLocation( const TPositionSatelliteInfo& aSatelliteInfo, 
 											  const CTelephony::TNetworkInfoV1& aNetworkInfo,
-                                              const TInt aError )
+                                              const TInt aError ) __SOFTFP
     {
     LOG( "CLocationManagerServer::CurrentLocation(), begin" );
     const TInt KParamLocationData = 0;
@@ -622,7 +608,7 @@
     LOG( "CLocationManagerServer::CurrentLocation(), end" );    
     }
 
-void CLocationManagerServer::GPSSignalQualityChanged( const TPositionSatelliteInfo& aSatelliteInfo )
+void CLocationManagerServer::GPSSignalQualityChanged( const TPositionSatelliteInfo& aSatelliteInfo ) __SOFTFP
 	{
 	LOG( "CLocationManagerServer::GPSSignalQualityChanged" );
 	const TInt KFixParam = 0;
@@ -697,7 +683,7 @@
 	}
 
 void CLocationManagerServer::CreateLocationObjectL( const TLocationData& aLocationData,
-													const TUint& aObjectId )
+													const TUint& aObjectId ) __SOFTFP
 	{
 	if ( !IsSessionReady() )
 		{
@@ -1058,7 +1044,7 @@
 	}
 
 void CLocationManagerServer::GpxFileCreated( const TDesC& aFileName, TItemId aTagId,
-		TReal32 aLength, TTime aStart, TTime aEnd )
+		TReal32 aLength, TTime aStart, TTime aEnd ) __SOFTFP
 	{
 	TRAP_IGNORE( CreateTrackLogL( aTagId, aFileName, aLength, aStart, aEnd ) );
 	}
@@ -1146,7 +1132,7 @@
     CleanupStack::PopAndDestroy( trackLog );
 	}
 
-TInt CLocationManagerServer::GetTrackLogStatus( TBool& aRecording, TPositionSatelliteInfo& aFixQuality)
+TInt CLocationManagerServer::GetTrackLogStatus( TBool& aRecording, TPositionSatelliteInfo& aFixQuality) __SOFTFP
 	{
 	if ( !iTrackLog )
 		{
--- a/mds_plat/metadata_engine_api/inc/mdeobjectcondition.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/mds_plat/metadata_engine_api/inc/mdeobjectcondition.h	Fri Mar 12 15:44:28 2010 +0200
@@ -232,7 +232,7 @@
      * @param aString         Text string to look for.
      * @param aObjectIds      object IDs to look for.
      */
-    void CMdEObjectCondition::ConstructL( const RArray<TItemId>* aObjectIds,
+    void ConstructL( const RArray<TItemId>* aObjectIds,
     		const TDesC* aString, const TMdEUintRange* aRange );
 
 private:
--- a/mds_plat/metadata_engine_api/inc/mdeproperty.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/mds_plat/metadata_engine_api/inc/mdeproperty.h	Fri Mar 12 15:44:28 2010 +0200
@@ -69,7 +69,7 @@
 	 * @param aObject owner object of property
 	 * @return new numeric property
 	 */
-	static CMdEProperty* CMdEProperty::NewL(const CMdEPropertyDef& aDef, const CMdEObject& aObject);
+	static CMdEProperty* NewL(const CMdEPropertyDef& aDef, const CMdEObject& aObject);
 
 	/**
 	 * Constructs a new property.
@@ -78,7 +78,7 @@
 	 * @param aObject owner object of property
 	 * @return new numeric property
 	 */
-	static CMdEProperty* CMdEProperty::NewLC(const CMdEPropertyDef& aDef, const CMdEObject& aObject);
+	static CMdEProperty* NewLC(const CMdEPropertyDef& aDef, const CMdEObject& aObject);
 
 
 	/**
--- a/mds_plat/metadata_engine_api/inc/mdequery.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/mds_plat/metadata_engine_api/inc/mdequery.h	Fri Mar 12 15:44:28 2010 +0200
@@ -658,6 +658,8 @@
     RPointerArray<MMdEQueryObserver> iObservers;
     
     CDesCArray* iDistinctResults;
+    
+    TBool iDestroyed;
     };
 
     
--- a/metadataengine/client/bwincw/mdeclientu.def	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/client/bwincw/mdeclientu.def	Fri Mar 12 15:44:28 2010 +0200
@@ -295,4 +295,5 @@
 	?PlaceholderOnly@CMdEObjectCondition@@QBEHXZ @ 294 NONAME ; int CMdEObjectCondition::PlaceholderOnly(void) const
 	?SetPlaceholderOnly@CMdEObjectCondition@@QAEXH@Z @ 295 NONAME ; void CMdEObjectCondition::SetPlaceholderOnly(int)
 	?CheckMassStorageMediaId@CMdEHarvesterSession@@QAEXK@Z @ 296 NONAME ; void CMdEHarvesterSession::CheckMassStorageMediaId(unsigned long)
+	?Id@CMdEObjectDef@@QBEKXZ @ 297 NONAME ; unsigned long CMdEObjectDef::Id(void) const
 
--- a/metadataengine/client/eabi/mdeclientu.def	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/client/eabi/mdeclientu.def	Fri Mar 12 15:44:28 2010 +0200
@@ -366,4 +366,5 @@
 	_ZN19CMdEObjectCondition18SetPlaceholderOnlyEi @ 365 NONAME
 	_ZNK19CMdEObjectCondition15PlaceholderOnlyEv @ 366 NONAME
 	_ZN20CMdEHarvesterSession23CheckMassStorageMediaIdEm @ 367 NONAME
+	_ZNK13CMdEObjectDef2IdEv @ 368 NONAME
 
--- a/metadataengine/client/group/mdeclient.mmp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/client/group/mdeclient.mmp	Fri Mar 12 15:44:28 2010 +0200
@@ -85,5 +85,5 @@
 
 DEBUGLIBRARY    flogger.lib
 
+OPTION ARMCC -O2 -OTime
 
-
--- a/metadataengine/client/inc/mdeenginesession.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/client/inc/mdeenginesession.h	Fri Mar 12 15:44:28 2010 +0200
@@ -37,11 +37,6 @@
 
 _LIT( KMdSServerFilename, "MdSServer" );
 
-#ifdef __WINS__
-static const TUint KServerMinHeapSize = 0x10000;
-static const TUint KServerMaxHeapSize = 0x400000; // ~4 megs
-#endif
-
 // FORWARD DECLARATIONS
 class CMdESessionImpl;
 class CMdESchemaItem;
--- a/metadataengine/client/inc/mdesessionimpl.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/client/inc/mdesessionimpl.h	Fri Mar 12 15:44:28 2010 +0200
@@ -639,9 +639,6 @@
                 
 		/** Open observer. */
 		MMdESessionObserver* iSessionObserver;
-
-		/** Schema observers. */
-		RPointerArray<MMdESchemaObserver> iSchemaObserverArray;
 		
 		RChunk iSchemaChunk;
 		
--- a/metadataengine/client/src/mdeasynchronousfindao.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/client/src/mdeasynchronousfindao.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -107,7 +107,7 @@
         }
 
     iConditionBuffer = 
-    	CMdEQueryCriteriaSerialization::NewLC( resultMode, iQuery.Type(),     										   
+    	CMdEQueryCriteriaSerialization::NewL( resultMode, iQuery.Type(),     										   
     										   iQuery.NamespaceDef(), 
     										   objectDef, 
     										   objectDefs, 
@@ -116,7 +116,6 @@
     										   queryOptimizationFlags, 
     										   iQuery.Conditions(), iQuery.OrderRules(),
     										   propertyFilter );
-	CleanupStack::Pop();
     iSession.DoFindAsync( 
     	iQuery.GetQueryId(), 
         *iConditionBuffer,
--- a/metadataengine/client/src/mdelogiccondition.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/client/src/mdelogiccondition.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -331,8 +331,8 @@
 MDE_IMPLEMENT_ADD_RANGE_PROPERTY_CONDITION(Real)
 MDE_IMPLEMENT_ADD_RANGE_PROPERTY_CONDITION(Time)
 
-EXPORT_C CMdETextPropertyCondition& 
-CMdELogicCondition::AddPropertyConditionL(const CMdEPropertyDef& aPropertyDef,
+EXPORT_C CMdETextPropertyCondition& CMdELogicCondition::AddPropertyConditionL(
+                                          const CMdEPropertyDef& aPropertyDef,
                                           TTextPropertyConditionCompareMethod aCompareMethod,
                                           const TDesC& aText)
     {
--- a/metadataengine/client/src/mdenotifierao.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/client/src/mdenotifierao.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -238,74 +238,64 @@
         case EObjectNotifyAdd:
         	{
         	MMdEObjectObserver* obs = static_cast<MMdEObjectObserver*>( iObserver );
-        	obs->HandleObjectNotification( iSessionImpl, ENotifyAdd, iIdArray );
-            iIdArray.Reset();            
+        	obs->HandleObjectNotification( iSessionImpl, ENotifyAdd, iIdArray );     
         	break;
         	}
         case EObjectNotifyModify:
         	{
         	MMdEObjectObserver* obs = static_cast<MMdEObjectObserver*>( iObserver );
-        	obs->HandleObjectNotification( iSessionImpl, ENotifyModify, iIdArray );
-            iIdArray.Reset();            
+        	obs->HandleObjectNotification( iSessionImpl, ENotifyModify, iIdArray );         
         	break;
         	}
         case EObjectNotifyRemove:
         	{
         	MMdEObjectObserver* obs = static_cast<MMdEObjectObserver*>( iObserver );
-        	obs->HandleObjectNotification( iSessionImpl, ENotifyRemove, iIdArray );
-            iIdArray.Reset();            
+        	obs->HandleObjectNotification( iSessionImpl, ENotifyRemove, iIdArray );        
         	break;
         	}
 
         case EObjectNotifyPresent:
         	{
 	    	MMdEObjectPresentObserver* obs = static_cast<MMdEObjectPresentObserver*>( iObserver );
-            obs->HandleObjectPresentNotification( iSessionImpl, ETrue, iIdArray );
-            iIdArray.Reset();            
+            obs->HandleObjectPresentNotification( iSessionImpl, ETrue, iIdArray );      
 	    	break;
         	}
         case EObjectNotifyNotPresent:
         	{
 	    	MMdEObjectPresentObserver* obs = static_cast<MMdEObjectPresentObserver*>( iObserver );
-            obs->HandleObjectPresentNotification( iSessionImpl, EFalse, iIdArray );
-            iIdArray.Reset();            
+            obs->HandleObjectPresentNotification( iSessionImpl, EFalse, iIdArray );       
 	    	break;
         	}
     	
         case ERelationNotifyAdd:
         	{
 	        MMdERelationObserver* obs = static_cast<MMdERelationObserver*>( iObserver );
-            obs->HandleRelationNotification( iSessionImpl, ENotifyAdd, iIdArray );
-            iIdArray.Reset();            
+            obs->HandleRelationNotification( iSessionImpl, ENotifyAdd, iIdArray );           
 	        break;
         	}
         case ERelationNotifyModify:
         	{
 	        MMdERelationObserver* obs = static_cast<MMdERelationObserver*>( iObserver );
-            obs->HandleRelationNotification( iSessionImpl, ENotifyModify, iIdArray );
-            iIdArray.Reset();            
+            obs->HandleRelationNotification( iSessionImpl, ENotifyModify, iIdArray );        
 	        break;
         	}
         case ERelationNotifyRemove:
         	{
 	        MMdERelationObserver* obs = static_cast<MMdERelationObserver*>( iObserver );
-            obs->HandleRelationNotification( iSessionImpl, ENotifyRemove, iIdArray );
-            iIdArray.Reset();            
+            obs->HandleRelationNotification( iSessionImpl, ENotifyRemove, iIdArray );        
 	        break;
         	}
 
         case ERelationNotifyPresent:
         	{
 	    	MMdERelationPresentObserver* obs = static_cast<MMdERelationPresentObserver*>( iObserver );
-            obs->HandleRelationPresentNotification( iSessionImpl, ETrue, iIdArray );
-            iIdArray.Reset();            
+            obs->HandleRelationPresentNotification( iSessionImpl, ETrue, iIdArray );          
 	    	break;
         	}
         case ERelationNotifyNotPresent:
         	{
 	    	MMdERelationPresentObserver* obs = static_cast<MMdERelationPresentObserver*>( iObserver );
-            obs->HandleRelationPresentNotification( iSessionImpl, EFalse, iIdArray );
-            iIdArray.Reset();            
+            obs->HandleRelationPresentNotification( iSessionImpl, EFalse, iIdArray );         
 	    	break;
         	}
         	
@@ -313,22 +303,21 @@
         	{
         	MMdERelationItemObserver* obs = static_cast<MMdERelationItemObserver*>( iObserver );
             obs->HandleRelationItemNotification( iSessionImpl, ENotifyRemove, iRelationItemArray );
-            iRelationItemArray.Reset();            
+            iRelationItemArray.Reset();
+            iRelationItemArray.Compress();
         	break;
         	}
 
         case EEventNotifyAdd:
         	{
             MMdEEventObserver* obs = static_cast<MMdEEventObserver*>( iObserver );
-            obs->HandleEventNotification( iSessionImpl, ENotifyAdd, iIdArray);
-            iIdArray.Reset();            
+            obs->HandleEventNotification( iSessionImpl, ENotifyAdd, iIdArray);      
             break;
         	}
         case EEventNotifyRemove:
         	{
             MMdEEventObserver* obs = static_cast<MMdEEventObserver*>( iObserver );
-            obs->HandleEventNotification( iSessionImpl, ENotifyRemove, iIdArray);
-            iIdArray.Reset();            
+            obs->HandleEventNotification( iSessionImpl, ENotifyRemove, iIdArray);           
             break;
         	}
     	
@@ -343,6 +332,8 @@
         	// no observer to call - this should be skipped on server side!
         	break;
         }
+    iIdArray.Reset();
+    iIdArray.Compress();
     }
 
 void CMdENotifierAO::DecodeIdBufferL()
@@ -356,6 +347,7 @@
 	__ASSERT_DEBUG( iNamespaceDefId == itemIds.iNamespaceDefId, User::Panic( _L("Incorrect namespaceDef from returned items!"), KErrCorrupt ) );
 
     iDataBuffer->PositionL( itemIds.iObjectIds.iPtr.iOffset );
+    iIdArray.ReserveL( itemIds.iObjectIds.iPtr.iCount );
 	for( TUint32 i = 0; i < itemIds.iObjectIds.iPtr.iCount; ++i )
 		{
 		TItemId id;
@@ -374,12 +366,13 @@
     CMdENamespaceDef& namespaceDef = iSessionImpl.GetNamespaceDefL( iNamespaceDefId );
     iDataBuffer->PositionL( items.iRelations.iPtr.iOffset );
     TMdERelation relation;
+    iRelationItemArray.ReserveL( items.iRelations.iPtr.iCount );
     for (TInt i = 0; i < items.iRelations.iPtr.iCount; ++i )
     	{
     	relation.DeSerializeL( *iDataBuffer, namespaceDef );
     	if ( relation.Id() )
     		{
-    		iRelationItemArray.Append( relation );
+    		iRelationItemArray.AppendL( relation );
     		}
     	}
 	}
--- a/metadataengine/client/src/mdeobjectdef.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/client/src/mdeobjectdef.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -71,7 +71,7 @@
     iPropertyDefs.Close();
     }
 
-TDefId CMdEObjectDef::Id() const
+EXPORT_C TDefId CMdEObjectDef::Id() const
     {
     return iObjectDef.iDefId;
     }
--- a/metadataengine/client/src/mdequery.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/client/src/mdequery.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -28,7 +28,7 @@
 CMdEQuery::CMdEQuery(TQueryType aType, CMdESession& aSession, CMdENamespaceDef& aNamespaceDef)
         : iQueryId( 0 ), iSession(aSession), iNamespaceDef(aNamespaceDef), iType(aType), 
           iResultMode(EQueryResultModeItem), iState(EStateNew), iError(KErrNone), 
-          iObjectResult(NULL), iCountResult(0), iDistinctResults(NULL)
+          iObjectResult(NULL), iCountResult(0), iDistinctResults(NULL), iDestroyed(EFalse)
     {
     }
 
@@ -41,6 +41,7 @@
 
 CMdEQuery::~CMdEQuery()
 	{
+    iDestroyed = ETrue;
 	Cancel();
   
     // This will destroy the entire conditions tree.
@@ -204,7 +205,10 @@
     if( incomplete || IsComplete() == EFalse )
     	{
     	iState = EStateError;
-    	NotifyCompleted( KErrCancel );
+    	if( !iDestroyed )
+    	    {
+            NotifyCompleted( KErrCancel );
+    	    }
     	}
     }
 
@@ -538,11 +542,14 @@
 
     // Update the latest error code.
     iError = aError;
-	for (TInt i = iObservers.Count() - 1; i >= 0; --i)
-		{
-		MMdEQueryObserver* observer = iObservers[i];
-		observer->HandleQueryCompleted(*this, aError);
-		}
+    for (TInt i = iObservers.Count() - 1; i >= 0; --i)
+        {
+        MMdEQueryObserver* observer = iObservers[i];
+        if( observer )
+            {
+            observer->HandleQueryCompleted(*this, aError);
+            }
+        }
     }
 
 
--- a/metadataengine/client/src/mdesessionimpl.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/client/src/mdesessionimpl.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -68,7 +68,11 @@
 			RMdESessionAsyncRequest::EAddRequest, 
 			aBuffer, aResultBuffer, aRequestStatus );
 
-	iRequests.Append(request);
+	const TInt error = iRequests.Append(request);
+    if( error != KErrNone )
+        {
+        return;
+        }
 
 	if( !IsActive() )
 		{
@@ -86,7 +90,11 @@
 			RMdESessionAsyncRequest::EUpdateRequest,
 			aBuffer, aResultBuffer, aRequestStatus);
 
-	iRequests.Append(request);
+	const TInt error = iRequests.Append(request);
+    if( error != KErrNone )
+        {
+        return;
+        }
 
 	if( !IsActive() )
 		{
@@ -104,7 +112,11 @@
 			RMdESessionAsyncRequest::ERemoveRequest, 
 			aBuffer, aResultBuffer, aRequestStatus);
 
-	iRequests.Append(request);
+	const TInt error = iRequests.Append(request);
+	if( error != KErrNone )
+	    {
+	    return;
+	    }
 
 	if( !IsActive() )
 		{
@@ -224,8 +236,6 @@
 	{
     // No session errors should be sent during deconstruction to avoid possible double deletion
     iSessionObserver = NULL;
-    
-	Close();
 
 	delete iSchemaBuffer;
 
@@ -253,8 +263,6 @@
 
 void CMdESessionImpl::Close()
 	{
-	iSchemaObserverArray.Reset();
-	iSchemaObserverArray.Close();
 	}
 
 TInt CMdESessionImpl::NamespaceDefCount() const
@@ -1669,7 +1677,7 @@
 	{
 	RPointerArray<CMdEInstanceItem> items;
 	CleanupClosePushL( items );
-	items.Append( &aItem );
+	items.AppendL( &aItem );
 	User::LeaveIfError( AddItemsL( items ) );
 	CleanupStack::PopAndDestroy( &items );
 	return aItem.Id();
@@ -1898,7 +1906,7 @@
     {
 	RPointerArray<CMdEInstanceItem> items;
 	CleanupClosePushL( items );
-	items.Append( &aRelation );
+	items.AppendL( &aRelation );
 	User::LeaveIfError( UpdateItemsL( items ) );
 	CleanupStack::PopAndDestroy( &items );
 	return aRelation.Id();
@@ -2269,7 +2277,7 @@
     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
 
     CleanupStack::Pop( notifier );
-    iNotifiers.Append( notifier );
+    iNotifiers.AppendL( notifier );
     
     CleanupStack::PopAndDestroy( aCondition );
     }
@@ -2296,7 +2304,7 @@
     		&aObserver, NULL, namespaceDef );
 
     CleanupStack::Pop( notifier );
-    iNotifiers.Append( notifier );
+    iNotifiers.AppendL( notifier );
 	}
 
 void CMdESessionImpl::AddRelationObserverL( MMdERelationObserver& aObserver,
@@ -2352,7 +2360,7 @@
     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
 
     CleanupStack::Pop( notifier );
-    iNotifiers.Append( notifier );
+    iNotifiers.AppendL( notifier );
     
     CleanupStack::PopAndDestroy( aCondition );
     }
@@ -2409,7 +2417,7 @@
 	notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
 	
 	CleanupStack::Pop( notifier );
-	iNotifiers.Append( notifier );
+	iNotifiers.AppendL( notifier );
 	
     CleanupStack::PopAndDestroy( aCondition );
 	}
@@ -2438,7 +2446,7 @@
     		&aObserver, NULL, namespaceDef );
 
     CleanupStack::Pop( notifier );
-    iNotifiers.Append( notifier );
+    iNotifiers.AppendL( notifier );
 	}
 
 void CMdESessionImpl::AddEventObserverL( MMdEEventObserver& aObserver,
@@ -2495,7 +2503,7 @@
     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
 
     CleanupStack::Pop( notifier );
-    iNotifiers.Append( notifier );
+    iNotifiers.AppendL( notifier );
     
     CleanupStack::PopAndDestroy( aCondition );
     }
--- a/metadataengine/server/inc/mdsfindengine.h	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/inc/mdsfindengine.h	Fri Mar 12 15:44:28 2010 +0200
@@ -137,13 +137,7 @@
         * Transfer result set to client
         * @aError error code or KErrNone
         */
-        void SetComplete( TInt aError );
-
-        /**
-        * Transfer results to client and completes find
-        * @aError error code or KErrNone
-        */
-        void FindComplete( TInt aError );
+        void SetComplete( TInt aError, TBool aSet );
 
 		const CMdCSerializationBuffer& ResultsL() const;
 
--- a/metadataengine/server/src/mdsclausebuffer.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsclausebuffer.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -62,15 +62,11 @@
 //
 void CMdsClauseBuffer::ConstructL( TInt aInitialSize )
     {
-    if ( aInitialSize < 1 )
+    if ( aInitialSize < 1 || aInitialSize > 100000 )
     	{
     	aInitialSize = 1;
     	}
     iCurrentBufSize = aInitialSize;
-    if (aInitialSize > 100000 || aInitialSize < 0)
-    	{
-    	aInitialSize = 0;
-    	}
 
     iBuffer = HBufC::NewL( iCurrentBufSize );
     }
@@ -104,11 +100,11 @@
         return EFalse;
         }
 
+    // realloc and copy
+    iBuffer = iBuffer->ReAllocL( aRequired );
+    
 	iCurrentBufSize = aRequired;
 
-    // realloc and copy
-    iBuffer = iBuffer->ReAllocL( iCurrentBufSize );
-
     return ETrue;
     }
 
--- a/metadataengine/server/src/mdsdiskspacenotifier.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsdiskspacenotifier.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -57,7 +57,13 @@
 		switch( status )
 			{
 			case KErrNone:
-				iFileServerSession.Volume( volumeInfo, iDrive );
+			    {
+				const TInt error = iFileServerSession.Volume( volumeInfo, iDrive );
+				if( error != KErrNone )
+				    {
+				    StartNotifier();
+				    break;
+				    }
 				
 				// Check if free space is less than threshold level
 				if( volumeInfo.iFree < iThreshold )
@@ -78,6 +84,7 @@
 					}
 				StartNotifier();
 				break;
+			    }
 
 			case KErrArgument:
 				User::Leave( status );
@@ -89,8 +96,15 @@
 	else if ( iState == CMdSDiskSpaceNotifierAO::EIterate )
 		{
 		const TInt KMaxIterations = 10;
-		
-		iFileServerSession.Volume( volumeInfo, iDrive );
+        TInt error = iFileServerSession.Volume( volumeInfo, iDrive );
+        if( error != KErrNone )
+            {
+            iState = ENormal;
+            iIterationCount = 0;
+            StartNotifier();
+            return;
+            }
+
 		if ( volumeInfo.iFree < iThreshold )
 			{
 			iObserver.HandleDiskSpaceNotificationL( MMdSDiskSpaceNotifierObserver::ELess );
@@ -104,7 +118,14 @@
 				}
 			else
 				{
-				iFileServerSession.Volume( volumeInfo, iDrive );
+		        error = iFileServerSession.Volume( volumeInfo, iDrive );
+		        if( error != KErrNone )
+		            {
+		            iState = ENormal;
+		            iIterationCount = 0;
+		            StartNotifier();
+		            return;
+		            }
 				if ( volumeInfo.iFree >= iThreshold )
 					{
 					iDiskFull = EFalse;
@@ -155,8 +176,8 @@
 	User::LeaveIfError( iFileServerSession.Connect( KMessageSlotCount ) );
 	
 	TVolumeInfo volumeInfo;
-	iFileServerSession.Volume( volumeInfo, iDrive );	
-	if ( volumeInfo.iFree < iThreshold )
+	const TInt error = iFileServerSession.Volume( volumeInfo, iDrive );	
+	if ( (error != KErrNone) || volumeInfo.iFree < iThreshold )
 		{
 		iDiskFull = ETrue;
 		}
--- a/metadataengine/server/src/mdseventdef.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdseventdef.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -74,7 +74,8 @@
     CleanupClosePushL( rowData );
 	rowData.AppendL( TColumn( aNamespaceDefId ) );
 	rowData.AppendL( TColumn( iPriority ) );
-	rowData.AppendL( TColumn( GetName().AllocL() ) );
+	rowData.AppendL( TColumn( GetName().AllocLC() ) );
+	CleanupStack::Pop(); // name
 
 	TDefId id = MMdSIndexer::ExecuteAndGetIndexL(KMdsSqlClauseAddEventDef, rowData );
 
--- a/metadataengine/server/src/mdsfindengine.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsfindengine.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -217,10 +217,20 @@
 // SetComplete
 // ---------------------------------------------------------------------------
 //
-void CMdSFindEngine::SetComplete( TInt aError )
+void CMdSFindEngine::SetComplete( TInt aError, TBool aSet )
     {
     TBool toComplete = iAsyncPending;
-    __LOG1( ELogServer, "<- Find Set Complete (%d)", aError );
+    
+#ifdef _DEBUG
+    if( aSet )
+        {
+        __LOG1( ELogServer, "<- Find Set Complete (%d)", aError );
+        }
+    else
+        {
+        __LOG1( ELogServer, "<- Find Complete (%d)", aError );    
+        }
+#endif
 
     if( aError == KErrNone )
         {
@@ -260,7 +270,14 @@
        		{        	
        		if ( toComplete && iMessage.IsNull() == EFalse ) 
        			{
-       			iMessage.Complete( EAsyncFindSetReady );
+       		    if( aSet )
+       		        {
+                    iMessage.Complete( EAsyncFindSetReady );
+       		        }
+       		    else
+       		        {
+       		        iMessage.Complete( EAsyncFindComplete );
+       		        }
        			}
        		}
         }
@@ -274,67 +291,6 @@
         }
     }
 
-// ---------------------------------------------------------------------------
-// FindComplete
-// ---------------------------------------------------------------------------
-//
-void CMdSFindEngine::FindComplete( TInt aError )
-    {
-    TBool toComplete = iAsyncPending;
-    __LOG1( ELogServer, "<- Find Complete (%d)", aError );
-
-    if( aError == KErrNone )
-        {
-        TUint32 resultSize = 0;
-
-        TInt err = KErrNone;
-
-        TRAP( err, resultSize = iSequence->ResultsL().Size() );
-
-       	if( err )
-       		{
-       		if ( toComplete && iMessage.IsNull() == EFalse )
-       			{
-       			iMessage.Complete( err );
-       			}
-       		return;
-       		}
-
-        iAsyncPending = EFalse;
-        
-        if ( iMessage.IsNull() == EFalse )
-        	{
-        	TPckgBuf<TInt> sizeBuf( resultSize );    	
-
-        	err = iMessage.Write( 2, sizeBuf );
-        	}
-
-       	if( err )
-       		{
-       		if ( toComplete && iMessage.IsNull() == EFalse ) 
-       			{
-       			iMessage.Complete( err );
-       			}
-       		return;
-       		}
-       	else
-			{
-        	if ( toComplete && iMessage.IsNull() == EFalse ) 
-        		{
-        		iMessage.Complete( EAsyncFindComplete );
-        		}
-			}
-        }
-    else
-        {
-       	if ( toComplete && iMessage.IsNull() == EFalse ) 
-       		{
-       		iMessage.Complete( aError );
-       		}
-       	return;
-        }
-    }
-
 const CMdCSerializationBuffer& CMdSFindEngine::ResultsL() const
 	{
 	return iSequence->ResultsL();
--- a/metadataengine/server/src/mdsfindsequence.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsfindsequence.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -284,7 +284,7 @@
         CMdSFindEngine* obs = iObserver;
         if ( obs )
         	{
-        	obs->SetComplete( KErrNone );
+        	obs->SetComplete( KErrNone, ETrue );
         	}
         }
     else if ( result == KErrCancel )
@@ -297,7 +297,7 @@
         CMdSFindEngine* obs = iObserver;
         if ( obs )
         	{
-        	obs->FindComplete( result );
+        	obs->SetComplete( result, EFalse );
         	}
         }
     }
@@ -311,7 +311,7 @@
     // Cleanup if RunL() leaves
     CMdSFindEngine* obs = iObserver;
     CleanUp();
-    obs->FindComplete( aError );
+    obs->SetComplete( aError, EFalse );
     return KErrNone;
     }
 
@@ -507,7 +507,7 @@
 
 		RArray<TMdCObject> objectArray;
 		CleanupClosePushL( objectArray );
-		objectArray.Reserve( items.iObjects.iPtr.iCount );
+		objectArray.ReserveL( items.iObjects.iPtr.iCount );
 		// store objects in array in correct order
 		for( TInt i = 0; i < items.iObjects.iPtr.iCount; ++i )
 			{
--- a/metadataengine/server/src/mdsfindsqlclause.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsfindsqlclause.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -2610,7 +2610,7 @@
 				// expected result for property's type
 			    iResultRow.AppendL( TColumn( propDef->GetSqlType() ) );
 
-			    iPropertyFilters.Append( propDef );
+			    iPropertyFilters.AppendL( propDef );
 				}
 			}
 		}
--- a/metadataengine/server/src/mdsimportexport.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsimportexport.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -570,6 +570,7 @@
 		    
 		    // Text properties may have an extra flag: index flag.
 		    TBool indexed( EFalse );
+		    // Ignore error code as the flag might not exist and indexing is not mandatory
 		    ImportNum( indexed, aParser );
     		// Add this property to the previously defined object.
     		iLastObjectDef->AddPropertyL( name, type, minVal32, maxVal32, readOnly, mandatory, indexed );
@@ -876,7 +877,7 @@
 	// DB version
     MMdsPreferences::GetL( KMdsDBVersionName, MMdsPreferences::EPreferenceBothGet,
     						  majorVersion, &minorVersion );
-	if ( majorVersion != KMdSServMajorVersionNumber && (TInt)minorVersion != KMdSServMinorVersionNumber )
+	if ( majorVersion != KMdSServMajorVersionNumber || (TInt64)minorVersion != KMdSServMinorVersionNumber )
 		{
 		return EFalse;
 		}
@@ -1165,6 +1166,7 @@
 			// check if uri exists
 			if ( !BaflUtils::FileExists( iFs, textValue ) )
 				{
+			    iLastObjectDef = NULL;
 				_LIT( KError, "uri is not real" );
 				LogError( KError );
 				User::Leave( KErrNotFound );
@@ -1720,7 +1722,7 @@
 			const CMdsObjectDef* objectDef = namespaceDefRestrict->GetObjectByIdL( objectDefId );
 			if (objectDef)
 				{
-				objectDefToExport.Append( objectDef );
+				objectDefToExport.AppendL( objectDef );
 				}
 			}
 		}
@@ -1741,7 +1743,7 @@
 			const CMdsEventDef* eventDef = namespaceDefRestrict->GetEventByIdL( eventDefId );
 			if (eventDef)
 				{
-				eventDefToExport.Append( eventDef );
+				eventDefToExport.AppendL( eventDef );
 				}
 			}
 		}
@@ -1762,7 +1764,7 @@
 			const CMdsRelationDef* relationDef = namespaceDefRestrict->GetRelationByIdL( relationDefId );
 			if ( relationDef )
 				{
-				relationDefToExport.Append( relationDef );
+				relationDefToExport.AppendL( relationDef );
 				}
 			}
 		}
@@ -1775,7 +1777,7 @@
 	RRowData freeTextRow;
 	CleanupClosePushL( freeTextRow );
 
-	TInt j;
+	TInt j( 0 );
 	
 	const TInt namespaceCount = aSchemaNew.iNamespaceDefs.Count();
 	
@@ -2408,11 +2410,12 @@
 //
 TInt CMdsImportExport::ImportInt64( Int64& aValue, TLex8& aParser )
     {
+    TInt error( KErrNone );
     // due to symbian int64 parser error
     // for now we will use ImportNum version
-    ImportNum( aValue, aParser );
+    error = ImportNum( aValue, aParser );
 
-    return KErrNone;
+    return error;
     }
 
 // ------------------------------------------------
--- a/metadataengine/server/src/mdsindexer.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsindexer.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -41,7 +41,7 @@
 
 void MMdSIndexer::GetLastItemIdL()
 	{
-	_LIT( KGetLastMaxId, "SELECT max(seq) FROM SQLITE_SEQUENCE WHERE name!='symbian_security';" );
+	_LIT( KGetLastMaxId, "SELECT max(seq) FROM SQLITE_SEQUENCE WHERE name!='symbian_security' LIMIT 1;" );
 	CMdSSqLiteConnection& connection = MMdSDbConnectionPool::GetDefaultDBL();
 
 	RRowData getData;
@@ -64,27 +64,8 @@
 
 TItemId MMdSIndexer::GetIndexL()
 	{
-	_LIT( KIndexerQuery, "SELECT last_insert_rowid();" );
-
 	CMdSSqLiteConnection& connection = MMdSDbConnectionPool::GetDefaultDBL();
-
-	RRowData getData;
-	CleanupClosePushL(getData);
-
-	RMdsStatement selectObject;
-	CleanupClosePushL(selectObject);
-
-	TItemId id = KNoId;
-	//Get one row and set first column to id
-	connection.ExecuteQueryL(KIndexerQuery,selectObject,getData);
-	getData.AppendL(TColumn(id));
-	if (connection.NextRowL(selectObject, getData))
-		{
-		getData.Column(0).Get(id);
-		}
-
-	CleanupStack::PopAndDestroy(2, &getData);
-	return id;
+	return connection.LastInsertedRowId();
 	}
 
 TItemId MMdSIndexer::ExecuteAndGetIndexL( const TDesC &aSqlClause,
--- a/metadataengine/server/src/mdslogger.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdslogger.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -56,6 +56,10 @@
 //
 CMdSLogger::~CMdSLogger()
     {
+    static CMdSLogger* singleton;
+    delete singleton;
+    singleton = NULL;
+    iValid = EFalse;
     iLog.CloseLog(); 
     iLog.Close();
     }
--- a/metadataengine/server/src/mdsmaintenanceengine.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsmaintenanceengine.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -237,7 +237,7 @@
     User::LeaveIfError( fs.Connect() );
     CleanupClosePushL( fs );
     TVolumeInfo volumeInfo;
-    fs.Volume( volumeInfo, EDriveC );
+    User::LeaveIfError( fs.Volume( volumeInfo, EDriveC ) );
     MMdsPreferences::InsertL( KCMediaIdKey, MMdsPreferences::EPreferenceValueSet,
     		(TUint32) volumeInfo.iUniqueID );
 
@@ -246,12 +246,12 @@
     if( massStorageError == KErrNone )
         {
         TVolumeInfo massStorageVolumeInfo;
-        fs.Volume( massStorageVolumeInfo, drive );
+        User::LeaveIfError( fs.Volume( massStorageVolumeInfo, drive ) );
         const TUint32 massStorageMediaId( massStorageVolumeInfo.iUniqueID );
         massStorageError = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive );
         if( massStorageError == KErrNone )
             {
-            fs.Volume( massStorageVolumeInfo, drive );
+            User::LeaveIfError( fs.Volume( massStorageVolumeInfo, drive ) );
             // Update mass storage media id if the mass storage is not memory card
             if( massStorageVolumeInfo.iUniqueID != massStorageMediaId && massStorageMediaId != 0 )
                 {
--- a/metadataengine/server/src/mdsmanipulationengine.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsmanipulationengine.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -34,14 +34,6 @@
 
 __USES_LOGGER
 
-// ======== LOCAL FUNCTIONS ========
-
-static void TransactionCleanupL(void* aConn)
-   {
-   CMdSSqLiteConnection* conn = (CMdSSqLiteConnection*)aConn;
-   conn->TransactionRollbackL();
-   }
-
 // ---------------------------------------------------------------------------
 // NewL
 // ---------------------------------------------------------------------------
@@ -156,63 +148,39 @@
         RMdsStatement objStmt;
         CleanupClosePushL(objStmt);
 		
-		if( KObjectCount > 1 )
-		    {
-	        RMdSTransaction transaction( connection );
-	        CleanupClosePushL(transaction);
-	        const TInt beginError( transaction.Error() );
-	        if( beginError != KErrNone )
-	            {
-	            CleanupStack::PopAndDestroy( &transaction );
-	            }
-	    
-		    for ( TInt i = 0; i < KObjectCount; ++i )
-			    {
-			    aBuffer.PositionL( items.iObjects.iPtr.iOffset + i * sizeof(TMdCObject) );
-			    TItemId id = KNoId;
-			    TRAPD( err, id = iManipulate->AddObjectL( connection, aBuffer, 
-			            baseObjStmt, objStmt, aServerSession ) );
-			    if (err == KErrNone)
-				    {
-				    aResultBuffer.InsertL( id );
-				    }
-			    else
-				    {
-				    aResultBuffer.InsertL( KNoId );
-				    if(resultIds.iErrorCode == KErrNone)
-					    {
-					    resultIds.iErrorCode = err;
-					    }
-				    }
-			    }
-		    if( beginError == KErrNone )
-		        {
-	            transaction.CommitL();
-	            CleanupStack::PopAndDestroy( &transaction );
-		        }
-		    }
-		else
-		    {
-            for ( TInt i = 0; i < KObjectCount; ++i )
+        RMdSTransaction transaction( connection );
+        CleanupClosePushL(transaction);
+        const TInt beginError( transaction.Error() );
+        if( beginError != KErrNone )
+            {
+            CleanupStack::PopAndDestroy( &transaction );
+            }
+    
+        for ( TInt i = 0; i < KObjectCount; ++i )
+            {
+            aBuffer.PositionL( items.iObjects.iPtr.iOffset + i * sizeof(TMdCObject) );
+            TItemId id = KNoId;
+            TRAPD( err, id = iManipulate->AddObjectL( connection, aBuffer, 
+                    baseObjStmt, objStmt, aServerSession ) );
+            if (err == KErrNone)
                 {
-                aBuffer.PositionL( items.iObjects.iPtr.iOffset + i * sizeof(TMdCObject) );
-                TItemId id = KNoId;
-                TRAPD( err, id = iManipulate->AddObjectL( connection, aBuffer, 
-                        baseObjStmt, objStmt, aServerSession ) );
-                if (err == KErrNone)
+                aResultBuffer.InsertL( id );
+                }
+            else
+                {
+                aResultBuffer.InsertL( KNoId );
+                if(resultIds.iErrorCode == KErrNone)
                     {
-                    aResultBuffer.InsertL( id );
-                    }
-                else
-                    {
-                    aResultBuffer.InsertL( KNoId );
-                    if(resultIds.iErrorCode == KErrNone)
-                        {
-                        resultIds.iErrorCode = err;
-                        }
+                    resultIds.iErrorCode = err;
                     }
                 }
-		    }
+            }
+        if( beginError == KErrNone )
+            {
+            transaction.CommitL();
+            CleanupStack::PopAndDestroy( &transaction );
+            }
+
         CleanupStack::PopAndDestroy(&objStmt);
         CleanupStack::PopAndDestroy(&baseObjStmt);
 		}
@@ -229,12 +197,13 @@
 		resultIds.iEventIds.iPtr.iOffset = aResultBuffer.Position();
 		resultIds.iEventIds.iPtr.iCount = KEventCount;
 	    
-	    if( KEventCount > 1 )
-	        {
-	        //More than 1 event, transaction will be used.
-	        connection.TransactionBeginL();
-	        CleanupStack::PushL(TCleanupItem(&TransactionCleanupL, &connection));
-	        }
+        RMdSTransaction transaction( connection );
+        CleanupClosePushL(transaction);
+        const TInt beginError( transaction.Error() );
+        if( beginError != KErrNone )
+            {
+            CleanupStack::PopAndDestroy( &transaction );
+            }
 
 		for ( TInt i = 0; i < KEventCount; ++i )
 			{
@@ -257,11 +226,11 @@
 				}
 			}
 
-		if( KEventCount > 1 )
-		    {
-		    connection.TransactionCommitL();
-		    CleanupStack::Pop();  //TransactionCleanup()
-	        }
+        if( beginError == KErrNone )
+            {
+            transaction.CommitL();
+            CleanupStack::PopAndDestroy( &transaction );
+            }
 		}
 	else
 		{
@@ -276,12 +245,13 @@
 		resultIds.iRelationIds.iPtr.iOffset = aResultBuffer.Position();
 		resultIds.iRelationIds.iPtr.iCount = KRelationCount;
 	    
-	    if( KRelationCount > 1 )
-	        {
-	        //More than 1 relation, transaction will be used.
-	        connection.TransactionBeginL();
-	        CleanupStack::PushL(TCleanupItem(&TransactionCleanupL, &connection));
-	        }
+        RMdSTransaction transaction( connection );
+        CleanupClosePushL(transaction);
+        const TInt beginError( transaction.Error() );
+        if( beginError != KErrNone )
+            {
+            CleanupStack::PopAndDestroy( &transaction );
+            }
 
 	    for ( TInt i = 0; i < KRelationCount; ++i )
 			{
@@ -304,11 +274,11 @@
 				}
 			}
 
-	    if( KRelationCount > 1 )
-	        {
-	        connection.TransactionCommitL();
-	        CleanupStack::Pop();   //TransactionCleanup()
-	        }
+        if( beginError == KErrNone )
+            {
+            transaction.CommitL();
+            CleanupStack::PopAndDestroy( &transaction );
+            }
 		}
 	else
 		{
@@ -596,6 +566,14 @@
 		resultIds.iObjectIds.iPtr.iOffset = aResultBuffer.Position();
 		resultIds.iObjectIds.iPtr.iCount = items.iObjects.iPtr.iCount;
 
+        RMdSTransaction transaction( connection );
+        CleanupClosePushL(transaction);
+        const TInt beginError( transaction.Error() );
+        if( beginError != KErrNone )
+            {
+            CleanupStack::PopAndDestroy( &transaction );
+            }
+		
 		for ( TInt i = 0; i < items.iObjects.iPtr.iCount; ++i )
 			{
 			aBuffer.PositionL( items.iObjects.iPtr.iOffset + i * sizeof(TMdCObject) );
@@ -615,6 +593,11 @@
 					}
 				}
 			}
+        if( beginError == KErrNone )
+            {
+            transaction.CommitL();
+            CleanupStack::PopAndDestroy( &transaction );
+            }
 		}
 	else
 		{
--- a/metadataengine/server/src/mdsnotifier.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsnotifier.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -76,6 +76,25 @@
 CMdSNotifier::~CMdSNotifier()
     {
     delete iComparator;
+    
+    const TInt count = iEntries.Count();
+    
+    for ( TInt i = 0; i < count; ++i )
+        {
+        TEntry& e = iEntries[i];
+            
+        if ( e.iSerializedCondition )
+            {
+            delete e.iSerializedCondition;
+            e.iSerializedCondition = NULL;
+            }
+        if ( e.iDataBuffer )
+            {
+            delete e.iDataBuffer;
+            e.iDataBuffer = NULL;
+            }
+        }
+    
     iEntries.Close();
     }
 
--- a/metadataengine/server/src/mdsobjectdef.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsobjectdef.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -243,7 +243,8 @@
 		rowData.AppendL( TColumn( aNamespaceDefId ) );
 		rowData.AppendL( TColumn( iParent ? iParent->GetId() : KNoDefId ) );
 		rowData.AppendL( TColumn( (TInt32)iFlags ) );
-		rowData.AppendL( TColumn( GetName().AllocL() ) );
+		rowData.AppendL( TColumn( GetName().AllocLC() ) );
+		CleanupStack::Pop(); // name
 
 		TDefId id = MMdSIndexer::ExecuteAndGetIndexL( KMdsSqlClauseAddObjectDef,rowData );
 
--- a/metadataengine/server/src/mdspropertydef.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdspropertydef.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -285,7 +285,8 @@
 #endif
     		User::Leave( KErrMdEUnknownPropertyType );
 		}
-	rowData.AppendL( TColumn( GetName().AllocL() ) );
+	rowData.AppendL( TColumn( GetName().AllocLC() ) );
+	CleanupStack::Pop(); //name
 
 	TDefId id;
 	id =  MMdSIndexer::ExecuteAndGetIndexL( KMdsSqlClauseAddPropertyDef, rowData );
--- a/metadataengine/server/src/mdsrelationdef.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsrelationdef.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -75,7 +75,8 @@
     CleanupClosePushL( rowData );
 
 	rowData.AppendL( TColumn( aNamespaceDefId ) );
-	rowData.AppendL( TColumn( GetName().AllocL() ) );
+	rowData.AppendL( TColumn( GetName().AllocLC() ) );
+	CleanupStack::Pop(); //name
 	TDefId id =  MMdSIndexer::ExecuteAndGetIndexL( KMdsSqlClauseAddRelationDef, rowData );
 	if ( id != KNoDefId )
 		{
--- a/metadataengine/server/src/mdsschema.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsschema.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -256,7 +256,7 @@
 			{
 			// add base objectdef[number]
 			clause->BufferL().Format( KBaseObjectDefinition, &MdeConstants::Object::KBaseObject, namespaceDefId );
-			TRAP_IGNORE( connection.ExecuteL( clause->ConstBufferL(), emptyRowData ) );			
+			connection.ExecuteL( clause->ConstBufferL(), emptyRowData );			
 
 			// add relations[number]
 			clause->BufferL().Format( KCreateRelationsTable, namespaceDefId );
@@ -320,7 +320,8 @@
 
 			// add updateremovedrelations[number]
             clauseTrigger->ReserveSpaceL( KMdsTriggerUpdateRemovedRelation().Size() + ( KMaxUintValueLength * 5 ) );  
-            clauseTrigger->BufferL().Format( KMdsTriggerUpdateRemovedRelation, namespaceDefId, namespaceDefId, EMdERelationFlagNotPresent | EMdERelationFlagDeleted, EMdERelationFlagNotPresent | EMdERelationFlagDeleted, namespaceDefId );
+            clauseTrigger->BufferL().Format( KMdsTriggerUpdateRemovedRelation, namespaceDefId, namespaceDefId, 
+                    EMdERelationFlagNotPresent | EMdERelationFlagDeleted, EMdERelationFlagNotPresent | EMdERelationFlagDeleted, namespaceDefId );
             connection.ExecuteL( clauseTrigger->ConstBufferL(), emptyRowData );
 
 			// add relationleftobjectidindex[number]
@@ -357,7 +358,7 @@
 				AddObjectToSqlClauseL( objectDef, clause, ETrue );
 
 				clause->AppendL( KMdsSqlClauseObjTableEnd );
-				TRAP_IGNORE( connection.ExecuteL( clause->ConstBufferL(), emptyRowData ) );
+				connection.ExecuteL( clause->ConstBufferL(), emptyRowData );
 
 				objectDef->SetTableStoredInDB();
 				}
@@ -393,6 +394,7 @@
     CleanupClosePushL( emptyRowData );
     clause->BufferL().Format( KMdsPropertyIndexCreate, &aTableName, &aPropertyName, aNamespaceId,
     		&aTableName, aNamespaceId, &aPropertyName );
+    // Ignore possible SQL error, MDS can still live without this index
 	TRAP_IGNORE( connection.ExecuteL( clause->ConstBufferL(), emptyRowData ) );
 	CleanupStack::PopAndDestroy( 2, clause ); // emptyRowData, clause
 	}
@@ -408,9 +410,6 @@
     CreateObjectTablesL();
 	StoreSchemaToDBL();
 	CreateCol2PropTableL();
-
-    transaction.CommitL();
-    CleanupStack::PopAndDestroy( &transaction );
     
     TUint propertyCount = iProperties.Count();
     for ( TUint i = 0; i < propertyCount; ++i )
@@ -419,6 +418,10 @@
     	CreatePropertyIndexL( propertyInfo.iPropertyName, propertyInfo.iTableName,
     			propertyInfo.iNamespaceId );
     	}
+    
+    transaction.CommitL();
+    CleanupStack::PopAndDestroy( &transaction );
+    
     iProperties.Reset();
 	}
 
@@ -564,7 +567,7 @@
 	for (TUint i = 0; i < KNumClauses; i++)
 		{
 		TRAP( error,connection.ExecuteL( (*descarray)[i], emptyRowData ) );
-		if ( error != KErrNone && error != KSqlErrGeneral )
+		if ( error != KErrNone )
 			{
 			User::Leave( error );
 			}
@@ -574,12 +577,26 @@
 
 	const TInt count = iNamespaceDefs.Count();
 	
+    RMdSTransaction transaction( connection );
+    CleanupClosePushL(transaction);
+    const TInt beginError( transaction.Error() );
+    if( beginError != KErrNone )
+        {
+        CleanupStack::PopAndDestroy( &transaction );
+        }
+	
 	// add only namespaceDef to DB
 	for( TInt i = 0; i < count; ++i )
 		{
 		iNamespaceDefs[i]->StoreToDBL( ETrue );
 		}
 
+    if( beginError == KErrNone )
+        {
+        transaction.CommitL();
+        CleanupStack::PopAndDestroy( &transaction );
+        }	
+
 	CleanupStack::PopAndDestroy( &emptyRowData );
 	}
 
@@ -588,6 +605,16 @@
 	_LIT( KMdsSqlClauseDeleteBoFromOd,  "DELETE FROM ObjectDef WHERE ObjectDefId=?;" );
 	_LIT( KMdsSqlClauseDeleteBoFromPd,  "DELETE FROM PropertyDef WHERE ObjectDefId=?;" );
 
+    CMdSSqLiteConnection& connection = MMdSDbConnectionPool::GetDefaultDBL();
+
+    RMdSTransaction transaction( connection );
+    CleanupClosePushL(transaction);
+    const TInt beginError( transaction.Error() );
+    if( beginError != KErrNone )
+        {
+        CleanupStack::PopAndDestroy( &transaction );
+        }
+    
 	iBaseObject->StoreToDBL( KNoDefId );
 	
 	const TInt count = iNamespaceDefs.Count();
@@ -598,11 +625,16 @@
 		iNamespaceDefs[i]->StoreToDBL();
 		}
 
+    if( beginError == KErrNone )
+        {
+        transaction.CommitL();
+        CleanupStack::PopAndDestroy( &transaction );
+        }   
+	
 	RRowData removeBo;
 	CleanupClosePushL( removeBo );
 	removeBo.AppendL( TColumn( KBaseObjectDefId ) );
 
-	CMdSSqLiteConnection& connection = MMdSDbConnectionPool::GetDefaultDBL();
 	TRAPD( err, connection.ExecuteL( KMdsSqlClauseDeleteBoFromOd,  removeBo ) );
 	TRAP ( err, connection.ExecuteL( KMdsSqlClauseDeleteBoFromPd,  removeBo ) );
 	
--- a/metadataengine/server/src/mdsserver.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsserver.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -853,11 +853,11 @@
     User::LeaveIfError( fs.Connect() );
     CleanupClosePushL( fs );
     
-    RFileReadStream tmpFile;
     TBuf<KMaxFileName> privatePath;
     TBuf<KMaxFileName> schema;
     TBuf<KMaxFileName> defaultImportProfile;
     TBuf<KMaxFileName> backupRegistration;
+    RFileReadStream tmpFile;
     
     fs.PrivatePath( privatePath );
     
@@ -887,7 +887,7 @@
         else if ( err == KErrPathNotFound)
             {
             // Create private dir
-            fs.CreatePrivatePath( EDriveC );
+            User::LeaveIfError( fs.CreatePrivatePath( EDriveC ) );
             
             // Copy schema.mde
             const TInt error = fileMan->Copy( KSchemaPath, schema, CFileMan::EOverWrite );
@@ -909,7 +909,7 @@
         else if ( err == KErrPathNotFound)
             {
             // Create private dir
-            fs.CreatePrivatePath( EDriveC );
+            User::LeaveIfError( fs.CreatePrivatePath( EDriveC ) );
              
             // Copy schema.mde
             const TInt error1 = fileMan->Copy( KDefaultImportProfilePath, defaultImportProfile, CFileMan::EOverWrite );
@@ -931,7 +931,7 @@
         else if ( err == KErrPathNotFound)
             {
             // Create private dir
-            fs.CreatePrivatePath( EDriveC );
+            User::LeaveIfError( fs.CreatePrivatePath( EDriveC ) );
             
             // Copy schema.mde
             const TInt error2 = fileMan->Copy( KBackupRegistrationPath, backupRegistration, CFileMan::EOverWrite );
--- a/metadataengine/server/src/mdsserversession.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdsserversession.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -741,7 +741,7 @@
 				User::Leave( KErrArgument );
 				}
 		    RBuf uri;
-		    uri.Create( uriLength );
+		    uri.CreateL( uriLength );
 		    CleanupClosePushL( uri );
 		    aMsg.ReadL( ECheckObjectArgTypeValue, uri );
 		    buffer = iServer.Manipulate().CheckObjectL( resultBufferLength, uri, namespaceDefId );
@@ -1235,7 +1235,7 @@
     	}
 
     RBuf fileName;
-    fileName.Create( fileNameLength );
+    fileName.CreateL( fileNameLength );
     CleanupClosePushL( fileName );
     aMsg.ReadL( 0, fileName );
 
@@ -1259,7 +1259,7 @@
     	}
     
     RBuf fileName;
-    fileName.Create( fileNameLength );
+    fileName.CreateL( fileNameLength );
     CleanupClosePushL( fileName );
     aMsg.ReadL( 0, fileName );
 
@@ -1287,7 +1287,7 @@
     	}
 
     RBuf fileName;
-    fileName.Create( fileNameLength );
+    fileName.CreateL( fileNameLength );
     CleanupClosePushL( fileName );
     aMsg.ReadL( 0, fileName );
 
@@ -1374,7 +1374,7 @@
 	const TInt32 KMediaInfoSize = sizeof( TMdEMediaInfo ) * KMaxDrives;
 
 	RBuf8 mediaInfoBuffer;
-	mediaInfoBuffer.Create( KMediaInfoSize );
+	mediaInfoBuffer.CreateL( KMediaInfoSize );
 	CleanupClosePushL( mediaInfoBuffer );
 
 	const TInt32 mediaCount = iServer.Manipulate().GetPresentMediasL( 
@@ -1495,12 +1495,12 @@
 		}
 
 	RBuf oldPath;
-	oldPath.Create( oldPathLength );
+	oldPath.CreateL( oldPathLength );
     CleanupClosePushL( oldPath );
     aMessage.ReadL( 0, oldPath );
 
     RBuf newPath;
-    newPath.Create( newPathLength );
+    newPath.CreateL( newPathLength );
     CleanupClosePushL( newPath );
     aMessage.ReadL( 1, newPath );
     
--- a/metadataengine/server/src/mdssqliteconnection.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdssqliteconnection.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -96,28 +96,46 @@
     	}
     /**
      * Open database:
-     *   First we try to create new db. If this fails check if db already exists and
-     *   try to open it. Otherwise we cannot open it and we leave
+     *   First we try to open db. If this fails because db not creater yer, then
+     *   try to create it. Otherwise we cannot open it and we leave
      */
-    err = iMdeSqlDb.Create( *iDbFileName, sqlSecurityPolicy, &KMdsSqlDbaConfig );
+    err = iMdeSqlDb.Open( *iDbFileName, &KMdsSqlDbaConfig );
     if ( err != KErrNone )
-    	{
-    	// it could fail because database exists
-    	if ( err == KErrAlreadyExists )
-    		{
-    		err = iMdeSqlDb.Open( *iDbFileName, &KMdsSqlDbaConfig );
-    		if ( err != KErrNone )
-    			{
-    			__LOG1( ELogDb, "Cannot open database %d", err );
-    			}
-    		}
-    	else 
-    		{
-    		__LOG1( ELogDb, "Unknown error while creating %d", err );
-    		}
-
-    	User::LeaveIfError( err );
-    	}
+        {
+        __LOG1( ELogDb, "Cannot open database %d", err );
+            
+        if( err == KErrNotFound )
+            {
+            __LOG1( ELogDb, "Cannot find database %d", err );
+            err = iMdeSqlDb.Create( *iDbFileName, sqlSecurityPolicy, &KMdsSqlDbaConfig );
+            if( err != KErrNone )
+                {
+                __LOG1( ELogDb, "Unknown error while creating %d", err );
+                User::LeaveIfError( err );
+                }
+            }
+        else if( err == KErrCorrupt ||
+                err == KSqlErrCorrupt )
+            {
+            __LOGLB( ELogDb, "Warning: Database is corrupted, will delete and re-create it." );
+            err = DeleteAndReCreateDB( iDbFileName, sqlSecurityPolicy, &KMdsSqlDbaConfig );
+        
+            if ( KErrNone == err  )
+                {
+                err = iMdeSqlDb.Open( *iDbFileName, &KMdsSqlDbaConfig );
+                if ( err != KErrNone )
+                    {
+                    __LOG1( ELogDb, "Cannot open database again after delete and re-create %d", err );
+                    User::LeaveIfError( err );
+                    }
+                } 
+            }
+        else 
+            {
+            __LOG1( ELogDb, "Unknown error while accessing database %d", err );
+            User::LeaveIfError( err );
+            }
+        }
     CleanupStack::PopAndDestroy( &sqlSecurityPolicy );
     }
 
@@ -335,6 +353,11 @@
     	}
     }
 
+TItemId CMdSSqLiteConnection::LastInsertedRowId()
+    {
+    return iMdeSqlDb.LastInsertedRowId();
+    }
+
 void CMdSSqLiteConnection::ColumnsL( const RSqlStatement& aStatement, RRowData& aRow )
     {
     const TInt count( aRow.Size() );
@@ -580,3 +603,20 @@
         }
     }
 
+
+TInt CMdSSqLiteConnection::DeleteAndReCreateDB( const HBufC* aDbFileName,
+                                                const RSqlSecurityPolicy& asqlSecurityPolicy,
+                                                const TDesC8* aKMdsSqlDbaConfig ) 
+    {    
+    TInt err = iMdeSqlDb.Delete( *aDbFileName );
+    if( err!= KErrNone )
+        {
+        __LOG1( ELogDb, "delete database err=%d.", err );
+        return err;
+        }
+
+    err = iMdeSqlDb.Create( *aDbFileName, asqlSecurityPolicy, aKMdsSqlDbaConfig );
+
+    return err;
+    }
+
--- a/metadataengine/server/src/mdssqlobjectmanipulate.cpp	Fri Feb 19 23:14:48 2010 +0200
+++ b/metadataengine/server/src/mdssqlobjectmanipulate.cpp	Fri Mar 12 15:44:28 2010 +0200
@@ -191,21 +191,18 @@
 
 void CMdSSqlObjectManipulate::ConstructL( )
     {
-    
 	iGenerator = CMdSIdentifierGenerator::NewL();
 
 	iNamespaceDef = NULL;
 	
-	TLockBuffer lockBuffer;
-	lockBuffer.iLock = EFalse;
 	for (TInt i = 0; i < KMaxBuffers; ++i)
 		{
-	    CMdsClauseBuffer* buffer = CMdsClauseBuffer::NewLC( 1024 );
-		lockBuffer.iBuffer = buffer;
+	    TLockBuffer lockBuffer;
+	    lockBuffer.iLock = EFalse;
+	    lockBuffer.iBuffer = CMdsClauseBuffer::NewLC( 1024 );
 		iBuffers.AppendL( lockBuffer );
 		CleanupStack::Pop(); // buffer
 		}
-
     }
 
 TBool CMdSSqlObjectManipulate::GarbageCollectionL()
@@ -2057,7 +2054,11 @@
 		if (!dataRow.Column(1).IsNull())
 			{
 			dataRow.Column(1).Get( relationId );
-			aRelationIds.InsertInOrder( relationId, TLinearOrder<TItemId>( CompareTItemIds ) );
+			const TInt error( aRelationIds.InsertInOrder( relationId, TLinearOrder<TItemId>( CompareTItemIds ) ) );
+			if( error == KErrNoMemory )
+			    {
+			    User::Leave( error );
+			    }
 			}
 		else
 			{
@@ -3266,11 +3267,18 @@
 		{
 		if (!iBuffers[i].iLock)
 			{
-			iBuffers[i].iLock = ETrue;
-			iBuffer = iBuffers[i].iBuffer;
+		    iBuffers[i].iLock = ETrue;
+            CMdsClauseBuffer* oldBuffer( iBuffer );
+            iBuffer = iBuffers[i].iBuffer;
+            TRAPD( error, iBuffer->ReserveSpaceL(aSize) );
+            if( error != KErrNone )
+                {
+                iBuffer = oldBuffer;
+                iBuffers[i].iLock = EFalse;
+                continue;
+                }		
+            TRAP_IGNORE( iBuffer->BufferL().Zero() );			
 			iNr = i;
-			TRAP_IGNORE( iBuffer->ReserveSpaceL(aSize) );
-			TRAP_IGNORE( iBuffer->BufferL().Zero() );
 			return;
 			}
 		}
Binary file sis/mds/mds_stub.sis has changed
--- a/sis/mds/package.pkg	Fri Feb 19 23:14:48 2010 +0200
+++ b/sis/mds/package.pkg	Fri Mar 12 15:44:28 2010 +0200
@@ -17,7 +17,7 @@
 &EN
 
 ;packet-header (name, uid, major, minor, build, type)
-#{"Metadata System Upgrade"},(0x200009F5), 9, 20, 4, TYPE=SA, RU
+#{"Metadata System Upgrade"},(0x200009F5), 9, 20, 6, TYPE=SA, RU
 
 ; Localised vendor name
 %{"Nokia"}
--- a/sis/mds/package_separate.pkg	Fri Feb 19 23:14:48 2010 +0200
+++ b/sis/mds/package_separate.pkg	Fri Mar 12 15:44:28 2010 +0200
@@ -17,7 +17,7 @@
 &EN
 
 ;packet-header (name, uid, major, minor, build, type)
-#{"Metadata System Upgrade"},(0x200009F5), 9, 20, 4, TYPE=SA, RU
+#{"Metadata System Upgrade"},(0x200009F5), 9, 20, 6, TYPE=SA, RU
 
 ; Localised vendor name
 %{"Nokia"}
--- a/sis/mds/stub.pkg	Fri Feb 19 23:14:48 2010 +0200
+++ b/sis/mds/stub.pkg	Fri Mar 12 15:44:28 2010 +0200
@@ -17,7 +17,7 @@
 &EN
 
 ; Header
-#{"Metadata System"}, (0x200009F5), 9, 20, 4, TYPE=SA
+#{"Metadata System"}, (0x200009F5), 9, 20, 6, TYPE=SA
 
 ; Localised Vendor name
 %{"Nokia"}
--- a/watchdog/group/bld.inf	Fri Feb 19 23:14:48 2010 +0200
+++ b/watchdog/group/bld.inf	Fri Mar 12 15:44:28 2010 +0200
@@ -24,4 +24,5 @@
 ../sis/mdswatchdog_stub.sis  /epoc32/data/z/system/install/mdswatchdog_stub.sis
 
 PRJ_MMPFILES
-watchdog.mmp
\ No newline at end of file
+watchdog.mmp
+