sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* Implements CScsTestSession. See class and function definitions
|
sl@0
|
16 |
* for more information.
|
sl@0
|
17 |
*
|
sl@0
|
18 |
*/
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
/**
|
sl@0
|
22 |
@file
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
#include "scstestserver.h"
|
sl@0
|
26 |
|
sl@0
|
27 |
|
sl@0
|
28 |
CScsTestSession* CScsTestSession::NewL(CScsTestServer &aServer)
|
sl@0
|
29 |
/**
|
sl@0
|
30 |
Factory function allocates new instance of CScsTestSession.
|
sl@0
|
31 |
|
sl@0
|
32 |
@param aServer Reference to our parent server
|
sl@0
|
33 |
@return New, initialized instance of CScsTestSession
|
sl@0
|
34 |
which is owned by the caller.
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
{
|
sl@0
|
37 |
CScsTestSession* s = new(ELeave) CScsTestSession(aServer);
|
sl@0
|
38 |
CleanupStack::PushL(s);
|
sl@0
|
39 |
s->ConstructL(); // CScsSession implementation
|
sl@0
|
40 |
CleanupStack::Pop(s);
|
sl@0
|
41 |
return s;
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
CScsTestSession::CScsTestSession(CScsTestServer &aServer)
|
sl@0
|
45 |
/**
|
sl@0
|
46 |
This private constructor prevents direct instantiation.
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
: CScsSession(aServer)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
// empty.
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
CScsTestSession::~CScsTestSession()
|
sl@0
|
54 |
/**
|
sl@0
|
55 |
Because this object does not (yet) own any resources, this
|
sl@0
|
56 |
destructor is only defined to ensure a single definition is
|
sl@0
|
57 |
generated.
|
sl@0
|
58 |
|
sl@0
|
59 |
The base class destructor destroys any remaining subsessions
|
sl@0
|
60 |
or outstanding requests.
|
sl@0
|
61 |
*/
|
sl@0
|
62 |
{
|
sl@0
|
63 |
// empty.
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
TBool CScsTestSession::DoServiceL(TInt aFunction, const RMessage2& aMessage)
|
sl@0
|
67 |
/**
|
sl@0
|
68 |
Implement CScsTestSession by handling the supplied message.
|
sl@0
|
69 |
|
sl@0
|
70 |
@param aFunction Function identifier without SCS code.
|
sl@0
|
71 |
@param aMessage Standard server-side handle to message.
|
sl@0
|
72 |
@return ETrue means complete client request now.
|
sl@0
|
73 |
|
sl@0
|
74 |
@see CScsSession::ServiceError.
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
{
|
sl@0
|
77 |
ScsTestImpl::TSessionFunction f = static_cast<ScsTestImpl::TSessionFunction>(aFunction);
|
sl@0
|
78 |
|
sl@0
|
79 |
switch (f)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
case ScsTestImpl::ESessNukeServer:
|
sl@0
|
82 |
CActiveScheduler::Stop();
|
sl@0
|
83 |
return EFalse; // Server will crash due to outstanding reqs
|
sl@0
|
84 |
|
sl@0
|
85 |
case ScsTestImpl::ESessDouble:
|
sl@0
|
86 |
{
|
sl@0
|
87 |
TPckgBuf<TInt> value;
|
sl@0
|
88 |
aMessage.Read(0, value);
|
sl@0
|
89 |
value() *= 2;
|
sl@0
|
90 |
aMessage.WriteL(0, value);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
break;
|
sl@0
|
93 |
|
sl@0
|
94 |
case ScsTestImpl::ESessTreble:
|
sl@0
|
95 |
{
|
sl@0
|
96 |
CTrebleRequest::NewL(this, /* aSubsession */ NULL, aMessage);
|
sl@0
|
97 |
return EFalse; // Do NOT complete client request yet
|
sl@0
|
98 |
}
|
sl@0
|
99 |
|
sl@0
|
100 |
default:
|
sl@0
|
101 |
User::Leave(KErrNotSupported);
|
sl@0
|
102 |
}
|
sl@0
|
103 |
return ETrue; // Complete client request now
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|
sl@0
|
106 |
CScsSubsession* CScsTestSession::DoCreateSubsessionL(TInt aFunction, const RMessage2& aMessage)
|
sl@0
|
107 |
/**
|
sl@0
|
108 |
Override CScsSession by allocating an instance of CScsTestSubsession
|
sl@0
|
109 |
to handle ScsTestImpl::ESessSubsessFromInt.
|
sl@0
|
110 |
|
sl@0
|
111 |
@param aFunction Function identifier without SCS code.
|
sl@0
|
112 |
@param aMessage Standard server-side handle to message.
|
sl@0
|
113 |
@see ScsTestImpl::ESessSubsessFromInt
|
sl@0
|
114 |
*/
|
sl@0
|
115 |
{
|
sl@0
|
116 |
switch (aFunction)
|
sl@0
|
117 |
{
|
sl@0
|
118 |
case ScsTestImpl::ESessSubsessFromInt:
|
sl@0
|
119 |
return CScsTestSubsession::NewL(*this, aMessage);
|
sl@0
|
120 |
|
sl@0
|
121 |
default:
|
sl@0
|
122 |
User::Leave(KErrNotSupported);
|
sl@0
|
123 |
return 0; // avoid compiler warning
|
sl@0
|
124 |
}
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|