1 /* |
|
2 * Copyright (c) 2002,2007 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: This is view that handles listing and |
|
15 * unblocking blocked devices view. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include <avkon.hrh> // AVKON components |
|
20 #include <akntitle.h> |
|
21 #include <aknViewAppUi.h> |
|
22 #include <BtuiViewResources.rsg> // Compiled resource ids |
|
23 #include <featmgr.h> // Feature Manager |
|
24 |
|
25 #include <AknGlobalNote.h> |
|
26 #include <aknnotewrappers.h> |
|
27 #include <StringLoader.h> // Series 60 localisation stringloader |
|
28 #include <AknMediatorFacade.h> |
|
29 #include <aknmessagequerydialog.h> |
|
30 #include <aknnotewrappers.h> |
|
31 #include <aknnavi.h> |
|
32 #include <hlplch.h> // Help launcher |
|
33 #include <btengdiscovery.h> // for device search |
|
34 |
|
35 #include <ctsydomainpskeys.h> |
|
36 #include <bt_subscribe.h> |
|
37 #include <btengsettings.h> |
|
38 #include <centralrepository.h> |
|
39 #include <CoreApplicationUIsSDKCRKeys.h> |
|
40 #include <bamdesca.h> |
|
41 |
|
42 #include "debug.h" |
|
43 #include "btui.h" // Global declarations |
|
44 #include "BTUIPairedDevicesView.h" |
|
45 #include "BTUIDeviceContainer.h" |
|
46 #include <secondarydisplay/BtuiSecondaryDisplayAPI.h> |
|
47 #include <csxhelp/bt.hlp.hrh> // Help IDs |
|
48 |
|
49 #include <gstabhelper.h> |
|
50 #include <btui.mbg> // Tab icon for General Setting |
|
51 #include <bluetoothuiutil.h> |
|
52 #include "BTUIMainView.h" // base View. |
|
53 |
|
54 |
|
55 const TInt KAutoConnect2ndTry = 1; |
|
56 const TUint32 SetExcludePairedDeviceMask = 0x800000; |
|
57 |
|
58 // ================= MEMBER FUNCTIONS ======================= |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // CBTUIPairedDevicesView::NewL |
|
62 // Two phased constructor called by BT AppUI when serve as part of btui.exe |
|
63 // --------------------------------------------------------- |
|
64 // |
|
65 CBTUIPairedDevicesView* CBTUIPairedDevicesView::NewL(MBtuiPluginViewActivationObserver* aObserver) |
|
66 { |
|
67 CBTUIPairedDevicesView* self = new (ELeave) CBTUIPairedDevicesView(aObserver); |
|
68 CleanupStack::PushL(self); |
|
69 |
|
70 self->iConstructAsGsPlugin = EFalse; |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop(self); |
|
73 return self; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------- |
|
77 // CBTUIPairedDevicesView::NewLC |
|
78 // Two phased constructor called by mainView when serve as GS Plugin. |
|
79 // --------------------------------------------------------- |
|
80 // |
|
81 CBTUIPairedDevicesView* CBTUIPairedDevicesView::NewLC(CBTUIMainView* aBaseView, CArrayPtrFlat<MGSTabbedView>* aTabViewArray) |
|
82 { |
|
83 CBTUIPairedDevicesView* self = new (ELeave) CBTUIPairedDevicesView(); |
|
84 CleanupStack::PushL( self ); |
|
85 |
|
86 self->iConstructAsGsPlugin = ETrue; |
|
87 self->ConstructL( aBaseView, aTabViewArray ); |
|
88 |
|
89 return self; |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CBTUIPairedDevicesView::ConstructL |
|
95 // Symbian 2nd phase constructor can leave. |
|
96 // --------------------------------------------------------- |
|
97 // |
|
98 void CBTUIPairedDevicesView::ConstructL() |
|
99 { |
|
100 TRACE_FUNC_ENTRY |
|
101 |
|
102 BaseConstructL(R_BTUI_OTHER_DEVICES_VIEW); |
|
103 |
|
104 iCoverDisplayEnabled = FeatureManager::FeatureSupported(KFeatureIdCoverDisplay); |
|
105 iHelpEnabled = FeatureManager::FeatureSupported(KFeatureIdHelp); |
|
106 |
|
107 iDeviceSearcher = CBTEngDiscovery::NewL(this); |
|
108 iBtEngSettings = CBTEngSettings::NewL(this); |
|
109 iBTPluginMan = CBTUIPluginMan::NewL( AppUi() ); |
|
110 iIsAlreadyConnected = EFalse; |
|
111 iExpectedCallBack = 0; |
|
112 TRACE_INFO(_L("Initial iIsAlreadyConnected -> False")) |
|
113 TRACE_FUNC_EXIT |
|
114 } |
|
115 |
|
116 void CBTUIPairedDevicesView::ConstructL( CBTUIMainView* aBaseView, CArrayPtrFlat<MGSTabbedView>* aTabViewArray ) |
|
117 { |
|
118 TRACE_FUNC_ENTRY |
|
119 |
|
120 iBaseView = aBaseView, |
|
121 iTabHelper = CGSTabHelper::NewL(); |
|
122 aTabViewArray->AppendL(this); |
|
123 |
|
124 BaseConstructL(R_BTUI_OTHER_DEVICES_VIEW_GS); |
|
125 iCoverDisplayEnabled = FeatureManager::FeatureSupported(KFeatureIdCoverDisplay); |
|
126 iHelpEnabled = FeatureManager::FeatureSupported(KFeatureIdHelp); |
|
127 |
|
128 iDeviceSearcher = CBTEngDiscovery::NewL(this); |
|
129 iBtEngSettings=CBTEngSettings::NewL(this); |
|
130 iBTPluginMan = CBTUIPluginMan::NewL( AppUi() ); |
|
131 iIsAlreadyConnected = EFalse; |
|
132 TRACE_INFO(_L("Initial iIsAlreadyConnected = False")) |
|
133 iExpectedCallBack = 0; |
|
134 |
|
135 TRACE_FUNC_EXIT |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------- |
|
139 // CBTUIBlockedDevicesView::CBTUIBlockedDevicesView |
|
140 // --------------------------------------------------------- |
|
141 |
|
142 CBTUIPairedDevicesView::CBTUIPairedDevicesView( MBtuiPluginViewActivationObserver* aObserver ) |
|
143 : iActivationObserver(aObserver) |
|
144 { |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------- |
|
148 // Destructor |
|
149 // --------------------------------------------------------- |
|
150 // |
|
151 CBTUIPairedDevicesView::~CBTUIPairedDevicesView() |
|
152 { |
|
153 TRACE_FUNC_ENTRY |
|
154 |
|
155 //close dialogs if any |
|
156 TRAP_IGNORE( |
|
157 DialogDismissedL(EAknSoftkeyCancel); |
|
158 ); |
|
159 |
|
160 delete iActive; |
|
161 |
|
162 if (iContainer) |
|
163 { |
|
164 AppUi()->RemoveFromViewStack(*this, iContainer); |
|
165 delete iContainer; |
|
166 iContainer = NULL; |
|
167 } |
|
168 |
|
169 if(iDeviceSearcher) |
|
170 { |
|
171 // Canceling devicesearches is done by DialogDismissedL(), |
|
172 // so it is not done here |
|
173 delete iDeviceSearcher; |
|
174 iDeviceSearcher = NULL ; |
|
175 } |
|
176 delete iConnectDevice; |
|
177 iConnectDevice=NULL; |
|
178 |
|
179 delete iPairingDevice; |
|
180 delete iBtEngSettings; |
|
181 delete iBTPluginMan; |
|
182 |
|
183 if(iConstructAsGsPlugin) |
|
184 delete iTabHelper; |
|
185 |
|
186 CancelDisconnectQueryDlg(); |
|
187 |
|
188 TRACE_FUNC_EXIT |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------- |
|
192 // From CAknView |
|
193 // CBTUIPairedDevicesView::Id |
|
194 // --------------------------------------------------------- |
|
195 // |
|
196 TUid CBTUIPairedDevicesView::Id() const |
|
197 { |
|
198 TRACE_FUNC_ENTRY |
|
199 return KBtuiPluginUidPairedDevicesView;//KBTOtherDevicesViewId; |
|
200 } |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 // --------------------------------------------------------- |
|
206 // From CAknView |
|
207 // CBTUIPairedDevicesView::HandleCommandL |
|
208 // Redirects commands to the appui class. |
|
209 // --------------------------------------------------------- |
|
210 // |
|
211 void CBTUIPairedDevicesView::HandleCommandL(TInt aCommand) |
|
212 { |
|
213 TRACE_FUNC_ENTRY |
|
214 |
|
215 switch (aCommand) |
|
216 { |
|
217 |
|
218 case EAknSoftkeyBack: |
|
219 // do not exit if devicechange is in progress. |
|
220 if(iModel->DeviceChangeInProgress() ) |
|
221 return; |
|
222 AppUi()->ActivateLocalViewL(iBaseView->GetParentView().iViewUid ); |
|
223 break; |
|
224 |
|
225 case EAknSoftkeyExit: |
|
226 { |
|
227 TRACE_INFO(_L("EAknSoftkeyExit")) |
|
228 // do not exit if devicechange or bt discovery is in progress. |
|
229 if(iModel->DeviceChangeInProgress() |
|
230 || iSearchOngoing ) |
|
231 { |
|
232 TRACE_INFO(_L("exit denied, due to operation")) |
|
233 return; |
|
234 } |
|
235 |
|
236 TRACE_INFO(_L("exit in progress")) |
|
237 AppUi()->ProcessCommandL(EEikCmdExit); |
|
238 break; |
|
239 } |
|
240 |
|
241 case EAknCmdHelp: |
|
242 { |
|
243 #ifdef __SERIES60_HELP |
|
244 HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(),AppUi()->AppHelpContextL()); |
|
245 #endif |
|
246 break; |
|
247 } |
|
248 |
|
249 case EBTUICmdNewPairedDevice: |
|
250 { |
|
251 iSearchOngoing=ETrue; |
|
252 NewPairedDeviceDlgL(); |
|
253 break; |
|
254 } |
|
255 |
|
256 case EBTUICmdDelete: |
|
257 { |
|
258 DeleteDeviceDlgL(); |
|
259 break; |
|
260 } |
|
261 |
|
262 case EBTUICmdDeleteAll: |
|
263 { |
|
264 DeleteAllDevicesDlgL(); |
|
265 break; |
|
266 } |
|
267 |
|
268 case EBTUICmdGiveNickname: |
|
269 { |
|
270 RenameDeviceDlgL(); |
|
271 break; |
|
272 } |
|
273 |
|
274 case EBTUICmdSetTrusted: |
|
275 { |
|
276 ChangeDeviceSecurityL(ETrue); |
|
277 break; |
|
278 } |
|
279 |
|
280 case EBTUICmdSetUnTrusted: |
|
281 { |
|
282 ChangeDeviceSecurityL(EFalse); |
|
283 break; |
|
284 } |
|
285 |
|
286 case EBTUICmdConnect: |
|
287 case EBTUICmdConnectAudio: |
|
288 { |
|
289 TBTDevice device; |
|
290 device.iIndex = iContainer->CurrentItemIndex(); |
|
291 iModel->GetDevice(device); |
|
292 if ( device.iStatus & EStatusBtuiConnected ) |
|
293 { |
|
294 // If device is already connected, we do nothing here. |
|
295 break; |
|
296 } |
|
297 device.iOperation = EOpConnect; |
|
298 ConnectL( device, ETrue ); |
|
299 break; |
|
300 } |
|
301 |
|
302 case EBTUICmdDisconnect: |
|
303 { |
|
304 DisconnectL(); |
|
305 break; |
|
306 } |
|
307 |
|
308 case EBTUICmdSetBlocked: |
|
309 { |
|
310 BlockDeviceDlgL(); |
|
311 break; |
|
312 } |
|
313 |
|
314 case EBTUICmdSettings: |
|
315 { |
|
316 LaunchSettingViewL(); |
|
317 break; |
|
318 } |
|
319 |
|
320 default: |
|
321 { |
|
322 AppUi()->HandleCommandL(aCommand); |
|
323 break; |
|
324 } |
|
325 } |
|
326 TRACE_FUNC_EXIT |
|
327 } |
|
328 |
|
329 |
|
330 // --------------------------------------------------------- |
|
331 // From CAknView |
|
332 // CBTUIPairedDevicesView::DoActivateL |
|
333 // --------------------------------------------------------- |
|
334 // |
|
335 void CBTUIPairedDevicesView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, |
|
336 TUid /*aCustomMessageId*/, |
|
337 const TDesC8& /*aCustomMessage*/) |
|
338 { |
|
339 TRACE_FUNC_ENTRY |
|
340 |
|
341 iModel = CBTDevModel::NewL(EGroupPaired, this); |
|
342 iContainer = CBTUiDeviceContainer::NewL(ClientRect(), this, EGroupPaired, this); |
|
343 iContainer->SetMopParent(this); // MObjectProvider |
|
344 |
|
345 // Setup title |
|
346 HBufC* btTitlePairedDevices = |
|
347 iCoeEnv->AllocReadResourceLC(R_BT_TITLE_PAIRED_DEV); |
|
348 CEikStatusPane* statusPane = StatusPane(); |
|
349 CAknTitlePane* titlePane; |
|
350 titlePane = (CAknTitlePane*) statusPane->ControlL( |
|
351 TUid::Uid(EEikStatusPaneUidTitle)); |
|
352 titlePane->SetTextL(btTitlePairedDevices->Des()); |
|
353 CleanupStack::PopAndDestroy(btTitlePairedDevices); // btTitlePairedDevices |
|
354 btTitlePairedDevices = NULL; |
|
355 |
|
356 AppUi()->AddToStackL(*this, iContainer); |
|
357 |
|
358 if( iBaseView && iConstructAsGsPlugin) |
|
359 { |
|
360 iTabHelper->CreateTabGroupL( Id(), |
|
361 static_cast<CArrayPtrFlat<MGSTabbedView>*> |
|
362 (iBaseView->TabbedViews()) ); |
|
363 } |
|
364 |
|
365 // MSK menu is added here. |
|
366 // the left key menu is added by resources. |
|
367 MenuBar()->SetContextMenuTitleResourceId( |
|
368 R_BTUI_MENUBAR_OTHER_DEVICES_VIEW_CONTEXT); |
|
369 // notify observer |
|
370 if( iActivationObserver && iConstructAsGsPlugin == EFalse) |
|
371 { |
|
372 iActivationObserver->PluginViewActivated(EPairedDevicesViewId); |
|
373 } |
|
374 |
|
375 TRACE_FUNC_EXIT |
|
376 } |
|
377 |
|
378 // --------------------------------------------------------- |
|
379 // From CAknView |
|
380 // CBTUIPairedDevicesView::DoDeactivate |
|
381 // --------------------------------------------------------- |
|
382 // |
|
383 void CBTUIPairedDevicesView::DoDeactivate() |
|
384 { |
|
385 TRACE_FUNC_ENTRY |
|
386 |
|
387 if (iContainer) |
|
388 { |
|
389 AppUi()->RemoveFromStack(iContainer); |
|
390 delete iContainer; |
|
391 iContainer = NULL; |
|
392 } |
|
393 if ( iDeviceSearcher ) |
|
394 { |
|
395 iDeviceSearcher->CancelSearchRemoteDevice(); |
|
396 } |
|
397 delete iModel; |
|
398 iModel=NULL; |
|
399 if(iConstructAsGsPlugin) |
|
400 iTabHelper->RemoveTabGroup(); |
|
401 delete iActive; |
|
402 iActive = NULL; |
|
403 iIsPairConnect = EFalse; |
|
404 TRACE_FUNC_EXIT |
|
405 } |
|
406 |
|
407 // --------------------------------------------------------- |
|
408 // From CAknView |
|
409 // CBTUIPairedDevicesView::DynInitMenuPaneL |
|
410 // Shows only options supported for selected device, if any. |
|
411 // If not show only options supported regardless of selected |
|
412 // device |
|
413 // --------------------------------------------------------- |
|
414 // |
|
415 void CBTUIPairedDevicesView::DynInitMenuPaneL(TInt aResId, CEikMenuPane* aMenu) |
|
416 { |
|
417 TRACE_FUNC_ENTRY |
|
418 iActiveMenuPane = aMenu; |
|
419 // dim help if it exists and is not supported |
|
420 TInt tmp; |
|
421 if ( aMenu->MenuItemExists(EAknCmdHelp,tmp ) ) |
|
422 { |
|
423 aMenu->SetItemDimmed(EAknCmdHelp, |
|
424 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); |
|
425 } |
|
426 |
|
427 if ( aResId == R_BTUI_OTHER_DEVICES_VIEW_MENU ) |
|
428 { |
|
429 TInt index = iContainer->CurrentItemIndex(); |
|
430 |
|
431 // we only show "new pair device", "help" , "Exit" and "Delete All" if view contains device(s). |
|
432 aMenu->SetItemDimmed(EBTUICmdSetTrusted, ETrue); |
|
433 aMenu->SetItemDimmed(EBTUICmdDelete,ETrue); |
|
434 aMenu->SetItemDimmed(EBTUICmdSetTrusted,ETrue); |
|
435 aMenu->SetItemDimmed(EBTUICmdSetUnTrusted,ETrue); |
|
436 aMenu->SetItemDimmed(EBTUICmdConnect,ETrue); |
|
437 aMenu->SetItemDimmed(EBTUICmdConnectAudio,ETrue); |
|
438 aMenu->SetItemDimmed(EBTUICmdDisconnect,ETrue); |
|
439 aMenu->SetItemDimmed(EBTUICmdSetBlocked,ETrue); |
|
440 aMenu->SetItemDimmed(EBTUICmdSettings,ETrue); |
|
441 aMenu->SetItemDimmed(EBTUICmdGiveNickname, ETrue); |
|
442 |
|
443 if ( index < 0 ) // No devices at list. Hide all device related commands. |
|
444 { |
|
445 aMenu->SetItemDimmed(EBTUICmdDeleteAll, ETrue); |
|
446 } |
|
447 |
|
448 } |
|
449 |
|
450 if ( aResId == R_BTUI_OTHER_DEVICES_VIEW_MENU_CONTEXT ) |
|
451 { |
|
452 TInt index = iContainer->CurrentItemIndex(); |
|
453 |
|
454 // If user is fast enough to click the RSK option between |
|
455 // bt discovery view and device found view, bt ui will crash. |
|
456 // Therefore, we disable commands if bt discovery is onging. |
|
457 // |
|
458 if(iSearchOngoing) |
|
459 { |
|
460 aMenu->SetItemDimmed(EBTUICmdGiveNickname, ETrue); |
|
461 aMenu->SetItemDimmed(EBTUICmdSetTrusted, ETrue); |
|
462 aMenu->SetItemDimmed(EBTUICmdSetUnTrusted, ETrue); |
|
463 aMenu->SetItemDimmed(EBTUICmdSetBlocked, ETrue); |
|
464 aMenu->SetItemDimmed(EBTUICmdDelete, ETrue); |
|
465 aMenu->SetItemDimmed(EBTUICmdConnect, ETrue); |
|
466 aMenu->SetItemDimmed(EBTUICmdConnectAudio, ETrue); |
|
467 aMenu->SetItemDimmed(EBTUICmdDisconnect, ETrue); |
|
468 aMenu->SetItemDimmed(EBTUICmdNewPairedDevice, ETrue); |
|
469 return; |
|
470 } |
|
471 |
|
472 if(index < 0) // No devices at list. Hide all device related commands. |
|
473 { |
|
474 TRACE_INFO(_L("no devices in list")) |
|
475 |
|
476 aMenu->SetItemDimmed(EBTUICmdGiveNickname, ETrue); |
|
477 aMenu->SetItemDimmed(EBTUICmdSetTrusted, ETrue); |
|
478 aMenu->SetItemDimmed(EBTUICmdSetUnTrusted, ETrue); |
|
479 aMenu->SetItemDimmed(EBTUICmdSetBlocked, ETrue); |
|
480 aMenu->SetItemDimmed(EBTUICmdDelete, ETrue); |
|
481 aMenu->SetItemDimmed(EBTUICmdConnect, ETrue); |
|
482 aMenu->SetItemDimmed(EBTUICmdConnectAudio, ETrue); |
|
483 aMenu->SetItemDimmed(EBTUICmdDisconnect, ETrue); |
|
484 aMenu->SetItemDimmed(EBTUICmdSettings, ETrue); |
|
485 } |
|
486 else // There are devices at list |
|
487 { |
|
488 TBTDevice device; |
|
489 device.iIndex = index; |
|
490 iModel->GetDevice(device); |
|
491 iMenuDevice = device; |
|
492 |
|
493 TRACE_INFO(_L("there are device in list")) |
|
494 |
|
495 TBool dim = (device.iStatus & EStatusTrusted) == EStatusTrusted; |
|
496 |
|
497 aMenu->SetItemDimmed(EBTUICmdSetTrusted, dim); |
|
498 aMenu->SetItemDimmed(EBTUICmdSetUnTrusted, !dim); |
|
499 |
|
500 // Check if device can be connected or disconnected |
|
501 dim = (! (device.iStatus & EStatusConnectable) |
|
502 || device.iStatus & EStatusBtuiConnected); |
|
503 |
|
504 if (dim) |
|
505 { |
|
506 aMenu->SetItemDimmed(EBTUICmdConnect, dim); |
|
507 aMenu->SetItemDimmed(EBTUICmdConnectAudio, dim); |
|
508 } |
|
509 else |
|
510 { |
|
511 if ( device.iDeviceClass.MajorDeviceClass() == EMajorDeviceComputer) |
|
512 { |
|
513 aMenu->SetItemDimmed(EBTUICmdConnect, ETrue); |
|
514 } |
|
515 else |
|
516 { |
|
517 aMenu->SetItemDimmed(EBTUICmdConnectAudio, ETrue); |
|
518 } |
|
519 } |
|
520 dim = (device.iStatus & EStatusBtuiConnected) != EStatusBtuiConnected; |
|
521 aMenu->SetItemDimmed(EBTUICmdDisconnect, dim); |
|
522 |
|
523 if ( !iBTPluginMan->IsPluginAvaiable(device.iDeviceClass) ) |
|
524 { |
|
525 aMenu->SetItemDimmed(EBTUICmdSettings, ETrue); |
|
526 } |
|
527 else |
|
528 { |
|
529 dim = (device.iStatus & EStatusBtuiConnected) != EStatusBtuiConnected; |
|
530 aMenu->SetItemDimmed(EBTUICmdSettings, dim); |
|
531 } |
|
532 //Hide New pair device |
|
533 aMenu->SetItemDimmed(EBTUICmdNewPairedDevice, ETrue); |
|
534 } |
|
535 } |
|
536 TRACE_FUNC_EXIT |
|
537 } |
|
538 |
|
539 |
|
540 // ---------------------------------------------------------- |
|
541 // CBTUIPairedDevicesView::RenameDeviceDlgL |
|
542 // ---------------------------------------------------------- |
|
543 // |
|
544 void CBTUIPairedDevicesView::RenameDeviceDlgL() |
|
545 { |
|
546 TRACE_FUNC_ENTRY |
|
547 |
|
548 TInt index = iContainer->CurrentItemIndex(); |
|
549 if(index == KErrNotFound) return; |
|
550 |
|
551 TBTDevice device; |
|
552 device.iIndex = index; |
|
553 iModel->GetDevice(device); |
|
554 TBTDeviceName name = device.iName; |
|
555 |
|
556 CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(device.iName); |
|
557 TInt keypress = dlg->ExecuteLD(R_BT_ENTER_NICKNAME_QUERY); |
|
558 |
|
559 if(keypress) // User has accepted the dialog |
|
560 { |
|
561 if(device.iName != name) // Check if the user really changed the name |
|
562 { |
|
563 device.iOperation = EOpChangeName; |
|
564 // Remove trouble making control chars |
|
565 AknTextUtils::StripCharacters(device.iName, KAknStripListControlChars); |
|
566 device.iName.TrimAll(); // Remove extra spaces |
|
567 iModel->ChangeDevice(device); |
|
568 } |
|
569 } |
|
570 TRACE_FUNC_EXIT |
|
571 } |
|
572 |
|
573 |
|
574 // ---------------------------------------------------------- |
|
575 // CBTUIPairedDevicesView::NewPairedDeviceDlgL |
|
576 // |
|
577 // Initiate bonding (pairing) by opening the search dialog. |
|
578 // DeviceSearchComplete is called after that. |
|
579 // ---------------------------------------------------------- |
|
580 // |
|
581 void CBTUIPairedDevicesView::NewPairedDeviceDlgL() |
|
582 { |
|
583 TRACE_FUNC_ENTRY |
|
584 // we must not have other pairing in progress. |
|
585 // we maight issue an error, but none is defined by |
|
586 // ui spec. Anyhow this should be possible |
|
587 // only by pressing everything roo rapidly. |
|
588 if(iPairingDevice!=NULL) |
|
589 return; |
|
590 iPairingDevice = CBTDevice::NewL(); |
|
591 |
|
592 // Here we use last bit in device class to inform bt inquiry notifier |
|
593 // not to display the device which is already paired and in the paired |
|
594 // device list. |
|
595 |
|
596 // We use DeviceClass to tell btnotif not to show paired device in |
|
597 // bt discovery notifier through bteng. |
|
598 // Set bit 24 to 1 ( bit 24 is not used for any other purpose currently ) |
|
599 iPairingDevice->SetDeviceClass(iPairingDevice->DeviceClass().DeviceClass() | SetExcludePairedDeviceMask ); |
|
600 TInt err = iDeviceSearcher->SearchRemoteDevice(iPairingDevice, |
|
601 &iPairingDevNameEntry, |
|
602 iPairingDevice->DeviceClass().DeviceClass()); |
|
603 |
|
604 |
|
605 if(err != KErrNone) |
|
606 { |
|
607 delete iPairingDevice; |
|
608 iPairingDevice=NULL; |
|
609 TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); |
|
610 } |
|
611 TRACE_FUNC_EXIT |
|
612 } |
|
613 |
|
614 // ---------------------------------------------------------- |
|
615 // CBTUIPairedDevicesView::DeleteDeviceDlgL |
|
616 // ---------------------------------------------------------- |
|
617 // |
|
618 void CBTUIPairedDevicesView::DeleteDeviceDlgL() |
|
619 { |
|
620 TRACE_FUNC_ENTRY |
|
621 |
|
622 iExpectedCallBack = 0; |
|
623 TInt index = iContainer->CurrentItemIndex(); |
|
624 if(index == KErrNotFound) return; |
|
625 |
|
626 TBTDevice device; |
|
627 device.iIndex = index; |
|
628 iModel->GetDevice(device); |
|
629 |
|
630 RBuf stringholder; |
|
631 CleanupClosePushL( stringholder ); |
|
632 |
|
633 TInt tmp=EStatusBtuiConnected|EStatusPhysicallyConnected; |
|
634 // Choose confirmation phrase |
|
635 TInt resourceId = ( device.iStatus & tmp ) ? R_BT_WARN_ERASE_CONNECTED : |
|
636 R_BT_WARN_ERASE; |
|
637 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
638 stringholder, resourceId, device.iName, 0 ); |
|
639 |
|
640 // Create confirmation query |
|
641 // |
|
642 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
643 |
|
644 if(iCoverDisplayEnabled) |
|
645 { |
|
646 CleanupStack::PushL(dlg); |
|
647 dlg->PublishDialogL(ECmdShowBtWarnEraseNote, KUidCoverUiCategoryBtui); |
|
648 // initializes cover support |
|
649 CleanupStack::Pop(dlg); |
|
650 |
|
651 CAknMediatorFacade* covercl = AknMediatorFacade(dlg); // uses MOP, so control provided |
|
652 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
653 { |
|
654 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName) ;// takes copy so consts are ok too |
|
655 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
656 } |
|
657 } |
|
658 TInt keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_QUERY, stringholder); |
|
659 |
|
660 CleanupStack::PopAndDestroy(&stringholder); // stringholder |
|
661 |
|
662 if(keypress) // User has accepted the dialog |
|
663 { |
|
664 // If device is connected we need to first to disconnect |
|
665 // then unpair, otherwise unpairing does not succeed. |
|
666 if((device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) |
|
667 { |
|
668 iExpectedCallBack++; |
|
669 DisconnectWithoutQuery(); |
|
670 return; |
|
671 } |
|
672 device.iOperation = EOpUnpair; |
|
673 iModel->ChangeDevice(device); |
|
674 } |
|
675 |
|
676 TRACE_FUNC_EXIT |
|
677 } |
|
678 |
|
679 // ---------------------------------------------------------- |
|
680 // CBTUIPairedDevicesView::DeleteAllDevicesDlgL |
|
681 // ---------------------------------------------------------- |
|
682 // |
|
683 void CBTUIPairedDevicesView::DeleteAllDevicesDlgL() |
|
684 { |
|
685 TRACE_FUNC_ENTRY |
|
686 |
|
687 iExpectedCallBack = 0; |
|
688 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
689 TInt keypress = KErrNone; |
|
690 |
|
691 CleanupStack::PushL(dlg); |
|
692 |
|
693 // Choose and execute confirmation query |
|
694 // |
|
695 if (iModel->IsAnyDeviceConnected()) |
|
696 { |
|
697 if(iCoverDisplayEnabled) |
|
698 { |
|
699 dlg->PublishDialogL(ECmdShowBtWarnEraseAllConnectedQuery, KUidCoverUiCategoryBtui); // initializes cover support |
|
700 } |
|
701 |
|
702 keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_ALL_CONNECTED_QUERY); |
|
703 } |
|
704 else |
|
705 { |
|
706 if(iCoverDisplayEnabled) |
|
707 { |
|
708 dlg->PublishDialogL(ECmdShowBtWarnEraseAllQuery, KUidCoverUiCategoryBtui); // initializes cover support |
|
709 } |
|
710 |
|
711 keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_ALL_QUERY); |
|
712 } |
|
713 CleanupStack::Pop(dlg); |
|
714 |
|
715 if(keypress) // User has accepted the dialog |
|
716 { |
|
717 TInt count = iContainer->CountItems(); |
|
718 for (TInt i = 0; i < count; i++) |
|
719 { |
|
720 // If device is connected we need to first to disconnect |
|
721 // then unpair, otherwise unpairing does not succeed. |
|
722 TBTDevice device; |
|
723 device.iIndex = i; |
|
724 iModel->GetDevice(device); |
|
725 if((device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) |
|
726 { |
|
727 iExpectedCallBack++; |
|
728 } |
|
729 } |
|
730 TRACE_INFO((_L("iExpectedCallBack %d"), iExpectedCallBack )) |
|
731 |
|
732 for (TInt i = 0; i < count; i++) |
|
733 { |
|
734 // If device is connected we need to first to disconnect |
|
735 // then unpair, otherwise unpairing does not succeed. |
|
736 TBTDevice device; |
|
737 device.iIndex = i; |
|
738 iModel->GetDevice(device); |
|
739 |
|
740 if((device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) |
|
741 { |
|
742 //disconnect it first, removal will be done in |
|
743 //callback NotifyChangeDeviceCompleteL for ChangeDevice() below |
|
744 TRACE_INFO((_L("EOpDisconnect issued for %d"), i )) |
|
745 device.iOperation = EOpDisconnect; |
|
746 iModel->ChangeDevice(device); |
|
747 } |
|
748 else |
|
749 { |
|
750 //otherwise, just remove it from the paired view |
|
751 device.iOperation = EOpUnpair; |
|
752 iModel->ChangeDevice(device); |
|
753 } |
|
754 } |
|
755 } |
|
756 |
|
757 TRACE_FUNC_EXIT |
|
758 } |
|
759 // ---------------------------------------------------------- |
|
760 // CBTUIPairedDevicesView::BlockDeviceDlgL |
|
761 // ---------------------------------------------------------- |
|
762 void CBTUIPairedDevicesView::BlockDeviceDlgL() |
|
763 { |
|
764 TRACE_FUNC_ENTRY |
|
765 |
|
766 TInt index = iContainer->CurrentItemIndex(); |
|
767 if(index == KErrNotFound) return; |
|
768 |
|
769 TBTDevice device; |
|
770 device.iIndex = index; |
|
771 iModel->GetDevice(device); |
|
772 |
|
773 //check if this is connected device |
|
774 |
|
775 HBufC* header= iCoeEnv->AllocReadResourceLC(R_BT_OPTION_BLOCK_DEVICE_HEADER); |
|
776 |
|
777 RBuf stringHolder; |
|
778 CleanupClosePushL( stringHolder ); |
|
779 TInt resouseId; |
|
780 if (device.iStatus & (EStatusBtuiConnected|EStatusPhysicallyConnected) ) |
|
781 { |
|
782 resouseId = iHelpEnabled? R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP : |
|
783 R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP; |
|
784 } |
|
785 else |
|
786 { |
|
787 resouseId = iHelpEnabled ? R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP : |
|
788 R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP; |
|
789 } |
|
790 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
791 stringHolder, resouseId, device.iName, 0 ); |
|
792 |
|
793 CAknMessageQueryDialog *queryDialog = CAknMessageQueryDialog::NewL (stringHolder, |
|
794 CAknQueryDialog::EConfirmationTone); |
|
795 queryDialog->PrepareLC(R_BT_MESSAGE_QUERY); |
|
796 |
|
797 (queryDialog)->Heading()->SetTextL(*header); |
|
798 queryDialog->SetFocus(ETrue); |
|
799 |
|
800 TInt keypress=EFalse; |
|
801 #ifdef __SERIES60_HELP |
|
802 if (iHelpEnabled) |
|
803 { |
|
804 HBufC* queryLink = StringLoader::LoadL(R_BT_BLOCK_DEVICE_LINK); |
|
805 TCoeHelpContext hc(KBtuiUid3,KBT_HLP_BLOCKED); |
|
806 TCallBack helpCallBack(CBTUIPairedDevicesView::LaunchHelp , &hc); |
|
807 |
|
808 TRAPD(err, |
|
809 static_cast<CAknMessageQueryDialog*>(queryDialog)->SetLinkTextL(*queryLink); |
|
810 static_cast<CAknMessageQueryDialog*>(queryDialog)->SetLink(helpCallBack);); |
|
811 if(err==KErrNone) |
|
812 { |
|
813 keypress = queryDialog->RunLD(); |
|
814 } |
|
815 |
|
816 delete queryLink; |
|
817 queryLink = NULL; |
|
818 } |
|
819 else |
|
820 #endif |
|
821 { |
|
822 keypress = queryDialog->RunLD(); |
|
823 } |
|
824 |
|
825 CleanupStack::PopAndDestroy(&stringHolder); |
|
826 CleanupStack::PopAndDestroy(header); |
|
827 |
|
828 if(keypress) |
|
829 { |
|
830 device.iOperation = EOpBlock; |
|
831 iModel->ChangeDevice(device); |
|
832 } |
|
833 TRACE_FUNC_EXIT |
|
834 } |
|
835 // ---------------------------------------------------------- |
|
836 // CBTUIPairedDevicesView::ChangeDeviceSecurityL |
|
837 // ---------------------------------------------------------- |
|
838 // |
|
839 void CBTUIPairedDevicesView::ChangeDeviceSecurityL(TBool aTrusted) |
|
840 { |
|
841 TRACE_FUNC_ENTRY |
|
842 |
|
843 TInt index = iContainer->CurrentItemIndex(); |
|
844 if(index == KErrNotFound) return; |
|
845 |
|
846 TBTDevice device; |
|
847 device.iIndex = index; |
|
848 iModel->GetDevice(device); |
|
849 |
|
850 if(aTrusted) |
|
851 { |
|
852 // set to trusted |
|
853 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
854 |
|
855 if(iCoverDisplayEnabled) |
|
856 { |
|
857 CleanupStack::PushL(dlg); |
|
858 dlg->PublishDialogL(ECmdShowBtAuthConfirmQuery, KUidCoverUiCategoryBtui); // initializes cover support |
|
859 CleanupStack::Pop(dlg); |
|
860 } |
|
861 TInt keypress = dlg->ExecuteLD(R_BT_SET_TRUSTED_QUERY); |
|
862 |
|
863 if(keypress) // User has accepted the dialog |
|
864 { |
|
865 device.iOperation = EOpTrust; |
|
866 iModel->ChangeDevice(device); |
|
867 } |
|
868 } |
|
869 else |
|
870 { |
|
871 device.iOperation = EOpUntrust; |
|
872 iModel->ChangeDevice(device); |
|
873 } |
|
874 TRACE_FUNC_EXIT |
|
875 } |
|
876 |
|
877 // ---------------------------------------------------- |
|
878 // CBTUIMainView::VisibilityModeChanged |
|
879 // ---------------------------------------------------- |
|
880 // |
|
881 void CBTUIPairedDevicesView::VisibilityModeChanged( TBTVisibilityMode ) |
|
882 { |
|
883 TRACE_FUNC_ENTRY |
|
884 |
|
885 |
|
886 TRACE_FUNC_EXIT |
|
887 } |
|
888 |
|
889 |
|
890 // ---------------------------------------------------- |
|
891 // CBTUIMainView::PowerStateChanged |
|
892 // ---------------------------------------------------- |
|
893 // |
|
894 void CBTUIPairedDevicesView::PowerStateChanged( TBTPowerStateValue ) |
|
895 { |
|
896 TRACE_FUNC_ENTRY |
|
897 |
|
898 if ( iIsConnectDevice ) |
|
899 { |
|
900 iModel->ChangeDevice(*iConnectDevice); |
|
901 iIsConnectDevice = EFalse; // reset flag |
|
902 } |
|
903 |
|
904 TRACE_FUNC_EXIT |
|
905 } |
|
906 |
|
907 // ---------------------------------------------------------- |
|
908 // CBTUIPairedDevicesView::ConnectL |
|
909 // ---------------------------------------------------------- |
|
910 // |
|
911 void CBTUIPairedDevicesView::ConnectL( |
|
912 const TBTDevice& aDevice, TBool aNewWaitNote ) |
|
913 { |
|
914 TRACE_FUNC_ENTRY |
|
915 |
|
916 iIsAlreadyConnected = EFalse; |
|
917 TRACE_INFO(_L("Set iIsAlreadyConnected -> False")) |
|
918 //Check that there is not more than max amount of connections allready. |
|
919 TInt connNum = 0; |
|
920 RProperty::Get(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount, connNum); |
|
921 if(connNum > KBtUiMaxConnections) |
|
922 { |
|
923 ConnectCompleteL(KErrServerBusy, aDevice); |
|
924 } |
|
925 else if(CallOnGoing()&& connNum > 1) |
|
926 { |
|
927 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog(CAknNoteDialog::ENoTone, |
|
928 CAknNoteDialog::ELongTimeout); |
|
929 if(iCoverDisplayEnabled) |
|
930 { |
|
931 CleanupStack::PushL(dlg); |
|
932 dlg->PublishDialogL(ECmdShowBtImpossibleIncallNote, KUidCoverUiCategoryBtui); // initializes cover support |
|
933 CleanupStack::Pop(dlg); |
|
934 } |
|
935 |
|
936 dlg->ExecuteLD(R_BT_NOT_INCALL_NOTE); |
|
937 } |
|
938 else |
|
939 { |
|
940 if(TBTUIViewsCommonUtils::TurnBTOnIfNeededL(iBtEngSettings,iCoverDisplayEnabled)!= KErrNone) |
|
941 return; |
|
942 |
|
943 TInt errorCode = KErrNone; |
|
944 TBTPowerStateValue currentPowerMode; |
|
945 errorCode=iBtEngSettings->GetPowerState(currentPowerMode); |
|
946 |
|
947 if(errorCode) |
|
948 { |
|
949 // handle the error code |
|
950 return; |
|
951 } |
|
952 if ( aNewWaitNote ) |
|
953 { |
|
954 // Launch wait note |
|
955 OpenWaitNoteL(iWaitForConnectDlg,R_BT_CONNECTING_TO_WAIT_NOTE,R_BT_CONNECTING_TO , |
|
956 ECmdShowBtWaitConnectingToNote,aDevice.iName); |
|
957 } |
|
958 iConnectDevice=new(ELeave) TBTDevice(aDevice); |
|
959 iConnectDevice->iOperation=EOpConnect; |
|
960 |
|
961 if( currentPowerMode == EBTPowerOff ) |
|
962 { |
|
963 // turn on the flag IsConnectDevice |
|
964 // |
|
965 iIsConnectDevice = ETrue; |
|
966 } |
|
967 else |
|
968 { |
|
969 // connect device |
|
970 // |
|
971 iModel->ChangeDevice(*iConnectDevice); |
|
972 |
|
973 // reset IsConnectDevice flag |
|
974 iIsConnectDevice = EFalse; |
|
975 } |
|
976 } |
|
977 TRACE_FUNC_EXIT |
|
978 } |
|
979 |
|
980 // ---------------------------------------------------------- |
|
981 // CBTUIPairedDevicesView::OpenWaitNoteL |
|
982 // ---------------------------------------------------------- |
|
983 void CBTUIPairedDevicesView::OpenWaitNoteL(CAknWaitDialog*& aWaitDialog,TUint aNoteResource,TUint aNoteTextResource, |
|
984 TSecondaryDisplayBtuiDialogs aSec,const TDesC& aDevName) |
|
985 { |
|
986 TRAPD(err, |
|
987 RBuf stringholder; |
|
988 CleanupClosePushL( stringholder ); |
|
989 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
990 stringholder, aNoteTextResource, aDevName, 0 ); |
|
991 aWaitDialog = new (ELeave) CAknWaitDialog( |
|
992 reinterpret_cast<CEikDialog**>(&aWaitDialog), ETrue); |
|
993 aWaitDialog->PrepareLC(aNoteResource); |
|
994 aWaitDialog->SetTextL(stringholder); |
|
995 |
|
996 if(iCoverDisplayEnabled) |
|
997 { |
|
998 aWaitDialog->PublishDialogL( |
|
999 aSec, KUidCoverUiCategoryBtui); // initializes cover support |
|
1000 CAknMediatorFacade* covercl = AknMediatorFacade(aWaitDialog); // uses MOP, so control provided |
|
1001 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1002 { |
|
1003 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevName);// takes copy so consts are ok too |
|
1004 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1005 } |
|
1006 } |
|
1007 aWaitDialog->SetCallback(this); // for capturing Cancel keypress |
|
1008 aWaitDialog->RunLD(); |
|
1009 |
|
1010 CleanupStack::PopAndDestroy(&stringholder); // stringholder |
|
1011 ); |
|
1012 // if the above functions leaves the iWaitNote is deleted, but |
|
1013 // not set to NULL. This will cause a problem, when |
|
1014 // the items may be deleted again, since it has to |
|
1015 // be a member variable, in order to be closed |
|
1016 // programmatically. |
|
1017 if(err!=KErrNone) |
|
1018 { |
|
1019 // that is why we set it to NULL here and |
|
1020 // continue leaving further. |
|
1021 aWaitDialog=NULL; |
|
1022 User::Leave(err); |
|
1023 } |
|
1024 } |
|
1025 |
|
1026 // ---------------------------------------------------------- |
|
1027 // CBTUIPairedDevicesView::LaunchSettingViewL |
|
1028 // ---------------------------------------------------------- |
|
1029 // |
|
1030 void CBTUIPairedDevicesView::LaunchSettingViewL() |
|
1031 { |
|
1032 TRACE_FUNC_ENTRY |
|
1033 |
|
1034 TInt index = iContainer->CurrentItemIndex(); |
|
1035 if(index == KErrNotFound) return; |
|
1036 TBTDevice device; |
|
1037 device.iIndex = index; |
|
1038 iModel->GetDevice(device); |
|
1039 |
|
1040 CAknView* settingView = iBTPluginMan->GetSettingViewL(device); |
|
1041 if(settingView != NULL) |
|
1042 { |
|
1043 TUid viewId = settingView->Id(); |
|
1044 if(( device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected ) |
|
1045 { |
|
1046 TBuf8<KMaxBCBluetoothNameLen> DeviceName; |
|
1047 DeviceName.Copy(device.iName); |
|
1048 AppUi()->ActivateLocalViewL( viewId, KNullUid, DeviceName); |
|
1049 } |
|
1050 else |
|
1051 { |
|
1052 AppUi()->ActivateLocalViewL( viewId ); |
|
1053 } |
|
1054 } |
|
1055 else |
|
1056 { |
|
1057 User::Leave(KErrNotFound); |
|
1058 } |
|
1059 |
|
1060 TRACE_FUNC_EXIT |
|
1061 } |
|
1062 |
|
1063 // ---------------------------------------------------------- |
|
1064 // CBTUIPairedDevicesView::DisconnectL |
|
1065 // ---------------------------------------------------------- |
|
1066 // |
|
1067 void CBTUIPairedDevicesView::DisconnectL() |
|
1068 { |
|
1069 TRACE_FUNC_ENTRY |
|
1070 |
|
1071 TInt index = iContainer->CurrentItemIndex(); |
|
1072 if(index == KErrNotFound) return; |
|
1073 |
|
1074 TBTDevice device; |
|
1075 device.iIndex = index; |
|
1076 iModel->GetDevice(device); |
|
1077 |
|
1078 if ( !( device.iStatus & EStatusBtuiConnected) ) |
|
1079 { |
|
1080 // If device is already disconnected, return immediately. |
|
1081 return; |
|
1082 } |
|
1083 |
|
1084 iDisconnectQueryDevice = device;//remember device related with query dialog |
|
1085 |
|
1086 // Create confirmation query |
|
1087 RBuf stringholder; |
|
1088 CleanupClosePushL( stringholder ); |
|
1089 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
1090 stringholder, R_BT_DISCONNECT_FROM, device.iName, 0 ); |
|
1091 if ( !iDisconnectQueryDlg ) |
|
1092 { |
|
1093 iDisconnectQueryDlg = CAknQueryDialog::NewL(); |
|
1094 } |
|
1095 |
|
1096 if(iCoverDisplayEnabled) |
|
1097 { |
|
1098 iDisconnectQueryDlg->PublishDialogL(ECmdShowDisconnectQuery, KUidCoverUiCategoryBtui); // initializes cover support |
|
1099 |
|
1100 CAknMediatorFacade* covercl = AknMediatorFacade(iDisconnectQueryDlg); // uses MOP, so control provided |
|
1101 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1102 { |
|
1103 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName);// takes copy so consts are ok too |
|
1104 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1105 } |
|
1106 } |
|
1107 |
|
1108 TInt keypress = iDisconnectQueryDlg->ExecuteLD(R_BT_DISCONNECT_FROM_QUERY, stringholder); |
|
1109 |
|
1110 CleanupStack::PopAndDestroy(&stringholder); // stringholder |
|
1111 |
|
1112 iDisconnectQueryDlg = NULL; |
|
1113 if(keypress) // User has accepted the dialog |
|
1114 { |
|
1115 device.iOperation = EOpDisconnect; |
|
1116 iModel->ChangeDevice(device); |
|
1117 } |
|
1118 TRACE_FUNC_EXIT |
|
1119 } |
|
1120 |
|
1121 // ---------------------------------------------------------- |
|
1122 // CBTUIPairedDevicesView::CancelDisconnectQueryDlgL |
|
1123 // ---------------------------------------------------------- |
|
1124 // |
|
1125 void CBTUIPairedDevicesView::CancelDisconnectQueryDlg() |
|
1126 { |
|
1127 TRACE_FUNC_ENTRY |
|
1128 |
|
1129 if(iDisconnectQueryDlg) |
|
1130 { |
|
1131 delete iDisconnectQueryDlg; |
|
1132 iDisconnectQueryDlg = NULL; |
|
1133 } |
|
1134 |
|
1135 TRACE_FUNC_EXIT |
|
1136 } |
|
1137 |
|
1138 // ---------------------------------------------------------- |
|
1139 // CBTUIPairedDevicesView::DisconnectWithoutQuery |
|
1140 // ---------------------------------------------------------- |
|
1141 // |
|
1142 void CBTUIPairedDevicesView::DisconnectWithoutQuery() |
|
1143 { |
|
1144 TRACE_FUNC_ENTRY |
|
1145 |
|
1146 TInt index = iContainer->CurrentItemIndex(); |
|
1147 if(index == KErrNotFound) return; |
|
1148 |
|
1149 TBTDevice device; |
|
1150 device.iIndex = index; |
|
1151 iModel->GetDevice(device); |
|
1152 device.iOperation = EOpDisconnect; |
|
1153 iModel->ChangeDevice(device); |
|
1154 } |
|
1155 // ---------------------------------------------------------- |
|
1156 // CBTUIPairedDevicesView::ConnectCompleteL |
|
1157 // ---------------------------------------------------------- |
|
1158 // |
|
1159 void CBTUIPairedDevicesView::ConnectCompleteL(TInt aError,const TBTDevice& aDevice, |
|
1160 const RBTDevNameArray* aConflictingDeviceNames) |
|
1161 { |
|
1162 TRACE_FUNC_ENTRY |
|
1163 |
|
1164 // Dismiss wait note |
|
1165 // |
|
1166 if(iConnectDevice) |
|
1167 { |
|
1168 delete iConnectDevice; |
|
1169 iConnectDevice=NULL; |
|
1170 } |
|
1171 |
|
1172 if ( iIsPairConnect ) |
|
1173 { |
|
1174 iIsPairConnect = EFalse; |
|
1175 if ( aError != KErrNone && |
|
1176 aError != KErrCancel && |
|
1177 aError != KErrNotSupported && |
|
1178 aError != KErrAlreadyExists && |
|
1179 aError != KErrServerBusy ) |
|
1180 { |
|
1181 // It is possible that we started connecting too soon before the |
|
1182 // device moves to conntable mode from pairing mode. Let's try |
|
1183 // once more: |
|
1184 if ( !iActive ) |
|
1185 { |
|
1186 iActive = CBTUIActive::NewL( |
|
1187 this, KAutoConnect2ndTry, CActive::EPriorityStandard ); |
|
1188 } |
|
1189 iActive->RequestStatus() = KRequestPending; |
|
1190 iActive->GoActive(); |
|
1191 TRequestStatus* stptr = &( iActive->RequestStatus() ); |
|
1192 User::RequestComplete( stptr, KErrNone ); |
|
1193 TRACE_INFO( _L("CBTUIPairedDevicesView, sceadule auto connect 2nd try") ) |
|
1194 return; |
|
1195 } |
|
1196 } |
|
1197 |
|
1198 if(iWaitForConnectDlg) |
|
1199 { |
|
1200 TRACE_INFO(_L("waiting dialog is active, dismiss it")) |
|
1201 iWaitForConnectDlg->ProcessFinishedL(); |
|
1202 } |
|
1203 |
|
1204 switch (aError) |
|
1205 { |
|
1206 case KErrCancel: |
|
1207 TRACE_INFO(_L("aError = KErrCancel")) |
|
1208 break; |
|
1209 case KErrAlreadyExists: // connection exists allready |
|
1210 { |
|
1211 RBuf stringholder; |
|
1212 CleanupClosePushL( stringholder ); |
|
1213 if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0) |
|
1214 { |
|
1215 if(aConflictingDeviceNames->Count() == 1) |
|
1216 { |
|
1217 BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, |
|
1218 R_BT_DISCONNECT_FIRST_PROMPT, |
|
1219 *(*aConflictingDeviceNames)[0], 0 ); |
|
1220 } |
|
1221 else |
|
1222 { |
|
1223 BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, |
|
1224 R_BT_DISCONNECT_FIRST_STEREO_PROMPT, |
|
1225 *(*aConflictingDeviceNames)[0], 0 ); |
|
1226 BluetoothUiUtil::AddSubstringL( stringholder, *(*aConflictingDeviceNames)[1], 1 ); |
|
1227 } |
|
1228 TRACE_INFO(_L("KErrAllreadyExists")) |
|
1229 } |
|
1230 else |
|
1231 { |
|
1232 // Showing a note in this case would always show a note with "%U" in it |
|
1233 // so the note is not shown at all |
|
1234 TRACE_INFO(_L("KErrAlreadyExists, but no device given, not showing a notification")) |
|
1235 CleanupStack::PopAndDestroy(&stringholder); |
|
1236 break; |
|
1237 } |
|
1238 |
|
1239 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
|
1240 |
|
1241 if(iCoverDisplayEnabled) |
|
1242 { |
|
1243 CleanupStack::PushL(note); |
|
1244 note->PublishDialogL(ECmdShowBtDisconnectFirstNote, KUidCoverUiCategoryBtui); // initializes cover support |
|
1245 CleanupStack::Pop(note); |
|
1246 |
|
1247 CAknMediatorFacade* covercl = AknMediatorFacade(note); // uses MOP, so control provided |
|
1248 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1249 { |
|
1250 if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0) |
|
1251 { |
|
1252 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(*(*aConflictingDeviceNames)[0]); |
|
1253 } |
|
1254 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1255 } |
|
1256 } |
|
1257 |
|
1258 note->ExecuteLD(stringholder); |
|
1259 CleanupStack::PopAndDestroy(&stringholder); |
|
1260 } |
|
1261 break; |
|
1262 case KErrServerBusy: |
|
1263 { |
|
1264 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( |
|
1265 CAknNoteDialog::ENoTone,CAknNoteDialog::ELongTimeout); |
|
1266 if(iCoverDisplayEnabled) |
|
1267 { |
|
1268 CleanupStack::PushL(dlg); |
|
1269 dlg->PublishDialogL(ECmdBtuiShowBtBusyNote, KUidCoverUiCategoryBtui); // initializes cover support |
|
1270 CleanupStack::Pop(dlg); |
|
1271 } |
|
1272 |
|
1273 dlg->ExecuteLD(R_BT_BUSY); |
|
1274 } |
|
1275 break; |
|
1276 case KErrNone: |
|
1277 { |
|
1278 |
|
1279 TRACE_INFO(_L("aError = KErrNone")) |
|
1280 // Create note |
|
1281 // |
|
1282 CAknInformationNote* notePtr = new (ELeave) CAknInformationNote(); |
|
1283 |
|
1284 RBuf stringHolder; |
|
1285 CleanupClosePushL( stringHolder ); |
|
1286 |
|
1287 BluetoothUiUtil::LoadResourceAndSubstringL( stringHolder, |
|
1288 R_BT_CONF_CONNECTED_PROMPT, aDevice.iName, 0 ); |
|
1289 |
|
1290 if(iCoverDisplayEnabled) |
|
1291 { |
|
1292 CleanupStack::PushL(notePtr); |
|
1293 notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support |
|
1294 CleanupStack::Pop(notePtr); |
|
1295 |
|
1296 CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided |
|
1297 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1298 { |
|
1299 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); |
|
1300 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1301 } |
|
1302 } |
|
1303 |
|
1304 notePtr->ExecuteLD(stringHolder); |
|
1305 CleanupStack::PopAndDestroy(&stringHolder); |
|
1306 } |
|
1307 |
|
1308 TRAP_IGNORE(LaunchSettingViewL();) |
|
1309 break; |
|
1310 |
|
1311 case KErrNotSupported: |
|
1312 { |
|
1313 TRACE_INFO(_L("error = KErrNotSupported")) |
|
1314 |
|
1315 RBuf stringHolder; |
|
1316 CleanupClosePushL( stringHolder ); |
|
1317 |
|
1318 BluetoothUiUtil::LoadResourceAndSubstringL( stringHolder, |
|
1319 R_BT_DEVICE_NOT_SUPPORTED, aDevice.iName, 0 ); |
|
1320 |
|
1321 // create note |
|
1322 // |
|
1323 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
|
1324 |
|
1325 if(iCoverDisplayEnabled) |
|
1326 { |
|
1327 CleanupStack::PushL(note); |
|
1328 note->PublishDialogL(ECmdBtuiShowBtDeviceNotSupported, KUidCoverUiCategoryBtui); // initializes cover support |
|
1329 CleanupStack::Pop(note); |
|
1330 |
|
1331 CAknMediatorFacade* covercl = AknMediatorFacade(note); // uses MOP, so control provided |
|
1332 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1333 { |
|
1334 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); |
|
1335 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1336 } |
|
1337 } |
|
1338 note->ExecuteLD(stringHolder); |
|
1339 CleanupStack::PopAndDestroy(&stringHolder); |
|
1340 } |
|
1341 break; |
|
1342 |
|
1343 default: |
|
1344 { |
|
1345 // Create note |
|
1346 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
|
1347 HBufC* stringHolder=StringLoader::LoadLC(R_BT_DEVICE_NOT_AVAIL_NOTE ); |
|
1348 |
|
1349 if(iCoverDisplayEnabled) |
|
1350 { |
|
1351 CleanupStack::PushL(note); |
|
1352 note->PublishDialogL(ECmdBtuiShowBtDeviceNotAvail, KUidCoverUiCategoryBtui); // initializes cover support |
|
1353 CleanupStack::Pop(note); |
|
1354 |
|
1355 } |
|
1356 |
|
1357 note->ExecuteLD(*stringHolder); |
|
1358 CleanupStack::PopAndDestroy(stringHolder); |
|
1359 TRACE_INFO(_L("default error note BT-not-available")) |
|
1360 } |
|
1361 break; |
|
1362 } |
|
1363 TRACE_FUNC_EXIT |
|
1364 } |
|
1365 |
|
1366 // ------------------------------------------------------ |
|
1367 // CBTUIPairedDevicesView::LaunchHelp |
|
1368 // static help launching function for TCallback |
|
1369 // ------------------------------------------------------ |
|
1370 TInt CBTUIPairedDevicesView::LaunchHelp(TAny* aCoeHelpContext) |
|
1371 { |
|
1372 #ifdef __SERIES60_HELP |
|
1373 //TRACE_FUNC_ENTRY |
|
1374 TCoeHelpContext hc; |
|
1375 |
|
1376 if(aCoeHelpContext==NULL) |
|
1377 hc = TCoeHelpContext(KBtuiUid3,KBT_HLP_BLOCKED); |
|
1378 else |
|
1379 hc = *static_cast<TCoeHelpContext*>(aCoeHelpContext); |
|
1380 TRAPD(err, |
|
1381 CArrayFix< TCoeHelpContext >* array=new (ELeave) CArrayFixFlat< TCoeHelpContext >(1); |
|
1382 array->AppendL(hc); |
|
1383 CleanupStack::PushL(array); |
|
1384 // codescan will complain about CCoeEnv::Static(), however it is not reasonable |
|
1385 // avoidable, since this is static funtion. |
|
1386 HlpLauncher::LaunchHelpApplicationL(CCoeEnv::Static()->WsSession() , array); |
|
1387 CleanupStack::Pop(array); |
|
1388 ); |
|
1389 |
|
1390 // the array is not deleted, since deleting it will result |
|
1391 // to E32User-CBase 3. It is assumed that HlpLancher is taking care of it. |
|
1392 // however this has not been documented. |
|
1393 //TRACE_FUNC_EXIT |
|
1394 return err; |
|
1395 #else |
|
1396 return KErrNone; |
|
1397 #endif |
|
1398 } |
|
1399 |
|
1400 // ------------------------------------------------------ |
|
1401 // CBTUIPairedDevicesView::CallOnGoing |
|
1402 // ------------------------------------------------------ |
|
1403 TBool CBTUIPairedDevicesView::CallOnGoing() |
|
1404 { |
|
1405 TRACE_FUNC_ENTRY |
|
1406 TInt callState; |
|
1407 // Try to get the call state property |
|
1408 |
|
1409 TInt err = RProperty::Get(KPSUidCtsyCallInformation, |
|
1410 KCTsyCallState, callState); //KPSUidTelephonyCallInformation should be used // Check also,if retrieving the property value succeeded |
|
1411 return (err == KErrNone) ? |
|
1412 (callState != EPSCTsyCallStateNone && |
|
1413 callState != EPSCTsyCallStateUninitialized) : |
|
1414 EFalse; |
|
1415 } |
|
1416 // ---------------------------------------------------------- |
|
1417 // From MProgressDialogCallback |
|
1418 // CBTUIPairedDevicesView::DialogDismissedL |
|
1419 // |
|
1420 // Cancels pairing/connection operation if user has pressed Cancel softkey. |
|
1421 // Does nothing if the dialog has been dismissed by this program. |
|
1422 // ---------------------------------------------------------- |
|
1423 // |
|
1424 void CBTUIPairedDevicesView::DialogDismissedL(TInt aButtonId ) |
|
1425 { |
|
1426 TRACE_FUNC_ENTRY |
|
1427 |
|
1428 // it was not canceled, but dialog was closed |
|
1429 // because it ended normally, so there is nothing to clean up. |
|
1430 if( aButtonId != EAknSoftkeyCancel ) |
|
1431 return; |
|
1432 |
|
1433 // Cancel ongoing operations if any |
|
1434 // |
|
1435 if ( iWaitForConnectDlg) |
|
1436 { |
|
1437 if( iConnectDevice ) |
|
1438 { |
|
1439 iModel->CancelChange(*iConnectDevice); |
|
1440 delete iConnectDevice; |
|
1441 iConnectDevice=NULL; |
|
1442 iIsPairConnect = EFalse; |
|
1443 } |
|
1444 iWaitForConnectDlg = NULL; |
|
1445 } |
|
1446 if ( iWaitForPairingDlg ) |
|
1447 { |
|
1448 if( iPairingDevice ) |
|
1449 { |
|
1450 TBTDevice device; |
|
1451 device.iAddr = iPairingDevice->BDAddr(); |
|
1452 device.iOperation = EOpPair; |
|
1453 |
|
1454 iDeviceSearcher->CancelSearchRemoteDevice(); |
|
1455 |
|
1456 iModel->CancelChange(device); |
|
1457 |
|
1458 delete iPairingDevice; |
|
1459 iPairingDevice=NULL; |
|
1460 } |
|
1461 // The dialog has already been deleted by UI framework and |
|
1462 // must not be deleted manually. |
|
1463 iWaitForPairingDlg = NULL; |
|
1464 } |
|
1465 |
|
1466 TRACE_FUNC_EXIT |
|
1467 } |
|
1468 // ------------------------------------------------------ |
|
1469 // From MBTEngSdpResultReceiver |
|
1470 // CBTUIPairedDevicesView::ServiceSearchComplete |
|
1471 // not used and implemented as empty |
|
1472 // ------------------------------------------------------ |
|
1473 void CBTUIPairedDevicesView::ServiceSearchComplete(const RSdpRecHandleArray& , TUint , TInt) |
|
1474 { |
|
1475 TRACE_FUNC_ENTRY |
|
1476 } |
|
1477 // ------------------------------------------------------ |
|
1478 // From MBTEngSdpResultReceiver |
|
1479 // CBTUIPairedDevicesView::AttributeSearchComplete |
|
1480 // not used and implemented as empty |
|
1481 // ------------------------------------------------------ |
|
1482 void CBTUIPairedDevicesView::AttributeSearchComplete(TSdpServRecordHandle, |
|
1483 const RSdpResultArray& ,TInt) |
|
1484 { |
|
1485 TRACE_FUNC_ENTRY |
|
1486 } |
|
1487 // ------------------------------------------------------ |
|
1488 // From MBTEngSdpResultReceiver |
|
1489 // CBTUIPairedDevicesView::AttributeSearchComplete |
|
1490 // not used and implemented as empty |
|
1491 // ------------------------------------------------------ |
|
1492 void CBTUIPairedDevicesView::ServiceAttributeSearchComplete(TSdpServRecordHandle , |
|
1493 const RSdpResultArray& ,TInt ) |
|
1494 { |
|
1495 TRACE_FUNC_ENTRY |
|
1496 } |
|
1497 // ------------------------------------------------------ |
|
1498 // From MBTEngSdpResultReceiver |
|
1499 // CBTUIPairedDevicesView::DeviceSearchComplete |
|
1500 // ------------------------------------------------------ |
|
1501 void CBTUIPairedDevicesView::DeviceSearchComplete(CBTDevice* aDevice, TInt aErr) |
|
1502 { |
|
1503 TRACE_FUNC_ENTRY |
|
1504 |
|
1505 TRAPD(err, DeviceSearchCompleteL(aDevice, NULL, aErr); |
|
1506 ); |
|
1507 // something went wrong. |
|
1508 if(err != KErrNone) |
|
1509 { |
|
1510 TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); |
|
1511 } |
|
1512 iSearchOngoing=EFalse; |
|
1513 TRACE_FUNC_EXIT |
|
1514 } |
|
1515 |
|
1516 // ------------------------------------------------------ |
|
1517 // From MBTEngSdpResultReceiver |
|
1518 // CBTUIPairedDevicesView::DeviceSearchComplete |
|
1519 // ------------------------------------------------------ |
|
1520 void CBTUIPairedDevicesView::DeviceSearchComplete( CBTDevice* aDevice, |
|
1521 TNameEntry* aNameEntry, TInt aErr ) |
|
1522 { |
|
1523 TRACE_FUNC_ENTRY |
|
1524 |
|
1525 TRAPD(err, DeviceSearchCompleteL(aDevice, aNameEntry, aErr); |
|
1526 ); |
|
1527 // something went wrong. |
|
1528 if(err != KErrNone) |
|
1529 { |
|
1530 TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); |
|
1531 } |
|
1532 iSearchOngoing=EFalse; |
|
1533 TRACE_FUNC_EXIT |
|
1534 } |
|
1535 |
|
1536 // ------------------------------------------------------ |
|
1537 // CBTUIPairedDevicesView::DeviceSearchCompleteL |
|
1538 // Leaving version of DeviceSearchComplete |
|
1539 // ------------------------------------------------------ |
|
1540 |
|
1541 void CBTUIPairedDevicesView::DeviceSearchCompleteL(CBTDevice* aDevice, |
|
1542 TNameEntry* aNameEntry, TInt aErr) |
|
1543 { |
|
1544 TRACE_FUNC_ENTRY |
|
1545 iSearchOngoing=EFalse; |
|
1546 if ( !iPairingDevice ) |
|
1547 { |
|
1548 delete iModel; |
|
1549 iModel = NULL; |
|
1550 return; |
|
1551 } |
|
1552 // we must not have multiple pairings at the same time |
|
1553 __ASSERT_DEBUG(aDevice->BDAddr() == iPairingDevice->BDAddr(), |
|
1554 PANIC(EBTPanicTwoPairingAttemptsAtTheSameTime) ); |
|
1555 |
|
1556 // other error condition, most likely dialog cancel. |
|
1557 if(aErr != KErrNone && (aErr != KErrAlreadyExists)) |
|
1558 { |
|
1559 delete iPairingDevice; |
|
1560 iPairingDevice=NULL; |
|
1561 return; |
|
1562 } |
|
1563 |
|
1564 // In case user switches the view fast enough before searching starts, |
|
1565 // It crashes the whole btui by iModel is null value. |
|
1566 // We add an extra check here |
|
1567 // |
|
1568 if ( !iModel ) |
|
1569 { |
|
1570 delete iPairingDevice; |
|
1571 iPairingDevice=NULL; |
|
1572 return; |
|
1573 } |
|
1574 |
|
1575 TBTDevice *tmpDevice=iModel->CreateDeviceL(aDevice, aNameEntry); |
|
1576 CleanupStack::PushL(tmpDevice); |
|
1577 if(tmpDevice->iStatus & (EStatusPhysicallyConnected|EStatusBtuiConnected|EStatusPaired)) |
|
1578 { |
|
1579 ShowDisconnecNoteL(tmpDevice); |
|
1580 CleanupStack::PopAndDestroy(tmpDevice); |
|
1581 delete iPairingDevice; |
|
1582 iPairingDevice=NULL; |
|
1583 return; |
|
1584 } |
|
1585 else |
|
1586 { |
|
1587 // Launch wait note |
|
1588 OpenWaitNoteL(iWaitForPairingDlg,R_BT_WAITING,R_BT_WAITING_PROMPT, |
|
1589 ECmdShowBtWaitingNote,tmpDevice->iName); |
|
1590 |
|
1591 CleanupStack::PopAndDestroy(tmpDevice); |
|
1592 tmpDevice=NULL; |
|
1593 // and start the pairing |
|
1594 iModel->ChangeDevice(aDevice, aNameEntry, EOpPair); |
|
1595 // aDevice is not deleted, since it points to iPairingDevice and it is still used |
|
1596 // after this |
|
1597 } |
|
1598 TRACE_FUNC_EXIT |
|
1599 } |
|
1600 |
|
1601 |
|
1602 // ------------------------------------------------------ |
|
1603 // CBTUIPairedDevicesView::ShowDisconnecNote |
|
1604 // ------------------------------------------------------ |
|
1605 void CBTUIPairedDevicesView::ShowDisconnecNoteL(TBTDevice *aDevice) |
|
1606 { |
|
1607 RBuf stringholder; |
|
1608 CleanupClosePushL( stringholder ); |
|
1609 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
1610 stringholder, R_BT_DISCONNECT_FIRST_PROMPT, aDevice->iName, 0 ); |
|
1611 // Launch a waiting confirmation note |
|
1612 // |
|
1613 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote(ETrue); |
|
1614 |
|
1615 if(iCoverDisplayEnabled) |
|
1616 { |
|
1617 CleanupStack::PushL(note); |
|
1618 note->PublishDialogL(ECmdShowBtSuccesfullyPairedNote, |
|
1619 KUidCoverUiCategoryBtui); // initializes cover support |
|
1620 CAknMediatorFacade* covercl = AknMediatorFacade(note); // uses MOP, so control provided |
|
1621 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1622 { |
|
1623 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice->iName);// takes copy so consts are ok too |
|
1624 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1625 } |
|
1626 CleanupStack::Pop(note); |
|
1627 } |
|
1628 |
|
1629 note->ExecuteLD(stringholder); |
|
1630 |
|
1631 CleanupStack::PopAndDestroy(&stringholder); // stringholder |
|
1632 |
|
1633 } |
|
1634 |
|
1635 void CBTUIPairedDevicesView::ConnectIfNeededAfterPairL( TInt aCount ) |
|
1636 { |
|
1637 TRACE_FUNC_ENTRY |
|
1638 TBTDevice device; |
|
1639 device.iAddr = iPairConnectAddr; |
|
1640 iModel->GetDevice(device); |
|
1641 device.iOperation = EOpConnect; |
|
1642 ConnectL( device, ( aCount ) ? EFalse : ETrue ); |
|
1643 TRACE_FUNC_EXIT |
|
1644 } |
|
1645 |
|
1646 // ------------------------------------------------------ |
|
1647 // CBTUIPairedDevicesView::BondingCompleted |
|
1648 // called by NotifyChangeDeviceComplete |
|
1649 // ------------------------------------------------------ |
|
1650 void CBTUIPairedDevicesView::BondingCompleteL(TInt aError, const TBTDevice& aDevice) |
|
1651 { |
|
1652 TRACE_INFO((_L("aError=%d"), aError)) |
|
1653 // We need to make a copy of the device, since it may be cleaned up |
|
1654 // by device refresh. |
|
1655 TBTDevice bDevice= aDevice; |
|
1656 |
|
1657 // this may look useless, however if the device has a given shortName it is listed with it |
|
1658 // all the time. If you omnit this line it will be shown with its original deviceName, |
|
1659 // dispite it will be listed with the given name |
|
1660 iModel->GetDevice(bDevice); |
|
1661 |
|
1662 delete iPairingDevice; |
|
1663 iPairingDevice=NULL; |
|
1664 |
|
1665 // Dismiss wait note |
|
1666 if(iWaitForPairingDlg) |
|
1667 { |
|
1668 iWaitForPairingDlg->ProcessFinishedL(); |
|
1669 iWaitForPairingDlg = NULL; |
|
1670 } |
|
1671 |
|
1672 // Error handling |
|
1673 switch(aError) |
|
1674 { |
|
1675 case KErrCancel: |
|
1676 break; |
|
1677 case KErrAlreadyExists: // This is a legal return value |
|
1678 case KErrNone: |
|
1679 case KHCIErrorBase: |
|
1680 { |
|
1681 if( (bDevice.iStatus & EStatusConnectable) |
|
1682 && (bDevice.iDeviceClass.MajorDeviceClass() != EMajorDeviceComputer)) |
|
1683 // Only automatically query for a connectable device but not a computer |
|
1684 { |
|
1685 iPairConnectAddr = aDevice.iAddr; |
|
1686 iIsPairConnect = ETrue; |
|
1687 ConnectIfNeededAfterPairL( 0 ); |
|
1688 } |
|
1689 break; |
|
1690 } |
|
1691 default: |
|
1692 { |
|
1693 break; |
|
1694 } |
|
1695 } |
|
1696 TRACE_FUNC_EXIT |
|
1697 } |
|
1698 |
|
1699 // ----------------------------------------------- |
|
1700 // From MBTDeviceObserver |
|
1701 // CBTUIPairedDevicesView::RefreshDeviceList |
|
1702 // calls the container to refresh the deviceList |
|
1703 // ----------------------------------------------- |
|
1704 void CBTUIPairedDevicesView::RefreshDeviceList(const RDeviceArray* aDevices, |
|
1705 TInt aSelectedItemIndex) |
|
1706 { |
|
1707 TRACE_FUNC_ENTRY |
|
1708 TRAPD(err, |
|
1709 if(iContainer) |
|
1710 { |
|
1711 iContainer->RefreshDeviceListL(aDevices,aSelectedItemIndex); |
|
1712 } |
|
1713 ); |
|
1714 if (iActiveMenuPane && iActiveMenuPane->NumberOfItemsInPane()>0 ) |
|
1715 { |
|
1716 TInt index = iContainer->CurrentItemIndex(); |
|
1717 if ( index >=0 ) |
|
1718 { |
|
1719 TBTDevice device; |
|
1720 device.iIndex = index; |
|
1721 iModel->GetDevice(device); |
|
1722 if ( iMenuDevice.iAddr == device.iAddr && |
|
1723 ( ( iMenuDevice.iStatus & EStatusBtuiConnected ) != ( device.iStatus & EStatusBtuiConnected ) ) ) |
|
1724 { |
|
1725 TRACE_INFO(_L("Device status changed, update menupane")); |
|
1726 iMenuDevice = device; |
|
1727 iActiveMenuPane->Close(); |
|
1728 TRAP_IGNORE( this->ProcessCommandL(EAknSoftkeyContextOptions) ); |
|
1729 } |
|
1730 } |
|
1731 } |
|
1732 if(err!= KErrNone) |
|
1733 { |
|
1734 TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); |
|
1735 } |
|
1736 TRACE_FUNC_EXIT |
|
1737 } |
|
1738 |
|
1739 |
|
1740 // ----------------------------------------------- |
|
1741 // |
|
1742 // ----------------------------------------------- |
|
1743 void CBTUIPairedDevicesView::RequestCompletedL( CBTUIActive* aActive, TInt aId, |
|
1744 TInt aStatus ) |
|
1745 { |
|
1746 TRACE_INFO( ( _L("CBTUIPairedDevicesView::RequestCompletedL err %d"), aStatus ) ) |
|
1747 (void) aActive; |
|
1748 (void) aId; |
|
1749 (void) aStatus; |
|
1750 TRACE_INFO( _L("CBTUIPairedDevicesView, auto connect 2nd try ... ") ) |
|
1751 ConnectIfNeededAfterPairL( 1 ); |
|
1752 } |
|
1753 |
|
1754 // ----------------------------------------------- |
|
1755 // |
|
1756 // ----------------------------------------------- |
|
1757 void CBTUIPairedDevicesView::HandleError( CBTUIActive* aActive, TInt aId, |
|
1758 TInt aError ) |
|
1759 { |
|
1760 (void) aActive; |
|
1761 (void) aId; |
|
1762 (void) aError; |
|
1763 iIsPairConnect = EFalse; |
|
1764 } |
|
1765 |
|
1766 // --------------------------------------------------------- |
|
1767 // From MBTDeviceObserver |
|
1768 // CBTUIPairedDevicesView::NotifyChangeDeviceComplete |
|
1769 // This function implement the functionality of command complete. |
|
1770 // The lists of shown devices are refreshed by RefreshDeviceList, |
|
1771 // not by this function |
|
1772 // --------------------------------------------------------- |
|
1773 // |
|
1774 void CBTUIPairedDevicesView::NotifyChangeDeviceComplete(const TInt aErr, |
|
1775 const TBTDevice& aDevice, const RBTDevNameArray* aDevNameArray) |
|
1776 { |
|
1777 TRACE_FUNC_ENTRY |
|
1778 TBTDevice tmpDevice=aDevice; |
|
1779 TRAPD(err,NotifyChangeDeviceCompleteL(aErr,tmpDevice,aDevNameArray |
|
1780 );); |
|
1781 if(err!= KErrNone) |
|
1782 { |
|
1783 TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); |
|
1784 } |
|
1785 TRACE_FUNC_EXIT |
|
1786 } |
|
1787 // --------------------------------------------------------- |
|
1788 // CBTUIPairedDevicesView::NotifyChangeDeviceCompleteL |
|
1789 // Leaving version of notifyChangeDevice |
|
1790 // --------------------------------------------------------- |
|
1791 |
|
1792 void CBTUIPairedDevicesView::NotifyChangeDeviceCompleteL(const TInt aErr, |
|
1793 const TBTDevice& aDevice, const RBTDevNameArray* aDevNameArray) |
|
1794 { |
|
1795 TRACE_FUNC_ENTRY |
|
1796 if(iContainer == NULL) return; |
|
1797 |
|
1798 TRACE_INFO((_L("aErr=%d"), aErr)) |
|
1799 TRACE_INFO((_L("aDevice.iOperation=%d"), aDevice.iOperation)) |
|
1800 TRACE_INFO((_L("aDevice.iStatus=%d"), aDevice.iStatus)) |
|
1801 TRACE_INFO((_L("iIsAlreadyConnected=%d"), iIsAlreadyConnected)) |
|
1802 |
|
1803 if (aDevice.iOperation == EOpDisconnect && iExpectedCallBack>0 ) |
|
1804 { |
|
1805 TBTDevice device; |
|
1806 device.iIndex = aDevice.iIndex; |
|
1807 iModel->GetDevice(device); |
|
1808 device.iOperation = EOpUnpair; |
|
1809 iModel->ChangeDevice(device); |
|
1810 iExpectedCallBack--; |
|
1811 } |
|
1812 |
|
1813 if( aDevice.iOperation == EOpConnect ) |
|
1814 { |
|
1815 if( aErr == KErrNone && iIsAlreadyConnected ) |
|
1816 { |
|
1817 TRACE_INFO(_L("Don't show notes several times for the same device with different profile connections")) |
|
1818 return; |
|
1819 } |
|
1820 ConnectCompleteL(aErr, aDevice, aDevNameArray ); |
|
1821 iIsAlreadyConnected = ETrue; |
|
1822 TRACE_INFO(_L("iIsAlreadyConnected False -> True")) |
|
1823 return; |
|
1824 } |
|
1825 if(aDevice.iOperation == EOpPair) |
|
1826 { |
|
1827 BondingCompleteL(aErr, aDevice); |
|
1828 } |
|
1829 if(aErr != KErrNone) |
|
1830 { |
|
1831 // The user tried to rename to a name that allready exists. |
|
1832 if(aDevice.iOperation == EOpChangeName && aErr == KErrAlreadyExists) |
|
1833 { |
|
1834 CAknNoteDialog* dlg2 = new (ELeave) CAknNoteDialog(CAknNoteDialog::EErrorTone, |
|
1835 CAknNoteDialog::ELongTimeout); |
|
1836 dlg2->ExecuteLD(R_BT_NAME_EXISTS_NOTE); |
|
1837 |
|
1838 RenameDeviceDlgL(); |
|
1839 return; |
|
1840 } |
|
1841 // Need to properly handle situation when "Disconnect from xxx" query |
|
1842 // has been shown and paired device has been turned off simultaneously. |
|
1843 // CancelDisconnectQuery dialog need to be closed. |
|
1844 if(aErr == KErrDisconnected) |
|
1845 { |
|
1846 if(iDisconnectQueryDlg && aDevice.iAddr == iDisconnectQueryDevice.iAddr) |
|
1847 CancelDisconnectQueryDlg(); |
|
1848 |
|
1849 TRACE_FUNC_EXIT |
|
1850 return; |
|
1851 } |
|
1852 // show general error if any of these failed |
|
1853 if( aDevice.iOperation== EOpTrust || |
|
1854 aDevice.iOperation== EOpUntrust || |
|
1855 aDevice.iOperation== EOpBlock || |
|
1856 aDevice.iOperation== EOpChangeName) |
|
1857 { |
|
1858 TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); |
|
1859 } |
|
1860 return; |
|
1861 } |
|
1862 |
|
1863 if(aDevice.iOperation == EOpUntrust) |
|
1864 { |
|
1865 // Unauthorise ok note, |
|
1866 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog(CAknNoteDialog::EConfirmationTone, |
|
1867 CAknNoteDialog::ELongTimeout); |
|
1868 |
|
1869 if(iCoverDisplayEnabled) |
|
1870 { |
|
1871 CleanupStack::PushL(dlg); |
|
1872 dlg->PublishDialogL(ECmdShowBtDevSetAsUntrustNote, KUidCoverUiCategoryBtui); |
|
1873 // initializes cover support |
|
1874 CleanupStack::Pop(dlg); |
|
1875 } |
|
1876 dlg->ExecuteLD( R_BT_DEVICE_UNTRUSTED_NOTE ); |
|
1877 } |
|
1878 TRACE_FUNC_EXIT |
|
1879 } |
|
1880 |
|
1881 // --------------------------------------------------------------------------- |
|
1882 // CBTUIPairedDevicesView::CreateTabIconL() |
|
1883 // Creates icon for tab. |
|
1884 // --------------------------------------------------------------------------- |
|
1885 // |
|
1886 CGulIcon* CBTUIPairedDevicesView::CreateTabIconL() |
|
1887 { |
|
1888 TFileName bmpFilename; |
|
1889 bmpFilename += KBitmapFileDrive; |
|
1890 bmpFilename += KDC_APP_BITMAP_DIR; |
|
1891 bmpFilename += KBtuiBmpFileName; |
|
1892 |
|
1893 CGulIcon* icon = AknsUtils::CreateGulIconL( |
|
1894 AknsUtils::SkinInstance(), |
|
1895 KAknsIIDQgnPropBtDevicesTab3, |
|
1896 bmpFilename, |
|
1897 EMbmBtuiQgn_prop_bt_devices_tab3, |
|
1898 EMbmBtuiQgn_prop_bt_devices_tab3_mask ); |
|
1899 |
|
1900 return icon; |
|
1901 } |
|
1902 |
|
1903 // End of File |
|
1904 |
|