1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Manasij Roy, Nalina Hariharan* |
|
14 * Description: |
|
15 * SMF Server private implementation for Symbian |
|
16 * |
|
17 **/ |
|
18 |
|
19 #ifndef SMFSERVERSYMBIAN_H |
|
20 #define SMFSERVERSYMBIAN_H |
|
21 #include <QObject> |
|
22 #include <e32hashtab.h> |
|
23 #include <e32base.h> |
|
24 #include <QByteArray> |
|
25 #include <QString> |
|
26 //testing -start |
|
27 #include "smfprovider.h" |
|
28 //end |
|
29 //SMF wide global const and macros, to be shared among SMF components as well as SMF aware apps |
|
30 //#include <smf/smfGlobal.h> |
|
31 |
|
32 //#include "clientGlobal.h" |
|
33 |
|
34 #include "SmfServer.h" |
|
35 //Forward declarations |
|
36 class SmfServerSymbianSession; |
|
37 |
|
38 /** |
|
39 * Stores session and request information. |
|
40 * For now storing RMessage2 is reduntant as we are allowing only one outstanding request per session |
|
41 */ |
|
42 struct CSessionStruct |
|
43 { |
|
44 SmfServerSymbianSession* iSession; |
|
45 RMessage2 iMsg; |
|
46 }; |
|
47 |
|
48 |
|
49 |
|
50 //Policy table---start |
|
51 //note capabilities are yet to be finalized |
|
52 //46 services as of 15th apr |
|
53 const TUint myRangeCount = 1/*7*/; |
|
54 |
|
55 //Passing everything for the time being |
|
56 const TInt myRanges[myRangeCount] = |
|
57 { |
|
58 0/*, //ERequestPass |
|
59 1, //ERequestFail |
|
60 2, //ERequestNotSupported |
|
61 3, //ERequestDrmService |
|
62 4, //ERequestUserEnvironmentService |
|
63 5, //ERequestCustomCheckPass |
|
64 6 //ERequestCustomCheckFail*/ |
|
65 }; |
|
66 |
|
67 |
|
68 /* bis: each element of this array actually indexes to a particular element of |
|
69 TPolicyElement. For eg. element 0 of this array maps element 0 of myRanges to |
|
70 a particular element of TpolicyElement array which is in this case element 0 |
|
71 of TPolicyElement |
|
72 */ |
|
73 const TUint8 myElementsIndex[myRangeCount] = |
|
74 { |
|
75 CPolicyServer::EAlwaysPass, //passing everything for now |
|
76 }; |
|
77 |
|
78 |
|
79 /* bis: Policies used by the server to check messages from the client |
|
80 for each message, the server will carry out security check according |
|
81 to this policy. |
|
82 */ |
|
83 const CPolicyServer::TPolicyElement myElements[] = |
|
84 { |
|
85 {_INIT_SECURITY_POLICY_PASS, CPolicyServer::EFailClient} |
|
86 }; |
|
87 |
|
88 /* bis: TPolicy used by the server to check messages from the client |
|
89 for each message. This structure is passed to the server at its creation. |
|
90 The Symbian client-server architecture will make sure that each client request |
|
91 passes through the security test as indicated by myPolicy before it is handled |
|
92 by myPolciyServer */ |
|
93 const CPolicyServer::TPolicy myPolicy = |
|
94 { |
|
95 //bis: |
|
96 //the connection policy (CPolicyServer::EAlwaysPass) should be changed if the |
|
97 //server wants to check for a particular policy before grating any connection |
|
98 //to the client. For eg. DRM manager server should only allow clients having DRM |
|
99 //capability to connect to it. To do so, change CPolicyserver::EAlwaysPass, |
|
100 //to the index no. of myElements which checks for ECapabilityDRM i.e index 2 |
|
101 //in this case. For EACM server, the server should allow only clients having |
|
102 //ECapabilityUserEnvironment to connect to it. |
|
103 CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass |
|
104 myRangeCount, |
|
105 myRanges, |
|
106 myElementsIndex, |
|
107 myElements, |
|
108 }; |
|
109 //Policy table---end |
|
110 /** |
|
111 * Our server class - an active object - and therefore derived ultimately from CActive. |
|
112 * It accepts requests from client threads and forwards |
|
113 * them to the client session to be dealt with. It also handles the creation |
|
114 * of the server-side client session. |
|
115 **/ |
|
116 class SmfServerSymbian : public CPolicyServer |
|
117 { |
|
118 |
|
119 public: |
|
120 /** |
|
121 * Creates a new session with the server; the function |
|
122 * implements the pure virtutal function |
|
123 * defined in class CServer2 |
|
124 */ |
|
125 SmfServerSymbian(CActive::TPriority aActiveObjectPriority,SmfServer* aWrapper); |
|
126 static SmfServerSymbian * NewL(CActive::TPriority aActiveObjectPriority,SmfServer* aWrapper); |
|
127 ~SmfServerSymbian(); |
|
128 CSession2 * NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
|
129 |
|
130 /** |
|
131 * Returns SmfServer |
|
132 */ |
|
133 SmfServer* wrapper(); |
|
134 /** |
|
135 * Adds session info to the currently active session map iMap. This map is used to |
|
136 * retreive the corresponding session to be serviced. The keys for this map is sent |
|
137 * alongwith the request to other components |
|
138 * @param aSession Session to be added |
|
139 * @param aMsg Currently redundant |
|
140 */ |
|
141 TInt addToSessionMap(SmfServerSymbianSession* aSession,const RMessage2& aMsg); |
|
142 /** |
|
143 * Removes the session from the active list of session map |
|
144 * @param aSession Session to be removed. |
|
145 * @param aMsg Currently redundant |
|
146 */ |
|
147 TInt removeFromSessionMap(SmfServerSymbianSession* aSession,RMessage2& aMsg); |
|
148 /** |
|
149 * Returns a symbian session for the given key from the iMap. |
|
150 * @param id Session ID in the SmfServer Session map |
|
151 */ |
|
152 SmfServerSymbianSession* findSession(TInt id); |
|
153 /** |
|
154 * Finds the given session and services it with the data. |
|
155 * @param requestID Session ID |
|
156 * @param parsedData Parsed and serialized data to be sent to client. |
|
157 * @param error Error code |
|
158 */ |
|
159 TInt findAndServiceclient(TInt requestID,QByteArray* parsedData,SmfError error); |
|
160 /** |
|
161 * Debugging |
|
162 */ |
|
163 void writeLog(QString log)const; |
|
164 //private: |
|
165 void ConstructL(); |
|
166 SmfServer* iWrapper; |
|
167 |
|
168 /** |
|
169 * Keeps track of the requests sent by each session |
|
170 */ |
|
171 RHashMap<TInt,CSessionStruct> iMap; |
|
172 |
|
173 /** |
|
174 * The key in the iMap. |
|
175 * Its sent to the wrapper |
|
176 */ |
|
177 TInt iRequestID; |
|
178 |
|
179 TInt iSessionCount; |
|
180 }; |
|
181 |
|
182 /** |
|
183 This class represents a session with the Smf server. |
|
184 Functions are provided to respond appropriately to client messages. |
|
185 */ |
|
186 class SmfServerSymbianSession : public CSession2 |
|
187 { |
|
188 public: |
|
189 /** |
|
190 * Creates a session. |
|
191 * @param aServer The server handle |
|
192 */ |
|
193 SmfServerSymbianSession(SmfServerSymbian* aServer); |
|
194 ~SmfServerSymbianSession(); |
|
195 /** |
|
196 * From CSession2 |
|
197 */ |
|
198 void ServiceL(const RMessage2 & aMessage); |
|
199 /** |
|
200 * Called by the SmfServerSymbian when results are available |
|
201 * @param parsedData Parsed serialized data |
|
202 * @param error Smf Error code |
|
203 */ |
|
204 void resultsAvailable(QByteArray* parsedData,SmfError error); |
|
205 /** |
|
206 * Called by the SmfServer when client authorization finishes. |
|
207 * @param success success of the authorization |
|
208 */ |
|
209 void clientathorizationFinished(bool success); |
|
210 protected: |
|
211 //TMessageParams ReadMessageAndRetrieveParams (const RMessage2 & aMessage); |
|
212 void PanicClient(const RMessage2 & aMessage, TInt aPanic) const; |
|
213 /** |
|
214 * Called by ServiceL() |
|
215 * It tests the function code and then delegates to |
|
216 * the appropriate function. |
|
217 */ |
|
218 void HandleClientMessageL(const RMessage2 & aMessage); |
|
219 |
|
220 //Following are for handling specific client requests |
|
221 /** |
|
222 * ESmfGetService |
|
223 */ |
|
224 void HandleGetService(const RMessage2 & aMessage); |
|
225 |
|
226 /** |
|
227 * Handles all the opcodes except ESmfGetService |
|
228 */ |
|
229 void HandleCommonServiceL(const RMessage2 & aMessage); |
|
230 |
|
231 |
|
232 //private: |
|
233 SmfServerSymbian* iServer; |
|
234 RMessage2 iMessage; |
|
235 |
|
236 //this interface id will be provided by Smf client, will map Smf Client |
|
237 // interface hierarchy |
|
238 SmfInterfaceID iInterfaceID; |
|
239 TPtr8 iIntfNmaeSymbian; |
|
240 TPtr iIntfNameSymbian16; |
|
241 TBuf8<125> iInterfaceNametbuf; |
|
242 TPtr8 iProviderSymbian; |
|
243 HBufC8* iProviderBuf; |
|
244 HBufC8* iIntfNameBuf; |
|
245 QMap<SmfPluginID,SmfProvider> iPluginIDMap; |
|
246 QList<SmfPluginID> iPluginIDList; |
|
247 QList<SmfPluginID> iAuthList; |
|
248 |
|
249 /** |
|
250 * To keep track of the requests sent by this session,not required for now, as only one |
|
251 * outstanding request per session is required |
|
252 */ |
|
253 RArray<RMessage2> iRequestList; |
|
254 /** |
|
255 * Last request opcode |
|
256 */ |
|
257 TInt iLastRequest; |
|
258 //testing |
|
259 TBuf<525> dataToPass; |
|
260 HBufC8* iBuf; |
|
261 HBufC* iBuf16; |
|
262 TPtr8 iPtrToBuf; |
|
263 QByteArray byteArrayToClnt; |
|
264 SmfProvider* providerToClnt; |
|
265 TInt iError; |
|
266 }; |
|
267 #endif // SMFSERVERSYMBIAN_H |
|