author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:37:10 +0300 | |
branch | RCL_3 |
changeset 61 | 269724087bed |
parent 56 | 9386f31cc85b |
child 72 | 4b59561a31c0 |
permissions | -rw-r--r-- |
56 | 1 |
/* |
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: Implements authorisation notifier class. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include <BTNotif.rsg> // Own resources |
|
21 |
#include "btnauthnotifier.h" // Own class definition |
|
22 |
#include "btNotifDebug.h" // Debugging macros |
|
23 |
#include <btextnotifiers.h> |
|
24 |
#include <AknMediatorFacade.h> // Cover UI |
|
25 |
#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h> |
|
26 |
#include <btengconstants.h> |
|
27 |
#include <btengsettings.h> |
|
28 |
#include <e32cmn.h> |
|
29 |
#include <btotgpairpub.inl> |
|
30 |
#include <btengprivatecrkeys.h> |
|
31 |
#include <e32property.h> |
|
32 |
#include <e32const.h> |
|
33 |
#include <e32des8.h> |
|
34 |
#include <e32cmn.h> |
|
35 |
#include <utf.h> // Unicode character conversion utilities |
|
36 |
#include <btengutil.h> |
|
37 |
#ifdef __SERIES60_HELP |
|
38 |
#include <hlplch.h> |
|
39 |
#include <csxhelp/bt.hlp.hrh> // The bt hrh info is needed, for help launching |
|
40 |
#endif |
|
41 |
#include <bluetoothuiutil.h> |
|
42 |
#include "btnotifnameutils.h" |
|
43 |
||
44 |
||
45 |
// |
|
46 |
// SDP UUID Constants - Short form |
|
47 |
// Taken from Bluetooth Profile specification v1.1 |
|
48 |
// These are used when registering the service to |
|
49 |
// local SDP database and when searching the service |
|
50 |
// information from remote device. |
|
51 |
const TUint KBTSdpDun = 0x1103; |
|
52 |
const TUint KBTSdpGenericTelephony = 0x1204; |
|
53 |
const TUint KBTSdpFax = 0x1111; |
|
54 |
const TUint KBTSdpObjectPush = 0x1105; |
|
55 |
const TUint KBTSdpFileTransfer = 0x1106; |
|
56 |
const TUint KBTSdpHeadSet = 0x1108; |
|
57 |
const TUint KBTSdpGenericNetworking = 0x1201; |
|
58 |
const TUint KBTSdpBasicImaging = 0x111b; |
|
59 |
||
60 |
/** Identification for active object */ |
|
61 |
const TInt KBTNotifAuthNotifierLockReq = 10; |
|
62 |
||
63 |
// ================= MEMBER FUNCTIONS ======================= |
|
64 |
||
65 |
// ---------------------------------------------------------- |
|
66 |
// CBTAuthNotifier::NewL |
|
67 |
// Two-phased constructor. |
|
68 |
// ---------------------------------------------------------- |
|
69 |
// |
|
70 |
CBTAuthNotifier* CBTAuthNotifier::NewL() |
|
71 |
{ |
|
72 |
CBTAuthNotifier* self = new (ELeave) CBTAuthNotifier(); |
|
73 |
CleanupStack::PushL(self); |
|
74 |
self->ConstructL(); |
|
75 |
CleanupStack::Pop(); |
|
76 |
return self; |
|
77 |
} |
|
78 |
||
79 |
// ---------------------------------------------------------- |
|
80 |
// CBTAuthNotifier::CBTAuthNotifier |
|
81 |
// C++ default constructor can NOT contain any code, that |
|
82 |
// might leave. |
|
83 |
// ---------------------------------------------------------- |
|
84 |
// |
|
85 |
CBTAuthNotifier::CBTAuthNotifier() |
|
86 |
{ |
|
87 |
} |
|
88 |
||
89 |
// ---------------------------------------------------------- |
|
90 |
// Destructor |
|
91 |
// ---------------------------------------------------------- |
|
92 |
// |
|
93 |
CBTAuthNotifier::~CBTAuthNotifier() |
|
94 |
{ |
|
95 |
} |
|
96 |
||
97 |
// ---------------------------------------------------------- |
|
98 |
// CBTAuthNotifier::RegisterL |
|
99 |
// ---------------------------------------------------------- |
|
100 |
// |
|
101 |
CBTAuthNotifier::TNotifierInfo CBTAuthNotifier::RegisterL() |
|
102 |
{ |
|
103 |
iInfo.iUid=KBTManAuthNotifierUid; |
|
104 |
iInfo.iChannel=KBTAuthorisationChannel; |
|
105 |
iInfo.iPriority=ENotifierPriorityVHigh; |
|
106 |
return iInfo; |
|
107 |
} |
|
108 |
||
109 |
// ---------------------------------------------------------- |
|
61
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
110 |
// CBTAuthNotifier::ProcessStartParamsL |
56 | 111 |
// Initialize parameters and check if device is already |
112 |
// in registry. Jump to RunL as soon as possible. |
|
113 |
// ---------------------------------------------------------- |
|
114 |
// |
|
61
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
115 |
void CBTAuthNotifier::ProcessStartParamsL() |
56 | 116 |
{ |
61
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
117 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::ProcessStartParamsL()")); |
56 | 118 |
|
119 |
if ( AutoLockOnL() ) |
|
120 |
{ |
|
121 |
// The phone is locked, access denied. |
|
122 |
// Write results back to caller and complete message. |
|
123 |
CompleteMessage(EFalse, KErrNone); |
|
124 |
return; |
|
125 |
} |
|
126 |
||
127 |
TBTAuthorisationParams param; |
|
128 |
TPckgC<TBTAuthorisationParams> pckg(param); |
|
61
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
129 |
pckg.Set(*iParamBuffer); |
56 | 130 |
|
131 |
iServiceUid = pckg().iUid.iUid; // Pick up service uid from message |
|
132 |
iBTAddr = pckg().iBDAddr; |
|
133 |
if ( OtherOutgoPairing( iBTAddr ) ) |
|
134 |
{ |
|
135 |
// We won't allow connection request from another device during outgoing pairing: |
|
136 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier: outgoing pair in progress, reject request from other device")); |
|
137 |
CompleteMessage(KErrCancel); |
|
138 |
return; |
|
139 |
} |
|
140 |
||
141 |
// create iDevice so that the name won't be lost if the device does |
|
142 |
// not exist in registry. |
|
143 |
iDevice = CBTDevice::NewL( iBTAddr ); |
|
144 |
BtNotifNameUtils::SetDeviceNameL(pckg().iName, *iDevice); |
|
145 |
||
146 |
if ( !iNotifLockProp.Handle() ) |
|
147 |
{ |
|
148 |
User::LeaveIfError( iNotifLockProp.Attach( |
|
149 |
KPSUidBluetoothEnginePrivateCategory, KBTNotifierLocks ) ); |
|
150 |
} |
|
151 |
||
152 |
if(!iLockActive) |
|
153 |
{ |
|
154 |
iLockActive = CBTNotifActive::NewL( this, KBTNotifAuthNotifierLockReq, CActive::EPriorityStandard ); |
|
155 |
} |
|
156 |
||
157 |
CheckAndSubscribeNotifLocks(); |
|
158 |
||
159 |
if ( !iSuspended ) |
|
160 |
{ |
|
161 |
// Check if device is in the registry, function of notifier base |
|
162 |
GetDeviceFromRegL( iBTAddr ); |
|
163 |
} |
|
164 |
||
165 |
#ifdef _DEBUG |
|
61
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
166 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::ProcessStartParamsL() Executing authorisation...")); |
56 | 167 |
TBuf<12> deviceAddressString; |
168 |
pckg().iBDAddr.GetReadable(deviceAddressString); |
|
169 |
FTRACE(FPrint(_L("[BTNOTIF]\t BT Address: %S"), &deviceAddressString)); |
|
61
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
170 |
FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::ProcessStartParamsL Service Uid: %d = 0x%X"), iServiceUid, iServiceUid )); |
56 | 171 |
#endif |
61
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
172 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::ProcessStartParamsL() completed")); |
56 | 173 |
} |
174 |
||
175 |
// ---------------------------------------------------------- |
|
176 |
// CBTAuthNotifier::UpdateL |
|
177 |
// Notifier update. Stores the received bluetooth |
|
178 |
// device name into registry and show it on screen. |
|
179 |
// ---------------------------------------------------------- |
|
180 |
// |
|
181 |
TPtrC8 CBTAuthNotifier::UpdateL(const TDesC8& aBuffer) |
|
182 |
{ |
|
183 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::UpdateL()")); |
|
184 |
||
185 |
TBTNotifierUpdateParams params; // Contains iName and iResult (name request) |
|
186 |
TPckgC<TBTNotifierUpdateParams> pckg(params); |
|
187 |
pckg.Set(aBuffer); |
|
188 |
||
189 |
FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::UpdateL - Name: '%S' length: %d"), &pckg().iName, pckg().iName.Length() )); |
|
190 |
||
191 |
||
192 |
// If the device name request was successful and if new name is valid, show the new name. |
|
193 |
if (pckg().iResult == KErrNone) |
|
194 |
{ |
|
195 |
BtNotifNameUtils::SetDeviceNameL(pckg().iName, *iDevice); // Override possible previous device name |
|
196 |
||
197 |
// Show new prompt for dialog if it is still on the screen |
|
198 |
if ( !iDevice->IsValidFriendlyName() && iDevice->IsValidDeviceName()) |
|
199 |
{ |
|
200 |
// Create new prompt string with new device name |
|
201 |
RBuf stringholder; |
|
202 |
CleanupClosePushL( stringholder ); |
|
203 |
BluetoothUiUtil::LoadResourceAndSubstringL( |
|
204 |
stringholder, iStrResourceId, |
|
205 |
BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()), 0 ); |
|
206 |
iNotifUiUtil->UpdateQueryDlgL( stringholder ); |
|
207 |
iNotifUiUtil->UpdateCoverUiL( iDevice->DeviceName() ); |
|
208 |
CleanupStack::PopAndDestroy(); // stringholder |
|
209 |
} |
|
210 |
} |
|
211 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::UpdateL() completed")); |
|
212 |
TPtrC8 ret(KNullDesC8); |
|
213 |
return (ret); |
|
214 |
} |
|
215 |
||
216 |
// ---------------------------------------------------------- |
|
217 |
// CBTAuthNotifier::RequestCompletedL |
|
218 |
// Gets called when P&S key notifies change |
|
219 |
// ---------------------------------------------------------- |
|
220 |
void CBTAuthNotifier::RequestCompletedL( CBTNotifActive* aActive, TInt aId, TInt aStatus ) |
|
221 |
{ |
|
222 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::RequestCompletedL()")); |
|
223 |
ASSERT( aId == KBTNotifAuthNotifierLockReq ); |
|
224 |
(void) aActive; |
|
225 |
(void) aId; |
|
226 |
||
227 |
if ( aStatus == KErrNone ) |
|
228 |
{ |
|
229 |
TBool prevSuspend = iSuspended; |
|
230 |
// check the latest lock status and subscribe to further lock event: |
|
231 |
CheckAndSubscribeNotifLocks(); |
|
232 |
if ( prevSuspend && !iSuspended ) |
|
233 |
{ |
|
234 |
// Check if device is in the registry, function of notifier base |
|
235 |
GetDeviceFromRegL( iBTAddr ); |
|
236 |
} |
|
237 |
else if ( iSuspended && !(iNotifUiUtil->IsQueryReleased()) ) |
|
238 |
{ |
|
239 |
iNotifUiUtil->DismissDialog(); |
|
240 |
} |
|
241 |
} |
|
242 |
else |
|
243 |
{ |
|
244 |
HandleError( aActive, KBTNotifAuthNotifierLockReq, iLockActive->RequestStatus().Int() ); |
|
245 |
} |
|
246 |
||
247 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::RequestCompletedL() completed")); |
|
248 |
||
249 |
} |
|
250 |
||
251 |
// ---------------------------------------------------------- |
|
252 |
// CBTAuthNotifier::HandleError |
|
253 |
// ---------------------------------------------------------- |
|
254 |
void CBTAuthNotifier::HandleError( CBTNotifActive* aActive, TInt aId, TInt aError ) |
|
255 |
{ |
|
256 |
FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::HandleError() error = %d"), aError )); |
|
257 |
(void) aActive; |
|
258 |
(void) aId; |
|
259 |
(void) aError; |
|
260 |
} |
|
261 |
||
262 |
// ---------------------------------------------------------- |
|
263 |
// CBTAuthNotifier::DoCancelRequest |
|
264 |
// Root caller is CBTNotifActive::CancelRequest(), which calls |
|
265 |
// CActive::Cancel that calls DoCancel() if request is active. |
|
266 |
// ---------------------------------------------------------- |
|
267 |
void CBTAuthNotifier::DoCancelRequest( CBTNotifActive* aActive, TInt aId ) |
|
268 |
{ |
|
269 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoCancel() >>")); |
|
270 |
ASSERT( aId == KBTNotifAuthNotifierLockReq ); |
|
271 |
(void) aActive; |
|
272 |
(void) aId; |
|
273 |
||
274 |
iNotifLockProp.Cancel(); |
|
275 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoCancel() <<")); |
|
276 |
} |
|
277 |
||
278 |
// ---------------------------------------------------------- |
|
279 |
// CBTAuthNotifier::Cancel |
|
280 |
// Not Active Object's cancel, but notifier deactivation |
|
281 |
// Release all own resources (member variables) |
|
282 |
// ---------------------------------------------------------- |
|
283 |
// |
|
284 |
void CBTAuthNotifier::Cancel() |
|
285 |
{ |
|
286 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::Cancel()")); |
|
287 |
||
288 |
if (iLockActive) |
|
289 |
{ |
|
290 |
iLockActive->CancelRequest(); |
|
291 |
delete iLockActive; |
|
292 |
iLockActive = NULL; |
|
293 |
} |
|
294 |
||
295 |
iNotifLockProp.Close(); |
|
296 |
||
297 |
CBTNotifierBase::Cancel(); |
|
298 |
||
299 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::Cancel() completed")); |
|
300 |
} |
|
301 |
||
302 |
void CBTAuthNotifier::HandleGetDeviceCompletedL(const CBTDevice* aDev) |
|
303 |
{ |
|
304 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::HandleGetDeviceCompleted()")); |
|
305 |
(void) aDev; |
|
306 |
if ( iSuspended) |
|
307 |
{ |
|
308 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::HandleGetDeviceCompleted, still suspended, wait")); |
|
309 |
return; |
|
310 |
} |
|
311 |
||
312 |
TBool reqAllowed = IsJustWorksPaired( iDevice->AsNamelessDevice() ) ? |
|
313 |
IsUserAwarePaired( iDevice->AsNamelessDevice() ) : ETrue ; |
|
314 |
FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier, reqAllowed %d" ), reqAllowed ) ); |
|
315 |
if ( !reqAllowed ) |
|
316 |
{ |
|
317 |
// Do not grant access to device that is not paired in Just Works mode without |
|
318 |
// user awareness, e.g. pairing due to an incoming connection request from a |
|
319 |
// headset. |
|
320 |
CompleteMessage(KErrAccessDenied); |
|
321 |
return; |
|
322 |
} |
|
323 |
||
324 |
iStrResourceId = R_BT_AUTHORISATION_NAME; |
|
325 |
||
326 |
// Select authorisation state for further use (dialogue selection) |
|
327 |
switch( iServiceUid ) |
|
328 |
{ |
|
329 |
case KBTSdpObjectPush: |
|
330 |
case KBTSdpBasicImaging: |
|
331 |
iAuthState = EBTObexAuthorisation; |
|
332 |
iStrResourceId = R_BT_RECEIVE_MESSAGE; |
|
333 |
iCoverUiDlgId = ECmdShowReceiveMessageFromDeviceDlg; |
|
334 |
||
335 |
if( IsUserAwarePaired( iDevice->AsNamelessDevice() ) ) |
|
336 |
{ |
|
337 |
iAuthState = EBTObexAuthForPairedDevice; |
|
338 |
iStrResourceId = R_BT_RECEIVE_MESSAGE_PAIRED; |
|
339 |
iCoverUiDlgId = ECmdShowReceiveMessageFromPairedDeviceDlg; |
|
340 |
} |
|
341 |
break; |
|
342 |
case KBTSdpFax: |
|
343 |
case KBTSdpDun: |
|
344 |
case KBTSdpFileTransfer: |
|
345 |
case KBTSdpHeadSet: |
|
346 |
case KBTSdpGenericTelephony: |
|
347 |
case KBTSdpGenericNetworking: |
|
348 |
if ( iDevice->GlobalSecurity().NoAuthorise() ) |
|
349 |
{ |
|
350 |
iAuthState = EBTAutoAuthorisation; |
|
351 |
} |
|
352 |
else |
|
353 |
{ |
|
354 |
iAuthState = EBTNormalAuthorisation; |
|
355 |
} |
|
356 |
iCoverUiDlgId = ECmdShowAcceptConnRequestDlg; |
|
357 |
break; |
|
358 |
default: |
|
359 |
{ // check if device is authorized |
|
360 |
if ( iDevice->GlobalSecurity().NoAuthorise() ) |
|
361 |
{ |
|
362 |
iAuthState = EBTAutoAuthorisation; |
|
363 |
} |
|
364 |
else |
|
365 |
{ |
|
366 |
iAuthState = EBTAutoAuthorisationNotAuthorisedOnPhone; |
|
367 |
} |
|
368 |
break; |
|
369 |
} |
|
370 |
} |
|
371 |
FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::HandleGetDeviceComplete() Complete. iAuthState = %d"), iAuthState )); |
|
372 |
ShowAuthoQueryL(); |
|
373 |
} |
|
374 |
||
375 |
// ---------------------------------------------------------- |
|
376 |
// CBTAuthNotifier::GetByPassAudioNotifier |
|
377 |
// is bypassing this audio connection query needed and if it is, will the |
|
378 |
// query be automatically accepted or rejected. |
|
379 |
// |
|
380 |
// This is used for bypassing the notifiers of the 2nd audio connection, so |
|
381 |
// the the user needs to reply to the incoming audio link only once. |
|
382 |
// ---------------------------------------------------------- |
|
383 |
// |
|
384 |
TBool CBTAuthNotifier::GetByPassAudioNotifier(const TBTDevAddr& aDeviceAddress,TBool& aAccept) |
|
385 |
{ |
|
386 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::GetByPassAudioNotifier()")); |
|
387 |
TBuf8<48> buf; |
|
388 |
||
389 |
RProperty::Define(KPSUidBluetoothEnginePrivateCategory,KBTAuthorInfoPerDevice, RProperty::EByteArray ); |
|
390 |
RProperty::Get(KPSUidBluetoothEnginePrivateCategory,KBTAuthorInfoPerDevice,buf); |
|
391 |
||
392 |
if(buf.Length()>2) |
|
393 |
{ |
|
394 |
// accept status of last attempt |
|
395 |
aAccept= (buf[0]=='1'); |
|
396 |
||
397 |
// last address |
|
398 |
TBuf<12> oldAddrString; |
|
399 |
oldAddrString.Copy(buf.Mid(2,12)); |
|
400 |
TBTDevAddr lastAddress; |
|
401 |
lastAddress.SetReadable(oldAddrString); |
|
402 |
||
403 |
// last time |
|
404 |
TInt64 num(0); |
|
405 |
TLex8 lex; |
|
406 |
lex=buf.Mid(15); |
|
407 |
TBuf<32> tmp_debug; |
|
408 |
tmp_debug.Copy(buf.Mid(15)); |
|
409 |
||
410 |
lex.Val( num ); |
|
411 |
TTime lastConnectionTime( num ); |
|
412 |
TTime now; |
|
413 |
now.UniversalTime(); |
|
414 |
||
415 |
TBuf16<48> buf2; |
|
416 |
buf2.Copy(buf); |
|
417 |
||
418 |
FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::GetByPassAudioNotifier() Complete same_address=%d Time_ok=%d last_reply=%d"),lastAddress==aDeviceAddress,now>=lastConnectionTime && now <lastConnectionTime+ TTimeIntervalSeconds(5),aAccept)); |
|
419 |
return lastAddress==aDeviceAddress && (now>=lastConnectionTime && now <lastConnectionTime+ TTimeIntervalSeconds(5) ); |
|
420 |
} |
|
421 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::GetByPassAudioNotifier() Complete - empty key")); |
|
422 |
return EFalse; |
|
423 |
} |
|
424 |
// ---------------------------------------------------------- |
|
425 |
// CBTAuthNotifier::MemorizeCurrentAudioAttempt |
|
426 |
// Store the information about this audio connection attempt |
|
427 |
// and what user replied to that. This is used by |
|
428 |
// GetBypassAudio Notifier. |
|
429 |
// ---------------------------------------------------------- |
|
430 |
// |
|
431 |
||
432 |
void CBTAuthNotifier::MemorizeCurrentAudioAttempt(const TBool aAccept,const TBTDevAddr& aDeviceAddress) |
|
433 |
{ |
|
434 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::MemorizeCurrentAudioAttempt()")); |
|
435 |
TBuf8<48> buf; |
|
436 |
buf.Zero(); |
|
437 |
buf.AppendNum(aAccept!=EFalse);//now 0/1 only. |
|
438 |
buf.Append(';'); |
|
439 |
||
440 |
TBuf<12> a; |
|
441 |
aDeviceAddress.GetReadable(a); |
|
442 |
for(TInt t=0;t<12;t++) |
|
443 |
buf.Append(a[t]); |
|
444 |
buf.Append(';'); |
|
445 |
||
446 |
TTime writeTime; |
|
447 |
writeTime.UniversalTime(); |
|
448 |
buf.AppendNum( writeTime.Int64() ); |
|
449 |
||
450 |
RProperty::Set(KPSUidBluetoothEnginePrivateCategory,KBTAuthorInfoPerDevice,buf); |
|
451 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::MemorizeCurrentAudioAttempt() complete")); |
|
452 |
} |
|
453 |
||
454 |
||
455 |
// ---------------------------------------------------------- |
|
456 |
// CBTAuthNotifier::ShowAuthoQueryL |
|
457 |
// Ask user's response on authorization query |
|
458 |
// ---------------------------------------------------------- |
|
459 |
// |
|
460 |
void CBTAuthNotifier::ShowAuthoQueryL() |
|
461 |
{ |
|
462 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::ShowAuthoQueryL")); |
|
463 |
||
464 |
if ( iAuthState == EBTAutoAuthorisation ) |
|
465 |
{ |
|
466 |
// device alreay set trusted now. allow connection automatically |
|
467 |
CompleteMessage(ETrue, KErrNone); |
|
468 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier, device authorized already, allow connection automatically" )); |
|
469 |
return; |
|
470 |
} |
|
471 |
||
472 |
TBool reply; |
|
473 |
if ( GetByPassAudioNotifier(iDevice->BDAddr(),reply) ) |
|
474 |
{ |
|
475 |
FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::ShowAuthoQueryL bypassing notifier with reply: %d"),reply)); |
|
476 |
CompleteMessage(reply, KErrNone); |
|
477 |
return; |
|
478 |
} |
|
479 |
||
480 |
// Not asking user's response if auth request is for: profile HFP/HSP/A2DP/AVRCP, and |
|
481 |
// there is already existing connection to one of those profiles from the same device. |
|
482 |
// |
|
483 |
TBool connectStatus = IsExistingConnectionToAudioL( iDevice->BDAddr() ); |
|
484 |
// if iAuthState==EBTAutoAuthorisationNotAuthorised and device is connected it means it tries several connections |
|
485 |
// so we just approve this. Also if connected & EBTAutoAuthorisation. |
|
486 |
// |
|
487 |
if(connectStatus && ( iAuthState==EBTAutoAuthorisationNotAuthorisedOnPhone)) |
|
488 |
{ |
|
489 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::Automatic authorisation ()")); |
|
490 |
//Antomatic authorisation without asking user |
|
491 |
CompleteMessage(ETrue, KErrNone); |
|
492 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::ShowAuthoQueryL() completed-" )); |
|
493 |
return; |
|
494 |
} |
|
495 |
||
496 |
// check if we're showing bt off query |
|
497 |
TInt queryValue=EBTQueryOff; |
|
498 |
RProperty::Get(KPSUidBluetoothEnginePrivateCategory,KBTTurnBTOffQueryOn,queryValue); |
|
499 |
if( queryValue == EBTQueryOn ) |
|
500 |
{ |
|
501 |
CompleteMessage(KErrCancel); |
|
502 |
return; |
|
503 |
} |
|
504 |
||
505 |
TBTDeviceName tempDeviceName; |
|
506 |
BtNotifNameUtils::GetDeviceDisplayName(tempDeviceName, iDevice); |
|
507 |
RBuf stringholder; |
|
508 |
CleanupClosePushL( stringholder ); |
|
509 |
BluetoothUiUtil::LoadResourceAndSubstringL( |
|
510 |
stringholder, iStrResourceId, tempDeviceName, 0); |
|
511 |
TInt keypress = iNotifUiUtil->ShowQueryL( stringholder, R_BT_AUTHORISATION_QUERY, |
|
512 |
iCoverUiDlgId, tempDeviceName, CAknQueryDialog::EConfirmationTone ); |
|
513 |
CleanupStack::PopAndDestroy(); // stringholder |
|
514 |
// If this notifier is cancelled by the caller, no need to perform the rest operation: |
|
515 |
if ( iSuspended || iMessage.IsNull() ) |
|
516 |
{ |
|
517 |
return; |
|
518 |
} |
|
519 |
||
520 |
if( keypress ) // User has accepted the dialog |
|
521 |
{ |
|
522 |
if( iDevice && !iDevice->IsValidLinkKey() ) |
|
523 |
{ |
|
524 |
TTime now; |
|
525 |
now.UniversalTime(); |
|
526 |
TBuf8<32> buf; |
|
527 |
buf.AppendNum( now.Int64() ); |
|
528 |
RProperty::Set(KPSUidBluetoothEnginePrivateCategory,KBTConnectionTimeStamp,buf); |
|
529 |
} |
|
530 |
||
531 |
MemorizeCurrentAudioAttempt(ETrue,iDevice->BDAddr() ); |
|
532 |
CompleteMessage( ETrue, KErrNone ); |
|
533 |
} |
|
534 |
else // User has rejected the dialog. |
|
535 |
{ |
|
536 |
iLockActive->CancelRequest(); |
|
537 |
DoRejectAuthorizationL(); |
|
538 |
} |
|
539 |
} |
|
540 |
||
541 |
||
542 |
// ---------------------------------------------------------- |
|
543 |
// CBTAuthNotifier::DoRejectAuthorizationL |
|
544 |
// Handle query threshold and block after user rejects authorization |
|
545 |
// ---------------------------------------------------------- |
|
546 |
// |
|
547 |
void CBTAuthNotifier::DoRejectAuthorizationL() |
|
548 |
{ |
|
549 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoRejectAuthorizationL()")); |
|
550 |
||
551 |
CheckAndHandleQueryIntervalL(); |
|
552 |
if( iMessage.IsNull() ) |
|
553 |
{ |
|
554 |
return; // No need to continue. |
|
555 |
} |
|
556 |
||
557 |
MemorizeCurrentAudioAttempt(EFalse,iDevice->BDAddr()); |
|
558 |
||
559 |
//Logic: query block only at the second time for the same paired device |
|
560 |
// query block everytime after rejection for non-paired device. |
|
561 |
if( IsPaired( iDevice->AsNamelessDevice() ) ) |
|
562 |
{ |
|
563 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoRejectAuthorizationL() rejected a paired device.")); |
|
564 |
||
565 |
TBuf<2*KBTDevAddrSize> tmp; //2 hex digits per byte |
|
566 |
RProperty::Get(KPSUidBluetoothEnginePrivateCategory, KBTBlockDevAddr, tmp); |
|
567 |
TBTDevAddr priorDeviceaddress; |
|
568 |
priorDeviceaddress.Reset(); |
|
569 |
priorDeviceaddress.SetReadable(tmp); |
|
570 |
||
571 |
if(priorDeviceaddress != iDevice->BDAddr() ) |
|
572 |
{ |
|
573 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoRejectAuthorizationL() NOT the prior rejected device, no block query.")); |
|
574 |
||
575 |
// The last device was not current device, |
|
576 |
// so the last device is updated to be current device. |
|
577 |
iDevice->BDAddr().GetReadable(tmp); |
|
578 |
RProperty::Set(KPSUidBluetoothEnginePrivateCategory, KBTBlockDevAddr, tmp ); |
|
579 |
||
580 |
// Complete message and free resources |
|
581 |
CompleteMessage(EFalse, KErrNone); |
|
582 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoRejectAuthorizationL() completed")); |
|
583 |
return; |
|
584 |
} |
|
585 |
else |
|
586 |
{ |
|
587 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoRejectAuthorizationL() IS SAME as the prior rejected device.")); |
|
588 |
||
589 |
// this was 2nd time in row. Clear the key, so the question will not be made next time. |
|
590 |
TBuf<2*KBTDevAddrSize> tmp; |
|
591 |
TBTDevAddr emptyAddr; |
|
592 |
emptyAddr.Reset(); |
|
593 |
emptyAddr.GetReadable(tmp); |
|
594 |
RProperty::Set(KPSUidBluetoothEnginePrivateCategory, KBTBlockDevAddr, tmp ); |
|
595 |
} |
|
596 |
} |
|
597 |
||
598 |
// Ask user to Block this device or not. |
|
599 |
if( !iMessage.IsNull() ) |
|
600 |
{ |
|
601 |
QueryBlockDeviceL(); |
|
602 |
} |
|
603 |
} |
|
604 |
||
605 |
// ---------------------------------------------------------- |
|
606 |
// CBTAuthNotifier::CheckAndSubscribeNotifLocks |
|
607 |
// Subscribe to PS key and check key value. |
|
608 |
// ---------------------------------------------------------- |
|
609 |
// |
|
610 |
void CBTAuthNotifier::CheckAndSubscribeNotifLocks() |
|
611 |
{ |
|
612 |
if ( !iLockActive->IsActive() ) |
|
613 |
{ |
|
614 |
FLOG(_L("[BTNOTIF]\t CBTAuthNotifier, Subscribe Device Operation Info")); |
|
615 |
iNotifLockProp.Subscribe( iLockActive->RequestStatus() ); |
|
616 |
iLockActive->GoActive(); |
|
617 |
} |
|
618 |
TInt ops; |
|
619 |
TBTNotifLockPublish::GetNotifLocks( iNotifLockProp, |
|
620 |
ops, iBTAddr ); |
|
621 |
iSuspended = ops & EBTNotiferLockPairedDeviceSetting; |
|
622 |
FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier suspended ? %d"), iSuspended )); |
|
623 |
} |
|
624 |
||
625 |
||
626 |
// End of File |