|
1 /* |
|
2 * Copyright (c) 2006 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 the implementation of setting view class |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <aknViewAppUi.h> |
|
19 #include <avkon.hrh> |
|
20 #include <eiklabel.h> |
|
21 #include <akntitle.h> |
|
22 #include <StringLoader.h> |
|
23 #include <hlplch.h> // Help launcher |
|
24 #include <aknradiobuttonsettingpage.h> |
|
25 #include <bautils.h> |
|
26 #include <BthidResource.rsg> |
|
27 #include <csxhelp/bt.hlp.hrh> // Help IDs |
|
28 #include <aknnavide.h> |
|
29 #include <akncontext.h> |
|
30 #include "bthidsettingview.h" |
|
31 #include "bthidsettingcontainer.h" |
|
32 #include "bthidsettings.h" |
|
33 #include "bthidsettinglist.h" |
|
34 #include "btkeyboard.hrh" |
|
35 #include <btkeyboard.mbg> |
|
36 #include "btengprivatecrkeys.h" |
|
37 #include "layoutmgr.h" |
|
38 #include "hidlayoutids.h" |
|
39 #include "debug.h" |
|
40 |
|
41 const TUid KBtHidSettingViewId = |
|
42 { |
|
43 0x2001E30B |
|
44 } |
|
45 ; // UID of HID device setting view. |
|
46 // --------------------------------------------------------- |
|
47 // CBtHidSettingView::NewNewGsPluginL |
|
48 // Two phased constructor |
|
49 // --------------------------------------------------------- |
|
50 // |
|
51 CBtHidSettingView* CBtHidSettingView::NewBtuiPluginL() |
|
52 { |
|
53 //TRACE_FUNC(_L("[BTHID]\t CBtHidSettingView::NewBtuiPluginL(), BEGIN")); |
|
54 |
|
55 CBtHidSettingView* self = new (ELeave) CBtHidSettingView(); |
|
56 |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop(); |
|
60 |
|
61 //TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::NewBtuiPluginL, END"),self) ); |
|
62 |
|
63 return self; |
|
64 } |
|
65 |
|
66 |
|
67 // ---------------------------------------------------- |
|
68 // CBtHidSettingView::CBtHidSettingView |
|
69 // default constructor |
|
70 // ---------------------------------------------------- |
|
71 // |
|
72 CBtHidSettingView::CBtHidSettingView() |
|
73 {} |
|
74 |
|
75 // ---------------------------------------------------- |
|
76 // CBtHidSettingView::ConstructL |
|
77 // ---------------------------------------------------- |
|
78 // |
|
79 void CBtHidSettingView::ConstructL() |
|
80 { |
|
81 TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]:ConstructL(), BEGIN"),this) ); |
|
82 |
|
83 User::LeaveIfError(iLayoutSession.Connect()); |
|
84 |
|
85 // Check to see what type of layout code the layout manager will return |
|
86 // us. (i.e nokia or standard) |
|
87 // This is used to know which settings page to display. |
|
88 TBool ignore; |
|
89 TRACE_INFO(_L("[BTHID]\t CBtHidMainView::ConstructL(), get layout info...")); |
|
90 User::LeaveIfError(iLayoutSession.GetDeviceInfo(iIsNokiaKeyboard, ignore)); |
|
91 |
|
92 iEikEnv = CEikonEnv::Static(); |
|
93 TFileName filename; |
|
94 filename += KFileDrive; |
|
95 filename += KDC_RESOURCE_FILES_DIR; |
|
96 filename += KResourceFileName; |
|
97 BaflUtils::NearestLanguageFile( iEikEnv->FsSession(), filename ); |
|
98 iResourceFileFlag=iEikEnv->AddResourceFileL(filename); |
|
99 BaseConstructL( R_BTKEYBOARD_SETTING_VIEW ); |
|
100 |
|
101 CEikStatusPane *sp = ((CAknAppUi*)iEikonEnv->EikAppUi())->StatusPane(); |
|
102 // Fetch pointer to the default title pane control |
|
103 iContextPane = (CAknContextPane *)sp->ControlL(TUid::Uid(EEikStatusPaneUidContext)); |
|
104 |
|
105 iSettings = CBtHidSettings::NewL(); |
|
106 |
|
107 TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]:ConstructL(), END"),this) ); |
|
108 } |
|
109 // ---------------------------------------------------- |
|
110 // CBtHidSettingView::~CBtHidSettingView() |
|
111 // Destructor |
|
112 // Frees reserved resources |
|
113 // ---------------------------------------------------- |
|
114 // |
|
115 CBtHidSettingView::~CBtHidSettingView() |
|
116 { |
|
117 TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::~CBtHidSettingView()"), this) ); |
|
118 iLayoutSession.Close(); |
|
119 |
|
120 delete iNaviDecorator; |
|
121 iEikEnv->DeleteResourceFile(iResourceFileFlag); |
|
122 |
|
123 if ( iSettingList ) |
|
124 { |
|
125 AppUi()->RemoveFromStack( (CCoeControl*) iSettingList ); |
|
126 delete iSettingList; |
|
127 } |
|
128 if ( iContainer ) |
|
129 { |
|
130 AppUi()->RemoveFromStack(iContainer ); |
|
131 delete iContainer; |
|
132 } |
|
133 if( iCenRepWatcher ) |
|
134 delete iCenRepWatcher; |
|
135 |
|
136 if (iSettings ) |
|
137 delete iSettings; |
|
138 TRACE_FUNC_EXIT |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------- |
|
142 // TUid CBtHidSettingView::Id |
|
143 // --------------------------------------------------------- |
|
144 // |
|
145 TUid CBtHidSettingView::Id() const |
|
146 { |
|
147 TUid id = KBtHidSettingViewId; //view id |
|
148 return id; |
|
149 } |
|
150 |
|
151 // ---------------------------------------------------- |
|
152 // CBtHidSettingView::HandleCommandL(TInt aCommand) |
|
153 // takes care of command handling |
|
154 // ---------------------------------------------------- |
|
155 // |
|
156 void CBtHidSettingView::HandleCommandL(TInt aCommand) |
|
157 { |
|
158 TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::HandleCommandL(%d)"),this, aCommand) ); |
|
159 switch ( aCommand ) |
|
160 { |
|
161 case EEikCmdExit: // fall-through, handled similarily |
|
162 case EAknSoftkeyExit: // fall-through, handled similarily |
|
163 //case EBTKeyCmdExit: |
|
164 { |
|
165 AppUi()->HandleCommandL( EEikCmdExit); |
|
166 } |
|
167 case EAknSoftkeyChange: |
|
168 case EBTKeyCmdAppChange: |
|
169 { |
|
170 if( iSettingList ) |
|
171 { |
|
172 iCenRepWatcher->DisableNotifications(); |
|
173 iSettingList->EditCurrentItemL( aCommand ); |
|
174 iCenRepWatcher->EnableNotifications(); |
|
175 } |
|
176 break; |
|
177 } |
|
178 case EAknSoftkeyBack: |
|
179 { |
|
180 AppUi()->ActivateLocalViewL( iPrevViewId.iViewUid ); |
|
181 break; |
|
182 } |
|
183 |
|
184 #ifdef __SERIES60_HELP |
|
185 case EBTKeyCmdAppHelp: |
|
186 { |
|
187 HlpLauncher::LaunchHelpApplicationL( |
|
188 iEikEnv->WsSession(), AppUi()->AppHelpContextL()); |
|
189 break; |
|
190 } |
|
191 |
|
192 #endif |
|
193 default: |
|
194 { |
|
195 AppUi()->HandleCommandL( aCommand ); |
|
196 break; |
|
197 } |
|
198 } |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // CBtHidSettingView::DoActivateL() |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 void CBtHidSettingView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
206 TUid aCustomMessageId, |
|
207 const TDesC8& aCustomMessage ) |
|
208 { |
|
209 TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::DoActivateL, BEGIN"),this) ); |
|
210 iPrevViewId = aPrevViewId; |
|
211 (void) aCustomMessageId; |
|
212 |
|
213 // Setup the title |
|
214 HBufC* title; |
|
215 title = iCoeEnv->AllocReadResourceLC(R_BTKEYBOARD_SETTINGS_STATUS_PANE_TITLE); |
|
216 |
|
217 CEikStatusPane* statusPane = StatusPane(); |
|
218 CAknTitlePane* titlePane; |
|
219 titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)); |
|
220 titlePane->SetTextL(title->Des()); |
|
221 CleanupStack::PopAndDestroy(); // title |
|
222 title = NULL; |
|
223 |
|
224 TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::DoActivateL(), Creating container..."),this) ); |
|
225 iContainer = new (ELeave) CBTHidSettingContainer; |
|
226 iContainer->SetMopParent(this); |
|
227 iContainer->ConstructL( ClientRect()); |
|
228 iContainer->MakeVisible( ETrue ); |
|
229 iContainer->ActivateL(); |
|
230 AppUi()->AddToStackL(iContainer); |
|
231 |
|
232 CreateSettingListL(); |
|
233 iCenRepWatcher = CBtHidCenRepWatcher::NewL( KCRUidBTEngPrivateSettings, *this ); // create listener for cenrep events. |
|
234 SetNavipaneTextL(aCustomMessage); |
|
235 |
|
236 TRACE_INFO((_L("[BTHID]\t CBtHidSettingView[0x%08x]::DoActivateL, END"),this) ); |
|
237 } |
|
238 |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // CBtHidSettingView::DoDeactivate |
|
242 // |
|
243 // Deactivate the settings view. |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CBtHidSettingView::DoDeactivate() |
|
247 { |
|
248 TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::DoDeactivate, BEGIN"),this) ); |
|
249 if ( iSettingList ) |
|
250 { |
|
251 AppUi()->RemoveFromStack( (CCoeControl*) iSettingList ); |
|
252 delete iSettingList; |
|
253 iSettingList = NULL; |
|
254 } |
|
255 if( iContainer ) |
|
256 { |
|
257 iContainer->MakeVisible(EFalse); |
|
258 AppUi()->RemoveFromStack( iContainer ); |
|
259 delete iContainer; |
|
260 iContainer = NULL; |
|
261 } |
|
262 |
|
263 if (iNaviDecorator) |
|
264 { |
|
265 delete iNaviDecorator; |
|
266 iNaviDecorator = NULL; |
|
267 } |
|
268 iLastSelectedLayout = iSettings->LoadLayoutSetting(); |
|
269 iLayoutSession.SetLayout(iLastSelectedLayout); |
|
270 delete iCenRepWatcher; |
|
271 iCenRepWatcher = NULL; |
|
272 TRACE_FUNC_EXIT |
|
273 } |
|
274 |
|
275 // ---------------------------------------------------- |
|
276 // CBtHidSettingView::DynInitMenuPaneL |
|
277 // ---------------------------------------------------- |
|
278 // |
|
279 void CBtHidSettingView::DynInitMenuPaneL( |
|
280 TInt aResourceId, CEikMenuPane* aMenuPane) |
|
281 { |
|
282 if (aResourceId == R_BTKEYBOARD_SETTING_MENU ) |
|
283 { |
|
284 aMenuPane->SetItemDimmed(EBTKeyCmdAppChange, ETrue); |
|
285 } |
|
286 |
|
287 |
|
288 } |
|
289 |
|
290 // ---------------------------------------------------- |
|
291 // CBtHidSettingView::CreateSettingListL |
|
292 // ---------------------------------------------------- |
|
293 // |
|
294 void CBtHidSettingView::CreateSettingListL() |
|
295 { |
|
296 TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::CreateSettingListL, BEGIN"),this) ); |
|
297 |
|
298 TInt resourceId = R_BTKEYBOARD_STANDARD_SETTING_LIST; |
|
299 |
|
300 TBool foundLayout; |
|
301 User::LeaveIfError(iLayoutSession.GetDeviceInfo(iIsNokiaKeyboard, foundLayout)); |
|
302 |
|
303 if(iIsNokiaKeyboard) |
|
304 { |
|
305 resourceId = R_BTKEYBOARD_NOKIA_SETTING_LIST; |
|
306 } |
|
307 else |
|
308 { |
|
309 resourceId = R_BTKEYBOARD_STANDARD_SETTING_LIST; |
|
310 } |
|
311 |
|
312 TInt layoutCode; |
|
313 if ( !foundLayout ) |
|
314 { |
|
315 //No layout found, find an appropriate one. |
|
316 layoutCode = CurrentLayoutL(); |
|
317 SetCurrentLayoutL(static_cast<THidKeyboardLayoutId>(layoutCode)); |
|
318 } |
|
319 else |
|
320 { |
|
321 //Layout found, load it as default |
|
322 iLayoutSession.GetLayout(layoutCode); |
|
323 SetCurrentLayoutL(static_cast<THidKeyboardLayoutId>(layoutCode)); |
|
324 } |
|
325 |
|
326 if ( iSettingList ) |
|
327 { |
|
328 AppUi()->RemoveFromStack( (CCoeControl*) iSettingList ); |
|
329 } |
|
330 delete iSettingList; |
|
331 iSettingList = NULL; |
|
332 |
|
333 iSettingList = new (ELeave) CBTKeySettingList( *iSettings, this); |
|
334 iSettingList->SetMopParent(this); |
|
335 iSettingList->ConstructFromResourceL(resourceId); |
|
336 AppUi()->AddToStackL( (CCoeControl*) iSettingList ); |
|
337 iSettingList->MakeVisible(ETrue); |
|
338 iSettingList->SetRect(ClientRect()); |
|
339 iSettingList->ActivateL(); |
|
340 iSettingList->DrawNow(); |
|
341 TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::CreateSettingListL, END"),this) ); |
|
342 } |
|
343 |
|
344 // ---------------------------------------------------- |
|
345 // CBtHidSettingView::SetCurrentLayoutL |
|
346 // ---------------------------------------------------- |
|
347 // |
|
348 void CBtHidSettingView::SetCurrentLayoutL(THidKeyboardLayoutId aLayoutValue) |
|
349 { |
|
350 // Ask the layout manager to change layout. |
|
351 // Use the leaving version so we the user can't confirm a selection |
|
352 // if an error occurs. |
|
353 iLayoutSession.SetLayoutL(aLayoutValue); |
|
354 |
|
355 iSettings->SaveLayoutSettingL( aLayoutValue ); |
|
356 } |
|
357 |
|
358 THidKeyboardLayoutId CBtHidSettingView::CurrentLayoutL() const |
|
359 { |
|
360 // Ask the layout manager for the current layout. |
|
361 // Use the leaving version. |
|
362 TInt layoutCode = iLayoutSession.GetLayoutL(); |
|
363 |
|
364 // Convert the Int to the enum. |
|
365 THidKeyboardLayoutId layoutID = |
|
366 static_cast<THidKeyboardLayoutId>(layoutCode); |
|
367 |
|
368 // If we believe this to be a Nokia keyboard then the layout settings |
|
369 // page will contain the list of Nokia Su8 items. |
|
370 // Conversly if we think this is a Standard keyboard the layout settings |
|
371 // page will contain the list of Standard layouts. |
|
372 // We must pass a valid value to the Settings page or it will panic. |
|
373 // Validate the code from the Layout Manager before returning it. |
|
374 if ( iIsNokiaKeyboard ) |
|
375 { |
|
376 CLayoutUtils::ValidateNokiaSU8Layout(layoutID); |
|
377 } |
|
378 else |
|
379 { |
|
380 CLayoutUtils::ValidateStandardLayout(layoutID); |
|
381 } |
|
382 |
|
383 return layoutID; |
|
384 } |
|
385 |
|
386 void CBtHidSettingView::SetNavipaneTextL(const TDesC8& aDeviceName) |
|
387 { |
|
388 TRACE_INFO(_L("[BTHID]\t CBtHidSettingView::SetNavipaneTextL Start")); |
|
389 CEikStatusPane* sp = |
|
390 iEikonEnv->AppUiFactory()->StatusPane(); |
|
391 |
|
392 CAknNavigationControlContainer* np = |
|
393 static_cast<CAknNavigationControlContainer*>( |
|
394 sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
395 |
|
396 delete iNaviDecorator; |
|
397 iNaviDecorator = NULL; |
|
398 |
|
399 TInt blank(1); |
|
400 if (aDeviceName.Length()>0 ) |
|
401 { |
|
402 HBufC* stringHolder = HBufC::NewLC(aDeviceName.Length() + blank); |
|
403 stringHolder->Des().Copy(aDeviceName); |
|
404 stringHolder->Des().Append(_L(" ")); |
|
405 iNaviDecorator = np->CreateNavigationLabelL( *stringHolder ); |
|
406 np->PushL( *iNaviDecorator ); |
|
407 sp->DrawNow(); |
|
408 CleanupStack::PopAndDestroy(stringHolder); // stringHolder |
|
409 } |
|
410 else |
|
411 { |
|
412 HBufC* temp = HBufC::NewLC(aDeviceName.Length()); |
|
413 temp->Des().Copy(aDeviceName); |
|
414 iNaviDecorator = np->CreateNavigationLabelL( *temp ); |
|
415 np->PushL( *iNaviDecorator ); |
|
416 sp->DrawNow(); |
|
417 CleanupStack::PopAndDestroy(temp); // temp |
|
418 } |
|
419 TRACE_INFO(_L("[BTHID]\t CBtHidSettingView::SetNavipaneTextL End")); |
|
420 } |
|
421 // ---------------------------------------------------- |
|
422 // CBtHidSettingView::CenRepDataChanged |
|
423 // ---------------------------------------------------- |
|
424 // |
|
425 void CBtHidSettingView::CenRepDataChanged(TUid& aUid, TUint32 aKey) |
|
426 { |
|
427 // just recreate the setting list |
|
428 TRACE_INFO((_L("[BTHID]\t CBtHidSettingView[0x%08x]::CenRepDataChanged"),this)); |
|
429 (void) aUid; |
|
430 if ( aKey == KBtHidKeyboardLayout ) |
|
431 { |
|
432 TRAPD( err, CreateSettingListL()); |
|
433 err = err; |
|
434 } |
|
435 } |
|
436 // End of File |