|
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 #include "NSmlDMSyncAppEngine.h" |
|
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 private: // from MAspActiveCallerObserver |
|
78 /** |
|
79 * From MAspActiveCallerObserver |
|
80 * Called when CAspActiveCaller completes. |
|
81 * @param None |
|
82 * @return None. |
|
83 */ |
|
84 void HandleActiveCallL(); |
|
85 |
|
86 |
|
87 private: // from MSyncMLEventObserver |
|
88 |
|
89 /** |
|
90 * From MSyncMLEventObserver |
|
91 * Called when SyncML session events oocur. |
|
92 * @param aEvent Sync event |
|
93 * @param aIdentifier Identifier for the sync event |
|
94 * @param aError Synce event error |
|
95 * @param aAdditionalData. |
|
96 * @return None. |
|
97 */ |
|
98 void OnSyncMLSessionEvent( TEvent aEvent, |
|
99 TInt aIdentifier, |
|
100 TInt aError, |
|
101 TInt aAdditionalData ); |
|
102 |
|
103 |
|
104 private: //from MSyncMLProgressObserver |
|
105 |
|
106 /** |
|
107 * Receives notification of a synchronisation error. |
|
108 * @param aErrorLevel The error level. |
|
109 * @param aError The type of error. This is one of |
|
110 * the SyncMLError error values. |
|
111 * @param aTaskId The ID of the task for which the error occurred. |
|
112 * @param aInfo1 An integer that can contain additional |
|
113 * information about the error. Normally 0. |
|
114 * @param aInfo2 An integer that can contain additional |
|
115 * information about the error. Normally 0. |
|
116 * @return None. |
|
117 */ |
|
118 void OnSyncMLSyncError( TErrorLevel aErrorLevel, |
|
119 TInt aError, |
|
120 TInt aTaskId, |
|
121 TInt aInfo1, |
|
122 TInt aInfo2 ); |
|
123 |
|
124 /** |
|
125 * Receives notification of synchronisation progress. |
|
126 * @param aStatus The current status, e.g. 'Connecting'. |
|
127 * @param aInfo1 An integer that can contain additional |
|
128 * information about the progress. |
|
129 * @param aInfo2 An integer that can contain additional |
|
130 * information about the progress. |
|
131 */ |
|
132 void OnSyncMLSyncProgress( TStatus aStatus, TInt aInfo1, TInt aInfo2); |
|
133 |
|
134 /** |
|
135 * Receives notification of modifications to synchronisation tasks. |
|
136 * @param aTaskId The ID of the task. |
|
137 * @param aClientModifications Modifications made on |
|
138 * the clients Data Store. |
|
139 * @param aServerModifications Modifications made on |
|
140 * the server Data Store. |
|
141 */ |
|
142 void OnSyncMLDataSyncModifications( |
|
143 TInt /*aTaskId*/, |
|
144 const TSyncMLDataSyncModifications& aClientModifications, |
|
145 const TSyncMLDataSyncModifications& aServerModifications ); |
|
146 |
|
147 private: |
|
148 |
|
149 /** |
|
150 * Shows error dialog. |
|
151 * @param None. |
|
152 * @return Error code. |
|
153 */ |
|
154 void HandleSyncErrorL(); |
|
155 |
|
156 /** |
|
157 * Called when sync completes |
|
158 * @param aError. |
|
159 * @return None. |
|
160 */ |
|
161 void SynchronizeCompletedL(TInt aError); |
|
162 |
|
163 /** |
|
164 * Read sync error from CNSmlSyncLog and show error message. |
|
165 * @param aProfileId Profile id. |
|
166 * @return Result code. |
|
167 */ |
|
168 TInt HandleSyncErrorL(TInt aProfileId); |
|
169 |
|
170 public: |
|
171 /** |
|
172 * Performs synchronization. |
|
173 * @param aServerName Name of the server |
|
174 * @param aProfileId Profile identifier. |
|
175 * @param aConnectionBearer Bearer |
|
176 * @param aUseFotaProgressNote Should the simplified progress note used. Only |
|
177 * used when checking for firmware updates. |
|
178 * @return None |
|
179 */ |
|
180 void SynchronizeL( TDesC& aServerName, |
|
181 const TInt aProfileId, |
|
182 const TInt aConnectionBearer, |
|
183 const TBool aUseFotaProgressNote ); |
|
184 |
|
185 /** |
|
186 * Performs ServerInitiated synchronization. |
|
187 * @param aServerName Name of the server |
|
188 * @param aProfileId Profile id |
|
189 * @param aJobId Job id. |
|
190 * @param aConnectionBearer Bearer |
|
191 * @param aUseFotaProgressNote Should the simplified progress note used. Only |
|
192 * used when checking for firmware updates. |
|
193 * @return None |
|
194 */ |
|
195 void SynchronizeL( TDesC& aServerName, |
|
196 const TInt aProfileId, |
|
197 const TInt aJobId, |
|
198 const TInt aConnectionBearer, |
|
199 const TBool aUseFotaProgressNote ); |
|
200 |
|
201 /** |
|
202 * Shows the progress dialog. |
|
203 * @param None. |
|
204 * @return None. |
|
205 */ |
|
206 void ShowProgressDialogL(); |
|
207 |
|
208 /** |
|
209 * Deletes the progress dialog if it exists. |
|
210 * @param None. |
|
211 * @return None. |
|
212 */ |
|
213 void HideProgressDialogL(); |
|
214 |
|
215 /** |
|
216 * Cancel synchronization. |
|
217 * @param None |
|
218 * @return None |
|
219 */ |
|
220 void CancelSynchronizeL(); |
|
221 |
|
222 private: |
|
223 |
|
224 /** |
|
225 * Performs synchronization. |
|
226 * @return None |
|
227 */ |
|
228 void SynchronizeL(); |
|
229 |
|
230 /** |
|
231 * Utility function. |
|
232 * @return Sync session. |
|
233 */ |
|
234 RSyncMLSession& Session(); |
|
235 |
|
236 public: |
|
237 |
|
238 /** |
|
239 * Utility function. |
|
240 * @return ETrue if sync is currently running, EFalse otherwise. |
|
241 */ |
|
242 TBool SyncRunning(); |
|
243 |
|
244 private: |
|
245 // session with sync server |
|
246 RSyncMLSession* iSyncSession; |
|
247 // app engine |
|
248 CNSmlDMSyncAppEngine* iSyncAppEngine; |
|
249 // profile id |
|
250 TInt iProfileId; |
|
251 // sync job id |
|
252 TInt iSyncJobId; |
|
253 // sync job |
|
254 RSyncMLDevManJob iSyncJob; |
|
255 |
|
256 // CheckUpdate state shown or Not |
|
257 TBool iCheckUpdate; |
|
258 |
|
259 CNSmlDMActiveCaller* iActiveCaller; |
|
260 // is sync currently running |
|
261 TBool iSyncRunning; |
|
262 // sync error code |
|
263 TInt iSyncError; |
|
264 // long buffer for string handling |
|
265 TBuf<KBufSize256> iBuf; |
|
266 //Job id |
|
267 TSmlJobId iJobId; |
|
268 // Bearer |
|
269 TInt iConnectionBearer; |
|
270 // Server name |
|
271 TBuf<KNSmlMaxProfileNameLength> iServerName; |
|
272 // Server sync |
|
273 TBool iServerAlertedSync; |
|
274 // Should the simpler FOTA progress not be used |
|
275 TBool iUseFotaProgressNote; |
|
276 // Retry sync (authentication error) |
|
277 TBool iRetrySync; |
|
278 // Variable to show whether in fotaview or not |
|
279 TInt iNotinFotaView; |
|
280 |
|
281 // Identifies Fota progress note launched or not |
|
282 TBool iFotaProgressLaunched; |
|
283 }; |
|
284 |
|
285 #endif // NSMLDMSYNCHANDLER_H |
|
286 |
|
287 // End of file |