22 #include <cmsettingsui.h> |
22 #include <cmsettingsui.h> |
23 #include <cmapplicationsettingsui.h> |
23 #include <cmapplicationsettingsui.h> |
24 #include <cmdestinationext.h> |
24 #include <cmdestinationext.h> |
25 #include <cmpluginvpndef.h> |
25 #include <cmpluginvpndef.h> |
26 #include <commdb.h> |
26 #include <commdb.h> |
27 #include <e32def.h> |
|
28 |
|
29 #include <vpnmanagementuirsc.rsg> |
27 #include <vpnmanagementuirsc.rsg> |
30 #include "vpnuiloader.h" |
28 #include "vpnuiloader.h" |
31 #include "vpnmanagementuiserversettingscontainer.h" |
29 #include "vpnmanagementuiserversettingscontainer.h" |
32 #include "vpnmanagementuidefs.h" |
30 #include "vpnmanagementuidefs.h" |
33 #include "serversettingconnectionsettingitem.h" |
31 #include "serversettingconnectionsettingitem.h" |
78 // --------------------------------------------------------------------------- |
76 // --------------------------------------------------------------------------- |
79 // CreateSettingItemL |
77 // CreateSettingItemL |
80 // --------------------------------------------------------------------------- |
78 // --------------------------------------------------------------------------- |
81 // |
79 // |
82 CAknSettingItem* CServerSettingsContainer::CreateSettingItemL( |
80 CAknSettingItem* CServerSettingsContainer::CreateSettingItemL( |
83 TInt aSettingId ) |
81 TInt /* aSettingId */) |
84 { |
82 { |
85 CAknSettingItem* settingItem(NULL); |
83 CAknSettingItem* settingItem(NULL); |
86 |
84 /*** NSSM support is discontinued. |
|
85 Code is kept in comments temporarily because similar UI functionality |
|
86 might be needed for another purpose. |
87 switch (aSettingId) |
87 switch (aSettingId) |
88 { |
88 { |
89 case EVpnUiSettingServerName: |
89 case EVpnUiSettingServerName: |
90 settingItem = new (ELeave) CAknTextSettingItem( |
90 settingItem = new (ELeave) CAknTextSettingItem( |
91 aSettingId, iServerDetails.iServerNameLocal ); |
91 aSettingId, iServerDetails.iServerNameLocal ); |
96 iServerAddressBuffer.Copy(iServerDetails.iServerUrl); |
96 iServerAddressBuffer.Copy(iServerDetails.iServerUrl); |
97 } |
97 } |
98 settingItem = new (ELeave) CAknTextSettingItem( |
98 settingItem = new (ELeave) CAknTextSettingItem( |
99 aSettingId, iServerAddressBuffer ); |
99 aSettingId, iServerAddressBuffer ); |
100 break; |
100 break; |
101 case EVpnUiSettingIap: |
101 case EVpnUiSettingIap: |
102 if ( iServerDetails.iSelection.iId <1 ) |
102 settingItem = new (ELeave) CServerSettingConnectionSettingItem( |
103 { |
103 aSettingId, iServerDetails.iSelection); |
104 RCmManagerExt cmManagerExt; |
|
105 cmManagerExt.OpenL(); |
|
106 CleanupClosePushL( cmManagerExt ); |
|
107 |
|
108 //Makes sure that Internet Destination Exists |
|
109 RArray<TUint32> destinationArray; |
|
110 cmManagerExt.AllDestinationsL( destinationArray ); |
|
111 CleanupClosePushL(destinationArray); |
|
112 |
|
113 TUint32 internetDestinationId = 0; |
|
114 for (TInt i = 0; i < destinationArray.Count(); ++i) |
|
115 { |
|
116 RCmDestinationExt destination = cmManagerExt.DestinationL( destinationArray[i] ); |
|
117 CleanupClosePushL(destination); |
|
118 |
|
119 TUint32 purposeMetaData = destination.MetadataL( ESnapMetadataPurpose ); |
|
120 if ( ESnapPurposeInternet == purposeMetaData ) |
|
121 { |
|
122 internetDestinationId = destinationArray[i]; |
|
123 CleanupStack::PopAndDestroy(); //destination |
|
124 break; |
|
125 } |
|
126 CleanupStack::PopAndDestroy(); //destination |
|
127 } |
|
128 |
|
129 iServerDetails.iSelection.iId = internetDestinationId; |
|
130 |
|
131 iServerDetails.iSelection.iResult=EDestination; |
|
132 |
|
133 |
|
134 settingItem = new (ELeave) CServerSettingConnectionSettingItem( |
|
135 aSettingId, iServerDetails.iSelection); |
|
136 CleanupStack::PopAndDestroy(2); //destinationArray,cmManagerExt |
|
137 |
|
138 } |
|
139 else |
|
140 settingItem = new (ELeave) CServerSettingConnectionSettingItem( |
|
141 aSettingId, iServerDetails.iSelection); |
|
142 break; |
104 break; |
143 default: |
105 default: |
144 // Do nothing |
106 // Do nothing |
145 break; |
107 break; |
146 } |
108 } |
147 |
109 ***/ |
148 return settingItem; |
110 return settingItem; |
149 } |
111 } |
150 |
112 |
151 |
113 |
152 // --------------------------------------------------------------------------- |
114 // --------------------------------------------------------------------------- |
155 // |
117 // |
156 void CServerSettingsContainer::ConstructL() |
118 void CServerSettingsContainer::ConstructL() |
157 { |
119 { |
158 // Server settings view sets iServerIndex to -1 when creating a new |
120 // Server settings view sets iServerIndex to -1 when creating a new |
159 // server |
121 // server |
|
122 /*** NSSM support is discontinued. |
|
123 Code is kept in comments temporarily because similar UI functionality |
|
124 might be needed for another purpose. |
160 if ( iServerIndex >= 0 ) |
125 if ( iServerIndex >= 0 ) |
161 { |
126 { |
162 iLoader.VpnApiWrapperL().GetServerDetailsL( iServerDetails ); |
127 iLoader.AcuApiWrapperL().GetServerDetailsL( |
|
128 iServerIndex, iServerDetails ); |
163 UpdateTitleL( iServerDetails.iServerNameLocal ); |
129 UpdateTitleL( iServerDetails.iServerNameLocal ); |
164 } |
130 } |
165 ConstructFromResourceL(R_VPN_SERVER_SETTING_LIST); |
131 ***/ |
166 CAknSettingItem* item = SettingItemArray()->At(EVpnUiSettingIap); |
132 ConstructFromResourceL(R_VPN_SERVER_SETTING_LIST); |
167 |
|
168 using namespace CMManager; |
|
169 |
|
170 RCmManagerExt cmManagerExt; |
|
171 cmManagerExt.OpenL(); |
|
172 CleanupClosePushL( cmManagerExt ); |
|
173 |
|
174 //Makes sure that Internet Destination Exists |
|
175 RArray<TUint32> destinationArray; |
|
176 cmManagerExt.AllDestinationsL( destinationArray ); |
|
177 CleanupClosePushL(destinationArray); |
|
178 TBool internetIapExist=EFalse; |
|
179 TUint32 internetDestinationId = 0; |
|
180 for (TInt i = 0; i < destinationArray.Count(); ++i) |
|
181 { |
|
182 RCmDestinationExt destination = cmManagerExt.DestinationL( destinationArray[i] ); |
|
183 CleanupClosePushL(destination); |
|
184 |
|
185 TUint32 purposeMetaData = destination.MetadataL( ESnapMetadataPurpose ); |
|
186 if ( ESnapPurposeInternet == purposeMetaData ) |
|
187 { |
|
188 internetDestinationId = destinationArray[i]; |
|
189 CleanupStack::PopAndDestroy(); //destination |
|
190 internetIapExist=ETrue; |
|
191 break; |
|
192 } |
|
193 CleanupStack::PopAndDestroy(); //destination |
|
194 } |
|
195 |
|
196 if ( internetIapExist != EFalse) |
|
197 { |
|
198 HBufC* defaultConn = GetDestinationNameL(internetDestinationId); |
|
199 CleanupStack::PushL(defaultConn); |
|
200 item->SetEmptyItemTextL(*defaultConn); |
|
201 item->LoadL(); |
|
202 item->UpdateListBoxTextL(); |
|
203 CleanupStack::PopAndDestroy(defaultConn); |
|
204 } |
|
205 |
|
206 CleanupStack::PopAndDestroy(); //destinationArray |
|
207 CleanupStack::PopAndDestroy(); //cmManagerExt |
|
208 } |
133 } |
209 |
134 |
210 |
135 |
211 // --------------------------------------------------------------------------- |
136 // --------------------------------------------------------------------------- |
212 // UpdateTitleL |
137 // UpdateTitleL |
214 // |
139 // |
215 void CServerSettingsContainer::UpdateTitleL( TDes& aText ) |
140 void CServerSettingsContainer::UpdateTitleL( TDes& aText ) |
216 { |
141 { |
217 iLoader.ActivateTitleL(KViewTitleParametersView,aText); |
142 iLoader.ActivateTitleL(KViewTitleParametersView,aText); |
218 } |
143 } |
|
144 |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // ServerNameExistsL |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 TBool CServerSettingsContainer::ServerNameExistsL( const TDesC& /* aText */) const |
|
151 { |
|
152 /*** NSSM support is discontinued. |
|
153 Code is kept in comments temporarily because similar UI functionality |
|
154 might be needed for another purpose. |
|
155 const CArrayFix<TAcuApiServerListElem>* serverList = iLoader.AcuApiWrapperL().ServerListL(); |
|
156 TInt count = serverList->Count(); |
|
157 |
|
158 for (TInt i = 0; i < count; ++i) |
|
159 { |
|
160 //If we are editing name, we don't want to compare itself |
|
161 if(i != iServerIndex) |
|
162 { |
|
163 if (serverList->At(i).iServerNameLocal.Compare(aText)==0) |
|
164 { |
|
165 //Name is already in use |
|
166 return ETrue; |
|
167 } |
|
168 } |
|
169 } ***/ |
|
170 return EFalse; |
|
171 } |
219 |
172 |
220 |
173 |
221 void CServerSettingsContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) |
174 void CServerSettingsContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) |
222 { |
175 { |
223 switch(aEventType) |
176 switch(aEventType) |
236 // ChangeSettingValueL |
189 // ChangeSettingValueL |
237 // --------------------------------------------------------------------------- |
190 // --------------------------------------------------------------------------- |
238 // |
191 // |
239 void CServerSettingsContainer::ChangeSettingValueL() |
192 void CServerSettingsContainer::ChangeSettingValueL() |
240 { |
193 { |
241 |
194 /*** NSSM support is discontinued. |
|
195 Code is kept in comments temporarily because similar UI functionality |
|
196 might be needed for another purpose. |
242 TInt currentItem( ListBox()->CurrentItemIndex() ); |
197 TInt currentItem( ListBox()->CurrentItemIndex() ); |
243 |
198 |
244 switch(currentItem) |
199 switch(currentItem) |
245 { |
200 { |
246 case EVpnUiSettingServerName: |
201 case EVpnUiSettingServerName: |
247 { |
202 { |
248 EditItemL(EVpnUiSettingServerName, ETrue); |
203 TBool alreadyInUse = ETrue; |
249 SettingItemArray()->At(EVpnUiSettingServerName)->StoreL(); |
204 while(alreadyInUse) |
250 } |
205 { |
|
206 EditItemL(EVpnUiSettingServerName, ETrue); |
|
207 SettingItemArray()->At(EVpnUiSettingServerName)->StoreL(); |
|
208 alreadyInUse = ServerNameExistsL( iServerDetails.iServerNameLocal ); |
|
209 if(alreadyInUse) |
|
210 { |
|
211 //Show an information note that server is currently in use |
|
212 HBufC* noteText; |
|
213 noteText = StringLoader::LoadLC( R_FLDR_NAME_ALREADY_USED, iServerDetails.iServerNameLocal ); |
|
214 CAknInformationNote* note = new(ELeave)CAknInformationNote(ETrue); |
|
215 note->SetTimeout(CAknNoteDialog::ELongTimeout); //3sec |
|
216 note->ExecuteLD(noteText->Des()); |
|
217 CleanupStack::PopAndDestroy(); // noteText |
|
218 } |
|
219 |
|
220 } |
251 if (iServerDetails.iServerNameLocal.Length() > 0) |
221 if (iServerDetails.iServerNameLocal.Length() > 0) |
252 { |
222 { |
253 UpdateTitleL( iServerDetails.iServerNameLocal ); |
223 UpdateTitleL( iServerDetails.iServerNameLocal ); |
254 } |
224 } |
255 |
225 } |
256 break; |
226 break; |
257 case EVpnUiSettingServerAddress: |
227 case EVpnUiSettingServerAddress: |
258 { |
228 { |
259 EditItemL(EVpnUiSettingServerAddress, ETrue); |
229 if( iServerDetails.iServerUrlReadOnly ) |
|
230 { |
|
231 //Show an information note that server cannot be |
|
232 //modified |
|
233 HBufC* noteText; |
|
234 noteText = StringLoader::LoadLC( |
|
235 R_VPN_INFO_CANNOT_MODIFY_SERVER_DEF ); |
|
236 CAknInformationNote* note = |
|
237 new(ELeave) CAknInformationNote(ETrue); |
|
238 note->SetTimeout(CAknNoteDialog::ELongTimeout); //3sec |
|
239 note->ExecuteLD(noteText->Des()); |
|
240 CleanupStack::PopAndDestroy(); // noteText |
|
241 } |
|
242 else |
|
243 { |
|
244 EditItemL(EVpnUiSettingServerAddress, ETrue); |
|
245 } |
260 } |
246 } |
261 break; |
247 break; |
262 case EVpnUiSettingIap: |
248 case EVpnUiSettingIap: |
263 { |
249 { |
264 EditItemL(EVpnUiSettingIap, ETrue); |
250 EditItemL(EVpnUiSettingIap, ETrue); |
265 } |
251 } |
266 break; |
252 break; |
267 default: |
253 default: |
268 User::Invariant(); |
254 User::Invariant(); |
269 break; |
255 break; |
270 } |
256 } ***/ |
271 } |
257 } |
272 |
258 |
273 |
259 |
274 |
260 // --------------------------------------------------------------------------- |
275 const TAgileProvisionApiServerSettings& CServerSettingsContainer::ServerDetailsL() |
261 // ServerDetails |
|
262 // --------------------------------------------------------------------------- |
|
263 // |
|
264 /*** NSSM support is discontinued. |
|
265 Code is kept in comments temporarily because similar UI functionality |
|
266 might be needed for another purpose. |
|
267 const TAcuApiServerDetails& CServerSettingsContainer::ServerDetailsL() |
276 { |
268 { |
277 StoreSettingsL(); |
269 StoreSettingsL(); |
278 if (iServerAddressBuffer.Length() > 0) |
270 if (iServerAddressBuffer.Length() > 0) |
279 { |
271 { |
280 iServerDetails.iServerUrl.Copy(iServerAddressBuffer); |
272 iServerDetails.iServerUrl.Copy(iServerAddressBuffer); |
311 } |
305 } |
312 |
306 |
313 TPtrC8 serverNameAddress = iServerDetails.iServerUrl.Left(numberOfCharactersCopiedFromAddress); |
307 TPtrC8 serverNameAddress = iServerDetails.iServerUrl.Left(numberOfCharactersCopiedFromAddress); |
314 iServerDetails.iServerNameLocal.Copy(serverNameAddress); |
308 iServerDetails.iServerNameLocal.Copy(serverNameAddress); |
315 iServerDetails.iServerNameLocal.Append(suffix); |
309 iServerDetails.iServerNameLocal.Append(suffix); |
316 |
310 |
|
311 }while(ServerNameExistsL( iServerDetails.iServerNameLocal) ); |
|
312 |
317 CAknSettingItem* item = SettingItemArray()->At(EVpnUiSettingServerName); |
313 CAknSettingItem* item = SettingItemArray()->At(EVpnUiSettingServerName); |
318 |
|
319 item->LoadL(); |
314 item->LoadL(); |
320 item->UpdateListBoxTextL(); |
315 item->UpdateListBoxTextL(); |
321 } |
316 } |
322 return iServerDetails; |
317 return iServerDetails; |
323 } |
318 } |
324 |
319 ***/ |
325 |
320 |
326 // --------------------------------------------------------------------------- |
321 // --------------------------------------------------------------------------- |
327 // GetIapNameL |
322 // GetIapNameL |
328 // --------------------------------------------------------------------------- |
323 // --------------------------------------------------------------------------- |
329 // |
324 // |