|
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: DS Sync flow |
|
15 * |
|
16 */ |
|
17 |
|
18 #define SYNCML_V3 |
|
19 // INCLUDE FILES |
|
20 #include <SyncMLHistory.h> |
|
21 #include <e32property.h> |
|
22 #include <DataSyncInternalPSKeys.h> |
|
23 #include <nsmlconstants.h> |
|
24 #include <nsmldebug.h> |
|
25 |
|
26 // common includes with DM |
|
27 #include "nsmlagenttestdefines.h" |
|
28 #include "nsmlcliagconstants.h" |
|
29 #include "NSmlAgentBase.h" |
|
30 #include "NSmlCmdsBase.h" |
|
31 #include "NSmlStatusContainer.h" |
|
32 #include "NSmlResponseController.h" |
|
33 #include "NSmlURI.h" |
|
34 #include "NSmlHistoryArray.h" |
|
35 |
|
36 // DS specific includes |
|
37 #include "nsmldsagconstants.h" |
|
38 #include "NSmlDSAgent.h" |
|
39 #include "NSmlDSCmds.h" |
|
40 #include "nsmldscontent.h" |
|
41 #include "nsmldserror.h" |
|
42 #include "nsmldssettings.h" |
|
43 #include "nsmlagentlog.h" |
|
44 #include "nsmlroam.h" |
|
45 //RD_AUTO_RESTART |
|
46 #include <e32base.h> |
|
47 #include <centralrepository.h> |
|
48 #include "SyncMLErr.h" |
|
49 #include "nsmldsconstants.h" |
|
50 //RD_AUTO_RESTART |
|
51 _LIT( KNetMon,"\\netmon.exe" ); |
|
52 _LIT( KAutoRestart,"netmon" ); |
|
53 |
|
54 #ifndef __WINS__ |
|
55 // This lowers the unnecessary compiler warning (armv5) to remark. |
|
56 // "Warning: #174-D: expression has no effect..." is caused by |
|
57 // DBG_ARGS8 macro in no-debug builds. |
|
58 #pragma diag_remark 174 |
|
59 #endif |
|
60 |
|
61 // ============================ MEMBER FUNCTIONS =============================== |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CNSmlDSAgent::CNSmlDSAgent |
|
65 // C++ constructor. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CNSmlDSAgent::CNSmlDSAgent() |
|
69 { |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CNSmlDSAgent::ConstructL |
|
74 // Symbian 2nd phase constructor. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CNSmlDSAgent::ConstructL( MSyncMLProgressObserver* aDSObserver ) |
|
78 { |
|
79 DBG_FILE(_S8("CNSmlDSAgent::ConstructL begins")); |
|
80 CNSmlAgentBase::ConstructL(); |
|
81 iDSObserver = aDSObserver; |
|
82 iDSContent = CNSmlDSContent::NewL(); |
|
83 iError = new ( ELeave ) TNSmlDSError; |
|
84 iSyncMLMIMEType = KNSmlDSAgentMIMEType().AllocL(); |
|
85 iResultAlertCode = KNSmlDSAgentResultAlert().AllocL(); |
|
86 iNextMessageCode = KNSmlDSAgentNextMessage().AllocL(); |
|
87 iEndOfDataAlertCode = KNSmlDSAgentNoEndOfData().AllocL(); |
|
88 iUpdateLastAnchor=ETrue; |
|
89 |
|
90 //RD_AUTO_RESTART |
|
91 //Check whether the Auto Restart Feature is enabled or not |
|
92 TInt keyVal; |
|
93 iAutoRestartInitiatedSync = EFalse; |
|
94 TRAPD (err ,ReadRepositoryL(KNsmlDsAutoRestart, keyVal)); |
|
95 if(err==KErrNone && keyVal==1) |
|
96 { |
|
97 iDSNetmon = CNsmlDSNetmon::NewL(*this); |
|
98 DBG_FILE(_S8("CNSmlDSAgent::ConstructL DSNetmon is Launched")); |
|
99 |
|
100 CNsmlProfileUtil* profileUtil = CNsmlProfileUtil::NewLC(); |
|
101 profileUtil->IsValidResumeL(iAutoRestartInitiatedSync); |
|
102 profileUtil->WriteInterruptFlagL(0); |
|
103 CleanupStack::PopAndDestroy(profileUtil); |
|
104 } |
|
105 else |
|
106 { |
|
107 iDSNetmon = NULL; |
|
108 DBG_FILE(_S8("CNSmlDSAgent::ConstructL DSNetmon is not Launched")); |
|
109 } |
|
110 //RD_AUTO_RESTART |
|
111 |
|
112 // security policies for P&S reading and writing |
|
113 _LIT_SECURITY_POLICY_S0( KNSmlPSWritePolicy, KNSmlSOSServerPolicyUID.iUid ); // SID check (sosserver) when writing |
|
114 _LIT_SECURITY_POLICY_PASS( KNSmlPSReadPolicy ); // no checks done when reading |
|
115 |
|
116 // Define P&S data field for sync ON/OFF flag (may fail e.g. if exists already) |
|
117 RProperty::Define( KPSUidDataSynchronizationInternalKeys, // category |
|
118 KDataSyncStatus, // field |
|
119 RProperty::EInt, // type |
|
120 KNSmlPSReadPolicy, // read policy |
|
121 KNSmlPSWritePolicy ); // write policy |
|
122 DBG_FILE(_S8("CNSmlDSAgent::ConstructL ends")); |
|
123 |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CNSmlDSAgent::NewL |
|
128 // Symbian two-phased constructor. |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 CNSmlDSAgent* CNSmlDSAgent::NewL( MSyncMLProgressObserver* aDSObserver ) |
|
132 { |
|
133 CNSmlDSAgent* self = new (ELeave) CNSmlDSAgent(); |
|
134 CleanupStack::PushL( self ); |
|
135 self->ConstructL( aDSObserver ); |
|
136 CleanupStack::Pop(); // self |
|
137 return self; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CNSmlDSAgent::~CNSmlDSAgent |
|
142 // Destructor. |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 CNSmlDSAgent::~CNSmlDSAgent() |
|
146 { |
|
147 delete iSyncLog; |
|
148 delete iDSContent; |
|
149 delete iDSServerId; |
|
150 delete iServerAlertPackage; |
|
151 |
|
152 if ( iDSSyncTypeArray ) |
|
153 { |
|
154 iDSSyncTypeArray->Reset(); |
|
155 delete iDSSyncTypeArray; |
|
156 } |
|
157 //RD_AUTO_RESTART |
|
158 if(iDSNetmon) |
|
159 { |
|
160 delete iDSNetmon; |
|
161 iDSNetmon = NULL; |
|
162 } |
|
163 //RD_AUTO_RESTART |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CNSmlDSAgent::Synchronise |
|
168 // Starts the sync, returns immediately and the initiated sync continues in the |
|
169 // RunL() function. |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 EXPORT_C void CNSmlDSAgent::Synchronise( TRequestStatus& aStatus, |
|
173 TSmlProfileId aProfileId, |
|
174 TSmlConnectionId aConnectionId, |
|
175 CArrayFix<TNSmlContentSpecificSyncType>* aTypeArray, |
|
176 TNSmlSyncInitiation aSyncInitiation, |
|
177 TInt aSessionId, |
|
178 HBufC8* aAlertPackage ) |
|
179 { |
|
180 |
|
181 CActiveScheduler::Add( this ); |
|
182 |
|
183 iCallerStatus = &aStatus; |
|
184 iSyncInitiation = aSyncInitiation; |
|
185 iProfileID = aProfileId; |
|
186 iMediumType.iUid = aConnectionId; |
|
187 iSessionId = aSessionId; |
|
188 |
|
189 *iCallerStatus = KRequestPending; |
|
190 |
|
191 TRAPD( err, PrepareSyncL( aTypeArray ) ); |
|
192 |
|
193 if ( err != KErrNone ) |
|
194 { |
|
195 DoErrorEvent( MSyncMLProgressObserver::ESmlFatalError, err, iDSContent->TaskId(), 0, 0 ); |
|
196 User::RequestComplete( iCallerStatus, err ); |
|
197 return; |
|
198 } |
|
199 |
|
200 if ( iSyncInitiation == EServerAlerted && aAlertPackage ) |
|
201 { |
|
202 TRAP( err, iServerAlertPackage = aAlertPackage->AllocL() ); |
|
203 |
|
204 if ( err != KErrNone ) |
|
205 { |
|
206 DoErrorEvent( MSyncMLProgressObserver::ESmlFatalError, err, iDSContent->TaskId(), 0, 0 ); |
|
207 User::RequestComplete( iCallerStatus, err ); |
|
208 return; |
|
209 } |
|
210 } |
|
211 |
|
212 SetActive(); |
|
213 TRequestStatus* status = &iStatus; |
|
214 User::RequestComplete( status, KErrNone ); |
|
215 } |
|
216 |
|
217 // |
|
218 // Private member functions |
|
219 // |
|
220 // |
|
221 // Begin state sub-functions |
|
222 // |
|
223 // --------------------------------------------------------- |
|
224 // CNSmlDSAgent::BeginSubStartStateL() |
|
225 // |
|
226 // --------------------------------------------------------- |
|
227 void CNSmlDSAgent::BeginSubStartStateL() |
|
228 { |
|
229 DBG_FILE(_S8("CNSmlDSAgent::BeginSubStartStateL() begins")); |
|
230 |
|
231 iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlConnecting, 0, 0 ); |
|
232 iDSCurrBeginSubState = EBeginSubReadSettings; |
|
233 |
|
234 DBG_FILE(_S8("CNSmlDSAgent::BeginSubStartStateL() ends")); |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------- |
|
238 // CNSmlDSAgent::BeginSubReadSettingsStateL() |
|
239 // |
|
240 // --------------------------------------------------------- |
|
241 void CNSmlDSAgent::BeginSubReadSettingsStateL() |
|
242 { |
|
243 DBG_FILE(_S8("CNSmlDSAgent::BeginSubReadSettingsStateL() begins")); |
|
244 |
|
245 ReadSettingsL(); |
|
246 iDSCurrBeginSubState = EBeginSubSyncmlCmdsInstance; |
|
247 |
|
248 DBG_FILE(_S8("CNSmlDSAgent::BeginSubReadSettingsStateL() ends")); |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------- |
|
252 // CNSmlDSAgent::BeginSubSyncmlCmdsInstanceStateL() |
|
253 // |
|
254 // --------------------------------------------------------- |
|
255 void CNSmlDSAgent::BeginSubSyncmlCmdsInstanceStateL() |
|
256 { |
|
257 DBG_FILE(_S8("CNSmlDSAgent::BeginSubSyncmlCmdsInstanceStateL() begins")); |
|
258 CreateSyncmlCmdsInstanceL(); |
|
259 DBG_FILE(_S8("CNSmlDSAgent::BeginSubSyncmlCmdsInstanceStateL() ends")); |
|
260 iDSCurrBeginSubState = EBeginSubServerAlerting; |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------- |
|
264 // CNSmlDSAgent::BeginSubServerAlertingStateL() |
|
265 // |
|
266 // --------------------------------------------------------- |
|
267 void CNSmlDSAgent::BeginSubServerAlertingStateL() |
|
268 { |
|
269 DBG_FILE(_S8("CNSmlDSAgent::BeginSubServerAlertingStateL() begins")); |
|
270 |
|
271 if ( iSyncInitiation == TNSmlSyncInitiation( EServerAlerted ) ) |
|
272 { |
|
273 DBG_FILE(_S8("CNSmlDSAgent::BeginSubServerAlertingStateL() Before ServerAlertStateL")); |
|
274 ServerAlertStateL(); |
|
275 } |
|
276 |
|
277 iDSContent->InitAllSyncLogEventsL( *iSyncLog ); |
|
278 iDSCurrBeginSubState = EBeginSubOpenContentInstances; |
|
279 |
|
280 DBG_FILE(_S8("CNSmlDSAgent::BeginSubServerAlertingStateL() ends")); |
|
281 } |
|
282 |
|
283 // --------------------------------------------------------- |
|
284 // CNSmlDSAgent::BeginSubOpenContentInstancesStateL() |
|
285 // |
|
286 // --------------------------------------------------------- |
|
287 void CNSmlDSAgent::BeginSubOpenContentInstancesStateL() |
|
288 { |
|
289 DBG_FILE(_S8("CNSmlDSAgent::BeginSubOpenContentInstancesStateL() begins")); |
|
290 TBool endOfOpening = EFalse; |
|
291 OpenDatabaseInstancesL( endOfOpening ); |
|
292 if ( endOfOpening ) |
|
293 { |
|
294 // <MAPINFO_RESEND_MOD_BEGIN> |
|
295 iDSCurrBeginSubState = EBeginSubScanMapInfo; |
|
296 // iDSCurrBeginSubState = EBeginSubCreateLUIDBuffers; |
|
297 // <MAPINFO_RESEND_MOD_END> |
|
298 } |
|
299 DBG_FILE(_S8("CNSmlDSAgent::BeginSubOpenContentInstancesStateL() ends")); |
|
300 } |
|
301 |
|
302 // --------------------------------------------------------- |
|
303 // CNSmlDSAgent::BeginSubCreateLUIDBuffersStateL() |
|
304 // |
|
305 // --------------------------------------------------------- |
|
306 void CNSmlDSAgent::BeginSubCreateLUIDBuffersStateL() |
|
307 { |
|
308 DBG_FILE(_S8("CNSmlDSAgent::BeginSubCreateLUIDBuffersStateL() begins")); |
|
309 TBool endOfCreating( EFalse ); |
|
310 |
|
311 CreateLUIDBuffersL( endOfCreating ); |
|
312 |
|
313 if ( endOfCreating ) |
|
314 { |
|
315 iCurrBeginningState = EBeginConnectingToServer; |
|
316 } |
|
317 |
|
318 DBG_FILE(_S8("CNSmlDSAgent::BeginSubCreateLUIDBuffersStateL() ends")); |
|
319 } |
|
320 |
|
321 // |
|
322 // Server Alert state functions |
|
323 // |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // CNSmlDSAgent::ServerAlertStateL |
|
327 // Marks server alerted databases as alerted |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void CNSmlDSAgent::ServerAlertStateL() |
|
331 { |
|
332 // parse syncml 1.1 server alert package |
|
333 if ( iProtocolVer == ESmlVersion1_1_2 ) |
|
334 { |
|
335 TPtr8 buffer( iSyncMLCmds->BufferAreaForParsingL() ); |
|
336 |
|
337 if ( iServerAlertPackage->Length() > buffer.MaxLength() ) |
|
338 { |
|
339 return; |
|
340 } |
|
341 |
|
342 buffer.Copy( *iServerAlertPackage ); |
|
343 delete iServerAlertPackage; |
|
344 iServerAlertPackage = NULL; |
|
345 |
|
346 iDSCurrServerAlertState = EServerAlertWaitingStartMessage; |
|
347 |
|
348 while ( iSyncMLCmds->ProcessReceivedDataL() ) { } |
|
349 |
|
350 if ( iDSCurrServerAlertState != EServerAlertMessageReceived ) |
|
351 { |
|
352 User::Leave( TNSmlError::ESmlIncompleteMessage ); |
|
353 } |
|
354 } |
|
355 |
|
356 iDSContent->RemoveNotServerAlertedContents(); |
|
357 |
|
358 if ( iProtocolVer == ESmlVersion1_2 ) |
|
359 { |
|
360 if ( iDSContent->AllDatabasesAreInterrupted() ) |
|
361 { |
|
362 if ( iError->SyncLogErrorCode() ) |
|
363 { |
|
364 User::Leave( iError->SyncLogErrorCode() ); |
|
365 } |
|
366 else |
|
367 { |
|
368 User::Leave( TNSmlDSError::ESmlDSNoValidDatabases ); |
|
369 } |
|
370 } |
|
371 } |
|
372 } |
|
373 |
|
374 // ----------------------------------------------------------------------------- |
|
375 // CNSmlDSAgent::ServerAlertStartMessageStateL |
|
376 // Handles SyncHdr in Server Alert Package from server. |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 void CNSmlDSAgent::ServerAlertStartMessageStateL( SmlSyncHdr_t* aSyncHdr ) |
|
380 { |
|
381 if ( iDSCurrServerAlertState != EServerAlertWaitingStartMessage ) |
|
382 { |
|
383 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
384 } |
|
385 |
|
386 iSyncMLCmds->ProcessSyncHdrL( aSyncHdr ); |
|
387 |
|
388 iDSCurrServerAlertState = EServerAlertWaitingAlerts; |
|
389 } |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // CNSmlDSAgent::ServerAlertAlertCmdStateL |
|
393 // Handles Alert command in Server Alert Package from server. |
|
394 // ----------------------------------------------------------------------------- |
|
395 // |
|
396 void CNSmlDSAgent::ServerAlertAlertCmdStateL( SmlAlert_t* aAlert ) |
|
397 { |
|
398 if ( iDSCurrServerAlertState != EServerAlertWaitingAlerts ) |
|
399 { |
|
400 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
401 } |
|
402 |
|
403 if ( iSyncMLCmds->AlertCode( aAlert ) == KNSmlAgentDisplayAlert ) |
|
404 { |
|
405 iSyncMLCmds->ProcessAlertCmdL( aAlert, EFalse, EFalse, ETrue ); |
|
406 } |
|
407 else |
|
408 { |
|
409 iSyncMLCmds->ProcessAlertCmdL( aAlert, EFalse, ETrue ); |
|
410 } |
|
411 } |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // CNSmlDSAgent::ServerAlertEndMessageStateL |
|
415 // Processes the end of the alert command in server alert package. |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 void CNSmlDSAgent::ServerAlertEndMessageStateL( TBool /*aFinal*/ ) |
|
419 { |
|
420 if ( iDSCurrServerAlertState != EServerAlertWaitingAlerts ) |
|
421 { |
|
422 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
423 } |
|
424 |
|
425 iDSCurrServerAlertState = EServerAlertMessageReceived; |
|
426 } |
|
427 |
|
428 // |
|
429 // Client Initialisation state functions |
|
430 // |
|
431 |
|
432 // --------------------------------------------------------- |
|
433 // CNSmlDSAgent::InitStartingMessageStateL() |
|
434 // "Initialising" event to UI, initialises interruption flags |
|
435 // set by possible first initialisation attempt, makes SyncHdr |
|
436 // --------------------------------------------------------- |
|
437 void CNSmlDSAgent::InitStartingMessageStateL() |
|
438 { |
|
439 iDSContent->InitInterruptionFlags(); |
|
440 iDSContent->SetToFirst(); |
|
441 InitStartingMessageStateBaseL(); |
|
442 } |
|
443 |
|
444 //RD_SUSPEND_RESUME |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CNSmlDSAgent::MapAlertCode |
|
447 // Maps the Alert code |
|
448 // ----------------------------------------------------------------------------- |
|
449 // |
|
450 TPtrC8 CNSmlDSAgent::MapAlertCode(TNSmlPreviousSyncType aAlertCode) |
|
451 |
|
452 { |
|
453 TPtrC8 prevAlert; |
|
454 if ( aAlertCode == ESyncDSTwoWay ) |
|
455 { |
|
456 prevAlert.Set( KNSmlDSTwoWay); |
|
457 } |
|
458 else if ( aAlertCode == ESyncDSSlowSync) |
|
459 { |
|
460 prevAlert.Set(KNSmlDSSlowSync); |
|
461 } |
|
462 else if ( aAlertCode == ESyncDSOneWayFromClient) |
|
463 { |
|
464 prevAlert.Set(KNSmlDSOneWayFromClient); |
|
465 } |
|
466 else if ( aAlertCode == ESyncDSRefreshFromClient) |
|
467 { |
|
468 prevAlert.Set(KNSmlDSRefreshFromClient); |
|
469 } |
|
470 else if ( aAlertCode == ESyncDSOneWayFromServer ) |
|
471 { |
|
472 prevAlert.Set(KNSmlDSOneWayFromServer); |
|
473 } |
|
474 else if(aAlertCode ==ESyncDSRefreshFromServer ) |
|
475 { |
|
476 prevAlert.Set(KNSmlDSRefreshFromServer); |
|
477 } |
|
478 else if(aAlertCode ==ESyncDSTwoWayByServer ) |
|
479 { |
|
480 prevAlert.Set(KNSmlDSTwoWayByServer); |
|
481 } |
|
482 else if(aAlertCode ==ESyncDSOneWayFromClientByServer ) |
|
483 { |
|
484 prevAlert.Set(KNSmlDSOneWayFromClientByServer); |
|
485 } |
|
486 else if(aAlertCode ==ESyncDSRefreshFromClientByServer ) |
|
487 { |
|
488 prevAlert.Set(KNSmlDSRefreshFromClientByServer); |
|
489 } |
|
490 else if(aAlertCode ==ESyncDSOneWayFromServerByServer ) |
|
491 { |
|
492 prevAlert.Set(KNSmlDSOneWayFromServerByServer); |
|
493 } |
|
494 else if(aAlertCode ==ESyncDSRefreshFromServerByServer ) |
|
495 { |
|
496 prevAlert.Set(KNSmlDSRefreshFromServerByServer); |
|
497 } |
|
498 |
|
499 return(prevAlert); |
|
500 |
|
501 |
|
502 } |
|
503 //RD_SUSPEND_RESUME |
|
504 |
|
505 // CNSmlDSAgent::InitAlertingStateL |
|
506 // Makes Alert command for each database. If there is a previously completed |
|
507 // sync the client suggests two-way sync else slow sync is proposed. |
|
508 // ----------------------------------------------------------------------------- |
|
509 // |
|
510 void CNSmlDSAgent::InitAlertingStateL() |
|
511 { |
|
512 |
|
513 if ( iDSClientNextSyncAnchor == TTime( 0 ) ) |
|
514 { |
|
515 iDSClientNextSyncAnchor.UniversalTime(); |
|
516 } |
|
517 |
|
518 if ( iDSContent->SetToFirst() ) |
|
519 { |
|
520 |
|
521 do |
|
522 { |
|
523 TBuf8<3> syncType( iDSContent->SyncType() ); |
|
524 TTime clientLastSyncAnchor( iDSContent->LastSyncAnchorL() ); |
|
525 TNSmlPreviousSyncType prevSyncType=iDSContent->PreviousClientSyncTypeL(); |
|
526 iDSContent->SetSessionResumedL(EFalse); |
|
527 if (!iDSContent->Interrupted()) |
|
528 { |
|
529 //RD_SUSPEND_RESUME |
|
530 if(iDSContent->SuspendedStateL() == EStateNotStarted) |
|
531 { |
|
532 if ( syncType == KNSmlDSTwoWay ) |
|
533 { |
|
534 // <MAPINFO_RESEND_MOD_BEGIN> |
|
535 if ( ( !iDSContent->HasSyncHistoryL() || iDSContent->SlowSyncRequestL() || clientLastSyncAnchor == TTime( 0 ) )&& !iDSContent->MapExists() ) |
|
536 // if ( !iDSContent->HasSyncHistoryL() || iDSContent->SlowSyncRequestL() || clientLastSyncAnchor == TTime( 0 ) ) |
|
537 // <MAPINFO_RESEND_MOD_BEGIN> |
|
538 { |
|
539 syncType = KNSmlDSSlowSync; |
|
540 |
|
541 } |
|
542 } |
|
543 } |
|
544 //checks for protocol version, stage of interruption ,sync history to send resume command |
|
545 else if (iProtocolVer==ESmlVersion1_2 && iDSContent->HasSyncHistoryL() && |
|
546 prevSyncType!=ETypeNotSet && syncType!= KNSmlDSRefreshFromServer) |
|
547 { |
|
548 //Client rejects to the Resume session when the Sync type is changed in the UI |
|
549 //Based on the section "Refusing to Resume a session" in the OMA-Protocol spec |
|
550 //Two way sync will be proposed by the client instead of the Resume session |
|
551 if(syncType.Compare(MapAlertCode(prevSyncType))==0) |
|
552 { |
|
553 syncType = KNSmlDSResume; |
|
554 iDSContent->SetSessionResumedL(ETrue); |
|
555 } |
|
556 else |
|
557 { |
|
558 syncType=KNSmlDSSlowSync; |
|
559 iDSContent->SetSessionResumedL(EFalse); |
|
560 } |
|
561 } |
|
562 //RD_SUSPEND_RESUME |
|
563 |
|
564 iSyncMLCmds->DoAlertL( syncType, &clientLastSyncAnchor, &iDSClientNextSyncAnchor ); |
|
565 iDSContent->SetInitAlertWaiting(); |
|
566 |
|
567 } |
|
568 |
|
569 |
|
570 } |
|
571 while ( iDSContent->SetToNext() ); |
|
572 } |
|
573 |
|
574 iCurrClientInitState = EInitDeviceInfo; |
|
575 } |
|
576 |
|
577 // ----------------------------------------------------------------------------- |
|
578 // CNSmlDSAgent::InitDeviceInfoStateL |
|
579 // If there is some database which is not previously synced with the server then |
|
580 // DevInfo is sent in a Put command. |
|
581 // ----------------------------------------------------------------------------- |
|
582 // |
|
583 void CNSmlDSAgent::InitDeviceInfoStateL() |
|
584 { |
|
585 if ( iDSContent->SetToFirst() ) |
|
586 { |
|
587 do |
|
588 { |
|
589 if ( ( !iDSContent->HasSyncHistoryL() || iDSContent->LastSyncAnchorL() == TTime( 0 ) ) && !iDSContent->Interrupted() ) |
|
590 { |
|
591 iSyncMLCmds->DoPutL(); |
|
592 iDSDeviceInfoRequestByClient = ETrue; |
|
593 break; |
|
594 } |
|
595 } |
|
596 while ( iDSContent->SetToNext() ); |
|
597 } |
|
598 |
|
599 iCurrClientInitState = EInitAskingDeviceInfo; |
|
600 } |
|
601 |
|
602 // --------------------------------------------------------- |
|
603 // CNSmlDSAgent::InitAskingDeviceInfoStateL() |
|
604 // If there is one database which is not previosly synced with the |
|
605 // server, Device Info is asked Get command |
|
606 // --------------------------------------------------------- |
|
607 void CNSmlDSAgent::InitAskingDeviceInfoStateL() |
|
608 { |
|
609 if ( iDSDeviceInfoRequestByClient ) |
|
610 { |
|
611 iSyncMLCmds->DoGetL(); |
|
612 } |
|
613 iCurrClientInitState = EInitEndingMessage; |
|
614 } |
|
615 |
|
616 // |
|
617 // Server Initialisation state functions |
|
618 // |
|
619 // --------------------------------------------------------- |
|
620 // CNSmlDSAgent::ServerInitialisationStateL() |
|
621 // Main state function to read Sync Initialization Package from Server |
|
622 // --------------------------------------------------------- |
|
623 void CNSmlDSAgent::ServerInitialisationStateL() |
|
624 { |
|
625 //DBG_FILE(_S8("CNSmlDSAgent::ServerInitialisationStateL begins")); |
|
626 |
|
627 TBool messageReceived( EFalse ); |
|
628 |
|
629 if ( iDSCurrServerInitState == EServerInitEnd ) |
|
630 { |
|
631 messageReceived = ETrue; |
|
632 } |
|
633 else |
|
634 { |
|
635 messageReceived = !iSyncMLCmds->ProcessReceivedDataL(); |
|
636 } |
|
637 |
|
638 if ( messageReceived ) |
|
639 { |
|
640 switch ( iDSCurrServerInitState ) |
|
641 { |
|
642 case EServerInitMessageReceived: |
|
643 { |
|
644 iBusyStatusReceived = iSyncMLCmds->BusyStatus(); |
|
645 NextMainStateL(); |
|
646 break; |
|
647 } |
|
648 |
|
649 case EServerInitPackageReceived: |
|
650 { |
|
651 if ( !iChallengeRequest ) |
|
652 { |
|
653 CheckStatusCodesAreReceivedL(); |
|
654 CheckCommandsAreReceivedL(); |
|
655 TInt retVal( iDSContent->SetTypeAndDevCapsL() ); |
|
656 |
|
657 if ( retVal != KErrNone ) |
|
658 { |
|
659 InterruptL( iDSContent->CurrentIndex(), TNSmlError::ESmlTypeNotSupported, EFalse, EFalse ); |
|
660 } |
|
661 } |
|
662 |
|
663 iDSLUIDBufferingStarted = EFalse; |
|
664 iDSCurrServerInitState = EServerInitEnd; |
|
665 break; |
|
666 } |
|
667 |
|
668 case EServerInitEnd: |
|
669 { |
|
670 TBool endOfInits( EFalse ); |
|
671 TInt resultCode( KErrNone ); |
|
672 |
|
673 iDSContent->SetDbAndTimeInitsL( endOfInits, resultCode, iDSLUIDBufferingStarted ); |
|
674 iDSLUIDBufferingStarted = ETrue; |
|
675 |
|
676 User::LeaveIfError( resultCode ); |
|
677 |
|
678 if ( endOfInits ) |
|
679 { |
|
680 NextMainStateL(); |
|
681 } |
|
682 break; |
|
683 } |
|
684 |
|
685 default: |
|
686 { |
|
687 User::Leave( TNSmlError::ESmlIncompleteMessage ); |
|
688 } |
|
689 } |
|
690 } |
|
691 //DBG_FILE(_S8("CNSmlDSAgent::ServerInitialisationStateL ends")); |
|
692 } |
|
693 |
|
694 // --------------------------------------------------------- |
|
695 // CNSmlDSAgent::ServerInitStartMessageStateL() |
|
696 // Handles SyncHdr in Initialization Package from Server |
|
697 // --------------------------------------------------------- |
|
698 void CNSmlDSAgent::ServerInitStartMessageStateL( SmlSyncHdr_t* aSyncHdr ) |
|
699 { |
|
700 DBG_FILE(_S8("CNSmlDSAgent::ServerInitStartMessageStateL begins")); |
|
701 if ( iDSCurrServerInitState != EServerInitWaitingStartMessage ) |
|
702 { |
|
703 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
704 } |
|
705 iSyncMLCmds->ProcessSyncHdrL( aSyncHdr ); |
|
706 iDSCurrServerInitState = EServerInitWaitingCommands; |
|
707 DBG_FILE(_S8("CNSmlDSAgent::ServerInitStartMessageStateL ends")); |
|
708 } |
|
709 |
|
710 // --------------------------------------------------------- |
|
711 // CNSmlDSAgent::ServerInitStatusCmdStateL() |
|
712 // Handles Status command in Initialization Package from Server |
|
713 // --------------------------------------------------------- |
|
714 void CNSmlDSAgent::ServerInitStatusCmdStateL( SmlStatus_t* aStatus ) |
|
715 { |
|
716 DBG_FILE(_S8("CNSmlDSAgent::ServerInitStatusCmdStateL begins")); |
|
717 if ( iChallengeRequest ) |
|
718 { |
|
719 return; |
|
720 } |
|
721 if ( iDSCurrServerInitState != EServerInitWaitingCommands ) |
|
722 { |
|
723 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
724 } |
|
725 DBG_FILE(_S8("CNSmlDSAgent::ServerInitStatusCmdStateL ends")); |
|
726 iSyncMLCmds->ProcessStatusCmdL( aStatus ); |
|
727 } |
|
728 |
|
729 // --------------------------------------------------------- |
|
730 // CNSmlDSAgent::ServerInitResultsCmdStateL() |
|
731 // Handles Results command in Initialization Package from Server |
|
732 // --------------------------------------------------------- |
|
733 void CNSmlDSAgent::ServerInitResultsCmdStateL( SmlResults_t* aResults ) |
|
734 { |
|
735 DBG_FILE(_S8("CNSmlDSAgent::ServerInitResultsCmdStateL begins")); |
|
736 if ( iChallengeRequest ) |
|
737 { |
|
738 return; |
|
739 } |
|
740 if ( iDSCurrServerInitState != EServerInitWaitingCommands ) |
|
741 { |
|
742 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
743 } |
|
744 if ( !iDSDeviceInfoRequestByClient ) |
|
745 { |
|
746 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
747 } |
|
748 else |
|
749 { |
|
750 iSyncMLCmds->ProcessResultsCmdL( aResults ); |
|
751 iDSDeviceInfoRequestByClient = EFalse; |
|
752 } |
|
753 DBG_FILE(_S8("CNSmlDSAgent::ServerInitResultsCmdStateL ends")); |
|
754 } |
|
755 |
|
756 // --------------------------------------------------------- |
|
757 // CNSmlDSAgent::ServerInitAlertCmdStateL() |
|
758 // Handles Alert command in Initialization Package from Server |
|
759 // --------------------------------------------------------- |
|
760 void CNSmlDSAgent::ServerInitAlertCmdStateL( SmlAlert_t* aAlert ) |
|
761 { |
|
762 DBG_FILE(_S8("CNSmlDSAgent::ServerInitAlertCmdStateL begins")); |
|
763 if ( iChallengeRequest ) |
|
764 { |
|
765 return; |
|
766 } |
|
767 if ( iDSCurrServerInitState != EServerInitWaitingCommands ) |
|
768 { |
|
769 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
770 } |
|
771 // Alert command may be init Alert, Next Alert or Display Alert |
|
772 TBool nextAlert = EFalse; |
|
773 TBool displayAlert = EFalse; |
|
774 |
|
775 if ( iSyncMLCmds->AlertCode( aAlert ) == KNSmlDSAgentNextMessage ) |
|
776 { |
|
777 if ( !iFinalMessageFromClient ) |
|
778 { |
|
779 nextAlert = ETrue; |
|
780 } |
|
781 } |
|
782 else |
|
783 { |
|
784 if ( iSyncMLCmds->AlertCode( aAlert ) == KNSmlAgentDisplayAlert ) |
|
785 { |
|
786 displayAlert = ETrue; |
|
787 } |
|
788 } |
|
789 |
|
790 iSyncMLCmds->ProcessAlertCmdL( aAlert, nextAlert, EFalse, displayAlert ); |
|
791 DBG_FILE(_S8("CNSmlDSAgent::ServerInitAlertCmdStateL ends")); |
|
792 } |
|
793 |
|
794 // --------------------------------------------------------- |
|
795 // CNSmlDSAgent::ServerInitPutCmdStateL() |
|
796 // Handles Put command in Initialization Package from Server |
|
797 // --------------------------------------------------------- |
|
798 void CNSmlDSAgent::ServerInitPutCmdStateL( SmlPut_t* aPut ) |
|
799 { |
|
800 DBG_FILE(_S8("CNSmlDSAgent::ServerInitPutCmdStateL begins")); |
|
801 if ( iChallengeRequest ) |
|
802 { |
|
803 return; |
|
804 } |
|
805 if ( iDSCurrServerInitState != EServerInitWaitingCommands ) |
|
806 { |
|
807 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
808 } |
|
809 iSyncMLCmds->ProcessPutCmdL( aPut ); |
|
810 DBG_FILE(_S8("CNSmlDSAgent::ServerInitPutCmdStateL ends")); |
|
811 } |
|
812 |
|
813 // --------------------------------------------------------- |
|
814 // CNSmlDSAgent::ServerInitGetCmdStateL() |
|
815 // Handles Get command in Initialization Package from Server |
|
816 // --------------------------------------------------------- |
|
817 void CNSmlDSAgent::ServerInitGetCmdStateL( SmlGet_t* aGet ) |
|
818 { |
|
819 DBG_FILE(_S8("CNSmlDSAgent::ServerInitGetCmdStateL begins")); |
|
820 if ( iChallengeRequest ) |
|
821 { |
|
822 return; |
|
823 } |
|
824 if ( iDSCurrServerInitState != EServerInitWaitingCommands ) |
|
825 { |
|
826 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
827 } |
|
828 iSyncMLCmds->ProcessGetCmdL( aGet ); |
|
829 iDSDeviceInfoRequestedByServer = ETrue; |
|
830 DBG_FILE(_S8("CNSmlDSAgent::ServerInitGetCmdStateL ends")); |
|
831 } |
|
832 |
|
833 // --------------------------------------------------------- |
|
834 // CNSmlDSAgent::ServerInitEndMessageStateL() |
|
835 // |
|
836 // --------------------------------------------------------- |
|
837 void CNSmlDSAgent::ServerInitEndMessageStateL( TBool aFinal ) |
|
838 { |
|
839 DBG_FILE(_S8("CNSmlDSAgent::ServerInitEndMessageStateL begins")); |
|
840 if ( iDSCurrServerInitState != EServerInitWaitingCommands ) |
|
841 { |
|
842 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
843 } |
|
844 if ( aFinal ) |
|
845 { |
|
846 iDSCurrServerInitState = EServerInitPackageReceived; |
|
847 } |
|
848 else |
|
849 { |
|
850 iDSCurrServerInitState = EServerInitMessageReceived; |
|
851 } |
|
852 DBG_FILE(_S8("CNSmlDSAgent::ServerInitEndMessageStateL ends")); |
|
853 } |
|
854 |
|
855 // |
|
856 // Client Modifications state functions |
|
857 // |
|
858 // --------------------------------------------------------- |
|
859 // CNSmlDSAgent::ClientModificationsStateL() |
|
860 // Makes Client Modification Package to Server |
|
861 // Navigate according to state code |
|
862 // --------------------------------------------------------- |
|
863 void CNSmlDSAgent::ClientModificationsStateL() |
|
864 { |
|
865 switch ( iDSCurrClientModState ) |
|
866 { |
|
867 case EClientModStartingMessage: |
|
868 ClientModStartingMessageStateL(); |
|
869 break; |
|
870 case EClientModMakingStatus: |
|
871 ClientModMakingStatusStateL(); |
|
872 break; |
|
873 case EClientModMakingResults: |
|
874 ClientModMakingResultsStateL(); |
|
875 break; |
|
876 case EClientModStartingSync: |
|
877 ClientModStartingSyncStateL(); |
|
878 break; |
|
879 case EClientModMakingUpdates: |
|
880 ClientModMakingUpdatesStateL(); |
|
881 break; |
|
882 case EClientModEndingSync: |
|
883 ClientModEndingSyncStateL(); |
|
884 break; |
|
885 case EClientModEndingMessage: |
|
886 ClientModEndingMessageStateL(); |
|
887 break; |
|
888 default: |
|
889 User::Leave( KErrGeneral ); |
|
890 } |
|
891 } |
|
892 |
|
893 // --------------------------------------------------------- |
|
894 // CNSmlDSAgent::ClientModStartingMessageStateL() |
|
895 // "Synchronising" event to UI, makes SyncHdr |
|
896 // --------------------------------------------------------- |
|
897 void CNSmlDSAgent::ClientModStartingMessageStateL() |
|
898 { |
|
899 DBG_FILE(_S8("CNSmlDSAgent::ClientModStartingMessageStateL begins")); |
|
900 iSyncMLCmds->DoSyncHdrL(); |
|
901 iBufferFull = EFalse; |
|
902 iDSCurrClientModState = EClientModMakingStatus; |
|
903 DBG_FILE(_S8("CNSmlDSAgent::ClientModStartingMessageStateL ends")); |
|
904 } |
|
905 |
|
906 // --------------------------------------------------------- |
|
907 // CNSmlDSAgent::ClientModMakingStatusStateL() |
|
908 // Writes all buffered status elements |
|
909 // --------------------------------------------------------- |
|
910 void CNSmlDSAgent::ClientModMakingStatusStateL() |
|
911 { |
|
912 DBG_FILE(_S8("ClientModMakingStatusStateL begins")); |
|
913 iSyncMLCmds->StatusContainer()->Begin(); |
|
914 TBool found( ETrue ); |
|
915 |
|
916 while( found ) |
|
917 { |
|
918 SmlStatus_t* status; |
|
919 found = iSyncMLCmds->StatusContainer()->NextStatusElement( status, ETrue ); |
|
920 if ( found ) |
|
921 { |
|
922 iSyncMLCmds->DoStatusL( status ); |
|
923 } |
|
924 } |
|
925 |
|
926 iDSCurrClientModState = EClientModMakingResults; |
|
927 DBG_FILE(_S8("CNSmlDSAgent::ClientModMakingStatusStateL ends")); |
|
928 } |
|
929 |
|
930 // --------------------------------------------------------- |
|
931 // CNSmlDSAgent::ClientModMakingResultsStateL() |
|
932 // Device Info to a server in Results command (if asked ) |
|
933 // --------------------------------------------------------- |
|
934 void CNSmlDSAgent::ClientModMakingResultsStateL() |
|
935 { |
|
936 DBG_FILE(_S8("CNSmlDSAgent::ClientModMakingResultsStateL begins")); |
|
937 if ( iDSDeviceInfoRequestedByServer && !iDSContent->AllDatabasesAreInterrupted() ) |
|
938 { |
|
939 iSyncMLCmds->DoResultsL(); |
|
940 iDSDeviceInfoRequestedByServer = EFalse; |
|
941 } |
|
942 if ( iFinalMessageFromClient ) |
|
943 { |
|
944 iDSContent->SetToFirst(); |
|
945 } |
|
946 else |
|
947 { |
|
948 iDSContent->SetIndexToSaved(); |
|
949 } |
|
950 iDSCurrClientModState = EClientModStartingSync; |
|
951 DBG_FILE(_S8("CNSmlDSAgent::ClientModMakingResultsStateL ends")); |
|
952 } |
|
953 |
|
954 // --------------------------------------------------------- |
|
955 // CNSmlDSAgent::ClientModStartingSyncStateL() |
|
956 // Makes Sync command |
|
957 // --------------------------------------------------------- |
|
958 void CNSmlDSAgent::ClientModStartingSyncStateL() |
|
959 { |
|
960 DBG_FILE(_S8("CNSmlDSAgent::ClientModStartingSyncStateL begins")); |
|
961 CNSmlCmdsBase::TReturnValue ret; |
|
962 if ( !iDSContent->Interrupted() ) |
|
963 { |
|
964 ret = iSyncMLCmds->DoStartSyncL(); |
|
965 switch ( ret ) |
|
966 { |
|
967 case CNSmlCmdsBase::EReturnOK: |
|
968 iDSCurrClientModState = EClientModMakingUpdates; |
|
969 if ( !iDSContent->ClientItemCountAsked() ) |
|
970 { |
|
971 iDSContent->SetClientItemCountAsked(); |
|
972 iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlSendingModificationsToServer, iDSContent->ClientItemCount(), 0 ); |
|
973 } |
|
974 break; |
|
975 case CNSmlCmdsBase::EReturnBufferFull: |
|
976 iDSCurrClientModState = EClientModEndingMessage; |
|
977 iBufferFull = ETrue; |
|
978 break; |
|
979 default: |
|
980 break; |
|
981 } |
|
982 } |
|
983 else |
|
984 // skip interrupted database |
|
985 { |
|
986 if ( !iDSContent->SetToNext() ) |
|
987 { |
|
988 iDSCurrClientModState = EClientModEndingMessage; |
|
989 } |
|
990 } |
|
991 DBG_FILE(_S8("CNSmlDSAgent::ClientModStartingSyncStateL ends")); |
|
992 } |
|
993 |
|
994 // --------------------------------------------------------- |
|
995 // CNSmlDSAgent::ClientModMakingUpdatesStateL() |
|
996 // Makes Replace or Delete command |
|
997 // --------------------------------------------------------- |
|
998 void CNSmlDSAgent::ClientModMakingUpdatesStateL() |
|
999 { |
|
1000 DBG_FILE(_S8("CNSmlDSAgent::ClientModMakingUpdatesStateL begins")); |
|
1001 |
|
1002 //RD_SUSPEND_RESUME |
|
1003 // Client modifications are not sent,if the previous session was interrupted at Server modifications state.Commented for Usability issue. |
|
1004 /*if(iDSContent->SuspendedState()== EStateServerModification && iDSContent->GetSessionResumed()) |
|
1005 { |
|
1006 iDSCurrClientModState = EClientModEndingSync; |
|
1007 }else */ |
|
1008 if ( iDSContent->SyncType() == KNSmlDSOneWayFromServer || |
|
1009 iDSContent->SyncType() == KNSmlDSOneWayFromServerByServer || |
|
1010 iDSContent->SyncType() == KNSmlDSRefreshFromServer || |
|
1011 iDSContent->SyncType() == KNSmlDSRefreshFromServerByServer ) |
|
1012 { |
|
1013 iDSCurrClientModState = EClientModEndingSync; |
|
1014 } |
|
1015 else |
|
1016 { |
|
1017 switch ( iSyncMLCmds->DoAddOrReplaceOrDeleteL() ) |
|
1018 { |
|
1019 case CNSmlCmdsBase::EReturnEndData: |
|
1020 iDSCurrClientModState = EClientModEndingSync; |
|
1021 break; |
|
1022 |
|
1023 case CNSmlCmdsBase::EReturnBufferFull: |
|
1024 iDSCurrClientModState = EClientModEndingSync; |
|
1025 iBufferFull = ETrue; |
|
1026 break; |
|
1027 |
|
1028 default: |
|
1029 break; |
|
1030 } |
|
1031 } |
|
1032 |
|
1033 DBG_FILE(_S8("CNSmlDSAgent::ClientModMakingUpdatesStateL ends")); |
|
1034 } |
|
1035 |
|
1036 // --------------------------------------------------------- |
|
1037 // CNSmlDSAgent::ClientModEndingSyncStateL() |
|
1038 // End of Sync command |
|
1039 // --------------------------------------------------------- |
|
1040 void CNSmlDSAgent::ClientModEndingSyncStateL() |
|
1041 { |
|
1042 DBG_FILE(_S8("CNSmlDSAgent::ClientModEndingSyncStateL begins")); |
|
1043 |
|
1044 iSyncMLCmds->DoEndSyncL(); |
|
1045 |
|
1046 if ( iBufferFull ) |
|
1047 { |
|
1048 iDSCurrClientModState = EClientModEndingMessage; |
|
1049 } |
|
1050 else |
|
1051 { |
|
1052 if ( iDSContent->SetToNext() ) |
|
1053 { |
|
1054 iDSCurrClientModState = EClientModStartingSync; |
|
1055 } |
|
1056 else |
|
1057 { |
|
1058 iDSCurrClientModState = EClientModEndingMessage; |
|
1059 } |
|
1060 } |
|
1061 |
|
1062 DBG_FILE(_S8("CNSmlDSAgent::ClientModEndingSyncStateL ends")); |
|
1063 } |
|
1064 |
|
1065 // --------------------------------------------------------- |
|
1066 // CNSmlDSAgent::ClientModEndingMessageStateL() |
|
1067 // End of SyncMl Message, read amounts are notified to UI |
|
1068 // --------------------------------------------------------- |
|
1069 void CNSmlDSAgent::ClientModEndingMessageStateL() |
|
1070 { |
|
1071 DBG_FILE(_S8("CNSmlDSAgent::ClientModEndingMessageStateL begins")); |
|
1072 if ( iBufferFull ) |
|
1073 { |
|
1074 iSyncMLCmds->DoEndMessageL( EFalse ); |
|
1075 iFinalMessageFromClient = EFalse; |
|
1076 iDSContent->SaveCurrentIndex(); |
|
1077 } |
|
1078 else |
|
1079 { |
|
1080 iSyncMLCmds->DoEndMessageL(); |
|
1081 iFinalMessageFromClient = ETrue; |
|
1082 } |
|
1083 NextMainStateL(); |
|
1084 DBG_FILE(_S8("CNSmlDSAgent::ClientModEndingMessageStateL ends")); |
|
1085 } |
|
1086 |
|
1087 // --------------------------------------------------------- |
|
1088 // CNSmlDSAgent::ServerModificationsStateL(() |
|
1089 // Main state function to read Server Modifications to Client Package |
|
1090 // --------------------------------------------------------- |
|
1091 void CNSmlDSAgent::ServerModificationsStateL() |
|
1092 { |
|
1093 DBG_FILE(_S8("ServerModificationsStateL begins")); |
|
1094 |
|
1095 if ( iCurrServerModState == EServerModWaitingStartMessage ) |
|
1096 { |
|
1097 |
|
1098 // <MAPINFO_RESEND_MOD_BEGIN> |
|
1099 iDSContent->SetMapRemovable(); |
|
1100 iDSContent->RemoveAllRemovableMap(); |
|
1101 // <MAPINFO_RESEND_MOD_BEGIN> |
|
1102 |
|
1103 iDSContent->SetSyncStatusToAll( ENoServerDataUpdated ); |
|
1104 } |
|
1105 |
|
1106 if ( !iSyncMLCmds->ProcessReceivedDataL() ) |
|
1107 { |
|
1108 if ( iCurrServerModState == EServerModMessageReceived ) |
|
1109 { |
|
1110 iBusyStatusReceived = iSyncMLCmds->BusyStatus(); |
|
1111 CheckStatusCodesAreReceivedL( EFalse ); |
|
1112 } |
|
1113 else |
|
1114 { |
|
1115 if ( iCurrServerModState == EServerModPackageReceived ) |
|
1116 { |
|
1117 CheckStatusCodesAreReceivedL(); |
|
1118 CheckCommandsAreReceivedL(); |
|
1119 iDSContent->SetSyncStatusToAll( ECompletedOK ); |
|
1120 } |
|
1121 else |
|
1122 { |
|
1123 User::Leave( TNSmlError::ESmlIncompleteMessage ); |
|
1124 } |
|
1125 } |
|
1126 NextMainStateL(); |
|
1127 } |
|
1128 |
|
1129 DBG_FILE(_S8("CNSmlDSAgent::ServerModificationsStateL ends")); |
|
1130 } |
|
1131 |
|
1132 // |
|
1133 // Server Modifications state functions |
|
1134 // |
|
1135 // --------------------------------------------------------- |
|
1136 // CNSmlDSAgent::ServerModStartSyncStateL(() |
|
1137 // Handles Sync command in Server Modifications to Client Package |
|
1138 // --------------------------------------------------------- |
|
1139 void CNSmlDSAgent::ServerModStartSyncStateL( SmlSync_t* aSync ) |
|
1140 { |
|
1141 DBG_FILE(_S8("CNSmlDSAgent::ServerModStartSyncStateL begins")); |
|
1142 |
|
1143 if ( iCurrServerModState != EServerModWaitingCommands ) |
|
1144 { |
|
1145 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
1146 } |
|
1147 |
|
1148 iSyncMLCmds->ProcessSyncL( aSync ); |
|
1149 |
|
1150 iCurrServerModState = EServerModWaitingUpdateCommands; |
|
1151 |
|
1152 DBG_FILE(_S8("CNSmlDSAgent::ServerModStartSyncStateL ends")); |
|
1153 } |
|
1154 |
|
1155 // --------------------------------------------------------- |
|
1156 // CNSmlDSAgent::ServerModEndSyncStateL(() |
|
1157 // Handles end of Sync command |
|
1158 // --------------------------------------------------------- |
|
1159 void CNSmlDSAgent::ServerModEndSyncStateL() |
|
1160 { |
|
1161 DBG_FILE(_S8("CNSmlDSAgent::ServerModEndSyncStateL begins")); |
|
1162 |
|
1163 iSyncMLCmds->ProcessEndSyncL(); |
|
1164 |
|
1165 iCurrServerModState = EServerModWaitingCommands; |
|
1166 DBG_FILE(_S8("CNSmlDSAgent::ServerModEndSyncStateL ends")); |
|
1167 } |
|
1168 |
|
1169 // ----------------------------------------------------------------------------- |
|
1170 // CNSmlDSAgent::ServerModStartAtomicStateL |
|
1171 // Handles the Atomic command. |
|
1172 // ----------------------------------------------------------------------------- |
|
1173 // |
|
1174 void CNSmlDSAgent::ServerModStartAtomicStateL( SmlAtomic_t* aContent ) |
|
1175 { |
|
1176 if ( ( iCurrServerModState != EServerModWaitingUpdateCommands ) && ( iCurrServerModState != EServerModWaitingCommands ) ) |
|
1177 { |
|
1178 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
1179 } |
|
1180 |
|
1181 if ( iNestedAtomicsCount > 0 ) |
|
1182 { |
|
1183 iSyncMLCmds->StatusToUnsupportedCommandL( ETrue, KNSmlAgentAtomic, aContent->cmdID, aContent->flags ); |
|
1184 WriteWarningL( TNSmlError::ESmlUnexpectedCmd ); |
|
1185 } |
|
1186 else |
|
1187 { |
|
1188 iSyncMLCmds->ProcessAtomicL( aContent ); |
|
1189 } |
|
1190 |
|
1191 ++iNestedAtomicsCount; |
|
1192 } |
|
1193 |
|
1194 // ----------------------------------------------------------------------------- |
|
1195 // CNSmlDSAgent::ServerModEndAtomicStateL |
|
1196 // Handles the end of the Atomic command. |
|
1197 // ----------------------------------------------------------------------------- |
|
1198 // |
|
1199 void CNSmlDSAgent::ServerModEndAtomicStateL() |
|
1200 { |
|
1201 if ( --iNestedAtomicsCount == 0 ) |
|
1202 { |
|
1203 iSyncMLCmds->ProcessEndAtomicL(); |
|
1204 } |
|
1205 } |
|
1206 |
|
1207 // |
|
1208 // Map Acknowledgement state functions |
|
1209 // |
|
1210 // --------------------------------------------------------- |
|
1211 // CNSmlDSAgent::MapAcknowledgeStateL() |
|
1212 // Main state function to read Map Acknowledgement from Server Package |
|
1213 // --------------------------------------------------------- |
|
1214 void CNSmlDSAgent::MapAcknowledgeStateL() |
|
1215 { |
|
1216 if ( !iSyncMLCmds->ProcessReceivedDataL() ) |
|
1217 { |
|
1218 if ( iDSCurrMapAcknowledgeState == EMapAckMessageReceived ) |
|
1219 { |
|
1220 iBusyStatusReceived = iSyncMLCmds->BusyStatus(); |
|
1221 } |
|
1222 else |
|
1223 { |
|
1224 if ( iDSCurrMapAcknowledgeState == EMapAckPackageReceived ) |
|
1225 { |
|
1226 CheckStatusCodesAreReceivedL(); |
|
1227 iDSContent->SetSyncStatusToAll( ECompletedOK ); |
|
1228 } |
|
1229 else |
|
1230 { |
|
1231 if ( iDSWaitingForMapAcknowledgement ) |
|
1232 { |
|
1233 User::Leave( TNSmlError::ESmlIncompleteMessage ); |
|
1234 } |
|
1235 } |
|
1236 } |
|
1237 NextMainStateL(); |
|
1238 } |
|
1239 } |
|
1240 |
|
1241 // --------------------------------------------------------- |
|
1242 // CNSmlDSAgent::MapAckStartMessageStateL |
|
1243 // Handles SyncHdr in Map Acknowledgement from Server Package |
|
1244 // --------------------------------------------------------- |
|
1245 void CNSmlDSAgent::MapAckStartMessageStateL( SmlSyncHdr_t* aSyncHdr ) |
|
1246 { |
|
1247 DBG_FILE(_S8("CNSmlDSAgent::MapAckStartMessageStateL begins")); |
|
1248 if ( iDSCurrMapAcknowledgeState != EMapAckWaitingStartMessage ) |
|
1249 { |
|
1250 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
1251 } |
|
1252 iSyncMLCmds->ProcessSyncHdrL( aSyncHdr ); |
|
1253 iDSCurrMapAcknowledgeState = EMapAckWaitingCommands; |
|
1254 DBG_FILE(_S8("CNSmlDSAgent::MapAckStartMessageStateL ends")); |
|
1255 } |
|
1256 |
|
1257 // --------------------------------------------------------- |
|
1258 // CNSmlDSAgent::MapAckStatusCmdStateL() |
|
1259 // Handles Status command in Map Acknowledgement from Server Package |
|
1260 // --------------------------------------------------------- |
|
1261 void CNSmlDSAgent::MapAckStatusCmdStateL( SmlStatus_t* aStatus ) |
|
1262 { |
|
1263 DBG_FILE(_S8("CNSmlDSAgent::MapAckStatusCmdStateL begins")); |
|
1264 if ( iDSCurrMapAcknowledgeState != EMapAckWaitingCommands ) |
|
1265 { |
|
1266 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
1267 } |
|
1268 iSyncMLCmds->ProcessStatusCmdL ( aStatus ); |
|
1269 DBG_FILE(_S8("CNSmlDSAgent::MapAckStatusCmdStateL ends")); |
|
1270 } |
|
1271 |
|
1272 // --------------------------------------------------------- |
|
1273 // CNSmlDSAgent::MapAckAlertCmdStateL() |
|
1274 // Handles Alert command in Map Acknowledgement from Server Package |
|
1275 // --------------------------------------------------------- |
|
1276 void CNSmlDSAgent::MapAckAlertCmdStateL( SmlAlert_t* aAlert ) |
|
1277 { |
|
1278 DBG_FILE(_S8("CNSmlDSAgent::MapAckAlertCmdStateL begins")); |
|
1279 if ( iDSCurrMapAcknowledgeState != EMapAckWaitingCommands ) |
|
1280 { |
|
1281 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
1282 } |
|
1283 |
|
1284 if ( iSyncMLCmds->AlertCode( aAlert ) == KNSmlAgentDisplayAlert ) |
|
1285 { |
|
1286 iSyncMLCmds->ProcessAlertCmdL( aAlert, EFalse, EFalse, ETrue ); |
|
1287 } |
|
1288 else |
|
1289 { |
|
1290 if ( !iFinalMessageFromClient ) |
|
1291 { |
|
1292 iSyncMLCmds->ProcessAlertCmdL( aAlert, ETrue ); |
|
1293 } |
|
1294 } |
|
1295 |
|
1296 DBG_FILE(_S8("CNSmlDSAgent::MapAckAlertCmdStateL ends")); |
|
1297 } |
|
1298 |
|
1299 // --------------------------------------------------------- |
|
1300 // CNSmlDSAgent::MapAckEndMessageStateL() |
|
1301 // Handles end of SyncML message |
|
1302 // --------------------------------------------------------- |
|
1303 void CNSmlDSAgent::MapAckEndMessageStateL( TBool aFinal ) |
|
1304 { |
|
1305 DBG_FILE(_S8("CNSmlDSAgent::MapAckEndMessageStateL begins")); |
|
1306 |
|
1307 if ( iDSCurrMapAcknowledgeState != EMapAckWaitingCommands ) |
|
1308 { |
|
1309 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
1310 } |
|
1311 |
|
1312 if ( aFinal ) |
|
1313 { |
|
1314 |
|
1315 // <MAPINFO_RESEND_MOD_BEGIN> |
|
1316 iDSContent->RemoveAllRemovableMap(); |
|
1317 // <MAPINFO_RESEND_MOD_BEGIN> |
|
1318 |
|
1319 iDSCurrMapAcknowledgeState = EMapAckPackageReceived; |
|
1320 } |
|
1321 else |
|
1322 { |
|
1323 iDSCurrMapAcknowledgeState = EMapAckMessageReceived; |
|
1324 } |
|
1325 |
|
1326 DBG_FILE(_S8("CNSmlDSAgent::MapAckEndMessageStateL ends")); |
|
1327 } |
|
1328 |
|
1329 // |
|
1330 // Finishing state functions |
|
1331 // |
|
1332 |
|
1333 // --------------------------------------------------------- |
|
1334 // CNSmlDSAgent::FinishingStateL() |
|
1335 // Finishing functions in the end of sync |
|
1336 // --------------------------------------------------------- |
|
1337 void CNSmlDSAgent::FinishingStateL() |
|
1338 { |
|
1339 DBG_FILE(_S8("CNSmlDSAgent::FinishingStateL begins")); |
|
1340 |
|
1341 TInt index = iDSContent->CurrentIndex(); |
|
1342 TInt keyVal; |
|
1343 TRAPD (srerr ,ReadRepositoryL(KNsmlDsSuspendResume, keyVal)); |
|
1344 |
|
1345 if(srerr == KErrNone && keyVal == 1) |
|
1346 { |
|
1347 |
|
1348 TNSmlSyncSuspendedState suspendedState; |
|
1349 if(iDSContent->SetToFirst()) |
|
1350 { |
|
1351 do |
|
1352 { |
|
1353 suspendedState = CurrentState(); |
|
1354 iDSContent->SetSuspendedStateL(suspendedState); |
|
1355 }while( iDSContent->SetToNext() ); |
|
1356 } |
|
1357 |
|
1358 if(iDSContent->SetToFirst()) |
|
1359 { |
|
1360 do |
|
1361 { |
|
1362 TBuf8<3> syncType( iDSContent->SyncType()); |
|
1363 TNSmlPreviousSyncType prevSyncType=MapAlertCode(syncType); |
|
1364 //Sync Type of the Current Sync session is stored. |
|
1365 iDSContent->SetPreviousSyncTypeL( prevSyncType ); |
|
1366 }while( iDSContent->SetToNext() ); |
|
1367 } |
|
1368 |
|
1369 if(iDSContent->SetToFirst()) |
|
1370 { |
|
1371 do |
|
1372 { |
|
1373 TBuf8<3> clientSyncType( iDSContent->ClientSyncType()); |
|
1374 TNSmlPreviousSyncType prevClientType=MapAlertCode(clientSyncType); |
|
1375 //Sync Type proposed by Client in the Current Sync session is stored. |
|
1376 iDSContent->SetPreviousClientSyncTypeL( prevClientType ); |
|
1377 }while( iDSContent->SetToNext() ); |
|
1378 } |
|
1379 |
|
1380 } |
|
1381 //RD_SUSPEND_RESUME |
|
1382 iDSContent->SetIndex(index); |
|
1383 if( !iPacketDataUnAvailable && iUpdateLastAnchor ) |
|
1384 iDSContent->UpdateSyncAnchorsL( iDSClientNextSyncAnchor ); |
|
1385 iDSContent->FinalizeDatabasesL(); |
|
1386 FinishL(); |
|
1387 FinalizeSyncLogL(); |
|
1388 //RD_AUTO_RESTART (BPSS-7GBFF3) |
|
1389 //Check whether the Auto Restart Feature is enabled or not |
|
1390 TRAPD (arerr ,ReadRepositoryL(KNsmlDsAutoRestart, keyVal)); |
|
1391 |
|
1392 if(arerr == KErrNone && keyVal == 1) |
|
1393 { |
|
1394 if(!iPacketDataUnAvailable && !iAutoRestartInitiatedSync ) |
|
1395 { |
|
1396 DBG_FILE(_S8("CNSmlDSAgent::FinishingStateL About to check the Profile ID")); |
|
1397 |
|
1398 if(CheckProfileIdL()) |
|
1399 { |
|
1400 TerminateAutoRestart(); |
|
1401 } |
|
1402 } |
|
1403 } |
|
1404 //RD_AUTO_RESTART |
|
1405 |
|
1406 DBG_FILE(_S8("CNSmlDSAgent::FinishingStateL ends")); |
|
1407 } |
|
1408 |
|
1409 // --------------------------------------------------------- |
|
1410 // CNSmlDSAgent::OpenDatabaseInstancesL |
|
1411 // Database instances (content data adapters are created) |
|
1412 // In the creation they are harcoded by the name,later on referenced |
|
1413 // by an index. |
|
1414 // --------------------------------------------------------- |
|
1415 void CNSmlDSAgent::OpenDatabaseInstancesL( TBool& aEnd ) |
|
1416 { |
|
1417 TInt resultCode; |
|
1418 TBool ret( EFalse ); |
|
1419 |
|
1420 if ( !iDSDatabaseOpeningStarted ) |
|
1421 { |
|
1422 ret = iDSContent->SetToFirst(); |
|
1423 iDSDatabaseOpeningStarted = ETrue; |
|
1424 } |
|
1425 else |
|
1426 { |
|
1427 ret = iDSContent->SetToNext(); |
|
1428 } |
|
1429 |
|
1430 if ( ret ) |
|
1431 { |
|
1432 iDSContent->OpenContentInstanceL( resultCode ); |
|
1433 |
|
1434 switch ( resultCode ) |
|
1435 { |
|
1436 case KErrNone: |
|
1437 { |
|
1438 TBool status( EFalse ); |
|
1439 |
|
1440 TRAPD( error, status = iDSContent->IsSupportedSyncTypeL( iDSContent->SyncType() )); |
|
1441 if ( error == KErrNone ) |
|
1442 { |
|
1443 if ( !status ) |
|
1444 { |
|
1445 InterruptL( iDSContent->CurrentIndex(), TNSmlDSError::ESmlDSUnsupportedSyncType, ETrue, EFalse ); |
|
1446 iDSContent->SetInterruptedBeforeSync(); |
|
1447 } |
|
1448 } |
|
1449 else |
|
1450 { |
|
1451 InterruptL( iDSContent->CurrentIndex(), error, ETrue, EFalse ); |
|
1452 iDSContent->SetInterruptedBeforeSync(); |
|
1453 } |
|
1454 |
|
1455 } |
|
1456 break; |
|
1457 |
|
1458 case KErrNotFound: |
|
1459 InterruptL( iDSContent->CurrentIndex(), TNSmlDSError::ESmlDSLocalDatabaseError, ETrue, EFalse ); |
|
1460 iDSContent->SetInterruptedBeforeSync(); |
|
1461 break; |
|
1462 |
|
1463 default: |
|
1464 User::Leave( resultCode ); |
|
1465 } |
|
1466 } |
|
1467 else |
|
1468 { |
|
1469 aEnd = ETrue; |
|
1470 } |
|
1471 } |
|
1472 |
|
1473 // --------------------------------------------------------- |
|
1474 // CNSmlDSAgent::CreateLUIDBuffersL |
|
1475 // |
|
1476 // --------------------------------------------------------- |
|
1477 void CNSmlDSAgent::CreateLUIDBuffersL( TBool& aEnd ) |
|
1478 { |
|
1479 TBool ret( EFalse ); |
|
1480 |
|
1481 if ( !iDSLUIDBufferingStarted ) |
|
1482 { |
|
1483 ret = iDSContent->SetToFirst(); |
|
1484 iDSLUIDBufferingStarted = ETrue; |
|
1485 } |
|
1486 else |
|
1487 { |
|
1488 ret = iDSContent->SetToNext(); |
|
1489 } |
|
1490 |
|
1491 if ( ret ) |
|
1492 { |
|
1493 if ( !iDSContent->Interrupted() ) |
|
1494 { |
|
1495 TInt resultCode(KErrNone); |
|
1496 TRAPD( error, iDSContent->CreateLUIDBufferL( resultCode )); |
|
1497 |
|
1498 if ( error != KErrNone || resultCode != KErrNone ) |
|
1499 { |
|
1500 InterruptL( iDSContent->CurrentIndex(), TNSmlDSError::ESmlDSLocalDatabaseError, EFalse, ETrue ); |
|
1501 } |
|
1502 } |
|
1503 } |
|
1504 else |
|
1505 { |
|
1506 aEnd = ETrue; |
|
1507 } |
|
1508 } |
|
1509 |
|
1510 // --------------------------------------------------------- |
|
1511 // CNSmlDSAgent::CreateSyncmlCmdsInstanceL() |
|
1512 // |
|
1513 // --------------------------------------------------------- |
|
1514 void CNSmlDSAgent::CreateSyncmlCmdsInstanceL() |
|
1515 { |
|
1516 if ( !iSyncMLCmds ) |
|
1517 { |
|
1518 TBool versionCheck( ETrue ); |
|
1519 TBuf8<16> sessionIdString; |
|
1520 |
|
1521 if ( iSessionId == 0 ) |
|
1522 { |
|
1523 iSessionId = GetSessionIDL(); |
|
1524 ++iSessionId; |
|
1525 UpdateSessionIDL( iSessionId ); |
|
1526 } |
|
1527 |
|
1528 sessionIdString.Num( iSessionId ); |
|
1529 |
|
1530 if ( iSyncInitiation == EServerAlerted ) |
|
1531 { |
|
1532 versionCheck = EFalse; |
|
1533 } |
|
1534 |
|
1535 if ( iProtocolVer == ESmlVersion1_1_2 ) |
|
1536 { |
|
1537 iSyncMLCmds = CNSmlDSCmds::NewL( this, sessionIdString, KNSmlDSAgentVerProto, KNSmlSyncMLPublicId, *iSyncMLUserName, iSyncServer, *iDSContent, *iDSObserver, versionCheck ); |
|
1538 } |
|
1539 else if ( iProtocolVer == ESmlVersion1_2 ) |
|
1540 { |
|
1541 iSyncMLCmds = CNSmlDSCmds::NewL( this, sessionIdString, KNSmlDSAgentVerProto12, KNSmlSyncMLPublicId12, *iSyncMLUserName, iSyncServer, *iDSContent, *iDSObserver, versionCheck ); |
|
1542 } |
|
1543 |
|
1544 TInt value(0); |
|
1545 TRAPD (err , ReadRepositoryL(KNSmlMaxMsgSizeKey, value)); |
|
1546 if ( ( iMediumType == KUidNSmlMediumTypeInternet ) && ( err == KErrNone ) ) |
|
1547 { |
|
1548 iSyncMLCmds->SetMaximumWorkspaceSize( value ); |
|
1549 } |
|
1550 else if ( iMediumType != KUidNSmlMediumTypeInternet ) |
|
1551 { |
|
1552 iSyncMLCmds->SetMaximumWorkspaceSize( KNSmlLocalSyncWorkspaceSize ); |
|
1553 } |
|
1554 } |
|
1555 } |
|
1556 |
|
1557 // --------------------------------------------------------- |
|
1558 // CNSmlDSAgent::InfoMessageToSyncLogL() |
|
1559 // Info messages are written during the sync |
|
1560 // --------------------------------------------------------- |
|
1561 void CNSmlDSAgent::InfoMessageToSyncLogL( TInt appIndex, TInt aErrorCode ) |
|
1562 { |
|
1563 iDSContent->SetIndex( appIndex ); |
|
1564 DoErrorEvent( MSyncMLProgressObserver::ESmlWarning, aErrorCode, iDSContent->TaskId(), 0, 0 ); |
|
1565 } |
|
1566 |
|
1567 // --------------------------------------------------------- |
|
1568 // CNSmlDSAgent::ReadSettingsL() |
|
1569 // Reads sync settings |
|
1570 // --------------------------------------------------------- |
|
1571 void CNSmlDSAgent::ReadSettingsL() |
|
1572 { |
|
1573 DBG_FILE(_S8("CNSmlDSAgent::ReadSettingsL BEGIN")); |
|
1574 CNSmlDSProfile* profile = CNSmlDSSettings::NewLC()->ProfileL( iProfileID ); |
|
1575 //RD_AUTO_RESTART |
|
1576 if(iDSNetmon) |
|
1577 { |
|
1578 iDSNetmon->iProfileID=iProfileID; |
|
1579 } |
|
1580 //RD_AUTO_RESTART |
|
1581 if ( !profile ) |
|
1582 { |
|
1583 User::Leave( TNSmlError::ESmlErrorInSettings ); |
|
1584 } |
|
1585 |
|
1586 CleanupStack::PushL( profile ); |
|
1587 |
|
1588 SetDSSessionInfoL(profile); |
|
1589 |
|
1590 if ( iMediumType.iUid == -1 ) |
|
1591 { |
|
1592 iMediumType.iUid = profile->IntValue( EDSProfileTransportId ); |
|
1593 iIAPId = profile->IntValue( EDSProfileIAPId ); |
|
1594 } |
|
1595 else if ( iMediumType.iUid == KUidNSmlMediumTypeInternet.iUid ) |
|
1596 { |
|
1597 iIAPId = profile->IntValue( EDSProfileIAPId ); |
|
1598 } |
|
1599 //RD_AUTO_RESTART |
|
1600 ReplaceIAPIdL(); |
|
1601 //RD_AUTO_RESTART |
|
1602 DBG_FILE_CODE(iIAPId , _S8("CNSmlDSAgent::ReadSettingsL, The Access Point ID for the Sync Session is :")); |
|
1603 |
|
1604 iIAPIdArray = new ( ELeave ) CArrayFixFlat<TUint32>( KSmlArrayGranularity ); |
|
1605 iIAPIdArray->AppendL( iIAPId ); |
|
1606 |
|
1607 if ( profile->IntValue( EDSProfileAutoChangeIAP ) ) |
|
1608 { |
|
1609 RDbNamedDatabase* dBase = CNSmlDSSettings::NewLC()->Database(); |
|
1610 CNSmlRoamTable* roam = CNSmlRoamTable::NewLC( *dBase ); |
|
1611 CNSmlIAPArray* iapArray( roam->GetItemsForIdL( iProfileID ) ); |
|
1612 CleanupStack::PushL( iapArray ); |
|
1613 |
|
1614 for ( TInt index = 0 ; index < iapArray->Count() ; index++ ) |
|
1615 { |
|
1616 iIAPIdArray->AppendL( iapArray->At( index ) ); |
|
1617 } |
|
1618 |
|
1619 iapArray->Reset(); |
|
1620 CleanupStack::PopAndDestroy( 3 ); // iapArray, roam, settings |
|
1621 } |
|
1622 |
|
1623 iDSServerId = profile->StrValue( EDSProfileServerId ).AllocL(); |
|
1624 iSyncMLUserName = profile->StrValue( EDSProfileSyncServerUsername ).AllocL(); |
|
1625 iSyncMLPassword = profile->StrValue( EDSProfileSyncServerPassword ).AllocL(); |
|
1626 iSyncHTTPAuthUserName = profile->StrValue( EDSProfileHttpAuthUsername ).AllocL(); |
|
1627 iSyncHTTPAuthPassword = profile->StrValue( EDSProfileHttpAuthPassword ).AllocL(); |
|
1628 iSyncHTTPAuthUsed = profile->IntValue( EDSProfileHttpAuthUsed ); |
|
1629 iProtocolVer = static_cast<TSmlProtocolVersion>( profile->IntValue( EDSProfileProtocolVersion ) ); |
|
1630 |
|
1631 // set sync started to P&S (if fails -> sync not interrupted) |
|
1632 if ( iProtocolVer == ESmlVersion1_1_2 ) |
|
1633 { |
|
1634 RProperty::Set( KPSUidDataSynchronizationInternalKeys, |
|
1635 KDataSyncStatus, |
|
1636 EDataSyncRunning ); |
|
1637 } |
|
1638 else // TSmlProtocolVersion::ESmlVersion1_2 |
|
1639 { |
|
1640 RProperty::Set( KPSUidDataSynchronizationInternalKeys, |
|
1641 KDataSyncStatus, |
|
1642 EDataSyncRunning12 ); |
|
1643 } |
|
1644 |
|
1645 |
|
1646 TBool ifInternet = ETrue ; // CR: 403-1188 |
|
1647 if ( iMediumType == KUidNSmlMediumTypeInternet ) |
|
1648 { |
|
1649 iSyncServer = CNSmlURI::NewL( profile->StrValue( EDSProfileServerURL ), ETrue ); |
|
1650 } |
|
1651 else |
|
1652 { |
|
1653 iSyncServer = CNSmlURI::NewL( profile->StrValue( EDSProfileServerURL ), EFalse ); |
|
1654 ifInternet = EFalse ; // CR: 403-1188 |
|
1655 } |
|
1656 |
|
1657 if ( !profile->iContentTypes ) |
|
1658 { |
|
1659 User::Leave( TNSmlError::ESmlErrorInSettings ); |
|
1660 } |
|
1661 |
|
1662 RArray<TSmlTaskId> taskIdArray; |
|
1663 |
|
1664 |
|
1665 TBool isRemotedatabaseDefined(ETrue); |
|
1666 for ( TInt i = 0; i < profile->iContentTypes->Count(); i++ ) |
|
1667 { |
|
1668 TBool addContent( EFalse ); |
|
1669 TBool serverAlert(EFalse); |
|
1670 CNSmlDbCaps::ENSmlSyncTypes syncType( CNSmlDbCaps::EAllTypes ); |
|
1671 |
|
1672 if ( iDSSyncTypeArray ) |
|
1673 { |
|
1674 if ( iDSSyncTypeArray->Count() > 0 ) |
|
1675 { |
|
1676 for ( TInt j = 0; j < iDSSyncTypeArray->Count(); j++ ) |
|
1677 { |
|
1678 if ( (*profile->iContentTypes)[i]->IntValue( EDSAdapterTableId ) == iDSSyncTypeArray->At( j ).iTaskId) |
|
1679 { |
|
1680 if ( iSyncInitiation == EClientInitiated ) |
|
1681 { |
|
1682 if ( (*profile->iContentTypes)[i]->IntValue( EDSAdapterEnabled ) ) |
|
1683 { |
|
1684 addContent = ETrue; |
|
1685 serverAlert = ETrue; |
|
1686 syncType = iDSSyncTypeArray->At( j ).iType; |
|
1687 } |
|
1688 } |
|
1689 else |
|
1690 { |
|
1691 addContent = ETrue; |
|
1692 serverAlert = ETrue; |
|
1693 syncType = iDSSyncTypeArray->At( j ).iType; |
|
1694 } |
|
1695 |
|
1696 break; |
|
1697 } |
|
1698 } |
|
1699 } |
|
1700 else |
|
1701 { |
|
1702 addContent = (*profile->iContentTypes)[i]->IntValue( EDSAdapterEnabled ); |
|
1703 } |
|
1704 } |
|
1705 else |
|
1706 { |
|
1707 addContent = (*profile->iContentTypes)[i]->IntValue( EDSAdapterEnabled ); |
|
1708 } |
|
1709 |
|
1710 if ( addContent ) |
|
1711 { |
|
1712 iDSContent->AddNewContentL(); |
|
1713 iDSContent->SetImplementationUID( (*profile->iContentTypes)[i]->IntValue( EDSAdapterImplementationId ) ); |
|
1714 |
|
1715 CNSmlURI* database = CNSmlURI::NewLC( *iImeiCode ); |
|
1716 database->SetDatabaseL( (*profile->iContentTypes)[i]->StrValue( EDSAdapterClientDataSource ) ); |
|
1717 TRAPD( localDatabaseError, iDSContent->SetLocalDatabaseL( *database ) ); |
|
1718 |
|
1719 if ((*profile->iContentTypes)[i]->StrValue( EDSAdapterClientDataSource ) != database->DataBaseWithoutRelativePrefix()) |
|
1720 { |
|
1721 (*profile->iContentTypes)[i]->SetStrValue( EDSAdapterClientDataSource ,database->DataBaseWithoutRelativePrefix()); |
|
1722 profile->SaveL() ; |
|
1723 } |
|
1724 CleanupStack::PopAndDestroy(); // database |
|
1725 |
|
1726 if ( localDatabaseError ) |
|
1727 { |
|
1728 DBG_ARGS(_S("CNSmlDSAgent::ReadSettingsL: local database error %d"), localDatabaseError); |
|
1729 iDSContent->RemoveContent(); |
|
1730 /* CR: 403-1188 */ |
|
1731 if ( ifInternet == EFalse && |
|
1732 iSyncInitiation == EServerAlerted && |
|
1733 (*profile->iContentTypes)[i]->IntValue( EDSAdapterImplementationId ) == KUidNSmlAdapterEMail.iUid) |
|
1734 { |
|
1735 CNSmlDSContentType* type = profile->ContentType( KUidNSmlAdapterEMail.iUid ); |
|
1736 type->SetIntValue (EDSAdapterEnabled, EFalse) ; |
|
1737 profile->SaveL() ; |
|
1738 } // CR: 403-1188 |
|
1739 continue; |
|
1740 } |
|
1741 |
|
1742 database = CNSmlURI::NewLC( iSyncServer->HostNameWithPortL() ); |
|
1743 database->SetDatabaseL( (*profile->iContentTypes)[i]->StrValue( EDSAdapterServerDataSource ) ); |
|
1744 if(database->Database().Length() < 1) |
|
1745 { |
|
1746 isRemotedatabaseDefined = EFalse; |
|
1747 } |
|
1748 iDSContent->SetRemoteDatabaseL( *database ); |
|
1749 CleanupStack::PopAndDestroy(); //database |
|
1750 |
|
1751 if ( iProtocolVer == ESmlVersion1_1_2 ) |
|
1752 { |
|
1753 HBufC* hostAddress = iSyncServer->HostName().AllocLC(); |
|
1754 |
|
1755 if ( !iDSContent->InitContentInstanceL( *hostAddress ) ) |
|
1756 { |
|
1757 iDSContent->RemoveContent(); |
|
1758 CleanupStack::PopAndDestroy(); // hostAddress |
|
1759 continue; |
|
1760 } |
|
1761 |
|
1762 CleanupStack::PopAndDestroy(); // hostAddress |
|
1763 } |
|
1764 else if ( iProtocolVer == ESmlVersion1_2 ) |
|
1765 { |
|
1766 if ( !iDSContent->InitContentInstanceL( *iDSServerId ) ) |
|
1767 { |
|
1768 iDSContent->RemoveContent(); |
|
1769 continue; |
|
1770 } |
|
1771 |
|
1772 RReadStream readStream( (*profile->iContentTypes)[i]->FilterReadStreamL() ); |
|
1773 CleanupClosePushL( readStream ); |
|
1774 |
|
1775 TInt numberOfFilters(0); |
|
1776 TInt error( KErrNone ); |
|
1777 TRAP(error, numberOfFilters = readStream.ReadInt32L() ); |
|
1778 |
|
1779 RPointerArray<CSyncMLFilter> filters; |
|
1780 CleanupStack::PushL( TCleanupItem( DeleteRPointerArray, &filters ) ); |
|
1781 |
|
1782 for ( TInt filterIndex = 0; filterIndex < numberOfFilters; filterIndex++ ) |
|
1783 { |
|
1784 CSyncMLFilter* filter = CSyncMLFilter::NewLC( readStream ); |
|
1785 filters.AppendL( filter ); |
|
1786 CleanupStack::Pop(); // filter |
|
1787 } |
|
1788 |
|
1789 iDSContent->SetUsedFiltersL( filters, static_cast<TSyncMLFilterMatchType>( (*profile->iContentTypes)[i]->IntValue( EDSAdapterFilterMatchType ) ) ); |
|
1790 |
|
1791 // ownership of array items is moved to iDSContent -> no need for ResetAndDestroy |
|
1792 filters.Close(); |
|
1793 |
|
1794 CleanupStack::Pop(); // filters |
|
1795 CleanupStack::PopAndDestroy(); // readStream |
|
1796 } |
|
1797 |
|
1798 if ( syncType == CNSmlDbCaps::EAllTypes ) |
|
1799 { |
|
1800 TSmlSyncType type = static_cast<TSmlSyncType>( (*profile->iContentTypes)[i]->IntValue( EDSAdapterSyncType ) ); |
|
1801 |
|
1802 switch ( type ) |
|
1803 { |
|
1804 case ESmlTwoWay: |
|
1805 syncType = CNSmlDbCaps::ETwoWaySync; |
|
1806 break; |
|
1807 |
|
1808 case ESmlOneWayFromServer: |
|
1809 syncType = CNSmlDbCaps::EOneWaySyncFromServer; |
|
1810 break; |
|
1811 |
|
1812 case ESmlOneWayFromClient: |
|
1813 syncType = CNSmlDbCaps::EOneWaySyncFromClient; |
|
1814 break; |
|
1815 |
|
1816 case ESmlSlowSync: |
|
1817 syncType = CNSmlDbCaps::ESlowTwoWaySync; |
|
1818 break; |
|
1819 |
|
1820 case ESmlRefreshFromServer: |
|
1821 syncType = CNSmlDbCaps::ERefreshSyncFromServer; |
|
1822 break; |
|
1823 |
|
1824 case ESmlRefreshFromClient: |
|
1825 syncType = CNSmlDbCaps::ERefreshSyncFromClient; |
|
1826 break; |
|
1827 |
|
1828 default: |
|
1829 User::Panic( _L("Sync type conversion error" ), type ); |
|
1830 } |
|
1831 } |
|
1832 |
|
1833 if ( syncType != CNSmlDbCaps::ESyncTypeNone ) |
|
1834 { |
|
1835 iDSContent->SetSyncTypeL( syncType ); |
|
1836 taskIdArray.Append( (*profile->iContentTypes)[i]->IntValue( EDSAdapterTableId ) ); |
|
1837 iDSContent->TaskId( (*profile->iContentTypes)[i]->IntValue( EDSAdapterTableId ) ); |
|
1838 |
|
1839 if ( serverAlert && iProtocolVer == ESmlVersion1_2 ) |
|
1840 { |
|
1841 iDSContent->SetAsServerAlerted(); |
|
1842 } |
|
1843 } |
|
1844 else |
|
1845 { |
|
1846 iDSContent->RemoveContent(); |
|
1847 } |
|
1848 } |
|
1849 } |
|
1850 |
|
1851 iSyncLog = CSyncMLHistoryJob::NewL( iProfileID, taskIdArray ); |
|
1852 |
|
1853 if ( iDSContent->Count() == 0 && iSyncInitiation == EClientInitiated ) |
|
1854 { |
|
1855 User::Leave( TNSmlError::ESmlErrorInSettings ); |
|
1856 } |
|
1857 // BPSS-7NZESW : If remote database value is empty,leave |
|
1858 //erorr log : Invalid remote database |
|
1859 if(!isRemotedatabaseDefined) |
|
1860 { |
|
1861 User::Leave( TNSmlError::ESmlStatusNotFound ); |
|
1862 } |
|
1863 taskIdArray.Close(); |
|
1864 CleanupStack::PopAndDestroy( 2 ); // profile, settings |
|
1865 DBG_FILE(_S8("CNSmlDSAgent::ReadSettingsL END")); |
|
1866 } |
|
1867 |
|
1868 // --------------------------------------------------------- |
|
1869 // CNSmlDSAgent::ReplaceIAPIdL() |
|
1870 // Gets IAPID from the Cenrep and if necessary will Replace |
|
1871 // the existing one |
|
1872 // --------------------------------------------------------- |
|
1873 void CNSmlDSAgent::ReplaceIAPIdL() |
|
1874 { |
|
1875 //Check whether the Auto Restart Feature is enabled or not |
|
1876 TInt keyVal; |
|
1877 TRAPD (err ,ReadRepositoryL(KNsmlDsAutoRestart, keyVal)); |
|
1878 |
|
1879 if(err==KErrNone && keyVal==1) |
|
1880 { |
|
1881 TInt LastUsedIAPId = 0; |
|
1882 |
|
1883 CNsmlProfileUtil* profileUtil = CNsmlProfileUtil::NewLC(); |
|
1884 |
|
1885 if(iAutoRestartInitiatedSync) |
|
1886 { |
|
1887 //Read the IAPID from the Cenrep |
|
1888 profileUtil->AccessPointIdL(LastUsedIAPId); |
|
1889 if(LastUsedIAPId > 0) |
|
1890 { |
|
1891 //Check Whether the IAPID still exists |
|
1892 TApBearerType bearertype = CheckAPBearerTypeL(LastUsedIAPId); |
|
1893 if(bearertype != TApBearerType(-1)) |
|
1894 { |
|
1895 iIAPId = LastUsedIAPId; |
|
1896 DBG_FILE_CODE(iIAPId , _S8("CNSmlDSAgent::ReadSettingsL, The Access Point ID Replaced from the CenRep:")); |
|
1897 } |
|
1898 else |
|
1899 { |
|
1900 //Stop the DS Sync Session |
|
1901 DBG_FILE(_S8("CNSmlDSAgent::ReadSettingsL, The Access Point ID is invalid so stopping the session")); |
|
1902 iPacketDataUnAvailable = ETrue; |
|
1903 StopDSSession(); |
|
1904 } |
|
1905 } |
|
1906 } |
|
1907 |
|
1908 CleanupStack::PopAndDestroy(profileUtil); |
|
1909 } |
|
1910 } |
|
1911 |
|
1912 // --------------------------------------------------------- |
|
1913 // CNSmlDSAgent::GetSessionIDL() |
|
1914 // Gets SessionID from Agent Log |
|
1915 // --------------------------------------------------------- |
|
1916 TInt CNSmlDSAgent::GetSessionIDL() |
|
1917 { |
|
1918 CNSmlDSAgentLog* agentLog( CNSmlDSAgentLog::NewLC() ); |
|
1919 TInt sessionID( 0 ); |
|
1920 |
|
1921 if ( iProtocolVer == ESmlVersion1_1_2 ) |
|
1922 { |
|
1923 HBufC* searchKey = iSyncServer->HostName().AllocLC(); |
|
1924 sessionID = agentLog->SessionIDL( *searchKey ); |
|
1925 CleanupStack::PopAndDestroy(); // searchKey |
|
1926 } |
|
1927 else if ( iProtocolVer == ESmlVersion1_2 ) |
|
1928 { |
|
1929 sessionID = agentLog->SessionIDL( *iDSServerId ); |
|
1930 } |
|
1931 |
|
1932 CleanupStack::PopAndDestroy(); // agentLog |
|
1933 |
|
1934 return sessionID; |
|
1935 } |
|
1936 |
|
1937 // --------------------------------------------------------- |
|
1938 // CNSmlDSAgent::UpdateSessionIDL() |
|
1939 // Updates SessionID in Agent Log |
|
1940 // --------------------------------------------------------- |
|
1941 void CNSmlDSAgent::UpdateSessionIDL( TInt aSessionID ) |
|
1942 { |
|
1943 CNSmlDSAgentLog* agentLog( CNSmlDSAgentLog::NewLC() ); |
|
1944 |
|
1945 if ( iProtocolVer == ESmlVersion1_1_2 ) |
|
1946 { |
|
1947 HBufC* searchKey = iSyncServer->HostName().AllocLC(); |
|
1948 agentLog->SetSessionIDL( *searchKey, aSessionID ); |
|
1949 CleanupStack::PopAndDestroy(); // searchKey |
|
1950 } |
|
1951 else if ( iProtocolVer == ESmlVersion1_2 ) |
|
1952 { |
|
1953 agentLog->SetSessionIDL( *iDSServerId, aSessionID ); |
|
1954 } |
|
1955 |
|
1956 CleanupStack::PopAndDestroy(); // agentLog |
|
1957 } |
|
1958 |
|
1959 // --------------------------------------------------------- |
|
1960 // CNSmlDSAgent::FinishL() |
|
1961 // |
|
1962 // --------------------------------------------------------- |
|
1963 void CNSmlDSAgent::FinishL() |
|
1964 { |
|
1965 iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlDisconnected, 0, 0 ); |
|
1966 |
|
1967 if ( iDSContent->AllDatabasesAreInterrupted() ) |
|
1968 { |
|
1969 DoErrorEvent( MSyncMLProgressObserver::ESmlFatalError, iError->SyncLogErrorCode(), 0, 0, 0 ); |
|
1970 User::RequestComplete( iCallerStatus, iError->SyncLogErrorCode() ); |
|
1971 } |
|
1972 else if ( iDSContent->AnyDatabaseIsInterrupted() ) |
|
1973 { |
|
1974 DoErrorEvent( MSyncMLProgressObserver::ESmlWarning, iError->SyncLogErrorCode(), 0, 0, 0 ); |
|
1975 iError->SetErrorCode( KErrNone ); |
|
1976 User::RequestComplete( iCallerStatus, KErrNone ); |
|
1977 } |
|
1978 //RD_AUTO_RESTART (BPSS-7GBGHP) |
|
1979 else if(iPacketDataUnAvailable) |
|
1980 { |
|
1981 DBG_FILE(_S8("CNSmlDSAgent::FinishL(), Setting the Dialog Text")); |
|
1982 |
|
1983 DoErrorEvent(MSyncMLProgressObserver::ESmlFatalError, |
|
1984 TNSmlError::ESmlCommunicationError, 0, 0, 0 ); |
|
1985 iError->SetErrorCode( TNSmlError::ESmlCommunicationError); |
|
1986 User::RequestComplete( iCallerStatus, TNSmlError::ESmlCommunicationError ); |
|
1987 } |
|
1988 //RD_AUTO_RESTART |
|
1989 else |
|
1990 { |
|
1991 User::RequestComplete( iCallerStatus, KErrNone ); |
|
1992 } |
|
1993 |
|
1994 iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlCompleted, 0, 0 ); |
|
1995 |
|
1996 iEnd = ETrue; |
|
1997 } |
|
1998 |
|
1999 // --------------------------------------------------------- |
|
2000 // CNSmlDSAgent::DoCancel |
|
2001 // Cancels ongoing asynchronous operations. |
|
2002 // --------------------------------------------------------- |
|
2003 void CNSmlDSAgent::DoCancel() |
|
2004 { |
|
2005 if ( iCommandIssued ) |
|
2006 { |
|
2007 TInt err( KErrNone ); |
|
2008 TRAP( err, iDSContent->CancelRequestL() ); |
|
2009 } |
|
2010 CNSmlAgentBase::DoCancel(); |
|
2011 } |
|
2012 |
|
2013 // |
|
2014 // Callback functions implementation |
|
2015 // |
|
2016 // --------------------------------------------------------- |
|
2017 // CNSmlDSAgent::smlAlertCmdFuncL |
|
2018 // Alert command from server. |
|
2019 // --------------------------------------------------------- |
|
2020 Ret_t CNSmlDSAgent::smlAlertCmdFuncL( SmlAlertPtr_t aContent ) |
|
2021 { |
|
2022 iCallbackCalled = ETrue; |
|
2023 |
|
2024 if ( iSyncMLCmds->AlertCode( aContent ) < KNSmlDSMeaningfulAlertMin || |
|
2025 iSyncMLCmds->AlertCode( aContent ) > KNSmlDSMeaningfulAlertMax ) |
|
2026 { |
|
2027 iSyncMLCmds->StatusToUnsupportedCommandL( ETrue, KNSmlAgentAlert, aContent->cmdID, aContent->flags ); |
|
2028 } |
|
2029 else |
|
2030 { |
|
2031 switch ( iCurrMainState ) |
|
2032 { |
|
2033 case EBeginning: |
|
2034 ServerAlertAlertCmdStateL( aContent ); |
|
2035 break; |
|
2036 |
|
2037 case EServerInitialisation: |
|
2038 ServerInitAlertCmdStateL( aContent ); |
|
2039 break; |
|
2040 |
|
2041 case EServerAlertNext: |
|
2042 ServerAlertNextAlertCmdStateL( aContent ); |
|
2043 break; |
|
2044 |
|
2045 case EServerModifications: |
|
2046 ServerModAlertCmdStateL( aContent ); |
|
2047 break; |
|
2048 |
|
2049 case EMapAcknowledge: |
|
2050 MapAckAlertCmdStateL( aContent ); |
|
2051 break; |
|
2052 |
|
2053 default: |
|
2054 iSyncMLCmds->StatusToUnsupportedCommandL( ETrue, KNSmlAgentAlert, aContent->cmdID, aContent->flags ); |
|
2055 } |
|
2056 } |
|
2057 |
|
2058 return 0; |
|
2059 } |
|
2060 |
|
2061 // --------------------------------------------------------- |
|
2062 // CNSmlDSAgent::smlGetCmdFuncL |
|
2063 // Get command from server |
|
2064 // --------------------------------------------------------- |
|
2065 Ret_t CNSmlDSAgent::smlGetCmdFuncL( SmlGetPtr_t aContent ) |
|
2066 { |
|
2067 iCallbackCalled = ETrue; |
|
2068 switch ( iCurrMainState ) |
|
2069 { |
|
2070 case EServerInitialisation: |
|
2071 ServerInitGetCmdStateL( aContent ); |
|
2072 break; |
|
2073 default: |
|
2074 iSyncMLCmds->StatusToUnsupportedCommandL( ETrue, KNSmlAgentGet, aContent->cmdID, aContent->flags ); |
|
2075 } |
|
2076 return 0; |
|
2077 } |
|
2078 |
|
2079 // --------------------------------------------------------- |
|
2080 // CNSmlDSAgent::smlPutCmdFuncL |
|
2081 // Put command from server |
|
2082 // --------------------------------------------------------- |
|
2083 Ret_t CNSmlDSAgent::smlPutCmdFuncL( SmlPutPtr_t aContent ) |
|
2084 { |
|
2085 iCallbackCalled = ETrue; |
|
2086 switch ( iCurrMainState ) |
|
2087 { |
|
2088 case EServerInitialisation: |
|
2089 ServerInitPutCmdStateL( aContent ); |
|
2090 break; |
|
2091 default: |
|
2092 iSyncMLCmds->StatusToUnsupportedCommandL( ETrue, KNSmlAgentPut, aContent->cmdID, aContent->flags ); |
|
2093 } |
|
2094 return 0; |
|
2095 } |
|
2096 |
|
2097 // --------------------------------------------------------- |
|
2098 // CNSmlDSAgent::smlResultsCmdFuncL |
|
2099 // Results command from server |
|
2100 // --------------------------------------------------------- |
|
2101 Ret_t CNSmlDSAgent::smlResultsCmdFuncL( SmlResultsPtr_t aContent ) |
|
2102 { |
|
2103 iCallbackCalled = ETrue; |
|
2104 switch ( iCurrMainState ) |
|
2105 { |
|
2106 case EServerInitialisation: |
|
2107 ServerInitResultsCmdStateL( aContent ); |
|
2108 break; |
|
2109 default: |
|
2110 iSyncMLCmds->StatusToUnsupportedCommandL( ETrue, KNSmlAgentResults, aContent->cmdID ); |
|
2111 } |
|
2112 return 0; |
|
2113 } |
|
2114 |
|
2115 // --------------------------------------------------------- |
|
2116 // CNSmlDSAgent::smlStatusCmdFuncL |
|
2117 // Status command from server |
|
2118 // --------------------------------------------------------- |
|
2119 Ret_t CNSmlDSAgent::smlStatusCmdFuncL( SmlStatusPtr_t aContent ) |
|
2120 { |
|
2121 iCallbackCalled = ETrue; |
|
2122 switch ( iCurrMainState ) |
|
2123 { |
|
2124 case EServerInitialisation: |
|
2125 ServerInitStatusCmdStateL( aContent ); |
|
2126 break; |
|
2127 case EServerModifications: |
|
2128 ServerModStatusCmdStateL( aContent ); |
|
2129 break; |
|
2130 case EMapAcknowledge: |
|
2131 MapAckStatusCmdStateL( aContent ); |
|
2132 break; |
|
2133 case EServerAlertNext: |
|
2134 ServerAlertNextStatusCmdStateL( aContent ); |
|
2135 break; |
|
2136 default: |
|
2137 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
2138 } |
|
2139 return 0; |
|
2140 } |
|
2141 |
|
2142 // --------------------------------------------------------- |
|
2143 // CNSmlDSAgent::smlStartMessageFuncL |
|
2144 // SyncHdr from server |
|
2145 // --------------------------------------------------------- |
|
2146 Ret_t CNSmlDSAgent::smlStartMessageFuncL( SmlSyncHdrPtr_t aContent ) |
|
2147 { |
|
2148 iCallbackCalled = ETrue; |
|
2149 |
|
2150 switch ( iCurrMainState ) |
|
2151 { |
|
2152 case EBeginning: |
|
2153 ServerAlertStartMessageStateL( aContent ); |
|
2154 break; |
|
2155 |
|
2156 case EServerInitialisation: |
|
2157 ServerInitStartMessageStateL( aContent ); |
|
2158 break; |
|
2159 |
|
2160 case EServerModifications: |
|
2161 ServerModStartMessageStateL( aContent ); |
|
2162 break; |
|
2163 |
|
2164 case EMapAcknowledge: |
|
2165 MapAckStartMessageStateL( aContent ); |
|
2166 break; |
|
2167 |
|
2168 case EServerAlertNext: |
|
2169 ServerAlertNextStartMessageStateL( aContent ); |
|
2170 break; |
|
2171 |
|
2172 default: |
|
2173 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
2174 } |
|
2175 |
|
2176 return 0; |
|
2177 } |
|
2178 |
|
2179 // --------------------------------------------------------- |
|
2180 // CNSmlDSAgent::smlEndMessageFuncL |
|
2181 // End of SyncML message was reached |
|
2182 // --------------------------------------------------------- |
|
2183 Ret_t CNSmlDSAgent::smlEndMessageFuncL( Boolean_t aFinal ) |
|
2184 { |
|
2185 iCallbackCalled = ETrue; |
|
2186 |
|
2187 switch ( iCurrMainState ) |
|
2188 { |
|
2189 case EBeginning: |
|
2190 ServerAlertEndMessageStateL( aFinal ); |
|
2191 break; |
|
2192 |
|
2193 case EServerInitialisation: |
|
2194 ServerInitEndMessageStateL( aFinal ); |
|
2195 break; |
|
2196 |
|
2197 case EServerModifications: |
|
2198 ServerModEndMessageStateL( aFinal ); |
|
2199 break; |
|
2200 |
|
2201 case EMapAcknowledge: |
|
2202 MapAckEndMessageStateL( aFinal ); |
|
2203 break; |
|
2204 |
|
2205 case EServerAlertNext: |
|
2206 ServerAlertNextEndMessageStateL( aFinal ); |
|
2207 break; |
|
2208 |
|
2209 default: |
|
2210 User::Leave( TNSmlError::ESmlUnexpectedCmd ); |
|
2211 } |
|
2212 |
|
2213 return 0; |
|
2214 } |
|
2215 |
|
2216 // --------------------------------------------------------- |
|
2217 // CNSmlDSAgent::smlStartSyncFuncL |
|
2218 // Sync command from server |
|
2219 // --------------------------------------------------------- |
|
2220 Ret_t CNSmlDSAgent::smlStartSyncFuncL( SmlSyncPtr_t aContent ) |
|
2221 { |
|
2222 iCallbackCalled = ETrue; |
|
2223 |
|
2224 switch ( iCurrMainState ) |
|
2225 { |
|
2226 case EServerModifications: |
|
2227 ServerModStartSyncStateL( aContent ); |
|
2228 break; |
|
2229 default: |
|
2230 iSyncMLCmds->StatusToUnsupportedCommandL( ETrue, KNSmlAgentSync, aContent->cmdID, aContent->flags ); |
|
2231 } |
|
2232 return 0; |
|
2233 } |
|
2234 |
|
2235 // --------------------------------------------------------- |
|
2236 // CNSmlDSAgent::smlEndSyncFuncL |
|
2237 // End of Sync command was reached |
|
2238 // --------------------------------------------------------- |
|
2239 Ret_t CNSmlDSAgent::smlEndSyncFuncL() |
|
2240 { |
|
2241 iCallbackCalled = ETrue; |
|
2242 switch ( iCurrMainState ) |
|
2243 { |
|
2244 case EServerModifications: |
|
2245 ServerModEndSyncStateL(); |
|
2246 break; |
|
2247 default: |
|
2248 break; |
|
2249 } |
|
2250 return 0; |
|
2251 } |
|
2252 |
|
2253 // ----------------------------------------------------------------------------- |
|
2254 // CNSmlDSAgent::smlStartAtomicFuncL |
|
2255 // Atomic command from server. |
|
2256 // ----------------------------------------------------------------------------- |
|
2257 // |
|
2258 Ret_t CNSmlDSAgent::smlStartAtomicFuncL( SmlAtomicPtr_t aContent ) |
|
2259 { |
|
2260 iCallbackCalled = ETrue; |
|
2261 |
|
2262 switch ( iCurrMainState ) |
|
2263 { |
|
2264 case EServerModifications: |
|
2265 ServerModStartAtomicStateL( aContent ); |
|
2266 break; |
|
2267 |
|
2268 default: |
|
2269 iSyncMLCmds->StatusToUnsupportedCommandL( EFalse, KNSmlAgentAtomic, aContent->cmdID, aContent->flags ); |
|
2270 break; |
|
2271 } |
|
2272 |
|
2273 return 0; |
|
2274 } |
|
2275 |
|
2276 // ----------------------------------------------------------------------------- |
|
2277 // CNSmlDSAgent::smlEndAtomicFuncL |
|
2278 // The end of the Atomic command was reached. |
|
2279 // ----------------------------------------------------------------------------- |
|
2280 // |
|
2281 Ret_t CNSmlDSAgent::smlEndAtomicFuncL() |
|
2282 { |
|
2283 iCallbackCalled = ETrue; |
|
2284 |
|
2285 ServerModEndAtomicStateL(); |
|
2286 |
|
2287 return 0; |
|
2288 } |
|
2289 |
|
2290 // --------------------------------------------------------- |
|
2291 // CNSmlDSAgent::smlStartSequenceFuncL |
|
2292 // Sequence command from server, Sequence is not supported |
|
2293 // --------------------------------------------------------- |
|
2294 Ret_t CNSmlDSAgent::smlStartSequenceFuncL( SmlSequencePtr_t aContent ) |
|
2295 { |
|
2296 iCallbackCalled = ETrue; |
|
2297 iSyncMLCmds->StatusToUnsupportedCommandL( EFalse, KNSmlAgentSequence, aContent->cmdID, aContent->flags ); |
|
2298 return 0; |
|
2299 } |
|
2300 |
|
2301 // --------------------------------------------------------- |
|
2302 // CNSmlDSAgent::smlEndSequenceFuncL |
|
2303 // |
|
2304 // --------------------------------------------------------- |
|
2305 Ret_t CNSmlDSAgent::smlEndSequenceFuncL() |
|
2306 { |
|
2307 iCallbackCalled = ETrue; |
|
2308 return 0; |
|
2309 } |
|
2310 |
|
2311 |
|
2312 // --------------------------------------------------------- |
|
2313 // CNSmlDSAgent::smlMoveCmdFuncL |
|
2314 // |
|
2315 // --------------------------------------------------------- |
|
2316 Ret_t CNSmlDSAgent::smlMoveCmdFuncL( SmlMovePtr_t aContent ) |
|
2317 { |
|
2318 iCallbackCalled = ETrue; |
|
2319 switch ( iCurrMainState ) |
|
2320 { |
|
2321 case EServerModifications: |
|
2322 ServerModUpdatesStateL( KNSmlAgentMove(), aContent ); |
|
2323 break; |
|
2324 default: |
|
2325 iSyncMLCmds->StatusToUnsupportedCommandL( ETrue, KNSmlAgentAdd, aContent->cmdID, aContent->flags ); |
|
2326 } |
|
2327 return 0; |
|
2328 } |
|
2329 |
|
2330 // --------------------------------------------------------- |
|
2331 // CNSmlDSAgent::NavigateMainStateL() |
|
2332 // Navigate according to state code |
|
2333 // --------------------------------------------------------- |
|
2334 void CNSmlDSAgent::NavigateMainStateL() |
|
2335 { |
|
2336 switch ( iCurrMainState ) |
|
2337 { |
|
2338 case EBeginning: |
|
2339 BeginningStateL(); |
|
2340 break; |
|
2341 case EClientInitialisation: |
|
2342 ClientInitialisationStateL(); |
|
2343 break; |
|
2344 case EServerInitialisation: |
|
2345 ServerInitialisationStateL(); |
|
2346 break; |
|
2347 // <MAPINFO_RESEND_MOD_BEGIN> |
|
2348 case EClientResendMapInfo: |
|
2349 ClientResendMapInfoStateL(); |
|
2350 break; |
|
2351 // <MAPINFO_RESEND_MOD_END> |
|
2352 case EClientModifications: |
|
2353 ClientModificationsStateL(); |
|
2354 break; |
|
2355 case EServerModifications: |
|
2356 ServerModificationsStateL(); |
|
2357 break; |
|
2358 case EDataUpdateStatus: |
|
2359 DataUpdateStatusStateL(); |
|
2360 break; |
|
2361 case EMapAcknowledge: |
|
2362 MapAcknowledgeStateL(); |
|
2363 break; |
|
2364 case EResultAlert: |
|
2365 ResultAlertStateL(); |
|
2366 break; |
|
2367 case EClientAlertNext: |
|
2368 ClientAlertNextStateL(); |
|
2369 break; |
|
2370 case EServerAlertNext: |
|
2371 ServerAlertNextStateL(); |
|
2372 break; |
|
2373 case EFinishing: |
|
2374 FinishingStateL(); |
|
2375 break; |
|
2376 case ESending: |
|
2377 SendingStateL(); |
|
2378 break; |
|
2379 case EReceiving: |
|
2380 ReceivingStateL(); |
|
2381 break; |
|
2382 default: |
|
2383 User::Leave( KErrGeneral ); |
|
2384 } |
|
2385 } |
|
2386 |
|
2387 // --------------------------------------------------------- |
|
2388 // CNSmlDSAgent::NextMainStateL() |
|
2389 // Change main state |
|
2390 // --------------------------------------------------------- |
|
2391 void CNSmlDSAgent::NextMainStateL() |
|
2392 { |
|
2393 switch ( iCurrMainState ) |
|
2394 { |
|
2395 case EBeginning: |
|
2396 if ( iSyncInitiation == EClientInitiated && iDSContent->AllDatabasesAreInterruptedImmediately() ) |
|
2397 { |
|
2398 iCurrMainState = EFinishing; |
|
2399 } |
|
2400 else |
|
2401 { |
|
2402 iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlConnected, 0, 0 ); |
|
2403 iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlLoggingOn, 0, 0 ); |
|
2404 iCurrMainState = EClientInitialisation; |
|
2405 } |
|
2406 break; |
|
2407 |
|
2408 case EClientInitialisation: |
|
2409 iPrevSyncState = iCurrMainState; |
|
2410 iCurrMainState = ESending; |
|
2411 break; |
|
2412 |
|
2413 case EServerInitialisation: |
|
2414 iPrevSyncState = iCurrMainState; |
|
2415 if ( iDSContent->AllDatabasesAreInterruptedImmediately() ) |
|
2416 { |
|
2417 iCurrMainState = EFinishing; |
|
2418 } |
|
2419 else |
|
2420 { |
|
2421 if ( iBusyStatusReceived ) |
|
2422 { |
|
2423 iCurrMainState = EResultAlert; |
|
2424 } |
|
2425 else |
|
2426 { |
|
2427 if ( iChallengeRequest ) |
|
2428 { |
|
2429 iCurrMainState = EClientInitialisation; |
|
2430 } |
|
2431 else |
|
2432 { |
|
2433 if ( iDSCurrServerInitState == EServerInitMessageReceived ) |
|
2434 { |
|
2435 iCurrMainState = EClientAlertNext; |
|
2436 } |
|
2437 else |
|
2438 { |
|
2439 iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlLoggedOn, 0, 0 ); |
|
2440 // <MAPINFO_RESEND_MOD_BEGIN> |
|
2441 iCurrMainState = EClientResendMapInfo; |
|
2442 DBG_FILE(_S8("CNSmlDSAgent::NextMainStateL Moved to EClientResendMapInfo...")); |
|
2443 // iCurrMainState = EClientModifications; |
|
2444 // <MAPINFO_RESEND_MOD_END> |
|
2445 } |
|
2446 } |
|
2447 } |
|
2448 } |
|
2449 break; |
|
2450 // <MAPINFO_RESEND_MOD_BEGIN> |
|
2451 case EClientResendMapInfo: |
|
2452 iPrevSyncState = iCurrMainState; |
|
2453 if(iMapResendStatusPackage) |
|
2454 { |
|
2455 iCurrMainState = ESending; |
|
2456 } |
|
2457 else |
|
2458 { |
|
2459 iCurrMainState = EClientModifications; |
|
2460 } |
|
2461 break; |
|
2462 // <MAPINFO_RESEND_MOD_END> |
|
2463 case EClientModifications: |
|
2464 iPrevSyncState = iCurrMainState; |
|
2465 iCurrMainState = ESending; |
|
2466 break; |
|
2467 |
|
2468 case EServerModifications: |
|
2469 iPrevSyncState = iCurrMainState; |
|
2470 if ( iDSContent->AllDatabasesAreInterruptedImmediately() ) |
|
2471 { |
|
2472 iCurrMainState = EFinishing; |
|
2473 } |
|
2474 else |
|
2475 { |
|
2476 if ( iBusyStatusReceived ) |
|
2477 { |
|
2478 iCurrMainState = EResultAlert; |
|
2479 } |
|
2480 else |
|
2481 { |
|
2482 if ( iCurrServerModState == EServerModMessageReceived ) |
|
2483 { |
|
2484 iCurrMainState = EClientAlertNext; |
|
2485 } |
|
2486 else |
|
2487 { |
|
2488 iCurrMainState = EDataUpdateStatus; |
|
2489 iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlSendingMappingsToServer, 0, 0 ); |
|
2490 } |
|
2491 } |
|
2492 } |
|
2493 break; |
|
2494 |
|
2495 case EDataUpdateStatus: |
|
2496 iPrevSyncState = iCurrMainState; |
|
2497 if ( iStatusPackage && ( !iDSContent->AllDatabasesOneWayFromClient() ) ) |
|
2498 { |
|
2499 iCurrMainState = ESending; |
|
2500 } |
|
2501 else |
|
2502 { |
|
2503 iCurrMainState = EFinishing; |
|
2504 } |
|
2505 break; |
|
2506 |
|
2507 case EMapAcknowledge: |
|
2508 // <MAPINFO_RESEND_MOD_BEGIN> |
|
2509 if(iPrevSyncState==EClientResendMapInfo) |
|
2510 { |
|
2511 iCurrMainState = EClientModifications; |
|
2512 // If map exitst remove map info, think to implement. |
|
2513 iDSContent->CleanMapInfo(); |
|
2514 } |
|
2515 else |
|
2516 { |
|
2517 // <MAPINFO_RESEND_MOD_END> |
|
2518 iPrevSyncState = iCurrMainState; |
|
2519 if ( iDSContent->AllDatabasesAreInterruptedImmediately() ) |
|
2520 { |
|
2521 iCurrMainState = EFinishing; |
|
2522 } |
|
2523 else |
|
2524 { |
|
2525 if ( iBusyStatusReceived ) |
|
2526 { |
|
2527 iCurrMainState = EResultAlert; |
|
2528 } |
|
2529 else |
|
2530 { |
|
2531 if ( iDSCurrMapAcknowledgeState == EMapAckMessageReceived ) |
|
2532 { |
|
2533 iCurrMainState = EClientAlertNext; |
|
2534 } |
|
2535 else |
|
2536 { |
|
2537 iCurrMainState = EFinishing; |
|
2538 } |
|
2539 } |
|
2540 } |
|
2541 // <MAPINFO_RESEND_MOD_BEGIN> |
|
2542 } |
|
2543 // <MAPINFO_RESEND_MOD_END> |
|
2544 break; |
|
2545 |
|
2546 case EResultAlert: |
|
2547 iCurrMainState = ESending; |
|
2548 break; |
|
2549 |
|
2550 case EClientAlertNext: |
|
2551 iCurrMainState = ESending; |
|
2552 break; |
|
2553 |
|
2554 case EServerAlertNext: |
|
2555 if ( iDSContent->AllDatabasesAreInterruptedImmediately() ) |
|
2556 { |
|
2557 iCurrMainState = EFinishing; |
|
2558 } |
|
2559 else |
|
2560 { |
|
2561 iCurrMainState = iPrevSyncState; |
|
2562 } |
|
2563 break; |
|
2564 |
|
2565 case ESending: |
|
2566 if ( iDSContent->AllDatabasesAreInterrupted() ) |
|
2567 { |
|
2568 iCurrMainState = EFinishing; |
|
2569 } |
|
2570 else |
|
2571 { |
|
2572 iCurrMainState = EReceiving; |
|
2573 } |
|
2574 break; |
|
2575 |
|
2576 case EReceiving: |
|
2577 if ( ( !iFinalMessageFromClient ) && |
|
2578 ( iPrevSyncState == EClientModifications || iPrevSyncState == EDataUpdateStatus ) ) |
|
2579 { |
|
2580 iCurrMainState = EServerAlertNext; |
|
2581 } |
|
2582 else |
|
2583 if ( iPrevSyncState == EClientInitialisation || iPrevSyncState == EServerInitialisation ) |
|
2584 { |
|
2585 iCurrMainState = EServerInitialisation; |
|
2586 } |
|
2587 else |
|
2588 if ( iPrevSyncState == EClientModifications || iPrevSyncState == EServerModifications ) |
|
2589 { |
|
2590 iCurrMainState = EServerModifications; |
|
2591 } |
|
2592 else |
|
2593 { |
|
2594 iCurrMainState = EMapAcknowledge; |
|
2595 }; |
|
2596 |
|
2597 iDSContent->UpdateInterruptedFlags(); |
|
2598 break; |
|
2599 |
|
2600 default: |
|
2601 break; |
|
2602 } |
|
2603 |
|
2604 InitialiseSubStates(); |
|
2605 } |
|
2606 |
|
2607 // --------------------------------------------------------- |
|
2608 // CNSmlDSAgent::InitialiseSubStates() |
|
2609 // |
|
2610 // --------------------------------------------------------- |
|
2611 // |
|
2612 void CNSmlDSAgent::InitialiseSubStates() |
|
2613 { |
|
2614 iCurrBeginningState = EBegin; |
|
2615 iDSCurrBeginSubState = EBeginSubStart; |
|
2616 iCurrClientInitState = EInitStartingMessage; |
|
2617 iDSCurrServerInitState = EServerInitWaitingStartMessage; |
|
2618 iDSCurrClientModState = EClientModStartingMessage; |
|
2619 iCurrResultAlertState = EResultAlertStartingMessage; |
|
2620 iCurrServerModState = EServerModWaitingStartMessage; |
|
2621 iCurrDataUpdateStatusState = EStatusStartingMessage; |
|
2622 iDSCurrMapAcknowledgeState = EMapAckWaitingStartMessage; |
|
2623 iCurrResultAlertState = EResultAlertStartingMessage; |
|
2624 iCurrClientAlertNextState = EClientAlertNextStartingMessage; |
|
2625 iCurrServerAlertNextState = EServerAlertNextWaitingStartMessage; |
|
2626 } |
|
2627 |
|
2628 // |
|
2629 // Beginning state functions |
|
2630 // |
|
2631 // |
|
2632 // --------------------------------------------------------- |
|
2633 // CNSmlDSAgent::BeginStateL() |
|
2634 // |
|
2635 // --------------------------------------------------------- |
|
2636 void CNSmlDSAgent::BeginStateL() |
|
2637 { |
|
2638 switch ( iDSCurrBeginSubState ) |
|
2639 { |
|
2640 case EBeginSubStart: |
|
2641 BeginSubStartStateL(); |
|
2642 break; |
|
2643 case EBeginSubReadSettings: |
|
2644 BeginSubReadSettingsStateL(); |
|
2645 break; |
|
2646 case EBeginSubSyncmlCmdsInstance: |
|
2647 BeginSubSyncmlCmdsInstanceStateL(); |
|
2648 break; |
|
2649 case EBeginSubServerAlerting: |
|
2650 BeginSubServerAlertingStateL(); |
|
2651 break; |
|
2652 case EBeginSubOpenContentInstances: |
|
2653 BeginSubOpenContentInstancesStateL(); |
|
2654 break; |
|
2655 // <MAPINFO_RESEND_MOD_BEGIN> |
|
2656 case EBeginSubScanMapInfo: |
|
2657 BeginSubScanMapInfo(); |
|
2658 break; |
|
2659 // <MAPINFO_RESEND_MOD_END> |
|
2660 case EBeginSubCreateLUIDBuffers: |
|
2661 BeginSubCreateLUIDBuffersStateL(); |
|
2662 break; |
|
2663 default: |
|
2664 User::Leave( KErrGeneral ); |
|
2665 } |
|
2666 } |
|
2667 |
|
2668 // |
|
2669 // Server Modifications state functions |
|
2670 // |
|
2671 // --------------------------------------------------------- |
|
2672 // CNSmlDSAgent::ServerModUpdatesStateL(() |
|
2673 // Handles Add, Replace or Delete command from server |
|
2674 // --------------------------------------------------------- |
|
2675 void CNSmlDSAgent::ServerModUpdatesStateL( const TDesC8& aCmd, SmlGenericCmd_t* aContent ) |
|
2676 { |
|
2677 DBG_FILE(_S8("CNSmlDSAgent::ServerModUpdatesStateL begins")); |
|
2678 if ( iCurrServerModState != EServerModWaitingUpdateCommands ) |
|
2679 { |
|
2680 iSyncMLCmds->StatusToUnsupportedCommandL( ETrue, aCmd, aContent->cmdID, aContent->flags ); |
|
2681 } |
|
2682 if ( iDSContent->ContentIndexIsSet() ) |
|
2683 { |
|
2684 if ( iDSContent->SyncType() == KNSmlDSOneWayFromClient || |
|
2685 iDSContent->SyncType() == KNSmlDSOneWayFromClientByServer || |
|
2686 iDSContent->SyncType() == KNSmlDSRefreshFromClient || |
|
2687 iDSContent->SyncType() == KNSmlDSRefreshFromClientByServer ) |
|
2688 { |
|
2689 iSyncMLCmds->StatusToUnsupportedCommandL( ETrue, aCmd, aContent->cmdID, aContent->flags ); |
|
2690 } |
|
2691 else |
|
2692 { |
|
2693 iSyncMLCmds->ProcessUpdatesL( aCmd, aContent ); |
|
2694 } |
|
2695 } |
|
2696 else |
|
2697 { |
|
2698 iSyncMLCmds->ProcessUpdatesL( aCmd, aContent ); |
|
2699 } |
|
2700 DBG_FILE(_S8("CNSmlDSAgent::ServerModUpdatesStateL ends")); |
|
2701 } |
|
2702 |
|
2703 // --------------------------------------------------------- |
|
2704 // CNSmlDSAgent::DataUpdateStatusStartingMessageStateL() |
|
2705 // Notify "Finalising" to UI, makes SyncHdr |
|
2706 // --------------------------------------------------------- |
|
2707 void CNSmlDSAgent::DataUpdateStatusStartingMessageStateL() |
|
2708 { |
|
2709 DBG_FILE(_S8("CNSmlDSAgent::DataUpdateStatusStartingMessageStateL begins")); |
|
2710 DataUpdateStatusStartingMessageStateBaseL(); |
|
2711 iDSContent->SetToFirst(); |
|
2712 DBG_FILE(_S8("CNSmlDSAgent::DataUpdateStatusStartingMessageStateL ends")); |
|
2713 } |
|
2714 |
|
2715 // --------------------------------------------------------- |
|
2716 // CNSmlDSAgent::DataUpdateStatusMakingMapStateL() |
|
2717 // Makes Map command(s) |
|
2718 // --------------------------------------------------------- |
|
2719 void CNSmlDSAgent::DataUpdateStatusMakingMapStateL() |
|
2720 { |
|
2721 DBG_FILE(_S8("CNSmlDSAgent::DataUpdateStatusMakingMapStateL begins")); |
|
2722 CNSmlCmdsBase::TReturnValue ret; |
|
2723 ret = iSyncMLCmds->DoMapL(); |
|
2724 switch ( ret ) |
|
2725 { |
|
2726 case CNSmlCmdsBase::EReturnOK: |
|
2727 iDSWaitingForMapAcknowledgement = ETrue; |
|
2728 // there is something to send |
|
2729 iStatusPackage = ETrue; |
|
2730 if ( !iDSContent->SetToNext() ) |
|
2731 { |
|
2732 iCurrDataUpdateStatusState = EStatusEndingMessage; |
|
2733 } |
|
2734 break; |
|
2735 case CNSmlCmdsBase::EReturnEndData: |
|
2736 if ( !iDSContent->SetToNext() ) |
|
2737 { |
|
2738 iCurrDataUpdateStatusState = EStatusEndingMessage; |
|
2739 } |
|
2740 break; |
|
2741 case CNSmlCmdsBase::EReturnBufferFull: |
|
2742 iBufferFull = ETrue; |
|
2743 iCurrDataUpdateStatusState = EStatusEndingMessage; |
|
2744 break; |
|
2745 default: |
|
2746 break; |
|
2747 } |
|
2748 DBG_FILE(_S8("CNSmlDSAgent::DataUpdateStatusMakingMapStateL ends")); |
|
2749 } |
|
2750 |
|
2751 // |
|
2752 // Alert for next state functions |
|
2753 // |
|
2754 |
|
2755 // ----------------------------------------------------------------------------- |
|
2756 // CNSmlDSAgent::ClientAlertNextMakingMapStateL |
|
2757 // Makes Map command(s). |
|
2758 // ----------------------------------------------------------------------------- |
|
2759 // |
|
2760 void CNSmlDSAgent::ClientAlertNextMakingMapStateL() |
|
2761 { |
|
2762 DBG_FILE(_S8("CNSmlDSAgent::ClientAlertNextMakingMapStateL begins")); |
|
2763 |
|
2764 iDSContent->SetToFirst(); |
|
2765 |
|
2766 do |
|
2767 { |
|
2768 if ( iSyncMLCmds->DoMapL() == CNSmlCmdsBase::EReturnBufferFull ) |
|
2769 { |
|
2770 break; |
|
2771 } |
|
2772 } |
|
2773 while ( iDSContent->SetToNext() ); |
|
2774 |
|
2775 iCurrClientAlertNextState = EClientAlertNextEndingMessage; |
|
2776 |
|
2777 DBG_FILE(_S8("CNSmlDSAgent::ClientAlertNextMakingMapStateL ends")); |
|
2778 } |
|
2779 |
|
2780 // ----------------------------------------------------------------------------- |
|
2781 // CNSmlDSAgent::NonceL |
|
2782 // Nonce (used in MD5 auth) from Agent Log |
|
2783 // ----------------------------------------------------------------------------- |
|
2784 // |
|
2785 HBufC* CNSmlDSAgent::NonceL() const |
|
2786 { |
|
2787 CNSmlDSAgentLog* agentLog = CNSmlDSAgentLog::NewLC(); |
|
2788 HBufC* nonce( NULL ); |
|
2789 |
|
2790 if ( iProtocolVer == ESmlVersion1_1_2 ) |
|
2791 { |
|
2792 HBufC* searchKey( iSyncServer->HostName().AllocLC() ); |
|
2793 nonce = agentLog->NonceL( *searchKey ); |
|
2794 CleanupStack::PopAndDestroy(); // searchKey |
|
2795 } |
|
2796 else if ( iProtocolVer == ESmlVersion1_2 ) |
|
2797 { |
|
2798 nonce = agentLog->NonceL( *iDSServerId ); |
|
2799 } |
|
2800 |
|
2801 CleanupStack::PopAndDestroy(); // agentLog |
|
2802 |
|
2803 return nonce; |
|
2804 } |
|
2805 |
|
2806 // ----------------------------------------------------------------------------- |
|
2807 // CNSmlDSAgent::SetNonceL |
|
2808 // Nonce from the server's challenge is stored to the Agent Log. |
|
2809 // ----------------------------------------------------------------------------- |
|
2810 // |
|
2811 void CNSmlDSAgent::SetNonceL( const TDesC& aNonce ) const |
|
2812 { |
|
2813 CNSmlDSAgentLog* agentLog = CNSmlDSAgentLog::NewLC(); |
|
2814 |
|
2815 if ( iProtocolVer == ESmlVersion1_1_2 ) |
|
2816 { |
|
2817 HBufC* searchKey( iSyncServer->HostName().AllocLC() ); |
|
2818 agentLog->SetNonceL( *searchKey, aNonce ); |
|
2819 CleanupStack::PopAndDestroy(); // searchKey |
|
2820 } |
|
2821 else if ( iProtocolVer == ESmlVersion1_2 ) |
|
2822 { |
|
2823 agentLog->SetNonceL( *iDSServerId, aNonce ); |
|
2824 } |
|
2825 |
|
2826 CleanupStack::PopAndDestroy(); // agentLog |
|
2827 } |
|
2828 |
|
2829 // ----------------------------------------------------------------------------- |
|
2830 // CNSmlDSAgent::FinalizeSyncLog |
|
2831 // Writes the sync history after synchronisation. |
|
2832 // ----------------------------------------------------------------------------- |
|
2833 // |
|
2834 void CNSmlDSAgent::FinalizeSyncLog() |
|
2835 { |
|
2836 TInt err( KErrNone ); |
|
2837 TRAP( err, FinalizeSyncLogL() ); |
|
2838 } |
|
2839 |
|
2840 // ----------------------------------------------------------------------------- |
|
2841 // CNSmlDSAgent::FinalizeSyncLogL |
|
2842 // Writes the sync history after synchronisation. |
|
2843 // ----------------------------------------------------------------------------- |
|
2844 // |
|
2845 void CNSmlDSAgent::FinalizeSyncLogL() |
|
2846 { |
|
2847 if ( iSyncLog ) |
|
2848 { |
|
2849 iDSContent->FinalizeSyncLogEvents(); |
|
2850 |
|
2851 TTime time; |
|
2852 time.UniversalTime(); |
|
2853 iSyncLog->SetResult( time, iError->SyncLogErrorCode() ); |
|
2854 |
|
2855 CNSmlDSSettings* settings = CNSmlDSSettings::NewLC(); |
|
2856 CNSmlDSProfile* profile = settings->ProfileL( iProfileID ); |
|
2857 CleanupStack::PushL( profile ); |
|
2858 CNSmlHistoryArray* array = CNSmlHistoryArray::NewL(); |
|
2859 CleanupStack::PushL( array ); |
|
2860 array->SetOwnerShip( ETrue ); |
|
2861 |
|
2862 RReadStream& readStream = profile->LogReadStreamL(); |
|
2863 CleanupClosePushL( readStream ); |
|
2864 |
|
2865 if ( readStream.Source()->SizeL() > 0 ) |
|
2866 { |
|
2867 array->InternalizeL( readStream ); |
|
2868 } |
|
2869 |
|
2870 CleanupStack::PopAndDestroy(); // readStream |
|
2871 |
|
2872 array->AppendEntryL( iSyncLog ); |
|
2873 RWriteStream& writeStream = profile->LogWriteStreamL(); |
|
2874 CleanupClosePushL( writeStream ); |
|
2875 array->ExternalizeL( writeStream ); |
|
2876 CleanupStack::PopAndDestroy(); // writeStream |
|
2877 profile->WriteStreamCommitL(); |
|
2878 |
|
2879 CleanupStack::PopAndDestroy( 3 ); // array, settings, profile |
|
2880 |
|
2881 iSyncLog = NULL; |
|
2882 } |
|
2883 |
|
2884 // Set sync stopped to P&S |
|
2885 RProperty::Set( KPSUidDataSynchronizationInternalKeys, KDataSyncStatus, EDataSyncNotRunning ); |
|
2886 |
|
2887 ResetDSSessionInfoL(); |
|
2888 } |
|
2889 |
|
2890 // ----------------------------------------------------------------------------- |
|
2891 // CNSmlDSAgent::WriteWarningL |
|
2892 // Sync level warning message to the Sync Log. |
|
2893 // ----------------------------------------------------------------------------- |
|
2894 // |
|
2895 void CNSmlDSAgent::WriteWarningL( TNSmlError::TNSmlAgentErrorCode aWarningCode ) |
|
2896 { |
|
2897 iDSContent->SetToFirst(); |
|
2898 |
|
2899 do |
|
2900 { |
|
2901 InfoMessageToSyncLogL( iDSContent->CurrentIndex(), aWarningCode ); |
|
2902 iDSContent->IncreaseWarnings(); |
|
2903 } |
|
2904 while ( iDSContent->SetToNext() ); |
|
2905 } |
|
2906 |
|
2907 // ----------------------------------------------------------------------------- |
|
2908 // CNSmlDSAgent::WriteWarningL |
|
2909 // Datastore level warning message to the Sync Log. |
|
2910 // ----------------------------------------------------------------------------- |
|
2911 // |
|
2912 void CNSmlDSAgent::WriteWarningL( TInt appIndex, TNSmlError::TNSmlAgentErrorCode aWarningCode ) |
|
2913 { |
|
2914 InfoMessageToSyncLogL( appIndex, aWarningCode ); |
|
2915 iDSContent->SetIndex( appIndex ); |
|
2916 iDSContent->IncreaseWarnings(); |
|
2917 } |
|
2918 |
|
2919 // ----------------------------------------------------------------------------- |
|
2920 // CNSmlDSAgent::WriteWarningL |
|
2921 // Datastore level warning message to the Sync Log. |
|
2922 // ----------------------------------------------------------------------------- |
|
2923 // |
|
2924 void CNSmlDSAgent::WriteWarningL( TInt appIndex, TNSmlError::TNSmlSyncMLStatusCode aWarningCode ) |
|
2925 { |
|
2926 InfoMessageToSyncLogL( appIndex, aWarningCode ); |
|
2927 iDSContent->SetIndex( appIndex ); |
|
2928 iDSContent->IncreaseWarnings(); |
|
2929 } |
|
2930 |
|
2931 // --------------------------------------------------------- |
|
2932 // CNSmlDSAgent::CheckServerStatusCodeL() |
|
2933 // Status code validating |
|
2934 // --------------------------------------------------------- |
|
2935 void CNSmlDSAgent::CheckServerStatusCodeL( TInt aEntryID ) |
|
2936 { |
|
2937 TDesC8& cmd = iSyncMLCmds->ResponseController()->Cmd( aEntryID ); |
|
2938 TNSmlError::TNSmlSyncMLStatusCode status = STATIC_CAST( TNSmlError::TNSmlSyncMLStatusCode, iSyncMLCmds->ResponseController()->StatusCode( aEntryID ) ); |
|
2939 TBool error( EFalse ); |
|
2940 |
|
2941 switch ( status ) |
|
2942 { |
|
2943 case TNSmlError::ESmlStatusInProgress: |
|
2944 if ( cmd != KNSmlAgentSyncHdr ) |
|
2945 { |
|
2946 error = ETrue; |
|
2947 } |
|
2948 break; |
|
2949 |
|
2950 case TNSmlError::ESmlStatusOK: |
|
2951 case TNSmlError::ESmlStatusItemAdded: |
|
2952 case TNSmlError::ESmlStatusAcceptedForProcessing: |
|
2953 case TNSmlError::ESmlStatusNonAuthoriveResponse: |
|
2954 case TNSmlError::ESmlStatusNoContent: |
|
2955 case TNSmlError::ESmlStatusResetContent: |
|
2956 case TNSmlError::ESmlStatusConflictResolvedWithMerge: |
|
2957 case TNSmlError::ESmlStatusConflictResolvedWithClientsCommand: |
|
2958 case TNSmlError::ESmlStatusConflictResolvedWithDuplicate: |
|
2959 case TNSmlError::ESmlStatusConflict: |
|
2960 case TNSmlError::ESmlStatusConflictResolvedWithServerData: |
|
2961 case TNSmlError::ESmlStatusSoftDeleteUpdateConflict: |
|
2962 case TNSmlError::ESmlStatusDeleteWithoutArchive: |
|
2963 case TNSmlError::ESmlStatusItemIsNotDeleted: |
|
2964 case TNSmlError::ESmlStatusItemAccepted: |
|
2965 case TNSmlError::ESmlStatusAlreadyExists: |
|
2966 break; |
|
2967 |
|
2968 case TNSmlError::ESmlStatusAuthenticationAccepted: // 212 |
|
2969 if ( cmd == KNSmlAgentSyncHdr ) |
|
2970 { |
|
2971 iAlreadyAuthenticated = ETrue; |
|
2972 } |
|
2973 break; |
|
2974 |
|
2975 case TNSmlError::ESmlStatusUnauthorized: // 401 |
|
2976 if ( cmd == KNSmlAgentSyncHdr && iCurrMainState == EServerInitialisation ) |
|
2977 { |
|
2978 if ( iSyncMLCmds->ResponseController()->ChalType( aEntryID ).Length() != 0 ) |
|
2979 { |
|
2980 if ( AuthenticationRequirementL( *iSyncMLCmds->ResponseController(), aEntryID ) ) |
|
2981 { |
|
2982 iChallengeRequest = ETrue; |
|
2983 SaveIfNonceL( *iSyncMLCmds->ResponseController(), aEntryID ); |
|
2984 iSyncMLCmds->ResponseController()->ResetL(); |
|
2985 return; |
|
2986 } |
|
2987 else |
|
2988 { |
|
2989 // If authentication has failed then rest of the package is not |
|
2990 // important anymore. |
|
2991 User::Leave( status ); |
|
2992 } |
|
2993 } |
|
2994 else |
|
2995 { |
|
2996 // If authentication has failed then rest of the package is not |
|
2997 // important anymore. |
|
2998 User::Leave( status ); |
|
2999 } |
|
3000 } |
|
3001 break; |
|
3002 |
|
3003 case TNSmlError::ESmlStatusClientAuthenticationRequired: // 407 |
|
3004 if ( cmd == KNSmlAgentSyncHdr && iCurrMainState == EServerInitialisation ) |
|
3005 { |
|
3006 if ( AuthenticationRequirementL( *iSyncMLCmds->ResponseController(), aEntryID ) ) |
|
3007 { |
|
3008 iChallengeRequest = ETrue; |
|
3009 SaveIfNonceL( *iSyncMLCmds->ResponseController(), aEntryID ); |
|
3010 iSyncMLCmds->ResponseController()->ResetL(); |
|
3011 return; |
|
3012 } |
|
3013 } |
|
3014 error = ETrue; |
|
3015 break; |
|
3016 |
|
3017 case TNSmlError::ESmlStatusRefreshRequired: |
|
3018 if ( cmd == KNSmlAgentSync ) |
|
3019 { |
|
3020 TInt appIndex( -1 ); |
|
3021 appIndex = iSyncMLCmds->ResponseController()->AppIndex( aEntryID ); |
|
3022 iDSContent->SetIndex( appIndex ); |
|
3023 iDSContent->SetSlowSyncReqForNextSyncL( ETrue ); |
|
3024 } |
|
3025 //RD_SUSPEND_RESUME |
|
3026 if(iDSContent->SetToFirst()) |
|
3027 { |
|
3028 do |
|
3029 { |
|
3030 if ( iDSContent->GetSessionResumed() ) |
|
3031 { |
|
3032 if(cmd==KNSmlAgentAlert) |
|
3033 { |
|
3034 iDSContent->SetRefreshRequiredL(ETrue); |
|
3035 } |
|
3036 } |
|
3037 }while( iDSContent->SetToNext() ); |
|
3038 |
|
3039 } |
|
3040 //RD_SUSPEND_RESUME |
|
3041 break; |
|
3042 |
|
3043 default: |
|
3044 error = ETrue; |
|
3045 } |
|
3046 |
|
3047 if ( cmd == KNSmlAgentSyncHdr ) |
|
3048 { |
|
3049 SaveIfNonceL( *iSyncMLCmds->ResponseController(), aEntryID ); |
|
3050 } |
|
3051 |
|
3052 if ( cmd == KNSmlAgentAlert ) |
|
3053 { |
|
3054 if ( iSyncMLCmds->ResponseController()->ResponseDetail( aEntryID ) == CNSmlResponseController::EResponseInitAlert ) |
|
3055 { |
|
3056 if ( status == TNSmlError::ESmlStatusOptFeatureNotSupported ) |
|
3057 { |
|
3058 status = (TNSmlError::TNSmlSyncMLStatusCode) TNSmlDSError::ESmlDSUnsupportedSyncType; |
|
3059 } |
|
3060 else |
|
3061 { |
|
3062 if ( status == TNSmlError::ESmlStatusCommandFailed || |
|
3063 status == TNSmlError::ESmlStatusCommandNotAllowed ) |
|
3064 { |
|
3065 iDSContent->SetIndex( iSyncMLCmds->ResponseController()->AppIndex ( aEntryID ) ); |
|
3066 if ( !iDSContent->IsSupportedSyncTypeByServerL() ) |
|
3067 { |
|
3068 status = (TNSmlError::TNSmlSyncMLStatusCode) TNSmlDSError::ESmlDSUnsupportedSyncType; |
|
3069 } |
|
3070 else |
|
3071 { |
|
3072 if ( status == TNSmlError::ESmlStatusCommandFailed ) |
|
3073 { |
|
3074 status = TNSmlError::ESmlStatusNotFound; |
|
3075 } |
|
3076 } |
|
3077 } |
|
3078 } |
|
3079 } |
|
3080 } |
|
3081 |
|
3082 if ( cmd == KNSmlAgentAdd || cmd == KNSmlAgentReplace || cmd == KNSmlAgentPartialReplace || cmd == KNSmlAgentDelete || cmd == KNSmlAgentMove || cmd == KNSmlAgentSoftDelete ) |
|
3083 { |
|
3084 if ( !iSyncMLCmds->ResponseController()->MoreData( aEntryID ) ) |
|
3085 { |
|
3086 iDSContent->SetIndex( iSyncMLCmds->ResponseController()->AppIndex ( aEntryID ) ); |
|
3087 TLex8 lex( iSyncMLCmds->ResponseController()->LUID( aEntryID ) ); |
|
3088 TInt val; |
|
3089 lex.Val( val ); |
|
3090 iDSContent->SetAsReceivedL( val ); |
|
3091 } |
|
3092 } |
|
3093 |
|
3094 if ( !error ) |
|
3095 { |
|
3096 if ( cmd == KNSmlAgentAdd || cmd == KNSmlAgentReplace || cmd == KNSmlAgentPartialReplace ) |
|
3097 { |
|
3098 if ( status == TNSmlError::ESmlStatusItemAdded ) |
|
3099 { |
|
3100 iDSContent->IncreaseItemsAdded(); |
|
3101 } |
|
3102 else |
|
3103 { |
|
3104 if ( status != TNSmlError::ESmlStatusItemAccepted ) |
|
3105 { |
|
3106 iDSContent->IncreaseItemsChanged(); |
|
3107 } |
|
3108 } |
|
3109 } |
|
3110 |
|
3111 if ( cmd == KNSmlAgentDelete || cmd == KNSmlAgentSoftDelete ) |
|
3112 { |
|
3113 if ( status != TNSmlError::ESmlStatusItemIsNotDeleted ) |
|
3114 { |
|
3115 iDSContent->IncreaseItemsDeleted(); |
|
3116 } |
|
3117 } |
|
3118 |
|
3119 if (cmd == KNSmlAgentMove) |
|
3120 { |
|
3121 if ( status == TNSmlError::ESmlStatusOK ) |
|
3122 { |
|
3123 iDSContent->IncreaseItemsMoved(); |
|
3124 } |
|
3125 } |
|
3126 } |
|
3127 else |
|
3128 { |
|
3129 if ( cmd == KNSmlAgentAdd || cmd == KNSmlAgentReplace || cmd == KNSmlAgentPartialReplace || cmd == KNSmlAgentDelete || cmd == KNSmlAgentMove || cmd == KNSmlAgentSoftDelete ) |
|
3130 { |
|
3131 iDSContent->IncreaseItemsFailed(); |
|
3132 } |
|
3133 else |
|
3134 { |
|
3135 InterruptL( iSyncMLCmds->ResponseController()->AppIndex( aEntryID ), status, ETrue, ETrue ); |
|
3136 } |
|
3137 } |
|
3138 } |
|
3139 |
|
3140 // ----------------------------------------------------------------------------- |
|
3141 // CNSmlDSAgent::CheckCommandsAreReceivedL |
|
3142 // Checks that server has sent all expected commands. |
|
3143 // ----------------------------------------------------------------------------- |
|
3144 // |
|
3145 void CNSmlDSAgent::CheckCommandsAreReceivedL() |
|
3146 { |
|
3147 if ( iDSDeviceInfoRequestByClient ) |
|
3148 { |
|
3149 Interrupt( TNSmlDSError::ESmlDSDeviceInfoMissing, ETrue, EFalse ); |
|
3150 } |
|
3151 |
|
3152 iDSContent->SetToFirst(); |
|
3153 |
|
3154 do |
|
3155 { |
|
3156 if ( !iDSContent->Interrupted() ) |
|
3157 { |
|
3158 if ( iDSContent->WaitingInitAlert() ) |
|
3159 { |
|
3160 InterruptL( iDSContent->CurrentIndex(), TNSmlError::ESmlAlertMissingInInitialisation, EFalse, EFalse ); |
|
3161 } |
|
3162 } |
|
3163 } |
|
3164 while ( iDSContent->SetToNext() ); |
|
3165 } |
|
3166 |
|
3167 // |
|
3168 // Authentications |
|
3169 // |
|
3170 |
|
3171 // ----------------------------------------------------------------------------- |
|
3172 // CNSmlDSAgent::AuthTypeL |
|
3173 // Gets authentication type (basic/MD5) from the Agent Log. |
|
3174 // ----------------------------------------------------------------------------- |
|
3175 // |
|
3176 CNSmlAgentBase::TAuthenticationType CNSmlDSAgent::AuthTypeL() const |
|
3177 { |
|
3178 CNSmlAgentBase::TAuthenticationType authType( ENoAuth ); |
|
3179 CNSmlDSAgentLog* agentLog = CNSmlDSAgentLog::NewLC(); |
|
3180 |
|
3181 if ( iProtocolVer == ESmlVersion1_1_2 ) |
|
3182 { |
|
3183 HBufC* searchKey( iSyncServer->HostName().AllocLC() ); |
|
3184 authType = (CNSmlAgentBase::TAuthenticationType)agentLog->AuthTypeL( *searchKey ); |
|
3185 CleanupStack::PopAndDestroy(); // searchKey |
|
3186 } |
|
3187 else if ( iProtocolVer == ESmlVersion1_2 ) |
|
3188 { |
|
3189 authType = (CNSmlAgentBase::TAuthenticationType)agentLog->AuthTypeL( *iDSServerId ); |
|
3190 } |
|
3191 |
|
3192 CleanupStack::PopAndDestroy(); // agentLog |
|
3193 |
|
3194 return authType; |
|
3195 } |
|
3196 |
|
3197 // ----------------------------------------------------------------------------- |
|
3198 // CNSmlDSAgent::SetAuthTypeL |
|
3199 // Saves authentication type to the Agent Log. |
|
3200 // ----------------------------------------------------------------------------- |
|
3201 // |
|
3202 void CNSmlDSAgent::SetAuthTypeL( CNSmlAgentBase::TAuthenticationType aAuthType ) const |
|
3203 { |
|
3204 CNSmlDSAgentLog* agentLog = CNSmlDSAgentLog::NewLC(); |
|
3205 |
|
3206 if ( iProtocolVer == ESmlVersion1_1_2 ) |
|
3207 { |
|
3208 HBufC* searchKey( iSyncServer->HostName().AllocLC() ); |
|
3209 agentLog->SetAuthTypeL( *searchKey, (TNSmlAgentLogAuthenticationType)aAuthType ); |
|
3210 CleanupStack::PopAndDestroy(); // searchKey |
|
3211 } |
|
3212 else if ( iProtocolVer == ESmlVersion1_2 ) |
|
3213 { |
|
3214 agentLog->SetAuthTypeL( *iDSServerId, (TNSmlAgentLogAuthenticationType)aAuthType ); |
|
3215 } |
|
3216 |
|
3217 CleanupStack::PopAndDestroy(); // agentLog |
|
3218 } |
|
3219 |
|
3220 // ----------------------------------------------------------------------------- |
|
3221 // CNSmlDSAgent::FreeResources |
|
3222 // Releases allocated resources. |
|
3223 // ----------------------------------------------------------------------------- |
|
3224 // |
|
3225 void CNSmlDSAgent::FreeResources() |
|
3226 { |
|
3227 FreeBaseResources(); |
|
3228 if(iEnd) |
|
3229 { |
|
3230 delete iDSContent; |
|
3231 iDSContent = NULL; |
|
3232 } |
|
3233 } |
|
3234 |
|
3235 // |
|
3236 // Error Handling functions |
|
3237 // |
|
3238 // --------------------------------------------------------- |
|
3239 // CNSmlDSAgent::Interrupt() |
|
3240 // Synchronisation with all databases is interrupted |
|
3241 // Synchronisation level error code to Sync Log. |
|
3242 // --------------------------------------------------------- |
|
3243 void CNSmlDSAgent::Interrupt( TInt aErrorCode, TBool aImmediatelyInterruption, TBool aStatusError ) |
|
3244 { |
|
3245 DBG_FILE(_S8("CNSmlDSAgent::Interrupt()")); |
|
3246 |
|
3247 if ( !iDSContent->AllDatabasesAreInterrupted() || aStatusError ) |
|
3248 { |
|
3249 // Error code is updated only once, except errors due to |
|
3250 // error Status codes from the server |
|
3251 DoErrorEvent( MSyncMLProgressObserver::ESmlFatalError, aErrorCode, iDSContent->TaskId(), 0, 0 ); |
|
3252 } |
|
3253 |
|
3254 TBool ret( iDSContent->SetToFirst() ); |
|
3255 |
|
3256 while ( ret ) |
|
3257 { |
|
3258 |
|
3259 if ( !iDSContent->Interrupted() ) |
|
3260 { |
|
3261 iDSContent->SetInterrupted(); |
|
3262 } |
|
3263 |
|
3264 if ( aImmediatelyInterruption ) |
|
3265 { |
|
3266 // if immediately interrupted then no response is sent |
|
3267 iDSContent->SetImmediatelyInterrupted(); |
|
3268 } |
|
3269 |
|
3270 if ( aStatusError ) |
|
3271 { |
|
3272 // error due to error Status from a server |
|
3273 iDSContent->SetServerStatusError(); |
|
3274 } |
|
3275 |
|
3276 ret = iDSContent->SetToNext(); |
|
3277 |
|
3278 } |
|
3279 } |
|
3280 |
|
3281 //RD_SUSPEND_RESUME |
|
3282 // --------------------------------------------------------- |
|
3283 // CNSmlDSAgent::MapAlertCode() |
|
3284 // Maps the alert code |
|
3285 // --------------------------------------------------------- |
|
3286 |
|
3287 TNSmlPreviousSyncType CNSmlDSAgent::MapAlertCode(TDes8& aAlertCode) |
|
3288 { |
|
3289 TNSmlPreviousSyncType alertcode=ETypeNotSet; |
|
3290 |
|
3291 if ( aAlertCode == KNSmlDSTwoWay ) |
|
3292 { |
|
3293 alertcode = ESyncDSTwoWay; |
|
3294 } |
|
3295 else if ( aAlertCode == KNSmlDSSlowSync ) |
|
3296 { |
|
3297 alertcode = ESyncDSSlowSync; |
|
3298 } |
|
3299 else if ( aAlertCode == KNSmlDSOneWayFromClient ) |
|
3300 { |
|
3301 alertcode = ESyncDSOneWayFromClient; |
|
3302 } |
|
3303 else if ( aAlertCode == KNSmlDSRefreshFromClient ) |
|
3304 { |
|
3305 alertcode = ESyncDSRefreshFromClient; |
|
3306 } |
|
3307 else if ( aAlertCode == KNSmlDSOneWayFromServer ) |
|
3308 { |
|
3309 alertcode = ESyncDSOneWayFromServer; |
|
3310 } |
|
3311 else if(aAlertCode ==KNSmlDSRefreshFromServer) |
|
3312 { |
|
3313 alertcode =ESyncDSRefreshFromServer; |
|
3314 } |
|
3315 else if(aAlertCode ==KNSmlDSTwoWayByServer) |
|
3316 { |
|
3317 alertcode =ESyncDSTwoWayByServer; |
|
3318 } |
|
3319 else if(aAlertCode ==KNSmlDSOneWayFromClientByServer) |
|
3320 { |
|
3321 alertcode =ESyncDSOneWayFromClientByServer; |
|
3322 } |
|
3323 else if(aAlertCode ==KNSmlDSRefreshFromClientByServer) |
|
3324 { |
|
3325 alertcode =ESyncDSRefreshFromClientByServer; |
|
3326 } |
|
3327 else if(aAlertCode ==KNSmlDSOneWayFromServerByServer) |
|
3328 { |
|
3329 alertcode =ESyncDSOneWayFromServerByServer; |
|
3330 } |
|
3331 else if(aAlertCode ==KNSmlDSRefreshFromServerByServer) |
|
3332 { |
|
3333 alertcode = ESyncDSRefreshFromServerByServer; |
|
3334 } |
|
3335 |
|
3336 return(alertcode); |
|
3337 |
|
3338 } |
|
3339 //RD_SUSPEND_RESUME |
|
3340 |
|
3341 // CNSmlDSAgent::InterruptL() |
|
3342 // Synchronisation with a given database is interrupted |
|
3343 // --------------------------------------------------------- |
|
3344 void CNSmlDSAgent::InterruptL( TInt appIndex, TInt aErrorCode, TBool aImmediatelyInterruption, TBool aStatusError ) |
|
3345 { |
|
3346 DBG_FILE(_S8("CNSmlDSAgent::InterruptL()")); |
|
3347 if ( !iDSContent->SetIndex( appIndex ) ) |
|
3348 { |
|
3349 // if index does not point to a database, interrupt all databases |
|
3350 Interrupt( aErrorCode, aImmediatelyInterruption, aStatusError ); |
|
3351 } |
|
3352 else |
|
3353 { |
|
3354 iDSContent->SetIndex( appIndex ); |
|
3355 if ( ( !iDSContent->Interrupted() ) || |
|
3356 ( aStatusError && !iDSContent->ServerStatusError() ) ) |
|
3357 { |
|
3358 // only one message to Sync Log expect Status code errors from a server |
|
3359 iDSContent->SetInterrupted(); |
|
3360 InfoMessageToSyncLogL( appIndex, aErrorCode ); |
|
3361 if ( aStatusError ) |
|
3362 { |
|
3363 iDSContent->SetServerStatusError(); |
|
3364 } |
|
3365 } |
|
3366 if ( aImmediatelyInterruption ) |
|
3367 { |
|
3368 // if immediately, any respose is not send |
|
3369 iDSContent->SetImmediatelyInterrupted(); |
|
3370 } |
|
3371 } |
|
3372 } |
|
3373 |
|
3374 // ----------------------------------------------------------------------------- |
|
3375 // CNSmlDSAgent::FinaliseWhenErrorL |
|
3376 // Gets called if sync is broken down immediately (Leave errors) |
|
3377 // ----------------------------------------------------------------------------- |
|
3378 // |
|
3379 void CNSmlDSAgent::FinaliseWhenErrorL() |
|
3380 { |
|
3381 DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL begins")); |
|
3382 |
|
3383 // <MAPINFO_RESEND_MOD_BEGIN> |
|
3384 if( iDSContent->ResendUsed() ) |
|
3385 { |
|
3386 DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL - calling iDSContent->PackupRequestL...")); |
|
3387 iDSContent->PackupRequestL( iDSClientNextSyncAnchor ); |
|
3388 } |
|
3389 // <MAPINFO_RESEND_MOD_END> |
|
3390 |
|
3391 //RD_SUSPEND_RESUME |
|
3392 TInt keyVal; |
|
3393 TRAPD (srerr ,ReadRepositoryL(KNsmlDsSuspendResume, keyVal)); |
|
3394 if(srerr == KErrNone && keyVal == 1) |
|
3395 { |
|
3396 TNSmlSyncSuspendedState suspendedState; |
|
3397 if(iDSContent->SetToFirst()) |
|
3398 { |
|
3399 do |
|
3400 { |
|
3401 suspendedState = CurrentState(); |
|
3402 iDSContent->SetSuspendedStateL(suspendedState); |
|
3403 }while( iDSContent->SetToNext() ); |
|
3404 } |
|
3405 if(iDSContent->SetToFirst()) |
|
3406 { |
|
3407 do |
|
3408 { |
|
3409 TBuf8<3> syncType( iDSContent->SyncType()); |
|
3410 TNSmlPreviousSyncType prevalertcode=MapAlertCode(syncType); |
|
3411 //Sync Type of the Current Sync session is stored. |
|
3412 iDSContent->SetPreviousSyncTypeL( prevalertcode ); |
|
3413 }while( iDSContent->SetToNext() ); |
|
3414 } |
|
3415 if(iDSContent->SetToFirst()) |
|
3416 { |
|
3417 do |
|
3418 { |
|
3419 TBuf8<3> clientSyncType( iDSContent->ClientSyncType()); |
|
3420 TNSmlPreviousSyncType prevClientType=MapAlertCode(clientSyncType); |
|
3421 //Sync Type proposed by Client in the Current Sync session is stored. |
|
3422 iDSContent->SetPreviousClientSyncTypeL( prevClientType ); |
|
3423 }while( iDSContent->SetToNext() ); |
|
3424 } |
|
3425 } |
|
3426 //RD_SUSPEND_RESUME |
|
3427 |
|
3428 iDSContent->FinalizeDatabasesL(); |
|
3429 |
|
3430 iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlDisconnected, 0, 0 ); |
|
3431 |
|
3432 if(iPacketDataUnAvailable) |
|
3433 { |
|
3434 DoErrorEvent(MSyncMLProgressObserver::ESmlFatalError, |
|
3435 TNSmlError::ESmlCommunicationError, 0, 0, 0 ); |
|
3436 } |
|
3437 |
|
3438 //RD_AUTO_RESTART (BPSS-7GBFF3) |
|
3439 DBG_FILE_CODE(iPacketDataUnAvailable,_S8("CNSmlDSAgent::FinaliseWhenErrorL PacketData is")); |
|
3440 //Check whether the Auto Restart Feature is enabled or not |
|
3441 TRAPD (arerr ,ReadRepositoryL(KNsmlDsAutoRestart, keyVal)); |
|
3442 |
|
3443 if(arerr == KErrNone && keyVal == 1) |
|
3444 { |
|
3445 if(!iPacketDataUnAvailable && !iAutoRestartInitiatedSync ) |
|
3446 { |
|
3447 |
|
3448 DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL About to check the Profile ID")); |
|
3449 |
|
3450 if(CheckProfileIdL()) |
|
3451 { |
|
3452 TerminateAutoRestart(); |
|
3453 } |
|
3454 } |
|
3455 } |
|
3456 //RD_AUTO_RESTART |
|
3457 |
|
3458 DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL ends")); |
|
3459 } |
|
3460 |
|
3461 // ----------------------------------------------------------------------------- |
|
3462 // CNSmlDSAgent::Interrupted |
|
3463 // Checks if all datastores are interrupted. |
|
3464 // ----------------------------------------------------------------------------- |
|
3465 // |
|
3466 TBool CNSmlDSAgent::Interrupted() |
|
3467 { |
|
3468 return iDSContent->AllDatabasesAreInterrupted(); |
|
3469 } |
|
3470 // ----------------------------------------------------------------------------- |
|
3471 // CNSmlDSAgent::LaunchAutoRestart |
|
3472 // Launch the NETMON exe after saving the Profile Info to the CenRep and Killing |
|
3473 // the current DSSync session |
|
3474 // ----------------------------------------------------------------------------- |
|
3475 // |
|
3476 void CNSmlDSAgent::LaunchAutoRestartL(TInt aError) |
|
3477 { |
|
3478 DBG_FILE(_S8("CNSmlDSAgent::LaunchAutoRestart() begins")); |
|
3479 |
|
3480 |
|
3481 //Check whether the Users' Network is in Roaming |
|
3482 if(iDSNetmon) |
|
3483 { |
|
3484 if(iDSNetmon->IsRoaming()) |
|
3485 { |
|
3486 DBG_FILE(_S8("CNSmlDSAgent::LaunchAutoRestart() Users' Network in Roaming Leaving the fuction")); |
|
3487 User::Leave(aError); |
|
3488 } |
|
3489 } |
|
3490 |
|
3491 //Fix for BPSS-7H7JPF |
|
3492 //Check whether the Auto-Restart is to be launched for the Profile that is already interrupted |
|
3493 if(!iAutoRestartInitiatedSync) |
|
3494 { |
|
3495 TerminateAutoRestart(); |
|
3496 } |
|
3497 |
|
3498 |
|
3499 //Save the Profile Information |
|
3500 SaveProfileInfoL(); |
|
3501 |
|
3502 //Kill the DS Sync Sesssion |
|
3503 StopDSSession(); |
|
3504 |
|
3505 //Launch the NETMON exe |
|
3506 LaunchNETMONL(); |
|
3507 |
|
3508 DBG_FILE(_S8("CNSmlDSAgent::LaunchAutoRestart() ends")); |
|
3509 |
|
3510 } |
|
3511 |
|
3512 // ----------------------------------------------------------------------------- |
|
3513 // CNSmlDSAgent::SaveProfileInfo |
|
3514 // Save the Profile Information in to the Central Repository |
|
3515 // ----------------------------------------------------------------------------- |
|
3516 // |
|
3517 void CNSmlDSAgent::SaveProfileInfoL() |
|
3518 { |
|
3519 DBG_FILE(_S8("CNSmlDSAgent::SaveProfileInfo() begins")); |
|
3520 |
|
3521 CNsmlProfileUtil* profileUtil = CNsmlProfileUtil::NewLC(); |
|
3522 profileUtil->InternalizeFromSettingsDBL(this->iProfileID); |
|
3523 profileUtil->ExternalizeToCenrepL(); |
|
3524 profileUtil->WriteAccessPointIdL(iNetmonAPId); |
|
3525 |
|
3526 //Error fix for BPSS-7GYDJV |
|
3527 RArray<TSmlTaskId> taskIdArray; |
|
3528 if ( iDSSyncTypeArray && iDSSyncTypeArray->Count() > 0) |
|
3529 { |
|
3530 TInt count = iDSSyncTypeArray->Count(); |
|
3531 DBG_FILE_CODE(count, _S8("CNSmlDSAgent::SaveProfileInfo() TaskId Count")); |
|
3532 for ( TInt i = 0; i < count; i++ ) |
|
3533 { |
|
3534 TSmlTaskId taskid; |
|
3535 taskid = iDSSyncTypeArray->At( i ).iTaskId; |
|
3536 taskIdArray.AppendL( taskid ); |
|
3537 } |
|
3538 } |
|
3539 else |
|
3540 { |
|
3541 DBG_FILE(_S8("CNSmlDSAgent::SaveProfileInfo() No TaskId")); |
|
3542 taskIdArray.Reset(); |
|
3543 } |
|
3544 profileUtil->ExternalizeTaskIdL(taskIdArray); |
|
3545 taskIdArray.Close(); |
|
3546 |
|
3547 CleanupStack::PopAndDestroy(profileUtil); |
|
3548 |
|
3549 DBG_FILE(_S8("CNSmlDSAgent::SaveProfileInfo() ends")); |
|
3550 } |
|
3551 |
|
3552 // ----------------------------------------------------------------------------- |
|
3553 // CNSmlDSAgent::LaunchNETMON |
|
3554 // ----------------------------------------------------------------------------- |
|
3555 // |
|
3556 void CNSmlDSAgent::LaunchNETMONL() |
|
3557 { |
|
3558 DBG_FILE(_S8("CNSmlDSAgent::LaunchNETMONL() begins")); |
|
3559 //Kill if any existing NetMon exe is running |
|
3560 //TerminateAutoRestart(); |
|
3561 //Starts the new Netmon process to register for the Connmon events |
|
3562 //This exe will start the Sync session once the Network is available |
|
3563 RProcess rp; |
|
3564 TInt err = rp.Create(KNetMon,KNullDesC); |
|
3565 User::LeaveIfError(err); |
|
3566 rp.Resume(); |
|
3567 |
|
3568 DBG_FILE(_S8("CNSmlDSAgent::LaunchNETMONL() ends")); |
|
3569 } |
|
3570 |
|
3571 // ----------------------------------------------------------------------------- |
|
3572 // CNSmlDSAgent::StopDSSession |
|
3573 // Kill the current DS Sync Session |
|
3574 // ----------------------------------------------------------------------------- |
|
3575 // |
|
3576 void CNSmlDSAgent::StopDSSession() |
|
3577 { |
|
3578 DBG_FILE(_S8("CNSmlDSAgent::StopDSSession() begins")); |
|
3579 |
|
3580 iCurrMainState = EFinishing; |
|
3581 Cancel(); |
|
3582 |
|
3583 DBG_FILE(_S8("CNSmlDSAgent::StopDSSession() ends")); |
|
3584 } |
|
3585 |
|
3586 |
|
3587 // ----------------------------------------------------------------------------- |
|
3588 // CNSmlDSAgent::DoErrorEvent |
|
3589 // Unsures error event |
|
3590 // ----------------------------------------------------------------------------- |
|
3591 // |
|
3592 void CNSmlDSAgent::DoErrorEvent( MSyncMLProgressObserver::TErrorLevel |
|
3593 aErrorLevel, |
|
3594 TInt aError, TInt aTaskId, |
|
3595 TInt aInfo1, TInt aInfo2 ) |
|
3596 { |
|
3597 if ( !iErrorNotified ) |
|
3598 { |
|
3599 iDSObserver->OnSyncMLSyncError( aErrorLevel, aError, |
|
3600 aTaskId, aInfo1, aInfo2 ); |
|
3601 iErrorNotified = ETrue; |
|
3602 } |
|
3603 } |
|
3604 |
|
3605 // ----------------------------------------------------------------------------- |
|
3606 // CNSmlDSAgent::PrepareSyncL |
|
3607 // Prepares sync. |
|
3608 // ----------------------------------------------------------------------------- |
|
3609 // |
|
3610 void CNSmlDSAgent::PrepareSyncL( CArrayFix<TNSmlContentSpecificSyncType>* aTypeArray ) |
|
3611 { |
|
3612 iDSContent->InitContentDataL(); |
|
3613 |
|
3614 if ( aTypeArray ) |
|
3615 { |
|
3616 iDSSyncTypeArray = new ( ELeave ) CArrayFixFlat<TNSmlContentSpecificSyncType>( 4 ); |
|
3617 |
|
3618 for ( TInt i = 0; i < aTypeArray->Count(); i++ ) |
|
3619 { |
|
3620 TNSmlContentSpecificSyncType type; |
|
3621 type.iTaskId = aTypeArray->At( i ).iTaskId; |
|
3622 type.iType = aTypeArray->At( i ).iType; |
|
3623 iDSSyncTypeArray->AppendL( type ); |
|
3624 } |
|
3625 } |
|
3626 } |
|
3627 |
|
3628 // <MAPINFO_RESEND_MOD_BEGIN> |
|
3629 |
|
3630 // --------------------------------------------------------- |
|
3631 // CNSmlDSAgent::BeginSubScanMapInfo() |
|
3632 // |
|
3633 // --------------------------------------------------------- |
|
3634 void CNSmlDSAgent::BeginSubScanMapInfo() |
|
3635 { |
|
3636 DBG_FILE(_S8("CNSmlDSAgent::BeginSubScanMapInfo() begins")); |
|
3637 TBool endOfMapLoading = EFalse; |
|
3638 TRAPD( err,ScanMapInfoL( endOfMapLoading ) ); |
|
3639 if( err != KErrNone || endOfMapLoading ) |
|
3640 { |
|
3641 DBG_FILE_CODE( endOfMapLoading, _S8("CNSmlDSAgent::BeginSubScanMapInfo(): endOfMapLoading: ") ); |
|
3642 DBG_FILE_CODE( err, _S8("CNSmlDSAgent::BeginSubScanMapInfo(): Moved to SubCreateLUIDBuffers...") ); |
|
3643 iDSCurrBeginSubState = EBeginSubCreateLUIDBuffers; |
|
3644 } |
|
3645 DBG_FILE(_S8("CNSmlDSAgent::BeginSubScanMapInfo() ends")); |
|
3646 } |
|
3647 |
|
3648 // |
|
3649 // Client Resend MapInformation state functions |
|
3650 // |
|
3651 // --------------------------------------------------------- |
|
3652 // CNSmlDSAgent::ClientResendMapInfoStateL() |
|
3653 // If mapinfo exists as a result of unsuccessfull last sync, |
|
3654 // it Makes Client Map Informtaion Package to be resent to Server |
|
3655 // Navigate according to state code |
|
3656 // --------------------------------------------------------- |
|
3657 void CNSmlDSAgent::ClientResendMapInfoStateL() |
|
3658 { |
|
3659 switch ( iCurrClientResendMapInfoState ) |
|
3660 { |
|
3661 case EResendMapInfoStartingMessage: |
|
3662 ClientResendMapInfoStartingMessageStateL(); |
|
3663 break; |
|
3664 case EResendMapInfoMakingStatus: |
|
3665 ClientResendMapInfoMakingStatusStateL(); |
|
3666 break; |
|
3667 case EResendMapInfoMakingResults: |
|
3668 ClientResendMapInfoMakingResultsStateL(); |
|
3669 break; |
|
3670 case EResendMapInfoStartingSync: |
|
3671 ClientResendMapInfoStartingSyncStateL(); |
|
3672 break; |
|
3673 case EResendMapInfoEndingSync: |
|
3674 ClientResendMapInfoEndingSyncStateL(); |
|
3675 break; |
|
3676 case EResendMapInfoMakingMap: |
|
3677 ClientResendMapInfoMakingMapStateL(); |
|
3678 break; |
|
3679 case EResendMapInfoEndingMessage: |
|
3680 ClientResendMapInfoEndingMessageStateL(); |
|
3681 break; |
|
3682 } |
|
3683 } |
|
3684 |
|
3685 void CNSmlDSAgent::ClientResendMapInfoStartingMessageStateL() |
|
3686 { |
|
3687 DBG_FILE(_S8("CNSmlAgentBase::ClientResendMapInfoStartingMessageStateL begins")); |
|
3688 iMapResendStatusPackage=EFalse; |
|
3689 iBufferFull = EFalse; |
|
3690 TBool mapFound=EFalse; |
|
3691 iDSContent->SetToFirst(); |
|
3692 if(iDSContent->MapExists()) |
|
3693 { |
|
3694 mapFound=ETrue; |
|
3695 } |
|
3696 while(iDSContent->SetToNext() && !mapFound) |
|
3697 { |
|
3698 if(iDSContent->MapExists()) |
|
3699 { |
|
3700 mapFound=ETrue; |
|
3701 } |
|
3702 } |
|
3703 if(mapFound) |
|
3704 { |
|
3705 DBG_FILE(_S8("CNSmlAgentBase::ClientResendMapInfoStartingMessageStateL Mapfound")); |
|
3706 iSyncMLCmds->DoSyncHdrL(); |
|
3707 iDSContent->SetToFirst(); |
|
3708 iCurrClientResendMapInfoState = EResendMapInfoMakingStatus; |
|
3709 } |
|
3710 else |
|
3711 { |
|
3712 NextMainStateL(); |
|
3713 } |
|
3714 DBG_FILE(_S8("CNSmlAgentBase::ClientResendMapInfoStartingMessageStateL ends")); |
|
3715 } |
|
3716 |
|
3717 void CNSmlDSAgent::ClientResendMapInfoMakingStatusStateL() |
|
3718 { |
|
3719 DBG_FILE(_S8("CNSmlDSAgent::ClientResendMapInfoMakingStatusStateL begins")); |
|
3720 iSyncMLCmds->StatusContainer()->Begin(); |
|
3721 TBool found( ETrue ); |
|
3722 while( found ) |
|
3723 { |
|
3724 SmlStatus_t* status; |
|
3725 found = iSyncMLCmds->StatusContainer()->NextStatusElement( status, ETrue ); |
|
3726 if ( found ) |
|
3727 { |
|
3728 iSyncMLCmds->DoStatusL( status ); |
|
3729 } |
|
3730 } |
|
3731 iCurrClientResendMapInfoState = EResendMapInfoMakingResults; |
|
3732 DBG_FILE(_S8("CNSmlAgent::ClientResendMapInfoMakingStatusStateL ends")); |
|
3733 } |
|
3734 |
|
3735 |
|
3736 void CNSmlDSAgent::ClientResendMapInfoMakingResultsStateL() |
|
3737 { |
|
3738 DBG_FILE(_S8("CNSmlDSAgent::ClientModMakingResultsStateL begins")); |
|
3739 if ( iDSDeviceInfoRequestedByServer && !iDSContent->AllDatabasesAreInterrupted() ) |
|
3740 { |
|
3741 iSyncMLCmds->DoResultsL(); |
|
3742 iDSDeviceInfoRequestedByServer = EFalse; |
|
3743 } |
|
3744 if ( iFinalMessageFromClient ) |
|
3745 { |
|
3746 iDSContent->SetToFirst(); |
|
3747 } |
|
3748 else |
|
3749 { |
|
3750 iDSContent->SetIndexToSaved(); |
|
3751 } |
|
3752 iCurrClientResendMapInfoState = EResendMapInfoStartingSync; |
|
3753 DBG_FILE(_S8("CNSmlAgent::ClientResendMapInfoMakingResultsStateL ends")); |
|
3754 } |
|
3755 // --------------------------------------------------------- |
|
3756 // CNSmlDSAgent::ClientResendMapInfoEndingSyncStateL() |
|
3757 // Makes Sync command |
|
3758 // --------------------------------------------------------- |
|
3759 void CNSmlDSAgent::ClientResendMapInfoStartingSyncStateL() |
|
3760 { |
|
3761 DBG_FILE(_S8("CNSmlDSAgent::ClientResendMapInfoStartingSyncStateL begins")); |
|
3762 CNSmlCmdsBase::TReturnValue ret; |
|
3763 if ( !iDSContent->Interrupted() ) |
|
3764 { |
|
3765 ret = iSyncMLCmds->DoStartSyncL(); |
|
3766 switch ( ret ) |
|
3767 { |
|
3768 case CNSmlCmdsBase::EReturnOK: |
|
3769 iCurrClientResendMapInfoState = EResendMapInfoEndingSync; |
|
3770 iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlSendingMappingsToServer, 0, 0 ); |
|
3771 break; |
|
3772 case CNSmlCmdsBase::EReturnBufferFull: |
|
3773 iCurrClientResendMapInfoState = EResendMapInfoEndingSync; |
|
3774 iBufferFull = ETrue; |
|
3775 break; |
|
3776 default: |
|
3777 break; |
|
3778 } |
|
3779 } |
|
3780 else |
|
3781 // skip interrupted database |
|
3782 { |
|
3783 if ( !iDSContent->SetToNext() ) |
|
3784 { |
|
3785 iCurrClientResendMapInfoState = EResendMapInfoEndingSync; |
|
3786 } |
|
3787 } |
|
3788 DBG_FILE(_S8("CNSmlDSAgent::ClientResendMapInfoStartingSyncStateL ends")); |
|
3789 } |
|
3790 // --------------------------------------------------------- |
|
3791 // CNSmlDSAgent::ClientResendMapInfoEndingSyncStateL() |
|
3792 // End of Sync command |
|
3793 // --------------------------------------------------------- |
|
3794 void CNSmlDSAgent::ClientResendMapInfoEndingSyncStateL() |
|
3795 { |
|
3796 DBG_FILE(_S8("CNSmlDSAgent::ClientResendMapInfoEndingSyncStateL begins")); |
|
3797 iSyncMLCmds->DoEndSyncL(); |
|
3798 if ( iBufferFull ) |
|
3799 { |
|
3800 iCurrClientResendMapInfoState = EResendMapInfoEndingMessage; |
|
3801 } |
|
3802 else |
|
3803 { |
|
3804 if ( iDSContent->SetToNext() ) |
|
3805 { |
|
3806 iCurrClientResendMapInfoState = EResendMapInfoStartingSync; |
|
3807 } |
|
3808 else |
|
3809 { |
|
3810 iCurrClientResendMapInfoState = EResendMapInfoMakingMap; |
|
3811 iDSContent->SetToFirst(); |
|
3812 } |
|
3813 } |
|
3814 DBG_FILE(_S8("CNSmlDSAgent::ClientResendMapInfoEndingSyncStateL ends")); |
|
3815 } |
|
3816 |
|
3817 void CNSmlDSAgent::ClientResendMapInfoMakingMapStateL() |
|
3818 { |
|
3819 DBG_FILE(_S8("CNSmlAgent::ClientResendMapInfoMakingMapStateL begins")); |
|
3820 CNSmlCmdsBase::TReturnValue ret=CNSmlCmdsBase::EReturnOK; |
|
3821 ret = iSyncMLCmds->DoMapL(); |
|
3822 switch ( ret ) |
|
3823 { |
|
3824 case CNSmlCmdsBase::EReturnOK: |
|
3825 iDSWaitingForMapAcknowledgement = ETrue; |
|
3826 // there is something to send |
|
3827 iMapResendStatusPackage = ETrue; |
|
3828 if ( !iDSContent->SetToNext() ) |
|
3829 { |
|
3830 iCurrClientResendMapInfoState = EResendMapInfoEndingMessage; |
|
3831 } |
|
3832 break; |
|
3833 case CNSmlCmdsBase::EReturnEndData: |
|
3834 if ( !iDSContent->SetToNext() ) |
|
3835 { |
|
3836 iCurrClientResendMapInfoState = EResendMapInfoEndingMessage; |
|
3837 } |
|
3838 break; |
|
3839 case CNSmlCmdsBase::EReturnBufferFull: |
|
3840 iBufferFull = ETrue; |
|
3841 iCurrClientResendMapInfoState = EResendMapInfoEndingMessage; |
|
3842 break; |
|
3843 default: |
|
3844 break; |
|
3845 } |
|
3846 DBG_FILE(_S8("CNSmlAgent::ClientResendMapInfoMakingMapStateL ends")); |
|
3847 } |
|
3848 |
|
3849 |
|
3850 void CNSmlDSAgent::ClientResendMapInfoEndingMessageStateL() |
|
3851 { |
|
3852 DBG_FILE(_S8("CNSmlAgentBase::ClientResendMapInfoEndingMessageStateL begins")); |
|
3853 iSyncMLCmds->DoEndMessageL( EFalse ); |
|
3854 |
|
3855 if ( iBufferFull ) |
|
3856 { |
|
3857 iFinalMessageFromClient = EFalse; |
|
3858 } |
|
3859 else |
|
3860 { |
|
3861 iFinalMessageFromClient = ETrue; |
|
3862 } |
|
3863 |
|
3864 NextMainStateL(); |
|
3865 DBG_FILE(_S8("CNSmlAgentBase::ClientResendMapInfoEndingMessageStateL ends")); |
|
3866 } |
|
3867 |
|
3868 // ------------------------------------------------------------------------------------------------------------------ |
|
3869 // CNSmlDSAgent::ScanMapInfoL |
|
3870 // Map information is searched for all the databases physical storage and calls functions to load map if exists |
|
3871 // ------------------------------------------------------------------------------------------------------------------ |
|
3872 void CNSmlDSAgent::ScanMapInfoL( TBool& aEnd ) |
|
3873 { |
|
3874 DBG_FILE(_S8("CNSmlDSAgent::ScanMapInfoL() begins")); |
|
3875 |
|
3876 if ( !iCommandIssued ) |
|
3877 { |
|
3878 TBool ret = EFalse; |
|
3879 if ( !iDSMapOpeningStarted ) |
|
3880 { |
|
3881 ret = iDSContent->SetToFirst(); |
|
3882 iDSMapOpeningStarted = ETrue; |
|
3883 } |
|
3884 else |
|
3885 { |
|
3886 ret = iDSContent->SetToNext(); |
|
3887 } |
|
3888 if ( ret ) |
|
3889 { |
|
3890 iDSContent->ScanMapContentL(iStatus); |
|
3891 iCommandIssued = ETrue; |
|
3892 } |
|
3893 else |
|
3894 { |
|
3895 aEnd = ETrue; |
|
3896 } |
|
3897 } |
|
3898 else // command was completed |
|
3899 { |
|
3900 iCommandIssued = EFalse; |
|
3901 if ( iStatus.Int() == KErrNotFound ) |
|
3902 { |
|
3903 DBG_FILE_CODE( iStatus.Int(), _S8("CNSmlDSAgent::ScanMapInfoL(): Error! (1)") ); |
|
3904 //InterruptL( iDSContent->CurrentIndex(), TNSmlDSError::ESmlDSLocalDatabaseError, ETrue, EFalse ); |
|
3905 //iDSContent->SetInterruptedBeforeSync(); |
|
3906 } |
|
3907 else |
|
3908 { |
|
3909 DBG_FILE_CODE( iStatus.Int(), _S8("CNSmlDSAgent::ScanMapInfoL(): Error! (2)") ); |
|
3910 User::LeaveIfError( iStatus.Int() ); |
|
3911 } |
|
3912 } |
|
3913 DBG_FILE(_S8("CNSmlDSAgent::ScanMapInfoL() ends")); |
|
3914 } |
|
3915 // <MAPINFO_RESEND_MOD_END> |
|
3916 |
|
3917 // CreateDSAgentL( MNSmlDSAgentObserver* aDSObserver ) |
|
3918 // Return the instance of the CNSmlDSAgent |
|
3919 // --------------------------------------------------------- |
|
3920 // |
|
3921 EXPORT_C CNSmlDSAgent* CreateDSAgentL( MSyncMLProgressObserver* aDSObserver ) |
|
3922 { |
|
3923 return CNSmlDSAgent::NewL( aDSObserver ); |
|
3924 } |
|
3925 |
|
3926 |
|
3927 //RD_SUSPEND_RESUME |
|
3928 // ------------------------------------------------------------------------------------------------------------------ |
|
3929 // CNSmlDSAgent::SyncFailure() |
|
3930 // |
|
3931 // ------------------------------------------------------------------------------------------------------------------ |
|
3932 TBool CNSmlDSAgent::SyncFailure() |
|
3933 { |
|
3934 DBG_FILE_CODE(iError->SyncLogErrorCode(),_S8("CNSmlDSAgent::SyncFailure( ).Error code")); |
|
3935 if(iError->SyncLogErrorCode()) |
|
3936 return(ETrue); |
|
3937 else |
|
3938 return(EFalse); |
|
3939 } |
|
3940 |
|
3941 // ------------------------------------------------------------------------------------------------------------------ |
|
3942 // CNSmlDSAgent::CurrentStateInFinishing() |
|
3943 // |
|
3944 // ------------------------------------------------------------------------------------------------------------------ |
|
3945 |
|
3946 TNSmlSyncSuspendedState CNSmlDSAgent::CurrentStateInFinishing() |
|
3947 { |
|
3948 TNSmlSyncSuspendedState state=EStateNotStarted; |
|
3949 |
|
3950 TBool chk=SyncFailure(); |
|
3951 DBG_FILE_CODE(chk,_S8("CNSmlDSAgent::CurrentStateInFinishing( )..Network failure check")); |
|
3952 |
|
3953 if(iDSContent->AnyDatabaseIsInterrupted() || iPacketDataUnAvailable |
|
3954 || chk ) |
|
3955 { |
|
3956 switch(iPrevSyncState) |
|
3957 { |
|
3958 case EBeginning: |
|
3959 case EClientInitialisation: |
|
3960 case EServerInitialisation: |
|
3961 case EResultAlert: |
|
3962 //if any sync failure occurs at pkt#1/pkt#2 stage, do not update |
|
3963 //sync anchors |
|
3964 if(chk) |
|
3965 iUpdateLastAnchor=EFalse; |
|
3966 state = EStateNotStarted; |
|
3967 break; |
|
3968 case EClientResendMapInfo: |
|
3969 case EClientModifications: |
|
3970 state = EStateClientModification; |
|
3971 break; |
|
3972 case EServerModifications: |
|
3973 state = EStateServerModification; |
|
3974 break; |
|
3975 case EDataUpdateStatus: |
|
3976 state = EStateDataUpdateStatus; |
|
3977 break; |
|
3978 case EMapAcknowledge: |
|
3979 state = EStateMapAcknowledge; |
|
3980 break; |
|
3981 |
|
3982 } |
|
3983 } |
|
3984 else |
|
3985 { |
|
3986 state = EStateNotStarted; |
|
3987 } |
|
3988 |
|
3989 return(state); |
|
3990 } |
|
3991 |
|
3992 // ------------------------------------------------------------------------------------------------------------------ |
|
3993 // CNSmlDSAgent::CurrentStateInReceiving() |
|
3994 // |
|
3995 // ------------------------------------------------------------------------------------------------------------------ |
|
3996 |
|
3997 TNSmlSyncSuspendedState CNSmlDSAgent::CurrentStateInReceiving() |
|
3998 { |
|
3999 TNSmlSyncSuspendedState state=EStateNotStarted; |
|
4000 if (iPrevSyncState == EClientInitialisation || iPrevSyncState == EServerInitialisation |
|
4001 || iPrevSyncState == EClientResendMapInfo ) |
|
4002 { |
|
4003 state = EStateNotStarted; |
|
4004 } |
|
4005 else if(iPrevSyncState == EClientModifications) |
|
4006 { |
|
4007 state = EStateClientModification; |
|
4008 } |
|
4009 else if (iPrevSyncState == EDataUpdateStatus) |
|
4010 { |
|
4011 state = EStateDataUpdateStatus; |
|
4012 } |
|
4013 else if (iPrevSyncState == EServerModifications ) |
|
4014 { |
|
4015 state = EStateServerModification; |
|
4016 } |
|
4017 else if (iPrevSyncState == EMapAcknowledge ) |
|
4018 { |
|
4019 state = EStateMapAcknowledge; |
|
4020 } |
|
4021 |
|
4022 return state; |
|
4023 } |
|
4024 |
|
4025 // ------------------------------------------------------------------------------------------------------------------ |
|
4026 // CNSmlDSAgent::CurrentStateInClientAlertNext() |
|
4027 // |
|
4028 // ------------------------------------------------------------------------------------------------------------------ |
|
4029 |
|
4030 TNSmlSyncSuspendedState CNSmlDSAgent::CurrentStateInClientAlertNext() |
|
4031 { |
|
4032 TNSmlSyncSuspendedState state=EStateNotStarted; |
|
4033 if (iPrevSyncState == EServerModifications) |
|
4034 { |
|
4035 state = EStateServerModification; |
|
4036 } |
|
4037 else if (iPrevSyncState == EMapAcknowledge) |
|
4038 { |
|
4039 state = EStateMapAcknowledge; |
|
4040 } |
|
4041 return(state); |
|
4042 } |
|
4043 |
|
4044 |
|
4045 // ------------------------------------------------------------------------------------------------------------------ |
|
4046 // CNSmlDSAgent::CurrentStateInServerAlertNext() |
|
4047 // |
|
4048 // ------------------------------------------------------------------------------------------------------------------ |
|
4049 |
|
4050 TNSmlSyncSuspendedState CNSmlDSAgent::CurrentStateInServerAlertNext() |
|
4051 { |
|
4052 TNSmlSyncSuspendedState state=EStateNotStarted; |
|
4053 if(iPrevSyncState == EClientModifications) |
|
4054 { |
|
4055 state = EStateClientModification; |
|
4056 } |
|
4057 else if (iPrevSyncState == EDataUpdateStatus) |
|
4058 { |
|
4059 state = EStateDataUpdateStatus; |
|
4060 } |
|
4061 return(state); |
|
4062 } |
|
4063 |
|
4064 // ------------------------------------------------------------------------------------------------------------------ |
|
4065 // CNSmlDSAgent::CurrentState() |
|
4066 // |
|
4067 // ------------------------------------------------------------------------------------------------------------------ |
|
4068 |
|
4069 |
|
4070 TNSmlSyncSuspendedState CNSmlDSAgent::CurrentState( ) |
|
4071 { |
|
4072 |
|
4073 TNSmlSyncSuspendedState state = EStateNotStarted; |
|
4074 |
|
4075 switch(iCurrMainState) |
|
4076 { |
|
4077 case EBeginning: |
|
4078 case EClientInitialisation: |
|
4079 case EServerInitialisation: |
|
4080 case EResultAlert: |
|
4081 if(SyncFailure()) |
|
4082 { |
|
4083 iUpdateLastAnchor=EFalse; |
|
4084 } |
|
4085 state=EStateNotStarted; |
|
4086 break; |
|
4087 case EFinishing: |
|
4088 state=CurrentStateInFinishing(); |
|
4089 break; |
|
4090 // <MAPINFO_RESEND_MOD_BEGIN> |
|
4091 case EClientResendMapInfo: |
|
4092 // <MAPINFO_RESEND_MOD_END> |
|
4093 case EClientModifications: |
|
4094 state = EStateClientModification; |
|
4095 break; |
|
4096 case EServerModifications: |
|
4097 state = EStateServerModification; |
|
4098 break; |
|
4099 case EDataUpdateStatus: |
|
4100 state = EStateDataUpdateStatus; |
|
4101 break; |
|
4102 case EMapAcknowledge: |
|
4103 state = EStateMapAcknowledge; |
|
4104 break; |
|
4105 |
|
4106 case EClientAlertNext: |
|
4107 state=CurrentStateInClientAlertNext(); |
|
4108 break; |
|
4109 |
|
4110 case EServerAlertNext: |
|
4111 state=CurrentStateInServerAlertNext(); |
|
4112 break; |
|
4113 case ESending: |
|
4114 case EReceiving: |
|
4115 { |
|
4116 state=CurrentStateInReceiving(); |
|
4117 break; |
|
4118 } |
|
4119 default: |
|
4120 state = EStateNotStarted; |
|
4121 break; |
|
4122 |
|
4123 } |
|
4124 DBG_FILE_CODE(state,_S8("CNSmlDSAgent::CurrentStateInFinishing( )..Network failure check")); |
|
4125 if(state!=EStateNotStarted && iUpdateLastAnchor) |
|
4126 iUpdateLastAnchor=EFalse; |
|
4127 return state; |
|
4128 } |
|
4129 // ------------------------------------------------------------------------------------------------------------------ |
|
4130 // CNSmlDSAgent::ReadRepositoryL() |
|
4131 // |
|
4132 // ------------------------------------------------------------------------------------------------------------------ |
|
4133 void CNSmlDSAgent::ReadRepositoryL(TInt aKey, TInt& aValue) |
|
4134 { |
|
4135 const TUid KRepositoryId = KCRUidDataSyncInternalKeys; |
|
4136 |
|
4137 CRepository* rep = CRepository::NewLC(KRepositoryId); |
|
4138 TInt err = rep->Get(aKey, aValue); |
|
4139 User::LeaveIfError(err); |
|
4140 CleanupStack::PopAndDestroy(rep); |
|
4141 } |
|
4142 //RD_SUSPEND_RESUME |
|
4143 |
|
4144 //RD_AUTO_RESTART |
|
4145 // ------------------------------------------------------------------------------------------------------------------ |
|
4146 // CNSmlDSAgent::CheckProfileIdL() |
|
4147 // |
|
4148 // ------------------------------------------------------------------------------------------------------------------ |
|
4149 TBool CNSmlDSAgent::CheckProfileIdL() |
|
4150 { |
|
4151 DBG_FILE(_S8("CNSmlDSAgent::CheckProfileId() begins")); |
|
4152 |
|
4153 CNsmlProfileUtil* profileUtil = CNsmlProfileUtil::NewLC(); |
|
4154 profileUtil->InternalizeFromCenrepL(); |
|
4155 TInt cachedprofileId = profileUtil->ProfileId(); |
|
4156 CleanupStack::PopAndDestroy(profileUtil); |
|
4157 |
|
4158 DBG_FILE_CODE(iProfileID, _S8("CNSmlDSAgent::CheckProfileId() Profile ID is")); |
|
4159 DBG_FILE_CODE(cachedprofileId, _S8("CNSmlDSAgent::CheckProfileId() cached Profile ID is")); |
|
4160 |
|
4161 if(iProfileID == cachedprofileId) |
|
4162 { |
|
4163 return ETrue; |
|
4164 } |
|
4165 |
|
4166 else |
|
4167 { |
|
4168 return EFalse; |
|
4169 } |
|
4170 } |
|
4171 |
|
4172 // ------------------------------------------------------------------------------------------------------------------ |
|
4173 // CNSmlDSAgent::TerminateAutoRestart() |
|
4174 // |
|
4175 // ------------------------------------------------------------------------------------------------------------------ |
|
4176 void CNSmlDSAgent::TerminateAutoRestart() |
|
4177 { |
|
4178 DBG_FILE(_S8("CNSmlDSAgent::TerminateAutoRestart() begins")); |
|
4179 |
|
4180 TFullName processName; |
|
4181 TFindProcess process; |
|
4182 while ( process.Next( processName ) != KErrNotFound ) |
|
4183 { |
|
4184 //DBG_ARGS(_S("CNSmlDSAgent::TerminateAutoRestart() The Process name is %S"), &processName); |
|
4185 |
|
4186 if ( ( processName.Find( KAutoRestart ) != KErrNotFound ) ) |
|
4187 { |
|
4188 RProcess rprocess; |
|
4189 if (rprocess.Open(process, EOwnerProcess) == KErrNone) |
|
4190 { |
|
4191 DBG_FILE(_S8("CNSmlDSAgent::TerminateAutoRestart() Process is found, Killing the Process")); |
|
4192 rprocess.Terminate(KErrNone); |
|
4193 rprocess.Close(); |
|
4194 DBG_FILE(_S8("CNSmlDSAgent::TerminateAutoRestart() Process killed successfully")); |
|
4195 } |
|
4196 } |
|
4197 } |
|
4198 |
|
4199 DBG_FILE(_S8("CNSmlDSAgent::TerminateAutoRestart() ends")); |
|
4200 } |
|
4201 // ------------------------------------------------------------------------------------------------------------------ |
|
4202 // CNSmlDSAgent::IsSyncClientInitiated() |
|
4203 // |
|
4204 // ------------------------------------------------------------------------------------------------------------------ |
|
4205 TBool CNSmlDSAgent::IsSyncClientInitiated() |
|
4206 { |
|
4207 DBG_FILE_CODE(iSyncInitiation, _S8("CNSmlDSAgent::IsSyncClientInitiated() The Sync Initiation status is")); |
|
4208 |
|
4209 if(iSyncInitiation == EClientInitiated) |
|
4210 return ETrue; |
|
4211 else |
|
4212 return EFalse; |
|
4213 } |
|
4214 //RD_AUTO_RESTART |
|
4215 |
|
4216 // ------------------------------------------------------------------------------------------------------------------ |
|
4217 // CNSmlDSAgent::SetDSSessionInfoL() |
|
4218 // |
|
4219 // ------------------------------------------------------------------------------------------------------------------ |
|
4220 void CNSmlDSAgent::SetDSSessionInfoL(CNSmlDSProfile* aProfile) |
|
4221 { |
|
4222 |
|
4223 CRepository* rep = CRepository::NewLC(KNsmlDsSessionInfoKey); |
|
4224 TInt err = rep->Set(EDSSessionProfileId, aProfile->IntValue( EDSProfileId )); |
|
4225 err = rep->Set(EDSSessionProfileName, aProfile->StrValue( EDSProfileDisplayName )); |
|
4226 err = rep->Set(EDSSessionServerId, aProfile->StrValue( EDSProfileServerId )); |
|
4227 User::LeaveIfError(err); |
|
4228 CleanupStack::PopAndDestroy(rep); |
|
4229 |
|
4230 |
|
4231 } |
|
4232 |
|
4233 // ------------------------------------------------------------------------------------------------------------------ |
|
4234 // CNSmlDSAgent::ResetDSSessionInfoL() |
|
4235 // |
|
4236 // ------------------------------------------------------------------------------------------------------------------ |
|
4237 void CNSmlDSAgent::ResetDSSessionInfoL() |
|
4238 { |
|
4239 |
|
4240 CRepository* rep = CRepository::NewLC(KNsmlDsSessionInfoKey); |
|
4241 TInt err = rep->Set(EDSSessionProfileId, KErrNotFound); |
|
4242 err = rep->Set(EDSSessionProfileName, _L("")); |
|
4243 err = rep->Set(EDSSessionServerId, _L("")); |
|
4244 User::LeaveIfError(err); |
|
4245 CleanupStack::PopAndDestroy(rep); |
|
4246 } |
|
4247 |
|
4248 // End of file |