1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
21 #include "rextfilesystem.h" |
21 #include "rextfilesystem.h" |
22 |
22 |
23 #include "cusbmsmountmanager.h" |
23 #include "cusbmsmountmanager.h" |
24 //#include "cusbhost.h" |
24 //#include "cusbhost.h" |
25 #include "cusbhostao.h" |
25 #include "cusbhostao.h" |
26 #include "tmslog.h" |
|
27 #include "debug.h" |
26 #include "debug.h" |
28 |
27 |
29 |
28 |
30 _LIT(KTxtApp,"CUSBHOSTAO"); |
29 _LIT(KTxtApp,"CUSBHOSTAO"); |
31 |
30 |
32 CUsbHostAo* CUsbHostAo::NewL(RUsbHubDriver& aHubDriver, |
31 CUsbHostAo* CUsbHostAo::NewL(RUsbHubDriver& aHubDriver, |
33 RUsbHubDriver::TBusEvent& aEvent, |
32 RUsbHubDriver::TBusEvent& aEvent, |
34 MUsbHostBusEventObserver& aObserver) |
33 MUsbHostBusEventObserver& aObserver) |
35 { |
34 { |
36 __MSFNSLOG |
|
37 CUsbHostAo* r = new (ELeave) CUsbHostAo(aHubDriver, aEvent, aObserver); |
35 CUsbHostAo* r = new (ELeave) CUsbHostAo(aHubDriver, aEvent, aObserver); |
38 r->ConstructL(); |
36 r->ConstructL(); |
39 return r; |
37 return r; |
40 } |
38 } |
41 |
39 |
42 |
40 |
43 void CUsbHostAo::ConstructL() |
41 void CUsbHostAo::ConstructL() |
44 { |
42 { |
45 __MSFNLOG |
|
46 } |
43 } |
47 |
44 |
48 |
45 |
49 CUsbHostAo::CUsbHostAo(RUsbHubDriver& aHubDriver, |
46 CUsbHostAo::CUsbHostAo(RUsbHubDriver& aHubDriver, |
50 RUsbHubDriver::TBusEvent& aEvent, |
47 RUsbHubDriver::TBusEvent& aEvent, |
52 : CActive(EPriorityStandard), |
49 : CActive(EPriorityStandard), |
53 iHubDriver(aHubDriver), |
50 iHubDriver(aHubDriver), |
54 iEvent(aEvent), |
51 iEvent(aEvent), |
55 iObserver(aObserver) |
52 iObserver(aObserver) |
56 { |
53 { |
57 __MSFNLOG |
|
58 CActiveScheduler::Add(this); |
54 CActiveScheduler::Add(this); |
59 } |
55 } |
60 |
56 |
61 |
57 |
62 CUsbHostAo::~CUsbHostAo() |
58 CUsbHostAo::~CUsbHostAo() |
63 { |
59 { |
64 __MSFNLOG |
60 Cancel(); |
65 Cancel(); |
|
66 |
61 |
67 } |
62 } |
68 |
63 |
69 |
64 |
70 void CUsbHostAo::Wait() |
65 void CUsbHostAo::Wait() |
71 { |
66 { |
72 __MSFNLOG |
67 if (IsActive()) |
73 if (IsActive()) |
68 { |
74 { |
69 __ASSERT_ALWAYS(EFalse, User::Panic(KTxtApp, -1)); |
75 __ASSERT_ALWAYS(EFalse, User::Panic(KTxtApp, -1)); |
70 return; |
76 return; |
71 } |
77 } |
|
78 |
72 |
79 __USBHOSTPRINT(_L("WaitForBusEvent...")); |
73 __USBHOSTPRINT(_L("WaitForBusEvent...")); |
80 iHubDriver.WaitForBusEvent(iEvent, iStatus); |
74 iHubDriver.WaitForBusEvent(iEvent, iStatus); |
81 __USBHOSTPRINT2(_L("WaitForBusEvent done. Event=%d Status=%d"), |
75 __USBHOSTPRINT2(_L("WaitForBusEvent done. Event=%d Status=%d"), |
82 iEvent.iEventType, iStatus.Int()); |
76 iEvent.iEventType, iStatus.Int()); |
83 SetActive(); |
77 SetActive(); |
84 } |
78 } |
85 |
79 |
86 |
80 |
87 void CUsbHostAo::DoCancel() |
81 void CUsbHostAo::DoCancel() |
88 { |
82 { |
89 __MSFNLOG |
|
90 iHubDriver.CancelWaitForBusEvent(); |
83 iHubDriver.CancelWaitForBusEvent(); |
91 } |
84 } |
92 |
85 |
93 |
86 |
94 void CUsbHostAo::RunL() |
87 void CUsbHostAo::RunL() |
95 { |
88 { |
96 __MSFNLOG |
|
97 |
89 |
98 TInt status = iStatus.Int(); |
90 TInt status = iStatus.Int(); |
99 if (status == KErrNotReady) |
91 if (status == KErrNotReady) |
100 { |
92 { |
101 const TInt KDelay = 500 * 1000; // in uSecs |
93 const TInt KDelay = 500 * 1000; // in uSecs |
102 User::After(KDelay); |
94 User::After(KDelay); |
103 Wait(); |
95 Wait(); |
104 return; |
96 return; |
105 } |
97 } |
106 |
98 |
107 // Let RunError handle any other error |
99 // Let RunError handle any other error |
108 User::LeaveIfError(status); |
100 User::LeaveIfError(status); |
109 |
101 |
110 // Process bus event |
102 // Process bus event |
111 TRAP(status, iObserver.ProcessBusEventL()); |
103 TRAP(status, iObserver.ProcessBusEventL()); |
112 if(status != KErrNone) |
104 if(status != KErrNone) |
113 { |
105 { |
114 Wait(); |
106 Wait(); |
115 return; |
107 return; |
116 } |
108 } |
117 |
109 |
118 Wait(); |
110 Wait(); |
119 } |
111 } |
120 |
112 |
121 _LIT(KErrLog, "ERROR %d in CActiveUsbHost"); |
113 _LIT(KErrLog, "ERROR %d in CActiveUsbHost"); |
122 |
114 |
123 TInt CUsbHostAo::RunError(TInt aError) |
115 TInt CUsbHostAo::RunError(TInt aError) |
124 { |
116 { |
125 __MSFNLOG |
117 RDebug::Print(KErrLog, aError); |
126 RDebug::Print(KErrLog, aError); |
118 return KErrNone; |
127 return KErrNone; |
119 } |
128 } |
|
129 |
120 |
130 |
121 |
131 |
122 |