21 #include <badesca.h> |
21 #include <badesca.h> |
22 #include <commdb.h> |
22 #include <commdb.h> |
23 #include <cdbcols.h> // CommsDB columname defs |
23 #include <cdbcols.h> // CommsDB columname defs |
24 #include <stringresourcereader.h> |
24 #include <stringresourcereader.h> |
25 #include <barsread.h> |
25 #include <barsread.h> |
26 #include <NSmlDMProvisioningAdapter.rsg> |
26 #include <nsmldmprovisioningadapter.rsg> |
27 #include <f32file.h> |
27 #include <f32file.h> |
28 #include <bautils.h> |
28 #include <bautils.h> |
29 #include <ApUtils.h> |
|
30 #include <utf.h> |
29 #include <utf.h> |
31 #include <featmgr.h> |
30 #include <featmgr.h> |
32 #include <barsc.h> |
31 #include <barsc.h> |
33 |
32 #include <cmconnectionmethoddef.h> |
|
33 #include <cmmanagerext.h> |
34 #include <nsmldebug.h> |
34 #include <nsmldebug.h> |
35 #include <CWPCharacteristic.h> |
35 #include <CWPCharacteristic.h> |
36 #include <CWPParameter.h> |
36 #include <CWPParameter.h> |
37 #include <CWPEngine.h> |
37 #include <CWPEngine.h> |
38 #include <NSmlPrivateAPI.h> |
38 #include <NSmlPrivateAPI.h> |
39 #include "NSmlDmProvisioningAdapter.h" |
39 #include "NSmlDmProvisioningAdapter.h" |
40 #include "NSmlTransportHandler.h" |
40 #include "NSmlTransportHandler.h" |
41 |
41 |
42 #include <data_caging_path_literals.hrh> |
42 #include <data_caging_path_literals.hrh> |
|
43 #define KMINPORT 0 |
|
44 #define KMAXPORT 65536 |
43 |
45 |
44 // ============================ MEMBER FUNCTIONS =============================== |
46 // ============================ MEMBER FUNCTIONS =============================== |
45 |
47 |
46 // ----------------------------------------------------------------------------- |
48 // ----------------------------------------------------------------------------- |
47 // CNSmlDmProvisioningAdapter::CNSmlDmProvisioningAdapter |
49 // CNSmlDmProvisioningAdapter::CNSmlDmProvisioningAdapter |
57 // CNSmlDmProvisioningAdapter::ConstructL |
59 // CNSmlDmProvisioningAdapter::ConstructL |
58 // Symbian 2nd phase constructor can leave. |
60 // Symbian 2nd phase constructor can leave. |
59 // ----------------------------------------------------------------------------- |
61 // ----------------------------------------------------------------------------- |
60 void CNSmlDmProvisioningAdapter::ConstructL() |
62 void CNSmlDmProvisioningAdapter::ConstructL() |
61 { |
63 { |
62 iLock = EFalse; |
|
63 iSession.OpenL(); |
64 iSession.OpenL(); |
64 FeatureManager::InitializeLibL(); |
65 FeatureManager::InitializeLibL(); |
65 } |
66 } |
66 |
67 |
67 // ----------------------------------------------------------------------------- |
68 // ----------------------------------------------------------------------------- |
183 if (iAuthSecretLimitIndicator) |
184 if (iAuthSecretLimitIndicator) |
184 { |
185 { |
185 iAuthSecretLimitIndicator = 0; |
186 iAuthSecretLimitIndicator = 0; |
186 User::Leave(KErrOverflow); |
187 User::Leave(KErrOverflow); |
187 } |
188 } |
188 |
189 |
|
190 //check for incorrect port |
|
191 //Only port address between 1 to 65536 is allowed. |
|
192 if( iProfiles[aItem]->iPort ) |
|
193 { |
|
194 const TDesC& port = iProfiles[aItem]->iPort->Des(); |
|
195 TInt len = port.Length(); |
|
196 if(len > 0) |
|
197 { |
|
198 HBufC* bufPort = port.AllocL(); |
|
199 TLex aLex(*bufPort); |
|
200 TInt portNum ; |
|
201 TInt err = aLex.Val(portNum); |
|
202 if(bufPort) |
|
203 { |
|
204 delete bufPort; |
|
205 bufPort = NULL; |
|
206 } |
|
207 if(err != KErrNone) |
|
208 { |
|
209 User::Leave(KErrGeneral); |
|
210 } |
|
211 if(!((portNum > KMINPORT) && (portNum < KMAXPORT))) |
|
212 { |
|
213 User::Leave(KErrGeneral); |
|
214 } |
|
215 } |
|
216 } |
|
217 |
189 TPckgBuf<TUint32> uid; |
218 TPckgBuf<TUint32> uid; |
190 |
219 |
191 RSyncMLDevManProfile profile,ProfileToSearch; |
220 RSyncMLDevManProfile profile,ProfileToSearch; |
192 RArray<TSmlProfileId> arr; |
221 RArray<TSmlProfileId> arr; |
193 iSession.ListProfilesL( arr, ESmlDevMan ); |
222 iSession.ListProfilesL( arr, ESmlDevMan ); |
216 { |
245 { |
217 profile.OpenL(iSession, ProfileId , ESmlOpenReadWrite ); |
246 profile.OpenL(iSession, ProfileId , ESmlOpenReadWrite ); |
218 TInt isprofilelocked=profile.ProfileLocked(EFalse, EFalse); |
247 TInt isprofilelocked=profile.ProfileLocked(EFalse, EFalse); |
219 if (isprofilelocked == 1) |
248 if (isprofilelocked == 1) |
220 { |
249 { |
221 profile.ProfileLocked(ETrue, EFalse); |
250 |
222 iLock = ETrue; |
251 profile.Close(); |
|
252 User::Leave(KErrAccessDenied); |
223 } |
253 } |
224 |
254 |
225 } |
255 } |
226 else |
256 else |
227 { |
257 { |
257 { |
287 { |
258 profile.SetPasswordL( iProfiles[aItem]->iPassword->Des() ); |
288 profile.SetPasswordL( iProfiles[aItem]->iPassword->Des() ); |
259 } |
289 } |
260 |
290 |
261 // creates profile -> must be done before opening the connection |
291 // creates profile -> must be done before opening the connection |
262 |
|
263 |
|
264 if(iLock) |
|
265 { |
|
266 profile.ProfileLocked(ETrue, ETrue); |
|
267 iLock = EFalse; |
|
268 } |
|
269 |
|
270 profile.UpdateL(); |
292 profile.UpdateL(); |
271 |
293 |
272 RSyncMLConnection connection; |
294 RSyncMLConnection connection; |
273 connection.OpenL( profile, KUidNSmlMediumTypeInternet.iUid ); |
295 connection.OpenL( profile, KUidNSmlMediumTypeInternet.iUid ); |
274 CleanupClosePushL( connection ); |
296 CleanupClosePushL( connection ); |
275 |
297 |
276 if( iProfiles[aItem]->iVisitParameter && iProfiles[aItem]->iVisitParameter->Data().Length() == uid.MaxLength() ) |
298 if( iProfiles[aItem]->iVisitParameter && iProfiles[aItem]->iVisitParameter->Data().Length() == uid.MaxLength() ) |
277 { |
299 { |
278 uid.Copy( iProfiles[aItem]->iVisitParameter->Data() ); |
300 uid.Copy( iProfiles[aItem]->iVisitParameter->Data() ); |
279 |
301 |
280 CCommsDatabase* commDb = CCommsDatabase::NewL(); |
302 RCmManagerExt cmmanagerExt; |
281 CleanupStack::PushL( commDb ); |
303 cmmanagerExt.OpenL(); |
282 CApUtils* aputils = CApUtils::NewLC( *commDb ); |
304 CleanupClosePushL(cmmanagerExt); |
|
305 RCmConnectionMethodExt cm; |
|
306 cm = cmmanagerExt.ConnectionMethodL( uid()); |
|
307 CleanupClosePushL( cm ); |
283 |
308 |
284 TUint apId = 0; |
309 TUint apId = 0; |
285 TRAPD( ERROR, apId = aputils->IapIdFromWapIdL( uid() ) ); |
310 TRAPD( ERROR, apId = cm.GetIntAttributeL(CMManager::ECmIapId) ); |
286 if( ERROR != KErrNone ) |
311 if( ERROR != KErrNone ) |
287 { |
312 { |
288 apId = GetDefaultIAPL(); |
313 apId = GetDefaultIAPL(); |
289 } |
314 } |
290 |
315 |
292 TPtr8 ptrBuf = iapBuf->Des(); |
317 TPtr8 ptrBuf = iapBuf->Des(); |
293 ptrBuf.Num( apId ); |
318 ptrBuf.Num( apId ); |
294 |
319 |
295 connection.SetPropertyL( KNSmlIAPId, *iapBuf ); |
320 connection.SetPropertyL( KNSmlIAPId, *iapBuf ); |
296 |
321 |
297 CleanupStack::PopAndDestroy( 3 ); //commdb, aputils, iapBuf |
322 CleanupStack::PopAndDestroy( 3 ); //cmmanager,cm, iapBuf |
298 } |
323 } |
299 |
324 |
300 if( iProfiles[aItem]->iHostAddress ) |
325 if( iProfiles[aItem]->iHostAddress ) |
301 { |
326 { |
302 // see if address contains also port |
327 // see if address contains also port |