|
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: Implementation of DM UI component |
|
15 * This is part of omadmappui. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 |
|
22 #include <textresolver.h> // for CTextResolver |
|
23 #include <e32property.h> |
|
24 #include <data_caging_path_literals.hrh> // for resource and bitmap directories |
|
25 #include <SyncMLErr.h> // sync error codes |
|
26 #include <DevManInternalCRKeys.h> |
|
27 #include <centralrepository.h> |
|
28 #include <featmgr.h> |
|
29 #include "nsmldmsynchandler.h" |
|
30 #include "nsmldmsyncdebug.h" |
|
31 #include "nsmldmsyncinternalpskeys.h" |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CNSmlDMSyncHandler::NewL |
|
35 // |
|
36 // Two-phased constructor. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CNSmlDMSyncHandler* CNSmlDMSyncHandler::NewL( RSyncMLSession* aSyncSession, |
|
40 CNSmlDMSyncAppEngine* aAppEngine ) |
|
41 { |
|
42 FLOG( "CNSmlDMSyncHandler::NewL()" ); |
|
43 |
|
44 CNSmlDMSyncHandler* self = |
|
45 new (ELeave) CNSmlDMSyncHandler( aSyncSession, |
|
46 aAppEngine); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop(self); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // Destructor. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CNSmlDMSyncHandler::~CNSmlDMSyncHandler() |
|
58 { |
|
59 FLOG( "CNSmlDMSyncHandler::~CNSmlDMSyncHandler()" ); |
|
60 delete iActiveCaller; |
|
61 |
|
62 if ( iSyncRunning ) |
|
63 { |
|
64 TRAP_IGNORE( iSyncJob.StopL() ); |
|
65 iSyncJob.Close(); |
|
66 } |
|
67 FeatureManager::UnInitializeLib(); |
|
68 FLOG( "CNSmlDMSyncHandler::~CNSmlDMSyncHandler() completed" ); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CNSmlDMSyncHandler::ConstructL |
|
73 // Symbian 2nd phase constructor can leave. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CNSmlDMSyncHandler::ConstructL( void ) |
|
77 { |
|
78 FLOG( "CNSmlDMSyncHandler::ConstructL" ); |
|
79 FeatureManager::InitializeLibL(); |
|
80 iActiveCaller = CNSmlDMActiveCaller::NewL(this); |
|
81 iServerAlertedSync = EFalse; |
|
82 iSyncRunning = EFalse; |
|
83 iSyncError = KErrNone; |
|
84 iCheckUpdate = EFalse; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CNSmlDMSyncHandler::CNSmlDMSyncHandler |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CNSmlDMSyncHandler::CNSmlDMSyncHandler( RSyncMLSession* aSyncSession, |
|
92 CNSmlDMSyncAppEngine* aAppEngine) |
|
93 : iSyncSession( aSyncSession ), |
|
94 iSyncAppEngine( aAppEngine ) |
|
95 { |
|
96 } |
|
97 |
|
98 |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CNSmlDMSyncHandler::SynchronizeL |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CNSmlDMSyncHandler::SynchronizeL( TDesC& aServerName, |
|
105 const TInt aProfileId, |
|
106 const TInt aJobId, |
|
107 const TInt aConnectionBearer, |
|
108 const TBool aUseFotaProgressNote ) |
|
109 { |
|
110 FLOG( "CNSmlDMSyncHandler::SynchronizeL Server alert" ); |
|
111 |
|
112 iServerName = aServerName; |
|
113 iConnectionBearer = aConnectionBearer; |
|
114 iProfileId = aProfileId; |
|
115 iJobId = aJobId; |
|
116 iUseFotaProgressNote = aUseFotaProgressNote; |
|
117 |
|
118 iSyncJob.OpenL( Session(), iJobId ); |
|
119 iSyncJobId = iSyncJob.Identifier(); |
|
120 FTRACE( FPrint( _L( |
|
121 "[OMADM]\tCNSmlDMSyncHandler::SynchronizeL--server alert, iSyncJobId = %d" ), |
|
122 iSyncJobId ) ); |
|
123 //SAN Support |
|
124 iServerAlertedSync = ETrue; |
|
125 |
|
126 //SAN Support |
|
127 SynchronizeL(); |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CNSmlDMSyncHandler::SynchronizeL |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CNSmlDMSyncHandler::SynchronizeL( TDesC& aServerName, |
|
135 const TInt aProfileId, |
|
136 const TInt aConnectionBearer, |
|
137 const TBool aUseFotaProgressNote ) |
|
138 { |
|
139 FLOG( "CNSmlDMSyncHandler::SynchronizeL" ); |
|
140 |
|
141 iServerName = aServerName; |
|
142 iConnectionBearer = aConnectionBearer; |
|
143 iProfileId = aProfileId; |
|
144 iUseFotaProgressNote = aUseFotaProgressNote; |
|
145 |
|
146 iSyncJob.CreateL( Session(), iProfileId ); |
|
147 iSyncJobId = iSyncJob.Identifier(); |
|
148 SynchronizeL(); |
|
149 |
|
150 |
|
151 FTRACE( FPrint( _L( |
|
152 "[OMADM]\tCNSmlDMSyncHandler::SynchronizeL--UI initiated, iSyncJobId = %d" ), |
|
153 iSyncJobId ) ); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CNSmlDMSyncHandler::SynchronizeL |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CNSmlDMSyncHandler::SynchronizeL() |
|
161 { |
|
162 FLOG( "CNSmlDMSyncHandler::SynchronizeL" ); |
|
163 |
|
164 TInt err = KErrNone; |
|
165 |
|
166 // for MSyncMLEventObserver events |
|
167 TRAP( err, Session().RequestEventL(*this) ); |
|
168 if ( err != KErrNone ) |
|
169 { |
|
170 iSyncJob.StopL(); |
|
171 iSyncJob.Close(); |
|
172 User::Leave(err); |
|
173 } |
|
174 |
|
175 // for MSyncMLProgressObserver events |
|
176 TRAP( err, Session().RequestProgressL(*this) ); |
|
177 if ( err != KErrNone ) |
|
178 { |
|
179 Session().CancelEvent(); |
|
180 iSyncJob.StopL(); |
|
181 iSyncJob.Close(); |
|
182 User::Leave( err ); |
|
183 } |
|
184 |
|
185 |
|
186 |
|
187 TRAP( err, ShowProgressDialogL() ); |
|
188 if ( err != KErrNone ) |
|
189 { |
|
190 Session().CancelEvent(); |
|
191 Session().CancelProgress(); |
|
192 iSyncJob.StopL(); |
|
193 iSyncJob.Close(); |
|
194 User::Leave( err ); |
|
195 } |
|
196 FLOG( "CNSmlDMSyncHandler::SynchronizeL Sync is running" ); |
|
197 |
|
198 //iSyncDocument->MarkFwUpdChangesStartL(); |
|
199 |
|
200 iSyncRunning = ETrue; |
|
201 iSyncError = KErrNone; |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CNSmlDMSyncHandler::SynchronizeCompletedL |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void CNSmlDMSyncHandler::SynchronizeCompletedL( TInt aError ) |
|
209 { |
|
210 FTRACE( FPrint( |
|
211 _L("[OMADM]\t CNSmlDMSyncHandler::SynchronizeCompletedL(), aError = %d"), |
|
212 aError ) ); |
|
213 |
|
214 if ( !SyncRunning() ) |
|
215 { |
|
216 FLOG( "CNSmlDMSyncHandler::SynchronizeCompletedL already completed" ); |
|
217 return; // sync has already completed |
|
218 } |
|
219 |
|
220 iSyncJob.Close(); |
|
221 |
|
222 FTRACE( FPrint( _L( |
|
223 "[OMADM]\tCNSmlDMSyncHandler::SynchronizecompletedL, iSyncJobId = %d" ), |
|
224 KNSmlDMNoUserInitiatedJob ) ); |
|
225 |
|
226 iSyncRunning = EFalse; |
|
227 iSyncError = aError; |
|
228 iCheckUpdate = EFalse; |
|
229 |
|
230 iUseFotaProgressNote = EFalse; |
|
231 iSyncJob.Close(); |
|
232 |
|
233 // handle error in HandleActiveCallL (when active caller completes) |
|
234 iActiveCaller->Start( aError ); |
|
235 |
|
236 FLOG( "CNSmlDMSyncHandler::SynchronizeCompletedL() completed" ); |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CNSmlDMSyncHandler::OnSyncMLSessionEvent |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 void CNSmlDMSyncHandler::OnSyncMLSessionEvent( TEvent aEvent, |
|
244 TInt aIdentifier, |
|
245 TInt aError, |
|
246 TInt /*aAdditionalData*/ ) |
|
247 { |
|
248 FTRACE( FPrint( _L( |
|
249 "[OMADM]\tCNSmlDMSyncHandler::OnSyncMLSessionEvent(), aEvent = %d, aIdentifier = %d, aError = %d" ), |
|
250 aEvent, aIdentifier, aError ) ); |
|
251 FTRACE( RDebug::Print( _L( |
|
252 "[OMADM]\tCNSmlDMSyncHandler::OnSyncMLSessionEvent(), aEvent = %d, aIdentifier = %d, aError = %d" ), |
|
253 aEvent, aIdentifier, aError ) ); |
|
254 |
|
255 if ( aEvent == EJobStop |
|
256 || aEvent == EJobStartFailed |
|
257 || aEvent == EJobRejected ) |
|
258 { |
|
259 FTRACE( RDebug::Print( _L( |
|
260 "[OMADM]\tCNSmlDMSyncHandler::OnSyncMLSessionEvent(), iSyncJobId = %d" ), |
|
261 iSyncJobId ) ); |
|
262 FTRACE( FPrint( _L( |
|
263 "[OMADM]\tCNSmlDMSyncHandler::OnSyncMLSessionEvent(), iSyncJobId = %d" ), |
|
264 iSyncJobId ) ); |
|
265 |
|
266 if ( iSyncJobId == aIdentifier ) |
|
267 { |
|
268 FLOG( "CNSmlDMSyncHandler::OnSyncMLSessionEvent EJobStop close" ); |
|
269 |
|
270 TRAP_IGNORE( SynchronizeCompletedL( aError ) ); |
|
271 } |
|
272 } |
|
273 FLOG( "[OMADM]\tCNSmlDMSyncHandler::OnSyncMLSessionEvent() completed" ); |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CNSmlDMSyncHandler::OnSyncMLSyncError |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 void CNSmlDMSyncHandler::OnSyncMLSyncError( TErrorLevel aErrorLevel, |
|
281 TInt aError, |
|
282 TInt /*aTaskId*/, |
|
283 TInt /*aInfo1*/, |
|
284 TInt /*aInfo2*/) |
|
285 { |
|
286 FTRACE( FPrint( _L( |
|
287 "[OMADM]\tCNSmlDMSyncHandler::OnSyncMLSyncError(), aErrorLevel = %d, aError = %d"), |
|
288 aErrorLevel, aError ) ); |
|
289 FTRACE( RDebug::Print( |
|
290 _L("CNSmlDMSyncHandler::OnSyncMLSyncProgress aErrorLevel =(%d) aError =(%d)"), aErrorLevel, aError ) ); |
|
291 |
|
292 if ( aErrorLevel == ESmlFatalError ) |
|
293 { |
|
294 TRAP_IGNORE( SynchronizeCompletedL( aError ) ); |
|
295 } |
|
296 FLOG( "[OMADM]\tCNSmlDMSyncHandler::OnSyncMLSyncError() completed" ); |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // CNSmlDMSyncHandler::OnSyncMLSyncProgress |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 void CNSmlDMSyncHandler::OnSyncMLSyncProgress( TStatus aStatus, |
|
304 TInt /*aInfo1*/, |
|
305 TInt /*aInfo2*/ ) |
|
306 { |
|
307 FTRACE( RDebug::Print( |
|
308 _L("CNSmlDMSyncHandler::OnSyncMLSyncProgress (%d)"), aStatus ) ); |
|
309 |
|
310 switch (aStatus) |
|
311 { |
|
312 case ESmlConnecting: |
|
313 //State()->SetSyncPhase( CNSmlDMSyncState::EPhaseConnecting ); |
|
314 break; |
|
315 case ESmlConnected: |
|
316 break; |
|
317 case ESmlLoggingOn: |
|
318 break; |
|
319 case ESmlLoggedOn: |
|
320 |
|
321 break; |
|
322 case ESmlDisconnected: |
|
323 |
|
324 break; |
|
325 case ESmlCompleted: |
|
326 |
|
327 break; |
|
328 case ESmlProcessingServerCommands: |
|
329 |
|
330 break; |
|
331 case ESmlReceivingServerCommands: |
|
332 |
|
333 break; |
|
334 |
|
335 case ESmlSendingModificationsToServer: |
|
336 { |
|
337 break; |
|
338 } |
|
339 |
|
340 default: |
|
341 break; |
|
342 } |
|
343 } |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // CNSmlDMSyncHandler::OnSyncMLDataSyncModifications |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 void CNSmlDMSyncHandler::OnSyncMLDataSyncModifications( TInt /*aTaskId*/, |
|
350 const TSyncMLDataSyncModifications& /*aClientModifications*/, |
|
351 const TSyncMLDataSyncModifications& /*aServerModifications*/ ) |
|
352 { |
|
353 FLOG( "CNSmlDMSyncHandler::OnSyncMLDataSyncModifications" ); |
|
354 |
|
355 } |
|
356 |
|
357 // ----------------------------------------------------------------------------- |
|
358 // CNSmlDMSyncHandler::HandleActiveCallL |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 void CNSmlDMSyncHandler::HandleActiveCallL() |
|
362 { |
|
363 FLOG( "CNSmlDMSyncHandler::HandleActiveCallL" ); |
|
364 |
|
365 // HandleSyncErrorL will set this to true if |
|
366 // sync will be retried. |
|
367 iRetrySync = EFalse; |
|
368 |
|
369 if ( (iSyncError != KErrNone) && (iSyncError != KErrCancel) ) |
|
370 { |
|
371 TRAP_IGNORE( HandleSyncErrorL() ); |
|
372 } |
|
373 if ( iRetrySync == EFalse ) |
|
374 { |
|
375 // Inform parent that sync is done. |
|
376 iSyncAppEngine->SyncCompleted( ENSmlSyncComplete ); |
|
377 } |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CNSmlDMSyncHandler::HandleSyncErrorL |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 void CNSmlDMSyncHandler::HandleSyncErrorL() |
|
385 { |
|
386 FLOG( "CNSmlDMSyncHandler::HandleSyncErrorL" ); |
|
387 |
|
388 if ( iSyncError != KDMErr ) |
|
389 { |
|
390 } |
|
391 if ( ( iSyncError == SyncMLError::KErrAuthenticationFailure ) || |
|
392 ( iSyncError == SyncMLError::KErrTransportAuthenticationFailure ) ) |
|
393 { |
|
394 FLOG( "CNSmlDMSyncHandler::HandleSyncErrorL ask username" ); |
|
395 } |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // CNSmlDMSyncHandler::ShowProgressDialogL |
|
400 // ----------------------------------------------------------------------------- |
|
401 // |
|
402 void CNSmlDMSyncHandler::ShowProgressDialogL( ) |
|
403 { |
|
404 FLOG( "CNSmlDMSyncHandler::ShowProgressDialogL" ); |
|
405 |
|
406 FLOG( "CNSmlDMSyncHandler::ShowProgressDialogL() completed" ); |
|
407 } |
|
408 |
|
409 // ----------------------------------------------------------------------------- |
|
410 // CNSmlDMSyncHandler::HideProgressDialogL |
|
411 // ----------------------------------------------------------------------------- |
|
412 // |
|
413 void CNSmlDMSyncHandler::HideProgressDialogL() |
|
414 { |
|
415 FLOG( "CNSmlDMSyncHandler::HideProgressDialogL" ); |
|
416 } |
|
417 |
|
418 // ----------------------------------------------------------------------------- |
|
419 // CNSmlDMSyncHandler::Session |
|
420 // ----------------------------------------------------------------------------- |
|
421 // |
|
422 RSyncMLSession& CNSmlDMSyncHandler::Session() |
|
423 { |
|
424 __ASSERT_DEBUG(iSyncSession, TUtil::Panic(KErrGeneral)); |
|
425 |
|
426 return *iSyncSession; |
|
427 } |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // CNSmlDMSyncHandler::SyncRunning |
|
431 // ----------------------------------------------------------------------------- |
|
432 // |
|
433 TBool CNSmlDMSyncHandler::SyncRunning() |
|
434 { |
|
435 FTRACE( RDebug::Print( |
|
436 _L("CNSmlDMSyncHandler::SyncRunning status (%d)"), iSyncRunning ) ); |
|
437 |
|
438 return iSyncRunning; |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // CNSmlDMSyncHandler::CancelSynchronizeL |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CNSmlDMSyncHandler::CancelSynchronizeL() |
|
446 { |
|
447 FLOG( "CNSmlDMSyncHandler::CancelSynchronizeL" ); |
|
448 |
|
449 if ( iSyncRunning ) |
|
450 { |
|
451 iSyncJob.StopL(); |
|
452 SynchronizeCompletedL( KErrCancel ); |
|
453 } |
|
454 } |
|
455 |
|
456 // End of File |