Revision: 201030 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 19 Aug 2010 09:57:40 +0300
branchRCL_3
changeset 19 2f5c9ee7098c
parent 17 41c99112ff9d
child 20 072a5fa0c63b
Revision: 201030 Kit: 201033
voicerecorder/AppSrc/CVRAppUI.cpp
voicerecorder/AppSrc/CVRAppUi.h
voicerecorder/AppSrc/CVRSettingsDialogMMCSupported.cpp
voicerecorder/RecViewInc/CVRRecView.h
voicerecorder/RecViewSrc/CVRMdaRecorder.cpp
voicerecorder/RecViewSrc/CVRRecView.cpp
voicerecorder/RecViewSrc/CVRRecViewModel.cpp
voicerecorder/RecViewSrc/CVRRecViewModel.h
voicerecorder/UtilsSrc/VRUtils.cpp
voicerecorder/gsplugin/src/CVRGSPluginContainer.cpp
--- a/voicerecorder/AppSrc/CVRAppUI.cpp	Mon Jun 21 15:43:26 2010 +0300
+++ b/voicerecorder/AppSrc/CVRAppUI.cpp	Thu Aug 19 09:57:40 2010 +0300
@@ -161,52 +161,8 @@
 // for multiple drives
 #else
 
-        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();
-                    }
-                }
-            }
 
-	    if (CVRUSBStateHanlder::IsUsbActive())
-	        {
-	        ShowDialogForWaitUSBPluggingOutL();
-	        Exit();
-	        }
-        
-        /***** 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,
@@ -228,70 +184,6 @@
 	}
 
 // ---------------------------------------------------------------------------
-// Make user insert the SD card, and choose SD card as the memo storage
-// ---------------------------------------------------------------------------
-//
-void CVRAppUi::SetDriveL()
-    {
-    TInt driveRemovableMassStorage = VRUtils::GetRemovableMassStorageL();
-    if ( VRUtils::DriveValid( (TDriveNumber) driveRemovableMassStorage ) )
-    	{
-    	VRUtils::SetMemoDriveL( (TDriveNumber) driveRemovableMassStorage );
-    	}
-    else
-        {
-        if (CVRUSBStateHanlder::IsUsbActive())
-            {
-            ShowDialogForWaitUSBPluggingOutL();
-            Exit();
-
-            }
-        while ( !VRUtils::DriveValid( (TDriveNumber) driveRemovableMassStorage ) )
-            {
-            if (!ShowDialogForWaitStorageCardL())
-                {
-                Exit();
-                }
-            }
-        // Come to here when driveRemovableMassStorage is valid
-        VRUtils::SetMemoDriveL( (TDriveNumber) driveRemovableMassStorage );
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// 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
 // 
 // ---------------------------------------------------------------------------
--- a/voicerecorder/AppSrc/CVRAppUi.h	Mon Jun 21 15:43:26 2010 +0300
+++ b/voicerecorder/AppSrc/CVRAppUi.h	Thu Aug 19 09:57:40 2010 +0300
@@ -118,24 +118,6 @@
 		*/
 		MVRSelectionProvider* SelectionProviderL();
 
-       	
-       	/**
-       	* 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
 		/**
 		* CActiveScheduler wrapper object. Owned.
--- a/voicerecorder/AppSrc/CVRSettingsDialogMMCSupported.cpp	Mon Jun 21 15:43:26 2010 +0300
+++ b/voicerecorder/AppSrc/CVRSettingsDialogMMCSupported.cpp	Thu Aug 19 09:57:40 2010 +0300
@@ -36,8 +36,15 @@
 #include <AknCommonDialogsDynMem.h>
 #include <driveinfo.h>
 #include <CAknMemorySelectionDialogMultiDrive.h>
+#include <CAknMemorySelectionSettingItemMultiDrive.h>
 #endif
 
+// ListBox item index
+enum TListItemIndex
+    {
+    EListItemQualityIndex = 0,
+    ElistItemMemoStoreIndex,
+    };
 // ---------------------------------------------------------------------------
 // CVRSettingsDialog::~CVRSettingsDialog
 // 
@@ -131,7 +138,6 @@
     CAknSettingItem* settingItem;
   
     HBufC* itemTitle;
-   	TInt id( 0 );
     if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) )
         {
     	// Add quality setting
@@ -145,7 +151,7 @@
     	CleanupStack::PushL( settingItem );
 
     	itemTitle = iCoeEnv->AllocReadResourceLC( R_QTN_VOREC_SET_QUALITY );
-    	settingItem->ConstructL( EFalse, id, *itemTitle, NULL,
+    	settingItem->ConstructL( EFalse, EListItemQualityIndex, *itemTitle, NULL,
     	                     R_VR_SETTINGS_DEFAULT_SPEAKER_PAGE, EAknCtPopupField, NULL,
     						 R_VR_SETTINGS_QUALITY_TEXTS );
     	CleanupStack::PopAndDestroy();		// itemTitle
@@ -153,7 +159,6 @@
     	// Add quality item to the settings array
     	iSettingItemArray.AppendL( settingItem ); 
     	CleanupStack::Pop();	// settingItem
-    	id++;
         }
 
     if ( VRUtils::MultipleMassStorageAvailable() )
@@ -173,21 +178,16 @@
 	CleanupStack::Pop();	// settingItem
 
 #else    //multiple drives
-
-	CAknMemorySelectionDialogMultiDrive* dlg = CAknMemorySelectionDialogMultiDrive::NewL(
-    ECFDDialogTypeNormal, 
-    R_VOREC_MEMORY_SELECTION_DIALOG, // Default resource Id
-    EFalse,
-    AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage |
-    AknCommonDialogsDynMem::EMemoryTypeMMCExternal);
-
-    CleanupStack::PushL( dlg );
-    TBool value = dlg->ExecuteL( iDrive );
-    CleanupStack::PopAndDestroy( dlg );
-    if (value)
-     	{
-        VRUtils::SetMemoDriveL( iDrive );
-       	}
+        settingItem = new( ELeave ) CAknMemorySelectionSettingItemMultiDrive(0, iDrive );
+        CleanupStack::PushL( settingItem );
+        TInt includedMedias = AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage |
+                                 AknCommonDialogsDynMem::EMemoryTypeMMCExternal;
+        static_cast< CAknMemorySelectionSettingItemMultiDrive *> ( settingItem )->SetIncludedMediasL( includedMedias );
+        // Set memo store item's title
+        settingItem->ConstructL( EFalse, ElistItemMemoStoreIndex, *itemTitle, NULL, 0, EAknSetListBox );
+        // Add memo store item to the settings array
+        iSettingItemArray.AppendL( settingItem );
+        CleanupStack::Pop();	// settingItem
  
 #endif
 
@@ -226,8 +226,17 @@
 		case EEventEditingStarted: // From ProcessCommand->ECmdChange
 			{
 			TInt index( aListBox->CurrentItemIndex() );
+			TInt driveDefaultMassStorage = VRUtils::DefaultMemoDriveL();
+			TInt driveRemovableMassStorage = VRUtils::GetRemovableMassStorageL();
+			
 			if ( index >=0 )	// index is -1 if there are no items in the list
 				{
+			    if(index == ElistItemMemoStoreIndex && 
+			        !VRUtils::DriveValid(driveDefaultMassStorage) && 
+			            !VRUtils::DriveValid(driveRemovableMassStorage) )
+			        {
+			        break;
+			        }
 			    iSettingItemArray.At( index )->EditItemL( 
 				aEventType == EEventEditingStarted );
 			    aListBox->DrawItem( index );
@@ -335,7 +344,10 @@
         	iDrive = (TDriveNumber)defaultDrive;
   			}
 	 	}
+    if(iDrive == defaultDrive || iDrive == VRUtils::GetRemovableMassStorageL())
+        {
         VRUtils::SetMemoDriveL( iDrive );
+        }
 #endif 
      
     if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) )
--- a/voicerecorder/RecViewInc/CVRRecView.h	Mon Jun 21 15:43:26 2010 +0300
+++ b/voicerecorder/RecViewInc/CVRRecView.h	Thu Aug 19 09:57:40 2010 +0300
@@ -41,6 +41,11 @@
 class CVRRecViewActivationContainer;
 class CVRRecViewModel;
 
+enum TDialogTypeID {
+        EDialogForWaitStorageCard = 0,
+        EDialogForWaitUSBPluggingOut
+    };
+
 // CLASS DEFINITION
 /**
  * CVRRecView is an CAknView inherited view class that implements
@@ -101,6 +106,47 @@
                 */
                 TCallBack iCallback;
             };
+        
+        /*
+        * One shot class for note pop-up
+        */
+        NONSHARABLE_CLASS( CVRRecViewDialogActivator ) 
+            : public CAsyncOneShot
+            {
+            public:  // constructor and destructor
+                CVRRecViewDialogActivator( CVRRecViewModel* aModel);
+                ~CVRRecViewDialogActivator(); 
+                
+            public: // new method
+                void SetDialogType(TDialogTypeID aType);
+                
+                void SetViewContexts(TVRRecViewContexts aContext);
+                
+            private: // Functions from base classes
+
+                /**
+                 * From CActive.
+                 */
+                void RunL();
+                void DoCancel();
+
+            private: // Data:
+
+                /*
+                * State machine model, not owned
+                */
+                CVRRecViewModel* iModel;
+                
+                /*
+                * The type of dialog
+                */
+                TDialogTypeID iType;
+                
+                /*
+                * Context that is used to activate model
+                */                
+                TVRRecViewContexts iContext;  
+            };
 	
 	
 	public: // Constructors and destructor
@@ -285,6 +331,22 @@
      * the actual UI container and deletes the empty one.
      */
     void ActivateContainerL();    
+    
+    /*
+     * Check the current state of drives
+     */
+    void CheckDriveState();    
+    
+    /**
+    * 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();
+    
+    /**
+     * Make user insert the SD card, and choose SD card as the memo storage
+     */
+    void SetDriveL();
    
 public:
     virtual TInt HandleUsbPlugInL();
@@ -321,8 +383,18 @@
 		* asynchronically. Owned.
 		*/
 		CVRRecViewModelActivator* iModelActivator;
+		
+		/**
+        * One shot object that is used to pop up the note
+        */
+		CVRRecViewDialogActivator* iDialogActivator;
 
     /**
+     * The type of dialog
+     */
+	TDialogTypeID iDialogType;
+		
+    /**
      * The command that passed to Handlecommand
      * 
      */
@@ -334,6 +406,10 @@
     
     CVRUSBStateHanlder* iUSBStateHandler;
     
+    /*
+    * Context that is used to activate model
+    */                
+    TVRRecViewContexts iContext;
     };
 
 #endif // __CVRRECVIEW_H__
--- a/voicerecorder/RecViewSrc/CVRMdaRecorder.cpp	Mon Jun 21 15:43:26 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRMdaRecorder.cpp	Thu Aug 19 09:57:40 2010 +0300
@@ -922,7 +922,8 @@
 		iTonePlayer->PlayTone( EAvkonSIDVoiceRecordingStopTone );
 		iTonePlayer->PrepareTone( EAvkonSIDVoiceRecordingStartTone );			
 
-		if( reallyStopping )
+		if( ( iAudioRecorder->State() == CMdaAudioRecorderUtility::EOpen ) ||
+				reallyStopping )
 			{
 			// Set lower preference to ensure other sounds will 
 			// be played correctly
--- a/voicerecorder/RecViewSrc/CVRRecView.cpp	Mon Jun 21 15:43:26 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRRecView.cpp	Thu Aug 19 09:57:40 2010 +0300
@@ -43,6 +43,8 @@
 #include <coreapplicationuisdomainpskeys.h>
 #include <AknLaunchAppService.h>
 #include <AiwGenericParam.h>
+#include <sysutil.h>
+#include <aknnotewrappers.h>
 
 #include "voicerecorder.hrh"
 #include "CVRRecView.h"
@@ -116,10 +118,13 @@
 //
 void CVRRecView::CVRRecViewModelActivator::RunL()
 	{
-	// Activate model in correct context
-	iModel->SetMemoNameNewL( iContext == EContextRecordNewForRemote);
-	iModel->EnterContextL( iContext );
-	iModel->ActivateL();
+	if(iModel->GetIsDriveReady())
+	    {
+        // Activate model in correct context
+	    iModel->SetMemoNameNewL( iContext == EContextRecordNewForRemote);
+	    iModel->EnterContextL( iContext );
+	    iModel->ActivateL();
+	    } 
 	
 	// Notify recview
 	iCallback.CallBack();
@@ -150,6 +155,101 @@
     {
     }
 
+// ---------------------------------------------------------------------------
+// CVRRecView::CVRRecViewDialogActivator::CVRRecViewDialogActivator
+// 
+// ---------------------------------------------------------------------------
+//
+CVRRecView::CVRRecViewDialogActivator::CVRRecViewDialogActivator( CVRRecViewModel* aModel)
+:CAsyncOneShot(EPriorityNormal), iModel(aModel)
+    {
+    
+    }
+
+// ---------------------------------------------------------------------------
+// CVRRecView::CVRRecViewDialogActivator::~CVRRecViewDialogActivator
+// 
+// ---------------------------------------------------------------------------
+//
+CVRRecView::CVRRecViewDialogActivator::~CVRRecViewDialogActivator()
+    {
+    Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CVRRecView::CVRRecViewDialogActivator::~CVRRecViewDialogActivator
+// 
+// ---------------------------------------------------------------------------
+//
+void CVRRecView::CVRRecViewDialogActivator::SetDialogType(TDialogTypeID aType)
+    {
+    iType = aType;
+    }
+
+// ---------------------------------------------------------------------------
+// CVRRecView::CVRRecViewDialogActivator::SetViewContexts
+// 
+// ---------------------------------------------------------------------------
+//
+void CVRRecView::CVRRecViewDialogActivator::SetViewContexts(TVRRecViewContexts aContext)
+    {
+    iContext = aContext;
+    }
+
+// ---------------------------------------------------------------------------
+// CVRRecView::CVRRecViewDialogActivator::DoCancel
+// 
+// ---------------------------------------------------------------------------
+//
+void CVRRecView::CVRRecViewDialogActivator::DoCancel()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVRRecView::CVRRecViewNoteActivator::RunL
+// 
+// ---------------------------------------------------------------------------
+//
+void CVRRecView::CVRRecViewDialogActivator::RunL()
+    {
+    if(iType == EDialogForWaitStorageCard)
+        {
+        TInt driveRemovableMassStorage = VRUtils::GetRemovableMassStorageL();
+        while ( !VRUtils::DriveValid( (TDriveNumber) driveRemovableMassStorage ) )
+            {
+            if (!ShowDialogForWaitStorageCardL())
+                {
+                iModel->SendExitEvent();
+                }
+            }
+        // Come to here when driveRemovableMassStorage is valid
+        VRUtils::SetMemoDriveL( (TDriveNumber) driveRemovableMassStorage );    
+        
+        /***** 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);
+           iModel->SendExitEvent();
+           }
+        // check memory size end
+        
+        // To activate view model
+        iModel->SetMemoNameNewL( iContext == EContextRecordNewForRemote);
+        iModel->SetIsDriveReady(ETrue);
+        iModel->EnterContextL( iContext );
+        iModel->ActivateL();
+        }
+    else if(iType == EDialogForWaitUSBPluggingOut)
+        {
+        ShowDialogForWaitUSBPluggingOutL();
+        iModel->SendExitEvent();
+        }
+    }
 
 // ---------------------------------------------------------------------------
 // CVRRecView::NewLC
@@ -186,6 +286,7 @@
 
     delete iContainer;
     delete iActivationContainer;
+    delete iDialogActivator;
     delete iModel;
     delete iSendUi;
     delete iModelActivator;
@@ -726,11 +827,15 @@
 	appUi->AddToViewStackL( *this, iActivationContainer );
 	iActivationContainer->ActivateL();
 
+	iDialogActivator = new( ELeave ) CVRRecViewDialogActivator(iModel);
+	CheckDriveState();
+
     // 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);
+    iContext = static_cast<TVRRecViewContexts> (aCustomMessageId.iUid);
+    iDialogActivator->SetViewContexts(iContext);
+    iModelActivator->Activate(iContext , cb);
 
     // Construct the real container
     iContainer = new (ELeave) CVRRecViewContainer;
@@ -739,6 +844,108 @@
     iContainer->SetVolumeChangeObserver(iModel);
     }
 
+// ---------------------------------------------------------------------------
+// CVRRecView::CheckDriveState
+// 
+// ---------------------------------------------------------------------------
+//
+void CVRRecView::CheckDriveState()
+    {
+    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();
+                }
+            }
+        }
+
+    
+    if (iModel->GetIsDriveReady() && CVRUSBStateHanlder::IsUsbActive())
+        {
+        iModel->SetIsDriveReady(EFalse);
+        iDialogActivator->SetDialogType(EDialogForWaitUSBPluggingOut);
+        iDialogActivator->Call();
+        }
+    
+    
+    if(iModel->GetIsDriveReady()) 
+        {
+        /***** 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);
+            iModel->SendExitEvent();
+            }
+        // check memory size end
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Make user insert the SD card, and choose SD card as the memo storage
+// ---------------------------------------------------------------------------
+//
+void CVRRecView::SetDriveL()
+    {
+    TInt driveRemovableMassStorage = VRUtils::GetRemovableMassStorageL();
+    if ( VRUtils::DriveValid( (TDriveNumber) driveRemovableMassStorage ) )
+        {
+        VRUtils::SetMemoDriveL( (TDriveNumber) driveRemovableMassStorage );
+        }
+    else
+        {
+        iModel->SetIsDriveReady(EFalse);
+        if (CVRUSBStateHanlder::IsUsbActive())
+            {
+            iDialogActivator->SetDialogType(EDialogForWaitUSBPluggingOut);
+            iDialogActivator->Call();
+            }
+        else
+            {
+            iDialogActivator->SetDialogType(EDialogForWaitStorageCard);
+            iDialogActivator->Call();
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// This method show a dialog to warn user to insert the SD card.
+// ---------------------------------------------------------------------------
+//
+TBool CVRRecView::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;
+    }
 
 // ---------------------------------------------------------------------------
 // CVRRecView::SetFileHandle
@@ -867,6 +1074,11 @@
 	
 
     HandleCommandL(ECmdUSBChange);
+    
+    if(!VRUtils::DriveValid(VRUtils::MemoDriveL()))
+        {
+        iModel->SendExitEvent();
+        }
     return KErrNone;
     }
 
--- a/voicerecorder/RecViewSrc/CVRRecViewModel.cpp	Mon Jun 21 15:43:26 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRRecViewModel.cpp	Thu Aug 19 09:57:40 2010 +0300
@@ -84,7 +84,8 @@
 	iLabelSets( 2 ),
 	iPreviousCallState( EPSCTsyCallStateNone ),
 	iCanHandleCommands( ETrue ),
-	iCBAEnabled( ETrue )
+	iCBAEnabled( ETrue ),
+	iIsDriveReady( ETrue )
 	{
 	}
 
@@ -804,7 +805,7 @@
 //	
 TInt CVRRecViewModel::ButtonState( TInt aButtonId ) const
 	{
-    if(CVRUSBStateHanlder::IsUsbActive())
+    if(CVRUSBStateHanlder::IsUsbActive() || !iIsDriveReady)
         {
             return EDimmed;
         }
@@ -2432,14 +2433,44 @@
             ( !CVRUSBStateHanlder::IsUsbActive() ) )
 		{
         //exit for mmc dismount	
-        TWsEvent event;
-        event.SetType( EAknSoftkeyExit );
-        event.SetTimeNow();
-        event.SetHandle( CCoeEnv::Static()->WsSession().WsHandle() );
-        CCoeEnv::Static()->WsSession().SendEventToWindowGroup( CEikonEnv::Static()->RootWin().Identifier(), event );
-        return;       
+        SendExitEvent();   
 		}
-	}
+    }
+
+// ---------------------------------------------------------------------------
+// CVRRecViewModel::SendExitEvent
+// 
+// ---------------------------------------------------------------------------
+//
+void CVRRecViewModel::SendExitEvent()
+    {
+    TWsEvent event;
+    event.SetType( EAknSoftkeyExit );
+    event.SetTimeNow();
+    event.SetHandle( CCoeEnv::Static()->WsSession().WsHandle() );
+    CCoeEnv::Static()->WsSession().SendEventToWindowGroup( CEikonEnv::Static()->RootWin().Identifier(), event );
+    return;
+    }
+
+// ---------------------------------------------------------------------------
+// CVRRecViewModel::SetIsDriveReady
+// 
+// ---------------------------------------------------------------------------
+//
+void CVRRecViewModel::SetIsDriveReady(TBool aIsDriveReady)
+    {
+    iIsDriveReady = aIsDriveReady;
+    }
+
+// ---------------------------------------------------------------------------
+// CVRRecViewModel::GetIsDriveReady
+// 
+// ---------------------------------------------------------------------------
+//
+TBool CVRRecViewModel::GetIsDriveReady()
+    {
+    return iIsDriveReady;
+    }
 
 
 // End of file
--- a/voicerecorder/RecViewSrc/CVRRecViewModel.h	Mon Jun 21 15:43:26 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRRecViewModel.h	Thu Aug 19 09:57:40 2010 +0300
@@ -432,7 +432,23 @@
 		*/
 		TVRQuality Quality() const;
 		
-		              
+        /**
+         * Send exit event to UI
+         */
+        void SendExitEvent();
+        
+        /**
+        * Set the value of iIsDriveReady.
+        * @param The new value of iIsDriveReady.
+        */
+        void SetIsDriveReady(TBool aIsDriveReady);
+                
+        /**
+        * Get the value of iIsDriveReady.
+        * @return The value of iIsDriveReady.
+        */
+        TBool GetIsDriveReady();
+
 	private: // new methods
 
 		/**
@@ -735,6 +751,11 @@
 		* causes no action.
 		*/
 		TBool iCBAEnabled;
+		
+	    /**
+	     * To judge whether the current drive is ready for recording
+	     */
+	    TBool iIsDriveReady;
 	};
 
 #endif // __CVRRECVIEWMODEL_H__
--- a/voicerecorder/UtilsSrc/VRUtils.cpp	Mon Jun 21 15:43:26 2010 +0300
+++ b/voicerecorder/UtilsSrc/VRUtils.cpp	Thu Aug 19 09:57:40 2010 +0300
@@ -1087,8 +1087,7 @@
 	TInt removableStorageErr = DriveInfo::GetDefaultDrive(
 			DriveInfo::EDefaultRemovableMassStorage,    driveRemovableMassStorage );
 	if ( (defaultStorageErr) || (removableStorageErr) ||
-			( driveDefaultMassStorage == driveRemovableMassStorage ) ||
-			!DriveValid(driveDefaultMassStorage) || !DriveValid(driveRemovableMassStorage) )
+			( driveDefaultMassStorage == driveRemovableMassStorage ) )
 		{ flag = EFalse; }
 	
 	return flag;
--- a/voicerecorder/gsplugin/src/CVRGSPluginContainer.cpp	Mon Jun 21 15:43:26 2010 +0300
+++ b/voicerecorder/gsplugin/src/CVRGSPluginContainer.cpp	Thu Aug 19 09:57:40 2010 +0300
@@ -45,6 +45,13 @@
 
 const TUid KVRAppUID = { KVoiceRecorderAppUID3 };
 
+// ListBox item index
+enum TListItemIndex
+    {
+    EListItemQualityIndex = 0,
+    ElistItemMemoStoreIndex,
+    };
+
 // ========================= MEMBER FUNCTIONS ================================
 
 // ---------------------------------------------------------------------------
@@ -158,7 +165,6 @@
     {
     CAknSettingItem* settingItem;
     HBufC* itemTitle;
-   	TInt id( 0 );    
 
 	// Add quality setting
     if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) )
@@ -174,7 +180,7 @@
     	CleanupStack::PushL( settingItem );
 
     	itemTitle = iCoeEnv->AllocReadResourceLC( R_QTN_VOREC_SET_QUALITY );
-    	settingItem->ConstructL( EFalse, id, *itemTitle, NULL,
+    	settingItem->ConstructL( EFalse, EListItemQualityIndex, *itemTitle, NULL,
     	                     R_VR_SETTINGS_DEFAULT_SPEAKER_PAGE, 
     	                     EAknCtPopupField, NULL,
     						 R_VR_SETTINGS_QUALITY_TEXTS );
@@ -184,9 +190,8 @@
     	// Add quality item to the settings array
     	iSettingItemArray->AppendL( settingItem );
       	CleanupStack::Pop();	// settingItem        
-      	id++;
         }
-    if ( VRUtils::MultipleMassStorageAvailable() )
+      if ( VRUtils::MultipleMassStorageAvailable() )
         {
     // Add memo store setting
 	// Create the memo store item
@@ -211,7 +216,7 @@
 	settingItem->ConstructL( EFalse, id, *itemTitle, NULL,
 	    R_VOREC_MEMORY_SELECTION_DIALOG, EAknCtPopupSettingList );
 #else
-   settingItem->ConstructL( EFalse, id, *itemTitle, NULL, 0, EAknCtPopupSettingList );
+        settingItem->ConstructL( EFalse, ElistItemMemoStoreIndex, *itemTitle, NULL, 0, EAknCtPopupSettingList );
 #endif
 	    
 	CleanupStack::PopAndDestroy();	// itemTitle
@@ -219,7 +224,6 @@
         // Add memo store item to the settings array
         iSettingItemArray->AppendL( settingItem );
         CleanupStack::Pop();	// settingItem
-        id++;
     	}
     }
 
@@ -268,9 +272,17 @@
 void CVRGSPluginContainer::HandleListBoxSelectionL( TInt aCommand ) 
     {
 	TInt index( iListBox->CurrentItemIndex() );
-
+	TInt driveDefaultMassStorage = VRUtils::DefaultMemoDriveL();
+	TInt driveRemovableMassStorage = VRUtils::GetRemovableMassStorageL();
+	
 	if ( index >=0 )	// index is -1 if there are no items in the list
 		{
+        if(index == ElistItemMemoStoreIndex &&
+		        !VRUtils::DriveValid(driveDefaultMassStorage) && 
+		            !VRUtils::DriveValid(driveRemovableMassStorage) )
+            {
+            return;
+            }
 		// Open edit dialog if EAknCmdOpen, invert the value otherwise
 		iSettingItemArray->At( index )->EditItemL( aCommand == EAknCmdOpen );
 		iListBox->DrawItem( index );
@@ -339,7 +351,10 @@
         	iDrive = (TDriveNumber)defaultDrive;
   			}
 	 	}
+    if(iDrive == defaultDrive || iDrive == VRUtils::GetRemovableMassStorageL())
+        {
         VRUtils::SetMemoDriveL( iDrive );
+        }
 #endif 
 
     // Save quality setting