|
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 <stringloader.h> // Localisation stringloader |
|
22 #include <BTNotif.rsg> // Own resources |
|
23 #include <btnotif.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 // 1. Show pairing status note |
|
131 FTRACE(FPrint(_L("[BTNOTIF]\t CBTPairedDevSettNotifier iPairingStatus: %d"), iPairingStatus)); |
|
132 TInt resourceId = ProcessPairingErrorCode( iPairingStatus ); |
|
133 HBufC* stringholder = StringLoader::LoadLC( resourceId ); |
|
134 _LIT(PU,"%U"); |
|
135 if( stringholder->Find(PU) != KErrNotFound) |
|
136 { |
|
137 CleanupStack::PopAndDestroy( stringholder ); |
|
138 stringholder = StringLoader::LoadLC( resourceId, name ); |
|
139 } |
|
140 |
|
141 if (!iPairingStatus) |
|
142 { |
|
143 iNotifUiUtil->ShowConfirmationNoteL( ETrue, *stringholder, iSecondaryDisplayCommand, name ); |
|
144 } |
|
145 else |
|
146 { |
|
147 iNotifUiUtil->ShowErrorNoteL( ETrue, *stringholder, iSecondaryDisplayCommand, name ); |
|
148 } |
|
149 CleanupStack::PopAndDestroy( stringholder ); // stringholder |
|
150 |
|
151 if( iPairingStatus || (iDevice && iDevice->GlobalSecurity().Banned() ) ) |
|
152 { |
|
153 TBTNotifLockPublish::DeleteNotifLocks( |
|
154 EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); |
|
155 CompleteMessage(KErrNone); |
|
156 return; |
|
157 } |
|
158 |
|
159 // 2. Show Authorization query |
|
160 // |
|
161 TInt keypress = iNotifUiUtil->ShowQueryL( R_BT_AUTHORIZATION_PROMPT, R_BT_AUTHORISATION_QUERY, |
|
162 iSecondaryDisplayCommand, CAknQueryDialog::EConfirmationTone); |
|
163 |
|
164 if (!iMessage.IsNull()) |
|
165 { |
|
166 // this notifier is not cancelled, continue the task: |
|
167 ChangeAuthorizeState(keypress); |
|
168 } |
|
169 } |
|
170 |
|
171 // ---------------------------------------------------------- |
|
172 // CBTGenericQueryNotifier::ProcessParamBufferL |
|
173 // Parse the data out of the message that is sent by the |
|
174 // client of the notifier. |
|
175 // ---------------------------------------------------------- |
|
176 void CBTPairedDevSettNotifier::ProcessParamBufferL(const TDesC8& aBuffer) |
|
177 { |
|
178 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::ProcessParamBufferL()")); |
|
179 |
|
180 TBTPairedDeviceSettingParamsPckg pckg; |
|
181 pckg.Copy( aBuffer ); |
|
182 |
|
183 iPairingStatus = pckg().iPairingStatus; |
|
184 if( iPairingStatus <= KHCIErrorBase ) |
|
185 { |
|
186 // Pairing status could be KErrNone, or the Symbian error code |
|
187 // used for indicating HCI error codes. |
|
188 iPairingStatus -= KHCIErrorBase; |
|
189 } |
|
190 if ( !iPairingStatus ) |
|
191 { |
|
192 TBTNotifLockPublish::AddNotifLocks( |
|
193 EBTNotiferLockPairedDeviceSetting, pckg().iRemoteAddr ); |
|
194 } |
|
195 |
|
196 iDevice = CBTDevice::NewL(pckg().iRemoteAddr); |
|
197 GetDeviceFromRegL( pckg().iRemoteAddr ); |
|
198 |
|
199 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::ProcessParamBufferL() end")); |
|
200 } |
|
201 |
|
202 // ---------------------------------------------------------- |
|
203 // CBTPairedDevSettNotifier::Cancel |
|
204 // Release all own resources (member variables) |
|
205 // ---------------------------------------------------------- |
|
206 // |
|
207 void CBTPairedDevSettNotifier::Cancel() |
|
208 { |
|
209 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::Cancel()")); |
|
210 |
|
211 TBTNotifLockPublish::DeleteNotifLocks( |
|
212 EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); |
|
213 CBTNotifierBase::Cancel(); |
|
214 |
|
215 FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::Cancel() completed")); |
|
216 } |
|
217 |
|
218 // ---------------------------------------------------------- |
|
219 // CBTPairedDevSettNotifier::ProcessPairingErrorCode |
|
220 // ---------------------------------------------------------- |
|
221 // |
|
222 TInt CBTPairedDevSettNotifier::ProcessPairingErrorCode( const TInt aErr ) |
|
223 { |
|
224 if( !aErr ) |
|
225 { |
|
226 return R_BT_SUCCESFULLY_PAIRED_PROMPT; |
|
227 } |
|
228 else if( aErr == -EHostBusyPairing ) |
|
229 { |
|
230 return R_BT_SSP_BUSY; |
|
231 } |
|
232 else |
|
233 { |
|
234 return R_BT_PAIRING_FAILED_PROMPT; |
|
235 } |
|
236 } |
|
237 |
|
238 |
|
239 void CBTPairedDevSettNotifier::QueryRenameDeviceL(const CBTDevice& /*aDevice*/) |
|
240 { |
|
241 // No implementation for now. |
|
242 } |
|
243 |
|
244 // End of File |