sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: //#include sl@0: //#include sl@0: //#include sl@0: //#include sl@0: sl@0: sl@0: //#include "rusbhostmslogicalunit.h" sl@0: // sl@0: // sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "usbtypes.h" sl@0: #include "rusbhostmsdevice.h" sl@0: #include "rextfilesystem.h" sl@0: sl@0: #include "cusbmsmountmanager.h" sl@0: //#include "cusbhost.h" sl@0: #include "cusbhostao.h" sl@0: #include "tmslog.h" sl@0: #include "debug.h" sl@0: sl@0: sl@0: _LIT(KTxtApp,"CUSBHOSTAO"); sl@0: sl@0: CUsbHostAo* CUsbHostAo::NewL(RUsbHubDriver& aHubDriver, sl@0: RUsbHubDriver::TBusEvent& aEvent, sl@0: MUsbHostBusEventObserver& aObserver) sl@0: { sl@0: __MSFNSLOG sl@0: CUsbHostAo* r = new (ELeave) CUsbHostAo(aHubDriver, aEvent, aObserver); sl@0: r->ConstructL(); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: void CUsbHostAo::ConstructL() sl@0: { sl@0: __MSFNLOG sl@0: } sl@0: sl@0: sl@0: CUsbHostAo::CUsbHostAo(RUsbHubDriver& aHubDriver, sl@0: RUsbHubDriver::TBusEvent& aEvent, sl@0: MUsbHostBusEventObserver& aObserver) sl@0: : CActive(EPriorityStandard), sl@0: iHubDriver(aHubDriver), sl@0: iEvent(aEvent), sl@0: iObserver(aObserver) sl@0: { sl@0: __MSFNLOG sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: sl@0: CUsbHostAo::~CUsbHostAo() sl@0: { sl@0: __MSFNLOG sl@0: Cancel(); sl@0: sl@0: } sl@0: sl@0: sl@0: void CUsbHostAo::Wait() sl@0: { sl@0: __MSFNLOG sl@0: if (IsActive()) sl@0: { sl@0: __ASSERT_ALWAYS(EFalse, User::Panic(KTxtApp, -1)); sl@0: return; sl@0: } sl@0: sl@0: __USBHOSTPRINT(_L("WaitForBusEvent...")); sl@0: iHubDriver.WaitForBusEvent(iEvent, iStatus); sl@0: __USBHOSTPRINT2(_L("WaitForBusEvent done. Event=%d Status=%d"), sl@0: iEvent.iEventType, iStatus.Int()); sl@0: SetActive(); sl@0: } sl@0: sl@0: sl@0: void CUsbHostAo::DoCancel() sl@0: { sl@0: __MSFNLOG sl@0: iHubDriver.CancelWaitForBusEvent(); sl@0: } sl@0: sl@0: sl@0: void CUsbHostAo::RunL() sl@0: { sl@0: __MSFNLOG sl@0: sl@0: TInt status = iStatus.Int(); sl@0: if (status == KErrNotReady) sl@0: { sl@0: const TInt KDelay = 500 * 1000; // in uSecs sl@0: User::After(KDelay); sl@0: Wait(); sl@0: return; sl@0: } sl@0: sl@0: // Let RunError handle any other error sl@0: User::LeaveIfError(status); sl@0: sl@0: // Process bus event sl@0: TRAP(status, iObserver.ProcessBusEventL()); sl@0: if(status != KErrNone) sl@0: { sl@0: Wait(); sl@0: return; sl@0: } sl@0: sl@0: Wait(); sl@0: } sl@0: sl@0: _LIT(KErrLog, "ERROR %d in CActiveUsbHost"); sl@0: sl@0: TInt CUsbHostAo::RunError(TInt aError) sl@0: { sl@0: __MSFNLOG sl@0: RDebug::Print(KErrLog, aError); sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: