|
1 /* |
|
2 * Copyright (c) 2005 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 "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: Mediator Server executable header file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef MEDIATORSERVER_H |
|
21 #define MEDIATORSERVER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 #include <barsread.h> |
|
27 #include <MediatorServiceDefs.h> |
|
28 |
|
29 // NAMESPACE |
|
30 |
|
31 // CONSTANTS |
|
32 // ---------------------------------------------------------------------------------------- |
|
33 // Server's policy |
|
34 // ---------------------------------------------------------------------------------------- |
|
35 |
|
36 //Total number of ranges |
|
37 const TUint KMediatorServerRangeCount = 2; |
|
38 |
|
39 //Definition of the ranges of IPC numbers |
|
40 const TInt KMediatorServerRanges[KMediatorServerRangeCount] = |
|
41 { |
|
42 0, // 1st range messages 0 - 4 |
|
43 5 // 2nd range messages 5 - |
|
44 }; |
|
45 |
|
46 //Policy to implement for each of the above ranges |
|
47 const TUint8 KMediatorServerElementsIndex[KMediatorServerRangeCount] = |
|
48 { |
|
49 CPolicyServer::ECustomCheck, // Applies to 1st range |
|
50 CPolicyServer::EAlwaysPass, //applies to 2nd range |
|
51 }; |
|
52 |
|
53 //Specific capability checks |
|
54 const CPolicyServer::TPolicyElement KMediatorServerElements[] = |
|
55 { |
|
56 //policy for range "0"; custom check is done |
|
57 {_INIT_SECURITY_POLICY_C1(ECapability_None), CPolicyServer::EFailClient} |
|
58 }; |
|
59 |
|
60 //Package all the above together into a policy |
|
61 const CPolicyServer::TPolicy KMediatorServerPolicy = |
|
62 { |
|
63 CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass |
|
64 KMediatorServerRangeCount, |
|
65 KMediatorServerRanges, |
|
66 KMediatorServerElementsIndex, |
|
67 KMediatorServerElements |
|
68 }; |
|
69 |
|
70 |
|
71 |
|
72 // DATA TYPES |
|
73 |
|
74 /* |
|
75 * Panic definitions |
|
76 */ |
|
77 enum TUPnPMediaServerPanic |
|
78 { |
|
79 EMSBadRequest, |
|
80 EMSBadDescriptor, |
|
81 EMSBadMediatorServerMessage, |
|
82 }; |
|
83 |
|
84 |
|
85 // FORWARD DECLARATIONS |
|
86 class CMediatorServerEventHandler; |
|
87 class CMediatorServerCommandHandler; |
|
88 class CMediatorServerObjectHandler; |
|
89 class CMediatorServerPluginHandler; |
|
90 |
|
91 // CLASS DECLARATION |
|
92 |
|
93 /** |
|
94 * Mediator Server Core class |
|
95 * |
|
96 * @lib MediatorServer |
|
97 * @since S60 3.1 |
|
98 */ |
|
99 class CMediatorServer : public CPolicyServer |
|
100 { |
|
101 |
|
102 public: // Constructors and destructor |
|
103 |
|
104 /** |
|
105 * Two-phased constructor. |
|
106 */ |
|
107 static CMediatorServer* NewLC(); |
|
108 |
|
109 /** |
|
110 * Destructor. |
|
111 */ |
|
112 ~CMediatorServer(); |
|
113 |
|
114 public: // New functions |
|
115 |
|
116 /** |
|
117 * Returns reference to event handler |
|
118 * |
|
119 * @since S60 3.1 |
|
120 * @param None. |
|
121 * @return CMediatorServerEventHandler reference to event handler |
|
122 */ |
|
123 CMediatorServerEventHandler& EventHandler(); |
|
124 |
|
125 /** |
|
126 * Returns reference to command handler |
|
127 * |
|
128 * @since S60 3.1 |
|
129 * @param None. |
|
130 * @return CMediatorServerCommandHandler reference to command handler |
|
131 */ |
|
132 CMediatorServerCommandHandler& CommandHandler(); |
|
133 |
|
134 /** |
|
135 * Returns reference to object handler |
|
136 * |
|
137 * @since S60 3.1 |
|
138 * @param None. |
|
139 * @return CMediatorServerObjectHandler reference to object handler |
|
140 */ |
|
141 CMediatorServerObjectHandler& ObjectHandler(); |
|
142 |
|
143 /** |
|
144 * Returns reference to plugin handler |
|
145 * |
|
146 * @since S60 3.1 |
|
147 * @param None. |
|
148 * @return CMediatorServerPluginHandler reference to plugin handler |
|
149 */ |
|
150 CMediatorServerPluginHandler& PluginHandler(); |
|
151 |
|
152 /** |
|
153 * Method to panic server in case of serious error |
|
154 * |
|
155 * @since S60 3.1 |
|
156 * @param aPanic panic reason. |
|
157 * @return None |
|
158 */ |
|
159 static void PanicServer( TInt aPanic ); |
|
160 |
|
161 /** |
|
162 * Method to panic client if e.g. message is malformed |
|
163 * |
|
164 * @since S60 3.1 |
|
165 * @param aMessage message from client |
|
166 * @param aPanic panic reason. |
|
167 * @return None |
|
168 */ |
|
169 static void PanicClient( const RMessage2& aMessage, TInt aPanic ); |
|
170 |
|
171 |
|
172 protected: // from CPolicyServer |
|
173 /** |
|
174 * Performs a custom security check. |
|
175 * |
|
176 * @since S60 3.1 |
|
177 * @param aMsg The message to check. |
|
178 * @param aAction A reference to the action to take if the security check fails. |
|
179 * @param aMissing A reference to the list of security attributes missing from the checked process. |
|
180 * @return A value from TCustomResult. |
|
181 */ |
|
182 CPolicyServer::TCustomResult CustomSecurityCheckL( const RMessage2& aMsg, |
|
183 TInt& aAction, |
|
184 TSecurityInfo& aMissing ); |
|
185 |
|
186 private: // New functions |
|
187 |
|
188 /** |
|
189 * Reads resource files and registers events |
|
190 * |
|
191 * @since S60 3.1 |
|
192 * @param aFsSession reference to file server session handle |
|
193 * @return None |
|
194 */ |
|
195 void ProcessResourceEventsL( RFs& aFsSession ); |
|
196 |
|
197 /** |
|
198 * Reads a single resource file and process it |
|
199 * |
|
200 * @since S60 3.1 |
|
201 * @param aFsSession reference to file server session handle |
|
202 * @param aFileName file name of the resource file |
|
203 * @return None |
|
204 */ |
|
205 void ProcessResourceFileL( RFs& aFsSession, const TDesC& aFileName ); |
|
206 |
|
207 /** |
|
208 * Reads event using resource reader and returns it |
|
209 * |
|
210 * @since S60 3.1 |
|
211 * @param aReader reference to resource reader used |
|
212 * @return TEvent structure |
|
213 */ |
|
214 MediatorService::TEvent ReadEvent( TResourceReader& aReader ); |
|
215 |
|
216 /** |
|
217 * Read resource file containing exeptionally handled SIDs |
|
218 * |
|
219 * @since S60 3.1 |
|
220 * @param aFsSession reference to file server session handle |
|
221 * @return None |
|
222 */ |
|
223 void ReadAllowedSidsFileL( RFs& aFsSession ); |
|
224 |
|
225 /** |
|
226 * Returns whether capability requirements can be ignored for the specified client. |
|
227 * |
|
228 * @since S60 3.1 |
|
229 * @param aSid Secure id of the client |
|
230 * @return TBool ETrue if capability requirement can be ignored, otherwise EFalse. |
|
231 */ |
|
232 TBool AllowCapabilityException( const TUid& aSid ); |
|
233 |
|
234 private: |
|
235 |
|
236 /** |
|
237 * C++ default constructor. |
|
238 */ |
|
239 CMediatorServer(); |
|
240 |
|
241 /** |
|
242 * By default Symbian 2nd phase constructor is private. |
|
243 */ |
|
244 void ConstructL(); |
|
245 |
|
246 private: // Functions from base classes |
|
247 /** |
|
248 * By default Symbian 2nd phase constructor is private. |
|
249 */ |
|
250 CSession2* NewSessionL( const TVersion& aVersion, |
|
251 const RMessage2& aMessage ) const; |
|
252 |
|
253 |
|
254 private: // Data |
|
255 |
|
256 // Pointer to event handler instance |
|
257 CMediatorServerEventHandler* iEventHandler; |
|
258 |
|
259 // Pointer to command handler instance |
|
260 CMediatorServerCommandHandler* iCommandHandler; |
|
261 |
|
262 // Pointer to object handler instance |
|
263 CMediatorServerObjectHandler* iObjectHandler; |
|
264 |
|
265 // Pointer to plugin handler instance |
|
266 CMediatorServerPluginHandler* iPluginHandler; |
|
267 |
|
268 // Array of SIDs that don't require SwEvent capability |
|
269 RArray<TUid> iAllowedSids; |
|
270 |
|
271 |
|
272 }; |
|
273 |
|
274 |
|
275 #endif // MEDIATORSERVER_H |
|
276 |
|
277 // End of File |