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: WLAN Ipv4 settings dialog |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <StringLoader.h> |
|
19 #include <akntitle.h> |
|
20 #include <akntextsettingpage.h> |
|
21 #include <aknmfnesettingpage.h> // for IP dialog |
|
22 #include <cmcommonui.h> |
|
23 #include <cmwlanui.rsg> |
|
24 #include <cmmanager.rsg> |
|
25 #include <csxhelp/cp.hlp.hrh> |
|
26 |
|
27 #include <cmpluginbaseeng.h> |
|
28 #include <cmpluginwlandef.h> |
|
29 #include "cmpwlansettingsdlgipv4.h" |
|
30 #include "cmwlancommonconstants.h" |
|
31 #include "cmpluginmenucommands.hrh" |
|
32 #include "cmpluginmultilinedialog.h" |
|
33 #include <cmcommonconstants.h> |
|
34 #include <cmpsettingsconsts.h> |
|
35 #include "cmmanagerimpl.h" |
|
36 |
|
37 using namespace CMManager; |
|
38 |
|
39 // ================= MEMBER FUNCTIONS ========================================= |
|
40 |
|
41 // -------------------------------------------------------------------------- |
|
42 // CmPluginWlanSettingsDlgIpv4::NewL |
|
43 // Two-phase dconstructor, second phase is ConstructAndRunLD |
|
44 // -------------------------------------------------------------------------- |
|
45 // |
|
46 CmPluginWlanSettingsDlgIpv4* CmPluginWlanSettingsDlgIpv4::NewL( |
|
47 CCmPluginBaseEng& aCmPluginBase ) |
|
48 { |
|
49 CmPluginWlanSettingsDlgIpv4* self = |
|
50 new ( ELeave ) CmPluginWlanSettingsDlgIpv4( aCmPluginBase ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // -------------------------------------------------------------------------- |
|
55 // CmPluginWlanSettingsDlgIpv4::CmPluginWlanSettingsDlgIpv4 |
|
56 // -------------------------------------------------------------------------- |
|
57 // |
|
58 CmPluginWlanSettingsDlgIpv4::CmPluginWlanSettingsDlgIpv4( |
|
59 CCmPluginBaseEng& aCmPluginBase ) : |
|
60 CmPluginBaseSettingsDlgIp( aCmPluginBase ) , |
|
61 iParent( NULL ) |
|
62 { |
|
63 iHelpContext = KSET_HLP_AP_WLAN_AS_IPV4; |
|
64 } |
|
65 |
|
66 // -------------------------------------------------------------------------- |
|
67 // CmPluginWlanSettingsDlgIpv4::ConstructAndRunLD |
|
68 // -------------------------------------------------------------------------- |
|
69 // |
|
70 TInt CmPluginWlanSettingsDlgIpv4::ConstructAndRunLD() |
|
71 { |
|
72 // Set this flag to allow edit continue |
|
73 iCanEditingContinue = ETrue; |
|
74 |
|
75 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr(); |
|
76 cmMgr.WatcherRegisterL( this ); |
|
77 |
|
78 return CmPluginBaseSettingsDlgIp::ConstructAndRunLD(); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------- |
|
82 // CmPluginWlanSettingsDlgIpv4::~CmPluginWlanSettingsDlgIpv4 |
|
83 // Destructor |
|
84 // --------------------------------------------------------- |
|
85 // |
|
86 CmPluginWlanSettingsDlgIpv4::~CmPluginWlanSettingsDlgIpv4() |
|
87 { |
|
88 } |
|
89 |
|
90 |
|
91 // -------------------------------------------------------------------------- |
|
92 // CmPluginWlanSettingsDlgIpv4::UpdateListBoxContentBearerSpecificL |
|
93 // -------------------------------------------------------------------------- |
|
94 // |
|
95 void CmPluginWlanSettingsDlgIpv4::UpdateListBoxContentBearerSpecificL( |
|
96 CDesCArray& aItemArray ) |
|
97 { |
|
98 // PHONE IP ADDRESS |
|
99 AppendSettingTextsL( aItemArray, EWlanIpAddr ); |
|
100 HBufC* ipAddr = iCmPluginBaseEng.GetStringAttributeL( EWlanIpAddr ); |
|
101 TBool isUnspec = IsUnspecifiedIPv4Address( *ipAddr ); |
|
102 delete ipAddr; ipAddr = NULL; |
|
103 |
|
104 if ( !isUnspec ) |
|
105 { |
|
106 // SUBNET MASK |
|
107 AppendSettingTextsL( aItemArray, EWlanIpNetMask ); |
|
108 // DEFAULT GATEWAY |
|
109 AppendSettingTextsL( aItemArray, EWlanIpGateway ); |
|
110 } |
|
111 |
|
112 // DNS SERVERS IP ADDRESS |
|
113 TBool boolValue = iCmPluginBaseEng.GetBoolAttributeL( |
|
114 EWlanIpDNSAddrFromServer ); |
|
115 AppendSettingTextsL( aItemArray, |
|
116 EWlanIpDNSAddrFromServer, |
|
117 boolValue ? |
|
118 R_QTN_SET_DNS_SERVERS_AUTOMATIC : |
|
119 R_QTN_SET_IP_USER_DEFINED ); |
|
120 } |
|
121 |
|
122 //--------------------------------------------------------------------------- |
|
123 // CmPluginWlanSettingsDlgIpv4::ShowPopupSettingPageL |
|
124 //--------------------------------------------------------------------------- |
|
125 // |
|
126 TBool CmPluginWlanSettingsDlgIpv4::ShowPopupSettingPageL( TUint32 aAttribute, |
|
127 TInt aCommandId ) |
|
128 { |
|
129 TBool retval = EFalse; |
|
130 switch ( aAttribute ) |
|
131 { |
|
132 case EWlanIpDNSAddrFromServer: |
|
133 { |
|
134 ShowPopupIPv4DNSEditorL( EWlanIpDNSAddrFromServer, |
|
135 EWlanIpNameServer1, |
|
136 EWlanIpNameServer2 ); |
|
137 break; |
|
138 } |
|
139 case EWlanIpAddr: |
|
140 case EWlanIpNetMask: |
|
141 case EWlanIpGateway: |
|
142 { |
|
143 ShowPopupIpSettingPageL( aAttribute ); |
|
144 break; |
|
145 } |
|
146 default: |
|
147 { |
|
148 CmPluginBaseSettingsDlgIp::ShowPopupSettingPageL( aAttribute, |
|
149 aCommandId ); |
|
150 break; |
|
151 } |
|
152 } |
|
153 return retval; |
|
154 } |
|
155 |
|
156 |
|
157 //--------------------------------------------------------------------------- |
|
158 // CmPluginWlanSettingsDlgIpv4::ProcessCommandL |
|
159 //--------------------------------------------------------------------------- |
|
160 // |
|
161 void CmPluginWlanSettingsDlgIpv4::ProcessCommandL( TInt aCommandId ) |
|
162 { |
|
163 if ( !iCanEditingContinue ) |
|
164 { |
|
165 // We have to block all editing activity if database changed by |
|
166 // other application |
|
167 return; |
|
168 } |
|
169 |
|
170 if ( MenuShowing() ) |
|
171 { |
|
172 HideMenu(); |
|
173 } |
|
174 |
|
175 switch ( aCommandId ) |
|
176 { |
|
177 case EPluginBaseCmdExit: |
|
178 { |
|
179 if ( ValidateAttribsL() ) |
|
180 { |
|
181 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr(); |
|
182 cmMgr.WatcherUnRegister(); |
|
183 |
|
184 iExitReason = KDialogUserExit; |
|
185 TryExitL( iExitReason ); |
|
186 } |
|
187 break; |
|
188 } |
|
189 case EPluginBaseCmdChange: |
|
190 { |
|
191 ShowPopupSettingPageL( |
|
192 iSettingIndex->At( iListbox->CurrentItemIndex() ), |
|
193 aCommandId ); |
|
194 break; |
|
195 } |
|
196 default: |
|
197 { |
|
198 CmPluginBaseSettingsDlgIp::ProcessCommandL( aCommandId ); |
|
199 break; |
|
200 } |
|
201 } |
|
202 } |
|
203 |
|
204 // -------------------------------------------------------------------------- |
|
205 // CmPluginWlanSettingsDlgIpv4::OkToExitL |
|
206 // -------------------------------------------------------------------------- |
|
207 // |
|
208 TBool CmPluginWlanSettingsDlgIpv4::OkToExitL( TInt aButtonId ) |
|
209 { |
|
210 // Database has been changed by other application so exit from this view |
|
211 // without update editings to database |
|
212 if ( !iCanEditingContinue ) |
|
213 { |
|
214 if ( iExitReason == KDialogUserExit ) |
|
215 { |
|
216 iCmPluginBaseEng.CmMgr().WatcherUnRegister(); |
|
217 |
|
218 // Set iExitReason back to KDialogUserBack so as to exit from this view through else in the next call |
|
219 TInt exitValue = KDialogUserExit; |
|
220 iExitReason = KDialogUserBack; |
|
221 // If destination has been deleted by other application |
|
222 // then we may have to exit from Cmmgr |
|
223 TryExitL( exitValue ); |
|
224 return EFalse; |
|
225 } |
|
226 else |
|
227 { |
|
228 // Exit from this view here to avoid possible update to databse |
|
229 return ETrue; |
|
230 } |
|
231 } |
|
232 |
|
233 TBool retval( EFalse ); |
|
234 |
|
235 switch ( aButtonId ) |
|
236 { |
|
237 case EAknSoftkeyOk: |
|
238 case EAknSoftkeyChange: |
|
239 { |
|
240 ProcessCommandL( EPluginBaseCmdChange ); |
|
241 break; |
|
242 } |
|
243 case EAknSoftkeyBack: |
|
244 { |
|
245 if ( ValidateAttribsL() ) |
|
246 { |
|
247 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr(); |
|
248 cmMgr.WatcherUnRegister(); |
|
249 |
|
250 iExitReason = KDialogUserBack; |
|
251 retval = ETrue; |
|
252 } |
|
253 break; |
|
254 } |
|
255 default: |
|
256 { |
|
257 retval = CmPluginBaseSettingsDlgIp::OkToExitL( aButtonId ); |
|
258 break; |
|
259 } |
|
260 } |
|
261 return retval; |
|
262 } |
|
263 |
|
264 // -------------------------------------------------------------------------- |
|
265 // CmPluginWlanSettingsDlgIpv4::ValidateAttribsL |
|
266 // -------------------------------------------------------------------------- |
|
267 // |
|
268 TBool CmPluginWlanSettingsDlgIpv4::ValidateAttribsL() |
|
269 { |
|
270 TBool retVal ( EFalse ); |
|
271 HBufC* ipAddr = iCmPluginBaseEng.GetStringAttributeL( EWlanIpAddr ); |
|
272 TBool isUnspec = IsUnspecifiedIPv4Address( *ipAddr ); |
|
273 delete ipAddr; ipAddr = NULL; |
|
274 |
|
275 if ( !isUnspec ) |
|
276 { |
|
277 ipAddr = iCmPluginBaseEng.GetStringAttributeL( EWlanIpNetMask ); |
|
278 TBool isUnspec1 = IsUnspecifiedIPv4Address( *ipAddr ); |
|
279 delete ipAddr; |
|
280 ipAddr = iCmPluginBaseEng.GetStringAttributeL( EWlanIpGateway ); |
|
281 TBool isUnspec2 = IsUnspecifiedIPv4Address( *ipAddr ); |
|
282 delete ipAddr; |
|
283 |
|
284 if ( isUnspec1 || isUnspec2 ) |
|
285 { |
|
286 if ( TCmCommonUi::ShowConfirmationQueryL( |
|
287 R_QTN_NETW_QUEST_IAP_INCOMPLETE_DELETE ) ) |
|
288 { |
|
289 // quit without saving, so restore attributes |
|
290 iCmPluginBaseEng.RestoreAttributeL( EWlanIpAddr ); |
|
291 iCmPluginBaseEng.RestoreAttributeL( EWlanIpNetMask ); |
|
292 iCmPluginBaseEng.RestoreAttributeL( EWlanIpGateway ); |
|
293 iCmPluginBaseEng.RestoreAttributeL( EWlanIpDNSAddrFromServer ); |
|
294 retVal = ETrue; |
|
295 } |
|
296 } |
|
297 else |
|
298 { |
|
299 retVal = ETrue; |
|
300 } |
|
301 } |
|
302 else |
|
303 { |
|
304 retVal = ETrue; |
|
305 } |
|
306 |
|
307 return retVal; |
|
308 } |
|
309 |
|
310 // -------------------------------------------------------------------------- |
|
311 // CmPluginWlanSettingsDlgIpv4::InitTextsL |
|
312 // -------------------------------------------------------------------------- |
|
313 // |
|
314 void CmPluginWlanSettingsDlgIpv4::InitTextsL() |
|
315 { |
|
316 // set pane text if neccessary... |
|
317 // pane text needed if not pop-up... |
|
318 if ( iEikonEnv ) |
|
319 { |
|
320 iStatusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
321 iTitlePane = |
|
322 ( CAknTitlePane* )iStatusPane->ControlL( |
|
323 TUid::Uid( EEikStatusPaneUidTitle ) ); |
|
324 |
|
325 iOldTitleText = iTitlePane->Text()->AllocL(); |
|
326 HBufC* title = StringLoader::LoadLC ( R_QTN_SET_IPV4_SETTINGS ); |
|
327 iTitlePane->SetTextL( *title ) ; |
|
328 CleanupStack::PopAndDestroy(title); |
|
329 iNaviPane = ( CAknNavigationControlContainer* ) |
|
330 iStatusPane->ControlL( |
|
331 TUid::Uid( EEikStatusPaneUidNavi ) ); |
|
332 iNaviDecorator = iNaviPane->CreateNavigationLabelL( KNullDesC ); |
|
333 iNaviPane->PushL( *iNaviDecorator ); |
|
334 } |
|
335 } |
|
336 |
|
337 // -------------------------------------------------------------------------- |
|
338 // CmPluginWlanSettingsDlgIpv4::RegisterParentView |
|
339 // -------------------------------------------------------------------------- |
|
340 // |
|
341 void CmPluginWlanSettingsDlgIpv4::RegisterParentView( CCmParentViewNotifier* aParent ) |
|
342 { |
|
343 iParent = aParent; |
|
344 } |
|
345 |
|
346 // -------------------------------------------------------------------------- |
|
347 // CmPluginWlanSettingsDlgIpv4::CommsDatChangesL |
|
348 // -------------------------------------------------------------------------- |
|
349 // |
|
350 void CmPluginWlanSettingsDlgIpv4::CommsDatChangesL() |
|
351 { |
|
352 if ( !iCanEditingContinue ) |
|
353 { |
|
354 return; |
|
355 } |
|
356 |
|
357 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr(); |
|
358 CCmDestinationImpl* parentDest = iCmPluginBaseEng.ParentDestination(); |
|
359 |
|
360 if ( parentDest ) |
|
361 { |
|
362 if( !cmMgr.DestinationStillExistedL( parentDest ) ) |
|
363 { |
|
364 if( iParent ) |
|
365 { |
|
366 iParent->NotifyParentView( KCmNotifiedDestinationDisappear ); |
|
367 } |
|
368 |
|
369 // If parent destination is deleted by somebody then the dialog must exit back to main view |
|
370 iExitReason = KDialogUserExit; |
|
371 iCanEditingContinue = EFalse; |
|
372 |
|
373 cmMgr.RemoveDestFromPool( parentDest ); |
|
374 delete parentDest; |
|
375 return; |
|
376 } |
|
377 |
|
378 // We may have to go back to parent view if database is changed by other application |
|
379 if( iParent ) |
|
380 { |
|
381 iParent->NotifyParentView( KCmNotifiedIapDisappear ); |
|
382 } |
|
383 iCanEditingContinue = EFalse; |
|
384 |
|
385 cmMgr.RemoveDestFromPool( parentDest ); |
|
386 delete parentDest; |
|
387 } |
|
388 else // Legacy |
|
389 { |
|
390 // We may have to go back to parent view if database is changed by other application |
|
391 if( iParent ) |
|
392 { |
|
393 iParent->NotifyParentView( KCmNotifiedIapDisappear ); |
|
394 } |
|
395 iCanEditingContinue = EFalse; |
|
396 } |
|
397 } |
|