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". |
20 #include <e32debug.h> |
20 #include <e32debug.h> |
21 |
21 |
22 #include "cusbotg.h" |
22 #include "cusbotg.h" |
23 #include "cusbotgwatcher.h" |
23 #include "cusbotgwatcher.h" |
24 |
24 |
25 #include "tmslog.h" |
|
26 #include "debug.h" |
25 #include "debug.h" |
27 |
26 |
28 |
27 |
29 CUsbOtgBaseWatcher::CUsbOtgBaseWatcher(RUsbOtgDriver& aLdd) |
28 CUsbOtgBaseWatcher::CUsbOtgBaseWatcher(RUsbOtgDriver& aLdd) |
30 : CActive(CActive::EPriorityStandard), |
29 : CActive(CActive::EPriorityStandard), |
31 iLdd(aLdd) |
30 iLdd(aLdd) |
32 { |
31 { |
33 __MSFNLOG |
32 CActiveScheduler::Add(this); |
34 CActiveScheduler::Add(this); |
33 } |
35 } |
|
36 |
34 |
37 |
35 |
38 CUsbOtgBaseWatcher::~CUsbOtgBaseWatcher() |
36 CUsbOtgBaseWatcher::~CUsbOtgBaseWatcher() |
39 { |
37 { |
40 __MSFNLOG |
38 Cancel(); |
41 Cancel(); |
39 } |
42 } |
|
43 |
40 |
44 void CUsbOtgBaseWatcher::Start() |
41 void CUsbOtgBaseWatcher::Start() |
45 { |
42 { |
46 __MSFNLOG |
43 Post(); |
47 Post(); |
44 } |
48 } |
|
49 |
45 |
50 |
46 |
51 |
47 |
52 CRequestSessionWatcher* CRequestSessionWatcher::NewL(MUsbRequestSessionObserver& aObserver) |
48 CRequestSessionWatcher* CRequestSessionWatcher::NewL(MUsbRequestSessionObserver& aObserver) |
53 { |
49 { |
54 __MSFNSLOG |
|
55 CRequestSessionWatcher* r = new (ELeave) CRequestSessionWatcher(aObserver); |
50 CRequestSessionWatcher* r = new (ELeave) CRequestSessionWatcher(aObserver); |
56 r->ConstructL(); |
51 r->ConstructL(); |
57 return r; |
52 return r; |
58 } |
53 } |
59 |
54 |
60 CRequestSessionWatcher::CRequestSessionWatcher(MUsbRequestSessionObserver& aObserver) |
55 CRequestSessionWatcher::CRequestSessionWatcher(MUsbRequestSessionObserver& aObserver) |
61 : CActive(EPriorityStandard), |
56 : CActive(EPriorityStandard), |
62 iObserver(aObserver) |
57 iObserver(aObserver) |
63 { |
58 { |
64 __MSFNLOG |
|
65 } |
59 } |
66 |
60 |
67 void CRequestSessionWatcher::ConstructL() |
61 void CRequestSessionWatcher::ConstructL() |
68 { |
62 { |
69 __MSFNLOG |
|
70 User::LeaveIfError(iProperty.Define(KUidUsbManCategory, KUsbRequestSessionProperty, RProperty::EInt)); |
63 User::LeaveIfError(iProperty.Define(KUidUsbManCategory, KUsbRequestSessionProperty, RProperty::EInt)); |
71 User::LeaveIfError(iProperty.Attach(KUidUsbManCategory, KUsbRequestSessionProperty)); |
64 User::LeaveIfError(iProperty.Attach(KUidUsbManCategory, KUsbRequestSessionProperty)); |
72 CActiveScheduler::Add(this); |
65 CActiveScheduler::Add(this); |
73 |
66 |
74 // initial subscription and process current property value |
67 // initial subscription and process current property value |
75 RunL(); |
68 RunL(); |
76 } |
69 } |
77 |
70 |
78 |
71 |
79 void CRequestSessionWatcher::DoCancel() |
72 void CRequestSessionWatcher::DoCancel() |
80 { |
73 { |
81 __MSFNLOG |
74 iProperty.Cancel(); |
82 iProperty.Cancel(); |
75 } |
83 } |
|
84 |
76 |
85 |
77 |
86 CRequestSessionWatcher::~CRequestSessionWatcher() |
78 CRequestSessionWatcher::~CRequestSessionWatcher() |
87 { |
79 { |
88 __MSFNLOG |
|
89 Cancel(); |
80 Cancel(); |
90 iProperty.Close(); |
81 iProperty.Close(); |
91 iProperty.Delete(KUidUsbManCategory, KUsbRequestSessionProperty); |
82 iProperty.Delete(KUidUsbManCategory, KUsbRequestSessionProperty); |
92 } |
83 } |
93 |
84 |
94 |
85 |
95 void CRequestSessionWatcher::RunL() |
86 void CRequestSessionWatcher::RunL() |
96 { |
87 { |
97 __MSFNLOG |
88 // resubscribe before processing new value to prevent missing updates |
98 // resubscribe before processing new value to prevent missing updates |
89 iProperty.Subscribe(iStatus); |
99 iProperty.Subscribe(iStatus); |
90 SetActive(); |
100 SetActive(); |
|
101 TInt val; |
91 TInt val; |
102 User::LeaveIfError(iProperty.Get(KUidUsbManCategory, KUsbRequestSessionProperty, val)); |
92 User::LeaveIfError(iProperty.Get(KUidUsbManCategory, KUsbRequestSessionProperty, val)); |
103 __USBOTGPRINT1(_L(">> CUsbRequestSessionWatcher[%d]"), val); |
93 __USBOTGPRINT1(_L(">> CUsbRequestSessionWatcher[%d]"), val); |
104 |
94 |
105 switch(val) |
95 switch(val) |
131 |
120 |
132 |
121 |
133 CUsbOtgEventWatcher* CUsbOtgEventWatcher::NewL(RUsbOtgDriver& aLdd, |
122 CUsbOtgEventWatcher* CUsbOtgEventWatcher::NewL(RUsbOtgDriver& aLdd, |
134 CUsbOtg& aUsbOtg) |
123 CUsbOtg& aUsbOtg) |
135 { |
124 { |
136 __MSFNSLOG |
|
137 CUsbOtgEventWatcher* r = new (ELeave) CUsbOtgEventWatcher(aLdd, aUsbOtg); |
125 CUsbOtgEventWatcher* r = new (ELeave) CUsbOtgEventWatcher(aLdd, aUsbOtg); |
138 r->ConstructL(); |
126 r->ConstructL(); |
139 return r; |
127 return r; |
140 } |
128 } |
141 |
129 |
142 CUsbOtgEventWatcher::CUsbOtgEventWatcher(RUsbOtgDriver& aLdd, |
130 CUsbOtgEventWatcher::CUsbOtgEventWatcher(RUsbOtgDriver& aLdd, |
143 CUsbOtg& aUsbOtg) |
131 CUsbOtg& aUsbOtg) |
144 : CUsbOtgBaseWatcher(aLdd), |
132 : CUsbOtgBaseWatcher(aLdd), |
145 iUsbOtg(aUsbOtg) |
133 iUsbOtg(aUsbOtg) |
146 { |
134 { |
147 __MSFNLOG |
|
148 } |
135 } |
149 |
136 |
150 |
137 |
151 void CUsbOtgEventWatcher::ConstructL() |
138 void CUsbOtgEventWatcher::ConstructL() |
152 { |
139 { |
153 __MSFNLOG |
|
154 } |
140 } |
155 |
141 |
156 |
142 |
157 void CUsbOtgEventWatcher::DoCancel() |
143 void CUsbOtgEventWatcher::DoCancel() |
158 { |
144 { |
159 __MSFNLOG |
|
160 iLdd.CancelOtgEventRequest(); |
145 iLdd.CancelOtgEventRequest(); |
161 } |
146 } |
162 |
147 |
163 |
148 |
164 CUsbOtgEventWatcher::~CUsbOtgEventWatcher() |
149 CUsbOtgEventWatcher::~CUsbOtgEventWatcher() |
165 { |
150 { |
166 __MSFNLOG |
|
167 } |
151 } |
168 |
152 |
169 |
153 |
170 void CUsbOtgEventWatcher::Post() |
154 void CUsbOtgEventWatcher::Post() |
171 { |
155 { |
172 __MSFNLOG |
|
173 iLdd.QueueOtgEventRequest(iEvent, iStatus); |
156 iLdd.QueueOtgEventRequest(iEvent, iStatus); |
174 SetActive(); |
157 SetActive(); |
175 } |
158 } |
176 |
159 |
177 void CUsbOtgEventWatcher::RunL() |
160 void CUsbOtgEventWatcher::RunL() |
178 { |
161 { |
179 __MSFNLOG |
|
180 |
|
181 TInt r = iStatus.Int(); |
162 TInt r = iStatus.Int(); |
182 User::LeaveIfError(r); |
163 User::LeaveIfError(r); |
183 |
164 |
184 __USBOTGPRINT1(_L(">> CUsbOtgEventWatcher[%x]"), iEvent); |
165 __USBOTGPRINT1(_L(">> CUsbOtgEventWatcher[%x]"), iEvent); |
185 User::LeaveIfError(r); |
166 User::LeaveIfError(r); |