kerneltest/e32test/usb/t_usb_device/src/activestallnotifier.cpp
changeset 0 a41df078684a
child 253 d37db4dcc88d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/src/activestallnotifier.cpp	Mon Oct 19 15:55:17 2009 +0100
@@ -0,0 +1,89 @@
+// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32test/usb\t_usb_device\src\activestallnotifier.cpp
+// USB Test Program T_USB_DEVICE, functional part.
+// Device-side part, to work against T_USB_HOST running on the host.
+// 
+//
+
+#include "general.h"									// CActiveControl, CActiveRW
+#include "activestallnotifier.h"
+
+extern RTest test;
+extern TBool gVerbose;
+extern TBool gSkip;
+extern TBool gStopOnFail;
+extern TInt gSoakCount;
+
+//
+// --- class CActiveStallNotifier ---------------------------------------------------------
+//
+
+CActiveStallNotifier::CActiveStallNotifier(CConsoleBase* aConsole, RDEVCLIENT* aPort)
+	: CActive(EPriorityNormal),
+	  iConsole(aConsole),
+	  iPort(aPort),
+	  iEndpointState(0)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CActiveStallNotifier* CActiveStallNotifier::NewL(CConsoleBase* aConsole, RDEVCLIENT* aPort)
+	{
+	CActiveStallNotifier* self = new (ELeave) CActiveStallNotifier(aConsole, aPort);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();									// self
+	return self;
+	}
+
+
+void CActiveStallNotifier::ConstructL()
+	{}
+
+
+CActiveStallNotifier::~CActiveStallNotifier()
+	{
+	TUSB_VERBOSE_PRINT("CActiveStallNotifier::~CActiveStallNotifier()");
+	Cancel();												// base class
+	}
+
+
+void CActiveStallNotifier::DoCancel()
+	{
+	TUSB_VERBOSE_PRINT("CActiveStallNotifier::DoCancel()");
+	iPort->EndpointStatusNotifyCancel();
+	}
+
+
+void CActiveStallNotifier::RunL()
+	{
+	// This just displays the bitmap, showing which endpoints (if any) are now stalled.
+	// In a real world program, the user could take here appropriate action (cancel a
+	// transfer request or whatever).
+	TUSB_VERBOSE_PRINT1("StallNotifier: Endpointstate 0x%x\n", iEndpointState);
+	Activate();
+	}
+
+
+void CActiveStallNotifier::Activate()
+	{
+	__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666));
+	iPort->EndpointStatusNotify(iStatus, iEndpointState);
+	SetActive();
+	}
+
+
+
+// -eof-