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: Implementation of plugin base class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <cmmanager.rsg> |
|
20 #include <StringLoader.h> |
|
21 |
|
22 #include "cmconnselectrbpage.h" |
|
23 #include "cmmanager.hrh" |
|
24 #include "cmconnsettingsuiimpl.h" |
|
25 #include "cmlogger.h" |
|
26 |
|
27 using namespace CMManager; |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CCMConnSelectRBPage::CCMConnSelectRBPage |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CCMConnSelectRBPage::CCMConnSelectRBPage( TInt aDialogResourceId, |
|
34 TInt& aCurrentSelectionIndex, |
|
35 const MDesCArray* aItemArray, |
|
36 CCmManagerImpl& aCmManagerImpl, |
|
37 TCmDCSettingSelectionMode& aSelectionMode, |
|
38 RArray<TUint32>& aDestinations, |
|
39 TBool areDestinations, |
|
40 TBool aOpenDestination, |
|
41 TCoeContextName& aContext ) |
|
42 : CAknRadioButtonSettingPage( aDialogResourceId, |
|
43 aCurrentSelectionIndex, |
|
44 aItemArray ) |
|
45 , iDialogResourceId (aDialogResourceId) |
|
46 , iCmManagerImpl( aCmManagerImpl ) |
|
47 , iSelectionMode( aSelectionMode ) |
|
48 , iDestinations( aDestinations ) |
|
49 , iAreDestinations( areDestinations ) |
|
50 , iOpenDestination( aOpenDestination ) |
|
51 , iHelpContext ( aContext ) |
|
52 , iFirstEnter( ETrue ) |
|
53 { |
|
54 CLOG_CREATE; |
|
55 iPrevItem = iDestinations[aCurrentSelectionIndex]; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CCMConnSelectRBPage::~CCMConnSelectRBPage |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CCMConnSelectRBPage::~CCMConnSelectRBPage() |
|
63 { |
|
64 CLOG_CLOSE; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CCMConnSelectRBPage::OkToExitL |
|
69 // Good to know : EAknSoftkeyCancel is never called, because |
|
70 // EEikDialogFlagNotifyEsc flag is not set in the resource. |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 TBool CCMConnSelectRBPage::OkToExitL( TInt aButtonId ) |
|
74 { |
|
75 LOGGER_ENTERFN("CCMConnSelectRBPage::OkToExitL"); |
|
76 |
|
77 // Convert the button presses into commands for the appui & current |
|
78 // view to handle |
|
79 TBool retval( EFalse ); |
|
80 if ( aButtonId == EAknSoftkeyOk ) |
|
81 { |
|
82 ProcessCommandL( ECmManagerUiCmdDestSelect ); |
|
83 retval = ETrue; |
|
84 } |
|
85 else |
|
86 { |
|
87 if ( aButtonId == EAknSoftkeyOptions ) |
|
88 { |
|
89 //*iSelected = iListbox->CurrentItemUid(); |
|
90 //retval = ETrue; |
|
91 DisplayMenuL(); |
|
92 retval = EFalse; |
|
93 } |
|
94 else |
|
95 { |
|
96 retval = ETrue; |
|
97 } |
|
98 } |
|
99 |
|
100 return retval; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CCMConnSelectRBPage::ProcessCommandL |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void CCMConnSelectRBPage::ProcessCommandL( TInt aCommandId ) |
|
108 { |
|
109 LOGGER_ENTERFN("CCMConnSelectRBPage::ProcessCommandL"); |
|
110 |
|
111 if ( MenuShowing() ) |
|
112 { |
|
113 HideMenu(); |
|
114 } |
|
115 |
|
116 switch ( aCommandId ) |
|
117 { |
|
118 case EAknSoftkeyOptions: |
|
119 { |
|
120 DisplayMenuL(); |
|
121 break; |
|
122 } |
|
123 |
|
124 case EAknSoftkeyCancel: |
|
125 { |
|
126 AttemptExitL(EFalse); |
|
127 break; |
|
128 } |
|
129 |
|
130 case EAknSoftkeyOk: |
|
131 case EAknSoftkeySelect: |
|
132 case ECmManagerUiCmdDestSelect: |
|
133 { |
|
134 TUint selectedItem = |
|
135 iDestinations[ ListBoxControl()->CurrentItemIndex() ]; |
|
136 if ( selectedItem == KDestItemAlwaysAsk ) |
|
137 { |
|
138 iSelectionMode = EDCAlwaysAsk; |
|
139 } |
|
140 else if ( selectedItem == KDestItemAskOnce ) |
|
141 { |
|
142 iSelectionMode = EDCAskOnce; |
|
143 } |
|
144 else if ( selectedItem == KDestItemDefaultConnection ) |
|
145 { |
|
146 iSelectionMode = EDCDefaultConnection; |
|
147 } |
|
148 else if ( selectedItem == KDestItemUncategorized ) |
|
149 { |
|
150 iSelectionMode = EDCConnectionMethod; |
|
151 } |
|
152 else |
|
153 { |
|
154 if (iAreDestinations) |
|
155 { |
|
156 iSelectionMode = EDCDestination; |
|
157 } |
|
158 else |
|
159 { |
|
160 iSelectionMode = EDCConnectionMethod; |
|
161 } |
|
162 } |
|
163 //iId is to be defined in the caller class |
|
164 SelectCurrentItemL(); |
|
165 AttemptExitL(ETrue); |
|
166 break; |
|
167 } |
|
168 |
|
169 case ECmManagerUiCmdCMSelect: |
|
170 { |
|
171 iSelectionMode = EDCConnectionMethod; |
|
172 SelectCurrentItemL(); |
|
173 AttemptExitL( ETrue ); |
|
174 break; |
|
175 } |
|
176 case EAknCmdHelp: |
|
177 { |
|
178 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
179 iEikonEnv->EikAppUi()->AppHelpContextL() ); |
|
180 } |
|
181 break; |
|
182 default: |
|
183 { |
|
184 break; |
|
185 } |
|
186 } |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CCMConnSelectRBPage::DynInitMenuPaneL |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CCMConnSelectRBPage::DynInitMenuPaneL( TInt aResourceId, |
|
194 CEikMenuPane* aMenuPane ) |
|
195 { |
|
196 LOGGER_ENTERFN("CCMConnSelectRBPage::DynInitMenuPaneL"); |
|
197 |
|
198 CAknSettingPage::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
199 if ( aResourceId == R_SELECT_NETW_CONN_MENU ) |
|
200 { |
|
201 if (!iCmManagerImpl.IsHelpOn()) |
|
202 { |
|
203 aMenuPane->DeleteMenuItem( EAknCmdHelp ); |
|
204 } |
|
205 TUint32 currentItem = |
|
206 iDestinations[ ListBoxControl()->CurrentItemIndex() ]; |
|
207 |
|
208 // Always Ask ( always the first item ) |
|
209 if ( (currentItem == KDestItemAlwaysAsk) || |
|
210 (currentItem == KDestItemAskOnce) || |
|
211 (currentItem == KDestItemDefaultConnection) || |
|
212 !iOpenDestination ) |
|
213 { |
|
214 aMenuPane->SetItemDimmed( ECmManagerUiCmdCMSelect, ETrue ); |
|
215 } |
|
216 else if ( ( currentItem != KDestItemAlwaysAsk ) && |
|
217 ( currentItem != KDestItemAskOnce ) && |
|
218 ( currentItem != KDestItemDefaultConnection ) && |
|
219 ( currentItem != KDestItemUncategorized )) |
|
220 { |
|
221 CCmDestinationImpl* destImpl = iCmManagerImpl.DestinationL( currentItem ); |
|
222 |
|
223 if ( !destImpl->ConnectionMethodCount() ) |
|
224 { |
|
225 aMenuPane->SetItemDimmed( ECmManagerUiCmdCMSelect, ETrue ); |
|
226 } |
|
227 |
|
228 delete destImpl; |
|
229 } |
|
230 else |
|
231 { |
|
232 RArray<TUint32> uncatArray( KCmArraySmallGranularity ); |
|
233 CleanupClosePushL( uncatArray ); |
|
234 iCmManagerImpl.ConnectionMethodL( uncatArray ); |
|
235 |
|
236 // Uncategorised - cannot be selected |
|
237 if ( currentItem == KDestItemUncategorized ) |
|
238 { |
|
239 aMenuPane->SetItemDimmed( ECmManagerUiCmdDestSelect, ETrue ); |
|
240 } |
|
241 CleanupStack::PopAndDestroy( &uncatArray ); |
|
242 } |
|
243 } |
|
244 } |
|
245 |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CCMConnSelectRBPage::OfferKeyEventL |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 TKeyResponse CCMConnSelectRBPage::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
252 TEventCode aType ) |
|
253 { |
|
254 LOGGER_ENTERFN("CCMConnSelectRBPage::OfferKeyEventL"); |
|
255 |
|
256 TKeyResponse retVal ( EKeyWasNotConsumed ); |
|
257 // save for the future use |
|
258 iPrevItem = iDestinations[ListBoxControl()->CurrentItemIndex()]; |
|
259 |
|
260 TKeyEvent aKeyEventmy = aKeyEvent; |
|
261 if ( aKeyEventmy.iCode == EKeyEnter ) |
|
262 { |
|
263 if ( iFirstEnter ) |
|
264 {//pressing the enter key at the first time will be changed |
|
265 //to an up arrow key so the first item in the list will be highlighted |
|
266 iFirstEnter = EFalse; |
|
267 aKeyEventmy.iScanCode = EStdKeyUpArrow; |
|
268 aKeyEventmy.iCode = EKeyUpArrow; |
|
269 } |
|
270 else |
|
271 {//change back to true for the next session |
|
272 iFirstEnter=ETrue; |
|
273 } |
|
274 } |
|
275 else if ( aKeyEventmy.iScanCode == EStdKeyDownArrow || aKeyEventmy.iScanCode == EStdKeyUpArrow ) |
|
276 { |
|
277 //we will have highligt so the following enter key should select the item |
|
278 iFirstEnter = EFalse; |
|
279 } |
|
280 |
|
281 switch ( aKeyEventmy.iScanCode ) |
|
282 { |
|
283 case EStdKeyDownArrow: |
|
284 case EStdKeyUpArrow: |
|
285 { |
|
286 if ( iOpenDestination ) //only if we are on 'destination level' and we are able to |
|
287 //open destinations |
|
288 { |
|
289 // If focus is on the 'uncategorised' destination, |
|
290 // change the soft key to 'Open' |
|
291 if ( iDestinations[ ListBoxControl()->CurrentItemIndex() ] == |
|
292 KDestItemUncategorized ) |
|
293 { |
|
294 HBufC* text = StringLoader::LoadLC( R_QTN_MSK_OPEN ); |
|
295 Cba()->SetCommandL( EAknSoftkeySelect, *text ); |
|
296 Cba()->DrawNow(); |
|
297 CleanupStack::PopAndDestroy( text ); |
|
298 } |
|
299 else |
|
300 { |
|
301 HBufC* text = StringLoader::LoadLC( R_QTN_MSK_SELECT ); |
|
302 Cba()->SetCommandL( EAknSoftkeySelect, *text ); |
|
303 Cba()->DrawNow(); |
|
304 CleanupStack::PopAndDestroy( text ); |
|
305 } |
|
306 } |
|
307 break; |
|
308 } |
|
309 default: |
|
310 { |
|
311 break; |
|
312 } |
|
313 } |
|
314 retVal = CAknRadioButtonSettingPage::OfferKeyEventL( aKeyEventmy, aType ); |
|
315 |
|
316 return retVal; |
|
317 } |
|
318 |
|
319 // -------------------------------------------------------------------------- |
|
320 // CCMConnSelectRBPage::GetHelpContext |
|
321 // -------------------------------------------------------------------------- |
|
322 // |
|
323 void CCMConnSelectRBPage::GetHelpContext( TCoeHelpContext& aContext ) const |
|
324 { |
|
325 LOGGER_ENTERFN("CCMConnSelectRBPage::GetHelpContext"); |
|
326 |
|
327 aContext.iMajor = KHelpUidPlugin; |
|
328 aContext.iContext = iHelpContext; |
|
329 } |
|
330 |
|
331 // --------------------------------------------------------------------------- |
|
332 // CCMConnSelectRBPage::HandleListBoxEventL |
|
333 // --------------------------------------------------------------------------- |
|
334 // |
|
335 void CCMConnSelectRBPage::HandleListBoxEventL(CEikListBox* aListBox, |
|
336 MEikListBoxObserver::TListBoxEvent aEventType) |
|
337 { |
|
338 LOGGER_ENTERFN("CCMConnSelectRBPage::HandleListBoxEventL"); |
|
339 |
|
340 if ( AknLayoutUtils::PenEnabled() ) |
|
341 { |
|
342 |
|
343 if (iDialogResourceId == R_RADIO_BUTTON_SETTING_PAGE_OK_CANCEL) |
|
344 { |
|
345 // Call base class implementation and return if no options menu |
|
346 CAknRadioButtonSettingPage::HandleListBoxEventL(aListBox, aEventType); |
|
347 |
|
348 switch ( aEventType ) |
|
349 { |
|
350 case EEventEnterKeyPressed: |
|
351 case EEventItemDoubleClicked: |
|
352 case EEventItemSingleClicked: |
|
353 case EEventItemClicked: |
|
354 { |
|
355 ProcessCommandL(ECmManagerUiCmdDestSelect); |
|
356 break; |
|
357 } |
|
358 |
|
359 default: |
|
360 { |
|
361 break; |
|
362 } |
|
363 } |
|
364 return; |
|
365 } |
|
366 |
|
367 switch ( aEventType ) |
|
368 { |
|
369 // All these actions are activating the listbox item |
|
370 case MEikListBoxObserver::EEventEnterKeyPressed: |
|
371 case MEikListBoxObserver::EEventItemActioned: |
|
372 CAknRadioButtonSettingPage::HandleListBoxEventL(aListBox, aEventType); |
|
373 break; |
|
374 |
|
375 case MEikListBoxObserver::EEventItemClicked: |
|
376 case MEikListBoxObserver::EEventItemSingleClicked: |
|
377 if (iPrevItem == iDestinations[ListBoxControl()->CurrentItemIndex()]) |
|
378 { |
|
379 ProcessCommandL(ECmManagerUiCmdDestSelect); |
|
380 } |
|
381 else |
|
382 { |
|
383 // save for the later use |
|
384 iPrevItem = iDestinations[ListBoxControl()->CurrentItemIndex()]; |
|
385 |
|
386 if ( iOpenDestination ) //only if we are on 'destination level' and we are able to |
|
387 //open destinations |
|
388 { |
|
389 // If focus is on the 'uncategorised' destination, |
|
390 // change the soft key to 'Open' |
|
391 if ( iDestinations[ ListBoxControl()->CurrentItemIndex() ] == |
|
392 KDestItemUncategorized ) |
|
393 { |
|
394 HBufC* text = StringLoader::LoadLC( R_QTN_MSK_OPEN ); |
|
395 Cba()->SetCommandL( EAknSoftkeySelect, *text ); |
|
396 Cba()->DrawNow(); |
|
397 CleanupStack::PopAndDestroy( text ); |
|
398 } |
|
399 else |
|
400 { |
|
401 HBufC* text = StringLoader::LoadLC( R_QTN_MSK_SELECT ); |
|
402 Cba()->SetCommandL( EAknSoftkeySelect, *text ); |
|
403 Cba()->DrawNow(); |
|
404 CleanupStack::PopAndDestroy( text ); |
|
405 } |
|
406 CAknRadioButtonSettingPage::SelectCurrentItemL(); |
|
407 } |
|
408 } |
|
409 break; |
|
410 |
|
411 case MEikListBoxObserver::EEventItemDoubleClicked: |
|
412 ProcessCommandL(ECmManagerUiCmdDestSelect); |
|
413 break; |
|
414 |
|
415 default: |
|
416 CAknRadioButtonSettingPage::HandleListBoxEventL(aListBox, aEventType); |
|
417 break; |
|
418 } |
|
419 } |
|
420 else |
|
421 { |
|
422 CAknRadioButtonSettingPage::HandleListBoxEventL(aListBox, aEventType); |
|
423 } |
|
424 } |
|
425 |
|
426 |
|