|
1 /* |
|
2 * Copyright (c) 2002-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 "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: Class to create,manage and destroy requestors for each request |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CLBSSUPLTIREQUESTMANAGER_H |
|
19 #define CLBSSUPLTIREQUESTMANAGER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <lbs/lbsnetcommon.h> |
|
25 #include <epos_suplterminal.h> |
|
26 |
|
27 //FORWARD DECALRATIONS |
|
28 class CCLbsSuplTiApiRequestor; |
|
29 class COMASuplTrace; |
|
30 class MLbsSuplTiObserver; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * Class: CCLbsSuplTiRequestManager |
|
36 * |
|
37 * Description: This class creates and manages all CCLbsSuplTiApiRequestor objects |
|
38 * using for making the location requests. Each time a new request is made |
|
39 * using the CSuplTiApi::RequestLocation with a new session id, this class |
|
40 * creates a new CCLbsSuplTiApiRequestor object which is used to make a |
|
41 * location request. The ownership of the created object is held |
|
42 * by this class in the iRequestorCollection array. |
|
43 */ |
|
44 class CCLbsSuplTiRequestManager : public CActive |
|
45 { |
|
46 public: |
|
47 // Constructors and destructor |
|
48 |
|
49 /** |
|
50 * Destructor for CCLbsSuplTiRequestManager. |
|
51 */ |
|
52 ~CCLbsSuplTiRequestManager(); |
|
53 |
|
54 /** |
|
55 * Two-phased constructor. |
|
56 */ |
|
57 static CCLbsSuplTiRequestManager* NewL(MLbsSuplTiObserver& aObserver); |
|
58 |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 */ |
|
62 static CCLbsSuplTiRequestManager* NewLC(MLbsSuplTiObserver& aObserver); |
|
63 |
|
64 public: |
|
65 |
|
66 /** |
|
67 * @Description: Method to make the initial location request. |
|
68 * Each time a location request is made this methos |
|
69 * searches the iRequestorCollection for the session id. |
|
70 * If the session id is not found then creates a new requestor object |
|
71 * and initaites the location request. |
|
72 * |
|
73 * @param: aSessionId is the Id of the location request.This id is passed |
|
74 * to the TI API's request id as argument |
|
75 * |
|
76 * @param aOptions should be of type TLbsNetPosRequestOptions. |
|
77 * This is used to retrieve the TSuplTerminalQop and |
|
78 * First Req paramaters to be passed to the TI API's |
|
79 * RunSession Method. |
|
80 * |
|
81 * @param aMethod This parameter contains a list of the positioning methods |
|
82 * that should be used to obtain the device's position. |
|
83 * This is used to for setCaps to be sent to the RunSession method. |
|
84 * |
|
85 * @return: None |
|
86 * |
|
87 */ |
|
88 void RequestLocation(const TLbsNetSessionId& aSessionId, const TLbsNetPosRequestOptionsBase& aOptions, const TLbsNetPosRequestMethod& aMethod); |
|
89 |
|
90 /** |
|
91 * @Description: Method to cancel the request made using the RequestLocation() method. |
|
92 * This method searches the iRequestorCollection for the session id. |
|
93 * If the session id is found then this method uses the corresponding |
|
94 * requestor object to cancel the asynchronous request. |
|
95 * If the session id is not found then it returns an error. |
|
96 * @param: aPositionInfo the position value is returned in this |
|
97 * @return: KErrNone if position retrieved successfully |
|
98 * KErrNotFound if session id not found |
|
99 * TODO: Other error codes to be put here |
|
100 * |
|
101 */ |
|
102 |
|
103 TInt CancelRequest(const TLbsNetSessionId& aSessionId); |
|
104 |
|
105 /** |
|
106 * @Description: Method to retrieve the Position obtained for request made |
|
107 * using the RequestLocation() method. |
|
108 * This method searches the iRequestorCollection for the session id. |
|
109 * If the session id is found then this method uses the corresponding |
|
110 * requestor object to retrieve the position present in that requestor. |
|
111 * If the session id is not found then it returns an error. |
|
112 * @param: aPositionInfo the position value is returned in this |
|
113 * @return: KErrNone if position retrieved successfully |
|
114 * KErrNotFound if session id not found |
|
115 * TODO: Other error codes to be put here |
|
116 * |
|
117 */ |
|
118 |
|
119 TInt GetPosition(const TLbsNetSessionId& aSessionId, TPositionInfoBase& aPositionInfo); |
|
120 |
|
121 /* |
|
122 * @Description: Method to close open sessions with server |
|
123 * @return None |
|
124 * |
|
125 */ |
|
126 void CloseSession(); |
|
127 |
|
128 private: |
|
129 // From CActive |
|
130 // Handle completion |
|
131 void RunL(); |
|
132 |
|
133 // For cancelling Ashnchronous requests |
|
134 void DoCancel(); |
|
135 |
|
136 // Override to handle leaves from RunL(). |
|
137 TInt RunError(TInt aError); |
|
138 |
|
139 /** |
|
140 * Constructor for performing 1st stage construction |
|
141 */ |
|
142 CCLbsSuplTiRequestManager(MLbsSuplTiObserver& aObserver); |
|
143 |
|
144 /** |
|
145 * EPOC default constructor for performing 2nd stage construction |
|
146 */ |
|
147 void ConstructL(); |
|
148 |
|
149 /** |
|
150 * @Description: Method to search and determine if a requestor exists |
|
151 * corresponding to a particular session id. |
|
152 * Searches the iRequestorCollection for the session id. |
|
153 * @param: aSessionId Session Id to search |
|
154 * @return: index of the requestor in the iRequestorCollection array if found |
|
155 * KErrNotFound otherwise |
|
156 * |
|
157 */ |
|
158 TInt FindSessionId(const TLbsNetSessionId& aSessionId); |
|
159 |
|
160 /** |
|
161 * @Description: Method to initiate the location request once a valid server handle is established. |
|
162 * If a valid server handle exists already this method is called to initiate location |
|
163 * request. |
|
164 * @param: none |
|
165 * @return: none |
|
166 * |
|
167 */ |
|
168 void InitiateLocationRequest(); |
|
169 private : |
|
170 |
|
171 //To signal completion |
|
172 MLbsSuplTiObserver& iObserver; |
|
173 //Hold a pointer to all requestor objects that were used to make location requests |
|
174 RPointerArray<CCLbsSuplTiApiRequestor> iRequestorCollection; |
|
175 |
|
176 RSuplTerminalServer iServer; |
|
177 |
|
178 /*For Logging*/ |
|
179 COMASuplTrace* iTrace; |
|
180 |
|
181 TLbsNetSessionId iSessionId; |
|
182 TLbsNetPosRequestOptionsBase iOptions; |
|
183 TLbsNetPosRequestMethod iMethod; |
|
184 }; |
|
185 |
|
186 #endif // CLBSSUPLTIREQUESTMANAGER_H |