|
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 the License "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 // INCLUDE FILES |
|
21 #include "minimaptimer.h" |
|
22 |
|
23 #include "minimap.h" |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 |
|
27 // EXTERNAL FUNCTION PROTOTYPES |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 |
|
34 // LOCAL CONSTANTS AND MACROS |
|
35 |
|
36 // MODULE DATA STRUCTURES |
|
37 |
|
38 // LOCAL FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 |
|
42 // ============================= LOCAL FUNCTIONS =============================== |
|
43 |
|
44 |
|
45 // ============================ MEMBER FUNCTIONS =============================== |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // ?classname::?classname |
|
49 // C++ default constructor can NOT contain any code, that |
|
50 // might leave. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CMinimapTimer::CMinimapTimer(CMinimap& aMinimap, TMinimapCb aCallback, TInt aPriority) |
|
54 : CActive(aPriority), |
|
55 iMinimap(&aMinimap), |
|
56 iCb(aCallback) |
|
57 { |
|
58 CActiveScheduler::Add(this); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMinimap::ConstructL |
|
63 // Symbian 2nd phase constructor can leave. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CMinimapTimer::ConstructL() |
|
67 { |
|
68 User::LeaveIfError(iTimer.CreateLocal()); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CMinimap::NewL |
|
73 // Two-phased constructor. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CMinimapTimer* CMinimapTimer::NewL(CMinimap& aMinimap, TMinimapCb aCallback, TInt aPriority) |
|
77 { |
|
78 CMinimapTimer* self = new( ELeave ) CMinimapTimer(aMinimap, aCallback, aPriority); |
|
79 |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop(); |
|
83 |
|
84 return self; |
|
85 } |
|
86 |
|
87 |
|
88 // Destructor |
|
89 CMinimapTimer::~CMinimapTimer() |
|
90 { |
|
91 Cancel(); |
|
92 iTimer.Close(); |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CMinimapTimer::Start |
|
98 // |
|
99 // |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CMinimapTimer::Start(TTimeIntervalMicroSeconds32 aTime) |
|
103 { |
|
104 Cancel(); |
|
105 iTime = aTime; |
|
106 iTimer.After(iStatus,aTime); |
|
107 SetActive(); |
|
108 } |
|
109 |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CMinimapTimer::StartOrExtend |
|
113 // |
|
114 // |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CMinimapTimer::StartOrContinue(TTimeIntervalMicroSeconds32 aTime) |
|
118 { |
|
119 if (!IsActive()) |
|
120 { |
|
121 iTime = aTime; |
|
122 iTimer.After(iStatus,aTime); |
|
123 SetActive(); |
|
124 } |
|
125 } |
|
126 |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CMinimapTimer::RunL |
|
130 // |
|
131 // |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CMinimapTimer::RunL() |
|
135 { |
|
136 if (iMinimap && iCb) |
|
137 { |
|
138 (iMinimap->*iCb)(); |
|
139 } |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CMinimapTimer::DoCancel |
|
144 // |
|
145 // |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 void CMinimapTimer::DoCancel() |
|
149 { |
|
150 iTimer.Cancel(); |
|
151 } |