CScsServer Class Reference

class CScsServer : public CPolicyServer

The main server object allocates sessions. It also uses a shutdown timer to stop the server when there have been no open sessions for a set period.

The implementor must define a subclass which returns session objects of the appropriate type.

Inherits from

Public Member Functions
~CScsServer()
voidAddAsyncRequestL(CAsyncRequest *)
voidCancelAsyncRequest(CScsSession *, CScsSubsession *, TInt)
voidCancelOutstandingRequests(CScsSession *, TBool)
voidCancelOutstandingRequests(CScsSession *, CScsSubsession *, TBool)
voidDecrementSessionCount()
IMPORT_C voidDoPostHeapMarkOrCheckL()
IMPORT_C voidDoPreHeapMarkOrCheckL()
voidIncrementSessionCount()
TInt SessionCount()
IMPORT_C voidShutdownWhenIdleL()
TInt StripScsFunctionMask(TInt)
Protected Member Functions
CScsServer(const TVersion &, CActive::TPriority)
CScsServer(const TVersion &, const CPolicyServer::TPolicy &, CActive::TPriority)
IMPORT_C voidConstructL(TInt)
IMPORT_C voidDisableShutdownTimer()
CScsSession *DoNewSessionL(const RMessage2 &)
IMPORT_C voidEnableShutdownTimerL(TInt)
IMPORT_C CSession2 *NewSessionL(const TVersion &, const RMessage2 &)
Private Member Functions
CAsyncRequest *FindAsyncRequest(CScsSession *, CScsSubsession *, TInt)
TInt RemoveCompletedRequests(TAny *)
voidRemoveCompletedRequests()
Inherited Functions
CActive::CActive(TInt)
CActive::Cancel()
CActive::Deque()
CActive::IsActive()const
CActive::IsAdded()const
CActive::Priority()const
CActive::SetActive()
CActive::SetPriority(TInt)
CActive::~CActive()
CBase::CBase()
CBase::Delete(CBase *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
CPolicyServer::CPolicyServer(TInt,const TPolicy &,TServerType)
CPolicyServer::CheckFailedL(const RMessage2 &,TInt,const TSecurityInfo &)
CPolicyServer::CustomFailureActionL(const RMessage2 &,TInt,const TSecurityInfo &)
CPolicyServer::CustomSecurityCheckL(const RMessage2 &,TInt &,TSecurityInfo &)
CPolicyServer::Extension_(TUint,TAny *&,TAny *)
CPolicyServer::ProcessError(const RMessage2 &,TInt)
CPolicyServer::ProcessL(const RMessage2 &)
CServer2::CServer2(TInt,TServerType)
CServer2::DoCancel()
CServer2::DoConnect(const RMessage2 &)
CServer2::Message()const
CServer2::ReStart()
CServer2::Server()const
CServer2::SetMaster(const CServer2 *)
CServer2::SetPinClientDescriptors(TBool)
CServer2::Start(const TDesC &)
CServer2::StartL(const TDesC &)
CServer2::~CServer2()
Public Member Enumerations
enumTFunctionRanges { EBaseSession = 0x01000000, EBaseSubSession = 0x02000000, EBaseMustAllow = 0x03000000 }
Inherited Enumerations
CActive:TPriority
CPolicyServer:TCustomResult
CPolicyServer:TFailureAction
CPolicyServer:TSpecialCase
CServer2:TPanic
CServer2:TServerType
Public Attributes
CAsyncCallBack *iAsyncCleanup
RPointerArray< CAsyncRequest >iAsyncRequests
CObjectConIx *iContainerIndex
Private Attributes
TInt iSessionCount
CShutdownTimer *iShutdownTimer
const TVersioniVersion
Inherited Attributes
CActive::iStatus
CServer2::iSessionIter

Constructor & Destructor Documentation

CScsServer(const TVersion &, CActive::TPriority)

IMPORT_CCScsServer(const TVersion &aVersion,
CActive::TPriorityaPriority = CActive::EPriorityStandard
)[protected]

Record this server's version so it can be compared against the requested version in NewSessionL.

Parameters

const TVersion & aVersionThis server's version. This is compared against each client's requested version when the client tries to connect.
CActive::TPriority aPriority = CActive::EPriorityStandardThis server's active object priority.

CScsServer(const TVersion &, const CPolicyServer::TPolicy &, CActive::TPriority)

IMPORT_CCScsServer(const TVersion &aVersion,
const CPolicyServer::TPolicy &aPolicy,
CActive::TPriorityaPriority = CActive::EPriorityStandard
)[protected]

Record this server's version so it can be compared against the requested version in NewSessionL.

Note that aPolicy must be configured to allow all functions covered by the KScsFunctionMask mask.

Parameters

const TVersion & aVersionThis server's version. This is compared against each client's requested version when the client tries to connect.
const CPolicyServer::TPolicy & aPolicyCan be used to configure security for server connect and session functions
CActive::TPriority aPriority = CActive::EPriorityStandardThis server's active object priority.

~CScsServer()

IMPORT_C~CScsServer()[virtual]

Frees resources used at this level. Specifically, frees the container index, which is used to generate subsession containers, the shutdown timer, and the async request cleanup object.

Member Functions Documentation

AddAsyncRequestL(CAsyncRequest *)

voidAddAsyncRequestL(CAsyncRequest *aAsyncRequest)

Add the supplied request to the server's collection.

Parameters

CAsyncRequest * aAsyncRequestRequest to add. If this function succeeds then ownership has been transferred to the collection.

CancelAsyncRequest(CScsSession *, CScsSubsession *, TInt)

voidCancelAsyncRequest(CScsSession *aSession,
CScsSubsession *aSubsession,
TIntaFunction
)

Cancels a specific (sub)session request in response to a client command. Also completes the client request.

CancelOutstandingRequest should be called when a (sub)session is closed.

Parameters

CScsSession * aSessionSession which hosts the request.
CScsSubsession * aSubsessionSubsession which hosts the request, NULL if the request is relative to a session.
TInt aFunctionThe function identifier, without any SCS code.

CancelOutstandingRequests(CScsSession *, TBool)

voidCancelOutstandingRequests(CScsSession *aSession,
TBoolaCompleteClientRequests
)

Cancels and deletes all outstanding asynchronous requests associated with the supplied session or any of its subsessions. Does not complete the associated client requests.

This function should be called when a session is closed. CancelAsyncRequest should be called when a specific request is cancelled.

Parameters

CScsSession * aSessionSession which is being closed.
TBool aCompleteClientRequestsWhether to complete the client-side requests with KErrCancel.

CancelOutstandingRequests(CScsSession *, CScsSubsession *, TBool)

voidCancelOutstandingRequests(CScsSession *aSession,
CScsSubsession *aSubsession,
TBoolaCompleteClientRequests
)

Cancels and deletes all outstanding asynchronous requests associated with the supplied session and subsession. This should be called when a session or subsession is closed.

As an exception, the user-side request is completed when a subsession is closed, else the request would not be completed until the session itself was destroyed.

CancelAsyncRequest should be called when a specific request is cancelled.

Parameters

CScsSession * aSessionSession which is being closed.
CScsSubsession * aSubsessionSubsession which is being closed. If this is KWildSubsession then a session is being closed so all of its subsession requests should be destroyed as well.
TBool aCompleteClientRequestsWhether to complete the client-side requests with KErrCancel.

ConstructL(TInt)

IMPORT_C voidConstructL(TIntaShutdownPeriodUs)[protected]

Second-phase constructor allocates the shutdown timer for this server object.

If aShutdownPeriodUs is not 0, this function starts the shutdown timer because the server starts up with no current sessions.

If aShutdownPeriodUs is 0, the timer is not started and the server will not auto-exit.

nb. It must be called, even if you do not want a shutdown timer.

This function does not start the server, i.e. it does not call StartL. The calling function must do this after this function returns.

Parameters

TInt aShutdownPeriodUsShutdown period in microseconds.

DecrementSessionCount()

voidDecrementSessionCount()

Record the fact that a session has been deleted. If this was the only remaining session then start the shutdown timer.

Note the shutdown timer may be deferred if a request cleanup is pending.

DisableShutdownTimer()

IMPORT_C voidDisableShutdownTimer()[protected]

The server will no longer shutdown after the last client session closes. Client calls to RScsClientBase::ShutdownServer will fail with KErrNotSupported.

DoNewSessionL(const RMessage2 &)

CScsSession *DoNewSessionL(const RMessage2 &aMessage)[protected, pure virtual]

NewSessionL checks that this server supports the version which is requested by the client. If that is so, then it calls this function to allocate a new session object.

Parameters

const RMessage2 & aMessageConnection message, as passed to NewSessionL.

DoPostHeapMarkOrCheckL()

IMPORT_C voidDoPostHeapMarkOrCheckL()[virtual]

This function is called just after the heap has either been marked or checked (which is just after DoPreHeapMarkOrCheck).

Typically this function should re-create any objects which had to be freed by DoPreHeapMarkOrCheck.

DoPreHeapMarkOrCheckL()

IMPORT_C voidDoPreHeapMarkOrCheckL()[virtual]

This function is called just before the SCS framework marks the heap for OOM testing and just before checking the heap.

Typically this function should compact any arrays and free objects which change size and can not be compacted back to the same level.

EnableShutdownTimerL(TInt)

IMPORT_C voidEnableShutdownTimerL(TIntaShutdownPeriodUs)[protected]

Enable shutdown timer support in the server. If there are currently no client sessions the timer will be immediately started, otherwise it will be started when the last client session closes. If the timer expires, before another client creates a session, the server will shutdown. The RScsClientBase::ShutdownServer api will now be supported, if called the server timeout will effectively be reduced to 0.

Parameters

TInt aShutdownPeriodUs

FindAsyncRequest(CScsSession *, CScsSubsession *, TInt)

CAsyncRequest *FindAsyncRequest(CScsSession *aSession,
CScsSubsession *aSubsession,
TIntaFunction
)[private]

Find the outstanding request which matches the supplied criteria.

Parameters

CScsSession * aSessionSession which hosts the request.
CScsSubsession * aSubsessionSubsession which hosts the request, NULL if the request is relative to a session.
TInt aFunctionThe function identifier, without any SCS code.

IncrementSessionCount()

voidIncrementSessionCount()

Record the fact that another session has been created. If this new session is the only session then cancel the shutdown timer.

NewSessionL(const TVersion &, const RMessage2 &)

IMPORT_C CSession2 *NewSessionL(const TVersion &aVersion,
const RMessage2 &aMessage
)const [protected, virtual]

Implement CServer2 by allocating a new session object. This function delegates the actual allocation to the subclass. Before creating the session object, it compares the requested version with its own version. After creating the session object, it increments the session count, which reset the shutdown timer if it is the only session.

Parameters

const TVersion & aVersionVersion of server which client requires.
const RMessage2 & aMessageConnect message.

RemoveCompletedRequests(TAny *)

TInt RemoveCompletedRequests(TAny *aPtr)[private, static]

This static function is called when iAsyncCleanup runs. It interprets its argument as a pointer to an instance of CScsServer and removes any asynchronous requests which have been completed.

RemoveCompletedRequests()

Parameters

TAny * aPtrRequired callback argument. Interpreted as a pointer to an instance of CScsServer.

RemoveCompletedRequests()

voidRemoveCompletedRequests()[private]

Delete any asynchronous requests which are marked for deletion.

SessionCount()

TInt SessionCount()const [inline]

ShutdownWhenIdleL()

IMPORT_C voidShutdownWhenIdleL()

Shutdown immediately when server is next idle. If the server is not transient (ie. has no shutdown timer), this call is prohibited and will leave with KErrNotSupported.

StripScsFunctionMask(TInt)

TInt StripScsFunctionMask(TIntaFunctionId)[static, inline]

Parameters

TInt aFunctionId

Member Enumerations Documentation

Enum TFunctionRanges

Function ranges to be used when configuring the server security via a CPolicyServer::TPolicy object.

Session/sSubsession function codes will be ORed into the EBaseSession/EBaseSubSession ranges.

Values from EBaseMustAllow, upwards, are used internally and must be allowed.

If there are multiple subsession types (with different function code values), then codes must be be different for each subsession (this restriction only applies if using the CPolicyServer::TPolicy mechanism to configure server security).

WARNNIG: These ranges MUST match the values in scscommon.h TScsFunction.

Enumerators

EBaseSession = 0x01000000
EBaseSubSession = 0x02000000
EBaseMustAllow = 0x03000000

Member Data Documentation

CAsyncCallBack * iAsyncCleanup

CAsyncCallBack *iAsyncCleanup

Runs to remove completed requests from iAsyncRequests.

RPointerArray< CAsyncRequest > iAsyncRequests

RPointerArray< CAsyncRequest >iAsyncRequests

Currently outstanding requests.

CObjectConIx * iContainerIndex

CObjectConIx *iContainerIndex

Generates instances of CObjectCon, for each session to host its subsessions. Public because must be accessible to session objects.

TInt iSessionCount

TInt iSessionCount[private]

Number of open sessions. Used to start and cancel the shutdown timer.

CShutdownTimer * iShutdownTimer

CShutdownTimer *iShutdownTimer[private]

Shutdown timer, started when there are no open sessions, cancelled when the first session is created.

const TVersion iVersion

const TVersioniVersion[private]

This server's version. It is compared against client's requested version when the client attempts to make a connection.