|
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: |
|
15 * Declaration file for client API's utilities |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __CLIENTAPIUTILS_H__ |
|
21 #define __CLIENTAPIUTILS_H__ |
|
22 |
|
23 #include <e32std.h> |
|
24 #include <SyncMLDef.h> |
|
25 #include <SyncMLClient.h> |
|
26 #include <SyncMLDataFilter.h> |
|
27 #include "NSmlHistoryArray.h" |
|
28 #include "NSmlTransportHandler.h" |
|
29 |
|
30 // |
|
31 // class for reacting to feature support |
|
32 // |
|
33 class NSmlClientAPIFeatureHandler |
|
34 { |
|
35 public: |
|
36 static void LeaveIfDataSyncNotSupportedL(); |
|
37 static void LeaveIfDevManNotSupportedL(); |
|
38 static void LeaveIfUsageTypeNotSupportedL( TSmlUsageType aUsageType ); |
|
39 |
|
40 private: |
|
41 NSmlClientAPIFeatureHandler(); // instantiation prohibited |
|
42 }; |
|
43 |
|
44 // |
|
45 // base class for session data |
|
46 // |
|
47 class CClientSessionData : public CBase |
|
48 { |
|
49 public: |
|
50 CClientSessionData(); |
|
51 virtual ~CClientSessionData(); |
|
52 virtual void InternalizeL( RReadStream& aStream ); |
|
53 virtual void ExternalizeL( RWriteStream& aStream ) const; |
|
54 |
|
55 void ReadIntegersToArrayL( RArray<TInt>& aArray ); // from buffer to array |
|
56 |
|
57 void SetBufferSizeL( TInt aSize = -1 ); |
|
58 void ClearDataBuffer(); |
|
59 TPtr8& DataBufferPtr(); |
|
60 CBufBase& DataBuffer(); |
|
61 static void PanicIfAlreadyCreated( CClientSessionData* aPtr ); |
|
62 |
|
63 private: |
|
64 CBufBase* iBuffer; |
|
65 TPtr8 iDataPtr; |
|
66 }; |
|
67 |
|
68 |
|
69 // |
|
70 // data for history log |
|
71 // |
|
72 class CHistoryLogSessionData : public CClientSessionData |
|
73 { |
|
74 public: |
|
75 static CHistoryLogSessionData* NewL(); |
|
76 static CHistoryLogSessionData* NewLC(); |
|
77 virtual ~CHistoryLogSessionData(); |
|
78 virtual void InternalizeL( RReadStream& aStream ); |
|
79 |
|
80 inline CNSmlHistoryArray& History() const; |
|
81 inline const TSmlProfileId Profile() const; |
|
82 |
|
83 void SetProfile( const TSmlProfileId aProfileId ); |
|
84 |
|
85 private: |
|
86 CHistoryLogSessionData(); |
|
87 void ConstructL(); |
|
88 |
|
89 private: |
|
90 CNSmlHistoryArray* iHistoryArray; |
|
91 TSmlProfileId iProfileId; |
|
92 }; |
|
93 |
|
94 |
|
95 // |
|
96 // data for all sync jobs (ds and dm) |
|
97 // |
|
98 class CJobBaseSessionData : public CClientSessionData |
|
99 { |
|
100 public: |
|
101 virtual ~CJobBaseSessionData(); |
|
102 virtual void InternalizeL( RReadStream& aStream ); |
|
103 |
|
104 void WriteIntegersToBufferL( const RArray<TInt>* aArray = NULL ); // from array to buffer |
|
105 |
|
106 inline TSmlJobId Identifier() const; |
|
107 inline TSmlProfileId Profile() const; |
|
108 |
|
109 void AddParamL( const TInt aParam ); |
|
110 void SetIdentifier( const TSmlJobId aJobId ); |
|
111 void SetProfile( const TSmlProfileId aProfileId ); |
|
112 |
|
113 protected: |
|
114 CJobBaseSessionData(); // created in child classes |
|
115 |
|
116 private: |
|
117 TSmlProfileId iProfileId; |
|
118 RArray<TInt> iParams; |
|
119 TSmlJobId iJobId; |
|
120 }; |
|
121 |
|
122 |
|
123 // |
|
124 // data for ds sync jobs |
|
125 // |
|
126 class CDataSyncJobSessionData : public CJobBaseSessionData |
|
127 { |
|
128 public: |
|
129 CDataSyncJobSessionData(); |
|
130 virtual ~CDataSyncJobSessionData(); |
|
131 virtual void InternalizeL( RReadStream& aStream ); |
|
132 |
|
133 inline const RArray<TSmlTaskId>& TaskIds() const; |
|
134 void SetTasksL( const RArray<TSmlTaskId>& aTasks ); |
|
135 |
|
136 private: |
|
137 RArray<TSmlTaskId> iTasks; |
|
138 }; |
|
139 |
|
140 |
|
141 // |
|
142 // data for dm sync jobs |
|
143 // |
|
144 class CDevManJobSessionData : public CJobBaseSessionData |
|
145 { |
|
146 public: |
|
147 CDevManJobSessionData(); |
|
148 virtual ~CDevManJobSessionData(); |
|
149 virtual void InternalizeL( RReadStream& aStream ); |
|
150 }; |
|
151 |
|
152 |
|
153 // |
|
154 // data for profiles |
|
155 // |
|
156 class CProfileBaseSessionData : public CClientSessionData |
|
157 { |
|
158 public: |
|
159 virtual ~CProfileBaseSessionData(); |
|
160 virtual void InternalizeL( RReadStream& aStream ); |
|
161 virtual void ExternalizeL( RWriteStream& aStream ) const; |
|
162 |
|
163 inline TSmlUsageType Type() const; |
|
164 inline TBool DeleteAllowed() const; |
|
165 inline TSmlOpenMode OpenMode() const; |
|
166 inline const TDesC8& ServerId() const; |
|
167 inline const TDesC8& UserName() const; |
|
168 inline const TDesC8& Password() const; |
|
169 inline TSmlCreatorId CreatorId() const; |
|
170 inline TSmlProfileId Identifier() const; |
|
171 inline const TDesC& DisplayName() const; |
|
172 inline const TDesC8& ServerPassword() const; |
|
173 inline TSmlServerAlertedAction SanAction() const; |
|
174 inline TSmlProtocolVersion ProtocolVersion() const; |
|
175 inline TBool ProfileLocked() const; |
|
176 |
|
177 void SetType( const TSmlUsageType aUsageType ); |
|
178 void SetCreatorId( const TSmlCreatorId aCreatorId ); |
|
179 void SetIdentifier( const TSmlProfileId aProfileId ); |
|
180 void SetDeleteAllowed( const TBool aDeleteAllowed ); |
|
181 void SetProfileLock( const TBool aProfileLocked ); |
|
182 void SetOpenMode( const TSmlOpenMode aOpenMode ); |
|
183 void SetDisplayNameL( const TDesC& aDisplayName ); |
|
184 void SetUserNameL( const TDesC8& aUserName ); |
|
185 void SetPasswordL( const TDesC8& aPassword ); |
|
186 void SetServerPasswordL( const TDesC8& aServerPassword ); |
|
187 void SetServerIdL( const TDesC8& aServerId ); |
|
188 void SetSanAction( const TSmlServerAlertedAction aSanAction ); |
|
189 void SetProtocolVersionL( const TSmlProtocolVersion aVersion ); |
|
190 |
|
191 protected: |
|
192 CProfileBaseSessionData(); // created in child classes |
|
193 void BaseConstructL( TBool aInitValues ); |
|
194 void InitValuesL(); |
|
195 void SetProfileLockL(RReadStream& aStream ); |
|
196 void GetProfileLockL(RWriteStream&aStream ) const ; |
|
197 private: |
|
198 TSmlServerAlertedAction iSanAction; |
|
199 TSmlProtocolVersion iProtocolVersion; |
|
200 TSmlUsageType iUsageType; |
|
201 TSmlCreatorId iCreatorId; |
|
202 TSmlProfileId iProfileId; |
|
203 TSmlOpenMode iOpenMode; |
|
204 HBufC* iDisplayName; |
|
205 HBufC8* iServerPassword; |
|
206 HBufC8* iUserName; |
|
207 HBufC8* iPassword; |
|
208 HBufC8* iServerId; |
|
209 TBool iDeleteAllowed; |
|
210 TBool iProfileLocked; |
|
211 }; |
|
212 |
|
213 |
|
214 // |
|
215 // data for data sync profiles |
|
216 // |
|
217 class CDataSyncProfileSessionData : public CProfileBaseSessionData |
|
218 { |
|
219 public: |
|
220 static CDataSyncProfileSessionData* NewL( const TBool aInitValues = EFalse ); |
|
221 static CDataSyncProfileSessionData* NewLC( const TBool aInitValues = EFalse ); |
|
222 |
|
223 virtual void InternalizeL( RReadStream& aStream ); |
|
224 virtual void ExternalizeL( RWriteStream& aStream ) const; |
|
225 |
|
226 virtual ~CDataSyncProfileSessionData(); |
|
227 |
|
228 private: |
|
229 CDataSyncProfileSessionData(); |
|
230 void ConstructL( const TBool aInitValues ); |
|
231 }; |
|
232 |
|
233 |
|
234 // |
|
235 // data for device management profiles |
|
236 // |
|
237 class CDevManProfileSessionData : public CProfileBaseSessionData |
|
238 { |
|
239 public: |
|
240 static CDevManProfileSessionData* NewL( const TBool aInitValues = EFalse ); |
|
241 static CDevManProfileSessionData* NewLC( const TBool aInitValues = EFalse ); |
|
242 |
|
243 virtual void InternalizeL( RReadStream& aStream ); |
|
244 virtual void ExternalizeL( RWriteStream& aStream ) const; |
|
245 |
|
246 virtual ~CDevManProfileSessionData(); |
|
247 |
|
248 private: |
|
249 CDevManProfileSessionData(); |
|
250 void ConstructL( const TBool aInitValues ); |
|
251 }; |
|
252 |
|
253 |
|
254 // |
|
255 // data for ds tasks |
|
256 // |
|
257 class CTaskSessionData : public CClientSessionData |
|
258 { |
|
259 public: |
|
260 static CTaskSessionData* NewL( const TBool aInitValues = EFalse ); |
|
261 static CTaskSessionData* NewLC( const TBool aInitValues = EFalse ); |
|
262 virtual ~CTaskSessionData(); |
|
263 virtual void InternalizeL( RReadStream& aStream ); |
|
264 virtual void ExternalizeL( RWriteStream& aStream ) const; |
|
265 |
|
266 inline TBool Enabled() const; |
|
267 inline TBool IsReadOnly() const; |
|
268 inline TSmlTaskId Identifier() const; |
|
269 inline TSmlProfileId Profile() const; |
|
270 inline TSmlCreatorId CreatorId() const; |
|
271 inline const TDesC& DisplayName() const; |
|
272 inline TSmlSyncType DefaultSyncType() const; |
|
273 inline const TDesC& ServerDataSource() const; |
|
274 inline const TDesC& ClientDataSource() const; |
|
275 inline TSmlDataProviderId DataProvider() const; |
|
276 |
|
277 inline TSyncMLFilterMatchType FilterMatchType() const; |
|
278 inline TSyncMLFilterChangeInfo FilterChangeInfo() const; |
|
279 |
|
280 void SetEnabled( const TBool aEnabled ); |
|
281 void SetReadOnly( const TBool aReadOnly ); |
|
282 void SetIdentifier( const TSmlTaskId aTaskId ); |
|
283 void SetProfile( const TSmlProfileId aProfileId ); |
|
284 void SetCreatorId( const TSmlCreatorId aCreatorId ); |
|
285 void SetDisplayNameL( const TDesC& aDisplayName ); |
|
286 void SetDefaultSyncType( TSmlSyncType aSyncType ); |
|
287 void SetServerDataSourceL( const TDesC& aServerDataSource ); |
|
288 void SetClientDataSourceL( const TDesC& aClientDataSource ); |
|
289 void SetDataProvider( TSmlDataProviderId aDataProviderId ); |
|
290 |
|
291 void SetFilterMatchType( TSyncMLFilterMatchType aFilterMatchType ); |
|
292 void SetTaskSupportedFiltersL( TDesC8& aData ); |
|
293 RPointerArray<CSyncMLFilter>& FilterArray(); |
|
294 void CopyTaskSupportedFiltersL( RPointerArray<CSyncMLFilter>& aFilterArray ); |
|
295 |
|
296 inline void SetFilterBufSize( TInt aBufferSize ); |
|
297 inline TInt FilterBufSize() const; |
|
298 TInt FilterDataSize() const; |
|
299 private: |
|
300 CTaskSessionData(); |
|
301 void ConstructL( const TBool aInitValues ); |
|
302 void InitValuesL(); |
|
303 |
|
304 private: |
|
305 TSmlDataProviderId iDataProviderId; |
|
306 TSmlProfileId iProfileId; |
|
307 TSmlCreatorId iCreatorId; |
|
308 TSmlSyncType iDefaultSyncType; |
|
309 TSmlTaskId iTaskId; |
|
310 HBufC* iDisplayName; |
|
311 HBufC* iServerDataSource; |
|
312 HBufC* iClientDataSource; |
|
313 TBool iReadOnly; |
|
314 TBool iEnabled; |
|
315 |
|
316 TSyncMLFilterMatchType iFilterMatchType; |
|
317 TSyncMLFilterChangeInfo iFilterChangeInfo; |
|
318 RPointerArray<CSyncMLFilter> iFilterArray; |
|
319 |
|
320 TInt iFilterBufSize; |
|
321 }; |
|
322 |
|
323 |
|
324 // |
|
325 // data for connection |
|
326 // |
|
327 class CConnectionSessionData : public CClientSessionData |
|
328 { |
|
329 public: |
|
330 static CConnectionSessionData* NewL( const TSmlTransportId aId, const TSmlUsageType aUsageType, const TBool aInitValues = EFalse ); |
|
331 static CConnectionSessionData* NewLC( const TSmlTransportId aId, const TSmlUsageType aUsageType, const TBool aInitValues = EFalse ); |
|
332 virtual ~CConnectionSessionData(); |
|
333 virtual void InternalizeL( RReadStream& aStream ); |
|
334 virtual void ExternalizeL( RWriteStream& aStream ) const; |
|
335 |
|
336 inline TUint Priority() const; |
|
337 inline TUint RetryCount() const; |
|
338 inline TSmlProfileId Profile() const; |
|
339 inline TSmlOpenMode OpenMode() const; |
|
340 inline const TDesC8& ServerURI() const; |
|
341 inline TSmlTransportId Identifier() const; |
|
342 |
|
343 const TDesC8& GetPropertyL( const TDesC8& aName ) const; |
|
344 void SetPropertyL( const TDesC8& aName, const TDesC8& aValue ); |
|
345 |
|
346 void SetPriority( const TUint aPriority ); |
|
347 void SetRetryCount( const TUint aRetryCount ); |
|
348 void SetServerURIL( const TDesC8& aServerURI ); |
|
349 void SetIdentifier( const TSmlTransportId aId ); |
|
350 void SetOpenMode( const TSmlOpenMode aOpenMode ); |
|
351 void SetProfile( const TSmlProfileId aProfileId ); |
|
352 |
|
353 private: |
|
354 TInt FindL( const TDesC8& aName ) const; |
|
355 void InitValuesL(); |
|
356 |
|
357 void ConstructL( const TBool aInitValues, const TSmlUsageType aUsageType ); |
|
358 CConnectionSessionData( const TSmlTransportId aId ); |
|
359 |
|
360 private: |
|
361 CNSmlTransportHandler* iHandler; |
|
362 RPointerArray<HBufC8> iPropVals; |
|
363 TSmlTransportId iId; |
|
364 TSmlProfileId iProfileId; |
|
365 TSmlOpenMode iOpenMode; |
|
366 HBufC8* iServerURI; |
|
367 TUint iPriority; |
|
368 TUint iRetryCount; |
|
369 }; |
|
370 |
|
371 |
|
372 // |
|
373 // data for transport |
|
374 // |
|
375 class CTransportSessionData : public CClientSessionData |
|
376 { |
|
377 public: |
|
378 static CTransportSessionData* NewL( const TSmlTransportId aId, const TSmlUsageType aUsageType ); |
|
379 virtual ~CTransportSessionData(); |
|
380 |
|
381 inline const TDesC& DisplayName() const; |
|
382 inline TSmlTransportId Identifier() const; |
|
383 inline const CSyncMLTransportPropertiesArray& Properties() const; |
|
384 |
|
385 void SetIdentifier( const TSmlTransportId aId ); |
|
386 |
|
387 private: |
|
388 void ConstructL( const TSmlUsageType aUsageType ); |
|
389 CTransportSessionData( const TSmlTransportId aId ); |
|
390 |
|
391 private: |
|
392 CNSmlTransportHandler* iHandler; |
|
393 TSmlTransportId iId; |
|
394 }; |
|
395 |
|
396 |
|
397 // |
|
398 // data for data provider |
|
399 // |
|
400 class CDataProviderSessionData : public CClientSessionData |
|
401 { |
|
402 public: |
|
403 CDataProviderSessionData(); |
|
404 virtual ~CDataProviderSessionData(); |
|
405 virtual void InternalizeL( RReadStream& aStream ); |
|
406 |
|
407 inline TSmlDataProviderId Identifier() const; |
|
408 inline TVersion Version() const; |
|
409 inline const TDesC& DisplayName() const; |
|
410 inline const TInt MimeTypeCount() const; |
|
411 inline const TDesC& MimeType( TInt aIndex ) const; |
|
412 inline const TDesC& MimeVersion( TInt aIndex ) const; |
|
413 inline const TDesC& DefaultDataStoreName() const; |
|
414 inline TBool AllowsMultipleDataStores() const; |
|
415 inline TSmlProtocolVersion RequiredProtocolVersion() const; |
|
416 |
|
417 void GetDataStoreNamesL( CDesCArray& aArray ) const; |
|
418 |
|
419 void SetIdentifier( const TSmlDataProviderId aId ); |
|
420 |
|
421 private: |
|
422 RPointerArray<HBufC> iDataStores; // default store is the first |
|
423 RPointerArray<HBufC> iMimeTypes; |
|
424 RPointerArray<HBufC> iMimeVersions; |
|
425 TSmlProtocolVersion iRequiredProtocolVersion; |
|
426 TSmlDataProviderId iId; |
|
427 TVersion iVersion; |
|
428 HBufC* iDisplayName; |
|
429 TBool iAllowMultipleDataStores; |
|
430 }; |
|
431 |
|
432 |
|
433 #include "NSmlClientAPIUtils.inl" |
|
434 |
|
435 #endif // __CLIENTAPIUTILS_H__ |
|
436 |
|
437 |