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 |
27 #include <vpnmanagementuirsc.rsg> |
29 #include <vpnmanagementuirsc.rsg> |
28 #include "vpnuiloader.h" |
30 #include "vpnuiloader.h" |
29 #include "vpnmanagementuiserversettingscontainer.h" |
31 #include "vpnmanagementuiserversettingscontainer.h" |
30 #include "vpnmanagementuidefs.h" |
32 #include "vpnmanagementuidefs.h" |
31 #include "serversettingconnectionsettingitem.h" |
33 #include "serversettingconnectionsettingitem.h" |
76 // --------------------------------------------------------------------------- |
78 // --------------------------------------------------------------------------- |
77 // CreateSettingItemL |
79 // CreateSettingItemL |
78 // --------------------------------------------------------------------------- |
80 // --------------------------------------------------------------------------- |
79 // |
81 // |
80 CAknSettingItem* CServerSettingsContainer::CreateSettingItemL( |
82 CAknSettingItem* CServerSettingsContainer::CreateSettingItemL( |
81 TInt /* aSettingId */) |
83 TInt aSettingId ) |
82 { |
84 { |
83 CAknSettingItem* settingItem(NULL); |
85 CAknSettingItem* settingItem(NULL); |
84 /*** NSSM support is discontinued. |
86 |
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 settingItem = new (ELeave) CServerSettingConnectionSettingItem( |
102 if ( iServerDetails.iSelection.iId <1 ) |
103 aSettingId, iServerDetails.iSelection); |
103 { |
|
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); |
104 break; |
142 break; |
105 default: |
143 default: |
106 // Do nothing |
144 // Do nothing |
107 break; |
145 break; |
108 } |
146 } |
109 ***/ |
147 |
110 return settingItem; |
148 return settingItem; |
111 } |
149 } |
112 |
150 |
113 |
151 |
114 // --------------------------------------------------------------------------- |
152 // --------------------------------------------------------------------------- |
117 // |
155 // |
118 void CServerSettingsContainer::ConstructL() |
156 void CServerSettingsContainer::ConstructL() |
119 { |
157 { |
120 // Server settings view sets iServerIndex to -1 when creating a new |
158 // Server settings view sets iServerIndex to -1 when creating a new |
121 // server |
159 // server |
122 /*** NSSM support is discontinued. |
|
123 Code is kept in comments temporarily because similar UI functionality |
|
124 might be needed for another purpose. |
|
125 if ( iServerIndex >= 0 ) |
160 if ( iServerIndex >= 0 ) |
126 { |
161 { |
127 iLoader.AcuApiWrapperL().GetServerDetailsL( |
162 iLoader.VpnApiWrapperL().GetServerDetailsL( iServerDetails ); |
128 iServerIndex, iServerDetails ); |
|
129 UpdateTitleL( iServerDetails.iServerNameLocal ); |
163 UpdateTitleL( iServerDetails.iServerNameLocal ); |
130 } |
164 } |
131 ***/ |
165 ConstructFromResourceL(R_VPN_SERVER_SETTING_LIST); |
132 ConstructFromResourceL(R_VPN_SERVER_SETTING_LIST); |
166 CAknSettingItem* item = SettingItemArray()->At(EVpnUiSettingIap); |
|
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 |
133 } |
208 } |
134 |
209 |
135 |
210 |
136 // --------------------------------------------------------------------------- |
211 // --------------------------------------------------------------------------- |
137 // UpdateTitleL |
212 // UpdateTitleL |
139 // |
214 // |
140 void CServerSettingsContainer::UpdateTitleL( TDes& aText ) |
215 void CServerSettingsContainer::UpdateTitleL( TDes& aText ) |
141 { |
216 { |
142 iLoader.ActivateTitleL(KViewTitleParametersView,aText); |
217 iLoader.ActivateTitleL(KViewTitleParametersView,aText); |
143 } |
218 } |
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 } |
|
172 |
219 |
173 |
220 |
174 void CServerSettingsContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) |
221 void CServerSettingsContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) |
175 { |
222 { |
176 switch(aEventType) |
223 switch(aEventType) |
189 // ChangeSettingValueL |
236 // ChangeSettingValueL |
190 // --------------------------------------------------------------------------- |
237 // --------------------------------------------------------------------------- |
191 // |
238 // |
192 void CServerSettingsContainer::ChangeSettingValueL() |
239 void CServerSettingsContainer::ChangeSettingValueL() |
193 { |
240 { |
194 /*** NSSM support is discontinued. |
241 |
195 Code is kept in comments temporarily because similar UI functionality |
|
196 might be needed for another purpose. |
|
197 TInt currentItem( ListBox()->CurrentItemIndex() ); |
242 TInt currentItem( ListBox()->CurrentItemIndex() ); |
198 |
243 |
199 switch(currentItem) |
244 switch(currentItem) |
200 { |
245 { |
201 case EVpnUiSettingServerName: |
246 case EVpnUiSettingServerName: |
202 { |
247 { |
203 TBool alreadyInUse = ETrue; |
248 EditItemL(EVpnUiSettingServerName, ETrue); |
204 while(alreadyInUse) |
249 SettingItemArray()->At(EVpnUiSettingServerName)->StoreL(); |
205 { |
250 } |
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 } |
|
221 if (iServerDetails.iServerNameLocal.Length() > 0) |
251 if (iServerDetails.iServerNameLocal.Length() > 0) |
222 { |
252 { |
223 UpdateTitleL( iServerDetails.iServerNameLocal ); |
253 UpdateTitleL( iServerDetails.iServerNameLocal ); |
224 } |
254 } |
225 } |
255 |
226 break; |
256 break; |
227 case EVpnUiSettingServerAddress: |
257 case EVpnUiSettingServerAddress: |
228 { |
258 { |
229 if( iServerDetails.iServerUrlReadOnly ) |
259 EditItemL(EVpnUiSettingServerAddress, ETrue); |
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 } |
|
246 } |
260 } |
247 break; |
261 break; |
248 case EVpnUiSettingIap: |
262 case EVpnUiSettingIap: |
249 { |
263 { |
250 EditItemL(EVpnUiSettingIap, ETrue); |
264 EditItemL(EVpnUiSettingIap, ETrue); |
251 } |
265 } |
252 break; |
266 break; |
253 default: |
267 default: |
254 User::Invariant(); |
268 User::Invariant(); |
255 break; |
269 break; |
256 } ***/ |
270 } |
257 } |
271 } |
258 |
272 |
259 |
273 |
260 // --------------------------------------------------------------------------- |
274 |
261 // ServerDetails |
275 const TAgileProvisionApiServerSettings& CServerSettingsContainer::ServerDetailsL() |
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() |
|
268 { |
276 { |
269 StoreSettingsL(); |
277 StoreSettingsL(); |
270 if (iServerAddressBuffer.Length() > 0) |
278 if (iServerAddressBuffer.Length() > 0) |
271 { |
279 { |
272 iServerDetails.iServerUrl.Copy(iServerAddressBuffer); |
280 iServerDetails.iServerUrl.Copy(iServerAddressBuffer); |
305 } |
311 } |
306 |
312 |
307 TPtrC8 serverNameAddress = iServerDetails.iServerUrl.Left(numberOfCharactersCopiedFromAddress); |
313 TPtrC8 serverNameAddress = iServerDetails.iServerUrl.Left(numberOfCharactersCopiedFromAddress); |
308 iServerDetails.iServerNameLocal.Copy(serverNameAddress); |
314 iServerDetails.iServerNameLocal.Copy(serverNameAddress); |
309 iServerDetails.iServerNameLocal.Append(suffix); |
315 iServerDetails.iServerNameLocal.Append(suffix); |
310 |
316 |
311 }while(ServerNameExistsL( iServerDetails.iServerNameLocal) ); |
317 CAknSettingItem* item = SettingItemArray()->At(EVpnUiSettingServerName); |
312 |
318 |
313 CAknSettingItem* item = SettingItemArray()->At(EVpnUiSettingServerName); |
|
314 item->LoadL(); |
319 item->LoadL(); |
315 item->UpdateListBoxTextL(); |
320 item->UpdateListBoxTextL(); |
316 } |
321 } |
317 return iServerDetails; |
322 return iServerDetails; |
318 } |
323 } |
319 ***/ |
324 |
320 |
325 |
321 // --------------------------------------------------------------------------- |
326 // --------------------------------------------------------------------------- |
322 // GetIapNameL |
327 // GetIapNameL |
323 // --------------------------------------------------------------------------- |
328 // --------------------------------------------------------------------------- |
324 // |
329 // |