1 // Copyright (c) 2003-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __LBSPOSITIONINFO_H__
17 #define __LBSPOSITIONINFO_H__
19 #include <lbsposition.h>
20 #include <lbscommon.h>
21 #include <lbsfields.h>
23 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
24 class TPositionFieldIndex;
25 #endif // SYMBIAN_ENABLE_SPLIT_HEADERS
29 The default size for a HPositionGenericInfo position information buffer
34 const TInt KPositionGenericInfoDefaultBufferSize = 1024;
37 The default number of requested fields for a HPositionGenericInfo
38 position information buffer
43 const TInt KPositionGenericInfoDefaultMaxFields = 32;
51 enum _TPositionUpdateType
53 /** EPositionUpdateUnknown */
54 EPositionUpdateUnknown = 0,
55 /** EPositionUpdateGeneral */
56 EPositionUpdateGeneral = 0x01
59 TPositionUpdateType code
63 typedef TUint32 TPositionUpdateType;
67 Position mode reasons. These values summarise the reasons why module
68 was unable to uses its preferred calculation mode when producing a
69 position update. The values are a bit mask that can be combined
70 to describe the various reasons.
72 NetworkError is used when there is no network coverage or
73 the service is unavailable.
75 LocalError represents environmental reasons that prevent a terminal
76 based calculation - such as no satellites in view.
78 DataError is returned when there is a problem with the initialisation
79 data. For example, GPS assistance data was received but it was
80 either invalid or could not be used..
85 enum _TPositionModeReason
87 /** Mode reason none */
88 EPositionModeReasonNone = 0,
89 /** Mode reason network error */
90 EPositionModeReasonNetworkError = 1 << 0,
91 /** Mode reason local error */
92 EPositionModeReasonLocalError = 1 << 1,
93 /** Mode reason data error */
94 EPositionModeReasonDataError = 1 << 2
98 TPositionModeReason code
102 typedef TUint32 TPositionModeReason;
105 class TPositionInfoBase : public TPositionClassTypeBase
107 This class provides the interface used by RPositioner to get a location fix,
108 and as such all classes used to get location info from the location server should
109 derive from this class.
111 Class contains info about the update type and the ID of the module that gave the
119 IMPORT_C TPositionModuleId ModuleId() const;
120 IMPORT_C void SetModuleId(TPositionModuleId aModuleId);
122 IMPORT_C TPositionUpdateType UpdateType() const;
123 IMPORT_C void SetUpdateType(TPositionUpdateType aUpdateType);
125 IMPORT_C TPositionModuleInfo::TTechnologyType PositionMode() const;
126 IMPORT_C void SetPositionMode(TPositionModuleInfo::TTechnologyType aMode);
128 IMPORT_C TPositionModeReason PositionModeReason() const;
129 IMPORT_C void SetPositionModeReason(TPositionModeReason aReason);
132 IMPORT_C TPositionInfoBase();
135 /** The Id of the module that gave the location fix. */
136 TPositionModuleId iModuleId;
137 /** The type of update that this location fix represents. */
140 /** The positioning mode used to calculate this location fix. */
141 TPositionModuleInfo::TTechnologyType iPositionMode;
143 /** The reason why the prefered position mode was not used. */
144 TPositionModeReason iPositionModeReason;
147 /** Unused variable for future expansion. */
152 class TPositionInfo : public TPositionInfoBase
154 Standard class for getting a TPosition location fix from the location server.
161 IMPORT_C TPositionInfo();
163 IMPORT_C void GetPosition(TPosition& aPosition) const;
164 IMPORT_C void SetPosition(const TPosition& aPosition);
167 /** The TPosition. */
172 class TPositionCourseInfo : public TPositionInfo
174 Class for getting a TCourse from the location server.
181 IMPORT_C TPositionCourseInfo();
183 IMPORT_C void GetCourse(TCourse& aCourse) const;
184 IMPORT_C void SetCourse(const TCourse& aCourse);
193 Class for getting arbitrary positioning related information back from the location server.
194 The client can set upto KPositionMaxRequestedFields as the number of requested fields.
195 The definitions of the fields are given in the enum #_TPositionFieldId. The client must
196 know what data type will be returned for each of the fields. The server will make a best
197 attempt to fill in the requested fields.
199 The client needs to allocate a big enough buffer to store the information it is requesting.
200 In order to be sure of getting back all the information the client must know and allocate
201 memory considering the return value for each requested field.
206 class HPositionGenericInfo : public TPositionInfo
210 IMPORT_C static HPositionGenericInfo* New(TInt aBufferSize = KPositionGenericInfoDefaultBufferSize,
211 TInt aMaxFields = KPositionGenericInfoDefaultMaxFields);
212 IMPORT_C static HPositionGenericInfo* NewL(TInt aBufferSize = KPositionGenericInfoDefaultBufferSize,
213 TInt aMaxFields = KPositionGenericInfoDefaultMaxFields);
214 IMPORT_C static HPositionGenericInfo* NewLC(TInt aBufferSize = KPositionGenericInfoDefaultBufferSize,
215 TInt aMaxFields = KPositionGenericInfoDefaultMaxFields);
216 IMPORT_C void ClearRequestedFields();
217 IMPORT_C TInt SetRequestedField(TPositionFieldId aFieldId);
218 IMPORT_C TInt SetRequestedFields(const TPositionFieldIdList aFieldIdList);
219 IMPORT_C TInt IsRequestedField(TPositionFieldId aFieldId) const;
220 IMPORT_C TPositionFieldId FirstRequestedFieldId() const;
221 IMPORT_C TPositionFieldId NextRequestedFieldId(TPositionFieldId aFieldId) const;
222 IMPORT_C TBool IsFieldAvailable(TPositionFieldId aFieldId) const;
223 IMPORT_C void ClearPositionData(); //Required on server side
224 IMPORT_C TInt BufferSize() const;
225 IMPORT_C TInt MaxFields() const;
228 * Used to store position information.
229 * @param aFieldId Standard position field identifier. See _TPositionFieldId
230 * @param [in] aValue The parameter aValue can be of the type
231 * TInt8, TInt16, TInt32, TInt64, TUint8, TUint16, TUint32,
232 * TReal32, TReal64, TTime, TTimeIntervalMicroSeconds, Des8, or Des16.
233 * @return a symbian OS error code.
234 * @return KErrNone on successful operation.
235 * @return KErrPositionBufferOverflow if the data contained in the
236 * parameter aValue cannot be added to the class due to the buffer being too small.
238 template <class TType>
239 inline TInt SetValue(TPositionFieldId aFieldId, const TType& aValue)
240 {return PositionFieldManager::SetValue(aFieldId, aValue, *this);}
243 * Used to retrieve position information.
244 * @param aFieldId Standard position field identifier. See _TPositionFieldId
245 * @param [out] aValue The parameter aValue can be of the type
246 * TInt8, TInt16, TInt32, TInt64, TUint8, TUint16, TUint32,
247 * TReal32, TReal64, TTime, TTimeIntervalMicroSeconds, Des8, or Des16.
248 * Panics with EPositionGenericInfoMismatchDataType if there is a
249 * mismatch in the data type of a field.
250 * @return a symbian OS error code.
251 * @return KErrNone on successful operation.
252 * @return KErrOverflow if the supplied descriptor is too short to contain the requested field.
253 * This method must use the same data type as that assigned by SetValue() .
255 template <class TType>
256 inline TInt GetValue(TPositionFieldId aFieldId, TType& aValue) const
257 {return PositionFieldManager::GetValue(aFieldId, aValue, *this);}
260 HPositionGenericInfo(TInt aDataBufferSize, TInt aMaxFields,
261 TUint aFieldIndexStartPoint, TUint aDataStartPoint, TBool aResetRequestedFields);
263 * internal private method
265 HPositionGenericInfo& operator=(const HPositionGenericInfo&);
267 * internal private method
269 HPositionGenericInfo(const HPositionGenericInfo&);
271 TInt FindEmptyRequestedFieldOffset(TInt& aEmptyFieldOffset) const;
274 * Helper method. For internal usage only
276 inline TPositionFieldId* RequestedFieldPtr();
278 * Helper method. For internal usage only
280 inline const TPositionFieldId* RequestedFieldPtr() const;
282 * Helper method. For internal usage only
284 inline TPositionFieldIndex* FieldIndexPtr();
286 * Helper method. For internal usage only
288 inline const TPositionFieldIndex* FieldIndexPtr() const;
291 friend class TPositionFieldSetter;
292 friend class TPositionFieldGetter;
294 /** Max number of requesable/returnable fields. */
295 const TInt iMaxFields;
297 /** Offset into iBuffer of the field index. */
298 const TUint iFieldIndexStartPoint;
300 /** Offset into iBuffer of the actual location data. */
301 const TUint iDataStartPoint;
303 /** Total size of the buffer */
304 const TInt iTotalBufferSize;
306 /** Start of the buffer. The heap cell allocated for an instance of this class
307 has space for information up to iBuffer[iTotalBufferSize-1]*/
308 TUint8 iBuffer[1]; //Must be at end of class
311 #endif //__LBSPOSITIONINFO_H__