|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef IAUPDATEFWSYNCUTIL_H |
|
21 #define IAUPDATEFWSYNCUTIL_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 |
|
26 // CLASS DECLARATION |
|
27 |
|
28 /** |
|
29 * TUtil |
|
30 * |
|
31 * This class contains general utility functions. |
|
32 */ |
|
33 NONSHARABLE_CLASS (TUtil) |
|
34 { |
|
35 public: |
|
36 |
|
37 /** |
|
38 * Panic |
|
39 * @param aReason. |
|
40 * @return None |
|
41 */ |
|
42 static void Panic( TInt aReason ); |
|
43 |
|
44 /** |
|
45 * String copy tool |
|
46 * @param aTarget. |
|
47 * @param aSource. |
|
48 * @return None |
|
49 */ |
|
50 static void StrCopy( TDes& aTarget, const TDesC& aSource ); |
|
51 /** |
|
52 * String copy tool |
|
53 * @param aTarget. |
|
54 * @param aSource. |
|
55 * @return None |
|
56 */ |
|
57 static void StrCopy( TDes& aTarget, const TDesC8& aSource ); |
|
58 |
|
59 /** |
|
60 * String copy tool |
|
61 * @param aTarget. |
|
62 * @param aSource. |
|
63 * @return None |
|
64 */ |
|
65 static void StrCopy( TDes8& aTarget, const TDesC& aSource ); |
|
66 |
|
67 /** |
|
68 * String append tool |
|
69 * @param aTarget. |
|
70 * @param aSource. |
|
71 * @return None |
|
72 */ |
|
73 static void StrAppend( TDes& aTarget, const TDesC& aSource ); |
|
74 |
|
75 /** |
|
76 * String insert tool |
|
77 * @param aTarget. |
|
78 * @param aSource. |
|
79 * @return None |
|
80 */ |
|
81 static void StrInsert( TDes& aTarget, const TDesC& aSource ); |
|
82 |
|
83 /** |
|
84 * Convert string to int |
|
85 * @param aText. |
|
86 * @param aNum. |
|
87 * @return None |
|
88 */ |
|
89 static TInt StrToInt( const TDesC& aText, TInt& aNum ); |
|
90 |
|
91 /** |
|
92 * Check whether textline is empty |
|
93 * @param aText. |
|
94 * @return ETrue if empty |
|
95 */ |
|
96 static TBool IsEmpty( const TDesC& aText ); |
|
97 |
|
98 /** |
|
99 * URI Parser |
|
100 * @param aURI |
|
101 * @param aAddress |
|
102 * @param aPort |
|
103 * @param aDocName |
|
104 * @return None |
|
105 */ |
|
106 static void ParseURIL( const TDesC& aURI, |
|
107 TDes& aAddress, |
|
108 TDes& aPort, |
|
109 TDes& aDocName ); |
|
110 |
|
111 /** |
|
112 * Returns formatted sync time |
|
113 * @param aLastSync |
|
114 * @return Sync time |
|
115 */ |
|
116 static HBufC* SyncTimeLC( TTime aLastSync ); |
|
117 |
|
118 /** |
|
119 * Get data as text |
|
120 * @param |
|
121 * @return |
|
122 */ |
|
123 static void GetDateTextL( TDes& aText, TTime aDateTime ); |
|
124 |
|
125 /** |
|
126 * Get time as text |
|
127 * @param |
|
128 * @return |
|
129 */ |
|
130 static void GetTimeTextL( TDes& aText, TTime aDateTime ); |
|
131 |
|
132 /** |
|
133 * Get data and time as text |
|
134 * @param |
|
135 * @return |
|
136 */ |
|
137 static void GetDateTimeTextL( TDes& aText, TTime aDateTime ); |
|
138 |
|
139 /** |
|
140 * Check if SettingEnforcement is set |
|
141 * @param |
|
142 * @return Boolean |
|
143 */ |
|
144 static TBool SettingEnforcementStateL(); |
|
145 |
|
146 /** |
|
147 * Check if SettingEnforcement is set (non-leaving) |
|
148 * @param |
|
149 * @return Boolean |
|
150 */ |
|
151 static TBool SettingEnforcementState(); |
|
152 |
|
153 private: |
|
154 |
|
155 /** |
|
156 * Check if sync has happened today |
|
157 * @param atime |
|
158 * @return Boolean |
|
159 */ |
|
160 static TBool IsToday( TTime aTime ); |
|
161 |
|
162 /** |
|
163 * Convert time to hometime |
|
164 * @param aUniversalTime |
|
165 * @return TTIme |
|
166 */ |
|
167 static TTime ConvertUniversalToHomeTime( const TTime& aUniversalTime ); |
|
168 |
|
169 }; |
|
170 |
|
171 /** |
|
172 * TStr contains descriptor operations with range checking. |
|
173 */ |
|
174 NONSHARABLE_CLASS (TStr) |
|
175 { |
|
176 public: |
|
177 /** |
|
178 * C++ default constructor. |
|
179 */ |
|
180 TStr(const TDesC& aStr); |
|
181 |
|
182 public: |
|
183 /** |
|
184 * String manipulating tools |
|
185 * @param aPos |
|
186 * @param aLen |
|
187 * @return TPtrC |
|
188 */ |
|
189 TPtrC Mid( TInt aPos, TInt aLen ); |
|
190 |
|
191 /** |
|
192 * String manipulating tools |
|
193 * @param aPos |
|
194 * @return TPtrC |
|
195 */ |
|
196 TPtrC Mid( TInt aPos ); |
|
197 |
|
198 /** |
|
199 * String manipulating tools |
|
200 * @param aPos |
|
201 * @return TPtrC |
|
202 */ |
|
203 TPtrC Left( TInt aPos ); |
|
204 |
|
205 /** |
|
206 * String manipulating tools |
|
207 * @param aPos |
|
208 * @return TPtrC |
|
209 */ |
|
210 TPtrC Right( TInt aPos ); |
|
211 |
|
212 /** |
|
213 * String manipulating tools |
|
214 * @param aStartPos |
|
215 * @param aEndPos |
|
216 * @return TPtrC |
|
217 */ |
|
218 TPtrC SubStr( TInt aStartPos, TInt aEndPos ); |
|
219 |
|
220 /** |
|
221 * String manipulating tools |
|
222 * @param aStartPos |
|
223 * @param aEndPos |
|
224 * @return TPtrC |
|
225 */ |
|
226 TPtrC SubStrEx( TInt aStartPos, TInt aEndPos ); |
|
227 |
|
228 /** |
|
229 * String manipulating tools |
|
230 * @return TInt |
|
231 */ |
|
232 TInt LastPos(); |
|
233 |
|
234 /** |
|
235 * String manipulating tools |
|
236 * @return TInt |
|
237 */ |
|
238 TInt Len(); |
|
239 |
|
240 /** |
|
241 * String manipulating tools |
|
242 * @param aPos |
|
243 * @param aChar |
|
244 * @return TBool |
|
245 */ |
|
246 TBool Compare( TInt aPos, TChar aChar ); |
|
247 |
|
248 /** |
|
249 * String manipulating tools |
|
250 * @param aStartPos |
|
251 * @param aChar |
|
252 * @return TInt |
|
253 */ |
|
254 TInt Find( TInt aPos, TChar aChar ); |
|
255 |
|
256 private: |
|
257 // reference to descriptor |
|
258 const TDesC& iStr; |
|
259 }; |
|
260 |
|
261 /** |
|
262 * TURIParser is used for parsing URI. |
|
263 */ |
|
264 NONSHARABLE_CLASS (TURIParser) |
|
265 { |
|
266 public: |
|
267 /** |
|
268 * C++ default constructor. |
|
269 */ |
|
270 TURIParser( const TDesC& aStr ); |
|
271 |
|
272 public: |
|
273 /** |
|
274 * URI manipulating tools |
|
275 * @param aText |
|
276 * @return None |
|
277 */ |
|
278 void GetUriWithoutPort( TDes& aText ); |
|
279 |
|
280 /** |
|
281 * URI manipulating tools |
|
282 * @param aText |
|
283 * @param aPort |
|
284 * @return None |
|
285 */ |
|
286 void GetUri( TDes& aText, const TInt aPort ); |
|
287 |
|
288 /** |
|
289 * URI manipulating tools |
|
290 * @return TInt |
|
291 */ |
|
292 TInt Port(); |
|
293 |
|
294 /** |
|
295 * URI manipulating tools |
|
296 * @return TInt |
|
297 */ |
|
298 TInt DefaultPort(); |
|
299 |
|
300 private: |
|
301 /** |
|
302 * URI manipulating tools |
|
303 * @return TPtrC |
|
304 */ |
|
305 TPtrC ParseHttp(); |
|
306 |
|
307 /** |
|
308 * URI manipulating tools |
|
309 * @return TPtrC |
|
310 */ |
|
311 TPtrC ParseAddress(); |
|
312 |
|
313 /** |
|
314 * URI manipulating tools |
|
315 * @return TPtrC |
|
316 */ |
|
317 TPtrC ParseDocument(); |
|
318 |
|
319 /** |
|
320 * URI manipulating tools |
|
321 * @param aPortNumber |
|
322 * @return TInt |
|
323 */ |
|
324 TInt ParsePort(TInt& aPortNumber); |
|
325 |
|
326 /** |
|
327 * URI manipulating tools |
|
328 * @return TPtrC |
|
329 */ |
|
330 TPtrC ParsePort(); |
|
331 |
|
332 private: |
|
333 |
|
334 /** |
|
335 * URI manipulating tools |
|
336 * @param aStartPos |
|
337 * @param aEndPos |
|
338 * @return None |
|
339 */ |
|
340 void GetHttpPos(TInt& aStartPos, TInt& aEndPos); |
|
341 |
|
342 /** |
|
343 * URI manipulating tools |
|
344 * @return NOne |
|
345 */ |
|
346 void SkipHttp(); |
|
347 |
|
348 private: |
|
349 // reference to original URI text |
|
350 const TDesC& iOriginalStr; |
|
351 |
|
352 // pointer to original URI text |
|
353 TPtrC iPtr; |
|
354 |
|
355 //reference to Boolean variable which tells about Slash in URI |
|
356 TBool iSlash; |
|
357 }; |
|
358 |
|
359 /** |
|
360 * MIAUpdateFWActiveCallerObserver |
|
361 * |
|
362 * MIAUpdateFWActiveCallerObserver is for observing CIAUpdateFWActiveCaller. |
|
363 */ |
|
364 class MIAUpdateFWActiveCallerObserver |
|
365 { |
|
366 public: |
|
367 virtual void HandleActiveCallL() = 0; |
|
368 }; |
|
369 |
|
370 /** |
|
371 * CIAUpdateFWActiveCaller |
|
372 * |
|
373 * CIAUpdateFWActiveCaller is used for generating a call from active scheduler. |
|
374 */ |
|
375 NONSHARABLE_CLASS (CIAUpdateFWActiveCaller) : public CActive |
|
376 { |
|
377 public: |
|
378 /** |
|
379 * Two-phased constructor. |
|
380 */ |
|
381 static CIAUpdateFWActiveCaller* NewL(MIAUpdateFWActiveCallerObserver* aObserver); |
|
382 |
|
383 /** |
|
384 * Destructor. |
|
385 */ |
|
386 virtual ~CIAUpdateFWActiveCaller(); |
|
387 |
|
388 private: |
|
389 /** |
|
390 * C++ default constructor. |
|
391 */ |
|
392 CIAUpdateFWActiveCaller(MIAUpdateFWActiveCallerObserver* aObserver); |
|
393 |
|
394 /** |
|
395 * By default Symbian 2nd phase constructor is private. |
|
396 */ |
|
397 void ConstructL(); |
|
398 |
|
399 public: |
|
400 /** |
|
401 * Calls observer using active object framework. |
|
402 * @param aCallId. |
|
403 * @param aMilliseconds Delay before observer is called. |
|
404 * @return None |
|
405 */ |
|
406 void Start( TInt aCallId, TInt aMilliseconds = 0 ); |
|
407 |
|
408 private: |
|
409 /** |
|
410 * From CActive. Called when asynchronous request completes. |
|
411 * @param None |
|
412 * @return None |
|
413 */ |
|
414 void RunL(); |
|
415 |
|
416 /** |
|
417 * From CActive. Called when RunL Leaves. |
|
418 * @param None |
|
419 * @return error |
|
420 */ |
|
421 TInt RunError( TInt aError ); |
|
422 |
|
423 /** |
|
424 * From CActive. Cancels asynchronous request. |
|
425 * @param None |
|
426 * @return None |
|
427 */ |
|
428 void DoCancel(); |
|
429 |
|
430 /** |
|
431 * Make active scheduler call RunL. |
|
432 * @param None |
|
433 * @return None |
|
434 */ |
|
435 void CompleteSelf(); |
|
436 |
|
437 private: |
|
438 // call that is passed to observer |
|
439 TInt iCallId; |
|
440 |
|
441 // timer |
|
442 RTimer iTimer; |
|
443 |
|
444 // observer that gets called |
|
445 MIAUpdateFWActiveCallerObserver* iObserver; |
|
446 }; |
|
447 |
|
448 #endif // NSMLDMSYNCUTIL_H |
|
449 |
|
450 // End of File |