|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __SIMTIMER_H__ |
|
17 #define __SIMTIMER_H__ |
|
18 |
|
19 /** |
|
20 * @file |
|
21 * |
|
22 * Header for timer class with time decrease mechanism using an |
|
23 * observer pattern. |
|
24 * |
|
25 * @internalAll |
|
26 */ |
|
27 |
|
28 #include <e32base.h> |
|
29 #include <simtsy.h> |
|
30 #include "CSimReduceTimers.h" |
|
31 |
|
32 |
|
33 enum TDirection |
|
34 { |
|
35 ESmsRx, |
|
36 ESmsTx |
|
37 }; |
|
38 |
|
39 |
|
40 class MTimerCallBack; |
|
41 class CSimPhone; |
|
42 /** |
|
43 Definition for a timer with observer functionality, which can be used |
|
44 retrieve and update the time duration at any point during the |
|
45 execution. |
|
46 */ |
|
47 class CSimTimer : public CActive, MSimTimerUpdateObserver |
|
48 { |
|
49 public: |
|
50 static CSimTimer* NewL(CSimPhone* aPhone); |
|
51 ~CSimTimer(); |
|
52 void Start(TInt aDuration, MTimerCallBack* aCallback); |
|
53 void Start(TInt aDuration, MTimerCallBack* aCallback,TInt aId); |
|
54 void DoCancel(); |
|
55 TBool Running() const; |
|
56 void Update(TInt aSecsOffTimer); |
|
57 TInt GetRemainingSeconds() const; |
|
58 TInt GetTimerEventInfo() const; |
|
59 |
|
60 private: |
|
61 CSimTimer(); |
|
62 void ConstructL(CSimPhone* aPhone); |
|
63 void RunL(); |
|
64 void RegisterWithSubjectInCSimPhone(); |
|
65 void UnRegisterFromSubjectInCSimPhone(); |
|
66 |
|
67 private: |
|
68 /** The RTimer handle used to request a specific delay before the |
|
69 RunL() function is called by the active scheduler..*/ |
|
70 RTimer iTimer; |
|
71 /** The duration requested of the timer, when a call is made to |
|
72 Start().*/ |
|
73 TInt iDuration; |
|
74 /** The system time when the timer started.*/ |
|
75 TTime iStartTime; |
|
76 /** Optional value; can be used to identify the purpose of the |
|
77 timer to the iCallback object.*/ |
|
78 TInt iCallBackId; |
|
79 /** The object to send a call-back to when the timer finishes.*/ |
|
80 MTimerCallBack* iCallback; |
|
81 /** The subject with which this observer is registered.*/ |
|
82 CSimReduceTimers* iReduceTimersSubject; |
|
83 /** States whether this observer has successfully attached to |
|
84 the subject.*/ |
|
85 TBool iRegistered; |
|
86 }; |
|
87 |
|
88 |
|
89 /** |
|
90 Abstract definition of the object required for the CSimTimer to pass |
|
91 a message back to, thus indicating that the timer duration has expired. |
|
92 */ |
|
93 class MTimerCallBack |
|
94 { |
|
95 public: |
|
96 /** |
|
97 A call-back function for when the given timer duration has ended. |
|
98 |
|
99 @param aId |
|
100 */ |
|
101 virtual void TimerCallBack(TInt aId)=0; |
|
102 }; |
|
103 |
|
104 #endif |