|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Methods for CNSmlDMSyncProfile |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "NSmlDMSyncProfile.h" |
|
20 #include <SyncMLTransportProperties.h> |
|
21 #include "NSmlDMdef.h" |
|
22 #include "NSmlDMSyncDebug.h" |
|
23 #include "NSmlDMSyncUtil.h" |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS ============================== |
|
26 // |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // NewLC |
|
30 // |
|
31 // Two-phased constructor. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CNSmlDMSyncProfile* CNSmlDMSyncProfile::NewLC( const TInt aApplicationId, |
|
35 RSyncMLSession* aSyncSession ) |
|
36 { |
|
37 FLOG( "[OMADM] CNSmlDMSyncProfile::NewLC()" ); |
|
38 |
|
39 CNSmlDMSyncProfile* self = new( ELeave ) CNSmlDMSyncProfile( aApplicationId, |
|
40 aSyncSession ); |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 return self; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // NewL |
|
48 // |
|
49 // Two-phased constructor. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CNSmlDMSyncProfile* CNSmlDMSyncProfile::NewL( const TInt aApplicationId, |
|
53 RSyncMLSession* aSyncSession ) |
|
54 { |
|
55 FLOG( "[OMADM] CNSmlDMSyncProfile::NewL:" ); |
|
56 |
|
57 CNSmlDMSyncProfile* self = new( ELeave ) CNSmlDMSyncProfile( aApplicationId, |
|
58 aSyncSession ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // Destructor. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CNSmlDMSyncProfile::~CNSmlDMSyncProfile() |
|
70 { |
|
71 FLOG( "[OMADM] CNSmlDMSyncProfile::~CNSmlDMSyncProfile:" ); |
|
72 |
|
73 iHistoryLog.Close(); |
|
74 iConnection.Close(); |
|
75 iProfile.Close(); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // ConstructL |
|
80 // |
|
81 // Symbian 2nd phase constructor can leave. |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void CNSmlDMSyncProfile::ConstructL() |
|
85 { |
|
86 FLOG( "[OMADM] CNSmlDMSyncProfile::ConstructL:" ); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // Constructor. |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 CNSmlDMSyncProfile::CNSmlDMSyncProfile( const TInt aApplicationId, |
|
94 RSyncMLSession* aSyncSession ) |
|
95 { |
|
96 FLOG( "[OMADM] CNSmlDMSyncProfile::CNSmlDMSyncProfile:" ); |
|
97 |
|
98 iSyncSession = aSyncSession; |
|
99 iApplicationId = aApplicationId; |
|
100 |
|
101 iHistoryLogOpen = EFalse; |
|
102 iConnectionOpen = EFalse; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CNSmlDMSyncProfile::OpenL |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CNSmlDMSyncProfile::OpenL( TInt aProfileId, TInt aOpenMode ) |
|
110 { |
|
111 FTRACE( FPrint( |
|
112 _L("[OMADM] CNSmlDMSyncProfile::OpenL(), aProfileId = %d, aOpenMode = %d"), |
|
113 aProfileId, aOpenMode ) ); |
|
114 |
|
115 if ( aOpenMode == EOpenRead ) |
|
116 { |
|
117 iProfile.OpenL( *iSyncSession, aProfileId, ESmlOpenRead ); |
|
118 } |
|
119 else |
|
120 { |
|
121 iProfile.OpenL( *iSyncSession, aProfileId, ESmlOpenReadWrite ); |
|
122 } |
|
123 if ( !iConnectionOpen ) |
|
124 { |
|
125 OpenConnection(); |
|
126 } |
|
127 FLOG( "[OMADM] CNSmlDMSyncProfile::OpenL() completed" ); |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CNSmlDMSyncProfile::CreateL |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 TInt CNSmlDMSyncProfile::CreateL() |
|
135 { |
|
136 FLOG( "[OMADM] CNSmlDMSyncProfile::CreateL()" ); |
|
137 |
|
138 iProfile.CreateL( *iSyncSession ); |
|
139 iProfile.SetCreatorId( iApplicationId ); |
|
140 iProfile.UpdateL(); |
|
141 TInt id = iProfile.Identifier(); |
|
142 iProfile.Close(); |
|
143 |
|
144 FLOG( "[OMADM] CNSmlDMSyncProfile::CreateL() completed" ); |
|
145 return id; |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CNSmlDMSyncProfile::CreateCopyL |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CNSmlDMSyncProfile::CreateCopyL( TInt aProfileId ) |
|
153 { |
|
154 FLOG( "[OMADM] CNSmlDMSyncProfile::CreateCopyL()" ); |
|
155 |
|
156 iProfile.CreateL( *iSyncSession ); |
|
157 iProfile.SetCreatorId( iApplicationId ); |
|
158 iProfile.UpdateL(); |
|
159 if ( !iConnectionOpen ) |
|
160 { |
|
161 OpenConnection(); |
|
162 } |
|
163 if ( !iHistoryLogOpen ) |
|
164 { |
|
165 OpenHistoryLog(); |
|
166 } |
|
167 |
|
168 CNSmlDMSyncProfile* profile = |
|
169 CNSmlDMSyncProfile::NewL( KUidSmlSyncApp.iUid, iSyncSession ); |
|
170 CleanupStack::PushL( profile ); |
|
171 profile->OpenL( aProfileId, ESmlOpenRead ); |
|
172 CopyValuesL( profile ); |
|
173 CleanupStack::PopAndDestroy( profile ); |
|
174 profile = NULL; |
|
175 |
|
176 iProfile.UpdateL(); |
|
177 CloseHistoryLog(); |
|
178 FLOG( "[OMADM] CNSmlDMSyncProfile::CreateCopyL() completed" ); |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CNSmlDMSyncProfile::SaveL |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 void CNSmlDMSyncProfile::SaveL() |
|
186 { |
|
187 FLOG( "[OMADM] CNSmlDMSyncProfile::SaveL()" ); |
|
188 |
|
189 iProfile.UpdateL(); |
|
190 if ( iConnectionOpen ) |
|
191 { |
|
192 iConnection.UpdateL(); // IPC call |
|
193 } |
|
194 iProfile.Close(); |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CNSmlDMSyncProfile::GetName |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 void CNSmlDMSyncProfile::GetName( TDes& aText ) |
|
202 { |
|
203 FLOG( "[OMADM] CNSmlDMSyncProfile::GetName()" ); |
|
204 |
|
205 TUtil::StrCopy( aText, iProfile.DisplayName() ); |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CNSmlDMSyncProfile::SetNameL |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CNSmlDMSyncProfile::SetNameL( const TDesC& aText ) |
|
213 { |
|
214 FLOG( "[OMADM] CNSmlDMSyncProfile::SetNameL:" ); |
|
215 |
|
216 iProfile.SetDisplayNameL( aText ); |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CNSmlDMSyncProfile::CreatorId |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 TInt CNSmlDMSyncProfile::CreatorId() |
|
224 { |
|
225 FLOG( "[OMADM] CNSmlDMSyncProfile::CreatorId:" ); |
|
226 |
|
227 return iProfile.CreatorId(); |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CNSmlDMSyncProfile::SetCreatorId |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 void CNSmlDMSyncProfile::SetCreatorId( TInt aCreatorId ) |
|
235 { |
|
236 FLOG( "[OMADM] CNSmlDMSyncProfile::SetCreatorId:" ); |
|
237 |
|
238 iProfile.SetCreatorId( aCreatorId ); |
|
239 } |
|
240 |
|
241 // ----------------------------------------------------------------------------- |
|
242 // CNSmlDMSyncProfile::ProfileId |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 TInt CNSmlDMSyncProfile::ProfileId() |
|
246 { |
|
247 FLOG( "[OMADM] CNSmlDMSyncProfile::ProfileId()" ); |
|
248 TInt retval = iProfile.Identifier(); |
|
249 FTRACE( FPrint( _L( |
|
250 "[OMADM] CNSmlDMSyncProfile::ProfileId() completed: Profile id = %d"), |
|
251 retval ) ); |
|
252 return retval; |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CNSmlDMSyncProfile::DeleteAllowed |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 TBool CNSmlDMSyncProfile::DeleteAllowed() |
|
260 { |
|
261 FLOG( "[OMADM] CNSmlDMSyncProfile::DeleteAllowed:" ); |
|
262 |
|
263 return iProfile.DeleteAllowed(); |
|
264 } |
|
265 //----------------------------------------------------------------------------- |
|
266 // CNSmlDMSyncProfile::ProfileLocked() |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 TBool CNSmlDMSyncProfile::ProfileLocked() |
|
270 { |
|
271 FLOG( "[OMADM] CNSmlDMSyncProfile::DeleteAllowed:" ); |
|
272 |
|
273 return iProfile.ProfileLocked(EFalse , EFalse); |
|
274 } |
|
275 // ----------------------------------------------------------------------------- |
|
276 // CNSmlDMSyncProfile::IsSynced |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 TBool CNSmlDMSyncProfile::IsSynced() |
|
280 { |
|
281 FLOG( "[OMADM] CNSmlDMSyncProfile::IsSynced()" ); |
|
282 |
|
283 TBool retVal = EFalse; |
|
284 if ( !iHistoryLogOpen ) |
|
285 { |
|
286 FLOG( "[OMADM] CNSmlDMSyncProfile::IsSynced(): Opening history log" ); |
|
287 OpenHistoryLog(); |
|
288 } |
|
289 |
|
290 if ( iHistoryLogOpen ) |
|
291 { |
|
292 FTRACE( FPrint( _L( |
|
293 "[OMADM] CNSmlDMSyncProfile::IsSynced(): Log open! Log count = %d"), |
|
294 iHistoryLog.Count() ) ); |
|
295 if ( iHistoryLog.Count() > 0 ) |
|
296 { |
|
297 const CSyncMLHistoryJob* job = LatestHistoryJob(); |
|
298 if ( job ) |
|
299 { |
|
300 FLOG( "[OMADM] CNSmlDMSyncProfile::IsSynced(): True" ); |
|
301 if( job->LastSuccessSyncTime() != NULL ) |
|
302 { |
|
303 retVal = ETrue; |
|
304 } |
|
305 } |
|
306 else |
|
307 { |
|
308 FLOG( "[OMADM] CNSmlDMSyncProfile::IsSynced(): False" ); |
|
309 } |
|
310 } |
|
311 } |
|
312 else |
|
313 { |
|
314 FLOG( "[OMADM] CNSmlDMSyncProfile::IsSynced() Could not open history log!!!" ); |
|
315 } |
|
316 CloseHistoryLog(); |
|
317 |
|
318 FLOG( "[OMADM] CNSmlDMSyncProfile::IsSynced() completed" ); |
|
319 return retVal; |
|
320 } |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // CNSmlDMSyncProfile::LastSync |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 TTime CNSmlDMSyncProfile::LastSync() |
|
327 { |
|
328 FLOG( "[OMADM] CNSmlDMSyncProfile::LastSync()" ); |
|
329 |
|
330 if ( !iHistoryLogOpen ) |
|
331 { |
|
332 FLOG( "[OMADM] CNSmlDMSyncProfile::LastSync(): Opening history log" ); |
|
333 OpenHistoryLog(); |
|
334 } |
|
335 |
|
336 TTime time = 0; |
|
337 if ( iHistoryLogOpen ) |
|
338 { |
|
339 FTRACE( FPrint( _L( |
|
340 "[OMADM] CNSmlDMSyncProfile::LastSync(): Log open! Log count = %d"), |
|
341 iHistoryLog.Count() ) ); |
|
342 |
|
343 if (iHistoryLog.Count() > 0) |
|
344 { |
|
345 const CSyncMLHistoryJob* job = LatestHistoryJob(); |
|
346 if ( job ) |
|
347 { |
|
348 FLOG( "[OMADM] CNSmlDMSyncProfile::LastSync() timestamp" ); |
|
349 time = job->TimeStamp(); |
|
350 } |
|
351 } |
|
352 } |
|
353 else |
|
354 { |
|
355 FLOG( "[OMADM] CNSmlDMSyncProfile::LastSync() Could not open history log!!!" ); |
|
356 } |
|
357 |
|
358 CloseHistoryLog(); |
|
359 |
|
360 FLOG( "[OMADM] CNSmlDMSyncProfile::LastSync() completed" ); |
|
361 return time; |
|
362 } |
|
363 |
|
364 TTime CNSmlDMSyncProfile::LastSuccessSync() |
|
365 { |
|
366 FLOG( "[OMADM] CNSmlDMSyncProfile::LastSuccessSynctime()" ); |
|
367 |
|
368 if ( !iHistoryLogOpen ) |
|
369 { |
|
370 FLOG( "[OMADM] CNSmlDMSyncProfile::LastSync(): Opening history log" ); |
|
371 OpenHistoryLog(); |
|
372 } |
|
373 |
|
374 TTime time = 0; |
|
375 if ( iHistoryLogOpen ) |
|
376 { |
|
377 FTRACE( FPrint( _L( |
|
378 "[OMADM] CNSmlDMSyncProfile::LastSync(): Log open! Log count = %d"), |
|
379 iHistoryLog.Count() ) ); |
|
380 |
|
381 if (iHistoryLog.Count() > 0) |
|
382 { |
|
383 const CSyncMLHistoryJob* job = LatestHistoryJob(); |
|
384 iProfileId=ProfileId(); |
|
385 if ( job ) |
|
386 { |
|
387 FLOG( "[OMADM] CNSmlDMSyncProfile::LastSync() timestamp" ); |
|
388 time = job->LastSuccessSyncTime(); |
|
389 } |
|
390 } |
|
391 } |
|
392 else |
|
393 { |
|
394 FLOG( "[OMADM] CNSmlDMSyncProfile::LastSync() Could not open history log!!!" ); |
|
395 } |
|
396 |
|
397 CloseHistoryLog(); |
|
398 |
|
399 FLOG( "[OMADM] CNSmlDMSyncProfile::LastSuccessSynctime() completed" ); |
|
400 return time; |
|
401 } |
|
402 |
|
403 // ----------------------------------------------------------------------------- |
|
404 // CNSmlDMSyncProfile::GetServerIdL |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 void CNSmlDMSyncProfile::GetServerId( TDes& aText ) |
|
408 { |
|
409 FLOG( "[OMADM] CNSmlDMSyncProfile::GetServerIdL:" ); |
|
410 |
|
411 TUtil::StrCopy(aText, iProfile.ServerId()); |
|
412 } |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // CNSmlDMSyncProfile::SetServerIdL |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 void CNSmlDMSyncProfile::SetServerIdL( const TDesC& aText ) |
|
419 { |
|
420 FLOG( "[OMADM] CNSmlDMSyncProfile::SetServerIdL:" ); |
|
421 |
|
422 TBuf8<KBufSize256> buf; |
|
423 TUtil::StrCopy(buf, aText); |
|
424 iProfile.SetServerIdL(buf); |
|
425 } |
|
426 |
|
427 // ----------------------------------------------------------------------------- |
|
428 // CNSmlDMSyncProfile::GetServerPassword |
|
429 // ----------------------------------------------------------------------------- |
|
430 // |
|
431 void CNSmlDMSyncProfile::GetServerPassword(TDes& aText) |
|
432 { |
|
433 FLOG( "[OMADM] CNSmlDMSyncProfile::GetServerPassword:" ); |
|
434 |
|
435 TUtil::StrCopy( aText, iProfile.ServerPassword() ); |
|
436 } |
|
437 |
|
438 // ----------------------------------------------------------------------------- |
|
439 // CNSmlDMSyncProfile::SetServerPasswordL |
|
440 // ----------------------------------------------------------------------------- |
|
441 // |
|
442 void CNSmlDMSyncProfile::SetServerPasswordL(const TDesC& aText) |
|
443 { |
|
444 FLOG( "[OMADM] CNSmlDMSyncProfile::SetServerPasswordL:" ); |
|
445 |
|
446 TUtil::StrCopy(iBuf8, aText); // conver TDes to TDes8 |
|
447 iProfile.SetServerPasswordL(iBuf8); |
|
448 } |
|
449 |
|
450 // ----------------------------------------------------------------------------- |
|
451 // CNSmlDMSyncProfile::ProtocolVersion |
|
452 // ----------------------------------------------------------------------------- |
|
453 // |
|
454 TInt CNSmlDMSyncProfile::ProtocolVersion() |
|
455 { |
|
456 FLOG( "[OMADM] CNSmlDMSyncProfile::ProtocolVersion:" ); |
|
457 |
|
458 TSmlProtocolVersion version = iProfile.ProtocolVersion(); |
|
459 return version; |
|
460 } |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // CNSmlDMSyncProfile::SetProtocolVersionL |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 void CNSmlDMSyncProfile::SetProtocolVersionL(TInt aProtocolVersion) |
|
467 { |
|
468 FLOG( "[OMADM] CNSmlDMSyncProfile::SetProtocolVersionL:" ); |
|
469 |
|
470 iProfile.SetProtocolVersionL((TSmlProtocolVersion) aProtocolVersion); |
|
471 } |
|
472 |
|
473 // ----------------------------------------------------------------------------- |
|
474 // CNSmlDMSyncProfile::BearerType |
|
475 // ----------------------------------------------------------------------------- |
|
476 // |
|
477 TInt CNSmlDMSyncProfile::BearerType() |
|
478 { |
|
479 FLOG( "[OMADM] CNSmlDMSyncProfile::BearerType:" ); |
|
480 |
|
481 TInt id = iConnection.Identifier(); |
|
482 |
|
483 if (id == KUidNSmlMediumTypeInternet.iUid) |
|
484 { |
|
485 return EAspBearerInternet; |
|
486 } |
|
487 else if (id == KUidNSmlMediumTypeBluetooth.iUid) |
|
488 { |
|
489 return EAspBearerBlueTooth; |
|
490 } |
|
491 else |
|
492 { |
|
493 return EAspBearerInternet; |
|
494 } |
|
495 } |
|
496 |
|
497 // ----------------------------------------------------------------------------- |
|
498 // CNSmlDMSyncProfile::SetBearerTypeL |
|
499 // ----------------------------------------------------------------------------- |
|
500 // |
|
501 void CNSmlDMSyncProfile::SetBearerTypeL(TInt aId) |
|
502 { |
|
503 FLOG( "[OMADM] CNSmlDMSyncProfile::SetBearerTypeL:" ); |
|
504 |
|
505 if ( aId == EAspBearerInternet ) |
|
506 { |
|
507 iConnection.CreateL( Profile(), KUidNSmlMediumTypeInternet.iUid ); |
|
508 } |
|
509 else if ( aId == EAspBearerBlueTooth ) |
|
510 { |
|
511 iConnection.CreateL( Profile(), KUidNSmlMediumTypeBluetooth.iUid ); |
|
512 } |
|
513 else |
|
514 { |
|
515 // Set default as Internet |
|
516 iConnection.CreateL( Profile(), KUidNSmlMediumTypeInternet.iUid ); |
|
517 } |
|
518 } |
|
519 |
|
520 // ----------------------------------------------------------------------------- |
|
521 // CNSmlDMSyncProfile::AccessPointL |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 TInt CNSmlDMSyncProfile::AccessPointL() |
|
525 { |
|
526 FLOG( "[OMADM] CNSmlDMSyncProfile::AccessPointL:" ); |
|
527 |
|
528 TInt num = KErrNotFound; |
|
529 |
|
530 if ( iConnectionOpen ) |
|
531 { |
|
532 if ( iConnection.Identifier() == KUidNSmlMediumTypeInternet.iUid ) |
|
533 { |
|
534 TBuf8<KBufSize32> key; |
|
535 TBuf<KBufSize32> value; |
|
536 |
|
537 GetConnectionPropertyNameL( key, EPropertyIntenetAccessPoint ); |
|
538 TUtil::StrCopy( value, iConnection.GetPropertyL( key ) ); |
|
539 User::LeaveIfError( TUtil::StrToInt(value, num) ); |
|
540 } |
|
541 } |
|
542 return num; |
|
543 } |
|
544 |
|
545 // ----------------------------------------------------------------------------- |
|
546 // CNSmlDMSyncProfile::SetAccessPointL |
|
547 // ----------------------------------------------------------------------------- |
|
548 // |
|
549 void CNSmlDMSyncProfile::SetAccessPointL( const TInt aId ) |
|
550 { |
|
551 FTRACE(RDebug::Print( |
|
552 _L("[OMADM] CNSmlDMSyncProfile::SetAccessPointL aId (%d)"), aId)); |
|
553 |
|
554 if ( iConnectionOpen ) |
|
555 { |
|
556 if ( iConnection.Identifier() == KUidNSmlMediumTypeInternet.iUid ) |
|
557 { |
|
558 TBuf<KBufSize32> buf; |
|
559 TBuf8<KBufSize32> key; |
|
560 TBuf8<KBufSize32> value; |
|
561 |
|
562 buf.Num(aId); |
|
563 TUtil::StrCopy(value, buf); // convert TDes to TDes8 |
|
564 |
|
565 GetConnectionPropertyNameL(key, EPropertyIntenetAccessPoint); |
|
566 |
|
567 FTRACE(RDebug::Print( |
|
568 _L("[OMADM] CNSmlDMSyncProfile::SetAccessPointL key (%S) value (%S)"), |
|
569 &key, &value ) ); |
|
570 |
|
571 iConnection.SetPropertyL( key, value ); |
|
572 } |
|
573 } |
|
574 } |
|
575 |
|
576 // ----------------------------------------------------------------------------- |
|
577 // CNSmlDMSyncProfile::GetHostAddressL |
|
578 // ----------------------------------------------------------------------------- |
|
579 // |
|
580 void CNSmlDMSyncProfile::GetHostAddress(TDes& aText, TInt& aPort) |
|
581 { |
|
582 FLOG( "[OMADM] CNSmlDMSyncProfile::GetHostAddress:" ); |
|
583 aText = KNullDesC; |
|
584 aPort = KDefaultHttpPort; |
|
585 |
|
586 if (!iConnectionOpen) |
|
587 { |
|
588 return; |
|
589 } |
|
590 |
|
591 if (BearerType() != EAspBearerInternet) |
|
592 { |
|
593 TUtil::StrCopy(aText, iConnection.ServerURI()); // convert TDes8 to TDes |
|
594 return; // port number handling is for internet bearer only |
|
595 } |
|
596 |
|
597 TUtil::StrCopy( iBuf, iConnection.ServerURI() ); // convert TDes8 to TDes |
|
598 |
|
599 TURIParser parser( iBuf ); |
|
600 parser.GetUriWithoutPort( aText ); |
|
601 aPort = parser.Port(); |
|
602 if (aPort == KErrNotFound) |
|
603 { |
|
604 aPort = parser.DefaultPort(); |
|
605 } |
|
606 } |
|
607 |
|
608 // ----------------------------------------------------------------------------- |
|
609 // CNSmlDMSyncProfile::SetHostAddressL |
|
610 // ----------------------------------------------------------------------------- |
|
611 // |
|
612 void CNSmlDMSyncProfile::SetHostAddressL( const TDesC& aText, const TInt aPort ) |
|
613 { |
|
614 FLOG( "[OMADM] CNSmlDMSyncProfile::SetHostAddressL:" ); |
|
615 |
|
616 if (!iConnectionOpen) |
|
617 { |
|
618 return; |
|
619 } |
|
620 if (BearerType() != EAspBearerInternet) |
|
621 { |
|
622 // port number handling is for internet bearer only |
|
623 TUtil::StrCopy(iBuf, aText); |
|
624 } |
|
625 else |
|
626 { |
|
627 TURIParser parser(aText); |
|
628 parser.GetUri(iBuf, aPort); |
|
629 } |
|
630 |
|
631 TUtil::StrCopy( iBuf8, iBuf ); |
|
632 iConnection.SetServerURIL( iBuf8 ); |
|
633 } |
|
634 |
|
635 // ----------------------------------------------------------------------------- |
|
636 // CNSmlDMSyncProfile::GetUserNameL |
|
637 // ----------------------------------------------------------------------------- |
|
638 // |
|
639 void CNSmlDMSyncProfile::GetUserName(TDes& aText) |
|
640 { |
|
641 FLOG( "[OMADM] CNSmlDMSyncProfile::GetUserNameL:" ); |
|
642 |
|
643 TUtil::StrCopy( aText, iProfile.UserName() ); |
|
644 } |
|
645 |
|
646 // ----------------------------------------------------------------------------- |
|
647 // CNSmlDMSyncProfile::SetUserNameL |
|
648 // ----------------------------------------------------------------------------- |
|
649 // |
|
650 void CNSmlDMSyncProfile::SetUserNameL(const TDesC& aText) |
|
651 { |
|
652 FLOG( "[OMADM] CNSmlDMSyncProfile::SetUserNameL:" ); |
|
653 |
|
654 TUtil::StrCopy(iBuf8, aText); // conver TDes to TDes8 |
|
655 iProfile.SetUserNameL(iBuf8); |
|
656 } |
|
657 |
|
658 // ----------------------------------------------------------------------------- |
|
659 // CNSmlDMSyncProfile::GetPasswordL |
|
660 // ----------------------------------------------------------------------------- |
|
661 // |
|
662 void CNSmlDMSyncProfile::GetPassword(TDes& aText) |
|
663 { |
|
664 FLOG( "[OMADM] CNSmlDMSyncProfile::GetPasswordL:" ); |
|
665 |
|
666 TUtil::StrCopy( aText, iProfile.Password() ); |
|
667 } |
|
668 |
|
669 // ----------------------------------------------------------------------------- |
|
670 // CNSmlDMSyncProfile::SetPasswordL |
|
671 // ----------------------------------------------------------------------------- |
|
672 // |
|
673 void CNSmlDMSyncProfile::SetPasswordL(const TDesC& aText) |
|
674 { |
|
675 FLOG( "[OMADM] CNSmlDMSyncProfile::SetPasswordL:" ); |
|
676 TUtil::StrCopy( iBuf8, aText ); // conver TDes to TDes8 |
|
677 |
|
678 FTRACE( RDebug::Print( |
|
679 _L("[OMADM] CNSmlDMSyncProfile::SetPasswordL iBuf8 (%S)"), &iBuf8 ) ); |
|
680 iProfile.SetPasswordL( iBuf8 ); |
|
681 } |
|
682 |
|
683 // ----------------------------------------------------------------------------- |
|
684 // CNSmlDMSyncProfile::SASyncState |
|
685 // ----------------------------------------------------------------------------- |
|
686 // |
|
687 TInt CNSmlDMSyncProfile::SASyncState() |
|
688 { |
|
689 FLOG( "[OMADM] CNSmlDMSyncProfile::SASyncState()" ); |
|
690 |
|
691 TSmlServerAlertedAction state = iProfile.SanUserInteraction(); |
|
692 |
|
693 FTRACE( FPrint( |
|
694 _L( "[OMADM] CNSmlDMSyncProfile::SASyncState() completed, state = %d" ), |
|
695 state ) ); |
|
696 |
|
697 if (state == ESmlConfirmSync) |
|
698 { |
|
699 return ESASyncStateConfirm; |
|
700 } |
|
701 else if (state == ESmlDisableSync) |
|
702 { |
|
703 return ESASyncStateDisable; |
|
704 } |
|
705 else |
|
706 { |
|
707 return ESASyncStateEnable; |
|
708 } |
|
709 } |
|
710 |
|
711 // ----------------------------------------------------------------------------- |
|
712 // CNSmlDMSyncProfile::SetSASyncStateL |
|
713 // ----------------------------------------------------------------------------- |
|
714 // |
|
715 void CNSmlDMSyncProfile::SetSASyncStateL(TInt aState) |
|
716 { |
|
717 if (aState == ESASyncStateConfirm) |
|
718 { |
|
719 FLOG( "[OMADM] CNSmlDMSyncProfile::SetSASyncStateL:ESmlConfirmSync" ); |
|
720 Profile().SetSanUserInteractionL(ESmlConfirmSync); |
|
721 } |
|
722 else if (aState == ESASyncStateDisable) |
|
723 { |
|
724 FLOG( "[OMADM] CNSmlDMSyncProfile::SetSASyncStateL:ESmlDisableSync" ); |
|
725 Profile().SetSanUserInteractionL(ESmlDisableSync); |
|
726 } |
|
727 else |
|
728 { |
|
729 FLOG( "[OMADM] CNSmlDMSyncProfile::SetSASyncStateL:ESmlEnableSync" ); |
|
730 Profile().SetSanUserInteractionL(ESmlEnableSync); |
|
731 } |
|
732 } |
|
733 |
|
734 // ----------------------------------------------------------------------------- |
|
735 // CNSmlDMSyncProfile::SetHttpUsed |
|
736 // ----------------------------------------------------------------------------- |
|
737 // |
|
738 void CNSmlDMSyncProfile::SetHttpUsedL(TBool aEnable) |
|
739 { |
|
740 FLOG( "[OMADM] CNSmlDMSyncProfile::SetHttpUsed:" ); |
|
741 |
|
742 if ( iConnectionOpen ) |
|
743 { |
|
744 if ( iConnection.Identifier() == KUidNSmlMediumTypeInternet.iUid ) |
|
745 { |
|
746 TBuf8<KBufSize32> key; |
|
747 TBuf8<KBufSize32> value; |
|
748 |
|
749 if ( aEnable ) |
|
750 { |
|
751 value.Num( KHttpUsed ); |
|
752 } |
|
753 else |
|
754 { |
|
755 value.Num( KHttpNotUsed ); |
|
756 } |
|
757 |
|
758 GetConnectionPropertyNameL( key, EPropertyHttpUsed ); |
|
759 iConnection.SetPropertyL( key, value ); |
|
760 } |
|
761 } |
|
762 } |
|
763 |
|
764 // ----------------------------------------------------------------------------- |
|
765 // CNSmlDMSyncProfile::HttpUsedL |
|
766 // ----------------------------------------------------------------------------- |
|
767 // |
|
768 TBool CNSmlDMSyncProfile::HttpUsedL() |
|
769 { |
|
770 FLOG( "[OMADM] CNSmlDMSyncProfile::HttpUsedL:" ); |
|
771 TBool retVal = EFalse; |
|
772 if ( iConnectionOpen ) |
|
773 { |
|
774 if ( iConnection.Identifier() == KUidNSmlMediumTypeInternet.iUid ) |
|
775 { |
|
776 TBuf8<KBufSize32> key; |
|
777 TBuf<KBufSize32> value; |
|
778 TInt intValue; |
|
779 |
|
780 GetConnectionPropertyNameL(key, EPropertyHttpUsed); |
|
781 TUtil::StrCopy(value, iConnection.GetPropertyL(key)); |
|
782 |
|
783 User::LeaveIfError( TUtil::StrToInt( value, intValue ) ); |
|
784 |
|
785 if ( intValue == 1 ) |
|
786 { |
|
787 retVal = ETrue; |
|
788 } |
|
789 } |
|
790 } |
|
791 return retVal; |
|
792 } |
|
793 |
|
794 // ----------------------------------------------------------------------------- |
|
795 // CNSmlDMSyncProfile::GetHttpUsernameL |
|
796 // ----------------------------------------------------------------------------- |
|
797 // |
|
798 void CNSmlDMSyncProfile::GetHttpUserNameL( TDes& aText ) |
|
799 { |
|
800 FLOG( "[OMADM] CNSmlDMSyncProfile::GetHttpUsernameL:" ); |
|
801 |
|
802 aText = KNullDesC; |
|
803 |
|
804 if ( iConnectionOpen ) |
|
805 { |
|
806 if ( iConnection.Identifier() == KUidNSmlMediumTypeInternet.iUid ) |
|
807 { |
|
808 TBuf8<KBufSize32> key; |
|
809 |
|
810 GetConnectionPropertyNameL( key, EPropertyHttpUserName ); |
|
811 TUtil::StrCopy( aText, iConnection.GetPropertyL( key ) ); |
|
812 } |
|
813 } |
|
814 } |
|
815 |
|
816 // ----------------------------------------------------------------------------- |
|
817 // CNSmlDMSyncProfile::SetHttpUsernameL |
|
818 // ----------------------------------------------------------------------------- |
|
819 // |
|
820 void CNSmlDMSyncProfile::SetHttpUserNameL( const TDesC& aText ) |
|
821 { |
|
822 FLOG( "[OMADM] CNSmlDMSyncProfile::SetHttpUsernameL:" ); |
|
823 |
|
824 if ( iConnectionOpen ) |
|
825 { |
|
826 if ( iConnection.Identifier() == KUidNSmlMediumTypeInternet.iUid ) |
|
827 { |
|
828 TBuf8<KBufSize32> key; |
|
829 |
|
830 GetConnectionPropertyNameL( key, EPropertyHttpUserName ); |
|
831 TUtil::StrCopy( iBuf8, aText ); // convert TDes to TDes8 |
|
832 iConnection.SetPropertyL( key, iBuf8 ); |
|
833 } |
|
834 } |
|
835 } |
|
836 |
|
837 // ----------------------------------------------------------------------------- |
|
838 // CNSmlDMSyncProfile::GetHttpPasswordL |
|
839 // ----------------------------------------------------------------------------- |
|
840 // |
|
841 void CNSmlDMSyncProfile::GetHttpPasswordL( TDes& aText ) |
|
842 { |
|
843 FLOG( "[OMADM] CNSmlDMSyncProfile::GetHttpPasswordL:" ); |
|
844 aText = KNullDesC; |
|
845 |
|
846 if ( iConnectionOpen ) |
|
847 { |
|
848 if ( iConnection.Identifier() == KUidNSmlMediumTypeInternet.iUid ) |
|
849 { |
|
850 TBuf8<KBufSize32> key; |
|
851 GetConnectionPropertyNameL( key, EPropertyHttpPassword ); |
|
852 TUtil::StrCopy( aText, iConnection.GetPropertyL( key ) ); |
|
853 } |
|
854 } |
|
855 } |
|
856 |
|
857 // ----------------------------------------------------------------------------- |
|
858 // CNSmlDMSyncProfile::SetHttpPasswordL |
|
859 // ----------------------------------------------------------------------------- |
|
860 // |
|
861 void CNSmlDMSyncProfile::SetHttpPasswordL( const TDesC& aText ) |
|
862 { |
|
863 FLOG( "[OMADM] CNSmlDMSyncProfile::SetHttpPasswordL:" ); |
|
864 |
|
865 if ( iConnectionOpen ) |
|
866 { |
|
867 if ( iConnection.Identifier() == KUidNSmlMediumTypeInternet.iUid ) |
|
868 { |
|
869 TBuf8<KBufSize32> key; |
|
870 |
|
871 GetConnectionPropertyNameL( key, EPropertyHttpPassword ); |
|
872 TUtil::StrCopy( iBuf8, aText ); // convert TDes to TDes8 |
|
873 iConnection.SetPropertyL( key, iBuf8 ); |
|
874 } |
|
875 } |
|
876 } |
|
877 |
|
878 // ----------------------------------------------------------------------------- |
|
879 // CNSmlDMSyncProfile::Profile |
|
880 // ----------------------------------------------------------------------------- |
|
881 // |
|
882 RSyncMLDevManProfile& CNSmlDMSyncProfile::Profile() |
|
883 { |
|
884 FLOG( "[OMADM] CNSmlDMSyncProfile::Profile()" ); |
|
885 |
|
886 return iProfile; |
|
887 } |
|
888 |
|
889 // ----------------------------------------------------------------------------- |
|
890 // CNSmlDMSyncProfile::LatestHistoryJob |
|
891 // ----------------------------------------------------------------------------- |
|
892 // |
|
893 const CSyncMLHistoryJob* CNSmlDMSyncProfile::LatestHistoryJob() |
|
894 { |
|
895 FLOG( "[OMADM] CNSmlDMSyncProfile::LatestHistoryJob:" ); |
|
896 |
|
897 if ( !iHistoryLogOpen ) |
|
898 { |
|
899 OpenHistoryLog(); |
|
900 } |
|
901 |
|
902 if ( iHistoryLogOpen ) |
|
903 { |
|
904 TInt count = iHistoryLog.Count(); |
|
905 FTRACE( FPrint( _L( |
|
906 "[OMADM] CNSmlDMSyncProfile::LatestHistoryJob(): Log count %d"), |
|
907 count ) ); |
|
908 |
|
909 if ( count == 0 ) |
|
910 { |
|
911 FLOG( "[OMADM] CNSmlDMSyncProfile::LatestHistoryJob(): No history" ); |
|
912 return NULL; // profile has no history job |
|
913 } |
|
914 |
|
915 // sort array |
|
916 iHistoryLog.SortEntries( CSyncMLHistoryEntry::ESortByTime ); |
|
917 |
|
918 // try to find latest sync job (start from last array entry) |
|
919 for ( TInt index = count - 1; index >= 0; index-- ) |
|
920 { |
|
921 FTRACE( FPrint( _L( |
|
922 "[OMADM] CNSmlDMSyncProfile::LatestHistoryJob: count %d index %d"), |
|
923 count, index ) ); |
|
924 //const CSyncMLHistoryEntry& entry = iHistoryLog[index]; |
|
925 const CSyncMLHistoryEntry& entry = iHistoryLog.Entry( index ); |
|
926 |
|
927 FTRACE( FPrint( _L( |
|
928 "[OMADM] CNSmlDMSyncProfile::LatestHistoryJob: Entry type = %x"), |
|
929 entry.EntryType().iUid ) ); |
|
930 |
|
931 const CSyncMLHistoryJob* jobEntry = |
|
932 CSyncMLHistoryJob::DynamicCast( &entry ); |
|
933 |
|
934 if ( jobEntry ) |
|
935 { |
|
936 FLOG( "[OMADM] CNSmlDMSyncProfile::LatestHistoryJob() completed: OK" ); |
|
937 return jobEntry; |
|
938 } |
|
939 } |
|
940 } |
|
941 |
|
942 FLOG( "[OMADM] CNSmlDMSyncProfile::LatestHistoryJob() completed: No history found" ); |
|
943 return NULL; // profile has no history job |
|
944 } |
|
945 |
|
946 // ----------------------------------------------------------------------------- |
|
947 // CNSmlDMSyncProfile::OpenHistoryLog |
|
948 // ----------------------------------------------------------------------------- |
|
949 // |
|
950 void CNSmlDMSyncProfile::OpenHistoryLog() |
|
951 { |
|
952 FLOG( "[OMADM] CNSmlDMSyncProfile::OpenHistoryLog()" ); |
|
953 |
|
954 TInt id = ProfileId(); |
|
955 TRAPD( err, iHistoryLog.OpenL( Session(), id ) ); |
|
956 |
|
957 if ( err == KErrNone ) |
|
958 { |
|
959 FLOG( "[OMADM] CNSmlDMSyncProfile::OpenHistoryLog(): Opened" ); |
|
960 iHistoryLogOpen = ETrue; |
|
961 } |
|
962 |
|
963 FLOG( "[OMADM] CNSmlDMSyncProfile::OpenHistoryLog() completed" ); |
|
964 } |
|
965 |
|
966 // ----------------------------------------------------------------------------- |
|
967 // CNSmlDMSyncProfile::CloseHistoryLog |
|
968 // ----------------------------------------------------------------------------- |
|
969 // |
|
970 void CNSmlDMSyncProfile::CloseHistoryLog() |
|
971 { |
|
972 FLOG( "[OMADM] CNSmlDMSyncProfile::CloseHistoryLog()" ); |
|
973 |
|
974 if ( iHistoryLogOpen ) |
|
975 { |
|
976 FLOG( "[OMADM] CNSmlDMSyncProfile::CloseHistoryLog(): Closed " ); |
|
977 iHistoryLog.Close(); |
|
978 iHistoryLogOpen = EFalse; |
|
979 } |
|
980 |
|
981 FLOG( "[OMADM] CNSmlDMSyncProfile::CloseHistoryLog() completed" ); |
|
982 } |
|
983 |
|
984 // ----------------------------------------------------------------------------- |
|
985 // CNSmlDMSyncProfile::OpenConnection |
|
986 // ----------------------------------------------------------------------------- |
|
987 // |
|
988 void CNSmlDMSyncProfile::OpenConnection() |
|
989 { |
|
990 FLOG( "[OMADM] CNSmlDMSyncProfile::OpenConnection()" ); |
|
991 |
|
992 TInt err = KErrNone; |
|
993 RArray<TSmlTransportId> arr; |
|
994 |
|
995 TRAP( err, Profile().ListConnectionsL(arr) ); |
|
996 if ( err != KErrNone ) |
|
997 { |
|
998 return; |
|
999 } |
|
1000 if ( arr.Count() == 0 ) |
|
1001 { |
|
1002 arr.Close(); |
|
1003 return; // no connection |
|
1004 } |
|
1005 |
|
1006 TInt transportId = arr[0]; |
|
1007 arr.Close(); |
|
1008 |
|
1009 TRAP( err, iConnection.OpenL( iProfile, transportId ) ); |
|
1010 if ( err == KErrNone ) |
|
1011 { |
|
1012 iConnectionOpen = ETrue; |
|
1013 } |
|
1014 |
|
1015 FTRACE( FPrint( _L( |
|
1016 "[OMADM] CNSmlDMSyncProfile::OpenConnection() completed, err = %d" ), |
|
1017 err ) ); |
|
1018 } |
|
1019 |
|
1020 // ----------------------------------------------------------------------------- |
|
1021 // CNSmlDMSyncProfile::Session |
|
1022 // ----------------------------------------------------------------------------- |
|
1023 // |
|
1024 RSyncMLSession& CNSmlDMSyncProfile::Session() |
|
1025 { |
|
1026 FLOG( "[OMADM] CNSmlDMSyncProfile::Session:" ); |
|
1027 |
|
1028 return *iSyncSession; |
|
1029 } |
|
1030 |
|
1031 // ----------------------------------------------------------------------------- |
|
1032 // CNSmlDMSyncProfile::GetConnectionPropertyNameL |
|
1033 // ----------------------------------------------------------------------------- |
|
1034 // |
|
1035 void CNSmlDMSyncProfile::GetConnectionPropertyNameL( TDes8& aText, |
|
1036 TInt aPropertyPos ) |
|
1037 { |
|
1038 FLOG( "[OMADM] CNSmlDMSyncProfile::GetConnectionPropertyNameL:" ); |
|
1039 |
|
1040 // at the moment RSyncMLTransport is only needed |
|
1041 // for internet connection settings |
|
1042 RSyncMLTransport transport; |
|
1043 CleanupClosePushL( transport ); |
|
1044 transport.OpenL( Session(), KUidNSmlMediumTypeInternet.iUid ); |
|
1045 |
|
1046 const CSyncMLTransportPropertiesArray& arr = transport.Properties(); |
|
1047 |
|
1048 __ASSERT_DEBUG( arr.Count() > aPropertyPos, TUtil::Panic( KErrGeneral ) ); |
|
1049 |
|
1050 const TSyncMLTransportPropertyInfo& info = arr.At( aPropertyPos ); |
|
1051 aText = info.iName; |
|
1052 CleanupStack::PopAndDestroy( &transport ); |
|
1053 |
|
1054 FLOG( "[OMADM] CNSmlDMSyncProfile::GetConnectionPropertyNameL() completed" ); |
|
1055 } |
|
1056 |
|
1057 // ----------------------------------------------------------------------------- |
|
1058 // CNSmlDMSyncProfile::CopyValuesL |
|
1059 // ----------------------------------------------------------------------------- |
|
1060 // |
|
1061 void CNSmlDMSyncProfile::CopyValuesL( CNSmlDMSyncProfile* aSource ) |
|
1062 { |
|
1063 FLOG( "[OMADM] CNSmlDMSyncProfile::CopyValuesL()" ); |
|
1064 |
|
1065 TBuf<KBufSize256> buf; |
|
1066 TInt num = 0; |
|
1067 |
|
1068 num = aSource->ProtocolVersion(); |
|
1069 SetProtocolVersionL( num ); |
|
1070 if ( num == 1 ) |
|
1071 { |
|
1072 aSource->GetServerId( buf ); |
|
1073 SetServerIdL( buf ); |
|
1074 } |
|
1075 |
|
1076 num = aSource->BearerType(); |
|
1077 SetBearerTypeL( num ); |
|
1078 |
|
1079 num = aSource->AccessPointL(); |
|
1080 SetAccessPointL( num ); |
|
1081 |
|
1082 aSource->GetHostAddress( buf, num ); |
|
1083 SetHostAddressL( buf, num ); |
|
1084 |
|
1085 aSource->GetUserName( buf ); |
|
1086 SetUserNameL(buf); |
|
1087 |
|
1088 aSource->GetPassword( buf ); |
|
1089 SetPasswordL( buf ); |
|
1090 |
|
1091 num = aSource->SASyncState(); |
|
1092 SetSASyncStateL( num ); |
|
1093 |
|
1094 if ( aSource->BearerType() == EAspBearerInternet) |
|
1095 { |
|
1096 num = aSource->HttpUsedL(); |
|
1097 SetHttpUsedL(num); |
|
1098 |
|
1099 aSource->GetHttpUserNameL(buf); |
|
1100 SetHttpUserNameL(buf); |
|
1101 |
|
1102 aSource->GetHttpPasswordL(buf); |
|
1103 SetHttpPasswordL(buf); |
|
1104 } |
|
1105 FLOG( "[OMADM] CNSmlDMSyncProfile::CopyValuesL() completed" ); |
|
1106 } |
|
1107 |
|
1108 // End of File |