|
1 /* |
|
2 * Copyright (c) 2004 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: Implementation of DS specific client api. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <s32mem.h> |
|
20 #include <SyncMLClientDS.h> |
|
21 #include <nsmldebug.h> |
|
22 |
|
23 #include "NSmlClientAPIUtils.h" |
|
24 #include "nsmlsosserverdefs.h" |
|
25 |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // |
|
30 // RSyncMLDataSyncJob |
|
31 // |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // RSyncMLDataSyncJob::RSyncMLDataSyncJob() |
|
35 // Constructor. |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 EXPORT_C RSyncMLDataSyncJob::RSyncMLDataSyncJob() |
|
39 : RSyncMLJobBase() |
|
40 { |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // RSyncMLDataSyncJob::CreateL() |
|
45 // Creates DS job. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 EXPORT_C void RSyncMLDataSyncJob::CreateL( RSyncMLSession& aSession, TSmlProfileId aProfileId ) |
|
49 { |
|
50 _DBG_FILE("RSyncMLDataSyncJob::CreateL() ECmdDataSyncJobCreateForProfile: begin"); |
|
51 |
|
52 // check that job is not yet open and ds sync is supported |
|
53 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
54 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
55 |
|
56 CDataSyncJobSessionData* data = new (ELeave) CDataSyncJobSessionData(); |
|
57 CleanupStack::PushL( data ); |
|
58 |
|
59 // add profile id to parameters and write the buffer |
|
60 data->AddParamL( aProfileId ); |
|
61 data->WriteIntegersToBufferL(); |
|
62 |
|
63 TPtr8 dataPtr = data->DataBufferPtr(); |
|
64 TPckgBuf<TInt> jobId; |
|
65 TIpcArgs args( &jobId, &dataPtr ); |
|
66 |
|
67 // open the sub-session |
|
68 User::LeaveIfError( CreateSubSession( aSession, ECmdDataSyncJobCreateForProfile, args ) ); |
|
69 |
|
70 data->SetProfile( aProfileId ); |
|
71 data->SetIdentifier( jobId() ); |
|
72 |
|
73 iData = data; |
|
74 CleanupStack::Pop(); // data |
|
75 |
|
76 _DBG_FILE("RSyncMLDataSyncJob::CreateL(): end"); |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // RSyncMLDataSyncJob::CreateL() |
|
81 // Creates DS job, transport override. |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 EXPORT_C void RSyncMLDataSyncJob::CreateL( RSyncMLSession& aSession, TSmlProfileId aProfileId, TSmlConnectionId aTransportId ) |
|
85 { |
|
86 _DBG_FILE("RSyncMLDataSyncJob::CreateL() ECmdDataSyncJobCreateForTransport: begin"); |
|
87 |
|
88 // check that job is not yet open and ds sync is supported |
|
89 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
90 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
91 |
|
92 CDataSyncJobSessionData* data = new (ELeave) CDataSyncJobSessionData(); |
|
93 CleanupStack::PushL( data ); |
|
94 |
|
95 // add ids to parameters and write the buffer |
|
96 data->AddParamL( aProfileId ); |
|
97 data->AddParamL( aTransportId ); |
|
98 data->WriteIntegersToBufferL(); |
|
99 |
|
100 TPtr8 dataPtr = data->DataBufferPtr(); |
|
101 TPckgBuf<TInt> jobId; |
|
102 TIpcArgs args( &jobId, &dataPtr ); |
|
103 |
|
104 // open the sub-session |
|
105 User::LeaveIfError( CreateSubSession( aSession, ECmdDataSyncJobCreateForTransport, args ) ); |
|
106 |
|
107 data->SetProfile( aProfileId ); |
|
108 data->SetIdentifier( jobId() ); |
|
109 |
|
110 iData = data; |
|
111 CleanupStack::Pop(); // data |
|
112 |
|
113 _DBG_FILE("RSyncMLDataSyncJob::CreateL(): end"); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // RSyncMLDataSyncJob::CreateL() |
|
118 // Creates DS job, sync type override. |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 EXPORT_C void RSyncMLDataSyncJob::CreateL( RSyncMLSession& aSession, TSmlProfileId aProfileId, TSmlSyncType aSyncType ) |
|
122 { |
|
123 _DBG_FILE("RSyncMLDataSyncJob::CreateL() ECmdDataSyncJobCreateForProfileST: begin"); |
|
124 |
|
125 // check that job is not yet open and ds sync is supported |
|
126 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
127 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
128 |
|
129 CDataSyncJobSessionData* data = new (ELeave) CDataSyncJobSessionData(); |
|
130 CleanupStack::PushL( data ); |
|
131 |
|
132 // add ids to parameters and write the buffer |
|
133 data->AddParamL( aProfileId ); |
|
134 data->AddParamL( aSyncType ); |
|
135 data->WriteIntegersToBufferL(); |
|
136 |
|
137 TPtr8 dataPtr = data->DataBufferPtr(); |
|
138 TPckgBuf<TInt> jobId; |
|
139 TIpcArgs args( &jobId, &dataPtr ); |
|
140 |
|
141 // open the sub-session |
|
142 User::LeaveIfError( CreateSubSession( aSession, ECmdDataSyncJobCreateForProfileST, args ) ); |
|
143 |
|
144 data->SetProfile( aProfileId ); |
|
145 data->SetIdentifier( jobId() ); |
|
146 |
|
147 iData = data; |
|
148 CleanupStack::Pop(); // data |
|
149 |
|
150 _DBG_FILE("RSyncMLDataSyncJob::CreateL(): end"); |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // RSyncMLDataSyncJob::CreateL() |
|
155 // Creates DS job, transport + sync type override. |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 EXPORT_C void RSyncMLDataSyncJob::CreateL( RSyncMLSession& aSession, TSmlProfileId aProfileId, TSmlConnectionId aTransportId, TSmlSyncType aSyncType ) |
|
159 { |
|
160 _DBG_FILE("RSyncMLDataSyncJob::CreateL() ECmdDataSyncJobCreateForTransportST: begin"); |
|
161 |
|
162 // check that job is not yet open and ds sync is supported |
|
163 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
164 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
165 |
|
166 CDataSyncJobSessionData* data = new (ELeave) CDataSyncJobSessionData(); |
|
167 CleanupStack::PushL( data ); |
|
168 |
|
169 // add ids to parameters and write the buffer |
|
170 data->AddParamL( aProfileId ); |
|
171 data->AddParamL( aTransportId ); |
|
172 data->AddParamL( aSyncType ); |
|
173 data->WriteIntegersToBufferL(); |
|
174 |
|
175 TPtr8 dataPtr = data->DataBufferPtr(); |
|
176 TPckgBuf<TInt> jobId; |
|
177 TIpcArgs args( &jobId, &dataPtr ); |
|
178 |
|
179 // open the sub-session |
|
180 User::LeaveIfError( CreateSubSession( aSession, ECmdDataSyncJobCreateForTransportST, args ) ); |
|
181 |
|
182 data->SetProfile( aProfileId ); |
|
183 data->SetIdentifier( jobId() ); |
|
184 |
|
185 iData = data; |
|
186 CleanupStack::Pop(); // data |
|
187 |
|
188 _DBG_FILE("RSyncMLDataSyncJob::CreateL(): end"); |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // RSyncMLDataSyncJob::CreateL() |
|
193 // Creates DS job, tasks override. |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 EXPORT_C void RSyncMLDataSyncJob::CreateL( RSyncMLSession& aSession, TSmlProfileId aProfileId, const RArray<TSmlTaskId>& aTasks ) |
|
197 { |
|
198 _DBG_FILE("RSyncMLDataSyncJob::CreateL() ECmdDataSyncJobCreateForTasks: begin"); |
|
199 |
|
200 // check that job is not yet open and ds sync is supported |
|
201 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
202 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
203 |
|
204 CDataSyncJobSessionData* data = new (ELeave) CDataSyncJobSessionData(); |
|
205 CleanupStack::PushL( data ); |
|
206 |
|
207 // add ids to parameters and write the buffer |
|
208 data->AddParamL( aProfileId ); |
|
209 data->WriteIntegersToBufferL( &aTasks ); |
|
210 |
|
211 TPtr8 dataPtr = data->DataBufferPtr(); |
|
212 TPckgBuf<TInt> jobId; |
|
213 TIpcArgs args( &jobId, &dataPtr ); |
|
214 |
|
215 // open the sub-session |
|
216 User::LeaveIfError( CreateSubSession( aSession, ECmdDataSyncJobCreateForTasks, args ) ); |
|
217 |
|
218 iData = data; |
|
219 CleanupStack::Pop(); // data |
|
220 |
|
221 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
222 |
|
223 data->SetProfile( aProfileId ); |
|
224 data->SetIdentifier( jobId() ); |
|
225 data->SetTasksL( aTasks ); |
|
226 |
|
227 CleanupStack::Pop(); // this |
|
228 |
|
229 _DBG_FILE("RSyncMLDataSyncJob::CreateL(): end"); |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // RSyncMLDataSyncJob::CreateL() |
|
234 // Creates DS job, transport + tasks override. |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 EXPORT_C void RSyncMLDataSyncJob::CreateL( RSyncMLSession& aSession, TSmlProfileId aProfileId, TSmlConnectionId aTransportId, const RArray<TSmlTaskId>& aTasks ) |
|
238 { |
|
239 _DBG_FILE("RSyncMLDataSyncJob::CreateL() ECmdDataSyncJobCreateForTransportAndTasks: begin"); |
|
240 |
|
241 // check that job is not yet open and ds sync is supported |
|
242 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
243 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
244 |
|
245 CDataSyncJobSessionData* data = new (ELeave) CDataSyncJobSessionData(); |
|
246 CleanupStack::PushL( data ); |
|
247 |
|
248 // add ids to parameters and write the buffer |
|
249 data->AddParamL( aProfileId ); |
|
250 data->AddParamL( aTransportId ); |
|
251 data->WriteIntegersToBufferL( &aTasks ); |
|
252 |
|
253 TPtr8 dataPtr = data->DataBufferPtr(); |
|
254 TPckgBuf<TInt> jobId; |
|
255 TIpcArgs args( &jobId, &dataPtr ); |
|
256 |
|
257 // open the sub-session |
|
258 User::LeaveIfError( CreateSubSession( aSession, ECmdDataSyncJobCreateForTransportAndTasks, args ) ); |
|
259 |
|
260 iData = data; |
|
261 CleanupStack::Pop(); // data |
|
262 |
|
263 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
264 |
|
265 data->SetProfile( aProfileId ); |
|
266 data->SetIdentifier( jobId() ); |
|
267 data->SetTasksL( aTasks ); |
|
268 |
|
269 CleanupStack::Pop(); // this |
|
270 |
|
271 _DBG_FILE("RSyncMLDataSyncJob::CreateL(): end"); |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // RSyncMLDataSyncJob::CreateL() |
|
276 // Creates DS job, sync type + tasks override. |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 EXPORT_C void RSyncMLDataSyncJob::CreateL( RSyncMLSession& aSession, TSmlProfileId aProfileId, TSmlSyncType aSyncType, const RArray<TSmlTaskId>& aTasks ) |
|
280 { |
|
281 _DBG_FILE("RSyncMLDataSyncJob::CreateL() ECmdDataSyncJobCreateForTasksST: begin"); |
|
282 |
|
283 // check that job is not yet open and ds sync is supported |
|
284 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
285 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
286 |
|
287 CDataSyncJobSessionData* data = new (ELeave) CDataSyncJobSessionData(); |
|
288 CleanupStack::PushL( data ); |
|
289 |
|
290 // add ids to parameters and write the buffer |
|
291 data->AddParamL( aProfileId ); |
|
292 data->AddParamL( aSyncType ); |
|
293 data->WriteIntegersToBufferL( &aTasks ); |
|
294 |
|
295 TPtr8 dataPtr = data->DataBufferPtr(); |
|
296 TPckgBuf<TInt> jobId; |
|
297 TIpcArgs args( &jobId, &dataPtr ); |
|
298 |
|
299 // open the sub-session |
|
300 User::LeaveIfError( CreateSubSession( aSession, ECmdDataSyncJobCreateForTasksST, args ) ); |
|
301 |
|
302 iData = data; |
|
303 CleanupStack::Pop(); // data |
|
304 |
|
305 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
306 |
|
307 data->SetProfile( aProfileId ); |
|
308 data->SetIdentifier( jobId() ); |
|
309 data->SetTasksL( aTasks ); |
|
310 |
|
311 CleanupStack::Pop(); // this |
|
312 |
|
313 _DBG_FILE("RSyncMLDataSyncJob::CreateL(): end"); |
|
314 } |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // RSyncMLDataSyncJob::CreateL() |
|
318 // Creates DS job, transport + sync type + tasks override. |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 EXPORT_C void RSyncMLDataSyncJob::CreateL( RSyncMLSession& aSession, TSmlProfileId aProfileId, TSmlConnectionId aTransportId, TSmlSyncType aSyncType, const RArray<TSmlTaskId>& aTasks ) |
|
322 { |
|
323 _DBG_FILE("RSyncMLDataSyncJob::CreateL() ECmdDataSyncJobCreateForTransportAndTasksST: begin"); |
|
324 |
|
325 // check that job is not yet open and ds sync is supported |
|
326 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
327 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
328 |
|
329 CDataSyncJobSessionData* data = new (ELeave) CDataSyncJobSessionData(); |
|
330 CleanupStack::PushL( data ); |
|
331 |
|
332 // add ids to parameters and write the buffer |
|
333 data->AddParamL( aProfileId ); |
|
334 data->AddParamL( aTransportId ); |
|
335 data->AddParamL( aSyncType ); |
|
336 data->WriteIntegersToBufferL( &aTasks ); |
|
337 |
|
338 TPtr8 dataPtr = data->DataBufferPtr(); |
|
339 TPckgBuf<TInt> jobId; |
|
340 TIpcArgs args( &jobId, &dataPtr ); |
|
341 |
|
342 // open the sub-session |
|
343 User::LeaveIfError( CreateSubSession( aSession, ECmdDataSyncJobCreateForTransportAndTasksST, args ) ); |
|
344 |
|
345 iData = data; |
|
346 CleanupStack::Pop(); // data |
|
347 |
|
348 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
349 |
|
350 data->SetProfile( aProfileId ); |
|
351 data->SetIdentifier( jobId() ); |
|
352 data->SetTasksL( aTasks ); |
|
353 |
|
354 CleanupStack::Pop(); // this |
|
355 |
|
356 _DBG_FILE("RSyncMLDataSyncJob::CreateL(): end"); |
|
357 } |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // RSyncMLDataSyncJob::OpenL() |
|
361 // Opens a job currently in servers job queue. If not found, leaves with |
|
362 // KErrNotFound. |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 EXPORT_C void RSyncMLDataSyncJob::OpenL( RSyncMLSession& aSession, TSmlJobId aJobId ) |
|
366 { |
|
367 _DBG_FILE("RSyncMLDataSyncJob::OpenL(): begin"); |
|
368 |
|
369 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
370 |
|
371 CDataSyncJobSessionData* data = new (ELeave) CDataSyncJobSessionData(); |
|
372 CleanupStack::PushL( data ); |
|
373 |
|
374 // open the sub-session and get size of data to be received |
|
375 TPckgBuf<TInt> dataSize; |
|
376 TIpcArgs args( &dataSize, aJobId ); |
|
377 User::LeaveIfError( CreateSubSession( aSession, ECmdJobOpen, args ) ); |
|
378 |
|
379 data->SetIdentifier( aJobId ); |
|
380 |
|
381 iData = data; |
|
382 CleanupStack::Pop(); // data |
|
383 |
|
384 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
385 |
|
386 // get the data: the profile id and list of task ids |
|
387 GetJobL( dataSize(), EFalse ); |
|
388 |
|
389 CleanupStack::Pop(); // this |
|
390 |
|
391 _DBG_FILE("RSyncMLDataSyncJob::OpenL(): end"); |
|
392 } |
|
393 |
|
394 // ----------------------------------------------------------------------------- |
|
395 // RSyncMLDataSyncJob::StopL() |
|
396 // If this job has started to execute in server, it is stopped and an |
|
397 // event is emitted. If the job is still in job queue, it is merely |
|
398 // removed from the queue. If not found, leaves with KErrNotFound. |
|
399 // ----------------------------------------------------------------------------- |
|
400 // |
|
401 EXPORT_C void RSyncMLDataSyncJob::StopL() |
|
402 { |
|
403 _DBG_FILE("RSyncMLDataSyncJob::StopL(): begin"); |
|
404 |
|
405 TInt jobId = Identifier(); |
|
406 TIpcArgs args( jobId ); |
|
407 User::LeaveIfError( SendReceive( ECmdJobStop, args ) ); |
|
408 |
|
409 _DBG_FILE("RSyncMLDataSyncJob::StopL(): end"); |
|
410 } |
|
411 |
|
412 // ----------------------------------------------------------------------------- |
|
413 // RSyncMLDataSyncJob::TaskIDs() |
|
414 // Returns the task id associated with this job (if given in CreateL). |
|
415 // ----------------------------------------------------------------------------- |
|
416 // |
|
417 EXPORT_C const RArray<TSmlTaskId>& RSyncMLDataSyncJob::TaskIDs() const |
|
418 { |
|
419 return static_cast<CDataSyncJobSessionData*>(iData)->TaskIds(); |
|
420 } |
|
421 |
|
422 |
|
423 // |
|
424 // RSyncMLDataSyncProfile |
|
425 // |
|
426 |
|
427 // ----------------------------------------------------------------------------- |
|
428 // RSyncMLDataSyncProfile::RSyncMLDataSyncProfile() |
|
429 // Constructor. |
|
430 // ----------------------------------------------------------------------------- |
|
431 // |
|
432 EXPORT_C RSyncMLDataSyncProfile::RSyncMLDataSyncProfile() |
|
433 : RSyncMLProfileBase() |
|
434 { |
|
435 } |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // RSyncMLDataSyncProfile::CreateL() |
|
439 // Opens a sub-session to server and creates a new profile |
|
440 // to server side. |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 EXPORT_C void RSyncMLDataSyncProfile::CreateL( RSyncMLSession& aSession ) |
|
444 { |
|
445 _DBG_FILE("RSyncMLDataSyncProfile::CreateL(): begin"); |
|
446 |
|
447 // check that profile is not yet open and ds sync is supported |
|
448 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
449 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
450 |
|
451 CDataSyncProfileSessionData* data = CDataSyncProfileSessionData::NewLC( ETrue ); |
|
452 |
|
453 // create sub-session and new profile |
|
454 User::LeaveIfError( CreateSubSession( aSession, ECmdProfileCreateDS ) ); |
|
455 |
|
456 iData = data; |
|
457 CleanupStack::Pop(); // data |
|
458 |
|
459 _DBG_FILE("RSyncMLDataSyncProfile::CreateL(): end"); |
|
460 } |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // RSyncMLDataSyncProfile::OpenL() |
|
464 // Opens a sub-session to server to an existing profile and |
|
465 // gets the profile's data to iData. |
|
466 // ----------------------------------------------------------------------------- |
|
467 // |
|
468 EXPORT_C void RSyncMLDataSyncProfile::OpenL( RSyncMLSession& aSession, TSmlProfileId aProfileId, TSmlOpenMode aOpenMode ) |
|
469 { |
|
470 _DBG_FILE("RSyncMLDataSyncProfile::OpenL(): begin"); |
|
471 |
|
472 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
473 |
|
474 CDataSyncProfileSessionData* data = CDataSyncProfileSessionData::NewLC(); |
|
475 |
|
476 TPckgBuf<TInt> dataSize; |
|
477 TIpcArgs args( &dataSize, aProfileId, aOpenMode ); |
|
478 |
|
479 // open the sub-session |
|
480 User::LeaveIfError( CreateSubSession( aSession, ECmdProfileOpenDS, args ) ); |
|
481 |
|
482 data->SetIdentifier( aProfileId ); |
|
483 data->SetOpenMode( (TSmlOpenMode)aOpenMode ); |
|
484 |
|
485 iData = data; |
|
486 CleanupStack::Pop(); // data |
|
487 |
|
488 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
489 |
|
490 // dataSize contains now the size of the data buffer that is received next -> get data |
|
491 GetProfileL( dataSize() ); |
|
492 |
|
493 CleanupStack::Pop(); // this |
|
494 |
|
495 _DBG_FILE("RSyncMLDataSyncProfile::OpenL(): end"); |
|
496 } |
|
497 |
|
498 // ----------------------------------------------------------------------------- |
|
499 // RSyncMLDataSyncProfile::SetCreatorId() |
|
500 // Sets creator id. |
|
501 // ----------------------------------------------------------------------------- |
|
502 // |
|
503 EXPORT_C void RSyncMLDataSyncProfile::SetCreatorId( TSmlCreatorId aCreatorId ) |
|
504 { |
|
505 RSyncMLProfileBase::SetCreatorId( aCreatorId ); |
|
506 } |
|
507 |
|
508 // ----------------------------------------------------------------------------- |
|
509 // RSyncMLDataSyncProfile::SetDisplayNameL() |
|
510 // Sets display name for this profile. |
|
511 // ----------------------------------------------------------------------------- |
|
512 // |
|
513 EXPORT_C void RSyncMLDataSyncProfile::SetDisplayNameL( const TDesC& aDisplayName ) |
|
514 { |
|
515 RSyncMLProfileBase::SetDisplayNameL( aDisplayName ); |
|
516 } |
|
517 |
|
518 // ----------------------------------------------------------------------------- |
|
519 // RSyncMLDataSyncProfile::SetUserNameL() |
|
520 // Sets user name. |
|
521 // ----------------------------------------------------------------------------- |
|
522 // |
|
523 EXPORT_C void RSyncMLDataSyncProfile::SetUserNameL( const TDesC8& aUserName ) |
|
524 { |
|
525 RSyncMLProfileBase::SetUserNameL( aUserName ); |
|
526 } |
|
527 |
|
528 // ----------------------------------------------------------------------------- |
|
529 // RSyncMLDataSyncProfile::SetPasswordL() |
|
530 // Sets password. |
|
531 // ----------------------------------------------------------------------------- |
|
532 // |
|
533 EXPORT_C void RSyncMLDataSyncProfile::SetPasswordL( const TDesC8& aPassword ) |
|
534 { |
|
535 RSyncMLProfileBase::SetPasswordL( aPassword ); |
|
536 } |
|
537 |
|
538 // ----------------------------------------------------------------------------- |
|
539 // RSyncMLDataSyncProfile::DeleteConnectionL() |
|
540 // Not supported (only one connection per profile). |
|
541 // ----------------------------------------------------------------------------- |
|
542 // |
|
543 EXPORT_C void RSyncMLDataSyncProfile::DeleteConnectionL( TSmlTransportId aTransportId ) |
|
544 { |
|
545 RSyncMLProfileBase::DeleteConnectionL( aTransportId ); |
|
546 } |
|
547 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // RSyncMLDataSyncProfile::ListTasksL() |
|
550 // Lists tasks associated with this profile. |
|
551 // ----------------------------------------------------------------------------- |
|
552 // |
|
553 EXPORT_C void RSyncMLDataSyncProfile::ListTasksL( RArray<TSmlTaskId>& aArray ) const |
|
554 { |
|
555 _DBG_FILE("RSyncMLDataSyncProfile::ListTasksL(): begin"); |
|
556 |
|
557 ReceiveArrayL( aArray, ECmdTaskListStart, ECmdTaskListNext ); |
|
558 |
|
559 _DBG_FILE("RSyncMLDataSyncProfile::ListTasksL(): end"); |
|
560 } |
|
561 |
|
562 // ----------------------------------------------------------------------------- |
|
563 // RSyncMLDataSyncProfile::DeleteTaskL() |
|
564 // Deletes given task. |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 EXPORT_C void RSyncMLDataSyncProfile::DeleteTaskL( TSmlTaskId aTaskId ) |
|
568 { |
|
569 _DBG_FILE("RSyncMLDataSyncProfile::DeleteTaskL(): begin"); |
|
570 |
|
571 TIpcArgs args( aTaskId ); |
|
572 User::LeaveIfError( SendReceive( ECmdTaskDelete, args ) ); |
|
573 |
|
574 _DBG_FILE("RSyncMLDataSyncProfile::DeleteTaskL(): end"); |
|
575 } |
|
576 |
|
577 // ----------------------------------------------------------------------------- |
|
578 // RSyncMLDataSyncProfile::UpdateL() |
|
579 // Sends profile data to server -> data updated. |
|
580 // ----------------------------------------------------------------------------- |
|
581 // |
|
582 EXPORT_C void RSyncMLDataSyncProfile::UpdateL() |
|
583 { |
|
584 RSyncMLProfileBase::UpdateL(); |
|
585 } |
|
586 |
|
587 |
|
588 // |
|
589 // RSyncMLTask |
|
590 // |
|
591 |
|
592 |
|
593 // ----------------------------------------------------------------------------- |
|
594 // RSyncMLTask::RSyncMLTask() |
|
595 // Constructor. |
|
596 // ----------------------------------------------------------------------------- |
|
597 // |
|
598 EXPORT_C RSyncMLTask::RSyncMLTask() |
|
599 : iData( NULL ) |
|
600 { |
|
601 } |
|
602 |
|
603 // ----------------------------------------------------------------------------- |
|
604 // RSyncMLTask::CreateL() |
|
605 // Creates new task for given profile. |
|
606 // ----------------------------------------------------------------------------- |
|
607 // |
|
608 EXPORT_C void RSyncMLTask::CreateL( RSyncMLDataSyncProfile& aProfile, TSmlDataProviderId aDataProviderId, |
|
609 const TDesC& aServerDataSource, const TDesC& aClientDataSource ) |
|
610 { |
|
611 _DBG_FILE("RSyncMLTask::CreateL(): begin"); |
|
612 |
|
613 // check that we're allowed to write |
|
614 if ( aProfile.IsReadOnly() ) |
|
615 { |
|
616 User::Leave( KErrLocked ); |
|
617 } |
|
618 |
|
619 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
620 |
|
621 TIpcArgs args( aProfile.Identifier(), aDataProviderId ); |
|
622 |
|
623 // create sub-session and new task |
|
624 RSessionBase session = static_cast<RSessionBase>( aProfile.Session() ); |
|
625 User::LeaveIfError( CreateSubSession( session, ECmdCreateTask, args ) ); |
|
626 |
|
627 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
628 |
|
629 iData = CTaskSessionData::NewL( ETrue ); |
|
630 static_cast<CTaskSessionData*>(iData)->SetProfile( aProfile.Identifier() ); |
|
631 static_cast<CTaskSessionData*>(iData)->SetDataProvider( aDataProviderId ); |
|
632 static_cast<CTaskSessionData*>(iData)->SetServerDataSourceL( aServerDataSource ); |
|
633 static_cast<CTaskSessionData*>(iData)->SetClientDataSourceL( aClientDataSource ); |
|
634 |
|
635 CleanupStack::Pop(); // this |
|
636 |
|
637 _DBG_FILE("RSyncMLTask::CreateL(): end"); |
|
638 } |
|
639 |
|
640 // ----------------------------------------------------------------------------- |
|
641 // RSyncMLTask::CreateL() |
|
642 // Creates new task. Filters are copied. |
|
643 // Ownership is moved from caller. |
|
644 // ----------------------------------------------------------------------------- |
|
645 // |
|
646 EXPORT_C void RSyncMLTask::CreateL( RSyncMLDataSyncProfile& aProfile, TSmlDataProviderId aDataProviderId, |
|
647 const TDesC& aServerDataSource, const TDesC& aClientDataSource, |
|
648 RPointerArray<CSyncMLFilter>& aFilterArray ) |
|
649 { |
|
650 _DBG_FILE("RSyncMLTask::CreateL(): begin"); |
|
651 |
|
652 // check that we're allowed to write |
|
653 if ( aProfile.IsReadOnly() ) |
|
654 { |
|
655 User::Leave( KErrLocked ); |
|
656 } |
|
657 |
|
658 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
659 |
|
660 TPckgBuf<TInt> dataSize; |
|
661 |
|
662 TIpcArgs args( aProfile.Identifier(), aDataProviderId, &dataSize ); |
|
663 |
|
664 // create sub-session and new task |
|
665 RSessionBase session = static_cast<RSessionBase>( aProfile.Session() ); |
|
666 User::LeaveIfError( CreateSubSession( session, ECmdCreateTask, args ) ); |
|
667 |
|
668 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
669 |
|
670 iData = CTaskSessionData::NewL( ETrue ); |
|
671 static_cast<CTaskSessionData*>(iData)->SetProfile( aProfile.Identifier() ); |
|
672 static_cast<CTaskSessionData*>(iData)->SetDataProvider( aDataProviderId ); |
|
673 static_cast<CTaskSessionData*>(iData)->SetServerDataSourceL( aServerDataSource ); |
|
674 static_cast<CTaskSessionData*>(iData)->SetClientDataSourceL( aClientDataSource ); |
|
675 |
|
676 if ( aProfile.ProtocolVersion() == ESmlVersion1_2 ) |
|
677 { |
|
678 //Copy filters |
|
679 static_cast<CTaskSessionData*>(iData)->CopyTaskSupportedFiltersL( aFilterArray ); |
|
680 } |
|
681 |
|
682 CleanupStack::Pop(); // this |
|
683 } |
|
684 |
|
685 // ----------------------------------------------------------------------------- |
|
686 // RSyncMLTask::OpenL() |
|
687 // Opens given task. |
|
688 // ----------------------------------------------------------------------------- |
|
689 // |
|
690 EXPORT_C void RSyncMLTask::OpenL( RSyncMLDataSyncProfile& aProfile, TSmlTaskId aTaskId ) |
|
691 { |
|
692 _DBG_FILE("RSyncMLTask::OpenL(): begin"); |
|
693 |
|
694 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
695 |
|
696 CTaskSessionData* data = CTaskSessionData::NewLC(); |
|
697 |
|
698 TPckgBuf<TInt> dataSize; |
|
699 TIpcArgs args( &dataSize, aProfile.Identifier(), aTaskId ); |
|
700 |
|
701 // open the sub-session |
|
702 RSessionBase session = static_cast<RSessionBase>( aProfile.Session() ); |
|
703 User::LeaveIfError( CreateSubSession( session, ECmdTaskOpen, args ) ); |
|
704 |
|
705 data->SetIdentifier( aTaskId ); |
|
706 data->SetProfile( aProfile.Identifier() ); |
|
707 if ( aProfile.IsReadOnly() ) |
|
708 { |
|
709 data->SetReadOnly( ETrue ); |
|
710 } |
|
711 |
|
712 iData = data; |
|
713 CleanupStack::Pop(); // data |
|
714 |
|
715 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
716 |
|
717 // Create data buffer |
|
718 // dataSize contains now the size of the data buffer that is received next |
|
719 iData->SetBufferSizeL( dataSize() ); |
|
720 TPtr8 bufPtr = iData->DataBufferPtr(); |
|
721 |
|
722 TIpcArgs args2( &bufPtr ); |
|
723 User::LeaveIfError( SendReceive( ECmdTaskGet, args2 ) ); |
|
724 |
|
725 // internalize the buffer to iData |
|
726 RDesReadStream readStream; |
|
727 readStream.Open( bufPtr ); |
|
728 CleanupClosePushL( readStream ); |
|
729 |
|
730 iData->InternalizeL( readStream ); |
|
731 |
|
732 CleanupStack::PopAndDestroy(); // readStream |
|
733 CleanupStack::Pop(); // this |
|
734 |
|
735 _DBG_FILE("RSyncMLTask::OpenL(): end"); |
|
736 } |
|
737 |
|
738 // ----------------------------------------------------------------------------- |
|
739 // RSyncMLTask::Identifier() |
|
740 // Returns the id of this task. |
|
741 // ----------------------------------------------------------------------------- |
|
742 // |
|
743 EXPORT_C TSmlTaskId RSyncMLTask::Identifier() const |
|
744 { |
|
745 return static_cast<CTaskSessionData*>(iData)->Identifier(); |
|
746 } |
|
747 |
|
748 // ----------------------------------------------------------------------------- |
|
749 // RSyncMLTask::Profile() |
|
750 // Returns the id of the profile this task belongs to. |
|
751 // ----------------------------------------------------------------------------- |
|
752 // |
|
753 EXPORT_C TSmlProfileId RSyncMLTask::Profile() const |
|
754 { |
|
755 return static_cast<CTaskSessionData*>(iData)->Profile(); |
|
756 } |
|
757 |
|
758 // ----------------------------------------------------------------------------- |
|
759 // RSyncMLTask::CreatorId() |
|
760 // Returns creator id. |
|
761 // ----------------------------------------------------------------------------- |
|
762 // |
|
763 EXPORT_C TSmlCreatorId RSyncMLTask::CreatorId() const |
|
764 { |
|
765 return static_cast<CTaskSessionData*>(iData)->CreatorId(); |
|
766 } |
|
767 |
|
768 // ----------------------------------------------------------------------------- |
|
769 // RSyncMLTask::DisplayName() |
|
770 // Returns display name. |
|
771 // ----------------------------------------------------------------------------- |
|
772 // |
|
773 EXPORT_C const TDesC& RSyncMLTask::DisplayName() const |
|
774 { |
|
775 return static_cast<CTaskSessionData*>(iData)->DisplayName(); |
|
776 } |
|
777 |
|
778 // ----------------------------------------------------------------------------- |
|
779 // RSyncMLTask::ServerDataSource() |
|
780 // Returns the name of the remote data source. |
|
781 // ----------------------------------------------------------------------------- |
|
782 // |
|
783 EXPORT_C const TDesC& RSyncMLTask::ServerDataSource() const |
|
784 { |
|
785 return static_cast<CTaskSessionData*>(iData)->ServerDataSource(); |
|
786 } |
|
787 |
|
788 // ----------------------------------------------------------------------------- |
|
789 // RSyncMLTask::ClientDataSource() |
|
790 // Returns the name of the local data source. |
|
791 // ----------------------------------------------------------------------------- |
|
792 // |
|
793 EXPORT_C const TDesC& RSyncMLTask::ClientDataSource() const |
|
794 { |
|
795 return static_cast<CTaskSessionData*>(iData)->ClientDataSource(); |
|
796 } |
|
797 |
|
798 // ----------------------------------------------------------------------------- |
|
799 // RSyncMLTask::DataProvider() |
|
800 // Returns the id of the data provider that is used with this task. |
|
801 // ----------------------------------------------------------------------------- |
|
802 // |
|
803 EXPORT_C TSmlDataProviderId RSyncMLTask::DataProvider() const |
|
804 { |
|
805 return static_cast<CTaskSessionData*>(iData)->DataProvider(); |
|
806 } |
|
807 |
|
808 // ----------------------------------------------------------------------------- |
|
809 // RSyncMLTask::DefaultSyncType() |
|
810 // Returns default sync type. |
|
811 // ----------------------------------------------------------------------------- |
|
812 // |
|
813 EXPORT_C TSmlSyncType RSyncMLTask::DefaultSyncType() const |
|
814 { |
|
815 return static_cast<CTaskSessionData*>(iData)->DefaultSyncType(); |
|
816 } |
|
817 |
|
818 // ----------------------------------------------------------------------------- |
|
819 // RSyncMLTask::FilterMatchType() |
|
820 // Not supported. |
|
821 // ----------------------------------------------------------------------------- |
|
822 // |
|
823 EXPORT_C TSyncMLFilterMatchType RSyncMLTask::FilterMatchType() const |
|
824 { |
|
825 return static_cast<CTaskSessionData*>(iData)->FilterMatchType(); |
|
826 } |
|
827 |
|
828 // ----------------------------------------------------------------------------- |
|
829 // RSyncMLTask::Enabled() |
|
830 // Returns whether or not this task is enabled. |
|
831 // ----------------------------------------------------------------------------- |
|
832 // |
|
833 EXPORT_C TBool RSyncMLTask::Enabled() const |
|
834 { |
|
835 return static_cast<CTaskSessionData*>(iData)->Enabled(); |
|
836 } |
|
837 |
|
838 // ----------------------------------------------------------------------------- |
|
839 // RSyncMLTask::SetCreatorId() |
|
840 // Sets the creator id. |
|
841 // ----------------------------------------------------------------------------- |
|
842 // |
|
843 EXPORT_C void RSyncMLTask::SetCreatorId( TSmlCreatorId aCreatorId ) |
|
844 { |
|
845 static_cast<CTaskSessionData*>(iData)->SetCreatorId( aCreatorId ); |
|
846 } |
|
847 |
|
848 // ----------------------------------------------------------------------------- |
|
849 // RSyncMLTask::SetDisplayNameL() |
|
850 // Sets the display name. |
|
851 // ----------------------------------------------------------------------------- |
|
852 // |
|
853 EXPORT_C void RSyncMLTask::SetDisplayNameL( const TDesC& aDisplayName ) |
|
854 { |
|
855 static_cast<CTaskSessionData*>(iData)->SetDisplayNameL( aDisplayName ); |
|
856 } |
|
857 |
|
858 // ----------------------------------------------------------------------------- |
|
859 // RSyncMLTask::SetDefaultSyncTypeL() |
|
860 // Sets default sync type. |
|
861 // ----------------------------------------------------------------------------- |
|
862 // |
|
863 EXPORT_C void RSyncMLTask::SetDefaultSyncTypeL( TSmlSyncType aSyncType ) |
|
864 { |
|
865 static_cast<CTaskSessionData*>(iData)->SetDefaultSyncType( aSyncType ); |
|
866 } |
|
867 |
|
868 // ----------------------------------------------------------------------------- |
|
869 // RSyncMLTask::SetFilterMatchTypeL() |
|
870 // Not supported. |
|
871 // ----------------------------------------------------------------------------- |
|
872 // |
|
873 EXPORT_C void RSyncMLTask::SetFilterMatchTypeL( TSyncMLFilterMatchType aType ) const |
|
874 { |
|
875 static_cast<CTaskSessionData*>(iData)->SetFilterMatchType( aType ); |
|
876 } |
|
877 |
|
878 // ----------------------------------------------------------------------------- |
|
879 // RSyncMLTask::SetEnabledL() |
|
880 // Sets whether or not this task is enabled. |
|
881 // ----------------------------------------------------------------------------- |
|
882 // |
|
883 EXPORT_C void RSyncMLTask::SetEnabledL( TBool aEnabled ) |
|
884 { |
|
885 static_cast<CTaskSessionData*>(iData)->SetEnabled( aEnabled ); |
|
886 } |
|
887 |
|
888 // ----------------------------------------------------------------------------- |
|
889 // RSyncMLTask::SupportedServerFiltersL() |
|
890 // Not supported. |
|
891 // ----------------------------------------------------------------------------- |
|
892 // |
|
893 EXPORT_C RPointerArray<CSyncMLFilter>& RSyncMLTask::SupportedServerFiltersL( TSyncMLFilterChangeInfo& aChangeInfo ) const |
|
894 { |
|
895 TPckgBuf<TInt> dataSize; |
|
896 TInt taskId( static_cast<CTaskSessionData*>(iData)->Identifier() ); |
|
897 |
|
898 TIpcArgs args( &dataSize, taskId ); |
|
899 User::LeaveIfError( SendReceive( ECmdTaskFilterBufferSize, args ) ); |
|
900 |
|
901 // Create data buffer |
|
902 static_cast<CTaskSessionData*>(iData)->SetFilterBufSize( dataSize() ); |
|
903 iData->SetBufferSizeL( static_cast<CTaskSessionData*>(iData)->FilterBufSize() ); |
|
904 |
|
905 TPtr8 bufPtr = iData->DataBufferPtr(); |
|
906 |
|
907 TIpcArgs args2( &bufPtr ); |
|
908 User::LeaveIfError( SendReceive( ECmdTaskSupportedFilters, args2 ) ); |
|
909 |
|
910 static_cast<CTaskSessionData*>(iData)->SetTaskSupportedFiltersL( bufPtr ); |
|
911 |
|
912 aChangeInfo = static_cast<CTaskSessionData*>(iData)->FilterChangeInfo(); |
|
913 return static_cast<CTaskSessionData*>(iData)->FilterArray(); |
|
914 } |
|
915 |
|
916 // ----------------------------------------------------------------------------- |
|
917 // RSyncMLTask::SupportsUserSelectableMatchType() |
|
918 // Not supported. |
|
919 // ----------------------------------------------------------------------------- |
|
920 // |
|
921 EXPORT_C TBool RSyncMLTask::SupportsUserSelectableMatchType() const |
|
922 { |
|
923 return static_cast<CTaskSessionData*>(iData)->FilterMatchType() == ESyncMLMatchDisabled ? EFalse : ETrue; |
|
924 } |
|
925 |
|
926 // ----------------------------------------------------------------------------- |
|
927 // RSyncMLTask::IsReadOnly() |
|
928 // Return whether or not this task (sub-session) is in read-only mode. |
|
929 // ----------------------------------------------------------------------------- |
|
930 // |
|
931 EXPORT_C TBool RSyncMLTask::IsReadOnly() const |
|
932 { |
|
933 return static_cast<CTaskSessionData*>(iData)->IsReadOnly(); |
|
934 } |
|
935 |
|
936 // ----------------------------------------------------------------------------- |
|
937 // RSyncMLTask::UpdateL() |
|
938 // Updates data to server. |
|
939 // ----------------------------------------------------------------------------- |
|
940 // |
|
941 EXPORT_C void RSyncMLTask::UpdateL() |
|
942 { |
|
943 _DBG_FILE("RSyncMLTask::UpdateL(): begin"); |
|
944 |
|
945 // check that we're allowed to write |
|
946 if ( IsReadOnly() ) |
|
947 { |
|
948 User::Leave( KErrLocked ); |
|
949 } |
|
950 |
|
951 //get filter size |
|
952 TInt filterBufSize = static_cast<CTaskSessionData*>(iData)->FilterDataSize(); |
|
953 static_cast<CTaskSessionData*>(iData)->SetFilterBufSize( filterBufSize ); |
|
954 |
|
955 // use iData as a buffer where the data is externalized to |
|
956 iData->SetBufferSizeL(); |
|
957 |
|
958 RBufWriteStream bufStream( iData->DataBuffer() ); |
|
959 CleanupClosePushL( bufStream ); |
|
960 |
|
961 // externalize |
|
962 iData->ExternalizeL( bufStream ); |
|
963 |
|
964 TPtr8 bufPtr = iData->DataBufferPtr(); |
|
965 |
|
966 // update data to server |
|
967 TPckgBuf<TInt> id; |
|
968 TIpcArgs args( &id, &bufPtr ); |
|
969 User::LeaveIfError( SendReceive( ECmdTaskSet, args ) ); |
|
970 |
|
971 static_cast<CTaskSessionData*>(iData)->SetIdentifier( id() ); |
|
972 |
|
973 CleanupStack::PopAndDestroy(); // bufStream |
|
974 |
|
975 _DBG_FILE("RSyncMLTask::UpdateL(): end"); |
|
976 } |
|
977 |
|
978 // ----------------------------------------------------------------------------- |
|
979 // RSyncMLTask::Close() |
|
980 // Closes sub-session. |
|
981 // ----------------------------------------------------------------------------- |
|
982 // |
|
983 EXPORT_C void RSyncMLTask::Close() |
|
984 { |
|
985 _DBG_FILE("RSyncMLTask::Close(): begin"); |
|
986 |
|
987 CloseSubSession( ECmdTaskClose ); |
|
988 |
|
989 delete iData; |
|
990 iData = NULL; |
|
991 |
|
992 _DBG_FILE("RSyncMLTask::Close(): end"); |
|
993 } |
|
994 |
|
995 |
|
996 // |
|
997 // RSyncMLDataProvider |
|
998 // |
|
999 |
|
1000 // ----------------------------------------------------------------------------- |
|
1001 // RSyncMLDataProvider::RSyncMLDataProvider() |
|
1002 // Constructor. |
|
1003 // ----------------------------------------------------------------------------- |
|
1004 // |
|
1005 EXPORT_C RSyncMLDataProvider::RSyncMLDataProvider() |
|
1006 : iData( NULL ) |
|
1007 { |
|
1008 } |
|
1009 |
|
1010 // ----------------------------------------------------------------------------- |
|
1011 // RSyncMLDataProvider::OpenL() |
|
1012 // Opens given data provider. |
|
1013 // ----------------------------------------------------------------------------- |
|
1014 // |
|
1015 EXPORT_C void RSyncMLDataProvider::OpenL( RSyncMLSession& aSession, TSmlDataProviderId aDataProviderId ) |
|
1016 { |
|
1017 _DBG_FILE("RSyncMLDataProvider::OpenL(): begin"); |
|
1018 |
|
1019 // check that data provider is not yet open and ds sync is supported |
|
1020 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
1021 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
1022 |
|
1023 CDataProviderSessionData* data = new (ELeave) CDataProviderSessionData(); |
|
1024 CleanupStack::PushL( data ); |
|
1025 |
|
1026 TPckgBuf<TInt> dataSize; |
|
1027 TIpcArgs args( &dataSize, aDataProviderId ); |
|
1028 |
|
1029 // open the sub-session |
|
1030 User::LeaveIfError( CreateSubSession( aSession, ECmdDataProviderOpen, args ) ); |
|
1031 |
|
1032 data->SetIdentifier( aDataProviderId ); |
|
1033 |
|
1034 iData = data; |
|
1035 CleanupStack::Pop(); // data |
|
1036 |
|
1037 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
1038 |
|
1039 // dataSize contains now the size of the data buffer that is received next |
|
1040 iData->SetBufferSizeL( dataSize() ); |
|
1041 TPtr8 bufPtr = iData->DataBufferPtr(); |
|
1042 |
|
1043 TIpcArgs args2( &bufPtr ); |
|
1044 User::LeaveIfError( SendReceive( ECmdDataProviderGet, args2 ) ); |
|
1045 |
|
1046 // internalize the buffer to data |
|
1047 RDesReadStream readStream; |
|
1048 readStream.Open( bufPtr ); |
|
1049 CleanupClosePushL( readStream ); |
|
1050 iData->InternalizeL( readStream ); |
|
1051 |
|
1052 CleanupStack::PopAndDestroy(); // readStream |
|
1053 CleanupStack::Pop(); // this |
|
1054 |
|
1055 _DBG_FILE("RSyncMLDataProvider::OpenL(): end"); |
|
1056 } |
|
1057 |
|
1058 // ----------------------------------------------------------------------------- |
|
1059 // RSyncMLDataProvider::Identifier() |
|
1060 // Return the id of this data provider. |
|
1061 // ----------------------------------------------------------------------------- |
|
1062 // |
|
1063 EXPORT_C TSmlDataProviderId RSyncMLDataProvider::Identifier() const |
|
1064 { |
|
1065 return static_cast<CDataProviderSessionData*>(iData)->Identifier(); |
|
1066 } |
|
1067 |
|
1068 // ----------------------------------------------------------------------------- |
|
1069 // RSyncMLDataProvider::Version() |
|
1070 // Return the version of this data provider. |
|
1071 // ----------------------------------------------------------------------------- |
|
1072 // |
|
1073 EXPORT_C TVersion RSyncMLDataProvider::Version() const |
|
1074 { |
|
1075 return static_cast<CDataProviderSessionData*>(iData)->Version(); |
|
1076 } |
|
1077 |
|
1078 // ----------------------------------------------------------------------------- |
|
1079 // RSyncMLDataProvider::DisplayName() |
|
1080 // Returns the display name of this data provider. |
|
1081 // ----------------------------------------------------------------------------- |
|
1082 // |
|
1083 EXPORT_C const TDesC& RSyncMLDataProvider::DisplayName() const |
|
1084 { |
|
1085 return static_cast<CDataProviderSessionData*>(iData)->DisplayName(); |
|
1086 } |
|
1087 |
|
1088 // ----------------------------------------------------------------------------- |
|
1089 // RSyncMLDataProvider::MimeTypeCount() |
|
1090 // Returns the amount of mime types this data provider has. |
|
1091 // ----------------------------------------------------------------------------- |
|
1092 // |
|
1093 EXPORT_C TInt RSyncMLDataProvider::MimeTypeCount() const |
|
1094 { |
|
1095 return static_cast<CDataProviderSessionData*>(iData)->MimeTypeCount(); |
|
1096 } |
|
1097 |
|
1098 // ----------------------------------------------------------------------------- |
|
1099 // RSyncMLDataProvider::MimeType() |
|
1100 // Return the mime type in given index. |
|
1101 // ----------------------------------------------------------------------------- |
|
1102 // |
|
1103 EXPORT_C const TDesC& RSyncMLDataProvider::MimeType( TInt aIndex ) const |
|
1104 { |
|
1105 return static_cast<CDataProviderSessionData*>(iData)->MimeType( aIndex ); |
|
1106 } |
|
1107 |
|
1108 // ----------------------------------------------------------------------------- |
|
1109 // RSyncMLDataProvider::MimeVersion() |
|
1110 // Return the mime version in the given index. |
|
1111 // ----------------------------------------------------------------------------- |
|
1112 // |
|
1113 EXPORT_C const TDesC& RSyncMLDataProvider::MimeVersion( TInt aIndex ) const |
|
1114 { |
|
1115 return static_cast<CDataProviderSessionData*>(iData)->MimeVersion( aIndex ); |
|
1116 } |
|
1117 |
|
1118 // ----------------------------------------------------------------------------- |
|
1119 // RSyncMLDataProvider::DefaultDataStoreName() |
|
1120 // Return the name of the default data store. |
|
1121 // ----------------------------------------------------------------------------- |
|
1122 // |
|
1123 EXPORT_C const TDesC& RSyncMLDataProvider::DefaultDataStoreName() const |
|
1124 { |
|
1125 return static_cast<CDataProviderSessionData*>(iData)->DefaultDataStoreName(); |
|
1126 } |
|
1127 |
|
1128 // ----------------------------------------------------------------------------- |
|
1129 // RSyncMLDataProvider::AllowsMultipleDataStores() |
|
1130 // Returns whether or not this data provider supports multiple data stores. |
|
1131 // ----------------------------------------------------------------------------- |
|
1132 // |
|
1133 EXPORT_C TBool RSyncMLDataProvider::AllowsMultipleDataStores() const |
|
1134 { |
|
1135 return static_cast<CDataProviderSessionData*>(iData)->AllowsMultipleDataStores(); |
|
1136 } |
|
1137 |
|
1138 // ----------------------------------------------------------------------------- |
|
1139 // RSyncMLDataProvider::GetDataStoreNamesL() |
|
1140 // On return, aArray contains the names of all supported data stores |
|
1141 // including the default store which is listed first. |
|
1142 // ----------------------------------------------------------------------------- |
|
1143 // |
|
1144 EXPORT_C void RSyncMLDataProvider::GetDataStoreNamesL( CDesCArray& aArray ) const |
|
1145 { |
|
1146 static_cast<CDataProviderSessionData*>(iData)->GetDataStoreNamesL( aArray ); |
|
1147 } |
|
1148 |
|
1149 // ----------------------------------------------------------------------------- |
|
1150 // RSyncMLDataProvider::RequiredProtocolVersionL() |
|
1151 // Returns the protocol version this data provider requires. |
|
1152 // ----------------------------------------------------------------------------- |
|
1153 // |
|
1154 EXPORT_C TSmlProtocolVersion RSyncMLDataProvider::RequiredProtocolVersionL() const |
|
1155 { |
|
1156 return static_cast<CDataProviderSessionData*>(iData)->RequiredProtocolVersion(); |
|
1157 } |
|
1158 |
|
1159 // ----------------------------------------------------------------------------- |
|
1160 // RSyncMLDataProvider::Close() |
|
1161 // Closes the sub-session. |
|
1162 // ----------------------------------------------------------------------------- |
|
1163 // |
|
1164 EXPORT_C void RSyncMLDataProvider::Close() |
|
1165 { |
|
1166 _DBG_FILE("RSyncMLDataProvider::Close(): begin"); |
|
1167 |
|
1168 CloseSubSession( ECmdDataProviderClose ); |
|
1169 |
|
1170 delete iData; |
|
1171 iData = NULL; |
|
1172 |
|
1173 _DBG_FILE("RSyncMLDataProvider::Close(): end"); |
|
1174 } |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |