1 /* |
|
2 * Copyright (c) 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 #include <AknGlobalNote.h> |
|
25 #include <aknmessagequerydialog.h> |
|
26 #include <aknnotewrappers.h> |
|
27 #include <StringLoader.h> // Series 60 localisation stringloader |
|
28 #include <aknnavi.h> |
|
29 #include <hlplch.h> // Help launcher |
|
30 #include <SecondaryDisplay/BtuiSecondaryDisplayAPI.h> |
|
31 |
|
32 #include "BTUIBlockedDevicesView.h" |
|
33 #include "BTUIDeviceContainer.h" |
|
34 #include "debug.h" |
|
35 #include "btui.h" |
|
36 |
|
37 #include <gstabhelper.h> |
|
38 #include <btui.mbg> // Tab icon for General Setting |
|
39 #include <bluetoothuiutil.h> |
|
40 #include "BTUIMainView.h" // base View. |
|
41 |
|
42 // --------------------------------------------------------- |
|
43 // CBTUIBlockedDevicesView::ConstructL |
|
44 // Symbian 2nd phase constructor can leave. |
|
45 // --------------------------------------------------------- |
|
46 // |
|
47 void CBTUIBlockedDevicesView::ConstructL() |
|
48 { |
|
49 TRACE_FUNC_ENTRY |
|
50 |
|
51 BaseConstructL(R_BTUI_BLOCK_DEVICES_VIEW); |
|
52 |
|
53 TRACE_FUNC_EXIT |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------- |
|
57 // CBTUIBlockedDevicesView::ConstructL |
|
58 // Symbian 2nd phase constructor when served as GS plugin. |
|
59 // --------------------------------------------------------- |
|
60 // |
|
61 void CBTUIBlockedDevicesView::ConstructL( CBTUIMainView* aBaseView, CArrayPtrFlat<MGSTabbedView>* aTabViewArray ) |
|
62 { |
|
63 iBaseView = aBaseView, |
|
64 iTabHelper = CGSTabHelper::NewL(); |
|
65 aTabViewArray->AppendL(this); |
|
66 |
|
67 BaseConstructL(R_BTUI_BLOCK_DEVICES_VIEW_GS); |
|
68 |
|
69 TRACE_INFO(_L("CBtuiGSPlugin* aBaseView, CArrayPtrFlat<MGSTabbedView>* aTabViewArray")) |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // CBTUIBlockedDevicesView::NewL |
|
74 // Two phased constructor |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 CBTUIBlockedDevicesView* CBTUIBlockedDevicesView::NewL(MBtuiPluginViewActivationObserver* aObserver) |
|
78 { |
|
79 //TRACE_FUNC_ENTRY |
|
80 CBTUIBlockedDevicesView* self = new (ELeave) CBTUIBlockedDevicesView(aObserver); |
|
81 CleanupStack::PushL(self); |
|
82 self->iConstructAsGsPlugin = EFalse; |
|
83 self->ConstructL(); |
|
84 CleanupStack::Pop(self); |
|
85 |
|
86 return self; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------- |
|
90 // CBTUIBlockedDevicesView::NewL |
|
91 // Two phased constructor |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 CBTUIBlockedDevicesView* CBTUIBlockedDevicesView::NewLC(CBTUIMainView* aBaseView, CArrayPtrFlat<MGSTabbedView>* aTabViewArray) |
|
95 { |
|
96 CBTUIBlockedDevicesView* self = new (ELeave) CBTUIBlockedDevicesView(); |
|
97 CleanupStack::PushL( self ); |
|
98 |
|
99 self->iConstructAsGsPlugin = ETrue; |
|
100 self->ConstructL( aBaseView, aTabViewArray ); |
|
101 |
|
102 return self; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------- |
|
106 // CBTUIBlockedDevicesView::CBTUIBlockedDevicesView |
|
107 // --------------------------------------------------------- |
|
108 |
|
109 CBTUIBlockedDevicesView::CBTUIBlockedDevicesView(MBtuiPluginViewActivationObserver* aObserver ) |
|
110 :iActivationObserver(aObserver) |
|
111 { |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------- |
|
115 // Destructor |
|
116 // --------------------------------------------------------- |
|
117 // |
|
118 CBTUIBlockedDevicesView::~CBTUIBlockedDevicesView() |
|
119 { |
|
120 TRACE_FUNC_ENTRY |
|
121 if (iContainer) |
|
122 { |
|
123 AppUi()->RemoveFromViewStack(*this, iContainer); |
|
124 } |
|
125 |
|
126 delete iContainer; |
|
127 delete iModel; |
|
128 |
|
129 if(iConstructAsGsPlugin) |
|
130 delete iTabHelper; |
|
131 |
|
132 TRACE_FUNC_EXIT |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------- |
|
136 // From CAknView |
|
137 // CBTUIBlockedDevicesView::Id |
|
138 // --------------------------------------------------------- |
|
139 // |
|
140 TUid CBTUIBlockedDevicesView::Id() const |
|
141 { |
|
142 TRACE_FUNC_ENTRY |
|
143 return KBtuiPluginUidBlockedDevicesView;//KBTBlockDevicesViewId; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------- |
|
147 // From CAknView |
|
148 // CBTUIBlockedDevicesView::HandleCommandL |
|
149 // --------------------------------------------------------- |
|
150 // |
|
151 void CBTUIBlockedDevicesView::HandleCommandL(TInt aCommand) |
|
152 { |
|
153 TRACE_FUNC_ENTRY |
|
154 TInt bItemIndex; |
|
155 switch (aCommand) |
|
156 { |
|
157 case EAknSoftkeyBack: |
|
158 // do not exit if devicechange is in progress. |
|
159 if(iModel->DeviceChangeInProgress() ) |
|
160 return; |
|
161 AppUi()->ActivateLocalViewL(iBaseView->GetParentView().iViewUid ); |
|
162 break; |
|
163 |
|
164 case EAknSoftkeyExit: |
|
165 // do not exit if devicechange is in progress. |
|
166 if(iModel->DeviceChangeInProgress() ) |
|
167 return; |
|
168 AppUi()->ProcessCommandL(EEikCmdExit); |
|
169 break; |
|
170 |
|
171 case EBTUICmdDelete: |
|
172 case EBTUICmdUnblock: |
|
173 { |
|
174 |
|
175 bItemIndex = iContainer->CurrentItemIndex(); |
|
176 if(bItemIndex < 0) |
|
177 break; |
|
178 |
|
179 TBTDevice device; |
|
180 device.iIndex = bItemIndex; |
|
181 iModel->GetDevice(device); |
|
182 |
|
183 RBuf s; |
|
184 CleanupClosePushL( s ); |
|
185 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
186 s, R_BT_WARN_ERASE_BLOCKED, device.iName, 0); |
|
187 |
|
188 CAknQueryDialog* dialog = CAknQueryDialog::NewL(CAknQueryDialog::EConfirmationTone); |
|
189 TInt keypress = dialog->ExecuteLD(R_BT_GENERIC_QUERY, s); |
|
190 |
|
191 CleanupStack::PopAndDestroy(&s); |
|
192 |
|
193 if(keypress) // User has accepted the dialog |
|
194 { |
|
195 device.iOperation = EOpUnblock; |
|
196 iModel->ChangeDevice(device); |
|
197 } |
|
198 |
|
199 break; |
|
200 |
|
201 } |
|
202 case EBTUICmdDeleteAll: |
|
203 case EBTUICmdUnblockAll: |
|
204 { |
|
205 CAknQueryDialog* dialog = CAknQueryDialog::NewL(CAknQueryDialog::EConfirmationTone); |
|
206 HBufC* s=iCoeEnv->AllocReadResourceLC(R_BT_WARN_ERASE_ALL_BLOCKED); |
|
207 TInt keypress=dialog->ExecuteLD(R_BT_GENERIC_QUERY, *s); |
|
208 CleanupStack::PopAndDestroy(s); |
|
209 |
|
210 if(keypress) |
|
211 { |
|
212 iModel->ChangeAllDevices(EOpUnblock); |
|
213 } |
|
214 |
|
215 break; |
|
216 } |
|
217 |
|
218 case EAknCmdHelp: |
|
219 { |
|
220 #ifdef __SERIES60_HELP |
|
221 HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), AppUi()->AppHelpContextL()); |
|
222 #endif |
|
223 break; |
|
224 } |
|
225 |
|
226 default: |
|
227 { |
|
228 AppUi()->HandleCommandL(aCommand); |
|
229 break; |
|
230 } |
|
231 } |
|
232 TRACE_FUNC_EXIT |
|
233 } |
|
234 |
|
235 |
|
236 // --------------------------------------------------------- |
|
237 // From CAknView |
|
238 // CBTUIBlockedDevicesView::DoActivateL |
|
239 // --------------------------------------------------------- |
|
240 // |
|
241 void CBTUIBlockedDevicesView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, |
|
242 TUid /*aCustomMessageId*/, |
|
243 const TDesC8& /*aCustomMessage*/) |
|
244 { |
|
245 TRACE_FUNC_ENTRY |
|
246 // Setup title |
|
247 // |
|
248 iModel = CBTDevModel::NewL(EGroupBlocked, this); |
|
249 iContainer = CBTUiDeviceContainer::NewL(ClientRect(), this, EGroupBlocked, this); |
|
250 |
|
251 HBufC* btBlockDevices = iCoeEnv->AllocReadResourceLC(R_BT_TITLE_BLOCKED_DEV); |
|
252 CEikStatusPane* statusPane = StatusPane(); |
|
253 CAknTitlePane* titlePane; |
|
254 titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)); |
|
255 titlePane->SetTextL(*btBlockDevices); |
|
256 CleanupStack::PopAndDestroy(btBlockDevices); |
|
257 AppUi()->AddToStackL(*this, iContainer); |
|
258 DimMskL(ETrue ); |
|
259 // the MSK will be undimmed, if there are blocked devices when |
|
260 // the deviceList will be refreshed |
|
261 |
|
262 if( iBaseView && iConstructAsGsPlugin) |
|
263 { |
|
264 iTabHelper->CreateTabGroupL( Id(), |
|
265 static_cast<CArrayPtrFlat<MGSTabbedView>*> |
|
266 (iBaseView->TabbedViews()) ); |
|
267 } |
|
268 |
|
269 |
|
270 MenuBar()->SetContextMenuTitleResourceId( |
|
271 R_BTUI_MENUBAR_BLOCK_DEVICES_VIEW); |
|
272 |
|
273 // notify observer |
|
274 if( iActivationObserver && iConstructAsGsPlugin == EFalse) |
|
275 { |
|
276 iActivationObserver->PluginViewActivated(EBlockedDevicesViewId); |
|
277 } |
|
278 |
|
279 TRACE_FUNC_EXIT |
|
280 } |
|
281 |
|
282 // --------------------------------------------------------- |
|
283 // From CAknView |
|
284 // CBTUIBlockedDevicesView::DoDeactivate |
|
285 // --------------------------------------------------------- |
|
286 // |
|
287 void CBTUIBlockedDevicesView::DoDeactivate() |
|
288 { |
|
289 TRACE_FUNC_ENTRY |
|
290 if (iContainer) |
|
291 { |
|
292 AppUi()->RemoveFromStack(iContainer); |
|
293 delete iContainer; |
|
294 iContainer = NULL; |
|
295 } |
|
296 |
|
297 delete iModel; |
|
298 iModel=NULL; |
|
299 if(iConstructAsGsPlugin) |
|
300 iTabHelper->RemoveTabGroup(); |
|
301 |
|
302 TRACE_FUNC_EXIT |
|
303 } |
|
304 // --------------------------------------------------------- |
|
305 // CBTUIBlockedDevicesView::DimMskL |
|
306 // This will dim/Undim MSK. |
|
307 // However the command is sent when the key is pressed |
|
308 // regardless wether the MSK command is visible and |
|
309 // the view must be able to receive it anyway. |
|
310 // --------------------------------------------------------- |
|
311 void CBTUIBlockedDevicesView::DimMskL(TBool aDimmed) |
|
312 { |
|
313 TRACE_FUNC_ENTRY |
|
314 if(aDimmed) |
|
315 { |
|
316 Cba()->SetCommandL (EBTUICmdUnblock,KNullDesC); |
|
317 } |
|
318 else |
|
319 { |
|
320 if(iConstructAsGsPlugin) |
|
321 { |
|
322 Cba()->SetCommandSetL(R_BTUI_SOFTKEYS_OPTIONS_BACK__UNBLOCK); |
|
323 } |
|
324 else |
|
325 { |
|
326 Cba()->SetCommandSetL(R_BTUI_SOFTKEYS_OPTIONS_EXIT__UNBLOCK); |
|
327 } |
|
328 } |
|
329 |
|
330 Cba()->DrawDeferred(); |
|
331 |
|
332 // NOTE: these will only hide the MSK label. |
|
333 // The command is still being sent if button is pressed. |
|
334 // HandleCommanL will take care |
|
335 // of the situation that there may be no devices to unblock |
|
336 TRACE_FUNC_EXIT |
|
337 } |
|
338 |
|
339 // --------------------------------------------------------- |
|
340 // From CAknView |
|
341 // CBTUIBlockedDevicesView::DynInitMenuPaneL |
|
342 // Shows selected item's context sensitive options menu. |
|
343 // --------------------------------------------------------- |
|
344 // |
|
345 void CBTUIBlockedDevicesView::DynInitMenuPaneL(TInt aResId, CEikMenuPane* aMenu) |
|
346 { |
|
347 TRACE_FUNC_ENTRY |
|
348 // dim help if it exists and is not supported |
|
349 TInt tmp; |
|
350 if ( aMenu->MenuItemExists(EAknCmdHelp,tmp ) ) |
|
351 { |
|
352 aMenu->SetItemDimmed(EAknCmdHelp, |
|
353 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); |
|
354 } |
|
355 |
|
356 // do not "unblock all" commands |
|
357 // if there is nothing to unblock |
|
358 if (aResId == R_BTUI_BLOCK_DEVICES_VIEW_MENU) |
|
359 { |
|
360 if( iContainer->CountItems() == 0) |
|
361 { |
|
362 aMenu->SetItemDimmed(EBTUICmdUnblockAll, ETrue); |
|
363 } |
|
364 else |
|
365 { |
|
366 aMenu->SetItemDimmed(EBTUICmdUnblockAll, EFalse); |
|
367 } |
|
368 } |
|
369 TRACE_FUNC_EXIT |
|
370 } |
|
371 |
|
372 // --------------------------------------------------------- |
|
373 // From MBTDeviceObserver |
|
374 // CBTUIBlockedDevicesView::NotifyChangeDeviceComplete |
|
375 // --------------------------------------------------------- |
|
376 // |
|
377 void CBTUIBlockedDevicesView::NotifyChangeDeviceComplete(const TInt aErr, |
|
378 const TBTDevice&, const RBTDevNameArray* ) |
|
379 { |
|
380 TRACE_FUNC_ENTRY |
|
381 // we do not show any note, when blocked devices are unblocked, |
|
382 // and that is the only command available. |
|
383 |
|
384 if(aErr!= KErrNone) |
|
385 { |
|
386 TRAP_IGNORE(TBTUIViewsCommonUtils::ShowGeneralErrorNoteL();); |
|
387 } |
|
388 TRACE_FUNC_EXIT |
|
389 } |
|
390 |
|
391 |
|
392 // ----------------------------------------------- |
|
393 // From MBTDeviceObserver |
|
394 // CBTUIBlockedDevicesView::RefreshDeviceList |
|
395 // ----------------------------------------------- |
|
396 void CBTUIBlockedDevicesView::RefreshDeviceList(const RDeviceArray* aDevices, |
|
397 TInt aSelectedItemIndex) |
|
398 { |
|
399 TRACE_FUNC_ENTRY |
|
400 |
|
401 TRAPD(err, |
|
402 if(iContainer) |
|
403 { |
|
404 iContainer->RefreshDeviceListL(aDevices,aSelectedItemIndex ); |
|
405 } |
|
406 // dim the MSK if there are no devices to unblock |
|
407 DimMskL(aDevices->Count()==0); |
|
408 |
|
409 ); |
|
410 if(err!= KErrNone) |
|
411 { |
|
412 TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); |
|
413 } |
|
414 |
|
415 TRACE_FUNC_EXIT |
|
416 } |
|
417 |
|
418 // --------------------------------------------------------------------------- |
|
419 // CBTUIBlockedDevicesView::CreateTabIconL() |
|
420 // Creates icon for tab. |
|
421 // --------------------------------------------------------------------------- |
|
422 // |
|
423 CGulIcon* CBTUIBlockedDevicesView::CreateTabIconL() |
|
424 { |
|
425 TFileName bmpFilename; |
|
426 bmpFilename += KBitmapFileDrive; |
|
427 bmpFilename += KDC_APP_BITMAP_DIR; |
|
428 bmpFilename += KBtuiBmpFileName; |
|
429 |
|
430 CGulIcon* icon = AknsUtils::CreateGulIconL( |
|
431 AknsUtils::SkinInstance(), |
|
432 KAknsIIDQgnPropBtBlockedTab3, |
|
433 bmpFilename, |
|
434 EMbmBtuiQgn_prop_bt_blocked_tab3, |
|
435 EMbmBtuiQgn_prop_bt_blocked_tab3_mask ); |
|
436 |
|
437 return icon; |
|
438 } |
|
439 |
|