Revision: 201017 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 11 May 2010 16:15:58 +0300
branchRCL_3
changeset 13 4e5b531d23cb
parent 11 a2fdc35b8f46
child 14 f962425b9f8b
Revision: 201017 Kit: 201019
voicerecorder/AppSrc/CVRAppUI.cpp
voicerecorder/AppSrc/CVRAppUi.h
voicerecorder/AppSrc/CVRSettingsDialogMMCSupported.cpp
voicerecorder/AppSrc/MVRUSBEventObserver.h
voicerecorder/BWINS/VoiceRecorderUtilsUU.DEF
voicerecorder/Conf/voicerecorder.confml
voicerecorder/EABI/VoiceRecorderUtilsUU.DEF
voicerecorder/RecViewInc/CVRRecView.h
voicerecorder/RecViewSrc/CVRMdaRecorder.cpp
voicerecorder/RecViewSrc/CVRMediaRemovalMonitor.h
voicerecorder/RecViewSrc/CVRRecView.cpp
voicerecorder/RecViewSrc/CVRRecViewModel.cpp
voicerecorder/RecViewSrc/CVRRecViewModel.h
voicerecorder/RecViewSrc/CVRStateInfoPanel.cpp
voicerecorder/RecViewSrc/CVRUSBEventHandler.cpp
voicerecorder/RecViewSrc/CVRUSBEventHandler.h
voicerecorder/RecViewSrc/MVRUSBEventObserver.h
voicerecorder/UtilsInc/VRUSBStateHanlder.h
voicerecorder/UtilsInc/VRUtils.h
voicerecorder/UtilsSrc/VRUSBStateHanlder.cpp
voicerecorder/UtilsSrc/VRUtils.cpp
voicerecorder/group/RecView.mmp
voicerecorder/group/Utils.mmp
voicerecorder/group/VoiceRecorderApp.mmp
voicerecorder/group/voicerecorder.hrh
voicerecorder/group/voicerecorder.rss
voicerecorder/gsplugin/src/CVRGSPluginContainer.cpp
voicerecorder/loc/voicerecorder.loc
voicerecorder/sis/VoiceRecorderCenrep.pkg
--- a/voicerecorder/AppSrc/CVRAppUI.cpp	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/AppSrc/CVRAppUI.cpp	Tue May 11 16:15:58 2010 +0300
@@ -51,7 +51,7 @@
 #ifdef RD_MULTIPLE_DRIVE
 #include <driveinfo.h>
 #endif
-
+#include <aknwaitdialog.h>
 _LIT( KVRCommandRecord, "record" );
 
 // ---------------------------------------------------------------------------
@@ -71,15 +71,15 @@
 //
 CVRAppUi::~CVRAppUi()
     {
-    if ( iActiveWait.IsStarted() )
-    	{
-    	iActiveWait.AsyncStop();
-    	}
-    
-    if ( iDoorObserver )
-         {
-         iDoorObserver->NotifyExit( MApaEmbeddedDocObserver::EEmpty );
-         }
+    if (iActiveWait.IsStarted())
+        {
+        iActiveWait.AsyncStop();
+        }
+
+    if (iDoorObserver)
+        {
+        iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::EEmpty);
+        }
 
 	delete iErrorUI;
 	FeatureManager::UnInitializeLib();
@@ -119,16 +119,16 @@
 		if ( memoStore == EMemoStoreMMC )
 			{
             // check if USB is connected, if so, then need to switch to phone memory
-			if (IsUsbActive())
-				{
-				HBufC* noteText = iCoeEnv->AllocReadResourceLC(
-														 R_QTN_MEMC_VOREC_NOTE1 );
-				CAknInformationNote* infoNote =
-									   new( ELeave ) CAknInformationNote( ETrue );
-				infoNote->ExecuteLD( *noteText );
-				CleanupStack::PopAndDestroy( noteText );
-				VRUtils::SetMemoStoreL( EMemoStorePhoneMemory );				
-				}
+            if (CVRUSBStateHanlder::IsUsbActive())
+                {
+                HBufC* noteText = iCoeEnv->AllocReadResourceLC(
+                        R_QTN_MEMC_VOREC_NOTE1 );
+                CAknInformationNote* infoNote =
+                new( ELeave ) CAknInformationNote( ETrue );
+                infoNote->ExecuteLD( *noteText );
+                CleanupStack::PopAndDestroy( noteText );
+                VRUtils::SetMemoStoreL( EMemoStorePhoneMemory );
+                }
 
 			// MMC not available or locked
 			else if ( memoStore && ( mmcInfo.iDriveLocked || !mmcInfo.iDrivePresent ) )
@@ -160,71 +160,51 @@
 			}
 // for multiple drives
 #else
-		TInt memoDrive = VRUtils::MemoDriveL();
-        TInt defaultDrive = VRUtils::DefaultMemoDriveL();
- 
-        //not default phone memory
-		if ( memoDrive != defaultDrive )
-			{
-             // check if USB is connected, if so, then need to switch to phone memory
-			if (IsUsbActive())
-				{
-				HBufC* noteText = iCoeEnv->AllocReadResourceLC(
-														 R_QTN_MEMC_VOREC_NOTE1 );
-				CAknInformationNote* infoNote =
-									   new( ELeave ) CAknInformationNote( ETrue );
-				infoNote->ExecuteLD( *noteText );
-				CleanupStack::PopAndDestroy( noteText );
-				VRUtils::SetMemoDriveL((TDriveNumber)defaultDrive );
-				}
-			else
-				{
-            	TUint status( 0 );
-	        	VRUtils::GetDriveInfo(memoDrive, status);
-				
-				// Drive not available or locked
-				if ((status & DriveInfo::EDriveLocked) || !(status & DriveInfo::EDrivePresent))
-			    	{
-			    	HBufC* noteText = iCoeEnv->AllocReadResourceLC(R_QTN_MEMC_VOREC_NOTE1 );
-					CAknInformationNote* infoNote = new( ELeave ) CAknInformationNote( ETrue );
-					infoNote->ExecuteLD( *noteText );
-					CleanupStack::PopAndDestroy( noteText );
-					VRUtils::SetMemoDriveL((TDriveNumber)defaultDrive );
-					}
-				else if ( status & DriveInfo::EDriveReadOnly )
-			    	{
-			    	HBufC* noteText = iCoeEnv->AllocReadResourceLC(R_QTN_MEMC_VOREC_NOTE2 );
-					CAknInformationNote* infoNote = new( ELeave ) CAknInformationNote( ETrue );
-					infoNote->ExecuteLD( *noteText );
-					CleanupStack::PopAndDestroy( noteText );				
-					VRUtils::SetMemoDriveL((TDriveNumber)defaultDrive );
-					}
-		    	else if ( status & DriveInfo::EDriveCorrupt )
-			    	{
-			    	// Drive corrupted -> use phone memory
-			    	VRUtils::SetMemoDriveL((TDriveNumber)defaultDrive );
-			    	}
-				}
-			}
 
+        TInt memoDrive = VRUtils::MemoDriveL();
+        if (VRUtils::DriveValid(memoDrive))
+            {
+            VRUtils::SetMemoDriveL((TDriveNumber) memoDrive);
+            }
+        else
+            {
+            TInt defaultDrive = VRUtils::DefaultMemoDriveL(); //eMMC
+            if (defaultDrive == memoDrive)
+                {
+                SetDriveL();
+                }
+            else
+                {
+                if (VRUtils::DriveValid(defaultDrive))
+                    {
+                    VRUtils::SetMemoDriveL((TDriveNumber) defaultDrive);
+                    }
+                else
+                    {
+                    SetDriveL();
+                    }
+                }
+            }
 
-    /***** check if memory is below min value, if yes, close app*****/	
-		RFs& fs( CEikonEnv::Static()->FsSession() );
-		if (SysUtil::DiskSpaceBelowCriticalLevelL( &fs, 0, VRUtils::MemoDriveL()))
-		{			
-	        HBufC* errorText = StringLoader::LoadLC( R_VR_MEMORY_LOW_STOP_WARNING );
-	        CAknErrorNote* dlg = new( ELeave ) CAknErrorNote( ETrue );
-	        dlg->ExecuteLD( *errorText );
-	        CleanupStack::PopAndDestroy( errorText );
-			Exit();
-		}
-	 // check memory size end
+        /***** check if memory is below min value, if yes, close app*****/
+        RFs& fs(CEikonEnv::Static()->FsSession());
+        if (SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0,
+                VRUtils::MemoDriveL()))
+            {
+            HBufC* errorText = StringLoader::LoadLC(
+                    R_VR_MEMORY_LOW_STOP_WARNING);
+            CAknErrorNote* dlg = new (ELeave) CAknErrorNote(ETrue);
+            dlg->ExecuteLD(*errorText);
+            CleanupStack::PopAndDestroy(errorText);
+            Exit();
+            }
+        // check memory size end
 #endif
 
 		}
 
-	CVRRecView* view = CVRRecView::NewLC(
-									R_VR_RECORDER_VIEW, R_VR_RECVIEW_STATES );
+    CVRRecView* view = CVRRecView::NewLC(R_VR_RECORDER_VIEW,
+            R_VR_RECVIEW_STATES);
 
 	AddViewL( view );
 	iLayoutChangeObserver = view;
@@ -233,15 +213,78 @@
 	SetDefaultViewL( *view );
 
     // Activate view straight away, if started through new file service	
-	if ( iEikonEnv->StartedAsServerApp() )
-		{
-    	ActivateLocalViewL( TUid::Uid( KVRRecorderViewUID ),
-        	TUid::Uid( EContextRecordNewForRemote ), KNullDesC8 );        	
-		}        
+    if (iEikonEnv->StartedAsServerApp())
+        {
+        ActivateLocalViewL(TUid::Uid(KVRRecorderViewUID), TUid::Uid(
+                EContextRecordNewForRemote), KNullDesC8);
+        }
 
 	}
 
 // ---------------------------------------------------------------------------
+// Make user insert the SD card, and choose SD card as the memo storage
+// ---------------------------------------------------------------------------
+//
+void CVRAppUi::SetDriveL()
+    {
+    if ( VRUtils::DriveValid( EDriveF ) )
+    	{
+    	VRUtils::SetMemoDriveL((TDriveNumber)EDriveF );
+    	}
+    else
+        {
+        if (CVRUSBStateHanlder::IsUsbActive())
+            {
+            ShowDialogForWaitUSBPluggingOutL();
+            Exit();
+
+            }
+        while (!VRUtils::DriveValid(EDriveF))
+            {
+            if (!ShowDialogForWaitStorageCardL())
+                {
+                Exit();
+                }
+            }
+        // Come to here when drive F is valid
+        VRUtils::SetMemoDriveL((TDriveNumber) EDriveF);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// This method show a dialog to warn user to insert the SD card.
+// ---------------------------------------------------------------------------
+//
+TBool CVRAppUi::ShowDialogForWaitStorageCardL()
+    {
+    HBufC* text = StringLoader::LoadLC( R_QTN_CCOR_INSERT_MMC );
+    CAknQueryDialog* dlg = CAknQueryDialog::NewL();
+    TInt result( dlg->ExecuteLD( R_INSERT_F_CARD_DIALOG, *text ) );
+    CleanupStack::PopAndDestroy( text );
+
+    if ( result )
+    	{
+    	return ETrue;
+    	}
+
+    return EFalse;
+    }
+
+
+TBool CVRAppUi::ShowDialogForWaitUSBPluggingOutL()
+{
+    HBufC* text = StringLoader::LoadLC(R_QTN_USB_MODE_NOTE_MODE);
+    CAknQueryDialog* dlg = CAknQueryDialog::NewL();
+    TInt result(dlg->ExecuteLD(R_INSERT_F_USB_PLUG_IN_DIALOG, *text));
+    CleanupStack::PopAndDestroy(text);
+    if (result)
+        {
+        return ETrue;
+        }
+    return EFalse;    
+}
+
+// ---------------------------------------------------------------------------
 // CVRAppUi::HandleCommandL
 // 
 // ---------------------------------------------------------------------------
@@ -266,17 +309,18 @@
 				iView->HandleCommandL( ECmdCancelNote );				
 				}
 
-			// The file service needs to abort if it's still going on
-			if ( iEmbeddedObserver )
-				{
-				CNewFileServiceBase * iNewFileService = NULL;
-				iNewFileService = dynamic_cast<CNewFileServiceBase*>(iEmbeddedObserver);
-				if(iNewFileService != NULL)
-					{
-					iNewFileService->SetErrorCode(KErrAbort);
-					}
-				iEmbeddedObserver->AbortL();
-				}
+            // The file service needs to abort if it's still going on
+            if (iEmbeddedObserver)
+                {
+                CNewFileServiceBase * iNewFileService = NULL;
+                iNewFileService
+                        = dynamic_cast<CNewFileServiceBase*> (iEmbeddedObserver);
+                if (iNewFileService != NULL)
+                    {
+                    iNewFileService->SetErrorCode(KErrAbort);
+                    }
+                iEmbeddedObserver->AbortL();
+                }
 
             Exit();
 			break;
@@ -288,75 +332,75 @@
 				iView->HandleCommandL( ECmdCancelNote );				
 				}
 
-			// The file service needs to abort if it's still going on
-			if ( iEmbeddedObserver )
-				{
-				CNewFileServiceBase * iNewFileService = NULL;
-				iNewFileService = dynamic_cast<CNewFileServiceBase*>(iEmbeddedObserver);
-				if(iNewFileService != NULL)
-					{
-					iNewFileService->SetErrorCode(KErrAbort);
-					}
-				iEmbeddedObserver->AbortL();
-				}
-			
-			Exit();
+            // The file service needs to abort if it's still going on
+            if (iEmbeddedObserver)
+                {
+                CNewFileServiceBase * iNewFileService = NULL;
+                iNewFileService
+                        = dynamic_cast<CNewFileServiceBase*> (iEmbeddedObserver);
+                if (iNewFileService != NULL)
+                    {
+                    iNewFileService->SetErrorCode(KErrAbort);
+                    }
+                iEmbeddedObserver->AbortL();
+                }
+
+            Exit();
+            break;
+            }
+        case ECmdHelp:
+            {
+            if (FeatureManager::FeatureSupported(KFeatureIdHelp))
+                {
+                if (iIsSettingsOpen)
+                    {
+                    CArrayFix<TCoeHelpContext>* contexts = AppHelpContextL();
+                    contexts->At(0).iContext = KVOREC_HLP_SETTINGS;
+                    HlpLauncher::LaunchHelpApplicationL(
+                            iEikonEnv->WsSession(), contexts);
+                    }
+                else
+                    {
+                    HlpLauncher::LaunchHelpApplicationL(
+                            iEikonEnv->WsSession(), AppHelpContextL());
+                    }
+                }
             break;
-			}
-		case ECmdHelp:
-			{
-			if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
-				{
-				if ( iIsSettingsOpen )
-					{
-					CArrayFix<TCoeHelpContext>* contexts = AppHelpContextL();
-					contexts->At(0).iContext = KVOREC_HLP_SETTINGS;
-					HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
-													contexts );
-					}
-				else
-					{
-					HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
-													AppHelpContextL() );
-					}
-				}
-			break;
-			}
-		case ECmdSettings:
-			{
-			if ( FeatureManager::FeatureSupported( KFeatureIdMmc ) ||
-                 VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) )
-				{
-				iIsSettingsOpen = ETrue;
-				CVRSettingsDialog* settingsDlg = CVRSettingsDialog::NewL();
-				settingsDlg->ExecuteLD( R_VR_SETTINGS_DIALOG );
-				iIsSettingsOpen = EFalse;
-				}
-			break;
-			}
-       	case ECmdNewFileServiceNotify:
-   			{
-			if ( iActiveWait.IsStarted() )
-				{
-				iActiveWait.AsyncStop();
-				}
-			break;
-   			}
-       	case ECmdEmbeddedRecordingReady:
-   			{
-   			if ( iEmbeddedObserver )
-   				{
-   				TBool canExit( ETrue );
-   				
-				TVRSelectionStyle selStyle;
-				TPtrC memoFile( SelectionProviderL()->
-								GetSelectedFilesLC( selStyle )->
-								MdcaPoint( 0 ) );
-				if ( memoFile.Length() > 0 )
-					{   		
-					TFileName myFilename( memoFile );
-					canExit = iEmbeddedObserver->FileCompleteL( myFilename );
-					}
+            }
+        case ECmdSettings:
+            {
+            if (FeatureManager::FeatureSupported(KFeatureIdMmc)
+                    || VRUtils::FeatureEnabled(EVRFeatureShowQualitySetting))
+                {
+                iIsSettingsOpen = ETrue;
+                CVRSettingsDialog* settingsDlg = CVRSettingsDialog::NewL();
+                settingsDlg->ExecuteLD(R_VR_SETTINGS_DIALOG);
+                iIsSettingsOpen = EFalse;
+                }
+            break;
+            }
+        case ECmdNewFileServiceNotify:
+            {
+            if (iActiveWait.IsStarted())
+                {
+                iActiveWait.AsyncStop();
+                }
+            break;
+            }
+        case ECmdEmbeddedRecordingReady:
+            {
+            if (iEmbeddedObserver)
+                {
+                TBool canExit(ETrue);
+
+                TVRSelectionStyle selStyle;
+                TPtrC memoFile(SelectionProviderL()-> GetSelectedFilesLC(
+                        selStyle)-> MdcaPoint(0));
+                if (memoFile.Length() > 0)
+                    {
+                    TFileName myFilename(memoFile);
+                    canExit = iEmbeddedObserver->FileCompleteL(myFilename);
+                    }
 
 				// destroy array from GetSelectedFilesLC()
 				CleanupStack::PopAndDestroy();
@@ -404,12 +448,12 @@
 	{
 	CAknViewAppUi::HandleResourceChangeL( aType );
 
-	if ( aType == KEikDynamicLayoutVariantSwitch ||
-		 aType == KAknsMessageSkinChange )
-		{
-		iLayoutChangeObserver->LayoutChangedL( aType );
-		}
-	}
+    if (aType == KEikDynamicLayoutVariantSwitch || aType
+            == KAknsMessageSkinChange)
+        {
+        iLayoutChangeObserver->LayoutChangedL(aType);
+        }
+    }
 
 // ---------------------------------------------------------------------------
 // CVRAppUi::RecordNewFileL
@@ -439,24 +483,23 @@
     TFileName& aDocumentName, const TDesC8& aTail )
     {
 
-	// Check if we got "-record" as command line parameter
-	// convert 8-bit descriptor to a 16-bit one without altering data.
-	const TUint16* ptr16 = reinterpret_cast< const TUint16* >(
-												   aTail.Ptr() );
-	TPtrC16 tail( ptr16, aTail.Size() >> 1);	
+    // Check if we got "-record" as command line parameter
+    // convert 8-bit descriptor to a 16-bit one without altering data.
+    const TUint16* ptr16 = reinterpret_cast<const TUint16*> (aTail.Ptr());
+    TPtrC16 tail(ptr16, aTail.Size() >> 1);
 
-	if ( aDocumentName.Compare( KVRCommandRecord ) == 0
-		|| tail.Compare( KVRCommandRecord ) == 0 )
-		{
-		// Enter recording context
-		ActivateLocalViewL( TUid::Uid( KVRRecorderViewUID ),
-				TUid::Uid( EContextRecordNewNormal ), KNullDesC8 );
-		return EFalse;
-		}
+    if (aDocumentName.Compare(KVRCommandRecord) == 0 || tail.Compare(
+            KVRCommandRecord) == 0)
+        {
+        // Enter recording context
+        ActivateLocalViewL(TUid::Uid(KVRRecorderViewUID), TUid::Uid(
+                EContextRecordNewNormal), KNullDesC8);
+        return EFalse;
+        }
     else // No record parameter, start normally
         {
-    	ActivateLocalViewL( TUid::Uid( KVRRecorderViewUID ),
-	    	TUid::Uid( EContextEmptyNormal ), KNullDesC8 );        
+        ActivateLocalViewL(TUid::Uid(KVRRecorderViewUID), TUid::Uid(
+                EContextEmptyNormal), KNullDesC8);
         }
         
 	if ( !ConeUtils::FileExists( aDocumentName ) )
@@ -471,9 +514,10 @@
 // 
 // ---------------------------------------------------------------------------
 //
-void CVRAppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent)
+void CVRAppUi::HandleApplicationSpecificEventL(TInt aType,
+        const TWsEvent& aEvent)
     {
-    if( aType == EAknSoftkeyExit )
+    if( aType == EAknSoftkeyExit || aType == KAknShutOrHideApp)
     	{
     	Exit();
     	}
@@ -489,16 +533,5 @@
     {
     iEmbeddedObserver = aObserver;
     }
-    
-    
-// ---------------------------------------------------------------------------
-// CVRAppUi::IsUsbActive  
-// ---------------------------------------------------------------------------
-//
-TBool CVRAppUi::IsUsbActive()
-    {
-    TInt usbState;
-    TInt err = RProperty::Get(  KPSUidUsbWatcher, KUsbWatcherSelectedPersonality,usbState);
-    return !err && usbState == KUsbPersonalityIdMS;
-    }
+
 // End of file
--- a/voicerecorder/AppSrc/CVRAppUi.h	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/AppSrc/CVRAppUi.h	Tue May 11 16:15:58 2010 +0300
@@ -27,11 +27,12 @@
 #include <apparc.h>			// MApaEmbeddedDocObserver
 
 #include "MVREmbeddedObserver.h"
-
+#include "VRUSBStateHanlder.h"
 // FORWARD DECLARATIONS
 class MVRSelectionProvider;
 class CErrorUI;
 class MVRLayoutChangeObserver;
+class CAknWaitDialog;
 
 // CLASS DECLARATION
 /**
@@ -104,7 +105,10 @@
 		*/
 		
 		void HandleApplicationSpecificEventL(TInt aType, const TWsEvent& aEvent);
-		
+
+	private: // from MVRUSBEventObserver
+		void HandleUSBEventL();
+	
 	private: // new methods
 
 		/**
@@ -114,12 +118,23 @@
 		*/
 		MVRSelectionProvider* SelectionProviderL();
 
-		/**
-		* Check USB connection state
-		* interface.
-		* @return True/False
-		*/        
-        TBool IsUsbActive();
+       	
+       	/**
+       	* This method show a dialog to warn user to insert the SD card.
+       	* @return if user insert the SD card or not
+       	*/
+       	static TBool ShowDialogForWaitStorageCardL();
+       	
+        /**
+        * This method show a dialog to warn user to plug the usb cable.
+        * @return if user plug the usb cable or not
+        */
+        static TBool ShowDialogForWaitUSBPluggingOutL();       	
+       	
+       	/**
+       	 * Make user insert the SD card, and choose SD card as the memo storage
+       	 */
+       	void SetDriveL();
 
 	private: // data
 		/**
@@ -148,7 +163,8 @@
 		/*
 		* For help context, whether settings page is active.
 		*/
-		TBool iIsSettingsOpen;
+		TBool iIsSettingsOpen;		
+
 
 	};
 
--- a/voicerecorder/AppSrc/CVRSettingsDialogMMCSupported.cpp	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/AppSrc/CVRSettingsDialogMMCSupported.cpp	Tue May 11 16:15:58 2010 +0300
@@ -177,7 +177,6 @@
     ECFDDialogTypeNormal, 
     R_VOREC_MEMORY_SELECTION_DIALOG, // Default resource Id
     EFalse,
-    AknCommonDialogsDynMem::EMemoryTypePhone |
     AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage |
     AknCommonDialogsDynMem::EMemoryTypeMMCExternal);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voicerecorder/AppSrc/MVRUSBEventObserver.h	Tue May 11 16:15:58 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2002-2006 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: 
+* This class can be used to observe changes that has been happened in
+* CVRUSBEventHandler class 
+*
+*/
+
+
+#ifndef __MVRUSBEVENTOBSERVER_H
+#define __MVRUSBEVENTOBSERVER_H
+
+// INCLUDES
+#include <e32def.h>
+#include <bldvariant.hrh>
+
+// CLASS DECLARATION
+/**
+*  MVRUSBEventObserver
+*/
+class MVRUSBEventObserver
+    {
+    public:  // Constructors and destructor		
+    
+    virtual void HandleUSBEventL() = 0;
+
+	};
+
+#endif      // __MVRUSBEVENTOBSERVER_H
+
+// End of File
--- a/voicerecorder/BWINS/VoiceRecorderUtilsUU.DEF	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/BWINS/VoiceRecorderUtilsUU.DEF	Tue May 11 16:15:58 2010 +0300
@@ -27,5 +27,8 @@
 	?SetQualityL@VRUtils@@SAXW4TVRQuality@@@Z @ 26 NONAME ; void VRUtils::SetQualityL(enum TVRQuality)
 	?ShowMemoryFullConfirmationQuery@VRUtils@@SAXH@Z @ 27 NONAME ; void VRUtils::ShowMemoryFullConfirmationQuery(int)
 	?UnsupportedCallTypeOngoing@VRUtils@@SAHH@Z @ 28 NONAME ; int VRUtils::UnsupportedCallTypeOngoing(int)
-	?GetDriveInfo@VRUtils@@SAXHAAI@Z @ 29 NONAME ; void VRUtils::GetDriveInfo(int, unsigned int &)
+	?GetDriveInfo@VRUtils@@SAHHAAI@Z @ 29 NONAME ; int VRUtils::GetDriveInfo(int, unsigned int &)
+	?IsUsbActive@CVRUSBStateHanlder@@SAHXZ @ 30 NONAME ; int CVRUSBStateHanlder::IsUsbActive(void)
+	?NewL@CVRUSBStateHanlder@@SAPAV1@PAVMVRUSBStateObserver@@@Z @ 31 NONAME ; class CVRUSBStateHanlder * CVRUSBStateHanlder::NewL(class MVRUSBStateObserver *)
+	?DriveValid@VRUtils@@SAHH@Z @ 32 NONAME ; int VRUtils::DriveValid(int)
 
Binary file voicerecorder/Conf/voicerecorder.confml has changed
--- a/voicerecorder/EABI/VoiceRecorderUtilsUU.DEF	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/EABI/VoiceRecorderUtilsUU.DEF	Tue May 11 16:15:58 2010 +0300
@@ -29,4 +29,9 @@
 	_ZN7VRUtils12GetDriveInfoEiRj @ 28 NONAME
 	_ZN7VRUtils13SetMemoDriveLE12TDriveNumber @ 29 NONAME
 	_ZN7VRUtils17DefaultMemoDriveLEv @ 30 NONAME
+	_ZN18CVRUSBStateHanlder11IsUsbActiveEv @ 31 NONAME
+	_ZN18CVRUSBStateHanlder4NewLEP19MVRUSBStateObserver @ 32 NONAME
+	_ZN7VRUtils10DriveValidEi @ 33 NONAME
+	_ZTI18CVRUSBStateHanlder @ 34 NONAME
+	_ZTV18CVRUSBStateHanlder @ 35 NONAME
 
--- a/voicerecorder/RecViewInc/CVRRecView.h	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/RecViewInc/CVRRecView.h	Tue May 11 16:15:58 2010 +0300
@@ -25,10 +25,14 @@
 
 // INCLUDES
 #include <aknview.h>
+#include <VoiceRecorderContexts.h>
+#include <voicerecorder.rsg>
+#include <aknwaitdialog.h>
+
 #include "MVRSelectionProvider.h"
 #include "MVRLayoutChangeObserver.h"
-#include <VoiceRecorderContexts.h>
 #include "voicerecorder.hrh"
+#include "VRUSBStateHanlder.h"
 
 // FORWARD DECLARATIONS
 class CAknLaunchAppService;
@@ -39,16 +43,19 @@
 
 // CLASS DEFINITION
 /**
-* CVRRecView is an CAknView inherited view class that implements
-* the recorder view functionality of Voicer Recorder.
-* It owns the view container (which, in turn, owns all the ui controls)
-* and the view model.
-*/
-class CVRRecView 
-	: public CAknView, public MVRSelectionProvider, 
-	  public MVRLayoutChangeObserver
-	{
-	private:	// nested classes
+ * CVRRecView is an CAknView inherited view class that implements
+ * the recorder view functionality of Voicer Recorder.
+ * It owns the view container (which, in turn, owns all the ui controls)
+ * and the view model.
+ */
+class CVRRecView : public CAknView,
+        public MVRSelectionProvider,
+        public MVRLayoutChangeObserver,
+        public MVRUSBStateObserver,
+        public MProgressDialogCallback
+    {
+private:
+    // nested classes
 
         /*
         * One shot class for model activation. Receives a pointer to
@@ -265,32 +272,39 @@
 								  TUid aCustomMessageId,
 								  const TDesC8& aCustomMessage );
 
-		/*
-		* Called by iModelActivator object after model has been
-		* fully activated.
-		* @param aRecView Always a valid pointer to CVRRecView object
-		* @return Return value required by TCallBack, not used.
-		*/
-		static TInt ActivationCallBack( TAny* aRecView );
-		
-		/*
-		* Non-static method called by ActivationCallBack. Activates
-		* the actual UI container and deletes the empty one.
-		*/
-		void ActivateContainerL();
-								  
-	private: // data
-		
-		/**
-		* Pointer to the UI control container. Owned.
-		*/
-		CVRRecViewContainer* iContainer;
-		
-		/**
-		* Pointer to the container that is displayed during
-		* model construction. Owned
-		*/
-		CVRRecViewActivationContainer* iActivationContainer;		
+    /*
+     * Called by iModelActivator object after model has been
+     * fully activated.
+     * @param aRecView Always a valid pointer to CVRRecView object
+     * @return Return value required by TCallBack, not used.
+     */
+    static TInt ActivationCallBack(TAny* aRecView);
+
+    /*
+     * Non-static method called by ActivationCallBack. Activates
+     * the actual UI container and deletes the empty one.
+     */
+    void ActivateContainerL();    
+   
+public:
+    virtual TInt HandleUsbPlugInL();
+    virtual TInt HandleUsbPlugOutL();
+    
+    virtual void DialogDismissedL( TInt aButtonId );
+
+private:
+    // data
+
+    /**
+     * Pointer to the UI control container. Owned.
+     */
+    CVRRecViewContainer* iContainer;
+
+    /**
+     * Pointer to the container that is displayed during
+     * model construction. Owned
+     */
+    CVRRecViewActivationContainer* iActivationContainer;
 
 		/**
 		* Pointer to the view model (statemachine). Owned.
@@ -308,14 +322,19 @@
 		*/
 		CVRRecViewModelActivator* iModelActivator;
 
-		/**
-		* The command that passed to Handlecommand
-		* 
-		*/
-        TInt iCommand;
-        
-        CAknLaunchAppService* iLaunchService;
-	};
+    /**
+     * The command that passed to Handlecommand
+     * 
+     */
+    TInt iCommand;
+
+    CAknLaunchAppService* iLaunchService;
+    
+    CAknWaitDialog* iUsbWaitDialog;
+    
+    CVRUSBStateHanlder* iUSBStateHandler;
+    
+    };
 
 #endif // __CVRRECVIEW_H__
 
--- a/voicerecorder/RecViewSrc/CVRMdaRecorder.cpp	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRMdaRecorder.cpp	Tue May 11 16:15:58 2010 +0300
@@ -187,11 +187,11 @@
         	iViewModel = dynamic_cast <CVRRecViewModel*>(iAutoStopObserver);
         	if(iViewModel != NULL)
         		{
-        		iViewModel->HandleCommandL(EEikCmdExit);
+        		TRAP_IGNORE( iViewModel->HandleCommandL(EEikCmdExit) );
         		}
         	else
         		{
-        		CEikonEnv::Static()->EikAppUi()->HandleCommandL( EAknSoftkeyExit);
+        		TRAP_IGNORE( CEikonEnv::Static()->EikAppUi()->HandleCommandL( EAknSoftkeyExit) );
         		}
         	}
  		
@@ -934,10 +934,15 @@
         iPropVRState.Set( KPSUidVoiceRecorder, KVoiceRecorderMode, EVRIdle );
         // Used to check the state of a phone call if any
        
-        if ( iCurrentCallHandler ) delete iCurrentCallHandler;
+        if ( iCurrentCallHandler ) 
+        	{
+        	delete iCurrentCallHandler;
+        	iCurrentCallHandler = NULL;
+        	}
         
     	TRAP_IGNORE( iCurrentCallHandler = CVRSystemEventHandler::NewL() );
-    	TInt currentState( iCurrentCallHandler->StateL(	KPSUidCtsyCallInformation, KCTsyCallState ) );
+    	TInt currentState( 0 );
+    	TRAP_IGNORE( currentState = iCurrentCallHandler->StateL( KPSUidCtsyCallInformation, KCTsyCallState ) );
     	
     	// Do not allow screen saver if there is an active phone call
     	if(currentState == EPSCTsyCallStateRinging)
--- a/voicerecorder/RecViewSrc/CVRMediaRemovalMonitor.h	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRMediaRemovalMonitor.h	Tue May 11 16:15:58 2010 +0300
@@ -27,7 +27,7 @@
  *  @lib Harvester
  *  @since S60 3.0
  */
-class CVRMediaRemovalMonitor : public CActive
+NONSHARABLE_CLASS( CVRMediaRemovalMonitor ) : public CActive
     {
 
 public:
--- a/voicerecorder/RecViewSrc/CVRRecView.cpp	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRRecView.cpp	Tue May 11 16:15:58 2010 +0300
@@ -50,11 +50,38 @@
 #include "CVRRecViewActivationContainer.h"
 #include "CVRRecViewModel.h"
 #include "VRUtils.h"
+#include "VRUSBStateHanlder.h"
 
 // CONSTANTS
-const TUid KUidMmsEditor = { 0x100058DE };
-const TUid KUidMailEditor = { 0x101F4CD6 };
+const TUid KUidMmsEditor =
+    {
+    0x100058DE
+    };
+const TUid KUidMailEditor =
+    {
+    0x101F4CD6
+    };
 
+inline TBool ShowDialogForWaitUSBPluggingOutL()
+    {
+    HBufC* text = StringLoader::LoadLC(R_QTN_USB_MODE_NOTE_MODE);
+    CAknQueryDialog* dlg = CAknQueryDialog::NewL();
+    TInt result(dlg->ExecuteLD(R_INSERT_F_USB_PLUG_IN_DIALOG, *text));
+    CleanupStack::PopAndDestroy(text);
+    if (result)
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+inline TInt WaitDialogForUSBPluggingOut(CAknWaitDialog*& aDialog)
+    {
+    aDialog = new (ELeave) CAknWaitDialog(
+            (REINTERPRET_CAST(CEikDialog**,&aDialog)));
+    aDialog->SetTone(CAknNoteDialog::EConfirmationTone);
+    return aDialog->ExecuteLD(R_VOREC_USB_CONNECTED_DIALOG);
+    }
 
 // ================= MEMBER FUNCTIONS ========================================
 
@@ -63,12 +90,12 @@
 // 
 // ---------------------------------------------------------------------------
 //
-CVRRecView::CVRRecViewModelActivator::CVRRecViewModelActivator( 
-	CVRRecViewModel* aModel )
-	: CAsyncOneShot( EPriorityNormal ), iModel( aModel ),
-	  iContext( EContextEmptyNormal )
-	{
-	}
+CVRRecView::CVRRecViewModelActivator::CVRRecViewModelActivator(
+        CVRRecViewModel* aModel) :
+    CAsyncOneShot(EPriorityNormal), iModel(aModel), iContext(
+            EContextEmptyNormal)
+    {
+    }
 
 
 // ---------------------------------------------------------------------------
@@ -157,14 +184,19 @@
 		AppUi()->RemoveFromViewStack( *this, iActivationContainer );
 		}
 
-	delete iContainer;
-	delete iActivationContainer;
-	delete iModel;
-	delete iSendUi;
-	delete iModelActivator;
-	delete iLaunchService;
-	}
+    delete iContainer;
+    delete iActivationContainer;
+    delete iModel;
+    delete iSendUi;
+    delete iModelActivator;
+    delete iLaunchService;
+    delete iUSBStateHandler;
 
+    if (iUsbWaitDialog)
+        {
+        TRAP_IGNORE(iUsbWaitDialog->ProcessFinishedL());
+        }
+    }
 
 // ---------------------------------------------------------------------------
 // CVRRecView::ConstructL
@@ -181,13 +213,19 @@
 	iModel->ConstructFromResourceL( reader );
 	CleanupStack::PopAndDestroy(); // reader;
 
-	// Create SendUi (Send as MMS, E-Mail, etc...)
-	iSendUi = CSendUi::NewL();
-	
-	iModelActivator = new(ELeave) CVRRecViewModelActivator( iModel );
- //       iCommand = 0;
-	}
+    // Create SendUi (Send as MMS, E-Mail, etc...)
+    iSendUi = CSendUi::NewL();
+
+    iModelActivator = new (ELeave) CVRRecViewModelActivator(iModel);
+
+    iUSBStateHandler = CVRUSBStateHanlder::NewL(this);
 
+    if (CVRUSBStateHanlder::IsUsbActive())
+        {
+        ShowDialogForWaitUSBPluggingOutL();
+        AppUi()->Exit();
+        }
+    }
 
 // ---------------------------------------------------------------------------
 // CVRRecView::Id
@@ -195,8 +233,11 @@
 // ---------------------------------------------------------------------------
 //
 TUid CVRRecView::Id() const
-	{
-	const TUid KVRRecViewUID = { KVRRecorderViewUID };
+    {
+    const TUid KVRRecViewUID =
+        {
+        KVRRecorderViewUID
+        };
 
 	return KVRRecViewUID;
 	}
@@ -267,52 +308,57 @@
 	        VRUtils::MemoStoreDirectoryL( path );
 	        TInt sortMode = 0;
 
-	        CAiwGenericParamList* inParams = CAiwGenericParamList::NewLC();
-            inParams->AppendL(TAiwGenericParam(
-                EGenericParamDir, TAiwVariant( path ) ) );
-            inParams->AppendL(TAiwGenericParam(
-                EGenericParamDir, TAiwVariant( sortMode ) ) );
+            CAiwGenericParamList* inParams = CAiwGenericParamList::NewLC();
+            inParams->AppendL(TAiwGenericParam(EGenericParamDir, TAiwVariant(
+                    path)));
+            inParams->AppendL(TAiwGenericParam(EGenericParamDir, TAiwVariant(
+                    sortMode)));
             iLaunchService = CAknLaunchAppService::NewL(
-                TUid::Uid( 0x101F84EB ), NULL, inParams );
-            CleanupStack::PopAndDestroy( inParams );
-			break;
-			}
-		case ECmdSendVia:
-			{
-			iModel->SendViaL( iSendUi );
-			break;
-			}
-					
-		// Handles Middle SoftKey presses in this view
-		case ECmdMSK:
-			{
-			// Don't forward the command if dimmed button was clicked or 
-			// if model can't handle commands
-			if ( iModel->ButtonState( iContainer->FocusedButton() ) == EDimmed ||
-				!iModel->CanHandleCommands() )
-				{
-				break;
-				}
-			
-			// Fetch the command to execute 
-			TInt commandId( iModel->CommandId( iContainer->FocusedButton() ) );
-			
-			iModel->HandleCommandL( commandId );
-			AppUi()->HandleCommandL( commandId );
-			
-			iContainer->UpdateButtonPanel( EVRUpdateStateChange );
-			break;
-			}
-		
-		default:
-			{
-			iModel->HandleCommandL( aCommandId );
-			AppUi()->HandleCommandL( aCommandId );
-			break;
-			}
-		}
-	}
+                    TUid::Uid(0x101F84EB), NULL, inParams);
+            CleanupStack::PopAndDestroy(inParams);
+            break;
+            }
+        case ECmdSendVia:
+            {
+            iModel->SendViaL(iSendUi);
+            break;
+            }
+
+            // Handles Middle SoftKey presses in this view
+        case ECmdMSK:
+            {
+            // Don't forward the command if dimmed button was clicked or 
+            // if model can't handle commands
+            if (iModel->ButtonState(iContainer->FocusedButton()) == EDimmed
+                    || !iModel->CanHandleCommands())
+                {
+                break;
+                }
 
+            // Fetch the command to execute 
+            TInt commandId(iModel->CommandId(iContainer->FocusedButton()));
+
+            iModel->HandleCommandL(commandId);
+            AppUi()->HandleCommandL(commandId);
+
+            iContainer->UpdateButtonPanel(EVRUpdateStateChange);
+            break;
+            }
+        case ECmdUSBChange:
+            if (iUsbWaitDialog)
+                {
+                iUsbWaitDialog->ProcessFinishedL();
+                }
+            iContainer->UpdateButtonPanel(EVRUpdateStateChange);
+            break;
+        default:
+            {
+            iModel->HandleCommandL(aCommandId);
+            AppUi()->HandleCommandL(aCommandId);
+            break;
+            }
+        }
+    }
 
 // ---------------------------------------------------------------------------
 // CVRRecView::DynInitMenuPaneL
@@ -328,9 +374,16 @@
 			{
             // Check if HELP is enabled in FeatureManager, if not, disable the Help menu item
             if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
-              {
-                  aMenuPane->SetItemDimmed(ECmdHelp, ETrue);
-              }
+                {
+                aMenuPane->SetItemDimmed(ECmdHelp, ETrue);
+                }
+            if (CVRUSBStateHanlder::IsUsbActive())
+                {
+                aMenuPane->SetItemDimmed(ECmdRecord, ETrue);
+                aMenuPane->SetItemDimmed(ECmdDelete, ETrue);
+                aMenuPane->SetItemDimmed(ECmdRename, ETrue);
+                aMenuPane->SetItemDimmed(ECmdGoToMyClips, ETrue);
+                }
 
 			AddSendToMenuL( aResourceId, aMenuPane );
 			break;
@@ -348,17 +401,21 @@
                   aMenuPane->SetItemDimmed(ECmdHelp, ETrue);
                   }
 
-				appuid = container->Application()->AppDllUid();
-				if ( ( appuid == KUidMmsEditor ) ||
-					 ( appuid == KUidMailEditor ) )
-					{
-					aMenuPane->SetItemDimmed( ECmdSaveAttachment, ETrue );
-					}
-				else
-					{
-					AddSendToMenuL( aResourceId, aMenuPane );
-					}
-				}
+                if (CVRUSBStateHanlder::IsUsbActive())
+                    {
+                    aMenuPane->SetItemDimmed(ECmdSaveAttachment, ETrue);
+                    }
+
+                appuid = container->Application()->AppDllUid();
+                if ((appuid == KUidMmsEditor) || (appuid == KUidMailEditor))
+                    {
+                    aMenuPane->SetItemDimmed(ECmdSaveAttachment, ETrue);
+                    }
+                else
+                    {
+                    AddSendToMenuL(aResourceId, aMenuPane);
+                    }
+                }
 
 			break;
 			}
@@ -380,26 +437,44 @@
 				aMenuPane->SetItemDimmed(ECmdHelp, ETrue);
 				}
 
-			// if recording already started, not allow to start recording again.	
-  			if (iModel->GetInRecordingFlag())
-				{
-				aMenuPane->SetItemDimmed(ECmdRecord, ETrue);
-				aMenuPane->SetItemDimmed(ECmdSettings, ETrue);
+            if (CVRUSBStateHanlder::IsUsbActive())
+                {
+                aMenuPane->SetItemDimmed(ECmdRecord, ETrue);
+                aMenuPane->SetItemDimmed(ECmdGoToMyClips, ETrue);
+
+                }
+
+            // if recording already started, not allow to start recording again.    
+            if (iModel->GetInRecordingFlag())
+                {
+                aMenuPane->SetItemDimmed(ECmdRecord, ETrue);
+                aMenuPane->SetItemDimmed(ECmdSettings, ETrue);
                 iModel->SetInRecordingFlag(EFalse);
-				}
-   
-         break; 
-			}
+                }
+
+            if (CVRUSBStateHanlder::IsUsbActive())
+                {
+                aMenuPane->SetItemDimmed(ECmdRecord, ETrue);
+                aMenuPane->SetItemDimmed(ECmdGoToMyClips, ETrue);
+                }
+
+            break;
+            }
 
-		case R_VR_REC_MENUPANE_INCALL_RECORDING_DISABLED:
-			{
-			// Check if HELP is enabled in FeatureManager, if not, disable the Help menu item
-			if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
-				{
-				aMenuPane->SetItemDimmed(ECmdHelp, ETrue);
-				}
-            break; 
-			}
+        case R_VR_REC_MENUPANE_INCALL_RECORDING_DISABLED:
+            {
+            // Check if HELP is enabled in FeatureManager, if not, disable the Help menu item
+            if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
+                {
+                aMenuPane->SetItemDimmed(ECmdHelp, ETrue);
+                }
+
+            if (CVRUSBStateHanlder::IsUsbActive())
+                {
+                aMenuPane->SetItemDimmed(ECmdGoToMyClips, ETrue);
+                }
+            break;
+            }
 
 		case R_VOREC_GS_SETTINGS_MENUPANE:
 			{
@@ -436,15 +511,14 @@
 // 
 // ---------------------------------------------------------------------------
 //
-void CVRRecView::DoActivateL( const TVwsViewId& aPrevViewId,
-							 TUid aCustomMessageId,
-							 const TDesC8& aCustomMessage )
-	{
-	TRAP_IGNORE( ReallyDoActivateL( aPrevViewId, 
-									aCustomMessageId, 
-									aCustomMessage ) );
-	}
+void CVRRecView::DoActivateL(const TVwsViewId& aPrevViewId,
+        TUid aCustomMessageId, const TDesC8& aCustomMessage)
+    {
+    TRAP_IGNORE( ReallyDoActivateL( aPrevViewId,
+                    aCustomMessageId,
+                    aCustomMessage ) );
 
+    }
 
 // ---------------------------------------------------------------------------
 // CVRRecView::DoDeactivate
@@ -487,16 +561,17 @@
 #endif
 
     TInt err = 0;
-    
-	if ( !iModel->IncomingCall() && ( iModel->VisualStateId() == EStatePlaying ||
-         iModel->VisualStateId() == EStateRecording ) )
-		{
-        
-        if (iModel->VisualStateId() == EStateRecording && iCommand ==  ECmdCancelNote )
-        	{
-		    TRAP_IGNORE (iModel->HandleCommandL( ECmdSaveAttachment ));	
-        	}
-        
+
+    if (!iModel->IncomingCall() && (iModel->VisualStateId() == EStatePlaying
+            || iModel->VisualStateId() == EStateRecording))
+        {
+
+        if (iModel->VisualStateId() == EStateRecording && iCommand
+                == ECmdCancelNote)
+            {
+            TRAP_IGNORE (iModel->HandleCommandL( ECmdSaveAttachment ));
+            }
+
         // Is autolock activating? 
         RProperty prop;
         TInt val;
@@ -508,14 +583,15 @@
     		
 		//messy, if it is ACC format, stop it. in the future when Pause is supported, it needs change 
 #ifdef    __AAC_ENCODER_PLUGIN 
-    			if  ((iModel->Quality() == EQualityHigh) && (GetStateId() == EStateRecording))
-					{
-					TRAP_IGNORE (iModel->HandleCommandL( ECmdAutoStopInterrupted ));
-					}
-    			else
-    				{
-					TRAP( err, iModel->HandleCommandL( ECmdPause ) );	    		
-    				}
+            if ((iModel->Quality() == EQualityHigh) && (GetStateId()
+                    == EStateRecording))
+                {
+                TRAP_IGNORE (iModel->HandleCommandL( ECmdAutoStopInterrupted ));
+                }
+            else
+                {
+                TRAP( err, iModel->HandleCommandL( ECmdPause ) );
+                }
 
 #else			
 	    		TRAP( err, iModel->HandleCommandL( ECmdPause ) );	
@@ -525,11 +601,12 @@
 				if( err )
 					{	
 #ifdef _DEBUG
-					RDebug::Print( _L("CVRRecView::ViewDeactivated, PauseError Id: %d"), 
-					err );
-#endif		
-					}	
-    		}
+                RDebug::Print(
+                        _L("CVRRecView::ViewDeactivated, PauseError Id: %d"),
+                        err);
+#endif      
+                }
+            }
 
 		}
 	else
@@ -549,8 +626,7 @@
 // ---------------------------------------------------------------------------
 //
 void CVRRecView::ViewActivatedL(const TVwsViewId& aPrevViewId,
-								TUid aCustomMessageId,
-								const TDesC8& aCustomMessage)
+        TUid aCustomMessageId, const TDesC8& aCustomMessage)
     {
     // dismiss sound player / file manager if it was active so that recording
     // view becomes visible
@@ -579,39 +655,38 @@
 // Use CSendAppUi to display the Send cascade
 // ---------------------------------------------------------------------------
 //
-void CVRRecView::AddSendToMenuL( TInt aResourceId, CEikMenuPane* aMenuPane )
-	{
-	// If the focused file is closed content (e.g. a DRM file or a protected
-	// MIDI file), the whole Send option mustn't be shown.
-	CCommonContentPolicy* ccp = CCommonContentPolicy::NewLC();
-	MDesCArray* filenames = iModel->GetSelectedFilesLC();
-	if ( filenames->MdcaCount() > 0 &&
-		!ccp->IsClosedFileL( filenames->MdcaPoint( 0 ) ) )
-		{
-		// Set proper capabilities
-		TSendingCapabilities capabilities( 0, KVRSendUiMsgSize,
-								TSendingCapabilities::ESupportsAttachments );
+void CVRRecView::AddSendToMenuL(TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    // If the focused file is closed content (e.g. a DRM file or a protected
+    // MIDI file), the whole Send option mustn't be shown.
+    CCommonContentPolicy* ccp = CCommonContentPolicy::NewLC();
+    MDesCArray* filenames = iModel->GetSelectedFilesLC();
+    if (filenames->MdcaCount() > 0 && !ccp->IsClosedFileL(
+            filenames->MdcaPoint(0)))
+        {
+        // Set proper capabilities
+        TSendingCapabilities capabilities(0, KVRSendUiMsgSize,
+                TSendingCapabilities::ESupportsAttachments);
 
-		// We want the send menuitem after a specific item
-		TInt itemPosForSend( 0 );
-		if ( aResourceId == R_VR_REC_MENUPANE_DEFAULT )
-			{
-			aMenuPane->ItemAndPos( ECmdRename, itemPosForSend );
-			}
-		else if ( aResourceId == R_VR_REC_MENUPANE_VIEWER )
-			{
-			aMenuPane->ItemAndPos( ECmdSaveAttachment, itemPosForSend );
-			}
-		itemPosForSend++;
-
-		iSendUi->AddSendMenuItemL( *aMenuPane, 
-								   itemPosForSend, 
-								   ECmdSendVia, 
-								   capabilities );
-		}
-	CleanupStack::PopAndDestroy( 2 ); // ccp, filenames
-	}
-
+        // We want the send menuitem after a specific item
+        TInt itemPosForSend(0);
+        if (aResourceId == R_VR_REC_MENUPANE_DEFAULT)
+            {
+            aMenuPane->ItemAndPos(ECmdRename, itemPosForSend);
+            }
+        else if (aResourceId == R_VR_REC_MENUPANE_VIEWER)
+            {
+            aMenuPane->ItemAndPos(ECmdSaveAttachment, itemPosForSend);
+            }
+        itemPosForSend++;
+        if (!CVRUSBStateHanlder::IsUsbActive())
+            {
+            iSendUi->AddSendMenuItemL(*aMenuPane, itemPosForSend,
+                    ECmdSendVia, capabilities);
+            }
+        }
+    CleanupStack::PopAndDestroy(2); // ccp, filenames
+    }
 
 // ---------------------------------------------------------------------------
 // CVRRecView::LayoutChangedL
@@ -633,22 +708,21 @@
 // 
 // ---------------------------------------------------------------------------
 //
-void CVRRecView::ReallyDoActivateL( const TVwsViewId& /*aPrevViewId*/,
-									TUid aCustomMessageId,
-									const TDesC8& /*aCustomMessage*/ )
-	{
-	// Don't do anything if activation is ongoing
-	if ( iActivationContainer )
-	    {
-	    return;
-	    }
-	
-	// If container exists, we have already been activated
-	// Deactivate needed before new activation.
-	if ( iContainer )
-		{
-		DoDeactivate();
-		}
+void CVRRecView::ReallyDoActivateL(const TVwsViewId& /*aPrevViewId*/,
+        TUid aCustomMessageId, const TDesC8& /*aCustomMessage*/)
+    {
+    // Don't do anything if activation is ongoing
+    if (iActivationContainer)
+        {
+        return;
+        }
+
+    // If container exists, we have already been activated
+    // Deactivate needed before new activation.
+    if (iContainer)
+        {
+        DoDeactivate();
+        }
 
 	// Display an empty UI container until model has been fully activated
 	iActivationContainer = new( ELeave ) CVRRecViewActivationContainer;
@@ -657,18 +731,18 @@
 	appUi->AddToViewStackL( *this, iActivationContainer );
 	iActivationContainer->ActivateL();
 
-	// Activate model in correct context asynchronically.
-	// iContainer will be activated trough callback after model activation
-	TCallBack cb( ActivationCallBack, this );
-	iModelActivator->Activate( static_cast< TVRRecViewContexts >(
-									aCustomMessageId.iUid ), cb );
-									
-	// Construct the real container
-	iContainer = new( ELeave ) CVRRecViewContainer;
-	iContainer->ConstructL( ClientRect(), iModel, iModel, iModel, this );	
-	iContainer->SetKeyObserver( iModel );
-	iContainer->SetVolumeChangeObserver( iModel );									
-	}
+    // Activate model in correct context asynchronically.
+    // iContainer will be activated trough callback after model activation
+    TCallBack cb(ActivationCallBack, this);
+    iModelActivator->Activate(
+            static_cast<TVRRecViewContexts> (aCustomMessageId.iUid), cb);
+
+    // Construct the real container
+    iContainer = new (ELeave) CVRRecViewContainer;
+    iContainer->ConstructL(ClientRect(), iModel, iModel, iModel, this);
+    iContainer->SetKeyObserver(iModel);
+    iContainer->SetVolumeChangeObserver(iModel);
+    }
 
 
 // ---------------------------------------------------------------------------
@@ -758,6 +832,45 @@
 		return iModel->Quality();
 	}
 
+TInt CVRRecView::HandleUsbPlugInL()
+    {
+    if (EStateRecording == iModel->VisualStateId() || EStateRecordingPaused
+            == iModel->VisualStateId() || EStatePlaying
+            == iModel->VisualStateId() || EStatePlayingPaused
+            == iModel->VisualStateId())
+        {
+        HandleCommandL(ECmdStop);
+        }
+
+    if (EStateIdleEmbedded == iModel->VisualStateId() || EStateRecordEmbedded
+            == iModel->VisualStateId() || EStateIdleRecordEmbedded
+            == iModel->VisualStateId())
+        {
+        ShowDialogForWaitUSBPluggingOutL();
+        AppUi()->Exit();
+        }
+
+    HandleCommandL(ECmdUSBChange);
+    WaitDialogForUSBPluggingOut(iUsbWaitDialog);
+    return KErrNone;
+    }
+
+TInt CVRRecView::HandleUsbPlugOutL()
+    {
+    if (iUsbWaitDialog)
+        {
+        iUsbWaitDialog->ProcessFinishedL();
+        }
+
+    HandleCommandL(ECmdUSBChange);
+    return KErrNone;
+    }
+
+void CVRRecView::DialogDismissedL(TInt /*aButtonId*/)
+    {
+    HandleCommandL(ECmdUSBChange);
+    }
+
 // ---------------------------------------------------------------------------
 // Called by UI Framework when view switches to and from foreground
 // ---------------------------------------------------------------------------
--- a/voicerecorder/RecViewSrc/CVRRecViewModel.cpp	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRRecViewModel.cpp	Tue May 11 16:15:58 2010 +0300
@@ -45,6 +45,9 @@
 #include "MessagingDomainCRKeys.h" // Disable e-mail variation flag
 
 #include <centralrepository.h> // link against centralrepository.lib
+#ifdef RD_MULTIPLE_DRIVE
+#include <driveinfo.h>
+#endif
 #include "VoiceRecorderInternalCRKeys.h"
 
 #include <voicerecorder.rsg>
@@ -53,12 +56,13 @@
 #include "CVRMdaRecorder.h"
 #include "VRConsts.h"
 #include "CVRSystemEventHandler.h"
-#include "CVRUSBEventHandler.h"
 #include "CVRMediaRemovalMonitor.h"
 #include "VRUtils.h"
 #include "CVRRecViewModel.h"
 #include <csxhelp/vorec.hlp.hrh>
 
+#include "VRUSBStateHanlder.h"
+
 
 // CONSTANTS
 const TInt KAllowInCallRecording( 1 );
@@ -113,9 +117,6 @@
 		{
 		delete iCurrentCallHandler;
 		}
-
-	delete iCurrentUSBHandler;
-	
 	delete iCurrentMMCEjectHandler;
 	
 	}
@@ -132,12 +133,6 @@
 	TRAP_IGNORE( iCurrentCallHandler = CVRSystemEventHandler::NewL() );
 	iCurrentCallHandler->Listen( KPSUidCtsyCallInformation, KCTsyCallState, 
 								 this );
-
-    // for USB
-    iCurrentUSBHandler = CVRUSBEventHandler::NewL();
-	iCurrentUSBHandler->Listen( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality,
-								 this );
-
 	//listen MMC eject
 	iCurrentMMCEjectHandler = CVRMediaRemovalMonitor::NewL(EDriveF, CEikonEnv::Static()->FsSession(), this);
 
@@ -808,6 +803,10 @@
 //	
 TInt CVRRecViewModel::ButtonState( TInt aButtonId ) const
 	{
+    if(CVRUSBStateHanlder::IsUsbActive())
+        {
+            return EDimmed;
+        }
 	// Disable rewind button if there's nothing to rewind
 	if ( aButtonId == EButtonRewind &&
 		( Position().Int64() / KVRSecondAsMicroSeconds ) < 1 )
@@ -2209,8 +2208,12 @@
 			
 //multiple drive
 #else
-		if (VRUtils::MemoDriveL() == VRUtils::DefaultMemoDriveL())
-			{
+		TInt memoDrive = VRUtils::MemoDriveL();
+		TUint status( 0 );
+		VRUtils::GetDriveInfo( memoDrive, status );
+		        
+		if ( status & DriveInfo::EDriveInternal )
+		    {
 			ShowNoteL( R_VR_MEMORY_WARNING, EAknGlobalWarningNote );
 			}
 		else
@@ -2411,45 +2414,6 @@
 	}
 
 
-// ---------------------------------------------------------------------------
-// CVRRecViewModel::HandleUSBEventL
-// 
-// ---------------------------------------------------------------------------
-//
-void CVRRecViewModel::HandleUSBEventL()
-	{
-	// Fetch the changed value from Pubsub
-    TInt usbState( 0 );
-    RProperty::Get(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, usbState );
-	if ( !iActive )
-		{
-		return;
-		}
-
-	// Actions to take when playing
-    if ( usbState == KUsbPersonalityIdMS )
-		{
-		ShowNoteL( R_QTN_MEMC_VOREC_NOTE1, EAknGlobalInformationNote );		
-//  when not support multiple drives
-#ifndef RD_MULTIPLE_DRIVE    
-		if (iMemo->MemoStore() != EMemoStorePhoneMemory) 
-			{
-            HandleCommandL( EEikCmdExit);
-			}		
-//multiple drive
-#else
-		if (iMemo->StorageDrive() != VRUtils::DefaultMemoDriveL()) 
-			{
-			
-	        HandleCommandL( EEikCmdExit );
-			}
-#endif			
-		}
-
-	}
-
-
-// End of file
 
 
 // ---------------------------------------------------------------------------
@@ -2462,7 +2426,7 @@
 	
 	// Actions to take when recording
 	TInt storageDrive = VRUtils::MemoDriveL();   	 
-    if ( storageDrive == EDriveF)
+    if ( storageDrive == EDriveF && !CVRUSBStateHanlder::IsUsbActive())
 		{
         //exit for mmc dismount	
         TWsEvent event;
--- a/voicerecorder/RecViewSrc/CVRRecViewModel.h	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRRecViewModel.h	Tue May 11 16:15:58 2010 +0300
@@ -38,7 +38,6 @@
 #include "MVRVolumeChangeObserver.h"
 
 #include "MVRSystemEventObserver.h"
-#include "MVRUSBEventObserver.h"
 #include "MVRMediaRemovalObserver.h"
 
 
@@ -56,7 +55,6 @@
 class TResourceReader;
 class TVRState;
 class CVRSystemEventHandler;
-class CVRUSBEventHandler;
 class CVRMediaRemovalMonitor;
 
 
@@ -71,7 +69,7 @@
 	  public MVRStateInfoModel, public MVRObserver,
 	  public MVRKeyObserver, public MVRVolumeChangeObserver,
       public MVRSystemEventObserver,
-      public MVRUSBEventObserver, public MVRMediaRemovalObserver      
+      public MVRMediaRemovalObserver      
 	{
 	private:	// nested classes
 
@@ -315,10 +313,6 @@
 	
 		void HandleSystemEventL();
 
-
-		void HandleUSBEventL();
-		
-		
 		void HandleMMCEjectEventL();
 		
 	public: // new methods
@@ -656,11 +650,6 @@
 		*/
 		CVRSystemEventHandler* iCurrentCallHandler;
 
-		/**
-		* For listening USB events. Owned.
-		*/
-		CVRUSBEventHandler* iCurrentUSBHandler;
-		
 		CVRMediaRemovalMonitor* iCurrentMMCEjectHandler;
 
 
--- a/voicerecorder/RecViewSrc/CVRStateInfoPanel.cpp	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRStateInfoPanel.cpp	Tue May 11 16:15:58 2010 +0300
@@ -171,12 +171,36 @@
 // ----------------------------------------------------------------------------
 //		
 void CVRStateInfoPanel::SizeChanged()
-	{
-	
-	for ( TInt i = 0; i < ENumLabels; i++ )
-		{
-		TAknTextComponentLayout layoutText = AknLayoutScalable_Apps::vorec_t(
-			KVRLabelMap[i] );
+    {
+    TAknTextComponentLayout layoutText;
+    
+    for ( TInt i = 0; i < ENumLabels; i++ )
+        {
+        switch ( KVRLabelMap[i] )
+            {
+            case 0: 
+                layoutText = AknLayoutScalable_Apps::vorec_t1();
+                break;
+            case 1:
+                layoutText = AknLayoutScalable_Apps::vorec_t2();
+                break;
+            case 2: 
+                layoutText = AknLayoutScalable_Apps::vorec_t3();
+                break;
+            case 3:
+                layoutText = AknLayoutScalable_Apps::vorec_t4();
+                break;
+            case 4: 
+                layoutText = AknLayoutScalable_Apps::vorec_t5();
+                break;
+            case 5:
+                layoutText = AknLayoutScalable_Apps::vorec_t6();
+                break;
+            case 6:
+                layoutText = AknLayoutScalable_Apps::vorec_t7();
+                break;          
+            }
+        
 		AknLayoutUtils::LayoutLabel( iLabels.At( i ), Rect(), layoutText.LayoutLine() );
 		
 		if ( i != ELabelStatus )
--- a/voicerecorder/RecViewSrc/CVRUSBEventHandler.cpp	Tue Apr 27 16:40:59 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +0,0 @@
-/*
-* Copyright (c) 2005 - 2006 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:  An active object class that is used to receive
-*  phone call related events from Publish&Subscribe and forward them
-*  to an MVRUSBEventObserver instance.
-*  Has to be attached to certain P&S -key, so it means having multiple
-*  
-*
-*
-*/
-
-
-// INCLUDE FILES
-#include <e32base.h>
-
-#include "CVRUSBEventHandler.h"
-#include "MVRUSBEventObserver.h"
-
-
-// ================= MEMBER FUNCTIONS ========================================
-
-// ---------------------------------------------------------------------------
-// CVRUSBEventHandler::CVRUSBEventHandler
-// 
-// ---------------------------------------------------------------------------
-//
-CVRUSBEventHandler::CVRUSBEventHandler() : CActive( EPriorityHigh )
-    {
-	CActiveScheduler::Add( this );
-    }
-
-
-// ---------------------------------------------------------------------------
-// CVRUSBEventHandler::ConstructL
-// 
-// ---------------------------------------------------------------------------
-//
-void CVRUSBEventHandler::ConstructL()
-    {
-	
-    }
-
-
-// ---------------------------------------------------------------------------
-// CVRUSBEventHandler::NewL
-// 
-// ---------------------------------------------------------------------------
-//
-// Two-phased constructor.
-CVRUSBEventHandler* CVRUSBEventHandler::NewL()
-    {
-    CVRUSBEventHandler* self = new (ELeave) CVRUSBEventHandler;
-
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop();
-
-    return self;
-    }
-
-
-// ---------------------------------------------------------------------------
-// CVRUSBEventHandler::~CVRUSBEventHandler
-// 
-// ---------------------------------------------------------------------------
-//
-// Destructor
-CVRUSBEventHandler::~CVRUSBEventHandler()
-    {
-	Cancel();
-    }
-
-
-// ---------------------------------------------------------------------------
-// CVRUSBEventHandler::IssueRequest
-// 
-// ---------------------------------------------------------------------------
-//
-void CVRUSBEventHandler::IssueRequest()
-	{
-	SetActive();
-	iProperty.Subscribe( iStatus );
-	}
-
-
-// ---------------------------------------------------------------------------
-// CVRUSBEventHandler::RunL
-// 
-// ---------------------------------------------------------------------------
-//
-void CVRUSBEventHandler::RunL()
-	{
-	// Event received
-
-	if ( iStatus != KErrCancel )
-		{
-		// Request a new event
-		IssueRequest();
-		// Notify the observer
-		iObserver->HandleUSBEventL();
-		}
-	}
-
-
-// ---------------------------------------------------------------------------
-// CVRUSBEventHandler::Listen
-// 
-// ---------------------------------------------------------------------------
-//
-void CVRUSBEventHandler::Listen( TUid aUid, 
-									TUint aKey, 
-									MVRUSBEventObserver* aObserver )
-	{
-	iProperty.Attach( aUid, aKey );
-	
-	iObserver = aObserver;
-	IssueRequest();
-	}
-
-
-// ---------------------------------------------------------------------------
-// CVRUSBEventHandler::DoCancel
-// 
-// ---------------------------------------------------------------------------
-//
-void CVRUSBEventHandler::DoCancel()
-	{
-	iProperty.Cancel();	
-	}
-
-
-// ---------------------------------------------------------------------------
-// CVRUSBEventHandler::StateL
-// 
-// ---------------------------------------------------------------------------
-//
-TInt CVRUSBEventHandler::StateL( TUid aUid, TUint aKey )
-	{
-	TInt value;
-	User::LeaveIfError( RProperty::Get( aUid, aKey, value ) );
-	return value;
-	}
-	
-//  End of File
--- a/voicerecorder/RecViewSrc/CVRUSBEventHandler.h	Tue Apr 27 16:40:59 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
-* Copyright (c) 2002-2006 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:  An active object class that is used to receive
-*  phone call related events from PS API and forward them
-*  to an MVRUSBEventObserver instance.
-*
-*
-*/
-
-
-
-#ifndef __CVRUSBEVENTHANDLER_H
-#define __CVRUSBEVENTHANDLER_H
-
-// INCLUDES
-#include <e32base.h>
-#include <e32property.h>
-
-// FORWARD DECLARATIONS
-class MVRUSBEventObserver;
-
-// CLASS DECLARATION
-
-/**
-*  An active object class that is used to receive
-*  phone call related events from RUSBAgent and forward them
-*  to an MVRUSBEventObserver instance.
-*/
-NONSHARABLE_CLASS( CVRUSBEventHandler ): public CActive
-    {
-    public:  // Constructors and destructor
-
-        /**
-        * Two-phased constructor.
-		* @return A pointer to fully constructed instance of CVRUSBEventHandler
-        */
-        static CVRUSBEventHandler* NewL();
-
-        /**
-        * Destructor.
-        */
-        virtual ~CVRUSBEventHandler();
-
-    public: // New functions
-		/**
-		* Get the current state of any pubsub key
-		* @param aUid The UID of the PS category
-		* @param aKey The id identifying the PS key
-		* @return The value of the state variable
-		*/
-		TInt StateL( TUid aUid, TUint aKey );
-
-		/**
-		* Start listening to USB events
-		* @param aUid The UID identifying the USB agent's state variable
-		* @param aObserver The observer who will be notified of events
-		*/
-		void Listen( TUid aUid, TUint aKey, MVRUSBEventObserver* aObserver );
-
-    public: // from CActive
-
-		/**
-		* When this method is called, an event has been received.
-		* Notify the observer.
-		*/
-        void RunL();
-
-		/**
-		* Cancel the request for event notifications.
-		*/
-		void DoCancel();
-
-    private:
-
-		/**
-		* Ask USB agent to notify us about events
-		*/
-		void IssueRequest();
-
-        /**
-        * Default constructor.
-        */
-        CVRUSBEventHandler();
-
-        /**
-        * 2nd phase constructor.
-        */
-        void ConstructL();
-
-    private:    // Data
-
-		/**
-		* For observing the USB events
-		*/
-		RProperty iProperty;
-
-        /**
-        * Pointer to the observer. Not owned.
-        */
-		MVRUSBEventObserver* iObserver;
-    };
-
-#endif      // __CVRUSBEVENTHANDLER_H
-
-// End of File
--- a/voicerecorder/RecViewSrc/MVRUSBEventObserver.h	Tue Apr 27 16:40:59 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
-* Copyright (c) 2002-2006 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: 
-* This class can be used to observe changes that has been happened in
-* CVRUSBEventHandler class 
-*
-*/
-
-
-#ifndef __MVRUSBEVENTOBSERVER_H
-#define __MVRUSBEVENTOBSERVER_H
-
-// INCLUDES
-#include <e32def.h>
-#include <bldvariant.hrh>
-
-// CLASS DECLARATION
-/**
-*  MVRUSBEventObserver
-*/
-class MVRUSBEventObserver
-    {
-    public:  // Constructors and destructor		
-    
-    virtual void HandleUSBEventL() = 0;
-
-	};
-
-#endif      // __MVRUSBEVENTOBSERVER_H
-
-// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voicerecorder/UtilsInc/VRUSBStateHanlder.h	Tue May 11 16:15:58 2010 +0300
@@ -0,0 +1,73 @@
+/*
+ ============================================================================
+ Name		: VRUSBStateHanlder.h
+ Author	  : Junhua Xu
+ Version	 : 1.0
+ Copyright   : Your copyright notice
+ Description : CVRUSBStateHanlder declaration
+ ============================================================================
+ */
+
+#ifndef VRUSBSTATEHANLDER_H
+#define VRUSBSTATEHANLDER_H
+
+#include <e32base.h>	// For CActive, link against: euser.lib
+#include <e32std.h>		// For RTimer, link against: euser.lib
+#include <e32property.h> 
+
+//#include "DummyUSBState.h" // for dummy testing
+
+class MVRUSBStateObserver
+    {
+public:
+    // Constructors and destructor
+
+    virtual TInt HandleUsbPlugInL() = 0;
+    virtual TInt HandleUsbPlugOutL() = 0;
+
+    };
+
+class CVRUSBStateHanlder : public CActive
+    {
+public:
+    // Cancel and destroy
+    ~CVRUSBStateHanlder();
+
+    IMPORT_C static CVRUSBStateHanlder* NewL(MVRUSBStateObserver* aObserver);
+
+public:
+
+    IMPORT_C static TBool IsUsbActive();
+
+private:
+    // C++ constructor
+    CVRUSBStateHanlder(MVRUSBStateObserver* aObserver);
+
+    // Second-phase constructor
+    void ConstructL();
+
+private:
+    // From CActive
+    // Handle completion
+    void RunL();
+
+    // How to cancel me
+    void DoCancel();
+
+    // Override to handle leaves from RunL(). Default implementation causes
+    // the active scheduler to panic.
+    TInt RunError(TInt aError);
+
+    void StartL();
+
+private:
+#ifdef DUMMY_USB_TESTING
+    RTimer iTimer; // Provides async timing service, for dummy testing
+    TInt isUSBActive;
+#else
+    RProperty iProperty;
+#endif
+    MVRUSBStateObserver* iObserver;    
+    };
+
+#endif // VRUSBSTATEHANLDER_H
--- a/voicerecorder/UtilsInc/VRUtils.h	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/UtilsInc/VRUtils.h	Tue May 11 16:15:58 2010 +0300
@@ -189,6 +189,14 @@
 		*/		
        	IMPORT_C static TInt AACAudioModeL();
 
+		/**
+		* This method checks the drive is valid or not
+		* @param aDrive is the drive id
+		* @param aNoteId store the note id
+	    * @return The default memo store
+		*/
+       	IMPORT_C static TBool DriveValid( const TInt aDrive );
+       	
 #ifdef RD_MULTIPLE_DRIVE    	
        	/**
         * This method sets the default memo store setting (to support multipledrives)
@@ -208,7 +216,7 @@
 		* This method returns the current status of Drive (inserted/locked/etc...)
 		* @param aDriveInfo MMC status
 		*/
-		IMPORT_C static void GetDriveInfo( TInt aDrive, TUint& aDriveInfo );
+		IMPORT_C static TInt GetDriveInfo( TInt aDrive, TUint& aDriveInfo );
 
         /**
         * This method returns the default memo drive setting
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voicerecorder/UtilsSrc/VRUSBStateHanlder.cpp	Tue May 11 16:15:58 2010 +0300
@@ -0,0 +1,130 @@
+/*
+ ============================================================================
+ Name		: VRUSBStateHanlder.cpp
+ Author	  : Junhua Xu
+ Version	 : 1.0
+ Copyright   : Your copyright notice
+ Description : CVRUSBStateHanlder implementation
+ ============================================================================
+ */
+
+#include <e32cmn.h>
+#include <usbpersonalityids.h>
+#include <e32property.h> 
+#include <UsbWatcherInternalPSKeys.h>
+#include <usbpersonalityids.h>
+
+#include <aknwaitdialog.h>
+#include <EIKENV.H> 
+
+#include "VRUSBStateHanlder.h"
+#include "CVRRecView.h"
+
+CVRUSBStateHanlder::CVRUSBStateHanlder(MVRUSBStateObserver* aObserver) :
+    CActive(EPriorityStandard), // Standard priority
+            iObserver(aObserver)
+    {
+    }
+
+EXPORT_C CVRUSBStateHanlder* CVRUSBStateHanlder::NewL(
+        MVRUSBStateObserver* aObserver)
+    {
+    CVRUSBStateHanlder* self = new (ELeave) CVRUSBStateHanlder(aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(); // self;
+    return self;
+    }
+
+void CVRUSBStateHanlder::ConstructL()
+    {
+#ifdef DUMMY_USB_TESTING 
+    User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
+#else
+    iProperty.Attach(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality);
+#endif
+    CActiveScheduler::Add(this); // Add to scheduler    
+    StartL();
+    }
+
+CVRUSBStateHanlder::~CVRUSBStateHanlder()
+    {
+    Cancel(); // Cancel any request, if outstanding
+#ifdef DUMMY_USB_TESTING   
+    iTimer.Close();
+#else      
+    iProperty.Close();
+#endif     
+    }
+
+void CVRUSBStateHanlder::DoCancel()
+    {
+#ifdef DUMMY_USB_TESTING   
+    iTimer.Cancel();
+#else      
+    iProperty.Cancel();
+#endif  
+
+    }
+
+void CVRUSBStateHanlder::StartL()
+    {
+    Cancel(); // Cancel any request, just to be sure
+#ifdef DUMMY_USB_TESTING
+    iTimer.After(iStatus, 10000000); // Set for later
+    SetActive(); // Tell scheduler a request is active   
+#else   
+    SetActive();
+    iProperty.Subscribe(iStatus);
+#endif
+    }
+
+void CVRUSBStateHanlder::RunL()
+    {
+#ifdef DUMMY_USB_TESTING
+    CDummyUSBState::HandleUSBEventL();
+#endif
+    if (IsUsbActive())
+        {
+        iObserver->HandleUsbPlugInL();
+        }
+    else
+        {
+        iObserver->HandleUsbPlugOutL();
+        }
+#ifdef DUMMY_USB_TESTING    
+    //    iStatus = KRequestPending;
+    SetActive(); // Tell scheduler a request is active    
+    iTimer.After(iStatus, 10000000); // Set for later
+#else
+    StartL();
+#endif
+    }
+
+TInt CVRUSBStateHanlder::RunError(TInt aError)
+    {
+    return aError;
+    }
+
+EXPORT_C TBool CVRUSBStateHanlder::IsUsbActive()
+    {
+#ifdef DUMMY_USB_TESTING
+    //dummy
+    return CDummyUSBState::IsUSBActive();
+#else
+
+    TInt usbState;
+    TInt err = RProperty::Get(KPSUidUsbWatcher,
+            KUsbWatcherSelectedPersonality, usbState);
+
+    if (KErrNone == err && KUsbPersonalityIdMS == usbState)
+        {
+        return true;
+        }
+    else
+        {
+        return false;
+        }
+#endif
+    }
+
--- a/voicerecorder/UtilsSrc/VRUtils.cpp	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/UtilsSrc/VRUtils.cpp	Tue May 11 16:15:58 2010 +0300
@@ -138,9 +138,9 @@
 		else
 			{			
             TUint status( 0 );
-	        VRUtils::GetDriveInfo(memoDrive, status);
+            TInt err = VRUtils::GetDriveInfo(memoDrive, status);
             // check if drive status is ok 
-			if ( (status & DriveInfo::EDrivePresent) && !(status & DriveInfo::EDriveLocked) &&
+			if ( ( err == KErrNone ) && (status & DriveInfo::EDrivePresent) && !(status & DriveInfo::EDriveLocked) &&
 				!( status & DriveInfo::EDriveCorrupt ) && !( status & DriveInfo::EDriveReadOnly ) )
 				{
 				// Drive usage is OK.
@@ -1053,6 +1053,29 @@
 	return mode;    
     }
 
+// ---------------------------------------------------------------------------
+// DriveValid checks the drive is valid or not
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool VRUtils::DriveValid( const TInt aDrive )
+    {
+    TUint status( 0 );
+    TBool flag( ETrue );
+    TInt err = VRUtils::GetDriveInfo( aDrive, status );
+    if ( err != KErrNone )
+    	{ flag = EFalse; }
+    else 
+    	{
+    	if ( !(status & DriveInfo::EDrivePresent) ||
+    			(status & DriveInfo::EDriveLocked) ||
+    			(status & DriveInfo::EDriveReadOnly) ||
+    			(status & DriveInfo::EDriveCorrupt) ||
+    			(status & DriveInfo::EDriveInUse) )
+    		{ flag = EFalse; }
+    	}
+    return flag;
+    
+    }
 
 #ifdef RD_MULTIPLE_DRIVE
 // ---------------------------------------------------------------------------
@@ -1103,7 +1126,7 @@
 EXPORT_C TInt VRUtils::DefaultMemoDriveL()
 	{
     TInt drive(0);
-    User::LeaveIfError( DriveInfo::GetDefaultDrive(DriveInfo::EDefaultPhoneMemory, drive ) );
+    User::LeaveIfError( DriveInfo::GetDefaultDrive(DriveInfo::EDefaultMassStorage, drive ) );
     return drive;
 	}
 
@@ -1113,10 +1136,11 @@
 // it is for multiple drive feature
 // ---------------------------------------------------------------------------
 //
-EXPORT_C void VRUtils::GetDriveInfo( TInt aDrive, TUint& aDriveInfo )
+EXPORT_C TInt VRUtils::GetDriveInfo( TInt aDrive, TUint& aDriveInfo )
     {
 	RFs& iFs = CCoeEnv::Static()->FsSession() ;
-	DriveInfo::GetDriveStatus( iFs, aDrive, aDriveInfo ); 
+	TInt err = DriveInfo::GetDriveStatus( iFs, aDrive, aDriveInfo ); 
+	return err;
     }
 #endif
 
--- a/voicerecorder/group/RecView.mmp	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/group/RecView.mmp	Tue May 11 16:15:58 2010 +0300
@@ -48,7 +48,6 @@
 SOURCE		CVRRemConObserver.cpp
 SOURCE		CVRTonePlayer.cpp
 SOURCE      CVRDiskSpaceWatcher.cpp
-SOURCE		CVRUSBEventHandler.cpp 
 SOURCE      CVRMediaRemovalMonitor.cpp
 
 USERINCLUDE	 ../RecViewSrc
--- a/voicerecorder/group/Utils.mmp	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/group/Utils.mmp	Tue May 11 16:15:58 2010 +0300
@@ -35,9 +35,11 @@
 SOURCEPATH	../UtilsSrc
 SOURCE      TVRRename.cpp
 SOURCE		DllMain.cpp
-SOURCE		VRUtils.cpp
+SOURCE		VRUtils.cpp  VRUSBStateHanlder.cpp
 
-USERINCLUDE     ../UtilsInc ../group
+USERINCLUDE     ../UtilsInc ../group ../../inc ..
+USERINCLUDE     ../RecViewInc
+
 APP_LAYER_SYSTEMINCLUDE
 
 LIBRARY		euser.lib
--- a/voicerecorder/group/VoiceRecorderApp.mmp	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/group/VoiceRecorderApp.mmp	Tue May 11 16:15:58 2010 +0300
@@ -54,6 +54,7 @@
 SOURCE		CVRSettingsDialog.cpp
 #endif
 
+
 USERINCLUDE     ../AppSrc
 USERINCLUDE     ../group
 USERINCLUDE	    ../UtilsInc
--- a/voicerecorder/group/voicerecorder.hrh	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/group/voicerecorder.hrh	Tue May 11 16:15:58 2010 +0300
@@ -68,7 +68,8 @@
 	ECmdMSK,			// When Middle Softkey is pressed
 	ECmdSetNewPosition,		// Progress Bar Touch	
 	ECmdNOP,			// No operation
-	ECmdGoToMyClips,
+	ECmdGoToMyClips,	
+	ECmdUSBChange,
 	
 	ECmdSendVia			// This MUST be the last entry
 	};
--- a/voicerecorder/group/voicerecorder.rss	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/group/voicerecorder.rss	Tue May 11 16:15:58 2010 +0300
@@ -39,6 +39,7 @@
 #include "voicerecorder.hrh"
 #include "VoiceRecorder.rh"
 #include <voicerecorder.loc>
+#include <mpxwaitnotedialog.loc>
 
 NAME VREC
 
@@ -201,6 +202,44 @@
 RESOURCE TBUF r_qtn_memc_unlock_query1 { buf = qtn_memc_unlock_query1; }
 RESOURCE TBUF r_qtn_memc_set_password_error { buf = qtn_memc_set_password_error; }
 RESOURCE TBUF r_qtn_memc_readonly { buf = qtn_memc_memorycard_read_only; }
+RESOURCE TBUF r_qtn_ccor_insert_mmc { buf = qtn_ccor_insert_mmc; }
+RESOURCE TBUF r_qtn_usb_mode_note_mode { buf = qtn_usb_mode_note_mode_activated; }
+
+RESOURCE DIALOG r_insert_f_card_dialog
+    {
+    flags = EGeneralQueryFlags | EEikDialogFlagWait | EEikDialogFlagNoBackgroundFade;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    items =
+    		{
+    		DLG_LINE
+    			{
+    			type = EAknCtQuery;
+    			id = EGeneralQuery;
+    			control = AVKON_CONFIRMATION_QUERY 
+    				{ 
+    				layout = EConfirmationLayout;
+    				};
+    			}
+    		};
+    } 
+
+RESOURCE DIALOG r_insert_f_usb_plug_in_dialog
+    {
+    flags = EGeneralQueryFlags | EEikDialogFlagWait | EEikDialogFlagNoBackgroundFade;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items =
+    		{
+    		DLG_LINE
+    			{
+    			type = EAknCtQuery;
+    			id = EGeneralQuery;
+    			control = AVKON_CONFIRMATION_QUERY 
+    				{ 
+    				layout = EConfirmationLayout;
+    				};
+    			}
+    		};
+    } 
 
 // Settings dialog stuff needed when there's an MMC (default store setting)
 // or the voice key is missing (defauly speaker setting)
@@ -2194,3 +2233,23 @@
             }
         };
     }
+
+RESOURCE DIALOG r_vorec_usb_connected_dialog
+    {
+    flags = EAknWaitNoteFlags|EEikDialogFlagModeless;
+    buttons = R_AVKON_SOFTKEYS_BACK;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EGeneralQuery;
+            control= AVKON_NOTE 
+                { 
+                layout = EWaitLayout;
+                singular_label = qtn_usb_mode_note_mode_activated;
+                animation = R_QGN_GRAF_WAIT_BAR_ANIM;
+                };
+            }
+        };
+    }
--- a/voicerecorder/gsplugin/src/CVRGSPluginContainer.cpp	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/gsplugin/src/CVRGSPluginContainer.cpp	Tue May 11 16:15:58 2010 +0300
@@ -40,6 +40,7 @@
 #ifdef RD_MULTIPLE_DRIVE
 #include <driveinfo.h>
 #include <CAknMemorySelectionSettingItemMultiDrive.h>
+#include <AknCommonDialogsDynMem.h>
 #endif
 
 const TUid KVRAppUID = { KVoiceRecorderAppUID3 };
@@ -195,6 +196,9 @@
 #else
     settingItem =
                 new( ELeave ) CAknMemorySelectionSettingItemMultiDrive(0, iDrive );
+       TInt includedMedias = AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage |
+                          AknCommonDialogsDynMem::EMemoryTypeMMCExternal;
+       static_cast< CAknMemorySelectionSettingItemMultiDrive *> ( settingItem )->SetIncludedMediasL( includedMedias );
 #endif
 
 	CleanupStack::PushL( settingItem );
--- a/voicerecorder/loc/voicerecorder.loc	Tue Apr 27 16:40:59 2010 +0300
+++ b/voicerecorder/loc/voicerecorder.loc	Tue May 11 16:15:58 2010 +0300
@@ -269,6 +269,20 @@
 // l: popup_note_window
 #define qtn_memc_unlock_query1		"The selected memory store is locked, it can't be used. Do you want to unlock it?"
 
+// d: Information note
+// d: Shown when VR is started and the SD card is not inserted
+// l: popup_note_window
+// w: 
+// r: 3.1
+#define qtn_ccor_insert_mmc            "Please insert memory card."
+
+// d: Information note
+// d: Shown when VR is started and the USB is inserted in Mass Storage mode
+// l: popup_note_window
+// w: 
+// r: 3.1
+#define qtn_usb_mode_note_mode_activated            "USB connected in Mass storage mode"
+
 // ---------------------------------------------------------------------------
 // No voice key specific strings
 
Binary file voicerecorder/sis/VoiceRecorderCenrep.pkg has changed