|
1 /* |
|
2 * Copyright (c) 2008 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 #ifndef IAUPDATEFWSYNCHANDLER_H |
|
21 #define IAUPDATEFWSYNCHANDLER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <AknProgressDialog.h> |
|
26 #include <SyncMLObservers.h> |
|
27 #include <cmmanagerext.h> |
|
28 |
|
29 #include "iaupdatefwsyncutil.h" |
|
30 #include "iaupdatefwsyncprofile.h" |
|
31 |
|
32 #include "iaupdatefwconst.h" |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CIAUpdateFWSyncState; |
|
36 class CIAUpdateFWActiveCaller; |
|
37 |
|
38 class CIAUpdateFWSyncAppEngine; |
|
39 class CAknWaitDialog; |
|
40 class CIAUpdateFWFotaModel; |
|
41 // CLASS DECLARATION |
|
42 |
|
43 /** |
|
44 * CIAUpdateFWSyncHandler class |
|
45 * |
|
46 */ |
|
47 NONSHARABLE_CLASS (CIAUpdateFWSyncHandler) : public CBase, |
|
48 public MIAUpdateFWActiveCallerObserver, |
|
49 public MSyncMLEventObserver, |
|
50 public MSyncMLProgressObserver, |
|
51 public MProgressDialogCallback |
|
52 |
|
53 { |
|
54 public: |
|
55 /** |
|
56 * Two-phased constructor. |
|
57 */ |
|
58 static CIAUpdateFWSyncHandler* NewL( RSyncMLSession* aSyncSession, |
|
59 CIAUpdateFWSyncAppEngine* aAppEngine, |
|
60 CIAUpdateFWFotaModel* aFotaModel ); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 virtual ~CIAUpdateFWSyncHandler(); |
|
66 |
|
67 private: |
|
68 /** |
|
69 * By default Symbian 2nd phase constructor is private. |
|
70 */ |
|
71 void ConstructL(); |
|
72 |
|
73 /** |
|
74 * C++ default constructor. |
|
75 */ |
|
76 CIAUpdateFWSyncHandler( RSyncMLSession* iSyncSession, |
|
77 CIAUpdateFWSyncAppEngine* aAppEngine, |
|
78 CIAUpdateFWFotaModel* aFotaModel ); |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 private: // from MAspActiveCallerObserver |
|
84 /** |
|
85 * From MAspActiveCallerObserver |
|
86 * Called when CAspActiveCaller completes. |
|
87 * @param None |
|
88 * @return None. |
|
89 */ |
|
90 void HandleActiveCallL(); |
|
91 |
|
92 |
|
93 private: // from MSyncMLEventObserver |
|
94 |
|
95 /** |
|
96 * From MSyncMLEventObserver |
|
97 * Called when SyncML session events oocur. |
|
98 * @param aEvent Sync event |
|
99 * @param aIdentifier Identifier for the sync event |
|
100 * @param aError Synce event error |
|
101 * @param aAdditionalData. |
|
102 * @return None. |
|
103 */ |
|
104 void OnSyncMLSessionEvent( TEvent aEvent, |
|
105 TInt aIdentifier, |
|
106 TInt aError, |
|
107 TInt aAdditionalData ); |
|
108 |
|
109 |
|
110 private: //from MSyncMLProgressObserver |
|
111 |
|
112 /** |
|
113 * Receives notification of a synchronisation error. |
|
114 * @param aErrorLevel The error level. |
|
115 * @param aError The type of error. This is one of |
|
116 * the SyncMLError error values. |
|
117 * @param aTaskId The ID of the task for which the error occurred. |
|
118 * @param aInfo1 An integer that can contain additional |
|
119 * information about the error. Normally 0. |
|
120 * @param aInfo2 An integer that can contain additional |
|
121 * information about the error. Normally 0. |
|
122 * @return None. |
|
123 */ |
|
124 void OnSyncMLSyncError( TErrorLevel aErrorLevel, |
|
125 TInt aError, |
|
126 TInt aTaskId, |
|
127 TInt aInfo1, |
|
128 TInt aInfo2 ); |
|
129 |
|
130 /** |
|
131 * Receives notification of synchronisation progress. |
|
132 * @param aStatus The current status, e.g. 'Connecting'. |
|
133 * @param aInfo1 An integer that can contain additional |
|
134 * information about the progress. |
|
135 * @param aInfo2 An integer that can contain additional |
|
136 * information about the progress. |
|
137 */ |
|
138 void OnSyncMLSyncProgress( TStatus aStatus, TInt aInfo1, TInt aInfo2); |
|
139 |
|
140 /** |
|
141 * Receives notification of modifications to synchronisation tasks. |
|
142 * @param aTaskId The ID of the task. |
|
143 * @param aClientModifications Modifications made on |
|
144 * the clients Data Store. |
|
145 * @param aServerModifications Modifications made on |
|
146 * the server Data Store. |
|
147 */ |
|
148 void OnSyncMLDataSyncModifications( |
|
149 TInt /*aTaskId*/, |
|
150 const TSyncMLDataSyncModifications& aClientModifications, |
|
151 const TSyncMLDataSyncModifications& aServerModifications ); |
|
152 |
|
153 private: |
|
154 |
|
155 /** |
|
156 * Shows error dialog. |
|
157 * @param None. |
|
158 * @return Error code. |
|
159 */ |
|
160 void HandleSyncErrorL(); |
|
161 |
|
162 /** |
|
163 * Called when sync completes |
|
164 * @param aError. |
|
165 * @return None. |
|
166 */ |
|
167 void SynchronizeCompletedL(TInt aError); |
|
168 |
|
169 |
|
170 /** |
|
171 * Read sync error from CNSmlSyncLog and show error message. |
|
172 * @param aProfileId Profile id. |
|
173 * @return Result code. |
|
174 */ |
|
175 TInt HandleSyncErrorL(TInt aProfileId); |
|
176 |
|
177 |
|
178 public: |
|
179 /** |
|
180 * Performs synchronization. |
|
181 * @param aServerName Name of the server |
|
182 * @param aProfileId Profile identifier. |
|
183 * @param aConnectionBearer Bearer |
|
184 * @param aUseFotaProgressNote Should the simplified progress note used. Only |
|
185 * used when checking for firmware updates. |
|
186 * @return None |
|
187 */ |
|
188 void SynchronizeL( TDesC& aServerName, |
|
189 const TInt aProfileId, |
|
190 const TInt aConnectionBearer, |
|
191 const TBool aUseFotaProgressNote ); |
|
192 |
|
193 /** |
|
194 * Performs ServerInitiated synchronization. |
|
195 * @param aServerName Name of the server |
|
196 * @param aProfileId Profile id |
|
197 * @param aJobId Job id. |
|
198 * @param aConnectionBearer Bearer |
|
199 * @param aUseFotaProgressNote Should the simplified progress note used. Only |
|
200 * used when checking for firmware updates. |
|
201 * @return None |
|
202 */ |
|
203 void SynchronizeL( TDesC& aServerName, |
|
204 const TInt aProfileId, |
|
205 const TInt aJobId, |
|
206 const TInt aConnectionBearer, |
|
207 const TBool aUseFotaProgressNote ); |
|
208 |
|
209 /** |
|
210 * Shows the progress dialog. |
|
211 * @param None. |
|
212 * @return None. |
|
213 */ |
|
214 void ShowProgressDialogL(); |
|
215 |
|
216 /** |
|
217 * Select IAP |
|
218 * @param None. |
|
219 * @return None. |
|
220 */ |
|
221 void SelectIAPL(); |
|
222 |
|
223 /** |
|
224 * Deletes the progress dialog if it exists. |
|
225 * @param None. |
|
226 * @return None. |
|
227 */ |
|
228 void HideProgressDialogL(); |
|
229 |
|
230 /** |
|
231 * Cancel synchronization. |
|
232 * @param None |
|
233 * @return None |
|
234 */ |
|
235 void CancelSynchronizeL(); |
|
236 |
|
237 /** |
|
238 * From MProgressDialogCallback. Handles the situation when the dialog |
|
239 * is dismissed. |
|
240 * @param aButtonId The identifier of the button, with which the dialog |
|
241 * was dismissed. |
|
242 * @return None |
|
243 */ |
|
244 void DialogDismissedL( TInt aButtonId ); |
|
245 |
|
246 private: |
|
247 |
|
248 /** |
|
249 * Performs synchronization. |
|
250 * @return None |
|
251 */ |
|
252 void SynchronizeL(); |
|
253 |
|
254 /** |
|
255 * Utility function. |
|
256 * @return Sync session. |
|
257 */ |
|
258 RSyncMLSession& Session(); |
|
259 |
|
260 |
|
261 /** |
|
262 * Utility function. |
|
263 * @return Sync state. |
|
264 */ |
|
265 CIAUpdateFWSyncState* State(); |
|
266 |
|
267 public: |
|
268 |
|
269 /** |
|
270 * Utility function. |
|
271 * @return ETrue if sync is currently running, EFalse otherwise. |
|
272 */ |
|
273 TBool SyncRunning(); |
|
274 |
|
275 private: |
|
276 |
|
277 TUint32 SelectConnectionMethodL(); |
|
278 TUint32 GetBestIAPInInternetSNAPL( RCmManagerExt& aCmManagerExt ); |
|
279 TUint32 GetBestIAPInThisSNAPL( RCmManagerExt& aCmManagerExt, TUint32 aSNAPID ); |
|
280 |
|
281 private: |
|
282 // session with sync server |
|
283 RSyncMLSession* iSyncSession; |
|
284 // app engine |
|
285 CIAUpdateFWSyncAppEngine* iSyncAppEngine; |
|
286 // Pointer to the application document class |
|
287 CIAUpdateFWFotaModel* iFotaModel; |
|
288 // profile id |
|
289 TInt iProfileId; |
|
290 // sync job id |
|
291 TInt iSyncJobId; |
|
292 // sync job |
|
293 RSyncMLDevManJob iSyncJob; |
|
294 |
|
295 // The alternative wait dialog used in FOTA |
|
296 CAknWaitDialog* iWaitDialog; |
|
297 |
|
298 // sync handler state |
|
299 CIAUpdateFWSyncState* iState; |
|
300 // for making function call via active scheduler |
|
301 CIAUpdateFWActiveCaller* iActiveCaller; |
|
302 // is sync currently running |
|
303 TBool iSyncRunning; |
|
304 // sync error code |
|
305 TInt iSyncError; |
|
306 // long buffer for string handling |
|
307 TBuf<KBufSize256> iBuf; |
|
308 //Job id |
|
309 TSmlJobId iJobId; |
|
310 // Bearer |
|
311 TInt iConnectionBearer; |
|
312 // Server name |
|
313 TBuf<KNSmlMaxProfileNameLength> iServerName; |
|
314 // Server sync |
|
315 TBool iServerAlertedSync; |
|
316 // Should the simpler FOTA progress not be used |
|
317 TBool iUseFotaProgressNote; |
|
318 // Retry sync (authentication error) |
|
319 TBool iRetrySync; |
|
320 }; |
|
321 |
|
322 #endif // NSMLDMSYNCHANDLER_H |
|
323 |
|
324 // End of file |