installationservices/swi/source/daemon/drivewatcher.h
branchRCL_3
changeset 66 8b7f4e561641
parent 0 ba25891c3a9e
equal deleted inserted replaced
65:7333d7932ef7 66:8b7f4e561641
       
     1 /*
       
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file 
       
    21  @internalComponent
       
    22  @released
       
    23 */
       
    24 
       
    25 #ifndef __DRIVEWATCHER_H__
       
    26 #define __DRIVEWATCHER_H__
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <f32file.h>
       
    30 
       
    31 namespace Swi
       
    32 {
       
    33 
       
    34 /**
       
    35  * Observer interface called whenever a media change is detected.
       
    36  */
       
    37 class MDriveObserver
       
    38 	{
       
    39 public:
       
    40 	/// Enumeration indicating whether a card was inserted or removed
       
    41 	enum TChangeType { EMediaInserted, EMediaRemoved };
       
    42 	
       
    43 	/**
       
    44 	 * This function is called to indicate a media change has occurred.
       
    45 	 *
       
    46 	 * @param aChangeType	EInserted to indicate media has been inserted,
       
    47 	 *						or ERemoved to indicate media has been removed.
       
    48 	 */
       
    49 	virtual void MediaChangeL(TInt aDrive, TChangeType aChangeType)=0;
       
    50 	};
       
    51 
       
    52 /**
       
    53  * This active object waits for an indication that the media has changed,
       
    54  * and then notifies its observer.
       
    55  */
       
    56 class CDriveWatcher : public CActive
       
    57 	{
       
    58 public:
       
    59 	static CDriveWatcher* NewL(RFs& aFs, TInt aDrive, MDriveObserver& aObserver,TInt aPriority = EPriorityStandard);
       
    60 	static CDriveWatcher* NewLC(RFs& aFs, TInt aDrive, MDriveObserver& aObserver,TInt aPriority = EPriorityStandard);
       
    61 	
       
    62 	~CDriveWatcher();
       
    63 
       
    64 	TInt Drive() const;
       
    65 private:
       
    66 	CDriveWatcher(RFs& aFs, TInt aDrive, MDriveObserver& aObserver, TInt aPriority);
       
    67 
       
    68 	void ConstructL();
       
    69 
       
    70 // from CActive
       
    71 	void DoCancel();
       
    72 	void RunL();
       
    73 
       
    74 	/// Set up change notification.
       
    75 	void WaitForChangeL();
       
    76 
       
    77 	/**
       
    78 	 * Notifies the observer of the appropriate media change depending on whether
       
    79 	 * media is now present on the drive we're currently watching.
       
    80 	 */
       
    81 	void NotifyMediaChange();
       
    82 	
       
    83 	/** 
       
    84 	 * Determines if the media is present in the drive we are currently watching.
       
    85 	 *
       
    86 	 * @return ETrue if the media is present, EFalse otherwise.
       
    87 	 */
       
    88 	TBool IsMediaPresentL();
       
    89 
       
    90 private:
       
    91 	/// Not owned by this class
       
    92 	RFs& iFs;
       
    93 	
       
    94 	/// Drive number we are watching
       
    95 	TInt iDrive;
       
    96 
       
    97 	/// Observer to notify of changes
       
    98 	MDriveObserver& iObserver;
       
    99 	};
       
   100 
       
   101 // inline functions from CDriveWatcher
       
   102 
       
   103 inline TInt CDriveWatcher::Drive() const
       
   104 	{
       
   105 	return iDrive;
       
   106 	}
       
   107 	
       
   108 } //namespace Swi
       
   109 
       
   110 #endif // #ifndef __DRIVEWATCHER_H__
       
   111