92 iOtgWatcher.VBusObserver()->SubscribeL(*this); |
91 iOtgWatcher.VBusObserver()->SubscribeL(*this); |
93 |
92 |
94 // Subscribe for otg watcher states change notifications |
93 // Subscribe for otg watcher states change notifications |
95 iOtgWatcher.SubscribeL(*this); |
94 iOtgWatcher.SubscribeL(*this); |
96 |
95 |
|
96 iConnectingIndicatorOn = EFalse; |
|
97 |
97 // check here for condition to set usb indicator |
98 // check here for condition to set usb indicator |
98 SetIndicator(); |
99 SetIndicator(); |
99 } |
100 |
100 |
101 } |
101 // --------------------------------------------------------------------------- |
102 |
102 // Show/hide static icon of the indicator. |
|
103 // If the indicator is blinking, stop blinking it and show/hide the static |
|
104 // form of the indicator. |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void CUsbIndicatorNotifier::ShowStatic(TBool aVisible) |
|
108 { |
|
109 LOG_FUNC |
|
110 |
|
111 LOG1("aVisible = %d" , aVisible); |
|
112 |
|
113 SetIndicatorState(aVisible |
|
114 ? EIndicatorStateOn |
|
115 : EIndicatorStateOff); |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void CUsbIndicatorNotifier::Blink() |
|
123 { |
|
124 LOG_FUNC |
|
125 |
|
126 SetIndicatorState( EIndicatorConnecting ); |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // From base class CUsbNotifier |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void CUsbIndicatorNotifier::ShowL() |
|
134 { |
|
135 LOG_FUNC |
|
136 |
|
137 ShowStatic(ETrue); |
|
138 } |
|
139 |
103 |
140 // --------------------------------------------------------------------------- |
104 // --------------------------------------------------------------------------- |
141 // From CUsbNotifier |
105 // From CUsbNotifier |
142 // --------------------------------------------------------------------------- |
106 // --------------------------------------------------------------------------- |
143 // |
107 // |
144 void CUsbIndicatorNotifier::Close() |
108 void CUsbIndicatorNotifier::Close() |
145 { |
109 { |
146 LOG_FUNC |
110 LOG_FUNC |
147 |
111 |
148 ShowStatic(EFalse); |
112 ToggleConnectingIndicator( EFalse ); |
149 } |
113 } |
150 |
114 |
151 // --------------------------------------------------------------------------- |
115 // --------------------------------------------------------------------------- |
152 // Set USB indicator On or Off |
116 // Set USB indicator On or Off |
153 // --------------------------------------------------------------------------- |
117 // --------------------------------------------------------------------------- |
154 // |
118 // |
155 void CUsbIndicatorNotifier::SetIndicatorState(const TInt aState) |
119 void CUsbIndicatorNotifier::ToggleConnectingIndicator(TBool aEnable) |
156 { |
120 { |
157 LOG1( "USB indicator State = %d" , aState); |
121 LOG1( "toggle connecting indicator = %d" , aEnable); |
158 |
122 |
159 TBool success = ETrue; |
123 TBool success = ETrue; |
160 |
124 |
161 if ((aState == EIndicatorConnecting) && !iConnectingIndicatorOn) |
125 if (aEnable && !iConnectingIndicatorOn) |
162 { |
126 { |
163 success = iUsbConnectingIndicator->Activate(KUsbConnectingIndicator); |
127 success = iUsbConnectingIndicator->Activate(KUsbConnectingIndicator); |
164 LOG1( "calling CHbIndicatorSymbian::Activate(), returned %d", success); |
128 LOG1( "calling CHbIndicatorSymbian::Activate(), returned %d", success); |
165 if (success) |
129 if (success) |
166 { |
130 { |
167 iConnectingIndicatorOn = ETrue; |
131 iConnectingIndicatorOn = ETrue; |
168 } |
132 } |
169 |
133 |
170 } |
134 } |
171 |
135 |
172 if ((aState != EIndicatorConnecting) && iConnectingIndicatorOn) |
136 if (!aEnable && iConnectingIndicatorOn) |
173 { |
137 { |
174 success = iUsbConnectingIndicator->Deactivate(KUsbConnectingIndicator); |
138 success = iUsbConnectingIndicator->Deactivate(KUsbConnectingIndicator); |
175 if (success) |
139 if (success) |
176 { |
140 { |
177 iConnectingIndicatorOn = EFalse; |
141 iConnectingIndicatorOn = EFalse; |
191 // |
155 // |
192 // --------------------------------------------------------------------------- |
156 // --------------------------------------------------------------------------- |
193 // |
157 // |
194 void CUsbIndicatorNotifier::OtgWatcherStateChangedL(TUsbStateIds aState) |
158 void CUsbIndicatorNotifier::OtgWatcherStateChangedL(TUsbStateIds aState) |
195 { |
159 { |
|
160 LOG_FUNC |
196 SetIndicator(); |
161 SetIndicator(); |
197 } |
162 } |
198 |
163 |
199 // --------------------------------------------------------------------------- |
164 // --------------------------------------------------------------------------- |
200 // |
165 // |
201 // --------------------------------------------------------------------------- |
166 // --------------------------------------------------------------------------- |
202 // |
167 // |
203 void CUsbIndicatorNotifier::VBusDownL() |
168 void CUsbIndicatorNotifier::VBusDownL() |
204 { |
169 { |
|
170 LOG_FUNC |
205 SetIndicator(); |
171 SetIndicator(); |
206 } |
172 } |
207 |
173 |
208 // --------------------------------------------------------------------------- |
174 // --------------------------------------------------------------------------- |
209 // |
175 // |
210 // --------------------------------------------------------------------------- |
176 // --------------------------------------------------------------------------- |
211 // |
177 // |
212 void CUsbIndicatorNotifier::VBusUpL() |
178 void CUsbIndicatorNotifier::VBusUpL() |
213 { |
179 { |
|
180 LOG_FUNC |
214 SetIndicator(); |
181 SetIndicator(); |
215 } |
182 } |
216 |
183 |
217 // --------------------------------------------------------------------------- |
184 // --------------------------------------------------------------------------- |
218 // |
185 // |
219 // --------------------------------------------------------------------------- |
186 // --------------------------------------------------------------------------- |
220 // |
187 // |
221 void CUsbIndicatorNotifier::VBusObserverErrorL(TInt aError) |
188 void CUsbIndicatorNotifier::VBusObserverErrorL(TInt aError) |
222 { |
189 { |
|
190 LOG_FUNC |
223 // do nothing |
191 // do nothing |
224 } |
192 } |
225 |
193 |
226 // --------------------------------------------------------------------------- |
194 // --------------------------------------------------------------------------- |
227 // |
195 // |
228 // --------------------------------------------------------------------------- |
196 // --------------------------------------------------------------------------- |
229 // |
197 // |
230 void CUsbIndicatorNotifier::SetIndicator() |
198 void CUsbIndicatorNotifier::SetIndicator() |
231 { |
199 { |
|
200 LOG_FUNC |
232 if (!(iOtgWatcher.IsDeviceA()) || iOtgWatcher.CurrentHostState()->Id() == EUsbStateHostAPeripheral) |
201 if (!(iOtgWatcher.IsDeviceA()) || iOtgWatcher.CurrentHostState()->Id() == EUsbStateHostAPeripheral) |
233 { |
202 { |
234 // if B or peripheral, than other party (usbwatcher) takes care of usb indicator |
203 // if B or peripheral, than other party (usbwatcher) takes care of usb indicator |
235 // in combined usbwatcher (if role swap allowed) one class has to manage usb indicator |
204 // in combined usbwatcher (if role swap allowed) one class has to manage usb indicator |
236 return; |
205 return; |
237 } |
206 } |
238 |
207 |
239 // if VBus Up and we are host -> show indicator |
208 // if VBus up and we are not host -> show connecting indicator |
240 if ((iOtgWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp) |
209 if ((iOtgWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp) |
241 && (iOtgWatcher.CurrentHostState()->Id() == EUsbStateHostAHost)) |
|
242 { |
|
243 ShowStatic(ETrue); |
|
244 } |
|
245 // if VBus up and we are not host -> Blink indicator |
|
246 else if ((iOtgWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp) |
|
247 && (iOtgWatcher.CurrentHostState()->Id() != EUsbStateHostAHost)) |
210 && (iOtgWatcher.CurrentHostState()->Id() != EUsbStateHostAHost)) |
248 { |
211 { |
249 Blink(); |
212 ToggleConnectingIndicator( ETrue ); |
250 } |
213 } |
251 else |
214 else |
252 // Otherwise do not show indicator |
215 // Otherwise do not show indicator |
253 { |
216 { |
254 ShowStatic(EFalse); |
217 ToggleConnectingIndicator( EFalse ); |
255 } |
218 } |
256 } |
219 } |
257 |
220 |
258 // End of file |
221 // End of file |