|
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 common client api. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <s32mem.h> |
|
23 #include <eikdll.h> |
|
24 #include <f32file.h> |
|
25 #include <ecom.h> |
|
26 #include <implementationinformation.h> |
|
27 #include <featmgr.h> |
|
28 #include <SyncMLClient.h> |
|
29 |
|
30 #include <nsmlconstants.h> |
|
31 #include <nsmldebug.h> |
|
32 #include <nsmldsconstants.h> |
|
33 #include "NSmlClientAPIDefs.h" |
|
34 #include "NSmlClientAPIUtils.h" |
|
35 #include "NSmlClientAPIActiveCallback.h" |
|
36 #include "nsmlsosserverdefs.h" |
|
37 |
|
38 |
|
39 // ============================= LOCAL FUNCTIONS =============================== |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // LaunchServerL() |
|
43 // Launches the server. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 TInt LaunchServerL() |
|
47 { |
|
48 _DBG_FILE("SyncML Client API LaunchServerL(): begin"); |
|
49 |
|
50 TInt res = KErrNone; |
|
51 |
|
52 // DLL launch |
|
53 RProcess server; |
|
54 res = server.Create(KServerExeName, KNullDesC); |
|
55 |
|
56 // Loading failed. |
|
57 User::LeaveIfError( res ); |
|
58 |
|
59 TRequestStatus status; |
|
60 server.Rendezvous(status); |
|
61 |
|
62 if (status != KRequestPending) |
|
63 { |
|
64 server.Kill(0); // abort startup |
|
65 server.Close(); |
|
66 return KErrGeneral; // status can be KErrNone: don't return status.Int() |
|
67 } |
|
68 else |
|
69 { |
|
70 server.Resume(); // logon OK - start the server |
|
71 } |
|
72 |
|
73 User::WaitForRequest(status); |
|
74 |
|
75 server.Close(); |
|
76 |
|
77 _DBG_FILE("SyncML Client API LaunchServerL(): end"); |
|
78 |
|
79 return status.Int(); |
|
80 } |
|
81 |
|
82 |
|
83 // ============================ MEMBER FUNCTIONS =============================== |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // RSyncMLSession::RSyncMLSession() |
|
87 // Constructor. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 EXPORT_C RSyncMLSession::RSyncMLSession() |
|
91 : RSessionBase(), iData( NULL ), iEventCallback( NULL ) |
|
92 { |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // RSyncMLSession::OpenL() |
|
97 // Opens sync session. |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C void RSyncMLSession::OpenL() |
|
101 { |
|
102 _DBG_FILE("RSyncMLSession::OpenL(): begin"); |
|
103 |
|
104 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
105 |
|
106 const TVersion KServerVersion( KNSmlSOSServerVersionMajor, KNSmlSOSServerVersionMinor, 0 ); |
|
107 |
|
108 TInt res = KErrNone; |
|
109 res = CreateSession( KSOSServerName, KServerVersion, KDefaultMessageSlots ); |
|
110 |
|
111 if ( res != KErrNone ) |
|
112 { |
|
113 res = LaunchServerL(); |
|
114 User::LeaveIfError( res ); |
|
115 res = CreateSession( KSOSServerName, KServerVersion, KDefaultMessageSlots ); |
|
116 } |
|
117 |
|
118 User::LeaveIfError( res ); |
|
119 |
|
120 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
121 |
|
122 // init feature manager and data |
|
123 FeatureManager::InitializeLibL(); |
|
124 iData = new (ELeave) CClientSessionData; |
|
125 |
|
126 CleanupStack::Pop(); // this |
|
127 _DBG_FILE("RSyncMLSession::OpenL(): end"); |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // RSyncMLSession::RequestEventL() |
|
132 // Begins notifing the given observer of sync events. |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C void RSyncMLSession::RequestEventL( MSyncMLEventObserver& aEventObserver ) |
|
136 { |
|
137 _DBG_FILE("RSyncMLSession::RequestEventL(): begin"); |
|
138 |
|
139 if ( !iEventCallback ) |
|
140 { |
|
141 // callback not yet created, create |
|
142 iEventCallback = new (ELeave) CSmlActiveCallback( *this ); |
|
143 } |
|
144 |
|
145 iEventCallback->SetEventObserverL( aEventObserver ); |
|
146 |
|
147 _DBG_FILE("RSyncMLSession::RequestEventL(): end"); |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // RSyncMLSession::CancelEvent() |
|
152 // Cancels event notification. |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 EXPORT_C void RSyncMLSession::CancelEvent() |
|
156 { |
|
157 _DBG_FILE("RSyncMLSession::CancelEvent(): begin"); |
|
158 |
|
159 if ( iEventCallback ) |
|
160 { |
|
161 iEventCallback->CancelEvent(); |
|
162 } |
|
163 |
|
164 _DBG_FILE("RSyncMLSession::CancelEvent(): end"); |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // RSyncMLSession::RequestProgressL() |
|
169 // Begins notifing the given observer of sync progress. |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 EXPORT_C void RSyncMLSession::RequestProgressL( MSyncMLProgressObserver& aProgressObserver ) |
|
173 { |
|
174 _DBG_FILE("RSyncMLSession::RequestProgressL(): begin"); |
|
175 |
|
176 if ( !iEventCallback ) |
|
177 { |
|
178 // callback not yet created, create |
|
179 iEventCallback = new (ELeave) CSmlActiveCallback( *this ); |
|
180 } |
|
181 |
|
182 iEventCallback->SetProgressObserverL( aProgressObserver ); |
|
183 |
|
184 _DBG_FILE("RSyncMLSession::RequestProgressL(): end"); |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // RSyncMLSession::CancelProgress() |
|
189 // Cancels progress notification. |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 EXPORT_C void RSyncMLSession::CancelProgress() |
|
193 { |
|
194 _DBG_FILE("RSyncMLSession::CancelProgress(): begin"); |
|
195 |
|
196 if ( iEventCallback ) |
|
197 { |
|
198 iEventCallback->CancelProgress(); |
|
199 } |
|
200 |
|
201 _DBG_FILE("RSyncMLSession::CancelProgress(): end"); |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // RSyncMLSession::CurrentJobL() |
|
206 // Fetches the id and usage type of currently running job. |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 EXPORT_C void RSyncMLSession::CurrentJobL( TSmlJobId& aJobId, TSmlUsageType& aUsageType ) const |
|
210 { |
|
211 _DBG_FILE("RSyncMLSession::CurrentJobL(): begin"); |
|
212 |
|
213 TPckgBuf<TInt> jobId( aJobId ); |
|
214 TPckgBuf<TInt> usageType( (TInt)aUsageType ); |
|
215 |
|
216 User::LeaveIfError( SendReceive( ECmdJobListCurrent, TIpcArgs( &jobId, &usageType ) ) ); |
|
217 |
|
218 aJobId = jobId(); |
|
219 aUsageType = (TSmlUsageType) usageType(); |
|
220 |
|
221 _DBG_FILE("RSyncMLSession::CurrentJobL(): end"); |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // RSyncMLSession::ListQueuedJobsL() |
|
226 // List the jobs that are currently in server's job queue. |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 EXPORT_C void RSyncMLSession::ListQueuedJobsL( RArray<TSmlJobId>& aArray, TSmlUsageType aType ) const |
|
230 { |
|
231 _DBG_FILE("RSyncMLSession::ListQueuedJobsL(): begin"); |
|
232 |
|
233 // check that usage type is supported |
|
234 NSmlClientAPIFeatureHandler::LeaveIfUsageTypeNotSupportedL( aType ); |
|
235 |
|
236 ReceiveArrayL( aArray, ECmdJobListStart, ECmdJobListNext, aType ); |
|
237 |
|
238 _DBG_FILE("RSyncMLSession::ListQueuedJobsL(): end"); |
|
239 } |
|
240 |
|
241 // ----------------------------------------------------------------------------- |
|
242 // RSyncMLSession::ListProfilesL() |
|
243 // List the profiles of given usage type. |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 EXPORT_C void RSyncMLSession::ListProfilesL( RArray<TSmlProfileId>& aArray, TSmlUsageType aType ) const |
|
247 { |
|
248 _DBG_FILE("RSyncMLSession::ListProfilesL(): begin"); |
|
249 |
|
250 // check that usage type is supported |
|
251 NSmlClientAPIFeatureHandler::LeaveIfUsageTypeNotSupportedL( aType ); |
|
252 |
|
253 ReceiveArrayL( aArray, ECmdProfileListStart, ECmdProfileListNext, aType ); |
|
254 |
|
255 _DBG_FILE("RSyncMLSession::ListProfilesL(): end"); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // RSyncMLSession::ListTransportsL() |
|
260 // Lists the transports available. Uses FeatureManager to find out |
|
261 // which transports are at use. |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 EXPORT_C void RSyncMLSession::ListTransportsL( RArray<TSmlTransportId>& aTransportIds ) const |
|
265 { |
|
266 _DBG_FILE("RSyncMLSession::ListTransportsL(): begin"); |
|
267 aTransportIds.Reset(); |
|
268 |
|
269 //Checking if internet transport type is supported |
|
270 if ( FeatureManager::FeatureSupported( KFeatureIdSyncMlDsOverHttp ) ) |
|
271 { |
|
272 aTransportIds.AppendL( KUidNSmlMediumTypeInternet.iUid ); |
|
273 } |
|
274 |
|
275 // if obex is supported, see which obex transports are supported |
|
276 if ( FeatureManager::FeatureSupported( KFeatureIdSyncMlObex ) ) |
|
277 { |
|
278 // bluetooth |
|
279 if ( FeatureManager::FeatureSupported( KFeatureIdBt ) ) |
|
280 { |
|
281 aTransportIds.AppendL( KUidNSmlMediumTypeBluetooth.iUid ); |
|
282 } |
|
283 } |
|
284 |
|
285 _DBG_FILE("RSyncMLSession::ListTransportsL(): end"); |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // RSyncMLSession::ListDataProvidersL() |
|
290 // Lists the DS adapters available. Uses ECom services |
|
291 // for the task. |
|
292 // ----------------------------------------------------------------------------- |
|
293 // |
|
294 EXPORT_C void RSyncMLSession::ListDataProvidersL( RArray<TSmlDataProviderId>& aDataProviderIds ) const |
|
295 { |
|
296 _DBG_FILE("RSyncMLSession::ListDataProvidersL(): begin"); |
|
297 |
|
298 // check that ds sync is supported |
|
299 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
300 |
|
301 aDataProviderIds.Reset(); |
|
302 |
|
303 RImplInfoPtrArray implArray; |
|
304 CleanupStack::PushL( PtrArrCleanupItemRArr( CImplementationInformation, &implArray ) ); |
|
305 TUid ifUid = { KNSmlDSInterfaceUid }; |
|
306 REComSession::ListImplementationsL( ifUid, implArray ); |
|
307 |
|
308 // append adapter id's to the given array |
|
309 for ( TInt i = 0; i < implArray.Count(); i++ ) |
|
310 { |
|
311 CImplementationInformation* implInfo = implArray[i]; |
|
312 aDataProviderIds.AppendL( implInfo->ImplementationUid().iUid ); |
|
313 } |
|
314 |
|
315 REComSession::FinalClose(); |
|
316 CleanupStack::PopAndDestroy(); // implArray |
|
317 |
|
318 _DBG_FILE("RSyncMLSession::ListDataProvidersL(): end"); |
|
319 } |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // RSyncMLSession::DeleteProfileL() |
|
323 // Deletes the given profile. |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 EXPORT_C void RSyncMLSession::DeleteProfileL( TSmlProfileId aId ) |
|
327 { |
|
328 _DBG_FILE("RSyncMLSession::DeleteProfileL(): begin"); |
|
329 |
|
330 TIpcArgs args( aId ); |
|
331 User::LeaveIfError( SendReceive( ECmdProfileDelete, args ) ); |
|
332 |
|
333 _DBG_FILE("RSyncMLSession::DeleteProfileL(): end"); |
|
334 } |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // RSyncMLSession::ListProtocolVersionsL() |
|
338 // Returns the default supported protocol for given usage type. |
|
339 // On return, aVersions array includes all the protocol |
|
340 // versions supported. |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 EXPORT_C TSmlProtocolVersion RSyncMLSession::ListProtocolVersionsL( TSmlUsageType aUsageType, RArray<TSmlProtocolVersion>& aVersions ) const |
|
344 { |
|
345 _DBG_FILE("RSyncMLSession::ListProtocolVersionsL(): begin"); |
|
346 |
|
347 // check that given usage type is supported |
|
348 NSmlClientAPIFeatureHandler::LeaveIfUsageTypeNotSupportedL( aUsageType ); |
|
349 |
|
350 TSmlProtocolVersion defaultVersion( ESmlVersion1_1_2 ); |
|
351 |
|
352 switch ( aUsageType ) |
|
353 { |
|
354 case ESmlDataSync: |
|
355 defaultVersion = ESmlVersion1_2; |
|
356 aVersions.AppendL( ESmlVersion1_2 ); |
|
357 break; |
|
358 case ESmlDevMan: |
|
359 if(!FeatureManager::FeatureSupported( KFeatureIdSyncMlDm112 )) |
|
360 { |
|
361 defaultVersion = ESmlVersion1_2; |
|
362 aVersions.AppendL( ESmlVersion1_2 ); |
|
363 } |
|
364 else |
|
365 { |
|
366 defaultVersion = ESmlVersion1_1_2; |
|
367 } |
|
368 break; |
|
369 default: |
|
370 break; |
|
371 } |
|
372 |
|
373 // both dm and ds support 1.1.2 |
|
374 aVersions.AppendL( ESmlVersion1_1_2 ); |
|
375 |
|
376 _DBG_FILE("RSyncMLSession::ListProtocolVersionsL(): end"); |
|
377 |
|
378 return defaultVersion; |
|
379 } |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // RSyncMLSession::Close() |
|
383 // Closes the session. |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 EXPORT_C void RSyncMLSession::Close() |
|
387 { |
|
388 _DBG_FILE("RSyncMLSession::Close(): begin"); |
|
389 |
|
390 // uninitialize feature manager |
|
391 FeatureManager::UnInitializeLib(); |
|
392 |
|
393 delete iEventCallback; |
|
394 iEventCallback = NULL; |
|
395 |
|
396 delete iData; |
|
397 iData = NULL; |
|
398 |
|
399 // close session |
|
400 RSessionBase::Close(); |
|
401 |
|
402 _DBG_FILE("RSyncMLSession::Close(): end"); |
|
403 } |
|
404 |
|
405 // ----------------------------------------------------------------------------- |
|
406 // RSyncMLSession::ReceiveArrayL() |
|
407 // Private utility method for receiving arrays of integers. |
|
408 // ----------------------------------------------------------------------------- |
|
409 // |
|
410 void RSyncMLSession::ReceiveArrayL( RArray<TInt>& aArray, TInt aStart, TInt aNext, TInt aUsageType ) const |
|
411 { |
|
412 _DBG_FILE("RSyncMLSession::ReceiveArrayL(): begin"); |
|
413 |
|
414 aArray.Reset(); |
|
415 |
|
416 iData->SetBufferSizeL( KNSmlMaxIntFetchCount*KSizeofTInt32 + KSizeofTInt8 ); |
|
417 TPtr8& dataPtr = iData->DataBufferPtr(); |
|
418 |
|
419 // IPC |
|
420 TIpcArgs args( &dataPtr, aUsageType ); |
|
421 TInt err = SendReceive( aStart, args ); |
|
422 |
|
423 if ( err == KErrNone || err == KErrOverflow ) |
|
424 { |
|
425 iData->ReadIntegersToArrayL( aArray ); // integers to array |
|
426 |
|
427 while ( err == KErrOverflow ) |
|
428 { |
|
429 dataPtr.Zero(); |
|
430 |
|
431 // new IPC |
|
432 args.Set( 0, &dataPtr ); |
|
433 err = SendReceive( aNext, args ); |
|
434 |
|
435 if ( err == KErrNone || err == KErrOverflow ) |
|
436 { |
|
437 iData->ReadIntegersToArrayL( aArray ); // integers to array |
|
438 } |
|
439 } |
|
440 } |
|
441 |
|
442 User::LeaveIfError( err ); |
|
443 |
|
444 _DBG_FILE("RSyncMLSession::ReceiveArrayL(): end"); |
|
445 } |
|
446 |
|
447 |
|
448 // |
|
449 // RSyncMLSettings ( Not Supported ) |
|
450 // |
|
451 |
|
452 // ----------------------------------------------------------------------------- |
|
453 // RSyncMLSettings::OpenL() |
|
454 // ----------------------------------------------------------------------------- |
|
455 // |
|
456 EXPORT_C void RSyncMLSettings::OpenL( RSyncMLSession& ) |
|
457 { |
|
458 User::Leave( KErrNotSupported ); |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // RSyncMLSettings::GetValueL() |
|
463 // ----------------------------------------------------------------------------- |
|
464 // |
|
465 EXPORT_C TInt RSyncMLSettings::GetValueL( TSmlGlobalSetting ) const |
|
466 { |
|
467 User::Leave( KErrNotSupported ); |
|
468 return 0; |
|
469 } |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // RSyncMLSettings::SetValueL() |
|
473 // ----------------------------------------------------------------------------- |
|
474 // |
|
475 EXPORT_C void RSyncMLSettings::SetValueL( TSmlGlobalSetting, TInt ) |
|
476 { |
|
477 User::Leave( KErrNotSupported ); |
|
478 } |
|
479 |
|
480 // ----------------------------------------------------------------------------- |
|
481 // RSyncMLSettings::Close() |
|
482 // ----------------------------------------------------------------------------- |
|
483 // |
|
484 EXPORT_C void RSyncMLSettings::Close() |
|
485 { |
|
486 } |
|
487 |
|
488 |
|
489 // |
|
490 // RSyncMLHistoryLog |
|
491 // |
|
492 |
|
493 |
|
494 // ----------------------------------------------------------------------------- |
|
495 // RSyncMLHistoryLog::RSyncMLHistoryLog() |
|
496 // Constructor. |
|
497 // ----------------------------------------------------------------------------- |
|
498 // |
|
499 EXPORT_C RSyncMLHistoryLog::RSyncMLHistoryLog() |
|
500 : RSubSessionBase(), iData( NULL ) |
|
501 { |
|
502 } |
|
503 |
|
504 // ----------------------------------------------------------------------------- |
|
505 // RSyncMLHistoryLog::OpenL() |
|
506 // Opens history log sub-session. |
|
507 // ----------------------------------------------------------------------------- |
|
508 // |
|
509 EXPORT_C void RSyncMLHistoryLog::OpenL( RSyncMLSession& aSession, TSmlProfileId aProfileId ) |
|
510 { |
|
511 _DBG_FILE("RSyncMLHistoryLog::OpenL(): begin"); |
|
512 |
|
513 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
514 |
|
515 CHistoryLogSessionData* data = CHistoryLogSessionData::NewLC(); |
|
516 |
|
517 TPckgBuf<TInt> dataSize; |
|
518 TIpcArgs args( &dataSize, aProfileId ); |
|
519 |
|
520 // open the sub-session |
|
521 User::LeaveIfError( CreateSubSession( aSession, ECmdHistoryLogOpen, args ) ); |
|
522 |
|
523 data->SetProfile( aProfileId ); |
|
524 |
|
525 iData = data; |
|
526 CleanupStack::Pop(); // data |
|
527 |
|
528 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
529 |
|
530 if ( dataSize() > 0 ) |
|
531 { |
|
532 // dataSize contains now the size of the data buffer that is received next |
|
533 iData->SetBufferSizeL( dataSize() ); |
|
534 TPtr8 dataPtr = iData->DataBufferPtr(); |
|
535 |
|
536 TIpcArgs args2( &dataPtr ); |
|
537 User::LeaveIfError( SendReceive( ECmdHistoryLogGet, args2 ) ); |
|
538 |
|
539 // internalize the buffer to data |
|
540 RDesReadStream readStream; |
|
541 readStream.Open( dataPtr ); |
|
542 CleanupClosePushL( readStream ); |
|
543 iData->InternalizeL( readStream ); |
|
544 |
|
545 CleanupStack::PopAndDestroy(); // readStream |
|
546 } |
|
547 |
|
548 CleanupStack::Pop(); // this |
|
549 |
|
550 _DBG_FILE("RSyncMLHistoryLog::OpenL(): end"); |
|
551 } |
|
552 |
|
553 // ----------------------------------------------------------------------------- |
|
554 // RSyncMLHistoryLog::SortEntries() |
|
555 // Sorts history log entries according to the given order. |
|
556 // ----------------------------------------------------------------------------- |
|
557 // |
|
558 EXPORT_C void RSyncMLHistoryLog::SortEntries( CSyncMLHistoryEntry::TSortOrder aSortOrder ) |
|
559 { |
|
560 _DBG_FILE("RSyncMLHistoryLog::SortEntries(): begin"); |
|
561 static_cast<CHistoryLogSessionData*>(iData)->History().SortEntries( aSortOrder ); |
|
562 _DBG_FILE("RSyncMLHistoryLog::SortEntries(): end"); |
|
563 } |
|
564 |
|
565 // ----------------------------------------------------------------------------- |
|
566 // RSyncMLHistoryLog::DeleteAllEntriesL() |
|
567 // Empties the history for this profile (from both server and client |
|
568 // side buffer). |
|
569 // ----------------------------------------------------------------------------- |
|
570 // |
|
571 EXPORT_C void RSyncMLHistoryLog::DeleteAllEntriesL() |
|
572 { |
|
573 _DBG_FILE("RSyncMLHistoryLog::DeleteAllEntriesL(): begin"); |
|
574 |
|
575 // send reset to server |
|
576 User::LeaveIfError( SendReceive( ECmdHistoryLogReset ) ); |
|
577 |
|
578 // delete entries from buffer |
|
579 static_cast<CHistoryLogSessionData*>(iData)->History().DeleteAllEntries(); |
|
580 |
|
581 _DBG_FILE("RSyncMLHistoryLog::DeleteAllEntriesL(): end"); |
|
582 } |
|
583 |
|
584 // ----------------------------------------------------------------------------- |
|
585 // RSyncMLHistoryLog::Profile() |
|
586 // Returns the id of the profile that was given in OpenL, i.e the profile |
|
587 // whose history has been opened. |
|
588 // ----------------------------------------------------------------------------- |
|
589 // |
|
590 EXPORT_C TSmlProfileId RSyncMLHistoryLog::Profile() const |
|
591 { |
|
592 return static_cast<CHistoryLogSessionData*>(iData)->Profile(); |
|
593 } |
|
594 |
|
595 // ----------------------------------------------------------------------------- |
|
596 // RSyncMLHistoryLog::Count() |
|
597 // Returns the count of history entries. |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 EXPORT_C TInt RSyncMLHistoryLog::Count() const |
|
601 { |
|
602 return static_cast<CHistoryLogSessionData*>(iData)->History().Count(); |
|
603 } |
|
604 |
|
605 // ----------------------------------------------------------------------------- |
|
606 // RSyncMLHistoryLog::Entry() |
|
607 // Returns the history entry in the given index. |
|
608 // ----------------------------------------------------------------------------- |
|
609 // |
|
610 EXPORT_C const CSyncMLHistoryEntry& RSyncMLHistoryLog::Entry( TInt aIndex ) const |
|
611 { |
|
612 return static_cast<CHistoryLogSessionData*>(iData)->History().Entry( aIndex ); |
|
613 } |
|
614 |
|
615 // ----------------------------------------------------------------------------- |
|
616 // RSyncMLHistoryLog::Close() |
|
617 // Close sub-session. |
|
618 // ----------------------------------------------------------------------------- |
|
619 // |
|
620 EXPORT_C void RSyncMLHistoryLog::Close() |
|
621 { |
|
622 _DBG_FILE("RSyncMLHistoryLog::Close(): begin"); |
|
623 CloseSubSession( ECmdHistoryLogClose ); |
|
624 |
|
625 delete iData; |
|
626 iData = NULL; |
|
627 _DBG_FILE("RSyncMLHistoryLog::Close(): end"); |
|
628 } |
|
629 |
|
630 |
|
631 |
|
632 // |
|
633 // RSyncMLJobBase |
|
634 // |
|
635 |
|
636 |
|
637 // ----------------------------------------------------------------------------- |
|
638 // RSyncMLJobBase::Identifier() |
|
639 // Return the id of the job. |
|
640 // ----------------------------------------------------------------------------- |
|
641 // |
|
642 EXPORT_C TSmlJobId RSyncMLJobBase::Identifier() const |
|
643 { |
|
644 return static_cast<CJobBaseSessionData*>(iData)->Identifier(); |
|
645 } |
|
646 |
|
647 // ----------------------------------------------------------------------------- |
|
648 // RSyncMLJobBase::Profile() |
|
649 // Returns the id of the profile used in the job. |
|
650 // ----------------------------------------------------------------------------- |
|
651 // |
|
652 EXPORT_C TSmlProfileId RSyncMLJobBase::Profile() const |
|
653 { |
|
654 return static_cast<CJobBaseSessionData*>(iData)->Profile(); |
|
655 } |
|
656 |
|
657 // ----------------------------------------------------------------------------- |
|
658 // RSyncMLJobBase::Close() |
|
659 // Closes sub-session. |
|
660 // ----------------------------------------------------------------------------- |
|
661 // |
|
662 EXPORT_C void RSyncMLJobBase::Close() |
|
663 { |
|
664 _DBG_FILE("RSyncMLJobBase::Close(): begin"); |
|
665 CloseSubSession( ECmdJobClose ); |
|
666 |
|
667 delete iData; |
|
668 iData = NULL; |
|
669 _DBG_FILE("RSyncMLJobBase::Close(): end"); |
|
670 } |
|
671 |
|
672 // ----------------------------------------------------------------------------- |
|
673 // RSyncMLJobBase::RSyncMLJobBase() |
|
674 // Constructor. |
|
675 // ----------------------------------------------------------------------------- |
|
676 // |
|
677 RSyncMLJobBase::RSyncMLJobBase() |
|
678 : RSubSessionBase(), iData( NULL ) |
|
679 { |
|
680 } |
|
681 |
|
682 // ----------------------------------------------------------------------------- |
|
683 // RSyncMLJobBase::GetJobL() |
|
684 // Fetches the job's data from server. |
|
685 // ----------------------------------------------------------------------------- |
|
686 // |
|
687 void RSyncMLJobBase::GetJobL( TInt aSize, TBool ) |
|
688 { |
|
689 _DBG_FILE("RSyncMLJobBase::GetJobL(): begin"); |
|
690 |
|
691 // Create data buffer |
|
692 iData->SetBufferSizeL( aSize ); |
|
693 TPtr8 dataPtr = iData->DataBufferPtr(); |
|
694 |
|
695 TIpcArgs args( &dataPtr ); |
|
696 User::LeaveIfError( SendReceive( ECmdJobGet, args ) ); |
|
697 |
|
698 // internalize data to iData |
|
699 RDesReadStream readStream; |
|
700 readStream.Open( dataPtr ); |
|
701 CleanupClosePushL( readStream ); |
|
702 iData->InternalizeL( readStream ); |
|
703 |
|
704 CleanupStack::PopAndDestroy(); // readStream |
|
705 |
|
706 _DBG_FILE("RSyncMLJobBase::GetJobL(): end"); |
|
707 } |
|
708 |
|
709 |
|
710 // |
|
711 // RSyncMLProfileBase |
|
712 // |
|
713 |
|
714 // ----------------------------------------------------------------------------- |
|
715 // RSyncMLProfileBase::SetCreatorId() |
|
716 // Sets the creator id to data buffer. |
|
717 // ----------------------------------------------------------------------------- |
|
718 // |
|
719 EXPORT_C void RSyncMLProfileBase::SetCreatorId( TSmlCreatorId aCreatorId ) |
|
720 { |
|
721 static_cast<CProfileBaseSessionData*>(iData)->SetCreatorId( aCreatorId ); |
|
722 } |
|
723 |
|
724 // ----------------------------------------------------------------------------- |
|
725 // RSyncMLProfileBase::SetDisplayNameL() |
|
726 // Sets the name of the profile to data buffer. |
|
727 // ----------------------------------------------------------------------------- |
|
728 // |
|
729 EXPORT_C void RSyncMLProfileBase::SetDisplayNameL( const TDesC& aDisplayName ) |
|
730 { |
|
731 static_cast<CProfileBaseSessionData*>(iData)->SetDisplayNameL( aDisplayName ); |
|
732 } |
|
733 |
|
734 // ----------------------------------------------------------------------------- |
|
735 // RSyncMLProfileBase::SetUserNameL() |
|
736 // Sets the username used with remote server to data buffer. |
|
737 // ----------------------------------------------------------------------------- |
|
738 // |
|
739 EXPORT_C void RSyncMLProfileBase::SetUserNameL( const TDesC8& aUserName ) |
|
740 { |
|
741 static_cast<CProfileBaseSessionData*>(iData)->SetUserNameL( aUserName ); |
|
742 } |
|
743 |
|
744 // ----------------------------------------------------------------------------- |
|
745 // RSyncMLProfileBase::SetPasswordL() |
|
746 // Sets the user's password on the remote sync server to data |
|
747 // buffer. |
|
748 // ----------------------------------------------------------------------------- |
|
749 // |
|
750 EXPORT_C void RSyncMLProfileBase::SetPasswordL( const TDesC8& aPassword ) |
|
751 { |
|
752 static_cast<CProfileBaseSessionData*>(iData)->SetPasswordL( aPassword ); |
|
753 } |
|
754 |
|
755 // ----------------------------------------------------------------------------- |
|
756 // RSyncMLProfileBase::SetServerIdL() |
|
757 // Sets the server id. |
|
758 // ----------------------------------------------------------------------------- |
|
759 // |
|
760 EXPORT_C void RSyncMLProfileBase::SetServerIdL( const TDesC8& aServerId ) |
|
761 { |
|
762 static_cast<CProfileBaseSessionData*>(iData)->SetServerIdL( aServerId ); |
|
763 } |
|
764 |
|
765 // ----------------------------------------------------------------------------- |
|
766 // RSyncMLProfileBase::SetServerPasswordL() |
|
767 // Sets server passwd. |
|
768 // ----------------------------------------------------------------------------- |
|
769 // |
|
770 EXPORT_C void RSyncMLProfileBase::SetServerPasswordL( const TDesC8& aServerPassword ) |
|
771 { |
|
772 static_cast<CProfileBaseSessionData*>(iData)->SetServerPasswordL( aServerPassword ); |
|
773 } |
|
774 |
|
775 // ----------------------------------------------------------------------------- |
|
776 // RSyncMLProfileBase::SetSanUserInteractionL() |
|
777 // Sets server alerted user interaction. |
|
778 // ----------------------------------------------------------------------------- |
|
779 // |
|
780 EXPORT_C void RSyncMLProfileBase::SetSanUserInteractionL( TSmlServerAlertedAction aSanAction ) |
|
781 { |
|
782 static_cast<CProfileBaseSessionData*>(iData)->SetSanAction( aSanAction ); |
|
783 } |
|
784 |
|
785 // ----------------------------------------------------------------------------- |
|
786 // RSyncMLProfileBase::SetProtocolVersionL() |
|
787 // Sets the SyncML protocol version used with this profile. |
|
788 // ----------------------------------------------------------------------------- |
|
789 // |
|
790 EXPORT_C void RSyncMLProfileBase::SetProtocolVersionL( TSmlProtocolVersion aProtocolVersion ) |
|
791 { |
|
792 static_cast<CProfileBaseSessionData*>(iData)->SetProtocolVersionL( aProtocolVersion ); |
|
793 } |
|
794 |
|
795 // ----------------------------------------------------------------------------- |
|
796 // RSyncMLProfileBase::DeleteConnectionL() |
|
797 // Since only one connection is supported with a profile, |
|
798 // the connection cannot be deleted. Leaves with KErrNotSupported. |
|
799 // ----------------------------------------------------------------------------- |
|
800 // |
|
801 EXPORT_C void RSyncMLProfileBase::DeleteConnectionL( TSmlTransportId /*aConnection*/ ) |
|
802 { |
|
803 _DBG_FILE("RSyncMLProfileBase::DeleteConnectionL(): begin"); |
|
804 |
|
805 User::Leave( KErrNotSupported ); |
|
806 |
|
807 _DBG_FILE("RSyncMLProfileBase::DeleteConnectionL(): end"); |
|
808 } |
|
809 |
|
810 // ----------------------------------------------------------------------------- |
|
811 // RSyncMLProfileBase::DeleteConnectionByConnectionIdL() |
|
812 // Since only one connection is supported with a profile, |
|
813 // the connection cannot be deleted. Leaves with KErrNotSupported. |
|
814 // ----------------------------------------------------------------------------- |
|
815 // |
|
816 EXPORT_C void RSyncMLProfileBase::DeleteConnectionByConnectionIdL( TSmlConnectionId aConnection ) |
|
817 { |
|
818 DeleteConnectionL( aConnection ); |
|
819 } |
|
820 |
|
821 // ----------------------------------------------------------------------------- |
|
822 // RSyncMLProfileBase::Identifier() |
|
823 // Returns the id of this profile. |
|
824 // ----------------------------------------------------------------------------- |
|
825 // |
|
826 EXPORT_C TSmlProfileId RSyncMLProfileBase::Identifier() const |
|
827 { |
|
828 return static_cast<CProfileBaseSessionData*>(iData)->Identifier(); |
|
829 } |
|
830 |
|
831 // ----------------------------------------------------------------------------- |
|
832 // RSyncMLProfileBase::Type() |
|
833 // Returns the type of this profile (DS or DM). |
|
834 // ----------------------------------------------------------------------------- |
|
835 // |
|
836 EXPORT_C TSmlUsageType RSyncMLProfileBase::Type() const |
|
837 { |
|
838 return static_cast<CProfileBaseSessionData*>(iData)->Type(); |
|
839 } |
|
840 |
|
841 // ----------------------------------------------------------------------------- |
|
842 // RSyncMLProfileBase::CreatorId() |
|
843 // Returns the creator id. |
|
844 // ----------------------------------------------------------------------------- |
|
845 // |
|
846 EXPORT_C TSmlCreatorId RSyncMLProfileBase::CreatorId() const |
|
847 { |
|
848 return static_cast<CProfileBaseSessionData*>(iData)->CreatorId(); |
|
849 } |
|
850 |
|
851 // ----------------------------------------------------------------------------- |
|
852 // RSyncMLProfileBase::DisplayName() |
|
853 // Returns the name of this profile. |
|
854 // ----------------------------------------------------------------------------- |
|
855 // |
|
856 EXPORT_C const TDesC& RSyncMLProfileBase::DisplayName() const |
|
857 { |
|
858 return static_cast<CProfileBaseSessionData*>(iData)->DisplayName(); |
|
859 } |
|
860 |
|
861 // ----------------------------------------------------------------------------- |
|
862 // RSyncMLProfileBase::UserName() |
|
863 // Returns the username used with the remote server. |
|
864 // ----------------------------------------------------------------------------- |
|
865 // |
|
866 EXPORT_C const TDesC8& RSyncMLProfileBase::UserName() const |
|
867 { |
|
868 return static_cast<CProfileBaseSessionData*>(iData)->UserName(); |
|
869 } |
|
870 |
|
871 // ----------------------------------------------------------------------------- |
|
872 // RSyncMLProfileBase::Password() |
|
873 // Returns the user's password to remote server. |
|
874 // ----------------------------------------------------------------------------- |
|
875 // |
|
876 EXPORT_C const TDesC8& RSyncMLProfileBase::Password() const |
|
877 { |
|
878 return static_cast<CProfileBaseSessionData*>(iData)->Password(); |
|
879 } |
|
880 |
|
881 // ----------------------------------------------------------------------------- |
|
882 // RSyncMLProfileBase::ServerId() |
|
883 // Returns the server id. |
|
884 // ----------------------------------------------------------------------------- |
|
885 // |
|
886 EXPORT_C const TDesC8& RSyncMLProfileBase::ServerId() const |
|
887 { |
|
888 return static_cast<CProfileBaseSessionData*>(iData)->ServerId(); |
|
889 } |
|
890 |
|
891 // ----------------------------------------------------------------------------- |
|
892 // RSyncMLProfileBase::ServerPassword() |
|
893 // Returns the server password. |
|
894 // ----------------------------------------------------------------------------- |
|
895 // |
|
896 EXPORT_C const TDesC8& RSyncMLProfileBase::ServerPassword() const |
|
897 { |
|
898 return static_cast<CProfileBaseSessionData*>(iData)->ServerPassword(); |
|
899 } |
|
900 |
|
901 // ----------------------------------------------------------------------------- |
|
902 // RSyncMLProfileBase::SanUserInteraction() |
|
903 // Return server alerted user interaction value. |
|
904 // ----------------------------------------------------------------------------- |
|
905 // |
|
906 EXPORT_C TSmlServerAlertedAction RSyncMLProfileBase::SanUserInteraction() const |
|
907 { |
|
908 return static_cast<CProfileBaseSessionData*>(iData)->SanAction(); |
|
909 } |
|
910 |
|
911 // ----------------------------------------------------------------------------- |
|
912 // RSyncMLProfileBase::ProtocolVersion() |
|
913 // Returns the version of the syncML protocol used with this |
|
914 // profile. |
|
915 // ----------------------------------------------------------------------------- |
|
916 // |
|
917 EXPORT_C TSmlProtocolVersion RSyncMLProfileBase::ProtocolVersion() const |
|
918 { |
|
919 return static_cast<CProfileBaseSessionData*>(iData)->ProtocolVersion(); |
|
920 } |
|
921 |
|
922 // ----------------------------------------------------------------------------- |
|
923 // RSyncMLProfileBase::ListConnectionsL() |
|
924 // Returns the list of connections supported by this profile. |
|
925 // Since currently only one connection per profile is supported, |
|
926 // the list contains only one connection on return. |
|
927 // ----------------------------------------------------------------------------- |
|
928 // |
|
929 EXPORT_C void RSyncMLProfileBase::ListConnectionsL( RArray<TSmlTransportId>& aArray ) const |
|
930 { |
|
931 _DBG_FILE("RSyncMLProfileBase::ListConnectionsL(): begin"); |
|
932 |
|
933 // there should never be more than one connection per profile, ECmdConnList used |
|
934 // also as "next" command |
|
935 ReceiveArrayL( aArray, ECmdConnList, ECmdConnList ); |
|
936 |
|
937 _DBG_FILE("RSyncMLProfileBase::ListConnectionsL(): end"); |
|
938 } |
|
939 |
|
940 // ----------------------------------------------------------------------------- |
|
941 // RSyncMLProfileBase::ListConnectionsByConnectionIdL( |
|
942 // Lists connections. |
|
943 // ----------------------------------------------------------------------------- |
|
944 // |
|
945 EXPORT_C void RSyncMLProfileBase::ListConnectionsByConnectionIdL( RArray<TSmlConnectionId>& aArray ) const |
|
946 { |
|
947 _DBG_FILE("RSyncMLProfileBase::ListConnectionsByConnectionIdL(): begin"); |
|
948 |
|
949 ListConnectionsL( aArray ); |
|
950 |
|
951 _DBG_FILE("RSyncMLProfileBase::ListConnectionsByConnectionIdL(): end"); |
|
952 } |
|
953 |
|
954 // ----------------------------------------------------------------------------- |
|
955 // RSyncMLProfileBase::IsReadOnly() |
|
956 // Returns ETrue if this profile has been opened in read-only mode, |
|
957 // EFalse otherwise. |
|
958 // ----------------------------------------------------------------------------- |
|
959 // |
|
960 EXPORT_C TBool RSyncMLProfileBase::IsReadOnly() const |
|
961 { |
|
962 return ( static_cast<CProfileBaseSessionData*>(iData)->OpenMode() == ESmlOpenRead ); |
|
963 } |
|
964 |
|
965 // ----------------------------------------------------------------------------- |
|
966 // RSyncMLProfileBase::DeleteAllowed() |
|
967 // Returns whether or not deletion is allowed. |
|
968 // ----------------------------------------------------------------------------- |
|
969 // |
|
970 EXPORT_C TBool RSyncMLProfileBase::DeleteAllowed() const |
|
971 { |
|
972 return static_cast<CProfileBaseSessionData*>(iData)->DeleteAllowed(); |
|
973 } |
|
974 |
|
975 // ----------------------------------------------------------------------------- |
|
976 // RSyncMLProfileBase::ProfileLocked() |
|
977 // Returns whether or not profile is locked or not . |
|
978 // ----------------------------------------------------------------------------- |
|
979 // |
|
980 EXPORT_C TInt RSyncMLProfileBase::ProfileLocked(TBool aReadWriteValue, TBool aLockValue) const |
|
981 { |
|
982 if(Type() == ESmlDataSync) |
|
983 return KErrNotSupported; |
|
984 |
|
985 if (aReadWriteValue == EFalse) |
|
986 { |
|
987 return static_cast<CProfileBaseSessionData*>(iData)->ProfileLocked(); |
|
988 } |
|
989 else |
|
990 { |
|
991 static_cast<CProfileBaseSessionData*>(iData)->SetProfileLock(aLockValue); |
|
992 return KErrNone; |
|
993 } |
|
994 |
|
995 } |
|
996 // ----------------------------------------------------------------------------- |
|
997 // RSyncMLProfileBase::UpdateL() |
|
998 // Sends the data in iData to server. The data is updated to |
|
999 // the profile in settings db. |
|
1000 // ----------------------------------------------------------------------------- |
|
1001 // |
|
1002 EXPORT_C void RSyncMLProfileBase::UpdateL() |
|
1003 { |
|
1004 _DBG_FILE("RSyncMLProfileBase::UpdateL(): begin"); |
|
1005 |
|
1006 // check that we're allowed to write |
|
1007 if ( IsReadOnly() ) |
|
1008 { |
|
1009 User::Leave( KErrLocked ); |
|
1010 } |
|
1011 |
|
1012 // use iData as a buffer where the data is externalized to |
|
1013 iData->SetBufferSizeL(); |
|
1014 |
|
1015 RBufWriteStream bufStream( iData->DataBuffer() ); |
|
1016 CleanupClosePushL( bufStream ); |
|
1017 |
|
1018 // externalize |
|
1019 iData->ExternalizeL( bufStream ); |
|
1020 |
|
1021 TPtr8 bufPtr = iData->DataBufferPtr(); |
|
1022 // update data to server |
|
1023 TPckgBuf<TInt> id; |
|
1024 TIpcArgs args( &id, &bufPtr ); |
|
1025 User::LeaveIfError( SendReceive( ECmdProfileSet, args ) ); |
|
1026 |
|
1027 static_cast<CProfileBaseSessionData*>(iData)->SetIdentifier( id() ); |
|
1028 |
|
1029 CleanupStack::PopAndDestroy(); // bufStream |
|
1030 |
|
1031 _DBG_FILE("RSyncMLProfileBase::UpdateL(): end"); |
|
1032 } |
|
1033 |
|
1034 // ----------------------------------------------------------------------------- |
|
1035 // RSyncMLProfileBase::Close() |
|
1036 // Closes the sub-session to server side profile and deletes |
|
1037 // the client side data buffer. |
|
1038 // ----------------------------------------------------------------------------- |
|
1039 // |
|
1040 EXPORT_C void RSyncMLProfileBase::Close() |
|
1041 { |
|
1042 _DBG_FILE("RSyncMLProfileBase::Close(): begin"); |
|
1043 CloseSubSession( ECmdProfileClose ); |
|
1044 |
|
1045 delete iData; |
|
1046 iData = NULL; |
|
1047 _DBG_FILE("RSyncMLProfileBase::Close(): end"); |
|
1048 } |
|
1049 |
|
1050 // ----------------------------------------------------------------------------- |
|
1051 // RSyncMLProfileBase::Session() |
|
1052 // Returns teh session object associated with this sub-session. |
|
1053 // ----------------------------------------------------------------------------- |
|
1054 // |
|
1055 const RSessionBase RSyncMLProfileBase::Session() |
|
1056 { |
|
1057 return RSubSessionBase::Session(); |
|
1058 } |
|
1059 |
|
1060 |
|
1061 // ----------------------------------------------------------------------------- |
|
1062 // RSyncMLProfileBase::RSyncMLProfileBase() |
|
1063 // Protected contructor, called by child classes. |
|
1064 // ----------------------------------------------------------------------------- |
|
1065 // |
|
1066 RSyncMLProfileBase::RSyncMLProfileBase() |
|
1067 : RSubSessionBase(), iData( NULL ) |
|
1068 { |
|
1069 } |
|
1070 |
|
1071 // ----------------------------------------------------------------------------- |
|
1072 // RSyncMLProfileBase::GetProfileL() |
|
1073 // Fetches the profiles data. |
|
1074 // ----------------------------------------------------------------------------- |
|
1075 // |
|
1076 void RSyncMLProfileBase::GetProfileL( TInt aSize ) |
|
1077 { |
|
1078 _DBG_FILE("RSyncMLProfileBase::GetProfileL(): begin"); |
|
1079 |
|
1080 // Create data buffer |
|
1081 iData->SetBufferSizeL( aSize ); |
|
1082 TPtr8 bufPtr = iData->DataBufferPtr(); |
|
1083 |
|
1084 TIpcArgs args( &bufPtr ); |
|
1085 User::LeaveIfError( SendReceive( ECmdProfileGet, args ) ); |
|
1086 |
|
1087 // internalize the buffer to iData |
|
1088 RDesReadStream readStream; |
|
1089 readStream.Open( bufPtr ); |
|
1090 CleanupClosePushL( readStream ); |
|
1091 iData->InternalizeL( readStream ); |
|
1092 |
|
1093 CleanupStack::PopAndDestroy(); // readStream |
|
1094 |
|
1095 _DBG_FILE("RSyncMLProfileBase::GetProfileL(): end"); |
|
1096 } |
|
1097 |
|
1098 // ----------------------------------------------------------------------------- |
|
1099 // RSyncMLProfileBase::ReceiveArrayL() |
|
1100 // Receives array of integers using the given IPC-commands. |
|
1101 // ----------------------------------------------------------------------------- |
|
1102 // |
|
1103 void RSyncMLProfileBase::ReceiveArrayL( RArray<TInt>& aArray, TInt aStart, TInt aNext ) const |
|
1104 { |
|
1105 _DBG_FILE("RSyncMLProfileBase::ReceiveArrayL(): begin"); |
|
1106 |
|
1107 aArray.Reset(); |
|
1108 |
|
1109 // Create data buffer |
|
1110 iData->SetBufferSizeL( KNSmlMaxIntFetchCount*KSizeofTInt32 + KSizeofTInt8 ); |
|
1111 TPtr8& dataPtr = iData->DataBufferPtr(); |
|
1112 |
|
1113 // IPC |
|
1114 TIpcArgs args( &dataPtr ); |
|
1115 TInt err = SendReceive( aStart, args ); |
|
1116 |
|
1117 if ( err == KErrNone || err == KErrOverflow ) |
|
1118 { |
|
1119 iData->ReadIntegersToArrayL( aArray ); // integers to array |
|
1120 |
|
1121 while ( err == KErrOverflow ) |
|
1122 { |
|
1123 dataPtr.Zero(); |
|
1124 |
|
1125 // new IPC |
|
1126 args.Set( 0, &dataPtr ); |
|
1127 err = SendReceive( aNext, args ); |
|
1128 |
|
1129 if ( err == KErrNone || err == KErrOverflow ) |
|
1130 { |
|
1131 iData->ReadIntegersToArrayL( aArray ); // integers to array |
|
1132 } |
|
1133 } |
|
1134 } |
|
1135 |
|
1136 User::LeaveIfError( err ); |
|
1137 |
|
1138 _DBG_FILE("RSyncMLProfileBase::ReceiveArrayL(): end"); |
|
1139 } |
|
1140 |
|
1141 |
|
1142 // |
|
1143 // RSyncMLConnection |
|
1144 // |
|
1145 |
|
1146 |
|
1147 // ----------------------------------------------------------------------------- |
|
1148 // RSyncMLConnection::RSyncMLConnection() |
|
1149 // Constructor. |
|
1150 // ----------------------------------------------------------------------------- |
|
1151 // |
|
1152 EXPORT_C RSyncMLConnection::RSyncMLConnection() |
|
1153 : RSubSessionBase(), iData( NULL ) |
|
1154 { |
|
1155 } |
|
1156 |
|
1157 // ----------------------------------------------------------------------------- |
|
1158 // RSyncMLConnection::CreateL() |
|
1159 // Changes the transport used with this profile. |
|
1160 // ----------------------------------------------------------------------------- |
|
1161 // |
|
1162 EXPORT_C void RSyncMLConnection::CreateL( RSyncMLProfileBase& aProfile, TSmlTransportId aIdentifier ) |
|
1163 { |
|
1164 _DBG_FILE("RSyncMLConnection::CreateL(): begin"); |
|
1165 |
|
1166 // check that profile did not change |
|
1167 if ( aProfile.Identifier() != Profile() ) |
|
1168 { |
|
1169 User::Leave( KErrArgument ); |
|
1170 } |
|
1171 |
|
1172 // check that profile is in read/write mode, i.e. we're allowed to write to profile |
|
1173 if ( aProfile.IsReadOnly() ) |
|
1174 { |
|
1175 User::Leave( KErrLocked ); |
|
1176 } |
|
1177 |
|
1178 // init iData |
|
1179 delete iData; |
|
1180 iData = NULL; |
|
1181 iData = CConnectionSessionData::NewL( aIdentifier, aProfile.Type(), ETrue ); |
|
1182 |
|
1183 // set profile id |
|
1184 static_cast<CConnectionSessionData*>(iData)->SetProfile( aProfile.Identifier() ); |
|
1185 |
|
1186 _DBG_FILE("RSyncMLConnection::CreateL(): end"); |
|
1187 } |
|
1188 |
|
1189 // ----------------------------------------------------------------------------- |
|
1190 // RSyncMLConnection::OpenL() |
|
1191 // Open a sub-session to sync server and fetches the connection |
|
1192 // data of the given profile to client side buffer. |
|
1193 // ----------------------------------------------------------------------------- |
|
1194 // |
|
1195 EXPORT_C void RSyncMLConnection::OpenL( RSyncMLProfileBase& aProfile, TSmlTransportId aIdentifier ) |
|
1196 { |
|
1197 _DBG_FILE("RSyncMLConnection::OpenL(): begin"); |
|
1198 |
|
1199 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
1200 |
|
1201 CConnectionSessionData* data = CConnectionSessionData::NewLC( aIdentifier, aProfile.Type() ); |
|
1202 |
|
1203 TPckgBuf<TInt> dataSize; |
|
1204 TIpcArgs args( &dataSize, aProfile.Identifier(), aIdentifier ); |
|
1205 |
|
1206 // open the sub-session |
|
1207 RSessionBase session = static_cast<RSessionBase>( aProfile.Session() ); |
|
1208 User::LeaveIfError( CreateSubSession( session, ECmdConnOpen, args ) ); |
|
1209 |
|
1210 // set profile id and open mode to data |
|
1211 data->SetProfile( aProfile.Identifier() ); |
|
1212 if ( aProfile.IsReadOnly() ) |
|
1213 { |
|
1214 data->SetOpenMode( ESmlOpenRead ); |
|
1215 } |
|
1216 |
|
1217 iData = data; |
|
1218 CleanupStack::Pop(); // data |
|
1219 |
|
1220 CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup |
|
1221 |
|
1222 // dataSize contains now the size of the data buffer that is received next |
|
1223 iData->SetBufferSizeL( dataSize() ); |
|
1224 TPtr8 bufPtr = iData->DataBufferPtr(); |
|
1225 |
|
1226 TIpcArgs args2(&bufPtr); |
|
1227 User::LeaveIfError( SendReceive( ECmdConnGet, args2 ) ); |
|
1228 |
|
1229 // internalize the buffer to data |
|
1230 RDesReadStream readStream; |
|
1231 readStream.Open( bufPtr ); |
|
1232 CleanupClosePushL( readStream ); |
|
1233 iData->InternalizeL( readStream ); |
|
1234 |
|
1235 CleanupStack::PopAndDestroy(); // readStream |
|
1236 CleanupStack::Pop(); // this |
|
1237 |
|
1238 _DBG_FILE("RSyncMLConnection::OpenL(): end"); |
|
1239 } |
|
1240 |
|
1241 // ----------------------------------------------------------------------------- |
|
1242 // RSyncMLConnection::OpenByConnectionIdL() |
|
1243 // Open a sub-session to sync server and fetches the connection |
|
1244 // data of the given profile to client side buffer. |
|
1245 // ----------------------------------------------------------------------------- |
|
1246 // |
|
1247 EXPORT_C void RSyncMLConnection::OpenByConnectionIdL( RSyncMLProfileBase& aProfile, TSmlConnectionId aIdentifier ) |
|
1248 { |
|
1249 _DBG_FILE("RSyncMLConnection::OpenByConnectionIdL(): begin"); |
|
1250 OpenL( aProfile, aIdentifier ); |
|
1251 _DBG_FILE("RSyncMLConnection::OpenByConnectionIdL(): end"); |
|
1252 } |
|
1253 |
|
1254 // ----------------------------------------------------------------------------- |
|
1255 // RSyncMLConnection::Identifier() |
|
1256 // Returns the transport id of this connection. |
|
1257 // ----------------------------------------------------------------------------- |
|
1258 // |
|
1259 EXPORT_C TSmlTransportId RSyncMLConnection::Identifier() const |
|
1260 { |
|
1261 return static_cast<CConnectionSessionData*>(iData)->Identifier(); |
|
1262 } |
|
1263 |
|
1264 // ----------------------------------------------------------------------------- |
|
1265 // RSyncMLConnection::Profile() |
|
1266 // Return the id of the profile who owns this connection. |
|
1267 // ----------------------------------------------------------------------------- |
|
1268 // |
|
1269 EXPORT_C TSmlProfileId RSyncMLConnection::Profile() const |
|
1270 { |
|
1271 if ( !iData ) |
|
1272 { |
|
1273 User::Leave( KErrArgument ); |
|
1274 } |
|
1275 return static_cast<CConnectionSessionData*>(iData)->Profile(); |
|
1276 } |
|
1277 |
|
1278 // ----------------------------------------------------------------------------- |
|
1279 // RSyncMLConnection::ConnectionId() |
|
1280 // Return the id of this connection. |
|
1281 // ----------------------------------------------------------------------------- |
|
1282 // |
|
1283 EXPORT_C TSmlConnectionId RSyncMLConnection::ConnectionId() const |
|
1284 { |
|
1285 return Identifier(); |
|
1286 } |
|
1287 |
|
1288 // ----------------------------------------------------------------------------- |
|
1289 // RSyncMLConnection::Priority() |
|
1290 // ----------------------------------------------------------------------------- |
|
1291 // |
|
1292 EXPORT_C TUint RSyncMLConnection::Priority() const |
|
1293 { |
|
1294 return static_cast<CConnectionSessionData*>(iData)->Priority(); |
|
1295 } |
|
1296 |
|
1297 // ----------------------------------------------------------------------------- |
|
1298 // RSyncMLConnection::RetryCount() |
|
1299 // ----------------------------------------------------------------------------- |
|
1300 // |
|
1301 EXPORT_C TUint RSyncMLConnection::RetryCount() const |
|
1302 { |
|
1303 return static_cast<CConnectionSessionData*>(iData)->RetryCount(); |
|
1304 } |
|
1305 |
|
1306 // ----------------------------------------------------------------------------- |
|
1307 // RSyncMLConnection::ServerURI() |
|
1308 // Return server uri. |
|
1309 // ----------------------------------------------------------------------------- |
|
1310 // |
|
1311 EXPORT_C const TDesC8& RSyncMLConnection::ServerURI() const |
|
1312 { |
|
1313 return static_cast<CConnectionSessionData*>(iData)->ServerURI(); |
|
1314 } |
|
1315 |
|
1316 // ----------------------------------------------------------------------------- |
|
1317 // RSyncMLConnection::GetPropertyL() |
|
1318 // Return the value of the given transport property. If not found, leaves |
|
1319 // with KErrNotFound. |
|
1320 // ----------------------------------------------------------------------------- |
|
1321 // |
|
1322 EXPORT_C const TDesC8& RSyncMLConnection::GetPropertyL( const TDesC8& aName ) const |
|
1323 { |
|
1324 return static_cast<CConnectionSessionData*>(iData)->GetPropertyL( aName ); |
|
1325 } |
|
1326 |
|
1327 // ----------------------------------------------------------------------------- |
|
1328 // RSyncMLConnection::SetPriority() |
|
1329 // ----------------------------------------------------------------------------- |
|
1330 // |
|
1331 EXPORT_C void RSyncMLConnection::SetPriority( TUint aPriority ) |
|
1332 { |
|
1333 static_cast<CConnectionSessionData*>(iData)->SetPriority( aPriority ); |
|
1334 } |
|
1335 |
|
1336 // ----------------------------------------------------------------------------- |
|
1337 // RSyncMLConnection::SetRetryCount() |
|
1338 // ----------------------------------------------------------------------------- |
|
1339 // |
|
1340 EXPORT_C void RSyncMLConnection::SetRetryCount( TUint aRetryCount ) |
|
1341 { |
|
1342 static_cast<CConnectionSessionData*>(iData)->SetRetryCount( aRetryCount ); |
|
1343 } |
|
1344 |
|
1345 // ----------------------------------------------------------------------------- |
|
1346 // RSyncMLConnection::SetServerURIL() |
|
1347 // Sets server uri. |
|
1348 // ----------------------------------------------------------------------------- |
|
1349 // |
|
1350 EXPORT_C void RSyncMLConnection::SetServerURIL( const TDesC8& aServerURI ) |
|
1351 { |
|
1352 static_cast<CConnectionSessionData*>(iData)->SetServerURIL( aServerURI ); |
|
1353 } |
|
1354 |
|
1355 // ----------------------------------------------------------------------------- |
|
1356 // RSyncMLConnection::SetPropertyL() |
|
1357 // Sets a value for a transport property. |
|
1358 // ----------------------------------------------------------------------------- |
|
1359 // |
|
1360 EXPORT_C void RSyncMLConnection::SetPropertyL( const TDesC8& aName, const TDesC8& aValue ) |
|
1361 { |
|
1362 static_cast<CConnectionSessionData*>(iData)->SetPropertyL( aName, aValue ); |
|
1363 } |
|
1364 |
|
1365 // ----------------------------------------------------------------------------- |
|
1366 // RSyncMLConnection::IsReadOnly() |
|
1367 // Returns whether this connection is read-only or not. |
|
1368 // ----------------------------------------------------------------------------- |
|
1369 // |
|
1370 EXPORT_C TBool RSyncMLConnection::IsReadOnly() const |
|
1371 { |
|
1372 return ( static_cast<CConnectionSessionData*>(iData)->OpenMode() == ESmlOpenRead ); |
|
1373 } |
|
1374 |
|
1375 // ----------------------------------------------------------------------------- |
|
1376 // RSyncMLConnection::UpdateL() |
|
1377 // Updates the data set to client-side buffer to server. |
|
1378 // ----------------------------------------------------------------------------- |
|
1379 // |
|
1380 EXPORT_C void RSyncMLConnection::UpdateL() |
|
1381 { |
|
1382 _DBG_FILE("RSyncMLConnection::UpdateL(): begin"); |
|
1383 |
|
1384 // check that we're allowed to write |
|
1385 if ( IsReadOnly() ) |
|
1386 { |
|
1387 User::Leave( KErrLocked ); |
|
1388 } |
|
1389 |
|
1390 // Create data buffer |
|
1391 // use iData as a buffer where the data is externalized to |
|
1392 iData->SetBufferSizeL(); |
|
1393 RBufWriteStream bufStream( iData->DataBuffer() ); |
|
1394 |
|
1395 CleanupClosePushL( bufStream ); |
|
1396 |
|
1397 // externalize |
|
1398 iData->ExternalizeL( bufStream ); |
|
1399 |
|
1400 // Get refrence to data buffer |
|
1401 TPtr8 bufPtr = iData->DataBufferPtr(); |
|
1402 |
|
1403 // update data to server |
|
1404 TIpcArgs args(&bufPtr); |
|
1405 User::LeaveIfError( SendReceive( ECmdConnSet, args ) ); |
|
1406 |
|
1407 CleanupStack::PopAndDestroy( &bufStream ); // stream |
|
1408 |
|
1409 _DBG_FILE("RSyncMLConnection::UpdateL(): end"); |
|
1410 } |
|
1411 |
|
1412 // ----------------------------------------------------------------------------- |
|
1413 // RSyncMLConnection::Close() |
|
1414 // Closes sub-session. |
|
1415 // ----------------------------------------------------------------------------- |
|
1416 // |
|
1417 EXPORT_C void RSyncMLConnection::Close() |
|
1418 { |
|
1419 _DBG_FILE("RSyncMLConnection::Close(): begin"); |
|
1420 CloseSubSession( ECmdConnClose ); |
|
1421 |
|
1422 delete iData; |
|
1423 iData = NULL; |
|
1424 _DBG_FILE("RSyncMLConnection::Close(): end"); |
|
1425 } |
|
1426 |
|
1427 |
|
1428 |
|
1429 // |
|
1430 // RSyncMLTransport |
|
1431 // |
|
1432 |
|
1433 |
|
1434 // ----------------------------------------------------------------------------- |
|
1435 // RSyncMLTransport::RSyncMLTransport() |
|
1436 // Constructor. |
|
1437 // ----------------------------------------------------------------------------- |
|
1438 // |
|
1439 EXPORT_C RSyncMLTransport::RSyncMLTransport() |
|
1440 : RSubSessionBase(), iData( NULL ) |
|
1441 { |
|
1442 } |
|
1443 |
|
1444 // ----------------------------------------------------------------------------- |
|
1445 // RSyncMLTransport::OpenL() |
|
1446 // Creates a list of transport properties using the given |
|
1447 // transport id. |
|
1448 // ----------------------------------------------------------------------------- |
|
1449 // |
|
1450 EXPORT_C void RSyncMLTransport::OpenL( RSyncMLSession& /*aSession*/, TSmlTransportId aId ) |
|
1451 { |
|
1452 _DBG_FILE("RSyncMLTransport::OpenL(): begin"); |
|
1453 |
|
1454 CClientSessionData::PanicIfAlreadyCreated( iData ); |
|
1455 iData = CTransportSessionData::NewL( aId, ESmlDataSync ); |
|
1456 |
|
1457 _DBG_FILE("RSyncMLTransport::OpenL(): end"); |
|
1458 } |
|
1459 |
|
1460 // ----------------------------------------------------------------------------- |
|
1461 // RSyncMLTransport::Identifier() |
|
1462 // Returns the transport id, whose properties this object |
|
1463 // contains. |
|
1464 // ----------------------------------------------------------------------------- |
|
1465 // |
|
1466 EXPORT_C TSmlTransportId RSyncMLTransport::Identifier() const |
|
1467 { |
|
1468 return static_cast<CTransportSessionData*>(iData)->Identifier(); |
|
1469 } |
|
1470 |
|
1471 // ----------------------------------------------------------------------------- |
|
1472 // RSyncMLTransport::DisplayName() |
|
1473 // Returns the display name. |
|
1474 // ----------------------------------------------------------------------------- |
|
1475 // |
|
1476 EXPORT_C const TDesC& RSyncMLTransport::DisplayName() const |
|
1477 { |
|
1478 return static_cast<CTransportSessionData*>(iData)->DisplayName(); |
|
1479 } |
|
1480 |
|
1481 // ----------------------------------------------------------------------------- |
|
1482 // RSyncMLTransport::SupportsCapability( |
|
1483 // Not supported, returns EFalse. |
|
1484 // ----------------------------------------------------------------------------- |
|
1485 // |
|
1486 EXPORT_C TBool RSyncMLTransport::SupportsCapability( TSmlTransportCap /*aCapability*/ ) const |
|
1487 { |
|
1488 return EFalse; |
|
1489 } |
|
1490 |
|
1491 // ----------------------------------------------------------------------------- |
|
1492 // RSyncMLTransport::Properties() |
|
1493 // Returns the list of transport properties related to this |
|
1494 // transport. |
|
1495 // ----------------------------------------------------------------------------- |
|
1496 // |
|
1497 EXPORT_C const CSyncMLTransportPropertiesArray& RSyncMLTransport::Properties() const |
|
1498 { |
|
1499 return static_cast<CTransportSessionData*>(iData)->Properties(); |
|
1500 } |
|
1501 |
|
1502 // ----------------------------------------------------------------------------- |
|
1503 // RSyncMLTransport::StartListeningL() |
|
1504 // Not supported. |
|
1505 // ----------------------------------------------------------------------------- |
|
1506 // |
|
1507 EXPORT_C void RSyncMLTransport::StartListeningL() const |
|
1508 { |
|
1509 User::Leave( KErrNotSupported ); |
|
1510 } |
|
1511 |
|
1512 // ----------------------------------------------------------------------------- |
|
1513 // RSyncMLTransport::StopListeningL() |
|
1514 // Not supported. |
|
1515 // ----------------------------------------------------------------------------- |
|
1516 // |
|
1517 EXPORT_C void RSyncMLTransport::StopListeningL() const |
|
1518 { |
|
1519 User::Leave( KErrNotSupported ); |
|
1520 } |
|
1521 |
|
1522 // ----------------------------------------------------------------------------- |
|
1523 // RSyncMLTransport::Close() |
|
1524 // Frees the resources used by this object. |
|
1525 // ----------------------------------------------------------------------------- |
|
1526 // |
|
1527 EXPORT_C void RSyncMLTransport::Close() |
|
1528 { |
|
1529 _DBG_FILE("RSyncMLTransport::Close(): begin"); |
|
1530 |
|
1531 delete iData; |
|
1532 iData = NULL; |
|
1533 |
|
1534 _DBG_FILE("RSyncMLTransport::Close(): end"); |
|
1535 } |
|
1536 |
|
1537 // End of File |