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