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