|
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: Client module of DS Host Servers |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // ------------------------------------------------------------------------------------------------ |
|
20 // Includes |
|
21 // ------------------------------------------------------------------------------------------------ |
|
22 #include <s32mem.h> |
|
23 #include <SmlDataProvider.h> |
|
24 |
|
25 #include "nsmldshostclient.h" |
|
26 #include "nsmldshostconstants.h" |
|
27 |
|
28 #ifdef __USE_FAKE_CLIENT__ |
|
29 #include "fakeclient.cpp" |
|
30 #else |
|
31 |
|
32 // ------------------------------------------------------------------------------------------------ |
|
33 // CNSmlDSHostClient - public methods |
|
34 // ------------------------------------------------------------------------------------------------ |
|
35 // ------------------------------------------------------------------------------------------------ |
|
36 // CNSmlDSHostClient::NewL |
|
37 // Creates new instance of CNSmlDSHostClient based class. |
|
38 // ------------------------------------------------------------------------------------------------ |
|
39 EXPORT_C CNSmlDSHostClient* CNSmlDSHostClient::NewL() |
|
40 { |
|
41 CNSmlDSHostClient* self = NewLC(); |
|
42 CleanupStack::Pop(); |
|
43 return self; |
|
44 } |
|
45 |
|
46 // ------------------------------------------------------------------------------------------------ |
|
47 // CNSmlDSHostClient::NewLC |
|
48 // Creates new instance of CNSmlDSHostClient based class. |
|
49 // ------------------------------------------------------------------------------------------------ |
|
50 EXPORT_C CNSmlDSHostClient* CNSmlDSHostClient::NewLC() |
|
51 { |
|
52 CNSmlDSHostClient* self = new (ELeave) CNSmlDSHostClient(); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ------------------------------------------------------------------------------------------------ |
|
59 // CNSmlDSHostClient::~CNSmlDSHostClient |
|
60 // C++ Destructor. |
|
61 // ------------------------------------------------------------------------------------------------ |
|
62 EXPORT_C CNSmlDSHostClient::~CNSmlDSHostClient() |
|
63 { |
|
64 iClient1.Close(); |
|
65 iClient2.Close(); |
|
66 iDataProviders1.Close(); |
|
67 iDataProviders2.Close(); |
|
68 } |
|
69 |
|
70 // ------------------------------------------------------------------------------------------------ |
|
71 // CNSmlDSHostClient::CreateDataProvidersL |
|
72 // Creates Data Providers. |
|
73 // ------------------------------------------------------------------------------------------------ |
|
74 EXPORT_C void CNSmlDSHostClient::CreateDataProvidersL( const RArray<TSmlDataProviderId>& aIds, RArray<TInt>& aResultArray ) |
|
75 { |
|
76 RArray<TSmlDataProviderId> tempIdsArray; |
|
77 CleanupClosePushL( tempIdsArray ); |
|
78 RArray<TInt> tempResultArray; |
|
79 CleanupClosePushL( tempResultArray ); |
|
80 |
|
81 // Find Data Providers from Host Server 2 |
|
82 iClient2.CreateDataProvidersL( aIds, aResultArray ); |
|
83 if ( aIds.Count() != aResultArray.Count() ) |
|
84 { |
|
85 User::Leave( KErrUnknown ); |
|
86 } |
|
87 for ( TInt i = 0; i < aIds.Count(); i++ ) |
|
88 { |
|
89 if ( aResultArray[ i ] != KErrNone ) |
|
90 { |
|
91 tempIdsArray.AppendL( aIds[ i ] ); |
|
92 } |
|
93 else |
|
94 { |
|
95 // Add succesfully loaded Data Providers to client array |
|
96 iDataProviders2.AppendL( aIds[ i ] ); |
|
97 } |
|
98 } |
|
99 |
|
100 // Find Data Providers from Host Server 1 |
|
101 if ( tempIdsArray.Count() > 0) |
|
102 { |
|
103 iClient1.CreateDataProvidersL( tempIdsArray, tempResultArray ); |
|
104 if ( tempIdsArray.Count() != tempResultArray.Count() ) |
|
105 { |
|
106 User::Leave( KErrUnknown ); |
|
107 } |
|
108 for ( TInt j = 0; j < tempIdsArray.Count(); j++ ) |
|
109 { |
|
110 for ( TInt k = 0; k < aIds.Count(); k++ ) |
|
111 { |
|
112 if ( aIds[ k ] == tempIdsArray[ j ] ) |
|
113 { |
|
114 aResultArray[ k ] = tempResultArray[ j ]; |
|
115 } |
|
116 } |
|
117 if ( tempResultArray[ j ] == KErrNone ) |
|
118 { |
|
119 // Add succesfully loaded Data Providers to client array |
|
120 iDataProviders1.AppendL( tempIdsArray[ j ] ); |
|
121 } |
|
122 } |
|
123 } |
|
124 CleanupStack::PopAndDestroy(2); //tempResultArray, tempIdsArray |
|
125 } |
|
126 |
|
127 // ------------------------------------------------------------------------------------------------ |
|
128 // CNSmlDSHostClient::CreateAllDataProvidersL |
|
129 // Creates all possible Data Providers. |
|
130 // ------------------------------------------------------------------------------------------------ |
|
131 EXPORT_C void CNSmlDSHostClient::CreateAllDataProvidersL( RArray<TSmlDataProviderId>& aIds ) |
|
132 { |
|
133 // Find Data Providers from Host server 2 |
|
134 // Find Data Providers from Host server 1 except those Data Providers that were found from |
|
135 // previous server |
|
136 RArray<TSmlDataProviderId> tmpArray; |
|
137 CleanupClosePushL( tmpArray ); |
|
138 |
|
139 iClient2.CreateAllDataProvidersL( aIds, tmpArray ); |
|
140 iDataProviders2.Reset(); |
|
141 |
|
142 for ( TInt i = 0; i < aIds.Count(); i++ ) |
|
143 { |
|
144 iDataProviders2.AppendL( aIds[ i ] ); |
|
145 } |
|
146 |
|
147 iClient1.CreateAllDataProvidersL( tmpArray, aIds ); |
|
148 iDataProviders1.Reset(); |
|
149 |
|
150 for ( TInt i = 0; i < tmpArray.Count(); i++ ) |
|
151 { |
|
152 iDataProviders1.AppendL( tmpArray[i] ); |
|
153 aIds.AppendL( tmpArray[i] ); |
|
154 } |
|
155 |
|
156 CleanupStack::PopAndDestroy(); //tmpArray |
|
157 } |
|
158 |
|
159 // ------------------------------------------------------------------------------------------------ |
|
160 // CNSmlDSHostClient::DataProviderInformationL |
|
161 // |
|
162 // ------------------------------------------------------------------------------------------------ |
|
163 EXPORT_C TNSmlDPInformation* CNSmlDSHostClient::DataProviderInformationL( const TSmlDataProviderId aId, TInt& aResultCode ) const |
|
164 { |
|
165 TNSmlDPInformation* ret = NULL; |
|
166 |
|
167 switch( SessionForDataProvider( aId ) ) |
|
168 { |
|
169 case ( ENSmlHostServer1 ): |
|
170 ret = iClient1.DataProviderInformationL( aId, aResultCode ); |
|
171 break; |
|
172 case ( ENSmlHostServer2 ): |
|
173 ret = iClient2.DataProviderInformationL( aId, aResultCode ); |
|
174 break; |
|
175 case ( ENSmlHostServerEnd ): |
|
176 default: |
|
177 User::Leave( KErrNotFound ); |
|
178 } |
|
179 aResultCode = HostErrorConversion( aResultCode ); |
|
180 return ret; |
|
181 } |
|
182 |
|
183 // ------------------------------------------------------------------------------------------------ |
|
184 // CNSmlDSHostClient::SupportsOperationL |
|
185 // Asks if Data Provider supports some operation. |
|
186 // ------------------------------------------------------------------------------------------------ |
|
187 EXPORT_C TBool CNSmlDSHostClient::SupportsOperationL( TUid aOpId, TSmlDataProviderId aId, TInt& aResultCode ) const |
|
188 { |
|
189 TBool ret( EFalse ); |
|
190 |
|
191 switch( SessionForDataProvider( aId ) ) |
|
192 { |
|
193 case ( ENSmlHostServer1 ): |
|
194 ret = iClient1.SupportsOperationL( aOpId, aId, aResultCode ); |
|
195 break; |
|
196 case ( ENSmlHostServer2 ): |
|
197 ret = iClient2.SupportsOperationL( aOpId, aId, aResultCode ); |
|
198 break; |
|
199 case ( ENSmlHostServerEnd ): |
|
200 default: |
|
201 User::Leave( KErrNotFound ); |
|
202 } |
|
203 aResultCode = HostErrorConversion( aResultCode ); |
|
204 return ret; |
|
205 } |
|
206 |
|
207 // ------------------------------------------------------------------------------------------------ |
|
208 // CNSmlDSHostClient::StoreFormatL |
|
209 // Creates Data Store format of Data Provider. |
|
210 // ------------------------------------------------------------------------------------------------ |
|
211 EXPORT_C CNSmlDbCaps* CNSmlDSHostClient::StoreFormatL( const TSmlDataProviderId aId, TInt& aResultCode ) |
|
212 { |
|
213 CNSmlDbCaps* ret = NULL; |
|
214 |
|
215 switch( SessionForDataProvider( aId ) ) |
|
216 { |
|
217 case ( ENSmlHostServer1 ): |
|
218 ret = iClient1.StoreFormatL( aId, aResultCode ); |
|
219 break; |
|
220 case ( ENSmlHostServer2 ): |
|
221 ret = iClient2.StoreFormatL( aId, aResultCode ); |
|
222 break; |
|
223 case ( ENSmlHostServerEnd ): |
|
224 default: |
|
225 User::Leave( KErrNotFound ); |
|
226 } |
|
227 aResultCode = HostErrorConversion( aResultCode ); |
|
228 return ret; |
|
229 } |
|
230 |
|
231 // ------------------------------------------------------------------------------------------------ |
|
232 // CNSmlDSHostClient::ListStoresL |
|
233 // Creates list of Data Store names of Data Provider. |
|
234 // ------------------------------------------------------------------------------------------------ |
|
235 EXPORT_C void CNSmlDSHostClient::ListStoresL( CDesCArray* aNameList, const TSmlDataProviderId aId, TInt& aResultCode ) |
|
236 { |
|
237 switch( SessionForDataProvider( aId ) ) |
|
238 { |
|
239 case ( ENSmlHostServer1 ): |
|
240 iClient1.ListStoresL( aNameList, aId, aResultCode ); |
|
241 break; |
|
242 case ( ENSmlHostServer2 ): |
|
243 iClient2.ListStoresL( aNameList, aId, aResultCode ); |
|
244 break; |
|
245 case ( ENSmlHostServerEnd ): |
|
246 default: |
|
247 User::Leave( KErrNotFound ); |
|
248 } |
|
249 aResultCode = HostErrorConversion( aResultCode ); |
|
250 } |
|
251 |
|
252 // ------------------------------------------------------------------------------------------------ |
|
253 // CNSmlDSHostClient::DefaultStoreL |
|
254 // Creates default name for Data Store of Data Provider. |
|
255 // ------------------------------------------------------------------------------------------------ |
|
256 EXPORT_C HBufC* CNSmlDSHostClient::DefaultStoreL( const TSmlDataProviderId aId, TInt& aResultCode ) |
|
257 { |
|
258 HBufC* ret = NULL; |
|
259 |
|
260 switch( SessionForDataProvider( aId ) ) |
|
261 { |
|
262 case ( ENSmlHostServer1 ): |
|
263 ret = iClient1.DefaultStoreL( aId, aResultCode ); |
|
264 break; |
|
265 case ( ENSmlHostServer2 ): |
|
266 ret = iClient2.DefaultStoreL( aId, aResultCode ); |
|
267 break; |
|
268 case ( ENSmlHostServerEnd ): |
|
269 default: |
|
270 User::Leave( KErrNotFound ); |
|
271 } |
|
272 aResultCode = HostErrorConversion( aResultCode ); |
|
273 return ret; |
|
274 } |
|
275 |
|
276 // ------------------------------------------------------------------------------------------------ |
|
277 // CNSmlDSHostClient::SupportedServerFiltersL |
|
278 // This method returns the set of filters that can be used to send to the Sync Partner. |
|
279 // ------------------------------------------------------------------------------------------------ |
|
280 EXPORT_C RPointerArray<CSyncMLFilter>* CNSmlDSHostClient::SupportedServerFiltersL( const TSmlDataProviderId aId, |
|
281 TSyncMLFilterMatchType& aMatchType, TSyncMLFilterChangeInfo& aChangeInfo, TInt& aResultCode ) const |
|
282 { |
|
283 RPointerArray<CSyncMLFilter>* result = NULL; |
|
284 switch( SessionForDataProvider( aId ) ) |
|
285 { |
|
286 case ( ENSmlHostServer1 ): |
|
287 result = iClient1.SupportedServerFiltersL( aId, aMatchType, aChangeInfo, aResultCode ); |
|
288 break; |
|
289 case ( ENSmlHostServer2 ): |
|
290 result = iClient2.SupportedServerFiltersL( aId, aMatchType, aChangeInfo, aResultCode ); |
|
291 break; |
|
292 case ( ENSmlHostServerEnd ): |
|
293 default: |
|
294 User::Leave( KErrNotFound ); |
|
295 } |
|
296 |
|
297 aResultCode = HostErrorConversion( aResultCode ); |
|
298 |
|
299 return result; |
|
300 } |
|
301 |
|
302 // ------------------------------------------------------------------------------------------------ |
|
303 // CNSmlDSHostClient::CheckServerFiltersL |
|
304 // This method updates dynamic filters up-to-date. |
|
305 // ------------------------------------------------------------------------------------------------ |
|
306 EXPORT_C void CNSmlDSHostClient::CheckServerFiltersL( const TSmlDataProviderId aId, RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterChangeInfo& aChangeInfo, TInt& aResultCode ) const |
|
307 { |
|
308 switch( SessionForDataProvider( aId ) ) |
|
309 { |
|
310 case ( ENSmlHostServer1 ): |
|
311 iClient1.CheckServerFiltersL( aId, aFilters, aChangeInfo, aResultCode ); |
|
312 break; |
|
313 case ( ENSmlHostServer2 ): |
|
314 iClient2.CheckServerFiltersL( aId, aFilters, aChangeInfo, aResultCode ); |
|
315 break; |
|
316 case ( ENSmlHostServerEnd ): |
|
317 default: |
|
318 User::Leave( KErrNotFound ); |
|
319 } |
|
320 |
|
321 aResultCode = HostErrorConversion( aResultCode ); |
|
322 } |
|
323 |
|
324 // ------------------------------------------------------------------------------------------------ |
|
325 // CNSmlDSHostClient::CheckSupportedServerFiltersL |
|
326 // This method returns the set of filters that can be used to send to the Sync Partner. |
|
327 // ------------------------------------------------------------------------------------------------ |
|
328 EXPORT_C void CNSmlDSHostClient::CheckSupportedServerFiltersL( const TSmlDataProviderId aId, |
|
329 const CNSmlDbCaps& aServerDataStoreFormat, const CArrayFix<TNSmlFilterCapData>& aFilterInfoArr, |
|
330 RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterChangeInfo& aChangeInfo, TInt& aResultCode ) const |
|
331 { |
|
332 switch( SessionForDataProvider( aId ) ) |
|
333 { |
|
334 case ( ENSmlHostServer1 ): |
|
335 iClient1.CheckSupportedServerFiltersL( aId, aServerDataStoreFormat, aFilterInfoArr, aFilters, aChangeInfo, aResultCode ); |
|
336 break; |
|
337 case ( ENSmlHostServer2 ): |
|
338 iClient2.CheckSupportedServerFiltersL( aId, aServerDataStoreFormat, aFilterInfoArr, aFilters, aChangeInfo, aResultCode ); |
|
339 break; |
|
340 case ( ENSmlHostServerEnd ): |
|
341 default: |
|
342 User::Leave( KErrNotFound ); |
|
343 } |
|
344 |
|
345 aResultCode = HostErrorConversion( aResultCode ); |
|
346 } |
|
347 |
|
348 // ------------------------------------------------------------------------------------------------ |
|
349 // CNSmlDSHostClient::GetFilterL |
|
350 // Get Filters. |
|
351 // ------------------------------------------------------------------------------------------------ |
|
352 EXPORT_C void CNSmlDSHostClient::GetFilterL( const TSmlDataProviderId aId, const TDesC& aStoreName, |
|
353 const RPointerArray<CSyncMLFilter>& aFilterArray, CNSmlFilter*& aFilter, |
|
354 TSyncMLFilterMatchType aMatchType, TInt& aResultCode ) |
|
355 { |
|
356 switch( SessionForDataProvider( aId ) ) |
|
357 { |
|
358 case ( ENSmlHostServer1 ): |
|
359 iClient1.GetFilterL( aId, aStoreName, aFilterArray, aFilter, aMatchType, aResultCode ); |
|
360 break; |
|
361 case ( ENSmlHostServer2 ): |
|
362 iClient2.GetFilterL( aId, aStoreName, aFilterArray, aFilter, aMatchType, aResultCode ); |
|
363 break; |
|
364 case ( ENSmlHostServerEnd ): |
|
365 default: |
|
366 User::Leave( KErrNotFound ); |
|
367 } |
|
368 |
|
369 aResultCode = HostErrorConversion( aResultCode ); |
|
370 } |
|
371 |
|
372 // ------------------------------------------------------------------------------------------------ |
|
373 // CNSmlDSHostClient::OpenL |
|
374 // Opens the data store specified by aStoreName asynchronously. |
|
375 // ------------------------------------------------------------------------------------------------ |
|
376 EXPORT_C void CNSmlDSHostClient::OpenL( const TSmlDataProviderId aId, const TDesC& aStoreName, const TDesC& aServerId, const TDesC& aRemoteDB, TInt& aResultCode ) |
|
377 { |
|
378 switch( SessionForDataProvider( aId ) ) |
|
379 { |
|
380 case ( ENSmlHostServer1 ): |
|
381 iClient1.OpenL( aId, aStoreName, aServerId, aRemoteDB, aResultCode ); |
|
382 break; |
|
383 case ( ENSmlHostServer2 ): |
|
384 iClient2.OpenL( aId, aStoreName, aServerId, aRemoteDB, aResultCode ); |
|
385 break; |
|
386 case ( ENSmlHostServerEnd ): |
|
387 default: |
|
388 User::Leave( KErrNotFound ); |
|
389 } |
|
390 aResultCode = HostErrorConversion( aResultCode ); |
|
391 } |
|
392 |
|
393 // ------------------------------------------------------------------------------------------------ |
|
394 // CNSmlDSHostClient::CancelRequestL |
|
395 // Cancel the current asynchronous request. |
|
396 // ------------------------------------------------------------------------------------------------ |
|
397 EXPORT_C void CNSmlDSHostClient::CancelRequestL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
398 { |
|
399 switch( SessionForDataProvider( aId ) ) |
|
400 { |
|
401 case ( ENSmlHostServer1 ): |
|
402 iClient1.CancelRequest( aId, aStoreName, aResultCode ); |
|
403 break; |
|
404 case ( ENSmlHostServer2 ): |
|
405 iClient2.CancelRequest( aId, aStoreName, aResultCode ); |
|
406 break; |
|
407 case ( ENSmlHostServerEnd ): |
|
408 default: |
|
409 User::Leave( KErrNotFound ); |
|
410 } |
|
411 aResultCode = HostErrorConversion( aResultCode ); |
|
412 } |
|
413 |
|
414 // ------------------------------------------------------------------------------------------------ |
|
415 // CNSmlDSHostClient::BeginTransactionL |
|
416 // Starts the transaction mode. |
|
417 // ------------------------------------------------------------------------------------------------ |
|
418 EXPORT_C void CNSmlDSHostClient::BeginTransactionL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
419 { |
|
420 switch( SessionForDataProvider( aId ) ) |
|
421 { |
|
422 case ( ENSmlHostServer1 ): |
|
423 iClient1.BeginTransaction( aId, aStoreName, aResultCode ); |
|
424 break; |
|
425 case ( ENSmlHostServer2 ): |
|
426 iClient2.BeginTransaction( aId, aStoreName, aResultCode ); |
|
427 break; |
|
428 case ( ENSmlHostServerEnd ): |
|
429 default: |
|
430 User::Leave( KErrNotFound ); |
|
431 } |
|
432 |
|
433 aResultCode = HostErrorConversion( aResultCode ); |
|
434 } |
|
435 |
|
436 // ------------------------------------------------------------------------------------------------ |
|
437 // CNSmlDSHostClient::CommitTransactionL |
|
438 // Method will be called at the end of a successful transaction. |
|
439 // ------------------------------------------------------------------------------------------------ |
|
440 EXPORT_C void CNSmlDSHostClient::CommitTransactionL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
441 { |
|
442 switch( SessionForDataProvider( aId ) ) |
|
443 { |
|
444 case ( ENSmlHostServer1 ): |
|
445 iClient1.CommitTransaction( aId, aStoreName, aResultCode ); |
|
446 break; |
|
447 case ( ENSmlHostServer2 ): |
|
448 iClient2.CommitTransaction( aId, aStoreName, aResultCode ); |
|
449 break; |
|
450 case ( ENSmlHostServerEnd ): |
|
451 default: |
|
452 User::Leave( KErrNotFound ); |
|
453 } |
|
454 |
|
455 aResultCode = HostErrorConversion( aResultCode ); |
|
456 } |
|
457 |
|
458 // ------------------------------------------------------------------------------------------------ |
|
459 // CNSmlDSHostClient::RevertTransactionL |
|
460 // Method will be called to abort an ongoing transaction. |
|
461 // ------------------------------------------------------------------------------------------------ |
|
462 EXPORT_C void CNSmlDSHostClient::RevertTransactionL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
463 { |
|
464 switch( SessionForDataProvider( aId ) ) |
|
465 { |
|
466 case ( ENSmlHostServer1 ): |
|
467 iClient1.RevertTransaction( aId, aStoreName, aResultCode ); |
|
468 break; |
|
469 case ( ENSmlHostServer2 ): |
|
470 iClient2.RevertTransaction( aId, aStoreName, aResultCode ); |
|
471 break; |
|
472 case ( ENSmlHostServerEnd ): |
|
473 default: |
|
474 User::Leave( KErrNotFound ); |
|
475 } |
|
476 |
|
477 aResultCode = HostErrorConversion( aResultCode ); |
|
478 } |
|
479 |
|
480 // ------------------------------------------------------------------------------------------------ |
|
481 // CNSmlDSHostClient::BeginBatchL |
|
482 // Starts the batch mode. |
|
483 // ------------------------------------------------------------------------------------------------ |
|
484 EXPORT_C void CNSmlDSHostClient::BeginBatchL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
485 { |
|
486 switch( SessionForDataProvider( aId ) ) |
|
487 { |
|
488 case ( ENSmlHostServer1 ): |
|
489 iClient1.BeginBatch( aId, aStoreName, aResultCode ); |
|
490 break; |
|
491 case ( ENSmlHostServer2 ): |
|
492 iClient2.BeginBatch( aId, aStoreName, aResultCode ); |
|
493 break; |
|
494 case ( ENSmlHostServerEnd ): |
|
495 default: |
|
496 User::Leave( KErrNotFound ); |
|
497 } |
|
498 aResultCode = HostErrorConversion( aResultCode ); |
|
499 } |
|
500 |
|
501 // ------------------------------------------------------------------------------------------------ |
|
502 // CNSmlDSHostClient::CommitBatchL |
|
503 // Method will be called at the end of the batch mode. |
|
504 // ------------------------------------------------------------------------------------------------ |
|
505 EXPORT_C void CNSmlDSHostClient::CommitBatchL( RArray<TInt>& aResultArray, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
506 { |
|
507 switch( SessionForDataProvider( aId ) ) |
|
508 { |
|
509 case ( ENSmlHostServer1 ): |
|
510 iClient1.CommitBatchL( aResultArray, aId, aStoreName, aResultCode ); |
|
511 break; |
|
512 case ( ENSmlHostServer2 ): |
|
513 iClient2.CommitBatchL( aResultArray, aId, aStoreName, aResultCode ); |
|
514 break; |
|
515 case ( ENSmlHostServerEnd ): |
|
516 default: |
|
517 User::Leave( KErrNotFound ); |
|
518 } |
|
519 aResultCode = HostErrorConversion( aResultCode ); |
|
520 } |
|
521 |
|
522 // ------------------------------------------------------------------------------------------------ |
|
523 // CNSmlDSHostClient::CancelBatchL |
|
524 // Method will be called to abort an ongoing batch mode. |
|
525 // ------------------------------------------------------------------------------------------------ |
|
526 EXPORT_C void CNSmlDSHostClient::CancelBatchL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
527 { |
|
528 switch( SessionForDataProvider( aId ) ) |
|
529 { |
|
530 case ( ENSmlHostServer1 ): |
|
531 iClient1.CancelBatch( aId, aStoreName, aResultCode ); |
|
532 break; |
|
533 case ( ENSmlHostServer2 ): |
|
534 iClient2.CancelBatch( aId, aStoreName, aResultCode ); |
|
535 break; |
|
536 case ( ENSmlHostServerEnd ): |
|
537 default: |
|
538 User::Leave( KErrNotFound ); |
|
539 } |
|
540 aResultCode = HostErrorConversion( aResultCode ); |
|
541 } |
|
542 |
|
543 // ------------------------------------------------------------------------------------------------ |
|
544 // CNSmlDSHostClient::SetRemoteDataStoreFormatL |
|
545 // Sets the Sync Partner Data Format. |
|
546 // ------------------------------------------------------------------------------------------------ |
|
547 EXPORT_C void CNSmlDSHostClient::SetRemoteDataStoreFormatL( const CNSmlDbCaps& aServerDataStoreFormat, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
548 { |
|
549 switch( SessionForDataProvider( aId ) ) |
|
550 { |
|
551 case ( ENSmlHostServer1 ): |
|
552 iClient1.SetRemoteDataStoreFormatL( aServerDataStoreFormat, aId, aStoreName, aResultCode ); |
|
553 break; |
|
554 case ( ENSmlHostServer2 ): |
|
555 iClient2.SetRemoteDataStoreFormatL( aServerDataStoreFormat, aId, aStoreName, aResultCode ); |
|
556 break; |
|
557 case ( ENSmlHostServerEnd ): |
|
558 default: |
|
559 User::Leave( KErrNotFound ); |
|
560 } |
|
561 aResultCode = HostErrorConversion( aResultCode ); |
|
562 } |
|
563 |
|
564 // ------------------------------------------------------------------------------------------------ |
|
565 // CNSmlDSHostClient::SetRemoteMaxObjectSizeL |
|
566 // Sets the SyncML server Sync Partner maximum object size. |
|
567 // ------------------------------------------------------------------------------------------------ |
|
568 EXPORT_C void CNSmlDSHostClient::SetRemoteMaxObjectSizeL( TInt aServerMaxObjectSize, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
569 { |
|
570 switch( SessionForDataProvider( aId ) ) |
|
571 { |
|
572 case ( ENSmlHostServer1 ): |
|
573 iClient1.SetRemoteMaxObjectSizeL( aServerMaxObjectSize, aId, aStoreName, aResultCode ); |
|
574 break; |
|
575 case ( ENSmlHostServer2 ): |
|
576 iClient2.SetRemoteMaxObjectSizeL( aServerMaxObjectSize, aId, aStoreName, aResultCode ); |
|
577 break; |
|
578 case ( ENSmlHostServerEnd ): |
|
579 default: |
|
580 User::Leave( KErrNotFound ); |
|
581 } |
|
582 aResultCode = HostErrorConversion( aResultCode ); |
|
583 } |
|
584 |
|
585 // ------------------------------------------------------------------------------------------------ |
|
586 // CNSmlDSHostClient::MaxObjectSizeL |
|
587 // Gets the Data Store maximum object size which is reported to the SyncML partner. |
|
588 // ------------------------------------------------------------------------------------------------ |
|
589 EXPORT_C TInt CNSmlDSHostClient::MaxObjectSizeL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) const |
|
590 { |
|
591 TInt ret(0); |
|
592 switch( SessionForDataProvider( aId ) ) |
|
593 { |
|
594 case ( ENSmlHostServer1 ): |
|
595 ret = iClient1.MaxObjectSize( aId, aStoreName, aResultCode ); |
|
596 break; |
|
597 case ( ENSmlHostServer2 ): |
|
598 ret = iClient2.MaxObjectSize( aId, aStoreName, aResultCode ); |
|
599 break; |
|
600 case ( ENSmlHostServerEnd ): |
|
601 default: |
|
602 User::Leave( KErrNotFound ); |
|
603 } |
|
604 |
|
605 aResultCode = HostErrorConversion( aResultCode ); |
|
606 return ret; |
|
607 } |
|
608 |
|
609 // ------------------------------------------------------------------------------------------------ |
|
610 // CNSmlDSHostClient::OpenItemL |
|
611 // Opens item at Data Store. |
|
612 // ------------------------------------------------------------------------------------------------ |
|
613 EXPORT_C void CNSmlDSHostClient::OpenItemL( TSmlDbItemUid aUid, TBool& aFieldChange, TInt& aSize, TSmlDbItemUid& aParent, HBufC8*& aMimeType, HBufC8*& aMimeVer, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
614 { |
|
615 switch( SessionForDataProvider( aId ) ) |
|
616 { |
|
617 case ( ENSmlHostServer1 ): |
|
618 iClient1.OpenItemL( aUid, aFieldChange, aSize, aParent, aMimeType, aMimeVer, aId, aStoreName, aResultCode ); |
|
619 break; |
|
620 case ( ENSmlHostServer2 ): |
|
621 iClient2.OpenItemL( aUid, aFieldChange, aSize, aParent, aMimeType, aMimeVer, aId, aStoreName, aResultCode ); |
|
622 break; |
|
623 case ( ENSmlHostServerEnd ): |
|
624 default: |
|
625 User::Leave( KErrNotFound ); |
|
626 } |
|
627 aResultCode = HostErrorConversion( aResultCode ); |
|
628 } |
|
629 |
|
630 // ------------------------------------------------------------------------------------------------ |
|
631 // CNSmlDSHostClient::CreateItemL |
|
632 // Creates new item to Data Store. |
|
633 // ------------------------------------------------------------------------------------------------ |
|
634 EXPORT_C void CNSmlDSHostClient::CreateItemL( TSmlDbItemUid& aUid, TInt aSize, TSmlDbItemUid aParent, const TDesC8& aMimeType, const TDesC8& aMimeVer, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
635 { |
|
636 switch( SessionForDataProvider( aId ) ) |
|
637 { |
|
638 case ( ENSmlHostServer1 ): |
|
639 iClient1.CreateItemL( aUid, aSize, aParent, aMimeType, aMimeVer, aId, aStoreName, aResultCode ); |
|
640 break; |
|
641 case ( ENSmlHostServer2 ): |
|
642 iClient2.CreateItemL( aUid, aSize, aParent, aMimeType, aMimeVer, aId, aStoreName, aResultCode ); |
|
643 break; |
|
644 case ( ENSmlHostServerEnd ): |
|
645 default: |
|
646 User::Leave( KErrNotFound ); |
|
647 } |
|
648 aResultCode = HostErrorConversion( aResultCode ); |
|
649 } |
|
650 |
|
651 // ------------------------------------------------------------------------------------------------ |
|
652 // CNSmlDSHostClient::ReplaceItemL |
|
653 // Replaces old item at Data Store. |
|
654 // ------------------------------------------------------------------------------------------------ |
|
655 EXPORT_C void CNSmlDSHostClient::ReplaceItemL( TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent, TBool aFieldChange, TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
656 { |
|
657 switch( SessionForDataProvider( aId ) ) |
|
658 { |
|
659 case ( ENSmlHostServer1 ): |
|
660 iClient1.ReplaceItemL( aUid, aSize, aParent, aFieldChange, aId, aStoreName, aResultCode ); |
|
661 break; |
|
662 case ( ENSmlHostServer2 ): |
|
663 iClient2.ReplaceItemL( aUid, aSize, aParent, aFieldChange, aId, aStoreName, aResultCode ); |
|
664 break; |
|
665 case ( ENSmlHostServerEnd ): |
|
666 default: |
|
667 User::Leave( KErrNotFound ); |
|
668 } |
|
669 aResultCode = HostErrorConversion( aResultCode ); |
|
670 } |
|
671 |
|
672 // ------------------------------------------------------------------------------------------------ |
|
673 // CNSmlDSHostClient::ReadItemL |
|
674 // Reads data from item at Data Store. Item must be opened before this method can be called. |
|
675 // This method is called until aBuffer is not used totally or method leaves with KErrEof. |
|
676 // ------------------------------------------------------------------------------------------------ |
|
677 EXPORT_C void CNSmlDSHostClient::ReadItemL( TDes8& aBuffer, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
678 { |
|
679 switch( SessionForDataProvider( aId ) ) |
|
680 { |
|
681 case ( ENSmlHostServer1 ): |
|
682 iClient1.ReadItemL( aBuffer, aId, aStoreName, aResultCode ); |
|
683 break; |
|
684 case ( ENSmlHostServer2 ): |
|
685 iClient2.ReadItemL( aBuffer, aId, aStoreName, aResultCode ); |
|
686 break; |
|
687 case ( ENSmlHostServerEnd ): |
|
688 default: |
|
689 User::Leave( KErrNotFound ); |
|
690 } |
|
691 aResultCode = HostErrorConversion( aResultCode ); |
|
692 } |
|
693 |
|
694 // ------------------------------------------------------------------------------------------------ |
|
695 // CNSmlDSHostClient::WriteItemL |
|
696 // Writes data to item to Data Provider. CreateItemL or ReplaceItemL method must be called before |
|
697 // this method can be called. This method is called until all data to current item is written. |
|
698 // ------------------------------------------------------------------------------------------------ |
|
699 EXPORT_C void CNSmlDSHostClient::WriteItemL( const TDesC8& aData, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
700 { |
|
701 switch( SessionForDataProvider( aId ) ) |
|
702 { |
|
703 case ( ENSmlHostServer1 ): |
|
704 iClient1.WriteItemL( aData, aId, aStoreName, aResultCode ); |
|
705 break; |
|
706 case ( ENSmlHostServer2 ): |
|
707 iClient2.WriteItemL( aData, aId, aStoreName, aResultCode ); |
|
708 break; |
|
709 case ( ENSmlHostServerEnd ): |
|
710 default: |
|
711 User::Leave( KErrNotFound ); |
|
712 } |
|
713 aResultCode = HostErrorConversion( aResultCode ); |
|
714 } |
|
715 |
|
716 // ------------------------------------------------------------------------------------------------ |
|
717 // CNSmlDSHostClient::CommitItemL |
|
718 // After item is written to Data Provider it can be saved to the Data Store. |
|
719 // This method can be called just after WriteItemL method. |
|
720 // ------------------------------------------------------------------------------------------------ |
|
721 EXPORT_C void CNSmlDSHostClient::CommitItemL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
722 { |
|
723 switch( SessionForDataProvider( aId ) ) |
|
724 { |
|
725 case ( ENSmlHostServer1 ): |
|
726 iClient1.CommitItem( aId, aStoreName, aResultCode ); |
|
727 break; |
|
728 case ( ENSmlHostServer2 ): |
|
729 iClient2.CommitItem( aId, aStoreName, aResultCode ); |
|
730 break; |
|
731 case ( ENSmlHostServerEnd ): |
|
732 default: |
|
733 User::Leave( KErrNotFound ); |
|
734 } |
|
735 aResultCode = HostErrorConversion( aResultCode ); |
|
736 } |
|
737 |
|
738 // ------------------------------------------------------------------------------------------------ |
|
739 // CNSmlDSHostClient::CloseItemL |
|
740 // Closes opened item. |
|
741 // ------------------------------------------------------------------------------------------------ |
|
742 EXPORT_C void CNSmlDSHostClient::CloseItemL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
743 { |
|
744 switch( SessionForDataProvider( aId ) ) |
|
745 { |
|
746 case ( ENSmlHostServer1 ): |
|
747 iClient1.CloseItem( aId, aStoreName, aResultCode ); |
|
748 break; |
|
749 case ( ENSmlHostServer2 ): |
|
750 iClient2.CloseItem( aId, aStoreName, aResultCode ); |
|
751 break; |
|
752 case ( ENSmlHostServerEnd ): |
|
753 default: |
|
754 User::Leave( KErrNotFound ); |
|
755 } |
|
756 aResultCode = HostErrorConversion( aResultCode ); |
|
757 } |
|
758 |
|
759 // ------------------------------------------------------------------------------------------------ |
|
760 // CNSmlDSHostClient::MoveItemL |
|
761 // Moves item to new location. |
|
762 // ------------------------------------------------------------------------------------------------ |
|
763 EXPORT_C void CNSmlDSHostClient::MoveItemL( TSmlDbItemUid aUid, TSmlDbItemUid aNewParent, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
764 { |
|
765 switch( SessionForDataProvider( aId ) ) |
|
766 { |
|
767 case ( ENSmlHostServer1 ): |
|
768 iClient1.MoveItemL( aUid, aNewParent, aId, aStoreName, aResultCode ); |
|
769 break; |
|
770 case ( ENSmlHostServer2 ): |
|
771 iClient2.MoveItemL( aUid, aNewParent, aId, aStoreName, aResultCode ); |
|
772 break; |
|
773 case ( ENSmlHostServerEnd ): |
|
774 default: |
|
775 User::Leave( KErrNotFound ); |
|
776 } |
|
777 aResultCode = HostErrorConversion( aResultCode ); |
|
778 } |
|
779 |
|
780 // ------------------------------------------------------------------------------------------------ |
|
781 // CNSmlDSHostClient::DeleteItemL |
|
782 // Deletes one item at Data Store permanently. |
|
783 // ------------------------------------------------------------------------------------------------ |
|
784 EXPORT_C void CNSmlDSHostClient::DeleteItemL( TSmlDbItemUid aUid, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
785 { |
|
786 switch( SessionForDataProvider( aId ) ) |
|
787 { |
|
788 case ( ENSmlHostServer1 ): |
|
789 iClient1.DeleteItemL( aUid, aId, aStoreName, aResultCode ); |
|
790 break; |
|
791 case ( ENSmlHostServer2 ): |
|
792 iClient2.DeleteItemL( aUid, aId, aStoreName, aResultCode ); |
|
793 break; |
|
794 case ( ENSmlHostServerEnd ): |
|
795 default: |
|
796 User::Leave( KErrNotFound ); |
|
797 } |
|
798 aResultCode = HostErrorConversion( aResultCode ); |
|
799 } |
|
800 |
|
801 // ------------------------------------------------------------------------------------------------ |
|
802 // CNSmlDSHostClient::SoftDeleteItemL |
|
803 // Soft deletes one item at Data Store. |
|
804 // ------------------------------------------------------------------------------------------------ |
|
805 EXPORT_C void CNSmlDSHostClient::SoftDeleteItemL( TSmlDbItemUid aUid, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
806 { |
|
807 switch( SessionForDataProvider( aId ) ) |
|
808 { |
|
809 case ( ENSmlHostServer1 ): |
|
810 iClient1.SoftDeleteItemL( aUid, aId, aStoreName, aResultCode ); |
|
811 break; |
|
812 case ( ENSmlHostServer2 ): |
|
813 iClient2.SoftDeleteItemL( aUid, aId, aStoreName, aResultCode ); |
|
814 break; |
|
815 case ( ENSmlHostServerEnd ): |
|
816 default: |
|
817 User::Leave( KErrNotFound ); |
|
818 } |
|
819 aResultCode = HostErrorConversion( aResultCode ); |
|
820 } |
|
821 |
|
822 // ------------------------------------------------------------------------------------------------ |
|
823 // CNSmlDSHostClient::DeleteAllItemsL |
|
824 // Deletes all items at Data Store permanently. |
|
825 // ------------------------------------------------------------------------------------------------ |
|
826 EXPORT_C void CNSmlDSHostClient::DeleteAllItemsL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
827 { |
|
828 switch( SessionForDataProvider( aId ) ) |
|
829 { |
|
830 case ( ENSmlHostServer1 ): |
|
831 iClient1.DeleteAllItems( aId, aStoreName, aResultCode ); |
|
832 break; |
|
833 case ( ENSmlHostServer2 ): |
|
834 iClient2.DeleteAllItems( aId, aStoreName, aResultCode ); |
|
835 break; |
|
836 case ( ENSmlHostServerEnd ): |
|
837 default: |
|
838 User::Leave( KErrNotFound ); |
|
839 } |
|
840 aResultCode = HostErrorConversion( aResultCode ); |
|
841 } |
|
842 |
|
843 // ------------------------------------------------------------------------------------------------ |
|
844 // CNSmlDSHostClient::HasSyncHistoryL |
|
845 // Checks if the Data Store has sync history. If not then slow sync is proposed to Sync Partner. |
|
846 // ------------------------------------------------------------------------------------------------ |
|
847 EXPORT_C TBool CNSmlDSHostClient::HasSyncHistoryL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) const |
|
848 { |
|
849 TBool ret( EFalse ); |
|
850 |
|
851 switch( SessionForDataProvider( aId ) ) |
|
852 { |
|
853 case ( ENSmlHostServer1 ): |
|
854 ret = iClient1.HasSyncHistory( aId, aStoreName, aResultCode ); |
|
855 break; |
|
856 case ( ENSmlHostServer2 ): |
|
857 ret = iClient2.HasSyncHistory( aId, aStoreName, aResultCode ); |
|
858 break; |
|
859 case ( ENSmlHostServerEnd ): |
|
860 default: |
|
861 User::Leave( KErrNotFound ); |
|
862 } |
|
863 aResultCode = HostErrorConversion( aResultCode ); |
|
864 return ret; |
|
865 } |
|
866 |
|
867 // ------------------------------------------------------------------------------------------------ |
|
868 // CNSmlDSHostClient::AddedItemsL |
|
869 // The Data Provider returns UIDs of items that are added after previous synchronization. |
|
870 // If the Data Provider uses hierarchical synchronization then added folders must be placed |
|
871 // first (from root to leaves) to UID set and finally items. |
|
872 // ------------------------------------------------------------------------------------------------ |
|
873 EXPORT_C void CNSmlDSHostClient::AddedItemsL( RNSmlDbItemModificationSet& aUidSet, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) const |
|
874 { |
|
875 switch( SessionForDataProvider( aId ) ) |
|
876 { |
|
877 case ( ENSmlHostServer1 ): |
|
878 iClient1.AddedItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
879 break; |
|
880 case ( ENSmlHostServer2 ): |
|
881 iClient2.AddedItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
882 break; |
|
883 case ( ENSmlHostServerEnd ): |
|
884 default: |
|
885 User::Leave( KErrNotFound ); |
|
886 } |
|
887 aResultCode = HostErrorConversion( aResultCode ); |
|
888 } |
|
889 |
|
890 // ------------------------------------------------------------------------------------------------ |
|
891 // CNSmlDSHostClient::DeletedItemsL |
|
892 // The Data Provider returns UIDs of items that are deleted after previous synchronization. |
|
893 // If the Data Provider uses hierarchical synchronization then deleted items must be placed |
|
894 // first to UID set and folders after items (from leaves to root). |
|
895 // ------------------------------------------------------------------------------------------------ |
|
896 EXPORT_C void CNSmlDSHostClient::DeletedItemsL( RNSmlDbItemModificationSet& aUidSet, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) const |
|
897 { |
|
898 switch( SessionForDataProvider( aId ) ) |
|
899 { |
|
900 case ( ENSmlHostServer1 ): |
|
901 iClient1.DeletedItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
902 break; |
|
903 case ( ENSmlHostServer2 ): |
|
904 iClient2.DeletedItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
905 break; |
|
906 case ( ENSmlHostServerEnd ): |
|
907 default: |
|
908 User::Leave( KErrNotFound ); |
|
909 } |
|
910 aResultCode = HostErrorConversion( aResultCode ); |
|
911 } |
|
912 |
|
913 // ------------------------------------------------------------------------------------------------ |
|
914 // CNSmlDSHostClient::SoftDeleteItemsL |
|
915 // The Data Provider returns UIDs of items that are soft deleted after previous synchronization. |
|
916 // If the Data Provider uses hierarchical synchronization then soft deleted items must be placed |
|
917 // first to UID set and folders after items (from leaves to root). |
|
918 // ------------------------------------------------------------------------------------------------ |
|
919 EXPORT_C void CNSmlDSHostClient::SoftDeleteItemsL( RNSmlDbItemModificationSet& aUidSet, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) const |
|
920 { |
|
921 switch( SessionForDataProvider( aId ) ) |
|
922 { |
|
923 case ( ENSmlHostServer1 ): |
|
924 iClient1.SoftDeleteItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
925 break; |
|
926 case ( ENSmlHostServer2 ): |
|
927 iClient2.SoftDeleteItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
928 break; |
|
929 case ( ENSmlHostServerEnd ): |
|
930 default: |
|
931 User::Leave( KErrNotFound ); |
|
932 } |
|
933 aResultCode = HostErrorConversion( aResultCode ); |
|
934 } |
|
935 |
|
936 // ------------------------------------------------------------------------------------------------ |
|
937 // CNSmlDSHostClient::ModifiedItemsL |
|
938 // The Data Provider returns UIDs of items that are modified after previous synchronization. |
|
939 // If the Data Provider uses hierarchical synchronization then modified folders must be placed |
|
940 // first (from root to leaves) to UID set and finally items. |
|
941 // ------------------------------------------------------------------------------------------------ |
|
942 EXPORT_C void CNSmlDSHostClient::ModifiedItemsL( RNSmlDbItemModificationSet& aUidSet, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) const |
|
943 { |
|
944 switch( SessionForDataProvider( aId ) ) |
|
945 { |
|
946 case ( ENSmlHostServer1 ): |
|
947 iClient1.ModifiedItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
948 break; |
|
949 case ( ENSmlHostServer2 ): |
|
950 iClient2.ModifiedItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
951 break; |
|
952 case ( ENSmlHostServerEnd ): |
|
953 default: |
|
954 User::Leave( KErrNotFound ); |
|
955 } |
|
956 aResultCode = HostErrorConversion( aResultCode ); |
|
957 } |
|
958 |
|
959 // ------------------------------------------------------------------------------------------------ |
|
960 // CNSmlDSHostClient::MovedItemsL |
|
961 // The Data Provider returns UIDs of items that are moved after previous synchronization. |
|
962 // If the Data Provider uses hierarchical synchronization then moved folders must be placed |
|
963 // first (from root to leaves) to UID set and finally items. |
|
964 // ------------------------------------------------------------------------------------------------ |
|
965 EXPORT_C void CNSmlDSHostClient::MovedItemsL( RNSmlDbItemModificationSet& aUidSet, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) const |
|
966 { |
|
967 switch( SessionForDataProvider( aId ) ) |
|
968 { |
|
969 case ( ENSmlHostServer1 ): |
|
970 iClient1.MovedItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
971 break; |
|
972 case ( ENSmlHostServer2 ): |
|
973 iClient2.MovedItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
974 break; |
|
975 case ( ENSmlHostServerEnd ): |
|
976 default: |
|
977 User::Leave( KErrNotFound ); |
|
978 } |
|
979 aResultCode = HostErrorConversion( aResultCode ); |
|
980 } |
|
981 |
|
982 // ------------------------------------------------------------------------------------------------ |
|
983 // CNSmlDSHostClient::AllItemsL |
|
984 // The Data Provider returns UIDs of items that are added, deleted, modified, softdeleted |
|
985 // or moved after previous synchronization. |
|
986 // ------------------------------------------------------------------------------------------------ |
|
987 EXPORT_C void CNSmlDSHostClient::AllItemsL( RNSmlDbItemModificationSet& aUidSet, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) const |
|
988 { |
|
989 switch( SessionForDataProvider( aId ) ) |
|
990 { |
|
991 case ( ENSmlHostServer1 ): |
|
992 iClient1.AllItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
993 break; |
|
994 case ( ENSmlHostServer2 ): |
|
995 iClient2.AllItemsL( aUidSet, aId, aStoreName, aResultCode ); |
|
996 break; |
|
997 case ( ENSmlHostServerEnd ): |
|
998 default: |
|
999 User::Leave( KErrNotFound ); |
|
1000 } |
|
1001 aResultCode = HostErrorConversion( aResultCode ); |
|
1002 } |
|
1003 |
|
1004 // ------------------------------------------------------------------------------------------------ |
|
1005 // CNSmlDSHostClient::ResetChangeInfoL |
|
1006 // Reset change info from the Data Provider. The result of this method is that the Data Provider |
|
1007 // sends just ADD commands to Sync Partner. |
|
1008 // ------------------------------------------------------------------------------------------------ |
|
1009 EXPORT_C void CNSmlDSHostClient::ResetChangeInfoL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
1010 { |
|
1011 switch( SessionForDataProvider( aId ) ) |
|
1012 { |
|
1013 case ( ENSmlHostServer1 ): |
|
1014 iClient1.ResetChangeInfo( aId, aStoreName, aResultCode ); |
|
1015 break; |
|
1016 case ( ENSmlHostServer2 ): |
|
1017 iClient2.ResetChangeInfo( aId, aStoreName, aResultCode ); |
|
1018 break; |
|
1019 case ( ENSmlHostServerEnd ): |
|
1020 default: |
|
1021 User::Leave( KErrNotFound ); |
|
1022 } |
|
1023 aResultCode = HostErrorConversion( aResultCode ); |
|
1024 } |
|
1025 |
|
1026 // ------------------------------------------------------------------------------------------------ |
|
1027 // CNSmlDSHostClient::CommitChangeInfoL |
|
1028 // This method is called after some changes are synchronized to Sync Partner. If some changes |
|
1029 // were synchronized correctly then those UIDs are included to aItems. |
|
1030 // ------------------------------------------------------------------------------------------------ |
|
1031 EXPORT_C void CNSmlDSHostClient::CommitChangeInfoL( const MSmlDataItemUidSet& aItems, const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
1032 { |
|
1033 switch( SessionForDataProvider( aId ) ) |
|
1034 { |
|
1035 case ( ENSmlHostServer1 ): |
|
1036 iClient1.CommitChangeInfoL( aItems, aId, aStoreName, aResultCode ); |
|
1037 break; |
|
1038 case ( ENSmlHostServer2 ): |
|
1039 iClient2.CommitChangeInfoL( aItems, aId, aStoreName, aResultCode ); |
|
1040 break; |
|
1041 case ( ENSmlHostServerEnd ): |
|
1042 default: |
|
1043 User::Leave( KErrNotFound ); |
|
1044 } |
|
1045 aResultCode = HostErrorConversion( aResultCode ); |
|
1046 } |
|
1047 |
|
1048 // ------------------------------------------------------------------------------------------------ |
|
1049 // CNSmlDSHostClient::CommitChangeInfoL |
|
1050 // This method is called after some changes are synchronized to Sync Partner. This method is used if |
|
1051 // all changes were synchronized correctly. |
|
1052 // ------------------------------------------------------------------------------------------------ |
|
1053 EXPORT_C void CNSmlDSHostClient::CommitChangeInfoL( const TSmlDataProviderId aId, const TDesC& aStoreName, TInt& aResultCode ) |
|
1054 { |
|
1055 switch( SessionForDataProvider( aId ) ) |
|
1056 { |
|
1057 case ( ENSmlHostServer1 ): |
|
1058 iClient1.CommitChangeInfo( aId, aStoreName, aResultCode ); |
|
1059 break; |
|
1060 case ( ENSmlHostServer2 ): |
|
1061 iClient2.CommitChangeInfo( aId, aStoreName, aResultCode ); |
|
1062 break; |
|
1063 case ( ENSmlHostServerEnd ): |
|
1064 default: |
|
1065 User::Leave( KErrNotFound ); |
|
1066 } |
|
1067 aResultCode = HostErrorConversion( aResultCode ); |
|
1068 } |
|
1069 |
|
1070 // ------------------------------------------------------------------------------------------------ |
|
1071 // CNSmlDSHostClient::UpdateServerIdL |
|
1072 // Replaces the give old server ID with new one. |
|
1073 // ------------------------------------------------------------------------------------------------ |
|
1074 EXPORT_C void CNSmlDSHostClient::UpdateServerIdL( TDesC& aOldServerId, TDesC& aNewValue, TInt& aResultCode ) |
|
1075 { |
|
1076 iClient1.UpdateServerIdL( aOldServerId, aNewValue, aResultCode ); |
|
1077 iClient2.UpdateServerIdL( aOldServerId, aNewValue, aResultCode ); |
|
1078 aResultCode = HostErrorConversion( aResultCode ); |
|
1079 } |
|
1080 |
|
1081 // ------------------------------------------------------------------------------------------------ |
|
1082 // CNSmlDSHostClient - private methods |
|
1083 // ------------------------------------------------------------------------------------------------ |
|
1084 // ------------------------------------------------------------------------------------------------ |
|
1085 // CNSmlDSHostClient::CNSmlDSHostClient |
|
1086 // C++ constructor. |
|
1087 // ------------------------------------------------------------------------------------------------ |
|
1088 CNSmlDSHostClient::CNSmlDSHostClient() |
|
1089 { |
|
1090 } |
|
1091 |
|
1092 // ------------------------------------------------------------------------------------------------ |
|
1093 // CNSmlDSHostClient::ConstrucL |
|
1094 // ConstrucL |
|
1095 // ------------------------------------------------------------------------------------------------ |
|
1096 void CNSmlDSHostClient::ConstructL() |
|
1097 { |
|
1098 TVersion DSHostServerVersion( KNSmlDSHostServerVersionMajor, |
|
1099 KNSmlDSHostServerVersionMinor, KNSmlDSHostServerVersionBuild ); |
|
1100 |
|
1101 User::LeaveIfError( iClient1.Connect( KNSmlDSHostServer1Name, DSHostServerVersion ) ); |
|
1102 User::LeaveIfError( iClient2.Connect( KNSmlDSHostServer2Name, DSHostServerVersion ) ); |
|
1103 User::LeaveIfError( iClient1.CreateChunk() ); |
|
1104 User::LeaveIfError( iClient1.SendChunkHandle() ); |
|
1105 User::LeaveIfError( iClient2.CreateChunk() ); |
|
1106 User::LeaveIfError( iClient2.SendChunkHandle() ); |
|
1107 } |
|
1108 |
|
1109 // ------------------------------------------------------------------------------------------------ |
|
1110 // CNSmlDSHostClient::SessionForDataProvider |
|
1111 // Return session to correct server that has current Data Provider. |
|
1112 // ------------------------------------------------------------------------------------------------ |
|
1113 TInt CNSmlDSHostClient::SessionForDataProvider( const TSmlDataProviderId aId ) const |
|
1114 { |
|
1115 for ( TInt i = 0; i < iDataProviders1.Count(); i++ ) |
|
1116 { |
|
1117 if ( iDataProviders1[i] == aId ) |
|
1118 { |
|
1119 return ENSmlHostServer1; |
|
1120 } |
|
1121 } |
|
1122 for ( TInt i = 0; i < iDataProviders2.Count(); i++ ) |
|
1123 { |
|
1124 if ( iDataProviders2[i] == aId ) |
|
1125 { |
|
1126 return ENSmlHostServer2; |
|
1127 } |
|
1128 } |
|
1129 return ENSmlHostServerEnd; |
|
1130 } |
|
1131 |
|
1132 // ------------------------------------------------------------------------------------------------ |
|
1133 // CNSmlDSHostClient::HostErrorConversion |
|
1134 // ------------------------------------------------------------------------------------------------ |
|
1135 TInt CNSmlDSHostClient::HostErrorConversion( TInt aStatusFromHost ) |
|
1136 { |
|
1137 TInt ret ( aStatusFromHost ); |
|
1138 |
|
1139 // in module tests no conversion. |
|
1140 #ifndef __HOST_SERVER_MTEST__ |
|
1141 switch( aStatusFromHost ) |
|
1142 { |
|
1143 case ENSmlDSHostServerErrNone: |
|
1144 ret = KErrNone; |
|
1145 break; |
|
1146 case ENSmlDSHostServerErrDPNotCreated: |
|
1147 ret = KErrNotFound; |
|
1148 break; |
|
1149 case ENSmlDSHostServerErrDSNotOpened: |
|
1150 ret = KErrNotFound; |
|
1151 break; |
|
1152 case ENSmlDSHostServerErrAsynchCallOutstanding: |
|
1153 ret = KErrServerBusy; |
|
1154 break; |
|
1155 default: |
|
1156 ret = aStatusFromHost; |
|
1157 } |
|
1158 #endif |
|
1159 return ret; |
|
1160 } |
|
1161 |
|
1162 #endif // __USE_FAKE_CLIENT__ |
|
1163 |
|
1164 // End of File |