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