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: Show pairing status and set authorized, unique devicename of paired device. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <BTNotif.rsg> // Own resources |
|
22 #include <btnotif.h> |
|
23 #include <bluetoothuiutil.h> |
|
24 #include "btnotiflock.h" |
|
25 #include "btnpaireddevsettnotifier.h" // Own class definition |
|
26 #include "btNotifDebug.h" // Debugging macros |
|
27 #include <bluetooth/hci/hcierrors.h> |
|
28 #include "btnotifnameutils.h" |
|
29 |
|
30 #include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h> |
|
31 |
|
32 #include <e32cmn.h> |
|
33 #include <AknMediatorFacade.h> // CoverUI |
|
34 |
|
35 #ifdef __SERIES60_HELP |
|
36 #include <hlplch.h> |
|
37 #include <csxhelp/bt.hlp.hrh> // The bt hrh info is needed, for help launching |
|
38 #endif |
|
39 |
|
40 // ================= MEMBER FUNCTIONS ======================= |
|
41 |
|
42 // ---------------------------------------------------------- |
|
43 // CBTPairedDevSettNotifier::NewL |
|
44 // Two-phased constructor. |
|
45 // ---------------------------------------------------------- |
|
46 // |
|
47 CBTPairedDevSettNotifier* CBTPairedDevSettNotifier::NewL() |
|
48 { |
|
49 CBTPairedDevSettNotifier* self=new (ELeave) CBTPairedDevSettNotifier(); |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop(); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------- |
|
57 // CBTPairedDevSettNotifier::CBTPairedDevSettNotifier |
|
58 // C++ default constructor can NOT contain any code, that |
|
59 // might leave. |
|
60 // ---------------------------------------------------------- |
|
61 // |
|
62 CBTPairedDevSettNotifier::CBTPairedDevSettNotifier() |
|
63 { |
|
64 } |
|
65 |
|
66 // ---------------------------------------------------------- |
|
67 // Destructor |
|
68 // ---------------------------------------------------------- |
|
69 // |
|
70 CBTPairedDevSettNotifier::~CBTPairedDevSettNotifier() |
|
71 { |
|
72 } |
|
73 |
|
74 // ---------------------------------------------------------- |
|
75 // CBTPairedDevSettNotifier::RegisterL |
|
76 // Register notifier. |
|
77 // ---------------------------------------------------------- |
|
78 // |
|
79 CBTPairedDevSettNotifier::TNotifierInfo CBTPairedDevSettNotifier::RegisterL() |
|
80 { |
|
81 iInfo.iUid = KBTPairedDeviceSettingNotifierUid; |
|
82 iInfo.iChannel = KBTPairedDeviceSettingChannel; |
|
83 iInfo.iPriority = ENotifierPriorityVHigh; |
|
84 return iInfo; |
|
85 } |
|
86 |
|
87 |
|
88 // ---------------------------------------------------------- |
|
89 // CBTPairedDevSettNotifier::GetParamsL |
|
90 // Mandatory for BT Notifiers when using asynchronous launch. |
|
91 // This notifier is synchronous so no implementation is needed. |
|
92 // ---------------------------------------------------------- |
|
93 // |
|
94 void CBTPairedDevSettNotifier::GetParamsL(const TDesC8& aBuffer, |
|
95 TInt aReplySlot, |
|
96 const RMessagePtr2& aMessage) |
|
97 { |
|
98 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::GetParamsL")); |
|
99 |
|
100 if( iReplySlot != NULL || !iMessage.IsNull()) |
|
101 { |
|
102 User::Leave(KErrInUse); |
|
103 } |
|
104 |
|
105 iMessage = aMessage; |
|
106 iReplySlot = aReplySlot; |
|
107 ProcessParamBufferL(aBuffer); |
|
108 |
|
109 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::GetParamsL Complete")); |
|
110 } |
|
111 |
|
112 // ---------------------------------------------------------- |
|
113 // CBTPairedDevSettNotifier::UpdateL |
|
114 // Update notifier according to new data |
|
115 // ---------------------------------------------------------- |
|
116 // |
|
117 TPtrC8 CBTPairedDevSettNotifier::UpdateL(const TDesC8& /*aBuffer*/) |
|
118 { |
|
119 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::UpdateL")); |
|
120 TPtrC8 ret(KNullDesC8); |
|
121 return (ret); |
|
122 } |
|
123 |
|
124 void CBTPairedDevSettNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) |
|
125 { |
|
126 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::HandleGetDeviceCompletedL >>")); |
|
127 TBTDeviceName name; |
|
128 BtNotifNameUtils::GetDeviceDisplayName(name, iDevice); |
|
129 |
|
130 RBuf stringholder; |
|
131 stringholder.CleanupClosePushL(); |
|
132 |
|
133 // 1. Show pairing status note |
|
134 FTRACE(FPrint(_L("[BTNOTIF]\t CBTPairedDevSettNotifier iPairingStatus: %d"), iPairingStatus)); |
|
135 TInt resourceId = ProcessPairingErrorCode( iPairingStatus ); |
|
136 BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, resourceId, name, 0 ); |
|
137 |
|
138 if (!iPairingStatus) |
|
139 { |
|
140 iNotifUiUtil->ShowConfirmationNoteL( ETrue, stringholder, iSecondaryDisplayCommand, name ); |
|
141 } |
|
142 else |
|
143 { |
|
144 iNotifUiUtil->ShowErrorNoteL( EFalse, stringholder, iSecondaryDisplayCommand, name ); |
|
145 } |
|
146 CleanupStack::PopAndDestroy( &stringholder ); |
|
147 |
|
148 if( iPairingStatus || (iDevice && iDevice->GlobalSecurity().Banned() ) ) |
|
149 { |
|
150 TBTNotifLockPublish::DeleteNotifLocks( |
|
151 EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); |
|
152 CompleteMessage(KErrNone); |
|
153 return; |
|
154 } |
|
155 |
|
156 // 2. Show Authorization query |
|
157 // |
|
158 TInt keypress = iNotifUiUtil->ShowQueryL( R_BT_AUTHORIZATION_PROMPT, R_BT_AUTHORISATION_QUERY, |
|
159 iSecondaryDisplayCommand, CAknQueryDialog::EConfirmationTone); |
|
160 |
|
161 if (!iMessage.IsNull()) |
|
162 { |
|
163 // this notifier is not cancelled, continue the task: |
|
164 ChangeAuthorizeState(keypress); |
|
165 } |
|
166 } |
|
167 |
|
168 // ---------------------------------------------------------- |
|
169 // CBTGenericQueryNotifier::ProcessParamBufferL |
|
170 // Parse the data out of the message that is sent by the |
|
171 // client of the notifier. |
|
172 // ---------------------------------------------------------- |
|
173 void CBTPairedDevSettNotifier::ProcessParamBufferL(const TDesC8& aBuffer) |
|
174 { |
|
175 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::ProcessParamBufferL()")); |
|
176 |
|
177 TBTPairedDeviceSettingParamsPckg pckg; |
|
178 pckg.Copy( aBuffer ); |
|
179 |
|
180 iPairingStatus = pckg().iPairingStatus; |
|
181 if( iPairingStatus <= KHCIErrorBase ) |
|
182 { |
|
183 // Pairing status could be KErrNone, or the Symbian error code |
|
184 // used for indicating HCI error codes. |
|
185 iPairingStatus -= KHCIErrorBase; |
|
186 } |
|
187 if ( !iPairingStatus ) |
|
188 { |
|
189 TBTNotifLockPublish::AddNotifLocks( |
|
190 EBTNotiferLockPairedDeviceSetting, pckg().iRemoteAddr ); |
|
191 } |
|
192 |
|
193 iDevice = CBTDevice::NewL(pckg().iRemoteAddr); |
|
194 GetDeviceFromRegL( pckg().iRemoteAddr ); |
|
195 |
|
196 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::ProcessParamBufferL() end")); |
|
197 } |
|
198 |
|
199 // ---------------------------------------------------------- |
|
200 // CBTPairedDevSettNotifier::Cancel |
|
201 // Release all own resources (member variables) |
|
202 // ---------------------------------------------------------- |
|
203 // |
|
204 void CBTPairedDevSettNotifier::Cancel() |
|
205 { |
|
206 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::Cancel()")); |
|
207 |
|
208 TBTNotifLockPublish::DeleteNotifLocks( |
|
209 EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); |
|
210 CBTNotifierBase::Cancel(); |
|
211 |
|
212 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::Cancel() completed")); |
|
213 } |
|
214 |
|
215 // ---------------------------------------------------------- |
|
216 // CBTPairedDevSettNotifier::ProcessPairingErrorCode |
|
217 // ---------------------------------------------------------- |
|
218 // |
|
219 TInt CBTPairedDevSettNotifier::ProcessPairingErrorCode( const TInt aErr ) |
|
220 { |
|
221 if( !aErr ) |
|
222 { |
|
223 return R_BT_SUCCESFULLY_PAIRED_PROMPT; |
|
224 } |
|
225 else if( aErr == -EHostBusyPairing ) |
|
226 { |
|
227 return R_BT_SSP_BUSY; |
|
228 } |
|
229 else |
|
230 { |
|
231 return R_BT_PAIRING_FAILED_PROMPT; |
|
232 } |
|
233 } |
|
234 |
|
235 |
|
236 void CBTPairedDevSettNotifier::QueryRenameDeviceL(const CBTDevice& /*aDevice*/) |
|
237 { |
|
238 // No implementation for now. |
|
239 } |
|
240 |
|
241 // End of File |
|