|
1 /* |
|
2 * Copyright (c) 2007 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: DM-settings adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "NSmlDMSettingsAdapter12.h" |
|
23 #include "nsmldebug.h" |
|
24 #include "nsmlconstants.h" |
|
25 #include "nsmldmconstants.h" |
|
26 #include "nsmldmiapmatcher.h" |
|
27 #include "nsmldmauthinfo.h" |
|
28 #include <featmgr.h> |
|
29 #include <implementationproxy.h> |
|
30 #include <SyncMLClientDM.h> |
|
31 #include <SyncMLTransportProperties.h> |
|
32 #include <e32base.h> |
|
33 #include <DevManInternalCRKeys.h> |
|
34 #include <centralrepository.h> |
|
35 #ifndef __WINS__ |
|
36 // This lowers the unnecessary compiler warning (armv5) to remark. |
|
37 // "Warning: #174-D: expression has no effect..." is caused by |
|
38 // DBG_ARGS8 macro in no-debug builds. |
|
39 #pragma diag_remark 174 |
|
40 #endif |
|
41 |
|
42 const TUint KNSmlDMSettingsAdapterImplUid = 0x10282CE8; |
|
43 |
|
44 const TInt KBufSize32 = 32; |
|
45 |
|
46 // ============================ MEMBER FUNCTIONS =============================== |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CNSmlDMSettingsAdapter12::NewL |
|
50 // Two-phased constructor. |
|
51 // ----------------------------------------------------------------------------- |
|
52 CNSmlDMSettingsAdapter12* CNSmlDMSettingsAdapter12::NewL( MSmlDmCallback* aDmCallback ) |
|
53 { |
|
54 _DBG_FILE("CNSmlDMSettingsAdapter12::NewL(): begin"); |
|
55 |
|
56 CNSmlDMSettingsAdapter12* self = NewLC( aDmCallback ); |
|
57 CleanupStack::Pop(); |
|
58 |
|
59 _DBG_FILE("CNSmlDMSettingsAdapter12::NewL(): end"); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CNSmlDMSettingsAdapter12::NewLC( ) |
|
65 // Loads the CNSmlDMSettingsAdapter12 class and pushes it to clenupstack. |
|
66 // ----------------------------------------------------------------------------- |
|
67 CNSmlDMSettingsAdapter12* CNSmlDMSettingsAdapter12::NewLC( MSmlDmCallback* aDmCallback ) |
|
68 { |
|
69 _DBG_FILE( "CNSmlDMSettingsAdapter12::NewLC(): begin" ); |
|
70 CNSmlDMSettingsAdapter12* self = new ( ELeave ) CNSmlDMSettingsAdapter12( aDmCallback ); |
|
71 CleanupStack::PushL( self ); |
|
72 self->iCallBack = aDmCallback; |
|
73 self->ConstructL(); |
|
74 self->iLeafType = EDMUnset; |
|
75 |
|
76 _DBG_FILE( "CNSmlDMSettingsAdapter12::NewLC(): end" ); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CNSmlDMSettingsAdapter12::CNSmlDMSettingsAdapter() |
|
82 // Default constructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 CNSmlDMSettingsAdapter12::CNSmlDMSettingsAdapter12( TAny* aEcomArguments) : |
|
85 CSmlDmAdapter(aEcomArguments ) |
|
86 { |
|
87 _DBG_FILE( "CNSmlDMSettingsAdapter12::CNSmlDMSettingsAdapter(): begin" ); |
|
88 _DBG_FILE( "CNSmlDMSettingsAdapter12::CNSmlDMSettingsAdapter(): end" ); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CNSmlDMSettingsAdapter12::~CNSmlDMSettingsAdapter() |
|
93 // Destructor. |
|
94 // ----------------------------------------------------------------------------- |
|
95 CNSmlDMSettingsAdapter12::~CNSmlDMSettingsAdapter12() |
|
96 { |
|
97 _DBG_FILE( "CNSmlDMSettingsAdapter12::~CNSmlDMSettingsAdapter(): begin" ); |
|
98 |
|
99 delete iField; |
|
100 delete iURIField; |
|
101 // Client API Session & Profile |
|
102 iProfile.Close(); |
|
103 iSyncSession.Close(); |
|
104 iSyncSessionOpen = EFalse; |
|
105 // In Case the Buffer isnt cleared |
|
106 if ( iBuffer) |
|
107 { |
|
108 for (TInt val =0; val<iBuffer->Count ();val++) |
|
109 { |
|
110 delete iBuffer->At(val).iMappingName; |
|
111 |
|
112 ClearBuffer ( iBuffer->At(val).iLeafBuf); |
|
113 delete iBuffer->At(val).iLeafBuf; |
|
114 } |
|
115 |
|
116 iBuffer->Reset (); |
|
117 delete iBuffer; |
|
118 } |
|
119 delete iPortNbr; |
|
120 iPortBuffer.Reset(); |
|
121 iPortBuffer.Close(); |
|
122 iProfileLockBuffer.Reset(); |
|
123 iProfileLockBuffer.Close(); |
|
124 |
|
125 iPrivateApi.Close(); |
|
126 |
|
127 iCallBack = 0; |
|
128 FeatureManager::UnInitializeLib(); |
|
129 _DBG_FILE( "CNSmlDMSettingsAdapter12::~CNSmlDMSettingsAdapter(): end" ); |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CNSmlDMSettingsAdapter12::ConstructL() |
|
134 // Second phase constructor. |
|
135 // ----------------------------------------------------------------------------- |
|
136 void CNSmlDMSettingsAdapter12::ConstructL() |
|
137 { |
|
138 iField = HBufC8::NewL( KNSmlMaxURLLength ); |
|
139 iURIField = NULL; |
|
140 iSyncSessionOpen = EFalse; |
|
141 FeatureManager::InitializeLibL(); |
|
142 // variables used for Buffering |
|
143 iBufOn = EFalse; |
|
144 iComplete = EFalse; |
|
145 iExecutionIndex = -1; |
|
146 iNewProfile = EFalse; |
|
147 // initialising iBuffer |
|
148 iBuffer = new (ELeave) CArrayFixFlat <TNSmlDMBufferElement> (KNSmlDMGranularity); |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CNSmlDMSettingsAdapter12::DDFVersionL() |
|
153 // Returns the DDF version number. |
|
154 // ----------------------------------------------------------------------------- |
|
155 void CNSmlDMSettingsAdapter12::DDFVersionL( CBufBase& aVersion ) |
|
156 { |
|
157 _DBG_FILE( |
|
158 "CNSmlDMSettingsAdapter12::DDFVersionL(CBufBase& aDDFVersion): begin" ); |
|
159 aVersion.InsertL( 0, KVersion ); |
|
160 _DBG_FILE( |
|
161 "CNSmlDMSettingsAdapter12::DDFVersionL(CBufBase& aDDFVersion): end" ); |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CNSmlDMSettingsAdapter12::DDFStructureL() |
|
166 // Fills the DDF structure of the adapter. |
|
167 // ----------------------------------------------------------------------------- |
|
168 void CNSmlDMSettingsAdapter12::DDFStructureL( MSmlDmDDFObject& aDDF ) |
|
169 { |
|
170 _DBG_FILE( "CNSmlDMSettingsAdapter12::DDFStructureL(): begin" ); |
|
171 |
|
172 //Making DMAcc as root |
|
173 |
|
174 MSmlDmDDFObject* ddfRoot = &aDDF; |
|
175 MSmlDmDDFObject& nDmDDF = ddfRoot->AddChildObjectL( KNSmlDefDMAcc ); |
|
176 |
|
177 TSmlDmAccessTypes *aclTypes = new ( ELeave ) TSmlDmAccessTypes(); |
|
178 CleanupStack::PushL( aclTypes ); |
|
179 |
|
180 // Set Get as acceptable operations |
|
181 aclTypes->SetGet(); |
|
182 |
|
183 nDmDDF.SetDFTitleL( KNSmlDMadapterTitle ); |
|
184 |
|
185 FillNodeInfoL( nDmDDF, *aclTypes, MSmlDmDDFObject::EOne, |
|
186 MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode, |
|
187 KNullDesC8, KNullDesC8, KNullDesC8 ); |
|
188 |
|
189 aclTypes->SetAdd(); |
|
190 // Set rest acceptable operations for data itself |
|
191 aclTypes->SetReplace(); |
|
192 aclTypes->SetDelete(); |
|
193 |
|
194 TSmlDmAccessTypes aclTypesNoGet; |
|
195 aclTypesNoGet.SetReplace(); |
|
196 aclTypesNoGet.SetAdd(); |
|
197 aclTypesNoGet.SetDelete(); |
|
198 |
|
199 TSmlDmAccessTypes aclTypesAR; |
|
200 aclTypesAR.SetReplace(); |
|
201 aclTypesAR.SetAdd(); |
|
202 |
|
203 TSmlDmAccessTypes aclTypesARG; |
|
204 aclTypesARG.SetReplace(); |
|
205 aclTypesARG.SetAdd(); |
|
206 aclTypesARG.SetGet(); |
|
207 |
|
208 TSmlDmAccessTypes aclTypesG; |
|
209 aclTypesG.SetGet(); |
|
210 |
|
211 TSmlDmAccessTypes aclTypesAG; |
|
212 aclTypesAG.SetGet(); |
|
213 aclTypesAG.SetAdd(); |
|
214 |
|
215 TSmlDmAccessTypes aclTypesAGD; |
|
216 aclTypesAGD.SetGet(); |
|
217 aclTypesAGD.SetAdd(); |
|
218 aclTypesAGD.SetDelete(); |
|
219 |
|
220 |
|
221 MSmlDmDDFObject& nProDDF = nDmDDF.AddChildObjectGroupL(); |
|
222 FillNodeInfoL( nProDDF, *aclTypes, MSmlDmDDFObject::EZeroOrMore, |
|
223 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, |
|
224 KNullDesC8, KNullDesC8, KMimeType ); |
|
225 |
|
226 MSmlDmDDFObject& nAppIdDDF = nProDDF.AddChildObjectL( KNSmlDdfAppId ); // Addr |
|
227 FillNodeInfoL( nAppIdDDF, aclTypesG, MSmlDmDDFObject::EOne, |
|
228 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
229 KNSmlDdfAppIdDescription, KNullDesC8, KMimeType ); |
|
230 |
|
231 //PrefConRef |
|
232 MSmlDmDDFObject& nPrefConRefDDF = nProDDF.AddChildObjectL( KNSmlDdfPrefConRef ); // PrefConRef |
|
233 FillNodeInfoL( nPrefConRefDDF, aclTypesARG, MSmlDmDDFObject::EOne, |
|
234 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
235 KNSmlDdfConRefDescription, KNullDesC8, KMimeType ); |
|
236 |
|
237 |
|
238 |
|
239 // App Address nodes |
|
240 MSmlDmDDFObject& nAppAddrDDF = nProDDF.AddChildObjectL( KNSmlDdfAppAddr ); // AppAddr |
|
241 FillNodeInfoL( nAppAddrDDF, aclTypesG, MSmlDmDDFObject::EOne, |
|
242 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, |
|
243 KNSmlDdfAddrDescription, KNullDesC8, KMimeType ); |
|
244 |
|
245 MSmlDmDDFObject& rtToAppAddrRef = nAppAddrDDF.AddChildObjectGroupL(); //AppAddr/<X> |
|
246 FillNodeInfoL(rtToAppAddrRef,aclTypesG,MSmlDmDDFObject::EOneOrMore, |
|
247 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::ENode, |
|
248 KNSmlDdfAddrDescription,KNullDesC8, KMimeType ); |
|
249 |
|
250 |
|
251 MSmlDmDDFObject& nAddrForAppAddrDDF = rtToAppAddrRef.AddChildObjectL( KNSmlDdfAddr ); // Addr |
|
252 FillNodeInfoL( nAddrForAppAddrDDF, aclTypesARG, MSmlDmDDFObject::EOne, |
|
253 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
254 KNSmlDdfAddrDescription, KNullDesC8, KMimeType ); |
|
255 |
|
256 MSmlDmDDFObject& nAddrTypeForAppAddrDDF = rtToAppAddrRef.AddChildObjectL( KNSmlDdfAddrType ); // AddrType |
|
257 FillNodeInfoL( nAddrTypeForAppAddrDDF, aclTypesG, MSmlDmDDFObject::EOne, |
|
258 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
259 KNSmlDdfAddrTypeDescription, KNullDesC8, KMimeType ); |
|
260 |
|
261 MSmlDmDDFObject& nPortForAppAddrDDF = rtToAppAddrRef.AddChildObjectL( KNSmlDdfPort ); // PortNbr |
|
262 FillNodeInfoL( nPortForAppAddrDDF, aclTypesG, MSmlDmDDFObject::EOne, |
|
263 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, |
|
264 KNSmlDdfPortNbrDescription, KNullDesC8, KMimeType ); |
|
265 |
|
266 //Runtime port address |
|
267 MSmlDmDDFObject& nrtToPortDDF = nPortForAppAddrDDF.AddChildObjectGroupL(); // PortNbr |
|
268 FillNodeInfoL( nrtToPortDDF, aclTypesG, MSmlDmDDFObject::EOneOrMore, |
|
269 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, |
|
270 KNSmlDdfPortNbrDescription, KNullDesC8, KMimeType ); |
|
271 |
|
272 MSmlDmDDFObject& nPortNbrToPortDDF = nrtToPortDDF.AddChildObjectL( KNSmlDdfPortNbr ); // PortNbr |
|
273 FillNodeInfoL( nPortNbrToPortDDF, aclTypesARG, MSmlDmDDFObject::EZeroOrOne, |
|
274 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EInt, |
|
275 KNSmlDdfPortNbrDescription, KNullDesC8, KMimeType ); |
|
276 |
|
277 |
|
278 MSmlDmDDFObject& nAuthSchemeDDF = nProDDF.AddChildObjectL( KNSmlDdfAuthScheme ); // AuthPref |
|
279 FillNodeInfoL( nAuthSchemeDDF, aclTypesARG, MSmlDmDDFObject::EOne, |
|
280 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
281 KNSmlDdfAuthSchemeDescription, KNullDesC8, KMimeType ); |
|
282 //APPAUthNodes |
|
283 |
|
284 MSmlDmDDFObject& nAppAuthDDF = nProDDF.AddChildObjectL( KNSmlDdfAppAuth ); // AppAuth |
|
285 FillNodeInfoL( nAppAuthDDF, aclTypesG, MSmlDmDDFObject::EOne, |
|
286 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, |
|
287 KNSmlDdfAuthSchemeDescription, KNullDesC8, KMimeType ); |
|
288 |
|
289 |
|
290 MSmlDmDDFObject& nrtToAppAuthDDF = nAppAuthDDF.AddChildObjectGroupL(); // appauth/<x> |
|
291 FillNodeInfoL( nrtToAppAuthDDF, aclTypesG, MSmlDmDDFObject::EOne, |
|
292 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, |
|
293 KNSmlDdfAuthSchemeDescription, KNullDesC8, KMimeType ); |
|
294 |
|
295 |
|
296 MSmlDmDDFObject& nAauthLevelDDF = nrtToAppAuthDDF.AddChildObjectL( KNSmlDdfAAuthLevel ); // AAuthLevel |
|
297 FillNodeInfoL( nAauthLevelDDF, aclTypesARG, MSmlDmDDFObject::EOne, |
|
298 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
299 KNSmlDdfAuthLevelDescription, KNullDesC8, KMimeType ); |
|
300 |
|
301 |
|
302 MSmlDmDDFObject& nAauthtypeDDF = nrtToAppAuthDDF.AddChildObjectL( KNSmlDdfAAuthType ); // AAuthType |
|
303 FillNodeInfoL( nAauthtypeDDF, aclTypesG, MSmlDmDDFObject::EOne, |
|
304 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
305 KNSmlDdfAddrTypeDescription, KNullDesC8, KMimeType ); |
|
306 |
|
307 |
|
308 MSmlDmDDFObject& nAauthNameDDF = nrtToAppAuthDDF.AddChildObjectL( KNSmlDdfAAuthName ); // AddrType |
|
309 FillNodeInfoL( nAauthNameDDF, aclTypesARG, MSmlDmDDFObject::EOne, |
|
310 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
311 KNSmlDdfAuthNameDescription, KNullDesC8, KMimeType ); |
|
312 |
|
313 |
|
314 MSmlDmDDFObject& nAauthSecretDDF = nrtToAppAuthDDF.AddChildObjectL( KNSmlDdfAAuthSecret ); // AddrType |
|
315 FillNodeInfoL( nAauthSecretDDF, aclTypesAR, MSmlDmDDFObject::EOne, |
|
316 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
317 KNSmlDdfAuthSecretDescription, KNullDesC8, KMimeType ); |
|
318 |
|
319 MSmlDmDDFObject& nAauthDataDDF = nrtToAppAuthDDF.AddChildObjectL( KNSmlDdfAAuthData ); // AddrType |
|
320 FillNodeInfoL( nAauthDataDDF, aclTypesAR, MSmlDmDDFObject::EOne, |
|
321 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
322 KNSmlDdfAuthDataDescription, KNullDesC8, KMimeType ); |
|
323 |
|
324 |
|
325 MSmlDmDDFObject& nNameDDF = nProDDF.AddChildObjectL( KNSmlDdfName ); // Name |
|
326 FillNodeInfoL( nNameDDF, aclTypesARG, MSmlDmDDFObject::EZeroOrOne, |
|
327 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
328 KNSmlDdfNameDescription, KNullDesC8, KMimeType ); |
|
329 |
|
330 |
|
331 |
|
332 MSmlDmDDFObject& nServerIdDDF = nProDDF.AddChildObjectL( KNSmlDdfServerId ); // ServerId |
|
333 FillNodeInfoL( nServerIdDDF, aclTypesAG, MSmlDmDDFObject::EOne, |
|
334 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
335 KNSmlDdfServerIdDescription, KNullDesC8, KMimeType ); |
|
336 |
|
337 MSmlDmDDFObject& nextDDF = nProDDF.AddChildObjectL( KNSmlDdfExt ); // Ext |
|
338 FillNodeInfoL( nextDDF, aclTypesG, MSmlDmDDFObject::EOne, |
|
339 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, |
|
340 KNSmlDdfServerIdDescription, KNullDesC8, KMimeType ); |
|
341 |
|
342 MSmlDmDDFObject& nlockedDDF = nextDDF.AddChildObjectL( KNSmlDdfLocked ); // locked |
|
343 FillNodeInfoL( nlockedDDF, aclTypesARG, MSmlDmDDFObject::EOne, |
|
344 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, |
|
345 KNSmlDdfServerIdDescription, KNullDesC8, KMimeType ); |
|
346 |
|
347 CleanupStack::PopAndDestroy(); //aclTypes |
|
348 |
|
349 _DBG_FILE("CNSmlDMSettingsAdapter12::DDFStructureL(): end"); |
|
350 } |
|
351 |
|
352 // ----------------------------------------------------------------------------- |
|
353 // CNSmlDMSettingsAdapter12::UpdateLeafObjectL |
|
354 // Updates profile leaf object data based on URI. |
|
355 // ----------------------------------------------------------------------------- |
|
356 void CNSmlDMSettingsAdapter12::UpdateLeafObjectL( const TDesC8& aURI, |
|
357 const TDesC8& aLUID, |
|
358 const TDesC8& aObject, |
|
359 const TDesC8& /*aType*/, |
|
360 const TInt aStatusRef ) |
|
361 { |
|
362 _DBG_FILE("CNSmlDMSettingsAdapter12::UpdateLeafObjectL(): begin"); |
|
363 TInt index = -1; |
|
364 if ( !iBufOn) |
|
365 { |
|
366 for (TInt val = 0; val<iBuffer->Count (); val++) |
|
367 { |
|
368 TPtrC8 firstUri = ParentURI (aURI); |
|
369 if ( iBuffer->At(val).iMappingName->Compare (firstUri)== 0) |
|
370 { |
|
371 index = iExecutionIndex = val; |
|
372 break; |
|
373 } |
|
374 } |
|
375 } |
|
376 if ( index >= 0) |
|
377 AddLeafBufferL (aURI, aObject, aStatusRef); |
|
378 else |
|
379 { |
|
380 TInt parentLUID = GetIntObject( aLUID ); |
|
381 if( parentLUID < 0 ) |
|
382 { |
|
383 if( IsDMAccUriFormatMatchPredefined(aURI) ) |
|
384 { |
|
385 parentLUID = ConstructTreeL(aURI); |
|
386 } |
|
387 } |
|
388 if( parentLUID < 0 ) |
|
389 { |
|
390 _DBG_FILE( "CNSmlDMSettingsAdapter12::UpdateLeafObjectL( ): ENotFound end" ); |
|
391 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
392 return; |
|
393 } |
|
394 |
|
395 if( parentLUID != iParentLUID ) |
|
396 { |
|
397 if( FindProfileIdL( parentLUID ) != EFalse ) |
|
398 { |
|
399 iParentLUID = parentLUID; |
|
400 } |
|
401 else |
|
402 { |
|
403 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
404 return; |
|
405 } |
|
406 } |
|
407 SetField( aURI ); |
|
408 SetURIInProcessL( aURI); |
|
409 if( !AcceptDMField() ) |
|
410 { |
|
411 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddLeafObjectL(): KErr field end" ); |
|
412 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject ); |
|
413 return; |
|
414 } |
|
415 |
|
416 // Get Database field type |
|
417 TNSmlDMFieldType fType = GetDMFieldType(); |
|
418 if ( fType == EWrong ) |
|
419 { |
|
420 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddLeafObjectL(): EError end" ); |
|
421 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
422 return; |
|
423 } |
|
424 |
|
425 TNSmlDMProfileData fData = GetDMField(); |
|
426 if( fData == ESyncAccepted ) |
|
427 { |
|
428 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddLeafObjectL(): EError end" ); |
|
429 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
430 return; |
|
431 } |
|
432 if( NotValidStrLenght( fData, aObject ) ) |
|
433 { |
|
434 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddLeafObjectL(): KErr length end" ); |
|
435 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ETooLargeObject ); |
|
436 return; |
|
437 } |
|
438 //Authentication data leafs to be handled |
|
439 if ( fData == EAuthenticationRequired || fData == EClientNonce |
|
440 || fData == EServerNonce ) |
|
441 { |
|
442 //Check if replace command and replace data as defined |
|
443 |
|
444 TInt replaceStatus = KErrGeneral; |
|
445 SetAuthInfoL( iParentLUID + KMaxDataSyncID, fData, aObject, replaceStatus ); |
|
446 if ( replaceStatus == KErrNone ) |
|
447 { |
|
448 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
449 } |
|
450 else if ( replaceStatus == KErrNotFound ) |
|
451 { |
|
452 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
453 } |
|
454 else |
|
455 { |
|
456 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
457 } |
|
458 |
|
459 _DBG_FILE( "CNSmlDMSettingsAdapter12::UpdateLeafObjectL():end" ); |
|
460 return; |
|
461 } |
|
462 |
|
463 TInt rValue = SetDMFieldDataL( iParentLUID, aObject, fData ); |
|
464 if ( fData == EProfilePort ) |
|
465 { |
|
466 // in case port is updated, save status ref to be used in |
|
467 // CompleteOutstandingCmdsL |
|
468 if(rValue==KErrNone) |
|
469 { |
|
470 iPortBuffer[iPortBuffer.Count()-1].iPortBufStatusRef = aStatusRef; |
|
471 } |
|
472 else if( rValue == KErrOverflow) |
|
473 { |
|
474 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ETooLargeObject ); |
|
475 } |
|
476 else |
|
477 { |
|
478 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
479 } |
|
480 } |
|
481 else if ( fData == EProfileLock && iNewProfile ) |
|
482 { |
|
483 if(rValue == KErrNone) |
|
484 iProfileLockBuffer[iProfileLockBuffer.Count()-1].iProfileLockStatusRef = aStatusRef; |
|
485 else |
|
486 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotAllowed); |
|
487 } |
|
488 else |
|
489 { |
|
490 if( rValue != KErrNone ) |
|
491 { |
|
492 if( rValue == KErrNotFound ) |
|
493 { |
|
494 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
495 } |
|
496 else if( rValue == KErrInUse ) |
|
497 { |
|
498 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EObjectInUse ); |
|
499 } |
|
500 else if( rValue == KErrNoMemory ) |
|
501 { |
|
502 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENoMemory ); |
|
503 } |
|
504 else if(rValue == KErrAccessDenied) |
|
505 { |
|
506 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotAllowed); |
|
507 |
|
508 } |
|
509 else if ( rValue == KErrArgument) |
|
510 { |
|
511 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject); |
|
512 |
|
513 } |
|
514 else |
|
515 { |
|
516 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
517 } |
|
518 } |
|
519 else |
|
520 { |
|
521 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
522 } |
|
523 } |
|
524 } |
|
525 _DBG_FILE( "CNSmlDMSettingsAdapter12::UpdateLeafObjectL():end" ); |
|
526 return; |
|
527 } |
|
528 |
|
529 // ----------------------------------------------------------------------------- |
|
530 // CNSmlDMSettingsAdapter12::DeleteObjectL |
|
531 // Deletes whole profile or leaf object data acording to aURI. |
|
532 // ----------------------------------------------------------------------------- |
|
533 void CNSmlDMSettingsAdapter12::DeleteObjectL( const TDesC8& aURI, |
|
534 const TDesC8& aLUID, |
|
535 const TInt aStatusRef ) |
|
536 { |
|
537 _DBG_FILE( "CNSmlDMSettingsAdapter12::DeleteObjectL( ): begin" ); |
|
538 |
|
539 if( aURI.Find( KNSmlDdfConRef ) != KErrNotFound ) |
|
540 { |
|
541 _DBG_FILE( "CNSmlDMSettingsAdapter12::DeleteObjectL(): NOT ALLOWED end" ); |
|
542 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
543 return; |
|
544 } |
|
545 iLUID = IntLUID( aLUID ); |
|
546 if(IsProfileLockedL(iLUID)) |
|
547 { |
|
548 _DBG_FILE( "CNSmlDMSettingsAdapter12::DeleteObjectL(): NOT ALLOWED end" ); |
|
549 |
|
550 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotAllowed ); |
|
551 return; |
|
552 } |
|
553 |
|
554 |
|
555 // Check which field going to be handled |
|
556 SetField( aURI ); |
|
557 SetURIInProcessL(aURI); |
|
558 |
|
559 // Check if valid field |
|
560 if( !AcceptDMField() ) |
|
561 { |
|
562 |
|
563 // Delete whole profile if aURI called for node |
|
564 TInt last = aURI.LocateReverse( '/' ); |
|
565 TInt pos = aURI.Find( KNSmlDefDMAcc ); |
|
566 if( last - 5 == pos ) |
|
567 { |
|
568 |
|
569 // If called for node means that profile will deleted from database |
|
570 iLUID = IntLUID( aLUID ); |
|
571 DBG_ARGS8( _S8("DeleteObjectL: URI %S LUID = %d"), &aURI, iLUID ); |
|
572 |
|
573 if( FindProfileIdL( iLUID ) == EFalse ) |
|
574 { |
|
575 _DBG_FILE( |
|
576 "CNSmlDMSettingsAdapter12::DeleteObjectL( ): notfound end"); |
|
577 |
|
578 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
579 return; |
|
580 } |
|
581 else |
|
582 { |
|
583 TInt sRet = DeleteProfileL( iLUID + KMaxDataSyncID ); |
|
584 if ( sRet != KErrNone ) |
|
585 { |
|
586 if( sRet == KErrNotFound ) |
|
587 { |
|
588 iCallBack->SetStatusL( aStatusRef, |
|
589 CSmlDmAdapter::ENotFound ); |
|
590 } |
|
591 else if( sRet == KErrInUse ) |
|
592 { |
|
593 iCallBack->SetStatusL( aStatusRef, |
|
594 CSmlDmAdapter::EObjectInUse ); |
|
595 } |
|
596 else |
|
597 { |
|
598 iCallBack->SetStatusL( aStatusRef, |
|
599 CSmlDmAdapter::EError ); |
|
600 } |
|
601 return; |
|
602 } |
|
603 else |
|
604 { |
|
605 _DBG_FILE( "CNSmlDMSettingsAdapter12::DeleteObjectL( ): EOk end" ); |
|
606 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
607 return; |
|
608 } |
|
609 } |
|
610 } |
|
611 else |
|
612 { |
|
613 _DBG_FILE( |
|
614 "CNSmlDMSettingsAdapter12::DeleteObjectL( ): EInvalidObject end" ); |
|
615 iCallBack->SetStatusL( aStatusRef,CSmlDmAdapter::EInvalidObject ); |
|
616 return; |
|
617 } |
|
618 }//Delete whole Profile |
|
619 |
|
620 iLUID = IntLUID( aLUID ); |
|
621 if ( iLUID != iParentLUID ) |
|
622 { |
|
623 if( FindProfileIdL( iLUID ) == EFalse ) |
|
624 { |
|
625 _DBG_FILE( "CNSmlDMSettingsAdapter12::DeleteObjectL( ): end" ); |
|
626 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
627 return; |
|
628 } |
|
629 iParentLUID = iLUID; |
|
630 } |
|
631 |
|
632 if ( iField->Compare( KNSmlDdfAuthScheme ) == 0 ) |
|
633 { |
|
634 DeleteDMAuthInfoL( iLUID, EAuthenticationRequired ); |
|
635 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
636 return; |
|
637 } |
|
638 else if( iField->Compare( KNSmlDdfClientNonce ) == 0 ) |
|
639 { |
|
640 DeleteDMAuthInfoL( iLUID, EClientNonce ); |
|
641 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
642 return; |
|
643 } |
|
644 else if( iField->Compare(KNSmlDdfServerNonce) == 0 ) |
|
645 { |
|
646 DeleteDMAuthInfoL( iLUID, EServerNonce ); |
|
647 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
648 return; |
|
649 } |
|
650 |
|
651 // Sets default value if not null field |
|
652 HBufC8* dataObject = HBufC8::NewLC( 15 ); |
|
653 dataObject->Des().Format( KNullDesC8 ); |
|
654 |
|
655 _LIT8(aType, "text/plain"); |
|
656 iLeafType = EDMDelete; |
|
657 UpdateLeafObjectL( aURI, aLUID, *dataObject, aType, aStatusRef ); |
|
658 CleanupStack::PopAndDestroy(); //dataObject |
|
659 iLeafType = EDMUnset; |
|
660 |
|
661 _DBG_FILE( "CNSmlDMSettingsAdapter12::DeleteObjectL( ): end" ); |
|
662 return; |
|
663 } |
|
664 |
|
665 // ----------------------------------------------------------------------------- |
|
666 // CNSmlDMSettingsAdapter12::FetchLeafObjectL |
|
667 // Fetches profile leaf object data acordint to aURI. |
|
668 // ----------------------------------------------------------------------------- |
|
669 void CNSmlDMSettingsAdapter12::FetchLeafObjectL( const TDesC8& aURI, |
|
670 const TDesC8& aLUID, |
|
671 const TDesC8& aType, |
|
672 const TInt aResultsRef, |
|
673 const TInt aStatusRef ) |
|
674 { |
|
675 |
|
676 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectL(): begin" ); |
|
677 DBG_ARGS(_S16( "DM:Fetch aURI - %S - %S"), &aURI, &aLUID ); |
|
678 |
|
679 iLUID = IntLUID( aLUID ); |
|
680 if ( iLUID >= 0 ) |
|
681 { |
|
682 if( FindProfileIdL( iLUID ) == EFalse ) |
|
683 { |
|
684 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectL(): ENotFound end" ); |
|
685 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
686 return; |
|
687 } |
|
688 } |
|
689 else |
|
690 { |
|
691 |
|
692 // Static node feature start |
|
693 iLUID = -1; |
|
694 if( IsDMAccUriFormatMatchPredefined(aURI) ) |
|
695 { |
|
696 iLUID = ConstructTreeL(aURI); |
|
697 } |
|
698 |
|
699 if (iLUID == -1) |
|
700 { |
|
701 _DBG_FILE( "CNSmlDMSettingsAdapter::FetchLeafObjectL(): ENotFound end" ); |
|
702 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
703 return; |
|
704 } |
|
705 // Static node feature end |
|
706 } |
|
707 |
|
708 // Check which field going to be handled |
|
709 SetField(aURI); |
|
710 SetURIInProcessL(aURI); |
|
711 |
|
712 // Check if valid field |
|
713 if( !AcceptDMField() ) |
|
714 { |
|
715 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectL(): EInvalidObject end" ); |
|
716 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject ); |
|
717 return; |
|
718 } |
|
719 /*if(iField->Compare(KNSmlDdfExt) == 0) |
|
720 { |
|
721 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
722 CBufBase* extNode = CBufFlat::NewL(128); |
|
723 CleanupStack::PushL(extNode); |
|
724 iCallBack->SetResultsL( aResultsRef, *extNode, KNullDesC8 ); |
|
725 CleanupStack::PopAndDestroy(extNode); |
|
726 return; |
|
727 }*/ |
|
728 |
|
729 // Get Database field type |
|
730 TInt fType = GetDMFieldType(); |
|
731 if ( fType == EWrong ) |
|
732 { |
|
733 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectL(): EError end" ); |
|
734 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
735 return; |
|
736 } |
|
737 |
|
738 TNSmlDMProfileData fieldId = GetDMField(); |
|
739 if( fieldId == ESyncAccepted ) |
|
740 { |
|
741 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddLeafObjectL(): EError end" ); |
|
742 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
743 return; |
|
744 } |
|
745 CBufBase *lObject = CBufFlat::NewL( 128 ); |
|
746 CleanupStack::PushL( lObject ); |
|
747 lObject->Reset(); |
|
748 |
|
749 CSmlDmAdapter::TError status; |
|
750 |
|
751 if ( fType == EStr || fType == EInt || fType == EBin ) |
|
752 { |
|
753 // Check for APPId and return w7 |
|
754 TInt rValue = KErrNone; |
|
755 /* if( iField->Compare(KNSmlDdfAppId ) ==0 ) |
|
756 { |
|
757 status = CSmlDmAdapter::EOk; |
|
758 lObject->InsertL(lObject->Size(),KNSmlDdfAppIdValue); |
|
759 |
|
760 }*/ |
|
761 |
|
762 rValue = GetObjectL( iLUID, fieldId, *lObject ); |
|
763 if( rValue != KErrNone ) |
|
764 { |
|
765 if( rValue == KErrNotFound ) |
|
766 { |
|
767 status = CSmlDmAdapter::ENotFound; |
|
768 } |
|
769 else if( rValue == KErrInUse ) |
|
770 { |
|
771 status = CSmlDmAdapter::EObjectInUse; |
|
772 } |
|
773 else if( rValue == KErrNoMemory ) |
|
774 { |
|
775 status = CSmlDmAdapter::ENoMemory; |
|
776 } |
|
777 else |
|
778 { |
|
779 status = CSmlDmAdapter::EError; |
|
780 } |
|
781 } |
|
782 else |
|
783 { |
|
784 status = CSmlDmAdapter::EOk; |
|
785 } |
|
786 } |
|
787 else |
|
788 { |
|
789 CleanupStack::PopAndDestroy(); //lObject |
|
790 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectL(): ENotFound end" ); |
|
791 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
792 iProfile.Close(); |
|
793 iSyncSession.Close(); |
|
794 iSyncSessionOpen = EFalse; |
|
795 return; |
|
796 } |
|
797 iCallBack->SetStatusL( aStatusRef, status ); |
|
798 |
|
799 if(status==CSmlDmAdapter::EOk) |
|
800 { |
|
801 iCallBack->SetResultsL( aResultsRef, *lObject, aType ); |
|
802 } |
|
803 |
|
804 CleanupStack::PopAndDestroy(); //lObject |
|
805 iProfile.Close(); |
|
806 iSyncSession.Close(); |
|
807 iSyncSessionOpen = EFalse; |
|
808 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectL(): end" ); |
|
809 return; |
|
810 } |
|
811 |
|
812 // ----------------------------------------------------------------------------- |
|
813 // CSmlDmSettingsAdapter::ChildURIListL |
|
814 // Function returns the list of profiles or leafs of the profile |
|
815 // acording to aURI. |
|
816 // ----------------------------------------------------------------------------- |
|
817 void CNSmlDMSettingsAdapter12::ChildURIListL( const TDesC8& aURI, |
|
818 const TDesC8& aLUID, |
|
819 const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, |
|
820 const TInt aResultsRef, |
|
821 const TInt aStatusRef ) |
|
822 { |
|
823 _DBG_FILE( "CNSmlDMSettingsAdapter12::ChildURIListL(): begin" ); |
|
824 CBufBase *currentURISegmentList = CBufFlat::NewL( 128 ); |
|
825 CleanupStack::PushL( currentURISegmentList ); |
|
826 |
|
827 if(( aURI.Match( KDmAccMatch ) != KErrNotFound ) && |
|
828 (aURI.Match( KDmAccMatch3 ) == KErrNotFound )) |
|
829 { |
|
830 // Check if Profile exists |
|
831 TInt checkLUID = GetIntObject( aLUID ); |
|
832 if( FindProfileIdL( checkLUID ) ) |
|
833 { |
|
834 currentURISegmentList->InsertL( currentURISegmentList->Size(), KSegmDMAcc ); |
|
835 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
836 iCallBack->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 ); |
|
837 } |
|
838 else |
|
839 { |
|
840 // Static node feature start |
|
841 checkLUID = -1; |
|
842 if( IsDMAccUriFormatMatchPredefined(aURI) ) |
|
843 { |
|
844 checkLUID = ConstructTreeL(aURI); |
|
845 } |
|
846 |
|
847 if (checkLUID == -1) |
|
848 { |
|
849 _DBG_FILE( "CNSmlDMSettingsAdapter::childURI(): ENotFound end" ); |
|
850 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
851 CleanupStack::PopAndDestroy( ); // currentURISegmentList |
|
852 _DBG_FILE( "CNSmlDMSettingsAdapter::ChildURIListL(): end" ); |
|
853 return; |
|
854 } |
|
855 else |
|
856 { |
|
857 currentURISegmentList->InsertL( currentURISegmentList->Size(), KSegmDMAcc ); |
|
858 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
859 iCallBack->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 ); |
|
860 |
|
861 } |
|
862 |
|
863 |
|
864 // iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
865 // Static node feature start end |
|
866 } |
|
867 |
|
868 CleanupStack::PopAndDestroy( ); // currentURISegmentList |
|
869 _DBG_FILE( "CNSmlDMSettingsAdapter12::ChildURIListL(): end" ); |
|
870 return; |
|
871 } |
|
872 else if(( aURI.Match( KDmAccMatch2 ) != KErrNotFound ) && |
|
873 (aURI.Match( KDmAccMatch ) == KErrNotFound )) |
|
874 { |
|
875 if( iSyncSessionOpen == EFalse ) |
|
876 { |
|
877 iSyncSession.OpenL(); |
|
878 iSyncSessionOpen = ETrue; |
|
879 } |
|
880 RArray<TSmlProfileId> profileIdArray; |
|
881 CleanupClosePushL( profileIdArray ); |
|
882 TSmlUsageType usageType = ESmlDevMan; |
|
883 iSyncSession.ListProfilesL( profileIdArray, usageType ); |
|
884 |
|
885 for( TInt p = 0; p < profileIdArray.Count(); p++ ) |
|
886 { |
|
887 TBool notInList = ETrue; |
|
888 TInt newline = 0; |
|
889 TInt ddId = profileIdArray[p] - KMaxDataSyncID; |
|
890 |
|
891 while( notInList && newline < aPreviousURISegmentList.Count() ) |
|
892 { |
|
893 TInt ppId = GetIntObject( aPreviousURISegmentList.At(newline).iURISegLUID ); |
|
894 if( ppId == ddId ) |
|
895 { |
|
896 notInList = EFalse; |
|
897 break; |
|
898 } |
|
899 newline++; |
|
900 } |
|
901 if( notInList ) |
|
902 { |
|
903 _LIT8( Kprev, "DMId" ); |
|
904 TBuf8<7> addNAME(Kprev); // DMIdnnn , nnn = profileid |
|
905 TInt fixedProfId = profileIdArray[p] - KMaxDataSyncID; //fit to 3 decimal |
|
906 addNAME.AppendNumFixedWidth( fixedProfId, EDecimal, 3 ); |
|
907 |
|
908 currentURISegmentList->InsertL( currentURISegmentList->Size(), addNAME ); |
|
909 currentURISegmentList->InsertL( currentURISegmentList->Size(), KSmlDmSlash ); |
|
910 DBG_ARGS8( _S8("notInList: Id = %d Name %S"), p, &addNAME ); |
|
911 |
|
912 // KNSmlDMStart includes start text for URISeg |
|
913 TBuf8<20> addURI; // SyncML/DMAcc/DMIdnnn , nnn = profileid |
|
914 addURI.Append( KNSmlDMStart ); |
|
915 addURI.AppendNumFixedWidth( fixedProfId, EDecimal, 3 ); |
|
916 |
|
917 TBuf8<3> addLUID; |
|
918 addLUID.Num( fixedProfId ); |
|
919 |
|
920 // Also added to mapping |
|
921 iCallBack->SetMappingL( addURI, addLUID ); |
|
922 } |
|
923 else |
|
924 { // Add those in PreviousList which are on database |
|
925 currentURISegmentList->InsertL( currentURISegmentList->Size(), |
|
926 aPreviousURISegmentList.At(newline).iURISeg ); |
|
927 currentURISegmentList->InsertL( currentURISegmentList->Size(), KSmlDmSlash ); |
|
928 // DBG_ARGS8( _S8("InList: Id = %d Name %S"), newline, |
|
929 // aPreviousURISegmentList.At(newline).iURISeg ); |
|
930 } |
|
931 } |
|
932 CleanupStack::PopAndDestroy( 1 );//profileIdArray |
|
933 } |
|
934 |
|
935 // AppAddr subtree |
|
936 else if( ( aURI.Match( KDmAccAppAddrMatch ) != KErrNotFound ) && (aURI.Match( KDmAccPortMatch ) == KErrNotFound ) && (aURI.Match( KDmAccPortFullMatch ) == KErrNotFound )) |
|
937 { |
|
938 currentURISegmentList->InsertL( currentURISegmentList->Size(), KDmAccAppAddrId ); |
|
939 } |
|
940 else if(( aURI.Match( KDmAccAppAddrFullMatch ) != KErrNotFound ) && (aURI.Match( KDmAccPortMatch ) == KErrNotFound ) && (aURI.Match( KDmAccPortFullMatch ) == KErrNotFound )) |
|
941 { |
|
942 currentURISegmentList->InsertL( currentURISegmentList->Size(), KSegmDMAccAppAddr ); |
|
943 } |
|
944 else if(( aURI.Match( KDmAccPortMatch ) != KErrNotFound ) && (aURI.Match( KDmAccPortFullMatch ) == KErrNotFound )) |
|
945 { |
|
946 currentURISegmentList->InsertL( currentURISegmentList->Size(), KSegmDMAccPortRT ); |
|
947 } |
|
948 else if( aURI.Match( KDmAccPortFullMatch ) != KErrNotFound ) |
|
949 { |
|
950 currentURISegmentList->InsertL( currentURISegmentList->Size(), KSegmDMAccport ); |
|
951 } |
|
952 |
|
953 else if(( aURI.Match( KDmAccAppAuthMatch ) != KErrNotFound ) && (aURI.Match( KDmAccAppAuthFullMatch ) == KErrNotFound )) |
|
954 { |
|
955 currentURISegmentList->InsertL( currentURISegmentList->Size(), KDmAccAppAuthNodes ); |
|
956 } |
|
957 else if((aURI.Match(KDmAccAppAuthSrvMatch) != KErrNotFound) || (aURI.Match(KDmAccAppAuthCliMatch) != KErrNotFound) || (aURI.Match(KDmAccAppAuthTransMatch) != KErrNotFound)) //|| (aURI.Match(KDmAccAppAuthObexMatch) != KErrNotFound) || (aURI.Match(KDmAccAppAuthHttpMatch) != KErrNotFound)) |
|
958 { |
|
959 currentURISegmentList->InsertL( currentURISegmentList->Size(), KSegmDMAccAppAuth ); |
|
960 } |
|
961 else if(( aURI.Match( KDmAccAppAuthFullMatch ) != KErrNotFound ) && (aURI.Find( KDmAccAppAuthNodes ) != KErrNotFound)) |
|
962 { |
|
963 currentURISegmentList->InsertL( currentURISegmentList->Size(), KSegmDMAccAppAuth ); |
|
964 } |
|
965 |
|
966 else if( aURI.Match( KDmAccExtMatch ) != KErrNotFound ) |
|
967 { |
|
968 currentURISegmentList->InsertL( currentURISegmentList->Size(), KSegmDMAccLocked ); |
|
969 } |
|
970 else |
|
971 { |
|
972 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject ); |
|
973 CleanupStack::PopAndDestroy( 1 ); // currentURISegmentList |
|
974 return; |
|
975 } |
|
976 |
|
977 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
978 iCallBack->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 ); |
|
979 CleanupStack::PopAndDestroy(); // currentURISegmentList |
|
980 _DBG_FILE( "CNSmlDMSettingsAdapter12::ChildURIListL(): end" ); |
|
981 return; |
|
982 } |
|
983 |
|
984 // ----------------------------------------------------------------------------- |
|
985 // CNSmlDMSettingsAdapter12::AddNodeObjectL |
|
986 // Adds new DM-settings profile to database |
|
987 // ----------------------------------------------------------------------------- |
|
988 void CNSmlDMSettingsAdapter12::AddNodeObjectL( const TDesC8& aURI, |
|
989 const TDesC8& aParentLUID, |
|
990 const TInt aStatusRef ) |
|
991 { |
|
992 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddNodeObjectL(): begin" ); |
|
993 |
|
994 if( aParentLUID.Length() > 0 ) |
|
995 { |
|
996 iParentLUID = GetIntObject( aParentLUID ); |
|
997 if( FindProfileIdL( iParentLUID ) != EFalse )// iProfile != NULL) |
|
998 { |
|
999 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddNodeObjectL(): EAlreadyExists end" ); |
|
1000 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EAlreadyExists ); |
|
1001 return; |
|
1002 } |
|
1003 } |
|
1004 iNewProfile = ETrue; |
|
1005 AddNodeBufferL (aURI, aStatusRef); |
|
1006 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddNodeObjectL(): end" ); |
|
1007 return; |
|
1008 } |
|
1009 |
|
1010 // ----------------------------------------------------------------------------- |
|
1011 // CNSmlDMSettingsAdapter12::UpdateLeafObjectL() |
|
1012 // ----------------------------------------------------------------------------- |
|
1013 void CNSmlDMSettingsAdapter12::UpdateLeafObjectL( const TDesC8&, const TDesC8&, |
|
1014 RWriteStream*&, const TDesC8&, |
|
1015 const TInt ) |
|
1016 { |
|
1017 //Not supported because data streaming is not supported by this adapter. |
|
1018 } |
|
1019 |
|
1020 // ----------------------------------------------------------------------------- |
|
1021 // CNSmlDMSettingsAdapter12::FetchLeafObjectSizeL |
|
1022 // This function fetches leaf object and returns its size. |
|
1023 // ----------------------------------------------------------------------------- |
|
1024 void CNSmlDMSettingsAdapter12::FetchLeafObjectSizeL( const TDesC8& aURI, |
|
1025 const TDesC8& aLUID, |
|
1026 const TDesC8& aType, |
|
1027 const TInt aResultsRef, |
|
1028 const TInt aStatusRef ) |
|
1029 { |
|
1030 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectSizeL() : begin" ); |
|
1031 DBG_ARGS( _S16("DM:Fetch aURI - %S - %S"), &aURI, &aLUID ); |
|
1032 |
|
1033 iLUID = IntLUID( aLUID ); |
|
1034 if ( iLUID >= 0 ) |
|
1035 { |
|
1036 if( FindProfileIdL( iLUID ) == EFalse ) |
|
1037 { |
|
1038 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectL(): ENotFound end" ); |
|
1039 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
1040 return; |
|
1041 } |
|
1042 } |
|
1043 else |
|
1044 { |
|
1045 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectL(): ENotFound end" ); |
|
1046 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
1047 return; |
|
1048 } |
|
1049 |
|
1050 // Check which field going to be handled |
|
1051 SetField( aURI ); |
|
1052 SetURIInProcessL (aURI); |
|
1053 |
|
1054 // Check if valid field |
|
1055 if( !AcceptDMField() ) |
|
1056 { |
|
1057 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectL(): EInvalidObject end" ); |
|
1058 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject ); |
|
1059 return; |
|
1060 } |
|
1061 /*if(aURI.Find( KNSmlDdfExt ) != KErrNotFound) |
|
1062 { |
|
1063 return; |
|
1064 }*/ |
|
1065 |
|
1066 // Get Database field type |
|
1067 TInt fType = GetDMFieldType(); |
|
1068 if ( fType == EWrong ) |
|
1069 { |
|
1070 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectL(): EError end" ); |
|
1071 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
1072 return; |
|
1073 } |
|
1074 |
|
1075 CBufBase *lObject = CBufFlat::NewL( 128 ); |
|
1076 CleanupStack::PushL( lObject ); |
|
1077 lObject->Reset(); |
|
1078 |
|
1079 if ( fType == EStr || fType == EInt || fType == EBin ) |
|
1080 { |
|
1081 TInt rValue = GetObjectL( iLUID, GetDMField(), *lObject ); |
|
1082 if( lObject->Size() == 0 || rValue != KErrNone ) |
|
1083 { |
|
1084 if( rValue == KErrNotFound ) |
|
1085 { |
|
1086 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
1087 } |
|
1088 else if( rValue == KErrInUse ) |
|
1089 { |
|
1090 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EObjectInUse ); |
|
1091 } |
|
1092 else if( rValue == KErrNoMemory ) |
|
1093 { |
|
1094 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENoMemory ); |
|
1095 } |
|
1096 else |
|
1097 { |
|
1098 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
1099 } |
|
1100 } |
|
1101 } |
|
1102 else |
|
1103 { |
|
1104 CleanupStack::PopAndDestroy();//lObject |
|
1105 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectL(): ENotFound end" ); |
|
1106 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
1107 return; |
|
1108 } |
|
1109 TInt objSizeInBytes = lObject->Size(); |
|
1110 TBuf8<16> stringObjSizeInBytes; |
|
1111 stringObjSizeInBytes.Num( objSizeInBytes ); |
|
1112 |
|
1113 lObject->Reset(); |
|
1114 lObject->InsertL( 0, stringObjSizeInBytes ); |
|
1115 iCallBack->SetResultsL( aResultsRef, *lObject, aType ); |
|
1116 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk); |
|
1117 |
|
1118 CleanupStack::PopAndDestroy( 1 ); //lObject |
|
1119 _DBG_FILE( "CNSmlDMSettingsAdapter12::FetchLeafObjectSizeL(): end" ); |
|
1120 return; |
|
1121 } |
|
1122 |
|
1123 // ----------------------------------------------------------------------------- |
|
1124 // CNSmlDMSettingsAdapter12::ExecuteCommandL() |
|
1125 // ----------------------------------------------------------------------------- |
|
1126 void CNSmlDMSettingsAdapter12::ExecuteCommandL( const TDesC8&, const TDesC8&, |
|
1127 const TDesC8&, const TDesC8&, |
|
1128 const TInt ) |
|
1129 { |
|
1130 //Not supported. Command execution via DM settings adapter not possible. |
|
1131 } |
|
1132 |
|
1133 // ----------------------------------------------------------------------------- |
|
1134 // CNSmlDMSettingsAdapter12::ExecuteCommandL() |
|
1135 // ----------------------------------------------------------------------------- |
|
1136 void CNSmlDMSettingsAdapter12::ExecuteCommandL( const TDesC8&, const TDesC8&, |
|
1137 RWriteStream*&, const TDesC8&, |
|
1138 const TInt ) |
|
1139 { |
|
1140 //Not supported. Command execution via DM settings adapter not possible. |
|
1141 } |
|
1142 |
|
1143 // ----------------------------------------------------------------------------- |
|
1144 // CNSmlDMSettingsAdapter12::CopyCommandL() |
|
1145 // ----------------------------------------------------------------------------- |
|
1146 void CNSmlDMSettingsAdapter12::CopyCommandL( const TDesC8&, const TDesC8&, |
|
1147 const TDesC8&, const TDesC8&, |
|
1148 const TDesC8&, TInt ) |
|
1149 { |
|
1150 //Not supported. |
|
1151 } |
|
1152 |
|
1153 // ----------------------------------------------------------------------------- |
|
1154 // CNSmlDMSettingsAdapter12::StartAtomicL() |
|
1155 // ----------------------------------------------------------------------------- |
|
1156 void CNSmlDMSettingsAdapter12::StartAtomicL() |
|
1157 { |
|
1158 //Not supported. Handling Atomic command cycles not supported by the adapter. |
|
1159 } |
|
1160 |
|
1161 // ----------------------------------------------------------------------------- |
|
1162 // CNSmlDMSettingsAdapter12::CommitAtomicL() |
|
1163 // ----------------------------------------------------------------------------- |
|
1164 void CNSmlDMSettingsAdapter12::CommitAtomicL() |
|
1165 { |
|
1166 //Not supported. Handling Atomic command cycles not supported by the adapter. |
|
1167 } |
|
1168 |
|
1169 // ----------------------------------------------------------------------------- |
|
1170 // CNSmlDMSettingsAdapter12::RollbackAtomicL() |
|
1171 // ----------------------------------------------------------------------------- |
|
1172 void CNSmlDMSettingsAdapter12::RollbackAtomicL() |
|
1173 { |
|
1174 //Not supported. Handling Atomic command cycles not supported by the adapter. |
|
1175 } |
|
1176 |
|
1177 // ----------------------------------------------------------------------------- |
|
1178 // CNSmlDMSettingsAdapter12::StreamingSupport() |
|
1179 // Indicates if streaming is supported. |
|
1180 // ----------------------------------------------------------------------------- |
|
1181 TBool CNSmlDMSettingsAdapter12::StreamingSupport( TInt& /*aItemSize*/ ) |
|
1182 { |
|
1183 return EFalse; |
|
1184 } |
|
1185 |
|
1186 // ----------------------------------------------------------------------------- |
|
1187 // CNSmlDMSettingsAdapter12::StreamCommittedL() |
|
1188 // ----------------------------------------------------------------------------- |
|
1189 void CNSmlDMSettingsAdapter12::StreamCommittedL() |
|
1190 { |
|
1191 //Not supported. Streaming not supported by the DM settings adapter. |
|
1192 } |
|
1193 // ----------------------------------------------------------------------------- |
|
1194 // CNSmlDMSettingsAdapter12::CompleteOutstandingCmdsL() |
|
1195 // If buffering used, commands must be executed before returning this function. |
|
1196 // ----------------------------------------------------------------------------- |
|
1197 void CNSmlDMSettingsAdapter12::CompleteOutstandingCmdsL() |
|
1198 { |
|
1199 // Check if Buffered |
|
1200 for (int val=0; val<iBuffer->Count ();val++) |
|
1201 { |
|
1202 if ( !iBuffer->At(val).iExecuted) |
|
1203 { |
|
1204 TInt count = iBuffer->At(val).iLeafBuf->Count ()-1; |
|
1205 iExecutionIndex = val; |
|
1206 iComplete = ETrue; |
|
1207 ExecuteBufferL (); |
|
1208 } |
|
1209 } |
|
1210 for (TInt i = 0;i<iProfileLockBuffer.Count(); i++) |
|
1211 { |
|
1212 TInt err = SetProfileLockL(iProfileLockBuffer[i].iProfileLockLUID, iProfileLockBuffer[i].iProfileLock) ; |
|
1213 |
|
1214 } |
|
1215 |
|
1216 // if port was updated, set it |
|
1217 for (TInt i = 0;i<iPortBuffer.Count(); i++) |
|
1218 { |
|
1219 TInt err = SetProfileConnectionPortNrL( iPortBuffer[i].iPortBufLUID, iPortBuffer[i].iPortBuf ); |
|
1220 |
|
1221 // set status |
|
1222 if ( err != KErrNone ) |
|
1223 { |
|
1224 iCallBack->SetStatusL( iPortBuffer[i].iPortBufStatusRef, CSmlDmAdapter::EError ); |
|
1225 } |
|
1226 else |
|
1227 { |
|
1228 iCallBack->SetStatusL( iPortBuffer[i].iPortBufStatusRef, CSmlDmAdapter::EOk ); |
|
1229 } |
|
1230 |
|
1231 } |
|
1232 iPortBuffer.Reset(); |
|
1233 } |
|
1234 |
|
1235 // ----------------------------------------------------------------------------- |
|
1236 // CNSmlDMSettingsAdapter12::AcceptDMField |
|
1237 // This function checks if field to be handled is valid. |
|
1238 // ----------------------------------------------------------------------------- |
|
1239 TBool CNSmlDMSettingsAdapter12::AcceptDMField() |
|
1240 { |
|
1241 _DBG_FILE("CNSmlDMSettingsAdapter12::AcceptDMField(): begin"); |
|
1242 |
|
1243 if ( iField->Compare( KNSmlDdfAddrType ) == 0 ) |
|
1244 { |
|
1245 return ETrue; |
|
1246 } |
|
1247 else if ( iField->Compare( KNSmlDdfAddr ) == 0 ) |
|
1248 { |
|
1249 return ETrue; |
|
1250 } |
|
1251 else if ( iField->Compare( KNSmlDdfPortNbr ) == 0 ) |
|
1252 { |
|
1253 return ETrue; |
|
1254 } |
|
1255 else if ( iField->Compare( KNSmlDdfAuthScheme ) == 0 ) |
|
1256 { |
|
1257 return ETrue; |
|
1258 } |
|
1259 else if ( iField->Compare( KNSmlDdfServerId ) == 0 ) |
|
1260 { |
|
1261 return ETrue; |
|
1262 } |
|
1263 else if ( iField->Compare( KNSmlDdfServerPW ) == 0 ) |
|
1264 { |
|
1265 return ETrue; |
|
1266 } |
|
1267 else if ( iField->Compare( KNSmlDdfServerNonce ) == 0 ) |
|
1268 { |
|
1269 return ETrue; |
|
1270 } |
|
1271 else if ( iField->Compare( KNSmlDdfClientUserName ) == 0 ) |
|
1272 { |
|
1273 return ETrue; |
|
1274 } |
|
1275 else if ( iField->Compare( KNSmlDdfClientPW ) == 0 ) |
|
1276 { |
|
1277 return ETrue; |
|
1278 } |
|
1279 else if ( iField->Compare( KNSmlDdfClientNonce ) == 0 ) |
|
1280 { |
|
1281 return ETrue; |
|
1282 } |
|
1283 else if ( iField->Compare( KNSmlDdfName ) == 0 ) |
|
1284 { |
|
1285 return ETrue; |
|
1286 } |
|
1287 |
|
1288 else if ( iField->Compare( KNSmlDdfId ) == 0 ) |
|
1289 { |
|
1290 return ETrue; |
|
1291 } |
|
1292 else if ( iField->Compare(KNSmlDdfAppId) == 0 ) |
|
1293 { |
|
1294 return ETrue; |
|
1295 } |
|
1296 else if ( iField->Compare(KNSmlDdfPrefConRef) == 0 ) |
|
1297 { |
|
1298 return ETrue; |
|
1299 } |
|
1300 else if (iField->Compare(KNSmlDdfAAuthLevel) == 0 ) |
|
1301 { |
|
1302 return ETrue; |
|
1303 } |
|
1304 |
|
1305 else if (iField->Compare(KNSmlDdfAAuthType) == 0 ) |
|
1306 { |
|
1307 return ETrue; |
|
1308 } |
|
1309 else if (iField->Compare(KNSmlDdfAAuthName) == 0 ) |
|
1310 { |
|
1311 return ETrue; |
|
1312 } |
|
1313 |
|
1314 else if (iField->Compare(KNSmlDdfAAuthSecret) == 0 ) |
|
1315 { |
|
1316 return ETrue; |
|
1317 } |
|
1318 else if (iField->Compare(KNSmlDdfAAuthData) == 0 ) |
|
1319 { |
|
1320 return ETrue; |
|
1321 } |
|
1322 else if (iField->Compare(KNSmlDdfLocked) == 0 ) |
|
1323 { |
|
1324 return ETrue; |
|
1325 } |
|
1326 |
|
1327 _DBG_FILE( "CNSmlDMSettingsAdapter12::AcceptDMField(): end" ); |
|
1328 return EFalse; // Not a valid Type |
|
1329 } |
|
1330 |
|
1331 // ----------------------------------------------------------------------------- |
|
1332 // CNSmlDMSettingsAdapter12::GetDMField |
|
1333 // Matches URI fieldname to DM-database. |
|
1334 // ----------------------------------------------------------------------------- |
|
1335 TNSmlDMProfileData CNSmlDMSettingsAdapter12::GetDMField() |
|
1336 { |
|
1337 |
|
1338 if ( iField->Compare( KNSmlDdfAddrType ) == 0 ) |
|
1339 { |
|
1340 |
|
1341 return EProfileAddrType; |
|
1342 |
|
1343 } |
|
1344 else if ( iField->Compare( KNSmlDdfAddr ) == 0 ) |
|
1345 { |
|
1346 return EProfileURL; |
|
1347 } |
|
1348 else if ( iField->Compare( KNSmlDdfPortNbr ) == 0 ) |
|
1349 { |
|
1350 return EProfilePort; |
|
1351 } |
|
1352 else if ( iField->Compare( KNSmlDdfAuthScheme ) == 0 ) |
|
1353 { |
|
1354 return EAuthenticationRequired; |
|
1355 } |
|
1356 else if ( iField->Compare( KNSmlDdfServerId ) == 0 ) |
|
1357 { |
|
1358 return EServerId; |
|
1359 } |
|
1360 else if ( iField->Compare( KNSmlDdfServerPW ) == 0 ) |
|
1361 { |
|
1362 return ESharedSecret; |
|
1363 } |
|
1364 else if ( iField->Compare( KNSmlDdfServerNonce ) == 0 ) |
|
1365 { |
|
1366 return EServerNonce; |
|
1367 } |
|
1368 else if ( iField->Compare( KNSmlDdfClientUserName ) == 0 ) |
|
1369 { |
|
1370 return EProfileDMServerUsername; |
|
1371 } |
|
1372 else if ( iField->Compare( KNSmlDdfClientPW ) == 0 ) |
|
1373 { |
|
1374 return EProfileDMServerPassword; |
|
1375 } |
|
1376 else if ( iField->Compare( KNSmlDdfClientNonce ) == 0 ) |
|
1377 { |
|
1378 return EClientNonce; |
|
1379 } |
|
1380 else if ( iField->Compare( KNSmlDdfName ) == 0 ) |
|
1381 { |
|
1382 return EProfileName; |
|
1383 } |
|
1384 else if ( iField->Compare( KNSmlDdfId ) == 0 ) |
|
1385 { |
|
1386 return EProfileId; |
|
1387 } |
|
1388 |
|
1389 else if ( iField->Compare( KNSmlDdfPrefConRef ) == 0 ) |
|
1390 { |
|
1391 return EProfileIAPId; |
|
1392 } |
|
1393 |
|
1394 else if ( iField->Compare( KNSmlDdfAppId ) == 0 ) |
|
1395 { |
|
1396 return EProfileIAPId; |
|
1397 } |
|
1398 else if ( iField->Compare( KNSmlDdfLocked) == 0 ) |
|
1399 { |
|
1400 return EProfileLock; |
|
1401 } |
|
1402 |
|
1403 else if (iField->Compare(KNSmlDdfAAuthLevel) == 0 ) |
|
1404 { |
|
1405 if(iURIField->Find(KDmAccAppAuthDyn1) != KErrNotFound) |
|
1406 return EPRofileServerCred; |
|
1407 else if (iURIField->Find(KDmAccAppAuthDyn2)!= KErrNotFound) |
|
1408 return EPRofileClientCred; |
|
1409 else if (iURIField->Find(KDmAccAppAuthTransport)!= KErrNotFound) |
|
1410 return EProfileTransport; |
|
1411 } |
|
1412 |
|
1413 else if (iField->Compare(KNSmlDdfAAuthType) == 0 ) |
|
1414 { |
|
1415 return EProfileAAuthType; |
|
1416 } |
|
1417 else if (iField->Compare(KNSmlDdfAAuthName) == 0 ) |
|
1418 { |
|
1419 if(iURIField->Find(KDmAccAppAuthDyn1) != KErrNotFound) |
|
1420 return EProfileName; |
|
1421 else if (iURIField->Find(KDmAccAppAuthDyn2)!= KErrNotFound) |
|
1422 return EProfileDMServerUsername; |
|
1423 else if (iURIField->Find(KDmAccAppAuthTransport)!= KErrNotFound) |
|
1424 { |
|
1425 return ETransportAuthName; |
|
1426 } |
|
1427 |
|
1428 // return ETrue; |
|
1429 } |
|
1430 |
|
1431 else if (iField->Compare(KNSmlDdfAAuthSecret) == 0 ) |
|
1432 { |
|
1433 if(iURIField->Find(KDmAccAppAuthDyn1) != KErrNotFound) |
|
1434 return ESharedSecret; |
|
1435 else if (iURIField->Find(KDmAccAppAuthDyn2)!= KErrNotFound) |
|
1436 return EProfileDMServerPassword; |
|
1437 else if (iURIField->Find(KDmAccAppAuthTransport)!= KErrNotFound) |
|
1438 { |
|
1439 return EProfileTransportPassword; |
|
1440 } |
|
1441 } |
|
1442 else if (iField->Compare(KNSmlDdfAAuthData) == 0 ) |
|
1443 { |
|
1444 if(iURIField->Find(KDmAccAppAuthDyn1) != KErrNotFound) |
|
1445 return EServerNonce; |
|
1446 else if (iURIField->Find(KDmAccAppAuthDyn2)!= KErrNotFound) |
|
1447 return EClientNonce; |
|
1448 else if (iURIField->Find(KDmAccAppAuthTransport)!= KErrNotFound) |
|
1449 return EProfileTransportAuthData; |
|
1450 } |
|
1451 |
|
1452 |
|
1453 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetDMField(): Error" ); |
|
1454 return ESyncAccepted; |
|
1455 } |
|
1456 |
|
1457 // ----------------------------------------------------------------------------- |
|
1458 // CNSmlDMSettingsAdapter12::GetDMFieldType |
|
1459 // Gets field data type. |
|
1460 // ----------------------------------------------------------------------------- |
|
1461 TNSmlDMFieldType CNSmlDMSettingsAdapter12::GetDMFieldType() const |
|
1462 { |
|
1463 if ( iField->Compare( KNSmlDdfAddrType ) == 0 ) |
|
1464 { |
|
1465 return EInt; |
|
1466 } |
|
1467 else if ( iField->Compare( KNSmlDdfAddr ) == 0 ) |
|
1468 { |
|
1469 return EStr; |
|
1470 } |
|
1471 else if ( iField->Compare( KNSmlDdfPortNbr ) == 0 ) |
|
1472 { |
|
1473 return EInt; |
|
1474 } |
|
1475 else if ( iField->Compare( KNSmlDdfAuthScheme ) == 0 ) |
|
1476 { |
|
1477 return EInt; |
|
1478 } |
|
1479 else if ( iField->Compare( KNSmlDdfServerId ) == 0 ) |
|
1480 { |
|
1481 return EStr; |
|
1482 } |
|
1483 else if ( iField->Compare( KNSmlDdfServerPW ) == 0 ) |
|
1484 { |
|
1485 return EStr; |
|
1486 } |
|
1487 else if ( iField->Compare( KNSmlDdfServerNonce ) == 0 ) |
|
1488 { |
|
1489 return EBin; |
|
1490 } |
|
1491 else if ( iField->Compare( KNSmlDdfClientUserName ) == 0 ) |
|
1492 { |
|
1493 return EStr; |
|
1494 } |
|
1495 else if ( iField->Compare( KNSmlDdfClientPW ) == 0 ) |
|
1496 { |
|
1497 return EStr; |
|
1498 } |
|
1499 else if (iField->Compare(KNSmlDdfClientNonce) == 0) |
|
1500 { |
|
1501 return EBin; |
|
1502 } |
|
1503 else if ( iField->Compare( KNSmlDdfName ) == 0 ) |
|
1504 { |
|
1505 return EStr; |
|
1506 } |
|
1507 |
|
1508 else if ( iField->Compare( KNSmlDdfId ) == 0 ) |
|
1509 { |
|
1510 return EInt; |
|
1511 } |
|
1512 else if( iField->Compare(KNSmlDdfAppId ) ==0 ) |
|
1513 { |
|
1514 return EStr; |
|
1515 } |
|
1516 else if ( iField->Compare( KNSmlDdfPrefConRef ) == 0 ) |
|
1517 { |
|
1518 return EInt; |
|
1519 } |
|
1520 else if (iField->Compare(KNSmlDdfAAuthLevel) == 0 ) |
|
1521 { |
|
1522 return EStr; |
|
1523 } |
|
1524 |
|
1525 else if (iField->Compare(KNSmlDdfAAuthType) == 0 ) |
|
1526 { |
|
1527 return EStr; |
|
1528 } |
|
1529 else if (iField->Compare(KNSmlDdfAAuthName) == 0 ) |
|
1530 { |
|
1531 return EStr; |
|
1532 } |
|
1533 |
|
1534 else if (iField->Compare(KNSmlDdfAAuthSecret) == 0 ) |
|
1535 { |
|
1536 return EStr; |
|
1537 } |
|
1538 else if (iField->Compare(KNSmlDdfAAuthData) == 0 ) |
|
1539 { |
|
1540 return EBin; |
|
1541 } |
|
1542 |
|
1543 else if(iField->Compare(KNSmlDdfLocked)==0) |
|
1544 { |
|
1545 return EStr; |
|
1546 } |
|
1547 |
|
1548 |
|
1549 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetDMFieldType(): Error" ); |
|
1550 return EWrong; |
|
1551 } |
|
1552 |
|
1553 // ----------------------------------------------------------------------------- |
|
1554 // CNSmlDMSettingsAdapter12::IntLUID |
|
1555 // Returns integer value for a profile LUID. |
|
1556 // ----------------------------------------------------------------------------- |
|
1557 TInt CNSmlDMSettingsAdapter12::IntLUID( const TDesC8& aLUID ) |
|
1558 { |
|
1559 TLex8 lLex( aLUID ); |
|
1560 |
|
1561 if( lLex.Val( iLUID ) == KErrNone ) |
|
1562 { |
|
1563 return iLUID; |
|
1564 } |
|
1565 else |
|
1566 { |
|
1567 return -1; |
|
1568 } |
|
1569 } |
|
1570 |
|
1571 // ----------------------------------------------------------------------------- |
|
1572 // CNSmlDMSettingsAdapter12::GetIntObject |
|
1573 // Returns integer value for a aObject. |
|
1574 // ----------------------------------------------------------------------------- |
|
1575 TInt CNSmlDMSettingsAdapter12::GetIntObject( const TDesC8& aObject ) |
|
1576 { |
|
1577 TLex8 lLex( aObject ); |
|
1578 |
|
1579 TInt value = 0; |
|
1580 |
|
1581 if( lLex.Val( value ) != KErrNone ) |
|
1582 { |
|
1583 return KErrNotFound; |
|
1584 } |
|
1585 else |
|
1586 { |
|
1587 return value; |
|
1588 } |
|
1589 } |
|
1590 |
|
1591 // ----------------------------------------------------------------------------- |
|
1592 // CNSmlDMSettingsAdapter12::GetIntObject16() |
|
1593 // Returns Integer Value for a 16 bit data object. |
|
1594 // ----------------------------------------------------------------------------- |
|
1595 TInt CNSmlDMSettingsAdapter12::GetIntObject16( const TDesC& aObject ) |
|
1596 { |
|
1597 TLex16 lLex( aObject ); |
|
1598 |
|
1599 TInt value = 0; |
|
1600 |
|
1601 if( lLex.Val( value ) == KErrNone ) |
|
1602 { |
|
1603 return value; |
|
1604 } |
|
1605 else |
|
1606 { |
|
1607 return value; |
|
1608 } |
|
1609 } |
|
1610 |
|
1611 // ----------------------------------------------------------------------------- |
|
1612 // CNSmlDMSettingsAdapter12::SetIntObjectLC |
|
1613 // Converts integer to HBufC8 type buffer and returns reference to it. |
|
1614 // ----------------------------------------------------------------------------- |
|
1615 TDesC8& CNSmlDMSettingsAdapter12::SetIntObjectLC( const TInt& aObject ) |
|
1616 { |
|
1617 HBufC8* buf = HBufC8::NewLC( 8 ); |
|
1618 TPtr8 ptrBuf = buf->Des(); |
|
1619 |
|
1620 ptrBuf.Num( aObject ); |
|
1621 return *buf; |
|
1622 } |
|
1623 |
|
1624 // ----------------------------------------------------------------------------- |
|
1625 // CNSmlDMSettingsAdapter12::NotValidStrLenght |
|
1626 // Checks if data length is valid. |
|
1627 // ----------------------------------------------------------------------------- |
|
1628 TBool CNSmlDMSettingsAdapter12::NotValidStrLenght( const TNSmlDMProfileData& aProfileItem, |
|
1629 const TDesC8& aSource ) |
|
1630 { |
|
1631 TInt lLen = aSource.Length(); |
|
1632 TBool lBool = EFalse; |
|
1633 |
|
1634 switch ( aProfileItem ) |
|
1635 { |
|
1636 case ( EProfileName ) : |
|
1637 { |
|
1638 if( lLen > KNSmlMaxProfileNameLength ) |
|
1639 { |
|
1640 lBool = ETrue; |
|
1641 } |
|
1642 } |
|
1643 break; |
|
1644 |
|
1645 case ( EProfileDMServerUsername ) : |
|
1646 { |
|
1647 if( lLen > KNSmlMaxUsernameLength ) |
|
1648 { |
|
1649 lBool = ETrue; |
|
1650 } |
|
1651 } |
|
1652 break; |
|
1653 |
|
1654 case ( EProfileHttpUsername ) : |
|
1655 case (ETransportAuthName): |
|
1656 { |
|
1657 if( lLen > KNSmlDmMaxHttpAuthUsernameLength ) |
|
1658 { |
|
1659 lBool = ETrue; |
|
1660 } |
|
1661 } |
|
1662 break; |
|
1663 case ( EProfileHttpPassword ) : |
|
1664 case (EProfileTransportPassword): |
|
1665 { |
|
1666 if( lLen > KNSmlDmMaxHttpAuthPasswordLength ) |
|
1667 { |
|
1668 lBool = ETrue; |
|
1669 } |
|
1670 } |
|
1671 break; |
|
1672 case ( EProfileDMServerPassword ) : |
|
1673 { |
|
1674 if( lLen > KNSmlMaxPasswordLength ) |
|
1675 { |
|
1676 lBool = ETrue; |
|
1677 } |
|
1678 } |
|
1679 break; |
|
1680 |
|
1681 case ( ESharedSecret ) : |
|
1682 { |
|
1683 if( lLen > KNSmlDmSharedSecretMaxLength ) |
|
1684 { |
|
1685 lBool = ETrue; |
|
1686 } |
|
1687 } |
|
1688 break; |
|
1689 |
|
1690 case ( EProfileURL ) : |
|
1691 { |
|
1692 if( lLen > KNSmlMaxURLLength ) |
|
1693 { |
|
1694 lBool = ETrue; |
|
1695 } |
|
1696 } |
|
1697 break; |
|
1698 |
|
1699 case ( EServerId ) : |
|
1700 { |
|
1701 if( lLen > KNSmlDmServerIdMaxLength ) |
|
1702 { |
|
1703 lBool = ETrue; |
|
1704 } |
|
1705 } |
|
1706 break; |
|
1707 |
|
1708 case ( EProfileIAPId ) : |
|
1709 { |
|
1710 if( lLen > KNSmlMaxURLLength ) |
|
1711 { |
|
1712 lBool = ETrue; |
|
1713 } |
|
1714 } |
|
1715 break; |
|
1716 |
|
1717 case ( EAuthenticationRequired ) : |
|
1718 case ( EProfileAAuthType ) : |
|
1719 { |
|
1720 if( lLen > 20 ) |
|
1721 { |
|
1722 lBool = ETrue; |
|
1723 } |
|
1724 } |
|
1725 break; |
|
1726 |
|
1727 case ( EProfileId ) : |
|
1728 case ( EProfilePort ) : |
|
1729 case ( EProfileMediumType ) : |
|
1730 case ( EProfileAddrType ) : |
|
1731 |
|
1732 { |
|
1733 if( lLen > 8 ) |
|
1734 { |
|
1735 lBool = ETrue; |
|
1736 } |
|
1737 } |
|
1738 break; |
|
1739 |
|
1740 case ( EServerNonce ) : |
|
1741 case ( EClientNonce ) : |
|
1742 case (EProfileTransportAuthData): |
|
1743 { |
|
1744 lBool = EFalse; |
|
1745 } |
|
1746 break; |
|
1747 case ( EProfileTransport ): |
|
1748 { |
|
1749 lBool = EFalse; |
|
1750 } |
|
1751 break; |
|
1752 case EProfileLock : |
|
1753 { |
|
1754 if(lLen > 6 ) |
|
1755 { |
|
1756 lBool = ETrue; |
|
1757 } |
|
1758 |
|
1759 } |
|
1760 break; |
|
1761 default: |
|
1762 { |
|
1763 lBool = ETrue; |
|
1764 } |
|
1765 } |
|
1766 |
|
1767 return lBool; |
|
1768 } |
|
1769 |
|
1770 // ----------------------------------------------------------------------------- |
|
1771 // CNSmlDMSettingsAdapter12::SetField |
|
1772 // Last element of the URI (after last '/') is returned. |
|
1773 // ----------------------------------------------------------------------------- |
|
1774 TInt CNSmlDMSettingsAdapter12::SetField( const TDesC8& aSource ) |
|
1775 { |
|
1776 if ( aSource.LocateReverse( KNSmlDMUriSeparator ) == KErrNotFound ) |
|
1777 { |
|
1778 iField->Des().Format( aSource ); |
|
1779 } |
|
1780 else |
|
1781 { |
|
1782 iField->Des().Format( aSource.Mid( aSource.LocateReverse( KNSmlDMUriSeparator ) + 1 ) ); |
|
1783 } |
|
1784 |
|
1785 return KErrNone; |
|
1786 } |
|
1787 |
|
1788 // ----------------------------------------------------------------------------- |
|
1789 // CNSmlDMSettingsAdapter12::SetField |
|
1790 // Last element of the URI (after last '/') is returned. |
|
1791 // ----------------------------------------------------------------------------- |
|
1792 TInt CNSmlDMSettingsAdapter12::SetURIInProcessL( const TDesC8& aSource ) |
|
1793 { |
|
1794 |
|
1795 if( iURIField ) |
|
1796 { |
|
1797 delete iURIField; |
|
1798 iURIField = NULL; |
|
1799 } |
|
1800 iURIField = HBufC8::NewL( aSource.Length() ); |
|
1801 TPtr8 newPortNbr = iURIField->Des(); |
|
1802 newPortNbr.Append( aSource ); |
|
1803 |
|
1804 return KErrNone; |
|
1805 } |
|
1806 |
|
1807 |
|
1808 |
|
1809 |
|
1810 // ----------------------------------------------------------------------------- |
|
1811 // CNSmlDMSettingsAdapter12::ConvertTo8LC |
|
1812 // Converts string value to 8-bit and returns reference. |
|
1813 // ----------------------------------------------------------------------------- |
|
1814 TDesC8& CNSmlDMSettingsAdapter12::ConvertTo8LC( const TDesC& aSource ) |
|
1815 { |
|
1816 HBufC8* buf = HBufC8::NewLC( aSource.Length() * 2 ); |
|
1817 TPtr8 bufPtr = buf->Des(); |
|
1818 CnvUtfConverter::ConvertFromUnicodeToUtf8( bufPtr, aSource ); |
|
1819 |
|
1820 return *buf; |
|
1821 } |
|
1822 |
|
1823 // ----------------------------------------------------------------------------- |
|
1824 // CNSmlDMSettingsAdapter12::ConvertTo16LC |
|
1825 // Converts string value to 16-bit and returns reference. |
|
1826 // ----------------------------------------------------------------------------- |
|
1827 TDesC16& CNSmlDMSettingsAdapter12::ConvertTo16LC( const TDesC8& aSource) |
|
1828 { |
|
1829 HBufC16* buf16 = HBufC16::NewLC( aSource.Length() ); |
|
1830 TPtr16 bufPtr16 = buf16->Des(); |
|
1831 |
|
1832 CnvUtfConverter::ConvertToUnicodeFromUtf8( bufPtr16, aSource ); |
|
1833 |
|
1834 return *buf16; |
|
1835 } |
|
1836 |
|
1837 // ------------------------------------------------------------------------------------- |
|
1838 // CNSmlDMSettingsAdapter12::GetConRefL |
|
1839 // Gets the URI for given aObject (IAP ID). |
|
1840 // ------------------------------------------------------------------------------------- |
|
1841 TInt CNSmlDMSettingsAdapter12::GetConRefL( CBufBase& aObject ) |
|
1842 { |
|
1843 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetConRefL() : begin" ); |
|
1844 TInt profIAPid = -1; |
|
1845 TInt apIdResponse = GetProfileIAPIdL( profIAPid ); |
|
1846 if( profIAPid < 0 ) |
|
1847 { |
|
1848 return KErrNone; |
|
1849 } |
|
1850 if( apIdResponse != KErrNone ) |
|
1851 { |
|
1852 return KErrNotFound; |
|
1853 } |
|
1854 CNSmlDMIAPMatcher* apmatch = CNSmlDMIAPMatcher::NewL( iCallBack ); |
|
1855 CleanupStack::PushL( apmatch ); |
|
1856 HBufC8* uri8 = apmatch->URIFromIAPIdL( profIAPid ); |
|
1857 if( uri8 ) |
|
1858 { |
|
1859 CleanupStack::PushL( uri8 ); |
|
1860 aObject.InsertL( aObject.Size(), uri8->Des() ); |
|
1861 CleanupStack::PopAndDestroy(); // uri8 |
|
1862 } |
|
1863 else |
|
1864 { |
|
1865 CleanupStack::PopAndDestroy(); // apMatch |
|
1866 return KErrGeneral; |
|
1867 } |
|
1868 CleanupStack::PopAndDestroy(); // iapMatch |
|
1869 _DBG_FILE( "CNSmlDSSettingsAdapter::GetToNAPIDL() : end" ); |
|
1870 return KErrNone; |
|
1871 } |
|
1872 |
|
1873 // ------------------------------------------------------------------------------------- |
|
1874 // CNSmlDMSettingsAdapter12::SetConRefL() |
|
1875 // Set the profile IAP Id value according to given URI. |
|
1876 // ------------------------------------------------------------------------------------- |
|
1877 TInt CNSmlDMSettingsAdapter12::SetConRefL( const TInt aLUID, const TDesC8& aObject ) |
|
1878 { |
|
1879 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetConRefL() : begin" ); |
|
1880 CNSmlDMIAPMatcher* apmatch = CNSmlDMIAPMatcher::NewL( iCallBack ); |
|
1881 CleanupStack::PushL( apmatch ); |
|
1882 TInt lIAPid = apmatch->IAPIdFromURIL( aObject ); |
|
1883 CleanupStack::PopAndDestroy(); // iapmatch |
|
1884 if(aObject.Length() >0 && lIAPid == KErrNotFound) |
|
1885 { |
|
1886 return KErrGeneral; |
|
1887 } |
|
1888 TInt apIdResponse = SetProfileConnectionPropertyL( aLUID, lIAPid ); |
|
1889 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetConRefL() : end" ); |
|
1890 return apIdResponse; |
|
1891 } |
|
1892 |
|
1893 // ------------------------------------------------------------------------------------------------ |
|
1894 // CNSmlDMSettingsAdapter12::ParseUri |
|
1895 // Resolves portnbr (separated with ':') as integer from Uri. |
|
1896 // ------------------------------------------------------------------------------------------------ |
|
1897 TInt CNSmlDMSettingsAdapter12::ParseUri( const TDesC8& aRealURI, TInt& aPort ) |
|
1898 { |
|
1899 TInt offset=0; |
|
1900 //http: |
|
1901 if( aRealURI.Find( KNSmlDMSettingsHTTP )==0 )//http: |
|
1902 { |
|
1903 offset = KNSmlDMSettingsHTTP().Length(); |
|
1904 } |
|
1905 else if( aRealURI.Find( KNSmlDMSettingsHTTPS )==0 )//https: |
|
1906 { |
|
1907 offset = KNSmlDMSettingsHTTPS().Length(); |
|
1908 } |
|
1909 |
|
1910 TBool portFound=EFalse; |
|
1911 ////123.234.345.456:80/syncml |
|
1912 for( TInt i = offset; i < aRealURI.Length(); i++ ) |
|
1913 { |
|
1914 if( aRealURI[i] == KNSmlDMColon )// ':' |
|
1915 { |
|
1916 portFound = ETrue; |
|
1917 offset=i; |
|
1918 } |
|
1919 if( portFound && aRealURI[i] == KNSmlDMUriSeparator ) // '/' |
|
1920 { |
|
1921 aPort = GetIntObject( aRealURI.Mid( (offset + 1), (i - offset-1) ) ); |
|
1922 } |
|
1923 else if ( portFound && i == aRealURI.Length() - 1 ) // last char |
|
1924 { |
|
1925 // port is from offset to the end |
|
1926 aPort = GetIntObject( aRealURI.Right( aRealURI.Length() - offset - 1 ) ); |
|
1927 } |
|
1928 } |
|
1929 |
|
1930 if( aPort != 0 ) |
|
1931 { |
|
1932 return KErrNone; |
|
1933 } |
|
1934 else |
|
1935 { |
|
1936 return KErrNotFound; |
|
1937 } |
|
1938 } |
|
1939 // ----------------------------------------------------------------------------- |
|
1940 // CNSmlDMSettingsAdapter12::OpenSyncSessionAndDSProfileL |
|
1941 // The function opens the server session and DM profile. |
|
1942 // ----------------------------------------------------------------------------- |
|
1943 TInt CNSmlDMSettingsAdapter12::OpenSyncSessionAndProfileL( const TInt aIntLUID, |
|
1944 TSmlOpenMode aMode ) |
|
1945 { |
|
1946 _DBG_FILE( "CNSmlDMSettingsAdapter12::OpenSyncSessionAndProfileL(): begin" ); |
|
1947 if( iSyncSessionOpen == EFalse ) |
|
1948 { |
|
1949 iSyncSession.OpenL(); |
|
1950 iSyncSessionOpen = ETrue; |
|
1951 } |
|
1952 TInt trueLuid = aIntLUID + KMaxDataSyncID; |
|
1953 TInt rValue(KErrNone); |
|
1954 |
|
1955 if(trueLuid!=iCurrentProfile) |
|
1956 { |
|
1957 RArray<TSmlProfileId> profileIdArray; |
|
1958 CleanupClosePushL( profileIdArray ); |
|
1959 TSmlUsageType usageType = ESmlDevMan; |
|
1960 iSyncSession.ListProfilesL( profileIdArray, usageType ); |
|
1961 TInt index = profileIdArray.Find( trueLuid ); |
|
1962 CleanupStack::PopAndDestroy(); //profileIdArray |
|
1963 if( index == KErrNotFound ) |
|
1964 { |
|
1965 return KErrNotFound; |
|
1966 } |
|
1967 TRAP( rValue, iProfile.OpenL( iSyncSession, trueLuid, aMode ) ); |
|
1968 iCurrentProfile = trueLuid; |
|
1969 if( rValue != KErrNone ) |
|
1970 { |
|
1971 iCurrentProfile = 0; |
|
1972 iProfile.Close(); |
|
1973 iSyncSession.Close(); |
|
1974 iSyncSessionOpen = EFalse; |
|
1975 } |
|
1976 } |
|
1977 _DBG_FILE( "CNSmlDMSettingsAdapter12::OpenSyncSessionAndProfileL(): end" ); |
|
1978 return rValue; |
|
1979 } |
|
1980 |
|
1981 // ----------------------------------------------------------------------------- |
|
1982 // CNSmlDMSettingsAdapter12::FindProfileId |
|
1983 // Function checks if profile can be found. |
|
1984 // ----------------------------------------------------------------------------- |
|
1985 TBool CNSmlDMSettingsAdapter12::FindProfileIdL( const TInt aIntLUID ) |
|
1986 { |
|
1987 _DBG_FILE( "CNSmlDMSettingsAdapter12::FindProfileIdL(): begin" ); |
|
1988 if( iSyncSessionOpen == EFalse ) |
|
1989 { |
|
1990 iSyncSession.OpenL(); |
|
1991 iSyncSessionOpen = ETrue; |
|
1992 } |
|
1993 |
|
1994 RArray <TSmlProfileId> profileList; |
|
1995 CleanupClosePushL( profileList ); |
|
1996 TSmlUsageType usageType = ESmlDevMan; |
|
1997 iSyncSession.ListProfilesL( profileList, usageType ); |
|
1998 if( profileList.Count() == 0 ) |
|
1999 { |
|
2000 CleanupStack::PopAndDestroy(); //profileList |
|
2001 return EFalse; |
|
2002 } |
|
2003 TInt item = profileList.Find( aIntLUID + KMaxDataSyncID ); |
|
2004 CleanupStack::PopAndDestroy(); //profileList |
|
2005 if( item != KErrNotFound ) |
|
2006 { |
|
2007 _DBG_FILE( "CNSmlDMSettingsAdapter12::FindProfileIdL(): end" ); |
|
2008 return ETrue; |
|
2009 } |
|
2010 _DBG_FILE( "CNSmlDMSettingsAdapter12::FindProfileIdL(): end" ); |
|
2011 return EFalse; |
|
2012 } |
|
2013 // ----------------------------------------------------------------------------- |
|
2014 // CNSmlDMSettingsAdapter12::IsServerIDExistL |
|
2015 // Function checks if serverid exist. |
|
2016 // ----------------------------------------------------------------------------- |
|
2017 TBool CNSmlDMSettingsAdapter12::IsServerIDExistL( const TDesC8& aServerid ) |
|
2018 { |
|
2019 _DBG_FILE( "CNSmlDMSettingsAdapter12::IsServerIDExistL(): begin" ); |
|
2020 if( iSyncSessionOpen == EFalse ) |
|
2021 { |
|
2022 iSyncSession.OpenL(); |
|
2023 iSyncSessionOpen = ETrue; |
|
2024 } |
|
2025 TBool ret(EFalse); |
|
2026 RArray <TSmlProfileId> profileList; |
|
2027 CleanupClosePushL( profileList ); |
|
2028 TSmlUsageType usageType = ESmlDevMan; |
|
2029 iSyncSession.ListProfilesL( profileList, usageType ); |
|
2030 TInt count = profileList.Count(); |
|
2031 if( count > 0 ) |
|
2032 { |
|
2033 for(TInt i =0; i< count; i++) |
|
2034 { |
|
2035 TInt pid = i + KMaxDataSyncID; |
|
2036 TInt index = profileList.Find(pid ); |
|
2037 if( index >= i ) |
|
2038 { |
|
2039 TInt rValue(KErrNone); |
|
2040 RSyncMLDevManProfile profile; |
|
2041 TRAP( rValue, profile.OpenL( iSyncSession, pid, ESmlOpenRead ) ); |
|
2042 if( rValue == KErrNone ) |
|
2043 { |
|
2044 CleanupClosePushL(profile); |
|
2045 if(((aServerid.Compare(profile.ServerId())) == 0) && |
|
2046 ((profile.ServerId()).Length() == aServerid.Length())) |
|
2047 { |
|
2048 ret = ETrue; |
|
2049 CleanupStack::PopAndDestroy(&profile);//profile |
|
2050 break; |
|
2051 } |
|
2052 CleanupStack::PopAndDestroy(&profile);//profile |
|
2053 } |
|
2054 } |
|
2055 } |
|
2056 } |
|
2057 CleanupStack::PopAndDestroy(); //profileList |
|
2058 _DBG_FILE( "CNSmlDMSettingsAdapter12::IsServerIDExistL(): end" ); |
|
2059 return ret; |
|
2060 } |
|
2061 // ----------------------------------------------------------------------------- |
|
2062 // CNSmlDMSettingsAdapter12::CreateNewProfileL |
|
2063 // The function creates new DM profile via client API. |
|
2064 // ----------------------------------------------------------------------------- |
|
2065 TInt CNSmlDMSettingsAdapter12::CreateNewProfileL( TInt& aPID ) |
|
2066 { |
|
2067 _DBG_FILE("CNSmlDMSettingsAdapter12::CreateNewProfileL(): begin"); |
|
2068 if( iSyncSessionOpen == EFalse ) |
|
2069 { |
|
2070 iSyncSession.OpenL(); |
|
2071 iSyncSessionOpen = ETrue; |
|
2072 } |
|
2073 TRAPD( value1, iProfile.CreateL( iSyncSession ) ); |
|
2074 if( value1 != KErrNone ) |
|
2075 { |
|
2076 iCurrentProfile = 0; |
|
2077 iProfile.Close(); |
|
2078 iSyncSession.Close(); |
|
2079 iSyncSessionOpen = EFalse; |
|
2080 return value1; |
|
2081 } |
|
2082 |
|
2083 TRAPD( value2, iProfile.UpdateL() ); |
|
2084 if( value2 != KErrNone ) |
|
2085 { |
|
2086 iCurrentProfile = 0; |
|
2087 iProfile.Close(); |
|
2088 iSyncSession.Close(); |
|
2089 iSyncSessionOpen = EFalse; |
|
2090 return value2; |
|
2091 } |
|
2092 |
|
2093 aPID = iProfile.Identifier(); |
|
2094 iCurrentProfile = 0; |
|
2095 iProfile.Close(); |
|
2096 _DBG_FILE( "CNSmlDMSettingsAdapter12::CreateNewProfileL(): end" ); |
|
2097 return KErrNone; |
|
2098 } |
|
2099 // ----------------------------------------------------------------------------- |
|
2100 // CNSmlDMSettingsAdapter12::SetProfileServerURIL() |
|
2101 // The function sets the server URL for a profile. |
|
2102 // ----------------------------------------------------------------------------- |
|
2103 TInt CNSmlDMSettingsAdapter12::SetProfileServerURIL( const TInt aPID, |
|
2104 const TDesC8& aObj ) |
|
2105 { |
|
2106 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileServerURIL(): begin" ); |
|
2107 TInt retVal = KErrNone; |
|
2108 retVal = OpenSyncSessionAndProfileL( aPID, ESmlOpenReadWrite ); |
|
2109 if( retVal != KErrNone ) |
|
2110 { |
|
2111 iCurrentProfile = 0; |
|
2112 iProfile.Close(); |
|
2113 return retVal; |
|
2114 } |
|
2115 RArray<TSmlTransportId> transportIdArray; |
|
2116 CleanupClosePushL( transportIdArray ); |
|
2117 iProfile.ListConnectionsL( transportIdArray ); |
|
2118 if( transportIdArray.Count() == 0 ) |
|
2119 { |
|
2120 CleanupStack::PopAndDestroy();//transportIdArray |
|
2121 iCurrentProfile = 0; |
|
2122 iProfile.Close(); |
|
2123 return KErrGeneral; |
|
2124 } |
|
2125 |
|
2126 TInt newPort(0); |
|
2127 |
|
2128 RSyncMLConnection conn; |
|
2129 CleanupClosePushL( conn ); |
|
2130 conn.OpenL( iProfile, transportIdArray[0] ); |
|
2131 |
|
2132 if(ParseUri(aObj,newPort)==KErrNotFound) |
|
2133 { |
|
2134 TInt port = 0; |
|
2135 ParseUri(conn.ServerURI(),port); |
|
2136 if(port==0) |
|
2137 { |
|
2138 port = 80; |
|
2139 } |
|
2140 |
|
2141 TBuf8<5> buf; |
|
2142 buf.Num( port ); |
|
2143 |
|
2144 TInt totalSize = aObj.Length() + buf.Length() + 1; |
|
2145 HBufC8* newServerURI = HBufC8::NewLC( totalSize ); |
|
2146 SetPortNrToAddrStr( aObj, newServerURI, buf ); |
|
2147 conn.SetServerURIL( *newServerURI ); |
|
2148 conn.UpdateL(); |
|
2149 CleanupStack::PopAndDestroy( newServerURI ); |
|
2150 } |
|
2151 else |
|
2152 { |
|
2153 conn.SetServerURIL( aObj ); |
|
2154 conn.UpdateL(); |
|
2155 } |
|
2156 |
|
2157 |
|
2158 iProfile.UpdateL(); |
|
2159 |
|
2160 CleanupStack::PopAndDestroy( 2 ); //transportIdArray, conn |
|
2161 iCurrentProfile = 0; |
|
2162 iProfile.Close(); |
|
2163 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileServerURIL(): end" ); |
|
2164 return KErrNone; |
|
2165 } |
|
2166 // ----------------------------------------------------------------------------- |
|
2167 // CNSmlDMSettingsAdapter12::SetProfileDisplayNameL() |
|
2168 // The function sets the display name for a profile. |
|
2169 // ----------------------------------------------------------------------------- |
|
2170 TInt CNSmlDMSettingsAdapter12::SetProfileDisplayNameL( const TInt aPID, |
|
2171 const TDesC8& aObj ) |
|
2172 { |
|
2173 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileDisplayNameL(): begin" ); |
|
2174 TInt retVal = KErrNone; |
|
2175 retVal = OpenSyncSessionAndProfileL( aPID, ESmlOpenReadWrite ); |
|
2176 if( retVal != KErrNone ) |
|
2177 { |
|
2178 iCurrentProfile = 0; |
|
2179 iProfile.Close(); |
|
2180 return retVal; |
|
2181 } |
|
2182 iProfile.SetDisplayNameL( ConvertTo16LC( aObj ) ); |
|
2183 iProfile.UpdateL(); |
|
2184 CleanupStack::PopAndDestroy(); //ConvertTo16LC |
|
2185 iCurrentProfile = 0; |
|
2186 iProfile.Close(); |
|
2187 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileDisplayNameL(): end" ); |
|
2188 return KErrNone; |
|
2189 } |
|
2190 // ----------------------------------------------------------------------------- |
|
2191 // CNSmlDMSettingsAdapter12::IsProfileLockedL() |
|
2192 // The function to tell whether the profile is locked |
|
2193 // ----------------------------------------------------------------------------- |
|
2194 TInt CNSmlDMSettingsAdapter12::IsProfileLockedL(const TInt aPID) |
|
2195 { |
|
2196 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileDisplayNameL(): begin" ); |
|
2197 TInt retVal = KErrNone; |
|
2198 retVal = OpenSyncSessionAndProfileL( aPID, ESmlOpenRead ); |
|
2199 if( retVal != KErrNone ) |
|
2200 { |
|
2201 iCurrentProfile = 0; |
|
2202 iProfile.Close(); |
|
2203 return retVal; |
|
2204 } |
|
2205 |
|
2206 retVal=iProfile.ProfileLocked(EFalse, EFalse); |
|
2207 iCurrentProfile = 0; |
|
2208 iProfile.Close(); |
|
2209 if(retVal) |
|
2210 { |
|
2211 /* CRepository* centrep = NULL; |
|
2212 TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys) ); |
|
2213 TInt IsPrfoileEditable = 0; |
|
2214 if(!err) |
|
2215 centrep->Get( KDevOverrideProfileLock, IsPrfoileEditable ); |
|
2216 delete centrep; |
|
2217 if (!IsPrfoileEditable) |
|
2218 retVal= KErrAccessDenied; |
|
2219 else |
|
2220 retVal= KErrNone;*/ |
|
2221 retVal= KErrAccessDenied; |
|
2222 } |
|
2223 |
|
2224 |
|
2225 |
|
2226 return retVal; |
|
2227 |
|
2228 } |
|
2229 |
|
2230 |
|
2231 |
|
2232 // ----------------------------------------------------------------------------- |
|
2233 // CNSmlDMSettingsAdapter12::SetProfileLockL() |
|
2234 // The function to setor reset the profile lock. |
|
2235 // ----------------------------------------------------------------------------- |
|
2236 |
|
2237 TInt CNSmlDMSettingsAdapter12::SetProfileLockL( const TInt aPID, TInt aLockValue) |
|
2238 { |
|
2239 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileLockL(): begin" ); |
|
2240 TInt retVal = KErrNone; |
|
2241 retVal = OpenSyncSessionAndProfileL( aPID, ESmlOpenReadWrite ); |
|
2242 if( retVal != KErrNone ) |
|
2243 { |
|
2244 iCurrentProfile = 0; |
|
2245 iProfile.Close(); |
|
2246 return retVal; |
|
2247 } |
|
2248 |
|
2249 iProfile.ProfileLocked(ETrue, aLockValue ); |
|
2250 iProfile.UpdateL(); |
|
2251 iCurrentProfile = 0; |
|
2252 iProfile.Close(); |
|
2253 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileLockL(): end" ); |
|
2254 return KErrNone; |
|
2255 } |
|
2256 |
|
2257 |
|
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 |
|
2263 // ----------------------------------------------------------------------------- |
|
2264 // CNSmlDMSettingsAdapter12::SetProfileHttpUserNameL |
|
2265 // The function sets the profile http/network name. |
|
2266 // ----------------------------------------------------------------------------- |
|
2267 |
|
2268 TInt CNSmlDMSettingsAdapter12::SetProfileHttpUserNameL( const TInt aPID, const TDesC8& aObj ) |
|
2269 { |
|
2270 TInt retVal = KErrNone; |
|
2271 retVal = OpenSyncSessionAndProfileL( aPID, ESmlOpenReadWrite ); |
|
2272 if( retVal != KErrNone ) |
|
2273 { |
|
2274 iCurrentProfile = 0; |
|
2275 iProfile.Close(); |
|
2276 return KErrGeneral; |
|
2277 } |
|
2278 |
|
2279 RSyncMLConnection connection; |
|
2280 TBuf8<KBufSize32> key; |
|
2281 RArray<TSmlTransportId> connIdArray; |
|
2282 CleanupClosePushL( connIdArray ); |
|
2283 iProfile.ListConnectionsL( connIdArray ); |
|
2284 if( connIdArray.Count() == 1 ) |
|
2285 { |
|
2286 |
|
2287 connection.OpenL( iProfile, KUidNSmlMediumTypeInternet.iUid ); |
|
2288 CleanupClosePushL( connection ); |
|
2289 |
|
2290 connection.SetPropertyL( KNSmlHTTPAuth, KNSmlTrueVal ); |
|
2291 connection.SetPropertyL( KNSmlHTTPUsername, aObj ); |
|
2292 connection.UpdateL(); |
|
2293 CleanupStack::PopAndDestroy( ); |
|
2294 } |
|
2295 else |
|
2296 { |
|
2297 connection.SetPropertyL( KNSmlHTTPAuth, KNSmlFalseVal ); |
|
2298 connection.UpdateL(); |
|
2299 } |
|
2300 |
|
2301 |
|
2302 CleanupStack::PopAndDestroy( ); |
|
2303 |
|
2304 return retVal; |
|
2305 |
|
2306 } |
|
2307 |
|
2308 // ----------------------------------------------------------------------------- |
|
2309 // CNSmlDMSettingsAdapter12::SetProfileUserNameL |
|
2310 // The function sets the profile user name. |
|
2311 // ----------------------------------------------------------------------------- |
|
2312 TInt CNSmlDMSettingsAdapter12::SetProfileUserNameL( const TInt aPID, |
|
2313 const TDesC8& aObj ) |
|
2314 { |
|
2315 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileUserNameL(): begin" ); |
|
2316 TInt retVal = OpenSyncSessionAndProfileL( aPID, ESmlOpenReadWrite ); |
|
2317 if( retVal != KErrNone ) |
|
2318 { |
|
2319 iCurrentProfile = 0; |
|
2320 iProfile.Close(); |
|
2321 return KErrGeneral; |
|
2322 } |
|
2323 iProfile.SetUserNameL( aObj ); |
|
2324 iProfile.UpdateL(); |
|
2325 iCurrentProfile = 0; |
|
2326 iProfile.Close(); |
|
2327 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileUserNameL(): end" ); |
|
2328 return KErrNone; |
|
2329 } |
|
2330 |
|
2331 // ----------------------------------------------------------------------------- |
|
2332 // CNSmlDMSettingsAdapter12::SetProfileProtocolVersionL |
|
2333 // The function sets the protocol version to be supported. |
|
2334 // ----------------------------------------------------------------------------- |
|
2335 TInt CNSmlDMSettingsAdapter12::SetProfileProtocolVersionL( const TInt aPID, |
|
2336 const TDesC8& ) |
|
2337 { |
|
2338 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileProtocolVersionL(): begin" ); |
|
2339 TInt retVal = KErrNone; |
|
2340 retVal = OpenSyncSessionAndProfileL( aPID, ESmlOpenReadWrite ); |
|
2341 if( retVal != KErrNone ) |
|
2342 { |
|
2343 iCurrentProfile = 0; |
|
2344 iProfile.Close(); |
|
2345 return retVal; |
|
2346 } |
|
2347 //The syncSession to Sync server is open. |
|
2348 TSmlProtocolVersion protocol = ESmlVersion1_2; |
|
2349 iProfile.SetProtocolVersionL( protocol ); |
|
2350 TRAPD( iError, iProfile.UpdateL() ); |
|
2351 iCurrentProfile = 0; |
|
2352 iProfile.Close(); |
|
2353 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileProtocolVersionL(): begin" ); |
|
2354 return iError; |
|
2355 } |
|
2356 |
|
2357 // ----------------------------------------------------------------------------- |
|
2358 // CNSmlDMSettingsAdapter12::SetProfileServerIdL |
|
2359 // The function sets the profile ServerId value. |
|
2360 // ----------------------------------------------------------------------------- |
|
2361 TInt CNSmlDMSettingsAdapter12::SetProfileServerIdL( const TInt aPID, |
|
2362 const TDesC8& aObj ) |
|
2363 { |
|
2364 _DBG_FILE("CNSmlDMSettingsAdapter12::SetProfileServerIdL(): begin"); |
|
2365 TInt retVal = OpenSyncSessionAndProfileL( aPID, ESmlOpenReadWrite ); |
|
2366 if( retVal != KErrNone ) |
|
2367 { |
|
2368 iCurrentProfile = 0; |
|
2369 iProfile.Close(); |
|
2370 return KErrGeneral; |
|
2371 } |
|
2372 iProfile.SetServerIdL( aObj ); |
|
2373 TRAP(retVal,iProfile.UpdateL() ); |
|
2374 iCurrentProfile = 0; |
|
2375 iProfile.Close(); |
|
2376 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileServerIdL(): end" ); |
|
2377 return retVal; |
|
2378 } |
|
2379 |
|
2380 // ----------------------------------------------------------------------------- |
|
2381 // CNSmlDMSettingsAdapter12::SetProfileServerPasswordL |
|
2382 // The function sets the profile server password. |
|
2383 // ----------------------------------------------------------------------------- |
|
2384 TInt CNSmlDMSettingsAdapter12::SetProfileServerPasswordL( const TInt aPID, |
|
2385 const TDesC8& aObj ) |
|
2386 { |
|
2387 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileServerPasswordL(): begin" ); |
|
2388 TInt retVal = OpenSyncSessionAndProfileL( aPID, ESmlOpenReadWrite ); |
|
2389 if( retVal != KErrNone ) |
|
2390 { |
|
2391 iCurrentProfile = 0; |
|
2392 iProfile.Close(); |
|
2393 return KErrGeneral; |
|
2394 } |
|
2395 iProfile.SetServerPasswordL( aObj ); |
|
2396 iProfile.UpdateL(); |
|
2397 iCurrentProfile = 0; |
|
2398 iProfile.Close(); |
|
2399 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileServerPasswordL(): end" ); |
|
2400 return KErrNone; |
|
2401 } |
|
2402 |
|
2403 // ----------------------------------------------------------------------------- |
|
2404 // CNSmlDMSettingsAdapter12::SetProfileHttpPasswordL |
|
2405 // The function sets the profile network/http password. |
|
2406 // ----------------------------------------------------------------------------- |
|
2407 |
|
2408 |
|
2409 TInt CNSmlDMSettingsAdapter12::SetProfileHttpPasswordL( const TInt aPID, const TDesC8& aObj ) |
|
2410 { |
|
2411 TInt retVal = KErrNone; |
|
2412 retVal = OpenSyncSessionAndProfileL( aPID, ESmlOpenReadWrite ); |
|
2413 if( retVal != KErrNone ) |
|
2414 { |
|
2415 iCurrentProfile = 0; |
|
2416 iProfile.Close(); |
|
2417 return KErrGeneral; |
|
2418 } |
|
2419 |
|
2420 RSyncMLConnection connection; |
|
2421 TBuf8<KBufSize32> key; |
|
2422 RArray<TSmlTransportId> connIdArray; |
|
2423 CleanupClosePushL( connIdArray ); |
|
2424 iProfile.ListConnectionsL( connIdArray ); |
|
2425 if( connIdArray.Count() == 1 ) |
|
2426 { |
|
2427 |
|
2428 connection.OpenL( iProfile, KUidNSmlMediumTypeInternet.iUid ); |
|
2429 CleanupClosePushL( connection ); |
|
2430 |
|
2431 connection.SetPropertyL( KNSmlHTTPAuth, KNSmlTrueVal ); |
|
2432 connection.SetPropertyL( KNSmlHTTPPassword, aObj ); |
|
2433 connection.UpdateL(); |
|
2434 CleanupStack::PopAndDestroy( ); |
|
2435 } |
|
2436 else |
|
2437 { |
|
2438 // connection.SetPropertyL( KNSmlHTTPAuth, KNSmlFalseVal ); |
|
2439 connection.UpdateL(); |
|
2440 } |
|
2441 |
|
2442 |
|
2443 CleanupStack::PopAndDestroy( ); |
|
2444 |
|
2445 return retVal; |
|
2446 |
|
2447 |
|
2448 |
|
2449 } |
|
2450 |
|
2451 |
|
2452 // ----------------------------------------------------------------------------- |
|
2453 // CNSmlDMSettingsAdapter12::SetProfilePasswordL |
|
2454 // The function sets the profile password. |
|
2455 // ----------------------------------------------------------------------------- |
|
2456 TInt CNSmlDMSettingsAdapter12::SetProfilePasswordL( const TInt aPID, |
|
2457 const TDesC8& aObj ) |
|
2458 { |
|
2459 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfilePasswordL(): begin" ); |
|
2460 TInt retVal = KErrNone; |
|
2461 retVal = OpenSyncSessionAndProfileL( aPID, ESmlOpenReadWrite ); |
|
2462 if( retVal != KErrNone ) |
|
2463 { |
|
2464 iCurrentProfile = 0; |
|
2465 iProfile.Close(); |
|
2466 return retVal; |
|
2467 } |
|
2468 iProfile.SetPasswordL( aObj ); |
|
2469 iProfile.UpdateL(); |
|
2470 iCurrentProfile = 0; |
|
2471 iProfile.Close(); |
|
2472 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfilePasswordL(): begin" ); |
|
2473 return KErrNone; |
|
2474 } |
|
2475 |
|
2476 // ----------------------------------------------------------------------------- |
|
2477 // CNSmlDMSettingsAdapter12::SetProfileConnectionPropertyL |
|
2478 // This function sets the profile IAP id. |
|
2479 // ----------------------------------------------------------------------------- |
|
2480 TInt CNSmlDMSettingsAdapter12::SetProfileConnectionPropertyL( const TInt aLUID, |
|
2481 const TInt aIAPid ) |
|
2482 { |
|
2483 TInt retVal = OpenSyncSessionAndProfileL( aLUID, ESmlOpenReadWrite ); |
|
2484 if( retVal != KErrNone ) |
|
2485 { |
|
2486 iCurrentProfile = 0; |
|
2487 iProfile.Close(); |
|
2488 return retVal; |
|
2489 } |
|
2490 RArray<TSmlTransportId> connIdArray; |
|
2491 CleanupClosePushL( connIdArray ); |
|
2492 iProfile.ListConnectionsL( connIdArray ); |
|
2493 if( connIdArray.Count() == 1 ) |
|
2494 { |
|
2495 RSyncMLTransport transport; |
|
2496 CleanupClosePushL( transport ); |
|
2497 transport.OpenL( iSyncSession, connIdArray[0] ); |
|
2498 const CSyncMLTransportPropertiesArray& props = transport.Properties(); |
|
2499 TInt index = props.Find( KNSmlIAPId ); |
|
2500 if( index > 0 ) |
|
2501 { |
|
2502 RSyncMLConnection conn; |
|
2503 CleanupClosePushL( conn ); |
|
2504 conn.OpenL( iProfile, connIdArray[0] ); |
|
2505 HBufC8* apIdBuffer = HBufC8::NewLC( 4 ); |
|
2506 TPtr8 ptrIapIdBuf = apIdBuffer->Des(); |
|
2507 ptrIapIdBuf.Num( aIAPid ); |
|
2508 conn.SetPropertyL( KNSmlIAPId, ptrIapIdBuf ); |
|
2509 conn.UpdateL(); |
|
2510 CleanupStack::PopAndDestroy( 2 ); //conn, apIdBuffer |
|
2511 retVal = KErrNone; |
|
2512 } |
|
2513 else |
|
2514 { |
|
2515 retVal = KErrNotFound; |
|
2516 } |
|
2517 CleanupStack::PopAndDestroy( 1 ); //transport |
|
2518 } |
|
2519 else |
|
2520 { |
|
2521 retVal = KErrNotFound; |
|
2522 } |
|
2523 iCurrentProfile = 0; |
|
2524 iProfile.Close(); |
|
2525 CleanupStack::PopAndDestroy(); //connIdArray |
|
2526 return retVal; |
|
2527 } |
|
2528 |
|
2529 // ----------------------------------------------------------------------------- |
|
2530 // CNSmlDMSettingsAdapter12::DeleteProfileL |
|
2531 // The function deleted the profile from DM database. |
|
2532 // ----------------------------------------------------------------------------- |
|
2533 TInt CNSmlDMSettingsAdapter12::DeleteProfileL( const TInt aPID ) |
|
2534 { |
|
2535 _DBG_FILE( "CNSmlDMSettingsAdapter12::DeleteProfileL(): begin" ); |
|
2536 if( iSyncSessionOpen == EFalse ) |
|
2537 { |
|
2538 iSyncSession.OpenL(); |
|
2539 iSyncSessionOpen = ETrue; |
|
2540 } |
|
2541 |
|
2542 RArray<TSmlProfileId> profileIdArray; |
|
2543 CleanupClosePushL( profileIdArray ); |
|
2544 TSmlUsageType usageType = ESmlDevMan; |
|
2545 iSyncSession.ListProfilesL( profileIdArray, usageType ); |
|
2546 TInt index = profileIdArray.Find( aPID ); |
|
2547 if ( index == KErrNotFound ) |
|
2548 { |
|
2549 //No match |
|
2550 CleanupStack::PopAndDestroy();//profileIdArray |
|
2551 return KErrNotFound; |
|
2552 } |
|
2553 iSyncSession.DeleteProfileL( aPID ); |
|
2554 iSyncSession.Close(); |
|
2555 iSyncSessionOpen = EFalse; |
|
2556 CleanupStack::PopAndDestroy();//profileIdArray |
|
2557 _DBG_FILE( "CNSmlDMSettingsAdapter12::DeleteProfileL(): end" ); |
|
2558 return KErrNone; |
|
2559 } |
|
2560 |
|
2561 // ----------------------------------------------------------------------------- |
|
2562 // CNSmlDMSettingsAdapter12::GetObjectL |
|
2563 // The function checks which leaf data to be fetched. |
|
2564 // ----------------------------------------------------------------------------- |
|
2565 TInt CNSmlDMSettingsAdapter12::GetObjectL( TInt aLUID, TNSmlDMProfileData aDMField, |
|
2566 CBufBase& aObject ) |
|
2567 { |
|
2568 TInt retVal = KErrNone; |
|
2569 if( iField->Compare(KNSmlDdfAppId ) ==0 ) |
|
2570 { |
|
2571 aObject.InsertL(aObject.Size(),KNSmlDdfAppIdValue); |
|
2572 return retVal; |
|
2573 |
|
2574 } |
|
2575 |
|
2576 retVal = OpenSyncSessionAndProfileL( aLUID, ESmlOpenRead ); |
|
2577 if( retVal != KErrNone ) |
|
2578 { |
|
2579 iCurrentProfile = 0; |
|
2580 iProfile.Close(); |
|
2581 return retVal; |
|
2582 } |
|
2583 switch ( aDMField ) |
|
2584 { |
|
2585 case ( EProfileName ) : |
|
2586 { |
|
2587 GetProfileNameL( aObject ); |
|
2588 } |
|
2589 break; |
|
2590 |
|
2591 case ( EProfileDMServerUsername ) : |
|
2592 { |
|
2593 GetProfileUserNameL( aObject ); |
|
2594 } |
|
2595 break; |
|
2596 |
|
2597 case ( EProfileURL ) : |
|
2598 { |
|
2599 GetProfileServerURLL( aObject ); |
|
2600 TInt port(0); |
|
2601 if(ParseUri(aObject.Ptr(0),port)==KErrNone) |
|
2602 { |
|
2603 HBufC8* addr = aObject.Ptr(0).AllocLC(); |
|
2604 aObject.Reset(); |
|
2605 TInt portStart = addr->LocateReverse(KNSmlDMColon); |
|
2606 aObject.InsertL(aObject.Size(),addr->Left(portStart)); |
|
2607 |
|
2608 TInt portLen=addr->Mid(portStart).Locate(KNSmlDMUriSeparator); |
|
2609 if(portLen!=KErrNotFound) |
|
2610 { |
|
2611 aObject.InsertL(aObject.Size(),addr->Mid(portStart+portLen)); |
|
2612 } |
|
2613 |
|
2614 CleanupStack::PopAndDestroy(); //addr |
|
2615 } |
|
2616 } |
|
2617 break; |
|
2618 |
|
2619 case ( EServerId ) : |
|
2620 { |
|
2621 GetServerIdL( aObject ); |
|
2622 } |
|
2623 break; |
|
2624 |
|
2625 case ( EProfileIAPId ) : |
|
2626 { |
|
2627 retVal = GetConRefL( aObject ); |
|
2628 } |
|
2629 break; |
|
2630 |
|
2631 case ( EProfilePort ) : |
|
2632 { |
|
2633 GetProfileServerURLL( aObject ); |
|
2634 if ( aObject.Size() == 0 ) |
|
2635 { |
|
2636 retVal = KErrNone; |
|
2637 break; |
|
2638 } |
|
2639 GetProfilePortNumberL ( aObject ); |
|
2640 } |
|
2641 break; |
|
2642 |
|
2643 case ( EProfileDMServerPassword ) : |
|
2644 { |
|
2645 retVal = EInvalidObject; |
|
2646 } |
|
2647 break; |
|
2648 |
|
2649 case ( ESharedSecret ) : |
|
2650 {//ServerPW |
|
2651 retVal = EInvalidObject; |
|
2652 } |
|
2653 break; |
|
2654 case ( EProfileId ) : |
|
2655 break; |
|
2656 case ( EProfileAddrType ) : |
|
2657 { |
|
2658 aObject.InsertL(aObject.Size(),KNSmlAddrtype); |
|
2659 } |
|
2660 break; |
|
2661 case (EProfileHttpUsername ): |
|
2662 { |
|
2663 retVal = GetHttpUsernameL(aObject); |
|
2664 } |
|
2665 break; |
|
2666 case (EPRofileServerCred) : |
|
2667 { |
|
2668 aObject.InsertL(aObject.Size(),KDmAccAppAuthLevelSrv); |
|
2669 |
|
2670 } |
|
2671 break; |
|
2672 case (EPRofileClientCred) : |
|
2673 { |
|
2674 aObject.InsertL(aObject.Size(),KDmAccAppAuthLevelCli); |
|
2675 } |
|
2676 break; |
|
2677 |
|
2678 case (ETransportAuthName) : |
|
2679 { |
|
2680 TInt mediumType= ENone; |
|
2681 GetProfileConnectiontypeL( mediumType ); |
|
2682 if( mediumType == EHttp) |
|
2683 { |
|
2684 retVal = GetHttpUsernameL(aObject); |
|
2685 } |
|
2686 else if(mediumType == EObex) |
|
2687 { |
|
2688 aObject.InsertL(aObject.Size(),KNSmlDMNullDesc8); |
|
2689 } |
|
2690 |
|
2691 } |
|
2692 break; |
|
2693 |
|
2694 |
|
2695 case (EProfileTransport) : |
|
2696 { |
|
2697 TInt mediumType= ENone; |
|
2698 GetProfileConnectiontypeL( mediumType ); |
|
2699 if( mediumType == EHttp) |
|
2700 { |
|
2701 aObject.InsertL(aObject.Size(),KDmAccAppAuthLevelHttp); |
|
2702 } |
|
2703 else if(mediumType == EObex) |
|
2704 { |
|
2705 aObject.InsertL(aObject.Size(),KDmAccAppAuthLevelObx); |
|
2706 } |
|
2707 |
|
2708 } |
|
2709 |
|
2710 break; |
|
2711 case ( EAuthenticationRequired ) : |
|
2712 case ( EProfileAAuthType ): |
|
2713 case ( EServerNonce ) : |
|
2714 case ( EClientNonce ) : |
|
2715 { |
|
2716 retVal = GetDMAuthInfoL( aLUID, aDMField, aObject ); |
|
2717 } |
|
2718 break; |
|
2719 |
|
2720 case EProfileLock : |
|
2721 { |
|
2722 |
|
2723 TBool isProfileLocked = iProfile.ProfileLocked(EFalse, EFalse); |
|
2724 if(isProfileLocked) |
|
2725 { |
|
2726 aObject.InsertL(aObject.Size(),KDmProfileLocked); |
|
2727 } |
|
2728 else |
|
2729 { |
|
2730 aObject.InsertL(aObject.Size(),KDmProfileUnLocked); |
|
2731 } |
|
2732 |
|
2733 } |
|
2734 break; |
|
2735 default: |
|
2736 { |
|
2737 User::Panic( KNSmlIndexOutOfBoundStr, KNSmlPanicIndexOutOfBound ); |
|
2738 } |
|
2739 } |
|
2740 iCurrentProfile = 0; |
|
2741 iProfile.Close(); |
|
2742 return retVal; |
|
2743 } |
|
2744 |
|
2745 // ----------------------------------------------------------------------------- |
|
2746 // CNSmlDMSettingsAdapter12::SetProfileConnectionPortNrL() |
|
2747 // The function sets the profile port number. |
|
2748 // ----------------------------------------------------------------------------- |
|
2749 TInt CNSmlDMSettingsAdapter12::SetProfileConnectionPortNrL( const TInt aLUID, |
|
2750 const TDesC8& aPort ) |
|
2751 { |
|
2752 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileConnectionPortNrL(): begin" ); |
|
2753 TInt retVal = KErrNone; |
|
2754 |
|
2755 if( iPortNbr ) |
|
2756 { |
|
2757 delete iPortNbr; |
|
2758 iPortNbr = NULL; |
|
2759 } |
|
2760 iPortNbr = HBufC8::NewL( aPort.Length() ); |
|
2761 TPtr8 newPortNbr = iPortNbr->Des(); |
|
2762 newPortNbr.Append( aPort ); |
|
2763 |
|
2764 retVal = OpenSyncSessionAndProfileL( aLUID, ESmlOpenReadWrite ); |
|
2765 if( retVal != KErrNone ) |
|
2766 { |
|
2767 iCurrentProfile = 0; |
|
2768 iProfile.Close(); |
|
2769 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileConnectionPortNrL(): end" ); |
|
2770 return retVal; |
|
2771 } |
|
2772 |
|
2773 RArray<TSmlTransportId> transportIdArray; |
|
2774 CleanupClosePushL( transportIdArray ); |
|
2775 iProfile.ListConnectionsL( transportIdArray ); |
|
2776 |
|
2777 RSyncMLConnection conn; |
|
2778 CleanupClosePushL( conn ); |
|
2779 conn.OpenL( iProfile, transportIdArray[0] ); |
|
2780 |
|
2781 HBufC8* serverURI = conn.ServerURI().AllocLC(); |
|
2782 if( serverURI->Length() == 0 ) |
|
2783 { |
|
2784 iCurrentProfile = 0; |
|
2785 iProfile.Close(); |
|
2786 CleanupStack::PopAndDestroy( 3 ); //transportIdArray, conn, serverURI |
|
2787 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileConnectionPortNrL(): end" ); |
|
2788 return retVal; |
|
2789 } |
|
2790 TInt totalSize = serverURI->Size() + newPortNbr.Size() + 1; |
|
2791 HBufC8* newServerURI = HBufC8::NewL( totalSize ); |
|
2792 CleanupStack::PushL( newServerURI ); |
|
2793 SetPortNrToAddrStr( *serverURI, newServerURI, newPortNbr ); |
|
2794 |
|
2795 conn.SetServerURIL( *newServerURI ); |
|
2796 conn.UpdateL(); |
|
2797 |
|
2798 CleanupStack::PopAndDestroy( 4 ); //transportIdArray, conn, serverURI, newServerURI |
|
2799 iCurrentProfile = 0; |
|
2800 iProfile.Close(); |
|
2801 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileConnectionPortNrL(): end" ); |
|
2802 return retVal; |
|
2803 } |
|
2804 |
|
2805 // ------------------------------------------------------------------------------------------------ |
|
2806 // CNSmlDMSettingsAdapter12::SetPortNrToAddrStr |
|
2807 // Sets a portnbr (separated with ':') to profile server URI. |
|
2808 // ------------------------------------------------------------------------------------------------ |
|
2809 void CNSmlDMSettingsAdapter12::SetPortNrToAddrStr( const TDesC8& aSrvURI, HBufC8* aNewURI, |
|
2810 const TDesC8& aPort ) |
|
2811 { |
|
2812 TInt offset=0; |
|
2813 if( aSrvURI.Find( KNSmlDMSettingsHTTP ) == 0 )//http:// |
|
2814 { |
|
2815 offset = KNSmlDMSettingsHTTP().Length(); |
|
2816 } |
|
2817 else if( aSrvURI.Find( KNSmlDMSettingsHTTPS ) == 0 )//https:// |
|
2818 { |
|
2819 offset = KNSmlDMSettingsHTTPS().Length(); |
|
2820 } |
|
2821 TInt portStart = -1; |
|
2822 TInt separatorPos = aSrvURI.Length(); |
|
2823 TInt i = 0; |
|
2824 for( i = offset; i < aSrvURI.Length(); i++ ) |
|
2825 { |
|
2826 if( aSrvURI[i] == KNSmlDMColon )// ':' |
|
2827 { |
|
2828 portStart = i; |
|
2829 } |
|
2830 if( aSrvURI[i] == KNSmlDMUriSeparator )// '/' |
|
2831 { |
|
2832 separatorPos = i; |
|
2833 break; |
|
2834 } |
|
2835 } |
|
2836 |
|
2837 TPtr8 ptrNewSrvURI = aNewURI->Des(); |
|
2838 if( portStart < 0 && separatorPos > 0 && iLeafType != EDMDelete ) |
|
2839 { |
|
2840 ptrNewSrvURI.Append( aSrvURI.Left( separatorPos ) );//http://123.234.345.456 |
|
2841 ptrNewSrvURI.Append( KNSmlDMColon ); |
|
2842 ptrNewSrvURI.Append( aPort ); |
|
2843 ptrNewSrvURI.Append( aSrvURI.Right( aSrvURI.Length() - separatorPos ) ); |
|
2844 } |
|
2845 else if ( portStart > 0 && separatorPos > 0 && iLeafType != EDMDelete ) |
|
2846 { |
|
2847 ptrNewSrvURI.Append( aSrvURI.Left( portStart + 1 ) );//123.234.345.456: |
|
2848 ptrNewSrvURI.Append( aPort );//123.234.345.456:xx(x) |
|
2849 ptrNewSrvURI.Append( aSrvURI.Right( aSrvURI.Length() - separatorPos ) ); |
|
2850 } |
|
2851 else if ( portStart > 0 && iLeafType == EDMDelete ) //delete port number from uri |
|
2852 { |
|
2853 ptrNewSrvURI.Append( aSrvURI.Left( portStart ) );//123.234.345.456 |
|
2854 ptrNewSrvURI.Append( aSrvURI.Right( aSrvURI.Length() - separatorPos ) ); |
|
2855 } |
|
2856 else |
|
2857 { |
|
2858 ptrNewSrvURI.Append( aSrvURI ); |
|
2859 } |
|
2860 return; |
|
2861 } |
|
2862 |
|
2863 // ------------------------------------------------------------------------------------------------ |
|
2864 // CNSmlDMSettingsAdapter12::SetDMFieldDataL |
|
2865 // Selects and Sets value to a field based on field id got from URI. |
|
2866 // ------------------------------------------------------------------------------------------------ |
|
2867 TInt CNSmlDMSettingsAdapter12::SetDMFieldDataL( const TInt aLUID, const TDesC8& aObject, |
|
2868 const TNSmlDMProfileData aField ) |
|
2869 { |
|
2870 TInt rValue = KErrGeneral; |
|
2871 TInt lockvalue =0; |
|
2872 if(aField != EProfileLock) |
|
2873 { |
|
2874 rValue=IsProfileLockedL(aLUID); |
|
2875 if (rValue!= KErrNone) |
|
2876 { |
|
2877 return rValue; |
|
2878 } |
|
2879 |
|
2880 } |
|
2881 else if (aField == EProfileLock) |
|
2882 { |
|
2883 if (! iNewProfile) |
|
2884 { |
|
2885 lockvalue =0; |
|
2886 if(aObject.Length()> 1) |
|
2887 { |
|
2888 rValue = KErrArgument; |
|
2889 return rValue; |
|
2890 } |
|
2891 lockvalue = GetIntObject(aObject); |
|
2892 if(lockvalue != 0 && lockvalue != 1) |
|
2893 { |
|
2894 //lockvalue = 0; |
|
2895 rValue = KErrArgument; |
|
2896 return rValue; |
|
2897 } |
|
2898 rValue = SetProfileLockL(aLUID , lockvalue); |
|
2899 return rValue; |
|
2900 } |
|
2901 |
|
2902 } |
|
2903 |
|
2904 switch ( aField ) |
|
2905 { |
|
2906 case ( EProfileURL ) : |
|
2907 { |
|
2908 rValue = SetProfileServerURIL( aLUID, aObject ); |
|
2909 } |
|
2910 break; |
|
2911 case ( EServerId ) : |
|
2912 { |
|
2913 rValue = SetProfileServerIdL( aLUID, aObject ); |
|
2914 } |
|
2915 break; |
|
2916 case ( ESharedSecret ) : |
|
2917 { |
|
2918 rValue = SetProfileServerPasswordL( aLUID, aObject ); |
|
2919 } |
|
2920 break; |
|
2921 case ( EProfileDMServerUsername ) : |
|
2922 { |
|
2923 rValue = SetProfileUserNameL( aLUID, aObject ); |
|
2924 } |
|
2925 break; |
|
2926 case ( EProfileDMServerPassword ) : |
|
2927 { |
|
2928 rValue = SetProfilePasswordL( aLUID, aObject ); |
|
2929 } |
|
2930 break; |
|
2931 case ( EProfileName ) : |
|
2932 { |
|
2933 rValue = SetProfileDisplayNameL( aLUID, aObject ); |
|
2934 } |
|
2935 break; |
|
2936 case ( EProfileIAPId ) : |
|
2937 { |
|
2938 rValue = SetConRefL( aLUID, aObject ); |
|
2939 } |
|
2940 break; |
|
2941 case ( ETransportAuthName ): |
|
2942 { |
|
2943 OpenSyncSessionAndProfileL( aLUID, ESmlOpenReadWrite ); |
|
2944 TInt mediumType = ENone; |
|
2945 GetProfileConnectiontypeL( mediumType ); |
|
2946 if( mediumType == EHttp) |
|
2947 { |
|
2948 rValue = SetProfileHttpUserNameL ( aLUID, aObject ); |
|
2949 } |
|
2950 else if(mediumType == EObex) |
|
2951 { |
|
2952 rValue = KErrNone; |
|
2953 |
|
2954 } |
|
2955 |
|
2956 |
|
2957 //break; |
|
2958 } |
|
2959 break; |
|
2960 case ( EProfileTransportPassword ): |
|
2961 { |
|
2962 TInt mediumType = ENone; |
|
2963 OpenSyncSessionAndProfileL( aLUID, ESmlOpenReadWrite ); |
|
2964 GetProfileConnectiontypeL( mediumType ); |
|
2965 if( mediumType == EHttp) |
|
2966 { |
|
2967 rValue = SetProfileHttpPasswordL ( aLUID, aObject ); |
|
2968 } |
|
2969 else if(mediumType == EObex) |
|
2970 { |
|
2971 rValue = KErrNone; |
|
2972 |
|
2973 } |
|
2974 } |
|
2975 break; |
|
2976 case (EProfileTransportAuthData) : |
|
2977 { |
|
2978 rValue = KErrNone; |
|
2979 } |
|
2980 break; |
|
2981 |
|
2982 case ( EProfileHttpUsername ) : |
|
2983 { |
|
2984 rValue = SetProfileHttpUserNameL ( aLUID, aObject ); |
|
2985 } |
|
2986 break; |
|
2987 case ( EProfileHttpPassword ) : |
|
2988 { |
|
2989 rValue = SetProfileHttpPasswordL ( aLUID, aObject ); |
|
2990 } |
|
2991 break; |
|
2992 case ( EProfileId ) : |
|
2993 { |
|
2994 } |
|
2995 break; |
|
2996 case ( EProfilePort ) : |
|
2997 { |
|
2998 if(aObject.Size()<=5) |
|
2999 { |
|
3000 TInt port = GetIntObject(aObject); |
|
3001 if( port > KPortMinSize && port < KPortMaxSize ) |
|
3002 { |
|
3003 TPortBuffer element; |
|
3004 element.iPortBuf=aObject; |
|
3005 element.iPortBufLUID = aLUID; |
|
3006 iPortBuffer.Append(element); |
|
3007 rValue=KErrNone; |
|
3008 } |
|
3009 else |
|
3010 { |
|
3011 if (port <= KPortMinSize ) |
|
3012 rValue = KErrUnderflow; |
|
3013 else |
|
3014 rValue=KErrOverflow; |
|
3015 } |
|
3016 } |
|
3017 else |
|
3018 { |
|
3019 rValue=KErrOverflow; |
|
3020 } |
|
3021 // save information of the port |
|
3022 } |
|
3023 break; |
|
3024 |
|
3025 case ( EProfileAddrType ) : |
|
3026 { |
|
3027 if (aObject.Match(KNSmlAddrtype)!=KErrNotFound) |
|
3028 rValue=KErrNone; |
|
3029 |
|
3030 } |
|
3031 break; |
|
3032 |
|
3033 |
|
3034 case ( EProfileMediumType ) : |
|
3035 { |
|
3036 if ( iLeafType == EDMDelete ) |
|
3037 { |
|
3038 return KErrNone; |
|
3039 } |
|
3040 iObject = GetIntObject( aObject ); |
|
3041 if(iObject<0) |
|
3042 { |
|
3043 iObject = EHttp; |
|
3044 } |
|
3045 rValue = SetProfileAddrTypeL( aLUID, iObject ); |
|
3046 } |
|
3047 break; |
|
3048 case ( EProfileTransport) : |
|
3049 { |
|
3050 if (aObject.Match(KDmAccAppAuthLevelHttp)!=KErrNotFound) |
|
3051 { |
|
3052 iObject = EHttp; |
|
3053 } |
|
3054 else if (aObject.Match(KDmAccAppAuthLevelObx)!=KErrNotFound) |
|
3055 { |
|
3056 iObject = EObex; |
|
3057 } |
|
3058 rValue = SetProfileAddrTypeL( aLUID, iObject ); |
|
3059 } |
|
3060 break; |
|
3061 case ( EAuthenticationRequired ) : |
|
3062 case ( EClientNonce ) : |
|
3063 case ( EServerNonce ) : |
|
3064 break; |
|
3065 case ( EProfileLock ) : |
|
3066 lockvalue =0; |
|
3067 lockvalue = GetIntObject(aObject); |
|
3068 if(lockvalue != 0 && lockvalue != 1) |
|
3069 lockvalue = 0; |
|
3070 |
|
3071 TLockBuffer element; |
|
3072 element.iProfileLock=lockvalue; |
|
3073 element.iProfileLockLUID = aLUID; |
|
3074 iProfileLockBuffer.Append(element); |
|
3075 rValue=KErrNone; |
|
3076 |
|
3077 |
|
3078 // rValue = SetProfileLock(aLUID , lockvalue); |
|
3079 break; |
|
3080 default: |
|
3081 rValue = KErrNotSupported; |
|
3082 } |
|
3083 return rValue; |
|
3084 } |
|
3085 |
|
3086 // ----------------------------------------------------------------------------- |
|
3087 // CNSmlDMSettingsAdapter12::FillNodeInfoL |
|
3088 // The function fills the node or leaf information. |
|
3089 // ----------------------------------------------------------------------------- |
|
3090 void CNSmlDMSettingsAdapter12::FillNodeInfoL( MSmlDmDDFObject& aNode, |
|
3091 TSmlDmAccessTypes aAccTypes, |
|
3092 MSmlDmDDFObject::TOccurence aOccurrence, |
|
3093 MSmlDmDDFObject::TScope aScope, |
|
3094 MSmlDmDDFObject::TDFFormat aFormat, |
|
3095 const TDesC8& aDescription, |
|
3096 const TDesC8& aDefaultValue, |
|
3097 const TDesC8& aMimeType ) |
|
3098 { |
|
3099 aNode.AddDFTypeMimeTypeL( aMimeType ); |
|
3100 aNode.SetAccessTypesL( aAccTypes ); |
|
3101 aNode.SetDescriptionL( aDescription ); |
|
3102 aNode.SetOccurenceL( aOccurrence ); |
|
3103 aNode.SetDefaultValueL( aDefaultValue ); |
|
3104 aNode.SetScopeL( aScope ); |
|
3105 aNode.SetDFFormatL( aFormat ); |
|
3106 return; |
|
3107 } |
|
3108 |
|
3109 // ----------------------------------------------------------------------------- |
|
3110 // CNSmlDMSettingsAdapter12::GetDMAuthInfoL |
|
3111 // This function gets authentication data from private API. |
|
3112 // ----------------------------------------------------------------------------- |
|
3113 TInt CNSmlDMSettingsAdapter12::GetDMAuthInfoL( const TInt aLUID, |
|
3114 const TNSmlDMProfileData aField, |
|
3115 CBufBase& aObject ) |
|
3116 { |
|
3117 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetDMAuthInfoL(): begin" ); |
|
3118 |
|
3119 CNSmlDMAuthInfo* authInfo = new (ELeave) CNSmlDMAuthInfo; |
|
3120 CleanupStack::PushL( authInfo ); |
|
3121 |
|
3122 authInfo->iProfileId = aLUID + KMaxDataSyncID; |
|
3123 iPrivateApi.OpenL(); |
|
3124 TInt ret = KErrNone; |
|
3125 |
|
3126 TRAPD(err,iPrivateApi.GetDMAuthInfoL( *authInfo )); |
|
3127 |
|
3128 if(err==KErrNone) |
|
3129 { |
|
3130 if ( aField == EServerNonce ) |
|
3131 { |
|
3132 aObject.InsertL( aObject.Size(), *authInfo->iServerNonce ); |
|
3133 } |
|
3134 else if ( aField == EClientNonce ) |
|
3135 { |
|
3136 aObject.InsertL( aObject.Size(), *authInfo->iClientNonce ); |
|
3137 } |
|
3138 else if (( aField == EAuthenticationRequired ) || (aField == EProfileAAuthType)) |
|
3139 { |
|
3140 TUint authPref = authInfo->iAuthPref; |
|
3141 /*if( authPref == ENoAuth ) |
|
3142 { |
|
3143 aObject.InsertL( aObject.Size(), KNSmlDMAuthPrefNoAuth ); |
|
3144 }*/ |
|
3145 if( authPref == EBasic ) |
|
3146 { |
|
3147 if(aField == EAuthenticationRequired) |
|
3148 { |
|
3149 aObject.InsertL( aObject.Size(), KNSmlDMAuthPrefBasic ); |
|
3150 } |
|
3151 else |
|
3152 { |
|
3153 aObject.InsertL( aObject.Size(), KNSmlDMAuthTypeBasic ); |
|
3154 } |
|
3155 |
|
3156 } |
|
3157 else if( authPref == EMD5 ) |
|
3158 { |
|
3159 if(aField == EAuthenticationRequired) |
|
3160 { |
|
3161 aObject.InsertL( aObject.Size(), KNSmlDMAuthPrefMD5 ); |
|
3162 } |
|
3163 else |
|
3164 { |
|
3165 aObject.InsertL( aObject.Size(), KNSmlDMAuthTypeMD5 ); |
|
3166 } |
|
3167 |
|
3168 } |
|
3169 else |
|
3170 { |
|
3171 aObject.InsertL( aObject.Size(), KNullDesC8 ); |
|
3172 } |
|
3173 } |
|
3174 } |
|
3175 iPrivateApi.Close(); |
|
3176 CleanupStack::PopAndDestroy(authInfo); |
|
3177 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetDMAuthInfoL(): end" ); |
|
3178 return ret; |
|
3179 } |
|
3180 |
|
3181 // ----------------------------------------------------------------------------- |
|
3182 // CNSmlDMSettingsAdapter12::DeleteDMAuthInfoL |
|
3183 // This function resets the authentication data. |
|
3184 // ----------------------------------------------------------------------------- |
|
3185 TInt CNSmlDMSettingsAdapter12::DeleteDMAuthInfoL( const TInt aLUID, |
|
3186 const TNSmlDMProfileData aField ) |
|
3187 { |
|
3188 _DBG_FILE( "CNSmlDMSettingsAdapter12::DeleteDMAuthInfoL(): begin" ); |
|
3189 CNSmlDMAuthInfo* authInfo = new (ELeave) CNSmlDMAuthInfo;; |
|
3190 CleanupStack::PushL( authInfo ); |
|
3191 authInfo->iProfileId = aLUID; |
|
3192 iPrivateApi.OpenL(); |
|
3193 iPrivateApi.GetDMAuthInfoL( *authInfo ); |
|
3194 if( aField == EServerNonce ) |
|
3195 { |
|
3196 authInfo->iServerNonce->Des().Delete( 0, authInfo->iServerNonce->Des().Size() ); |
|
3197 authInfo->iServerNonce->Des().Insert( 0, KNullDesC8 ); |
|
3198 } |
|
3199 else if( aField == EClientNonce ) |
|
3200 { |
|
3201 authInfo->iClientNonce->Des().Delete( 0, authInfo->iClientNonce->Des().Size() ); |
|
3202 authInfo->iClientNonce->Des().Insert( 0, KNullDesC8 ); |
|
3203 } |
|
3204 else if( aField == EAuthenticationRequired ) |
|
3205 { |
|
3206 authInfo->iAuthPref = 0; |
|
3207 } |
|
3208 iPrivateApi.SetDMAuthInfoL( *authInfo ); |
|
3209 iPrivateApi.Close(); |
|
3210 CleanupStack::PopAndDestroy(authInfo); |
|
3211 _DBG_FILE( "CNSmlDMSettingsAdapter12::DeleteDMAuthInfoL(): end" ); |
|
3212 return KErrNone; |
|
3213 } |
|
3214 |
|
3215 // ----------------------------------------------------------------------------- |
|
3216 // CNSmlDMSettingsAdapter12::SetProfileAddrTypeL |
|
3217 // This function sets the AddrType value. |
|
3218 // ----------------------------------------------------------------------------- |
|
3219 TInt CNSmlDMSettingsAdapter12::SetProfileAddrTypeL( const TInt aLUID, |
|
3220 const TInt aIntObj ) |
|
3221 { |
|
3222 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileAddrTypeL(): begin" ); |
|
3223 TInt retVal = OpenSyncSessionAndProfileL( aLUID, ESmlOpenReadWrite ); |
|
3224 if( retVal != KErrNone ) |
|
3225 { |
|
3226 iCurrentProfile = 0; |
|
3227 iProfile.Close(); |
|
3228 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileAddrTypeL(): end" ); |
|
3229 return retVal; |
|
3230 } |
|
3231 TInt mediumType = ENone; |
|
3232 GetMediumTypeL( aIntObj, mediumType ); |
|
3233 if( mediumType == ENone ) |
|
3234 { |
|
3235 iCurrentProfile = 0; |
|
3236 iProfile.Close(); |
|
3237 return KErrGeneral; |
|
3238 } |
|
3239 RArray<TSmlTransportId> transportIdArray; |
|
3240 CleanupClosePushL( transportIdArray ); |
|
3241 iProfile.ListConnectionsL( transportIdArray ); |
|
3242 RSyncMLConnection conn; |
|
3243 CleanupClosePushL( conn ); |
|
3244 conn.OpenL( iProfile, transportIdArray[0] ); |
|
3245 HBufC8* sURI = conn.ServerURI().AllocLC(); |
|
3246 if(mediumType!=transportIdArray[0]) |
|
3247 { |
|
3248 if ( !FeatureManager::FeatureSupported( KFeatureIdSyncMlDmObex ) ) |
|
3249 { |
|
3250 CleanupStack::PopAndDestroy( 3 );//transportIdArray, conn, sURI |
|
3251 return EInvalidObject; |
|
3252 } |
|
3253 else |
|
3254 { |
|
3255 conn.CreateL(iProfile,mediumType); |
|
3256 } |
|
3257 } |
|
3258 conn.SetServerURIL( *sURI ); |
|
3259 conn.UpdateL(); |
|
3260 CleanupStack::PopAndDestroy( 3 );//transportIdArray, conn, sURI |
|
3261 iCurrentProfile = 0; |
|
3262 iProfile.Close(); |
|
3263 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetProfileAddrTypeL(): end" ); |
|
3264 return KErrNone; |
|
3265 } |
|
3266 |
|
3267 // ----------------------------------------------------------------------------- |
|
3268 // CNSmlDMSettingsAdapter12::GetHttpUsernameL |
|
3269 // This function gets the httpuser value. |
|
3270 // ----------------------------------------------------------------------------- |
|
3271 |
|
3272 |
|
3273 TInt CNSmlDMSettingsAdapter12::GetHttpUsernameL( CBufBase& aObject ) |
|
3274 { |
|
3275 |
|
3276 TInt retVal = KErrNone; |
|
3277 TBuf8<KBufSize32> key; |
|
3278 TInt intValue; |
|
3279 |
|
3280 RArray<TSmlTransportId> connIdArray; |
|
3281 CleanupClosePushL( connIdArray ); |
|
3282 iProfile.ListConnectionsL( connIdArray ); |
|
3283 if( connIdArray.Count() == 1 ) |
|
3284 { |
|
3285 RSyncMLTransport transport; |
|
3286 CleanupClosePushL( transport ); |
|
3287 transport.OpenL( iSyncSession, connIdArray[0] ); |
|
3288 const CSyncMLTransportPropertiesArray& arr = transport.Properties(); |
|
3289 const TSyncMLTransportPropertyInfo& info = arr.At( EPropertyHttpUsed ); |
|
3290 key = info.iName; |
|
3291 RSyncMLConnection conn; |
|
3292 CleanupClosePushL( conn ); |
|
3293 conn.OpenL( iProfile, connIdArray[0] ); |
|
3294 HBufC8* value = conn.GetPropertyL( key ).AllocLC(); |
|
3295 intValue = GetIntObject( *value ); |
|
3296 CleanupStack::PopAndDestroy( ); //value |
|
3297 if ( intValue == 1 ) |
|
3298 { |
|
3299 retVal = KErrNone; |
|
3300 const TSyncMLTransportPropertyInfo& info2 = arr.At( EPropertyHttpUserName ); |
|
3301 key= info2.iName; |
|
3302 HBufC8* value = conn.GetPropertyL( key ).AllocLC(); |
|
3303 aObject.InsertL(aObject.Size(),value->Des()); |
|
3304 CleanupStack::PopAndDestroy( ); //value |
|
3305 } |
|
3306 else |
|
3307 { |
|
3308 retVal = KErrNotFound; |
|
3309 } |
|
3310 CleanupStack::PopAndDestroy( 2 ); // conn, transport |
|
3311 } |
|
3312 CleanupStack::PopAndDestroy( ); //connIdArray |
|
3313 |
|
3314 return retVal; |
|
3315 } |
|
3316 |
|
3317 // ----------------------------------------------------------------------------- |
|
3318 // CNSmlDMSettingsAdapter12::GetProfileConnectiontypeL |
|
3319 // The function gets the profile medium type. |
|
3320 // ----------------------------------------------------------------------------- |
|
3321 TInt CNSmlDMSettingsAdapter12::GetProfileConnectiontypeL( TInt& aMediumTYpe ) |
|
3322 { |
|
3323 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetProfileConnectiontypeL(): begin" ); |
|
3324 RArray<TSmlTransportId> transportIdArray; |
|
3325 CleanupClosePushL( transportIdArray ); |
|
3326 iProfile.ListConnectionsL( transportIdArray ); |
|
3327 TInt transportItems = transportIdArray.Count(); |
|
3328 if( transportItems == 0 ) |
|
3329 { |
|
3330 //No matching items |
|
3331 CleanupStack::PopAndDestroy(); //transportIdArray |
|
3332 return KErrGeneral; |
|
3333 } |
|
3334 else if( transportItems > 1 ) |
|
3335 { |
|
3336 //Error case : against specification |
|
3337 CleanupStack::PopAndDestroy(); //transportIdArray |
|
3338 return KErrGeneral; |
|
3339 } |
|
3340 aMediumTYpe = 0; |
|
3341 if ( transportIdArray[0] == KUidNSmlMediumTypeInternet.iUid ) |
|
3342 { |
|
3343 aMediumTYpe = 1; //EHttp; |
|
3344 } |
|
3345 else if ( transportIdArray[0] == KUidNSmlMediumTypeBluetooth.iUid || |
|
3346 transportIdArray[0] == KUidNSmlMediumTypeUSB.iUid || |
|
3347 transportIdArray[0] == KUidNSmlMediumTypeIrDA.iUid ) |
|
3348 { |
|
3349 aMediumTYpe = 3; //EObex; |
|
3350 } |
|
3351 CleanupStack::PopAndDestroy( 1 ); //transportIdArray, SetIntObjectLC |
|
3352 return KErrNone; |
|
3353 } |
|
3354 |
|
3355 // ----------------------------------------------------------------------------- |
|
3356 // CNSmlDMSettingsAdapter12::GetProfileIAPIdL |
|
3357 // The function gets the profile IAP Id. |
|
3358 // ----------------------------------------------------------------------------- |
|
3359 TInt CNSmlDMSettingsAdapter12::GetProfileIAPIdL( TInt& aIAPid ) |
|
3360 { |
|
3361 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetProfileIAPIdL(): begin" ); |
|
3362 TInt retVal = KErrGeneral; |
|
3363 aIAPid = -1; |
|
3364 RArray<TSmlTransportId> connIdArray; |
|
3365 CleanupClosePushL( connIdArray ); |
|
3366 iProfile.ListConnectionsL( connIdArray ); |
|
3367 if( connIdArray.Count() == 1 ) |
|
3368 { |
|
3369 RSyncMLTransport transport; |
|
3370 CleanupClosePushL( transport ); |
|
3371 transport.OpenL( iSyncSession, connIdArray[0] ); |
|
3372 const CSyncMLTransportPropertiesArray& props = transport.Properties(); |
|
3373 TInt index = props.Find( KNSmlIAPId ); |
|
3374 if( index > 0 ) |
|
3375 { |
|
3376 RSyncMLConnection conn; |
|
3377 CleanupClosePushL( conn ); |
|
3378 conn.OpenL( iProfile, connIdArray[0] ); |
|
3379 HBufC8* apId = conn.GetPropertyL( KNSmlIAPId ).AllocLC(); |
|
3380 aIAPid = GetIntObject( *apId ); |
|
3381 CleanupStack::PopAndDestroy( 2 ); //conn, apId |
|
3382 retVal = KErrNone; |
|
3383 } |
|
3384 else |
|
3385 { |
|
3386 retVal = KErrNotFound; |
|
3387 } |
|
3388 CleanupStack::PopAndDestroy( 1 ); //transport |
|
3389 iCurrentProfile = 0; |
|
3390 iProfile.Close(); |
|
3391 } |
|
3392 else |
|
3393 { |
|
3394 retVal = KErrNotFound; |
|
3395 } |
|
3396 CleanupStack::PopAndDestroy(); //connIdArray |
|
3397 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetProfileIAPIdL(): end" ); |
|
3398 return retVal; |
|
3399 } |
|
3400 |
|
3401 // ----------------------------------------------------------------------------- |
|
3402 // CNSmlDMSettingsAdapter12::GetProfileServerURLL |
|
3403 // The function gets the profile Server URI. |
|
3404 // ----------------------------------------------------------------------------- |
|
3405 void CNSmlDMSettingsAdapter12::GetProfileServerURLL( CBufBase& aURL ) |
|
3406 { |
|
3407 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetProfileServerURLL(): begin" ); |
|
3408 RArray<TSmlTransportId> transportIdArray; |
|
3409 CleanupClosePushL( transportIdArray ); |
|
3410 iProfile.ListConnectionsL( transportIdArray ); |
|
3411 if( transportIdArray.Count() > 0 ) |
|
3412 { |
|
3413 RSyncMLConnection profConn; |
|
3414 CleanupClosePushL( profConn ); |
|
3415 profConn.OpenL( iProfile, transportIdArray[0] ); |
|
3416 HBufC8* sURI = profConn.ServerURI().AllocL(); |
|
3417 CleanupStack::PushL( sURI ); |
|
3418 TPtr8 uriPtr = sURI->Des(); |
|
3419 if( uriPtr.Length() > 0 ) |
|
3420 { |
|
3421 aURL.InsertL( aURL.Size(),uriPtr ); |
|
3422 } |
|
3423 else |
|
3424 { |
|
3425 aURL.InsertL( aURL.Size(), KNullDesC8 ); |
|
3426 } |
|
3427 CleanupStack::PopAndDestroy( 2 );//profConn, sURI |
|
3428 } |
|
3429 CleanupStack::PopAndDestroy(); //transportIdArray |
|
3430 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetProfileServerURLL(): end" ); |
|
3431 return; |
|
3432 } |
|
3433 |
|
3434 // ----------------------------------------------------------------------------- |
|
3435 // CNSmlDMSettingsAdapter12::GetMediumTypeL |
|
3436 // Checks the requested medium type. |
|
3437 // ----------------------------------------------------------------------------- |
|
3438 void CNSmlDMSettingsAdapter12::GetMediumTypeL( const TInt aIntObj, |
|
3439 TInt& aMediumType ) |
|
3440 { |
|
3441 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetMediumTypeL(): begin" ); |
|
3442 if( aIntObj == EHttp || aIntObj == EWsp ) |
|
3443 { |
|
3444 aMediumType = KUidNSmlMediumTypeInternet.iUid; |
|
3445 return; |
|
3446 } |
|
3447 RArray<TSmlTransportId> transportIdArray; |
|
3448 CleanupClosePushL( transportIdArray ); |
|
3449 iSyncSession.ListTransportsL( transportIdArray ); |
|
3450 |
|
3451 if ( transportIdArray.Find( KUidNSmlMediumTypeBluetooth.iUid ) != KErrNotFound ) |
|
3452 { |
|
3453 aMediumType = KUidNSmlMediumTypeBluetooth.iUid; |
|
3454 } |
|
3455 else if ( transportIdArray.Find( KUidNSmlMediumTypeUSB.iUid ) != KErrNotFound ) |
|
3456 { |
|
3457 aMediumType = KUidNSmlMediumTypeUSB.iUid; |
|
3458 } |
|
3459 else if ( transportIdArray.Find( KUidNSmlMediumTypeIrDA.iUid ) != KErrNotFound ) |
|
3460 { |
|
3461 aMediumType = KUidNSmlMediumTypeIrDA.iUid; |
|
3462 } |
|
3463 CleanupStack::PopAndDestroy(); //transportIdArray |
|
3464 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetMediumTypeL(): end" ); |
|
3465 return; |
|
3466 } |
|
3467 |
|
3468 // ----------------------------------------------------------------------------- |
|
3469 // CNSmlDMSettingsAdapter12::GetServerIdL |
|
3470 // Gets the server id value. |
|
3471 // ----------------------------------------------------------------------------- |
|
3472 void CNSmlDMSettingsAdapter12::GetServerIdL( CBufBase& aObject ) |
|
3473 { |
|
3474 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetServerIdL(): begin" ); |
|
3475 HBufC8* serverId = iProfile.ServerId().AllocL(); |
|
3476 CleanupStack::PushL( serverId ); |
|
3477 aObject.InsertL( aObject.Size(), *serverId ); |
|
3478 CleanupStack::PopAndDestroy( 1 ); //serverId |
|
3479 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetServerIdL(): end" ); |
|
3480 return; |
|
3481 } |
|
3482 |
|
3483 // ----------------------------------------------------------------------------- |
|
3484 // CNSmlDMSettingsAdapter12::GetProfileNameL |
|
3485 // Gets the display name value. |
|
3486 // ----------------------------------------------------------------------------- |
|
3487 void CNSmlDMSettingsAdapter12::GetProfileNameL( CBufBase& aObject ) |
|
3488 { |
|
3489 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetProfileNameL(): begin" ); |
|
3490 HBufC16* dataBuf = iProfile.DisplayName().AllocL(); |
|
3491 CleanupStack::PushL( dataBuf ); |
|
3492 TPtr16 ptrDisplayName = dataBuf->Des(); |
|
3493 HBufC8* dataBuf8 = HBufC8::NewL( ptrDisplayName.Length() * 2 ); |
|
3494 CleanupStack::PushL( dataBuf8 ); |
|
3495 |
|
3496 TPtr8 ptrDisplayName8 = dataBuf8->Des(); |
|
3497 ptrDisplayName8 = ConvertTo8LC( ptrDisplayName ); |
|
3498 aObject.InsertL( aObject.Size(), ptrDisplayName8 ); |
|
3499 CleanupStack::PopAndDestroy( 3 );//dataBuf, ConvertTo8LC |
|
3500 _DBG_FILE("CNSmlDMSettingsAdapter12::GetProfileNameL(): end"); |
|
3501 return; |
|
3502 } |
|
3503 |
|
3504 // ----------------------------------------------------------------------------- |
|
3505 // CNSmlDMSettingsAdapter12::GetProfileUserNameL |
|
3506 // Gets the profile user name value. |
|
3507 // ----------------------------------------------------------------------------- |
|
3508 void CNSmlDMSettingsAdapter12::GetProfileUserNameL( CBufBase& aObject ) |
|
3509 { |
|
3510 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetProfileUserNameL(): begin" ); |
|
3511 HBufC8* dataBuf = iProfile.UserName().AllocL(); |
|
3512 CleanupStack::PushL( dataBuf ); |
|
3513 TPtr8 ptrUserName = dataBuf->Des(); |
|
3514 aObject.InsertL( aObject.Size(), ptrUserName ); |
|
3515 CleanupStack::PopAndDestroy();//dataBuf |
|
3516 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetProfileUserNameL(): end" ); |
|
3517 return; |
|
3518 } |
|
3519 |
|
3520 // ----------------------------------------------------------------------------- |
|
3521 // CNSmlDMSettingsAdapter12::GetProfilePortNumberL |
|
3522 // Gets the port number value. |
|
3523 // ----------------------------------------------------------------------------- |
|
3524 void CNSmlDMSettingsAdapter12::GetProfilePortNumberL( CBufBase& aObject ) |
|
3525 { |
|
3526 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetProfilePortNumberL(): begin" ); |
|
3527 TInt bSize = aObject.Size(); |
|
3528 TInt portNum = 0; |
|
3529 HBufC8* bufStorage = HBufC8::NewLC( bSize ); |
|
3530 TPtr8 bufStoragePtr = bufStorage->Des(); |
|
3531 aObject.Read( 0, bufStoragePtr, aObject.Size() ); |
|
3532 aObject.Reset(); |
|
3533 |
|
3534 //find out the port number |
|
3535 ParseUri( *bufStorage, portNum ); |
|
3536 aObject.InsertL( aObject.Size(), SetIntObjectLC( portNum ) ); |
|
3537 |
|
3538 CleanupStack::PopAndDestroy( 2 ); //bufStorage, SetIntObjectLC() |
|
3539 _DBG_FILE( "CNSmlDMSettingsAdapter12::GetProfilePortNumberL(): end" ); |
|
3540 return; |
|
3541 } |
|
3542 |
|
3543 // ----------------------------------------------------------------------------- |
|
3544 // CNSmlDMSettingsAdapter12::SetAuthInfoL |
|
3545 // The function checks if authinfo already exits. If exits command is replace. |
|
3546 // ----------------------------------------------------------------------------- |
|
3547 void CNSmlDMSettingsAdapter12::SetAuthInfoL( const TInt aLUID, |
|
3548 const TNSmlDMProfileData aField, |
|
3549 const TDesC8& aObject, TInt& aStatus ) |
|
3550 { |
|
3551 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetAuthInfoL(): begin" ); |
|
3552 |
|
3553 CNSmlDMAuthInfo* authInfo = new (ELeave) CNSmlDMAuthInfo(); |
|
3554 CleanupStack::PushL( authInfo ); |
|
3555 authInfo->iProfileId = aLUID; |
|
3556 |
|
3557 iPrivateApi.OpenL(); |
|
3558 TRAPD( err, iPrivateApi.GetDMAuthInfoL( *authInfo ) ); |
|
3559 |
|
3560 if ( err ) |
|
3561 { |
|
3562 CleanupStack::PopAndDestroy( authInfo ); |
|
3563 iPrivateApi.Close(); |
|
3564 aStatus = err; |
|
3565 return; |
|
3566 } |
|
3567 |
|
3568 CNSmlDMAuthInfo* newAuthInfo = new (ELeave) CNSmlDMAuthInfo(); |
|
3569 CleanupStack::PushL( newAuthInfo ); |
|
3570 newAuthInfo->iProfileId = aLUID; |
|
3571 |
|
3572 if ( aField == EServerNonce ) |
|
3573 { |
|
3574 newAuthInfo->iServerNonce = aObject.Alloc(); |
|
3575 newAuthInfo->iClientNonce = authInfo->iClientNonce->Des().Alloc(); |
|
3576 newAuthInfo->iAuthPref = authInfo->iAuthPref; |
|
3577 |
|
3578 iPrivateApi.SetDMAuthInfoL( *newAuthInfo ); |
|
3579 } |
|
3580 else if ( aField == EClientNonce ) |
|
3581 { |
|
3582 newAuthInfo->iServerNonce = authInfo->iServerNonce->Des().Alloc(); |
|
3583 newAuthInfo->iClientNonce = aObject.Alloc(); |
|
3584 newAuthInfo->iAuthPref = authInfo->iAuthPref; |
|
3585 |
|
3586 iPrivateApi.SetDMAuthInfoL( *newAuthInfo ); |
|
3587 } |
|
3588 else if ( aField == EAuthenticationRequired ) |
|
3589 { |
|
3590 if ( aObject.Match( KNSmlDMAuthPrefNoAuth ) != KErrNotFound ) |
|
3591 { |
|
3592 newAuthInfo->iAuthPref = ENoAuth; |
|
3593 } |
|
3594 else if ( aObject.Match( KNSmlDMAuthPrefBasic ) != KErrNotFound ) |
|
3595 { |
|
3596 newAuthInfo->iAuthPref = EBasic; |
|
3597 } |
|
3598 else if ( aObject.Match( KNSmlDMAuthPrefMD5 ) != KErrNotFound ) |
|
3599 { |
|
3600 newAuthInfo->iAuthPref = EMD5; |
|
3601 } |
|
3602 newAuthInfo->iServerNonce = authInfo->iServerNonce->Des().Alloc(); |
|
3603 newAuthInfo->iClientNonce = authInfo->iClientNonce->Des().Alloc(); |
|
3604 |
|
3605 iPrivateApi.SetDMAuthInfoL( *newAuthInfo ); |
|
3606 } |
|
3607 |
|
3608 CleanupStack::PopAndDestroy( newAuthInfo ); |
|
3609 CleanupStack::PopAndDestroy( authInfo ); |
|
3610 |
|
3611 iPrivateApi.Close(); |
|
3612 aStatus = KErrNone; |
|
3613 _DBG_FILE( "CNSmlDMSettingsAdapter12::SetAuthInfoL(): end" ); |
|
3614 return; |
|
3615 } |
|
3616 |
|
3617 //------------------------------------------------------------------------------ |
|
3618 // CNSmlDMSettingsAdapter12::AddNodeBufferL() |
|
3619 // Buffers Node Object |
|
3620 //------------------------------------------------------------------------------ |
|
3621 void CNSmlDMSettingsAdapter12::AddNodeBufferL( const TDesC8& aURI, |
|
3622 const TInt aStatusRef) |
|
3623 { |
|
3624 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddNodeBufferL(): begin" ); |
|
3625 TInt index = -1; |
|
3626 |
|
3627 for (TInt i = 0; i<iBuffer->Count (); i++) |
|
3628 { |
|
3629 if ( iBuffer->At(i).iMappingName->Compare (aURI)== 0) |
|
3630 { |
|
3631 index = i; |
|
3632 //CallBack for duplicate |
|
3633 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddNodeBufferL(): EAlreadyExists end" ); |
|
3634 iCallBack->SetStatusL ( aStatusRef, CSmlDmAdapter::EAlreadyExists); |
|
3635 break; |
|
3636 } |
|
3637 } |
|
3638 |
|
3639 if ( index<0) |
|
3640 { |
|
3641 TNSmlDMBufferElement newNode; |
|
3642 newNode.iMappingName = aURI.AllocLC (); |
|
3643 newNode.iLeafBuf = new (ELeave) CArrayFixFlat <TNSmlDMLeafElement> (4); |
|
3644 newNode.iExecuted = EFalse; |
|
3645 newNode.iDMBuffStatusref = aStatusRef; |
|
3646 newNode.iAddr = EFalse; |
|
3647 newNode.iServerId = EFalse; |
|
3648 newNode.iUName = EFalse; |
|
3649 newNode.iServerName = EFalse; |
|
3650 |
|
3651 iBuffer->AppendL (newNode); |
|
3652 //newNode.iMappingName |
|
3653 CleanupStack::Pop (); |
|
3654 } |
|
3655 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddNodeBufferL(): end" ); |
|
3656 } |
|
3657 |
|
3658 //------------------------------------------------------------------------------ |
|
3659 // CNSmlDMSettingsAdapter12::AddLeafBufferL() |
|
3660 // Buffers Leaf Obj & checks for Mandatory fields |
|
3661 //------------------------------------------------------------------------------ |
|
3662 void CNSmlDMSettingsAdapter12::AddLeafBufferL( const TDesC8& aURI, |
|
3663 const TDesC8& aObject, const TInt aStatusRef) |
|
3664 { |
|
3665 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddLeafBufferL(): begin" ); |
|
3666 TNSmlDMLeafElement newCommand; |
|
3667 |
|
3668 newCommand.iUri = aURI.AllocLC (); |
|
3669 newCommand.iData = aObject.AllocLC (); |
|
3670 newCommand.iLuid = HBufC8::NewLC (8); //Allocate Mem. for iLUID |
|
3671 newCommand.iStatusRef = aStatusRef; |
|
3672 //Add Leaf to the index updated by UpdateLeafObj |
|
3673 iBuffer->At(iExecutionIndex).iLeafBuf->AppendL (newCommand); |
|
3674 // iUri, iData, ILuid |
|
3675 CleanupStack::Pop (3); |
|
3676 SetField ( aURI); |
|
3677 SetURIInProcessL ( aURI); |
|
3678 if ( iField->Compare (KNSmlDdfAddr)== 0) |
|
3679 { |
|
3680 iBuffer->At(iExecutionIndex).iAddr = ETrue; |
|
3681 } |
|
3682 else |
|
3683 if ( iField->Compare (KNSmlDdfServerId)== 0) |
|
3684 { |
|
3685 if(!IsServerIDExistL(aObject)) |
|
3686 iBuffer->At(iExecutionIndex).iServerId = ETrue; |
|
3687 } |
|
3688 else |
|
3689 if ( iField->Compare (KNSmlDdfAAuthName)== 0) |
|
3690 { |
|
3691 //AAuthName under AppAuthCli |
|
3692 if ( iURIField->Find (KDmAccAppAuthDyn2)!= KErrNotFound) |
|
3693 iBuffer->At(iExecutionIndex).iUName = ETrue; |
|
3694 } |
|
3695 else |
|
3696 if ( iField->Compare (KNSmlDdfName)== 0) |
|
3697 { |
|
3698 iBuffer->At(iExecutionIndex).iServerName = ETrue; |
|
3699 } |
|
3700 |
|
3701 // If Address,ServerId,ServerName,UserName then Add |
|
3702 |
|
3703 if ( iBuffer->At(iExecutionIndex).iAddr && iBuffer->At(iExecutionIndex).iServerId &&iBuffer->At(iExecutionIndex).iUName && iBuffer->At(iExecutionIndex).iServerName) |
|
3704 { |
|
3705 ExecuteBufferL (); |
|
3706 iExecutionIndex = -1; |
|
3707 } |
|
3708 _DBG_FILE( "CNSmlDMSettingsAdapter12::AddLeafBufferL(): end" ); |
|
3709 return; |
|
3710 } |
|
3711 |
|
3712 //------------------------------------------------------------------------------ |
|
3713 // CNSmlDMSettingsAdapter12::ExecuteBufferL() |
|
3714 // Adds the Node/Leaf obj to the db |
|
3715 //------------------------------------------------------------------------------ |
|
3716 void CNSmlDMSettingsAdapter12::ExecuteBufferL() |
|
3717 { |
|
3718 _DBG_FILE( "CNSmlDMSettingsAdapter12::ExecuteBufferL(): begin" ); |
|
3719 TBuf8<8> newLUID; |
|
3720 TInt rValue; |
|
3721 //Buffer is being Executed |
|
3722 iBufOn = ETrue; |
|
3723 |
|
3724 // Robustness check for Execution Index |
|
3725 if ( iExecutionIndex<0) |
|
3726 { |
|
3727 return; |
|
3728 } |
|
3729 |
|
3730 //Execute BufferL is called from CompleteOutstandingCmdsL only when - |
|
3731 //mandatory fields are not set. Dont update Node/Leaf to the db, return a failure |
|
3732 |
|
3733 if ( !iComplete) |
|
3734 rValue = CreateNewProfileL (iLUID); |
|
3735 else |
|
3736 rValue = CSmlDmAdapter::EError; |
|
3737 |
|
3738 iBuffer->At(iExecutionIndex).iExecuted = ETrue; |
|
3739 |
|
3740 if ( rValue != KErrNone) |
|
3741 { |
|
3742 if ( rValue == KErrNoMemory) |
|
3743 { |
|
3744 iCallBack->SetStatusL ( iBuffer->At(iExecutionIndex).iDMBuffStatusref, CSmlDmAdapter::ENoMemory); |
|
3745 } |
|
3746 else |
|
3747 if ( rValue == KErrNotSupported) |
|
3748 { |
|
3749 iCallBack->SetStatusL ( iBuffer->At(iExecutionIndex).iDMBuffStatusref, |
|
3750 CSmlDmAdapter::EInvalidObject); |
|
3751 } |
|
3752 else |
|
3753 if ( rValue == KErrInUse) |
|
3754 { |
|
3755 iCallBack->SetStatusL ( iBuffer->At(iExecutionIndex).iDMBuffStatusref, |
|
3756 CSmlDmAdapter::EObjectInUse); |
|
3757 } |
|
3758 else |
|
3759 if ( rValue == KErrDiskFull) |
|
3760 { |
|
3761 iCallBack->SetStatusL ( iBuffer->At(iExecutionIndex).iDMBuffStatusref, |
|
3762 CSmlDmAdapter::EDiskFull); |
|
3763 } |
|
3764 else |
|
3765 { |
|
3766 iCallBack->SetStatusL ( iBuffer->At(iExecutionIndex).iDMBuffStatusref, |
|
3767 CSmlDmAdapter::EError); |
|
3768 } |
|
3769 // dont return, UpdateLeafObjectL will update the callback status for leaf Nodes |
|
3770 } |
|
3771 else |
|
3772 { |
|
3773 if ( iLUID >= KMaxDataSyncID) |
|
3774 { |
|
3775 newLUID.Num ( iLUID - KMaxDataSyncID); |
|
3776 } |
|
3777 else |
|
3778 { |
|
3779 newLUID.Num ( iLUID); |
|
3780 } |
|
3781 |
|
3782 iCallBack->SetMappingL ( *iBuffer->At(iExecutionIndex).iMappingName, newLUID); |
|
3783 |
|
3784 iCallBack->SetStatusL (iBuffer->At(iExecutionIndex).iDMBuffStatusref, CSmlDmAdapter::EOk); |
|
3785 } |
|
3786 |
|
3787 for (TInt val= 0; val < iBuffer->At(iExecutionIndex).iLeafBuf->Count ();val++) |
|
3788 { |
|
3789 //Update the LUID data in the Leaf structure with the Profile LUID before calling UpdateLeafObj |
|
3790 TPtr8 tempLUID(iBuffer->At(iExecutionIndex).iLeafBuf->At(val).iLuid->Des ()); |
|
3791 tempLUID.Append (newLUID); |
|
3792 UpdateLeafObjectL (*iBuffer->At(iExecutionIndex).iLeafBuf->At(val).iUri, *iBuffer->At(iExecutionIndex).iLeafBuf->At(val).iLuid, *iBuffer->At(iExecutionIndex).iLeafBuf->At(val).iData, *iBuffer->At(iExecutionIndex).iMappingName, iBuffer->At(iExecutionIndex).iLeafBuf->At(val).iStatusRef); |
|
3793 |
|
3794 } |
|
3795 |
|
3796 // Delete the dynamically allocated buffers (Node/Leaf obj) |
|
3797 |
|
3798 ClearBuffer ( iBuffer->At(iExecutionIndex).iLeafBuf); |
|
3799 |
|
3800 delete iBuffer->At(iExecutionIndex).iLeafBuf; |
|
3801 |
|
3802 if ( iBuffer->At(iExecutionIndex).iMappingName) |
|
3803 { |
|
3804 delete iBuffer->At(iExecutionIndex).iMappingName; |
|
3805 iBuffer->At(iExecutionIndex).iMappingName = NULL; |
|
3806 } |
|
3807 |
|
3808 iBuffer->Delete (iExecutionIndex); |
|
3809 iBuffer->Compress (); |
|
3810 //Buffer Execution Complete |
|
3811 iBufOn = EFalse; |
|
3812 _DBG_FILE( "CNSmlDMSettingsAdapter12::ExecuteBufferL(): end" ); |
|
3813 } |
|
3814 |
|
3815 //------------------------------------------------------------------------------ |
|
3816 // TPtrC8 CNSmlDMSettingsAdapter12::ParentURI(const TDesC8& aURI) |
|
3817 // returns parent uri |
|
3818 // Searches till the 2nd "/" is reached |
|
3819 //------------------------------------------------------------------------------ |
|
3820 TPtrC8 CNSmlDMSettingsAdapter12::ParentURI(const TDesC8& aURI) |
|
3821 { |
|
3822 _DBG_FILE( "CNSmlDMSettingsAdapter12::ParentURI(): begin" ); |
|
3823 TInt count; |
|
3824 TInt flag = 0; |
|
3825 for (count=0; count<=aURI.Length ()-1;count++) |
|
3826 { |
|
3827 |
|
3828 if ( aURI[count]=='/') |
|
3829 { |
|
3830 flag++; |
|
3831 if ( flag == KDynNodePosn) // KDynNodePosn =2 --> DMAcc/DMIDxxx |
|
3832 break; |
|
3833 } |
|
3834 } |
|
3835 _DBG_FILE( "CNSmlDMSettingsAdapter12::ParentURI(): end" ); |
|
3836 return aURI.Left (count); |
|
3837 } |
|
3838 |
|
3839 //----------------------------------------------------------------------------------------- |
|
3840 // Clears the elements of the passed in LeafElement Structure |
|
3841 //----------------------------------------------------------------------------------------- |
|
3842 void CNSmlDMSettingsAdapter12::ClearBuffer( |
|
3843 CArrayFixFlat<TNSmlDMLeafElement>* aBuffer) |
|
3844 { |
|
3845 _DBG_FILE( "CNSmlDMSettingsAdapter12::ClearBuffer(): begin" ); |
|
3846 for (TInt i = 0; i < aBuffer->Count (); i++) |
|
3847 { |
|
3848 delete aBuffer->At(i).iUri; |
|
3849 aBuffer->At(i).iUri = NULL; |
|
3850 |
|
3851 delete aBuffer->At(i).iData; |
|
3852 aBuffer->At(i).iData = NULL; |
|
3853 |
|
3854 delete aBuffer->At(i).iLuid; |
|
3855 aBuffer->At(i).iLuid = NULL; |
|
3856 } |
|
3857 |
|
3858 aBuffer->Reset (); |
|
3859 _DBG_FILE( "CNSmlDMSettingsAdapter12::ClearBuffer(): end" ); |
|
3860 } |
|
3861 |
|
3862 //-------------------------------------------------------------------- |
|
3863 //TInt CNSmlDMSettingsAdapter::IsDMAccUriFormatMatchPredefined(const TDesC8 & aURI) |
|
3864 // |
|
3865 //------------------------------------------------------------------- |
|
3866 |
|
3867 |
|
3868 TBool CNSmlDMSettingsAdapter12::IsDMAccUriFormatMatchPredefined(const TDesC8 & aURI) |
|
3869 { |
|
3870 |
|
3871 // include strings for tree for Bearer , DNS related Dynamic nodes . |
|
3872 |
|
3873 if(aURI.Match(_L8("DMAcc/DMId*")) != KErrNotFound ) |
|
3874 { |
|
3875 return ETrue; |
|
3876 } |
|
3877 else |
|
3878 { |
|
3879 return EFalse; |
|
3880 } |
|
3881 |
|
3882 |
|
3883 } |
|
3884 |
|
3885 //-------------------------------------------------------------------- |
|
3886 //TInt CNSmlDMSettingsAdapter::ConstructTreeL(const TDesC8& aURI) |
|
3887 // |
|
3888 //------------------------------------------------------------------- |
|
3889 |
|
3890 TInt CNSmlDMSettingsAdapter12::ConstructTreeL(const TDesC8& aURI) |
|
3891 { |
|
3892 TInt profileID = KErrNotFound; |
|
3893 if( iSyncSessionOpen == EFalse ) |
|
3894 { |
|
3895 iSyncSession.OpenL(); |
|
3896 iSyncSessionOpen = ETrue; |
|
3897 } |
|
3898 RArray<TSmlProfileId> profileIdArray; |
|
3899 CleanupClosePushL( profileIdArray ); |
|
3900 TSmlUsageType usageType = ESmlDevMan; |
|
3901 iSyncSession.ListProfilesL( profileIdArray, usageType ); |
|
3902 |
|
3903 for( TInt p = 0; p < profileIdArray.Count(); p++ ) |
|
3904 { |
|
3905 TInt ddId = profileIdArray[p] - KMaxDataSyncID; |
|
3906 |
|
3907 _LIT8( Kprev, "DMId" ); |
|
3908 TBuf8<7> addNAME(Kprev); // DMIdnnn , nnn = profileid |
|
3909 TInt fixedProfId = profileIdArray[p] - KMaxDataSyncID; //fit to 3 decimal |
|
3910 addNAME.AppendNumFixedWidth( fixedProfId, EDecimal, 3 ); |
|
3911 DBG_ARGS8( _S8("notInList: Id = %d Name %S"), p, &addNAME ); |
|
3912 // KNSmlDMStart includes start text for URISeg |
|
3913 TBuf8<20> addURI; // DMAcc/DMIdnnn , nnn = profileid |
|
3914 addURI.Append( KNSmlDMStart ); |
|
3915 addURI.AppendNumFixedWidth( fixedProfId, EDecimal, 3 ); |
|
3916 TBuf8<3> addLUID; |
|
3917 addLUID.Num( fixedProfId ); |
|
3918 |
|
3919 HBufC8* mapInfo = iCallBack->GetLuidAllocL(addURI); |
|
3920 |
|
3921 if (mapInfo->Length() == 0) |
|
3922 { |
|
3923 iCallBack->SetMappingL(addURI,addLUID); |
|
3924 if( aURI.Find(addURI) >= 0 ) |
|
3925 { |
|
3926 profileID = fixedProfId; |
|
3927 } |
|
3928 } |
|
3929 else |
|
3930 { |
|
3931 delete mapInfo; |
|
3932 } |
|
3933 } |
|
3934 |
|
3935 CleanupStack::PopAndDestroy( 1 );//profileIdArray |
|
3936 return profileID; |
|
3937 } |
|
3938 |
|
3939 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
3940 |
|
3941 #ifndef IMPLEMENTATION_PROXY_ENTRY |
|
3942 #define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr) {{aUid},(aFuncPtr)} |
|
3943 #endif |
|
3944 |
|
3945 const TImplementationProxy ImplementationTable[] = |
|
3946 { |
|
3947 IMPLEMENTATION_PROXY_ENTRY( KNSmlDMSettingsAdapterImplUid, CNSmlDMSettingsAdapter12::NewL ) |
|
3948 }; |
|
3949 |
|
3950 |
|
3951 // ----------------------------------------------------------------------------- |
|
3952 // TImplementationProxy* ImplementationGroupProxy() |
|
3953 // ----------------------------------------------------------------------------- |
|
3954 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
3955 { |
|
3956 _DBG_FILE( "ImplementationGroupProxy() for CNSmlDMSettingsAdapter: begin" ); |
|
3957 |
|
3958 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
3959 |
|
3960 _DBG_FILE( "ImplementationGroupProxy() for CNSmlDMSettingsAdapter: end" ); |
|
3961 return ImplementationTable; |
|
3962 } |
|
3963 |
|
3964 // End of File |
|
3965 |