|
1 /* |
|
2 * Copyright (c) 2009 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: SyncML DM NetMon |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_NETMON_H |
|
19 #define C_NETMON_H |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32base.h> |
|
23 #include <rconnmon.h> |
|
24 #include <SyncMLClient.h> |
|
25 #include <SyncMLClientDS.h> |
|
26 #include <SyncMLObservers.h> |
|
27 #include <e32property.h> |
|
28 #include <centralrepository.h> |
|
29 #include <DevManInternalCRKeys.h> |
|
30 |
|
31 // USER INCLUDES |
|
32 #include "nsmldebug.h" |
|
33 //#include "NsmlProfileUtil.h" |
|
34 |
|
35 // NetMon states |
|
36 enum TNetMonStates { ERegister = 0, |
|
37 EMonitor, |
|
38 ENetworkUp, |
|
39 EDMJobOk, |
|
40 EInitSync, |
|
41 EComplete, |
|
42 ENetworkDown}; |
|
43 |
|
44 /** |
|
45 * Monitors the network for availability and starts any pending |
|
46 * data sync sessions. |
|
47 */ |
|
48 class CDMNetworkMon : public CActive, |
|
49 public MConnectionMonitorObserver, |
|
50 public MSyncMLEventObserver, |
|
51 public MSyncMLProgressObserver |
|
52 { |
|
53 public: |
|
54 |
|
55 /** |
|
56 * Two phase construction |
|
57 */ |
|
58 static CDMNetworkMon* NewL(); |
|
59 |
|
60 /** |
|
61 * Destructor |
|
62 */ |
|
63 ~CDMNetworkMon(); |
|
64 |
|
65 protected: |
|
66 |
|
67 // From base class CActive |
|
68 |
|
69 /** |
|
70 * Implements cancellation of an outstanding request |
|
71 */ |
|
72 void DoCancel(); |
|
73 |
|
74 /** |
|
75 * Handles an active objects request completion event. |
|
76 */ |
|
77 void RunL(); |
|
78 |
|
79 /** |
|
80 * If the RunL function leaves, then the active scheduler call |
|
81 * RunError() to handle the leave. |
|
82 * @param aError - The error code |
|
83 */ |
|
84 TInt RunError ( TInt aError ); |
|
85 |
|
86 private: |
|
87 |
|
88 /** |
|
89 * Constructor |
|
90 */ |
|
91 CDMNetworkMon(); |
|
92 |
|
93 /** |
|
94 * Second phase constructor |
|
95 */ |
|
96 void ConstructL(); |
|
97 |
|
98 /** |
|
99 * Resgiter for events |
|
100 */ |
|
101 void RegisterL(); |
|
102 |
|
103 /** |
|
104 * Trigger Device Management Session |
|
105 */ |
|
106 void StartDeviceManagementSessionL(); |
|
107 |
|
108 /** |
|
109 * Close the server |
|
110 */ |
|
111 void Complete(); |
|
112 |
|
113 /** |
|
114 * Set active |
|
115 */ |
|
116 void IssueRequest(); |
|
117 |
|
118 |
|
119 |
|
120 /** |
|
121 * Cancels global auto restart timer |
|
122 */ |
|
123 void CancelGlobalTimer(); |
|
124 |
|
125 /** |
|
126 * Checks if packet data is available using conmon |
|
127 */ |
|
128 TBool PacketDataAvailable(); |
|
129 |
|
130 /** |
|
131 * Moves the state to NetworkUp2 since it is stable |
|
132 */ |
|
133 void NetworkStable(); |
|
134 |
|
135 /** |
|
136 * Check if network is already up |
|
137 */ |
|
138 void StartOperationL(); |
|
139 |
|
140 /** |
|
141 * Check if network is really up. Callback method |
|
142 */ |
|
143 static TInt NetworkUp(TAny* arg); |
|
144 |
|
145 /** |
|
146 * Check if any other sync is in progress |
|
147 */ |
|
148 void OtherSyncStatus(); |
|
149 |
|
150 |
|
151 /** |
|
152 * Global timeout for auto restart has expired. |
|
153 */ |
|
154 static TInt Timeout(TAny* arg); |
|
155 |
|
156 /** |
|
157 * Read the Global timeout from cenrep. |
|
158 */ |
|
159 TInt ReadTimeoutFromCenrepL(); |
|
160 |
|
161 /** |
|
162 * Create the Sync Job. |
|
163 */ |
|
164 void CreateDeviceManagementSessionL(); |
|
165 |
|
166 /** |
|
167 * From base class MConnectionMonitorObserver |
|
168 */ |
|
169 void EventL ( const CConnMonEventBase& aConnMonEvent ); |
|
170 |
|
171 /** |
|
172 * From base class MSyncMLEventObserver |
|
173 */ |
|
174 void OnSyncMLSessionEvent(TEvent aEvent, |
|
175 TInt aIdentifier, |
|
176 TInt aError, |
|
177 TInt aAdditionalData); |
|
178 |
|
179 //from MSyncMLProgressObserver |
|
180 |
|
181 /** |
|
182 * Receives notification of a synchronisation error. |
|
183 * @param aErrorLevel The error level. |
|
184 * @param aError The type of error. This is one of the SyncMLError error values. |
|
185 * @param aTaskId The ID of the task for which the error occurred. |
|
186 * @param aInfo1 An integer that can contain additional information about the error. Normally 0. |
|
187 * @param aInfo2 An integer that can contain additional information about the error. Normally 0. |
|
188 * @return None. |
|
189 */ |
|
190 void OnSyncMLSyncError(TErrorLevel aErrorLevel, TInt aError, TInt aTaskId, TInt aInfo1, TInt aInfo2); |
|
191 |
|
192 /** |
|
193 * Receives notification of synchronisation progress. |
|
194 * @param aStatus The current status, e.g. 'Connecting'. |
|
195 * @param aInfo1 An integer that can contain additional information about the progress. |
|
196 * @param aInfo2 An integer that can contain additional information about the progress. |
|
197 */ |
|
198 void OnSyncMLSyncProgress(TStatus aStatus, TInt aInfo1, TInt aInfo2); |
|
199 |
|
200 /** |
|
201 * Receives notification of modifications to synchronisation tasks. |
|
202 * @param aTaskId The ID of the task. |
|
203 * @param aClientModifications Modifications made on the clients Data Store. |
|
204 * @param aServerModifications Modifications made on the server Data Store. |
|
205 */ |
|
206 void OnSyncMLDataSyncModifications(TInt aTaskId, const TSyncMLDataSyncModifications& aClientModifications, const TSyncMLDataSyncModifications& aServerModifications); |
|
207 |
|
208 |
|
209 /** |
|
210 * Set/Reset the interrupt flag in the CenRep |
|
211 */ |
|
212 TBool IsRoamingDisabled(); |
|
213 void OpenSyncSessionL(); |
|
214 |
|
215 void CloseSyncSession(); |
|
216 |
|
217 private: |
|
218 |
|
219 /** |
|
220 * Connection Monitor Server Instance |
|
221 */ |
|
222 RConnectionMonitor iConnectionMonitor; |
|
223 |
|
224 /** |
|
225 * States |
|
226 */ |
|
227 TNetMonStates iState; |
|
228 |
|
229 TNetMonStates iPrevState; |
|
230 |
|
231 /** |
|
232 * SyncML session |
|
233 */ |
|
234 RSyncMLSession iSyncSession; |
|
235 |
|
236 /** |
|
237 * Data sync job |
|
238 */ |
|
239 RSyncMLDataSyncJob iSyncJob; |
|
240 |
|
241 /** |
|
242 * Stability Timer |
|
243 */ |
|
244 CPeriodic* iStabilityTimer; |
|
245 |
|
246 /** |
|
247 * Global Timer |
|
248 */ |
|
249 CPeriodic* iGlobalTimer; |
|
250 |
|
251 /** |
|
252 * Profile id to be used |
|
253 */ |
|
254 TSmlProfileId iLastUsedProfileId; |
|
255 |
|
256 /** |
|
257 * Sync status P&S keys |
|
258 */ |
|
259 RProperty iProperty; |
|
260 |
|
261 /** |
|
262 * Connection Id used for the Sync Session |
|
263 */ |
|
264 TConnMonBearerId iConMonBearerId; |
|
265 /** |
|
266 * Global timeout from cenrep. |
|
267 */ |
|
268 TInt iGlobalTimeout; |
|
269 |
|
270 /** |
|
271 * Timer count |
|
272 */ |
|
273 TInt iTimerCount; |
|
274 |
|
275 TBool iSyncSessionOpen; |
|
276 |
|
277 TInt iError; |
|
278 TBool iCancelledNWEvent; |
|
279 }; |
|
280 |
|
281 #endif // End of file |