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