author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:15:45 +0300 | |
branch | RCL_3 |
changeset 67 | 2abf74df9cdc |
parent 52 | 4f0867e42d62 |
permissions | -rw-r--r-- |
52 | 1 |
/* |
2 |
* Copyright (c) 2002-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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
// INCLUDES |
|
21 |
#include "AspSyncHandler.h" |
|
22 |
#include "AspDebug.h" |
|
23 |
#include "AspSettingDialog.h" |
|
24 |
||
25 |
#include <aspsyncutil.mbg> // for progress dialog bitmap enumerations |
|
26 |
||
27 |
#include <SyncMLErr.h> // sync error codes |
|
28 |
||
29 |
#include <ecom/ecom.h> |
|
30 |
#include <ecom/implementationinformation.h> |
|
31 |
#include <rconnmon.h> |
|
32 |
#include <e32std.h> //For TRequestStatus |
|
33 |
#include <e32property.h> |
|
34 |
#include "CPreSyncPlugin.h" |
|
35 |
#include "AspPreSyncPluginInterface.h" |
|
36 |
||
37 |
#include <DataSyncInternalPSKeys.h> |
|
67
2abf74df9cdc
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
38 |
|
52 | 39 |
|
40 |
/****************************************************************************** |
|
41 |
* class TAspSyncParam |
|
42 |
******************************************************************************/ |
|
43 |
||
44 |
||
45 |
// ------------------------------------------------------------------------------- |
|
46 |
// TAspSyncParam::TAspSyncParam |
|
47 |
// |
|
48 |
// ------------------------------------------------------------------------------- |
|
49 |
// |
|
50 |
TAspSyncParam::TAspSyncParam(TInt aApplicationId) |
|
51 |
: iApplicationId(aApplicationId), iProfileId(KErrNotFound), iJobId(KErrNotFound), |
|
52 |
iTaskId(KErrNotFound), iSyncDirection(KErrNotFound), iDialogMode(EModeDialogNoWait) |
|
53 |
{ |
|
54 |
} |
|
55 |
||
56 |
||
57 |
||
58 |
/****************************************************************************** |
|
59 |
* class CAspSyncHandler |
|
60 |
******************************************************************************/ |
|
61 |
||
62 |
||
63 |
// ----------------------------------------------------------------------------- |
|
64 |
// CAspSyncHandler::NewL |
|
65 |
// |
|
66 |
// ----------------------------------------------------------------------------- |
|
67 |
// |
|
68 |
CAspSyncHandler* CAspSyncHandler::NewL(const TAspParam& aParam) |
|
69 |
{ |
|
70 |
FLOG( _L("CAspSyncHandler::NewL START") ); |
|
71 |
||
72 |
CAspSyncHandler* self = new (ELeave) CAspSyncHandler(aParam); |
|
73 |
CleanupStack::PushL(self); |
|
74 |
self->ConstructL(); |
|
75 |
CleanupStack::Pop(self); |
|
76 |
||
77 |
FLOG( _L("CAspSyncHandler::NewL END") ); |
|
78 |
return self; |
|
79 |
} |
|
80 |
||
81 |
||
82 |
// ----------------------------------------------------------------------------- |
|
83 |
// Destructor |
|
84 |
// |
|
85 |
// ----------------------------------------------------------------------------- |
|
86 |
// |
|
87 |
CAspSyncHandler::~CAspSyncHandler() |
|
88 |
{ |
|
89 |
FLOG( _L("CAspSyncHandler::~CAspSyncHandler START") ); |
|
90 |
||
91 |
delete iProgressDialog; |
|
92 |
delete iState; |
|
93 |
delete iResHandler; |
|
94 |
delete iActiveCaller; |
|
95 |
delete iTextResolver; |
|
96 |
||
97 |
delete iContentList; |
|
98 |
||
99 |
if (iWait && iWait->IsStarted()) |
|
100 |
{ |
|
101 |
iWait->AsyncStop(); |
|
102 |
} |
|
103 |
delete iWait; |
|
104 |
||
105 |
RProperty::Delete(KPSUidNSmlDSSyncApp, KDsJobCancel); |
|
106 |
||
107 |
CloseSyncSession(); |
|
108 |
||
109 |
FLOG( _L("CAspSyncHandler::~CAspSyncHandler END") ); |
|
110 |
} |
|
111 |
||
112 |
||
113 |
// ----------------------------------------------------------------------------- |
|
114 |
// CAspSyncHandler::ConstructL |
|
115 |
// |
|
116 |
// ----------------------------------------------------------------------------- |
|
117 |
// |
|
118 |
void CAspSyncHandler::ConstructL() |
|
119 |
{ |
|
120 |
FLOG( _L("CAspSyncHandler::ConstructL START") ); |
|
121 |
||
122 |
iState = CAspState::NewL(); |
|
123 |
||
124 |
iActiveCaller = CAspActiveCaller::NewL(this); |
|
125 |
iTextResolver = CTextResolver::NewL(); |
|
126 |
||
127 |
iServerAlertSync = EFalse; |
|
128 |
iSyncRunning = EFalse; |
|
129 |
iSyncError = KErrNone; |
|
130 |
iCurrentSyncJobId = KErrNotFound; |
|
131 |
iSyncSessionOpen = EFalse; |
|
132 |
||
133 |
iWait = new (ELeave) CActiveSchedulerWait(); |
|
134 |
//Define property for cancel operation. |
|
135 |
static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); |
|
136 |
static _LIT_SECURITY_POLICY_C1(KAllowWriteDeviceDataPolicy, ECapabilityWriteDeviceData); |
|
137 |
RProperty::Define( KPSUidNSmlDSSyncApp,KDsJobCancel,RProperty::EInt, |
|
138 |
KAllowAllPolicy,KAllowWriteDeviceDataPolicy); |
|
139 |
RProperty::Set( KPSUidNSmlDSSyncApp, |
|
140 |
KDsJobCancel, KErrNone ); |
|
141 |
FLOG( _L("CAspSyncHandler::ConstructL END") ); |
|
142 |
} |
|
143 |
||
144 |
||
145 |
// ----------------------------------------------------------------------------- |
|
146 |
// CAspSyncHandler::CAspSyncHandler |
|
147 |
// |
|
148 |
// ----------------------------------------------------------------------------- |
|
149 |
// |
|
150 |
CAspSyncHandler::CAspSyncHandler(const TAspParam& /*aParam*/) |
|
151 |
{ |
|
152 |
} |
|
153 |
||
154 |
||
155 |
// ----------------------------------------------------------------------------- |
|
156 |
// CAspSyncHandler::SetObserver |
|
157 |
// |
|
158 |
// ----------------------------------------------------------------------------- |
|
159 |
// |
|
160 |
void CAspSyncHandler::SetObserver(MAspSyncObserver* aObserver) |
|
161 |
{ |
|
162 |
iSyncObserver = aObserver; |
|
163 |
} |
|
164 |
||
165 |
||
166 |
// ----------------------------------------------------------------------------- |
|
167 |
// CAspSyncHandler::HandleDialogEventL (from MAspProgressDialogObserver) |
|
168 |
// |
|
169 |
// |
|
170 |
// Canceling sequence after user presses "Cancel": |
|
171 |
// |
|
172 |
// 1. framework calls CAspProgressDialog2::OkToExitL |
|
173 |
// 2. OkToExitL calls CAspProgressDialog::DialogDismissedL |
|
174 |
// 3. DialogDismissedL calls CAspSyncHandler::HandleDialogEventL |
|
175 |
// 4. HandleDialogEventL cancels sync (RSyncMLDataSyncJob::StopL) |
|
176 |
// and updates progress dialog text ("Cancelling") |
|
177 |
// 5. MSyncMLEventObserver::EJobStop arrives (asynchronously) |
|
178 |
// and CAspProgressDialog is closed |
|
179 |
// |
|
180 |
// ----------------------------------------------------------------------------- |
|
181 |
// |
|
182 |
void CAspSyncHandler::HandleDialogEventL(TInt aButtonId) |
|
183 |
{ |
|
184 |
FLOG( _L("CAspSyncHandler::HandleDialogEventL START") ); |
|
185 |
||
186 |
TBool syncRunning = SyncRunning(); |
|
187 |
||
188 |
// close handling (eg. end key) |
|
189 |
if (aButtonId == EKeyPhoneEnd && syncRunning) |
|
190 |
{ |
|
191 |
//Set Cancel property when user cancel the Caopy All from Server. |
|
192 |
RProperty::Set( KPSUidNSmlDSSyncApp, |
|
193 |
KDsJobCancel, KErrCancel ); |
|
194 |
TRAPD(err, iSyncJob.StopL()); |
|
195 |
||
196 |
if (err != KErrNone) |
|
197 |
{ |
|
198 |
FLOG( _L("### RSyncMLDataSyncJob::StopL failed (%d) ###"), err ); |
|
199 |
} |
|
200 |
||
201 |
iSyncJob.Close(); // this can be done when job has not been opened |
|
202 |
||
203 |
CloseSyncSession(); |
|
204 |
||
205 |
iSyncRunning = EFalse; |
|
206 |
||
207 |
if (iIsSynchronousOperation && iWait->IsStarted()) |
|
208 |
{ |
|
209 |
iWait->AsyncStop(); |
|
210 |
} |
|
211 |
||
212 |
||
213 |
FLOG( _L("CAspSyncHandler::HandleDialogEventL: end key handling done") ); |
|
214 |
FLOG( _L("CAspSyncHandler::HandleDialogEventL END") ); |
|
215 |
return; |
|
216 |
} |
|
217 |
||
218 |
// cancel key handling |
|
219 |
if (aButtonId == EEikBidCancel && syncRunning) |
|
220 |
{ |
|
221 |
RProperty::Set( KPSUidNSmlDSSyncApp, |
|
222 |
KDsJobCancel, KErrCancel ); |
|
223 |
||
224 |
if (iStopEventReceived) |
|
225 |
{ |
|
226 |
CompleteWithDelay(KErrNone); |
|
227 |
FLOG( _L("### EJobStop already received ###") ); |
|
228 |
FLOG( _L("CAspSyncHandler::HandleDialogEventL END") ); |
|
229 |
return; |
|
230 |
} |
|
231 |
||
232 |
TInt jobId = CAspProfile::CurrentJob(&iSyncSession); |
|
233 |
if (jobId != iCurrentSyncJobId) |
|
234 |
{ |
|
235 |
CompleteWithDelay(KErrNotFound); |
|
236 |
||
237 |
FLOG( _L("### job conflict (%d/%d) ###"), iCurrentSyncJobId, jobId ); |
|
238 |
FLOG( _L("CAspSyncHandler::HandleDialogEventL END") ); |
|
239 |
return; |
|
240 |
} |
|
241 |
||
242 |
TRAPD(err, iSyncJob.StopL()); |
|
243 |
if (err != KErrNone) |
|
244 |
{ |
|
245 |
CompleteWithDelay(err); |
|
246 |
||
247 |
FLOG( _L("### RSyncMLDataSyncJob::StopL failed (%d) ###"), err ); |
|
248 |
FLOG( _L("CAspSyncHandler::HandleDialogEventL END") ); |
|
249 |
return; |
|
250 |
} |
|
251 |
||
252 |
State()->SetSyncPhase(CAspState::EPhaseCanceling); |
|
253 |
UpdateDialog(); |
|
254 |
||
255 |
FLOG( _L("CAspSyncHandler::HandleDialogEventL: cancel key handling done") ); |
|
256 |
} |
|
257 |
||
258 |
FLOG( _L("CAspSyncHandler::HandleDialogEventL END") ); |
|
259 |
} |
|
260 |
||
261 |
||
262 |
TBool CAspSyncHandler::IsRoamingL() |
|
263 |
{ |
|
264 |
RConnectionMonitor conMon; |
|
265 |
||
266 |
conMon.ConnectL(); |
|
267 |
||
268 |
TRequestStatus status; |
|
269 |
TInt registrationStatus(0); |
|
270 |
||
271 |
//check network status |
|
272 |
conMon.GetIntAttribute(EBearerIdGSM, 0, KNetworkRegistration, |
|
273 |
registrationStatus, status); |
|
274 |
||
275 |
User::WaitForRequest(status); |
|
276 |
conMon.Close(); |
|
277 |
||
278 |
if (registrationStatus == ENetworkRegistrationRoaming) |
|
279 |
{ |
|
280 |
return ETrue; |
|
281 |
} |
|
282 |
||
283 |
return EFalse; |
|
284 |
} |
|
285 |
||
286 |
// ----------------------------------------------------------------------------- |
|
287 |
// CAspSyncHandler::ReadRepositoryL |
|
288 |
// |
|
289 |
// ----------------------------------------------------------------------------- |
|
290 |
// |
|
291 |
void CAspSyncHandler::ReadRepositoryL(TInt aKey, TInt& aValue) |
|
292 |
{ |
|
293 |
CRepository* rep = CRepository::NewLC(KCRUidNSmlDSApp); |
|
294 |
TInt err = rep->Get(aKey, aValue); |
|
295 |
User::LeaveIfError(err); |
|
296 |
||
297 |
CleanupStack::PopAndDestroy(rep); |
|
298 |
} |
|
299 |
||
300 |
TInt CAspSyncHandler::BearerTypeL(TInt aProfileId) |
|
301 |
{ |
|
302 |
TInt BearerType = KErrNotFound; |
|
303 |
||
304 |
// sync session |
|
305 |
RSyncMLSession syncSession; |
|
306 |
syncSession.OpenL(); |
|
307 |
CleanupClosePushL( syncSession ); |
|
308 |
||
309 |
RSyncMLDataSyncProfile syncProfile; |
|
310 |
syncProfile.OpenL( syncSession, aProfileId, ESmlOpenRead ); |
|
311 |
CleanupClosePushL( syncProfile ); |
|
312 |
||
313 |
// Check if always ask is selected as accesspoint |
|
314 |
RSyncMLConnection connection; |
|
315 |
||
316 |
TInt err = KErrNone; |
|
317 |
RArray<TSmlTransportId> arr; |
|
318 |
||
319 |
TRAP(err, syncProfile.ListConnectionsL(arr)); |
|
320 |
if (err != KErrNone) |
|
321 |
{ |
|
322 |
syncProfile.Close(); |
|
323 |
CleanupStack::Pop( &syncProfile ); |
|
324 |
return KErrNotFound; |
|
325 |
} |
|
326 |
if (arr.Count() == 0) |
|
327 |
{ |
|
328 |
syncProfile.Close(); |
|
329 |
CleanupStack::Pop( &syncProfile ); |
|
330 |
arr.Close(); |
|
331 |
return KErrNotFound; // no connection |
|
332 |
} |
|
333 |
||
334 |
TInt transportId = arr[0]; |
|
335 |
arr.Close(); |
|
336 |
||
337 |
TRAP(err, connection.OpenL( syncProfile, transportId ) ); |
|
338 |
CleanupClosePushL( connection ); |
|
339 |
||
340 |
if ( err == KErrNone ) |
|
341 |
{ |
|
342 |
TInt id = connection.Identifier(); |
|
343 |
if (id == KUidNSmlMediumTypeInternet.iUid) |
|
344 |
{ |
|
345 |
BearerType = EAspBearerInternet; |
|
346 |
} |
|
347 |
else if (id == KUidNSmlMediumTypeBluetooth.iUid) |
|
348 |
{ |
|
349 |
BearerType = EAspBearerBlueTooth; |
|
350 |
} |
|
351 |
else if (id == KUidNSmlMediumTypeUSB.iUid) |
|
352 |
{ |
|
353 |
BearerType = EAspBearerUsb; |
|
354 |
} |
|
355 |
else if (id == KUidNSmlMediumTypeIrDA.iUid) |
|
356 |
{ |
|
357 |
BearerType = EAspBearerIrda; |
|
358 |
} |
|
359 |
} |
|
360 |
||
361 |
connection.Close(); |
|
362 |
CleanupStack::Pop( &connection ); |
|
363 |
||
364 |
syncProfile.Close(); |
|
365 |
CleanupStack::Pop( &syncProfile ); |
|
366 |
||
367 |
syncSession.Close(); |
|
368 |
CleanupStack::Pop( &syncSession ); |
|
369 |
return BearerType; |
|
370 |
} |
|
371 |
// ----------------------------------------------------------------------------- |
|
372 |
// CAspSyncHandler::SynchronizeL |
|
373 |
// |
|
374 |
// ----------------------------------------------------------------------------- |
|
375 |
// |
|
376 |
void CAspSyncHandler::SynchronizeL(TAspSyncParam& aSyncParam) |
|
377 |
{ |
|
378 |
iServerAlertSync = EFalse; |
|
379 |
iSyncRunning = EFalse; |
|
380 |
iCurrentSyncJobId = KErrNotFound; |
|
381 |
iSyncError = KErrNone; |
|
382 |
iCompleteEventReceived = EFalse; |
|
383 |
iStopEventReceived = EFalse; |
|
384 |
iIsSynchronousOperation = EFalse; |
|
385 |
TBool bCanSync = ETrue; |
|
386 |
||
387 |
TInt aValue = 0; |
|
388 |
ReadRepositoryL(KNSmlDSRoamingFeature, aValue); |
|
389 |
if(( IsRoamingL() ) && (aValue == EAspRoamingSettingFeatureEnabled)) |
|
390 |
{ |
|
391 |
TInt bearerType = BearerTypeL(aSyncParam.iProfileId); |
|
392 |
if (bearerType == EAspBearerInternet) |
|
393 |
{ |
|
394 |
CPreSyncPluginInterface* syncPluginInterface = CPreSyncPluginInterface::NewL(); |
|
395 |
CPreSyncPlugin* syncPlugin = |
|
396 |
syncPluginInterface->InstantiateRoamingPluginLC(aSyncParam.iProfileId); |
|
397 |
||
398 |
if(syncPlugin->IsSupported()) |
|
399 |
{ |
|
400 |
bCanSync = syncPlugin->CanSyncL(); |
|
401 |
} |
|
402 |
||
403 |
CleanupStack::PopAndDestroy(syncPlugin); |
|
404 |
//syncPluginInterface->UnloadPlugIns(); |
|
405 |
delete syncPluginInterface; |
|
406 |
||
407 |
if(!bCanSync) |
|
408 |
{ |
|
409 |
return; |
|
410 |
} |
|
411 |
} |
|
412 |
} |
|
413 |
||
414 |
State()->SetSyncPhase(CAspState::EPhaseConnecting); |
|
415 |
State()->ResetProgress(); |
|
416 |
//State()->SetTotalProgress(KTotalProgress); |
|
417 |
||
418 |
TRAPD(err, DoSynchronizeL(aSyncParam)); |
|
419 |
||
420 |
if (err != KErrNone) |
|
421 |
{ |
|
422 |
SynchronizeCompleted(err); |
|
423 |
return; |
|
424 |
} |
|
425 |
} |
|
426 |
||
427 |
||
428 |
// ----------------------------------------------------------------------------- |
|
429 |
// CAspSyncHandler::DoSynchronizeL |
|
430 |
// |
|
431 |
// ----------------------------------------------------------------------------- |
|
432 |
// |
|
433 |
void CAspSyncHandler::DoSynchronizeL(TAspSyncParam& aSyncParam) |
|
434 |
{ |
|
435 |
FLOG( _L("CAspSyncHandler::DoSynchronizeL START") ); |
|
436 |
||
437 |
//set the cancel Pub sub key to none |
|
438 |
if(aSyncParam.iSyncDirection == ESyncDirectionRefreshFromServer) |
|
439 |
{ |
|
440 |
RProperty::Set( KPSUidNSmlDSSyncApp, |
|
441 |
KDsJobCancel, KErrNone ); |
|
442 |
} |
|
443 |
iApplicationId = aSyncParam.iApplicationId; |
|
444 |
iProfileId = aSyncParam.iProfileId; |
|
445 |
if (aSyncParam.iDialogMode == EModeDialogWait) |
|
446 |
{ |
|
447 |
iIsSynchronousOperation = ETrue; // email 3.2 needs synchronous syncing |
|
448 |
} |
|
449 |
||
450 |
||
451 |
ShowProgressDialogL(); |
|
452 |
OpenSyncSessionL(); |
|
453 |
CreateContentListL(); |
|
454 |
||
455 |
iSyncSession.RequestEventL(*this); // for MSyncMLEventObserver events |
|
456 |
iSyncSession.RequestProgressL(*this); // for MSyncMLProgressObserver events |
|
457 |
||
458 |
if (aSyncParam.iTaskId != KErrNotFound && iProfileId != KErrNotFound) |
|
459 |
{ |
|
460 |
RArray<TSmlTaskId> arr(1); |
|
461 |
CleanupClosePushL(arr); |
|
462 |
User::LeaveIfError(arr.Append(aSyncParam.iTaskId)); |
|
463 |
if (aSyncParam.iSyncDirection != KErrNotFound) |
|
464 |
{ |
|
465 |
TSmlSyncType syncDirection = TAspTask::SmlSyncDirection(aSyncParam.iSyncDirection); |
|
466 |
iSyncJob.CreateL(iSyncSession, iProfileId, syncDirection, arr); |
|
467 |
} |
|
468 |
else |
|
469 |
{ |
|
470 |
iSyncJob.CreateL(iSyncSession, iProfileId, arr); |
|
471 |
} |
|
472 |
||
473 |
CleanupStack::PopAndDestroy(&arr); |
|
474 |
} |
|
475 |
else if (iProfileId != KErrNotFound) |
|
476 |
{ |
|
477 |
if (aSyncParam.iSyncDirection != KErrNotFound) |
|
478 |
{ |
|
479 |
TSmlSyncType syncDirection = TAspTask::SmlSyncDirection(aSyncParam.iSyncDirection); |
|
480 |
iSyncJob.CreateL(iSyncSession, iProfileId, syncDirection); |
|
481 |
} |
|
482 |
else |
|
483 |
{ |
|
484 |
iSyncJob.CreateL(iSyncSession, iProfileId); |
|
485 |
} |
|
486 |
} |
|
487 |
else |
|
488 |
{ |
|
489 |
User::Leave(KErrArgument); |
|
490 |
} |
|
491 |
||
492 |
iCurrentSyncJobId = iSyncJob.Identifier(); |
|
493 |
iSyncRunning = ETrue; |
|
494 |
||
495 |
if (iIsSynchronousOperation) |
|
496 |
{ |
|
497 |
iWait->Start(); // stop here until sync has completed |
|
498 |
} |
|
499 |
||
500 |
FLOG( _L("sync job created: app=%d, profile=%d, job=%d, task=%d"), iApplicationId, iProfileId, aSyncParam.iJobId, aSyncParam.iTaskId ); |
|
501 |
FLOG( _L("CAspSyncHandler::DoSynchronizeL END") ); |
|
502 |
} |
|
503 |
||
504 |
||
505 |
// ----------------------------------------------------------------------------- |
|
506 |
// CAspSyncHandler::SynchronizeCompleted |
|
507 |
// |
|
508 |
// ----------------------------------------------------------------------------- |
|
509 |
// |
|
510 |
void CAspSyncHandler::SynchronizeCompleted(TInt aError) |
|
511 |
{ |
|
512 |
FLOG( _L("CAspSyncHandler::SynchronizeCompleted START") ); |
|
513 |
||
514 |
iSyncRunning = EFalse; |
|
515 |
RProperty::Set( KPSUidNSmlDSSyncApp, |
|
516 |
KDsJobCancel, KErrNone ); |
|
517 |
if (aError != KErrNone) |
|
518 |
{ |
|
519 |
iSyncError = aError; |
|
520 |
} |
|
521 |
||
522 |
iSyncJob.Close(); // this can be done when job has not been opened |
|
523 |
||
524 |
TRAP_IGNORE(Dialog()->CancelProgressDialogL()); |
|
525 |
||
526 |
if (iSyncError != KErrNone) |
|
527 |
{ |
|
528 |
CloseSyncSession(); |
|
529 |
ShowErrorNote(); |
|
530 |
||
531 |
FLOG( _L("### sync failed (%d) ###"), iSyncError ); |
|
532 |
} |
|
533 |
else |
|
534 |
{ |
|
535 |
CloseSyncSession(); |
|
536 |
TRAP_IGNORE(TDialogUtil::ShowInformationNoteL(R_ASP_SYNC_COMPLETED)); |
|
537 |
} |
|
538 |
||
539 |
if (iSyncObserver) |
|
540 |
{ |
|
541 |
TRAP_IGNORE(iSyncObserver->HandleSyncEventL(iSyncError, iProfileId)); |
|
542 |
} |
|
543 |
||
544 |
if (iIsSynchronousOperation && iWait->IsStarted()) |
|
545 |
{ |
|
546 |
iWait->AsyncStop(); |
|
547 |
} |
|
548 |
||
549 |
FLOG( _L("CAspSyncHandler::SynchronizeCompleted END") ); |
|
550 |
} |
|
551 |
||
552 |
||
553 |
// ----------------------------------------------------------------------------- |
|
554 |
// CAspSyncHandler::OnSyncMLSessionEvent (from MSyncMLEventObserver) |
|
555 |
// |
|
556 |
// ----------------------------------------------------------------------------- |
|
557 |
// |
|
558 |
void CAspSyncHandler::OnSyncMLSessionEvent(TEvent aEvent, TInt aIdentifier, TInt aError, TInt /*aAdditionalData*/) |
|
559 |
{ |
|
560 |
FLOG( _L("CAspSyncHandler::OnSyncMLSessionEvent START") ); |
|
561 |
||
562 |
#ifdef _DEBUG |
|
563 |
LogSessionEvent(aEvent, aIdentifier, aError); |
|
564 |
#endif |
|
565 |
||
566 |
if (iCurrentSyncJobId != aIdentifier) |
|
567 |
{ |
|
568 |
FLOG( _L("### job conflict (%d/%d) ###"), iCurrentSyncJobId, aIdentifier ); |
|
569 |
FLOG( _L("CAspSyncHandler::OnSyncMLSessionEvent END") ); |
|
570 |
return; // not our sync job |
|
571 |
} |
|
572 |
||
573 |
if (aEvent == EJobStop) |
|
574 |
{ |
|
575 |
RProperty::Set( KPSUidNSmlDSSyncApp, |
|
576 |
KDsJobCancel, KErrNone ); |
|
577 |
||
578 |
iStopEventReceived = ETrue; |
|
579 |
if (aError != KErrNone) |
|
580 |
{ |
|
581 |
iSyncError = aError; |
|
582 |
} |
|
583 |
||
584 |
if (State()->SyncPhase() == CAspState::EPhaseCanceling) |
|
585 |
{ |
|
586 |
CompleteWithDelay(aError); |
|
587 |
} |
|
588 |
else if (iCompleteEventReceived || iSyncError != KErrNone) |
|
589 |
{ |
|
590 |
CompleteWithDelay(aError); |
|
591 |
} |
|
592 |
} |
|
593 |
||
594 |
if (aEvent == EJobStartFailed || aEvent == EJobRejected) |
|
595 |
{ |
|
596 |
RProperty::Set( KPSUidNSmlDSSyncApp, |
|
597 |
KDsJobCancel, KErrNone ); |
|
598 |
CompleteWithDelay(aError); |
|
599 |
} |
|
600 |
||
601 |
FLOG( _L("CAspSyncHandler::OnSyncMLSessionEvent END") ); |
|
602 |
} |
|
603 |
||
604 |
||
605 |
// ----------------------------------------------------------------------------- |
|
606 |
// CAspSyncHandler::CompleteWithDelay |
|
607 |
// |
|
608 |
// ----------------------------------------------------------------------------- |
|
609 |
// |
|
610 |
void CAspSyncHandler::CompleteWithDelay(TInt aError) |
|
611 |
{ |
|
612 |
iActiveCaller->Start(aError, 0); // call SynchronizeCompleted with delay |
|
613 |
} |
|
614 |
||
615 |
||
616 |
// ----------------------------------------------------------------------------- |
|
617 |
// CAspSyncHandler::OnSyncMLSyncError (from MSyncMLProgressObserver) |
|
618 |
// |
|
619 |
// ----------------------------------------------------------------------------- |
|
620 |
// |
|
621 |
void CAspSyncHandler::OnSyncMLSyncError(TErrorLevel aErrorLevel, TInt aError, TInt /*aTaskId*/, TInt /*aInfo1*/, TInt /*aInfo2*/) |
|
622 |
{ |
|
623 |
FLOG( _L("CAspSyncHandler::OnSyncMLSyncError START") ); |
|
624 |
||
625 |
// just store error code - sync is terminated only in function OnSyncMLSessionEvent |
|
626 |
if (aErrorLevel == ESmlFatalError || aErrorLevel == ESmlWarning) |
|
627 |
{ |
|
628 |
iSyncError = aError; |
|
629 |
} |
|
630 |
||
631 |
#ifdef _DEBUG |
|
632 |
LogErrorEvent(aErrorLevel, aError); |
|
633 |
#endif |
|
634 |
||
635 |
FLOG( _L("CAspSyncHandler::OnSyncMLSyncError END") ); |
|
636 |
} |
|
637 |
||
638 |
||
639 |
// ----------------------------------------------------------------------------- |
|
640 |
// CAspSyncHandler::OnSyncMLSyncProgress (from MSyncMLProgressObserver) |
|
641 |
// |
|
642 |
// ----------------------------------------------------------------------------- |
|
643 |
// |
|
644 |
void CAspSyncHandler::OnSyncMLSyncProgress(TStatus aStatus, TInt aInfo1, TInt /*aInfo2*/) |
|
645 |
{ |
|
646 |
FLOG( _L("CAspSyncHandler::OnSyncMLSyncProgress START") ); |
|
647 |
||
648 |
if (State()->SyncPhase() == CAspState::EPhaseCanceling) |
|
649 |
{ |
|
650 |
return; // no progress dialog updating while canceling |
|
651 |
} |
|
652 |
||
653 |
#ifdef _DEBUG |
|
654 |
LogProgressEvent(aStatus, aInfo1); |
|
655 |
#endif |
|
656 |
||
657 |
switch (aStatus) |
|
658 |
{ |
|
659 |
case ESmlConnecting: |
|
660 |
State()->SetSyncPhase(CAspState::EPhaseConnecting); |
|
661 |
UpdateDialog(); |
|
662 |
break; |
|
663 |
case ESmlConnected: |
|
664 |
break; |
|
665 |
case ESmlLoggingOn: |
|
666 |
break; |
|
667 |
case ESmlLoggedOn: |
|
668 |
State()->SetSyncPhase(CAspState::EPhaseSynchronizing); |
|
669 |
UpdateDialog(); |
|
670 |
break; |
|
671 |
case ESmlDisconnected: |
|
672 |
State()->SetSyncPhase(CAspState::EPhaseDisconnecting); |
|
673 |
UpdateDialog(); |
|
674 |
break; |
|
675 |
case ESmlCompleted: |
|
676 |
iCompleteEventReceived = ETrue; |
|
677 |
||
678 |
if (iStopEventReceived) |
|
679 |
{ |
|
680 |
FLOG( _L("### EJobStop already received ###") ); |
|
681 |
CompleteWithDelay(iSyncError); |
|
682 |
} |
|
683 |
else |
|
684 |
{ |
|
685 |
State()->SetSyncPhase(CAspState::EPhaseDisconnecting); |
|
686 |
UpdateDialog(); |
|
687 |
} |
|
688 |
break; |
|
689 |
||
690 |
case ESmlSendingModificationsToServer: |
|
691 |
State()->SetSyncPhase(CAspState::EPhaseSending); |
|
692 |
State()->ResetProgress(); |
|
693 |
State()->SetTotalProgress(aInfo1); // set total sync event count |
|
694 |
||
695 |
UpdateDialog(); |
|
696 |
break; |
|
697 |
case ESmlReceivingModificationsFromServer: |
|
698 |
State()->SetSyncPhase(CAspState::EPhaseReceiving); |
|
699 |
State()->ResetProgress(); |
|
700 |
State()->SetTotalProgress(aInfo1); // set total sync event count |
|
701 |
||
702 |
UpdateDialog(); |
|
703 |
break; |
|
704 |
||
705 |
case ESmlSendingMappingsToServer: |
|
706 |
State()->SetSyncPhase(CAspState::EPhaseSynchronizing); |
|
707 |
UpdateDialog(); |
|
708 |
break; |
|
709 |
||
710 |
default: |
|
711 |
break; |
|
712 |
} |
|
713 |
||
714 |
FLOG( _L("CAspSyncHandler::OnSyncMLSyncProgress END") ); |
|
715 |
} |
|
716 |
||
717 |
||
718 |
// ----------------------------------------------------------------------------- |
|
719 |
// CAspSyncHandler::OnSyncMLDataSyncModifications (from MSyncMLProgressObserver) |
|
720 |
// |
|
721 |
// ----------------------------------------------------------------------------- |
|
722 |
// |
|
723 |
void CAspSyncHandler::OnSyncMLDataSyncModifications(TInt aTaskId, |
|
724 |
const TSyncMLDataSyncModifications& aClientModifications, |
|
725 |
const TSyncMLDataSyncModifications& aServerModifications) |
|
726 |
{ |
|
727 |
||
728 |
if (!Dialog()->ProgressDialog()) |
|
729 |
{ |
|
730 |
//it is observed that some times this call back comes |
|
731 |
//just after deleting progress dialog. |
|
732 |
return; |
|
733 |
} |
|
734 |
||
735 |
TRAPD(err, OnSyncMLDataSyncModificationsL(aTaskId, aClientModifications, aServerModifications)); |
|
736 |
if (err != KErrNone) |
|
737 |
{ |
|
738 |
FLOG( _L("### CAspSyncHandler::OnSyncMLDataSyncModificationsL failed (%d) ###"), err ); |
|
739 |
FLOG( _L("### CAspSyncHandler::OnSyncMLDataSyncModificationsL failed (%d) ###"), err ); |
|
740 |
} |
|
741 |
} |
|
742 |
||
743 |
||
744 |
// ----------------------------------------------------------------------------- |
|
745 |
// CAspSyncHandler::OnSyncMLDataSyncModificationsL |
|
746 |
// |
|
747 |
// ----------------------------------------------------------------------------- |
|
748 |
// |
|
749 |
void CAspSyncHandler::OnSyncMLDataSyncModificationsL(TInt aTaskId, |
|
750 |
const TSyncMLDataSyncModifications& aClientModifications, |
|
751 |
const TSyncMLDataSyncModifications& aServerModifications) |
|
752 |
{ |
|
753 |
FLOG( _L("CAspSyncHandler::OnSyncMLDataSyncModificationsL START") ); |
|
754 |
||
755 |
||
756 |
if (State()->Progress() == 0) |
|
757 |
{ |
|
758 |
TInt index = iContentList->FindProviderIndexForTask(aTaskId); |
|
759 |
||
760 |
if (index != KErrNotFound) |
|
761 |
{ |
|
762 |
TAspProviderItem& item = iContentList->ProviderItem(index); |
|
763 |
HBufC* hBuf = CAspResHandler::GetContentNameLC(item.iDataProviderId, |
|
764 |
item.iDisplayName); |
|
765 |
State()->SetContentL(hBuf->Des()); |
|
766 |
||
767 |
#ifdef _DEBUG |
|
768 |
LogModificationEvent(aTaskId, hBuf->Des()); |
|
769 |
#endif |
|
770 |
||
771 |
CleanupStack::PopAndDestroy(hBuf); |
|
772 |
} |
|
773 |
else |
|
774 |
{ |
|
775 |
State()->SetContentL(KNullDesC); |
|
776 |
FLOG( _L("### task not found (%d) ###"), aTaskId ); |
|
777 |
} |
|
778 |
} |
|
779 |
||
780 |
// Set sync event count. On last OnSyncMLDataSyncModifications call it |
|
781 |
// must match total sync event count (set in OnSyncMLSyncProgress). |
|
782 |
TInt count = ProgressCount(aClientModifications, aServerModifications); |
|
783 |
State()->IncreaseProgress(count); |
|
784 |
||
785 |
UpdateDialog(); |
|
786 |
||
787 |
||
788 |
#ifdef _DEBUG |
|
789 |
LogModificationEvent(aTaskId, aClientModifications, aServerModifications); |
|
790 |
#endif |
|
791 |
||
792 |
||
793 |
FLOG( _L("CAspSyncHandler::OnSyncMLDataSyncModificationsL END") ); |
|
794 |
FLOG( _L(" ") ); |
|
795 |
} |
|
796 |
||
797 |
||
798 |
||
799 |
// ----------------------------------------------------------------------------- |
|
800 |
// CAspSyncHandler::UpdateDialog |
|
801 |
// |
|
802 |
// ----------------------------------------------------------------------------- |
|
803 |
// |
|
804 |
void CAspSyncHandler::UpdateDialog() |
|
805 |
{ |
|
806 |
TRAPD(err, UpdateDialogL()); |
|
807 |
||
808 |
if (err != KErrNone) |
|
809 |
{ |
|
810 |
FLOG( _L("### CAspSyncHandler::UpdateDialogL failed (%d) ###"), err ); |
|
811 |
} |
|
812 |
} |
|
813 |
||
814 |
||
815 |
// ----------------------------------------------------------------------------- |
|
816 |
// CAspSyncHandler::UpdateDialogL |
|
817 |
// |
|
818 |
// ----------------------------------------------------------------------------- |
|
819 |
// |
|
820 |
void CAspSyncHandler::UpdateDialogL() |
|
821 |
{ |
|
822 |
if (!SyncRunning()) |
|
823 |
{ |
|
824 |
FLOG( _L("### CAspSyncHandler::UpdateDialogL: Sync not running ###") ); |
|
825 |
return; |
|
826 |
} |
|
827 |
||
828 |
TInt phase = State()->SyncPhase(); |
|
829 |
||
830 |
if (phase == CAspState::EPhaseConnecting) |
|
831 |
{ |
|
832 |
Dialog()->StartAnimationL(); |
|
833 |
HBufC* hBuf = ResHandlerL()->ReadLC(R_SYNCSTATUS_SYNC_CONN); // "Connecting" |
|
834 |
Dialog()->UpdateTextL(hBuf->Des()); |
|
835 |
CleanupStack::PopAndDestroy(hBuf); |
|
836 |
} |
|
837 |
||
838 |
if (phase == CAspState::EPhaseSynchronizing) |
|
839 |
{ |
|
840 |
Dialog()->StartAnimationL(); |
|
841 |
HBufC* hBuf = ResHandlerL()->ReadLC(R_SYNCSTATUS_SYNC_SYNC); // "Synchronizing" |
|
842 |
Dialog()->UpdateTextL(hBuf->Des()); |
|
843 |
CleanupStack::PopAndDestroy(hBuf); |
|
844 |
} |
|
845 |
||
846 |
if (phase == CAspState::EPhaseDisconnecting) |
|
847 |
{ |
|
848 |
Dialog()->StartAnimationL(); |
|
849 |
HBufC* hBuf = ResHandlerL()->ReadLC(R_SYNCSTATUS_SYNC_DISC); // "Disconnecting" |
|
850 |
Dialog()->UpdateTextL(hBuf->Des()); |
|
851 |
CleanupStack::PopAndDestroy(hBuf); |
|
852 |
} |
|
853 |
||
854 |
if (phase == CAspState::EPhaseCanceling) |
|
855 |
{ |
|
856 |
Dialog()->StartAnimationL(); |
|
857 |
HBufC* hBuf = ResHandlerL()->ReadLC(R_SYNCSTATUS_CANC); // "Canceling" |
|
858 |
Dialog()->UpdateTextL(hBuf->Des()); |
|
859 |
CleanupStack::PopAndDestroy(hBuf); |
|
860 |
Dialog()->HideButtonL(); |
|
861 |
} |
|
862 |
||
863 |
//The number of Emails-Synced NOT printed if Sync is started from Sync E-mail Application |
|
864 |
if (iApplicationId == EApplicationIdEmail) |
|
865 |
return; |
|
866 |
||
867 |
if (phase == CAspState::EPhaseSending || phase == CAspState::EPhaseReceiving) |
|
868 |
{ |
|
869 |
if (State()->Progress() == 0 || State()->TotalProgress() == 0) |
|
870 |
{ |
|
871 |
return; |
|
872 |
} |
|
873 |
||
874 |
if (State()->FirstProgress()) |
|
875 |
{ |
|
876 |
if (State()->ProgressKnown()) |
|
877 |
{ |
|
878 |
Dialog()->CancelAnimation(); |
|
879 |
Dialog()->SetFinalProgress(State()->TotalProgress()); |
|
880 |
Dialog()->SetProgress(State()->Progress()); |
|
881 |
} |
|
882 |
else |
|
883 |
{ |
|
884 |
Dialog()->SetFinalProgress(0); |
|
885 |
Dialog()->StartAnimationL(); |
|
886 |
} |
|
887 |
} |
|
888 |
else if (State()->ProgressKnown()) |
|
889 |
{ |
|
890 |
Dialog()->SetProgress(State()->Progress()); |
|
891 |
} |
|
892 |
||
67
2abf74df9cdc
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
893 |
HBufC* hBuf = ResHandlerL()->ReadProgressTextLC(State()->Content(), phase); |
52 | 894 |
|
895 |
||
896 |
#ifdef _DEBUG |
|
897 |
TBuf<KBufSize> buf1; TBuf<KBufSize> buf2; |
|
898 |
buf1 = hBuf->Des(); |
|
899 |
buf2.Format(_L("%S\n (%d/%d)"), &buf1, State()->Progress(), State()->TotalProgress()); |
|
900 |
CleanupStack::PopAndDestroy(hBuf); |
|
901 |
hBuf = NULL; |
|
902 |
hBuf = buf2.AllocLC(); |
|
903 |
#endif |
|
904 |
||
905 |
||
906 |
Dialog()->UpdateTextL(hBuf->Des()); |
|
907 |
CleanupStack::PopAndDestroy(hBuf); |
|
908 |
} |
|
909 |
} |
|
910 |
||
911 |
||
912 |
// ----------------------------------------------------------------------------- |
|
913 |
// CAspSyncHandler::UpdateRequired |
|
914 |
// |
|
915 |
// ----------------------------------------------------------------------------- |
|
916 |
// |
|
917 |
TBool CAspSyncHandler::UpdateRequired() |
|
918 |
{ |
|
919 |
const TInt KProgressLevel_1 = 10; |
|
920 |
const TInt KProgressLevel_2 = 20; |
|
921 |
const TInt KProgressLevel_3 = 50; |
|
922 |
||
923 |
const TInt KProgressStep_1 = 5; |
|
924 |
const TInt KProgressStep_2 = 10; |
|
925 |
const TInt KProgressStep_3 = 20; |
|
926 |
||
927 |
TInt total = State()->TotalProgress(); |
|
928 |
TInt current = State()->Progress(); |
|
929 |
TBool firstProgress = State()->FirstProgress(); |
|
930 |
TBool progressKnown = State()->ProgressKnown(); |
|
931 |
||
932 |
// always show first progress |
|
933 |
if (firstProgress) |
|
934 |
{ |
|
935 |
return ETrue; |
|
936 |
} |
|
937 |
||
938 |
// handle case where total progress count is not known |
|
939 |
if (!progressKnown) |
|
940 |
{ |
|
941 |
if (current <= KProgressStep_2) |
|
942 |
{ |
|
943 |
return ETrue; |
|
944 |
} |
|
945 |
else if (current % KProgressStep_1 == 0) |
|
946 |
{ |
|
947 |
return ETrue; |
|
948 |
} |
|
949 |
||
950 |
return EFalse; |
|
951 |
} |
|
952 |
||
953 |
// handle case where total progress count is known |
|
954 |
if (current == total) |
|
955 |
{ |
|
956 |
return ETrue; // always show last progress |
|
957 |
} |
|
958 |
else if (total <= KProgressLevel_1) |
|
959 |
{ |
|
960 |
return ETrue; |
|
961 |
} |
|
962 |
else if (total > KProgressLevel_1 && total <= KProgressLevel_2) |
|
963 |
{ |
|
964 |
if (current % KProgressStep_1 == 0) |
|
965 |
{ |
|
966 |
return ETrue; |
|
967 |
} |
|
968 |
} |
|
969 |
else if (total > KProgressLevel_2 && total <= KProgressLevel_3) |
|
970 |
{ |
|
971 |
if (current % KProgressStep_2 == 0) |
|
972 |
{ |
|
973 |
return ETrue; |
|
974 |
} |
|
975 |
} |
|
976 |
else if (total > KProgressLevel_3) |
|
977 |
{ |
|
978 |
if (current % KProgressStep_3 == 0) |
|
979 |
{ |
|
980 |
return ETrue; |
|
981 |
} |
|
982 |
} |
|
983 |
||
984 |
return EFalse; |
|
985 |
} |
|
986 |
||
987 |
||
988 |
// ----------------------------------------------------------------------------- |
|
989 |
// CAspSyncHandler::HandleActiveCallL (from MAspActiveCallerObserver) |
|
990 |
// |
|
991 |
// ----------------------------------------------------------------------------- |
|
992 |
// |
|
993 |
void CAspSyncHandler::HandleActiveCallL(TInt aCallId) |
|
994 |
{ |
|
995 |
SynchronizeCompleted(aCallId); |
|
996 |
} |
|
997 |
||
998 |
||
999 |
// ----------------------------------------------------------------------------- |
|
1000 |
// CAspSyncHandler::ShowErrorNote |
|
1001 |
// |
|
1002 |
// ----------------------------------------------------------------------------- |
|
1003 |
// |
|
1004 |
void CAspSyncHandler::ShowErrorNote() |
|
1005 |
{ |
|
1006 |
if (iSyncError == KErrNone || iSyncError == KErrCancel) |
|
1007 |
{ |
|
1008 |
return; // nothing to show |
|
1009 |
} |
|
1010 |
||
1011 |
// show sync engine error |
|
1012 |
if (iSyncError <= SyncMLError::KErrSyncEngineErrorBase) |
|
1013 |
{ |
|
1014 |
HBufC* hBuf = NULL; |
|
1015 |
hBuf = TAspSyncError::GetSmlErrorText(iSyncError, 0); |
|
1016 |
if (hBuf) // hBuf can be NULL |
|
1017 |
{ |
|
1018 |
TRAP_IGNORE(TDialogUtil::ShowErrorQueryL(hBuf->Des())); |
|
1019 |
delete hBuf; |
|
1020 |
} |
|
1021 |
||
1022 |
return; |
|
1023 |
} |
|
1024 |
||
1025 |
// show system error |
|
1026 |
TPtrC errorMsg; |
|
1027 |
||
1028 |
errorMsg.Set(iTextResolver->ResolveErrorString(iSyncError, CTextResolver::ECtxNoCtxNoSeparator)); |
|
1029 |
||
1030 |
TRAP_IGNORE(TDialogUtil::ShowErrorQueryL(errorMsg)); |
|
1031 |
} |
|
1032 |
||
1033 |
// ----------------------------------------------------------------------------- |
|
1034 |
// CAspSyncHandler::ShowProgressDialogL |
|
1035 |
// |
|
1036 |
// ----------------------------------------------------------------------------- |
|
1037 |
// |
|
1038 |
void CAspSyncHandler::ShowProgressDialogL() |
|
1039 |
{ |
|
1040 |
delete iProgressDialog; |
|
1041 |
iProgressDialog = NULL; |
|
1042 |
iProgressDialog = CAspProgressDialog::NewL(this); |
|
1043 |
||
1044 |
TInt resId = R_SYNCSTATUS_SYNC_CONN; |
|
1045 |
if (iApplicationId == EApplicationIdEmail) |
|
1046 |
{ |
|
1047 |
resId = R_SYNCSTATUS_SYNC_SYNC; |
|
1048 |
} |
|
1049 |
||
1050 |
HBufC* hBuf = CAspResHandler::ReadLC(resId); |
|
1051 |
||
1052 |
iProgressDialog->SetApplicationId(iApplicationId); |
|
1053 |
||
1054 |
TFileName bitmapName; |
|
1055 |
CAspResHandler::GetBitmapFileName(bitmapName); |
|
1056 |
||
1057 |
iProgressDialog->LaunchProgressDialogL(hBuf->Des(), |
|
1058 |
KAknsIIDQgnNoteSml, |
|
1059 |
bitmapName, |
|
1060 |
EMbmAspsyncutilQgn_note_sml, |
|
1061 |
EMbmAspsyncutilQgn_note_sml_mask); |
|
1062 |
CleanupStack::PopAndDestroy(hBuf); |
|
1063 |
} |
|
1064 |
||
1065 |
||
1066 |
// ----------------------------------------------------------------------------- |
|
1067 |
// CAspSyncHandler::CreateContentListL |
|
1068 |
// |
|
1069 |
// ----------------------------------------------------------------------------- |
|
1070 |
// |
|
1071 |
void CAspSyncHandler::CreateContentListL() |
|
1072 |
{ |
|
1073 |
TAspParam param(iApplicationId, &iSyncSession); |
|
1074 |
||
1075 |
CAspProfile* profile = CAspProfile::NewLC(param); |
|
1076 |
profile->OpenL(iProfileId, CAspProfile::EOpenRead, CAspProfile::EBaseProperties); |
|
1077 |
||
1078 |
param.iProfile = profile; |
|
1079 |
param.iMode = CAspContentList::EInitAll; |
|
1080 |
||
1081 |
delete iContentList; |
|
1082 |
iContentList = NULL; |
|
1083 |
iContentList = CAspContentList::NewL(param); |
|
1084 |
||
1085 |
CleanupStack::PopAndDestroy(profile); |
|
1086 |
} |
|
1087 |
||
1088 |
||
1089 |
// ----------------------------------------------------------------------------- |
|
1090 |
// CAspSyncHandler::CheckLocalDatabaseL |
|
1091 |
// |
|
1092 |
// ----------------------------------------------------------------------------- |
|
1093 |
// |
|
1094 |
void CAspSyncHandler::CheckLocalDatabaseL(TInt aProfileId) |
|
1095 |
{ |
|
1096 |
TAspParam param(iApplicationId, &iSyncSession); |
|
1097 |
||
1098 |
CAspProfile* profile = CAspProfile::NewLC(param); |
|
1099 |
profile->OpenL(aProfileId, CAspProfile::EOpenRead, CAspProfile::EBaseProperties); |
|
1100 |
||
1101 |
TInt dataProviderId = KErrNotFound; |
|
1102 |
TBool databaseFound = TAspTask::CheckLocalDatabase(profile, dataProviderId); |
|
1103 |
CleanupStack::PopAndDestroy(profile); |
|
1104 |
||
1105 |
if (!databaseFound) |
|
1106 |
{ |
|
1107 |
User::Leave(SyncMLError::KErrClientDatabaseNotFound); |
|
1108 |
} |
|
1109 |
} |
|
1110 |
||
1111 |
||
1112 |
||
1113 |
// ----------------------------------------------------------------------------- |
|
1114 |
// CAspSyncHandler::Dialog |
|
1115 |
// |
|
1116 |
// ----------------------------------------------------------------------------- |
|
1117 |
// |
|
1118 |
CAspProgressDialog* CAspSyncHandler::Dialog() |
|
1119 |
{ |
|
1120 |
__ASSERT_DEBUG(iProgressDialog, TUtil::Panic(KErrGeneral)); |
|
1121 |
||
1122 |
return iProgressDialog; |
|
1123 |
} |
|
1124 |
||
1125 |
||
1126 |
// ----------------------------------------------------------------------------- |
|
1127 |
// CAspSyncHandler::State |
|
1128 |
// |
|
1129 |
// ----------------------------------------------------------------------------- |
|
1130 |
// |
|
1131 |
CAspState* CAspSyncHandler::State() |
|
1132 |
{ |
|
1133 |
__ASSERT_DEBUG(iState, TUtil::Panic(KErrGeneral)); |
|
1134 |
||
1135 |
return iState; |
|
1136 |
} |
|
1137 |
||
1138 |
||
1139 |
// ----------------------------------------------------------------------------- |
|
1140 |
// CAspSyncHandler::ResHandlerL |
|
1141 |
// |
|
1142 |
// ----------------------------------------------------------------------------- |
|
1143 |
// |
|
1144 |
CAspResHandler* CAspSyncHandler::ResHandlerL() |
|
1145 |
{ |
|
1146 |
if (!iResHandler) |
|
1147 |
{ |
|
1148 |
iResHandler = CAspResHandler::NewL(); |
|
1149 |
} |
|
1150 |
||
1151 |
return iResHandler; |
|
1152 |
} |
|
1153 |
||
1154 |
||
1155 |
// ----------------------------------------------------------------------------- |
|
1156 |
// SyncRunning |
|
1157 |
// |
|
1158 |
// ----------------------------------------------------------------------------- |
|
1159 |
// |
|
1160 |
TBool CAspSyncHandler::SyncRunning() |
|
1161 |
{ |
|
1162 |
return iSyncRunning; |
|
1163 |
} |
|
1164 |
||
1165 |
// ----------------------------------------------------------------------------- |
|
1166 |
// IsServerAlertSync |
|
1167 |
// |
|
1168 |
// ----------------------------------------------------------------------------- |
|
1169 |
// |
|
1170 |
TBool CAspSyncHandler::IsServerAlertSync() |
|
1171 |
{ |
|
1172 |
return iServerAlertSync; |
|
1173 |
} |
|
1174 |
||
1175 |
||
1176 |
// ----------------------------------------------------------------------------- |
|
1177 |
// OpenSyncSessionL |
|
1178 |
// |
|
1179 |
// ----------------------------------------------------------------------------- |
|
1180 |
// |
|
1181 |
void CAspSyncHandler::OpenSyncSessionL() |
|
1182 |
{ |
|
1183 |
if (!iSyncSessionOpen) |
|
1184 |
{ |
|
1185 |
TRAPD(err, iSyncSession.OpenL()); |
|
1186 |
||
1187 |
if (err != KErrNone) |
|
1188 |
{ |
|
1189 |
FLOG( _L("### CAspSyncHandler: RSyncMLSession::OpenL failed (%d) ###"), err ); |
|
1190 |
User::Leave(err); |
|
1191 |
} |
|
1192 |
||
1193 |
iSyncSessionOpen = ETrue; |
|
1194 |
} |
|
1195 |
} |
|
1196 |
||
1197 |
||
1198 |
// ----------------------------------------------------------------------------- |
|
1199 |
// CloseSyncSession |
|
1200 |
// |
|
1201 |
// ----------------------------------------------------------------------------- |
|
1202 |
// |
|
1203 |
void CAspSyncHandler::CloseSyncSession() |
|
1204 |
{ |
|
1205 |
if (iSyncSessionOpen) |
|
1206 |
{ |
|
1207 |
iSyncSession.Close(); |
|
1208 |
iSyncSessionOpen = EFalse; |
|
1209 |
} |
|
1210 |
} |
|
1211 |
||
1212 |
||
1213 |
// ----------------------------------------------------------------------------- |
|
1214 |
// ProgressCount |
|
1215 |
// |
|
1216 |
// ----------------------------------------------------------------------------- |
|
1217 |
// |
|
1218 |
TInt CAspSyncHandler::ProgressCount(const TSyncMLDataSyncModifications& aC, |
|
1219 |
const TSyncMLDataSyncModifications& aS) |
|
1220 |
{ |
|
1221 |
TInt num1 = aC.iNumAdded + aC.iNumReplaced + aC.iNumMoved + aC.iNumDeleted + aC.iNumFailed; |
|
1222 |
TInt num2 = aS.iNumAdded + aS.iNumReplaced + aS.iNumMoved + aS.iNumDeleted + aS.iNumFailed; |
|
1223 |
||
1224 |
return num1 + num2; |
|
1225 |
} |
|
1226 |
||
1227 |
||
1228 |
||
1229 |
#ifdef _DEBUG |
|
1230 |
||
1231 |
||
1232 |
// ----------------------------------------------------------------------------- |
|
1233 |
// LogModificationEvent |
|
1234 |
// |
|
1235 |
// ----------------------------------------------------------------------------- |
|
1236 |
// |
|
1237 |
void CAspSyncHandler::LogModificationEvent(TInt aTaskId, const TSyncMLDataSyncModifications& aC, const TSyncMLDataSyncModifications& aS) |
|
1238 |
{ |
|
1239 |
TInt num1 = State()->Progress(); |
|
1240 |
TInt num2 = State()->TotalProgress(); |
|
1241 |
||
1242 |
if (num1 > num2 && num2 != -1) |
|
1243 |
{ |
|
1244 |
FTRACE( RDebug::Print(_L("### syncui: task=%d, progress=%d, totalprogress=%d ###"), aTaskId, num1, num2) ); |
|
1245 |
FLOG(_L("### syncui: task=%d, progress=%d, totalprogress=%d ###"), aTaskId, num1, num2); |
|
1246 |
} |
|
1247 |
else |
|
1248 |
{ |
|
1249 |
FTRACE( RDebug::Print(_L("syncui: task=%d, progress=%d, totalprogress=%d"), aTaskId, num1, num2) ); |
|
1250 |
FLOG(_L("syncui: task=%d, progress=%d, totalprogress=%d"), aTaskId, num1, num2); |
|
1251 |
} |
|
1252 |
||
1253 |
num1 = aC.iNumAdded + aC.iNumReplaced + aC.iNumMoved + aC.iNumDeleted + aC.iNumFailed; |
|
1254 |
num2 = aS.iNumAdded + aS.iNumReplaced + aS.iNumMoved + aS.iNumDeleted + aS.iNumFailed; |
|
1255 |
||
1256 |
if ( (num1>0 && num2>0) || (num1<0 || num2<0) || (num1==0 && num2==0) ) |
|
1257 |
{ |
|
1258 |
FLOG( _L("### parameter error ###") ); |
|
1259 |
} |
|
1260 |
||
1261 |
FTRACE( RDebug::Print(_L("client: add=%d, rep=%d, mov=%d del=%d fai=%d"), aC.iNumAdded, aC.iNumReplaced, aC.iNumMoved, aC.iNumDeleted, aC.iNumFailed) ); |
|
1262 |
FTRACE( RDebug::Print(_L("server: add=%d, rep=%d, mov=%d del=%d fai=%d"), aS.iNumAdded, aS.iNumReplaced, aS.iNumMoved, aS.iNumDeleted, aS.iNumFailed) ); |
|
1263 |
||
1264 |
FLOG(_L("client: add=%d, rep=%d, mov=%d del=%d fai=%d"), aC.iNumAdded, aC.iNumReplaced, aC.iNumMoved, aC.iNumDeleted, aC.iNumFailed); |
|
1265 |
FLOG(_L("server: add=%d, rep=%d, mov=%d del=%d fai=%d"), aS.iNumAdded, aS.iNumReplaced, aS.iNumMoved, aS.iNumDeleted, aS.iNumFailed); |
|
1266 |
} |
|
1267 |
||
1268 |
||
1269 |
// ----------------------------------------------------------------------------- |
|
1270 |
// LogModificationEvent |
|
1271 |
// |
|
1272 |
// ----------------------------------------------------------------------------- |
|
1273 |
// |
|
1274 |
void CAspSyncHandler::LogModificationEvent(TInt aTaskId, const TDesC& aText) |
|
1275 |
{ |
|
1276 |
FTRACE( RDebug::Print(_L("progress = 0, task id = %d, task name ='%S'"), aTaskId, &aText) ); |
|
1277 |
FLOG(_L("progress = 0, task id = %d, task name ='%S'"), aTaskId, &aText); |
|
1278 |
} |
|
1279 |
||
1280 |
||
1281 |
// ----------------------------------------------------------------------------- |
|
1282 |
// LogSessionEvent |
|
1283 |
// |
|
1284 |
// ----------------------------------------------------------------------------- |
|
1285 |
// |
|
1286 |
void CAspSyncHandler::LogSessionEvent(TEvent& aEvent, TInt aIdentifier, TInt aError) |
|
1287 |
{ |
|
1288 |
TBuf<KBufSize> eventStr; |
|
1289 |
GetSyncEventText(eventStr, aEvent); |
|
1290 |
||
1291 |
TBuf<KBufSize> errStr; |
|
1292 |
TAspSyncError::GetSyncMLErrorText(errStr, aError); |
|
1293 |
||
1294 |
if (aError == KErrNone) |
|
1295 |
{ |
|
1296 |
FTRACE( RDebug::Print(_L("event='%S' err='%S' job= %d curjob= %d"), &eventStr, &errStr, aIdentifier, iCurrentSyncJobId) ); |
|
1297 |
FLOG(_L("event='%S' err='%S' job= %d curjob= %d"), &eventStr, &errStr, aIdentifier, iCurrentSyncJobId); |
|
1298 |
} |
|
1299 |
else |
|
1300 |
{ |
|
1301 |
FTRACE( RDebug::Print(_L("### event='%S' err='%S' job= %d curjob= %d ###"), &eventStr, &errStr, aIdentifier, iCurrentSyncJobId) ); |
|
1302 |
FLOG(_L("### event='%S' err='%S' job= %d curjob= %d ###"), &eventStr, &errStr, aIdentifier, iCurrentSyncJobId); |
|
1303 |
} |
|
1304 |
} |
|
1305 |
||
1306 |
||
1307 |
// ----------------------------------------------------------------------------- |
|
1308 |
// LogProgressEvent |
|
1309 |
// |
|
1310 |
// ----------------------------------------------------------------------------- |
|
1311 |
// |
|
1312 |
void CAspSyncHandler::LogProgressEvent(TStatus& aStatus, TInt aInfo1) |
|
1313 |
{ |
|
1314 |
TBuf<KBufSize> statusStr; |
|
1315 |
GetSyncStatusText(statusStr, aStatus); |
|
1316 |
FTRACE( RDebug::Print(_L("OnSyncMLSyncProgress: status = '%S' info1 = %d"), &statusStr, aInfo1) ); |
|
1317 |
FLOG(_L("OnSyncMLSyncProgress: status = '%S' info1 = %d"), &statusStr, aInfo1); |
|
1318 |
||
1319 |
TInt num1 = State()->Progress(); |
|
1320 |
TInt num2 = State()->TotalProgress(); |
|
1321 |
if (num1 != num2 && num2 != -1) |
|
1322 |
{ |
|
1323 |
FTRACE( RDebug::Print(_L("### progress count error (%d/%d) ###"), num1, num2) ); |
|
1324 |
FLOG(_L("### progress count error (%d/%d) ###"), num1, num2); |
|
1325 |
} |
|
1326 |
} |
|
1327 |
||
1328 |
||
1329 |
// ----------------------------------------------------------------------------- |
|
1330 |
// LogErrorEvent |
|
1331 |
// |
|
1332 |
// ----------------------------------------------------------------------------- |
|
1333 |
// |
|
1334 |
void CAspSyncHandler::LogErrorEvent(TErrorLevel aErrorLevel, TInt aError) |
|
1335 |
{ |
|
1336 |
TBuf<KBufSize> errStr; |
|
1337 |
TAspSyncError::GetSyncMLErrorText(errStr, aError); |
|
1338 |
||
1339 |
if (aErrorLevel == ESmlFatalError) |
|
1340 |
{ |
|
1341 |
FTRACE( RDebug::Print(_L("### OnSyncMLSyncError: fatalerror = %S ###"), &errStr) ); |
|
1342 |
FLOG(_L("### OnSyncMLSyncError: fatalerror = %S ###"), &errStr); |
|
1343 |
} |
|
1344 |
else |
|
1345 |
{ |
|
1346 |
FTRACE( RDebug::Print(_L("### OnSyncMLSyncError: error = %S ###"), &errStr) ); |
|
1347 |
FLOG(_L("### OnSyncMLSyncError: error = %S ###"), &errStr); |
|
1348 |
} |
|
1349 |
} |
|
1350 |
||
1351 |
||
1352 |
||
1353 |
// ----------------------------------------------------------------------------- |
|
1354 |
// GetSyncStatusText |
|
1355 |
// |
|
1356 |
// ----------------------------------------------------------------------------- |
|
1357 |
// |
|
1358 |
void CAspSyncHandler::GetSyncStatusText(TDes& aText, MSyncMLProgressObserver::TStatus aStatus) |
|
1359 |
{ |
|
1360 |
aText = _L("Unknown"); |
|
1361 |
||
1362 |
if (aStatus == MSyncMLProgressObserver::ESmlConnecting) |
|
1363 |
{ |
|
1364 |
aText = _L("ESmlConnecting"); |
|
1365 |
} |
|
1366 |
if (aStatus == MSyncMLProgressObserver::ESmlConnected) |
|
1367 |
{ |
|
1368 |
aText = _L("ESmlConnected"); |
|
1369 |
} |
|
1370 |
if (aStatus == MSyncMLProgressObserver::ESmlLoggingOn) |
|
1371 |
{ |
|
1372 |
aText = _L("ESmlLoggingOn"); |
|
1373 |
} |
|
1374 |
if (aStatus == MSyncMLProgressObserver::ESmlLoggedOn) |
|
1375 |
{ |
|
1376 |
aText = _L("ESmlLoggedOn"); |
|
1377 |
} |
|
1378 |
if (aStatus == MSyncMLProgressObserver::ESmlDisconnected) |
|
1379 |
{ |
|
1380 |
aText = _L("ESmlDisconnected"); |
|
1381 |
} |
|
1382 |
if (aStatus == MSyncMLProgressObserver::ESmlCompleted) |
|
1383 |
{ |
|
1384 |
aText = _L("ESmlCompleted"); |
|
1385 |
} |
|
1386 |
if (aStatus == MSyncMLProgressObserver::ESmlSendingModificationsToServer) |
|
1387 |
{ |
|
1388 |
aText = _L("ESmlSendingModificationsToServer"); |
|
1389 |
} |
|
1390 |
if (aStatus == MSyncMLProgressObserver::ESmlReceivingModificationsFromServer) |
|
1391 |
{ |
|
1392 |
aText = _L("ESmlReceivingModificationsFromServer"); |
|
1393 |
} |
|
1394 |
if (aStatus == MSyncMLProgressObserver::ESmlSendingMappingsToServer) |
|
1395 |
{ |
|
1396 |
aText = _L("ESmlSendingMappingsToServer"); |
|
1397 |
} |
|
1398 |
} |
|
1399 |
||
1400 |
||
1401 |
// ----------------------------------------------------------------------------- |
|
1402 |
// GetSyncEventText |
|
1403 |
// |
|
1404 |
// ----------------------------------------------------------------------------- |
|
1405 |
// |
|
1406 |
void CAspSyncHandler::GetSyncEventText(TDes& aText, MSyncMLEventObserver::TEvent aEvent) |
|
1407 |
{ |
|
1408 |
aText = _L("Unknown"); |
|
1409 |
||
1410 |
if (aEvent == MSyncMLEventObserver::EJobStart) |
|
1411 |
{ |
|
1412 |
aText = _L("EJobStart"); |
|
1413 |
} |
|
1414 |
if (aEvent == MSyncMLEventObserver::EJobStartFailed) |
|
1415 |
{ |
|
1416 |
aText = _L("EJobStartFailed"); |
|
1417 |
} |
|
1418 |
if (aEvent == MSyncMLEventObserver::EJobStop) |
|
1419 |
{ |
|
1420 |
aText = _L("EJobStop"); |
|
1421 |
} |
|
1422 |
if (aEvent == MSyncMLEventObserver::EJobRejected) |
|
1423 |
{ |
|
1424 |
aText = _L("EJobRejected"); |
|
1425 |
} |
|
1426 |
if (aEvent == MSyncMLEventObserver::EProfileCreated) |
|
1427 |
{ |
|
1428 |
aText = _L("EProfileCreated"); |
|
1429 |
} |
|
1430 |
if (aEvent == MSyncMLEventObserver::EProfileChanged) |
|
1431 |
{ |
|
1432 |
aText = _L("EProfileChanged"); |
|
1433 |
} |
|
1434 |
if (aEvent == MSyncMLEventObserver::EProfileDeleted) |
|
1435 |
{ |
|
1436 |
aText = _L("EProfileDeleted"); |
|
1437 |
} |
|
1438 |
if (aEvent == MSyncMLEventObserver::ETransportTimeout) |
|
1439 |
{ |
|
1440 |
aText = _L("ETransportTimeout"); |
|
1441 |
} |
|
1442 |
if (aEvent == MSyncMLEventObserver::EServerSuspended) |
|
1443 |
{ |
|
1444 |
aText = _L("EServerSuspended"); |
|
1445 |
} |
|
1446 |
if (aEvent == MSyncMLEventObserver::EServerTerminated) |
|
1447 |
{ |
|
1448 |
aText = _L("EServerTerminated"); |
|
1449 |
} |
|
1450 |
} |
|
1451 |
||
1452 |
#endif |
|
1453 |
||
1454 |
||
1455 |
||
1456 |
||
1457 |
||
1458 |
// End of file |
|
1459 |