Revision: 201012 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 14 Apr 2010 16:00:13 +0300
branchRCL_3
changeset 10 bb90e4148332
parent 9 45ab7373901d
child 11 a2fdc35b8f46
Revision: 201012 Kit: 201015
voicerecorder/AppSrc/CVRAppUI.cpp
voicerecorder/AppSrc/CVRAppUi.h
voicerecorder/RecViewSrc/CVRMediaRemovalMonitor.cpp
voicerecorder/RecViewSrc/CVRMediaRemovalMonitor.h
voicerecorder/RecViewSrc/CVRRecViewModel.cpp
voicerecorder/RecViewSrc/CVRRecViewModel.h
voicerecorder/RecViewSrc/MVRMediaRemovalObserver.h
voicerecorder/group/RecView.mmp
--- a/voicerecorder/AppSrc/CVRAppUI.cpp	Wed Mar 31 21:35:17 2010 +0300
+++ b/voicerecorder/AppSrc/CVRAppUI.cpp	Wed Apr 14 16:00:13 2010 +0300
@@ -466,6 +466,19 @@
 	return ConeUtils::FileExists( aDocumentName );
     }
 
+// ---------------------------------------------------------------------------
+// CVRAppUi::HandleApplicationSpecificEventL
+// 
+// ---------------------------------------------------------------------------
+//
+void CVRAppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent)
+    {
+    if( aType == EAknSoftkeyExit )
+    	{
+    	Exit();
+    	}
+    	CEikAppUi::HandleApplicationSpecificEventL(aType, aEvent);
+    }
 
 // ---------------------------------------------------------------------------
 // CVRAppUi::SetEmbeddedObserver
--- a/voicerecorder/AppSrc/CVRAppUi.h	Wed Mar 31 21:35:17 2010 +0300
+++ b/voicerecorder/AppSrc/CVRAppUi.h	Wed Apr 14 16:00:13 2010 +0300
@@ -98,6 +98,13 @@
 		TBool ProcessCommandParametersL( TApaCommand aCommand,
 		    TFileName& aDocumentName, const TDesC8& aTail );
 
+		/**
+		* Handles events from window group  
+		* @param aType The type of event
+		*/
+		
+		void HandleApplicationSpecificEventL(TInt aType, const TWsEvent& aEvent);
+		
 	private: // new methods
 
 		/**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voicerecorder/RecViewSrc/CVRMediaRemovalMonitor.cpp	Wed Apr 14 16:00:13 2010 +0300
@@ -0,0 +1,161 @@
+/*
+* Copyright (c) 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:  Monitors for Media removal
+*
+*/
+
+
+#include <e32base.h>
+#include <f32file.h>
+#include "CVRMediaRemovalMonitor.h"
+
+// ---------------------------------------------------------------------------
+// C++ Constructor
+// ---------------------------------------------------------------------------
+//
+CVRMediaRemovalMonitor::CVRMediaRemovalMonitor
+                  ( TInt aDrive, RFs& aFs, MVRMediaRemovalObserver* aObserver ) 
+                                                       : CActive(EPriorityHigh),
+                                                         iDrive( aDrive ),
+                                                         iFs( aFs ),
+                                                         iDiskRemoved( EFalse ),
+                                                         iObserver( aObserver )
+                                                         
+    {
+    CActiveScheduler::Add(this);
+    }
+
+
+// ---------------------------------------------------------------------------
+// 2nd Phase Constructor
+// ---------------------------------------------------------------------------
+//
+void CVRMediaRemovalMonitor::ConstructL()
+    {
+ 
+    // Initial state
+    TDriveInfo drive;
+  	User::LeaveIfError(iFs.Drive(drive, TInt(iDrive)));
+   	iDiskRemoved = (drive.iType == EMediaNotPresent);
+
+    // Start listening
+    TNotifyType notType(ENotifyDisk);
+    iFs.NotifyChange( notType, iStatus );
+    SetActive();
+    }
+
+
+// ---------------------------------------------------------------------------
+// Two-Phased Constructor
+// ---------------------------------------------------------------------------
+//
+CVRMediaRemovalMonitor* CVRMediaRemovalMonitor::NewL
+                ( TInt aDrive, RFs& aFs, MVRMediaRemovalObserver* aObserver )
+    {
+    CVRMediaRemovalMonitor* self
+                               = CVRMediaRemovalMonitor::NewLC( aDrive,
+                                                                 aFs,
+                                                                 aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Two-Phased Constructor
+// ---------------------------------------------------------------------------
+//
+CVRMediaRemovalMonitor* CVRMediaRemovalMonitor::NewLC
+               ( TInt aDrive, RFs& aFs, MVRMediaRemovalObserver* aObserver )
+    {
+    CVRMediaRemovalMonitor* self = 
+                          new( ELeave ) CVRMediaRemovalMonitor( aDrive,
+                                                                 aFs,
+                                                                 aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CVRMediaRemovalMonitor::~CVRMediaRemovalMonitor()
+    {
+    Cancel();
+    }
+
+    
+// ---------------------------------------------------------------------------
+// Service the request
+// ---------------------------------------------------------------------------
+//
+void CVRMediaRemovalMonitor::RunL()
+    {
+    // Re-subscribe to event.
+    TNotifyType notType(ENotifyDisk);
+    iFs.NotifyChange( notType, iStatus );
+    SetActive();
+    
+    // Check state
+    TDriveInfo drive;
+	User::LeaveIfError(iFs.Drive(drive, TInt(iDrive)));
+	
+	  // Notify Observer
+    switch(drive.iType)
+        {
+        case EMediaNotPresent:
+            {
+            if (!iDiskRemoved)
+                {
+                iObserver->HandleMMCEjectEventL( );
+                }
+                iDiskRemoved = ETrue;
+            break;
+            }
+        default:
+            {
+            if ( iDiskRemoved &&
+        		 ( drive.iMediaAtt & ( KMediaAttLockable|KMediaAttLocked|KMediaAttHasPassword ) ) != 
+ 				 ( KMediaAttLockable|KMediaAttLocked|KMediaAttHasPassword ) ) 
+                {
+                //do nothing
+                iDiskRemoved = EFalse;
+                }
+            break;
+            }
+        }
+    
+    }
+    
+// ---------------------------------------------------------------------------
+// Cancel NotifyChange request from file system
+// ---------------------------------------------------------------------------
+//
+void CVRMediaRemovalMonitor::DoCancel()
+    {
+    iFs.NotifyChangeCancel();
+    }
+    
+// ----------------------------------------------------------------------------
+// Handles a leave occurring in the request completion event handler RunL()
+// Don't care if client has a User::Leave() in RunL(), keep monitoring for events
+// ----------------------------------------------------------------------------
+//
+TInt CVRMediaRemovalMonitor::RunError(TInt aError)
+    {
+    return KErrNone;
+    }           
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voicerecorder/RecViewSrc/CVRMediaRemovalMonitor.h	Wed Apr 14 16:00:13 2010 +0300
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Monitors for media removal events
+*
+*/
+
+
+#ifndef CVRMEDIAREMOVALMONITER_H
+#define CVRMEDIAREMOVALMONITER_H
+
+#include <e32base.h>
+#include "MVRMediaRemovalObserver.h"
+
+/**
+ *  Class to monitors for File System dismount events
+ *  @lib Harvester
+ *  @since S60 3.0
+ */
+class CVRMediaRemovalMonitor : public CActive
+    {
+
+public:
+
+    /**
+    * Two-phase constructor
+    * @param aDrive drive to monitor
+    * @param aFs file server session
+    * @param aObserver observer to the event
+    */
+    static CVRMediaRemovalMonitor* NewL(  TInt aDrive, 
+                                          RFs& aFs,
+                                          MVRMediaRemovalObserver* aObserver );
+    /**
+    * Two-phase constructor
+    * @param aDrive drive to monitor
+    * @param aFs file server session
+    * @param aObserver observer to the event
+    */
+    static CVRMediaRemovalMonitor* NewLC(  TInt aDrive, 
+                                           RFs& aFs,
+                                           MVRMediaRemovalObserver* aObserver );
+
+    /**
+    * Virtual destructor
+    */
+    virtual ~CVRMediaRemovalMonitor();
+
+protected: // From base class 
+    
+    /*
+    * From CActive
+    */
+    void RunL();
+    
+    /*
+    * From CActive
+    */
+    void DoCancel();
+
+    /**
+    *  From CActive
+    */
+    TInt RunError(TInt aError);    
+        
+private:
+
+    /**
+    *  C++ constructor
+    * @param aDrive drive to monitor
+    * @param aFs file server session
+    * @param aObserver observer to the event
+    */
+    CVRMediaRemovalMonitor(  TInt aDrive,
+                             RFs& aFs,  
+                             MVRMediaRemovalObserver* aObserver );
+
+    void ConstructL();
+
+private: // data
+    
+    TInt iDrive;        // Drive that is being monitored
+    RFs& iFs;           // File Session, not owned
+    TBool iDiskRemoved; // Is the disk inserted
+    
+    /*
+    * Observer interface to callback to an observer
+    */
+    MVRMediaRemovalObserver* iObserver;
+    };
+
+#endif // CVRMEDIAREMOVALMONITER_H
--- a/voicerecorder/RecViewSrc/CVRRecViewModel.cpp	Wed Mar 31 21:35:17 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRRecViewModel.cpp	Wed Apr 14 16:00:13 2010 +0300
@@ -54,6 +54,7 @@
 #include "VRConsts.h"
 #include "CVRSystemEventHandler.h"
 #include "CVRUSBEventHandler.h"
+#include "CVRMediaRemovalMonitor.h"
 #include "VRUtils.h"
 #include "CVRRecViewModel.h"
 #include <csxhelp/vorec.hlp.hrh>
@@ -115,6 +116,8 @@
 
 	delete iCurrentUSBHandler;
 	
+	delete iCurrentMMCEjectHandler;
+	
 	}
 
 
@@ -135,6 +138,8 @@
 	iCurrentUSBHandler->Listen( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality,
 								 this );
 
+	//listen MMC eject
+	iCurrentMMCEjectHandler = CVRMediaRemovalMonitor::NewL(EDriveF, CEikonEnv::Static()->FsSession(), this);
 
 	if ( FeatureManager::FeatureSupported( KFeatureIdKeypadNoVoiceKey ) &&
 		FeatureManager::FeatureSupported( 
@@ -2445,3 +2450,29 @@
 
 
 // End of file
+
+
+// ---------------------------------------------------------------------------
+// CVRRecViewModel::HandleMMCEjectEventL
+// 
+// ---------------------------------------------------------------------------
+//
+void CVRRecViewModel::HandleMMCEjectEventL()
+	{
+	
+	// Actions to take when recording
+	TInt storageDrive = VRUtils::MemoDriveL();   	 
+    if ( storageDrive == EDriveF)
+		{
+        //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;       
+		}
+	}
+
+
+// End of file
--- a/voicerecorder/RecViewSrc/CVRRecViewModel.h	Wed Mar 31 21:35:17 2010 +0300
+++ b/voicerecorder/RecViewSrc/CVRRecViewModel.h	Wed Apr 14 16:00:13 2010 +0300
@@ -39,6 +39,8 @@
 
 #include "MVRSystemEventObserver.h"
 #include "MVRUSBEventObserver.h"
+#include "MVRMediaRemovalObserver.h"
+
 
 #include "TVRContext.h"
 #include "voicerecorder.hrh"
@@ -55,6 +57,7 @@
 class TVRState;
 class CVRSystemEventHandler;
 class CVRUSBEventHandler;
+class CVRMediaRemovalMonitor;
 
 
 // CLASS DEFINITION
@@ -68,7 +71,7 @@
 	  public MVRStateInfoModel, public MVRObserver,
 	  public MVRKeyObserver, public MVRVolumeChangeObserver,
       public MVRSystemEventObserver,
-      public MVRUSBEventObserver      
+      public MVRUSBEventObserver, public MVRMediaRemovalObserver      
 	{
 	private:	// nested classes
 
@@ -315,6 +318,9 @@
 
 		void HandleUSBEventL();
 		
+		
+		void HandleMMCEjectEventL();
+		
 	public: // new methods
 
 		/**
@@ -654,6 +660,8 @@
 		* For listening USB events. Owned.
 		*/
 		CVRUSBEventHandler* iCurrentUSBHandler;
+		
+		CVRMediaRemovalMonitor* iCurrentMMCEjectHandler;
 
 
 		/**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voicerecorder/RecViewSrc/MVRMediaRemovalObserver.h	Wed Apr 14 16:00:13 2010 +0300
@@ -0,0 +1,44 @@
+/*
+* 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
+* CVRMediaRemovalHandler class 
+*
+*/
+
+
+#ifndef __MVRMEDIAREMOVALOBSERVER_H
+#define __MVRMEDIAREMOVALOBSERVER_H
+
+// INCLUDES
+#include <e32def.h>
+#include <bldvariant.hrh>
+
+// CLASS DECLARATION
+/**
+*  __MVRMEDIAREMOVALOBSERVER_H
+*/
+class MVRMediaRemovalObserver
+    {
+    public:  // Constructors and destructor		
+    
+    virtual void HandleMMCEjectEventL( ) = 0;
+
+	};
+
+#endif     
+
+// __MVRMEDIAREMOVALOBSERVER_H
+
+// End of File
--- a/voicerecorder/group/RecView.mmp	Wed Mar 31 21:35:17 2010 +0300
+++ b/voicerecorder/group/RecView.mmp	Wed Apr 14 16:00:13 2010 +0300
@@ -48,7 +48,8 @@
 SOURCE		CVRRemConObserver.cpp
 SOURCE		CVRTonePlayer.cpp
 SOURCE      CVRDiskSpaceWatcher.cpp
-SOURCE		CVRUSBEventHandler.cpp
+SOURCE		CVRUSBEventHandler.cpp 
+SOURCE      CVRMediaRemovalMonitor.cpp
 
 USERINCLUDE	 ../RecViewSrc
 USERINCLUDE	 ../RecViewInc
@@ -81,6 +82,7 @@
 LIBRARY		platformenv.lib	// PathInfo
 LIBRARY		apgrfx.lib // RApaLsSession
 LIBRARY		apmime.lib  // TDataType
+LIBRARY		ws32.lib 
 
 LIBRARY		CdlEngine.lib
 LIBRARY		AknIcon.lib