author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 17 Sep 2010 08:37:32 +0300 | |
changeset 60 | 9a7e3d5f461a |
parent 51 | 95c570bf4a05 |
permissions | -rw-r--r-- |
36 | 1 |
// Copyright (c) 2005-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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// INCLUDE FILES |
|
15 |
// |
|
16 |
||
17 |
||
18 |
||
19 |
#include <e32base.h> |
|
20 |
#include <e32svr.h> |
|
21 |
#include <ecom/ecom.h> |
|
22 |
#include <connect/sbdefs.h> |
|
23 |
||
24 |
//#include <LbsIpc.h> |
|
25 |
//#include <StartPosServer.h> |
|
26 |
#include <lbsipc.h> |
|
27 |
#include "lbslocservermessageenums.h" |
|
28 |
#include "EPos_CPosResourceReader.h" |
|
29 |
#include <eposserver.rsg> |
|
30 |
#include <lbs/epos_mposmodulesobserver.h> |
|
60
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
31 |
#include <centralrepository.h> |
36 | 32 |
#ifdef SYMBIAN_FEATURE_MANAGER |
33 |
#include <featdiscovery.h> |
|
34 |
#include <featureuids.h> |
|
35 |
#endif |
|
36 |
#include "epos_cposmodulessettings.h" |
|
37 |
#include "EPos_CPosServer.h" |
|
38 |
#include "EPos_ServerPanic.h" |
|
39 |
#include "EPos_CPosSession.h" |
|
40 |
#include "EPos_CPosServerDelayedShutdown.h" |
|
41 |
#include "EPos_CPosModulesStatus.h" |
|
42 |
#include "EPos_CPosLocMonitorReqHandlerHub.h" |
|
60
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
43 |
#include "lbsrootcenrepdefs.h" |
36 | 44 |
|
45 |
#include "EPos_Global.h" |
|
46 |
#include "lbspositioningstatusprops.h" |
|
47 |
||
48 |
// CONSTANTS |
|
49 |
_LIT(KPosResourceFile, "\\private\\101F97B2\\eposserver.rsc"); |
|
50 |
||
51 |
#ifdef _DEBUG |
|
52 |
_LIT(KTraceFileName, "EPos_CPosServer.cpp"); |
|
53 |
#endif |
|
54 |
||
55 |
// ================= SERVER'S POLICY ======================= |
|
56 |
||
57 |
//Definition of the ranges of IPC numbers |
|
58 |
const TInt eposServerPolicyRanges[] = |
|
59 |
{ |
|
60 |
0, |
|
61 |
ELbsServerCancelAsyncRequest, |
|
62 |
ELbsGetDefaultModuleId, |
|
63 |
ELbsEmptyLastKnownPositionStore, |
|
64 |
ELbsServerLastMessageId, |
|
65 |
||
66 |
ELbsPositionerCancelAsyncRequest, |
|
67 |
ELbsPositionerOpen, |
|
68 |
ELbsPositionerClose, |
|
69 |
ELbsSetSingleRequestor, |
|
70 |
ELbsPositionerLastMessageId, |
|
71 |
ELbsPositionCustomCodesFirst |
|
72 |
}; |
|
73 |
||
74 |
// Total number of ranges |
|
75 |
const TUint eposServerPolicyRangeCount = |
|
76 |
sizeof(eposServerPolicyRanges) / sizeof(TInt); |
|
77 |
||
78 |
// Types of Policies |
|
79 |
enum TPolicies |
|
80 |
{ |
|
81 |
EPolicyLocationNeeded = 0, |
|
82 |
EPolicyWriteUserDataNeeded, |
|
83 |
}; |
|
84 |
||
85 |
// Specific capability checks |
|
86 |
const CPolicyServer::TPolicyElement eposServerPolicyElements[] = |
|
87 |
{ |
|
88 |
// policy EPolicyLocationNeeded - fail call if Location not present |
|
89 |
{_INIT_SECURITY_POLICY_C1(ECapabilityLocation), CPolicyServer::EFailClient}, |
|
90 |
// policy EPolicyWriteUserDataNeeded - fail call if WriteUserData capability not present |
|
91 |
{_INIT_SECURITY_POLICY_C1(ECapabilityWriteUserData), CPolicyServer::EFailClient} |
|
92 |
}; |
|
93 |
||
94 |
//Policy to implement for each of the above ranges |
|
95 |
const TUint8 eposServerPolicyElementsIndex[eposServerPolicyRangeCount] = |
|
96 |
{ |
|
97 |
CPolicyServer::ENotSupported, |
|
98 |
CPolicyServer::EAlwaysPass, // server cancel |
|
99 |
EPolicyLocationNeeded, // GetDefModId -> NotifyModStatusEv |
|
100 |
EPolicyWriteUserDataNeeded, // Empty Last Known position store |
|
101 |
CPolicyServer::ENotSupported, // reserved server's codes |
|
102 |
CPolicyServer::EAlwaysPass, // positioner cancel |
|
103 |
CPolicyServer::EAlwaysPass, // open methods |
|
104 |
CPolicyServer::EAlwaysPass, // close positioner |
|
105 |
EPolicyLocationNeeded, // SetSingReq -> GetLastKnownPositionArea |
|
106 |
CPolicyServer::ENotSupported, // reserved positioner's codes |
|
107 |
CPolicyServer::ECustomCheck // custom requests |
|
108 |
}; |
|
109 |
||
110 |
//Package all the above together into a policy |
|
111 |
const CPolicyServer::TPolicy eposServerPolicy = |
|
112 |
{ |
|
113 |
CPolicyServer::EAlwaysPass, // onConnect |
|
114 |
eposServerPolicyRangeCount, // number of ranges |
|
115 |
eposServerPolicyRanges, // ranges array |
|
116 |
eposServerPolicyElementsIndex, // elements<->ranges index |
|
117 |
eposServerPolicyElements, // array of elements |
|
118 |
}; |
|
119 |
||
120 |
// ================= MEMBER FUNCTIONS ======================= |
|
121 |
||
122 |
/** |
|
123 |
* C++ constructor. |
|
124 |
* |
|
125 |
* @param aPriority Priority at which to run the server active object. |
|
126 |
* @param aPolicy Reference to a policy object describing the security |
|
127 |
* checks required for each message type. |
|
128 |
* @param aServerType Sharable or non-sharable sessions. |
|
129 |
*/ |
|
130 |
CPosServer::CPosServer(TInt aPriority, const TPolicy &aPolicy, TServerType aServerType) |
|
131 |
: CPolicyServer(aPriority, aPolicy, aServerType) |
|
132 |
{ |
|
133 |
} |
|
134 |
||
135 |
/** |
|
136 |
* Symbian default constructor. |
|
137 |
*/ |
|
138 |
void CPosServer::ConstructL() |
|
139 |
{ |
|
51
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
140 |
#if defined __WINSCW__ && defined SYMBIAN_CELLMO_CENTRIC |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
141 |
TBool LocationManagementSupported = EFalse; |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
142 |
#else |
36 | 143 |
#ifdef SYMBIAN_FEATURE_MANAGER |
51
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
144 |
TBool LocationManagementSupported = CFeatureDiscovery::IsFeatureSupportedL(NFeature::KLocationManagement); |
36 | 145 |
#else |
146 |
__ASSERT_ALWAYS(EFalse, User::Invariant()); // Would happen on older versions of symbian OS if this code ever backported |
|
51
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
147 |
#endif // SYMBIAN_FEATURE_MANAGER |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
148 |
#endif // __WINSCW__ && defined SYMBIAN_CELLMO_CENTRIC |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
149 |
|
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
150 |
|
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
151 |
#if defined __WINSCW__ |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
152 |
if(LocationManagementSupported && !FindRootProcess()) |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
153 |
{ |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
154 |
_LIT(KLbsRootFileName, "\\sys\\bin\\lbsroot.exe"); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
155 |
_LIT(KLbsRootProcessName, "lbsroot.exe"); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
156 |
_LIT(KLbsCommandLine, ""); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
157 |
RProcess process; |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
158 |
TInt r=process.Create(KLbsRootProcessName,KLbsCommandLine); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
159 |
if (r!=KErrNone) |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
160 |
{ |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
161 |
User::Leave(r); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
162 |
} |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
163 |
TRequestStatus stat; |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
164 |
process.Rendezvous(stat); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
165 |
if (stat!=KRequestPending) |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
166 |
{ |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
167 |
process.Kill(0); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
168 |
} |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
169 |
else |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
170 |
{ |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
171 |
process.Resume(); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
172 |
} |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
173 |
User::WaitForRequest(stat); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
174 |
r=(process.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
175 |
|
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
176 |
process.Close(); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
177 |
if (r!=KErrNone) |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
178 |
{ |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
179 |
User::Leave(r); |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
180 |
} |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
181 |
} |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
182 |
#endif // WINSCW |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
183 |
|
36 | 184 |
// Backup listener |
185 |
DEBUG_TRACE("Checking for backup or restore...", __LINE__) |
|
186 |
iBackupListener = CPosBackupListener::NewL(); |
|
187 |
if (iBackupListener->IsBackupOperationOngoing()) |
|
188 |
{ |
|
189 |
User::Leave(KErrNotReady); |
|
190 |
} |
|
191 |
iBackupListener->Start(*this); |
|
192 |
||
193 |
||
194 |
// Settings and last position handler |
|
195 |
CPosResourceReader* resources = CPosResourceReader::NewLC(KPosResourceFile); |
|
196 |
iServerShutdownDelay = resources->ReadInt32L(R_POS_SERVER_SHUTDOWN_DELAY); |
|
197 |
||
198 |
TInt dumpInterval = resources->ReadInt32L(R_POS_SERVER_DUMP_INTERVAL); |
|
199 |
||
200 |
//DEBUG_TRACE("Reading last known position...", __LINE__) |
|
201 |
// HBufC* lastKnownPositionFileName = resources->ReadHBufCL(R_LAST_KNOWN_POSITION_FILENAME); |
|
202 |
// CleanupStack::PushL(lastKnownPositionFileName); |
|
203 |
iLocMonitorReqHandlerHub = CPosLocMonitorReqHandlerHub::NewL(); |
|
204 |
||
205 |
||
206 |
CleanupStack::PopAndDestroy(resources); |
|
207 |
||
208 |
// Shutdown timer |
|
209 |
iShutdown = CPosServerDelayedShutdown::NewL(); |
|
210 |
||
211 |
||
212 |
DEBUG_TRACE("Opening Location Settings...", __LINE__) |
|
213 |
// Location Settings |
|
214 |
iModuleSettings = CPosModuleSettings::NewL(); |
|
215 |
iModulesStatus = CPosModulesStatus::NewL(iModuleSettings->PosModules()); |
|
216 |
DEBUG_TRACE("Setting Location Settings observer...", __LINE__) |
|
217 |
iModuleSettings->AddListenerL(*this); |
|
218 |
||
219 |
// Define the MO Positioning Status property |
|
220 |
LbsPositioningStatusProps::InitializeMoPropertyL(); |
|
60
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
221 |
|
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
222 |
// Reset the key to zero |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
223 |
TInt posStatusCategory; |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
224 |
|
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
225 |
CRepository* rep = CRepository::NewLC(KLbsCenRepUid); |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
226 |
TInt err = rep->Get(KMoPositioningStatusAPIKey, posStatusCategory); |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
227 |
if( err == KErrNone ) |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
228 |
{ |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
229 |
err = RProperty::Set(TUid::Uid(posStatusCategory), KLbsMoPositioningStatusKey,0); |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
230 |
} |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
231 |
CleanupStack::PopAndDestroy(rep); |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
232 |
|
36 | 233 |
DEBUG_TRACE("Starting server active object...", __LINE__) |
234 |
StartL(KPositionServerName); |
|
235 |
} |
|
236 |
||
237 |
/** |
|
238 |
* Two-phased constructor. |
|
239 |
*/ |
|
240 |
CPosServer* CPosServer::NewL() |
|
241 |
{ |
|
242 |
CPosServer* self = new (ELeave) CPosServer(EPriority, eposServerPolicy); |
|
243 |
CleanupStack::PushL(self); |
|
244 |
self->ConstructL(); |
|
245 |
CleanupStack::Pop(self); |
|
246 |
return self; |
|
247 |
} |
|
248 |
||
249 |
/** |
|
250 |
* Destructor. |
|
251 |
*/ |
|
252 |
CPosServer::~CPosServer() |
|
253 |
{ |
|
254 |
delete iLocMonitorReqHandlerHub; |
|
255 |
||
256 |
delete iShutdown; |
|
257 |
delete iModulesStatus; |
|
258 |
delete iModuleSettings; |
|
259 |
delete iBackupListener; |
|
260 |
||
261 |
||
262 |
// This is needed because CPositioner might have used ECom (PSYs) |
|
263 |
REComSession::FinalClose(); |
|
264 |
} |
|
265 |
||
266 |
/** |
|
267 |
* From MPosModuleSettingsListener. |
|
268 |
* |
|
269 |
* Called when a change has been detected in the modules database. |
|
270 |
* @param aEvent Event information |
|
271 |
*/ |
|
272 |
void CPosServer::HandleModuleSettingsChangedL(TPosModulesEvent aEvent) |
|
273 |
{ |
|
274 |
// Notify iModuleStatus |
|
275 |
iModulesStatus->HandleSettingsChangeL(aEvent); |
|
276 |
||
277 |
// For all sessions, call HandleSettingsChangeL() |
|
278 |
iSessionIter.SetToFirst(); |
|
279 |
CPosSession* session = static_cast <CPosSession*> (iSessionIter++); |
|
280 |
while (session) |
|
281 |
{ |
|
282 |
session->HandleSettingsChangeL(aEvent); |
|
283 |
session = static_cast <CPosSession*> (iSessionIter++); |
|
284 |
} |
|
285 |
} |
|
286 |
||
287 |
/** |
|
288 |
* From MPosBackupEventCallback |
|
289 |
* |
|
290 |
* Called by iBackupListener when a backup or restore |
|
291 |
* operation either starts. Shuts down the server. |
|
292 |
*/ |
|
293 |
void CPosServer::HandleBackupOperationEventL() |
|
294 |
{ |
|
295 |
||
296 |
DEBUG_TRACE("HandleBackupOperationEventL", __LINE__) |
|
297 |
conn::TBURPartType state = conn::EBURUnset; |
|
298 |
conn::TBackupIncType type = conn::ENoBackup; |
|
299 |
iBackupListener->GetCurrentValue(state, type); |
|
300 |
||
301 |
// At the moment it just shuts down if backup/restore is in progress |
|
302 |
if ((state != conn::EBURUnset) && (state != conn::EBURNormal)) |
|
303 |
{ |
|
304 |
iSessionIter.SetToFirst(); |
|
305 |
CPosSession* session = static_cast <CPosSession*> (iSessionIter++); |
|
306 |
while (session) |
|
307 |
{ |
|
308 |
session->NotifyServerShutdown(); |
|
309 |
session = static_cast <CPosSession*> (iSessionIter++); |
|
310 |
} |
|
311 |
||
312 |
// Shutdown the server by shutting down the active scheduler. |
|
313 |
CActiveScheduler::Stop(); |
|
314 |
} |
|
315 |
else |
|
316 |
{ |
|
317 |
iBackupListener->Start(*this); // continue listening |
|
318 |
} |
|
319 |
} |
|
320 |
||
321 |
/** |
|
322 |
* From CServer2 |
|
323 |
*/ |
|
324 |
CSession2* CPosServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const |
|
325 |
{ |
|
326 |
// Check we're the right version |
|
327 |
TVersion version(KPosMajorVersionNumber, |
|
328 |
KPosMinorVersionNumber, |
|
329 |
KPosBuildVersionNumber); |
|
330 |
if (!User::QueryVersionSupported(version, aVersion)) |
|
331 |
{ |
|
332 |
User::Leave(KErrNotSupported); |
|
333 |
} |
|
334 |
||
335 |
// Make new session |
|
336 |
CPosSession* newSession = |
|
337 |
CPosSession::NewL( |
|
338 |
*(const_cast<CPosServer*>(this)), |
|
339 |
*iModuleSettings, |
|
340 |
*iModulesStatus, |
|
341 |
*iLocMonitorReqHandlerHub); |
|
342 |
||
343 |
return newSession; |
|
344 |
} |
|
345 |
||
346 |
/** |
|
347 |
* From CPolicyServer |
|
348 |
*/ |
|
349 |
CPolicyServer::TCustomResult CPosServer::CustomSecurityCheckL(const RMessage2& /*aMsg*/, TInt& /*aAction*/,TSecurityInfo& /*aMissing*/) |
|
350 |
{ |
|
351 |
DEBUG_TRACE("CustomSecurityCheck", __LINE__) |
|
352 |
return CPolicyServer::EFail; |
|
353 |
} |
|
354 |
||
355 |
/** |
|
356 |
* Increment number of sessions |
|
357 |
*/ |
|
358 |
void CPosServer::IncrementSessions() |
|
359 |
{ |
|
360 |
DEBUG_TRACE("IncrementSessions", __LINE__) |
|
361 |
||
362 |
iNumSessions++; |
|
363 |
iShutdown->Cancel(); |
|
364 |
} |
|
365 |
||
366 |
/** |
|
367 |
* Decrement number of sessions |
|
368 |
*/ |
|
369 |
void CPosServer::DecrementSessions() |
|
370 |
{ |
|
371 |
DEBUG_TRACE("DecrementSessions", __LINE__) |
|
372 |
||
373 |
// This panic handles an internal error. |
|
374 |
__ASSERT_DEBUG(iNumSessions > 0, |
|
375 |
DebugPanic(EPosServerPanicSessionsCountInconsistency)); |
|
376 |
||
377 |
if (--iNumSessions == 0) |
|
378 |
{ |
|
379 |
iShutdown->Start(iServerShutdownDelay); |
|
380 |
} |
|
381 |
} |
|
382 |
||
383 |
TBool CPosServer::FindRootProcess() |
|
384 |
{ |
|
385 |
_LIT(KLbsRootProcessName, "lbsroot.exe*"); |
|
386 |
TInt err(KErrNotFound); |
|
387 |
TFullName fullName; |
|
388 |
TFindProcess processFinder(KLbsRootProcessName); |
|
389 |
while (err = processFinder.Next(fullName), err == KErrNone) |
|
390 |
{ |
|
391 |
RProcess process; |
|
392 |
TInt processOpenErr = process.Open(processFinder); |
|
393 |
if (processOpenErr == KErrNone) |
|
394 |
{ |
|
395 |
TExitType exitType = process.ExitType(); |
|
396 |
if (exitType == EExitPending) |
|
397 |
{ |
|
398 |
// Found a running instance of lbsroot.exe, |
|
399 |
return ETrue; |
|
400 |
} |
|
401 |
} |
|
402 |
process.Close(); |
|
403 |
} |
|
404 |
||
405 |
return EFalse; |
|
406 |
} |
|
407 |
// End of File |
|
408 |