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: Dialog for editing packet data settings for a packet data |
|
15 * connection method |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 // System |
|
22 #include <StringLoader.h> |
|
23 #include <akntextsettingpage.h> |
|
24 #include <cmpacketdataui.rsg> |
|
25 #include <cmmanager.rsg> |
|
26 #include <csxhelp/cp.hlp.hrh> |
|
27 |
|
28 // User |
|
29 #include "cmlogger.h" |
|
30 #include "cmpacketdatacommonconstants.h" |
|
31 #include <cmpluginpacketdatadef.h> |
|
32 #include "cmppacketdatasettingsdlg.h" |
|
33 #include "cmppacketdatasettingsdlgadv.h" |
|
34 #include "cmpluginpacketdata.h" |
|
35 #include "cmpluginmenucommands.hrh" |
|
36 #include <cmcommonconstants.h> |
|
37 #include <cmpsettingsconsts.h> |
|
38 #include "cmmanagerimpl.h" |
|
39 |
|
40 using namespace CMManager; |
|
41 |
|
42 const TUint32 KPlainAuthSelectionItems[] = |
|
43 { |
|
44 R_QTN_SET_PASSWD_AUT_NORMAL, |
|
45 R_QTN_SET_PASSWD_AUT_SECURE, |
|
46 0 |
|
47 }; |
|
48 |
|
49 const TUint32 KPromptForAuthSelectionItems[] = |
|
50 { |
|
51 R_QTN_SET_PROMPT_PASSWD_NO, |
|
52 R_QTN_SET_PROMPT_PASSWD_YES, |
|
53 0 |
|
54 }; |
|
55 |
|
56 // ================= MEMBER FUNCTIONS ======================================= |
|
57 |
|
58 // -------------------------------------------------------------------------- |
|
59 // CmPluginPacketDataSettingsDlg::NewL() |
|
60 // Two-phase dconstructor, second phase is ConstructAndRunLD |
|
61 // -------------------------------------------------------------------------- |
|
62 // |
|
63 CmPluginPacketDataSettingsDlg* CmPluginPacketDataSettingsDlg::NewL( |
|
64 CCmPluginBaseEng& aCmPluginBase ) |
|
65 { |
|
66 CmPluginPacketDataSettingsDlg* self = |
|
67 new ( ELeave ) CmPluginPacketDataSettingsDlg( aCmPluginBase ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // -------------------------------------------------------------------------- |
|
72 // CmPluginPacketDataSettingsDlg::CmPluginPacketDataSettingsDlg() |
|
73 // -------------------------------------------------------------------------- |
|
74 // |
|
75 CmPluginPacketDataSettingsDlg::CmPluginPacketDataSettingsDlg( |
|
76 CCmPluginBaseEng& aCmPluginBase ) |
|
77 : CmPluginBaseSettingsDlg( aCmPluginBase ) |
|
78 , iNotifyFromSon( KCmNotifiedNone ) |
|
79 { |
|
80 |
|
81 } |
|
82 |
|
83 // -------------------------------------------------------------------------- |
|
84 // CmPluginPacketDataSettingsDlg::UpdateListBoxContentL |
|
85 // -------------------------------------------------------------------------- |
|
86 // |
|
87 void CmPluginPacketDataSettingsDlg::UpdateListBoxContentL() |
|
88 { |
|
89 CmPluginBaseSettingsDlg::UpdateListBoxContentL(); |
|
90 } |
|
91 |
|
92 //--------------------------------------------------------------------------- |
|
93 // CmPluginPacketDataSettingsDlg::ConstructAndRunLD |
|
94 // -------------------------------------------------------------------------- |
|
95 // |
|
96 |
|
97 TInt CmPluginPacketDataSettingsDlg::ConstructAndRunLD( ) |
|
98 { |
|
99 CleanupStack::PushL( this ); |
|
100 LoadResourceL( KPluginPacketDataResDirAndFileName ); |
|
101 CleanupStack::Pop( this ); |
|
102 |
|
103 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr(); |
|
104 cmMgr.WatcherRegisterL( this ); |
|
105 |
|
106 return CmPluginBaseSettingsDlg::ConstructAndRunLD( ); |
|
107 } |
|
108 |
|
109 |
|
110 // -------------------------------------------------------------------------- |
|
111 // CmPluginPacketDataSettingsDlg::~CmPluginPacketDataSettingsDlg |
|
112 // Destructor |
|
113 // -------------------------------------------------------------------------- |
|
114 // |
|
115 CmPluginPacketDataSettingsDlg::~CmPluginPacketDataSettingsDlg() |
|
116 { |
|
117 iResourceReader.Close(); |
|
118 } |
|
119 |
|
120 // -------------------------------------------------------------------------- |
|
121 // CmPluginBaseSettingsDlg::RunAdvancedSettingsL |
|
122 // -------------------------------------------------------------------------- |
|
123 // |
|
124 void CmPluginPacketDataSettingsDlg::RunAdvancedSettingsL() |
|
125 { |
|
126 CmPluginPacketDataSettingsDlgAdv* advDlg = |
|
127 CmPluginPacketDataSettingsDlgAdv::NewL( iCmPluginBaseEng ); |
|
128 |
|
129 // This view may have to un-register as watcher here |
|
130 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr(); |
|
131 cmMgr.WatcherUnRegister(); |
|
132 |
|
133 advDlg->RegisterParentView( this ); |
|
134 TInt ret = advDlg->ConstructAndRunLD(); |
|
135 |
|
136 if( iNotifyFromSon == KCmNotifiedNone ) |
|
137 { |
|
138 if( ret == KDialogUserExit ) |
|
139 { |
|
140 iExitReason = KDialogUserExit; |
|
141 TryExitL( iExitReason ); |
|
142 } |
|
143 else |
|
144 { |
|
145 // Re-register as watcher if advanced view comes back or exists normally |
|
146 cmMgr.WatcherRegisterL( this ); |
|
147 } |
|
148 } |
|
149 else |
|
150 { |
|
151 HandleCommsDatChangeL(); |
|
152 } |
|
153 } |
|
154 |
|
155 // -------------------------------------------------------------------------- |
|
156 // CmPluginBaseSettingsDlg::UpdateListBoxContentBearerSpecificL |
|
157 // -------------------------------------------------------------------------- |
|
158 // |
|
159 void CmPluginPacketDataSettingsDlg::UpdateListBoxContentBearerSpecificL( |
|
160 CDesCArray& aItemArray ) |
|
161 { |
|
162 LOGGER_ENTERFN( "CmPluginPacketDataSettingsDlg::UpdateListBoxContentBearerSpecificL" ); |
|
163 |
|
164 TBool boolSettingVal( EFalse ); // just for helping make code readable |
|
165 |
|
166 // DATA BEARER - only for real bearer types |
|
167 AppendSettingTextsL( aItemArray, ECmBearerSettingName ); |
|
168 // AP NAME |
|
169 AppendSettingTextsL( aItemArray, EPacketDataAPName ); |
|
170 // USER NAME |
|
171 AppendSettingTextsL( aItemArray, EPacketDataIFAuthName ); |
|
172 // PROMPT PASSWORD |
|
173 boolSettingVal = iCmPluginBaseEng.GetBoolAttributeL( |
|
174 EPacketDataIFPromptForAuth ); |
|
175 AppendSettingTextsL( aItemArray, EPacketDataIFPromptForAuth, |
|
176 boolSettingVal ? |
|
177 R_QTN_SET_PROMPT_PASSWD_YES : |
|
178 R_QTN_SET_PROMPT_PASSWD_NO ); |
|
179 // PASSWORD |
|
180 AppendSettingTextsL( aItemArray, EPacketDataIFAuthPass ); |
|
181 // PASSWORD AUTHENTICATION |
|
182 boolSettingVal = iCmPluginBaseEng.GetBoolAttributeL( |
|
183 EPacketDataDisablePlainTextAuth ); |
|
184 AppendSettingTextsL( aItemArray, |
|
185 EPacketDataDisablePlainTextAuth, |
|
186 boolSettingVal ? |
|
187 R_QTN_SET_PASSWD_AUT_SECURE : |
|
188 R_QTN_SET_PASSWD_AUT_NORMAL ); |
|
189 // HOMEPAGE |
|
190 AppendSettingTextsL( aItemArray, ECmStartPage ); |
|
191 } |
|
192 |
|
193 // -------------------------------------------------------------------------- |
|
194 // CmPluginPacketDataSettingsDlg::ChangeBoolSettingL |
|
195 // -------------------------------------------------------------------------- |
|
196 // |
|
197 TBool CmPluginPacketDataSettingsDlg::ChangeBoolSettingL( TUint32 aAttribute, |
|
198 TInt aCommandId ) |
|
199 { |
|
200 LOGGER_ENTERFN( "CmPluginPacketDataSettingsDlg::ChangeBoolSettingL" ); |
|
201 |
|
202 if ( aCommandId == EPluginBaseCmdChange ) |
|
203 { |
|
204 const TUint32* items = NULL; |
|
205 TInt titleResId(0); |
|
206 |
|
207 // Add the list items |
|
208 switch ( aAttribute ) |
|
209 { |
|
210 case EPacketDataDisablePlainTextAuth: |
|
211 { |
|
212 titleResId = R_QTN_SET_PASSWD_AUT; |
|
213 items = KPlainAuthSelectionItems; |
|
214 break; |
|
215 } |
|
216 case EPacketDataIFPromptForAuth: |
|
217 { |
|
218 titleResId = R_QTN_SET_PROMPT_PASSWD; |
|
219 items = KPromptForAuthSelectionItems; |
|
220 break; |
|
221 } |
|
222 default: |
|
223 { |
|
224 User::Leave( KErrNotSupported ); |
|
225 } |
|
226 } |
|
227 |
|
228 TInt selected = iCmPluginBaseEng.GetBoolAttributeL( aAttribute ); |
|
229 TInt originalValue = selected; |
|
230 if ( ShowRadioButtonSettingPageL( items, |
|
231 selected, |
|
232 titleResId ) && |
|
233 originalValue != selected ) |
|
234 { |
|
235 iCmPluginBaseEng.SetBoolAttributeL( aAttribute, selected ); |
|
236 UpdateListBoxContentL(); |
|
237 } |
|
238 |
|
239 return selected; |
|
240 } |
|
241 else |
|
242 { |
|
243 TBool boolFromCM = boolFromCM = |
|
244 iCmPluginBaseEng.GetBoolAttributeL( aAttribute ); |
|
245 iCmPluginBaseEng.SetBoolAttributeL( aAttribute, !boolFromCM ); |
|
246 UpdateListBoxContentL(); |
|
247 return !boolFromCM; |
|
248 } |
|
249 } |
|
250 |
|
251 // -------------------------------------------------------------------------- |
|
252 // CmPluginPacketDataSettingsDlg::ShowPopupSettingPageL |
|
253 // -------------------------------------------------------------------------- |
|
254 // |
|
255 TBool CmPluginPacketDataSettingsDlg::ShowPopupSettingPageL( |
|
256 TUint32 aAttribute, TInt aCommandId ) |
|
257 { |
|
258 LOGGER_ENTERFN( "CmPluginPacketDataSettingsDlg::ShowPopupSettingPageL" ); |
|
259 |
|
260 TBool retval = EFalse; |
|
261 switch ( aAttribute ) |
|
262 { |
|
263 case EPacketDataIFAuthPass: |
|
264 { |
|
265 retval = ShowPopupPasswordSettingPageL( aAttribute ); |
|
266 break; |
|
267 } |
|
268 case EPacketDataDisablePlainTextAuth: |
|
269 case EPacketDataIFPromptForAuth: |
|
270 { |
|
271 ChangeBoolSettingL( aAttribute, aCommandId ); |
|
272 break; |
|
273 } |
|
274 default: |
|
275 { |
|
276 CmPluginBaseSettingsDlg::ShowPopupSettingPageL( aAttribute, |
|
277 aCommandId ); |
|
278 break; |
|
279 } |
|
280 } |
|
281 return retval; |
|
282 } |
|
283 |
|
284 |
|
285 // -------------------------------------------------------------------------- |
|
286 // CmPluginPacketDataSettingsDlg::ProcessCommandL |
|
287 // -------------------------------------------------------------------------- |
|
288 // |
|
289 void CmPluginPacketDataSettingsDlg::ProcessCommandL( TInt aCommandId ) |
|
290 { |
|
291 LOGGER_ENTERFN( "CmPluginPacketDataSettingsDlg::ProcessCommandL" ); |
|
292 |
|
293 if ( MenuShowing() ) |
|
294 { |
|
295 HideMenu(); |
|
296 } |
|
297 |
|
298 switch ( aCommandId ) |
|
299 { |
|
300 case EPluginBaseCmdAdvanced: |
|
301 { |
|
302 RunAdvancedSettingsL(); |
|
303 break; |
|
304 } |
|
305 case EPluginBaseCmdChange: // flow to EAknSoftkeyOk |
|
306 case EAknSoftkeyOk: |
|
307 { |
|
308 TInt attrib = iSettingIndex->At( iListbox->CurrentItemIndex() ); |
|
309 ShowPopupSettingPageL( attrib, aCommandId ); |
|
310 break; |
|
311 } |
|
312 default: |
|
313 { |
|
314 CmPluginBaseSettingsDlg::ProcessCommandL( aCommandId ); |
|
315 break; |
|
316 } |
|
317 } |
|
318 } |
|
319 |
|
320 // -------------------------------------------------------------------------- |
|
321 // CmPluginPacketDataSettingsDlg::OkToExitL |
|
322 // -------------------------------------------------------------------------- |
|
323 // |
|
324 TBool CmPluginPacketDataSettingsDlg::OkToExitL( TInt aButtonId ) |
|
325 { |
|
326 TBool retval( EFalse ); |
|
327 |
|
328 switch ( aButtonId ) |
|
329 { |
|
330 case EPluginBaseCmdExit: |
|
331 case EAknSoftkeyBack: |
|
332 { |
|
333 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr(); |
|
334 cmMgr.WatcherUnRegister(); |
|
335 } |
|
336 default: |
|
337 { |
|
338 retval = CmPluginBaseSettingsDlg::OkToExitL( aButtonId ); |
|
339 break; |
|
340 } |
|
341 } |
|
342 |
|
343 return retval; |
|
344 } |
|
345 |
|
346 // -------------------------------------------------------------------------- |
|
347 // CmPluginPacketDataSettingsDlg::GetHelpContext |
|
348 // -------------------------------------------------------------------------- |
|
349 // |
|
350 |
|
351 void CmPluginPacketDataSettingsDlg::GetHelpContext( TCoeHelpContext& aContext ) const |
|
352 { |
|
353 LOGGER_ENTERFN( "CmPluginPacketDataSettingsDlg::GetHelpContext" ); |
|
354 |
|
355 aContext.iMajor = KHelpUidPlugin; |
|
356 aContext.iContext = KSET_HLP_AP_SETTING_GPRS; |
|
357 } |
|
358 |
|
359 // -------------------------------------------------------------------------- |
|
360 // CmPluginPacketDataSettingsDlg::CommsDatChangesL |
|
361 // -------------------------------------------------------------------------- |
|
362 // |
|
363 void CmPluginPacketDataSettingsDlg::CommsDatChangesL() |
|
364 { |
|
365 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr(); |
|
366 CCmDestinationImpl* parentDest = iCmPluginBaseEng.ParentDestination(); |
|
367 |
|
368 if ( parentDest ) |
|
369 { |
|
370 if( !cmMgr.DestinationStillExistedL( parentDest ) ) |
|
371 { |
|
372 cmMgr.WatcherUnRegister(); |
|
373 // If parent destination diappears with some reason |
|
374 // then the view must exit back to main view for it |
|
375 // may be danger if going back to parent view |
|
376 iExitReason = KDialogUserExit; |
|
377 TryExitL( iExitReason ); |
|
378 |
|
379 cmMgr.RemoveDestFromPool( parentDest ); |
|
380 delete parentDest; |
|
381 return; |
|
382 } |
|
383 |
|
384 if( !cmMgr.IsIapStillInDestL( parentDest, iCmPluginBaseEng ) ) |
|
385 { |
|
386 cmMgr.WatcherUnRegister(); |
|
387 // In this case, the view can go back to the parent view |
|
388 TryExitL( iExitReason ); |
|
389 |
|
390 cmMgr.RemoveDestFromPool( parentDest ); |
|
391 delete parentDest; |
|
392 return; |
|
393 } |
|
394 |
|
395 // We may have to go back to parent view even though this Iap is still in CommsDat |
|
396 // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more |
|
397 // after this call when some Iap is deleted. |
|
398 cmMgr.WatcherUnRegister(); |
|
399 TryExitL( iExitReason ); |
|
400 |
|
401 cmMgr.RemoveDestFromPool( parentDest ); |
|
402 delete parentDest; |
|
403 } |
|
404 else |
|
405 { |
|
406 if( !cmMgr.IapStillExistedL( iCmPluginBaseEng ) ) |
|
407 { |
|
408 cmMgr.WatcherUnRegister(); |
|
409 // In this case, the dialog can go back to the parent view |
|
410 TryExitL( iExitReason ); |
|
411 return; |
|
412 } |
|
413 |
|
414 // We may have to go back to parent view even though this Iap is still in CommsDat |
|
415 // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more |
|
416 // after this call when some Iap is deleted. |
|
417 cmMgr.WatcherUnRegister(); |
|
418 TryExitL( iExitReason ); |
|
419 } |
|
420 } |
|
421 |
|
422 // -------------------------------------------------------------------------- |
|
423 // CmPluginPacketDataSettingsDlg::NotifyParentView |
|
424 // -------------------------------------------------------------------------- |
|
425 // |
|
426 void CmPluginPacketDataSettingsDlg::NotifyParentView( TInt aValue ) |
|
427 { |
|
428 iNotifyFromSon = aValue; |
|
429 } |
|
430 |
|
431 // -------------------------------------------------------------------------- |
|
432 // CmPluginPacketDataSettingsDlg::HandleCommsDatChangeL |
|
433 // -------------------------------------------------------------------------- |
|
434 // |
|
435 void CmPluginPacketDataSettingsDlg::HandleCommsDatChangeL() |
|
436 { |
|
437 if( iNotifyFromSon == KCmNotifiedIapIsNotInThisDestination || |
|
438 iNotifyFromSon == KCmNotifiedIapDisappear ) |
|
439 { |
|
440 TryExitL( iExitReason ); |
|
441 } |
|
442 else if( iNotifyFromSon == KCmNotifiedDestinationDisappear ) |
|
443 { |
|
444 iExitReason = KDialogUserExit; |
|
445 TryExitL( iExitReason ); |
|
446 } |
|
447 } |
|