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.
19 #include <lbspositioninfo.h>
20 #include <lbsareainfo.h>
22 #include <lbscommon.h>
23 #include <lbsrequestor.h>
24 #include <lbscriteria.h>
26 // Forward declarations
27 class CPositioningPtrHolder;
28 class CServerPositioningPtrHolder;
29 class RPositionServer : public RSessionBase
32 This is generally the first interface class used by all client applications.
33 It is used to make the primary connection to the location server. After the
34 primary connection has been established, its handle is passed as a parameter
35 of the Open methods of RPositioner to create a "sub-session".
37 The RPositionServer class can also be used to discover what position
38 technology "modules" are available. However, this is only required if a
39 client application actually needs to use a particular module. It is also
40 used for requests to clear(empty) the last known position store.
42 Asynchronous requests can be cancelled using the method CancelRequest() with
43 a value from the enumeration _TReqestId corresponding to the particular
44 operation being cancelled.
51 /** Type for values defined in _TRequestId
54 typedef TInt TRequestId;
56 /** Identification numbers used for cancelling requests.
57 Note that the TRequestId enum may be extended in the future by adding
58 more enumerated values. To maintain compatibility any unrecognized values
59 must be handled as EReqUnknown.
64 /** Unknown/undefined Id */
66 /** The id of the RPositionServer::NotifyModuleStatusEvent request */
67 EReqNotifyModuleStatusEvent = 1,
68 /** The id of the RPositionServer::EmptyLastKnownPositionStore request */
69 EReqEmptyLastKnownPositionStore = 2
73 IMPORT_C RPositionServer();
75 IMPORT_C TInt Connect();
76 IMPORT_C void Close();
78 IMPORT_C TInt CancelRequest(TRequestId aRequestId);
79 IMPORT_C TVersion Version() const;
81 IMPORT_C TInt GetDefaultModuleId(TPositionModuleId& aModuleId) const;
82 IMPORT_C TInt GetNumModules(TUint& aNumModules) const;
83 IMPORT_C TInt GetModuleInfoByIndex(TInt aModuleIndex,
84 TPositionModuleInfoBase& aModuleInfo) const;
85 IMPORT_C TInt GetModuleInfoById(TPositionModuleId aModuleId,
86 TPositionModuleInfoBase& aModuleInfo) const;
88 IMPORT_C TInt GetModuleStatus(TPositionModuleStatusBase& aPosModuleStatus,
89 TPositionModuleId aModuleId) const;
91 IMPORT_C void NotifyModuleStatusEvent(TPositionModuleStatusEventBase& aStatusEvent,
92 TRequestStatus& aStatus,
93 const TPositionModuleId aModuleId = KPositionNullModuleId) const;
95 IMPORT_C void EmptyLastKnownPositionStore(TRequestStatus& aStatus);
100 static TInt StartServer();
103 /** A pointer to a container that holds pointer descriptors, needed to point
104 to the clients request data during asynchronous requests */
105 CServerPositioningPtrHolder* iPtrHolder;
107 /** Variable for future expansion. */
112 class RPositionerSubSessionBase : public RSubSessionBase
114 Abstract base class for all positioning sub-sessions, including RPositioner.
116 Asynchronous requests issued from derived classess are cancelled using the
117 method CancelRequest() with a value from the enumeration _TReqestId corresponding
118 to the particular operation being cancelled.
128 /** Type for values defined in _TRequestId
131 typedef TInt TRequestId;
133 /** Identification numbers used for cancelling requests.
134 Note that the TRequestId enum may be extended in the future by adding
135 more enumerated values. To maintain compatibility any unrecognized values
136 must be handled as EReqUnknown.
141 /** Unknown/undefined Id */
143 /** The id of the GetLastKnownPosition request */
144 EReqGetLastKnownPosition = 1,
145 /** The id of the GetLastKnownPositionArea request */
146 EReqGetLastKnownPositionArea = 2,
147 /** The id of the ReqNotifyPositionUpdate request */
148 EReqNotifyPositionUpdate = 3
151 IMPORT_C TInt CancelRequest(TRequestId aRequestId);
153 IMPORT_C TInt CompleteRequest(TInt aRequestId);
156 IMPORT_C RPositionerSubSessionBase();
158 IMPORT_C virtual TAny* ExtendedInterface(TInt aFunctionNumber, TAny* aPtr1, TAny* aPtr2);
161 /** Unused variable for future expansion. */
166 class RPositioner : public RPositionerSubSessionBase
168 This class is used to create a sub-session with the server for the
169 purpose of obtaining the current position. In addition to actually
170 obtaining position information, this class also provides mechanisms
171 for obtaining the last known position, the last known position with
172 area information, the general status of the positioning module,
173 changing how often it wishes to receive position updates, as well as
174 identifying itself to the location framework.
176 Before using the class, a primary connection must have already been
177 established with the server.
186 IMPORT_C RPositioner();
188 IMPORT_C TInt Open(RPositionServer& aPosServer);
189 IMPORT_C TInt Open(RPositionServer& aPosServer,
190 TPositionModuleId aModuleId);
191 IMPORT_C TInt Open(RPositionServer& aPosServer,
192 const TPositionCriteriaBase& aCriteria);
193 IMPORT_C void Close();
195 IMPORT_C TInt SetRequestor(CRequestor::TRequestorType aType,
196 CRequestor::TRequestorFormat aFormat,
198 IMPORT_C TInt SetRequestor(const RRequestorStack& aRequestorStack);
200 IMPORT_C TInt SetUpdateOptions(const TPositionUpdateOptionsBase& aPosOption);
201 IMPORT_C TInt GetUpdateOptions(TPositionUpdateOptionsBase& aPosOption) const;
203 IMPORT_C void GetLastKnownPosition(TPositionInfoBase& aPosInfo,
204 TRequestStatus& aStatus) const;
206 IMPORT_C void GetLastKnownPositionArea(TPositionInfoBase& aPosInfo,
207 TPositionAreaInfoBase& aAreaInfo,
208 TRequestStatus& aStatus) const;
210 IMPORT_C void NotifyPositionUpdate(TPositionInfoBase& aPosInfo,
211 TRequestStatus& aStatus) const;
214 IMPORT_C virtual void ConstructL();
215 IMPORT_C virtual void Destruct();
216 IMPORT_C virtual TAny* ExtendedInterface(TInt aFunctionNumber, TAny* aPtr1, TAny* aPtr2);
219 TInt OpenImpl(RPositionServer& aPosServer, TPositionModuleId aModuleId, const TPositionCriteriaBase& aCriteria, TBool aOpenedUsingModuleId);
221 /** A pointer to a container that holds pointer descriptors, needed to point
222 to the clients request data during asynchronous requests */
223 CPositioningPtrHolder* iPtrHolder;
224 /** Unused variable for future expansion. */