|
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 * Information shared between SCS client and server implementations, |
|
16 * and with the subclass implementations, but not with the client API user. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalTechnology |
|
24 @released |
|
25 */ |
|
26 |
|
27 #ifndef SCSCOMMON_H |
|
28 #define SCSCOMMON_H |
|
29 |
|
30 #include <e32std.h> |
|
31 |
|
32 #ifndef BULLSEYE_OFF |
|
33 #ifdef _BullseyeCoverage |
|
34 #define BULLSEYE_OFF "BullseyeCoverage save off"; |
|
35 #define BULLSEYE_RESTORE "BullseyeCoverage restore"; |
|
36 #else |
|
37 #define BULLSEYE_OFF |
|
38 #define BULLSEYE_RESTORE |
|
39 #endif |
|
40 #endif |
|
41 |
|
42 namespace ScsImpl |
|
43 { |
|
44 /** |
|
45 Bit position of SCS code in function code. |
|
46 |
|
47 Do not change - Some of the codes based off this definition |
|
48 ARE public. |
|
49 */ |
|
50 const TInt KScsFunctionPos = 24; |
|
51 |
|
52 /** |
|
53 Mask used to extract SCS commands. |
|
54 |
|
55 Do not change - Some of the codes based off this definition |
|
56 ARE public. |
|
57 */ |
|
58 const TInt KScsFunctionMask = 0xFF000000; |
|
59 |
|
60 enum TScsFunction |
|
61 /** |
|
62 Bits 31:24 of the function code are reserved for SCS fields. |
|
63 The values below should be or'd into the code that is sent to |
|
64 the server, on the client side. |
|
65 |
|
66 The recognized values intentionally exclude zero, to ensure |
|
67 that a field is added on the client side. |
|
68 */ |
|
69 { |
|
70 /** |
|
71 Function should be handled by session's DoServiceL. |
|
72 |
|
73 This value is effectively PUBLIC because the range used is |
|
74 described by defines in scsserver.h (used for configuring |
|
75 server security). |
|
76 */ |
|
77 ECallSessionFunc = 1 << KScsFunctionPos, |
|
78 |
|
79 /** |
|
80 The SCS sends the lower bits of the function code to the subsession's |
|
81 (not the session's) ServiceL implementation. |
|
82 |
|
83 The session's implementation of [Do]ServiceL is not involved. |
|
84 |
|
85 This value is effectively PUBLIC because the range used is |
|
86 described by defines in scsserver.h (used for configuring |
|
87 server security). |
|
88 */ |
|
89 ECallSubsessionFunc = 2 << KScsFunctionPos, |
|
90 |
|
91 /** |
|
92 This message is send with no function identifier or |
|
93 IPC arguments just before the session is closed. Although |
|
94 not necessary, it will cancel any outstanding requests on |
|
95 the session or its subsessions with KErrCancel, so if the |
|
96 client has any outstanding requests they will still get |
|
97 completed. |
|
98 */ |
|
99 EPreCloseSession = 3 << KScsFunctionPos, |
|
100 |
|
101 /** |
|
102 Cancel an asynchronous session-relative function. The low |
|
103 bits of the function code should be the same as the original |
|
104 function code. E.g. if the function was set up with |
|
105 ENoScsFunction | X then it would be cancelled with ECancelSessionFunction | X. |
|
106 |
|
107 The session's implementation of [Do]ServiceL is not involved. |
|
108 */ |
|
109 ECancelSessionFunc = 4 << KScsFunctionPos, |
|
110 |
|
111 /** |
|
112 Tells the server that this function will create a new subsession. |
|
113 The low bits can be interpreted by the implementation to indicate |
|
114 a type of subsession. |
|
115 */ |
|
116 ECreateSubsession = 5 << KScsFunctionPos, |
|
117 /** |
|
118 This SCS code should be used on its own. Any information in the |
|
119 lower bits will be ignored. |
|
120 */ |
|
121 ECloseSubsession = 6 << KScsFunctionPos, |
|
122 |
|
123 /** |
|
124 Similar to ECancelSessionFunction, this cancels an asynchronous |
|
125 request on a subsession object. The request will be completed with |
|
126 KErrCancel. |
|
127 |
|
128 The subsession's implementation of ServiceL is not involved. |
|
129 |
|
130 @see ECancelSessionFunction |
|
131 */ |
|
132 ECancelSubsessionFunc = 7 << KScsFunctionPos, |
|
133 |
|
134 /** |
|
135 Only supported in debug builds, this function starts a server-side |
|
136 heap mark with __UHEAP_MARK and sets a deterministic failure rate. |
|
137 This function should only be used by RScsClientBase::SetServerHeapFail. |
|
138 |
|
139 @see EUHeapResetFail |
|
140 @see RScsClientBase::SetServerHeapFail |
|
141 */ |
|
142 EUHeapSetFail = 8 << KScsFunctionPos, |
|
143 |
|
144 /** |
|
145 Only supported in debug builds, this function ends the server-side |
|
146 heap mark set up with EUHeapSetFail, with __UHEAP_MARKEND, and resets |
|
147 the heap failure rate. This function should only be used by |
|
148 RScsClientBase::ResetServerHeapFail. |
|
149 |
|
150 @see EUHeapSetFail |
|
151 @see RScsClientBase::ResetServerHeapFail |
|
152 */ |
|
153 EUHeapResetFail = 9 << KScsFunctionPos, |
|
154 |
|
155 /** |
|
156 Intended for debug use, but also present in production builds. |
|
157 |
|
158 Returns the PID of the server. This is a number, not a |
|
159 handle, so does not impact security. |
|
160 |
|
161 */ |
|
162 EGetServerPid = 10 << KScsFunctionPos, |
|
163 |
|
164 /** |
|
165 Intended for debug use, but also present in production builds. |
|
166 |
|
167 This call causes a server which has an inactivity shutdown |
|
168 timer to shutdown immediately the next time it is |
|
169 idle. This is just adjusts the timing of existing |
|
170 functionality, so is not believed to impact security. |
|
171 |
|
172 If the server has a shutdown timer, then a flag is set |
|
173 which causes the server to immediately exit the next time |
|
174 it becomes idle. |
|
175 |
|
176 If the server does not have a shutdown timer, then the |
|
177 calls fails with KErrNotSupported. |
|
178 */ |
|
179 EShutdownAsap = 11 << KScsFunctionPos, |
|
180 |
|
181 /** |
|
182 This value is not used by the server implementation. It is provided |
|
183 for test code to confirm the server handles an uncrecognized instruction |
|
184 correctly, by failing with KErrNotSupported. |
|
185 */ |
|
186 EScsUnused = 0x20 << KScsFunctionPos |
|
187 }; |
|
188 |
|
189 inline void ExtractScsAndImplFunctions(const RMessage2& aMessage, TScsFunction* aScsFunc, TInt* aImplFunc); |
|
190 inline TBool ScsFieldUsed(TInt aFunction); |
|
191 |
|
192 /** |
|
193 SCS clients are panicked with this category when invalid |
|
194 input to the server is detected. |
|
195 |
|
196 @see TClientPanic |
|
197 */ |
|
198 _LIT(KScsClientPanicCat, "SCS-Client"); |
|
199 |
|
200 enum TScsClientPanic |
|
201 /** |
|
202 Reasons why the SCS server might panic its clients. |
|
203 |
|
204 @see KScsClientPanicCat |
|
205 */ |
|
206 { |
|
207 EScsClBadDesc = 0, ///< Client provided a bad descriptor as an IPC argument. |
|
208 EScsClBadHandle = 1, ///< Client passed a bad subsession handle. |
|
209 EScsClAsyncAlreadyQueued = 2, ///< Client attempted to requeue an outstanding request. |
|
210 |
|
211 /** No-arg session-relative function identifier used reserved SCS bits. */ |
|
212 EScsClNoArgsSessUsedScs = 4, |
|
213 |
|
214 /** Arg session-relative function identifier used reserved SCS bits. */ |
|
215 EScsClArgsSessUsedScs = 5, |
|
216 |
|
217 /** Arg session-relative async function identifier used reserved SCS bits. */ |
|
218 EScsClArgsSessAsyncUsedScs = 6, |
|
219 |
|
220 /** Session-relative cancel function identifier used reserved SCS bits. */ |
|
221 EScsClCancelSessUsedScs = 7, |
|
222 |
|
223 /** No-arg subsession-relative function identifier used reserved SCS bits. */ |
|
224 EScsClNoArgsSubsessUsedScs = 16, |
|
225 |
|
226 /** Arg subsession-relative function identifier used reserved SCS bits. */ |
|
227 EScsClArgsSubsessUsedScs = 17, |
|
228 |
|
229 /** Arg subsession-relative async function identifier used reserved SCS bits. */ |
|
230 EScsClArgsSubsessAsyncUsedScs = 18, |
|
231 |
|
232 /* Subsesion-relative cancel function identifier used reserved SCS bits. */ |
|
233 EScsClCancelSubsessUsedScs = 19 |
|
234 }; |
|
235 |
|
236 // defined only in client-side implementation |
|
237 void ClientSidePanic(ScsImpl::TScsClientPanic aReason); |
|
238 } // namespace ScsImpl |
|
239 |
|
240 #include <scs/scscommon.inl> |
|
241 |
|
242 #endif // #ifndef SCSCOMMON_H |
|
243 |