Revision: 201001
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 26 Jan 2010 12:13:20 +0200
changeset 1 acef663c1218
parent 0 c53acadfccc6
child 2 b73a2e62868f
Revision: 201001 Kit: 201004
clfwrapper/ClientSrc/CCLFItemImpl.cpp
clfwrapper/ClientSrc/CCLFItemListModelImpl.cpp
clfwrapper/ClientSrc/CCLFServerProxy.cpp
clfwrapper/group/contentlistingframework.mmp
clfwrapper/mediacollectionmanagersrc/mediacollectionmanagerimpl.cpp
contextengine/plugins/locationplugin/src/locationcontextplugin.cpp
harvester/blacklistclient/src/blacklistclient.cpp
harvester/blacklistserver/src/blacklistserver.cpp
harvester/client/inc/harvesterrequestactive.h
harvester/client/inc/harvesterrequestqueue.h
harvester/client/src/harvesterclient.cpp
harvester/client/src/harvesterrequestactive.cpp
harvester/client/src/harvesterrequestqueue.cpp
harvester/common/inc/harvestercommon.h
harvester/common/inc/listener.h
harvester/common/src/harvesterplugin.cpp
harvester/composerplugins/imagecomposer/inc/imagepresentobserver.h
harvester/composerplugins/imagecomposer/inc/locationrelationobserver.h
harvester/composerplugins/imagecomposer/src/imagecomposerao.cpp
harvester/composerplugins/imagecomposer/src/locationrelationobserver.cpp
harvester/data/default_origin_mappings.db
harvester/harvesterplugins/AudioPlugin/src/harvesteraudioplugin.cpp
harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp
harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp
harvester/monitorplugins/fileplugin/src/FolderRenamer.cpp
harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp
harvester/monitorplugins/messageplugin/src/messagemonitorplugin.cpp
harvester/monitorplugins/mmcplugin/inc/mmcfilelist.h
harvester/monitorplugins/mmcplugin/inc/mmcscannerao.h
harvester/monitorplugins/mmcplugin/src/mmcfilelist.cpp
harvester/monitorplugins/mmcplugin/src/mmcmonitorao.cpp
harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp
harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp
harvester/monitorplugins/mmcplugin/src/mmcscannerao.cpp
harvester/server/inc/harvesterao.h
harvester/server/src/harvesterao.cpp
harvester/server/src/harvesteroomao.cpp
harvester/server/src/harvesterqueue.cpp
harvester/server/src/restorewatcher.cpp
inc/mdcitem.h
inc/mdssqliteconnection.h
locationmanager/inc/locationmanagerdebug.h
locationmanager/locationtrail/group/locationtrail.mmp
locationmanager/locationtrail/inc/locationremappingao.h
locationmanager/locationtrail/src/cgpxconverterao.cpp
locationmanager/locationtrail/src/clocationrecord.cpp
locationmanager/locationtrail/src/ctracklog.cpp
locationmanager/server/inc/clocationmanagerserver.h
locationmanager/server/src/clocationmanagerserver.cpp
locationmanager/server/src/clocationmanagersession.cpp
mds_plat/harvester_framework_api/inc/harvesterplugin.h
mds_plat/metadata_engine_api/inc/mdeobjectdef.h
mds_plat/metadata_engine_api/tsrc/src/MdETestScripter.cpp
mds_pub/content_listing_framework_api/tsrc/src/T_CLFApiModuleTests.cpp
metadataengine/client/src/mdeasynchronousfindao.cpp
metadataengine/client/src/mdeobjectdef.cpp
metadataengine/client/src/mdesessionimpl.cpp
metadataengine/common/src/mdcitem.cpp
metadataengine/server/group/mdsserver.mmp
metadataengine/server/inc/mdslogger.h
metadataengine/server/inc/mdsserver.h
metadataengine/server/src/mdsfindsequence.cpp
metadataengine/server/src/mdsimportexport.cpp
metadataengine/server/src/mdslogger.cpp
metadataengine/server/src/mdsnotifier.cpp
metadataengine/server/src/mdsserver.cpp
metadataengine/server/src/mdsserversession.cpp
sis/mds/mds_stub.sis
sis/mds/package.pkg
sis/mds/package_separate.pkg
sis/mds/stub.pkg
--- a/clfwrapper/ClientSrc/CCLFItemImpl.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/clfwrapper/ClientSrc/CCLFItemImpl.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -258,7 +258,7 @@
         {
         // Get the actual data
         CMdEProperty* prop = NULL;
-        TInt index = iMdEObject.Property( *propertyDef, prop );
+        const TInt index = iMdEObject.Property( *propertyDef, prop );
         if ( prop )
             {
             const TInt num = sizeof ( clfwrappermusictypes ) / sizeof( TDesC* );
--- a/clfwrapper/ClientSrc/CCLFItemListModelImpl.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/clfwrapper/ClientSrc/CCLFItemListModelImpl.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -482,7 +482,7 @@
         error = iItemProvider->GetItems( iItemArray );
         if ( error == KErrNone )
             {
-            TRAP( error, RefreshL( ECLFRefreshAll ) );
+            RefreshL( ECLFRefreshAll );
             }
         }
     iOperationObserver.HandleOperationEventL( ECLFRefreshComplete, error );
--- a/clfwrapper/ClientSrc/CCLFServerProxy.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/clfwrapper/ClientSrc/CCLFServerProxy.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -17,7 +17,7 @@
 
 
 // INCLUDE FILES
-#include <PathInfo.h>
+#include <pathinfo.h>
 #include <driveinfo.h>
 #include <s32mem.h>
 #include <bautils.h>
@@ -186,7 +186,7 @@
     {
     iWasNotificationHandled = EFalse;
 
-    TInt index = iIdsPendingUpdate.Find( aId );
+    const TInt index = iIdsPendingUpdate.Find( aId );
     if ( index != KErrNotFound )
         {
         iWasNotificationHandled = ETrue;
@@ -286,7 +286,7 @@
 
     if ( aType == ENotifyRemove )
         {
-        TInt index = iIdsPendingRemoval.Find( aId );
+        const TInt index = iIdsPendingRemoval.Find( aId );
         if ( index != KErrNotFound )
             {
             iWasNotificationHandled = ETrue;
@@ -708,13 +708,14 @@
 //
 void CUpdateFoldersHandler::HarvestingComplete( TDesC& aURI, const TInt aError )
     {
-    const TFileName uri( aURI );
     TBool match( EFalse );
     TCollationMethod m = *Mem::CollationMethodByIndex( 0 );
 
     iHarvestError = aError;
     m.iFlags = ( TCollationMethod::EIgnoreNone | TCollationMethod::EFoldCase );   
 
+    const TFileName uri( aURI );
+    
     if ( uri.CompareC( iHarvestingFile, 3, &m ) == 0 )
         {
         match = ETrue;
@@ -1021,6 +1022,7 @@
         if ( aHandler->AllDone() )
             {
             delete aHandler;
+            aHandler = NULL;
             iUpdateItemsHandlerArray.Remove( iUpdateItemsHandlerArray.Count() - 1 );
             }
         else
@@ -1059,6 +1061,7 @@
                 iUpdateItemsHandlerArray[ j ]->AsyncStopScheduler();
                 iUpdateItemsHandlerArray[j]->SetRemoveObserverFlag( EFalse );
                 delete iUpdateItemsHandlerArray[ j ]; 
+                iUpdateItemsHandlerArray[ j ] = NULL;
                 iUpdateItemsHandlerArray.Remove( j );
                 j--; // Compensate for the removed handler
                 }
@@ -1108,6 +1111,7 @@
                 iUpdateItemsHandlerArray[ j ]->AsyncStopScheduler();
                 iUpdateItemsHandlerArray[j]->SetRemoveObserverFlag( EFalse );
                 delete iUpdateItemsHandlerArray[ j ]; 
+                iUpdateItemsHandlerArray[ j ] = NULL;
                 iUpdateItemsHandlerArray.Remove( j );
                 j--; // Compensate for the removed handler
                 }
--- a/clfwrapper/group/contentlistingframework.mmp	Mon Jan 18 20:34:07 2010 +0200
+++ b/clfwrapper/group/contentlistingframework.mmp	Tue Jan 26 12:13:20 2010 +0200
@@ -18,7 +18,7 @@
 
 #include <platform_paths.hrh>
 #include <data_caging_paths.hrh>
-#include <../CommonInc/CLFUID.hrh>
+#include <../commoninc/clfuid.hrh>
 
 VERSION         10.0
 TARGET          ContentListingFramework.dll
--- a/clfwrapper/mediacollectionmanagersrc/mediacollectionmanagerimpl.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/clfwrapper/mediacollectionmanagersrc/mediacollectionmanagerimpl.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -220,7 +220,7 @@
     {
     User::Leave( KErrNotSupported );
     
-    TInt drive( 0 );
+    const TInt drive( 0 );
     return drive;
     }
 
--- a/contextengine/plugins/locationplugin/src/locationcontextplugin.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/contextengine/plugins/locationplugin/src/locationcontextplugin.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -19,7 +19,7 @@
 #include <e32std.h>
 #include <uri16.h>
 #include <e32math.h>
-#include <LbsPosition.h> 
+#include <lbsposition.h> 
 #include <etel3rdparty.h>
 
 #include "locationcontextplugin.h"
--- a/harvester/blacklistclient/src/blacklistclient.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/blacklistclient/src/blacklistclient.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -151,7 +151,7 @@
     ipcArgs.Set( 1, &aUri );
     ipcArgs.Set( 2, &mediaIdPckg );
  
-    TInt err = SendReceive( EBlacklistRemoveFromDB, ipcArgs );
+    const TInt err = SendReceive( EBlacklistRemoveFromDB, ipcArgs );
     User::LeaveIfError( err );
 
     WRITELOG( "CBlacklistServer::RemoveFromDBL - end" );
@@ -168,7 +168,7 @@
     TPckgBuf<TInt> handleBuf;
     TIpcArgs ipcArgs;
     ipcArgs.Set( 1, &handleBuf );
-    TInt err = SendReceive( EGetBlacklistData, ipcArgs );
+    const TInt err = SendReceive( EGetBlacklistData, ipcArgs );
     User::LeaveIfError( err );
     aHandle = handleBuf();
 
@@ -270,7 +270,7 @@
     {
     WRITELOG( "CBlacklistServer::RemoveFromMemoryTableL - begin" );
 
-    TInt index = GetListIndex( aUri, aMediaId );
+    const TInt index = GetListIndex( aUri, aMediaId );
     if ( index >= 0 )
         {
         CBlacklistItem* item = iBlacklistMemoryTable[index];
@@ -290,7 +290,7 @@
     {
     WRITELOG( "CBlacklistServer::IsBlacklistedL - begin" );
 
-    TInt index = GetListIndex( aUri, aMediaId );
+    const TInt index = GetListIndex( aUri, aMediaId );
     if ( index >= 0 )
         {
         TInt64 modified( 0 );
--- a/harvester/blacklistserver/src/blacklistserver.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/blacklistserver/src/blacklistserver.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -23,7 +23,7 @@
 #include "mdssqliteconnection.h"
 #include "mdcserializationbuffer.h"
 
-#include <PathInfo.h>
+#include <pathinfo.h>
 
 // Security policy
 const TUint KServerPolicyRangeCount = 6;
@@ -154,7 +154,7 @@
     {
     WRITELOG( "CBlacklistServer::ConstructL - begin" );
 
-    TInt error = Start( KBlacklistServerName );
+    const TInt error = Start( KBlacklistServerName );
 
     if ( error != KErrNone )
         {
@@ -474,7 +474,7 @@
 
     WRITELOG( "CBlacklistServer::RemoveFromMemoryTable - begin" );
 
-    TInt index = GetMemoryTableIndex( aUri, aMediaId );
+    const TInt index = GetMemoryTableIndex( aUri, aMediaId );
     if ( index >= 0 )
         {
         CBlacklistItem * item = iBlacklistMemoryTable[index];
--- a/harvester/client/inc/harvesterrequestactive.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/client/inc/harvesterrequestactive.h	Tue Jan 26 12:13:20 2010 +0200
@@ -137,7 +137,7 @@
     /**
      * Session. Ref.
      */
-    RHarvesterClient& iClient;
+    RHarvesterClient iClient;
 
     /**
      * Observer to receive notifications about completed operations. Not owned.
@@ -157,7 +157,7 @@
     TBool iAddLocation;
     
     // not own
-    CHarvesterRequestQueue* iRequestQueue;
+    mutable CHarvesterRequestQueue* iRequestQueue;
     
     TPckg<TBool> iLocation;
     
@@ -172,6 +172,8 @@
      * If set, this request object can be deleted.
      */
     TBool iRequestCompleted;
+    
+    TBool iCancelled;
 };
 
 #endif // HARVESTERREQUESTACTIVE_H
@@ -180,7 +182,7 @@
 
 // INLINE FUNCTIONS
 
-inline TBool CHarvesterRequestActive::RequestCompleted()const
+inline TBool CHarvesterRequestActive::RequestCompleted() const
     {
     return iRequestCompleted;
     }
--- a/harvester/client/inc/harvesterrequestqueue.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/client/inc/harvesterrequestqueue.h	Tue Jan 26 12:13:20 2010 +0200
@@ -76,6 +76,13 @@
      */
     void ForceRequests();
 
+    /**
+     * ETrue if there are any unfinished harvesting requests
+     *
+     * @since S60 v5.0
+     */
+    TBool RequestsPending();
+
 protected:
     // from base class CActive
 
--- a/harvester/client/src/harvesterclient.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/client/src/harvesterclient.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -169,7 +169,11 @@
     
     WRITELOG( "RHarvesterClient::Close() - UnregisterHarvest done" );
     
-    iRequestQueue->ForceRequests();
+    if( iRequestQueue && iRequestQueue->RequestsPending() )
+        {
+        iRequestQueue->Cancel();
+        iRequestQueue->ForceRequests();
+        }
     
     delete iRequestQueue;
     iRequestQueue = NULL;
--- a/harvester/client/src/harvesterrequestactive.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/client/src/harvesterrequestactive.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -68,7 +68,7 @@
     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 )
+    iRequestQueue( aQueue ), iLocation( EFalse ), iCancelled( EFalse )
     {
     CActiveScheduler::Add( this );
     }
@@ -115,7 +115,7 @@
 //
 void CHarvesterRequestActive::DoCancel()
     {
-    // Nothing to do here
+    iCancelled = ETrue;
     }
 
 // ---------------------------------------------------------------------------
@@ -130,8 +130,11 @@
     TIpcArgs ipcArgs( &iUri, iAlbumIds, &iLocation );
     iPersistentArgs = ipcArgs;
     
-    iClient.HarvestFile( iService, iPersistentArgs, iStatus );
-    SetActive();
+    if( !iCancelled )
+        {
+        iClient.HarvestFile( iService, iPersistentArgs, iStatus );
+        SetActive();
+        }
     }
 
 // ---------------------------------------------------------------------------
--- a/harvester/client/src/harvesterrequestqueue.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/client/src/harvesterrequestqueue.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -45,7 +45,7 @@
 // C++ default constructor can NOT contain any code, that might leave.
 // ---------------------------------------------------------------------------
 //
-CHarvesterRequestQueue::CHarvesterRequestQueue(): CActive( CActive::EPriorityStandard )
+CHarvesterRequestQueue::CHarvesterRequestQueue(): CActive( CActive::EPriorityUserInput )
     {
     CActiveScheduler::Add( this );
     }
@@ -119,61 +119,81 @@
     WRITELOG2( "CHarvesterRequestQueue::RunL() begin - requests: %d, active requests: %d",
                iRequests.Count(), iActiveRequests );
     
-    CHarvesterRequestActive* selectedRequest = NULL;
-    
-    for ( TInt i = 0; i < iRequests.Count(); i++ )
+    const TInt status = iStatus.Int();
+
+    if ( status >= KErrNone && !iShutdown )
         {
-        CHarvesterRequestActive* request = iRequests[i];
-        
-        // remove completed tasks    
-        if ( request->RequestCompleted() && !request->IsActive() )
+        CHarvesterRequestActive* selectedRequest = NULL;
+    
+        for ( TInt i = 0; i < iRequests.Count(); i++ )
             {
-            // delete completed task
-            delete request;
-            iRequests.Remove( i );
+            CHarvesterRequestActive* request = iRequests[i];
+        
+            // remove completed tasks    
+            if ( !request || (request->RequestCompleted() && !request->IsActive()) )
+                {
+                // delete completed task
+                delete request;
+                request = NULL;
+                iRequests.Remove( i );
+            
+                // correct the index so that no tasks are skipped
+                i--;
+                if(i <= -1)
+                    {
+                    i = -1;
+                    }
             
-            // correct the index so that no tasks are skipped
-            i--;
-            if(i <= -1)
+                WRITELOG( "CHarvesterRequestQueue::RunL() - removing completed request");
+                }
+            // select priorised task
+            else
                 {
-                i = -1;
+                // not yet activated
+                if( !request->IsActive() )
+                     {
+                    selectedRequest = request;
+                    break;
+                    }
                 }
-            
-            WRITELOG( "CHarvesterRequestQueue::RunL() - removing completed request");
+            }
+
+        // activate selected
+        if ( selectedRequest && !iShutdown )
+            {
+            iActiveRequests++;
+            selectedRequest->Start();
             }
-        // select priorised task
+ 
+#ifdef _DEBUG        
+        WRITELOG2( "CHarvesterRequestQueue::RunL() end - requests: %d, active requests: %d",
+                iRequests.Count(), iActiveRequests );
+#endif
+    
+        // continue processing if needed
+        if ( !iShutdown && (iActiveRequests < KMaxClientRequests)  && 
+                (iRequests.Count() > iActiveRequests))
+            {  
+            SetActive();
+            TRequestStatus* statusPtr = &iStatus;
+            User::RequestComplete( statusPtr, KErrNone );
+            }
         else
             {
-            // not yet activated
-            if( !request->IsActive() )
-                {
-                selectedRequest = request;
-                }
+            iRequests.Compress();
             }
         }
-
-    // activate selected
-    if ( selectedRequest )
+    else if( status != KErrCancel )
         {
-        iActiveRequests++;
-        selectedRequest->Start();
+        // continue processing if needed
+        if ( !iShutdown && (iActiveRequests < KMaxClientRequests)  && 
+                (iRequests.Count() > iActiveRequests))
+            {  
+            SetActive();
+            TRequestStatus* statusPtr = &iStatus;
+            User::RequestComplete( statusPtr, KErrNone );
+            }
         }
-    
-    WRITELOG2( "CHarvesterRequestQueue::RunL() end - requests: %d, active requests: %d",
-            iRequests.Count(), iActiveRequests );
-    
-    // continue processing if needed
-    if ( !iShutdown && (iActiveRequests < KMaxClientRequests)  && 
-            (iRequests.Count() > iActiveRequests))
-        {  
-        SetActive();
-        TRequestStatus* statusPtr = &iStatus;
-        User::RequestComplete( statusPtr, KErrNone );
-        }
-    else
-    	{
-    	iRequests.Compress();
-    	}
     }
 
 // ---------------------------------------------------------------------------
@@ -203,13 +223,18 @@
 void CHarvesterRequestQueue::DoCancel()
     {
     WRITELOG( "CHarvesterRequestQueue::DoCancel()");
+
+    iShutdown = ETrue;
     
-    for( TInt i(0); i < iRequests.Count(); i++ )
+    const TInt count( iRequests.Count() );
+    for( TInt i = 0; i < count; i++ )
         {
-        iRequests[i]->Cancel();
+        CHarvesterRequestActive* request = iRequests[i];
+        if( request )
+            {
+            request->Cancel();
+            }
         }
-    
-    iShutdown = ETrue;
     }
 
 
@@ -247,30 +272,40 @@
     {
     WRITELOG( "CHarvesterRequestQueue::ForceRequests()");
     
-    Cancel();
-    
     for ( TInt i = 0; i < iRequests.Count(); i++ )
         {
         CHarvesterRequestActive* request = iRequests[i];
-        // remove completed tasks    
-        if ( request->RequestCompleted() )
+          
+        if ( request && !request->RequestCompleted() )
             {
-            // delete completed task
-            delete request;
-            iRequests.Remove( i );
+			request->ForceHarvest();
+			}
+        // delete completed task
+        delete request;
+        request = NULL;
+        iRequests.Remove( i );
         
-            // correct the index so that no tasks are skipped
-            i--;
-            if(i <= -1)
-                {
-                i = -1;
-                }
-            }
-        else
+        // correct the index so that no tasks are skipped
+        i--;
+        if(i <= -1)
             {
-            iRequests[i]->ForceHarvest();
+            i = -1;
             }
         }
     }
 
+// ---------------------------------------------------------------------------
+// CHarvesterRequestQueue::DoCancel()
+// ---------------------------------------------------------------------------
+//
+TBool CHarvesterRequestQueue::RequestsPending()
+    {
+    if( iRequests.Count() > 0 )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
 // End of file
+
--- a/harvester/common/inc/harvestercommon.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/common/inc/harvestercommon.h	Tue Jan 26 12:13:20 2010 +0200
@@ -90,6 +90,7 @@
 	TMdsOomMemoryGood
 	};
 
+const TInt KHarvesterGetRootDirFlags = EDirsFirst;
 const TInt KHarvesterGetDirFlags = ESortByDate | EDescending | EDirsFirst;
 
 const TInt KOriginIgnored = 255;
--- a/harvester/common/inc/listener.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/common/inc/listener.h	Tue Jan 26 12:13:20 2010 +0200
@@ -120,7 +120,7 @@
      * @param aPropertyCategory The property's category.   
      * @param aKey       		The P&S key to be watched. 
 	 */
-   	CListener::CListener( const TUid aPropertyCategory,
+   	CListener( const TUid aPropertyCategory,
     			const TUint aKey ); 
     	
    	/**
--- a/harvester/common/src/harvesterplugin.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/common/src/harvesterplugin.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -24,8 +24,11 @@
 #include "harvesterlog.h"
 #include "harvestercommon.h"
 #include "harvesterblacklist.h"
+#include "harvestereventmanager.h"
 #include "mdsutils.h"
 
+const TInt KCacheItemCountForEventCaching = 1;
+
 // ---------------------------------------------------------------------------
 // NewL
 // ---------------------------------------------------------------------------
@@ -49,6 +52,7 @@
 	{
 	User::LeaveIfError( iFs.Connect() );
 	iState = EHarvesterIdle;
+	iHarvesterEventManager = CHarvesterEventManager::GetInstanceL();
 	CActiveScheduler::Add( this );
 	}
 
@@ -86,6 +90,11 @@
 EXPORT_C CHarvesterPlugin::~CHarvesterPlugin() // destruct - virtual
 	{
 	Cancel();
+
+    if (iHarvesterEventManager)
+        {
+        iHarvesterEventManager->ReleaseInstance();
+        }
 	
 	iFs.Close();
 	REComSession::DestroyedImplementation( iDtor_ID_Key );
@@ -139,10 +148,22 @@
             if( iQueue->Count() == 0 )
                 {
                 SetNextRequest( EHarvesterIdle );
+                iHarvesting = EFalse;                       
+                iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateFinished );
+                iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
                 iQueue->Compress();
                 }
             else
             	{
+                if ( !iHarvesting )
+                    {
+                    iHarvesting = ETrue;
+                    iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateStarted );
+                    // This next line is for caching the harvester started event for observers registering
+                    // after harvesting has already started
+                    iHarvesterEventManager->IncreaseItemCount( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
+                    }
+            
             	CHarvesterData* hd = (*iQueue)[0];
             	iQueue->Remove( 0 );
             	const TDesC& uri = hd->Uri();
--- a/harvester/composerplugins/imagecomposer/inc/imagepresentobserver.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/composerplugins/imagecomposer/inc/imagepresentobserver.h	Tue Jan 26 12:13:20 2010 +0200
@@ -98,7 +98,7 @@
 	CImagePresentObserver();
 
 	/**
-	 * EPOC default constructor for performing 2nd stage construction
+	 * default constructor for performing 2nd stage construction
 	 */
 	void ConstructL( CMdESession* aSession, CComposerImagePlugin* aComposer, CMdEHarvesterSession* aMdEHarvesterSession );
 	
--- a/harvester/composerplugins/imagecomposer/inc/locationrelationobserver.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/composerplugins/imagecomposer/inc/locationrelationobserver.h	Tue Jan 26 12:13:20 2010 +0200
@@ -93,7 +93,7 @@
 	CLocationRelationObserver();
 
 	/**
-	 * EPOC default constructor for performing 2nd stage construction
+	 * default constructor for performing 2nd stage construction
 	 */
 	void ConstructL( CMdESession* aSession, CComposerImagePlugin* aComposer );
 	
--- a/harvester/composerplugins/imagecomposer/src/imagecomposerao.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/composerplugins/imagecomposer/src/imagecomposerao.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -134,7 +134,7 @@
     const TInt itemsCount = aItems.Count();
     for ( TInt i = 0; i < itemsCount; ++i )
         {
-        TInt res = iNextItemsSkip.FindInOrder( aItems[i],
+        const TInt res = iNextItemsSkip.FindInOrder( aItems[i],
         		TLinearOrder<TItemId>( CImageComposerAO::CompareTItemIds ) );
         if ( res != KErrNotFound && res >= 0 )
             {
@@ -472,7 +472,6 @@
         
         if ( !iMdeObject->OpenForModifications() )
             {
-            // we have get version
             const TItemId objectId = iMdeObject->Id();
             delete iMdeObject;
             iMdeObject = NULL;
@@ -517,18 +516,17 @@
 
         CMdEPropertyDef& lastModDatePropDef = iImageObjectDef->GetPropertyDefL(
         		Object::KLastModifiedDateProperty );
-            {
-            CMdEProperty* lastModDateProp = NULL;
-            iMdeObject->Property( lastModDatePropDef, lastModDateProp, 0 );
+        
+        CMdEProperty* lastModDateProp = NULL;
+        iMdeObject->Property( lastModDatePropDef, lastModDateProp, 0 );
 
-            if ( lastModDateProp )
-                {
-                lastModDateProp->SetTimeValueL( fileEntry.iModified );
-                }
-            else
-                {
-                iMdeObject->AddTimePropertyL( lastModDatePropDef, fileEntry.iModified );
-                }
+        if ( lastModDateProp )
+            {
+            lastModDateProp->SetTimeValueL( fileEntry.iModified );
+            }
+        else
+            {
+            iMdeObject->AddTimePropertyL( lastModDatePropDef, fileEntry.iModified );
             }
         iSession->CommitObjectL( *iMdeObject );
         iNextItemsSkip.InsertInOrder( iMdeObject->Id(),
--- a/harvester/composerplugins/imagecomposer/src/locationrelationobserver.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/composerplugins/imagecomposer/src/locationrelationobserver.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -48,9 +48,9 @@
 	{
 	WRITELOG( "CLocationRelationObserver::NewL start" );
 	CLocationRelationObserver* self = new (ELeave)CLocationRelationObserver();
-	CleanupStack::PushL(self);
+	CleanupStack::PushL( self );
 	self->ConstructL( aSession, aComposer );
-	CleanupStack::Pop(); // self;
+	CleanupStack::Pop( self ); 
 	WRITELOG( "CLocationRelationObserver::NewL end" );
 	return self;
 	}
--- a/harvester/data/default_origin_mappings.db	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/data/default_origin_mappings.db	Tue Jan 26 12:13:20 2010 +0200
@@ -29,6 +29,8 @@
 10281FA6	4
 101FFA91  254
 10208A29  254
+20026F35  254
+20026F2F  254
 200009F5	255
 2000A7AE	255
 200071BE	255
--- a/harvester/harvesterplugins/AudioPlugin/src/harvesteraudioplugin.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/harvesterplugins/AudioPlugin/src/harvesteraudioplugin.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -25,6 +25,7 @@
 
 #include "harvesteraudioplugin.h"
 #include "harvesteraudiopluginutils.h"
+#include "mdsutils.h"
 
 #include "harvesterlog.h"
 
@@ -144,13 +145,15 @@
 	{
 	WRITELOG( "CHarvesterAudioPlugin::HarvestL()" );
 	
-	TInt err = KErrNone;
-	
-	TRAP( err, DoHarvestL( aHD ) );
-	
-	if ( err != KErrNone )
+	TRAPD( error, DoHarvestL( aHD ) );
+	if ( error != KErrNone )
 	    {
-	    aHD->SetErrorCode( err );
+        WRITELOG1( "CHarvesterAudioPlugin::HarvestL() - error: %d", error );
+        TInt convertedError = KErrNone;
+        MdsUtils::ConvertTrapError( error, convertedError );
+        aHD->SetErrorCode( convertedError );
+        WRITELOG1( "CHarvesterAudioPlugin::HarvestL() - returning: %d", convertedError );
+	    
 	    }
 	}
 
@@ -259,6 +262,8 @@
 
 	CMdeObjectWrapper::HandleObjectPropertyL(
               mdeObject, *iPropDefs->iSizePropertyDef, &entry.iSize, aIsAdd );
+	
+	mdeObject.SetPlaceholder( EFalse );
     }
 
 // ---------------------------------------------------------------------------
--- a/harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -266,12 +266,14 @@
     CHarvestData* harvestData = CHarvestData::NewL();
     CleanupStack::PushL( harvestData );
         
-    const TInt errorCode = GatherDataL( mdeObject, *fileData, *harvestData );
-    if ( errorCode == KErrNone || errorCode == KErrCompletion ) // ok, something got harvested
+    TInt errorCode( KErrNone );
+    TRAPD( error, errorCode = GatherDataL( mdeObject, *fileData, *harvestData ) );
+    if ( error == KErrNone && (errorCode == KErrNone || errorCode == KErrCompletion ) ) // ok, something got harvested
         {
         if ( mdeObject.Id() == 0 || mdeObject.Placeholder() ) // is a new object or placeholder
             {
             TRAP_IGNORE( HandleObjectPropertiesL( *harvestData, *fileData, *aHD, ETrue ) );
+            mdeObject.SetPlaceholder( EFalse );
             }
         else   // not a new object
             {
@@ -305,6 +307,14 @@
         	aHD->SetLocationData( locData );
         	}
         }
+    else if( error != KErrNone)
+        {
+        WRITELOG1( "CHarvesterImagePlugin::HarvestL() - other error: %d", error );
+        TInt convertedError = KErrNone;
+        MdsUtils::ConvertTrapError( error, convertedError );
+        aHD->SetErrorCode( convertedError );
+        WRITELOG1( "CHarvesterImagePlugin::HarvestL() - returning: %d", convertedError );
+        }
     else
         {
         WRITELOG1( "CHarvesterImagePlugin::HarvestL() - other error: %d", errorCode );
--- a/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -322,17 +322,12 @@
         
         if ( isNewObject || mdeObject.Placeholder() )
             {
-            TRAP( error, HandleObjectPropertiesL( *aHD, *fileData, ETrue ) );
+            TRAP_IGNORE( HandleObjectPropertiesL( *aHD, *fileData, ETrue ) );
             mdeObject.SetPlaceholder( EFalse );
             }
         else
             {
-            TRAP( error, HandleObjectPropertiesL( *aHD, *fileData, EFalse ) );
-            }
-
-        if ( error != KErrNone )
-            {
-            WRITELOG1( "CHarvesterVideoPlugin::HarvestSingleFileL() - Handling object failed: ", error );
+            TRAP_IGNORE( HandleObjectPropertiesL( *aHD, *fileData, EFalse ) );
             }
     	}
     else
--- a/harvester/monitorplugins/fileplugin/src/FolderRenamer.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/monitorplugins/fileplugin/src/FolderRenamer.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -71,7 +71,7 @@
 
 void CRenameItem::HandleFileEventsL(CFileEventHandlerAO &aCFileEventHandlerAO)
 	{
-	TInt count = iFileEvents.Count();
+	const TInt count = iFileEvents.Count();
 	for (TInt i = 0; i < count; i++)
 		{
 		aCFileEventHandlerAO.HandleNotificationL(* (iFileEvents[i]));
@@ -184,7 +184,7 @@
 void CFolderRenamer::RenameL(const TDesC &aOldName, const TDesC &aNewName)
 	{
     //There comes multiple events for single rename, drop these 
-	TInt count = iRenamedFolders.Count();
+	const TInt count = iRenamedFolders.Count();
 	for (TInt i = 0; i < count; i++)
 		{
 		if ( iRenamedFolders[i]->OldName().CompareF(aOldName) == 0 && 
--- a/harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -165,6 +165,7 @@
     	                    {
     	                    iQueue.Remove( 0 );
     	                    delete tempItem;
+    	                    tempItem = NULL;
     	                    iEventArray->AppendL( status );
     	                    }
     	                else
@@ -811,7 +812,8 @@
     
     iIgnoreList.ResetAndDestroy();
     
-    for ( TInt i = aList.Count(); --i >= 0; )
+    const TInt count( aList.Count() );
+    for ( TInt i = count; --i >= 0; )
         {
         TDesC* listPath = aList[i];
         
@@ -843,7 +845,7 @@
 void CFileEventHandlerAO::NotMoveEvent(RPointerArray<CHarvesterData>& aHDArray)
 	{
 	TInt count = aHDArray.Count();
-	for (int i = 0; i < count; ++i)
+	for (TInt i = 0; i < count; ++i)
 		{
 		CHarvesterData* hd = aHDArray[i];
         iObserver->MonitorEvent( hd );
--- a/harvester/monitorplugins/messageplugin/src/messagemonitorplugin.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/monitorplugins/messageplugin/src/messagemonitorplugin.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -31,7 +31,7 @@
 #include <mtclreg.h>
 #include <smsclnt.h>
 #include <driveinfo.h>
-#include <PathInfo.h>
+#include <pathinfo.h>
 
 // CONSTANTS
 #ifdef _DEBUG
@@ -328,7 +328,37 @@
             hd->SetTakeSnapshot( EFalse );
             hd->SetBinary( EFalse );
             iMonitorPluginObserver->MonitorEvent( hd );
-            }          
+            }
+            
+               
+#ifdef __WINSCW__
+		else if (!err && KMsvDraftEntryId == aFolderId2 && KMsvGlobalOutBoxIndexEntryId == aFolderId1 )
+			{
+			CClientMtmRegistry* clientMtmReg;
+			clientMtmReg = CClientMtmRegistry::NewL(*iMsvSession);
+			CleanupStack::PushL(clientMtmReg);
+			
+			
+			CSmsClientMtm* smsMtm = static_cast<CSmsClientMtm*>(clientMtmReg->NewMtmL(KUidMsgTypeSMS));	
+			CleanupStack::PushL(smsMtm);
+			smsMtm->SwitchCurrentEntryL( msgId );
+			
+			TMsvSelectionOrdering selection;
+			selection.SetShowInvisibleEntries(ETrue);
+			
+			CMsvEntry* parentEntry = CMsvEntry::NewL( smsMtm->Session(),
+                smsMtm->Entry().Entry().Parent(), selection );
+             
+             CleanupStack::PushL(parentEntry);
+        	// Move the message
+        	TRAP_IGNORE( parentEntry->MoveL( msgId, KMsvSentEntryId ) );
+        	CleanupStack::PopAndDestroy(3,clientMtmReg); // parentEntry
+        				
+
+			
+			}
+#endif             
+		
         }
 	WRITELOG("END CMessageMonitorPlugin::HandleMsgMovedL");	        
 	}
--- a/harvester/monitorplugins/mmcplugin/inc/mmcfilelist.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/monitorplugins/mmcplugin/inc/mmcfilelist.h	Tue Jan 26 12:13:20 2010 +0200
@@ -55,6 +55,8 @@
 	CHarvesterEventManager* iHem;
     // not own
     CHarvesterMediaIdUtil* iMediaIdUtil;
+    
+    RPointerArray<HBufC> iIgnorePaths;
 };
 
 #endif /*MMCFILELIST_H_*/
--- a/harvester/monitorplugins/mmcplugin/inc/mmcscannerao.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/monitorplugins/mmcplugin/inc/mmcscannerao.h	Tue Jan 26 12:13:20 2010 +0200
@@ -35,7 +35,7 @@
 	// Two-phased constructor.
 	static CMmcScannerAO* NewL( TUint32 aMediaId, CMdEHarvesterSession* aMdEClient,
 			MMonitorPluginObserver* aObserver, CHarvesterPluginFactory* aHarvesterPluginFactory,
-			CActive::TPriority aPriority, TBool aAlreadyWaited );
+			const TInt aPriority, TBool aAlreadyWaited );
 
 public:
 
@@ -43,7 +43,7 @@
 	// C++ constructor
 	CMmcScannerAO( TUint32 aMediaId, CMdEHarvesterSession* aMdEClient, 
 			MMonitorPluginObserver* aObserver, CHarvesterPluginFactory* aHarvesterPluginFactory,
-			CActive::TPriority aPriority );
+			const TInt aPriority );
 
 	// Second-phase constructor
 	void ConstructL( TBool aAlreadyWaited );
--- a/harvester/monitorplugins/mmcplugin/src/mmcfilelist.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/monitorplugins/mmcplugin/src/mmcfilelist.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -52,6 +52,7 @@
 	{
 	iHem = CHarvesterEventManager::GetInstanceL();
 	iMediaIdUtil = &RMediaIdUtil::GetInstanceL();
+	CHarvesterCenRepUtil::GetIgnorePathL( iIgnorePaths );
 	}
 
 CMmcFileList::~CMmcFileList()
@@ -61,6 +62,8 @@
 		iHem->ReleaseInstance();
 		}
 	RMediaIdUtil::ReleaseInstance();
+	iIgnorePaths.ResetAndDestroy();
+	iIgnorePaths.Close();
 	}
 
 TBool CMmcFileList::IsDescInArray(const TPtrC& aSearch, const RPointerArray<HBufC>& aArray)
@@ -96,18 +99,22 @@
 	
 	WRITELOG1( "CMmcFileList::BuildFileListL - mediaId: %d", mediaId );
 	
-	RPointerArray<HBufC> ignorePaths;
-	TCleanupItem cleanupItem( MdsUtils::CleanupPtrArray<HBufC>, &ignorePaths );
-    CleanupStack::PushL( cleanupItem );
-    
-    CHarvesterCenRepUtil::GetIgnorePathL( ignorePaths );
-	
     CDir* directory = NULL;
     TFileName name; 
+    TBool rootDir( ETrue );
     
 	while ( path->Count() > 0 )
 		{
-		TInt error = aFs.GetDir( (*path)[0], KEntryAttDir, KHarvesterGetDirFlags, directory );
+		TInt error( KErrNone );
+		if( rootDir )
+		    {
+		    error = aFs.GetDir( (*path)[0], KEntryAttDir, KHarvesterGetRootDirFlags, directory );
+		    rootDir = EFalse;
+		    }
+		else
+		    {
+		    error = aFs.GetDir( (*path)[0], KEntryAttDir, KHarvesterGetDirFlags, directory );
+		    }
 		if ( error == KErrNone )
 			{
 			for ( TInt i=0; i < directory->Count(); ++i )
@@ -127,8 +134,8 @@
 			
 				if ( entry.IsDir() )
 					{
-					// If path is too long, skip it as the file cannot be supported
-	                if( name.Length() >= KMaxPath )
+					// If path is too long with backslash, skip it as the file cannot be supported
+	                if( name.Length() + 1 >= KMaxPath )
 	                    {
 	                    continue;
 	                    }
@@ -140,7 +147,7 @@
 					// remove drive letter and colon from path
 					TPtrC pathOnly = name.Mid( 2 );
 					
-					if ( IsDescInArray( pathOnly, ignorePaths ) )
+					if ( IsDescInArray( pathOnly, iIgnorePaths ) )
 						{
 						continue;
 						}
@@ -171,8 +178,6 @@
 		directory = NULL;
 		}
 	
-	CleanupStack::PopAndDestroy( &ignorePaths );
-	
 	CleanupStack::PopAndDestroy( path );
 	
 	WRITELOG( "CMmcFileList::BuildFileListL - end" );
--- a/harvester/monitorplugins/mmcplugin/src/mmcmonitorao.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/monitorplugins/mmcplugin/src/mmcmonitorao.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -66,10 +66,11 @@
 	
     BuildDriveList();
     
-    for ( TInt i = 0; i < aMedias.Count(); i++ )
+    const TInt count( aMedias.Count() );
+    for ( TInt i = 0; i < count; i++ )
     	{
     	TInt drive(0);
-    	TInt err = iFs.CharToDrive( aMedias[i].iDrive, drive );
+    	const TInt err = iFs.CharToDrive( aMedias[i].iDrive, drive );
     	if ( err == KErrNone )
     		{
     		WRITELOG2( "CMMCMonitorAO::StartMonitoring - set drive %d mediaid to %d ", drive, aMedias[i].iMediaId );
--- a/harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -24,6 +24,8 @@
 
 #include <e32cmn.h>
 
+const TInt KMassStorageScanCustomPriority = 5;
+
 _LIT( KColon, ":" );
 
 // construct/destruct
@@ -106,8 +108,8 @@
     hdMediaId = iMountTask->GetInternalDriveMediaId();
     TBool alreadyWaited( EFalse );
     
-    
-    for ( TInt i = 0; i < medias.Count(); i++ )
+    const TInt count( medias.Count() );
+    for ( TInt i = 0; i < count; i++ )
     	{
     	TRAP_IGNORE( iMdEClient->GetMediaL( medias[i].iMediaId, driveLetter, presentState ) );
     	
@@ -136,7 +138,7 @@
 			medias.Append( hdInfo );
 			
 			TRAP_IGNORE( iHddScanner = CMmcScannerAO::NewL( hdMediaId, iMdEClient, iObserver,
-			    				aHarvesterPluginFactory, CActive::EPriorityUserInput, alreadyWaited ));
+			    				aHarvesterPluginFactory, KMassStorageScanCustomPriority, alreadyWaited ));
 			}
 		}
 
@@ -279,7 +281,6 @@
 void CMMCMonitorPlugin::StartMonitoringAllMMCsL( RArray<TMdEMediaInfo>& aMedias )
     {
     WRITELOG( "CMMCMonitorPlugin::StartMonitoringAllMMCs" );
-    TInt count( 0 );
     
     RFs fs;
     User::LeaveIfError( fs.Connect() );
@@ -297,6 +298,7 @@
     TChar drive;
     const TInt acount = driveList.Length();
     const TInt mediaCount = aMedias.Count();
+    TInt count( 0 );
     
     // set removed medias to not present
     for ( i = 0; i < mediaCount; i++ )
--- a/harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -234,7 +234,7 @@
 			
 			RMsgQueue<TInt> unmountQueue;
 			_LIT( KUnmountHandlerAOString, "unmounthandlerao" );
-			TInt err = unmountQueue.OpenGlobal( KUnmountHandlerAOString );
+			const TInt err = unmountQueue.OpenGlobal( KUnmountHandlerAOString );
 			if( err == KErrNone )
 				{
 				unmountQueue.Send( iMountData->iMediaID );
@@ -281,21 +281,25 @@
 					SetNextRequest( ERequestStartTask );
 					break;
 					}
+				
+	            if ( iEntryArray.Count() > 0 )
+	                {
+	                SetNextRequest( ERequestHandleFileEntry );
+	                break;
+	                }
+				}
+			
+		    if ( iHarvestEntryArray.Count() > 0 )
+				{
+				SetNextRequest( ERequestHandleReharvest );
+				break;
 				}
 			else
 				{
-				RemoveNotPresentFromMDE();
-				SetNextRequest( ERequestCleanup );
-				break;
-				}
-				
-			if ( iHarvestEntryArray.Count() > 0 )
-				{
-				SetNextRequest( ERequestHandleReharvest );
-				}
-			else
-				{
-				SetNextRequest( ERequestHandleFileEntry );
+                // All detected entries are set as present at this stage, clear not present entries
+                RemoveNotPresentFromMDE();
+                SetNextRequest( ERequestCleanup );
+                break;
 				}
 			}
 		break;
@@ -430,7 +434,10 @@
 		aArray.Remove( 0 );
 		}
 	
-	aArray.Compress();
+    if( aArray.Count() == 0 )
+        {
+        aArray.Compress();
+        }
 			
 	if ( iObserver )
 		{
@@ -473,8 +480,8 @@
 void CMMCMountTaskAO::Initialize()
 	{
 	WRITELOG( "CMMCMountTaskAO::Initialize" );
-	iEntryArray.Reset();
-	iHarvestEntryArray.Reset();
+    iEntryArray.ResetAndDestroy();
+    iHarvestEntryArray.ResetAndDestroy();
 	}
 	
 void CMMCMountTaskAO::Deinitialize()
@@ -511,7 +518,7 @@
 	TDriveList driveList;
     TInt numOfElements( 0 );
 
-    TInt err = DriveInfo::GetUserVisibleDrives( 
+    const TInt err = DriveInfo::GetUserVisibleDrives( 
     		iFs, driveList, numOfElements, 
     		KDriveAttExclude | KDriveAttRemote | KDriveAttRom );
     if( err != KErrNone )
@@ -531,7 +538,7 @@
 	        	{
 	        	// check if disk is internal
 	        	TUint driveStatus;
-	        	TInt err = DriveInfo::GetDriveStatus( iFs, i, driveStatus );
+	        	const TInt err = DriveInfo::GetDriveStatus( iFs, i, driveStatus );
 	        	if ( (err == KErrNone ) && ( driveStatus & DriveInfo::EDriveInternal ) )
 	        		{
 	        		// get media id
--- a/harvester/monitorplugins/mmcplugin/src/mmcscannerao.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/monitorplugins/mmcplugin/src/mmcscannerao.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -32,7 +32,7 @@
 
 CMmcScannerAO::CMmcScannerAO( TUint32 aMediaId, 
 		CMdEHarvesterSession* aMdEClient, MMonitorPluginObserver* aObserver, 
-		CHarvesterPluginFactory* aHarvesterPluginFactory, CActive::TPriority aPriority ) : 
+		CHarvesterPluginFactory* aHarvesterPluginFactory, const TInt aPriority ) : 
 		CTimer( aPriority ), iState( EUninitialized ), iMmcFileList( NULL )   
 	{
 	iMediaId = aMediaId;
@@ -43,7 +43,7 @@
 
 CMmcScannerAO* CMmcScannerAO::NewL( TUint32 aMediaId, CMdEHarvesterSession* aMdEClient,
 		MMonitorPluginObserver* aObserver, CHarvesterPluginFactory* aHarvesterPluginFactory, 
-		CActive::TPriority aPriority, TBool aAlreadyWaited )
+		const TInt aPriority, TBool aAlreadyWaited )
 	{
 	CMmcScannerAO* self = new ( ELeave ) CMmcScannerAO( aMediaId, aMdEClient, aObserver, 
 			aHarvesterPluginFactory, aPriority );
@@ -67,7 +67,7 @@
         TInt tmpDelay( KDefaultDelay );
         TTimeIntervalMicroSeconds32 delay( tmpDelay * KMillion ); 
         CRepository* repo = CRepository::NewLC( KRepositoryUid );
-        TInt err = repo->Get( KScanDelayKey, tmpDelay );
+        const TInt err = repo->Get( KScanDelayKey, tmpDelay );
         if ( err == KErrNone )
             {
             delay = tmpDelay * KMillion;
@@ -146,12 +146,12 @@
 				WRITELOG("CMmcScannerAO::RunL - handling file list");
 				iMmcFileList->HandleFileEntryL( *iMdEClient, iEntryArray, 
 						iHarvestEntryArray, iMediaId, iHarvesterPluginFactory );
-				SetState( EHarvestFiles );
-				}
-			else 
-				{
-				SetState( ERemoveNPFiles );
-				}
+				SetState( EProcessFiles );
+                }
+            else 
+                {
+                SetState( EHarvestFiles );
+                }
 			break;
 			}
 		
@@ -165,7 +165,7 @@
 				}
 			else
 				{
-				SetState( EProcessFiles );
+				SetState( ERemoveNPFiles );
 				}
 			break;
 			}
@@ -181,6 +181,8 @@
 		case( EDone ):
 			{
 			iFs.Close();
+			iEntryArray.Compress();
+			iHarvestEntryArray.Compress();
 			break;
 			}
 		
--- a/harvester/server/inc/harvesterao.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/server/inc/harvesterao.h	Tue Jan 26 12:13:20 2010 +0200
@@ -525,7 +525,6 @@
         CHarvesterEventManager* iHarvesterEventManager;
                 
         MHarvesterStatusObserver* iHarvesterStatusObserver;
-        TBool iHarvesting;
         
         CRestoreWatcher* iRestoreWatcher;
         
--- a/harvester/server/src/harvesterao.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/server/src/harvesterao.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -47,7 +47,7 @@
 const TInt KContainerPlaceholderQueueSize = 10;
 const TInt KObjectDefStrSize = 20;
 
-const TInt KCacheItemCountForEventCaching = 1;
+const TInt KHarvesterAOCustomPriority = 5;
 
 _LIT( KTAGDaemonName, "ThumbAGDaemon" );
 _LIT( KTAGDaemonExe, "thumbagdaemon.exe" );
@@ -114,7 +114,7 @@
 // CHarvesterAO
 // ---------------------------------------------------------------------------
 //
-CHarvesterAO::CHarvesterAO() : CActive( CActive::EPriorityStandard )
+CHarvesterAO::CHarvesterAO() : CActive( KHarvesterAOCustomPriority)
     {
     WRITELOG( "CHarvesterAO::CHarvesterAO() - begin" );
     
@@ -123,7 +123,6 @@
     
     iContextEngineInitialized = EFalse;
     iMdeSessionInitialized = EFalse;
-    iHarvesting = EFalse;
     }
      
 // ---------------------------------------------------------------------------
@@ -320,7 +319,7 @@
     {
     WRITELOG( "CHarvesterAO::StartMonitoring()" );
 
-    TInt count( iMonitorPluginArray.Count() );  
+    const TInt count( iMonitorPluginArray.Count() );  
     
     for ( TInt i = 0; i < count; i++ )
         {
@@ -337,7 +336,7 @@
     {
     WRITELOG( "CHarvesterAO::StopMonitoring()" );
 
-    TInt count( iMonitorPluginArray.Count() );
+    const TInt count( iMonitorPluginArray.Count() );
     
     for ( TInt i = 0; i < count; i++ )
         {
@@ -352,7 +351,7 @@
 void CHarvesterAO::PauseMonitoring()
     {
     WRITELOG( "CHarvesterAO::PauseMonitoring()" );
-    TInt count( iMonitorPluginArray.Count() );
+    const TInt count( iMonitorPluginArray.Count() );
     
     for ( TInt i = 0; i<count; i++ )
         {
@@ -369,7 +368,7 @@
     {
     WRITELOG( "CHarvesterAO::ResumeMonitoring()" );
     
-    TInt count( iMonitorPluginArray.Count() );
+    const TInt count( iMonitorPluginArray.Count() );
     
     for ( TInt i=0; i < count; i++ )
         {
@@ -389,7 +388,6 @@
 	
     TUint32 mediaId(0);
     TUint removed(0);
-    TInt err(0);
     CHarvesterData* hd = NULL;
     
 #ifdef _DEBUG
@@ -402,6 +400,8 @@
 		iReadyPHArray.ResetAndDestroy();
 		}
 
+    TInt err( KErrNone );
+	
 #ifdef _DEBUG
 	WRITELOG1( "CHarvesterAO::HandleUnmount() iPHArray.Count() = %d", iPHArray.Count() );
 #endif
@@ -466,14 +466,15 @@
 	removed = 0;
 	
 	RPointerArray<CHarvesterPluginInfo>& hpiArray = iHarvesterPluginFactory->GetPluginInfos();
-	if( hpiArray.Count() > 0 )
+	const TInt arrayCount( hpiArray.Count() );
+	if( arrayCount > 0 )
 		{
 		RArray<TItemId> placeholders;
 		
-		TUint32 mediaId(0);
-		TInt err(0);
+		TUint32 mediaId( 0 );
+		TInt err( KErrNone );
 		
-		for( TInt i = hpiArray.Count(); --i >= 0; )
+		for( TInt i = arrayCount; --i >= 0; )
 			{
 			CHarvesterPluginInfo* hpi = hpiArray[i];
 			for( TInt j = hpi->iQueue.Count(); --j >= 0; )
@@ -529,8 +530,7 @@
     TCleanupItem cleanupItem( MdsUtils::CleanupEComArray, &infoArray );
     CleanupStack::PushL( cleanupItem );
     CComposerPlugin::ListImplementationsL( infoArray );
-    TInt count( 0 );
-    count = infoArray.Count();
+    const TInt count( infoArray.Count() );
 
     for ( TInt i=0; i < count; i++ )
         {
@@ -560,7 +560,8 @@
     {
     WRITELOG( "CHarvesterAO::StopComposers()" );
     
-    for ( TInt i = iComposerPluginArray.Count(); --i >= 0; )
+    const TInt count( iComposerPluginArray.Count() );
+    for ( TInt i = count; --i >= 0; )
         {
         iComposerPluginArray[i]->RemoveSession();
         }
@@ -589,7 +590,8 @@
     {
     WRITELOG( "CHarvesterAO::IsComposingReady()" );
     
-    for ( TInt i = iComposerPluginArray.Count(); --i >= 0; )
+    const TInt count( iComposerPluginArray.Count() );
+    for ( TInt i = count; --i >= 0; )
         {
         if ( iComposerPluginArray[i]->IsComposingComplete() == EFalse )
             {
@@ -706,7 +708,7 @@
 		    TEntry* entry = new (ELeave) TEntry();
 		    CleanupStack::PushL( entry );
 		    const TDesC& uri = hd->Uri();
-		    TInt err = iFs.Entry( uri, *entry );
+		    const TInt err = iFs.Entry( uri, *entry );
 		    if ( err != KErrNone )
 		    	{
 		    	WRITELOG( "CHarvesterAO::HandlePlaceholdersL() - cannot create placeholder data object for camera. file does not exists" );
@@ -771,16 +773,25 @@
     	// set origin
 		mdeObject->AddUint8PropertyL( *iPropDefs->iOriginPropertyDef, hd->Origin() );
     	
-    	CPlaceholderData* ph = static_cast<CPlaceholderData*>( hd->ClientData() );
-	    TInt isPreinstalled = ph->Preinstalled();
+    	CPlaceholderData* ph = NULL;
+    	if( hd->TakeSnapshot() )
+    	    {
+    	    ph = static_cast<CPlaceholderData*>( hd->ClientData() );
+    	    }
+    	else
+    	    {
+    	    ph = phData;
+    	    }
+    	
+	    const TInt isPreinstalled = ph->Preinstalled();
 	    if( isPreinstalled == MdeConstants::MediaObject::EPreinstalled )
 	    	{
 	    	WRITELOG("CHarvesterAO::HandlePlaceholdersL() - preinstalled");
 	    	mdeObject->AddInt32PropertyL( *iPropDefs->iPreinstalledPropertyDef, isPreinstalled );
-	    	}	    
+	    	}
 		
 	    hd->SetEventType( EHarvesterEdit );
-	    
+		
 		// skip 
 		if( hd->TakeSnapshot() )
 			{
@@ -803,7 +814,7 @@
 		iPHArray.Remove( i );
 		}
 	
-	TInt objectCount = mdeObjectArray.Count();  
+	const TInt objectCount = mdeObjectArray.Count();  
 	
     if( objectCount > 0 )
 		{
@@ -827,7 +838,7 @@
 			}
 		
 #ifdef _DEBUG
-		for (TInt i = 0; i < mdeObjectArray.Count(); ++i)
+		for (TInt i = 0; i < objectCount; ++i)
 			{
 			CMdEObject* mdeObject = mdeObjectArray[i];
 			if(mdeObject->Id() == 0)
@@ -1026,8 +1037,7 @@
 	        		WRITELOG( "CHarvesterAO::HarvestingCompleted() - Creating location object. " );
 	        		RLocationObjectManipulator lo;
 	        		
-	        		TInt loError = KErrNone;     		
-	        		loError = lo.Connect();
+	        		const TInt loError = lo.Connect();     		
 	        		
 	        		if (loError == KErrNone)
 	        			{
@@ -1081,6 +1091,8 @@
         else
             {
             WRITELOG1( "CHarvesterAO::HarvestingCompleted() - unknown error: %d", errorCode );
+            delete aHD;
+            aHD = NULL;
             }
         
         WRITELOG( "==============================ERROR done =========================" );
@@ -1115,6 +1127,13 @@
         	{
             WRITELOG( "CHarvesterAO::HandleSessionOpened() - error creating mde harvester session" );
         	}
+        
+        TRAPD( ohTrap, iMdeObjectHandler = CMdeObjectHandler::NewL( *iMdESession ) );
+        if ( ohTrap != KErrNone )
+                {
+                WRITELOG( "CHarvesterAO::HandleSessionOpened() - ObjectHandler creation failed" );
+                }
+        
 #ifdef _DEBUG
         TRAP( errorTrap, PreallocateNamespaceL( aSession.GetDefaultNamespaceDefL() ) );
         if ( errorTrap != KErrNone )
@@ -1165,12 +1184,6 @@
         	{
         	WRITELOG( "CHarvesterAO::HandleSessionOpened() - couldn't create on demand observer" );
         	}
-
-    	TRAPD( ohTrap, iMdeObjectHandler = CMdeObjectHandler::NewL( *iMdESession ) );
-    	if ( ohTrap != KErrNone )
-				{
-				WRITELOG( "CHarvesterAO::HandleSessionOpened() - ObjectHandler creation failed" );
-				}
     	
         // Initializing pause indicator
         iServerPaused = EFalse;
@@ -1297,6 +1310,9 @@
         case ERequestIdle:
             {
             WRITELOG( "CHarvesterAO::RunL - ERequestIdle" );
+            iReadyPHArray.Compress();
+            iContainerPHArray.Compress();
+            iPHArray.Compress();
             }
         break;
 
@@ -1308,15 +1324,6 @@
             // harvest new items first...
             if ( iQueue->ItemsInQueue() > 0 )
                 {
-                if ( !iHarvesting )
-                	{
-                	iHarvesting = ETrue;
-                	iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateStarted );
-                	// This next line is for caching the harvester started event for observers registering
-                	// after harvesting has already started
-                	iHarvesterEventManager->IncreaseItemCount( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
-                	}
-                
                 ReadItemFromQueueL();
 				SetNextRequest( ERequestHarvest );
                 }
@@ -1337,24 +1344,24 @@
 #ifdef _DEBUG
             		WRITELOG1("CHarvesterAO::RunL - items in ready pharray: %d", iReadyPHArray.Count() );
 #endif   		
-            		for ( TInt i = iReadyPHArray.Count(); --i >= 0; )
+            		const TInt beginIndex( iReadyPHArray.Count() );
+            		TInt endIndex( beginIndex - KPlaceholderQueueSize );
+            		if( endIndex < 0 )
+            		    {
+            		    endIndex = 0;
+            		    }
+            		for ( TInt i = beginIndex; --i >= endIndex; )
             			{
                 		CheckFileExtensionAndHarvestL( iReadyPHArray[i] );
                 		iReadyPHArray.Remove( i );
             			}
+            		if( iReadyPHArray.Count() )
+            		    {
+            		    SetNextRequest( ERequestHarvest );
+            		    break;
+            		    }
             		iReadyPHArray.Reset();
             		}
-				
-				if ( iHarvesting && !UnharvestedItemsLeftInPlugins() && 
-					 !iReHarvester->ItemsInQueue() )
-					{
-					iHarvesting = EFalse;						
-					iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateFinished );
-					iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
-				    iReadyPHArray.Compress();
-				    iContainerPHArray.Compress();
-				    iPHArray.Compress();
-					}
 
                 SetNextRequest( ERequestIdle );
                 }
@@ -1797,13 +1804,13 @@
             return;
             }
 
-        #ifdef _DEBUG
+#ifdef _DEBUG
         const TInt count = albumIds.Count();
         for (TInt i = 0; i < count; ++i)
             {
             WRITELOG2( "RHarvesterClient::HarvestFileWithUID - album id[%d]: %d", i, albumIds[i] );
             }
-        #endif
+#endif
         
         delete albumIdBuf;
         albumIdBuf = NULL;
@@ -2411,7 +2418,7 @@
 TBool CHarvesterAO::UnharvestedItemsLeftInPlugins()
 	{
 	RPointerArray<CHarvesterPluginInfo>& infos = iHarvesterPluginFactory->GetPluginInfos();
-	TInt count = infos.Count();
+	const TInt count = infos.Count();
 	for ( TInt i = count; --i >= 0; )
 		{
 		if ( infos[i]->iQueue.Count() > 0 )
--- a/harvester/server/src/harvesteroomao.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/server/src/harvesteroomao.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -73,8 +73,8 @@
 	{
 	User::LeaveIfError( iStatus.Int() );
 	
-	TInt oomStatus(0);
-	TInt err = iOomMsgQueue.Receive( oomStatus );
+	TInt oomStatus( 0 );
+	const TInt err = iOomMsgQueue.Receive( oomStatus );
 	
 	if( oomStatus == TMdsOomFreeRam )
 		{
--- a/harvester/server/src/harvesterqueue.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/server/src/harvesterqueue.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -148,11 +148,11 @@
             WRITELOG( "CHarvesterQueue::Append() - found a blacklisted file" );
             delete aItem;
             aItem = NULL;
-            err = KErrCorrupt;
+            return;
             }
         }
 
-    if ( err != KErrCorrupt )
+    if ( err == KErrNone )
         {
 		// check if fast harvest file and add to start of queue
     	if ( aItem->ObjectType() == EFastHarvest || aItem->Origin() == MdeConstants::Object::ECamera )
@@ -168,14 +168,9 @@
 			{
 			delete aItem;
 			aItem = NULL;
+			return;
 			}
         }
-
-    if ( err != KErrNone )
-        {
-        WRITELOG1( "CHarvesterQueue::Append() - error: %d", err );
-        delete aItem;
-        }
     }
 
 // ---------------------------------------------------------------------------
@@ -253,9 +248,5 @@
     	{
     	MonitorEvent( aHarvesterDataArray[i] );
     	}
-    
-    // "clear" array after ownership of items
-    // was changed for MonitorEvent-method
-    aHarvesterDataArray.Reset();
     }
 
--- a/harvester/server/src/restorewatcher.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/harvester/server/src/restorewatcher.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -19,7 +19,7 @@
 #include <centralrepository.h>
 #include <sbdefs.h>
 #include <driveinfo.h>
-#include <PathInfo.h>
+#include <pathinfo.h>
 
 // USER INCLUDE
 #include "restorewatcher.h"
--- a/inc/mdcitem.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/inc/mdcitem.h	Tue Jan 26 12:13:20 2010 +0200
@@ -24,7 +24,7 @@
 NONSHARABLE_CLASS(TMdCItem) : protected TMdCSerializationType
 	{
 	protected:
-		TMdCItem(TMdCStructTypes aType) : TMdCSerializationType( aType )
+		TMdCItem(TMdCStructTypes aType) : TMdCSerializationType( aType ), iId( 0 ), iDefId( 0 )
 			{
 			}
 		
--- a/inc/mdssqliteconnection.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/inc/mdssqliteconnection.h	Tue Jan 26 12:13:20 2010 +0200
@@ -293,7 +293,7 @@
             {
             }
 
-        inline void RMdsStatement::Close()
+        inline void Close()
             {
             iStatement.Close();
             }
--- a/locationmanager/inc/locationmanagerdebug.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/locationmanager/inc/locationmanagerdebug.h	Tue Jan 26 12:13:20 2010 +0200
@@ -18,6 +18,8 @@
 #ifndef LOCATIONMANAGERDEBUG_H
 #define LOCATIONMANAGERDEBUG_H
 
+#include "harvesterlog.h"
+
 /**
  *  Usage:  LOG(_L("[MODULE_NAME]\t Trace text here"));
  *          TRACE(Print(_L("[MODULE_NAME]\t Trace text here with parameter %d"), iCount));
--- a/locationmanager/locationtrail/group/locationtrail.mmp	Mon Jan 18 20:34:07 2010 +0200
+++ b/locationmanager/locationtrail/group/locationtrail.mmp	Tue Jan 26 12:13:20 2010 +0200
@@ -35,6 +35,7 @@
 
 USERINCLUDE     ../inc
 USERINCLUDE     ../../inc
+USERINCLUDE     ../../../inc
 
 SOURCEPATH      ../src
 SOURCE          clocationrecord.cpp
--- a/locationmanager/locationtrail/inc/locationremappingao.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/locationmanager/locationtrail/inc/locationremappingao.h	Tue Jan 26 12:13:20 2010 +0200
@@ -20,7 +20,7 @@
 
 #include <e32base.h>
 #include <etel3rdparty.h>
-#include <LbsPosition.h> 
+#include <lbsposition.h> 
 #include <centralrepository.h>
 
 #include "locationdatatype.h"
--- a/locationmanager/locationtrail/src/cgpxconverterao.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/locationmanager/locationtrail/src/cgpxconverterao.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -17,7 +17,7 @@
 
 #include <f32file.h>
 #include <s32file.h>
-#include <PathInfo.h>
+#include <pathinfo.h>
 #include "cgpxconverterao.h"
 #include "locationmanagerdebug.h"
 
--- a/locationmanager/locationtrail/src/clocationrecord.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/locationmanager/locationtrail/src/clocationrecord.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -16,8 +16,8 @@
 */
 
 #include <e32cmn.h> 
-#include <LbsErrors.h>
-#include <LbsSatellite.h>
+#include <lbserrors.h>
+#include <lbssatellite.h>
 
 #include "rlocationtrail.h"
 #include "clocationrecord.h"
--- a/locationmanager/locationtrail/src/ctracklog.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/locationmanager/locationtrail/src/ctracklog.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -21,7 +21,7 @@
 #include "rtracklog.h"
 #include <f32file.h>
 #include <s32file.h>
-#include <PathInfo.h>
+#include <pathinfo.h>
 #include <centralrepository.h>
 #include <locationeventdef.h>
 #include "cgpxconverterao.h"
--- a/locationmanager/server/inc/clocationmanagerserver.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/locationmanager/server/inc/clocationmanagerserver.h	Tue Jan 26 12:13:20 2010 +0200
@@ -224,7 +224,7 @@
      * @param aHandle
      * @return None.
      */
-    void CLocationManagerServer::CancelTrackLogNotificationRequest( const TInt aHandle );
+    void CancelTrackLogNotificationRequest( const TInt aHandle );
 
     /**
      * Get current network cell id.
--- a/locationmanager/server/src/clocationmanagerserver.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/locationmanager/server/src/clocationmanagerserver.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -1122,6 +1122,7 @@
     	{
     	TItemId objectId = mdeObject->Id();
 	    delete mdeObject;
+	    mdeObject = NULL;
 	    
 		TTime time( 0 );
 		CMdENamespaceDef& nsDef = iMdeSession->GetDefaultNamespaceDefL();
--- a/locationmanager/server/src/clocationmanagersession.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/locationmanager/server/src/clocationmanagersession.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -17,7 +17,7 @@
 
 #include <e32debug.h>
 #include <s32mem.h>
-#include <LbsSatellite.h> 
+#include <lbssatellite.h> 
 #include <locationdatatype.h>
 #include <locationeventdef.h>
 
@@ -88,7 +88,7 @@
     LOG( "CLocationManagerSession::ServiceL" );
     _LIT( KSemaphore, "LocManSynchSemaphore" );
     RSemaphore semaphore;
-    TInt result = semaphore.OpenGlobal( KSemaphore );
+    const TInt result = semaphore.OpenGlobal( KSemaphore );
     LOG1( "CLocationManagerSession::ServiceL - semaphore open result: %d", result );
     iMessage = RMessage2( aMessage );
     if ( result == KErrNone )
--- a/mds_plat/harvester_framework_api/inc/harvesterplugin.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/mds_plat/harvester_framework_api/inc/harvesterplugin.h	Tue Jan 26 12:13:20 2010 +0200
@@ -25,6 +25,7 @@
 class CHarvesterBlacklist;
 class CHarvesterData;
 class CMdEPropertyDef;
+class CHarvesterEventManager;
 
 // Uid for this interface
 const TUid KCHarvesterPluginInterfaceUid = { 0x200009F8 };
@@ -240,6 +241,10 @@
 
 	CMdEPropertyDef* iOriginPropertyDef;
 	CMdEPropertyDef* iTitlePropertyDef;
+	
+    TBool iHarvesting;
+	
+	CHarvesterEventManager* iHarvesterEventManager;
     };
 
 #endif // __CHARVESTERPLUGIN_H__
--- a/mds_plat/metadata_engine_api/inc/mdeobjectdef.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/mds_plat/metadata_engine_api/inc/mdeobjectdef.h	Tue Jan 26 12:13:20 2010 +0200
@@ -116,7 +116,31 @@
 	CMdEPropertyDef* GetPropertyDefL(const TDesC& aName, CMdEObjectDef* aChild);
 
 	void ConstructL(CMdCSerializationBuffer& aSchemaBuffer);
+	
+    /**
+     * Compares two properties.
+     *
+     * @param aFirst   First property.
+     * @param aSecond  Second property.
+     *
+     * @return  0, if the properties are equal;
+     *          a negative value, if the first property is less than the second;
+     *          a positive value, if the first property is greater than the second.
+     */
+    static TInt CompareProperties( const CMdEPropertyDef& aFirst, const CMdEPropertyDef& aSecond );
 
+    /**
+     * Compares two properties.
+     *
+     * @param aFirst   First property id.
+     * @param aSecond  Second property.
+     *
+     * @return  0, if the properties are equal;
+     *          a negative value, if the first property is less than the second;
+     *          a positive value, if the first property is greater than the second.
+     */
+    static TInt CompareProperties( const TDefId* aFirst, const CMdEPropertyDef& aSecond );
+    
 private:
 	const TMdCObjectDef& iObjectDef;
 	CMdENamespaceDef& iNamespaceDef;
--- a/mds_plat/metadata_engine_api/tsrc/src/MdETestScripter.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/mds_plat/metadata_engine_api/tsrc/src/MdETestScripter.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -18,7 +18,7 @@
 // INCLUDE FILES
 #include <StifTestInterface.h>
 #include <SettingServerClient.h>
-#include <PathInfo.h>
+#include <pathinfo.h>
 #include <mdesession.h>
 #include "MdETestScripter.h"
 #include "MdETestScripterAO.h"
--- a/mds_pub/content_listing_framework_api/tsrc/src/T_CLFApiModuleTests.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/mds_pub/content_listing_framework_api/tsrc/src/T_CLFApiModuleTests.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -35,7 +35,7 @@
 #include <MCLFSortingStyle.h>
 #include <T_ContentListingFramework.rsg>
 #include <collate.h>
-#include <PathInfo.h>
+#include <pathInfo.h>
 #include <MCLFProcessObserver.h>
 #include <CLFContentListingExtended.hrh>
 
--- a/metadataengine/client/src/mdeasynchronousfindao.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/client/src/mdeasynchronousfindao.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -246,20 +246,30 @@
 
     const TQueryType mode = iQuery.Type();
 
-    if ( mode == EQueryTypeObject ) 
-        {
-        CMdEObjectQueryImpl& qi = (CMdEObjectQueryImpl&)iQuery;
-        qi.DoNotifyCompleted( aError );
-        }
-    else if ( mode == EQueryTypeRelation )
+    switch( mode )
         {
-        CMdERelationQueryImpl& qi = (CMdERelationQueryImpl&)iQuery;
-        qi.DoNotifyCompleted( aError );
-        }
-    else if ( mode == EQueryTypeEvent )
-        {
-        CMdEEventQueryImpl& qi = (CMdEEventQueryImpl&)iQuery;
-        qi.DoNotifyCompleted( aError );
+        case EQueryTypeObject: 
+            {
+            CMdEObjectQueryImpl& qi = (CMdEObjectQueryImpl&)iQuery;
+            qi.DoNotifyCompleted( aError );
+            break;
+            }
+        case EQueryTypeRelation:
+            {
+            CMdERelationQueryImpl& qi = (CMdERelationQueryImpl&)iQuery;
+            qi.DoNotifyCompleted( aError );
+            break;
+            }
+        case EQueryTypeEvent:
+            {
+            CMdEEventQueryImpl& qi = (CMdEEventQueryImpl&)iQuery;
+            qi.DoNotifyCompleted( aError );
+            break;
+            }
+        default:
+            {
+            return KErrNone;
+            }
         }
 
 	return KErrNone;
@@ -274,20 +284,30 @@
         {
         const TQueryType mode = iQuery.Type();
 
-        if ( mode == EQueryTypeObject )
-            {
-            CMdEObjectQueryImpl& qi = (CMdEObjectQueryImpl&)iQuery;
-            qi.DoNotifyResultsL( iResultList );
-            }
-        else if ( mode == EQueryTypeRelation )
+        switch( mode )
             {
-            CMdERelationQueryImpl& qi = (CMdERelationQueryImpl&)iQuery;
-            qi.DoNotifyResultsL( iResultList );
-            }
-        else if ( mode == EQueryTypeEvent )
-            {
-            CMdEEventQueryImpl& qi = (CMdEEventQueryImpl&)iQuery;
-            qi.DoNotifyResultsL( iResultList );
+            case EQueryTypeObject:
+                {
+                CMdEObjectQueryImpl& qi = (CMdEObjectQueryImpl&)iQuery;
+                qi.DoNotifyResultsL( iResultList );
+                break;
+                }
+            case EQueryTypeRelation:
+                {
+                CMdERelationQueryImpl& qi = (CMdERelationQueryImpl&)iQuery;
+                qi.DoNotifyResultsL( iResultList );
+                break;
+                }
+            case EQueryTypeEvent:
+                {
+                CMdEEventQueryImpl& qi = (CMdEEventQueryImpl&)iQuery;
+                qi.DoNotifyResultsL( iResultList );
+                break;
+                }
+            default:
+                {
+                // Nothing to do
+                }
             }
 
         // get rid of local results list
@@ -300,20 +320,30 @@
         {
         const TQueryType mode = iQuery.Type();
         
-        if ( mode == EQueryTypeObject )
-            {
-            CMdEObjectQueryImpl& qi = (CMdEObjectQueryImpl&)iQuery;
-            qi.DoNotifyResultsL( iIdResultList );
-            }
-        else if ( mode == EQueryTypeRelation )
+        switch( mode )
             {
-            CMdERelationQueryImpl& qi = (CMdERelationQueryImpl&)iQuery;
-            qi.DoNotifyResultsL( iIdResultList );
-            }
-        else if ( mode == EQueryTypeEvent )
-            {
-            CMdEEventQueryImpl& qi = (CMdEEventQueryImpl&)iQuery;
-            qi.DoNotifyResultsL( iIdResultList );
+            case EQueryTypeObject:
+                {
+                CMdEObjectQueryImpl& qi = (CMdEObjectQueryImpl&)iQuery;
+                qi.DoNotifyResultsL( iIdResultList );
+                break;
+                }
+            case EQueryTypeRelation:
+                {
+                CMdERelationQueryImpl& qi = (CMdERelationQueryImpl&)iQuery;
+                qi.DoNotifyResultsL( iIdResultList );
+                break;
+                }
+            case EQueryTypeEvent:
+                {
+                CMdEEventQueryImpl& qi = (CMdEEventQueryImpl&)iQuery;
+                qi.DoNotifyResultsL( iIdResultList );
+                break;
+                }
+            default:
+                {
+                // Nothing to do
+                }
             }
 
         // get rid of local results list
@@ -323,20 +353,30 @@
         {
         const TQueryType mode = iQuery.Type();
         
-        if ( mode == EQueryTypeObject )
-            {
-            CMdEObjectQueryImpl& qi = (CMdEObjectQueryImpl&)iQuery;
-            qi.DoNotifyResults( iCountResult );
-            }
-        else if ( mode == EQueryTypeRelation )
+        switch( mode )
             {
-            CMdERelationQueryImpl& qi = (CMdERelationQueryImpl&)iQuery;
-            qi.DoNotifyResults( iCountResult );
-            }
-        else if ( mode == EQueryTypeEvent )
-            {
-            CMdEEventQueryImpl& qi = (CMdEEventQueryImpl&)iQuery;
-            qi.DoNotifyResults( iCountResult );
+            case EQueryTypeObject:
+                {
+                CMdEObjectQueryImpl& qi = (CMdEObjectQueryImpl&)iQuery;
+                qi.DoNotifyResults( iCountResult );
+                break;
+                }
+            case EQueryTypeRelation:
+                {
+                CMdERelationQueryImpl& qi = (CMdERelationQueryImpl&)iQuery;
+                qi.DoNotifyResults( iCountResult );
+                break;
+                }
+            case EQueryTypeEvent:
+                {
+                CMdEEventQueryImpl& qi = (CMdEEventQueryImpl&)iQuery;
+                qi.DoNotifyResults( iCountResult );
+                break;
+                }
+            default:
+                {
+                // Nothing to do
+                }
             }
         }
     else if ( ( aStatus == EAsyncFindSetReady ||
@@ -365,20 +405,30 @@
         
         const TQueryType mode = iQuery.Type();
 
-        if ( mode == EQueryTypeObject ) 
-            {
-            CMdEObjectQueryImpl& qi = (CMdEObjectQueryImpl&)iQuery;
-            qi.DoNotifyCompleted( code );
-            }
-        else if ( mode == EQueryTypeRelation )
+        switch( mode )
             {
-            CMdERelationQueryImpl& qi = (CMdERelationQueryImpl&)iQuery;
-            qi.DoNotifyCompleted( code );
-            }
-        else if ( mode == EQueryTypeEvent )
-            {
-            CMdEEventQueryImpl& qi = (CMdEEventQueryImpl&)iQuery;
-            qi.DoNotifyCompleted( code );
+            case EQueryTypeObject:
+                {
+                CMdEObjectQueryImpl& qi = (CMdEObjectQueryImpl&)iQuery;
+                qi.DoNotifyCompleted( code );
+                break;
+                }
+            case EQueryTypeRelation:
+                {
+                CMdERelationQueryImpl& qi = (CMdERelationQueryImpl&)iQuery;
+                qi.DoNotifyCompleted( code );
+                break;
+                }
+            case EQueryTypeEvent:
+                {
+                CMdEEventQueryImpl& qi = (CMdEEventQueryImpl&)iQuery;
+                qi.DoNotifyCompleted( code );
+                break;
+                }
+            default:
+                {
+                // Nothing to do
+                }
             }
         }
     
--- a/metadataengine/client/src/mdeobjectdef.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/client/src/mdeobjectdef.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -59,7 +59,8 @@
         {
 		aSchemaBuffer.PositionL( propertyOffset + i * sizeof(TMdCPropertyDef) );
 		const TMdCPropertyDef& propertyDef = TMdCPropertyDef::GetFromBufferL(aSchemaBuffer);
-		iPropertyDefs.AppendL( CMdEPropertyDef::NewL( propertyDef, aSchemaBuffer, *this ) );
+		CMdEPropertyDef* propertyDefImpl = CMdEPropertyDef::NewL( propertyDef, aSchemaBuffer, *this );
+		iPropertyDefs.InsertInOrder( propertyDefImpl, TLinearOrder<CMdEPropertyDef>(CMdEObjectDef::CompareProperties) );
         }
     }
 
@@ -129,7 +130,7 @@
 	}
 
 CMdEPropertyDef* CMdEObjectDef::GetPropertyDefL( const TDesC& aName, CMdEObjectDef* aChild )
-    {
+    {    
     const TInt propertyDefCount = iPropertyDefs.Count();
     for ( TInt i = 0; i < propertyDefCount; ++i )
         {
@@ -156,16 +157,11 @@
 
 CMdEPropertyDef* CMdEObjectDef::GetPropertyDefL(TDefId aId, CMdEObjectDef* aChild)
     {
-    const TInt count = iPropertyDefs.Count();
+    const TInt i = iPropertyDefs.FindInOrder(aId, CMdEObjectDef::CompareProperties );
     
-    for ( TInt i = 0; i < count; ++i )
+    if (i >= 0 && i < iPropertyDefs.Count() && iPropertyDefs[i] )
         {
-        CMdEPropertyDef* propDef = iPropertyDefs[i];
-        
-        if( propDef && propDef->Id() == aId )
-        	{
-        	return propDef;
-        	}
+        return iPropertyDefs[i];
         }
 
     CMdEObjectDef* parent = ParentL();
@@ -192,3 +188,14 @@
 
 	return iPropertyDefs[aIndex];
 	}
+
+TInt CMdEObjectDef::CompareProperties( const CMdEPropertyDef& aFirst, const CMdEPropertyDef& aSecond )
+    {
+    return aFirst.Id() - aSecond.Id();
+    }
+
+TInt CMdEObjectDef::CompareProperties( const TDefId* aFirst, const CMdEPropertyDef& aSecond )
+    {
+    return *aFirst - aSecond.Id();
+    }
+
--- a/metadataengine/client/src/mdesessionimpl.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/client/src/mdesessionimpl.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -222,6 +222,9 @@
 
 CMdESessionImpl::~CMdESessionImpl()
 	{
+    // No session errors should be sent during deconstruction to avoid possible double deletion
+    iSessionObserver = NULL;
+    
 	Close();
 
 	delete iSchemaBuffer;
@@ -450,7 +453,7 @@
 
 	CMdENamespaceDef& defaultNamespaceDef = GetDefaultNamespaceDefL();
 
-    TInt index = FindNotifier( ESchemaModify, &aObserver, defaultNamespaceDef );
+    const TInt index = FindNotifier( ESchemaModify, &aObserver, defaultNamespaceDef );
     if ( index != KErrNotFound )
         {
 	    iNotifiers[index]->Cancel();
@@ -1628,7 +1631,7 @@
 	CleanupStack::Pop( successfulBuffer );
 	CleanupClosePushL( dataBuffer );
     
-    TInt firstItemError = DeserializeIdsL( dataBuffer, NULL, NULL, 
+    const TInt firstItemError = DeserializeIdsL( dataBuffer, NULL, NULL, 
     		&aSuccessful );
     CleanupStack::PopAndDestroy( &dataBuffer ); // successfulBuffer, buffer
     CleanupStack::PopAndDestroy( buffer ); // successfulBuffer, buffer
@@ -2093,7 +2096,7 @@
 	CleanupClosePushL( dataBuffer );
 	
     iSession.DoRemoveItemsL( *buffer, *successfulBuffer );
-    TInt firstItemError = DeserializeIdsL( dataBuffer, NULL, 
+    const TInt firstItemError = DeserializeIdsL( dataBuffer, NULL, 
     		&aSuccessful );
 
     CleanupStack::PopAndDestroy( &dataBuffer );
@@ -2511,7 +2514,7 @@
     	namespaceDef = aNamespaceDef;
     	}
 
-    TInt index = FindNotifier( 
+    const TInt index = FindNotifier( 
     		EObjectNotifyAdd | EObjectNotifyModify | EObjectNotifyRemove,
     		&aObserver, *namespaceDef );
     if ( index != KErrNotFound )
@@ -2533,7 +2536,7 @@
 	// if namespace is not given get default namespace definition
     CMdENamespaceDef& namespaceDef = GetDefaultNamespaceDefL();
 
-    TInt index = FindNotifier( EObjectNotifyPresent | EObjectNotifyNotPresent,
+    const TInt index = FindNotifier( EObjectNotifyPresent | EObjectNotifyNotPresent,
     		&aObserver, namespaceDef );
     if ( index != KErrNotFound )
         {
@@ -2562,7 +2565,7 @@
     	namespaceDef = aNamespaceDef;
     	}
 
-    TInt index = FindNotifier( 
+    const TInt index = FindNotifier( 
     		ERelationNotifyAdd | ERelationNotifyModify | ERelationNotifyRemove,
     		&aObserver, *namespaceDef );
     if ( index != KErrNotFound )
@@ -2592,7 +2595,7 @@
     	namespaceDef = aNamespaceDef;
     	}
 
-    TInt index = FindNotifier( 
+    const TInt index = FindNotifier( 
     		/*ERelationItemNotifyAdd | ERelationItemNotifyModify |*/ 
     		ERelationItemNotifyRemove,
     		&aObserver, *namespaceDef );
@@ -2615,7 +2618,7 @@
 	// if namespace is not given get default namespace definition
     CMdENamespaceDef& namespaceDef = GetDefaultNamespaceDefL();
 
-    TInt index = FindNotifier( 
+    const TInt index = FindNotifier( 
     		ERelationNotifyPresent | ERelationNotifyNotPresent,
     		&aObserver, namespaceDef );
     if ( index != KErrNotFound )
@@ -2645,7 +2648,7 @@
     	namespaceDef = aNamespaceDef;
     	}
     
-    TInt index = FindNotifier( EEventNotifyAdd | EEventNotifyRemove,
+    const TInt index = FindNotifier( EEventNotifyAdd | EEventNotifyRemove,
     		&aObserver, *namespaceDef );
     if ( index != KErrNotFound )
         {
@@ -2676,7 +2679,7 @@
 
 void CMdESessionImpl::NotifierInError( CMdENotifierAO* aNotifier )
     {
-    TInt index = iNotifiers.Find( aNotifier );
+    const TInt index = iNotifiers.Find( aNotifier );
     delete aNotifier;
     iNotifiers.Remove( index );
     }
--- a/metadataengine/common/src/mdcitem.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/common/src/mdcitem.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -20,7 +20,7 @@
 //  TMdCObject
 ///////////////////
 
-EXPORT_C TMdCObject::TMdCObject() : TMdCItem( EMdCObject )
+EXPORT_C TMdCObject::TMdCObject() : TMdCItem( EMdCObject ), iFlags( 0 )
 	{
 	}
 
@@ -53,7 +53,8 @@
 //  TMdCRelation
 ///////////////////
 
-EXPORT_C TMdCRelation::TMdCRelation() : TMdCItem( EMdCRelation )
+EXPORT_C TMdCRelation::TMdCRelation() : TMdCItem( EMdCRelation ),
+        iLeftObjectId( 0 ), iRightObjectId( 0 )
 	{
 	}
 
--- a/metadataengine/server/group/mdsserver.mmp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/server/group/mdsserver.mmp	Tue Jan 26 12:13:20 2010 +0200
@@ -34,8 +34,8 @@
 CAPABILITY        CAP_SERVER AllFiles
 VENDORID        	VID_DEFAULT
 
-//MACRO             LOG_MASTER_FLAG
-MACRO             LOG_QUERY
+MACRO             LOG_MASTER_FLAG
+//MACRO             LOG_QUERY
 MACRO          	  LOG_DB
 // MACRO          LOG_MUTEX
 MACRO             LOG_SERVER
--- a/metadataengine/server/inc/mdslogger.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/server/inc/mdslogger.h	Tue Jan 26 12:13:20 2010 +0200
@@ -45,8 +45,8 @@
     ELogServer      = 0x0010, // client/server commands
     };
 
-
 #ifdef LOG_MASTER_FLAG
+#ifdef _DEBUG
 
 const TChar KNewLine = '\n';
 const TInt KLineLength = 80;
@@ -57,7 +57,9 @@
 _LIT(KFilename, "server.txt");
 _LIT(KAltFilename, "server2.txt");
 
+#ifdef LOG_QUERY
 #define MDE_FILE_LOGGING
+#endif
 
 // CLASS DECLARATION
 /**
@@ -164,11 +166,11 @@
     #define __LOG1(CATEGORY,A,B)        {if (gLogger->IsActive(CATEGORY)) { gLogger->Log().WriteFormat( _L(A), B ); gLogger->CheckSize( 1 ); }}
     #define __LOG2(CATEGORY,A,B,C)      {if (gLogger->IsActive(CATEGORY)) { gLogger->Log().WriteFormat( _L(A), B, C ); gLogger->CheckSize( 1 ); }}
     #define __LOG3(CATEGORY,A,B,C,D)    {if (gLogger->IsActive(CATEGORY)) { gLogger->Log().WriteFormat( _L(A), B, C, D ); gLogger->CheckSize( 1 ); }}
-#else
+#else // MDE_FILE_LOGGING
 	#define __LOG1(CATEGORY,A,B)        {if (gLogger->IsActive(CATEGORY)) { RDebug::Print( _L(A), B ); }}
 	#define __LOG2(CATEGORY,A,B,C)      {if (gLogger->IsActive(CATEGORY)) { RDebug::Print( _L(A), B, C ); }}
 	#define __LOG3(CATEGORY,A,B,C,D)    {if (gLogger->IsActive(CATEGORY)) { RDebug::Print( _L(A), B, C, D ); }}
-#endif
+#endif // MDE_FILE_LOGGING
 
 	#ifdef LOG_QUERY
 	    #define __LOGQUERY_16(INFO, BUFFER, ROWDATA) \
@@ -180,7 +182,23 @@
 	    #define __LOGQUERY_16(INFO, BUFFER, ROWDATA)
 	#endif //LOG_QUERY
 
-#else
+#else // _DEBUG
+
+#define __DEFINE_LOGGER 
+#define __USES_LOGGER
+#define __INIT_LOGGER
+#define __DESTROY_LOGGER
+#define __LOGLB(CATEGORY,A)
+#define __LOG(CATEGORY,A)
+#define __LOG1(CATEGORY,A,B)
+#define __LOG2(CATEGORY,A,B,C)
+#define __LOG3(CATEGORY,A,B,C,D)
+#define __LOGQUERY_16(INFO, BUFFER, ROWDATA)
+
+#endif // _DEBUG
+
+#else // LOG_MASTER_FLAG
+
     #define __DEFINE_LOGGER 
     #define __USES_LOGGER
     #define __INIT_LOGGER
@@ -191,7 +209,8 @@
     #define __LOG2(CATEGORY,A,B,C)
     #define __LOG3(CATEGORY,A,B,C,D)
 	#define __LOGQUERY_16(INFO, BUFFER, ROWDATA)
-#endif  // METADATA_LOG
+
+#endif  // LOG_MASTER_FLAG
 
 
 #endif  //__MDSLOGGER_H__
--- a/metadataengine/server/inc/mdsserver.h	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/server/inc/mdsserver.h	Tue Jan 26 12:13:20 2010 +0200
@@ -332,6 +332,8 @@
         CMDSShutdownObserver* iShutdownObserver;
         
         TBool iShutdown;
+        
+        RThread iClientThread;
     };
 
 #endif // __MDSSERVER_H__
--- a/metadataengine/server/src/mdsfindsequence.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/server/src/mdsfindsequence.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -125,8 +125,7 @@
  
     iFindOperation = CreateOperationL( aSerializedCriteria );
 
-    TInt result = KErrNone;
-    result = iFindOperation->ExecuteL();
+    const TInt result( iFindOperation->ExecuteL() );
     
     iFindResults = iFindOperation->Results();
     
@@ -152,7 +151,7 @@
 		iFindResults = NULL;
 		}
     
-    TInt result = iFindOperation->ContinueL();
+    const TInt result = iFindOperation->ContinueL();
 
     if ( result == KErrNone )
         {
@@ -328,7 +327,7 @@
         CleanUp();
         return;
         }
-    TInt state = iFindOperation->State();
+    const TInt state = iFindOperation->State();
     if ( state == CMdSSqlFindOperation::EStateIdle )
         {
         // loop is idle - safe to clean up.
--- a/metadataengine/server/src/mdsimportexport.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/server/src/mdsimportexport.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -19,6 +19,7 @@
 #include <charconv.h>
 #include <convgeneratedcpp.h>
 #include <badesca.h>
+#include <bautils.h>
 #include <e32math.h>
 #include <pathinfo.h>
 
@@ -963,6 +964,16 @@
 	iDefaultSchema = &aSchemaNew;
     iLineNumber = 0;
     iFailed = 0;
+    
+    CMdSSqLiteConnection& connection = MMdSDbConnectionPool::GetDefaultDBL();
+    RMdSTransaction transaction( connection );
+    CleanupClosePushL(transaction);
+    const TInt beginError( transaction.Error() );
+    if( beginError != KErrNone )
+        {
+        CleanupStack::PopAndDestroy( &transaction );
+        }
+    
     while( ReadMetadataFileLineL() )
         {
         if ( iLine.Length() > 0 )
@@ -978,6 +989,12 @@
 		else
         	iLastLineProcessed = ETrue;
         }
+    
+    if( beginError == KErrNone )
+        {
+        transaction.CommitL();
+        CleanupStack::PopAndDestroy( &transaction );
+        }
 
 	iDefaultSchema = NULL;
     CleanupStack::PopAndDestroy( &iReadStream ); // Closes stream.
@@ -1133,16 +1150,11 @@
 	    		beginUri.Compare( KColonBackslashMatch ) == 0 )
 	    	{
 			// check if uri exists
-	        RFileReadStream tmpFile;
-			TInt err = KErrNone;
-			err = tmpFile.Open( iFs, textValue, EFileRead | EFileShareAny );
-			tmpFile.Close();
-			if ( err != KErrNone )
+			if ( !BaflUtils::FileExists( iFs, textValue ) )
 				{
 				_LIT( KError, "uri is not real" );
-				validUri = EFalse;
 				LogError( KError );
-				error = err;
+				User::Leave( KErrNotFound );
 				}
 	    	}
 	    else
--- a/metadataengine/server/src/mdslogger.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/server/src/mdslogger.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -20,6 +20,7 @@
 
 
 #ifdef LOG_MASTER_FLAG
+#ifdef _DEBUG
 
 // ========================= MEMBER FUNCTIONS ==================================
 
@@ -149,9 +150,9 @@
 // CheckSize
 // ------------------------------------------------
 //
+#ifdef MDE_FILE_LOGGING
 void CMdSLogger::CheckSize( TInt aLines )
     {
-#ifdef MDE_FILE_LOGGING
     iLineCounter += aLines;
     if ( iLineCounter < KLogfileMaxLength ) return; // no worries
 
@@ -170,10 +171,13 @@
         iAltFileFlag = EFalse;        
         }    
     iLog.SetDateAndTime(EFalse, ETrue);
+    }
 #else
-    aLines = 0;
+void CMdSLogger::CheckSize( TInt /*aLines*/ )
+    {
+    // Nothing to check
+    }
 #endif
-    }
 
 // ---------------------------------------------------------------------------
 // DescribeL                Returns sql clause with variables
@@ -331,4 +335,6 @@
         }
     }
 
+#endif // _DEBUG
 #endif // LOG_MASTER_FLAG
+
--- a/metadataengine/server/src/mdsnotifier.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/server/src/mdsnotifier.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -108,7 +108,7 @@
 	TUint32 aCompleteCode,
     const RArray<TItemId>& aIdArray )
     {
-    TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
+    const TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
     iRemoteSizeMsgSlot = KErrNotFound;
 
     __ASSERT_DEBUG( !iDataBuffer, MMdCCommon::Panic( KErrCorrupt ) );
@@ -137,7 +137,7 @@
 	CMdCSerializationBuffer& aBuffer,
 	const RArray<TItemId>& aRelationIdArray)
     {
-    TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
+    const TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
     iRemoteSizeMsgSlot = KErrNotFound;
 
     __ASSERT_DEBUG( !iDataBuffer, MMdCCommon::Panic( KErrCorrupt ) );
@@ -303,7 +303,7 @@
 void CMdSNotifier::TEntry::TriggerCachedL(TUint32 aCompleteCode, 
 		CMdCSerializationBuffer* aData)
     {
-    TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
+    const TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
     iRemoteSizeMsgSlot = KErrNotFound;
 
     __ASSERT_DEBUG( !iDataBuffer, MMdCCommon::Panic( KErrCorrupt ) );
@@ -596,7 +596,7 @@
 	            	if(e.IsPending())
 	            		{
 		            	// Match found. Trigger notifier entry.
-		            	TInt err;
+		            	TInt err( KErrNone );
 		            	
 		            	if( allMatches )
 		            		{
--- a/metadataengine/server/src/mdsserver.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/server/src/mdsserver.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -15,6 +15,7 @@
 */
 
 // INCLUDE FILES
+#include <f32file.h>
 #include "mdsserver.h"
 #include "mdscommoninternal.h"
 #include "mdsserversession.h"
@@ -30,7 +31,6 @@
 #include "mdebackuprestorewatcher.h"
 #include "mdsschema.h"
 #include "mdcserializationbuffer.h"
-#include <f32file.h>
 
 __DEFINE_LOGGER
 
@@ -289,7 +289,7 @@
 	variables.AppendL( TColumn( KMemoryCardLimit ) );
 	variables.AppendL( TColumn( KObjectCleanupLimit ) );
 	
-	TInt rowCount = iDefaultDBConnection->ExecuteL( clause->ConstBufferL(), variables );
+	const TInt rowCount = iDefaultDBConnection->ExecuteL( clause->ConstBufferL(), variables );
 
 	CleanupStack::PopAndDestroy( 2, clause ); // variables, clause
 	}
@@ -408,8 +408,8 @@
 
 CMdSServer::~CMdSServer()
     {
-    
     iShutdown = ETrue;
+    iClientThread.Close();
     
 	delete iBURWatcher;
 	delete iDiskSpaceGarbageCollectorNotifier;
@@ -544,7 +544,7 @@
 	// if there happens to be old chunk, close it
 	iHarvestingPrioritizationChunk.Close();
 
-	TInt error = iHarvestingPrioritizationChunk.Open( aMessage, aParam, EFalse );
+	const TInt error = iHarvestingPrioritizationChunk.Open( aMessage, aParam, EFalse );
 
 	if( error != KErrNone )
 		{
@@ -573,7 +573,9 @@
 		{
 		iHarvestingPrioritizationLocked = EFalse;
 
+		iClientThread.Close();
 		iHarvestingPrioritizationObserver = aMessage;
+		iHarvestingPrioritizationObserver.Client( iClientThread );
 
 		// reserve space for harvesting prioritization URI count
 		iHarvestingPrioritizationLimit = CMdCSerializationBuffer::KRequiredSizeForTInt32;
@@ -583,15 +585,14 @@
 		}
 	else
 	    {
-        RThread clientThread;
-        iHarvestingPrioritizationObserver.Client( clientThread );
-        TExitType exitType = clientThread.ExitType();
-        clientThread.Close();
+        TExitType exitType = iClientThread.ExitType();
         if( EExitPending != exitType )
             {
             iHarvestingPrioritizationLocked = EFalse;
 
+            iClientThread.Close();
             iHarvestingPrioritizationObserver = aMessage;
+            iHarvestingPrioritizationObserver.Client( iClientThread );
 
             // reserve space for harvesting prioritization URI count
             iHarvestingPrioritizationLimit = CMdCSerializationBuffer::KRequiredSizeForTInt32;
@@ -707,14 +708,11 @@
 	{
 	if( !iHarvestingPrioritizationObserver.IsNull() )
 		{
-	    RThread clientThread;
-	    iHarvestingPrioritizationObserver.Client( clientThread );
-	    TExitType exitType = clientThread.ExitType();
+	    TExitType exitType = iClientThread.ExitType();
 	    if( EExitPending == exitType )
 	        {
 	        iHarvestingPrioritizationObserver.Complete( aStatus );
 	        }
-	    clientThread.Close();
 		}
 	}
 
@@ -853,7 +851,6 @@
     CleanupClosePushL( fs );
     
     RFileReadStream tmpFile;
-    TInt err( KErrNone );
     TBuf<KMaxFileName> privatePath;
     TBuf<KMaxFileName> schema;
     TBuf<KMaxFileName> defaultImportProfile;
@@ -872,8 +869,8 @@
     
     CFileMan* fileMan = CFileMan::NewL( fs );
     CleanupStack::PushL( fileMan);
-            
-    err = tmpFile.Open( fs, schema, EFileRead | EFileShareAny );
+    
+    TInt err = tmpFile.Open( fs, schema, EFileRead | EFileShareAny );
     __LOG1( ELogAlways, "open schema.mde %d", err );
     tmpFile.Close();
     if ( err != KErrNone )
--- a/metadataengine/server/src/mdsserversession.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/server/src/mdsserversession.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -552,7 +552,7 @@
 	// check that all queries are complete
 	QueriesCompleteL();
 
-    TInt serializedCriteriaLength = aMsg.GetDesLength( EFindArgConditions );
+    const TInt serializedCriteriaLength = aMsg.GetDesLength( EFindArgConditions );
 	CMdCSerializationBuffer* serializedCriteriaBuffer = CMdCSerializationBuffer::NewLC( serializedCriteriaLength );
 	TPtr8 serializedCriteriaBufferPtr(serializedCriteriaBuffer->Buffer());
 	aMsg.ReadL( EFindArgConditions, serializedCriteriaBufferPtr );
@@ -592,7 +592,7 @@
     // check that all queries are complete
     QueriesCompleteL();
 
-    TInt serializedCriteriaLength = aMsg.GetDesLength( EFindArgConditions );
+    const TInt serializedCriteriaLength = aMsg.GetDesLength( EFindArgConditions );
 	CMdCSerializationBuffer* serializedCriteriaBuffer = CMdCSerializationBuffer::NewLC( serializedCriteriaLength );
 	TPtr8 serializedCriteriaBufferPtr(serializedCriteriaBuffer->Buffer());
 	aMsg.ReadL( EFindArgConditions, serializedCriteriaBufferPtr );
@@ -907,7 +907,7 @@
 //
 void CMdSServerSession::UpdateL( const RMessage2& aMsg )
     {
-    TInt successfulLength = aMsg.GetDesLengthL( 1 );
+    const TInt successfulLength = aMsg.GetDesLengthL( 1 );
     
     CMdCSerializationBuffer* buffer = CMdCSerializationBuffer::NewLC( aMsg, 0 );
     CMdCSerializationBuffer* successfullBuffer = CMdCSerializationBuffer::NewLC( successfulLength );
@@ -926,7 +926,7 @@
     __LOG3( ELogServer, "-> Register %u for NS: %u Type: %d",
         (TUint32)aMsg.Int0(), (TDefId)aMsg.Int3(), aMsg.Int1() );
 
-    TInt length = aMsg.GetDesLength( 2 );
+    const TInt length = aMsg.GetDesLength( 2 );
 	CMdCSerializationBuffer* buffer = CMdCSerializationBuffer::NewLC( length );
 	TPtr8 bufferPtr( buffer->Buffer() );
 	aMsg.ReadL( 2, bufferPtr );
@@ -982,7 +982,7 @@
 void CMdSServerSession::UnregisterL( const RMessage2& aMsg )
     {
     __LOG1( ELogServer, "-> Unregister %d", aMsg.Int0() );
-    TInt id = aMsg.Int0();
+    const TInt id = aMsg.Int0();
     iServer.Notifier().RemoveEntryL(id);
 	TInt count = iNotificationCache.Count();
 	for(TInt i(count - 1); i >= 0; --i)
Binary file sis/mds/mds_stub.sis has changed
--- a/sis/mds/package.pkg	Mon Jan 18 20:34:07 2010 +0200
+++ b/sis/mds/package.pkg	Tue Jan 26 12:13:20 2010 +0200
@@ -17,7 +17,7 @@
 &EN
 
 ;packet-header (name, uid, major, minor, build, type)
-#{"Metadata System Upgrade"},(0x200009F5), 9, 20, 0, TYPE=SA, RU
+#{"Metadata System Upgrade"},(0x200009F5), 9, 20, 1, TYPE=SA, RU
 
 ; Localised vendor name
 %{"Nokia"}
--- a/sis/mds/package_separate.pkg	Mon Jan 18 20:34:07 2010 +0200
+++ b/sis/mds/package_separate.pkg	Tue Jan 26 12:13:20 2010 +0200
@@ -17,7 +17,7 @@
 &EN
 
 ;packet-header (name, uid, major, minor, build, type)
-#{"Metadata System Upgrade"},(0x200009F5), 9, 20, 0, TYPE=SA, RU
+#{"Metadata System Upgrade"},(0x200009F5), 9, 20, 1, TYPE=SA, RU
 
 ; Localised vendor name
 %{"Nokia"}
--- a/sis/mds/stub.pkg	Mon Jan 18 20:34:07 2010 +0200
+++ b/sis/mds/stub.pkg	Tue Jan 26 12:13:20 2010 +0200
@@ -17,7 +17,7 @@
 &EN
 
 ; Header
-#{"Metadata System"}, (0x200009F5), 9, 20, 0, TYPE=SA
+#{"Metadata System"}, (0x200009F5), 9, 20, 1, TYPE=SA
 
 ; Localised Vendor name
 %{"Nokia"}