0
|
1 |
// Copyright (c) 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 |
#include <e32base.h>
|
|
17 |
#include <f32file.h>
|
|
18 |
#include <d32usbdi_hubdriver.h>
|
|
19 |
#include "usbtypes.h"
|
|
20 |
#include "rusbhostmsdevice.h"
|
|
21 |
#include "rextfilesystem.h"
|
|
22 |
|
|
23 |
#include "cusbmsmountmanager.h"
|
|
24 |
//#include "cusbhost.h"
|
|
25 |
#include "cusbhostao.h"
|
|
26 |
#include "tmslog.h"
|
|
27 |
#include "debug.h"
|
|
28 |
|
|
29 |
|
|
30 |
_LIT(KTxtApp,"CUSBHOSTAO");
|
|
31 |
|
|
32 |
CUsbHostAo* CUsbHostAo::NewL(RUsbHubDriver& aHubDriver,
|
|
33 |
RUsbHubDriver::TBusEvent& aEvent,
|
|
34 |
MUsbHostBusEventObserver& aObserver)
|
|
35 |
{
|
|
36 |
__MSFNSLOG
|
|
37 |
CUsbHostAo* r = new (ELeave) CUsbHostAo(aHubDriver, aEvent, aObserver);
|
|
38 |
r->ConstructL();
|
|
39 |
return r;
|
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
void CUsbHostAo::ConstructL()
|
|
44 |
{
|
|
45 |
__MSFNLOG
|
|
46 |
}
|
|
47 |
|
|
48 |
|
|
49 |
CUsbHostAo::CUsbHostAo(RUsbHubDriver& aHubDriver,
|
|
50 |
RUsbHubDriver::TBusEvent& aEvent,
|
|
51 |
MUsbHostBusEventObserver& aObserver)
|
|
52 |
: CActive(EPriorityStandard),
|
|
53 |
iHubDriver(aHubDriver),
|
|
54 |
iEvent(aEvent),
|
|
55 |
iObserver(aObserver)
|
|
56 |
{
|
|
57 |
__MSFNLOG
|
|
58 |
CActiveScheduler::Add(this);
|
|
59 |
}
|
|
60 |
|
|
61 |
|
|
62 |
CUsbHostAo::~CUsbHostAo()
|
|
63 |
{
|
|
64 |
__MSFNLOG
|
|
65 |
Cancel();
|
|
66 |
|
|
67 |
}
|
|
68 |
|
|
69 |
|
|
70 |
void CUsbHostAo::Wait()
|
|
71 |
{
|
|
72 |
__MSFNLOG
|
|
73 |
if (IsActive())
|
|
74 |
{
|
|
75 |
__ASSERT_ALWAYS(EFalse, User::Panic(KTxtApp, -1));
|
|
76 |
return;
|
|
77 |
}
|
|
78 |
|
|
79 |
__USBHOSTPRINT(_L("WaitForBusEvent..."));
|
|
80 |
iHubDriver.WaitForBusEvent(iEvent, iStatus);
|
|
81 |
__USBHOSTPRINT2(_L("WaitForBusEvent done. Event=%d Status=%d"),
|
|
82 |
iEvent.iEventType, iStatus.Int());
|
|
83 |
SetActive();
|
|
84 |
}
|
|
85 |
|
|
86 |
|
|
87 |
void CUsbHostAo::DoCancel()
|
|
88 |
{
|
|
89 |
__MSFNLOG
|
|
90 |
iHubDriver.CancelWaitForBusEvent();
|
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
void CUsbHostAo::RunL()
|
|
95 |
{
|
|
96 |
__MSFNLOG
|
|
97 |
|
|
98 |
TInt status = iStatus.Int();
|
|
99 |
if (status == KErrNotReady)
|
|
100 |
{
|
|
101 |
const TInt KDelay = 500 * 1000; // in uSecs
|
|
102 |
User::After(KDelay);
|
|
103 |
Wait();
|
|
104 |
return;
|
|
105 |
}
|
|
106 |
|
|
107 |
// Let RunError handle any other error
|
|
108 |
User::LeaveIfError(status);
|
|
109 |
|
|
110 |
// Process bus event
|
|
111 |
TRAP(status, iObserver.ProcessBusEventL());
|
|
112 |
if(status != KErrNone)
|
|
113 |
{
|
|
114 |
Wait();
|
|
115 |
return;
|
|
116 |
}
|
|
117 |
|
|
118 |
Wait();
|
|
119 |
}
|
|
120 |
|
|
121 |
_LIT(KErrLog, "ERROR %d in CActiveUsbHost");
|
|
122 |
|
|
123 |
TInt CUsbHostAo::RunError(TInt aError)
|
|
124 |
{
|
|
125 |
__MSFNLOG
|
|
126 |
RDebug::Print(KErrLog, aError);
|
|
127 |
return KErrNone;
|
|
128 |
}
|
|
129 |
|
|
130 |
|
|
131 |
|