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.

Public Member Functions
~CScsServer ()
void AddAsyncRequestL ( CAsyncRequest *)
void CancelAsyncRequest ( CScsSession *, CScsSubsession *, TInt )
void CancelOutstandingRequests ( CScsSession *, TBool )
void CancelOutstandingRequests ( CScsSession *, CScsSubsession *, TBool )
void DecrementSessionCount ()
IMPORT_C void DoPostHeapMarkOrCheckL ()
IMPORT_C void DoPreHeapMarkOrCheckL ()
void IncrementSessionCount ()
TInt SessionCount ()
IMPORT_C void ShutdownWhenIdleL ()
TInt StripScsFunctionMask ( TInt )
Protected Member Functions
CScsServer (const TVersion &, CActive::TPriority )
CScsServer (const TVersion &, const CPolicyServer::TPolicy &, CActive::TPriority )
IMPORT_C void ConstructL ( TInt )
IMPORT_C void DisableShutdownTimer ()
CScsSession * DoNewSessionL (const RMessage2 &)
IMPORT_C void EnableShutdownTimerL ( TInt )
IMPORT_C CSession2 * NewSessionL (const TVersion &, const RMessage2 &)
Private Member Functions
CAsyncRequest * FindAsyncRequest ( CScsSession *, CScsSubsession *, TInt )
TInt RemoveCompletedRequests ( TAny *)
void RemoveCompletedRequests ()
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
enum TFunctionRanges { 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 TVersion iVersion
Inherited Attributes
CActive::iStatus
CServer2::iSessionIter

Constructor & Destructor Documentation

CScsServer(const TVersion &, CActive::TPriority)

IMPORT_C CScsServer ( const TVersion & aVersion,
CActive::TPriority aPriority = CActive::EPriorityStandard
) [protected]

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

Parameters

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

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

IMPORT_C CScsServer ( const TVersion & aVersion,
const CPolicyServer::TPolicy & aPolicy,
CActive::TPriority aPriority = 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 & aVersion This server's version. This is compared against each client's requested version when the client tries to connect.
const CPolicyServer::TPolicy & aPolicy Can be used to configure security for server connect and session functions
CActive::TPriority aPriority = CActive::EPriorityStandard This 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 *)

void AddAsyncRequestL ( CAsyncRequest * aAsyncRequest )

Add the supplied request to the server's collection.

Parameters

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

CancelAsyncRequest(CScsSession *, CScsSubsession *, TInt)

void CancelAsyncRequest ( CScsSession * aSession,
CScsSubsession * aSubsession,
TInt aFunction
)

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 * aSession Session which hosts the request.
CScsSubsession * aSubsession Subsession which hosts the request, NULL if the request is relative to a session.
TInt aFunction The function identifier, without any SCS code.

CancelOutstandingRequests(CScsSession *, TBool)

void CancelOutstandingRequests ( CScsSession * aSession,
TBool aCompleteClientRequests
)

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 * aSession Session which is being closed.
TBool aCompleteClientRequests Whether to complete the client-side requests with KErrCancel.

CancelOutstandingRequests(CScsSession *, CScsSubsession *, TBool)

void CancelOutstandingRequests ( CScsSession * aSession,
CScsSubsession * aSubsession,
TBool aCompleteClientRequests
)

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 * aSession Session which is being closed.
CScsSubsession * aSubsession Subsession 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 aCompleteClientRequests Whether to complete the client-side requests with KErrCancel.

ConstructL(TInt)

IMPORT_C void ConstructL ( TInt aShutdownPeriodUs ) [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 aShutdownPeriodUs Shutdown period in microseconds.

DecrementSessionCount()

void DecrementSessionCount ( )

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 void DisableShutdownTimer ( ) [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 & aMessage Connection message, as passed to NewSessionL.

DoPostHeapMarkOrCheckL()

IMPORT_C void DoPostHeapMarkOrCheckL ( ) [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 void DoPreHeapMarkOrCheckL ( ) [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 void EnableShutdownTimerL ( TInt aShutdownPeriodUs ) [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,
TInt aFunction
) [private]

Find the outstanding request which matches the supplied criteria.

Parameters

CScsSession * aSession Session which hosts the request.
CScsSubsession * aSubsession Subsession which hosts the request, NULL if the request is relative to a session.
TInt aFunction The function identifier, without any SCS code.

IncrementSessionCount()

void IncrementSessionCount ( )

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 & aVersion Version of server which client requires.
const RMessage2 & aMessage Connect 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 * aPtr Required callback argument. Interpreted as a pointer to an instance of CScsServer.

RemoveCompletedRequests()

void RemoveCompletedRequests ( ) [private]

Delete any asynchronous requests which are marked for deletion.

SessionCount()

TInt SessionCount ( ) const [inline]

ShutdownWhenIdleL()

IMPORT_C void ShutdownWhenIdleL ( )

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 ( TInt aFunctionId ) [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 TVersion iVersion [private]

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