|
1 /* |
|
2 * Copyright (c) 2009 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: the base class of pairing handling |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "btengpairman.h" |
|
19 #include "btengpairbase.h" |
|
20 #include "debug.h" |
|
21 |
|
22 // ======== MEMBER FUNCTIONS ======== |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // C++ default constructor |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 CBTEngPairBase::CBTEngPairBase( CBTEngPairMan& aParent, const TBTDevAddr& aAddr) |
|
29 : iAddr( aAddr ), iParent( aParent ) |
|
30 { |
|
31 } |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // Symbian 2nd-phase constructor |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 void CBTEngPairBase::BaseConstructL( ) |
|
38 { |
|
39 iActive = CBTEngActive::NewL(*this, 0, CActive::EPriorityStandard); |
|
40 TRACE_BDADDR( iAddr ); |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // Destructor |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CBTEngPairBase::~CBTEngPairBase() |
|
48 { |
|
49 CancelNotifier(); |
|
50 iNotifier.Close(); |
|
51 delete iActive; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // Message passes through only if the result is for the same device this |
|
56 // object is for. |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 void CBTEngPairBase::HandlePairServerResult( const TBTDevAddr& aAddr, TInt aResult ) |
|
60 { |
|
61 if ( aAddr == iAddr ) |
|
62 { |
|
63 TRACE_FUNC_ENTRY |
|
64 DoHandlePairServerResult( aResult ); |
|
65 TRACE_FUNC_EXIT |
|
66 } |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // Message passes through only if the result is for the same device this |
|
71 // object is for. |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void CBTEngPairBase::HandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ) |
|
75 { |
|
76 if ( aDev.Address() == iAddr ) |
|
77 { |
|
78 TRACE_FUNC_ENTRY |
|
79 DoHandleRegistryNewPairedEvent( aDev ); |
|
80 TRACE_FUNC_EXIT |
|
81 } |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // Default impl of virtual function. do nothing |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 void CBTEngPairBase::CancelOutgoingPair() |
|
89 { |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // Cancel outstanding notifier |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 void CBTEngPairBase::CancelNotifier() |
|
97 { |
|
98 if( iActive && iActive->IsActive() && |
|
99 iActive->RequestId() == EDevicePairUserNotification ) |
|
100 { |
|
101 TRACE_FUNC_ENTRY |
|
102 iNotifier.CancelNotifier( KBTPairedDeviceSettingNotifierUid ); |
|
103 iActive->Cancel(); |
|
104 TRACE_FUNC_EXIT |
|
105 } |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // Show the pairing result and ask the user to authorize the device. |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 void CBTEngPairBase::ShowPairingNoteAndAuthorizeQuery() |
|
113 { |
|
114 TRACE_FUNC_ENTRY |
|
115 if ( iActive->IsActive() ) |
|
116 { |
|
117 // In profress of showing note, won't interrupt it: |
|
118 return; |
|
119 } |
|
120 TInt err ( KErrNone ); |
|
121 if (!iNotifier.Handle()) |
|
122 { |
|
123 err = iNotifier.Connect(); |
|
124 } |
|
125 if ( !err ) |
|
126 { |
|
127 // Inform the user of the pairing status. |
|
128 iActive->SetRequestId( EDevicePairUserNotification ); |
|
129 iAuthoPckg().iPairingStatus = iPairResult; |
|
130 iAuthoPckg().iRemoteAddr = iAddr; |
|
131 iNotifier.StartNotifierAndGetResponse( iActive->RequestStatus(), |
|
132 KBTPairedDeviceSettingNotifierUid, |
|
133 iAuthoPckg, iAuthoPckg ); |
|
134 iActive->GoActive(); |
|
135 } |
|
136 TRACE_FUNC_EXIT |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // Invalidate iPairResultSet |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CBTEngPairBase::UnSetPairResult() |
|
144 { |
|
145 iPairResultSet = EFalse; |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // Save the result and validate the flag |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 void CBTEngPairBase::SetPairResult( TInt aResult ) |
|
153 { |
|
154 iPairResult = aResult; |
|
155 iPairResultSet = ETrue; |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // Returns the flag |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 TBool CBTEngPairBase::IsPairResultSet() |
|
163 { |
|
164 return iPairResultSet; |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // check AO validity and its request information |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 TBool CBTEngPairBase::IsNotifyingPairResult() |
|
172 { |
|
173 return iActive && iActive->IsActive() && |
|
174 iActive->RequestId() == EDevicePairUserNotification ; |
|
175 } |
|
176 |