equal
deleted
inserted
replaced
52 CUsbIndicatorNotifier::~CUsbIndicatorNotifier() |
52 CUsbIndicatorNotifier::~CUsbIndicatorNotifier() |
53 { |
53 { |
54 LOG_FUNC |
54 LOG_FUNC |
55 |
55 |
56 Close(); |
56 Close(); |
57 delete iIconBlinkingTimer; |
|
58 |
57 |
59 if (iOtgWatcher.VBusObserver()) |
58 if (iOtgWatcher.VBusObserver()) |
60 { |
59 { |
61 TRAP_IGNORE(iOtgWatcher.VBusObserver()->UnsubscribeL(*this)); |
60 TRAP_IGNORE(iOtgWatcher.VBusObserver()->UnsubscribeL(*this)); |
62 } |
61 } |
93 iOtgWatcher.VBusObserver()->SubscribeL(*this); |
92 iOtgWatcher.VBusObserver()->SubscribeL(*this); |
94 |
93 |
95 // Subscribe for otg watcher states change notifications |
94 // Subscribe for otg watcher states change notifications |
96 iOtgWatcher.SubscribeL(*this); |
95 iOtgWatcher.SubscribeL(*this); |
97 |
96 |
98 iIconBlinkingTimer = CUsbTimer::NewL(*this, EIconBlinkingTimer); |
|
99 |
|
100 // check here for condition to set usb indicator |
97 // check here for condition to set usb indicator |
101 SetIndicatorL(); |
98 SetIndicatorL(); |
102 |
|
103 } |
99 } |
104 |
100 |
105 // --------------------------------------------------------------------------- |
101 // --------------------------------------------------------------------------- |
106 // Show/hide static icon of the indicator. |
102 // Show/hide static icon of the indicator. |
107 // If the indicator is blinking, stop blinking it and show/hide the static |
103 // If the indicator is blinking, stop blinking it and show/hide the static |
112 { |
108 { |
113 LOG_FUNC |
109 LOG_FUNC |
114 |
110 |
115 LOG1("aVisible = %d" , aVisible); |
111 LOG1("aVisible = %d" , aVisible); |
116 |
112 |
117 iIconBlinkingTimer->Cancel(); |
|
118 |
|
119 SetIndicatorStateL(aVisible |
113 SetIndicatorStateL(aVisible |
120 ? EAknIndicatorStateOn |
114 ? EAknIndicatorStateOn |
121 : EAknIndicatorStateOff); |
115 : EAknIndicatorStateOff); |
122 } |
116 } |
123 |
117 |
127 // |
121 // |
128 void CUsbIndicatorNotifier::BlinkL() |
122 void CUsbIndicatorNotifier::BlinkL() |
129 { |
123 { |
130 LOG_FUNC |
124 LOG_FUNC |
131 |
125 |
132 // Will be canceled if active in After() |
126 SetIndicatorStateL( EAknIndicatorStateAnimate ); |
133 iIconBlinkingTimer->After(0); |
|
134 } |
127 } |
135 |
128 |
136 // --------------------------------------------------------------------------- |
129 // --------------------------------------------------------------------------- |
137 // From base class CUsbNotifier |
130 // From base class CUsbNotifier |
138 // --------------------------------------------------------------------------- |
131 // --------------------------------------------------------------------------- |
150 // |
143 // |
151 void CUsbIndicatorNotifier::Close() |
144 void CUsbIndicatorNotifier::Close() |
152 { |
145 { |
153 LOG_FUNC |
146 LOG_FUNC |
154 |
147 |
155 iIconBlinkingTimer->Cancel(); |
|
156 TRAP_IGNORE( ShowStaticL(EFalse) ); |
148 TRAP_IGNORE( ShowStaticL(EFalse) ); |
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // From MUsbTimerObserver |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CUsbIndicatorNotifier::TimerElapsedL(TUsbTimerId aTimerId) |
|
164 { |
|
165 switch (aTimerId) |
|
166 { |
|
167 case EIconBlinkingTimer: |
|
168 { |
|
169 SetIndicatorStateL(iIndicatorState |
|
170 ? EAknIndicatorStateOn |
|
171 : EAknIndicatorStateOff); |
|
172 |
|
173 iIndicatorState |
|
174 = (iIndicatorState == EAknIndicatorStateOn |
|
175 ? EAknIndicatorStateOff |
|
176 : EAknIndicatorStateOn); |
|
177 |
|
178 // Will be canceled if active in After() |
|
179 iIconBlinkingTimer->After(KUsbIndicatorBlinkingInterval); |
|
180 break; |
|
181 } |
|
182 default: |
|
183 { |
|
184 LOG1("Unknown timer id = %d", aTimerId) |
|
185 Panic(EWrongTimerId); |
|
186 } |
|
187 } |
|
188 } |
149 } |
189 |
150 |
190 // --------------------------------------------------------------------------- |
151 // --------------------------------------------------------------------------- |
191 // Set USB indicator On or Off |
152 // Set USB indicator On or Off |
192 // --------------------------------------------------------------------------- |
153 // --------------------------------------------------------------------------- |
242 // |
203 // |
243 // --------------------------------------------------------------------------- |
204 // --------------------------------------------------------------------------- |
244 // |
205 // |
245 void CUsbIndicatorNotifier::SetIndicatorL() |
206 void CUsbIndicatorNotifier::SetIndicatorL() |
246 { |
207 { |
247 if (!(iOtgWatcher.IsDeviceA())) |
208 if (!(iOtgWatcher.IsDeviceA()) || iOtgWatcher.CurrentHostState()->Id() == EUsbStateHostAPeripheral) |
248 { |
209 { |
249 // if B, than other party (usbwatcher) takes care of usb indicator |
210 // if B or peripheral, than other party (usbwatcher) takes care of usb indicator |
250 // in combined usbwatcher (if role swap allowed) one class has to manage usb indicator |
211 // in combined usbwatcher (if role swap allowed) one class has to manage usb indicator |
251 return; |
212 return; |
252 } |
213 } |
253 |
214 |
254 // if VBus Up and we are host -> show indicator |
215 // if VBus Up and we are host -> show indicator |