88 // Destructor |
88 // Destructor |
89 // --------------------------------------------------------------------------- |
89 // --------------------------------------------------------------------------- |
90 // |
90 // |
91 CBTEngSettingsNotify::~CBTEngSettingsNotify() |
91 CBTEngSettingsNotify::~CBTEngSettingsNotify() |
92 { |
92 { |
93 delete iPowerKeyWatcher; |
93 if ( iPowerKeyCenRep ) |
|
94 { |
|
95 iPowerKeyCenRep->NotifyCancel( KBTPowerState ); |
|
96 } |
|
97 delete iPowerKeyWatcher; // Will call Cancel() |
94 delete iPowerKeyCenRep; |
98 delete iPowerKeyCenRep; |
95 delete iVisiKeyWatcher; |
99 if ( iVisiKeyCenRep ) |
|
100 { |
|
101 iVisiKeyCenRep->NotifyCancel( KBTDiscoverable ); |
|
102 } |
|
103 delete iVisiKeyWatcher; // Will call Cancel() |
96 delete iVisiKeyCenRep; |
104 delete iVisiKeyCenRep; |
97 iBTeng.Close(); |
105 if( iBTeng.Handle() ) |
|
106 { |
|
107 iBTeng.Close(); |
|
108 } |
98 } |
109 } |
99 |
110 |
100 |
111 |
101 // --------------------------------------------------------------------------- |
112 // --------------------------------------------------------------------------- |
102 // Toggles Bluetooth power based on the existence of a session. |
113 // Toggles Bluetooth power based on the existence of a session. |
125 // --------------------------------------------------------------------------- |
136 // --------------------------------------------------------------------------- |
126 // From class MBTEngCenRepNotify. |
137 // From class MBTEngCenRepNotify. |
127 // Handles notification of a setting change, and informs our observer. |
138 // Handles notification of a setting change, and informs our observer. |
128 // --------------------------------------------------------------------------- |
139 // --------------------------------------------------------------------------- |
129 // |
140 // |
130 void CBTEngSettingsNotify::RequestCompletedL( CBTEngActive* aActive, |
141 void CBTEngSettingsNotify::RequestCompletedL( CBTEngActive* aActive, TInt aId, |
131 TInt aStatus ) |
142 TInt aStatus ) |
132 { |
143 { |
133 TRACE_FUNC_ARG( ( _L( "Id(%d), status(%d)" ), aActive->RequestId(), aStatus ) ) |
144 TRACE_FUNC_ARG( ( _L( "Id(%d), status(%d)" ), aId, aStatus ) ) |
134 |
145 |
135 if( aActive->RequestId() == KPowerKeyReqId && aStatus == KBTPowerState ) |
146 if( aId == KPowerKeyReqId && aStatus == KBTPowerState ) |
136 { |
147 { |
137 iPowerKeyCenRep->NotifyRequest( KBTPowerState, |
148 iPowerKeyCenRep->NotifyRequest( KBTPowerState, |
138 iPowerKeyWatcher->RequestStatus() ); |
149 iPowerKeyWatcher->RequestStatus() ); |
139 iPowerKeyWatcher->GoActive(); |
150 iPowerKeyWatcher->GoActive(); |
140 TInt value = 0; |
151 TInt value = 0; |
142 if( !err ) |
153 if( !err ) |
143 { |
154 { |
144 iObserver->PowerStateChanged( (TBTPowerStateValue) value ); |
155 iObserver->PowerStateChanged( (TBTPowerStateValue) value ); |
145 } |
156 } |
146 } |
157 } |
147 else if( aActive->RequestId() == KVisibilityKeyReqId && aStatus == KBTDiscoverable ) |
158 else if( aId == KVisibilityKeyReqId && aStatus == KBTDiscoverable ) |
148 { |
159 { |
149 iVisiKeyCenRep->NotifyRequest( KBTDiscoverable, |
160 iVisiKeyCenRep->NotifyRequest( KBTDiscoverable, |
150 iVisiKeyWatcher->RequestStatus() ); |
161 iVisiKeyWatcher->RequestStatus() ); |
151 iVisiKeyWatcher->GoActive(); |
162 iVisiKeyWatcher->GoActive(); |
152 TInt value = 0; |
163 TInt value = 0; |
159 else |
170 else |
160 { |
171 { |
161 // Coudl be a repository-wide reset (KInvalidNotificationId), |
172 // Coudl be a repository-wide reset (KInvalidNotificationId), |
162 // or an invalid key ID. Anyway we know the ID of the active |
173 // or an invalid key ID. Anyway we know the ID of the active |
163 // object, so we can just reset the watcher. |
174 // object, so we can just reset the watcher. |
164 HandleError( aActive, aStatus ); |
175 HandleError( aActive, aId, aStatus ); |
165 } |
176 } |
166 TRACE_FUNC_EXIT |
177 TRACE_FUNC_EXIT |
167 } |
178 } |
168 |
179 |
169 // --------------------------------------------------------------------------- |
|
170 // From class MBTEngActiveObserver. |
|
171 // Handles cancelation of an outstanding request |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CBTEngSettingsNotify::CancelRequest( TInt aRequestId ) |
|
175 { |
|
176 TRACE_FUNC_ARG( ( _L( "reqID %d" ), aRequestId ) ) |
|
177 |
|
178 if( aRequestId == KPowerKeyReqId ) |
|
179 { |
|
180 iPowerKeyCenRep->NotifyCancel( KBTPowerState ); |
|
181 } |
|
182 else if( aRequestId == KVisibilityKeyReqId ) |
|
183 { |
|
184 iVisiKeyCenRep->NotifyCancel( KBTDiscoverable ); |
|
185 } |
|
186 TRACE_FUNC_EXIT |
|
187 } |
|
188 |
180 |
189 // --------------------------------------------------------------------------- |
181 // --------------------------------------------------------------------------- |
190 // From class MBTEngCenRepNotify. |
182 // From class MBTEngCenRepNotify. |
191 // Handles error situation by just re-ordering notification from CenRep. |
183 // Handles error situation by just re-ordering notification from CenRep. |
192 // --------------------------------------------------------------------------- |
184 // --------------------------------------------------------------------------- |
193 // |
185 // |
194 void CBTEngSettingsNotify::HandleError( CBTEngActive* aActive, |
186 void CBTEngSettingsNotify::HandleError( CBTEngActive* aActive, TInt aId, |
195 TInt aError ) |
187 TInt aError ) |
196 { |
188 { |
197 TRACE_FUNC_ARG( ( _L( "Id(%d), status(%d)" ), aActive->RequestId(), aError ) ) |
189 TRACE_FUNC_ARG( ( _L( "Id(%d), status(%d)" ), aId, aError ) ) |
198 (void) aError; |
190 (void) aError; |
199 if( aActive->RequestId() == KPowerKeyReqId ) |
191 if( aId == KPowerKeyReqId ) |
200 { |
192 { |
201 delete iPowerKeyCenRep; |
193 delete iPowerKeyCenRep; |
202 iPowerKeyCenRep = NULL; |
194 iPowerKeyCenRep = NULL; |
203 TRAPD( err, iPowerKeyCenRep = |
195 TRAPD( err, iPowerKeyCenRep = |
204 CRepository::NewL( KCRUidBluetoothPowerState ) ); |
196 CRepository::NewL( KCRUidBluetoothPowerState ) ); |
207 iPowerKeyCenRep->NotifyRequest( KBTPowerState, |
199 iPowerKeyCenRep->NotifyRequest( KBTPowerState, |
208 aActive->RequestStatus() ); |
200 aActive->RequestStatus() ); |
209 aActive->GoActive(); |
201 aActive->GoActive(); |
210 } |
202 } |
211 } |
203 } |
212 else if( aActive->RequestId() == KVisibilityKeyReqId ) |
204 else if( aId == KVisibilityKeyReqId ) |
213 { |
205 { |
214 delete iVisiKeyCenRep; |
206 delete iVisiKeyCenRep; |
215 iVisiKeyCenRep = NULL; |
207 iVisiKeyCenRep = NULL; |
216 TRAPD( err, iVisiKeyCenRep = |
208 TRAPD( err, iVisiKeyCenRep = |
217 CRepository::NewL( KCRUidBTEngPrivateSettings ) ); |
209 CRepository::NewL( KCRUidBTEngPrivateSettings ) ); |