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