kerneltest/e32test/usbho/t_usbdi/inc/UsbClientStateWatcher.h
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 #ifndef __USB_CLIENT_STATE_WATCHER_H
       
     2 #define __USB_CLIENT_STATE_WATCHER_H
       
     3 
       
     4 /*
       
     5 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     6 * All rights reserved.
       
     7 * This component and the accompanying materials are made available
       
     8 * under the terms of the License "Eclipse Public License v1.0"
       
     9 * which accompanies this distribution, and is available
       
    10 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    11 *
       
    12 * Initial Contributors:
       
    13 * Nokia Corporation - initial contribution.
       
    14 *
       
    15 * Contributors:
       
    16 *
       
    17 * Description:
       
    18 * @file UsbClientStateWatcher.h
       
    19 * @internalComponent
       
    20 * 
       
    21 *
       
    22 */
       
    23 
       
    24 
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <d32usbc.h>
       
    28 #include "testdebug.h"
       
    29 
       
    30 namespace NUnitTesting_USBDI
       
    31 	{
       
    32 	
       
    33 /**
       
    34 This class describes an interface class that observers state changes in the client
       
    35 */
       
    36 class MUsbClientStateObserver
       
    37 	{
       
    38 public:
       
    39 /**
       
    40 Called when the host has changed the state of the client device (e.g. to suspended)
       
    41 @param aNewState the new state of the device configured by the host
       
    42 @param aChangeCompletionCode the request completion code
       
    43 */
       
    44 	virtual void StateChangeL(TUsbcDeviceState aNewState,TInt aChangeCompletionCode) = 0;
       
    45 	};
       
    46 
       
    47 /**
       
    48 This class describes an observer that gets notified when the host selects an alternate setting
       
    49 */
       
    50 class MAlternateSettingObserver
       
    51 	{
       
    52 public:
       
    53 /**
       
    54 Called when the host selects an alternate interface setting
       
    55 @param aAlternateInterfaceSetting the alternate interface setting number
       
    56 */
       
    57 	virtual void AlternateInterfaceSelectedL(TInt aAlternateInterfaceSetting) = 0;
       
    58 	};
       
    59 
       
    60 /**
       
    61 This class represents a watcher of USB client device states
       
    62 @internal
       
    63 */
       
    64 class CUsbClientStateWatcher : public CActive
       
    65 	{
       
    66 public:
       
    67 /**
       
    68 Factory two-phase construction
       
    69 @param aUsbClientDriver a referrence to a USB client driver interface object
       
    70 */
       
    71 	static CUsbClientStateWatcher* NewL(RDevUsbcClient& aClientDriver,MUsbClientStateObserver& aStateObserver);
       
    72 
       
    73 /**
       
    74 Destructor
       
    75 */
       
    76 	~CUsbClientStateWatcher();
       
    77 	
       
    78 private:
       
    79 
       
    80 /**
       
    81 Constructor, builds a USB client state change watcher
       
    82 @param aUsbClientDriver the referrence to the USB client driver
       
    83 */
       
    84 	CUsbClientStateWatcher(RDevUsbcClient& aClientDriver,MUsbClientStateObserver& aStateObserver);
       
    85 
       
    86 /**
       
    87 2nd phase construction
       
    88 */
       
    89 	void ConstructL();
       
    90 
       
    91 private: // from CActive
       
    92 
       
    93 /**
       
    94 Cancels the notification of device state changes
       
    95 */
       
    96 	void DoCancel();
       
    97 	
       
    98 /**
       
    99 Handles any Leave errors from this AO as it receives notification
       
   100 of state changes
       
   101 @param aError the leave code error from RunL
       
   102 @return KErrNone (currently)
       
   103 */
       
   104 	TInt RunError(TInt aError);
       
   105 	
       
   106 /**
       
   107 Code that is scheduled when this AO completes
       
   108 */
       
   109 	void RunL();
       
   110 
       
   111 private:
       
   112 /**
       
   113 The referrence to the USB client driver
       
   114 */
       
   115 	RDevUsbcClient& iClientDriver;
       
   116 	
       
   117 /**
       
   118 The current state of the USB device (integer value)
       
   119 */
       
   120 	TUint iState;
       
   121 
       
   122 /**
       
   123 The observers for the state of the USB client
       
   124 */	
       
   125 	MUsbClientStateObserver& iStateObserver;
       
   126 	};
       
   127 	
       
   128 	
       
   129 /**
       
   130 This class represents a watcher of Alternate interface selections
       
   131 @intenal
       
   132 */
       
   133 class CAlternateInterfaceSelectionWatcher : public CActive
       
   134 	{
       
   135 public:
       
   136 /**
       
   137 Symbian construction of a watcher of alternate interface setting selections
       
   138 @param aClientDriver the channel to the client driver
       
   139 @param aObserver the observer of alternate interface setting selections
       
   140 */
       
   141 	static CAlternateInterfaceSelectionWatcher* NewL(RDevUsbcClient& aClientDriver,MAlternateSettingObserver& aObserver);
       
   142 
       
   143 /**
       
   144 Destructor
       
   145 */
       
   146 	~CAlternateInterfaceSelectionWatcher();
       
   147 
       
   148 private:
       
   149 
       
   150 /**
       
   151 Constructor, builds an object that watchers for selections of alternate interface settings
       
   152 @param aClientDriver the channel to the client driver
       
   153 @param aObserver the observer of alternate interface setting selections
       
   154 */
       
   155 	CAlternateInterfaceSelectionWatcher(RDevUsbcClient& aClientDriver,MAlternateSettingObserver& aObserver);
       
   156 
       
   157 /**
       
   158 2nd phase construction
       
   159 */
       
   160 	void ConstructL();
       
   161 
       
   162 private: // From CActive
       
   163 
       
   164 /**
       
   165 */
       
   166 	void DoCancel();
       
   167 	
       
   168 /**
       
   169 */
       
   170 	void RunL();
       
   171 	
       
   172 /**
       
   173 */
       
   174 	TInt RunError(TInt aError);
       
   175 
       
   176 private:
       
   177 /**
       
   178 The referrence to the USB client driver
       
   179 */
       
   180 	RDevUsbcClient& iClientDriver;
       
   181 		
       
   182 /**
       
   183 The current state of the USB device (integer value)
       
   184 */
       
   185 	TUint iState;
       
   186 		
       
   187 /**
       
   188 The observer that will be notified when a host selects any alternate interface setting 
       
   189 that this watcher knows about
       
   190 */
       
   191 	MAlternateSettingObserver& iObserver;
       
   192 	};
       
   193 
       
   194 	}
       
   195 
       
   196 #endif
       
   197