|
1 /* |
|
2 * Copyright (c) 2007 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 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include <lbspositioninfo.h> // TPositionInfoBase |
|
22 #include <lbs/epos_cpositioner.h> // CPositioner |
|
23 |
|
24 #include <dhcppsy.h> |
|
25 #include "dhcpwlanqueryhandler.h" |
|
26 #include "dhcppsylogging.h" |
|
27 #include "dhcppsypanic.h" |
|
28 #include "dhcppsy.hrh" |
|
29 #include "dhcppsypositioner.h" |
|
30 #include "dhcppsyrequester.h" |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CDhcpPsyRequester::CDhcpPsyRequester |
|
36 // C++default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CDhcpPsyRequester::CDhcpPsyRequester () |
|
41 { |
|
42 TRACESTRING( "CDhcpPsyRequester::CDhcpPsyRequester" ) |
|
43 } |
|
44 |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CDhcpPsyRequester::ConstructL |
|
48 // Symbian 2nd phase constructor can leave. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CDhcpPsyRequester::ConstructL() |
|
52 { |
|
53 TRACESTRING( "CDhcpPsyRequester::ConstructL start" ) |
|
54 iWlanDhcpQuery = CDhcpWlanQueryHandler::NewL(this); |
|
55 TRACESTRING( "CDhcpPsyRequester::ConstructL end" ) |
|
56 } |
|
57 |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CDhcpPsyRequester::NewL |
|
61 // Two - phased constructor. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CDhcpPsyRequester* CDhcpPsyRequester::NewL() |
|
65 { |
|
66 TRACESTRING( "CDhcpPsyRequester::NewL" ) |
|
67 CDhcpPsyRequester* self = new(ELeave) CDhcpPsyRequester (); |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 CleanupStack::Pop( self ); |
|
71 return self; |
|
72 } |
|
73 |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CDhcpPsyRequester::~CDhcpPsyRequester |
|
77 // |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CDhcpPsyRequester::~CDhcpPsyRequester() |
|
81 { |
|
82 TRACESTRING( "CDhcpPsyRequester::~CDhcpPsyRequester" ) |
|
83 Flush(); |
|
84 delete iLocationData; |
|
85 TRACESTRING( "CDhcpPsyRequester::~CDhcpPsyRequester,destructed" ) |
|
86 } |
|
87 |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CDhcpPsyRequester::NotifyPositionUpdate |
|
91 // |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void CDhcpPsyRequester::NotifyPositionUpdate (TPositionInfoBase& aPosInfo, |
|
95 TRequestStatus& aStatus ) |
|
96 { |
|
97 TRACESTRING( "CDhcpPsyRequester::NotifyPositionUpdate start" ) |
|
98 aStatus = KRequestPending; |
|
99 iRequestStatus = &aStatus; |
|
100 TInt result=FetchPositioningGenericData (aPosInfo); |
|
101 if (result==KErrNone) |
|
102 { |
|
103 // Start the location query |
|
104 TRAPD (err, iWlanDhcpQuery->MakeLocationQueryL (iIAPProfileId)) ; |
|
105 result = err; |
|
106 } |
|
107 if (result!=KErrNone) |
|
108 { |
|
109 CompleteRequest (result); |
|
110 } |
|
111 TRACESTRING( "CDhcpPsyRequester::NotifyPositionUpdate" ) |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CDhcpPsyRequester::FetchPositioningGenericData |
|
116 // |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 TInt CDhcpPsyRequester::FetchPositioningGenericData (TPositionInfoBase& aPosInfo) |
|
120 { |
|
121 TInt result=KErrArgument; |
|
122 TRACESTRING( "CDhcpPsyRequester::FetchPositioningGenericData" ) |
|
123 iPositionInfo = &aPosInfo; |
|
124 if (aPosInfo.PositionClassType () & EPositionGenericInfoClass) |
|
125 { |
|
126 HPositionGenericInfo* posInfo = |
|
127 static_cast<HPositionGenericInfo*>(iPositionInfo); |
|
128 if ( posInfo->IsRequestedField(EDhcpPsyIAPProfileIdField)) |
|
129 { |
|
130 result = posInfo->GetValue (EDhcpPsyIAPProfileIdField, iIAPProfileId); |
|
131 TRACESTRING2( "CDhcpPsyRequester::FetchPositioningGenericData, IAP id : %d ", iIAPProfileId ); |
|
132 } |
|
133 } |
|
134 TRACESTRING2( "CDhcpPsyRequester::FetchPositioningGenericData, result : %d ", result ); |
|
135 return result; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CDhcpPsyRequester::ProgressPsyRequestNotificationL |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CDhcpPsyRequester::ProgressPsyRequestNotificationL(TRequestProgressPhases aPhase, |
|
143 TInt aPhaseValue) |
|
144 { |
|
145 TRACESTRING2( "CDhcpPsyRequester::ProgressPsyRequestNotificationL, %d",aPhase); |
|
146 TRACESTRING2( "CDhcpPsyRequester::ProgressPsyRequestNotificationL, %d",aPhaseValue); |
|
147 switch ( aPhase ) |
|
148 { |
|
149 case MDhcpPsyRequesterProgressObserver::EConnectionInitiated: |
|
150 { |
|
151 // Nothing yet |
|
152 } |
|
153 break; |
|
154 case MDhcpPsyRequesterProgressObserver::ELocationQueryStarted: |
|
155 { |
|
156 // Location query started |
|
157 } |
|
158 break; |
|
159 case MDhcpPsyRequesterProgressObserver::ELocationQueryFinished: |
|
160 { |
|
161 // Location query finished, without problem or not. |
|
162 if(aPhaseValue==KErrNone&&!iCancelled) |
|
163 { |
|
164 HPositionGenericInfo* posInfo = |
|
165 static_cast<HPositionGenericInfo*>(iPositionInfo); |
|
166 posInfo->SetRequestedField(EDhcpPsyLocationResultDataField); |
|
167 if(iLocationData) |
|
168 { |
|
169 delete iLocationData; |
|
170 iLocationData = NULL; |
|
171 } |
|
172 |
|
173 TPtrC8 ptr(*iWlanDhcpQuery->LocationData()); |
|
174 iLocationData = ptr.AllocL(); |
|
175 ptr.Set(*iLocationData); |
|
176 posInfo->SetValue (EDhcpPsyLocationResultDataField, ptr ); |
|
177 } |
|
178 CompleteRequest (aPhaseValue); |
|
179 } |
|
180 break; |
|
181 case MDhcpPsyRequesterProgressObserver::ECancelled: |
|
182 { |
|
183 // Nothing yet |
|
184 } |
|
185 break; |
|
186 default: |
|
187 { |
|
188 TRACESTRING( "CDhcpPsyRequester::ProgressPsyRequestNotificationL, Not supported" ) |
|
189 User::Leave(KErrNotSupported); |
|
190 } |
|
191 break; |
|
192 } |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CDhcpPsyRequester::CancelRequest |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 void CDhcpPsyRequester::CancelRequest () |
|
200 { |
|
201 TRACESTRING( "CDhcpPsyRequester::CancelRequest" ) // |
|
202 if (iWlanDhcpQuery) |
|
203 { |
|
204 iWlanDhcpQuery->Cancel(); |
|
205 } |
|
206 |
|
207 if (iRequestStatus) |
|
208 { |
|
209 User::RequestComplete ( iRequestStatus, KErrNone ); |
|
210 } |
|
211 |
|
212 iCancelled = ETrue; |
|
213 TRACESTRING( "CDhcpPsyRequester::CancelRequest" ) // |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CDhcpPsyRequester::Flush |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 void CDhcpPsyRequester::Flush() |
|
221 { |
|
222 TRACESTRING( "CDhcpPsyRequester::Flush" ) |
|
223 delete iWlanDhcpQuery; |
|
224 iWlanDhcpQuery = NULL; |
|
225 } |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // CDhcpPsyRequester::CompleteRequest |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 void CDhcpPsyRequester::CompleteRequest(TInt aStatusCode) |
|
232 { |
|
233 TRACESTRING( "CDhcpPsyRequester::CompleteRequest" ) // |
|
234 //Set UID before complete the request |
|
235 iPositionInfo->SetModuleId( TUid::Uid( KDhcpPsyImplUid ) ); |
|
236 User::RequestComplete( iRequestStatus, aStatusCode ); |
|
237 TRACESTRING( "CDhcpPsyRequester::CompleteRequest, request complete" ) |
|
238 } |
|
239 |
|
240 // End of File |