1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Defines dialog CApSelQueryDialog for access point selection. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <aknlists.h> |
|
22 #include <ApListItem.h> |
|
23 #include <AknIconArray.h> |
|
24 #include <AknsUtils.h> |
|
25 |
|
26 #include <apsetui.rsg> |
|
27 #include <apsettings.mbg> |
|
28 |
|
29 #include <featmgr.h> |
|
30 |
|
31 #include "ApSelectorListBoxModel.h" |
|
32 #include "ApSettingsModel.h" |
|
33 #include "ApSettingsHandlerUI.hrh" |
|
34 #include "ApSelQueryDialog.h" |
|
35 |
|
36 |
|
37 #include "ApSettingsHandlerLogger.h" |
|
38 #include <data_caging_path_literals.hrh> |
|
39 |
|
40 // CONSTANTS |
|
41 // Drive and file name of the MBM file containing icons for Protection |
|
42 _LIT( KFileIcons, "z:ApSettings.mbm" ); |
|
43 |
|
44 |
|
45 // ================= MEMBER FUNCTIONS ======================= |
|
46 |
|
47 // Destructor |
|
48 CApSelQueryDialog::~CApSelQueryDialog() |
|
49 { |
|
50 APSETUILOGGER_ENTERFN( EOther,"SelQuery::~CApSelQueryDialog") |
|
51 |
|
52 if ( iDataModel ) |
|
53 { |
|
54 if ( iDataModel->Database() ) |
|
55 { |
|
56 // iModel is deleted by the ListBox because LB owns the model |
|
57 iDataModel->Database()->RemoveObserver( this ); |
|
58 } |
|
59 } |
|
60 |
|
61 APSETUILOGGER_LEAVEFN( EOther,"SelQuery::~CApSelQueryDialog") |
|
62 } |
|
63 |
|
64 |
|
65 |
|
66 // Constructor |
|
67 CApSelQueryDialog::CApSelQueryDialog( CApSettingsModel& aModel, |
|
68 TUint32* aIndex ) |
|
69 :CAknListQueryDialog( (TInt*)aIndex ), |
|
70 iNeedUnlock( EFalse ) |
|
71 { |
|
72 iDataModel = &aModel; |
|
73 iSelected = aIndex; |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CApSelQueryDialog::HandleApDbEventL |
|
80 // called by the active access point framework |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 void CApSelQueryDialog::HandleApDbEventL( TEvent anEvent ) |
|
84 { |
|
85 APSETUILOGGER_ENTERFN( EOther,"SelQuery::HandleApDbEventL") |
|
86 |
|
87 switch ( anEvent ) |
|
88 { |
|
89 case EDbChanged: |
|
90 { |
|
91 FillListBoxWithDataL(); |
|
92 break; |
|
93 } |
|
94 case EDbClosing: |
|
95 { |
|
96 break; |
|
97 } |
|
98 case EDbAvailable: |
|
99 { |
|
100 if ( iNeedUnlock ) |
|
101 { |
|
102 FillListBoxWithDataL(); |
|
103 } |
|
104 break; |
|
105 } |
|
106 default: |
|
107 { |
|
108 __ASSERT_DEBUG( EFalse, Panic( EUnknownCase ) ); |
|
109 break; |
|
110 } |
|
111 } |
|
112 |
|
113 APSETUILOGGER_LEAVEFN( EOther,"SelQuery::HandleApDbEventL") |
|
114 } |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 // --------------------------------------------------------- |
|
120 // CApSelQueryDialog::PostLayoutDynInitL(); |
|
121 // called by framework before dialog is shown |
|
122 // --------------------------------------------------------- |
|
123 // |
|
124 void CApSelQueryDialog::PreLayoutDynInitL() |
|
125 { |
|
126 APSETUILOGGER_ENTERFN( EOther,"SelQuery::PreLayoutDynInitL") |
|
127 |
|
128 // parent creates the private listbox |
|
129 CAknListQueryDialog::PreLayoutDynInitL(); |
|
130 // and now we get access to it... |
|
131 CAknListQueryControl *control = |
|
132 ( CAknListQueryControl* )Control( EListQueryControl ); |
|
133 iList = control->Listbox(); |
|
134 LoadIconsL(); |
|
135 FillListBoxWithDataL(); |
|
136 iDataModel->Database()->AddObserverL( this ); |
|
137 |
|
138 APSETUILOGGER_LEAVEFN( EOther,"SelQuery::PreLayoutDynInitL") |
|
139 } |
|
140 |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // CApSelQueryDialog::PostLayoutDynInitL(); |
|
144 // called by framework before dialog is shown |
|
145 // --------------------------------------------------------- |
|
146 // |
|
147 void CApSelQueryDialog::PostLayoutDynInitL() |
|
148 { |
|
149 APSETUILOGGER_ENTERFN( EOther,"SelQuery::PostLayoutDynInitL") |
|
150 |
|
151 CAknListQueryDialog::PostLayoutDynInitL(); |
|
152 |
|
153 APSETUILOGGER_LEAVEFN( EOther,"SelQuery::PostLayoutDynInitL") |
|
154 } |
|
155 |
|
156 |
|
157 // --------------------------------------------------------- |
|
158 // CApSelQueryDialog::OkToExitL( TInt aButtonId ) |
|
159 // called by framework when the OK button is pressed |
|
160 // --------------------------------------------------------- |
|
161 // |
|
162 TBool CApSelQueryDialog::OkToExitL( TInt aButtonId ) |
|
163 { |
|
164 APSETUILOGGER_ENTERFN( EOther,"SelQuery::OkToExitL") |
|
165 |
|
166 // Translate the button presses into commands for the appui & current |
|
167 // view to handle |
|
168 TBool retval( EFalse ); |
|
169 if ( aButtonId == EAknSoftkeySelect ) |
|
170 { |
|
171 TInt idx = iList->CurrentItemIndex(); |
|
172 if ( idx >= 0 ) |
|
173 { |
|
174 if ( iModel->At( iList->CurrentItemIndex() )->IsReadOnly() ) |
|
175 { // read only, do not accept |
|
176 // show note |
|
177 ShowNoteL( R_APUI_NOTE_CANNOT_USE_PROTECTED_AP ); |
|
178 retval = EFalse; |
|
179 } |
|
180 else |
|
181 { |
|
182 *iSelected = iModel->At( iList->CurrentItemIndex() )->Uid(); |
|
183 retval = ETrue; |
|
184 } |
|
185 } |
|
186 } |
|
187 else |
|
188 { |
|
189 if ( aButtonId == EAknSoftkeyBack ) |
|
190 { |
|
191 retval = ETrue; |
|
192 } |
|
193 } |
|
194 |
|
195 APSETUILOGGER_LEAVEFN( EOther,"SelQuery::OkToExitL") |
|
196 return retval; |
|
197 } |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 // From CCoeControl |
|
203 // --------------------------------------------------------- |
|
204 // CApSelQueryDialog::OfferKeyEventL |
|
205 // --------------------------------------------------------- |
|
206 // |
|
207 TKeyResponse CApSelQueryDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
208 TEventCode aType) |
|
209 { |
|
210 APSETUILOGGER_ENTERFN( EOther,"SelQuery::OfferKeyEventL") |
|
211 |
|
212 TKeyResponse retval; |
|
213 if ( aType == EEventKey ) |
|
214 { |
|
215 if ( aKeyEvent.iCode == EKeyOK ) |
|
216 { // process only if command is available... |
|
217 ProcessCommandL( EApSelCmdSelect ); |
|
218 retval = EKeyWasConsumed; |
|
219 } |
|
220 else |
|
221 { |
|
222 retval = CAknListQueryDialog::OfferKeyEventL( |
|
223 aKeyEvent, aType ); |
|
224 } |
|
225 } |
|
226 else |
|
227 { |
|
228 retval = CAknListQueryDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
229 } |
|
230 |
|
231 APSETUILOGGER_LEAVEFN( EOther,"SelQuery::OfferKeyEventL") |
|
232 return retval; |
|
233 } |
|
234 |
|
235 |
|
236 |
|
237 // From MEikCommandObserver |
|
238 // --------------------------------------------------------- |
|
239 // CApSelQueryDialog::ProcessCommandL |
|
240 // --------------------------------------------------------- |
|
241 // |
|
242 void CApSelQueryDialog::ProcessCommandL( TInt aCommandId ) |
|
243 { |
|
244 APSETUILOGGER_ENTERFN( EOther,"SelQuery::ProcessCommandL") |
|
245 |
|
246 if ( MenuShowing() ) |
|
247 { |
|
248 HideMenu(); |
|
249 } |
|
250 |
|
251 switch ( aCommandId ) |
|
252 { |
|
253 case EAknSoftkeyOptions: |
|
254 { |
|
255 DisplayMenuL(); |
|
256 break; |
|
257 } |
|
258 case EAknSoftkeyBack: |
|
259 { |
|
260 TryExitL( EFalse ); |
|
261 break; |
|
262 } |
|
263 case EApSelCmdSelect: |
|
264 { |
|
265 TryExitL( EAknSoftkeySelect ); |
|
266 break; |
|
267 } |
|
268 case EAknCmdHelp: |
|
269 { |
|
270 FeatureManager::InitializeLibL(); |
|
271 TBool helpSupported = FeatureManager::FeatureSupported( KFeatureIdHelp ); |
|
272 FeatureManager::UnInitializeLib(); |
|
273 if ( helpSupported ) |
|
274 { |
|
275 iDataModel->LaunchHelpL(); |
|
276 } |
|
277 break; |
|
278 } |
|
279 case EApSelCmdExit: |
|
280 case EEikCmdExit: |
|
281 { |
|
282 TryExitL( EFalse ); |
|
283 break; |
|
284 } |
|
285 default: |
|
286 { |
|
287 // silently ignore it |
|
288 break; |
|
289 } |
|
290 } |
|
291 |
|
292 APSETUILOGGER_LEAVEFN( EOther,"SelQuery::ProcessCommandL") |
|
293 } |
|
294 |
|
295 |
|
296 |
|
297 // --------------------------------------------------------- |
|
298 // CApSelQueryDialog::FillListBoxWithDataL() |
|
299 // called when listbopx needs to be filled with data |
|
300 // --------------------------------------------------------- |
|
301 // |
|
302 void CApSelQueryDialog::FillListBoxWithDataL() |
|
303 { |
|
304 APSETUILOGGER_ENTERFN( EOther,"SelQuery::FillListBoxWithDataL") |
|
305 |
|
306 TBool needtopop( EFalse ); |
|
307 |
|
308 if ( ! iModel ) |
|
309 { |
|
310 // we must use temp var to satisfy CodeScanner |
|
311 CApSelectorListboxModel* tmp = new( ELeave )CApSelectorListboxModel( |
|
312 CApSelectorListboxModel::EGraphicProtection ); |
|
313 // although it will be member, but mainly owned by the listbox, |
|
314 // so as long as ownership is not transferred, MUST push it |
|
315 CleanupStack::PushL( tmp ); |
|
316 iModel = tmp; |
|
317 // we need to Pop after ownership is passed to listbox |
|
318 needtopop = ETrue; |
|
319 } |
|
320 TBool isLocked( EFalse ); |
|
321 iNeedUnlock = EFalse; |
|
322 iDataModel->AllListItemDataL( isLocked, *iModel, KEApIspTypeAll, |
|
323 EApBearerTypeAll, KEApSortNameAscending, |
|
324 iDataModel->RequestedIPvType(), |
|
325 EVpnFilterNoVpn, |
|
326 EFalse ); |
|
327 |
|
328 if ( isLocked ) |
|
329 { |
|
330 iNeedUnlock = ETrue; |
|
331 } |
|
332 |
|
333 SetItemTextArray( iModel ); |
|
334 if ( needtopop ) |
|
335 { |
|
336 // it signals that ownership of iModel had JUST been passed, |
|
337 // so we can Pop it. |
|
338 CleanupStack::Pop( iModel); |
|
339 } |
|
340 |
|
341 APSETUILOGGER_LEAVEFN( EOther,"SelQuery::FillListBoxWithDataL") |
|
342 } |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 // --------------------------------------------------------- |
|
348 // CApSelQueryDialog::LoadIconsL() |
|
349 // called when listbox is constructed |
|
350 // --------------------------------------------------------- |
|
351 // |
|
352 TInt CApSelQueryDialog::LoadIconsL() |
|
353 { |
|
354 APSETUILOGGER_ENTERFN( EOther,"SelQuery::LoadIconsL") |
|
355 |
|
356 CArrayPtr< CGulIcon >* icons = new( ELeave ) CAknIconArray( KGranularity ); |
|
357 CleanupStack::PushL( icons ); |
|
358 |
|
359 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
360 |
|
361 TParse mbmFile; |
|
362 User::LeaveIfError( mbmFile.Set( KFileIcons, &KDC_APP_BITMAP_DIR, NULL ) ); |
|
363 |
|
364 icons->AppendL( AknsUtils::CreateGulIconL( |
|
365 skinInstance, |
|
366 KAknsIIDQgnIndiSettProtectedAdd, |
|
367 mbmFile.FullName(), |
|
368 EMbmApsettingsQgn_indi_sett_protected_add, |
|
369 EMbmApsettingsQgn_indi_sett_protected_add_mask ) ); |
|
370 |
|
371 SetIconArrayL( icons ); |
|
372 |
|
373 CleanupStack::Pop(); // icons |
|
374 |
|
375 APSETUILOGGER_LEAVEFN( EOther,"SelQuery::LoadIconsL") |
|
376 return 0; |
|
377 } |
|
378 |
|
379 // End of File |
|