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