os/kernelhwsrv/kerneltest/e32test/usb/t_usb_device/include/usbms.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @internalComponent
    19 */
    20 
    21 #ifndef USBMS_H
    22 #define USBMS_H
    23 
    24 #include <e32base.h>
    25 #include <e32property.h>		// RProperty
    26 #include <d32usbcsc.h>
    27 #include <d32usbc.h>
    28 
    29 typedef RDEVCLIENT RUsb;
    30 typedef TUint TUsbDeviceState;
    31 
    32 //-----------------------------------------------------------------------------
    33 /**
    34     Class describing a file system mounted on the drive.
    35     It has a limitation: full list of possible FS extensions is not supported, only the primary one.
    36 */
    37 class CFileSystemDescriptor : public CBase
    38     {
    39  public:
    40     ~CFileSystemDescriptor();    
    41     static CFileSystemDescriptor* NewL(const TDesC& aFsName, const TDesC& aPrimaryExtName, TBool aDrvSynch);
    42 
    43     TPtrC FsName() const            {return iFsName;}
    44     TPtrC PrimaryExtName() const    {return iPrimaryExtName;}
    45     TBool DriveIsSynch() const      {return iDriveSynch;}
    46 
    47  private:
    48     CFileSystemDescriptor() {}
    49     CFileSystemDescriptor(const CFileSystemDescriptor&);
    50     CFileSystemDescriptor& operator=(const CFileSystemDescriptor&);
    51  
    52  private:   
    53 
    54     RBuf    iFsName;        ///< file system name
    55     RBuf    iPrimaryExtName;///< name of the primary extension if present. Empty otherwise
    56     TBool   iDriveSynch;    ///< ETrue if the drive is synchronous
    57 
    58     };  
    59 
    60 class PropertyHandlers
    61 	{
    62 public:
    63 	typedef void(*THandler)(RProperty&);
    64 	static TBuf8<16> allDrivesStatus;
    65 	static TUsbMsBytesTransferred iKBytesRead;
    66 	static TUsbMsBytesTransferred iKBytesWritten;
    67 	static TInt iMediaError;
    68 
    69 	static void Transferred(RProperty& aProperty, TUsbMsBytesTransferred& aReadOrWritten);
    70 	static void Read(RProperty& aProperty);
    71 	static void Written(RProperty& aProperty);
    72 	static void DriveStatus(RProperty& aProperty);
    73 	static void MediaError(RProperty& aProperty);
    74 	};
    75 
    76 /**
    77 An active object that tracks changes to the KUsbMsDriveState properties
    78 */
    79 class CPropertyWatch : public CActive
    80 	{
    81 public:
    82 	static CPropertyWatch* NewLC(TUsbMsDriveState_Subkey aSubkey, PropertyHandlers::THandler aHandler);
    83 	~CPropertyWatch();
    84 private:
    85 	CPropertyWatch(PropertyHandlers::THandler aHandler);
    86 	void ConstructL(TUsbMsDriveState_Subkey aSubkey);
    87 	void RunL();
    88 	void DoCancel();
    89 	
    90 	RProperty iProperty;
    91 	PropertyHandlers::THandler iHandler;
    92 	};
    93 
    94 /**
    95 An active object that tracks changes to the KUsbMsDriveState properties
    96 */
    97 class CUsbWatch : public CActive
    98 	{
    99 public:
   100 	static CUsbWatch* NewLC(RUsb& aUsb);
   101 	~CUsbWatch();
   102 private:
   103 	CUsbWatch(RUsb& aUsb);
   104 	void ConstructL();
   105 	void RunL();
   106 	void DoCancel();
   107 
   108 	RUsb& iUsb;
   109 	TUsbDeviceState iUsbDeviceState;
   110 	TBool iWasConfigured;
   111 	};
   112 
   113 class CMessageKeyProcessor : public CActive
   114 	{
   115 public:
   116 	static CMessageKeyProcessor* NewLC(CConsoleBase* aConsole);
   117 	static CMessageKeyProcessor* NewL(CConsoleBase* aConsole);
   118 	~CMessageKeyProcessor();
   119 
   120 public:
   121 	// Issue request
   122 	void RequestCharacter();
   123 	// Cancel request.
   124 	// Defined as pure virtual by CActive;
   125 	// implementation provided by this class.
   126 	void DoCancel();
   127 	// Service completed request.
   128 	// Defined as pure virtual by CActive;
   129 	// implementation provided by this class,
   130 	void RunL();
   131 	// Called from RunL() to handle the completed request
   132 	void ProcessKeyPress(TChar aChar);
   133 
   134 private:
   135 	CMessageKeyProcessor(CConsoleBase* aConsole);
   136 	void ConstructL();
   137 	CConsoleBase* iConsole; // A console for reading from
   138 	};
   139 
   140 
   141 #endif // USBMSAPP_H