mmappcomponents/harvester/server/inc/mpxmediaremovalmonitor.h
branchRCL_3
changeset 19 51035f0751c2
parent 0 a2952bb97e68
--- a/mmappcomponents/harvester/server/inc/mpxmediaremovalmonitor.h	Wed Mar 31 22:26:09 2010 +0300
+++ b/mmappcomponents/harvester/server/inc/mpxmediaremovalmonitor.h	Wed Apr 14 16:28:17 2010 +0300
@@ -20,21 +20,35 @@
 #define CMPXMEDIAREMOVALMONITOR_H
 
 #include <e32base.h>
+#include <disknotifyhandler.h>
 #include "mpxsystemeventobserver.h"
 
 /**
  *  Class to monitors for File System dismount events
+ * 
+ *  The monitor emits events to MMPXSystemEventObserver
+ * 
+ *     EDiskDismountEvent whenever a drive is about to be dismounted (see RFs::NotifyDismount).
+ *     EDiskRemovedEvent  whenever a specified drive has been dismounted or removed
+ *     EDiskInsertedEvent whenever a specified drive has been inserted
+ *
+ *  The observer is expected to prepare the drive for dismounting during the EDiskDismountEvent.
+ *
+ *  Dismount monitoring is automatically subscribed for all non-remote drives.
+ *  Inserted/Removed monitor is subscribed only for the drive given in the constructor.
+ *
  *  @lib Harvester
  *  @since S60 3.0
  */
-class CMPXMediaRemovalMonitor : public CActive
+class CMPXMediaRemovalMonitor : public CBase, 
+                                public MDiskNotifyHandlerCallback
     {
 
 public:
 
     /**
     * Two-phase constructor
-    * @param aDrive drive to monitor
+    * @param aDrive drive to monitor for insertions and removals
     * @param aFs file server session
     * @param aObserver observer to the event
     */
@@ -55,24 +69,24 @@
     * Virtual destructor
     */
     virtual ~CMPXMediaRemovalMonitor();
-
-protected: // From base class 
     
-    /*
-    * From CActive
+    /**
+    * Check the status of the monitored disks
+    *
+    * This check should be done whenever there is a risk that we got
+    * a NotifyDismount even though the drives actually weren't dismounted.
+    * 
     */
-    void RunL();
-    
-    /*
-    * From CActive
-    */
-    void DoCancel();
+    void CheckDriveStatus();
+
+protected: // From Base Class
 
     /**
-    *  From CActive
+    * From MDiskNotifyHandlerCallback
     */
-    TInt RunError(TInt aError);    
-        
+    void HandleNotifyDismount( TInt aError, const TDismountEvent& aEvent );
+    void HandleNotifyDisk( TInt aError, const TDiskEvent& aEvent );
+
 private:
 
     /**
@@ -89,6 +103,7 @@
 
 private: // data
     
+    CDiskNotifyHandler*  iDiskNotifyHandler;  // Disk notification handler
     TInt iDrive;        // Drive that is being monitored
     RFs& iFs;           // File Session, not owned
     TBool iDiskRemoved; // Is the disk inserted