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