25
|
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: Synchronization handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef NSMLDMSYNCHANDLER_H
|
|
20 |
#define NSMLDMSYNCHANDLER_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <AknProgressDialog.h>
|
|
25 |
#include <SyncMLObservers.h>
|
|
26 |
#include "NSmlDMProgress.h"
|
|
27 |
#include "NSmlDMSyncUtil.h"
|
|
28 |
#include "NSmlDMSyncProfile.h"
|
|
29 |
|
|
30 |
// FORWARD DECLARATIONS
|
|
31 |
class CNSmlDMSyncState;
|
|
32 |
class CNSmlDMActiveCaller;
|
|
33 |
class CEikonEnv;
|
|
34 |
class CNSmlDMSyncDocument;
|
|
35 |
class CAknWaitDialog;
|
|
36 |
|
|
37 |
// CLASS DECLARATION
|
|
38 |
|
|
39 |
/**
|
|
40 |
* CNSmlDMSyncHandler class
|
|
41 |
*
|
|
42 |
*/
|
|
43 |
NONSHARABLE_CLASS (CNSmlDMSyncHandler) : public CBase,
|
|
44 |
public MNSmlDMProgressDialogObserver,
|
|
45 |
public MNSmlDMActiveCallerObserver,
|
|
46 |
public MSyncMLEventObserver,
|
|
47 |
public MSyncMLProgressObserver,
|
|
48 |
public MProgressDialogCallback
|
|
49 |
|
|
50 |
{
|
|
51 |
public:
|
|
52 |
/**
|
|
53 |
* Two-phased constructor.
|
|
54 |
*/
|
|
55 |
static CNSmlDMSyncHandler* NewL( RSyncMLSession* aSyncSession,
|
|
56 |
CNSmlDMSyncAppEngine* aAppEngine,
|
|
57 |
CNSmlDMSyncDocument* aSyncDocument );
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Destructor.
|
|
61 |
*/
|
|
62 |
virtual ~CNSmlDMSyncHandler();
|
|
63 |
|
|
64 |
private:
|
|
65 |
/**
|
|
66 |
* By default Symbian 2nd phase constructor is private.
|
|
67 |
*/
|
|
68 |
void ConstructL();
|
|
69 |
|
|
70 |
/**
|
|
71 |
* C++ default constructor.
|
|
72 |
*/
|
|
73 |
CNSmlDMSyncHandler( RSyncMLSession* iSyncSession,
|
|
74 |
CNSmlDMSyncAppEngine* aAppEngine,
|
|
75 |
CNSmlDMSyncDocument* aSyncDocument );
|
|
76 |
|
|
77 |
|
|
78 |
private:
|
|
79 |
/**
|
|
80 |
* From MAspProgressDialogObserver
|
|
81 |
* Gets called when sync progress dialog closes.
|
|
82 |
* @param aButtonId Button id.
|
|
83 |
* @return None
|
|
84 |
*/
|
|
85 |
void HandleDialogEventL( TInt aButtonId );
|
|
86 |
|
|
87 |
|
|
88 |
private: // from MAspActiveCallerObserver
|
|
89 |
/**
|
|
90 |
* From MAspActiveCallerObserver
|
|
91 |
* Called when CAspActiveCaller completes.
|
|
92 |
* @param None
|
|
93 |
* @return None.
|
|
94 |
*/
|
|
95 |
void HandleActiveCallL();
|
|
96 |
|
|
97 |
|
|
98 |
private: // from MSyncMLEventObserver
|
|
99 |
|
|
100 |
/**
|
|
101 |
* From MSyncMLEventObserver
|
|
102 |
* Called when SyncML session events oocur.
|
|
103 |
* @param aEvent Sync event
|
|
104 |
* @param aIdentifier Identifier for the sync event
|
|
105 |
* @param aError Synce event error
|
|
106 |
* @param aAdditionalData.
|
|
107 |
* @return None.
|
|
108 |
*/
|
|
109 |
void OnSyncMLSessionEvent( TEvent aEvent,
|
|
110 |
TInt aIdentifier,
|
|
111 |
TInt aError,
|
|
112 |
TInt aAdditionalData );
|
|
113 |
|
|
114 |
|
|
115 |
private: //from MSyncMLProgressObserver
|
|
116 |
|
|
117 |
/**
|
|
118 |
* Receives notification of a synchronisation error.
|
|
119 |
* @param aErrorLevel The error level.
|
|
120 |
* @param aError The type of error. This is one of
|
|
121 |
* the SyncMLError error values.
|
|
122 |
* @param aTaskId The ID of the task for which the error occurred.
|
|
123 |
* @param aInfo1 An integer that can contain additional
|
|
124 |
* information about the error. Normally 0.
|
|
125 |
* @param aInfo2 An integer that can contain additional
|
|
126 |
* information about the error. Normally 0.
|
|
127 |
* @return None.
|
|
128 |
*/
|
|
129 |
void OnSyncMLSyncError( TErrorLevel aErrorLevel,
|
|
130 |
TInt aError,
|
|
131 |
TInt aTaskId,
|
|
132 |
TInt aInfo1,
|
|
133 |
TInt aInfo2 );
|
|
134 |
|
|
135 |
/**
|
|
136 |
* Receives notification of synchronisation progress.
|
|
137 |
* @param aStatus The current status, e.g. 'Connecting'.
|
|
138 |
* @param aInfo1 An integer that can contain additional
|
|
139 |
* information about the progress.
|
|
140 |
* @param aInfo2 An integer that can contain additional
|
|
141 |
* information about the progress.
|
|
142 |
*/
|
|
143 |
void OnSyncMLSyncProgress( TStatus aStatus, TInt aInfo1, TInt aInfo2);
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Receives notification of modifications to synchronisation tasks.
|
|
147 |
* @param aTaskId The ID of the task.
|
|
148 |
* @param aClientModifications Modifications made on
|
|
149 |
* the clients Data Store.
|
|
150 |
* @param aServerModifications Modifications made on
|
|
151 |
* the server Data Store.
|
|
152 |
*/
|
|
153 |
void OnSyncMLDataSyncModifications(
|
|
154 |
TInt /*aTaskId*/,
|
|
155 |
const TSyncMLDataSyncModifications& aClientModifications,
|
|
156 |
const TSyncMLDataSyncModifications& aServerModifications );
|
|
157 |
|
|
158 |
private:
|
|
159 |
|
|
160 |
/**
|
|
161 |
* Shows error dialog.
|
|
162 |
* @param None.
|
|
163 |
* @return Error code.
|
|
164 |
*/
|
|
165 |
void HandleSyncErrorL();
|
|
166 |
|
|
167 |
/**
|
|
168 |
* Called when sync completes
|
|
169 |
* @param aError.
|
|
170 |
* @return None.
|
|
171 |
*/
|
|
172 |
void SynchronizeCompletedL(TInt aError);
|
|
173 |
|
|
174 |
/**
|
|
175 |
* Gets sync error text.
|
|
176 |
* @param aError.
|
|
177 |
* @return Error text.
|
|
178 |
*/
|
|
179 |
void GetErrorText( TDes& aErrorText,
|
|
180 |
TInt aErrorCode,
|
|
181 |
TInt aTransport );
|
|
182 |
|
|
183 |
/**
|
|
184 |
* Read sync error from CNSmlSyncLog and show error message.
|
|
185 |
* @param aProfileId Profile id.
|
|
186 |
* @return Result code.
|
|
187 |
*/
|
|
188 |
TInt HandleSyncErrorL(TInt aProfileId);
|
|
189 |
|
|
190 |
/**
|
|
191 |
* Set synchronisation error message text.
|
|
192 |
* @param aError Error code.
|
|
193 |
* @param aMsg Error text.
|
|
194 |
* @return None.
|
|
195 |
*/
|
|
196 |
void SetErrorMessageL(TInt aError, TDes& aMsg);
|
|
197 |
|
|
198 |
|
|
199 |
public:
|
|
200 |
/**
|
|
201 |
* Performs synchronization.
|
|
202 |
* @param aServerName Name of the server
|
|
203 |
* @param aProfileId Profile identifier.
|
|
204 |
* @param aConnectionBearer Bearer
|
|
205 |
* @param aUseFotaProgressNote Should the simplified progress note used. Only
|
|
206 |
* used when checking for firmware updates.
|
|
207 |
* @return None
|
|
208 |
*/
|
|
209 |
void SynchronizeL( TDesC& aServerName,
|
|
210 |
const TInt aProfileId,
|
|
211 |
const TInt aConnectionBearer,
|
|
212 |
const TBool aUseFotaProgressNote );
|
|
213 |
|
|
214 |
/**
|
|
215 |
* Performs ServerInitiated synchronization.
|
|
216 |
* @param aServerName Name of the server
|
|
217 |
* @param aProfileId Profile id
|
|
218 |
* @param aJobId Job id.
|
|
219 |
* @param aConnectionBearer Bearer
|
|
220 |
* @param aUseFotaProgressNote Should the simplified progress note used. Only
|
|
221 |
* used when checking for firmware updates.
|
|
222 |
* @return None
|
|
223 |
*/
|
|
224 |
void SynchronizeL( TDesC& aServerName,
|
|
225 |
const TInt aProfileId,
|
|
226 |
const TInt aJobId,
|
|
227 |
const TInt aConnectionBearer,
|
|
228 |
const TBool aUseFotaProgressNote,
|
|
229 |
const TBool aSilent);
|
|
230 |
|
|
231 |
/**
|
|
232 |
* Shows the progress dialog.
|
|
233 |
* @param None.
|
|
234 |
* @return None.
|
|
235 |
*/
|
|
236 |
void ShowProgressDialogL();
|
|
237 |
|
|
238 |
/**
|
|
239 |
* Deletes the progress dialog if it exists.
|
|
240 |
* @param None.
|
|
241 |
* @return None.
|
|
242 |
*/
|
|
243 |
void HideProgressDialogL();
|
|
244 |
|
|
245 |
/**
|
|
246 |
* Cancel synchronization.
|
|
247 |
* @param None
|
|
248 |
* @return None
|
|
249 |
*/
|
|
250 |
void CancelSynchronizeL();
|
|
251 |
|
|
252 |
/**
|
|
253 |
* From MProgressDialogCallback. Handles the situation when the dialog
|
|
254 |
* is dismissed.
|
|
255 |
* @param aButtonId The identifier of the button, with which the dialog
|
|
256 |
* was dismissed.
|
|
257 |
* @return None
|
|
258 |
*/
|
|
259 |
void DialogDismissedL( TInt aButtonId );
|
|
260 |
|
|
261 |
private:
|
|
262 |
|
|
263 |
/**
|
|
264 |
* Performs synchronization.
|
|
265 |
* @return None
|
|
266 |
*/
|
|
267 |
void SynchronizeL();
|
|
268 |
|
|
269 |
/**
|
|
270 |
* Utility function.
|
|
271 |
* @return Sync session.
|
|
272 |
*/
|
|
273 |
RSyncMLSession& Session();
|
|
274 |
|
|
275 |
/**
|
|
276 |
* Utility function.
|
|
277 |
* @return Progress dialog.
|
|
278 |
*/
|
|
279 |
CNSmlDMProgressDialog* Dialog();
|
|
280 |
|
|
281 |
/**
|
|
282 |
* Utility function.
|
|
283 |
* @return Sync state.
|
|
284 |
*/
|
|
285 |
CNSmlDMSyncState* State();
|
|
286 |
|
|
287 |
public:
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Starts synchronization.
|
|
291 |
* @return None
|
|
292 |
*/
|
|
293 |
void StartSynchronizeL();
|
|
294 |
/**
|
|
295 |
* Utility function.
|
|
296 |
* @return ETrue if sync is currently running, EFalse otherwise.
|
|
297 |
*/
|
|
298 |
TBool SyncRunning();
|
|
299 |
|
|
300 |
private:
|
|
301 |
|
|
302 |
/**
|
|
303 |
* Checks the progress state and returns a corresponding
|
|
304 |
* dialog text string.
|
|
305 |
* @param Reference to the descriptor where the result is stored.
|
|
306 |
* @return None.
|
|
307 |
*/
|
|
308 |
void GetStatusDialogTextL( TDes& aBuffer );
|
|
309 |
|
|
310 |
/**
|
|
311 |
* Updates progress dialog.
|
|
312 |
* @param None.
|
|
313 |
* @return None.
|
|
314 |
*/
|
|
315 |
void UpdateDialogL();
|
|
316 |
|
|
317 |
/**
|
|
318 |
* Utility function.
|
|
319 |
* @param aText text to show
|
|
320 |
* @param aResourceId resource id
|
|
321 |
* @return None.
|
|
322 |
*/
|
|
323 |
void ReadL( TDes& aText, TInt aResourceId );
|
|
324 |
|
|
325 |
/**
|
|
326 |
* Utility function.
|
|
327 |
* @param aText text to show
|
|
328 |
* @param aContent
|
|
329 |
* @param aCurrent Progress phase
|
|
330 |
* @param aFinal Progress phase
|
|
331 |
* @param aPhase Progress phase
|
|
332 |
* @return None.
|
|
333 |
*/
|
|
334 |
void ReadProgressTextL( TDes& aText,
|
|
335 |
const TDesC& aContent,
|
|
336 |
TInt aCurrent,
|
|
337 |
TInt aFinal,
|
|
338 |
TInt aPhase );
|
|
339 |
|
|
340 |
private:
|
|
341 |
// session with sync server
|
|
342 |
RSyncMLSession* iSyncSession;
|
|
343 |
// app engine
|
|
344 |
CNSmlDMSyncAppEngine* iSyncAppEngine;
|
|
345 |
// Pointer to the application document class
|
|
346 |
CNSmlDMSyncDocument* iSyncDocument;
|
|
347 |
// profile id
|
|
348 |
TInt iProfileId;
|
|
349 |
// sync job id
|
|
350 |
TInt iSyncJobId;
|
|
351 |
// sync job
|
|
352 |
RSyncMLDevManJob iSyncJob;
|
|
353 |
// shows sync progress dialog
|
|
354 |
CNSmlDMProgressDialog* iProgressDialog;
|
|
355 |
|
|
356 |
// The alternative wait dialog used in FOTA
|
|
357 |
CAknWaitDialog* iWaitDialog;
|
|
358 |
|
|
359 |
// The progress wait dialog used for any session from main view
|
|
360 |
CNSmlDMProgressDialog* iFotaProgressDialog;
|
|
361 |
|
|
362 |
// CheckUpdate state shown or Not
|
|
363 |
TBool iCheckUpdate;
|
|
364 |
|
|
365 |
// sync handler state
|
|
366 |
CNSmlDMSyncState* iState;
|
|
367 |
// for making function call via active scheduler
|
|
368 |
CNSmlDMActiveCaller* iActiveCaller;
|
|
369 |
// is sync currently running
|
|
370 |
TBool iSyncRunning;
|
|
371 |
// sync error code
|
|
372 |
TInt iSyncError;
|
|
373 |
// long buffer for string handling
|
|
374 |
TBuf<KBufSize256> iBuf;
|
|
375 |
//Job id
|
|
376 |
TSmlJobId iJobId;
|
|
377 |
// Bearer
|
|
378 |
TInt iConnectionBearer;
|
|
379 |
// Server name
|
|
380 |
TBuf<KNSmlMaxProfileNameLength> iServerName;
|
|
381 |
// Server sync
|
|
382 |
TBool iServerAlertedSync;
|
|
383 |
// Should the simpler FOTA progress not be used
|
|
384 |
TBool iUseFotaProgressNote;
|
|
385 |
// Retry sync (authentication error)
|
|
386 |
TBool iRetrySync;
|
|
387 |
// Variable to show whether in fotaview or not
|
|
388 |
TInt iNotinFotaView;
|
|
389 |
|
|
390 |
// Identifies Fota progress note launched or not
|
|
391 |
TBool iFotaProgressLaunched;
|
|
392 |
// Set true for silent session
|
|
393 |
TBool iSilent;
|
|
394 |
|
|
395 |
public:
|
|
396 |
// Periodic timer active object to start synchronization
|
|
397 |
CPeriodic* iPeriodic;
|
|
398 |
};
|
|
399 |
|
|
400 |
#endif // NSMLDMSYNCHANDLER_H
|
|
401 |
|
|
402 |
// End of file
|