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