201033
authorhgs
Mon, 23 Aug 2010 13:33:21 +0300
changeset 48 1389872e7c51
parent 43 c5e73110f733
child 51 87e65c44ff3a
201033
harvester/blacklistserver/src/blacklistsession.cpp
harvester/client/eabi/harvesterclientarm.def
harvester/client/group/harvesterclient.mmp
harvester/client/inc/harvesterclientao.h
harvester/client/inc/harvesternotificationqueue.h
harvester/client/inc/harvesterrequestactive.h
harvester/client/src/harvesterclient.cpp
harvester/client/src/harvesterclientao.cpp
harvester/client/src/harvesternotificationqueue.cpp
harvester/client/src/harvesterrequestactive.cpp
harvester/client/src/harvestersessionwatcher.cpp
harvester/client/traces/fixed_id.definitions
harvester/client/traces/harvesterclientaoTraces.h
harvester/common/bwincw/harvesterplugininterfacewinscw.def
harvester/common/eabi/harvesterplugininterfacearm.def
harvester/common/inc/harvestercommon.h
harvester/common/inc/harvesterpluginfactory.h
harvester/common/src/harvesterexifutil.cpp
harvester/common/src/harvesterplugin.cpp
harvester/common/src/harvesterpluginfactory.cpp
harvester/common/src/mdeobjectwrapper.cpp
harvester/composerplugins/imagecomposer/src/imagecomposerao.cpp
harvester/composerplugins/imagecomposer/src/imagepresentobserver.cpp
harvester/data/default_origin_mappings.db
harvester/harvesterplugins/OMADRMPlugin/src/harvesteromadrmplugin.cpp
harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp
harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp
harvester/monitorplugins/fileplugin/src/processoriginmapper.cpp
harvester/monitorplugins/inc/mdsfileserverpluginclient.h
harvester/monitorplugins/mdsfileserverplugin/src/mdsfileserverplugin.cpp
harvester/monitorplugins/mmcplugin/inc/mmcmounttaskao.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/monitorplugins/mmcplugin/src/mmcusbao.cpp
harvester/server/inc/harvesterao.h
harvester/server/src/harvesterao.cpp
harvester/server/src/harvesterqueue.cpp
harvester/server/src/harvesterserver.cpp
harvester/server/src/ondemandao.cpp
harvester/server/src/reharvesterao.cpp
inc/mdcdef.h
inc/mdscommoninternal.h
locationmanager/ReverseGeoCoderPlugin/src/reversegeocoderplugin.cpp
locationmanager/ReverseGeocode/inc/clientengine.h
locationmanager/ReverseGeocode/inc/internalreversegeocode.h
locationmanager/ReverseGeocode/inc/xmlhandler.h
locationmanager/ReverseGeocode/src/clientengine.cpp
locationmanager/ReverseGeocode/src/internalreversegeocode.cpp
locationmanager/ReverseGeocode/src/xmlhandler.cpp
locationmanager/geoconverter/inc/cgeoconverter.h
locationmanager/geoconverter/src/cgeoconverter.cpp
locationmanager/geotagger/src/cinternalgeotagger.cpp
locationmanager/locationtrail/src/clocationrecord.cpp
mds_plat/harvester_framework_api/inc/harvesterclient.h
mds_plat/harvester_framework_api/inc/harvesterplugin.h
metadataengine/client/src/mdeharvestersession.cpp
metadataengine/server/inc/mdssqldbmaintenance.h
metadataengine/server/src/mdsfindsequence.cpp
metadataengine/server/src/mdsmaintenanceengine.cpp
metadataengine/server/src/mdsmanipulationengine.cpp
metadataengine/server/src/mdsnotifycomparator.cpp
metadataengine/server/src/mdssqldbmaintenance.cpp
metadataengine/server/src/mdssqlobjectmanipulate.cpp
rom/mds_cellid_reverse_geocode_enabled.iby
rom/mds_reverse_geocode_enabled_only.iby
--- a/harvester/blacklistserver/src/blacklistsession.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/blacklistserver/src/blacklistsession.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -118,7 +118,7 @@
     aMessage.ReadL( 0, mediaIdPckg );
  
  	RBuf uri;
-    uri.Create( aMessage.GetDesLength( 1 ) );
+ 	User::LeaveIfError( uri.Create( aMessage.GetDesLength( 1 ) ) );
     CleanupClosePushL( uri );
     aMessage.ReadL( 1, uri );
    	
--- a/harvester/client/eabi/harvesterclientarm.def	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/client/eabi/harvesterclientarm.def	Mon Aug 23 13:33:21 2010 +0300
@@ -20,6 +20,4 @@
 	_ZTV22CHarvesterRequestQueue @ 19 NONAME ; #<VT>#
 	_ZN16RHarvesterClient19AddSessionObserverLER25MHarvesterSessionObserver @ 20 NONAME
 	_ZN16RHarvesterClient21RemoveSessionObserverEv @ 21 NONAME
-	_ZTI27CHarvesterNotificationQueue @ 22 NONAME
-	_ZTV27CHarvesterNotificationQueue @ 23 NONAME
 
--- a/harvester/client/group/harvesterclient.mmp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/client/group/harvesterclient.mmp	Mon Aug 23 13:33:21 2010 +0300
@@ -46,7 +46,6 @@
 SOURCE		      harvestereventobserverao.cpp 
 SOURCE            harvesterrequestactive.cpp
 SOURCE            harvesterrequestqueue.cpp
-SOURCE            harvesternotificationqueue.cpp
 
 MW_LAYER_SYSTEMINCLUDE
 
--- a/harvester/client/inc/harvesterclientao.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/client/inc/harvesterclientao.h	Mon Aug 23 13:33:21 2010 +0300
@@ -25,14 +25,16 @@
 
 #include "harvesterclient.h"
 
+class RHarvesterClient;
+class MHarvestObserver;
+
 NONSHARABLE_CLASS( CHarvesterClientAO ) : public CActive
     {
     public:
         /**
         * Construction.
         */
-        static CHarvesterClientAO* NewL( RHarvesterClient& aHarvesterClient,
-                                                            CHarvesterNotificationQueue* aNotificationQueue );
+        static CHarvesterClientAO* NewL( RHarvesterClient &aHarvesterClient );
 
         /**
         * Destruction.
@@ -44,14 +46,22 @@
         * @param aObserver  Pointer to observer object.
         */
         void SetObserver( MHarvestObserver* aObserver );
+
+        /**
+        * Method for removing an observer.
+        * @param aObserver  Pointer to observer object.
+        */		
+        void RemoveObserver( MHarvestObserver* aObserver );
+        
+        void NotificateObserver( TInt aErr );
         
         /**
          * Set AO to active state. RunL is launched from harvesting complete
          * request which are subscribed from server.
          */ 
-        void Active( TDesC& aUri );
+        void Active();
         
-        TBool RequestComplete();
+        void CancelRequest();
         
     protected:
 		
@@ -80,8 +90,7 @@
         * 
         * @param aHarvesterClient Reference to session class
         */	
-        CHarvesterClientAO( RHarvesterClient& aHarvesterClient,
-                                           CHarvesterNotificationQueue* aNotificationQueue );
+        CHarvesterClientAO( RHarvesterClient &aHarvesterClient );
 
         /**
         * 2nd phase construction
@@ -97,20 +106,15 @@
 
         /**
         * Reference to Harvester client session
-        */      
+        */   	
         RHarvesterClient& iHarvesterClient;
-        
-        /**
-        * Pointer to harvest notification request queue, not owned
-        */   	
-        CHarvesterNotificationQueue* iNotificationQueue;
 
         /**
          * Harvester server assigned file name
          */ 
-        HBufC* iURI;
+        TFileName iURI;
         
-        TBool iRequestComplete;
+        TBool iCancelled;
     };
 
 #endif // __CHARVESTERCLIENTAO_H__
--- a/harvester/client/inc/harvesternotificationqueue.h	Fri Aug 06 09:56:02 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
-* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Processor object for running harvester requests
-*
-*/
-
-
-#ifndef HARVESTERNOTIFICATIONQUEUE_H
-#define HARVESTERNOTIFICATIONQUEUE_H
-
-#include <e32base.h>
-
-class CHarvesterClientAO;
-class MHarvestObserver;
-
-/**
- *  Processor object for running queued tasks.
- *
- */
-class CHarvesterNotificationQueue: public CBase
-    {
-public:
-
-    /**
-     * Two-phased constructor.
-     *
-     * @return Instance of CHarvesterNotificationQueue.
-     */
-    static CHarvesterNotificationQueue* NewL();
-
-    /**
-     * Destructor
-     *
-     */
-    virtual ~CHarvesterNotificationQueue();
-    
-    /**
-     * Adds new request to the queue.
-     *
-     * @param aRequest Request to be added to the queue.
-     */
-    void AddRequestL( CHarvesterClientAO* aRequest );
-    
-    /**
-     * Marks request completed.
-     */
-    void Cleanup( TBool aShutdown );
-    
-    void SetObserver( MHarvestObserver* aObserver );
-    
-private:
-
-    /**
-     * C++ default constructor
-     * @return Instance of CHarvesterNotificationQueue.
-     */
-    CHarvesterNotificationQueue();
-
-    /**
-     * Symbian 2nd phase constructor can leave.
-     */
-    void ConstructL();
-
-private:
-
-    /**
-     * Array of active objects for each pending harvester request.
-     */
-    RPointerArray <CHarvesterClientAO> iRequests;
-
-};
-
-#endif // HARVESTERNOTIFICATIONQUEUE_H
--- a/harvester/client/inc/harvesterrequestactive.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/client/inc/harvesterrequestactive.h	Mon Aug 23 13:33:21 2010 +0300
@@ -58,7 +58,7 @@
      * @return New CHarvesterRequestActive object.
      */
     static CHarvesterRequestActive* NewL( 
-            RHarvesterClient& aClient,
+            RHarvesterClient& aClient, MHarvestObserver* aObserver,
             TInt aService, const TDesC& aUri, 
             HBufC8* aAlbumIds, TBool aAddLocation,
             CHarvesterRequestQueue* aQueue );
@@ -103,7 +103,7 @@
      * @return New CHarvesterRequestActive object.
      */
     CHarvesterRequestActive( RHarvesterClient& aClient,
-            TInt aService, const TDesC& aUri, 
+            MHarvestObserver* aObserver, TInt aService, const TDesC& aUri, 
             HBufC8* aAlbumIds, TBool aAddLocation,
             CHarvesterRequestQueue* aQueue );
 
@@ -141,6 +141,11 @@
      */
     RHarvesterClient iClient;
 
+    /**
+     * Observer to receive notifications about completed operations. Not owned.
+     */
+    MHarvestObserver* iObserver;
+    
     TInt iService;
     
     /**
--- a/harvester/client/src/harvesterclient.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/client/src/harvesterclient.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -19,7 +19,6 @@
 #include "harvesterclient.h"
 #include "harvestercommon.h"
 #include "harvesterrequestqueue.h"
-#include "harvesternotificationqueue.h"
 #include "harvestereventobserverao.h"
 #include "harvesterlog.h"
 #include "harvesterclientao.h"
@@ -58,7 +57,8 @@
     iObserver = NULL;
     iHEO = NULL;
     iRequestQueue = NULL;
-    iNotificationQueue = NULL;
+    iHarvesterClientAO = NULL;
+    iSessionWatcher = NULL;
     }
 
 // ----------------------------------------------------------------------------------------
@@ -81,29 +81,26 @@
         return KErrLocked;
         }
     
-    if( iRequestQueue )
+    if( iHarvesterClientAO )
     	{
     	return KErrAlreadyExists;
     	}
     
+    TRAPD( err, iHarvesterClientAO = CHarvesterClientAO::NewL(*this) );
+    if ( err != KErrNone )
+        {
+        WRITELOG( "RHarvesterClient::RHarvesterClient() - Couldn't create active object" );
+        return err;
+        }
+    
     // request processor
-    TRAPD( err, iRequestQueue = CHarvesterRequestQueue::NewL() )
+    TRAP( err, iRequestQueue = CHarvesterRequestQueue::NewL() )
         {
         if ( err != KErrNone )
             {
             WRITELOG( "RHarvesterClient::RHarvesterClient() - Couldn't create harvester request queue" );
-            return err;
-            }
-        }
-
-    // request processor
-    TRAP( err, iNotificationQueue = CHarvesterNotificationQueue::NewL() )
-        {
-        if ( err != KErrNone )
-            {
-            WRITELOG( "RHarvesterClient::RHarvesterClient() - Couldn't create harvester notification queue" );
-            delete iRequestQueue;
-            iRequestQueue = NULL;
+            delete iHarvesterClientAO;
+            iHarvesterClientAO = NULL;
             return err;
             }
         }
@@ -117,28 +114,29 @@
         }
     else
         {
+        WRITELOG1( "RHarvesterClient::Connect() - Server is not running or could not be started, error &d", err );
         delete iRequestQueue;
         iRequestQueue = NULL;
-        delete iNotificationQueue;
-        iNotificationQueue = NULL;
+        delete iHarvesterClientAO;
+        iHarvesterClientAO = NULL;
+        return err;
         }
 
-#ifdef _DEBUG
-    if ( err != KErrNone )
+    if( err != KErrNone )
         {
-        WRITELOG1( "RHarvesterClient::Connect() - Server is not running or could not be started, error &d", err );
+        WRITELOG1( "RHarvesterClient::Connect() - Session creation failed, error &d", err );
+        delete iRequestQueue;
+        iRequestQueue = NULL;
+        delete iHarvesterClientAO;
+        iHarvesterClientAO = NULL;    
         }
-    else
-        {
-        WRITELOG( "RHarvesterClient::Connect() - no errors" );
-        }
-    WRITELOG( "RHarvesterClient::Connect() - end" );
-#endif
-
+    
     iHEO = NULL;
     
     iSessionWatcher = NULL;
     
+    WRITELOG( "RHarvesterClient::Connect() - end" );
+    
     return err;
     }
 
@@ -186,25 +184,40 @@
     delete iSessionWatcher;
     iSessionWatcher = NULL;
     
-    // cancels Harvest Complete request if it exist at server
+    WRITELOG( "RHarvesterClient::Close() - cancelling pending harvesting requests" );
+    if( iRequestQueue && iRequestQueue->RequestsPending() )
+        {
+        iRequestQueue->Cancel();
+        }
+    
+    WRITELOG( "RHarvesterClient::Close() - removing harvester client observer" );
+    if( iObserver )
+        {
+        RemoveObserver( iObserver );
+        }
     UnregisterHarvestComplete();
-    delete iNotificationQueue;
-    iNotificationQueue = NULL;
     
     WRITELOG( "RHarvesterClient::Close() - UnregisterHarvest done" );
     
+    WRITELOG( "RHarvesterClient::Close() - forcing remaining harvesting requests" );
     if( iRequestQueue && iRequestQueue->RequestsPending() )
         {
-        iRequestQueue->Cancel();
+        WRITELOG( "RHarvesterClient::Close() - Pending harvesting requests detected -> ForceHarvest" );
         iRequestQueue->ForceRequests();
         }
     
+    WRITELOG( "RHarvesterClient::Close() - ForceHarvest done" );
+    
     delete iRequestQueue;
     iRequestQueue = NULL;
     
     delete iHEO;
     iHEO = NULL;
     
+    WRITELOG( "RHarvesterClient::Close() - deleting harvester client AO" );
+    delete iHarvesterClientAO;
+    iHarvesterClientAO = NULL;
+    
     WRITELOG( "RHarvesterClient::Close() - Closing session" );
     
     RSessionBase::Close();
@@ -219,8 +232,11 @@
     WRITELOG( "RHarvesterClient::SetObserver()" );
     OstTrace0( TRACE_NORMAL, RHARVESTERCLIENT_SETOBSERVER, "RHarvesterClient::SetObserver" );
 
+    if ( iHarvesterClientAO )
+        {
+       iHarvesterClientAO->SetObserver( aObserver );
+       }
 	iObserver = aObserver;
-	iNotificationQueue->SetObserver( iObserver );
     }
 
 // ----------------------------------------------------------------------------------------
@@ -232,11 +248,17 @@
     WRITELOG( "RHarvesterClient::RemoveObserver()" );
     OstTrace0( TRACE_NORMAL, RHARVESTERCLIENT_REMOVEOBSERVER, "RHarvesterClient::RemoveObserver" );
     
-	if ( aObserver == iObserver )
+	if ( aObserver == iObserver && iObserver )
 		{
 		WRITELOG( "RHarvesterClient::RemoveObserver() - deleting observer" );
+		
+	    if ( iHarvesterClientAO )
+	        {
+	        WRITELOG( "RHarvesterClient::RemoveObserver() - calling iHarvesterClientAO->RemoveObserver" );
+	        iHarvesterClientAO->RemoveObserver( aObserver );
+	        }
+		
 		iObserver = NULL;
-		iNotificationQueue->SetObserver( iObserver );
 		}
     }
 
@@ -305,7 +327,7 @@
     	}
         
     CHarvesterRequestActive* harvestFileActive( NULL );
-    TRAP( err, harvestFileActive = CHarvesterRequestActive::NewL( *this, (TInt)EHarvestFile, aURI, 
+    TRAP( err, harvestFileActive = CHarvesterRequestActive::NewL( *this, iObserver, (TInt)EHarvestFile, aURI, 
                                                                                                    paramBuf, aAddLocation, iRequestQueue ) );
     if( err )
         {
@@ -382,7 +404,7 @@
         }
 
     CHarvesterRequestActive* harvestFileActive( NULL );
-    TRAP( err, harvestFileActive = CHarvesterRequestActive::NewL( *this, (TInt)EHarvestFile, aURI, 
+    TRAP( err, harvestFileActive = CHarvesterRequestActive::NewL( *this, iObserver, (TInt)EHarvestFile, aURI, 
                                                                                                    paramBuf, aAddLocation, iRequestQueue ) );
     if( err )
         {
@@ -463,7 +485,7 @@
 // ----------------------------------------------------------------------------------------
 //
 void RHarvesterClient::RegisterHarvestComplete(TDes& aURI, TRequestStatus& aStatus)
-	{	
+	{
 	TIpcArgs ipcArgs( &aURI );
 	OstTrace0( TRACE_NORMAL, RHARVESTERCLIENT_REGISTERHARVESTCOMPLETE, "RHarvesterClient::RegisterHarvestComplete" );
 	
@@ -493,35 +515,12 @@
 // HarvestFile
 // ----------------------------------------------------------------------------------------
 //
-void RHarvesterClient::HarvestFile( TInt& aService, TIpcArgs& aArgs, TRequestStatus& aStatus, TDesC& aUri )
+void RHarvesterClient::HarvestFile( TInt& aService, TIpcArgs& aArgs, TRequestStatus& aStatus )
     {
     // send to server harvesting complete observer
-    if( iObserver )
+    if( iObserver && iHarvesterClientAO )
         {
-        CHarvesterClientAO* harvestNotificationRequest( NULL );
-        TRAPD( err, harvestNotificationRequest = CHarvesterClientAO::NewL(*this, iNotificationQueue ) );
-        if( err )
-            {
-            WRITELOG1( "RHarvesterClient::HarvestFile() - cannot issue harvesting notitification request, error: %d", err );
-            iObserver->HarvestingComplete( const_cast<TDesC&>(aUri), KErrCompletion );  
-            delete harvestNotificationRequest;
-            harvestNotificationRequest = NULL;
-            }
-        else
-            {
-            TRAP( err, iNotificationQueue->AddRequestL( harvestNotificationRequest ) );
-            if( err )
-                {
-                iObserver->HarvestingComplete( const_cast<TDesC&>(aUri), KErrCompletion );  
-                delete harvestNotificationRequest;
-                harvestNotificationRequest = NULL;            
-                }
-            else
-                {
-                harvestNotificationRequest->SetObserver( iObserver );
-                harvestNotificationRequest->Active( aUri );
-                }
-            }
+        iHarvesterClientAO->Active();
         }
     SendReceive( aService, aArgs, aStatus );
     }
--- a/harvester/client/src/harvesterclientao.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/client/src/harvesterclientao.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -17,7 +17,6 @@
 
 
 #include "harvesterclientao.h"
-#include "harvesternotificationqueue.h"
 #include "harvestercommon.h"
 #include "harvesterlog.h"
 #include "mdsutils.h"
@@ -31,13 +30,12 @@
 // NewL
 // ---------------------------------------------------------------------------
 //
-CHarvesterClientAO* CHarvesterClientAO::NewL( RHarvesterClient& aHarvesterClient, 
-        CHarvesterNotificationQueue* aNotificationQueue )
+CHarvesterClientAO* CHarvesterClientAO::NewL( RHarvesterClient& aHarvesterClient )
 	{
     WRITELOG( "CHarvesterClientAO::NewL()" );
     OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_NEWL, "CHarvesterClientAO::NewL" );
     
-	CHarvesterClientAO* self = new (ELeave) CHarvesterClientAO( aHarvesterClient, aNotificationQueue );
+	CHarvesterClientAO* self = new (ELeave) CHarvesterClientAO( aHarvesterClient );
 	CleanupStack::PushL( self );
 	self->ConstructL();
 	CleanupStack::Pop( self );
@@ -53,10 +51,7 @@
     OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_CHARVESTERCLIENTAO, "CHarvesterClientAO::~CHarvesterClientAO" );
     
     WRITELOG( "CHarvesterClientAO::~CHarvesterClientAO()" );
-    Cancel();
-    
-    delete iURI;
-    iURI = NULL;
+    CancelRequest();
  	}
 
 // ---------------------------------------------------------------------------
@@ -64,14 +59,11 @@
 // First-phase C++ constructor
 // ---------------------------------------------------------------------------
 //
-CHarvesterClientAO::CHarvesterClientAO( RHarvesterClient& aHarvesterClient, 
-        CHarvesterNotificationQueue* aNotificationQueue )
-    : CActive( CActive::EPriorityStandard ), 
+CHarvesterClientAO::CHarvesterClientAO( RHarvesterClient& aHarvesterClient )
+    : CActive( CActive::EPriorityUserInput ), 
     iObserver( NULL ),
     iHarvesterClient( aHarvesterClient ),
-    iNotificationQueue( aNotificationQueue ),
-    iURI( NULL ),
-    iRequestComplete( EFalse )
+    iCancelled( EFalse )
   	{
     OstTrace0( TRACE_NORMAL, DUP1_CHARVESTERCLIENTAO_CHARVESTERCLIENTAO, "CHarvesterClientAO::CHarvesterClientAO" );
     
@@ -103,6 +95,23 @@
 	}
 
 // ---------------------------------------------------------------------------
+// RemoveObserver
+// ---------------------------------------------------------------------------
+//	
+void CHarvesterClientAO::RemoveObserver( MHarvestObserver* /*aObserver*/ )
+	{
+	WRITELOG( "CHarvesterClientAO::RemoveObserver()" );
+	OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_REMOVEOBSERVER, "CHarvesterClientAO::RemoveObserver" );
+    if ( iObserver )
+        {
+        WRITELOG( "CHarvesterClientAO::RemoveObserver() - deleting observer" );
+        iObserver = NULL;
+        }
+    
+    CancelRequest();
+	}
+
+// ---------------------------------------------------------------------------
 // DoCancel
 // ---------------------------------------------------------------------------
 //
@@ -110,33 +119,24 @@
 	{
 	WRITELOG( "CHarvesterClientAO::DoCancel()" );
 	OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_DOCANCEL, "CHarvesterClientAO::DoCancel" );
-	iRequestComplete = ETrue;
+	iHarvesterClient.UnregisterHarvestComplete();
+	WRITELOG( "CHarvesterClientAO::DoCancel() - end" );
 	}
 	
 // ---------------------------------------------------------------------------
 // Active
 // ---------------------------------------------------------------------------
 //
-void CHarvesterClientAO::Active( TDesC& aUri )
+void CHarvesterClientAO::Active()
 	{	
-    WRITELOG( "CHarvesterClientAO::Active()");
-    if( iObserver && !IsActive() )
-        {
-        delete iURI;
-        iURI = NULL;
-        iURI = aUri.Alloc();
-        if( iURI )
-            {
-            TPtr16 uri( iURI->Des() );
-            iHarvesterClient.RegisterHarvestComplete( uri, iStatus );
-            SetActive();            
-            }
-        else if( iObserver )
-            {
-            iObserver->HarvestingComplete( aUri, KErrCompletion );
-            iRequestComplete = ETrue;
-            }
-        }
+    WRITELOG( "CHarvesterClientAO::Active" );
+	if ( iObserver && !IsActive())
+		{
+	    WRITELOG( "CHarvesterClientAO::Active - calling RegisterHarvestComplete" );
+		iHarvesterClient.RegisterHarvestComplete(iURI, iStatus);
+		iCancelled = EFalse;
+		SetActive();
+		}
 	}
 
 // ---------------------------------------------------------------------------
@@ -148,8 +148,6 @@
 	WRITELOG( "CHarvesterClientAO::RunL()" );
 	OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_RUNL, "CHarvesterClientAO::RunL" );
 
-	iNotificationQueue->Cleanup( EFalse );
-	
 	const TInt status = iStatus.Int();
 	
     if ( status < KErrNone )
@@ -158,16 +156,19 @@
         }
 
 	// Callback to client process
-	if ( iObserver && iURI )
+	if ( iObserver )
 		{
-		WRITELOG( "CHarvesterClientAO::RunL() - Request complete - calling callback" );
-		TPtrC16 uri( iURI->Des() );
-		iObserver->HarvestingComplete( uri, status );
+		WRITELOG( "CHarvesterClientAO::RunL() - ECompleteRequest - calling callback" );
+		iObserver->HarvestingComplete( iURI, status );
 		}
 	
-    delete iURI;
-    iURI = NULL;
-	iRequestComplete = ETrue;
+	// if the request was not canceled or server is not terminated, Activating AO again
+	if ( status != KErrCancel && status != KErrServerTerminated && iObserver && !iCancelled )
+		{
+	    WRITELOG( "CHarvesterClientAO::RunL() - not cancelled or terminated, calling Active" );
+		Active();
+		}
+	WRITELOG( "CHarvesterClientAO::RunL() - end" );
 	}
 	
 // ---------------------------------------------------------------------------
@@ -182,18 +183,26 @@
     {
     WRITELOG1( "CHarvesterClientAO::RunError(), errorcode: %d", aError );
     
-    iNotificationQueue->Cleanup( EFalse );
-    iRequestComplete = ETrue;
-    
     return KErrNone;
     }
 
 // ---------------------------------------------------------------------------
-// RequestComplete
+// Active
 // ---------------------------------------------------------------------------
-//  
-TBool CHarvesterClientAO::RequestComplete()
-    {
-    return iRequestComplete;
+//
+void CHarvesterClientAO::CancelRequest()
+    {   
+    WRITELOG( "CHarvesterClientAO::CancelRequest" );
+    if( !iCancelled )
+        {
+        WRITELOG( "CHarvesterClientAO::CancelRequest - not cancelled, calling Cancel" );
+        iCancelled = ETrue;
+        Cancel();
+        }
+    if( !IsActive() )
+        {
+        WRITELOG( "CHarvesterClientAO::CancelRequest - setting priority to High" );
+        SetPriority( CActive::EPriorityHigh );
+        }
     }
 
--- a/harvester/client/src/harvesternotificationqueue.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
-* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Processor object for running harvester requests
-*
-*/
-
-
-#include "harvesternotificationqueue.h"
-#include "harvesterclientao.h"
-#include "harvesterlog.h"
-
-// ======== MEMBER FUNCTIONS ========
-
-// ---------------------------------------------------------------------------
-// CHarvesterNotificationQueue::NewL()
-// Two-phased constructor.
-// ---------------------------------------------------------------------------
-//
-CHarvesterNotificationQueue* CHarvesterNotificationQueue::NewL()
-    {
-    CHarvesterNotificationQueue* self = new( ELeave )CHarvesterNotificationQueue();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-
-// ---------------------------------------------------------------------------
-// CHarvesterNotificationQueue::CHarvesterNotificationQueue()
-// C++ default constructor can NOT contain any code, that might leave.
-// ---------------------------------------------------------------------------
-//
-CHarvesterNotificationQueue::CHarvesterNotificationQueue()
-    {
-    }
-
-
-// ---------------------------------------------------------------------------
-// CHarvesterNotificationQueue::ConstructL()
-// Symbian 2nd phase constructor can leave.
-// ---------------------------------------------------------------------------
-//
-void CHarvesterNotificationQueue::ConstructL()
-    {
-    }
-
-
-// ---------------------------------------------------------------------------
-// CHarvesterNotificationQueue::~CHarvesterNotificationQueue()
-// Destructor.
-// ---------------------------------------------------------------------------
-//
-CHarvesterNotificationQueue::~CHarvesterNotificationQueue()
-    {
-    WRITELOG( "CHarvesterNotificationQueue::~CHarvesterNotificationQueue()");
-    
-    Cleanup( ETrue );
-    iRequests.ResetAndDestroy();
-    
-    WRITELOG( "CHarvesterNotificationQueue::~CHarvesterNotificationQueue() - All requests deleted");
-    }
-
-
-// ---------------------------------------------------------------------------
-// CHarvesterNotificationQueue::AddRequestL()
-// Adds new request to the queue.
-// ---------------------------------------------------------------------------
-//
-void CHarvesterNotificationQueue::AddRequestL( CHarvesterClientAO* aRequest )
-    {
-    WRITELOG( "CHarvesterNotificationQueue::AddRequestL()");
-    
-    iRequests.AppendL( aRequest );
-    }
-
-// ---------------------------------------------------------------------------
-// CHarvesterNotificationQueue::RequestComplete()
-// Completes the request
-// ---------------------------------------------------------------------------
-//
-void CHarvesterNotificationQueue::Cleanup( TBool aShutdown )
-    {
-    WRITELOG( "CHarvesterNotificationQueue::RequestComplete()");
-    
-    for( TInt i = iRequests.Count() - 1; i >=0; i-- )
-        {
-        if( aShutdown )
-            {
-            iRequests[i]->Cancel();
-            }
-        
-        if( iRequests[i]->RequestComplete() && !iRequests[i]->IsActive() )
-            {
-            delete iRequests[i];
-            iRequests[i] = NULL;
-            iRequests.Remove( i );
-            
-            // correct the index so that no items are skipped
-            i--;
-            if(i <= -1)
-                {
-                i = -1;
-                }
-            }
-        }
-
-    if( iRequests.Count() == 0 && !aShutdown )
-        {
-        iRequests.Compress();
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// SetObserver
-// ---------------------------------------------------------------------------
-//
-void CHarvesterNotificationQueue::SetObserver( MHarvestObserver* aObserver )
-    {
-    WRITELOG( "CHarvesterNotificationQueue::SetObserver()" );
-    
-    for( TInt i = iRequests.Count() - 1; i >=0; i-- )
-        {
-        iRequests[i]->SetObserver( aObserver );
-        }
-    }
-
-// End of file
-
--- a/harvester/client/src/harvesterrequestactive.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/client/src/harvesterrequestactive.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -19,7 +19,6 @@
 
 #include "harvesterrequestactive.h"
 #include "harvesterrequestqueue.h"
-#include "harvesterlog.h"
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -33,9 +32,9 @@
     if( IsActive() )
         {
         Cancel();
-        iRequestCompleted = ETrue;
         }
     
+    iRequestCompleted = ETrue;
     delete iAlbumIds;
     iAlbumIds = NULL;
     }
@@ -46,12 +45,12 @@
 // --------------------------------------------------------------------------- 
 //
 CHarvesterRequestActive* CHarvesterRequestActive::NewL(
-        RHarvesterClient& aClient,
+        RHarvesterClient& aClient, MHarvestObserver* aObserver,
         TInt aService, const TDesC& aUri, 
         HBufC8* aAlbumIds, TBool aAddLocation,
         CHarvesterRequestQueue* aQueue )
     {
-    CHarvesterRequestActive* self = new( ELeave )CHarvesterRequestActive( aClient,
+    CHarvesterRequestActive* self = new( ELeave )CHarvesterRequestActive( aClient, aObserver,
             aService, aUri, aAlbumIds, aAddLocation, aQueue );
     return self;
     }
@@ -61,10 +60,10 @@
 // C++ default constructor can NOT contain any code, that might leave.
 // ---------------------------------------------------------------------------
 //
-CHarvesterRequestActive::CHarvesterRequestActive( RHarvesterClient& aClient, 
-    TInt aService, const TDesC& aUri, 
+CHarvesterRequestActive::CHarvesterRequestActive( RHarvesterClient& aClient,
+    MHarvestObserver* aObserver, TInt aService, const TDesC& aUri, 
     HBufC8* aAlbumIds, TBool aAddLocation, CHarvesterRequestQueue* aQueue )
-    : CActive( CActive::EPriorityStandard ), iClient( aClient ), 
+    : CActive( CActive::EPriorityStandard ), iClient( aClient ), iObserver( aObserver ), 
     iService( aService ), iUri( aUri ), iAlbumIds( aAlbumIds ), iAddLocation( aAddLocation ),
     iRequestQueue( aQueue ), iLocation( EFalse ), iCancelled( EFalse )
     {
@@ -77,6 +76,16 @@
 //
 void CHarvesterRequestActive::RunL()
     {
+    if( iStatus.Int() == KErrCancel )
+        {
+        return;
+        }           
+    
+    if( iStatus.Int() && iObserver )
+        {
+        iObserver->HarvestingComplete( iUri, iStatus.Int() );
+        }       
+    
     iRequestCompleted = ETrue;
     if( iRequestQueue )
         {
@@ -95,6 +104,11 @@
         return KErrNone;
         }
     
+    if( iObserver )
+        {
+        iObserver->HarvestingComplete( iUri, aError );
+        }
+    
     iRequestCompleted = ETrue;
     return KErrNone;
     }
@@ -106,6 +120,7 @@
 void CHarvesterRequestActive::DoCancel()
     {
     iCancelled = ETrue;
+	iObserver = NULL;
     }
 
 // ---------------------------------------------------------------------------
@@ -122,7 +137,7 @@
     
     if( !iCancelled )
         {
-        iClient.HarvestFile( iService, iPersistentArgs, iStatus, iUri );
+        iClient.HarvestFile( iService, iPersistentArgs, iStatus );
         SetActive();
         }
     }
@@ -133,7 +148,7 @@
 //
 void CHarvesterRequestActive::ForceHarvest()
     {
-    WRITELOG( "CHarvesterRequestActive::ForceHarvest()");
+    iObserver = NULL;
     
     TPckg<TBool> location( iAddLocation );
     iLocation.Set( location );
--- a/harvester/client/src/harvestersessionwatcher.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/client/src/harvestersessionwatcher.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -38,6 +38,7 @@
 CHarvesterSessionWatcher::~CHarvesterSessionWatcher() // destruct
 	{   
     Cancel();
+    iObserver = NULL;
  	}
 
 // ---------------------------------------------------------------------------
@@ -105,7 +106,10 @@
           case ERunning:
               {
               // server terminated, notify clients
-              iObserver->HarvesterServerTerminated();
+              if( iObserver )
+                  {
+                  iObserver->HarvesterServerTerminated();
+                  }
               break;
               }
             
--- a/harvester/client/traces/fixed_id.definitions	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/client/traces/fixed_id.definitions	Mon Aug 23 13:33:21 2010 +0300
@@ -4,6 +4,7 @@
 [TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_CONSTRUCTL=0x10
 [TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_DOCANCEL=0x13
 [TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_NEWL=0xd
+[TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_REMOVEOBSERVER=0x15
 [TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_RUNL=0x14
 [TRACE]TRACE_NORMAL[0x3]_CHARVESTERCLIENTAO_SETOBSERVER=0x11
 [TRACE]TRACE_NORMAL[0x3]_DUP1_CHARVESTERCLIENTAO_CHARVESTERCLIENTAO=0xf
--- a/harvester/client/traces/harvesterclientaoTraces.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/client/traces/harvesterclientaoTraces.h	Mon Aug 23 13:33:21 2010 +0300
@@ -13,6 +13,7 @@
 #define CHARVESTERCLIENTAO_SETOBSERVER 0x30011
 #define CHARVESTERCLIENTAO_DOCANCEL 0x30013
 #define CHARVESTERCLIENTAO_RUNL 0x30014
+#define CHARVESTERCLIENTAO_REMOVEOBSERVER 0x30015
 
 
 #endif
--- a/harvester/common/bwincw/harvesterplugininterfacewinscw.def	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/common/bwincw/harvesterplugininterfacewinscw.def	Mon Aug 23 13:33:21 2010 +0300
@@ -13,4 +13,5 @@
 	?GetMimeType@CHarvesterPlugin@@UAEXABVTDesC16@@AAVTDes16@@@Z @ 12 NONAME ; void CHarvesterPlugin::GetMimeType(class TDesC16 const &, class TDes16 &)
 	?SetHarvesterPluginFactory@CHarvesterPlugin@@QAEXAAVCHarvesterPluginFactory@@@Z @ 13 NONAME ; void CHarvesterPlugin::SetHarvesterPluginFactory(class CHarvesterPluginFactory &)
 	?PluginInIdleState@CHarvesterPlugin@@QAEHXZ @ 14 NONAME ; int CHarvesterPlugin::PluginInIdleState(void)
+	?StopHarvest@CHarvesterPlugin@@UAEXXZ @ 15 NONAME ; void CHarvesterPlugin::StopHarvest(void)
 
--- a/harvester/common/eabi/harvesterplugininterfacearm.def	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/common/eabi/harvesterplugininterfacearm.def	Mon Aug 23 13:33:21 2010 +0300
@@ -17,4 +17,5 @@
 	_ZN16CHarvesterPlugin11GetMimeTypeERK7TDesC16R6TDes16 @ 16 NONAME
 	_ZN16CHarvesterPlugin25SetHarvesterPluginFactoryER23CHarvesterPluginFactory @ 17 NONAME
 	_ZN16CHarvesterPlugin17PluginInIdleStateEv @ 18 NONAME
+	_ZN16CHarvesterPlugin11StopHarvestEv @ 19 NONAME
 
--- a/harvester/common/inc/harvestercommon.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/common/inc/harvestercommon.h	Mon Aug 23 13:33:21 2010 +0300
@@ -98,6 +98,7 @@
 
 const TInt KOriginIgnored = 255;
 const TInt KOriginFastHarvest = 254;
+const TInt KOriginIgnoreAttribsChanged = 253;
 
 const CActive::TPriority KHarvesterPriorityContextEngine = CActive::EPriorityUserInput;
 const CActive::TPriority KHarvesterPriorityMonitorPlugin = CActive::EPriorityUserInput;
@@ -106,9 +107,8 @@
 
 // Between Standard and UserInput to allow components to react to important events correctly
 const TInt KHarvesterCustomImportantPriority = 5;
-// Higher than MonitorPlugin priority but lower than High to ensure server can answer to all
-// connection requests as fast as possible
-const TInt KHarvesterServerSessionPriority = 11;
+// Higher than MonitorPlugin priority but lower than High. Highest priority within Harvester
+const TInt KHarvesterServerHighPriority = 11;
 
 #endif
 
--- a/harvester/common/inc/harvesterpluginfactory.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/common/inc/harvesterpluginfactory.h	Mon Aug 23 13:33:21 2010 +0300
@@ -61,6 +61,9 @@
 		  
 	    TBool iHarvesting;
 		CHarvesterEventManager* iHarvesterEventManager;
+		
+		HBufC* iLastConfirmedContainerExt;
+		HBufC* iLastConfirmedSupportedExt;
 	};
 
 #endif
--- a/harvester/common/src/harvesterexifutil.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/common/src/harvesterexifutil.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -433,7 +433,7 @@
 EXPORT_C TTime CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL(
 		const TDesC8& aDateTime )
     {
-    WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL()" );
+    WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL()" );
     OstTrace0( TRACE_NORMAL, CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL" );    
     
     TDateTime datetime( 0, EJanuary, 0, 0, 0, 0, 0 );
@@ -446,7 +446,7 @@
     TInt error = lex.Val( number );
     if ( error != KErrNone )
         {
-        WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get year" );
+        WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get year" );
         OstTrace0( TRACE_NORMAL, DUP1_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get year" );
         
         User::Leave( error );
@@ -459,7 +459,7 @@
     error = lex.Val( number );
     if ( error != KErrNone )
         {
-        WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get month" );
+        WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get month" );
         OstTrace0( TRACE_NORMAL, DUP2_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get month" );
         
         User::Leave( error );
@@ -474,7 +474,7 @@
     error = lex.Val( number );
     if ( error != KErrNone )
         {
-        WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get date" );
+        WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get date" );
         OstTrace0( TRACE_NORMAL, DUP3_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get date" );
         
         User::Leave( error );
@@ -487,7 +487,7 @@
     error = lex.Val( number );
     if ( error != KErrNone )
         {
-        WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get hours" );
+        WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get hours" );
         OstTrace0( TRACE_NORMAL, DUP4_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get hours" );
         
         User::Leave( error );
@@ -500,7 +500,7 @@
     error = lex.Val( number );
     if ( error != KErrNone )
         {
-        WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get minutes" );
+        WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get minutes" );
         OstTrace0( TRACE_NORMAL, DUP5_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get minutes" );
         
         User::Leave( error );
@@ -513,7 +513,7 @@
     error = lex.Val( number );
     if ( error != KErrNone )
         {
-        WRITELOG( "CHarvesterImagePluginAO::ConvertExifDateTimeToSymbianTimeL() - couldn't get seconds" );
+        WRITELOG( "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL() - couldn't get seconds" );
         OstTrace0( TRACE_NORMAL, DUP6_CHARVESTEREXIFUTIL_CONVERTEXIFDATETIMETOSYMBIANTIMEL, "CHarvesterExifUtil::ConvertExifDateTimeToSymbianTimeL - couldn't get seconds" );
         
         User::Leave( error );
@@ -829,7 +829,9 @@
         WRITELOG( "CHarvesterExifUtil::ComposeExifData() - Image doesn't contain EXIF data" );
         modifyExif = CExifModify::NewL( aImagePtr, 
         		CExifModify::ECreate, CExifModify::ENoJpegParsing );
+        CleanupStack::PushL( modifyExif );
         SetExifDefaultsL( aMdeObject, *modifyExif );
+        CleanupStack::Pop( modifyExif );
         exifChanged = ETrue;
         }
     CleanupStack::PushL( modifyExif );
--- a/harvester/common/src/harvesterplugin.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/common/src/harvesterplugin.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -65,7 +65,8 @@
     iDtor_ID_Key( KNullUid ),
     iOriginPropertyDef( NULL ),
     iTitlePropertyDef( NULL ),
-    iHarvesting( EFalse )
+    iHarvesting( EFalse ),
+    iPaused( EFalse )
 	{
 	}
 
@@ -109,6 +110,7 @@
 	{
 	if( iState == EHarvesterIdle )
 		{
+		iPaused = EFalse;
 		SetNextRequest( EHarvesterGathering );
 		}
 	}
@@ -154,6 +156,7 @@
                 }
             else
             	{
+                WRITELOG( "CHarvesterPlugin::RunL EHarvesterGathering - items in queue" );
                 if ( !iHarvesting )
                     {
                     TRAP_IGNORE( iFactory->SendHarvestingStatusEventL( ETrue ) );
@@ -244,12 +247,28 @@
 	}
 
 // ---------------------------------------------------------------------------
+// StartHarvest
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CHarvesterPlugin::StopHarvest()
+    {
+    Cancel();
+    iState = EHarvesterIdle;
+    if( iHarvesting )
+        {
+        TRAP_IGNORE( iFactory->SendHarvestingStatusEventL( EFalse ) );
+        iHarvesting = EFalse;     
+        }
+    iPaused = ETrue;
+    }
+
+// ---------------------------------------------------------------------------
 // SetNextRequest
 // ---------------------------------------------------------------------------
 //
 void CHarvesterPlugin::SetNextRequest( THarvesterState aState )
     {
-    if ( ! IsActive() )
+    if ( !IsActive() && !iPaused )
         {
         iState = aState;
         SetActive();
--- a/harvester/common/src/harvesterpluginfactory.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/common/src/harvesterpluginfactory.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -68,6 +68,12 @@
 	{
 	WRITELOG( "CHarvesterPluginFactory::~CHarvesterPluginFactory()" );
 	
+	delete iLastConfirmedContainerExt;
+	iLastConfirmedContainerExt = NULL;
+	
+	delete iLastConfirmedSupportedExt;
+	iLastConfirmedSupportedExt = NULL;
+	
     if (iHarvesterEventManager)
         {
         iHarvesterEventManager->ReleaseInstance();
@@ -330,6 +336,13 @@
 	TPtrC extPtr;
 	if( MdsUtils::GetExt( aFileName, extPtr ) )
 		{
+        if( iLastConfirmedSupportedExt &&
+            extPtr.CompareF( iLastConfirmedSupportedExt->Des() ) == 0 )
+            {
+            // Extension has previously been confirmed to be 
+            // supported file extension, no need to ask from plugins
+            return ETrue;
+            }
 		TInt pluginInfoCount = iHarvesterPluginInfoArray.Count();
 		TInt extCount = 0;
 		for ( TInt i = pluginInfoCount; --i >= 0; )
@@ -343,6 +356,9 @@
 				TInt result = MdsUtils::Compare( *ext, extPtr );
 				if ( result == 0 )
 					{
+                    delete iLastConfirmedSupportedExt;
+                    iLastConfirmedSupportedExt = NULL;
+                    iLastConfirmedSupportedExt = extPtr.Alloc();				    
 					return ETrue;
 					}
 				}
@@ -358,6 +374,14 @@
 	
 	if( MdsUtils::GetExt( aURI, extPtr ) )
 		{
+	    if( iLastConfirmedContainerExt &&
+	        extPtr.CompareF( iLastConfirmedContainerExt->Des() ) == 0 )
+	        {
+	        // Extension has previously been confirmed to be 
+	        // container file extension, no need to ask from plugins
+	        return ETrue;
+	        }
+	
 		RPointerArray<CHarvesterPluginInfo> supportedPlugins;
 		CleanupClosePushL( supportedPlugins );
 		GetSupportedPluginsL( supportedPlugins, extPtr );
@@ -367,6 +391,9 @@
 			if( info->iObjectTypes.Count() >  1 )
 				{
 				isContainerFile = ETrue;
+				delete iLastConfirmedContainerExt;
+				iLastConfirmedContainerExt = NULL;
+				iLastConfirmedContainerExt = extPtr.Alloc();
 				break;
 				}
 			}
@@ -395,6 +422,7 @@
 
 EXPORT_C void CHarvesterPluginFactory::SendHarvestingStatusEventL( TBool aStarted )
     {
+    WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL" );
     const TInt pluginInfoCount = iHarvesterPluginInfoArray.Count();
     TBool itemsLeft( EFalse );
     TBool allPluginsOnIdle( ETrue );
@@ -418,6 +446,7 @@
     
     if( !iHarvesting && itemsLeft && aStarted )
         {
+        WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL - overall started" );
         iHarvesting = ETrue;
         iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateStarted );
         // This next line is for caching the harvester started event for observers registering
@@ -427,6 +456,7 @@
         }
     else if( iHarvesting && (!itemsLeft || allPluginsOnIdle) && !aStarted )
         {
+        WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL - overall finished" );
         iHarvesting = EFalse;                       
         iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateFinished );
         iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
@@ -440,7 +470,7 @@
         {
         if( iHarvesterPluginInfoArray[i]->iPlugin && aPaused )
             {
-            iHarvesterPluginInfoArray[i]->iPlugin->Cancel();
+            iHarvesterPluginInfoArray[i]->iPlugin->StopHarvest();
             }
         else if( iHarvesterPluginInfoArray[i]->iPlugin )
             {
@@ -481,6 +511,8 @@
                 info->iPlugin->SetBlacklist( *iBlacklist );
                 }
             info->iPlugin->GetObjectType( aHD->Uri(), aObjectDef );
+            // It is possible for unmount to occure while we are waiting
+            // for GetObjectType to return, thus check aHD for validity
             if( aHD && aObjectDef.Length() > 0 )
                 {
                 aHD->SetHarvesterPluginInfo( info );
--- a/harvester/common/src/mdeobjectwrapper.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/common/src/mdeobjectwrapper.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -157,7 +157,7 @@
 				case EPropertyReal32:
 					{
 					TReal32* value = static_cast<TReal32*>( aData );
-					WRITELOG2("CMdeObjectWrapper::HandleObjectPropertyL - Edit property: %S with value %d", &aPropertyDef.Name(), *value );
+					WRITELOG2("CMdeObjectWrapper::HandleObjectPropertyL - Edit property: %S with value %f", &aPropertyDef.Name(), *value );
 					property->SetReal32ValueL( *value );
 					}
 				break;
@@ -173,9 +173,7 @@
 				case EPropertyTime:
 					{
 					TTime* value = static_cast<TTime*>( aData );
-#ifdef _DEBUG
-					WRITELOG2("CMdeObjectWrapper::HandleObjectPropertyL - Edit property: %S with value %d", &aPropertyDef.Name(), value->Int64() );
-#endif
+					WRITELOG2("CMdeObjectWrapper::HandleObjectPropertyL - Edit property: %S with value %u", &aPropertyDef.Name(), value->Int64() );
 					property->SetTimeValueL( *value );
 					}
 				break;
--- a/harvester/composerplugins/imagecomposer/src/imagecomposerao.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/composerplugins/imagecomposer/src/imagecomposerao.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -275,7 +275,7 @@
 	                
 	                SetNextRequest( ERequestCompose );
 	                }
-	            // if object does not exists, find next
+	            // if object does not exists, or data is not modified, find next
 	            else if ( err == KErrNotFound || err == KErrAbort )
 	                 {
 	                 if ( err == KErrAbort && mdeObjectId != KNoId )
@@ -423,6 +423,7 @@
 	
 	    	if( error != KErrNone || entry.iModified == time )
 	    		{
+	    	    WRITELOG( "CImageComposerAO::GetObjectFromMdeL() - image data has not been modified - abort" );
 	    		User::Leave( KErrAbort );
 	    		}
 	    	}
--- a/harvester/composerplugins/imagecomposer/src/imagepresentobserver.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/composerplugins/imagecomposer/src/imagepresentobserver.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -87,8 +87,10 @@
 void CImagePresentObserver::HandleObjectPresentNotification(CMdESession& /*aSession*/, 
 		TBool aPresent, const RArray<TItemId>& aObjectIdArray)
 	{
+    WRITELOG( "CImagePresentObserver::HandleObjectPresentNotification" );
 	if ( aPresent )
 		{
+	    WRITELOG( "CImagePresentObserver::HandleObjectPresentNotification - objects present" );
 		if ( !iStarted )
 			{
 			CMdEObjectDef* imageObjDef = NULL;
--- a/harvester/data/default_origin_mappings.db	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/data/default_origin_mappings.db	Mon Aug 23 13:33:21 2010 +0300
@@ -8,9 +8,9 @@
 101FFA86	1
 2000D16B	1
 10208A6D	1
-101f857a  1
-10003a3f	2 
-101f4d90	2 
+101F857A  1
+10003A3F	2 
+101F4D90	2 
 1028242D	2 
 1028242E	2 
 101FFB51	2 
@@ -29,11 +29,12 @@
 10281FA7	4
 10281FA5	4
 10281FA6	4
+101FFC31  253
 101FFA91  254
 20026F35  254
 20026F2F  254
 200009F5	255
 2000A7AE	255
 200071BE	255
-101f7771  255
-1020e519  255 
+101F7771  255
+1020E519  255 
--- a/harvester/harvesterplugins/OMADRMPlugin/src/harvesteromadrmplugin.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/harvesterplugins/OMADRMPlugin/src/harvesteromadrmplugin.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -193,7 +193,7 @@
 
 void CHarvesterOMADRMPlugin::HarvestL( CHarvesterData* aHarvesterData )
 	{
-	WRITELOG( "CHarvesterImagePlugin::HarvestL()" );
+	WRITELOG( "CHarvesterOMADRMPlugin::HarvestL()" );
     CMdEObject& mdeObject = aHarvesterData->MdeObject();
 	CDRMHarvestData* drmHarvestData = CDRMHarvestData::NewL();
 	CleanupStack::PushL( drmHarvestData );
@@ -330,31 +330,36 @@
         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting protection info failed %d", err );
         }
       
-    CImageDecoder* decoder = NULL;
-
-    TRAP( err, decoder = CImageDecoder::FileNewL( iFs, uri, ContentAccess::EPeek, 
-            ( CImageDecoder::TOptions )( CImageDecoder::EPreferFastDecode )));
-
-    CleanupStack::PushL( decoder );
-    
-    if(decoder && !err)
+    if( aMetadataObject.Def().Name() == MdeConstants::Image::KImageObject )
         {
-        WRITELOG( "CHarvesterImagePlugin::GatherData() - Image decoder has opened the file." );        
-        // Get image width, frame count, height and bits per pixel from image decoder.
-        const TFrameInfo info = decoder->FrameInfo( 0 );
-        const TSize imageSize = info.iOverallSizeInPixels;
-        const TInt framecount = decoder->FrameCount();
-        aFileData.iFrameCount = framecount;
-        aFileData.iImageWidth = imageSize.iWidth;
-        aFileData.iImageHeight = imageSize.iHeight;
-        aFileData.iBitsPerPixel = info.iBitsPerPixel;
-        }
-    else
-        {
-        WRITELOG1( "CHarvesterImagePlugin::GatherData() - ERROR: decoder %d", err );
+        CImageDecoder* decoder = NULL;
+
+        TRAP( err, decoder = CImageDecoder::FileNewL( iFs, uri, ContentAccess::EPeek, 
+                ( CImageDecoder::TOptions )( CImageDecoder::EPreferFastDecode )));
+
+        CleanupStack::PushL( decoder );
+    
+        if(decoder && !err)
+            {
+            WRITELOG( "CHarvesterImagePlugin::GatherData() - Image decoder has opened the file." );        
+            // Get image width, frame count, height and bits per pixel from image decoder.
+            const TFrameInfo info = decoder->FrameInfo( 0 );
+            const TSize imageSize = info.iOverallSizeInPixels;
+            const TInt framecount = decoder->FrameCount();
+            aFileData.iFrameCount = framecount;
+            aFileData.iImageWidth = imageSize.iWidth;
+            aFileData.iImageHeight = imageSize.iHeight;
+            aFileData.iBitsPerPixel = info.iBitsPerPixel;
+            }
+        else
+            {
+            WRITELOG1( "CHarvesterImagePlugin::GatherData() - ERROR: decoder %d", err );
+            }    
+        CleanupStack::PopAndDestroy( decoder );
         }
 
-    CleanupStack::PopAndDestroy( 4 ); // content, data, attrSet, imagedecoder
+
+    CleanupStack::PopAndDestroy( 3 ); // content, data, attrSet
     return KErrNone;
     }
 
--- a/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -339,7 +339,7 @@
     if ( error != KErrNone )
         {
         WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - File open error: %d", error );
-        if( error == KErrInUse )
+        if( error == KErrInUse || KErrLocked )
             {
 #ifdef _DEBUG
             TPtrC fileName( aUri.Mid(2) );
@@ -627,6 +627,7 @@
         TRAP( error, helixMetadata->OpenFileL( file ) );        
 
         // No need for the file handle anymore so closing it
+        WRITELOG( "CHarvesterVideoPlugin - Parsing done, file handle can be closed" );   
         file.Close();
         
         if ( error == KErrNone )
@@ -981,7 +982,7 @@
             }
 #endif
         }
-    WRITELOG( "CHarvesterVideoPlugin - Closing file" );        
+    WRITELOG( "CHarvesterVideoPlugin - Closing file, if still open" );        
     CleanupStack::PopAndDestroy( &file );        
 
 #ifdef _DEBUG
@@ -1247,6 +1248,7 @@
     CleanupStack::PushL( helixMetadata );
     
 	TRAPD( err, helixMetadata->OpenFileL( aFile ) );
+	aFile.Close();
 
 	if( err == KErrNone )
 		{
@@ -1273,10 +1275,10 @@
 	
 		const TInt mimeCount = mimes.Count();
 		
-		// at least one MIME type must be found
+		// Set to Video, regardless how badly file is corrupted
 		if( mimeCount == 0 )
 			{
-			User::Leave( KErrNotFound );
+		    aType.Copy( KVideo );
 			}
 	
 		for( TInt i = 0; i < mimeCount; i++ )
@@ -1336,8 +1338,7 @@
     if( blackListError == KErrNone )
         {
         RemoveFileFromBlackList( tempName, mediaId );
-        }
-    
+        }  
 	}
 
 TInt CHarvesterVideoPlugin::AddFileToBlackList( const TFileName& aFullName, const TUint32& aMediaId )
--- a/harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -300,6 +300,14 @@
             WRITELOG1( "CFileEventHandlerAO::HandleNotificationL - ignored camera origin for %S", &status.iFileName );
             return;
             }
+        
+        if( (origin == KOriginIgnoreAttribsChanged ||
+             origin == MdeConstants::Object::ECamera ) &&
+            aEvent.iFileEventType == EMdsFileAttribsChanged )
+            {
+            WRITELOG1( "CFileEventHandlerAO::HandleNotificationL - ignored attribs changed event for %S", &status.iFileName );
+            return;        
+            }
         }
 
     // ignore created file event if extension is not supported by any harverter plugin
@@ -338,6 +346,7 @@
         break;
         
         case EMdsFileModified:
+        case EMdsFileAttribsChanged:
             {
             WRITELOG1( "CFileEventHandlerAO::HandleNotificationL - EmdsFileModified: %S", &status.iFileName );
             ModifyL( status.iFileName, origin, fastHarvest );
--- a/harvester/monitorplugins/fileplugin/src/processoriginmapper.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/monitorplugins/fileplugin/src/processoriginmapper.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -227,7 +227,7 @@
 //
 TInt CProcessOriginMapper::ReadFileL()
     {
-    WRITELOG( "CProcessOriginMapper::ReadFileL - reading default file..." );
+    WRITELOG( "CProcessOriginMapper::ReadFileL - reading default file" );
     iDefaultFileRead = ETrue;
     const TInt count = ReadFileL( KDefaultMappingFile );
     iDefaultFileRead = EFalse;
--- a/harvester/monitorplugins/inc/mdsfileserverpluginclient.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/monitorplugins/inc/mdsfileserverpluginclient.h	Mon Aug 23 13:33:21 2010 +0300
@@ -50,7 +50,8 @@
 	EMdsFileDeleted,
 	EMdsDriveFormatted,
 	EMdsFileUnknown,
-	EMdsDirRenamed
+	EMdsDirRenamed,
+	EMdsFileAttribsChanged
 	};
 
 typedef TPckgBuf<TMdsFSPStatus> TMdsFSPStatusPckg;
--- a/harvester/monitorplugins/mdsfileserverplugin/src/mdsfileserverplugin.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/monitorplugins/mdsfileserverplugin/src/mdsfileserverplugin.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -450,7 +450,7 @@
                 return KErrNone;
                 }
             
-            fileEventType = EMdsFileModified;
+            fileEventType = EMdsFileAttribsChanged;
             }
             break;            
             
--- a/harvester/monitorplugins/mmcplugin/inc/mmcmounttaskao.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/monitorplugins/mmcplugin/inc/mmcmounttaskao.h	Mon Aug 23 13:33:21 2010 +0300
@@ -53,9 +53,9 @@
 		void SetHarvesterPluginFactory( CHarvesterPluginFactory* aPluginFactory );
 		
 		/**
-		 * Returns internal hard drive's media id if the device has one. 0 if not or drive is not present
+		 * Returns internal hard drive's media id if the device has one.
 		 */
-		TUint32 GetInternalDriveMediaId();
+		TUint32 GetInternalDriveMediaId( TBool& aPresent );
 		
         void SetCachingStatus( TBool aCachingStatus );
         
--- a/harvester/monitorplugins/mmcplugin/src/mmcfilelist.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/monitorplugins/mmcplugin/src/mmcfilelist.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -104,7 +104,7 @@
 	TUint32 mediaId( 0 );
 	iMediaIdUtil->GetMediaId( aDrivePath, mediaId );
 	
-	WRITELOG1( "CMmcFileList::BuildFileListL - mediaId: %d", mediaId );
+	WRITELOG1( "CMmcFileList::BuildFileListL - mediaId: %u", mediaId );
 	
     CDir* directory = NULL;
     TFileName name; 
@@ -294,7 +294,6 @@
 		aEntryArray.Compress();
 		}
 	
-	WRITELOG( "CMmcFileList::HandleFileEntryL -- cleanupstack" );
 	CleanupStack::PopAndDestroy( &results );
 	CleanupStack::PopAndDestroy( &fileInfos );
 	CleanupStack::PopAndDestroy( &uris );
--- a/harvester/monitorplugins/mmcplugin/src/mmcmonitorao.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/monitorplugins/mmcplugin/src/mmcmonitorao.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -124,6 +124,8 @@
 		return;
 		}
 
+	StartNotify();
+	
 	iPreviousDriveList.Zero();
 	iPreviousDriveList.Copy( iDriveList );
 
@@ -138,8 +140,6 @@
 #ifdef _DEBUG
 	PrintAllLists();
 #endif
-
-	StartNotify();
 	}
 
 #ifdef _DEBUG
@@ -161,7 +161,7 @@
 	iFs.NotifyChangeCancel( iStatus );
 	}
 
-CMMCMonitorAO::CMMCMonitorAO() : CActive( KHarvesterPriorityMonitorPlugin ),
+CMMCMonitorAO::CMMCMonitorAO() : CActive( KHarvesterServerHighPriority ),
     iObserver( NULL )
 	{
 	}
@@ -283,7 +283,7 @@
 			{
 			if ( iMediaIdList[i] != mediaId )
 				{
-				WRITELOG3( "CMMCMonitorAO::CompareDriveLists media changed %d, old=%d, new=%d", i, iMediaIdList[i], mediaId ); // DEBUG INFO
+				WRITELOG3( "CMMCMonitorAO::CompareDriveLists media changed %d, old=%u, new=%u", i, iMediaIdList[i], mediaId ); // DEBUG INFO
 				// skip mount events if mediaId is 0
 				if ( iMediaIdList[i] != 0 )
 					{
--- a/harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -116,7 +116,8 @@
 	TBool presentState( EFalse );
     
 	TUint32 hdMediaId( 0 );
-    hdMediaId = iMountTask->GetInternalDriveMediaId();
+	TBool hdPresent( EFalse );
+    hdMediaId = iMountTask->GetInternalDriveMediaId( hdPresent );
     
     for( TInt i = medias.Count() - 1; i >=0; i-- )
     	{
@@ -137,10 +138,10 @@
     		}
     	}
  
-    if( hdMediaId == 0 )
+    if( hdMediaId == 0 || !hdPresent )
         {
         // Try to fetch internall mass storage media id again if it was not mounted
-        hdMediaId = iMountTask->GetInternalDriveMediaId();
+        hdMediaId = iMountTask->GetInternalDriveMediaId( hdPresent );
         }
     
     // scan mass storage to catch all chances even if battery dies during operation that should  be catched
@@ -149,7 +150,7 @@
 		TBool exists( EFalse );
 		TRAP_IGNORE( exists= iMdEClient->GetMediaL( hdMediaId, driveLetter, presentState ) );
 		
-		if ( exists )
+		if ( exists && hdPresent )
 			{
 			WRITELOG("CMMCMonitorPlugin::StartMonitoring - start mass storage scan");
 			
@@ -267,33 +268,39 @@
                 if( internalMassStorageError == KErrNone )
                     {
                     const TUint32 massStorageMediaId( internalMassStorageVolumeInfo.iUniqueID );
-                    TUint32 mmcMediaId( 0 );
-                    TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive ) );
-                    if( mmcError == KErrNone )
+                    if( massStorageMediaId == aMediaID &&
+                        massStorageMediaId != 0 )
                         {
-                        TVolumeInfo mmcVolumeInfo;
-                        mmcError = iFs.Volume( mmcVolumeInfo, drive );
+                        TUint32 mmcMediaId( 0 );
+                        TInt mmcDrive( -1 );
+                        TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, mmcDrive ) );
                         if( mmcError == KErrNone )
                             {
-                            mmcMediaId = mmcVolumeInfo.iUniqueID;
+                            if( drive != mmcDrive )
+                                {
+                                TVolumeInfo mmcVolumeInfo;
+                                mmcError = iFs.Volume( mmcVolumeInfo, mmcDrive );
+                                if( mmcError == KErrNone )
+                                    {
+                                    mmcMediaId = mmcVolumeInfo.iUniqueID;
+                                    }                        
+                                }
+                            else
+                                {
+                                mmcMediaId = massStorageMediaId;
+                                }
                             }
-                        }
                     
-                    // If removable storage is not found, assume internal mass storage was mounted
-                    if( mmcError )
-                        {
-                        if( massStorageMediaId != 0 && 
-                            massStorageMediaId == aMediaID )
+                        // If removable storage is not found, assume internal mass storage was mounted
+                        if( mmcError )
+                            {
+                            iMdEClient->CheckMassStorageMediaId( massStorageMediaId );              
+                            }
+                        else if( massStorageMediaId != mmcMediaId )
                             {
                             iMdEClient->CheckMassStorageMediaId( massStorageMediaId );
-                            }                    
-                        }
-                    else if( massStorageMediaId != mmcMediaId && 
-                                massStorageMediaId != 0 && 
-                                massStorageMediaId == aMediaID )
-                        {
-                        iMdEClient->CheckMassStorageMediaId( massStorageMediaId );
-                        }          
+                            }          
+                        }                    
                     }
                 }
             
--- a/harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -114,6 +114,25 @@
 	{
 	WRITELOG("CMMCMountTaskAO::StartMount");
 	
+	// Remove pending mount request for the same drive
+	// if for example USB cable is pluged and unpluged
+	// several times in a row
+	for( TInt i = iMountDataQueue.Count() - 1; i >=0; i-- )
+	    {
+	    WRITELOG( "CMMCMountTaskAO::StartUnmountL - checking for pending mount notifications" );
+	    TMountData* tempData = iMountDataQueue[i];
+	    if( tempData->iMediaID == aMountData.iMediaID &&
+	        tempData->iMountType == TMountData::EMount &&
+	        aMountData.iMountType == TMountData::EMount &&
+	        tempData->iDrivePath == aMountData.iDrivePath )
+	        {
+	        WRITELOG( "CMMCMountTaskAO::StartUnmountL - removing obsolite mount notifications" );
+	        iMountDataQueue.Remove(i);
+	        delete tempData;
+	        tempData = NULL;
+	        }
+	    }
+
 	User::LeaveIfError( iMountDataQueue.Append( &aMountData ));
 	
 	if ( iNextRequest == ERequestIdle )
@@ -135,7 +154,26 @@
 			Deinitialize();
 			}
 		}
-		
+
+    // Remove pending unmount request for the same drive
+    // if for example USB cable is pluged and unpluged
+    // several times in a row
+    for( TInt i = iMountDataQueue.Count() - 1; i >=0; i-- )
+        {
+        WRITELOG( "CMMCMountTaskAO::StartUnmountL - checking for pending unmount notifications" );
+        TMountData* tempData = iMountDataQueue[i];
+        if( tempData->iMediaID == aMountData.iMediaID &&
+            tempData->iMountType == TMountData::EUnmount &&
+            aMountData.iMountType == TMountData::EUnmount &&
+            tempData->iDrivePath == aMountData.iDrivePath )
+            {
+            WRITELOG( "CMMCMountTaskAO::StartUnmountL - removing obsolite unmount notifications" );
+            iMountDataQueue.Remove(i);
+            delete tempData;
+            tempData = NULL;
+            }
+        }
+	
 	User::LeaveIfError( iMountDataQueue.Append( &aMountData ));
 		
 	SetNextRequest( ERequestStartTask );
@@ -181,7 +219,7 @@
 
 				WRITELOG1( "iMountData.iMountType: %d", iMountData->iMountType );
 				WRITELOG1( "iMountData.iDrivePath: %S", &iMountData->iDrivePath );
-				WRITELOG1( "iMountData.iMediaID: %d", iMountData->iMediaID );
+				WRITELOG1( "iMountData.iMediaID: %u", iMountData->iMediaID );
 
 				if ( iMountData->iMountType == TMountData::EMount )
 					{
@@ -393,6 +431,7 @@
 	{
 	WRITELOG1( "CMMCMountTaskAO::RunError with error code: %d", aError );
 	Deinitialize();
+	SetNextRequest( ERequestStartTask );
 	return KErrNone;
 	}
 
@@ -415,7 +454,7 @@
 
 void CMMCMountTaskAO::SetNotPresentToMDE()
 	{
-	WRITELOG1("CMMCMountTaskAO::SetNotPresentToMDE - MediaID %d", iMountData->iMediaID);
+	WRITELOG1("CMMCMountTaskAO::SetNotPresentToMDE - MediaID %u", iMountData->iMediaID);
 	if ( iMountData->iMediaID )
 		{
 		iMdeSession->SetFilesToNotPresent( iMountData->iMediaID );
@@ -538,7 +577,7 @@
 		}
 	}
 
-TUint32 CMMCMountTaskAO::GetInternalDriveMediaId()
+TUint32 CMMCMountTaskAO::GetInternalDriveMediaId( TBool& aPresent )
 	{
     WRITELOG( "CMMCMountTaskAO::GetInternalDriveMediaId" );
 	    
@@ -581,10 +620,15 @@
 	        	// check if disk is internal
 	        	TUint driveStatus;
 	        	const TInt err = DriveInfo::GetDriveStatus( iFs, i, driveStatus );
-	        	if ( (err == KErrNone ) && ( driveStatus & DriveInfo::EDriveInternal ) )
+	        	if ( ( err == KErrNone ) && 
+	        	     ( driveStatus & DriveInfo::EDriveInternal ))
 	        		{
 	        		// get media id
 	        		hdMediaId = FSUtil::MediaID( iFs, i );
+	        		if( driveStatus & DriveInfo::EDrivePresent )
+	        		    {
+	        		    aPresent = ETrue;
+	        		    }
 	        		break;
 	        		}
 	        	}
--- a/harvester/monitorplugins/mmcplugin/src/mmcscannerao.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/monitorplugins/mmcplugin/src/mmcscannerao.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -108,6 +108,14 @@
 		{
 		case( EUninitialized ):
 			{
+		    WRITELOG("CMmcScannerAO::RunL - Starting processing");
+		    if( iMediaId == 0 )
+		        {
+		        WRITELOG("CMmcScannerAO::RunL - MediaId == 0 -> end");
+                SetState( EDone );
+                break;		    
+		        }
+		    
 			WRITELOG("CMmcScannerAO::RunL - Setting files to not present");
 			iMdEClient->SetFilesToNotPresent( iMediaId, ETrue );
 			SetState( EReadFiles );
--- a/harvester/monitorplugins/mmcplugin/src/mmcusbao.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/monitorplugins/mmcplugin/src/mmcusbao.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -136,7 +136,7 @@
             TFileName* fn = new (ELeave) TFileName( driveChar );
             _LIT( KIndicator, ":" );
             fn->Append( KIndicator );
-            WRITELOG1( "CMMCUsbAO::RunL - drive letter: %S", fn );
+            WRITELOG1( "CMMCUsbAO::RunL - drive letter: %S", &(*fn) );
             PrintDriveStatus( driveStatus );
             delete fn;
             fn = NULL;
--- a/harvester/server/inc/harvesterao.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/server/inc/harvesterao.h	Mon Aug 23 13:33:21 2010 +0300
@@ -22,6 +22,8 @@
 #include <e32base.h>
 #include <badesca.h>
 
+#include <rlocationobjectmanipulator.h>
+
 #include "contextengine.h"
 #include "mdeharvestersession.h"
 
@@ -584,7 +586,11 @@
         HBufC* iMmcSoundsPath;
         
         TBool iUnmountDetected;
+        TBool iUnmountHandlingOngoing;
         TBool iPriorityInterruptDetected;
+        
+        RLocationObjectManipulator iLocManipulator;
+        TBool iLocManipulatorConnected;
 	};
 	
 #endif //__CHARVESTERAO_H__
--- a/harvester/server/src/harvesterao.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/server/src/harvesterao.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -19,7 +19,6 @@
 #include <caf/caf.h>
 #include <driveinfo.h>
 
-#include <rlocationobjectmanipulator.h>
 #include <placeholderdata.h>
 #include <harvesterclientdata.h>
 #include <pathinfo.h>
@@ -62,7 +61,7 @@
 _LIT(KVideo, "Video");
 _LIT(KInUse, "InUse");
 
-_LIT(KUndefinedMime, " ");
+_LIT(KUndefined, " ");
 
 _LIT( KExtensionMp4,   "mp4" );
 _LIT( KExtensionMpg4,  "mpg4" );
@@ -156,7 +155,9 @@
     iHarvestingPlaceholders = EFalse;
     
     iUnmountDetected = EFalse;
+    iUnmountHandlingOngoing = EFalse;
     iPriorityInterruptDetected = EFalse;
+    iLocManipulatorConnected = EFalse;
     }
      
 // ---------------------------------------------------------------------------
@@ -172,6 +173,8 @@
 
 	iFs.Close();
 	
+	iLocManipulator.Close();
+	
 	if (iCtxEngine)
 		{
 		iCtxEngine->ReleaseInstance();
@@ -507,6 +510,7 @@
 	OstTrace1( TRACE_NORMAL, CHARVESTERAO_HANDLEUNMOUNT, "CHarvesterAO::HandleUnmount;aMediaId=%d", aMediaId );
     
     iUnmountDetected = ETrue;
+    iUnmountHandlingOngoing = ETrue;
     
     if( !iServerPaused )
         {
@@ -731,12 +735,10 @@
     iMediaIdUtil->RemoveMediaId( aMediaId );
 	
 	// resume harvesting from last state
-    if( !iRamFull && !iDiskFull )
-        {
-        // resume monitoring
-        ResumeMonitoring();
-        TRAP_IGNORE( ResumeHarvesterL() );    
-        }
+    iUnmountHandlingOngoing = EFalse;
+    // resume monitoring
+    ResumeMonitoring();
+    TRAP_IGNORE( ResumeHarvesterL() );    
 	}
 
 // ---------------------------------------------------------------------------
@@ -847,9 +849,9 @@
             {
             SetPriority( KHarvesterCustomImportantPriority );
             }
-    	while( hd != NULL &&
-				iPHArray.Count() < KPlaceholderQueueSize &&
-				hd->ObjectType() == EPlaceholder )
+    	while( hd &&
+			   iPHArray.Count() < KPlaceholderQueueSize &&
+			   hd->ObjectType() == EPlaceholder )
     		{
         	if(iPHArray.Append( hd ) != KErrNone)
         	    {
@@ -985,7 +987,9 @@
 		{
 		CHarvesterData* hd = iPHArray[i];
 		
-		if( aCheck && iHarvesterPluginFactory->IsContainerFileL( hd->Uri() ) )
+		if( aCheck && 
+		    hd->Origin() != MdeConstants::Object::ECamera &&
+		    iHarvesterPluginFactory->IsContainerFileL( hd->Uri() ) )
 			{
 			if( iContainerPHArray.Append( hd ) != KErrNone )
 			    {
@@ -1078,7 +1082,30 @@
 		if( objDefStr.Length() == 0 ||
 		    ( objDefStr == KInUse ) )
 			{
-		    WRITELOG( "CHarvesterAO::HandlePlaceholdersL() - no objectDef or in use, failing harvesting" );
+#ifdef _DEBUG
+		    if( objDefStr.Length() == 0 )
+		        {
+		        WRITELOG( "CHarvesterAO::HandlePlaceholdersL() - no objectDef failing harvesting" );
+		        }
+		    else
+		        {
+		        WRITELOG( "CHarvesterAO::HandlePlaceholdersL() - in use, failing harvesting" );
+		        }
+		    WRITELOG1( "CHarvesterAO::HandlePlaceholdersL() - harvesting failed, uri: %S", &(hd->Uri()) );
+#endif
+		    // If object has not been created in the device so that monitors would have
+		    // picked up creation event, and the file is in use, subclose event will
+		    // not trigger the file to be harvester when closed, thus it needs to be moved 
+		    // to reharvesting queue
+		    if( objDefStr == KInUse &&
+		        !hd->TakeSnapshot() )
+		        {
+		        iPHArray.Remove( i );
+		        i--;
+		        endindex--;
+		        iReHarvester->AddItem( hd );
+		        continue;
+		        }
 			const TInt error( KErrUnknown );
             // notify observer, notification is needed even if file is not supported
             HarvestCompleted( hd->ClientId(), hd->Uri(), error );
@@ -1191,7 +1218,7 @@
             }
         else
             {
-            mdeObject->AddTextPropertyL( *iPropDefs->iItemTypePropertyDef, KUndefinedMime );
+            mdeObject->AddTextPropertyL( *iPropDefs->iItemTypePropertyDef, KUndefined );
             }
 		
         if( hd->Origin() == MdeConstants::Object::ECamera )
@@ -1213,7 +1240,7 @@
 	        }
 	    else
 	        {
-	        mdeObject->AddTextPropertyL( *iPropDefs->iTitlePropertyDef, KNullDesC );
+	        mdeObject->AddTextPropertyL( *iPropDefs->iTitlePropertyDef, KUndefined );
 	        }
 	    
     	CPlaceholderData* ph = NULL;
@@ -1566,18 +1593,25 @@
 	        		WRITELOG( "CHarvesterAO::HarvestingCompleted() - Creating location object. " );
 	        		OstTrace0( TRACE_NORMAL, DUP6_CHARVESTERAO_HARVESTINGCOMPLETED, "CHarvesterAO::HarvestingCompleted - Creating location object." );
 	        		
-	        		RLocationObjectManipulator lo;
-	        		
-	        		const TInt loError = lo.Connect();     		
+	        		TInt loError( KErrNone ); 
+	        		if( !iLocManipulatorConnected )
+	        		    {
+	        		    loError = iLocManipulator.Connect();
+	        		    if( loError == KErrNone )
+	        		        {
+	        		        iLocManipulatorConnected = ETrue;
+	        		        }
+	        		    }    		
 	        		
 	        		if (loError == KErrNone)
 	        			{
-	        			TInt err = lo.CreateLocationObject( *locData, aHD->MdeObject().Id() );
+	        			TInt err = iLocManipulator.CreateLocationObject( *locData, aHD->MdeObject().Id() );
 	        			if( err != KErrNone )
 	        				{
 	        				WRITELOG( "CHarvesterAO::HarvestingCompleted() - Location object creation failed!!!" );
 	        				OstTrace0( TRACE_NORMAL, DUP7_CHARVESTERAO_HARVESTINGCOMPLETED, "CHarvesterAO::HarvestingCompleted - Location object creation failed!!!" );
-	        				
+	        				iLocManipulator.Close();
+	        				iLocManipulatorConnected = EFalse;
 	        				}
 	        			}
 	        		else
@@ -1585,8 +1619,6 @@
 	        			WRITELOG( "CHarvesterAO::HarvestingCompleted() - LocationObjectManipulator connect failed!!!" );
 	        			OstTrace0( TRACE_NORMAL, DUP8_CHARVESTERAO_HARVESTINGCOMPLETED, "CHarvesterAO::HarvestingCompleted - LocationObjectManipulator connect failed!!" );	        			
 	        			}
-	        		
-	        		lo.Close();
 	        		}
 	        	
 	        	TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, 1 ) );
@@ -1793,31 +1825,38 @@
             if( internalMassStorageError == KErrNone )
                 {
                 const TUint32 massStorageMediaId( internalMassStorageVolumeInfo.iUniqueID );
-                TUint32 mmcMediaId( 0 );
-                TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive ) );
-                if( mmcError == KErrNone )
+                if( massStorageMediaId != 0 )
                     {
-                    TVolumeInfo mmcVolumeInfo;
-                    mmcError = iFs.Volume( mmcVolumeInfo, drive );
+                    TUint32 mmcMediaId( 0 );
+                    TInt mmcDrive( -1 );
+                    TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, mmcDrive ) );
                     if( mmcError == KErrNone )
                         {
-                        mmcMediaId = mmcVolumeInfo.iUniqueID;
+                        if( drive != mmcDrive )
+                            {
+                            TVolumeInfo mmcVolumeInfo;
+                            mmcError = iFs.Volume( mmcVolumeInfo, mmcDrive );
+                            if( mmcError == KErrNone )
+                                {
+                                mmcMediaId = mmcVolumeInfo.iUniqueID;
+                                }                        
+                            }
+                        else
+                            {
+                            mmcMediaId = massStorageMediaId;
+                            }
                         }
-                    }
                 
-                // If removable storage is not found, assume internal mass storage was mounted
-                if( mmcError )
-                    {
-                    if( massStorageMediaId != 0 )
+                    // If removable storage is not found, assume internal mass storage was mounted
+                    if( mmcError )
+                        {
+                        iMdEHarvesterSession->CheckMassStorageMediaId( massStorageMediaId );                  
+                        }
+                    else if( massStorageMediaId != mmcMediaId )
                         {
                         iMdEHarvesterSession->CheckMassStorageMediaId( massStorageMediaId );
-                        }                    
-                    }
-                else if( massStorageMediaId != mmcMediaId && 
-                            massStorageMediaId != 0 )
-                    {
-                    iMdEHarvesterSession->CheckMassStorageMediaId( massStorageMediaId );
-                    }          
+                        }          
+                    }                    
                 }
             }
         }
@@ -1882,11 +1921,6 @@
     iHarvesterPluginFactory->PauseHarvester( ETrue );
     iServerPaused = ETrue;
     
-    if( !iRamFull && !iDiskFull && !iUnmountDetected )
-        {
-        iManualPauseEnabled = ETrue;
-        }
-    
     // Everything is paused
     WRITELOG( "CHarvesterAO::PauseHarvester() - Moving paused state paused" );
     OstTrace0( TRACE_NORMAL, DUP1_CHARVESTERAO_PAUSEHARVESTER, "CHarvesterAO::PauseHarvester - Moving paused state paused" );
@@ -1902,17 +1936,19 @@
     {
     WRITELOG( "CHarvesterAO::ResumeHarvesterL()" );
     OstTrace0( TRACE_NORMAL, CHARVESTERAO_RESUMEHARVESTERL, "CHarvesterAO::ResumeHarvesterL" );
+
+    if( iRamFull || iDiskFull || iUnmountHandlingOngoing || iManualPauseEnabled )
+        {
+        return;
+        }
     
     iHarvesterPluginFactory->PauseHarvester( EFalse );
     iServerPaused = EFalse;
     
-    if( !iManualPauseEnabled &&
-        iNextRequest == ERequestIdle )
+    if( iNextRequest == ERequestIdle )
         {
         SetNextRequest( ERequestHarvest );
-        }
-    
-    iManualPauseEnabled = EFalse;
+        }  
     }
 
 // ---------------------------------------------------------------------------
@@ -1948,6 +1984,12 @@
             iContainerPHArray.Compress();
             iPHArray.Compress();
             iTempReadyPHArray.Compress();
+            
+            if( iLocManipulatorConnected )
+                {
+                iLocManipulator.Close();
+                iLocManipulatorConnected = EFalse;            
+                }
             }
         break;
 
@@ -2066,7 +2108,11 @@
         	while( i < count )
         		{
         		CHarvesterData* hd = iContainerPHArray[0];
-        		iPHArray.Append( hd );
+        		if( iPHArray.Append( hd ) != KErrNone )
+        		    {
+        		    delete hd;
+        		    hd = NULL;
+        		    }
         		iContainerPHArray.Remove( 0 );
         		i++;
         		}
@@ -2093,6 +2139,7 @@
             WRITELOG( "CHarvesterAO::RunL - ERequestPause" );
             OstTrace0( TRACE_NORMAL, DUP6_CHARVESTERAO_RUNL, "CHarvesterAO::RunL - ERequestPause" );
             User::LeaveIfError( PauseHarvester() );
+            iManualPauseEnabled = ETrue;
             iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStatePaused );
             if( iHarvesterStatusObserver )
             	{
@@ -2106,6 +2153,19 @@
             {
             WRITELOG( "CHarvesterAO::RunL - ERequestResume" );
             OstTrace0( TRACE_NORMAL, DUP7_CHARVESTERAO_RUNL, "CHarvesterAO::RunL - ERequestResume" );
+            iManualPauseEnabled = EFalse;
+            // If for some reason, mds session is not (yet) ready, only inform that
+            // server state is no longer paused, but do not restart actual harvesting
+            // yet.
+            if( !iMdeSessionInitialized )
+                {
+                iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateResumed );
+                if( iHarvesterStatusObserver )
+                    {
+                    iHarvesterStatusObserver->ResumeReady( KErrNone );
+                    }
+                break;
+                }
             ResumeHarvesterL();
             iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateResumed );
             if( iHarvesterStatusObserver )
@@ -2303,7 +2363,7 @@
         PauseMonitoring();   
         PauseHarvester();    
         }
-    else if( !iRamFull && !iManualPauseEnabled && iServerPaused )
+    else if( iServerPaused )
         {
         // resume monitoring
         ResumeMonitoring();
@@ -2874,7 +2934,6 @@
             	continue;
             	}
             
-            //if (aMessage.Identity() == msg.Identity())
             if( &req.iSession == &aSession )
             	{
             	err = KErrNone;
@@ -3395,9 +3454,10 @@
 	PauseMonitoring();
 	PauseHarvester();
 	
-	iPHArray.Compress();
-	iReadyPHArray.Compress();
-	iContainerPHArray.Compress();
+    iReadyPHArray.Compress();
+    iContainerPHArray.Compress();
+    iPHArray.Compress();
+    iTempReadyPHArray.Compress();
 	}
 
 void CHarvesterAO::MemoryGood()
@@ -3407,7 +3467,7 @@
     
     iRamFull = EFalse;
     
-    if( !iDiskFull && !iManualPauseEnabled && iServerPaused )
+    if( iServerPaused )
         {
         // resume monitoring
         ResumeMonitoring();
--- a/harvester/server/src/harvesterqueue.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/server/src/harvesterqueue.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -144,7 +144,7 @@
     WRITELOG( "CHarvesterQueue::Append()" );
     TInt err( KErrNone );
 
-    if ( iBlacklist )
+    if ( iBlacklist && aItem->Origin() != MdeConstants::Object::ECamera )
         {
         TUint32 mediaId( 0 );
 		err = iMediaIdUtil->GetMediaId( aItem->Uri(), mediaId );
--- a/harvester/server/src/harvesterserver.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/server/src/harvesterserver.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -162,7 +162,7 @@
     WRITELOG( "CHarvesterServer::NewLC() - begin" );
     
 	CHarvesterServer* self = new (ELeave) CHarvesterServer(
-	        KHarvesterServerSessionPriority, KHarvesterServerPolicy, 
+	        KHarvesterServerHighPriority, KHarvesterServerPolicy, 
 			ESharableSessions );
 	CleanupStack::PushL( self );
 	self->ConstructL();
--- a/harvester/server/src/ondemandao.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/server/src/ondemandao.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -72,7 +72,7 @@
 void COnDemandAO::DoCancel()
 	{
 	WRITELOG("COnDemandAO::DoCancel");
-	iMdEHarvesterSession->CancelHarvestingPrioritizationObserver ();
+	iMdEHarvesterSession->CancelHarvestingPrioritizationObserver();
 	}
 
 void COnDemandAO::StartL()
@@ -80,7 +80,7 @@
 	WRITELOG("COnDemandAO::StartL");
 	// Cancel any request, just to be sure
 	Cancel ();
-	iMdEHarvesterSession->SetHarvestingPrioritizationChunkL ( 16384 );
+	iMdEHarvesterSession->SetHarvestingPrioritizationChunkL( 16384 );
 	WaitHarvestingRequest ();
 	}
 
--- a/harvester/server/src/reharvesterao.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/harvester/server/src/reharvesterao.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -170,13 +170,7 @@
             }
         }
     
-    CMdEObject* mdeObject = &aItem->MdeObject();
-    if( mdeObject )
-    	{
-    	delete mdeObject;
-    	mdeObject = NULL;
-    	aItem->SetMdeObject( NULL );
-    	}
+    aItem->SetMdeObject( NULL );
     
     if(iItems.Append( aItem ) != KErrNone )
         {
--- a/inc/mdcdef.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/inc/mdcdef.h	Mon Aug 23 13:33:21 2010 +0300
@@ -25,7 +25,7 @@
 NONSHARABLE_CLASS(TMdCDef) : protected TMdCSerializationType
 	{
 	protected:
-		TMdCDef(TMdCStructTypes aType) : TMdCSerializationType( aType )
+		TMdCDef(TMdCStructTypes aType) : TMdCSerializationType( aType ), iDefId( 0 )
 			{
 			}
 		
--- a/inc/mdscommoninternal.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/inc/mdscommoninternal.h	Mon Aug 23 13:33:21 2010 +0300
@@ -45,6 +45,9 @@
 
 const TItemId KSystemFavouritesAlbumId = 1;
 
+_LIT( KSystemFavouritesAlbumUri, "defaultalbum_favourites" );
+_LIT( KSystemCapturedAlbumUri, "defaultalbum_captured" );
+
 const TInt KMaxUintValueLength   = 10;
 const TInt KMaxUint64ValueLength = 20;
 
@@ -69,7 +72,7 @@
 
 const TUint32 KNokiaVendorId = 52487775;
 
-const TInt64 KDiskFullThreshold = 1024*50; // 50 kB
+const TInt64 KDiskFullThreshold = 1024*70; // 70 kB, SQLite default maximum journal size
 
 // P&S stuff
 static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
--- a/locationmanager/ReverseGeoCoderPlugin/src/reversegeocoderplugin.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/locationmanager/ReverseGeoCoderPlugin/src/reversegeocoderplugin.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -84,6 +84,7 @@
     {
     LOG( "CReverseGeoCoderPlugin::~CReverseGeoCoderPlugin,begin" );
     delete iRevGeocoder;
+    iRevGeocoder = NULL;    
     iObserver = NULL;
     LOG( "CReverseGeoCoderPlugin::~CReverseGeoCoderPlugin,end" );
     }
--- a/locationmanager/ReverseGeocode/inc/clientengine.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/locationmanager/ReverseGeocode/inc/clientengine.h	Mon Aug 23 13:33:21 2010 +0300
@@ -179,8 +179,12 @@
 	* @return ETrue if silent connection is allowed
 	*/
     TBool SilentConnectionAllowed();
-    
+
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
     private:
+#endif    
     /*
      * Perform the second phase construction of a CClientEngine object.
      */
@@ -208,7 +212,11 @@
      */
     void SetupConnectionL( const TConnectionOption aOption );
 
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
     private:
+#endif  
     //From MHTTPSessionEventCallback
     /*
      * Called by framework to notify about transaction events.
@@ -231,7 +239,12 @@
      */
     TInt MHFRunError( TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent );
 
+    
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
     private:
+#endif 
     // from MMobilityProtocolResp
     void PreferredCarrierAvailable( TAccessPointInfo aOldAPInfo,
                                     TAccessPointInfo aNewAPInfo,
@@ -246,7 +259,11 @@
     TBool IsWlanOnly(const TMobileRoamingStatus& aRoamingStatus,
                 const TCmGenConnSettings& aGenConnSettings) const;
     
-private: // from CActive
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
+    private:
+#endif 
 
 	/**
 	  * RunL
@@ -267,14 +284,22 @@
 	  */	
     TInt RunError(TInt aError);
 
-private:
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
+    private:
+#endif 
 
 	/**
 	  * Submits a HTTP transaction
 	  */
     void DoHTTPGetL();
-   
-private:
+    
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
+    private:
+#endif 
   // declare members
     RSocketServ                 iSocketServ;
     RConnection                 iConnection;
--- a/locationmanager/ReverseGeocode/inc/internalreversegeocode.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/locationmanager/ReverseGeocode/inc/internalreversegeocode.h	Mon Aug 23 13:33:21 2010 +0300
@@ -73,7 +73,11 @@
     */    
     void HandleTimedoutEvent(TInt aErrorCode);
     
-protected:
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
+    protected:
+#endif 
    
    /**
     * Second phase construction
@@ -130,7 +134,11 @@
     const RMobilePhone::TMobilePhoneNetworkInfoV1& 
         GetHomeNetworkInfo(TBool& aHomeNwInfoAvailableFlag);
 
-private:
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
+    private:
+#endif 
 
     /**
      * Starts the timer
@@ -142,7 +150,11 @@
      */	
     void CloseConnection();
 
-private:
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
+    private:
+#endif 
     CXmlHandler *iXmlHandler;
     CClientEngine *iClientEngine;
     CInternalAddressInfo *iAddressInfo;
--- a/locationmanager/ReverseGeocode/inc/xmlhandler.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/locationmanager/ReverseGeocode/inc/xmlhandler.h	Mon Aug 23 13:33:21 2010 +0300
@@ -99,7 +99,12 @@
 
     void StartParsingL(  HBufC8 *aBuf  );
     
-    private: // Constructors
+
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
+    private:
+#endif 
 
 	/**
 	* @param aObserver The observer class to be notified after xml parsing is done
@@ -113,7 +118,12 @@
 	*/	
     void ConstructL();
     
-    private: 
+
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
+    private:
+#endif 
     // from MContentHandler
 
 	/**
@@ -201,8 +211,12 @@
 	* @param aUid  the uid identifying the required interface
 	*/    
     TAny *GetExtendedInterface( const TInt32 aUid );
-    
+
+#ifdef REVERSEGEOCODE_UNIT_TESTCASE
+    public:
+#else    
     private: // Private data
+#endif     
 
     MXmlHandlerObserver& iObserver;
     CParser*             iParser;
--- a/locationmanager/ReverseGeocode/src/clientengine.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/locationmanager/ReverseGeocode/src/clientengine.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -87,6 +87,8 @@
         iMobility->Cancel();
         }
     delete iMobility;
+    iMobility = NULL;
+    
     if(iConnectionSetupDone)
         {
         iSession.Close();
@@ -94,6 +96,7 @@
         iSocketServ.Close();
         }
     delete iUri;
+    iUri = NULL;
    
 	iCmManager.Close();
 
--- a/locationmanager/ReverseGeocode/src/internalreversegeocode.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/locationmanager/ReverseGeocode/src/internalreversegeocode.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -194,9 +194,14 @@
         iTimer = NULL;
         }
     delete iXMLBuf;
+    iXMLBuf = NULL;
     delete iXmlHandler;
+    iXmlHandler = NULL;
     delete iClientEngine;
+    iClientEngine = NULL;
     delete iAddressInfo;
+    iAddressInfo = NULL;
+    
     LOG( "CInternalReverseGeocode::~CInternalReverseGeocode,end" );  
     }
 
--- a/locationmanager/ReverseGeocode/src/xmlhandler.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/locationmanager/ReverseGeocode/src/xmlhandler.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -68,7 +68,9 @@
     {
     LOG("CXmlHandler::~CXmlHandler");
     delete iParser;
+    iParser = NULL;
     delete iBuffer;
+    iBuffer = NULL;
     }
 
 // --------------------------------------------------------------------------
--- a/locationmanager/geoconverter/inc/cgeoconverter.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/locationmanager/geoconverter/inc/cgeoconverter.h	Mon Aug 23 13:33:21 2010 +0300
@@ -63,12 +63,21 @@
     IMPORT_C virtual ~CGeoConverter();
     
     IMPORT_C void ConvertL( const CTelephony::TNetworkInfoV1& aNetworkInfo );
-        
+
+#ifdef GEOCONVERTER_UNIT_TESTCASE
+    public:
+#else
 protected:
+#endif
     // From MLbsLocationInfoConverterObserver
     void OnConversionComplete( TInt aStatusCode );
     
-private:
+#ifdef GEOCONVERTER_UNIT_TESTCASE
+    public:
+#else    
+    private:
+#endif    
+
     /**
      * C++ constructor.
      */
@@ -78,7 +87,12 @@
      */
     void ConstructL();    
     
-private:
+#ifdef GEOCONVERTER_UNIT_TESTCASE
+    public:
+#else    
+    private:
+#endif    
+
     MGeoConverterObserver& iObserver;
 #ifdef LOC_GEOTAGGING_CELLID    
     CLbsLocationInfoConverter*  iLocConverter;
--- a/locationmanager/geoconverter/src/cgeoconverter.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/locationmanager/geoconverter/src/cgeoconverter.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -59,9 +59,13 @@
     LOG("CGeoConverter::~CGeoConverter, begin");
 #ifdef LOC_GEOTAGGING_CELLID    
     delete iGsmCellInfo;
+    iGsmCellInfo = NULL;    
     delete iWcdmaCellInfo;
+    iWcdmaCellInfo = NULL;
     delete iLocInfo;
+    iLocInfo = NULL;
     delete iLocConverter;
+    iLocConverter = NULL;
 #endif    
     LOG("CGeoConverter::~CGeoConverter, end");
     }
--- a/locationmanager/geotagger/src/cinternalgeotagger.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/locationmanager/geotagger/src/cinternalgeotagger.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -117,9 +117,11 @@
 	   TRAP_IGNORE(
         iRevGeocoderPlugin = reinterpret_cast<CReverseGeoCoderPlugin*>(
            REComSession::CreateImplementationL(KReverseGeoCodeUid, iDtorKey));)
-
-        iRevGeocoderPlugin->AddObserverL(*this); 
-
+           	
+        if( iRevGeocoderPlugin )
+			{
+            iRevGeocoderPlugin->AddObserverL(*this); 
+			}
 
 #endif //LOC_REVERSEGEOCODE
 
@@ -145,18 +147,21 @@
 		iRelationQuery->RemoveObserver(*this);
 		iRelationQuery->Cancel();
 		delete iRelationQuery;
+		iRelationQuery = NULL;
 		}
 	if(iLocationQuery)
 		{
 		iLocationQuery->RemoveObserver(*this);
 		iLocationQuery->Cancel();
 		delete iLocationQuery;
+		iLocationQuery = NULL;
 		}
 	if(iTagQuery)
 		{
 		iTagQuery->RemoveObserver(*this);
 		iTagQuery->Cancel();
 		delete iTagQuery;
+		iTagQuery = NULL;
 		}	
 #ifdef LOC_REVERSEGEOCODE
     delete iTagCreator;
@@ -168,7 +173,9 @@
     if(iMdeSessionOwnFlag)
         {
     	delete iMdeSession;
+    	iMdeSession = NULL; 
         delete iASW;
+        iASW = NULL;
         }
     LOG("CInternalGeoTagger::~CInternalGeoTagger ,end");
     }
--- a/locationmanager/locationtrail/src/clocationrecord.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/locationmanager/locationtrail/src/clocationrecord.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -138,8 +138,10 @@
 
     iRevGeocoderPlugin = reinterpret_cast<CReverseGeoCoderPlugin*>(
           REComSession::CreateImplementationL(KReverseGeoCodeUid,iDtorKey));
-
-     iRevGeocoderPlugin->AddObserverL(*this);
+     if( iRevGeocoderPlugin )
+	 	{
+     	iRevGeocoderPlugin->AddObserverL(*this);
+	 	}
 
 
  
@@ -217,6 +219,7 @@
 		{
 		iRemapper->StopRemapping();
 		delete iRemapper;
+		iRemapper = NULL;
 		}
     if(iLocationQuery)
 		{
@@ -506,7 +509,7 @@
     
     if ( !iTrailStarted || iState == RLocationTrail::ETrailStopped)
         {
-    	LOG("trail not started/stopped");
+    	LOG("CLocationRecord::Position(), trail not started/stopped");
         iPositionInfo->Stop();
         return;
         }
@@ -530,24 +533,24 @@
         case KPositionQualityLoss: 
             {
             // Location is stored, even if it may not be valid.
-            LOG("Partial update");
+            LOG("CLocationRecord::Position(), Partial update");
             if ( iState != RLocationTrail::EWaitingGPSData && 
             	 iState != RLocationTrail::ETrailStopping ) 
                 {
                 SetCurrentState( RLocationTrail::EWaitingGPSData );
-            	LOG("Trail waiting for gps");
+            	LOG("CLocationRecord::Position(), Trail waiting for gps");
                 }
             break;
             }
         case KErrNone:
             {
-            LOG("Good GPS coordinates");
+            LOG("CLocationRecord::Position(), Good GPS coordinates");
             iGpsDataAvailableFlag = ETrue;
             if ( iState != RLocationTrail::ETrailStarted ) 
                 {
                 if ( iRemapper )
                 	{
-                	LOG("Start remapping");
+                	LOG("CLocationRecord::Position(), Start remapping");
                		iRemapper->StartRemappingObjects( iNewItem.iLocationData );
 
                     if( iObserver->WaitForPositioningStopTimeout() && !RemappingNeeded() )                                
@@ -568,7 +571,7 @@
             }
         default:
             {
-            LOG1("Searching GPS, aError %d", aError );
+            LOG1("CLocationRecord::Position(), Searching GPS, aError %d", aError );
             if ( iState != RLocationTrail::ESearchingGPS &&
                	 iState != RLocationTrail::ETrailStopping ) 
                 {
@@ -579,12 +582,12 @@
             }      
         }
     TBool fixState = CheckGPSFix( positionSatelliteInfo );
-    LOG1( "fixState %d", fixState );
-    LOG1( "iLastGPSFixState %d", iLastGPSFixState );
+    LOG1( "CLocationRecord::Position(), fixState %d", fixState );
+    LOG1( "CLocationRecord::Position(), iLastGPSFixState %d", iLastGPSFixState );
     
     if ( iObserver && iLastGPSFixState != fixState )
     	{
-    	LOG("Quality changed");
+    	LOG("CLocationRecord::Position(), Quality changed");
     	iObserver->GPSSignalQualityChanged( positionSatelliteInfo );
     	}
     
@@ -965,7 +968,7 @@
             {
             // no n/w info... put it into remap.
             // remove the last appended element.
-            LOG("No network info (offline mode + no GPS fix), keep for remapping");
+            LOG("CLocationRecord::LocationSnapshotL(), No network info (offline mode + no GPS fix), keep for remapping");
 			TRemapItem remapItem;
 			remapItem.iObjectId = aObjectId;
 			remapItem.iTime = timestamp;
@@ -974,7 +977,12 @@
 			TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
 			iMediaItems.Remove(iMediaItems.Count() - 1);
 			iMediaItems.Compress();
-			delete firstPtr;
+            if( firstPtr == newItem)
+                {                
+                newItem = NULL;
+                }           
+            delete firstPtr;            
+            firstPtr = NULL;
             }   
         else
             {
@@ -985,6 +993,7 @@
 	else if ( Math::IsNaN( locationData.iPosition.Latitude() ) && 
 			Math::IsNaN( locationData.iPosition.Longitude() ))
 		{
+        LOG("CLocationRecord::LocationSnapshotL(), coordinates empty with or without cellular info")
 	    // coordinates empty, with or without cellular info
 
 		if ( net->iCellId == 0 && 
@@ -992,7 +1001,7 @@
 				net->iCountryCode.Length() == 0 &&
 				net->iNetworkId.Length() == 0 )
 			{
-            LOG("No network info (offline mode + no GPS fix), keep for remapping");
+            LOG("CLocationRecord::LocationSnapshotL(), No network info (offline mode + no GPS fix), keep for remapping");
 			TRemapItem remapItem;
 			remapItem.iObjectId = aObjectId;
 			remapItem.iTime = timestamp;
@@ -1001,7 +1010,12 @@
 			TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
 			iMediaItems.Remove(iMediaItems.Count() - 1);
 			iMediaItems.Compress();
-			delete firstPtr;
+            if( firstPtr == newItem)
+                {                
+                newItem = NULL;
+                }           
+            delete firstPtr;            
+            firstPtr = NULL;
 			}
 		// check match for last created locationobject
 #ifdef LOC_REVERSEGEOCODE
@@ -1011,6 +1025,7 @@
         else if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0)
 #endif //LOC_REVERSEGEOCODE
 			{
+            LOG("CLocationRecord::LocationSnapshotL(), last created locationobject match" );
 			TLocationData lastLocationData = iLastMediaItem.iLocationData;
 			CTelephony::TNetworkInfoV1* lastnet = &lastLocationData.iNetworkInfo;
 
@@ -1035,11 +1050,16 @@
 				TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
 				iMediaItems.Remove(iMediaItems.Count() - 1);
 				iMediaItems.Compress();
-				delete firstPtr;
+	            if( firstPtr == newItem)
+	                {                
+	                newItem = NULL;
+	                }           
+	            delete firstPtr;            
+	            firstPtr = NULL;
 				}
 			}
 		
-		if ( !previousMatch )
+        if (  newItem && !previousMatch )
 		    {
 			// go for n/w based
             newItem->iFlag |= KNetQueryBit;
@@ -1050,6 +1070,7 @@
 	else if ( lastLocationId != 0 && 
         ((iLastMediaItem.iFlag & KSnapMediaFile) > 0))
 		{
+        LOG("CLocationRecord::LocationSnapshotL(), valid coordinates found");
         TLocationData lastLocationData = iLastMediaItem.iLocationData;
 		CTelephony::TNetworkInfoV1* lastnet = &lastLocationData.iNetworkInfo;
 		
@@ -1075,7 +1096,7 @@
 				
 				if ( distance < iLocationDelta )
 					{
-					LOG("location close to the previous one");
+					LOG("CLocationRecord::LocationSnapshotL(), location close to the previous one");
 					previousMatch = ETrue;
 					CreateRelationL( aObjectId, lastLocationId );
 					
@@ -1088,9 +1109,14 @@
                         TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
                         iMediaItems.Remove(iMediaItems.Count() - 1);
                         iMediaItems.Compress();
-                        delete firstPtr;
+                        if( firstPtr == newItem)
+                            {                
+                            newItem = NULL;
+                            }           
+                        delete firstPtr;            
+                        firstPtr = NULL;
 					    }
-					else 
+					else if (newItem)
 					    {
 					    // country tag not found.. go for reverse geocoding..
 					    newItem->iLocationId = lastLocationId;
@@ -1114,7 +1140,12 @@
                     TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
                     iMediaItems.Remove(iMediaItems.Count() - 1);
                     iMediaItems.Compress();
-                    delete firstPtr;
+                    if( firstPtr == newItem)
+                        {                
+                        newItem = NULL;
+                        }           
+                    delete firstPtr;            
+                    firstPtr = NULL;
 
 #endif //LOC_REVERSEGEOCODE
 					}
@@ -1190,7 +1221,7 @@
 	     || (iMediaItems.Count() <= 0))
         {
 		// query is in progress or queue is empty
-		LOG1( "query is in progress or queue is empty. Count - %d", iMediaItems.Count() );
+		LOG1( "CLocationRecord::FindLocationFromDBL(), Count - %d", iMediaItems.Count() );
         return;
         }
      if ( (iMediaItems[0]->iFlag & KNetQueryBit) > 0 )
@@ -1233,10 +1264,10 @@
      CMdELogicCondition& cond = iLocationQuery->Conditions();
      cond.SetOperator( ELogicConditionOperatorAnd );
             
-     LOG1( "latitude: %f", latitude);
-     LOG1( "latdelta: %f", latDelta);
-     LOG1( "longitude: %f", longitude);
-     LOG1( "londelta: %f", lonDelta);
+     LOG1( "CLocationRecord::FindLocationFromDBL(), latitude: %f", latitude);
+     LOG1( "CLocationRecord::FindLocationFromDBL(), latdelta: %f", latDelta);
+     LOG1( "CLocationRecord::FindLocationFromDBL(), longitude: %f", longitude);
+     LOG1( "CLocationRecord::FindLocationFromDBL(), londelta: %f", lonDelta);
             
      cond.AddPropertyConditionL( *iLatitudeDef, 
                     TMdERealBetween( latitude - latDelta, latitude + latDelta ));
@@ -1326,14 +1357,14 @@
 	locationObject->AddTextPropertyL( itemTypeDef, Location::KLocationItemType );
 	locationObject->AddInt16PropertyL( offSetDef, timeOffset.Int() / 60 );
 	
-	LOG1( "Location created with stamp: %Ld", timestamp.Int64() );
+	LOG1( "CLocationRecord::DoCreateLocationL(), Location created with stamp: %Ld", timestamp.Int64() );
 	
 	// location related properties
 	if ( !Math::IsNaN( aLocationData.iPosition.Latitude() ) && 
 		 !Math::IsNaN( aLocationData.iPosition.Longitude() ))
 		{
-        LOG1("Lan - %f", aLocationData.iPosition.Latitude());
-        LOG1("Lon - %f", aLocationData.iPosition.Longitude());
+        LOG1("CLocationRecord::DoCreateLocationL(), Lan - %f", aLocationData.iPosition.Latitude());
+        LOG1("CLocationRecord::DoCreateLocationL(), Lon - %f", aLocationData.iPosition.Longitude());
 		locationObject->AddReal64PropertyL( *iLatitudeDef, aLocationData.iPosition.Latitude() );
 		locationObject->AddReal64PropertyL( *iLongitudeDef, aLocationData.iPosition.Longitude() );
 
@@ -1358,29 +1389,44 @@
 	// network related properties
 	if ( aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown )
 		{
-		LOG1("Cell id - %d", aLocationData.iNetworkInfo.iCellId);
+		LOG1("CLocationRecord::DoCreateLocationL(), Cell id - %d", aLocationData.iNetworkInfo.iCellId);
 		locationObject->AddUint32PropertyL( cellIdDef, aLocationData.iNetworkInfo.iCellId );
 		}
 	if ( aLocationData.iNetworkInfo.iAreaKnown && 
         aLocationData.iNetworkInfo.iLocationAreaCode != 0 &&
 		aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown )
 		{
-		LOG1("Areacode - %d", aLocationData.iNetworkInfo.iLocationAreaCode);
+		LOG1("CLocationRecord::DoCreateLocationL(), Areacode - %d", aLocationData.iNetworkInfo.iLocationAreaCode);
 		locationObject->AddUint32PropertyL( locationCodeDef, 
 				aLocationData.iNetworkInfo.iLocationAreaCode );
 		}
 #ifdef _DEBUG
-    TLex lexer( aLocationData.iNetworkInfo.iCountryCode );
-    TUint countryCode = 0;
-    
-    User::LeaveIfError( lexer.Val( countryCode, EDecimal) );
-    LOG1("Country code - %d", countryCode);
+	
+    if ( aLocationData.iNetworkInfo.iCountryCode.Length() > 0 )
+        {
+        TLex lexer( aLocationData.iNetworkInfo.iCountryCode );
+        TUint countryCode = 0;    
+        TRAP_IGNORE(lexer.Val( countryCode, EDecimal));        
+        LOG1("CLocationRecord::DoCreateLocationL(), Country code - %d", countryCode);
+        }
+    else
+        {
+        LOG("CLocationRecord::DoCreateLocationL(), No Country code");
+        }
     
     //Set mobile network code
-    lexer = aLocationData.iNetworkInfo.iNetworkId;
-    TUint networkCode = 0;
-    User::LeaveIfError( lexer.Val( networkCode, EDecimal) );
-    LOG1("Network id - %d", networkCode);
+    if ( aLocationData.iNetworkInfo.iNetworkId.Length() > 0 )
+        {
+        TLex lexer = aLocationData.iNetworkInfo.iNetworkId;
+        TUint networkCode = 0;
+        TRAP_IGNORE(lexer.Val( networkCode, EDecimal));
+        LOG1("CLocationRecord::DoCreateLocationL(), Network id - %d", networkCode); 
+        }
+    else
+        {
+        LOG("CLocationRecord::DoCreateLocationL(), No network code");
+        }
+
 #endif
 	if ( aLocationData.iNetworkInfo.iCountryCode.Length() > 0 )
 		{
@@ -1395,7 +1441,7 @@
 	        
 	// Add the location object to the database.
 	locationObjectId = iMdeSession->AddObjectL( *locationObject );
-    LOG1("Location id - %d", locationObjectId);
+    LOG1("CLocationRecord::DoCreateLocationL(), Location id - %d", locationObjectId);
 	CleanupStack::PopAndDestroy( locationObject );
     LOG( "CLocationRecord::DoCreateLocationL(), end" );
 
@@ -2194,6 +2240,11 @@
     CMdEProperty* property = NULL;
     
     object = iMdeSession->GetObjectL( aObjectId );
+    if( !object )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
     CleanupStack::PushL( object );
     object->Property( timeDef, property, 0 );
     if ( !property )
@@ -2203,7 +2254,10 @@
     
     const TTime timeValue( property->TimeValueL() );
     CleanupStack::PopAndDestroy( object );
+    
+    LOG( "CLocationRecord::GetMdeObjectTimeL(), end" );
     return timeValue;
+        
     }
 
 
--- a/mds_plat/harvester_framework_api/inc/harvesterclient.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/mds_plat/harvester_framework_api/inc/harvesterclient.h	Mon Aug 23 13:33:21 2010 +0300
@@ -32,7 +32,6 @@
 class MHarvesterEventObserver;
 class CHarvesterRequestActive;
 class CHarvesterRequestQueue;
-class CHarvesterNotificationQueue;
 class MHarvesterSessionObserver;
 class CHarvesterSessionWatcher;
 
@@ -337,9 +336,8 @@
          * @param aService  Service request which to execute on server side
          * @param aArgs     Parameters for harvesting
          * @param aStatus   Status of the asunchronous call
-		 * @param aUri      Uri of the file to be harvested
          */ 
-        void HarvestFile( TInt& aService, TIpcArgs& aArgs, TRequestStatus& aStatus, TDesC& aUri );
+        void HarvestFile( TInt& aService, TIpcArgs& aArgs, TRequestStatus& aStatus  );
 
         /**
          * Restricted method for doing fast harvesting. These files
@@ -362,6 +360,11 @@
          * Private method for version.
          */      
         TVersion Version() const;
+
+        /**
+         * Harvester client active object.
+         */    
+        CHarvesterClientAO* iHarvesterClientAO;
         
         /** 
          * Pointer to Harvester event observer active object.
@@ -372,11 +375,6 @@
          * Request queue processor.
          */
         CHarvesterRequestQueue* iRequestQueue;
-
-        /**
-         * Notification queue processor.
-         */
-        CHarvesterNotificationQueue* iNotificationQueue;
         
         /**
          * Harvester session observer AO.
--- a/mds_plat/harvester_framework_api/inc/harvesterplugin.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/mds_plat/harvester_framework_api/inc/harvesterplugin.h	Mon Aug 23 13:33:21 2010 +0300
@@ -160,6 +160,11 @@
 	 * @param aBlacklist  Reference to blacklisting component.
 	 */
 	IMPORT_C virtual void SetBlacklist( CHarvesterBlacklist& aBlacklist );
+	
+    /** 
+	 * Method to stop harvester plugin if needed.
+	 */
+	IMPORT_C virtual void StopHarvest();
 
 protected:
     
@@ -265,6 +270,7 @@
 	CMdEPropertyDef* iTitlePropertyDef;
 	
     TBool iHarvesting;
+    TBool iPaused;
 	
     };
 
--- a/metadataengine/client/src/mdeharvestersession.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/metadataengine/client/src/mdeharvestersession.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -138,8 +138,10 @@
 	WRITELOG( "CMdEHarvesterSession::SetFilesToPresentL -- Start" );
 	if( aUris.Count() != aFileInfos.Count() )
 		{
+#ifdef _DEBUG
 		WRITELOG2( "CMdEHarvesterSession::SetFilesToPresentL -- Leave (%d, %d)", 
 				aUris.Count(), aFileInfos.Count() );
+#endif
 		User::Leave( KErrArgument );
 		}
 
--- a/metadataengine/server/inc/mdssqldbmaintenance.h	Fri Aug 06 09:56:02 2010 +0300
+++ b/metadataengine/server/inc/mdssqldbmaintenance.h	Mon Aug 23 13:33:21 2010 +0300
@@ -55,6 +55,11 @@
         * Drops and re-creates tables
         */
         void CreateDatabaseL();
+
+        /**
+        * Does quick check to the existing database to detect obvious corruption
+        */
+        TBool CheckForCorruptionL();
     };
 
 #endif // __MDSSQLDBMAINTENANCE_H__
--- a/metadataengine/server/src/mdsfindsequence.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/metadataengine/server/src/mdsfindsequence.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -15,6 +15,7 @@
 */
 
 #include <badesca.h>
+#include <mdequery.h>
 
 #include "mdsfindsequence.h"
 
@@ -72,7 +73,7 @@
     , iObserver( &aObserver )
     , iUserLevel( EUserLevelNone )
     {
-	iNotifyCount = KMaxTUint32;
+	iNotifyCount = KMdEQueryDefaultMaxCount;
 
     iFindOperation = NULL;
     }
--- a/metadataengine/server/src/mdsmaintenanceengine.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/metadataengine/server/src/mdsmaintenanceengine.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -120,7 +120,7 @@
     TBool isValid(EFalse);
     TRAPD(err, isValid = iMaintenance->ValidateL( ));
     
-    if(err == KErrCorrupt)
+    if( err == KErrCorrupt )
         {
         DeleteDatabase();
         User::Leave( err );
@@ -174,11 +174,6 @@
 				User::Leave( schemaError );
 				}
 			}
-
-		if ( FailedImports() != 0 )
-  			{
-	       	User::Leave( KErrBadName );
-       		}
 		
 		// try to read default import file from C drive
        	TRAPD( err, ImportMetadataL( aManipulate, aSchema, KMdsDefaultImportFile ) );
@@ -188,6 +183,13 @@
        		// and ignore errors
        		TRAP_IGNORE( ImportMetadataL( aManipulate, aSchema, KMdsDefaultRomImportFile ) );
        		}
+
+#ifdef _DEBUG
+        if ( FailedImports() != 0 )
+            {
+            User::Leave( KErrBadName );
+            }
+#endif
        	
        	__LOG1( ELogAlways, "MDS DB tables created %d", 0 );
 
@@ -206,6 +208,12 @@
 			DeleteDatabase();
 			User::Leave( err );
         	}
+        
+        if( !iMaintenance->CheckForCorruptionL() )
+            {
+            DeleteDatabase();
+            User::Leave( KErrCorrupt );
+            }
         }
     __LOG1( ELogAlways, "CMdSMaintenanceEngine::InstallL complete: %d", 0 );
     }
--- a/metadataengine/server/src/mdsmanipulationengine.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/metadataengine/server/src/mdsmanipulationengine.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -852,11 +852,11 @@
 
 #ifdef _DEBUG    	
     	const TInt64 time = fileInfo.iModifiedTime;
-        RDebug::Print( _L("CMdSManipulationEngine::SetFilesToPresentL: (%d) iSize %u, iModified %Ld, uri %S"),
+        RDebug::Print( _L("CMdSManipulationEngine::SetFilesToPresentL: (%d) uri %S, iSize %u, iModified %Ld"),
         		i,
+        		&uri,
         		fileInfo.iSize,
-        		time,
-        		&uri);
+        		time );
 #endif
 
     	TFilePresentStates placeHolder;
--- a/metadataengine/server/src/mdsnotifycomparator.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/metadataengine/server/src/mdsnotifycomparator.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -1180,7 +1180,7 @@
 		{
 		aSerializedCondition.PositionL( aRelationCondition.iRelationIds.iPtr.iOffset );
 
-		for (TInt i = 0; i < aRelationCondition.iRelationIds.iPtr.iCount; ++i)
+		for (TUint i = 0; i < aRelationCondition.iRelationIds.iPtr.iCount; ++i)
 			{
 			TItemId relationId;
 			aSerializedCondition.ReceiveL( relationId );
--- a/metadataengine/server/src/mdssqldbmaintenance.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/metadataengine/server/src/mdssqldbmaintenance.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -188,7 +188,6 @@
             }
           }
     CleanupStack::PopAndDestroy( &col2propQuery );
-    emptyRowData.Reset();
      
     CleanupStack::PopAndDestroy( &emptyRowData );
     
@@ -227,3 +226,49 @@
 	CleanupStack::PopAndDestroy( &emptyRowData );
     }
 
+TBool CMdSSqlDbMaintenance::CheckForCorruptionL()
+    {
+    // Check the MDS default namespace main table for validity
+    // This table should always contain at least 1 default system folder object
+    _LIT( KValidateData, "SELECT COUNT(*) FROM Object%u;" );
+ 
+    RBuf commonClauseOne;
+    User::LeaveIfError( commonClauseOne.Create( KValidateData.iTypeLength + KMaxUintValueLength ) );
+    CleanupClosePushL( commonClauseOne ); 
+    commonClauseOne.Format( KValidateData, KDefaultNamespaceDefId );    
+    
+    RRowData emptyRowData;
+    CleanupClosePushL( emptyRowData );
+        
+    RMdsStatement validationQuery;
+    CleanupClosePushL( validationQuery );
+    
+    CMdSSqLiteConnection& connection = MMdSDbConnectionPool::GetDefaultDBL();
+    
+    TInt test( KErrNone );
+    TUint32 count( 0 );
+    TRAP( test, connection.ExecuteQueryL( commonClauseOne, validationQuery, emptyRowData ) );
+    if( test == KErrNone )
+        {
+        emptyRowData.AppendL( TColumn( count ) );
+        TRAP( test, connection.NextRowL(validationQuery, emptyRowData));
+        if(test == KErrNone)
+            {
+            emptyRowData.Column(0).Get( count );
+                    
+            if(count <= 0)
+                {
+                test = KErrCorrupt;
+                }
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( &validationQuery );
+     
+    CleanupStack::PopAndDestroy( &emptyRowData );
+    
+    CleanupStack::PopAndDestroy( &commonClauseOne );
+    
+    return ( test == KErrNone );
+    }
+
--- a/metadataengine/server/src/mdssqlobjectmanipulate.cpp	Fri Aug 06 09:56:02 2010 +0300
+++ b/metadataengine/server/src/mdssqlobjectmanipulate.cpp	Mon Aug 23 13:33:21 2010 +0300
@@ -2271,8 +2271,8 @@
 		TPtrC16 uri = aBuffer.ReceivePtr16L();
         objectId = SearchObjectByUriL( uri, flags );
         if ( objectId != KNoId && 
-             objectId != KSystemFavouritesAlbumId && 
-             objectId != KSystemCapturedAlbumId )
+             uri != KSystemFavouritesAlbumUri && 
+             uri != KSystemCapturedAlbumUri )
 			{
 			// unlock object, so update is no possible anymore
 			if ( iLockList.IsLocked( *iNamespaceDef, objectId ) )
--- a/rom/mds_cellid_reverse_geocode_enabled.iby	Fri Aug 06 09:56:02 2010 +0300
+++ b/rom/mds_cellid_reverse_geocode_enabled.iby	Mon Aug 23 13:33:21 2010 +0300
@@ -121,16 +121,4 @@
 data=ZSYSTEM\install\mds_stub.sis	system\install\mds_stub.sis
 data=ZSYSTEM\install\mdswatchdog_stub.sis	system\install\mdswatchdog_stub.sis
 
-data=ZSYSTEM\install\locationmanagerclient_stub.sis       system\install\locationmanagerclient_stub.sis
-data=ZSYSTEM\install\locationtrail_stub.sis       system\install\locationtrail_stub.sis
-data=ZSYSTEM\install\locationmanagerserver_stub.sis       system\install\locationmanagerserver_stub.sis
-
-data=ZSYSTEM\install\ReverseGeocode_stub.sis       system\install\ReverseGeocode_stub.sis
-data=ZSYSTEM\install\ReverseGeoCoderPlugin_stub.sis       system\install\ReverseGeoCoderPlugin_stub.sis
-data=ZSYSTEM\install\tagcreator_stub.sis       system\install\tagcreator_stub.sis
-data=ZSYSTEM\install\geotagger_stub.sis       system\install\geotagger_stub.sis
-data=ZSYSTEM\install\geoconverter_stub.sis       system\install\geoconverter_stub.sis
-
-
-
 #endif //__METADATA_IBY__
--- a/rom/mds_reverse_geocode_enabled_only.iby	Fri Aug 06 09:56:02 2010 +0300
+++ b/rom/mds_reverse_geocode_enabled_only.iby	Mon Aug 23 13:33:21 2010 +0300
@@ -118,11 +118,4 @@
 data=ZSYSTEM\install\mds_stub.sis	system\install\mds_stub.sis
 data=ZSYSTEM\install\mdswatchdog_stub.sis	system\install\mdswatchdog_stub.sis
 
-data=ZSYSTEM\install\locationmanagerclient_stub.sis       system\install\locationmanagerclient_stub.sis
-data=ZSYSTEM\install\locationtrail_stub.sis       system\install\locationtrail_stub.sis
-data=ZSYSTEM\install\locationmanagerserver_stub.sis       system\install\locationmanagerserver_stub.sis
-data=ZSYSTEM\install\ReverseGeocode_stub.sis       system\install\ReverseGeocode_stub.sis
-data=ZSYSTEM\install\ReverseGeoCoderPlugin_stub.sis       system\install\ReverseGeoCoderPlugin_stub.sis
-data=ZSYSTEM\install\tagcreator_stub.sis       system\install\tagcreator_stub.sis
-data=ZSYSTEM\install\geotagger_stub.sis       system\install\geotagger_stub.sis
 #endif //__METADATA_IBY__