|
1 /* |
|
2 * Copyright (c) 2007-2009 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 CPOSPSYFIXSTATEMANAGER_H |
|
21 #define CPOSPSYFIXSTATEMANAGER_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <lbs.h> |
|
25 |
|
26 #include "epos_mposfixstatetimerlistener.h" |
|
27 |
|
28 class MPosPsyFixStateListener; |
|
29 class CPosFixStateTimer; |
|
30 class CPosConstManager; |
|
31 class CPosPsyListHandler; |
|
32 |
|
33 |
|
34 /** |
|
35 * The CPosPsyFixStateManager manages fix state of loaded PSYs. |
|
36 */ |
|
37 class CPosPsyFixStateManager : public CBase, public MPosFixStateTimerListener |
|
38 { |
|
39 public: //Definitions |
|
40 /* |
|
41 * The enumeration defines PSY fix state |
|
42 */ |
|
43 enum TPsyFixState |
|
44 { |
|
45 EPsyFixStateUnknown = 0, ///PSY fix state unkown |
|
46 EPsyFixStateYes, ///PSY is able to give a fix |
|
47 EPsyFixStateNo ///PSY is not able to give a fix |
|
48 }; |
|
49 |
|
50 public: // Constructors and destructor |
|
51 |
|
52 /** |
|
53 * Get an instance of CPosPsyFixStateManager. |
|
54 * |
|
55 * This function must be called in pair with |
|
56 * ReleaseInstance() . |
|
57 * |
|
58 * @return The new instance of this class. |
|
59 */ |
|
60 static CPosPsyFixStateManager* GetInstanceL(); |
|
61 |
|
62 /** |
|
63 * Release the instance of CPosPsyFixStateManager. |
|
64 * |
|
65 * This function must be called in pair with |
|
66 * GetInstanceL() |
|
67 */ |
|
68 void ReleaseInstance(); |
|
69 |
|
70 /** |
|
71 * Add a listener. |
|
72 * |
|
73 * @param aListener Pointer to a new listener |
|
74 */ |
|
75 void AddListenerL( MPosPsyFixStateListener* aListener ); |
|
76 |
|
77 /** |
|
78 * Remove a listner. |
|
79 * |
|
80 * @param aListener Pointer to the listener. |
|
81 */ |
|
82 void RemoveListener( MPosPsyFixStateListener* aListener ); |
|
83 |
|
84 /** |
|
85 * Inform PSY fix state manager that a PSY is loaded. |
|
86 * The PSY will be added to PSY list and the fix state |
|
87 * of the PSY is maintained by the PSY fix state |
|
88 * manager. |
|
89 * |
|
90 * Client does not need to inform the PSY fix state |
|
91 * manager if a PSY is unloaded. |
|
92 * |
|
93 * @param aPsyId Id of the loaded PSY. |
|
94 */ |
|
95 void PsyLoadedL( |
|
96 TPositionModuleId aPsyId ); |
|
97 |
|
98 /** |
|
99 * Get fix state of a specific PSY. |
|
100 * |
|
101 * If the PSY has not been laoded, then |
|
102 * EPsyFixStateUnknow will be returned. |
|
103 * |
|
104 * @param aPsyId Id of the PSY |
|
105 * @return Fix state of the PSY |
|
106 */ |
|
107 TPsyFixState GetPsyFixState( |
|
108 TPositionModuleId aPsyId ); |
|
109 |
|
110 /** |
|
111 * Notify PSY fix state manager that a PSY is used. |
|
112 * |
|
113 * When function SetPsyFixState is called, the location |
|
114 * request has been completed. And PSY is not used any more. |
|
115 * |
|
116 * @param aPsyId The ID of the PSY |
|
117 * @param aPreviousDeviceStatus The device status before the PSY |
|
118 * is used. |
|
119 */ |
|
120 void PsyUsed( |
|
121 TPositionModuleId aPsyId, |
|
122 TPositionModuleStatus::TDeviceStatus aPreviousDeviceStatus ); |
|
123 |
|
124 /** |
|
125 * Set fix state to a specific PSY. |
|
126 * |
|
127 * If the PSY has not been loaded before, this |
|
128 * function does nothing. |
|
129 * |
|
130 * @param aPsyId The Id of the PSY. |
|
131 * @param aLRErr Location request complete error code |
|
132 */ |
|
133 void SetPsyFixState( |
|
134 TPositionModuleId aPsyId, |
|
135 TInt aLRErr ); |
|
136 |
|
137 /** |
|
138 * Set fix state of external GPS PSY. This function is used by |
|
139 * CPosExternalGpsMonitor |
|
140 * |
|
141 * @param aPsyId The Id of the PSY. |
|
142 * @param aLRErr Location request complete error code |
|
143 */ |
|
144 void SetExtGpsPsyFixState( |
|
145 TPositionModuleId aPsyId, |
|
146 TInt aLRErr ); |
|
147 |
|
148 public: //From base class |
|
149 /** |
|
150 * From MPosFixStateTimerListener |
|
151 */ |
|
152 virtual void TimeshiftTimerTimeout( |
|
153 TPositionModuleId aPsyId ); |
|
154 |
|
155 /** |
|
156 * From MPosFixStateTimerListener |
|
157 */ |
|
158 virtual void UnknownTimerTimeout( |
|
159 TPositionModuleId aPsyId ); |
|
160 |
|
161 private: |
|
162 /** |
|
163 * PSY and fix state structure |
|
164 */ |
|
165 struct TPsyAndFixState |
|
166 { |
|
167 TPositionModuleId iPsyId; //The Id of the PSY |
|
168 TPsyFixState iPsyState; //The state of the PSY |
|
169 TInt iLocationRequestCount; //The location request count |
|
170 CPosFixStateTimer* iTimer;//Fix state timer |
|
171 }; |
|
172 |
|
173 private: |
|
174 |
|
175 /** |
|
176 * C++ default constructor. |
|
177 */ |
|
178 CPosPsyFixStateManager(); |
|
179 |
|
180 /** |
|
181 * EPOC constructor. |
|
182 */ |
|
183 void ConstructL(); |
|
184 |
|
185 /** |
|
186 * Destructor. |
|
187 */ |
|
188 ~CPosPsyFixStateManager(); |
|
189 |
|
190 /** |
|
191 * Find index of the PSY in PSY state array. This function |
|
192 * returns KErrNotFound if the PSY is not found in the |
|
193 * PSY state array. Otherwise the index is returned. |
|
194 */ |
|
195 TInt PsyIndex( |
|
196 TPositionModuleId aPsyId ); |
|
197 |
|
198 /** |
|
199 * Start timeshift timer |
|
200 */ |
|
201 void StartTimeshiftTimer( |
|
202 TPsyAndFixState& aFixState, |
|
203 TPositionModuleStatus::TDeviceStatus aPreviousDeviceStatus ); |
|
204 |
|
205 /** |
|
206 * Notify listener that PSY fix state is changed |
|
207 * |
|
208 * @param aPsyID The ID of the PSY |
|
209 * @param aPreviousFixState Previous fix state |
|
210 */ |
|
211 void NotifyListener( |
|
212 TPositionModuleId aPsyId, |
|
213 TPsyFixState aPreviousFixState ); |
|
214 |
|
215 // By default, prohibit copy constructor |
|
216 CPosPsyFixStateManager(const CPosPsyFixStateManager&); |
|
217 // Prohibit assigment operator |
|
218 CPosPsyFixStateManager& operator= (const CPosPsyFixStateManager&); |
|
219 |
|
220 private: // Data |
|
221 //Reference count |
|
222 TInt iRefCount; |
|
223 |
|
224 //List handler to get TTFF and TTNF |
|
225 CPosPsyListHandler* iListHandler; |
|
226 |
|
227 //Const manager |
|
228 CPosConstManager* iConstManager; |
|
229 |
|
230 //Listner array |
|
231 RPointerArray< MPosPsyFixStateListener > iListenerArray; |
|
232 |
|
233 //Psy fix state array |
|
234 RArray< TPsyAndFixState > iPsyStateArray; |
|
235 |
|
236 }; |
|
237 |
|
238 #endif // CPOSPSYFIXSTATEMANAGER_H |
|
239 |
|
240 // End of File |