|
1 /* |
|
2 ============================================================================ |
|
3 Name : TimeAO.cpp |
|
4 Author : |
|
5 Version : 1.0 |
|
6 Copyright : Your copyright notice |
|
7 Description : CTimeAO implementation |
|
8 ============================================================================ |
|
9 */ |
|
10 |
|
11 #include "TimeAO.h" |
|
12 #include "MCountTime.h" |
|
13 // --------------------------------------------------------------------------- |
|
14 // CTimeAO() |
|
15 // --------------------------------------------------------------------------- |
|
16 // |
|
17 CTimeAO::CTimeAO() : |
|
18 CActive(EPriorityStandard) // Standard priority |
|
19 { |
|
20 } |
|
21 // --------------------------------------------------------------------------- |
|
22 // NewLC() |
|
23 // --------------------------------------------------------------------------- |
|
24 // |
|
25 CTimeAO* CTimeAO::NewLC() |
|
26 { |
|
27 CTimeAO* self = new (ELeave) CTimeAO(); |
|
28 CleanupStack::PushL(self); |
|
29 self->ConstructL(); |
|
30 return self; |
|
31 } |
|
32 // --------------------------------------------------------------------------- |
|
33 // NewL() |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CTimeAO* CTimeAO::NewL() |
|
37 { |
|
38 CTimeAO* self = CTimeAO::NewLC(); |
|
39 CleanupStack::Pop(); // self; |
|
40 return self; |
|
41 } |
|
42 // --------------------------------------------------------------------------- |
|
43 // ConstructL() |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 void CTimeAO::ConstructL() |
|
47 { |
|
48 User::LeaveIfError(iTimer.CreateLocal()); |
|
49 CActiveScheduler::Add(this); // Add to scheduler |
|
50 } |
|
51 // --------------------------------------------------------------------------- |
|
52 // ~CTimeAO() |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CTimeAO::~CTimeAO() |
|
56 { |
|
57 Cancel(); // Cancel any request, if outstanding |
|
58 iTimer.Close(); // Destroy the RTimer object |
|
59 // Delete instance variables if any |
|
60 } |
|
61 // --------------------------------------------------------------------------- |
|
62 // DoCancel() |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void CTimeAO::DoCancel() |
|
66 { |
|
67 iTimer.Cancel(); |
|
68 } |
|
69 // --------------------------------------------------------------------------- |
|
70 // StartL() |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 void CTimeAO::StartL() |
|
74 { |
|
75 Cancel(); // Cancel any request, just to be sure |
|
76 iTimer.After(iStatus, 1000000); // Set for later |
|
77 SetActive(); // Tell scheduler a request is active |
|
78 } |
|
79 // --------------------------------------------------------------------------- |
|
80 // SetObserver() |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CTimeAO::SetObserver(MCountTime* aObserver) |
|
84 { |
|
85 iObserver = aObserver; |
|
86 } |
|
87 // --------------------------------------------------------------------------- |
|
88 // RunL() |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 void CTimeAO::RunL() |
|
92 { |
|
93 |
|
94 if (iObserver != NULL) |
|
95 { |
|
96 iObserver->Notify(); |
|
97 } |
|
98 } |
|
99 // --------------------------------------------------------------------------- |
|
100 // RunError() |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 TInt CTimeAO::RunError(TInt aError) |
|
104 { |
|
105 return aError; |
|
106 } |