72 CUsbOtgWatcher& aOtgWatcher) : |
73 CUsbOtgWatcher& aOtgWatcher) : |
73 CUsbNotifier(aNotifManager, KUsbUiNotifOtgIndicator, NULL), iOtgWatcher( |
74 CUsbNotifier(aNotifManager, KUsbUiNotifOtgIndicator, NULL), iOtgWatcher( |
74 aOtgWatcher) |
75 aOtgWatcher) |
75 { |
76 { |
76 LOG_FUNC |
77 LOG_FUNC |
77 |
78 |
78 //To be changed to EAknIndicatorStateAnimate and remove iIconBlinkingTimer |
|
79 //when AVKON implements animation form of usb indicator. |
|
80 iIndicatorState = EAknIndicatorStateOn; |
|
81 } |
79 } |
82 |
80 |
83 // --------------------------------------------------------------------------- |
81 // --------------------------------------------------------------------------- |
84 // Second-phase constructor |
82 // Second-phase constructor |
85 // --------------------------------------------------------------------------- |
83 // --------------------------------------------------------------------------- |
86 // |
84 // |
87 void CUsbIndicatorNotifier::ConstructL() |
85 void CUsbIndicatorNotifier::ConstructL() |
88 { |
86 { |
89 LOG_FUNC |
87 LOG_FUNC |
90 |
88 |
|
89 iUsbConnectingIndicator = CHbIndicatorSymbian::NewL(); |
|
90 |
91 // Subscribe for VBus change notifications |
91 // Subscribe for VBus change notifications |
92 iOtgWatcher.VBusObserver()->SubscribeL(*this); |
92 iOtgWatcher.VBusObserver()->SubscribeL(*this); |
93 |
93 |
94 // Subscribe for otg watcher states change notifications |
94 // Subscribe for otg watcher states change notifications |
95 iOtgWatcher.SubscribeL(*this); |
95 iOtgWatcher.SubscribeL(*this); |
96 |
96 |
97 // check here for condition to set usb indicator |
97 // check here for condition to set usb indicator |
98 SetIndicatorL(); |
98 SetIndicator(); |
99 } |
99 } |
100 |
100 |
101 // --------------------------------------------------------------------------- |
101 // --------------------------------------------------------------------------- |
102 // Show/hide static icon of the indicator. |
102 // Show/hide static icon of the indicator. |
103 // 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 |
104 // form of the indicator. |
104 // form of the indicator. |
105 // --------------------------------------------------------------------------- |
105 // --------------------------------------------------------------------------- |
106 // |
106 // |
107 void CUsbIndicatorNotifier::ShowStaticL(TBool aVisible) |
107 void CUsbIndicatorNotifier::ShowStatic(TBool aVisible) |
108 { |
108 { |
109 LOG_FUNC |
109 LOG_FUNC |
110 |
110 |
111 LOG1("aVisible = %d" , aVisible); |
111 LOG1("aVisible = %d" , aVisible); |
112 |
112 |
113 SetIndicatorStateL(aVisible |
113 SetIndicatorState(aVisible |
114 ? EAknIndicatorStateOn |
114 ? EIndicatorStateOn |
115 : EAknIndicatorStateOff); |
115 : EIndicatorStateOff); |
116 } |
116 } |
117 |
117 |
118 // --------------------------------------------------------------------------- |
118 // --------------------------------------------------------------------------- |
119 // |
119 // |
120 // --------------------------------------------------------------------------- |
120 // --------------------------------------------------------------------------- |
121 // |
121 // |
122 void CUsbIndicatorNotifier::BlinkL() |
122 void CUsbIndicatorNotifier::Blink() |
123 { |
123 { |
124 LOG_FUNC |
124 LOG_FUNC |
125 |
125 |
126 SetIndicatorStateL( EAknIndicatorStateAnimate ); |
126 SetIndicatorState( EIndicatorConnecting ); |
127 } |
127 } |
128 |
128 |
129 // --------------------------------------------------------------------------- |
129 // --------------------------------------------------------------------------- |
130 // From base class CUsbNotifier |
130 // From base class CUsbNotifier |
131 // --------------------------------------------------------------------------- |
131 // --------------------------------------------------------------------------- |
132 // |
132 // |
133 void CUsbIndicatorNotifier::ShowL() |
133 void CUsbIndicatorNotifier::ShowL() |
134 { |
134 { |
135 LOG_FUNC |
135 LOG_FUNC |
136 |
136 |
137 ShowStaticL(ETrue); |
137 ShowStatic(ETrue); |
138 } |
138 } |
139 |
139 |
140 // --------------------------------------------------------------------------- |
140 // --------------------------------------------------------------------------- |
141 // From CUsbNotifier |
141 // From CUsbNotifier |
142 // --------------------------------------------------------------------------- |
142 // --------------------------------------------------------------------------- |
143 // |
143 // |
144 void CUsbIndicatorNotifier::Close() |
144 void CUsbIndicatorNotifier::Close() |
145 { |
145 { |
146 LOG_FUNC |
146 LOG_FUNC |
147 |
147 |
148 TRAP_IGNORE( ShowStaticL(EFalse) ); |
148 ShowStatic(EFalse); |
149 } |
149 } |
150 |
150 |
151 // --------------------------------------------------------------------------- |
151 // --------------------------------------------------------------------------- |
152 // Set USB indicator On or Off |
152 // Set USB indicator On or Off |
153 // --------------------------------------------------------------------------- |
153 // --------------------------------------------------------------------------- |
154 // |
154 // |
155 void CUsbIndicatorNotifier::SetIndicatorStateL(const TInt aState) |
155 void CUsbIndicatorNotifier::SetIndicatorState(const TInt aState) |
156 { |
156 { |
157 |
|
158 LOG1( "USB indicator State = %d" , aState); |
157 LOG1( "USB indicator State = %d" , aState); |
159 |
158 |
160 CAknSmallIndicator* indicator = CAknSmallIndicator::NewLC(TUid::Uid( |
159 TBool success = ETrue; |
161 EAknIndicatorUSBConnection)); |
160 |
162 indicator->SetIndicatorStateL(aState); |
161 if ((aState == EIndicatorConnecting) && !iConnectingIndicatorOn) |
163 CleanupStack::PopAndDestroy(indicator); //indicator |
162 { |
164 } |
163 success = iUsbConnectingIndicator->Activate(KUsbConnectingIndicator); |
165 |
164 LOG1( "calling CHbIndicatorSymbian::Activate(), returned %d", success); |
|
165 if (success) |
|
166 { |
|
167 iConnectingIndicatorOn = ETrue; |
|
168 } |
|
169 |
|
170 } |
|
171 |
|
172 if ((aState != EIndicatorConnecting) && iConnectingIndicatorOn) |
|
173 { |
|
174 success = iUsbConnectingIndicator->Deactivate(KUsbConnectingIndicator); |
|
175 if (success) |
|
176 { |
|
177 iConnectingIndicatorOn = EFalse; |
|
178 } |
|
179 LOG1( "calling CHbIndicatorSymbian::Deactivate(), returned %d", success); |
|
180 } |
|
181 |
|
182 // if success became false loading the indicator failed, log the error |
|
183 if (!success) |
|
184 { |
|
185 TInt error = iUsbConnectingIndicator->Error(); |
|
186 LOG1( "indicator error is %d", error); |
|
187 } |
|
188 } |
|
189 |
166 // --------------------------------------------------------------------------- |
190 // --------------------------------------------------------------------------- |
167 // |
191 // |
168 // --------------------------------------------------------------------------- |
192 // --------------------------------------------------------------------------- |
169 // |
193 // |
170 void CUsbIndicatorNotifier::OtgWatcherStateChangedL(TUsbStateIds aState) |
194 void CUsbIndicatorNotifier::OtgWatcherStateChangedL(TUsbStateIds aState) |
171 { |
195 { |
172 SetIndicatorL(); |
196 SetIndicator(); |
173 } |
197 } |
174 |
198 |
175 // --------------------------------------------------------------------------- |
199 // --------------------------------------------------------------------------- |
176 // |
200 // |
177 // --------------------------------------------------------------------------- |
201 // --------------------------------------------------------------------------- |
178 // |
202 // |
179 void CUsbIndicatorNotifier::VBusDownL() |
203 void CUsbIndicatorNotifier::VBusDownL() |
180 { |
204 { |
181 SetIndicatorL(); |
205 SetIndicator(); |
182 } |
206 } |
183 |
207 |
184 // --------------------------------------------------------------------------- |
208 // --------------------------------------------------------------------------- |
185 // |
209 // |
186 // --------------------------------------------------------------------------- |
210 // --------------------------------------------------------------------------- |
187 // |
211 // |
188 void CUsbIndicatorNotifier::VBusUpL() |
212 void CUsbIndicatorNotifier::VBusUpL() |
189 { |
213 { |
190 SetIndicatorL(); |
214 SetIndicator(); |
191 } |
215 } |
192 |
216 |
193 // --------------------------------------------------------------------------- |
217 // --------------------------------------------------------------------------- |
194 // |
218 // |
195 // --------------------------------------------------------------------------- |
219 // --------------------------------------------------------------------------- |